reneco-hierarchized-picker 0.4.2-beta.8 → 0.4.2

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.
Files changed (27) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/reneco-hierarchized-picker.cjs.js +1 -1
  3. package/dist/cjs/reneco-hierarchized-picker_2.cjs.entry.js +152 -60
  4. package/dist/collection/components/hierarchized-picker/hierarchized-picker.js +112 -29
  5. package/dist/collection/components/treejs/index.js +15 -12
  6. package/dist/collection/core/options-manager.js +6 -0
  7. package/dist/collection/core/raw-data-manager.js +14 -4
  8. package/dist/collection/features/tree/drag-drop.js +15 -5
  9. package/dist/collection/features/tree/tree-utils.js +10 -11
  10. package/dist/custom-elements/index.js +153 -61
  11. package/dist/esm/loader.js +1 -1
  12. package/dist/esm/reneco-hierarchized-picker.js +1 -1
  13. package/dist/esm/reneco-hierarchized-picker_2.entry.js +152 -60
  14. package/dist/esm-es5/loader.js +1 -1
  15. package/dist/esm-es5/reneco-hierarchized-picker.js +1 -1
  16. package/dist/esm-es5/reneco-hierarchized-picker_2.entry.js +1 -1
  17. package/dist/reneco-hierarchized-picker/p-73168a50.system.js +1 -1
  18. package/dist/reneco-hierarchized-picker/{p-d255cf51.entry.js → p-a0b09a0d.entry.js} +1 -1
  19. package/dist/reneco-hierarchized-picker/p-b9b4b7a6.system.entry.js +3 -0
  20. package/dist/reneco-hierarchized-picker/reneco-hierarchized-picker.esm.js +1 -1
  21. package/dist/types/components/hierarchized-picker/hierarchized-picker.d.ts +4 -1
  22. package/dist/types/components.d.ts +2 -0
  23. package/dist/types/core/options-manager.d.ts +1 -0
  24. package/dist/types/core/raw-data-manager.d.ts +2 -1
  25. package/dist/types/features/tree/drag-drop.d.ts +5 -5
  26. package/package.json +1 -1
  27. package/dist/reneco-hierarchized-picker/p-c2b4b61b.system.entry.js +0 -3
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["reneco-hierarchized-picker_2.cjs",[[0,"reneco-hierarchized-picker",{"options":[1],"valueChangeCallback":[16],"disabled":[4],"newoptions":[1],"newfilter":[1],"isDisabled":[32],"componentID":[32],"rawData":[32],"pickerClass":[32],"displayedValue":[32],"value":[32],"shownTree":[32],"searchResultData":[32],"hasFocus":[32],"errorToLog":[32],"getValue":[64],"refreshPicker":[64],"setOptions":[64],"getSearchResult":[64],"filterTree":[64],"clearPicker":[64],"showSelectedNodes":[64]}],[0,"search-input",{"placeholder":[1],"setFocus":[64]}]]]], options);
17
+ return index.bootstrapLazy([["reneco-hierarchized-picker_2.cjs",[[0,"reneco-hierarchized-picker",{"options":[1],"valueChangeCallback":[16],"disabled":[4],"newoptions":[1],"newfilter":[1],"activatedDragAndDrop":[4,"activated-drag-and-drop"],"isDisabled":[32],"componentID":[32],"rawData":[32],"pickerClass":[32],"displayedValue":[32],"value":[32],"shownTree":[32],"searchResultData":[32],"hasFocus":[32],"errorToLog":[32],"getValue":[64],"refreshPicker":[64],"setOptions":[64],"getSearchResult":[64],"filterTree":[64],"clearPicker":[64],"showSelectedNodes":[64]}],[0,"search-input",{"placeholder":[1],"setFocus":[64]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -17,7 +17,7 @@ const patchBrowser = () => {
17
17
  };
18
18
 
19
19
  patchBrowser().then(options => {
20
- return index.bootstrapLazy([["reneco-hierarchized-picker_2.cjs",[[0,"reneco-hierarchized-picker",{"options":[1],"valueChangeCallback":[16],"disabled":[4],"newoptions":[1],"newfilter":[1],"isDisabled":[32],"componentID":[32],"rawData":[32],"pickerClass":[32],"displayedValue":[32],"value":[32],"shownTree":[32],"searchResultData":[32],"hasFocus":[32],"errorToLog":[32],"getValue":[64],"refreshPicker":[64],"setOptions":[64],"getSearchResult":[64],"filterTree":[64],"clearPicker":[64],"showSelectedNodes":[64]}],[0,"search-input",{"placeholder":[1],"setFocus":[64]}]]]], options);
20
+ return index.bootstrapLazy([["reneco-hierarchized-picker_2.cjs",[[0,"reneco-hierarchized-picker",{"options":[1],"valueChangeCallback":[16],"disabled":[4],"newoptions":[1],"newfilter":[1],"activatedDragAndDrop":[4,"activated-drag-and-drop"],"isDisabled":[32],"componentID":[32],"rawData":[32],"pickerClass":[32],"displayedValue":[32],"value":[32],"shownTree":[32],"searchResultData":[32],"hasFocus":[32],"errorToLog":[32],"getValue":[64],"refreshPicker":[64],"setOptions":[64],"getSearchResult":[64],"filterTree":[64],"clearPicker":[64],"showSelectedNodes":[64]}],[0,"search-input",{"placeholder":[1],"setFocus":[64]}]]]], options);
21
21
  });
22
22
 
23
23
  exports.setNonce = index.setNonce;
@@ -52,7 +52,9 @@ const acceptableDelayBetweenSimilarActions = 300;
52
52
  /**
53
53
  * Handles the drag start event.
54
54
  */
55
- function onItemDragStart(el, e) {
55
+ function onItemDragStart(el, e, active = true) {
56
+ if (!active)
57
+ return;
56
58
  curDraggingItem = el;
57
59
  el.classList.add('dragging');
58
60
  e.stopPropagation();
@@ -60,7 +62,9 @@ function onItemDragStart(el, e) {
60
62
  /**
61
63
  * Handles the drag end event.
62
64
  */
63
- function onItemDragEnd(el, e) {
65
+ function onItemDragEnd(el, e, active = true) {
66
+ if (!active)
67
+ return;
64
68
  el.classList.remove('dragging');
65
69
  e.stopPropagation();
66
70
  clearDragOverStyles(el.parentElement);
@@ -68,7 +72,9 @@ function onItemDragEnd(el, e) {
68
72
  /**
69
73
  * Handles the drag over event.
70
74
  */
71
- function onItemDragOver(el, e) {
75
+ function onItemDragOver(el, e, active = true) {
76
+ if (!active)
77
+ return;
72
78
  const now = new Date().getTime();
73
79
  if (now - lastDraggedOverTimeForAscendent < 50 && el.dataset.nodeId !== lastDraggedOverNodeId) {
74
80
  return;
@@ -97,7 +103,9 @@ function onItemDragOver(el, e) {
97
103
  /**
98
104
  * Handles the drag leave event.
99
105
  */
100
- function onItemDragLeave(el, e) {
106
+ function onItemDragLeave(el, e, active = true) {
107
+ if (!active)
108
+ return;
101
109
  clearDragOverStyles(el);
102
110
  el.classList.remove('dragover');
103
111
  e.stopPropagation();
@@ -105,7 +113,9 @@ function onItemDragLeave(el, e) {
105
113
  /**
106
114
  * Handles the drop event.
107
115
  */
108
- function onItemDrop(el, e, dropCallback) {
116
+ function onItemDrop(el, e, active = true, dropCallback) {
117
+ if (!active)
118
+ return;
109
119
  clearDragOverStyles(el);
110
120
  el.classList.remove('dragover');
111
121
  e.stopPropagation();
@@ -281,16 +291,16 @@ Tree.prototype.buildTree = function (nodes, depth) {
281
291
  };
282
292
  Tree.prototype.bindEvent = function (ele) {
283
293
  var _a;
284
- const that = this;
285
294
  if (!this.options.parentApi.isDisabled) {
286
295
  const contextMenu = this.options.parentApi.theOptions.contextMenu;
287
296
  if ((_a = contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.items) === null || _a === void 0 ? void 0 : _a.length) {
288
297
  new VanillaContextMenu(Object.assign(Object.assign({}, contextMenu), { scope: ele, menuItems: contextMenu.items.map(item => {
289
298
  return typeof item === 'string'
290
299
  ? item
291
- : Object.assign(Object.assign({}, item), { callback: e => {
292
- let targetOutput = Object.assign(Object.assign({}, that.nodesById[e.target.nodeId]), { hasChildren: that.nodesById[e.target.nodeId] && that.nodesById[e.target.nodeId].children &&
293
- that.nodesById[e.target.nodeId].children.length && that.nodesById[e.target.nodeId].children.length > 0 });
300
+ : Object.assign(Object.assign({}, item), { callback: async (e) => {
301
+ const pickerValue = await this.options.parentApi.getValue();
302
+ const treeJsNodeInfo = Object.assign({}, this.options.parentApi.loadedTreeJs.nodesById[pickerValue.nodeid]);
303
+ let targetOutput = Object.assign(Object.assign({}, treeJsNodeInfo), { hasChildren: treeJsNodeInfo.children.length > 0 });
294
304
  delete targetOutput.children;
295
305
  this.options.parentApi.onItemContextMenuItemClick(Object.assign(Object.assign({}, e), { target: targetOutput, contextMenuItem: item }));
296
306
  } });
@@ -329,9 +339,11 @@ Tree.prototype.bindEvent = function (ele) {
329
339
  // If source is webservice (it shouldn't be something else)
330
340
  if (this.options.parentApi.theOptions.source == 'webservice') {
331
341
  if (this.options.parentApi.theOptions.origin == 'classification') {
342
+ const contextualApiParams = this.options.parentApi.getContextualApiParams(Object.assign(Object.assign({}, this.options.parentApi.theOptions.options), { startNode: target.parentNode.nodeId }));
343
+ const contextualApiURL = this.options.parentApi.getContextualApiURL();
332
344
  // WS Call
333
345
  this.options.rawDataManager
334
- .getFromClassification(this.options.parentApi.theOptions.url, Object.assign(Object.assign({}, this.options.parentApi.theOptions.options), { startNode: target.parentNode.nodeId }))
346
+ .getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
335
347
  .then(data => {
336
348
  this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
337
349
  });
@@ -343,7 +355,7 @@ Tree.prototype.bindEvent = function (ele) {
343
355
  StartNodeID: target.parentNode.nodeId,
344
356
  lng: this.options.parentApi.theOptions.options.lng,
345
357
  IsDeprecated: this.options.parentApi.theOptions.options.IsDeprecated,
346
- })
358
+ }, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
347
359
  .then(data => {
348
360
  this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
349
361
  });
@@ -633,7 +645,7 @@ Tree.prototype.createUlEle = function () {
633
645
  Tree.prototype.createLiEle = function (node, closed) {
634
646
  const li = document.createElement('li');
635
647
  li.classList.add('treejs-node');
636
- if (node.deprecated) {
648
+ if (node.deprecated || node.Is_Deprecated) {
637
649
  li.classList.add('treejs-node__deprecated');
638
650
  }
639
651
  if (node.isDesaturated) {
@@ -666,19 +678,19 @@ Tree.prototype.createLiEle = function (node, closed) {
666
678
  if (this.options.parentApi.theOptions.dragAndDropEnabled) {
667
679
  li.setAttribute('draggable', 'true');
668
680
  li.addEventListener('dragstart', e => {
669
- onItemDragStart(li, e);
681
+ onItemDragStart(li, e, this.options.parentApi.activatedDragAndDrop);
670
682
  });
671
683
  li.addEventListener('dragend', e => {
672
- onItemDragEnd(li, e);
684
+ onItemDragEnd(li, e, this.options.parentApi.activatedDragAndDrop);
673
685
  });
674
686
  li.addEventListener('dragover', e => {
675
- onItemDragOver(li, e);
687
+ onItemDragOver(li, e, this.options.parentApi.activatedDragAndDrop);
676
688
  });
677
689
  li.addEventListener('dragleave', e => {
678
- onItemDragLeave(li, e);
690
+ onItemDragLeave(li, e, this.options.parentApi.activatedDragAndDrop);
679
691
  });
680
692
  li.addEventListener('drop', e => {
681
- onItemDrop(li, e, (dragEl, dropEl, position) => {
693
+ onItemDrop(li, e, this.options.parentApi.activatedDragAndDrop, (dragEl, dropEl, position) => {
682
694
  this.options.parentApi.itemDropped.emit({ dragEl, dropEl, position });
683
695
  });
684
696
  });
@@ -18182,7 +18194,7 @@ class RawDataManager {
18182
18194
  continue;
18183
18195
  const value = options[key];
18184
18196
  const lowerKey = key.toLowerCase();
18185
- if ((lowerKey === 'startnode' || lowerKey === 'startnodeid') && !pathSegment) {
18197
+ if ((lowerKey === 'startnode') && !pathSegment) {
18186
18198
  pathSegment = encodeURIComponent(value);
18187
18199
  continue; // Skip adding this to the query string
18188
18200
  }
@@ -18269,8 +18281,16 @@ class RawDataManager {
18269
18281
  * Merge new data into the existing data.
18270
18282
  * @param newData New data to merge.
18271
18283
  */
18272
- mergeData(newData) {
18273
- this.rawData = this.genericMerge(this.rawData || {}, newData, 'key', 'children');
18284
+ mergeData(newData, idKey) {
18285
+ if (!this.rawData)
18286
+ this.rawData = newData;
18287
+ else {
18288
+ this.rawData = this.genericMerge(this.rawData, newData, idKey, 'children');
18289
+ }
18290
+ }
18291
+ reorderItems(referenceArray, toReorderArray, idKey) {
18292
+ const idMap = new Map(toReorderArray.map(item => [item[idKey], item]));
18293
+ return referenceArray.map(refItem => idMap.get(refItem[idKey])).filter(Boolean);
18274
18294
  }
18275
18295
  /**
18276
18296
  * Generic merge method.
@@ -18286,9 +18306,11 @@ class RawDataManager {
18286
18306
  }
18287
18307
  if (!toAdd || !((_a = toAdd[childrenKey]) === null || _a === void 0 ? void 0 : _a.length))
18288
18308
  return source;
18309
+ if (source[childrenKey] && source[childrenKey].length > 0 && toAdd[childrenKey] && toAdd[childrenKey].length > 0)
18310
+ toAdd[childrenKey] = this.reorderItems(source[childrenKey], toAdd[childrenKey], idKey);
18289
18311
  source[childrenKey] = ((_b = source[childrenKey]) === null || _b === void 0 ? void 0 : _b.length)
18290
18312
  ? source[childrenKey].map((child, index) => {
18291
- return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[0], idKey, childrenKey);
18313
+ return this.genericMerge(child, toAdd[childrenKey].filter(item => item.key == child.key)[index], idKey, childrenKey);
18292
18314
  })
18293
18315
  : toAdd[childrenKey];
18294
18316
  return source;
@@ -18358,6 +18380,12 @@ class OptionsManager {
18358
18380
  delete this.options.defaultValue;
18359
18381
  }
18360
18382
  }
18383
+ // This method is pretty ugly and shouldn't have to be called, but temporarily works until a better solution is set
18384
+ dropReach() {
18385
+ if (this.options.options && this.options.options.Reach) {
18386
+ delete this.options.options.Reach;
18387
+ }
18388
+ }
18361
18389
  }
18362
18390
 
18363
18391
  /**
@@ -18412,7 +18440,7 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
18412
18440
  const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
18413
18441
  if (myObject && myObject.length) {
18414
18442
  myObject.forEach(value => {
18415
- var _a, _b, _c, _d, _e;
18443
+ var _a, _b, _c, _d;
18416
18444
  let keyPropFromNode = null;
18417
18445
  let valueTranslatedPropFromNode = null;
18418
18446
  let fullpathPropFromNode = null;
@@ -18420,15 +18448,12 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
18420
18448
  if (options.origin == "classification") {
18421
18449
  keyPropFromNode = getPropertyFromNode(value, 'ID');
18422
18450
  valueTranslatedPropFromNode = (_a = getPropertyFromNode(value, 'Translations')[options.language]) === null || _a === void 0 ? void 0 : _a.translated_name;
18423
- // TODO Not sure this is correct in the latest versions, may require review during second half of 2025
18424
- if (searched) {
18425
- fullpathPropFromNode = (_b = getPropertyFromNode(value, 'Properties')) === null || _b === void 0 ? void 0 : _b.System_FullPath;
18426
- fullpathTranslatedPropFromNode = (_c = getPropertyFromNode(value, 'fullpathTranslated')[options.language]) === null || _c === void 0 ? void 0 : _c.translated_fullpath;
18427
- }
18428
- else {
18429
- fullpathPropFromNode = (_d = getPropertyFromNode(value, 'Properties')) === null || _d === void 0 ? void 0 : _d.System_Fullpath;
18430
- fullpathTranslatedPropFromNode = (_e = getPropertyFromNode(value, 'Translations')[options.language]) === null || _e === void 0 ? void 0 : _e.translated_fullpath;
18431
- }
18451
+ fullpathPropFromNode = (_b = getPropertyFromNode(value, 'Properties')) === null || _b === void 0 ? void 0 : _b.System_Fullpath;
18452
+ fullpathTranslatedPropFromNode = (_c = getPropertyFromNode(value, 'Translations')[options.language]) === null || _c === void 0 ? void 0 : _c.translated_fullpath;
18453
+ if (!fullpathPropFromNode)
18454
+ fullpathPropFromNode = (_d = getPropertyFromNode(value, 'Properties')) === null || _d === void 0 ? void 0 : _d.System_FullPath;
18455
+ if (!fullpathTranslatedPropFromNode)
18456
+ fullpathTranslatedPropFromNode = getPropertyFromNode(value, 'fullpathTranslated');
18432
18457
  }
18433
18458
  else {
18434
18459
  keyPropFromNode = getPropertyFromNode(value, 'key');
@@ -18437,7 +18462,9 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
18437
18462
  fullpathTranslatedPropFromNode = getPropertyFromNode(value, 'fullpathTranslated');
18438
18463
  }
18439
18464
  const childrenPropFromNode = getPropertyFromNode(value, 'children', false);
18440
- const deprecated = getPropertyFromNode(value, 'deprecated', false);
18465
+ let deprecated = getPropertyFromNode(value, 'deprecated', null);
18466
+ if (deprecated === null)
18467
+ deprecated = getPropertyFromNode(value, 'Is_Deprecated', false);
18441
18468
  const objToPush = {
18442
18469
  id: keyPropFromNode,
18443
18470
  nodeId: keyPropFromNode,
@@ -18812,7 +18839,10 @@ const HierarchizedPickerComponent = class {
18812
18839
  const isEqual = lodash.isEqual(newV, oldV);
18813
18840
  if (!newV.defaultValue && !oldV.defaultValue)
18814
18841
  return;
18815
- const changeDefaultValue = !(newV.defaultValue.length == oldV.defaultValue.length && newV.defaultValue.every(value => oldV.defaultValue.includes(value)));
18842
+ const newDefault = Array.isArray(newV.defaultValue) ? newV.defaultValue : [newV.defaultValue];
18843
+ const oldDefault = Array.isArray(oldV.defaultValue) ? oldV.defaultValue : [oldV.defaultValue];
18844
+ const changeDefaultValue = newDefault.length !== oldDefault.length ||
18845
+ !newDefault.every(value => oldDefault.includes(value));
18816
18846
  if (!isEqual && changeDefaultValue) {
18817
18847
  return changeDefaultValue;
18818
18848
  }
@@ -18862,6 +18892,7 @@ const HierarchizedPickerComponent = class {
18862
18892
  this.value = [];
18863
18893
  this.shownTree = false;
18864
18894
  this.searchResultData = [];
18895
+ this.activatedDragAndDrop = true;
18865
18896
  this.hasFocus = undefined;
18866
18897
  this.errorToLog = '';
18867
18898
  this.checkFields = this.checkFields.bind(this);
@@ -18906,7 +18937,7 @@ const HierarchizedPickerComponent = class {
18906
18937
  return;
18907
18938
  }
18908
18939
  if (((_a = this.optionsManager.getOptions()) === null || _a === void 0 ? void 0 : _a.loading) == 'display') {
18909
- this.loadDataForTree(true);
18940
+ this.loadDataForTree(true, document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"));
18910
18941
  }
18911
18942
  }
18912
18943
  async initComponent() {
@@ -19096,14 +19127,61 @@ const HierarchizedPickerComponent = class {
19096
19127
  }
19097
19128
  getApiSearchURL() {
19098
19129
  if (this.optionsManager.getOptions().origin == 'classification') {
19099
- let substringUpToLastSlash = this.optionsManager.getOptions().url.substring(0, this.optionsManager.getOptions().url.lastIndexOf('/'));
19100
- let context = substringUpToLastSlash.substring(substringUpToLastSlash.lastIndexOf('/'), substringUpToLastSlash.length);
19101
- return substringUpToLastSlash.substring(0, substringUpToLastSlash.lastIndexOf('/')) + '/search' + context;
19130
+ const baseURL = this.optionsManager.getOptions().url;
19131
+ if (baseURL.indexOf("getTree") > -1) {
19132
+ return baseURL.replace("/getTree/", "/search/");
19133
+ }
19134
+ else {
19135
+ let substringUpToLastSlash = this.optionsManager.getOptions().url.substring(0, this.optionsManager.getOptions().url.lastIndexOf('/'));
19136
+ let context = substringUpToLastSlash.substring(substringUpToLastSlash.lastIndexOf('/'), substringUpToLastSlash.length);
19137
+ return substringUpToLastSlash.substring(0, substringUpToLastSlash.lastIndexOf('/')) + '/search' + context;
19138
+ }
19102
19139
  }
19103
19140
  else {
19104
19141
  return this.optionsManager.getOptions().url.substring(0, this.optionsManager.getOptions().url.lastIndexOf('/')) + '/GetTreeFromSearch';
19105
19142
  }
19106
19143
  }
19144
+ // TODO > Celine would rather like the context (thesaurus or position) to be extracted another way
19145
+ getContextualApiURL() {
19146
+ const { options, url } = this.optionsManager.getOptions();
19147
+ if (options.Reach) {
19148
+ // Use a base URL for relative paths
19149
+ const base = window.location.origin; // fallback for relative URLs
19150
+ const parsedUrl = new URL(url, base);
19151
+ const pathSegments = parsedUrl.pathname.split('/');
19152
+ let dynamicType = pathSegments[pathSegments.length - 2];
19153
+ if (['thesaurus', 'position'].indexOf(dynamicType) == -1)
19154
+ dynamicType = pathSegments[pathSegments.length - 1];
19155
+ const newPathname = `/api/v1/classification/reach/${dynamicType}/${options.Reach}`;
19156
+ this.optionsManager.dropReach();
19157
+ return `${parsedUrl.origin}${newPathname}`;
19158
+ }
19159
+ return url;
19160
+ }
19161
+ getContextualApiParams(options = null, search = null) {
19162
+ if (!options)
19163
+ options = this.optionsManager.getOptions().options;
19164
+ let optionsToReturn = Object.assign({}, options);
19165
+ if (options.Reach) {
19166
+ delete optionsToReturn.Reach;
19167
+ if ("startNode" in optionsToReturn) {
19168
+ optionsToReturn.startingnode = optionsToReturn.startNode;
19169
+ delete optionsToReturn.startNode;
19170
+ }
19171
+ else if ("StartNodeID" in optionsToReturn) {
19172
+ optionsToReturn.startingnode = optionsToReturn.StartNodeID;
19173
+ delete optionsToReturn.StartNodeID;
19174
+ }
19175
+ }
19176
+ else if (search) {
19177
+ optionsToReturn.searchedValue = search;
19178
+ if ("startNode" in optionsToReturn) {
19179
+ optionsToReturn.StartNodeID = optionsToReturn.startNode;
19180
+ delete optionsToReturn.startNode;
19181
+ }
19182
+ }
19183
+ return optionsToReturn;
19184
+ }
19107
19185
  translateDataForTree(dataToLoad, searchID = null, searched = null) {
19108
19186
  if (searched && searched != "") {
19109
19187
  this.loadSearchDataInCurrentTree(searchID, searched);
@@ -19115,11 +19193,11 @@ const HierarchizedPickerComponent = class {
19115
19193
  loadSearchDataInCurrentTree(searchID, searched) {
19116
19194
  let displayResults = (newtree) => {
19117
19195
  if (this.searchToDisplay > -1) { // TODO > Not working anymore after refact, prevents issues in displaying results when running multiple researchs at the same time && searchID == this.searchToDisplay) {
19118
- this.rawDataManager.mergeData(newtree);
19196
+ this.rawDataManager.mergeData(newtree, this.theOptions.origin == 'classification' ? "ID" : "key");
19119
19197
  newtree.children.forEach((value, index) => {
19120
19198
  completeCurrentTreeWithTree(this.loadedTreeJs, value, this.optionsManager.getOptions());
19121
19199
  });
19122
- this.triggerTreeDisplay(this.rawData, searched);
19200
+ this.triggerTreeDisplay(this.rawDataManager.getData(), searched);
19123
19201
  displayAutocompleteWithResults(this.rawDataManager.getData(), searched, this.optionsManager, this.editValue.bind(this), this.showTree.bind(this));
19124
19202
  // Deploys all nodes
19125
19203
  document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node').forEach((item) => {
@@ -19137,9 +19215,7 @@ const HierarchizedPickerComponent = class {
19137
19215
  if (this.theOptions.source == 'webservice') {
19138
19216
  if (this.theOptions.origin == 'classification') {
19139
19217
  // WS Call
19140
- this.rawDataManager.getFromClassification(this.getApiSearchURL(), {
19141
- searchedValue: searched
19142
- })
19218
+ this.rawDataManager.getFromClassification(this.getApiSearchURL(), Object.assign({}, this.getContextualApiParams(null, searched)), document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"))
19143
19219
  .then((data) => {
19144
19220
  displayResults(data);
19145
19221
  if (!searched) {
@@ -19158,7 +19234,7 @@ const HierarchizedPickerComponent = class {
19158
19234
  searchedValue: searched,
19159
19235
  searchNameOnly: true,
19160
19236
  deprecated: false,
19161
- })
19237
+ }, document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"))
19162
19238
  .then((data) => {
19163
19239
  displayResults(data);
19164
19240
  if (!searched) {
@@ -19275,7 +19351,7 @@ const HierarchizedPickerComponent = class {
19275
19351
  onItemContextMenuItemClick(e) {
19276
19352
  this.itemContextMenuItemClick.emit(e);
19277
19353
  }
19278
- async setNodeAsSelected(id, treeToUpdate, userClick) {
19354
+ setNodeAsSelected(id, treeToUpdate, userClick) {
19279
19355
  // TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
19280
19356
  if (((this.isDisabled && this.optionsManager.getOptions().mode != "tree") && this.shownTree && this.setValueOnClick) ||
19281
19357
  (this.loadedTreeJs.liElementsById[id] && this.loadedTreeJs.liElementsById[id].classList.value && this.loadedTreeJs.liElementsById[id].classList.value.indexOf('readonly_node') != -1)) {
@@ -19288,19 +19364,24 @@ const HierarchizedPickerComponent = class {
19288
19364
  // ----- BEGIN -----
19289
19365
  let node = treeToUpdate.nodesById[id];
19290
19366
  let onChange = treeToUpdate.options.onChange;
19291
- if (!node.disabled) {
19292
- treeToUpdate.setValue(id);
19293
- treeToUpdate.updateLiElements();
19367
+ if (!node) {
19368
+ this.logError("The current selected value is not part of the loaded tree!");
19294
19369
  }
19295
- userClick && onChange && onChange.call(treeToUpdate);
19296
- // ------ END ------
19297
- if (this.setValueOnClick) {
19298
- this.editValue(node, userClick);
19299
- if (this.shownTree && userClick) {
19300
- // TODO > is this required ?
19301
- // await focusMainInput(this);
19302
- if (!this.optionsManager.getOptions().multiple) {
19303
- this.showTree('hide');
19370
+ else {
19371
+ if (!node.disabled) {
19372
+ treeToUpdate.setValue(id);
19373
+ treeToUpdate.updateLiElements();
19374
+ }
19375
+ userClick && onChange && onChange.call(treeToUpdate);
19376
+ // ------ END ------
19377
+ if (this.setValueOnClick) {
19378
+ this.editValue(node, userClick);
19379
+ if (this.shownTree && userClick) {
19380
+ // TODO > is this required ?
19381
+ // await focusMainInput(this);
19382
+ if (!this.optionsManager.getOptions().multiple) {
19383
+ this.showTree('hide');
19384
+ }
19304
19385
  }
19305
19386
  }
19306
19387
  }
@@ -19379,6 +19460,11 @@ const HierarchizedPickerComponent = class {
19379
19460
  if (this.hasFocus.indexOf('hide') > -1 && !isStillInsidePicker) {
19380
19461
  this.hasFocus = [];
19381
19462
  }
19463
+ else {
19464
+ if (!this.shownTree && this.theOptions.loading == 'click' && !this.ready) {
19465
+ this.loadDataForTree(true, document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"));
19466
+ }
19467
+ }
19382
19468
  const previousShownTree = this.shownTree;
19383
19469
  this.shownTree = this.hasFocus.length > 0;
19384
19470
  if (this.shownTree && !previousShownTree) {
@@ -19427,12 +19513,13 @@ const HierarchizedPickerComponent = class {
19427
19513
  if (!value)
19428
19514
  value = this.value;
19429
19515
  this.displayedValue = value.map(item => {
19430
- var _a, _b;
19431
- return (_b = (_a = item.fullpathTranslated) !== null && _a !== void 0 ? _a : item.shortpathTranslated) !== null && _b !== void 0 ? _b : `Node ${item.nodeid}`;
19516
+ var _a;
19517
+ return (_a = (this.optionsManager.getOptions().isFullpath ? item.fullpathTranslated : item.shortpathTranslated)) !== null && _a !== void 0 ? _a : `Node ${item.nodeid}`;
19432
19518
  }).join(';');
19433
19519
  }
19434
19520
  // Search a value in the tree and triggers a search when necessary
19435
19521
  search(searched) {
19522
+ this.loader.classList.add('loading');
19436
19523
  let searchinput = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search input');
19437
19524
  if (this.optionsManager.getOptions().mode == 'input' && searchinput) {
19438
19525
  searchinput.classList.remove('fieldError');
@@ -19469,6 +19556,7 @@ const HierarchizedPickerComponent = class {
19469
19556
  // this.checkFields(this.value, false);
19470
19557
  this.setSearchResults([]);
19471
19558
  }
19559
+ this.loader.classList.remove('loading');
19472
19560
  }
19473
19561
  // Refresh the tree with search results
19474
19562
  triggerSearch(searched) {
@@ -19487,7 +19575,9 @@ const HierarchizedPickerComponent = class {
19487
19575
  loadDataForTree(init, loader) {
19488
19576
  if (this.optionsManager.getOptions().source == 'webservice') {
19489
19577
  if (this.optionsManager.getOptions().origin == 'classification') {
19490
- this.rawDataManager.getFromClassification(this.optionsManager.getOptions().url, this.optionsManager.getOptions().options, loader).then((data) => {
19578
+ const contextualApiParams = this.getContextualApiParams();
19579
+ const contextualApiURL = this.getContextualApiURL();
19580
+ this.rawDataManager.getFromClassification(contextualApiURL, contextualApiParams, loader).then((data) => {
19491
19581
  this.rawData = data;
19492
19582
  if (init) {
19493
19583
  this.formatDefaultValue();
@@ -19631,7 +19721,9 @@ const HierarchizedPickerComponent = class {
19631
19721
  this.scrollable = el;
19632
19722
  }, class: 'hierarchized-picker-modal-area ' + (!this.shownTree ? ' hidden ' : ''), onClick: event => {
19633
19723
  clickPickerModalArea(this);
19634
- } }, index.h("div", { class: 'hierarchized-picker-modal ' + (!this.ready ? 'hidden' : '') }, index.h("search-input", { placeholder: getLanguageValue(this.optionsManager.getOptions().searchPlaceholder, this.optionsManager.getOptions().language, defaultLanguage), onInputFocus: () => focusInSearchEvent(this), onInputBlur: () => focusOutSearchEvent(this, event), onSearch: (event) => this.search(event.detail) }), index.h("ul", { id: "autocomplete-results-area" }), index.h("div", { id: 'tree-area-' + this.componentID, class: 'hierarchized-picker-tree hierarchized-picker-tree-area ' + this.pickerClass }))))) : (index.h("div", { class: 'hierarchized-picker-raw-tree-area' + (this.isDisabled ? ' readonly' : ''), onClick: event => {
19724
+ } }, index.h("div", { class: "loader", ref: el => {
19725
+ this.loader = el;
19726
+ } }, index.h("div", { class: "loader-inner" }, "Loading...")), index.h("div", { class: 'hierarchized-picker-modal ' + (!this.ready ? 'hidden' : '') }, index.h("search-input", { placeholder: getLanguageValue(this.optionsManager.getOptions().searchPlaceholder, this.optionsManager.getOptions().language, defaultLanguage), onInputFocus: () => focusInSearchEvent(this), onInputBlur: () => focusOutSearchEvent(this, event), onSearch: (event) => this.search(event.detail) }), index.h("ul", { id: "autocomplete-results-area" }), index.h("div", { id: 'tree-area-' + this.componentID, class: 'hierarchized-picker-tree hierarchized-picker-tree-area ' + this.pickerClass }))))) : (index.h("div", { class: 'hierarchized-picker-raw-tree-area' + (this.isDisabled ? ' readonly' : ''), onClick: event => {
19635
19727
  clickPickerModalArea(this);
19636
19728
  } }, index.h("div", { class: "loader", ref: el => {
19637
19729
  this.loader = el;