wunderbaum 0.10.1 → 0.11.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.10.1, Sat, 20 Jul 2024 13:53:46 GMT (https://github.com/mar10/wunderbaum)
297
+ * v0.11.0, Sun, 04 Aug 2024 15:35:53 GMT (https://github.com/mar10/wunderbaum)
298
298
  */
299
299
  /** @module util */
300
300
  /** Readable names for `MouseEvent.button` */
@@ -926,6 +926,11 @@
926
926
  // Use value from value options dict, fallback do default
927
927
  return value !== null && value !== void 0 ? value : defaultValue;
928
928
  }
929
+ /** Return the next value from a list of values (rotating). @since 0.11 */
930
+ function rotate(value, values) {
931
+ const idx = values.indexOf(value);
932
+ return values[(idx + 1) % values.length];
933
+ }
929
934
  /** Convert an Array or space-separated string to a Set. */
930
935
  function toSet(val) {
931
936
  if (val instanceof Set) {
@@ -954,12 +959,7 @@
954
959
  * const width = util.toPixel(x, y, 100); // returns 123
955
960
  * ```
956
961
  */
957
- function toPixel(
958
- // val: string | number | undefined | null,
959
- ...defaults) {
960
- // if (typeof val === "number") {
961
- // return val;
962
- // }
962
+ function toPixel(...defaults) {
963
963
  for (const d of defaults) {
964
964
  if (typeof d === "number") {
965
965
  return d;
@@ -978,12 +978,7 @@
978
978
  * const value = util.toBool(opts.foo, opts.flag, false); // returns true
979
979
  * ```
980
980
  */
981
- function toBool(
982
- // val: boolean | undefined | null,
983
- ...boolDefaults) {
984
- // if (val != null) {
985
- // return !!val;
986
- // }
981
+ function toBool(...boolDefaults) {
987
982
  for (const d of boolDefaults) {
988
983
  if (d != null) {
989
984
  return !!d;
@@ -1127,6 +1122,7 @@
1127
1122
  noop: noop,
1128
1123
  onEvent: onEvent,
1129
1124
  overrideMethod: overrideMethod,
1125
+ rotate: rotate,
1130
1126
  setElemDisplay: setElemDisplay,
1131
1127
  setTimeoutPromise: setTimeoutPromise,
1132
1128
  setValueToElem: setValueToElem,
@@ -1142,10 +1138,10 @@
1142
1138
  /*!
1143
1139
  * Wunderbaum - types
1144
1140
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1145
- * v0.10.1, Sat, 20 Jul 2024 13:53:46 GMT (https://github.com/mar10/wunderbaum)
1141
+ * v0.11.0, Sun, 04 Aug 2024 15:35:53 GMT (https://github.com/mar10/wunderbaum)
1146
1142
  */
1147
1143
  /**
1148
- * Possible values for {@link WunderbaumNode.update()} and {@link Wunderbaum.update()}.
1144
+ * Possible values for {@link WunderbaumNode.update} and {@link Wunderbaum.update}.
1149
1145
  */
1150
1146
  var ChangeType;
1151
1147
  (function (ChangeType) {
@@ -1174,7 +1170,7 @@
1174
1170
  RenderFlag["redraw"] = "redraw";
1175
1171
  RenderFlag["scroll"] = "scroll";
1176
1172
  })(RenderFlag || (RenderFlag = {}));
1177
- /** Possible values for {@link WunderbaumNode.setStatus()}. */
1173
+ /** Possible values for {@link WunderbaumNode.setStatus}. */
1178
1174
  var NodeStatusType;
1179
1175
  (function (NodeStatusType) {
1180
1176
  NodeStatusType["ok"] = "ok";
@@ -1206,7 +1202,7 @@
1206
1202
  /*!
1207
1203
  * Wunderbaum - wb_extension_base
1208
1204
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1209
- * v0.10.1, Sat, 20 Jul 2024 13:53:46 GMT (https://github.com/mar10/wunderbaum)
1205
+ * v0.11.0, Sun, 04 Aug 2024 15:35:53 GMT (https://github.com/mar10/wunderbaum)
1210
1206
  */
1211
1207
  class WunderbaumExtension {
1212
1208
  constructor(tree, id, defaults) {
@@ -1265,7 +1261,7 @@
1265
1261
  /*!
1266
1262
  * Wunderbaum - ext-filter
1267
1263
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1268
- * v0.10.1, Sat, 20 Jul 2024 13:53:46 GMT (https://github.com/mar10/wunderbaum)
1264
+ * v0.11.0, Sun, 04 Aug 2024 15:35:53 GMT (https://github.com/mar10/wunderbaum)
1269
1265
  */
1270
1266
  const START_MARKER = "\uFFF7";
1271
1267
  const END_MARKER = "\uFFF8";
@@ -1590,7 +1586,7 @@
1590
1586
  /*!
1591
1587
  * Wunderbaum - ext-keynav
1592
1588
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1593
- * v0.10.1, Sat, 20 Jul 2024 13:53:46 GMT (https://github.com/mar10/wunderbaum)
1589
+ * v0.11.0, Sun, 04 Aug 2024 15:35:53 GMT (https://github.com/mar10/wunderbaum)
1594
1590
  */
1595
1591
  const QUICKSEARCH_DELAY = 500;
1596
1592
  class KeynavExtension extends WunderbaumExtension {
@@ -1954,7 +1950,7 @@
1954
1950
  /*!
1955
1951
  * Wunderbaum - ext-logger
1956
1952
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1957
- * v0.10.1, Sat, 20 Jul 2024 13:53:46 GMT (https://github.com/mar10/wunderbaum)
1953
+ * v0.11.0, Sun, 04 Aug 2024 15:35:53 GMT (https://github.com/mar10/wunderbaum)
1958
1954
  */
1959
1955
  class LoggerExtension extends WunderbaumExtension {
1960
1956
  constructor(tree) {
@@ -1996,7 +1992,7 @@
1996
1992
  /*!
1997
1993
  * Wunderbaum - common
1998
1994
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
1999
- * v0.10.1, Sat, 20 Jul 2024 13:53:46 GMT (https://github.com/mar10/wunderbaum)
1995
+ * v0.11.0, Sun, 04 Aug 2024 15:35:53 GMT (https://github.com/mar10/wunderbaum)
2000
1996
  */
2001
1997
  const DEFAULT_DEBUGLEVEL = 3; // Replaced by rollup script
2002
1998
  /**
@@ -2051,6 +2047,15 @@
2051
2047
  folderOpen: "bi bi-folder2-open",
2052
2048
  folderLazy: "bi bi-folder-symlink",
2053
2049
  doc: "bi bi-file-earmark",
2050
+ colSortable: "bi bi-chevron-expand",
2051
+ // colSortable: "bi bi-arrow-down-up",
2052
+ // colSortAsc: "bi bi-chevron-down",
2053
+ // colSortDesc: "bi bi-chevron-up",
2054
+ colSortAsc: "bi bi-arrow-down",
2055
+ colSortDesc: "bi bi-arrow-up",
2056
+ colFilter: "bi bi-filter-circle",
2057
+ colFilterActive: "bi bi-filter-circle-fill wb-helper-invalid",
2058
+ colMenu: "bi bi-three-dots-vertical",
2054
2059
  },
2055
2060
  fontawesome6: {
2056
2061
  error: "fa-solid fa-triangle-exclamation",
@@ -2069,6 +2074,12 @@
2069
2074
  folderOpen: "fa-regular fa-folder-open",
2070
2075
  folderLazy: "fa-solid fa-folder-plus",
2071
2076
  doc: "fa-regular fa-file",
2077
+ colSortable: "fa-solid fa-fw fa-sort",
2078
+ colSortAsc: "fa-solid fa-fw fa-sort-up",
2079
+ colSortDesc: "fa-solid fa-fw fa-sort-down",
2080
+ colFilter: "fa-solid fa-fw fa-filter",
2081
+ colFilterActive: "fa-solid fa-fw fa-filter wb-helper-invalid",
2082
+ colMenu: "fa-solid fa-fw fa-ellipsis-v",
2072
2083
  },
2073
2084
  };
2074
2085
  /** Dict keys that are evaluated by source loader (others are added to `tree.data` instead). */
@@ -2117,7 +2128,7 @@
2117
2128
  };
2118
2129
  /** Return a callback that returns true if the node title matches the string
2119
2130
  * or regular expression.
2120
- * @see {@link WunderbaumNode.findAll()}
2131
+ * @see {@link WunderbaumNode.findAll}
2121
2132
  */
2122
2133
  function makeNodeTitleMatcher(match) {
2123
2134
  if (match instanceof RegExp) {
@@ -2321,7 +2332,7 @@
2321
2332
  /*!
2322
2333
  * Wunderbaum - ext-dnd
2323
2334
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
2324
- * v0.10.1, Sat, 20 Jul 2024 13:53:46 GMT (https://github.com/mar10/wunderbaum)
2335
+ * v0.11.0, Sun, 04 Aug 2024 15:35:53 GMT (https://github.com/mar10/wunderbaum)
2325
2336
  */
2326
2337
  const nodeMimeType = "application/x-wunderbaum-node";
2327
2338
  class DndExtension extends WunderbaumExtension {
@@ -2766,7 +2777,7 @@
2766
2777
  /*!
2767
2778
  * Wunderbaum - drag_observer
2768
2779
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
2769
- * v0.10.1, Sat, 20 Jul 2024 13:53:46 GMT (https://github.com/mar10/wunderbaum)
2780
+ * v0.11.0, Sun, 04 Aug 2024 15:35:53 GMT (https://github.com/mar10/wunderbaum)
2770
2781
  */
2771
2782
  /**
2772
2783
  * Convert mouse- and touch events to 'dragstart', 'drag', and 'dragstop'.
@@ -2915,7 +2926,7 @@
2915
2926
  /*!
2916
2927
  * Wunderbaum - ext-grid
2917
2928
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
2918
- * v0.10.1, Sat, 20 Jul 2024 13:53:46 GMT (https://github.com/mar10/wunderbaum)
2929
+ * v0.11.0, Sun, 04 Aug 2024 15:35:53 GMT (https://github.com/mar10/wunderbaum)
2919
2930
  */
2920
2931
  class GridExtension extends WunderbaumExtension {
2921
2932
  constructor(tree) {
@@ -2932,7 +2943,7 @@
2932
2943
  const colDef = info.colDef;
2933
2944
  const allow = colDef &&
2934
2945
  this.tree.element.contains(e.dragElem) &&
2935
- toBool(colDef.resizable, tree.options.resizableColumns, false);
2946
+ toBool(colDef.resizable, tree.options.columnsResizable, false);
2936
2947
  // this.tree.log("dragstart", colDef, e, info);
2937
2948
  this.tree.element.classList.toggle("wb-col-resizing", !!allow);
2938
2949
  info.colElem.classList.toggle("wb-col-resizing", !!allow);
@@ -3006,7 +3017,7 @@
3006
3017
  /*!
3007
3018
  * Wunderbaum - deferred
3008
3019
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
3009
- * v0.10.1, Sat, 20 Jul 2024 13:53:46 GMT (https://github.com/mar10/wunderbaum)
3020
+ * v0.11.0, Sun, 04 Aug 2024 15:35:53 GMT (https://github.com/mar10/wunderbaum)
3010
3021
  */
3011
3022
  /**
3012
3023
  * Implement a ES6 Promise, that exposes a resolve() and reject() method.
@@ -3059,7 +3070,7 @@
3059
3070
  /*!
3060
3071
  * Wunderbaum - wunderbaum_node
3061
3072
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
3062
- * v0.10.1, Sat, 20 Jul 2024 13:53:46 GMT (https://github.com/mar10/wunderbaum)
3073
+ * v0.11.0, Sun, 04 Aug 2024 15:35:53 GMT (https://github.com/mar10/wunderbaum)
3063
3074
  */
3064
3075
  /** WunderbaumNode properties that can be passed with source data.
3065
3076
  * (Any other source properties will be stored as `node.data.PROP`.)
@@ -3102,6 +3113,12 @@
3102
3113
  * @see Use {@link setKey} to modify.
3103
3114
  */
3104
3115
  this.refKey = undefined;
3116
+ /**
3117
+ * Array of child nodes (null for leaf nodes).
3118
+ * For lazy nodes, this is `null` or ùndefined` until the children are loaded
3119
+ * and leaf nodes may be `[]` (empty array).
3120
+ * @see {@link hasChildren}, {@link addChildren}, {@link lazy}.
3121
+ */
3105
3122
  this.children = null;
3106
3123
  /** Additional classes added to `div.wb-row`.
3107
3124
  * @see {@link hasClass}, {@link setClass}. */
@@ -3689,7 +3706,7 @@
3689
3706
  hasClass(className) {
3690
3707
  return this.classes ? this.classes.has(className) : false;
3691
3708
  }
3692
- /** Return true if node ist the currently focused node. */
3709
+ /** Return true if node ist the currently focused node. @since 0.9.0 */
3693
3710
  hasFocus() {
3694
3711
  return this.tree.focusNode === this;
3695
3712
  }
@@ -3911,6 +3928,8 @@
3911
3928
  if (tree.options.selectMode === "hier") {
3912
3929
  this.fixSelection3FromEndNodes();
3913
3930
  }
3931
+ // Allow to un-sort nodes after sorting
3932
+ this.resetNativeChildOrder();
3914
3933
  this._callEvent("load");
3915
3934
  }
3916
3935
  async _fetchWithOptions(source) {
@@ -4854,7 +4873,7 @@
4854
4873
  *
4855
4874
  * @param name name of the option property (on node and tree)
4856
4875
  * @param defaultValue return this if nothing else matched
4857
- * {@link Wunderbaum.getOption|Wunderbaum.getOption()}
4876
+ * {@link Wunderbaum.getOption|Wunderbaum.getOption}
4858
4877
  */
4859
4878
  getOption(name, defaultValue) {
4860
4879
  const tree = this.tree;
@@ -4890,7 +4909,7 @@
4890
4909
  return value !== null && value !== void 0 ? value : defaultValue;
4891
4910
  }
4892
4911
  /** Make sure that this node is visible in the viewport.
4893
- * @see {@link Wunderbaum.scrollTo|Wunderbaum.scrollTo()}
4912
+ * @see {@link Wunderbaum.scrollTo|Wunderbaum.scrollTo}
4894
4913
  */
4895
4914
  async scrollIntoView(options) {
4896
4915
  const opts = Object.assign({ node: this }, options);
@@ -5029,9 +5048,9 @@
5029
5048
  * and column content. It can be reduced to 'ChangeType.status' if only
5030
5049
  * active/focus/selected state has changed.
5031
5050
  *
5032
- * This method will eventually call {@link WunderbaumNode._render()} with
5051
+ * This method will eventually call {@link WunderbaumNode._render} with
5033
5052
  * default options, but may be more consistent with the tree's
5034
- * {@link Wunderbaum.update()} API.
5053
+ * {@link Wunderbaum.update} API.
5035
5054
  */
5036
5055
  update(change = ChangeType.data) {
5037
5056
  assert(change === ChangeType.status || change === ChangeType.data, `Invalid change type ${change}`);
@@ -5360,6 +5379,80 @@
5360
5379
  this.tree.update(ChangeType.structure);
5361
5380
  // this.triggerModify("sort"); // TODO
5362
5381
  }
5382
+ /**
5383
+ * Renumber nodes `_nativeIndex`. This is useful to allow to restore the
5384
+ * order after sorting a column.
5385
+ * This method is automatically called after loading new child nodes.
5386
+ * @since 0.11.0
5387
+ */
5388
+ resetNativeChildOrder(options) {
5389
+ const { recursive = true, propName = "_nativeIndex" } = options !== null && options !== void 0 ? options : {};
5390
+ if (this.children) {
5391
+ this.children.forEach((child, i) => {
5392
+ child.data[propName] = i;
5393
+ if (recursive && child.children) {
5394
+ child.resetNativeChildOrder(options);
5395
+ }
5396
+ });
5397
+ }
5398
+ }
5399
+ /**
5400
+ * Convenience method to implement column sorting.
5401
+ * @since 0.11.0
5402
+ */
5403
+ sortByProperty(options) {
5404
+ var _a, _b, _c;
5405
+ const { caseInsensitive = true, deep = true, nativeOrderPropName = "_nativeIndex", updateColInfo = false, } = options;
5406
+ let order;
5407
+ let colDef;
5408
+ if (updateColInfo) {
5409
+ colDef = this.tree["_columnsById"][options.colId];
5410
+ assert(colDef, `Invalid colId specified: ${options.colId}`);
5411
+ order =
5412
+ (_a = options.order) !== null && _a !== void 0 ? _a : rotate(colDef.sortOrder, ["asc", "desc", undefined]);
5413
+ for (const col of this.tree.columns) {
5414
+ col.sortOrder = col === colDef ? order : undefined;
5415
+ }
5416
+ this.tree.update(ChangeType.colStructure);
5417
+ }
5418
+ else {
5419
+ order = (_b = options.order) !== null && _b !== void 0 ? _b : "asc";
5420
+ }
5421
+ let propName = (_c = options.propName) !== null && _c !== void 0 ? _c : (options.colId || "");
5422
+ if (propName === "*") {
5423
+ propName = "title";
5424
+ }
5425
+ if (order == null) {
5426
+ propName = nativeOrderPropName;
5427
+ order = "asc";
5428
+ }
5429
+ this.logDebug(`sortByProperty(), propName=${propName}, ${order}`, options);
5430
+ assert(propName, "No property name specified");
5431
+ const cmp = (a, b) => {
5432
+ let av, bv;
5433
+ if (NODE_DICT_PROPS.has(propName)) {
5434
+ av = a[propName];
5435
+ bv = b[propName];
5436
+ }
5437
+ else {
5438
+ av = a.data[propName];
5439
+ bv = b.data[propName];
5440
+ }
5441
+ if (caseInsensitive) {
5442
+ if (typeof av === "string") {
5443
+ av = av.toLowerCase();
5444
+ }
5445
+ if (typeof bv === "string") {
5446
+ bv = bv.toLowerCase();
5447
+ }
5448
+ }
5449
+ if (order === "desc") {
5450
+ return av === bv ? 0 : av > bv ? -1 : 1;
5451
+ }
5452
+ return av === bv ? 0 : av > bv ? 1 : -1;
5453
+ };
5454
+ return this.sortChildren(cmp, deep);
5455
+ }
5363
5456
  /**
5364
5457
  * Trigger `modifyChild` event on a parent to signal that a child was modified.
5365
5458
  * @param {string} operation Type of change: 'add', 'remove', 'rename', 'move', 'data', ...
@@ -5468,7 +5561,7 @@
5468
5561
  /*!
5469
5562
  * Wunderbaum - ext-edit
5470
5563
  * Copyright (c) 2021-2024, Martin Wendt. Released under the MIT license.
5471
- * v0.10.1, Sat, 20 Jul 2024 13:53:46 GMT (https://github.com/mar10/wunderbaum)
5564
+ * v0.11.0, Sun, 04 Aug 2024 15:35:53 GMT (https://github.com/mar10/wunderbaum)
5472
5565
  */
5473
5566
  // const START_MARKER = "\uFFF7";
5474
5567
  class EditExtension extends WunderbaumExtension {
@@ -5799,8 +5892,8 @@
5799
5892
  * https://github.com/mar10/wunderbaum
5800
5893
  *
5801
5894
  * Released under the MIT license.
5802
- * @version v0.10.1
5803
- * @date Sat, 20 Jul 2024 13:53:46 GMT
5895
+ * @version v0.11.0
5896
+ * @date Sun, 04 Aug 2024 15:35:53 GMT
5804
5897
  */
5805
5898
  // import "./wunderbaum.scss";
5806
5899
  class WbSystemRoot extends WunderbaumNode {
@@ -5970,7 +6063,8 @@
5970
6063
  // Attach tree instance to <div>
5971
6064
  this.element._wb_tree = this;
5972
6065
  // Create header markup, or take it from the existing html
5973
- this.headerElement = this.element.querySelector("div.wb-header");
6066
+ this.headerElement =
6067
+ this.element.querySelector("div.wb-header");
5974
6068
  const wantHeader = opts.header == null ? this.columns.length > 1 : !!opts.header;
5975
6069
  if (this.headerElement) {
5976
6070
  // User existing header markup to define `this.columns`
@@ -6007,8 +6101,10 @@
6007
6101
  <div class="wb-node-list"></div>
6008
6102
  </div>`;
6009
6103
  this.listContainerElement = this.element.querySelector("div.wb-list-container");
6010
- this.nodeListElement = this.listContainerElement.querySelector("div.wb-node-list");
6011
- this.headerElement = this.element.querySelector("div.wb-header");
6104
+ this.nodeListElement =
6105
+ this.listContainerElement.querySelector("div.wb-node-list");
6106
+ this.headerElement =
6107
+ this.element.querySelector("div.wb-header");
6012
6108
  this.element.classList.toggle("wb-grid", this.columns.length > 1);
6013
6109
  this._initExtensions();
6014
6110
  // --- apply initial options
@@ -6065,6 +6161,16 @@
6065
6161
  this.update(ChangeType.resize);
6066
6162
  });
6067
6163
  this.resizeObserver.observe(this.element);
6164
+ onEvent(this.element, "click", ".wb-button,.wb-col-icon", (e) => {
6165
+ var _a, _b;
6166
+ const info = Wunderbaum.getEventInfo(e);
6167
+ const command = (_b = (_a = e.target) === null || _a === void 0 ? void 0 : _a.dataset) === null || _b === void 0 ? void 0 : _b.command;
6168
+ this._callEvent("buttonClick", {
6169
+ event: e,
6170
+ info: info,
6171
+ command: command,
6172
+ });
6173
+ });
6068
6174
  onEvent(this.nodeListElement, "click", "div.wb-row", (e) => {
6069
6175
  const info = Wunderbaum.getEventInfo(e);
6070
6176
  const node = info.node;
@@ -6645,7 +6751,7 @@
6645
6751
  }
6646
6752
  /** Run code, but defer rendering of viewport until done.
6647
6753
  *
6648
- * ```
6754
+ * ```js
6649
6755
  * tree.runWithDeferredUpdate(() => {
6650
6756
  * return someFuncThatWouldUpdateManyNodes();
6651
6757
  * });
@@ -7123,13 +7229,17 @@
7123
7229
  console.warn(this.toString(), ...args); // eslint-disable-line no-console
7124
7230
  }
7125
7231
  }
7126
- /** Reset column widths to default. */
7232
+ /** Reset column widths to default. @since 0.10.0 */
7127
7233
  resetColumns() {
7128
7234
  this.columns.forEach((col) => {
7129
7235
  delete col.customWidthPx;
7130
7236
  });
7131
7237
  this.update(ChangeType.colStructure);
7132
7238
  }
7239
+ // /** Renumber nodes `_nativeIndex`. @see {@link WunderbaumNode.resetNativeChildOrder} */
7240
+ // resetNativeChildOrder(options?: ResetOrderOptions) {
7241
+ // this.root.resetNativeChildOrder(options);
7242
+ // }
7133
7243
  /**
7134
7244
  * Make sure that this node is vertically scrolled into the viewport.
7135
7245
  *
@@ -7444,6 +7554,14 @@
7444
7554
  sortChildren(cmp = nodeTitleSorter, deep = false) {
7445
7555
  this.root.sortChildren(cmp, deep);
7446
7556
  }
7557
+ /**
7558
+ * Convenience method to implement column sorting.
7559
+ * @see {@link WunderbaumNode.sortByProperty}.
7560
+ * @since 0.11.0
7561
+ */
7562
+ sortByProperty(options) {
7563
+ this.root.sortByProperty(options);
7564
+ }
7447
7565
  /** Convert tree to an array of plain objects.
7448
7566
  *
7449
7567
  * @param callback is called for every node, in order to allow
@@ -7557,6 +7675,11 @@
7557
7675
  // }
7558
7676
  return modified;
7559
7677
  }
7678
+ _insertIcon(icon, elem) {
7679
+ const iconElem = document.createElement("i");
7680
+ iconElem.className = icon;
7681
+ elem.appendChild(iconElem);
7682
+ }
7560
7683
  /** Create/update header markup from `this.columns` definition.
7561
7684
  * @internal
7562
7685
  */
@@ -7567,6 +7690,7 @@
7567
7690
  if (!wantHeader) {
7568
7691
  return;
7569
7692
  }
7693
+ const iconMap = this.iconMap;
7570
7694
  const colCount = this.columns.length;
7571
7695
  const headerRow = this.headerElement.querySelector(".wb-row");
7572
7696
  assert(headerRow, "Expected a row in header element");
@@ -7585,23 +7709,54 @@
7585
7709
  else {
7586
7710
  col.classes ? colElem.classList.add(...col.classes.split(" ")) : 0;
7587
7711
  }
7588
- const title = escapeHtml(col.title || col.id);
7712
+ // Add tooltip to column title
7589
7713
  let tooltip = "";
7590
7714
  if (col.tooltip) {
7591
7715
  tooltip = escapeTooltip(col.tooltip);
7592
7716
  tooltip = ` title="${tooltip}"`;
7593
7717
  }
7594
- let resizer = "";
7718
+ // Add column header icons
7719
+ let addMarkup = "";
7720
+ // NOTE: we use CSS float: right to align icons, so they must be added in
7721
+ // reverse order
7722
+ if (toBool(col.menu, this.options.columnsMenu, false)) {
7723
+ const iconClass = "wb-col-icon-menu " + iconMap.colMenu;
7724
+ const icon = `<i data-command=menu class="wb-col-icon ${iconClass}"></i>`;
7725
+ addMarkup += icon;
7726
+ }
7727
+ if (toBool(col.sortable, this.options.columnsSortable, false)) {
7728
+ let iconClass = "wb-col-icon-sort " + iconMap.colSortable;
7729
+ if (col.sortOrder) {
7730
+ iconClass += `wb-col-sort-${col.sortOrder}`;
7731
+ iconClass +=
7732
+ col.sortOrder === "asc" ? iconMap.colSortAsc : iconMap.colSortDesc;
7733
+ }
7734
+ const icon = `<i data-command=sort class="wb-col-icon ${iconClass}"></i>`;
7735
+ addMarkup += icon;
7736
+ }
7737
+ if (toBool(col.filterable, this.options.columnsFilterable, false)) {
7738
+ colElem.classList.toggle("wb-col-filter", !!col.filterActive);
7739
+ let iconClass = "wb-col-icon-filter " + iconMap.colFilter;
7740
+ if (col.filterActive) {
7741
+ iconClass += iconMap.colFilterActive;
7742
+ }
7743
+ const icon = `<i data-command=filter class="wb-col-icon ${iconClass}"></i>`;
7744
+ addMarkup += icon;
7745
+ }
7746
+ // Add resizer to all but the last column
7595
7747
  if (i < colCount - 1) {
7596
- if (toBool(col.resizable, this.options.resizableColumns, false)) {
7597
- resizer =
7748
+ if (toBool(col.resizable, this.options.columnsResizable, false)) {
7749
+ addMarkup +=
7598
7750
  '<span class="wb-col-resizer wb-col-resizer-active"></span>';
7599
7751
  }
7600
7752
  else {
7601
- resizer = '<span class="wb-col-resizer"></span>';
7753
+ addMarkup += '<span class="wb-col-resizer"></span>';
7602
7754
  }
7603
7755
  }
7604
- colElem.innerHTML = `<span class="wb-col-title"${tooltip}>${title}</span>${resizer}`;
7756
+ // Create column header
7757
+ const title = escapeHtml(col.title || col.id);
7758
+ colElem.innerHTML = `<span class="wb-col-title"${tooltip}>${title}</span>${addMarkup}`;
7759
+ // Highlight active column
7605
7760
  if (this.isCellNav()) {
7606
7761
  colElem.classList.toggle("wb-active", i === this.activeColIdx);
7607
7762
  }
@@ -8018,6 +8173,7 @@
8018
8173
  /**
8019
8174
  * Return the number of nodes that match the current filter.
8020
8175
  * @see {@link Wunderbaum.filterNodes}
8176
+ * @since 0.9.0
8021
8177
  */
8022
8178
  countMatches() {
8023
8179
  return this.extensions.filter.countMatches();
@@ -8050,7 +8206,7 @@
8050
8206
  }
8051
8207
  Wunderbaum.sequence = 0;
8052
8208
  /** Wunderbaum release version number "MAJOR.MINOR.PATCH". */
8053
- Wunderbaum.version = "v0.10.1"; // Set to semver by 'grunt release'
8209
+ Wunderbaum.version = "v0.11.0"; // Set to semver by 'grunt release'
8054
8210
  /** Expose some useful methods of the util.ts module as `Wunderbaum.util`. */
8055
8211
  Wunderbaum.util = util;
8056
8212