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