lexgui 8.2.4 → 8.2.5

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.
package/build/lexgui.js CHANGED
@@ -16,7 +16,7 @@
16
16
  exports.LX = g.LX;
17
17
  if (!exports.LX) {
18
18
  exports.LX = {
19
- version: '8.2.4',
19
+ version: '8.2.5',
20
20
  ready: false,
21
21
  extensions: [], // Store extensions used
22
22
  extraCommandbarEntries: [], // User specific entries for command bar
@@ -4986,6 +4986,7 @@
4986
4986
  item.id = exports.LX.getSupportedDOMName(node.id);
4987
4987
  item.tabIndex = '0';
4988
4988
  item.treeData = node;
4989
+ node.treeEl = item;
4989
4990
  // Select hierarchy icon
4990
4991
  let icon = (this.options.skipDefaultIcon ?? true) ? null : 'Dot'; // Default: no childs
4991
4992
  if (isParent) {
@@ -5468,21 +5469,45 @@
5468
5469
  el.focus();
5469
5470
  }
5470
5471
  }
5471
- select(id) {
5472
+ /* 'path' here helps to identity the correct item based on its parent path, for same 'id' issues */
5473
+ select(id, path) {
5472
5474
  const nodeFilter = this.domEl.querySelector('.lexnodetreefilter');
5473
5475
  if (nodeFilter) {
5474
5476
  nodeFilter.value = '';
5475
5477
  }
5476
5478
  this.refresh(null, id);
5477
5479
  this.domEl.querySelectorAll('.selected').forEach((i) => i.classList.remove('selected'));
5478
- // Unselect
5479
- if (!id) {
5480
- this.selected.length = 0;
5481
- return;
5480
+ if (id === undefined) {
5481
+ // if no id, try with the path
5482
+ if (path !== undefined) {
5483
+ id = path.at(-1);
5484
+ }
5485
+ else {
5486
+ // Unselect
5487
+ this.selected.length = 0;
5488
+ return;
5489
+ }
5490
+ }
5491
+ let el = null;
5492
+ if (path !== undefined) {
5493
+ let sourceData = this.data;
5494
+ for (const p of path) {
5495
+ const pItem = sourceData.children.find((item) => item.id === p);
5496
+ if (!pItem)
5497
+ break;
5498
+ sourceData = pItem;
5499
+ }
5500
+ el = sourceData.treeEl;
5501
+ console.assert(el, 'NodeTree: No domEl in item ' + id);
5502
+ }
5503
+ else if (id !== undefined) {
5504
+ // Element should exist, since tree was refreshed to show it
5505
+ el = this.domEl.querySelector('#' + exports.LX.getSupportedDOMName(id));
5506
+ console.assert(el, "NodeTree: Can't select node " + id);
5507
+ }
5508
+ if (!el) {
5509
+ console.assert(el, "NodeTree: Can't select node " + id);
5482
5510
  }
5483
- // Element should exist, since tree was refreshed to show it
5484
- const el = this.domEl.querySelector('#' + exports.LX.getSupportedDOMName(id));
5485
- console.assert(el, "NodeTree: Can't select node " + id);
5486
5511
  el.classList.add('selected');
5487
5512
  this.selected = [el.treeData];
5488
5513
  el.focus();