wunderbaum 0.12.0 → 0.12.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.
@@ -5,6 +5,11 @@
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
7
  /*!
8
+ * Wunderbaum - debounce.ts
9
+ * Copyright (c) 2021-2025, Martin Wendt. Released under the MIT license.
10
+ * v0.12.1, Sat, 22 Feb 2025 22:59:20 GMT (https://github.com/mar10/wunderbaum)
11
+ */
12
+ /*
8
13
  * debounce & throttle, taken from https://github.com/lodash/lodash v4.17.21
9
14
  * MIT License: https://raw.githubusercontent.com/lodash/lodash/4.17.21-npm/LICENSE
10
15
  * Modified for TypeScript type annotations.
@@ -293,8 +298,8 @@
293
298
 
294
299
  /*!
295
300
  * Wunderbaum - util
296
- * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
297
- * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
301
+ * Copyright (c) 2021-2025, Martin Wendt. Released under the MIT license.
302
+ * v0.12.1, Sat, 22 Feb 2025 22:59:20 GMT (https://github.com/mar10/wunderbaum)
298
303
  */
299
304
  /** @module util */
300
305
  /** Readable names for `MouseEvent.button` */
@@ -1147,8 +1152,8 @@
1147
1152
 
1148
1153
  /*!
1149
1154
  * Wunderbaum - types
1150
- * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1151
- * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
1155
+ * Copyright (c) 2021-2025, Martin Wendt. Released under the MIT license.
1156
+ * v0.12.1, Sat, 22 Feb 2025 22:59:20 GMT (https://github.com/mar10/wunderbaum)
1152
1157
  */
1153
1158
  /**
1154
1159
  * Possible values for {@link WunderbaumNode.update} and {@link Wunderbaum.update}.
@@ -1172,7 +1177,7 @@
1172
1177
  /** Vertical scroll event. Update the 'top' property of all rows. */
1173
1178
  ChangeType["scroll"] = "scroll";
1174
1179
  })(ChangeType || (ChangeType = {}));
1175
- /* Internal use. */
1180
+ /** @internal */
1176
1181
  var RenderFlag;
