reneco-hierarchized-picker 0.4.2-beta.9 → 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 (28) 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 +147 -56
  4. package/dist/collection/components/hierarchized-picker/hierarchized-picker.js +111 -28
  5. package/dist/collection/components/treejs/index.js +10 -9
  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 +148 -57
  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 +147 -56
  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-a0b09a0d.entry.js +1 -0
  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 +3 -0
  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-3b063318.entry.js +0 -1
  28. package/dist/reneco-hierarchized-picker/p-f29100a4.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();
@@ -290,7 +300,6 @@ Tree.prototype.bindEvent = function (ele) {
290
300
  : Object.assign(Object.assign({}, item), { callback: async (e) => {
291
301
  const pickerValue = await this.options.parentApi.getValue();
292
302
  const treeJsNodeInfo = Object.assign({}, this.options.parentApi.loadedTreeJs.nodesById[pickerValue.nodeid]);
293
- console.log("---- HELLO ", pickerValue, treeJsNodeInfo);
294
303
  let targetOutput = Object.assign(Object.assign({}, treeJsNodeInfo), { hasChildren: treeJsNodeInfo.children.length > 0 });
295
304
  delete targetOutput.children;
296
305
  this.options.parentApi.onItemContextMenuItemClick(Object.assign(Object.assign({}, e), { target: targetOutput, contextMenuItem: item }));
@@ -330,9 +339,11 @@ Tree.prototype.bindEvent = function (ele) {
330
339
  // If source is webservice (it shouldn't be something else)
331
340
  if (this.options.parentApi.theOptions.source == 'webservice') {
332
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();
333
344
  // WS Call
334
345
  this.options.rawDataManager
335
- .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"))
336
347
  .then(data => {
337
348
  this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
338
349
  });
@@ -344,7 +355,7 @@ Tree.prototype.bindEvent = function (ele) {
344
355
  StartNodeID: target.parentNode.nodeId,
345
356
  lng: this.options.parentApi.theOptions.options.lng,
346
357
  IsDeprecated: this.options.parentApi.theOptions.options.IsDeprecated,
347
- })
358
+ }, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
348
359
  .then(data => {
349
360
  this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
350
361
  });
@@ -634,7 +645,7 @@ Tree.prototype.createUlEle = function () {
634
645
  Tree.prototype.createLiEle = function (node, closed) {
635
646
  const li = document.createElement('li');
636
647
  li.classList.add('treejs-node');
637
- if (node.deprecated) {
648
+ if (node.deprecated || node.Is_Deprecated) {
638
649
  li.classList.add('treejs-node__deprecated');
639
650
  }
640
651
  if (node.isDesaturated) {
@@ -667,19 +678,19 @@ Tree.prototype.createLiEle = function (node, closed) {
667
678
  if (this.options.parentApi.theOptions.dragAndDropEnabled) {
668
679
  li.setAttribute('draggable', 'true');
669
680
  li.addEventListener('dragstart', e => {
670
- onItemDragStart(li, e);
681
+ onItemDragStart(li, e, this.options.parentApi.activatedDragAndDrop);
671
682
  });
672
683
  li.addEventListener('dragend', e => {
673
- onItemDragEnd(li, e);
684
+ onItemDragEnd(li, e, this.options.parentApi.activatedDragAndDrop);
674
685
  });
675
686
  li.addEventListener('dragover', e => {
676
- onItemDragOver(li, e);
687
+ onItemDragOver(li, e, this.options.parentApi.activatedDragAndDrop);
677
688
  });
678
689
  li.addEventListener('dragleave', e => {
679
- onItemDragLeave(li, e);
690
+ onItemDragLeave(li, e, this.options.parentApi.activatedDragAndDrop);
680
691
  });
681
692
  li.addEventListener('drop', e => {
682
- onItemDrop(li, e, (dragEl, dropEl, position) => {
693
+ onItemDrop(li, e, this.options.parentApi.activatedDragAndDrop, (dragEl, dropEl, position) => {
683
694
  this.options.parentApi.itemDropped.emit({ dragEl, dropEl, position });
684
695
  });
685
696
  });
@@ -18183,7 +18194,7 @@ class RawDataManager {
18183
18194
  continue;
18184
18195
  const value = options[key];
18185
18196
  const lowerKey = key.toLowerCase();
18186
- if ((lowerKey === 'startnode' || lowerKey === 'startnodeid') && !pathSegment) {
18197
+ if ((lowerKey === 'startnode') && !pathSegment) {
18187
18198
  pathSegment = encodeURIComponent(value);
18188
18199
  continue; // Skip adding this to the query string
18189
18200
  }
@@ -18270,8 +18281,16 @@ class RawDataManager {
18270
18281
  * Merge new data into the existing data.
18271
18282
  * @param newData New data to merge.
18272
18283
  */
18273
- mergeData(newData) {
18274
- 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);
18275
18294
  }
18276
18295
  /**
18277
18296
  * Generic merge method.
@@ -18287,9 +18306,11 @@ class RawDataManager {
18287
18306
  }
18288
18307
  if (!toAdd || !((_a = toAdd[childrenKey]) === null || _a === void 0 ? void 0 : _a.length))
18289
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);
18290
18311
  source[childrenKey] = ((_b = source[childrenKey]) === null || _b === void 0 ? void 0 : _b.length)
18291
18312
  ? source[childrenKey].map((child, index) => {
18292
- 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);
18293
18314
  })
18294
18315
  : toAdd[childrenKey];
18295
18316
  return source;
@@ -18359,6 +18380,12 @@ class OptionsManager {
18359
18380
  delete this.options.defaultValue;
18360
18381
  }
18361
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
+ }
18362
18389
  }
18363
18390
 
18364
18391
  /**
@@ -18413,7 +18440,7 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
18413
18440
  const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
18414
18441
  if (myObject && myObject.length) {
18415
18442
  myObject.forEach(value => {
18416
- var _a, _b, _c, _d, _e;
18443
+ var _a, _b, _c, _d;
18417
18444
  let keyPropFromNode = null;
18418
18445
  let valueTranslatedPropFromNode = null;
18419
18446
  let fullpathPropFromNode = null;
@@ -18421,15 +18448,12 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
18421
18448
  if (options.origin == "classification") {
18422
18449
  keyPropFromNode = getPropertyFromNode(value, 'ID');
18423
18450
  valueTranslatedPropFromNode = (_a = getPropertyFromNode(value, 'Translations')[options.language]) === null || _a === void 0 ? void 0 : _a.translated_name;
18424
- // TODO Not sure this is correct in the latest versions, may require review during second half of 2025
18425
- if (searched) {
18426
- fullpathPropFromNode = (_b = getPropertyFromNode(value, 'Properties')) === null || _b === void 0 ? void 0 : _b.System_FullPath;
18427
- fullpathTranslatedPropFromNode = (_c = getPropertyFromNode(value, 'fullpathTranslated')[options.language]) === null || _c === void 0 ? void 0 : _c.translated_fullpath;
18428
- }
18429
- else {
18430
- fullpathPropFromNode = (_d = getPropertyFromNode(value, 'Properties')) === null || _d === void 0 ? void 0 : _d.System_Fullpath;
18431
- fullpathTranslatedPropFromNode = (_e = getPropertyFromNode(value, 'Translations')[options.language]) === null || _e === void 0 ? void 0 : _e.translated_fullpath;
18432
- }
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');
18433
18457
  }
18434
18458
  else {
18435
18459
  keyPropFromNode = getPropertyFromNode(value, 'key');
@@ -18438,7 +18462,9 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
18438
18462
  fullpathTranslatedPropFromNode = getPropertyFromNode(value, 'fullpathTranslated');
18439
18463
  }
18440
18464
  const childrenPropFromNode = getPropertyFromNode(value, 'children', false);
18441
- const deprecated = getPropertyFromNode(value, 'deprecated', false);
18465
+ let deprecated = getPropertyFromNode(value, 'deprecated', null);
18466
+ if (deprecated === null)
18467
+ deprecated = getPropertyFromNode(value, 'Is_Deprecated', false);
18442
18468
  const objToPush = {
18443
18469
  id: keyPropFromNode,
18444
18470
  nodeId: keyPropFromNode,
@@ -18813,7 +18839,10 @@ const HierarchizedPickerComponent = class {
18813
18839
  const isEqual = lodash.isEqual(newV, oldV);
18814
18840
  if (!newV.defaultValue && !oldV.defaultValue)
18815
18841
  return;
18816
- 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));
18817
18846
  if (!isEqual && changeDefaultValue) {
18818
18847
  return changeDefaultValue;
18819
18848
  }
@@ -18863,6 +18892,7 @@ const HierarchizedPickerComponent = class {
18863
18892
  this.value = [];
18864
18893
  this.shownTree = false;
18865
18894
  this.searchResultData = [];
18895
+ this.activatedDragAndDrop = true;
18866
18896
  this.hasFocus = undefined;
18867
18897
  this.errorToLog = '';
18868
18898
  this.checkFields = this.checkFields.bind(this);
@@ -18907,7 +18937,7 @@ const HierarchizedPickerComponent = class {
18907
18937
  return;
18908
18938
  }
18909
18939
  if (((_a = this.optionsManager.getOptions()) === null || _a === void 0 ? void 0 : _a.loading) == 'display') {
18910
- this.loadDataForTree(true);
18940
+ this.loadDataForTree(true, document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"));
18911
18941
  }
18912
18942
  }
18913
18943
  async initComponent() {
@@ -19097,14 +19127,61 @@ const HierarchizedPickerComponent = class {
19097
19127
  }
19098
19128
  getApiSearchURL() {
19099
19129
  if (this.optionsManager.getOptions().origin == 'classification') {
19100
- let substringUpToLastSlash = this.optionsManager.getOptions().url.substring(0, this.optionsManager.getOptions().url.lastIndexOf('/'));
19101
- let context = substringUpToLastSlash.substring(substringUpToLastSlash.lastIndexOf('/'), substringUpToLastSlash.length);
19102
- 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
+ }
19103
19139
  }
19104
19140
  else {
19105
19141
  return this.optionsManager.getOptions().url.substring(0, this.optionsManager.getOptions().url.lastIndexOf('/')) + '/GetTreeFromSearch';
19106
19142
  }
19107
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
+ }
19108
19185
  translateDataForTree(dataToLoad, searchID = null, searched = null) {
19109
19186
  if (searched && searched != "") {
19110
19187
  this.loadSearchDataInCurrentTree(searchID, searched);
@@ -19116,11 +19193,11 @@ const HierarchizedPickerComponent = class {
19116
19193
  loadSearchDataInCurrentTree(searchID, searched) {
19117
19194
  let displayResults = (newtree) => {
19118
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) {
19119
- this.rawDataManager.mergeData(newtree);
19196
+ this.rawDataManager.mergeData(newtree, this.theOptions.origin == 'classification' ? "ID" : "key");
19120
19197
  newtree.children.forEach((value, index) => {
19121
19198
  completeCurrentTreeWithTree(this.loadedTreeJs, value, this.optionsManager.getOptions());
19122
19199
  });
19123
- this.triggerTreeDisplay(this.rawData, searched);
19200
+ this.triggerTreeDisplay(this.rawDataManager.getData(), searched);
19124
19201
  displayAutocompleteWithResults(this.rawDataManager.getData(), searched, this.optionsManager, this.editValue.bind(this), this.showTree.bind(this));
19125
19202
  // Deploys all nodes
19126
19203
  document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node').forEach((item) => {
@@ -19138,9 +19215,7 @@ const HierarchizedPickerComponent = class {
19138
19215
  if (this.theOptions.source == 'webservice') {
19139
19216
  if (this.theOptions.origin == 'classification') {
19140
19217
  // WS Call
19141
- this.rawDataManager.getFromClassification(this.getApiSearchURL(), {
19142
- searchedValue: searched
19143
- })
19218
+ this.rawDataManager.getFromClassification(this.getApiSearchURL(), Object.assign({}, this.getContextualApiParams(null, searched)), document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"))
19144
19219
  .then((data) => {
19145
19220
  displayResults(data);
19146
19221
  if (!searched) {
@@ -19159,7 +19234,7 @@ const HierarchizedPickerComponent = class {
19159
19234
  searchedValue: searched,
19160
19235
  searchNameOnly: true,
19161
19236
  deprecated: false,
19162
- })
19237
+ }, document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"))
19163
19238
  .then((data) => {
19164
19239
  displayResults(data);
19165
19240
  if (!searched) {
@@ -19289,19 +19364,24 @@ const HierarchizedPickerComponent = class {
19289
19364
  // ----- BEGIN -----
19290
19365
  let node = treeToUpdate.nodesById[id];
19291
19366
  let onChange = treeToUpdate.options.onChange;
19292
- if (!node.disabled) {
19293
- treeToUpdate.setValue(id);
19294
- treeToUpdate.updateLiElements();
19367
+ if (!node) {
19368
+ this.logError("The current selected value is not part of the loaded tree!");
19295
19369
  }
19296
- userClick && onChange && onChange.call(treeToUpdate);
19297
- // ------ END ------
19298
- if (this.setValueOnClick) {
19299
- this.editValue(node, userClick);
19300
- if (this.shownTree && userClick) {
19301
- // TODO > is this required ?
19302
- // await focusMainInput(this);
19303
- if (!this.optionsManager.getOptions().multiple) {
19304
- 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
+ }
19305
19385
  }
19306
19386
  }
19307
19387
  }
@@ -19380,6 +19460,11 @@ const HierarchizedPickerComponent = class {
19380
19460
  if (this.hasFocus.indexOf('hide') > -1 && !isStillInsidePicker) {
19381
19461
  this.hasFocus = [];
19382
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
+ }
19383
19468
  const previousShownTree = this.shownTree;
19384
19469
  this.shownTree = this.hasFocus.length > 0;
19385
19470
  if (this.shownTree && !previousShownTree) {
@@ -19428,12 +19513,13 @@ const HierarchizedPickerComponent = class {
19428
19513
  if (!value)
19429
19514
  value = this.value;
19430
19515
  this.displayedValue = value.map(item => {
19431
- var _a, _b;
19432
- 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}`;
19433
19518
  }).join(';');
19434
19519
  }
19435
19520
  // Search a value in the tree and triggers a search when necessary
19436
19521
  search(searched) {
19522
+ this.loader.classList.add('loading');
19437
19523
  let searchinput = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search input');
19438
19524
  if (this.optionsManager.getOptions().mode == 'input' && searchinput) {
19439
19525
  searchinput.classList.remove('fieldError');
@@ -19470,6 +19556,7 @@ const HierarchizedPickerComponent = class {
19470
19556
  // this.checkFields(this.value, false);
19471
19557
  this.setSearchResults([]);
19472
19558
  }
19559
+ this.loader.classList.remove('loading');
19473
19560
  }
19474
19561
  // Refresh the tree with search results
19475
19562
  triggerSearch(searched) {
@@ -19488,7 +19575,9 @@ const HierarchizedPickerComponent = class {
19488
19575
  loadDataForTree(init, loader) {
19489
19576
  if (this.optionsManager.getOptions().source == 'webservice') {
19490
19577
  if (this.optionsManager.getOptions().origin == 'classification') {
19491
- 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) => {
19492
19581
  this.rawData = data;
19493
19582
  if (init) {
19494
19583
  this.formatDefaultValue();
@@ -19632,7 +19721,9 @@ const HierarchizedPickerComponent = class {
19632
19721
  this.scrollable = el;
19633
19722
  }, class: 'hierarchized-picker-modal-area ' + (!this.shownTree ? ' hidden ' : ''), onClick: event => {
19634
19723
  clickPickerModalArea(this);
19635
- } }, 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 => {
19636
19727
  clickPickerModalArea(this);
19637
19728
  } }, index.h("div", { class: "loader", ref: el => {
19638
19729
  this.loader = el;