reneco-hierarchized-picker 0.4.3-beta.14 → 0.4.3-beta.15

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.
@@ -18619,19 +18619,6 @@ function handleFocusEvent(component, type) {
18619
18619
  component.showTree('hide');
18620
18620
  }
18621
18621
  }
18622
- function manageFocusOut(component, event) {
18623
- const relatedTarget = event.relatedTarget;
18624
- if (!isInsidePicker(component, relatedTarget)) {
18625
- setTimeout(() => {
18626
- if (!isInsidePicker(component, document.activeElement)) {
18627
- handleFocusEvent(component, 'hide');
18628
- }
18629
- }, 100);
18630
- }
18631
- else {
18632
- handleFocusEvent(component, 'search');
18633
- }
18634
- }
18635
18622
  function clickPickerModalArea(component, _event) {
18636
18623
  if (component.pickerClass === 'fieldError') {
18637
18624
  component.showTree('hide');
@@ -18648,7 +18635,6 @@ function focusInSearchEvent(component) {
18648
18635
  handleFocusEvent(component, 'search');
18649
18636
  }
18650
18637
  function focusOutSearchEvent(component, event) {
18651
- manageFocusOut(component, event);
18652
18638
  }
18653
18639
 
18654
18640
  let focusedNodeIndex = 0;
@@ -18939,27 +18925,30 @@ const HierarchizedPickerComponent = class {
18939
18925
  this.getShortenedFullpath = (realFullpath) => {
18940
18926
  var _a, _b, _c, _d;
18941
18927
  let toret = realFullpath;
18942
- try {
18943
- const property_nodeid = (this.optionsManager.getOptions().origin == 'classification' ? "startNode" : "StartNodeID");
18944
- const property_value = this.optionsManager.getOptions().options[property_nodeid];
18945
- if (property_value in ["0", 0])
18946
- return toret;
18947
- if (isNumeric(property_value)) {
18948
- if (this.optionsManager.getOptions().origin == 'classification') {
18949
- const { Translations, Properties } = this.rawDataManager.getData();
18950
- const currentLanguage = this.optionsManager.getOptions().language;
18951
- toret = ((_b = (_a = Translations[currentLanguage]) === null || _a === void 0 ? void 0 : _a.translated_name) !== null && _b !== void 0 ? _b : Properties === null || Properties === void 0 ? void 0 : Properties.System_Name) + realFullpath.replace(((_d = (_c = Translations[currentLanguage]) === null || _c === void 0 ? void 0 : _c.translated_fullpath) !== null && _d !== void 0 ? _d : Properties === null || Properties === void 0 ? void 0 : Properties.System_Fullpath), "");
18952
- }
18953
- else {
18954
- const { fullpath, fullpathTranslated, title, valueTranslated } = this.rawDataManager.getData();
18955
- toret = (valueTranslated !== null && valueTranslated !== void 0 ? valueTranslated : title) + realFullpath.replace((fullpathTranslated !== null && fullpathTranslated !== void 0 ? fullpathTranslated : fullpath), "");
18928
+ const rdmdata = this.rawDataManager.getData();
18929
+ if (rdmdata) {
18930
+ try {
18931
+ const property_nodeid = (this.optionsManager.getOptions().origin == 'classification' ? "startNode" : "StartNodeID");
18932
+ const property_value = this.optionsManager.getOptions().options[property_nodeid];
18933
+ if (property_value in ["0", 0])
18934
+ return toret;
18935
+ if (isNumeric(property_value)) {
18936
+ if (this.optionsManager.getOptions().origin == 'classification') {
18937
+ const { Translations, Properties } = rdmdata;
18938
+ const currentLanguage = this.optionsManager.getOptions().language;
18939
+ toret = ((_b = (_a = Translations[currentLanguage]) === null || _a === void 0 ? void 0 : _a.translated_name) !== null && _b !== void 0 ? _b : Properties === null || Properties === void 0 ? void 0 : Properties.System_Name) + realFullpath.replace(((_d = (_c = Translations[currentLanguage]) === null || _c === void 0 ? void 0 : _c.translated_fullpath) !== null && _d !== void 0 ? _d : Properties === null || Properties === void 0 ? void 0 : Properties.System_Fullpath), "");
18940
+ }
18941
+ else {
18942
+ const { fullpath, fullpathTranslated, title, valueTranslated } = rdmdata;
18943
+ toret = (valueTranslated !== null && valueTranslated !== void 0 ? valueTranslated : title) + realFullpath.replace((fullpathTranslated !== null && fullpathTranslated !== void 0 ? fullpathTranslated : fullpath), "");
18944
+ }
18956
18945
  }
18946
+ else
18947
+ this.errorToLog = "Error in getFullpath : startnode is not number";
18948
+ }
18949
+ catch (error) {
18950
+ this.errorToLog = "Error in getFullpath " + error.toString();
18957
18951
  }
18958
- else
18959
- this.errorToLog = "Error in getFullpath : startnode is not number";
18960
- }
18961
- catch (error) {
18962
- this.errorToLog = "Error in getFullpath " + error.toString();
18963
18952
  }
18964
18953
  return toret;
18965
18954
  };
@@ -19237,14 +19226,14 @@ const HierarchizedPickerComponent = class {
19237
19226
  getContextualApiURL(init = false) {
19238
19227
  const { options, url } = this.optionsManager.getOptions();
19239
19228
  if (init && options.Reach) {
19240
- // Use a base URL for relative paths
19241
- const base = window.location.origin; // fallback for relative URLs
19229
+ const base = window.location.origin;
19242
19230
  const parsedUrl = new URL(url, base);
19243
- const pathSegments = parsedUrl.pathname.split('/');
19244
- let dynamicType = pathSegments[pathSegments.length - 2];
19245
- if (['thesaurus', 'position'].indexOf(dynamicType) == -1)
19246
- dynamicType = pathSegments[pathSegments.length - 1];
19247
- const newPathname = `/api/v1/classification/reach/${dynamicType}`;
19231
+ const pathSegments = parsedUrl.pathname.split('/').filter(Boolean);
19232
+ const idx = pathSegments.indexOf("getTree");
19233
+ if (idx !== -1) {
19234
+ pathSegments[idx] = "reach";
19235
+ }
19236
+ const newPathname = "/" + pathSegments.join("/");
19248
19237
  return `${parsedUrl.origin}${newPathname}`;
19249
19238
  }
19250
19239
  return url;
@@ -19583,9 +19572,12 @@ const HierarchizedPickerComponent = class {
19583
19572
  return item.nodeid == node.id;
19584
19573
  });
19585
19574
  // If the passed node already exists in the array of values, remove it
19586
- if (userClick && result > -1) {
19587
- this.value.splice(result, 1);
19588
- } // Else, add the node to the array of values
19575
+ if (result > -1) {
19576
+ if (userClick)
19577
+ this.value.splice(result, 1);
19578
+ else
19579
+ return;
19580
+ }
19589
19581
  else {
19590
19582
  if (this.optionsManager.getOptions().multiple) {
19591
19583
  this.value = [
@@ -19614,10 +19606,11 @@ const HierarchizedPickerComponent = class {
19614
19606
  setDisplayedValue(value = null) {
19615
19607
  if (!value)
19616
19608
  value = this.value;
19617
- this.displayedValue = value.map(item => {
19609
+ const toDisplay = value.map(item => {
19618
19610
  var _a, _b;
19619
19611
  return (_b = (this.optionsManager.getOptions().isFullpath ? this.getShortenedFullpath((_a = item.fullpathTranslated) !== null && _a !== void 0 ? _a : item.fullpath) : item.shortpathTranslated)) !== null && _b !== void 0 ? _b : `Node ${item.nodeid}`;
19620
19612
  }).join(';');
19613
+ this.displayedValue = toDisplay;
19621
19614
  }
19622
19615
  // Search a value in the tree and triggers a search when necessary
19623
19616
  search(searched) {
@@ -19684,6 +19677,7 @@ const HierarchizedPickerComponent = class {
19684
19677
  if (init) {
19685
19678
  this.formatDefaultValue();
19686
19679
  this.showSelectedNodes();
19680
+ this.checkFields(this.value);
19687
19681
  }
19688
19682
  })
19689
19683
  .catch(error => {
@@ -19749,8 +19743,19 @@ const HierarchizedPickerComponent = class {
19749
19743
  formatDefaultValue() {
19750
19744
  let found = 0;
19751
19745
  let that = this;
19746
+ let fieldsToCheck = [];
19747
+ function addToFieldsToCheck(item) {
19748
+ if (Array.isArray(item)) {
19749
+ item.forEach(el => addToFieldsToCheck(el));
19750
+ }
19751
+ else {
19752
+ const exists = fieldsToCheck.some(el => (el.nodeid || el.ID) == (item.nodeid || item.ID));
19753
+ if (!exists) {
19754
+ fieldsToCheck.push(item);
19755
+ }
19756
+ }
19757
+ }
19752
19758
  let recursive = function (children) {
19753
- //158424
19754
19759
  children.forEach(element => {
19755
19760
  that.theOptions.defaultValue.forEach(dfValue => {
19756
19761
  if (typeof dfValue == 'string' && isNumeric(dfValue)) {
@@ -19760,7 +19765,7 @@ const HierarchizedPickerComponent = class {
19760
19765
  if ((typeof dfValue == 'string' && getPropertyFromNode(element, 'Properties').FullPath == dfValue) ||
19761
19766
  (typeof dfValue == 'number' && getPropertyFromNode(element, 'ID') == dfValue)) {
19762
19767
  element.nodeid = element.id;
19763
- that.checkFields([element]);
19768
+ addToFieldsToCheck([element]);
19764
19769
  found++;
19765
19770
  }
19766
19771
  }
@@ -19770,7 +19775,7 @@ const HierarchizedPickerComponent = class {
19770
19775
  (typeof dfValue == 'string' && getPropertyFromNode(element, 'fullpathTranslated') == dfValue) ||
19771
19776
  (typeof dfValue == 'number' && getPropertyFromNode(element, 'key') == dfValue)) {
19772
19777
  element.nodeid = element.key;
19773
- that.checkFields([element]);
19778
+ addToFieldsToCheck([element]);
19774
19779
  found++;
19775
19780
  }
19776
19781
  }
@@ -19782,6 +19787,7 @@ const HierarchizedPickerComponent = class {
19782
19787
  if (this.rawDataManager.getData()) {
19783
19788
  recursive([this.rawDataManager.getData()]);
19784
19789
  }
19790
+ that.checkFields(fieldsToCheck);
19785
19791
  if (this.theOptions.defaultValue.length != found) {
19786
19792
  if (found == 0) {
19787
19793
  try {
@@ -200,27 +200,30 @@ export class HierarchizedPickerComponent {
200
200
  this.getShortenedFullpath = (realFullpath) => {
201
201
  var _a, _b, _c, _d;
202
202
  let toret = realFullpath;
203
- try {
204
- const property_nodeid = (this.optionsManager.getOptions().origin == 'classification' ? "startNode" : "StartNodeID");
205
- const property_value = this.optionsManager.getOptions().options[property_nodeid];
206
- if (property_value in ["0", 0])
207
- return toret;
208
- if (isNumeric(property_value)) {
209
- if (this.optionsManager.getOptions().origin == 'classification') {
210
- const { Translations, Properties } = this.rawDataManager.getData();
211
- const currentLanguage = this.optionsManager.getOptions().language;
212
- toret = ((_b = (_a = Translations[currentLanguage]) === null || _a === void 0 ? void 0 : _a.translated_name) !== null && _b !== void 0 ? _b : Properties === null || Properties === void 0 ? void 0 : Properties.System_Name) + realFullpath.replace(((_d = (_c = Translations[currentLanguage]) === null || _c === void 0 ? void 0 : _c.translated_fullpath) !== null && _d !== void 0 ? _d : Properties === null || Properties === void 0 ? void 0 : Properties.System_Fullpath), "");
213
- }
214
- else {
215
- const { fullpath, fullpathTranslated, title, valueTranslated } = this.rawDataManager.getData();
216
- toret = (valueTranslated !== null && valueTranslated !== void 0 ? valueTranslated : title) + realFullpath.replace((fullpathTranslated !== null && fullpathTranslated !== void 0 ? fullpathTranslated : fullpath), "");
203
+ const rdmdata = this.rawDataManager.getData();
204
+ if (rdmdata) {
205
+ try {
206
+ const property_nodeid = (this.optionsManager.getOptions().origin == 'classification' ? "startNode" : "StartNodeID");
207
+ const property_value = this.optionsManager.getOptions().options[property_nodeid];
208
+ if (property_value in ["0", 0])
209
+ return toret;
210
+ if (isNumeric(property_value)) {
211
+ if (this.optionsManager.getOptions().origin == 'classification') {
212
+ const { Translations, Properties } = rdmdata;
213
+ const currentLanguage = this.optionsManager.getOptions().language;
214
+ toret = ((_b = (_a = Translations[currentLanguage]) === null || _a === void 0 ? void 0 : _a.translated_name) !== null && _b !== void 0 ? _b : Properties === null || Properties === void 0 ? void 0 : Properties.System_Name) + realFullpath.replace(((_d = (_c = Translations[currentLanguage]) === null || _c === void 0 ? void 0 : _c.translated_fullpath) !== null && _d !== void 0 ? _d : Properties === null || Properties === void 0 ? void 0 : Properties.System_Fullpath), "");
215
+ }
216
+ else {
217
+ const { fullpath, fullpathTranslated, title, valueTranslated } = rdmdata;
218
+ toret = (valueTranslated !== null && valueTranslated !== void 0 ? valueTranslated : title) + realFullpath.replace((fullpathTranslated !== null && fullpathTranslated !== void 0 ? fullpathTranslated : fullpath), "");
219
+ }
217
220
  }
221
+ else
222
+ this.errorToLog = "Error in getFullpath : startnode is not number";
223
+ }
224
+ catch (error) {
225
+ this.errorToLog = "Error in getFullpath " + error.toString();
218
226
  }
219
- else
220
- this.errorToLog = "Error in getFullpath : startnode is not number";
221
- }
222
- catch (error) {
223
- this.errorToLog = "Error in getFullpath " + error.toString();
224
227
  }
225
228
  return toret;
226
229
  };
@@ -501,14 +504,14 @@ export class HierarchizedPickerComponent {
501
504
  getContextualApiURL(init = false) {
502
505
  const { options, url } = this.optionsManager.getOptions();
503
506
  if (init && options.Reach) {
504
- // Use a base URL for relative paths
505
- const base = window.location.origin; // fallback for relative URLs
507
+ const base = window.location.origin;
506
508
  const parsedUrl = new URL(url, base);
507
- const pathSegments = parsedUrl.pathname.split('/');
508
- let dynamicType = pathSegments[pathSegments.length - 2];
509
- if (['thesaurus', 'position'].indexOf(dynamicType) == -1)
510
- dynamicType = pathSegments[pathSegments.length - 1];
511
- const newPathname = `/api/v1/classification/reach/${dynamicType}`;
509
+ const pathSegments = parsedUrl.pathname.split('/').filter(Boolean);
510
+ const idx = pathSegments.indexOf("getTree");
511
+ if (idx !== -1) {
512
+ pathSegments[idx] = "reach";
513
+ }
514
+ const newPathname = "/" + pathSegments.join("/");
512
515
  return `${parsedUrl.origin}${newPathname}`;
513
516
  }
514
517
  return url;
@@ -847,9 +850,12 @@ export class HierarchizedPickerComponent {
847
850
  return item.nodeid == node.id;
848
851
  });
849
852
  // If the passed node already exists in the array of values, remove it
850
- if (userClick && result > -1) {
851
- this.value.splice(result, 1);
852
- } // Else, add the node to the array of values
853
+ if (result > -1) {
854
+ if (userClick)
855
+ this.value.splice(result, 1);
856
+ else
857
+ return;
858
+ }
853
859
  else {
854
860
  if (this.optionsManager.getOptions().multiple) {
855
861
  this.value = [
@@ -878,10 +884,11 @@ export class HierarchizedPickerComponent {
878
884
  setDisplayedValue(value = null) {
879
885
  if (!value)
880
886
  value = this.value;
881
- this.displayedValue = value.map(item => {
887
+ const toDisplay = value.map(item => {
882
888
  var _a, _b;
883
889
  return (_b = (this.optionsManager.getOptions().isFullpath ? this.getShortenedFullpath((_a = item.fullpathTranslated) !== null && _a !== void 0 ? _a : item.fullpath) : item.shortpathTranslated)) !== null && _b !== void 0 ? _b : `Node ${item.nodeid}`;
884
890
  }).join(';');
891
+ this.displayedValue = toDisplay;
885
892
  }
886
893
  // Search a value in the tree and triggers a search when necessary
887
894
  search(searched) {
@@ -948,6 +955,7 @@ export class HierarchizedPickerComponent {
948
955
  if (init) {
949
956
  this.formatDefaultValue();
950
957
  this.showSelectedNodes();
958
+ this.checkFields(this.value);
951
959
  }
952
960
  })
953
961
  .catch(error => {
@@ -1013,8 +1021,19 @@ export class HierarchizedPickerComponent {
1013
1021
  formatDefaultValue() {
1014
1022
  let found = 0;
1015
1023
  let that = this;
1024
+ let fieldsToCheck = [];
1025
+ function addToFieldsToCheck(item) {
1026
+ if (Array.isArray(item)) {
1027
+ item.forEach(el => addToFieldsToCheck(el));
1028
+ }
1029
+ else {
1030
+ const exists = fieldsToCheck.some(el => (el.nodeid || el.ID) == (item.nodeid || item.ID));
1031
+ if (!exists) {
1032
+ fieldsToCheck.push(item);
1033
+ }
1034
+ }
1035
+ }
1016
1036
  let recursive = function (children) {
1017
- //158424
1018
1037
  children.forEach(element => {
1019
1038
  that.theOptions.defaultValue.forEach(dfValue => {
1020
1039
  if (typeof dfValue == 'string' && isNumeric(dfValue)) {
@@ -1024,7 +1043,7 @@ export class HierarchizedPickerComponent {
1024
1043
  if ((typeof dfValue == 'string' && getPropertyFromNode(element, 'Properties').FullPath == dfValue) ||
1025
1044
  (typeof dfValue == 'number' && getPropertyFromNode(element, 'ID') == dfValue)) {
1026
1045
  element.nodeid = element.id;
1027
- that.checkFields([element]);
1046
+ addToFieldsToCheck([element]);
1028
1047
  found++;
1029
1048
  }
1030
1049
  }
@@ -1034,7 +1053,7 @@ export class HierarchizedPickerComponent {
1034
1053
  (typeof dfValue == 'string' && getPropertyFromNode(element, 'fullpathTranslated') == dfValue) ||
1035
1054
  (typeof dfValue == 'number' && getPropertyFromNode(element, 'key') == dfValue)) {
1036
1055
  element.nodeid = element.key;
1037
- that.checkFields([element]);
1056
+ addToFieldsToCheck([element]);
1038
1057
  found++;
1039
1058
  }
1040
1059
  }
@@ -1046,6 +1065,7 @@ export class HierarchizedPickerComponent {
1046
1065
  if (this.rawDataManager.getData()) {
1047
1066
  recursive([this.rawDataManager.getData()]);
1048
1067
  }
1068
+ that.checkFields(fieldsToCheck);
1049
1069
  if (this.theOptions.defaultValue.length != found) {
1050
1070
  if (found == 0) {
1051
1071
  try {
@@ -36,17 +36,17 @@ export function handleFocusEvent(component, type) {
36
36
  }
37
37
  }
38
38
  export function manageFocusOut(component, event) {
39
- const relatedTarget = event.relatedTarget;
40
- if (!isInsidePicker(component, relatedTarget)) {
41
- setTimeout(() => {
42
- if (!isInsidePicker(component, document.activeElement)) {
43
- handleFocusEvent(component, 'hide');
44
- }
45
- }, 100);
46
- }
47
- else {
48
- handleFocusEvent(component, 'search');
49
- }
39
+ // TODO > REVIEW THIS, IT SEEMS TO PREVENT PROPER FOCUS MANAGEMENT RATHER THAN IMPROVING IT
40
+ // const relatedTarget = (event.relatedTarget || event.target) as HTMLElement;
41
+ // if (!isInsidePicker(component, relatedTarget)) {
42
+ // setTimeout(() => {
43
+ // if (!isInsidePicker(component, document.activeElement)) {
44
+ // handleFocusEvent(component, 'hide');
45
+ // }
46
+ // }, 100);
47
+ // } else {
48
+ // handleFocusEvent(component, 'search');
49
+ // }
50
50
  }
51
51
  export function clickPickerModalArea(component, _event) {
52
52
  if (component.pickerClass === 'fieldError') {
@@ -18616,19 +18616,6 @@ function handleFocusEvent(component, type) {
18616
18616
  component.showTree('hide');
18617
18617
  }
18618
18618
  }
18619
- function manageFocusOut(component, event) {
18620
- const relatedTarget = event.relatedTarget;
18621
- if (!isInsidePicker(component, relatedTarget)) {
18622
- setTimeout(() => {
18623
- if (!isInsidePicker(component, document.activeElement)) {
18624
- handleFocusEvent(component, 'hide');
18625
- }
18626
- }, 100);
18627
- }
18628
- else {
18629
- handleFocusEvent(component, 'search');
18630
- }
18631
- }
18632
18619
  function clickPickerModalArea(component, _event) {
18633
18620
  if (component.pickerClass === 'fieldError') {
18634
18621
  component.showTree('hide');
@@ -18645,7 +18632,6 @@ function focusInSearchEvent(component) {
18645
18632
  handleFocusEvent(component, 'search');
18646
18633
  }
18647
18634
  function focusOutSearchEvent(component, event) {
18648
- manageFocusOut(component, event);
18649
18635
  }
18650
18636
 
18651
18637
  let focusedNodeIndex = 0;
@@ -18937,27 +18923,30 @@ const HierarchizedPickerComponent = class extends HTMLElement {
18937
18923
  this.getShortenedFullpath = (realFullpath) => {
18938
18924
  var _a, _b, _c, _d;
18939
18925
  let toret = realFullpath;
18940
- try {
18941
- const property_nodeid = (this.optionsManager.getOptions().origin == 'classification' ? "startNode" : "StartNodeID");
18942
- const property_value = this.optionsManager.getOptions().options[property_nodeid];
18943
- if (property_value in ["0", 0])
18944
- return toret;
18945
- if (isNumeric(property_value)) {
18946
- if (this.optionsManager.getOptions().origin == 'classification') {
18947
- const { Translations, Properties } = this.rawDataManager.getData();
18948
- const currentLanguage = this.optionsManager.getOptions().language;
18949
- toret = ((_b = (_a = Translations[currentLanguage]) === null || _a === void 0 ? void 0 : _a.translated_name) !== null && _b !== void 0 ? _b : Properties === null || Properties === void 0 ? void 0 : Properties.System_Name) + realFullpath.replace(((_d = (_c = Translations[currentLanguage]) === null || _c === void 0 ? void 0 : _c.translated_fullpath) !== null && _d !== void 0 ? _d : Properties === null || Properties === void 0 ? void 0 : Properties.System_Fullpath), "");
18950
- }
18951
- else {
18952
- const { fullpath, fullpathTranslated, title, valueTranslated } = this.rawDataManager.getData();
18953
- toret = (valueTranslated !== null && valueTranslated !== void 0 ? valueTranslated : title) + realFullpath.replace((fullpathTranslated !== null && fullpathTranslated !== void 0 ? fullpathTranslated : fullpath), "");
18926
+ const rdmdata = this.rawDataManager.getData();
18927
+ if (rdmdata) {
18928
+ try {
18929
+ const property_nodeid = (this.optionsManager.getOptions().origin == 'classification' ? "startNode" : "StartNodeID");
18930
+ const property_value = this.optionsManager.getOptions().options[property_nodeid];
18931
+ if (property_value in ["0", 0])
18932
+ return toret;
18933
+ if (isNumeric(property_value)) {
18934
+ if (this.optionsManager.getOptions().origin == 'classification') {
18935
+ const { Translations, Properties } = rdmdata;
18936
+ const currentLanguage = this.optionsManager.getOptions().language;
18937
+ toret = ((_b = (_a = Translations[currentLanguage]) === null || _a === void 0 ? void 0 : _a.translated_name) !== null && _b !== void 0 ? _b : Properties === null || Properties === void 0 ? void 0 : Properties.System_Name) + realFullpath.replace(((_d = (_c = Translations[currentLanguage]) === null || _c === void 0 ? void 0 : _c.translated_fullpath) !== null && _d !== void 0 ? _d : Properties === null || Properties === void 0 ? void 0 : Properties.System_Fullpath), "");
18938
+ }
18939
+ else {
18940
+ const { fullpath, fullpathTranslated, title, valueTranslated } = rdmdata;
18941
+ toret = (valueTranslated !== null && valueTranslated !== void 0 ? valueTranslated : title) + realFullpath.replace((fullpathTranslated !== null && fullpathTranslated !== void 0 ? fullpathTranslated : fullpath), "");
18942
+ }
18954
18943
  }
18944
+ else
18945
+ this.errorToLog = "Error in getFullpath : startnode is not number";
18946
+ }
18947
+ catch (error) {
18948
+ this.errorToLog = "Error in getFullpath " + error.toString();
18955
18949
  }
18956
- else
18957
- this.errorToLog = "Error in getFullpath : startnode is not number";
18958
- }
18959
- catch (error) {
18960
- this.errorToLog = "Error in getFullpath " + error.toString();
18961
18950
  }
18962
18951
  return toret;
18963
18952
  };
@@ -19235,14 +19224,14 @@ const HierarchizedPickerComponent = class extends HTMLElement {
19235
19224
  getContextualApiURL(init = false) {
19236
19225
  const { options, url } = this.optionsManager.getOptions();
19237
19226
  if (init && options.Reach) {
19238
- // Use a base URL for relative paths
19239
- const base = window.location.origin; // fallback for relative URLs
19227
+ const base = window.location.origin;
19240
19228
  const parsedUrl = new URL(url, base);
19241
- const pathSegments = parsedUrl.pathname.split('/');
19242
- let dynamicType = pathSegments[pathSegments.length - 2];
19243
- if (['thesaurus', 'position'].indexOf(dynamicType) == -1)
19244
- dynamicType = pathSegments[pathSegments.length - 1];
19245
- const newPathname = `/api/v1/classification/reach/${dynamicType}`;
19229
+ const pathSegments = parsedUrl.pathname.split('/').filter(Boolean);
19230
+ const idx = pathSegments.indexOf("getTree");
19231
+ if (idx !== -1) {
19232
+ pathSegments[idx] = "reach";
19233
+ }
19234
+ const newPathname = "/" + pathSegments.join("/");
19246
19235
  return `${parsedUrl.origin}${newPathname}`;
19247
19236
  }
19248
19237
  return url;
@@ -19581,9 +19570,12 @@ const HierarchizedPickerComponent = class extends HTMLElement {
19581
19570
  return item.nodeid == node.id;
19582
19571
  });
19583
19572
  // If the passed node already exists in the array of values, remove it
19584
- if (userClick && result > -1) {
19585
- this.value.splice(result, 1);
19586
- } // Else, add the node to the array of values
19573
+ if (result > -1) {
19574
+ if (userClick)
19575
+ this.value.splice(result, 1);
19576
+ else
19577
+ return;
19578
+ }
19587
19579
  else {
19588
19580
  if (this.optionsManager.getOptions().multiple) {
19589
19581
  this.value = [
@@ -19612,10 +19604,11 @@ const HierarchizedPickerComponent = class extends HTMLElement {
19612
19604
  setDisplayedValue(value = null) {
19613
19605
  if (!value)
19614
19606
  value = this.value;
19615
- this.displayedValue = value.map(item => {
19607
+ const toDisplay = value.map(item => {
19616
19608
  var _a, _b;
19617
19609
  return (_b = (this.optionsManager.getOptions().isFullpath ? this.getShortenedFullpath((_a = item.fullpathTranslated) !== null && _a !== void 0 ? _a : item.fullpath) : item.shortpathTranslated)) !== null && _b !== void 0 ? _b : `Node ${item.nodeid}`;
19618
19610
  }).join(';');
19611
+ this.displayedValue = toDisplay;
19619
19612
  }
19620
19613
  // Search a value in the tree and triggers a search when necessary
19621
19614
  search(searched) {
@@ -19682,6 +19675,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
19682
19675
  if (init) {
19683
19676
  this.formatDefaultValue();
19684
19677
  this.showSelectedNodes();
19678
+ this.checkFields(this.value);
19685
19679
  }
19686
19680
  })
19687
19681
  .catch(error => {
@@ -19747,8 +19741,19 @@ const HierarchizedPickerComponent = class extends HTMLElement {
19747
19741
  formatDefaultValue() {
19748
19742
  let found = 0;
19749
19743
  let that = this;
19744
+ let fieldsToCheck = [];
19745
+ function addToFieldsToCheck(item) {
19746
+ if (Array.isArray(item)) {
19747
+ item.forEach(el => addToFieldsToCheck(el));
19748
+ }
19749
+ else {
19750
+ const exists = fieldsToCheck.some(el => (el.nodeid || el.ID) == (item.nodeid || item.ID));
19751
+ if (!exists) {
19752
+ fieldsToCheck.push(item);
19753
+ }
19754
+ }
19755
+ }
19750
19756
  let recursive = function (children) {
19751
- //158424
19752
19757
  children.forEach(element => {
19753
19758
  that.theOptions.defaultValue.forEach(dfValue => {
19754
19759
  if (typeof dfValue == 'string' && isNumeric(dfValue)) {
@@ -19758,7 +19763,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
19758
19763
  if ((typeof dfValue == 'string' && getPropertyFromNode(element, 'Properties').FullPath == dfValue) ||
19759
19764
  (typeof dfValue == 'number' && getPropertyFromNode(element, 'ID') == dfValue)) {
19760
19765
  element.nodeid = element.id;
19761
- that.checkFields([element]);
19766
+ addToFieldsToCheck([element]);
19762
19767
  found++;
19763
19768
  }
19764
19769
  }
@@ -19768,7 +19773,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
19768
19773
  (typeof dfValue == 'string' && getPropertyFromNode(element, 'fullpathTranslated') == dfValue) ||
19769
19774
  (typeof dfValue == 'number' && getPropertyFromNode(element, 'key') == dfValue)) {
19770
19775
  element.nodeid = element.key;
19771
- that.checkFields([element]);
19776
+ addToFieldsToCheck([element]);
19772
19777
  found++;
19773
19778
  }
19774
19779
  }
@@ -19780,6 +19785,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
19780
19785
  if (this.rawDataManager.getData()) {
19781
19786
  recursive([this.rawDataManager.getData()]);
19782
19787
  }
19788
+ that.checkFields(fieldsToCheck);
19783
19789
  if (this.theOptions.defaultValue.length != found) {
19784
19790
  if (found == 0) {
19785
19791
  try {