1177
1182
  (function (RenderFlag) {
1178
1183
  RenderFlag["clearMarkup"] = "clearMarkup";
@@ -1203,16 +1208,20 @@
1203
1208
  /** Initial navigation mode and possible transition. */
1204
1209
  var NavModeEnum;
1205
1210
  (function (NavModeEnum) {
1211
+ /** Start with row mode, but allow cell-nav mode */
1206
1212
  NavModeEnum["startRow"] = "startRow";
1213
+ /** Cell-nav mode only */
1207
1214
  NavModeEnum["cell"] = "cell";
1215
+ /** Start in cell-nav mode, but allow row mode */
1208
1216
  NavModeEnum["startCell"] = "startCell";
1217
+ /** Row mode only */
1209
1218
  NavModeEnum["row"] = "row";
1210
1219
  })(NavModeEnum || (NavModeEnum = {}));
1211
1220
 
1212
1221
  /*!
1213
1222
  * Wunderbaum - wb_extension_base
1214
- * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1215
- * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
1223
+ * Copyright (c) 2021-2025, Martin Wendt. Released under the MIT license.
1224
+ * v0.12.1, Sat, 22 Feb 2025 22:59:20 GMT (https://github.com/mar10/wunderbaum)
1216
1225
  */
1217
1226
  class WunderbaumExtension {
1218
1227
  constructor(tree, id, defaults) {
@@ -1270,8 +1279,8 @@
1270
1279
 
1271
1280
  /*!
1272
1281
  * Wunderbaum - ext-filter
1273
- * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1274
- * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
1282
+ * Copyright (c) 2021-2025, Martin Wendt. Released under the MIT license.
1283
+ * v0.12.1, Sat, 22 Feb 2025 22:59:20 GMT (https://github.com/mar10/wunderbaum)
1275
1284
  */
1276
1285
  const START_MARKER = "\uFFF7";
1277
1286
  const END_MARKER = "\uFFF8";
@@ -1403,7 +1412,7 @@
1403
1412
  };
1404
1413
  }
1405
1414
  tree.filterMode = opts.mode;
1406
- // eslint-disable-next-line prefer-rest-params, prefer-spread
1415
+ // eslint-disable-next-line prefer-rest-params
1407
1416
  this.lastFilterArgs = arguments;
1408
1417
  tree.element.classList.toggle("wb-ext-filter-hide", !!hideMode);
1409
1418
  tree.element.classList.toggle("wb-ext-filter-dim", !hideMode);
@@ -1595,8 +1604,8 @@
1595
1604
 
1596
1605
  /*!
1597
1606
  * Wunderbaum - ext-keynav
1598
- * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1599
- * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
1607
+ * Copyright (c) 2021-2025, Martin Wendt. Released under the MIT license.
1608
+ * v0.12.1, Sat, 22 Feb 2025 22:59:20 GMT (https://github.com/mar10/wunderbaum)
1600
1609
  */
1601
1610
  const QUICKSEARCH_DELAY = 500;
1602
1611
  class KeynavExtension extends WunderbaumExtension {
@@ -1959,8 +1968,8 @@
1959
1968
 
1960
1969
  /*!
1961
1970
  * Wunderbaum - ext-logger
1962
- * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1963
- * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
1971
+ * Copyright (c) 2021-2025, Martin Wendt. Released under the MIT license.
1972
+ * v0.12.1, Sat, 22 Feb 2025 22:59:20 GMT (https://github.com/mar10/wunderbaum)
1964
1973
  */
1965
1974
  class LoggerExtension extends WunderbaumExtension {
1966
1975
  constructor(tree) {
@@ -2001,8 +2010,8 @@
2001
2010
 
2002
2011
  /*!
2003
2012
  * Wunderbaum - ext-dnd
2004
- * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
2005
- * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
2013
+ * Copyright (c) 2021-2025, Martin Wendt. Released under the MIT license.
2014
+ * v0.12.1, Sat, 22 Feb 2025 22:59:20 GMT (https://github.com/mar10/wunderbaum)
2006
2015
  */
2007
2016
  const nodeMimeType = "application/x-wunderbaum-node";
2008
2017
  class DndExtension extends WunderbaumExtension {
@@ -2222,7 +2231,7 @@
2222
2231
  viewportY >= height - sensitivity) {
2223
2232
  // Mouse in bottom 20px area: scroll down
2224
2233
  // sp.scrollTop = scrollTop + dndOpts.scrollSpeed;
2225
- this.currentScrollDir = +1;
2234
+ this.currentScrollDir = 1;
2226
2235
  }
2227
2236
  if (this.currentScrollDir) {
2228
2237
  this.applyScrollDirThrottled();
@@ -2451,8 +2460,8 @@
2451
2460
 
2452
2461
  /*!
2453
2462
  * Wunderbaum - drag_observer
2454
- * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
2455
- * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
2463
+ * Copyright (c) 2021-2025, Martin Wendt. Released under the MIT license.
2464
+ * v0.12.1, Sat, 22 Feb 2025 22:59:20 GMT (https://github.com/mar10/wunderbaum)
2456
2465
  */
2457
2466
  /**
2458
2467
  * Convert mouse- and touch events to 'dragstart', 'drag', and 'dragstop'.
@@ -2600,8 +2609,8 @@
2600
2609
 
2601
2610
  /*!
2602
2611
  * Wunderbaum - common
2603
- * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
2604
- * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
2612
+ * Copyright (c) 2021-2025, Martin Wendt. Released under the MIT license.
2613
+ * v0.12.1, Sat, 22 Feb 2025 22:59:20 GMT (https://github.com/mar10/wunderbaum)
2605
2614
  */
2606
2615
  const DEFAULT_DEBUGLEVEL = 3; // Replaced by rollup script
2607
2616
  /**
@@ -2628,8 +2637,11 @@
2628
2637
  // export const RECURSIVE_REQUEST_ERROR = "$recursive_request";
2629
2638
  // export const INVALID_REQUEST_TARGET_ERROR = "$request_target_invalid";
2630
2639
  /**
2631
- * Default node icons.
2632
- * Requires bootstrap icons https://icons.getbootstrap.com
2640
+ * Default node icons for icon libraries
2641
+ *
2642
+ * - 'bootstrap': {@link https://icons.getbootstrap.com}
2643
+ * - 'fontawesome6' {@link https://fontawesome.com/icons}
2644
+ *
2633
2645
  */
2634
2646
  const iconMaps = {
2635
2647
  bootstrap: {
@@ -2770,10 +2782,12 @@
2770
2782
  /**
2771
2783
  * Convert 'flat' to 'nested' format.
2772
2784
  *
2773
- * Flat node entry format:
2774
- * [PARENT_ID, [POSITIONAL_ARGS]]
2775
- * or
2776
- * [PARENT_ID, [POSITIONAL_ARGS], {KEY_VALUE_ARGS}]
2785
+ * Flat node entry format:
2786
+ * [PARENT_IDX, {KEY_VALUE_ARGS}]
2787
+ * or, if N _positional re defined:
2788
+ * [PARENT_IDX, POSITIONAL_ARG_1, POSITIONAL_ARG_2, ..., POSITIONAL_ARG_N]
2789
+ * Even if _positional additional are defined, KEY_VALUE_ARGS can be appended:
2790
+ * [PARENT_IDX, POSITIONAL_ARG_1, ..., {KEY_VALUE_ARGS}]
2777
2791
  *
2778
2792
  * 1. Parent-referencing list is converted to a list of nested dicts with
2779
2793
  * optional `children` properties.
@@ -2782,10 +2796,11 @@
2782
2796
  function unflattenSource(source) {
2783
2797
  var _a, _b, _c;
2784
2798
  const { _format, _keyMap = {}, _positional = [], children } = source;
2799
+ const _positionalCount = _positional.length;
2785
2800
  if (_format !== "flat") {
2786
2801
  throw new Error(`Expected source._format: "flat", but got ${_format}`);
2787
2802
  }
2788
- if (_positional && _positional.includes("children")) {
2803
+ if (_positionalCount && _positional.includes("children")) {
2789
2804
  throw new Error(`source._positional must not include "children": ${_positional}`);
2790
2805
  }
2791
2806
  let longToShort = _keyMap;
@@ -2799,7 +2814,7 @@
2799
2814
  longToShort[value] = key;
2800
2815
  }
2801
2816
  }
2802
- const positionalShort = _positional.map((e) => longToShort[e]);
2817
+ const positionalShort = _positional.map((e) => { var _a; return (_a = longToShort[e]) !== null && _a !== void 0 ? _a : e; });
2803
2818
  const newChildren = [];
2804
2819
  const keyToNodeMap = {};
2805
2820
  const indexToNodeMap = {};
@@ -2809,19 +2824,32 @@
2809
2824
  // Node entry format:
2810
2825
  // [PARENT_ID, [POSITIONAL_ARGS]]
2811
2826
  // or
2812
- // [PARENT_ID, [POSITIONAL_ARGS], {KEY_VALUE_ARGS}]
2813
- const [parentId, args, kwargs = {}] = nodeTuple;
2827
+ // [PARENT_ID, POSITIONAL_ARG_1, POSITIONAL_ARG_2, ..., {KEY_VALUE_ARGS}]
2828
+ let kwargs;
2829
+ const [parentId, ...args] = nodeTuple;
2830
+ if (args.length === _positionalCount) {
2831
+ kwargs = {};
2832
+ }
2833
+ else if (args.length === _positionalCount + 1) {
2834
+ kwargs = args.pop();
2835
+ if (typeof kwargs !== "object") {
2836
+ throw new Error(`unflattenSource: Expected dict as last tuple element: ${nodeTuple}`);
2837
+ }
2838
+ }
2839
+ else {
2840
+ throw new Error(`unflattenSource: unexpected tuple length: ${nodeTuple}`);
2841
+ }
2814
2842
  // Free up some memory as we go
2815
2843
  nodeTuple[1] = null;
2816
2844
  if (nodeTuple[2] != null) {
2817
2845
  nodeTuple[2] = null;
2818
2846
  }
2819
- // console.log("flatten", parentId, args, kwargs)
2820
2847
  // We keep `kwargs` as our new node definition. Then we add all positional
2821
2848
  // values to this object:
2822
2849
  args.forEach((val, positionalIdx) => {
2823
2850
  kwargs[positionalShort[positionalIdx]] = val;
2824
2851
  });
2852
+ args.length = 0;
2825
2853
  // Find the parent node. `null` means 'toplevel'. PARENT_ID may be the numeric
2826
2854
  // index of the source.children list. If PARENT_ID is a string, we search
2827
2855
  // a parent with node.key of this value.
@@ -2940,8 +2968,8 @@
2940
2968
 
2941
2969
  /*!
2942
2970
  * Wunderbaum - ext-grid
2943
- * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
2944
- * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
2971
+ * Copyright (c) 2021-2025, Martin Wendt. Released under the MIT license.
2972
+ * v0.12.1, Sat, 22 Feb 2025 22:59:20 GMT (https://github.com/mar10/wunderbaum)
2945
2973
  */
2946
2974
  class GridExtension extends WunderbaumExtension {
2947
2975
  constructor(tree) {
@@ -3031,8 +3059,8 @@
3031
3059
 
3032
3060
  /*!
3033
3061
  * Wunderbaum - deferred
3034
- * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
3035
- * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
3062
+ * Copyright (c) 2021-2025, Martin Wendt. Released under the MIT license.
3063
+ * v0.12.1, Sat, 22 Feb 2025 22:59:20 GMT (https://github.com/mar10/wunderbaum)
3036
3064
  */
3037
3065
  /**
3038
3066
  * Implement a ES6 Promise, that exposes a resolve() and reject() method.
@@ -3084,8 +3112,8 @@
3084
3112
 
3085
3113
  /*!
3086
3114
  * Wunderbaum - wunderbaum_node
3087
- * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
3088
- * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
3115
+ * Copyright (c) 2021-2025, Martin Wendt. Released under the MIT license.
3116
+ * v0.12.1, Sat, 22 Feb 2025 22:59:20 GMT (https://github.com/mar10/wunderbaum)
3089
3117
  */
3090
3118
  /** WunderbaumNode properties that can be passed with source data.
3091
3119
  * (Any other source properties will be stored as `node.data.PROP`.)
@@ -5169,7 +5197,8 @@
5169
5197
  case undefined:
5170
5198
  changed = this.selected || !this._partsel;
5171
5199
  this.selected = false;
5172
- this._partsel = true;
5200
+ // #110: end nodess cannot have a `_partsel` flag
5201
+ this._partsel = this.hasChildren() ? true : false;
5173
5202
  break;
5174
5203
  default:
5175
5204
  error(`Invalid state: ${state}`);
@@ -5630,8 +5659,8 @@
5630
5659
 
5631
5660
  /*!
5632
5661
  * Wunderbaum - ext-edit
5633
- * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
5634
- * v0.12.0, Sun, 12 Jan 2025 10:51:41 GMT (https://github.com/mar10/wunderbaum)
5662
+ * Copyright (c) 2021-2025, Martin Wendt. Released under the MIT license.
5663
+ * v0.12.1, Sat, 22 Feb 2025 22:59:20 GMT (https://github.com/mar10/wunderbaum)
5635
5664
  */
5636
5665
  // const START_MARKER = "\uFFF7";
5637
5666
  class EditExtension extends WunderbaumExtension {
@@ -5962,12 +5991,12 @@
5962
5991
  *
5963
5992
  * A treegrid control.
5964
5993
  *
5965
- * Copyright (c) 2021-2024, Martin Wendt (https://wwWendt.de).
5994
+ * Copyright (c) 2021-2025, Martin Wendt (https://wwWendt.de).
5966
5995
  * https://github.com/mar10/wunderbaum
5967
5996
  *
5968
5997
  * Released under the MIT license.
5969
- * @version v0.12.0
5970
- * @date Sun, 12 Jan 2025 10:51:41 GMT
5998
+ * @version v0.12.1
5999
+ * @date Sat, 22 Feb 2025 22:59:20 GMT
5971
6000
  */
5972
6001
  // import "./wunderbaum.scss";
5973
6002
  class WbSystemRoot extends WunderbaumNode {
@@ -5988,7 +6017,7 @@
5988
6017
  */
5989
6018
  class Wunderbaum {
5990
6019
  /** Currently active node if any.
5991
- * Use @link {WunderbaumNode.setActive|setActive} to modify.
6020
+ * Use {@link WunderbaumNode.setActive|setActive} to modify.
5992
6021
  */
5993
6022
  get activeNode() {
5994
6023
  var _a;
@@ -5996,7 +6025,7 @@
5996
6025
  return ((_a = this._activeNode) === null || _a === void 0 ? void 0 : _a.tree) ? this._activeNode : null;
5997
6026
  }
5998
6027
  /** Current node hat has keyboard focus if any.
5999
- * Use @link {WunderbaumNode.setFocus|setFocus()} to modify.
6028
+ * Use {@link WunderbaumNode.setFocus|setFocus()} to modify.
6000
6029
  */
6001
6030
  get focusNode() {
6002
6031
  var _a;
@@ -6146,7 +6175,7 @@
6146
6175
  const wantHeader = opts.header == null ? this.columns.length > 1 : !!opts.header;
6147
6176
  if (this.headerElement) {
6148
6177
  // User existing header markup to define `this.columns`
6149
- assert(!this.columns, "`opts.columns` must not be set if markup already contains a header");
6178
+ assert(!this.columns, "`opts.columns` must not be set if table markup already contains a header");
6150
6179
  this.columns = [];
6151
6180
  const rowElement = this.headerElement.querySelector("div.wb-row");
6152
6181
  for (const colDiv of rowElement.querySelectorAll("div")) {
@@ -6194,8 +6223,7 @@
6194
6223
  // --- Load initial data
6195
6224
  if (opts.source) {
6196
6225
  if (opts.showSpinner) {
6197
- this.nodeListElement.innerHTML =
6198
- "<progress class='spinner'>loading...</progress>";
6226
+ this.nodeListElement.innerHTML = `<progress class='spinner'>${opts.strings.loading}</progress>`;
6199
6227
  }
6200
6228
  this.load(opts.source)
6201
6229
  .then(() => {
@@ -7990,8 +8018,9 @@
7990
8018
  // this.debug("render", opts);
7991
8019
  const obsoleteNodes = new Set();
7992
8020
  this.nodeListElement.childNodes.forEach((elem) => {
7993
- const tr = elem;
7994
- obsoleteNodes.add(tr._wb_node);
8021
+ if (elem._wb_node) {
8022
+ obsoleteNodes.add(elem._wb_node);
8023
+ }
7995
8024
  });
7996
8025
  let idx = 0;
7997
8026
  let top = 0;
@@ -8292,7 +8321,7 @@
8292
8321
  }
8293
8322
  Wunderbaum.sequence = 0;
8294
8323
  /** Wunderbaum release version number "MAJOR.MINOR.PATCH". */
8295
- Wunderbaum.version = "v0.12.0"; // Set to semver by 'grunt release'
8324
+ Wunderbaum.version = "v0.12.1"; // Set to semver by 'grunt release'
8296
8325
  /** Expose some useful methods of the util.ts module as `Wunderbaum.util`. */
8297
8326
  Wunderbaum.util = util;
8298
8327