wunderbaum 0.4.0 → 0.5.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.
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Wunderbaum - util
3
3
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
4
- * v0.4.0, Wed, 06 Sep 2023 08:21:56 GMT (https://github.com/mar10/wunderbaum)
4
+ * v0.5.0, Fri, 15 Sep 2023 14:34:23 GMT (https://github.com/mar10/wunderbaum)
5
5
  */
6
6
  /** @module util */
7
7
  /** Readable names for `MouseEvent.button` */
@@ -756,7 +756,7 @@ var util = /*#__PURE__*/Object.freeze({
756
756
  /*!
757
757
  * Wunderbaum - types
758
758
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
759
- * v0.4.0, Wed, 06 Sep 2023 08:21:56 GMT (https://github.com/mar10/wunderbaum)
759
+ * v0.5.0, Fri, 15 Sep 2023 14:34:23 GMT (https://github.com/mar10/wunderbaum)
760
760
  */
761
761
  /**
762
762
  * Possible values for {@link WunderbaumNode.update()} and {@link Wunderbaum.update()}.
@@ -795,7 +795,7 @@ var NodeStatusType;
795
795
  NodeStatusType["loading"] = "loading";
796
796
  NodeStatusType["error"] = "error";
797
797
  NodeStatusType["noData"] = "noData";
798
- // paging = "paging",
798
+ NodeStatusType["paging"] = "paging";
799
799
  })(NodeStatusType || (NodeStatusType = {}));
800
800
  /** Define the subregion of a node, where an event occurred. */
801
801
  var NodeRegion;
@@ -820,7 +820,7 @@ var NavModeEnum;
820
820
  /*!
821
821
  * Wunderbaum - wb_extension_base
822
822
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
823
- * v0.4.0, Wed, 06 Sep 2023 08:21:56 GMT (https://github.com/mar10/wunderbaum)
823
+ * v0.5.0, Fri, 15 Sep 2023 14:34:23 GMT (https://github.com/mar10/wunderbaum)
824
824
  */
825
825
  class WunderbaumExtension {
826
826
  constructor(tree, id, defaults) {
@@ -1175,7 +1175,7 @@ function throttle(func, wait = 0, options = {}) {
1175
1175
  /*!
1176
1176
  * Wunderbaum - ext-filter
1177
1177
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1178
- * v0.4.0, Wed, 06 Sep 2023 08:21:56 GMT (https://github.com/mar10/wunderbaum)
1178
+ * v0.5.0, Fri, 15 Sep 2023 14:34:23 GMT (https://github.com/mar10/wunderbaum)
1179
1179
  */
1180
1180
  const START_MARKER = "\uFFF7";
1181
1181
  const END_MARKER = "\uFFF8";
@@ -1475,7 +1475,7 @@ function _markFuzzyMatchedChars(text, matches, escapeTitles = true) {
1475
1475
  /*!
1476
1476
  * Wunderbaum - ext-keynav
1477
1477
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1478
- * v0.4.0, Wed, 06 Sep 2023 08:21:56 GMT (https://github.com/mar10/wunderbaum)
1478
+ * v0.5.0, Fri, 15 Sep 2023 14:34:23 GMT (https://github.com/mar10/wunderbaum)
1479
1479
  */
1480
1480
  const QUICKSEARCH_DELAY = 500;
1481
1481
  class KeynavExtension extends WunderbaumExtension {
@@ -1815,7 +1815,7 @@ class KeynavExtension extends WunderbaumExtension {
1815
1815
  /*!
1816
1816
  * Wunderbaum - ext-logger
1817
1817
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1818
- * v0.4.0, Wed, 06 Sep 2023 08:21:56 GMT (https://github.com/mar10/wunderbaum)
1818
+ * v0.5.0, Fri, 15 Sep 2023 14:34:23 GMT (https://github.com/mar10/wunderbaum)
1819
1819
  */
1820
1820
  class LoggerExtension extends WunderbaumExtension {
1821
1821
  constructor(tree) {
@@ -1855,7 +1855,7 @@ class LoggerExtension extends WunderbaumExtension {
1855
1855
  /*!
1856
1856
  * Wunderbaum - common
1857
1857
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
1858
- * v0.4.0, Wed, 06 Sep 2023 08:21:56 GMT (https://github.com/mar10/wunderbaum)
1858
+ * v0.5.0, Fri, 15 Sep 2023 14:34:23 GMT (https://github.com/mar10/wunderbaum)
1859
1859
  */
1860
1860
  const DEFAULT_DEBUGLEVEL = 3; // Replaced by rollup script
1861
1861
  /**
@@ -1883,30 +1883,50 @@ const TEST_IMG = new RegExp(/\.|\//);
1883
1883
  * Default node icons.
1884
1884
  * Requires bootstrap icons https://icons.getbootstrap.com
1885
1885
  */
1886
- const iconMap = {
1887
- error: "bi bi-exclamation-triangle",
1888
- // loading: "bi bi-hourglass-split wb-busy",
1889
- loading: "bi bi-chevron-right wb-busy",
1890
- // loading: "bi bi-arrow-repeat wb-spin",
1891
- // loading: '<div class="spinner-border spinner-border-sm" role="status"> <span class="visually-hidden">Loading...</span> </div>',
1892
- // noData: "bi bi-search",
1893
- noData: "bi bi-question-circle",
1894
- expanderExpanded: "bi bi-chevron-down",
1895
- // expanderExpanded: "bi bi-dash-square",
1896
- expanderCollapsed: "bi bi-chevron-right",
1897
- // expanderCollapsed: "bi bi-plus-square",
1898
- expanderLazy: "bi bi-chevron-right wb-helper-lazy-expander",
1899
- // expanderLazy: "bi bi-chevron-bar-right",
1900
- checkChecked: "bi bi-check-square",
1901
- checkUnchecked: "bi bi-square",
1902
- checkUnknown: "bi bi-dash-square-dotted",
1903
- radioChecked: "bi bi-circle-fill",
1904
- radioUnchecked: "bi bi-circle",
1905
- radioUnknown: "bi bi-record-circle",
1906
- folder: "bi bi-folder2",
1907
- folderOpen: "bi bi-folder2-open",
1908
- folderLazy: "bi bi-folder-symlink",
1909
- doc: "bi bi-file-earmark",
1886
+ const iconMaps = {
1887
+ bootstrap: {
1888
+ error: "bi bi-exclamation-triangle",
1889
+ // loading: "bi bi-hourglass-split wb-busy",
1890
+ loading: "bi bi-chevron-right wb-busy",
1891
+ // loading: "bi bi-arrow-repeat wb-spin",
1892
+ // loading: '<div class="spinner-border spinner-border-sm" role="status"> <span class="visually-hidden">Loading...</span> </div>',
1893
+ // noData: "bi bi-search",
1894
+ noData: "bi bi-question-circle",
1895
+ expanderExpanded: "bi bi-chevron-down",
1896
+ // expanderExpanded: "bi bi-dash-square",
1897
+ expanderCollapsed: "bi bi-chevron-right",
1898
+ // expanderCollapsed: "bi bi-plus-square",
1899
+ expanderLazy: "bi bi-chevron-right wb-helper-lazy-expander",
1900
+ // expanderLazy: "bi bi-chevron-bar-right",
1901
+ checkChecked: "bi bi-check-square",
1902
+ checkUnchecked: "bi bi-square",
1903
+ checkUnknown: "bi bi-dash-square-dotted",
1904
+ radioChecked: "bi bi-circle-fill",
1905
+ radioUnchecked: "bi bi-circle",
1906
+ radioUnknown: "bi bi-record-circle",
1907
+ folder: "bi bi-folder2",
1908
+ folderOpen: "bi bi-folder2-open",
1909
+ folderLazy: "bi bi-folder-symlink",
1910
+ doc: "bi bi-file-earmark",
1911
+ },
1912
+ fontawesome6: {
1913
+ error: "fa-solid fa-triangle-exclamation",
1914
+ loading: "fa-regular fa-chevron-right fa-beat",
1915
+ noData: "fa-solid fa-circle-question",
1916
+ expanderExpanded: "fa-regular fa-chevron-down",
1917
+ expanderCollapsed: "fa-regular fa-chevron-right",
1918
+ expanderLazy: "fa-regular fa-chevron-right wb-helper-lazy-expander",
1919
+ checkChecked: "fa-regular fa-square-check",
1920
+ checkUnchecked: "fa-regular fa-square",
1921
+ checkUnknown: "fa-regular fa-square-minus",
1922
+ radioChecked: "fa-solid fa-circle",
1923
+ radioUnchecked: "fa-regular fa-circle",
1924
+ radioUnknown: "fa-regular fa-circle-question",
1925
+ folder: "fa-solid fa-folder-closed",
1926
+ folderOpen: "fa-regular fa-folder-open",
1927
+ folderLazy: "fa-solid fa-folder-plus",
1928
+ doc: "fa-regular fa-file",
1929
+ },
1910
1930
  };
1911
1931
  /** Dict keys that are evaluated by source loader (others are added to `tree.data` instead). */
1912
1932
  const RESERVED_TREE_SOURCE_KEYS = new Set([
@@ -2101,7 +2121,7 @@ function inflateSourceData(source) {
2101
2121
  /*!
2102
2122
  * Wunderbaum - ext-dnd
2103
2123
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2104
- * v0.4.0, Wed, 06 Sep 2023 08:21:56 GMT (https://github.com/mar10/wunderbaum)
2124
+ * v0.5.0, Fri, 15 Sep 2023 14:34:23 GMT (https://github.com/mar10/wunderbaum)
2105
2125
  */
2106
2126
  const nodeMimeType = "application/x-wunderbaum-node";
2107
2127
  class DndExtension extends WunderbaumExtension {
@@ -2298,7 +2318,7 @@ class DndExtension extends WunderbaumExtension {
2298
2318
  n._org_key = n.key;
2299
2319
  delete n.key;
2300
2320
  });
2301
- nodeData.treeId = srcNode.tree.id;
2321
+ nodeData._treeId = srcNode.tree.id;
2302
2322
  const json = JSON.stringify(nodeData);
2303
2323
  e.dataTransfer.setData(nodeMimeType, json);
2304
2324
  // e.dataTransfer!.setData("text/html", $(node.span).html());
@@ -2431,7 +2451,7 @@ class DndExtension extends WunderbaumExtension {
2431
2451
  /*!
2432
2452
  * Wunderbaum - drag_observer
2433
2453
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2434
- * v0.4.0, Wed, 06 Sep 2023 08:21:56 GMT (https://github.com/mar10/wunderbaum)
2454
+ * v0.5.0, Fri, 15 Sep 2023 14:34:23 GMT (https://github.com/mar10/wunderbaum)
2435
2455
  */
2436
2456
  /**
2437
2457
  * Convert mouse- and touch events to 'dragstart', 'drag', and 'dragstop'.
@@ -2567,7 +2587,7 @@ class DragObserver {
2567
2587
  /*!
2568
2588
  * Wunderbaum - ext-grid
2569
2589
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2570
- * v0.4.0, Wed, 06 Sep 2023 08:21:56 GMT (https://github.com/mar10/wunderbaum)
2590
+ * v0.5.0, Fri, 15 Sep 2023 14:34:23 GMT (https://github.com/mar10/wunderbaum)
2571
2591
  */
2572
2592
  class GridExtension extends WunderbaumExtension {
2573
2593
  constructor(tree) {
@@ -2604,7 +2624,7 @@ class GridExtension extends WunderbaumExtension {
2604
2624
  /*!
2605
2625
  * Wunderbaum - deferred
2606
2626
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2607
- * v0.4.0, Wed, 06 Sep 2023 08:21:56 GMT (https://github.com/mar10/wunderbaum)
2627
+ * v0.5.0, Fri, 15 Sep 2023 14:34:23 GMT (https://github.com/mar10/wunderbaum)
2608
2628
  */
2609
2629
  /**
2610
2630
  * Implement a ES6 Promise, that exposes a resolve() and reject() method.
@@ -2657,7 +2677,7 @@ class Deferred {
2657
2677
  /*!
2658
2678
  * Wunderbaum - wunderbaum_node
2659
2679
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
2660
- * v0.4.0, Wed, 06 Sep 2023 08:21:56 GMT (https://github.com/mar10/wunderbaum)
2680
+ * v0.5.0, Fri, 15 Sep 2023 14:34:23 GMT (https://github.com/mar10/wunderbaum)
2661
2681
  */
2662
2682
  /** WunderbaumNode properties that can be passed with source data.
2663
2683
  * (Any other source properties will be stored as `node.data.PROP`.)
@@ -2679,16 +2699,12 @@ const NODE_PROPS = new Set([
2679
2699
  "tooltip",
2680
2700
  "type",
2681
2701
  "unselectable",
2682
- // "unselectableIgnore",
2683
- // "unselectableStatus",
2684
2702
  ]);
2685
2703
  /** WunderbaumNode properties that will be returned by `node.toDict()`.)
2686
2704
  */
2687
2705
  const NODE_DICT_PROPS = new Set(NODE_PROPS);
2688
2706
  NODE_DICT_PROPS.delete("_partsel");
2689
2707
  NODE_DICT_PROPS.delete("unselectable");
2690
- // NODE_DICT_PROPS.delete("unselectableIgnore");
2691
- // NODE_DICT_PROPS.delete("unselectableStatus");
2692
2708
  /**
2693
2709
  * A single tree node.
2694
2710
  *
@@ -2705,13 +2721,6 @@ class WunderbaumNode {
2705
2721
  */
2706
2722
  this.refKey = undefined;
2707
2723
  this.children = null;
2708
- this.lazy = false;
2709
- /** Expansion state.
2710
- * @see {@link isExpandable}, {@link isExpanded}, {@link setExpanded}. */
2711
- this.expanded = false;
2712
- /** Selection state.
2713
- * @see {@link isSelected}, {@link setSelected}, {@link toggleSelected}. */
2714
- this.selected = false;
2715
2724
  /** Additional classes added to `div.wb-row`.
2716
2725
  * @see {@link hasClass}, {@link setClass}. */
2717
2726
  this.classes = null; //new Set<string>();
@@ -2737,7 +2746,7 @@ class WunderbaumNode {
2737
2746
  data.icon != null ? (this.icon = data.icon) : 0;
2738
2747
  this.lazy = data.lazy === true;
2739
2748
  data.statusNodeType != null
2740
- ? (this.statusNodeType = "" + data.statusNodeType)
2749
+ ? (this.statusNodeType = ("" + data.statusNodeType))
2741
2750
  : 0;
2742
2751
  data.colspan != null ? (this.colspan = !!data.colspan) : 0;
2743
2752
  // Selection
@@ -2745,10 +2754,6 @@ class WunderbaumNode {
2745
2754
  data.radiogroup != null ? (this.radiogroup = !!data.radiogroup) : 0;
2746
2755
  this.selected = data.selected === true;
2747
2756
  data.unselectable === true ? (this.unselectable = true) : 0;
2748
- // data.unselectableStatus != null
2749
- // ? (this.unselectableStatus = !!data.unselectableStatus)
2750
- // : 0;
2751
- // data.unselectableIgnore === true ? (this.unselectableIgnore = true) : 0;
2752
2757
  if (data.classes) {
2753
2758
  this.setClass(data.classes);
2754
2759
  }
@@ -2880,7 +2885,7 @@ class WunderbaumNode {
2880
2885
  // if (this.parent && this.parent.children) {
2881
2886
  // this.fixSelection3FromEndNodes();
2882
2887
  // } else {
2883
- // // my happen when loading __root__;
2888
+ // // may happen when loading __root__;
2884
2889
  // }
2885
2890
  // }
2886
2891
  tree.enableUpdate(true);
@@ -3325,7 +3330,7 @@ class WunderbaumNode {
3325
3330
  return false;
3326
3331
  }
3327
3332
  if (this.children == null) {
3328
- return this.lazy; // null or undefined can trigger lazy load
3333
+ return !!this.lazy; // null or undefined can trigger lazy load
3329
3334
  }
3330
3335
  if (this.children.length === 0) {
3331
3336
  return !!this.tree.options.emptyChildListExpandable;
@@ -3494,6 +3499,7 @@ class WunderbaumNode {
3494
3499
  else if (isPlainObject(source)) {
3495
3500
  // source is a plain object with `.url` property.
3496
3501
  ({ url, params, body, options, ...rest } = source);
3502
+ assert(!rest || Object.keys(rest).length === 0, `Unexpected source properties: ${Object.keys(rest)}. Use 'options' instead.`);
3497
3503
  assert(typeof url === "string", `expected source.url as string`);
3498
3504
  if (isPlainObject(options)) {
3499
3505
  fetchOpts = options;
@@ -3892,7 +3898,7 @@ class WunderbaumNode {
3892
3898
  renderColInfosById: renderColInfosById,
3893
3899
  };
3894
3900
  }
3895
- _createIcon(parentElem, replaceChild, showLoading) {
3901
+ _createIcon(iconMap, parentElem, replaceChild, showLoading) {
3896
3902
  let iconSpan;
3897
3903
  let icon = this.getOption("icon");
3898
3904
  if (this._errorInfo) {
@@ -4005,7 +4011,7 @@ class WunderbaumNode {
4005
4011
  }
4006
4012
  // Render the icon (show a 'loading' icon if we do not have an expander that
4007
4013
  // we would prefer).
4008
- iconSpan = this._createIcon(nodeElem, null, !expanderSpan);
4014
+ iconSpan = this._createIcon(tree.iconMap, nodeElem, null, !expanderSpan);
4009
4015
  if (iconSpan) {
4010
4016
  ofsTitlePx += ICON_WIDTH;
4011
4017
  }
@@ -4139,6 +4145,7 @@ class WunderbaumNode {
4139
4145
  _render_status(opts) {
4140
4146
  // this.log("_render_status", opts);
4141
4147
  const tree = this.tree;
4148
+ const iconMap = tree.iconMap;
4142
4149
  const treeOptions = tree.options;
4143
4150
  const typeInfo = this.type ? tree.types[this.type] : null;
4144
4151
  const rowDiv = this._rowElem;
@@ -4224,7 +4231,7 @@ class WunderbaumNode {
4224
4231
  // Update icon (if not opts.isNew, which would rebuild markup anyway)
4225
4232
  const iconSpan = nodeElem.querySelector("i.wb-icon");
4226
4233
  if (iconSpan) {
4227
- this._createIcon(nodeElem, iconSpan, !expanderSpan);
4234
+ this._createIcon(tree.iconMap, nodeElem, iconSpan, !expanderSpan);
4228
4235
  }
4229
4236
  }
4230
4237
  // Adjust column width
@@ -4953,7 +4960,7 @@ WunderbaumNode.sequence = 0;
4953
4960
  /*!
4954
4961
  * Wunderbaum - ext-edit
4955
4962
  * Copyright (c) 2021-2023, Martin Wendt. Released under the MIT license.
4956
- * v0.4.0, Wed, 06 Sep 2023 08:21:56 GMT (https://github.com/mar10/wunderbaum)
4963
+ * v0.5.0, Fri, 15 Sep 2023 14:34:23 GMT (https://github.com/mar10/wunderbaum)
4957
4964
  */
4958
4965
  // const START_MARKER = "\uFFF7";
4959
4966
  class EditExtension extends WunderbaumExtension {
@@ -5249,8 +5256,8 @@ class EditExtension extends WunderbaumExtension {
5249
5256
  * https://github.com/mar10/wunderbaum
5250
5257
  *
5251
5258
  * Released under the MIT license.
5252
- * @version v0.4.0
5253
- * @date Wed, 06 Sep 2023 08:21:56 GMT
5259
+ * @version v0.5.0
5260
+ * @date Fri, 15 Sep 2023 14:34:23 GMT
5254
5261
  */
5255
5262
  // import "./wunderbaum.scss";
5256
5263
  class WbSystemRoot extends WunderbaumNode {
@@ -5322,6 +5329,7 @@ class Wunderbaum {
5322
5329
  header: null,
5323
5330
  // headerHeightPx: ROW_HEIGHT,
5324
5331
  rowHeightPx: ROW_HEIGHT,
5332
+ iconMap: "bootstrap",
5325
5333
  columns: null,
5326
5334
  types: null,
5327
5335
  // escapeTitles: true,
@@ -5636,6 +5644,16 @@ class Wunderbaum {
5636
5644
  }
5637
5645
  return null;
5638
5646
  }
5647
+ /**
5648
+ * Return the icon-function -> icon-definition mapping.
5649
+ */
5650
+ get iconMap() {
5651
+ const map = this.options.iconMap;
5652
+ if (typeof map === "string") {
5653
+ return iconMaps[map];
5654
+ }
5655
+ return map;
5656
+ }
5639
5657
  /**
5640
5658
  * Return a WunderbaumNode instance from element or event.
5641
5659
  */
@@ -7372,7 +7390,7 @@ class Wunderbaum {
7372
7390
  }
7373
7391
  Wunderbaum.sequence = 0;
7374
7392
  /** Wunderbaum release version number "MAJOR.MINOR.PATCH". */
7375
- Wunderbaum.version = "v0.4.0"; // Set to semver by 'grunt release'
7393
+ Wunderbaum.version = "v0.5.0"; // Set to semver by 'grunt release'
7376
7394
  /** Expose some useful methods of the util.ts module as `Wunderbaum.util`. */
7377
7395
  Wunderbaum.util = util;
7378
7396