reneco-hierarchized-picker 0.2.2-classifications → 0.2.3

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.
@@ -4,55 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-55df525c.js');
6
6
 
7
- function ajax(_options) {
8
- const defaultOptions = {
9
- method: 'GET',
10
- url: '',
11
- async: true,
12
- success: null,
13
- failed: null,
14
- 'Content-Type': 'application/json; charset=utf-8',
15
- };
16
- const options = Object.assign(defaultOptions, _options);
17
- const xhr = new XMLHttpRequest();
18
-
19
- const postData = Object.entries(options.data)
20
- .reduce((acc, [key, value]) => {
21
- acc.push(`${key}=${value}`);
22
- return acc;
23
- }, [])
24
- .join('&');
25
-
26
- if (options.method.toUpperCase() === 'POST') {
27
- xhr.open(options.method, options.url, options.async);
28
- xhr.setRequestHeader('Content-Type', options['Content-Type']);
29
- xhr.send(postData);
30
- } else if (options.method.toUpperCase() === 'GET') {
31
- let {url} = options;
32
- if (postData) {
33
- if (url.indexOf('?') !== -1) {
34
- url += `&${postData}`;
35
- } else {
36
- url += `&${postData}`;
37
- }
38
- }
39
- xhr.open(options.method, url, options.async);
40
- xhr.setRequestHeader('Content-Type', options['Content-Type']);
41
- xhr.send(null);
42
- }
43
- xhr.onreadystatechange = function() {
44
- if (xhr.readyState === 4 && xhr.status === 200) {
45
- let res = xhr.responseText;
46
- if (options['Content-Type'] === defaultOptions['Content-Type']) {
47
- res = JSON.parse(res);
48
- }
49
- options.success && options.success(res);
50
- } else {
51
- options.failed && options.failed(xhr.status);
52
- }
53
- };
54
- }
55
-
56
7
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
57
8
 
58
9
  function getDefaultExportFromCjs (x) {
@@ -83,7 +34,6 @@ const VanillaContextMenu = /*@__PURE__*/getDefaultExportFromCjs(vanillaContextMe
83
34
  function deepClone(obj) {
84
35
  return JSON.parse(JSON.stringify(obj));
85
36
  }
86
-
87
37
  function uniq(arr) {
88
38
  const map = {};
89
39
  return arr.reduce((acc, item) => {
@@ -94,13 +44,13 @@ function uniq(arr) {
94
44
  return acc;
95
45
  }, []);
96
46
  }
97
-
98
47
  function empty(ele) {
99
- while (ele.firstChild) {
100
- ele.removeChild(ele.firstChild);
48
+ if (ele && ele.firstChild) {
49
+ while (ele.firstChild) {
50
+ ele.removeChild(ele.firstChild);
51
+ }
101
52
  }
102
53
  }
103
-
104
54
  function animation(duration, callback) {
105
55
  requestAnimationFrame(() => {
106
56
  callback.enter();
@@ -112,7 +62,6 @@ function animation(duration, callback) {
112
62
  });
113
63
  });
114
64
  }
115
-
116
65
  function Tree(container, options) {
117
66
  const defaultOptions = {
118
67
  selectMode: 'checkbox',
@@ -131,7 +80,6 @@ function Tree(container, options) {
131
80
  this.willUpdateNodesById = {};
132
81
  this.container = container;
133
82
  this.options = Object.assign(defaultOptions, options);
134
-
135
83
  Object.defineProperties(this, {
136
84
  values: {
137
85
  get() {
@@ -179,58 +127,39 @@ function Tree(container, options) {
179
127
  },
180
128
  },
181
129
  });
182
-
183
- if (this.options.url) {
184
- this.load(data => {
185
- this.init(data);
186
- });
187
- } else {
188
- this.init(this.options.data);
189
- }
130
+ this.init(this.options.data);
190
131
  }
191
-
192
132
  Tree.prototype.init = function (data) {
193
- console.time('init');
194
133
  let { treeNodes, nodesById, leafNodesById, defaultValues, defaultDisables } = Tree.parseTreeData(data);
195
134
  this.treeNodes = treeNodes;
196
135
  this.nodesById = nodesById;
197
136
  this.leafNodesById = leafNodesById;
198
137
  this.render(this.treeNodes);
199
138
  const { values, disables, loaded } = this.options;
200
- if (values && values.length) defaultValues = values;
139
+ if (values && values.length)
140
+ defaultValues = values;
201
141
  defaultValues.length && this.setValues(defaultValues);
202
- if (disables && disables.length) defaultDisables = disables;
142
+ if (disables && disables.length)
143
+ defaultDisables = disables;
203
144
  defaultDisables.length && this.setDisables(defaultDisables);
204
145
  loaded && loaded.call(this);
205
- console.timeEnd('init');
206
146
  };
207
-
208
- Tree.prototype.load = function (callback) {
209
- console.time('load');
210
- const { url, method, beforeLoad } = this.options;
211
- ajax({
212
- url,
213
- method,
214
- success: result => {
215
- let data = result;
216
- console.timeEnd('load');
217
- if (beforeLoad) {
218
- data = beforeLoad(result);
219
- }
220
- callback(data);
221
- },
222
- });
223
- };
224
-
225
147
  Tree.prototype.render = function (treeNodes) {
226
148
  const treeEle = Tree.createRootEle();
227
149
  treeEle.appendChild(this.buildTree(treeNodes, 0));
228
150
  this.bindEvent(treeEle);
229
- const ele = document.querySelector(this.container);
230
- empty(ele);
231
- ele.appendChild(treeEle);
151
+ let ele = null;
152
+ try {
153
+ ele = document.querySelector(this.container);
154
+ }
155
+ catch (_a) {
156
+ ele = this.container;
157
+ }
158
+ if (ele) {
159
+ empty(ele);
160
+ ele.appendChild(treeEle);
161
+ }
232
162
  };
233
-
234
163
  Tree.prototype.buildTree = function (nodes, depth) {
235
164
  const rootUlEle = this.createUlEle();
236
165
  if (nodes && nodes.length) {
@@ -247,102 +176,100 @@ Tree.prototype.buildTree = function (nodes, depth) {
247
176
  }
248
177
  return rootUlEle;
249
178
  };
250
-
251
179
  Tree.prototype.bindEvent = function (ele) {
180
+ var _a;
181
+ // let parentOptions:any = {};
182
+ // try{
183
+ // parentOptions = JSON.parse(this.options.parentApi.theOptions);
184
+ // }
185
+ // catch {
186
+ // parentOptions = this.options.parentApi.theOptions;
187
+ // }
188
+ // @ts-ignore
252
189
  function getLi(target) {
253
190
  return target.classList.contains('treejs-node') ? target : target.closest('.treejs-node');
254
191
  }
255
- const contextMenu = this.options.parentApi.options.contextMenu;
256
- if (contextMenu?.items?.length) {
257
- new VanillaContextMenu({
258
- ...contextMenu,
259
- scope: ele,
260
- menuItems: contextMenu.items.map(item => {
261
- return typeof item === 'string'
262
- ? item
263
- : {
264
- ...item,
265
- callback: e => {
192
+ if (!this.options.parentApi.isDisabled) {
193
+ const contextMenu = this.options.parentApi.theOptions.contextMenu;
194
+ if ((_a = contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.items) === null || _a === void 0 ? void 0 : _a.length) {
195
+ new VanillaContextMenu(Object.assign(Object.assign({}, contextMenu), { scope: ele, menuItems: contextMenu.items.map(item => {
196
+ return typeof item === 'string'
197
+ ? item
198
+ : Object.assign(Object.assign({}, item), { callback: e => {
266
199
  const target = getLi(e.target);
267
- this.options.parentApi.onItemContextMenuItemClick({ ...e, target, contextMenuItem: item });
268
- },
269
- };
270
- }),
271
- });
200
+ this.options.parentApi.onItemContextMenuItemClick(Object.assign(Object.assign({}, e), { target, contextMenuItem: item }));
201
+ } });
202
+ }) }));
203
+ }
272
204
  }
273
- ele.addEventListener(
274
- 'click',
275
- e => {
276
- const { target } = e;
277
- if (target.nodeName === 'SPAN' && (target.classList.contains('treejs-checkbox') || target.classList.contains('treejs-label'))) {
278
- this.onItemClick(target.parentNode.nodeId);
279
- } else if (target.nodeName === 'LI' && target.classList.contains('treejs-node')) {
280
- this.onItemClick(target.nodeId);
281
- } else if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher')) {
282
- this.onSwitcherClick(target);
283
- }
284
-
285
- //CUSTOM
286
- const childspans = Array.prototype.slice.call(e.target.parentNode.querySelectorAll(':scope > ul > li > span'));
287
- let hasUndefinedchild = [];
288
-
289
- //This may be a problem the day a node value is "undefined"
290
- hasUndefinedchild = childspans.filter(ele => {
291
- return ele.textContent === 'undefined';
292
- });
293
-
294
- // If the user clicked on an unloaded node
295
- if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher') && hasUndefinedchild.length > 0) {
296
- // Clear the subnode HTML
297
- e.target.parentNode.querySelector('ul').innerHTML = '';
298
-
299
- // If source is webservice (it shouldn't be something else)
300
- if (this.options.parentApi.options.source == 'webservice') {
301
-
302
- if (this.options.parentApi.options.origin == 'classification') {
205
+ ele.addEventListener('click', e => {
206
+ const { target } = e;
207
+ if (target.nodeName === 'SPAN' && (target.classList.contains('treejs-checkbox') || target.classList.contains('treejs-label'))) {
208
+ this.onItemClick(target.parentNode.nodeId);
209
+ }
210
+ else if (target.nodeName === 'LI' && target.classList.contains('treejs-node')) {
211
+ this.onItemClick(target.nodeId);
212
+ }
213
+ else if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher')) {
214
+ this.onSwitcherClick(target);
215
+ }
216
+ //CUSTOM
217
+ const childspans = Array.prototype.slice.call(e.target.parentNode.querySelectorAll('ul > li > span.treejs-label')).filter((ele) => {
218
+ return ele.parentNode.parentNode.parentNode === e.target.parentNode;
219
+ });
220
+ let hasUndefinedchild = [];
221
+ //This may be a problem the day a node value is "undefined"
222
+ hasUndefinedchild = childspans.filter(ele => {
223
+ return ele.textContent === 'undefined';
224
+ });
225
+ // If the user clicked on an unloaded node
226
+ if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher') && hasUndefinedchild.length > 0) {
227
+ // Clear the subnode HTML
228
+ e.target.parentNode.querySelector('ul').innerHTML = '';
229
+ // If source is webservice (it shouldn't be something else)
230
+ if (this.options.parentApi.theOptions.source == 'webservice') {
231
+ if (this.options.parentApi.theOptions.origin == 'classification') {
303
232
  // WS Call
304
233
  this.options.parentApi
305
- .getDataFromSourceClassification(this.options.parentApi.options.url, {
306
- startNode: target.parentNode.nodeId
307
- })
234
+ .getDataFromSourceClassification(this.options.parentApi.theOptions.url, {
235
+ startNode: target.parentNode.nodeId
236
+ })
308
237
  .then(data => {
309
- debugger;
310
- this.options.parentApi.completeCurrentTreeWithTree(data, target.parentNode.nodeId);
311
- });
312
- }
313
- else {
314
- // WS Call
315
- this.options.parentApi
316
- .getDataFromSource(this.options.parentApi.options.url, {
317
- StartNodeID: target.parentNode.nodeId,
318
- lng: this.options.parentApi.options.options.lng,
319
- IsDeprecated: this.options.parentApi.options.options.IsDeprecated,
320
- })
321
- .then(data => {
322
- this.options.parentApi.completeCurrentTreeWithTree(data, target.parentNode.nodeId);
323
- });
324
- }
238
+ this.options.parentApi.completeCurrentTreeWithTree(data, target.parentNode.nodeId);
239
+ });
240
+ }
241
+ else {
242
+ // WS Call
243
+ this.options.parentApi
244
+ .getDataFromSource(this.options.parentApi.theOptions.url, {
245
+ StartNodeID: target.parentNode.nodeId,
246
+ lng: this.options.parentApi.theOptions.options.lng,
247
+ IsDeprecated: this.options.parentApi.theOptions.options.IsDeprecated,
248
+ })
249
+ .then(data => {
250
+ this.options.parentApi.completeCurrentTreeWithTree(data);
251
+ });
325
252
  }
326
-
327
- this.onSwitcherClick(target);
328
253
  }
329
- },
330
- false,
331
- );
254
+ this.onSwitcherClick(target);
255
+ }
256
+ }, false);
332
257
  };
333
-
334
258
  Tree.prototype.onItemClick = function (id) {
259
+ if (this.options.parentApi.isDisabled)
260
+ return;
261
+ if (!this.options.parentApi.theOptions.multiple)
262
+ this.emptyNodesCheckStatus();
335
263
  this.options.parentApi.setNodeAsSelected(id, this, true);
336
264
  };
337
-
338
- Tree.prototype.unCheckElement = id => {
339
- undefined.setValue(id);
340
- undefined.updateLiElements();
265
+ Tree.prototype.unCheckElement = function (id) {
266
+ this.setValue(id);
267
+ this.updateLiElements();
341
268
  };
342
-
343
269
  Tree.prototype.setValue = function (value) {
344
270
  const node = this.nodesById[value];
345
- if (!node) return;
271
+ if (!node)
272
+ return;
346
273
  const childrenStatus = getChildrenStatus(node);
347
274
  const prevStatus = node.status;
348
275
  let status = null;
@@ -350,7 +277,8 @@ Tree.prototype.setValue = function (value) {
350
277
  if (childrenStatus) {
351
278
  status = prevStatus === 1 ? 2 : 1;
352
279
  // No child selected default comportement
353
- } else {
280
+ }
281
+ else {
354
282
  status = prevStatus === 1 || prevStatus === 2 ? 0 : 2;
355
283
  }
356
284
  node.status = status;
@@ -358,17 +286,16 @@ Tree.prototype.setValue = function (value) {
358
286
  this.walkUp(node, 'status');
359
287
  this.walkDown(node, 'status');
360
288
  };
361
-
362
289
  function getChildrenStatus(node) {
363
290
  if (node.children && node.children.length) {
364
291
  const childrenChecked = node.children.reduce((acc, child) => {
365
- if (!isNaN(child.status)) return acc + child.status;
292
+ if (!isNaN(child.status))
293
+ return acc + child.status;
366
294
  return acc;
367
295
  }, 0);
368
296
  return childrenChecked;
369
297
  }
370
298
  }
371
-
372
299
  Tree.prototype.getValues = function () {
373
300
  const values = [];
374
301
  for (let id in this.leafNodesById) {
@@ -380,7 +307,6 @@ Tree.prototype.getValues = function () {
380
307
  }
381
308
  return values;
382
309
  };
383
-
384
310
  Tree.prototype.setValues = function (values) {
385
311
  this.emptyNodesCheckStatus();
386
312
  values.forEach(value => {
@@ -390,10 +316,10 @@ Tree.prototype.setValues = function (values) {
390
316
  const { onChange } = this.options;
391
317
  onChange && onChange.call(this);
392
318
  };
393
-
394
319
  Tree.prototype.setDisable = function (value) {
395
320
  const node = this.nodesById[value];
396
- if (!node) return;
321
+ if (!node)
322
+ return;
397
323
  const prevDisabled = node.disabled;
398
324
  if (!prevDisabled) {
399
325
  node.disabled = true;
@@ -402,7 +328,6 @@ Tree.prototype.setDisable = function (value) {
402
328
  this.walkDown(node, 'disabled');
403
329
  }
404
330
  };
405
-
406
331
  Tree.prototype.getDisables = function () {
407
332
  const values = [];
408
333
  for (let id in this.leafNodesById) {
@@ -414,7 +339,6 @@ Tree.prototype.getDisables = function () {
414
339
  }
415
340
  return values;
416
341
  };
417
-
418
342
  Tree.prototype.setDisables = function (values) {
419
343
  this.emptyNodesDisable();
420
344
  values.forEach(value => {
@@ -422,21 +346,19 @@ Tree.prototype.setDisables = function (values) {
422
346
  });
423
347
  this.updateLiElements();
424
348
  };
425
-
426
349
  Tree.prototype.emptyNodesCheckStatus = function () {
427
350
  this.willUpdateNodesById = this.getSelectedNodesById();
428
- Object.values(this.willUpdateNodesById).forEach(node => {
429
- if (!node.disabled) node.status = 0;
351
+ Object.values(this.willUpdateNodesById).forEach((node) => {
352
+ if (!node.disabled)
353
+ node.status = 0;
430
354
  });
431
355
  };
432
-
433
356
  Tree.prototype.emptyNodesDisable = function () {
434
357
  this.willUpdateNodesById = this.getDisabledNodesById();
435
- Object.values(this.willUpdateNodesById).forEach(node => {
358
+ Object.values(this.willUpdateNodesById).forEach((node) => {
436
359
  node.disabled = false;
437
360
  });
438
361
  };
439
-
440
362
  Tree.prototype.getSelectedNodesById = function () {
441
363
  return Object.entries(this.nodesById).reduce((acc, [id, node]) => {
442
364
  if (node.status === 1 || node.status === 2) {
@@ -445,7 +367,6 @@ Tree.prototype.getSelectedNodesById = function () {
445
367
  return acc;
446
368
  }, {});
447
369
  };
448
-
449
370
  Tree.prototype.getDisabledNodesById = function () {
450
371
  return Object.entries(this.nodesById).reduce((acc, [id, node]) => {
451
372
  if (node.disabled) {
@@ -454,18 +375,15 @@ Tree.prototype.getDisabledNodesById = function () {
454
375
  return acc;
455
376
  }, {});
456
377
  };
457
-
458
378
  Tree.prototype.updateLiElements = function () {
459
379
  Object.values(this.willUpdateNodesById).forEach(node => {
460
380
  this.updateLiElement(node);
461
381
  });
462
382
  this.willUpdateNodesById = {};
463
383
  };
464
-
465
384
  Tree.prototype.markWillUpdateNode = function (node) {
466
385
  this.willUpdateNodesById[node.id] = node;
467
386
  };
468
-
469
387
  Tree.prototype.onSwitcherClick = function (target) {
470
388
  const liEle = target.parentNode;
471
389
  const ele = liEle.lastChild;
@@ -486,7 +404,8 @@ Tree.prototype.onSwitcherClick = function (target) {
486
404
  liEle.classList.remove('treejs-node__close');
487
405
  },
488
406
  });
489
- } else {
407
+ }
408
+ else {
490
409
  animation(150, {
491
410
  enter() {
492
411
  ele.style.height = `${height}px`;
@@ -504,7 +423,6 @@ Tree.prototype.onSwitcherClick = function (target) {
504
423
  });
505
424
  }
506
425
  };
507
-
508
426
  Tree.prototype.walkUp = function (node, changeState) {
509
427
  const { parent } = node;
510
428
  if (parent) {
@@ -512,33 +430,39 @@ Tree.prototype.walkUp = function (node, changeState) {
512
430
  let pStatus = null;
513
431
  // reduce status of selected children
514
432
  const statusCount = parent.children.reduce((acc, child) => {
515
- if (!isNaN(child.status)) return acc + child.status;
433
+ if (!isNaN(child.status))
434
+ return acc + child.status;
516
435
  return acc;
517
436
  }, 0);
518
437
  // at least one child selected or halfchecked (status 1)
519
438
  if (statusCount) {
520
439
  // at least one child selected and parent is selected : status 2 else 1
521
440
  pStatus = statusCount >= 2 && parent.status === 2 ? 2 : 1;
522
- } else {
441
+ }
442
+ else {
523
443
  pStatus = 0;
524
444
  }
525
- if (parent.status === pStatus || parent.status === 2) return;
445
+ if (parent.status === pStatus || parent.status === 2)
446
+ return;
526
447
  parent.status = pStatus;
527
448
  if (parent.parent) {
528
- parent.parent.children.find(item => item.id === parent.id).status = pStatus;
449
+ let parentparentchild = parent.parent.children.find(item => item.id === parent.id);
450
+ if (parentparentchild) {
451
+ parentparentchild.status = pStatus;
452
+ }
529
453
  }
530
- } else {
454
+ }
455
+ else {
531
456
  const pDisabled = parent.children.reduce((acc, child) => acc && child.disabled, true);
532
- if (parent.disabled === pDisabled) return;
457
+ if (parent.disabled === pDisabled)
458
+ return;
533
459
  parent.disabled = pDisabled;
534
460
  }
535
461
  this.markWillUpdateNode(parent);
536
462
  this.walkUp(parent, changeState);
537
463
  }
538
464
  };
539
-
540
- Tree.prototype.walkDown = function (node, changeState) {};
541
-
465
+ Tree.prototype.walkDown = function (node, changeState) { };
542
466
  Tree.prototype.updateLiElement = function (node) {
543
467
  const { classList } = this.liElementsById[node.id];
544
468
  switch (node.status) {
@@ -554,17 +478,17 @@ Tree.prototype.updateLiElement = function (node) {
554
478
  classList.add('treejs-node__checked');
555
479
  break;
556
480
  }
557
-
558
481
  switch (node.disabled) {
559
482
  case true:
560
- if (!classList.contains('treejs-node__disabled')) classList.add('treejs-node__disabled');
483
+ if (!classList.contains('treejs-node__disabled'))
484
+ classList.add('treejs-node__disabled');
561
485
  break;
562
486
  case false:
563
- if (classList.contains('treejs-node__disabled')) classList.remove('treejs-node__disabled');
487
+ if (classList.contains('treejs-node__disabled'))
488
+ classList.remove('treejs-node__disabled');
564
489
  break;
565
490
  }
566
491
  };
567
-
568
492
  Tree.parseTreeData = function (data) {
569
493
  const treeNodes = deepClone(data);
570
494
  const nodesById = {};
@@ -574,17 +498,21 @@ Tree.parseTreeData = function (data) {
574
498
  const walkTree = function (nodes, parent) {
575
499
  nodes.forEach(node => {
576
500
  nodesById[node.id] = node;
577
- if (node.checked) values.push(node.id);
578
- if (node.disabled) disables.push(node.id);
579
- if (parent) node.parent = parent;
501
+ if (node.checked)
502
+ values.push(node.id);
503
+ if (node.disabled)
504
+ disables.push(node.id);
505
+ if (parent)
506
+ node.parent = parent;
580
507
  if (node.children && node.children.length) {
581
508
  walkTree(node.children, node);
582
- } else {
509
+ }
510
+ else {
583
511
  leafNodesById[node.id] = node;
584
512
  }
585
513
  });
586
514
  };
587
- walkTree(treeNodes);
515
+ walkTree(treeNodes, null);
588
516
  return {
589
517
  treeNodes,
590
518
  nodesById,
@@ -593,19 +521,16 @@ Tree.parseTreeData = function (data) {
593
521
  defaultDisables: disables,
594
522
  };
595
523
  };
596
-
597
524
  Tree.createRootEle = function () {
598
525
  const div = document.createElement('div');
599
526
  div.classList.add('treejs');
600
527
  return div;
601
528
  };
602
-
603
529
  Tree.prototype.createUlEle = function () {
604
530
  const ul = document.createElement('ul');
605
531
  ul.classList.add('treejs-nodes');
606
532
  return ul;
607
533
  };
608
-
609
534
  Tree.prototype.createLiEle = function (node, closed) {
610
535
  const li = document.createElement('li');
611
536
  li.classList.add('treejs-node');
@@ -615,29 +540,32 @@ Tree.prototype.createLiEle = function (node, closed) {
615
540
  if (node.isDesaturated) {
616
541
  li.classList.add('treejs-node__desaturated');
617
542
  }
618
- if (closed) li.classList.add('treejs-node__close');
543
+ if (node.searchMatch) {
544
+ li.classList.add('treejs-node__searchmatch');
545
+ }
546
+ if (closed)
547
+ li.classList.add('treejs-node__close');
619
548
  if (node.children && node.children.length) {
620
549
  const switcher = document.createElement('span');
621
550
  switcher.classList.add('treejs-switcher');
622
551
  li.appendChild(switcher);
623
- } else {
552
+ }
553
+ else {
624
554
  li.classList.add('treejs-placeholder');
625
555
  }
626
-
627
- if (!this.options.parentApi || (this.options.parentApi && this.options.parentApi.options.multiple)) {
556
+ if (!this.options.parentApi || (this.options.parentApi && this.options.parentApi.theOptions.multiple)) {
628
557
  const checkbox = document.createElement('span');
629
558
  checkbox.classList.add('treejs-checkbox');
630
559
  li.appendChild(checkbox);
631
560
  }
632
-
633
561
  const label = document.createElement('span');
634
562
  label.classList.add('treejs-label');
635
563
  const text = document.createTextNode(node.text);
636
564
  label.appendChild(text);
637
565
  li.appendChild(label);
638
566
  li.nodeId = node.id;
639
- if (this.options.parentApi.options.dragAndDropEnabled) {
640
- li.setAttribute('draggable', true);
567
+ if (this.options.parentApi.theOptions.dragAndDropEnabled) {
568
+ li.setAttribute('draggable', 'true');
641
569
  li.addEventListener('dragstart', e => {
642
570
  this.options.parentApi.onItemDragStart(li, e);
643
571
  });
@@ -654,7 +582,6 @@ Tree.prototype.createLiEle = function (node, closed) {
654
582
  this.options.parentApi.onItemDrop(li, e);
655
583
  });
656
584
  }
657
-
658
585
  return li;
659
586
  };
660
587
 
@@ -17848,13 +17775,23 @@ var lodash = createCommonjsModule(function (module, exports) {
17848
17775
  }.call(commonjsGlobal));
17849
17776
  });
17850
17777
 
17851
- const hierarchizedPickerCss = "reneco-hierarchized-picker .hierarchized-picker-raw-tree-area{position:relative;-webkit-box-sizing:border-box;box-sizing:border-box}reneco-hierarchized-picker .loader{position:absolute;z-index:1;min-width:100%;min-height:100%;background:#FFFFFF99;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:10px;-webkit-box-sizing:border-box;box-sizing:border-box}reneco-hierarchized-picker .loader .loader-inner{background:#FFF;padding:20px;-webkit-box-shadow:0 0 5px #000;box-shadow:0 0 5px #000;-webkit-box-sizing:border-box;box-sizing:border-box}reneco-hierarchized-picker .loader:not(.loading){display:none}reneco-hierarchized-picker .scrollable{overflow-y:auto;position:relative}reneco-hierarchized-picker .treejs{-webkit-box-sizing:border-box;box-sizing:border-box;font-size:14px}reneco-hierarchized-picker .treejs *:after,reneco-hierarchized-picker .treejs *:before{-webkit-box-sizing:border-box;box-sizing:border-box}reneco-hierarchized-picker .treejs>.treejs-node{padding-left:0}reneco-hierarchized-picker .treejs .treejs-nodes{list-style:none;padding-left:20px;overflow:hidden;-webkit-transition:height 150ms ease-out, opacity 150ms ease-out;-o-transition:height 150ms ease-out, opacity 150ms ease-out;transition:height 150ms ease-out, opacity 150ms ease-out}reneco-hierarchized-picker .treejs .treejs-node{cursor:pointer;overflow:hidden;position:relative}reneco-hierarchized-picker .treejs .treejs-node.treejs-placeholder{padding-left:20px}reneco-hierarchized-picker .treejs .treejs-switcher{display:inline-block;vertical-align:middle;width:20px;height:20px;cursor:pointer;position:relative;-webkit-transition:-webkit-transform 150ms ease-out;transition:-webkit-transform 150ms ease-out;-o-transition:transform 150ms ease-out;transition:transform 150ms ease-out;transition:transform 150ms ease-out, -webkit-transform 150ms ease-out}reneco-hierarchized-picker .treejs .treejs-switcher:before{position:absolute;top:8px;left:6px;display:block;content:' ';border:4px solid transparent;border-top:4px solid rgba(0, 0, 0, 0.4);-webkit-transition:border-color 150ms;-o-transition:border-color 150ms;transition:border-color 150ms}reneco-hierarchized-picker .treejs .treejs-switcher:hover:before{border-top:4px solid rgba(0, 0, 0, 0.65)}reneco-hierarchized-picker .treejs .treejs-node__close>.treejs-switcher{-webkit-transform:rotate(-90deg);-ms-transform:rotate(-90deg);transform:rotate(-90deg)}reneco-hierarchized-picker .treejs .treejs-node__close>.treejs-nodes{height:0}reneco-hierarchized-picker .treejs .treejs-checkbox{display:inline-block;vertical-align:middle;width:20px;height:20px;cursor:pointer;position:relative}reneco-hierarchized-picker .treejs .treejs-checkbox:before{-webkit-transition:all 0.3s;-o-transition:all 0.3s;transition:all 0.3s;cursor:pointer;position:absolute;top:2px;content:' ';display:block;width:16px;height:16px;border:1px solid #d9d9d9;border-radius:2px}reneco-hierarchized-picker .treejs .treejs-checkbox:hover:before{-webkit-box-shadow:0 0 2px 1px #1890ff;box-shadow:0 0 2px 1px #1890ff}reneco-hierarchized-picker .treejs .treejs-node__checked>.treejs-checkbox:before{background-color:#1890ff;border-color:#1890ff}reneco-hierarchized-picker .treejs .treejs-node__checked>.treejs-checkbox:after{position:absolute;content:' ';display:block;top:4px;left:5px;width:5px;height:9px;border:2px solid #fff;border-top:none;border-left:none;-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}reneco-hierarchized-picker .treejs .treejs-node__halfchecked>.treejs-checkbox:before{background-color:#1890ff;border-color:#1890ff}reneco-hierarchized-picker .treejs .treejs-node__halfchecked>.treejs-checkbox:after{position:absolute;content:' ';display:block;top:9px;left:3px;width:10px;height:2px;background-color:#fff}reneco-hierarchized-picker .treejs .treejs-node__disabled{cursor:not-allowed;color:rgba(0, 0, 0, 0.25)}reneco-hierarchized-picker .treejs .treejs-node__disabled .treejs-checkbox{cursor:not-allowed}reneco-hierarchized-picker .treejs .treejs-node__disabled .treejs-checkbox:before{cursor:not-allowed;border-color:#d9d9d9 !important;background-color:#f5f5f5 !important}reneco-hierarchized-picker .treejs .treejs-node__disabled .treejs-checkbox:hover:before{-webkit-box-shadow:none !important;box-shadow:none !important}reneco-hierarchized-picker .treejs .treejs-node__disabled .treejs-node__checked>.treejs-checkbox:after{border-color:#d9d9d9}reneco-hierarchized-picker .treejs .treejs-node__disabled .treejs-node__halfchecked>.treejs-checkbox:after{background-color:#d9d9d9}reneco-hierarchized-picker .treejs .treejs-node__disabled.treejs-node__checked>.treejs-checkbox:after{border-color:#d9d9d9}reneco-hierarchized-picker .treejs .treejs-node__disabled.treejs-node__halfchecked>.treejs-checkbox:after{background-color:#d9d9d9}reneco-hierarchized-picker .treejs .treejs-label{vertical-align:middle}reneco-hierarchized-picker .treejs .treejs-node__deprecated>.treejs-label{text-decoration:line-through}reneco-hierarchized-picker .treejs .treejs-node__desaturated>.treejs-label{opacity:.5}reneco-hierarchized-picker .treejs .dragging{background:yellow;display:inline;opacity:.9}reneco-hierarchized-picker .treejs .dragover{background:#CCC}reneco-hierarchized-picker .treejs .dragover-over::after{content:\"\";display:block;width:2px;height:100%;position:absolute;top:0;left:0;background:red}reneco-hierarchized-picker .treejs .dragover-before::after{content:\"\";display:block;height:2px;width:100%;position:absolute;top:0;left:0;background:red}reneco-hierarchized-picker .treejs .dragover-after::after{content:\"\";display:block;height:2px;width:100%;position:absolute;bottom:0;left:0;background:red}reneco-hierarchized-picker .fieldError{color:red !important}reneco-hierarchized-picker .readonly-mode{color:grey}reneco-hierarchized-picker .hidden{display:none;opacity:0}reneco-hierarchized-picker ul.treejs-nodes:first-child{padding-left:0px !important;margin-top:0px !important;margin-left:0px !important}reneco-hierarchized-picker ul.treejs-nodes:not(:first-child){margin:0 !important;padding-left:15px !important;background-color:var(--ion-color-light-tint, #F0F0F0)}reneco-hierarchized-picker ul.treejs-nodes{margin-left:15px !important;padding-left:0px !important}reneco-hierarchized-picker .hierarchized-picker-raw-tree li.treejs-node ul.treejs-nodes{margin:11px 0 0 0 !important}reneco-hierarchized-picker .hierarchized-picker-raw-tree li.treejs-node__close ul.treejs-nodes{margin:0 !important}reneco-hierarchized-picker li.treejs-node__close{background-color:var(--ion-color-light)}reneco-hierarchized-picker li:not(.treejs-node__close){background-color:var(--ion-color-medium);padding-bottom:0px !important}reneco-hierarchized-picker li:not(.treejs-node__close) ul.treejs-nodes li{margin-top:2px !important}reneco-hierarchized-picker ul li:last-child{margin-bottom:0px !important}reneco-hierarchized-picker li.treejs-node__checked{background-color:var(--ion-color-background, initial)}reneco-hierarchized-picker li.treejs-node{padding:2px 0px;margin-bottom:2px}reneco-hierarchized-picker .treejs-node.readonly_node{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;color:darkgrey}reneco-hierarchized-picker .treejs-node:not(.readonly_node){-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;color:black}reneco-hierarchized-picker .hierarchized-picker-container{position:relative;width:100%}reneco-hierarchized-picker .hierarchized-picker-input-area{background-color:transparent !important;display:inline;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center}reneco-hierarchized-picker .hierarchized-picker-input-area .input-wrapper{padding-left:10px !important}reneco-hierarchized-picker .hierarchized-picker-input{-ms-flex:2;flex:2}reneco-hierarchized-picker .hierarchized-picker-input.hierarchized-picker-icon{margin-left:8px}reneco-hierarchized-picker .hierarchized-picker-label{position:stacked;margin-left:5px}reneco-hierarchized-picker .hierarchized-picker-input input,reneco-hierarchized-picker .hierarchized-picker-search input{padding-left:5px !important;text-overflow:ellipsis !important;border:0;background:transparent;outline:none}reneco-hierarchized-picker .hierarchized-picker-search input{width:90%}reneco-hierarchized-picker .hierarchized-picker-search{background-color:var(--ion-color-medium-tint);position:absolute !important;width:333px !important;margin-top:10px;border-radius:4px;padding:8.5px}reneco-hierarchized-picker .hierarchized-picker-tree-area{width:333px !important;padding-top:45px}reneco-hierarchized-picker .hierarchized-picker-modal-area{background-color:var(--ion-color-light-tint) !important;position:absolute;z-index:10;padding-left:15px;overflow:auto;top:30px;min-height:100px;max-height:200px;-webkit-box-shadow:0 0px 15px 0 rgba(0, 0, 0, 0.2);box-shadow:0 0px 15px 0 rgba(0, 0, 0, 0.2);border-radius:4px;margin-right:0px !important}reneco-hierarchized-picker .hierarchized-picker-modal{display:inline-block;width:357px}reneco-hierarchized-picker .hierarchized-picker{display:-ms-flexbox;display:flex;width:100%;font-family:'Roboto', sans-serif}reneco-hierarchized-picker .hierarchized-picker-spinner{margin:35px 0px 0px 145px}reneco-hierarchized-picker .reneco:before{position:relative;top:1px}reneco-hierarchized-picker .hierarchized-picker-input-area span.reneco{padding:10px 15px}reneco-hierarchized-picker .hierarchized-picker-input-area span.reneco:hover{cursor:pointer}reneco-hierarchized-picker .hierarchized-picker-input-area span.reneco-close{-webkit-transform:translate(5px, -8px);transform:translate(5px, -8px);color:var(--ion-color-danger, red) !important}reneco-hierarchized-picker .treejs .treejs-switcher:before{border-top:4px solid var(--ion-color-dark-shade, #121212)}reneco-hierarchized-picker .treejs .treejs-checkbox:before{-webkit-box-shadow:none !important;box-shadow:none !important}reneco-hierarchized-picker .treejs .treejs-node__checked>.treejs-checkbox:before,reneco-hierarchized-picker .treejs .treejs-node__halfchecked>.treejs-checkbox:before{background-color:var(--ion-color-primary) !important;border-color:var(--ion-color-primary) !important;-webkit-box-shadow:none !important;box-shadow:none !important}reneco-hierarchized-picker #searchInTree{padding:8.5px 8px;background:var(--ion-color-background);border:none !important;border-radius:4px}reneco-hierarchized-picker #searchInTree:focus{border:none !important;outline:none !important;-webkit-box-shadow:none !important;box-shadow:none !important}reneco-hierarchized-picker #autocomplete-results-area{position:absolute;margin-top:28px;background-color:white;left:20px;z-index:10;padding:0px 5px;max-width:300px;max-height:110px;overflow:auto}reneco-hierarchized-picker #autocomplete-results-area li{list-style-type:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer}reneco-hierarchized-picker .hierarchized-picker-raw-tree-area li.treejs-node{padding:11px 0px}::-webkit-scrollbar-thumb{background:var(--ion-color-primary);width:8px;margin:5px;border-radius:5px}::-webkit-scrollbar{background:var(--ion-color-medium-tint);width:8px;height:8px;margin:5px;cursor:pointer;border-radius:5px}::-webkit-scrollbar-corner{background-color:var(--ion-color-light-tint)}[class$=\"-dark\"] reneco-hierarchized-picker li.treejs-node__close{background-color:var(--ion-color-dark-tint);color:var(--ion-color-dark-contrast)}[class$=\"-dark\"] reneco-hierarchized-picker li:not(.treejs-node__close){background-color:var(--ion-color-dark);color:var(--ion-color-dark-contrast)}[class$=\"-dark\"] reneco-hierarchized-picker li.treejs-node__checked{background-color:var(--ion-color-background, initial);color:var(--ion-color-primary-contrast) !important}[class$=\"-dark\"] reneco-hierarchized-picker .treejs-switcher:before{border-top-color:var(--ion-color-dark-contrast, #fff) !important}[class$=\"-dark\"] reneco-hierarchized-picker li.treejs-node__checked .treejs-switcher:before{color:var(--ion-color-light-contrast) !important}[class$=\"-dark\"] reneco-hierarchized-picker ul.treejs-nodes:not(:first-child){background-color:var(--ion-color-light-contrast) !important}";
17778
+ var browser = XMLHttpRequest;
17779
+
17780
+ const hierarchizedPickerCss = "reneco-hierarchized-picker .hierarchized-picker-raw-tree-area{position:relative;-webkit-box-sizing:border-box;box-sizing:border-box}reneco-hierarchized-picker .loader{position:absolute;z-index:1;min-width:100%;min-height:100%;background:#FFFFFF99;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:10px;-webkit-box-sizing:border-box;box-sizing:border-box}reneco-hierarchized-picker .loader .loader-inner{background:#FFF;padding:20px;-webkit-box-shadow:0 0 5px #000;box-shadow:0 0 5px #000;-webkit-box-sizing:border-box;box-sizing:border-box}reneco-hierarchized-picker .loader:not(.loading){display:none}reneco-hierarchized-picker .scrollable{overflow-y:auto;position:relative}reneco-hierarchized-picker .treejs{-webkit-box-sizing:border-box;box-sizing:border-box;font-size:14px}reneco-hierarchized-picker .treejs *:after,reneco-hierarchized-picker .treejs *:before{-webkit-box-sizing:border-box;box-sizing:border-box}reneco-hierarchized-picker .treejs>.treejs-node{padding-left:0}reneco-hierarchized-picker .treejs .treejs-nodes{list-style:none;padding-left:20px;overflow:hidden;-webkit-transition:height 150ms ease-out, opacity 150ms ease-out;-o-transition:height 150ms ease-out, opacity 150ms ease-out;transition:height 150ms ease-out, opacity 150ms ease-out}reneco-hierarchized-picker .treejs .treejs-node{cursor:pointer;overflow:hidden;position:relative}reneco-hierarchized-picker .treejs .treejs-node.treejs-placeholder{padding-left:20px}reneco-hierarchized-picker .treejs .treejs-switcher{display:inline-block;vertical-align:middle;width:20px;height:20px;cursor:pointer;position:relative;-webkit-transition:-webkit-transform 150ms ease-out;transition:-webkit-transform 150ms ease-out;-o-transition:transform 150ms ease-out;transition:transform 150ms ease-out;transition:transform 150ms ease-out, -webkit-transform 150ms ease-out}reneco-hierarchized-picker .treejs .treejs-switcher:before{position:absolute;top:8px;left:6px;display:block;content:' ';border:4px solid transparent;border-top:4px solid rgba(0, 0, 0, 0.4);-webkit-transition:border-color 150ms;-o-transition:border-color 150ms;transition:border-color 150ms}reneco-hierarchized-picker .treejs .treejs-switcher:hover:before{border-top:4px solid rgba(0, 0, 0, 0.65)}reneco-hierarchized-picker .treejs .treejs-node__close>.treejs-switcher{-webkit-transform:rotate(-90deg);-ms-transform:rotate(-90deg);transform:rotate(-90deg)}reneco-hierarchized-picker .treejs .treejs-node__close>.treejs-nodes{height:0}reneco-hierarchized-picker .treejs .treejs-checkbox{display:inline-block;vertical-align:middle;width:20px;height:20px;cursor:pointer;position:relative}reneco-hierarchized-picker .treejs .treejs-checkbox:before{-webkit-transition:all 0.3s;-o-transition:all 0.3s;transition:all 0.3s;cursor:pointer;position:absolute;top:2px;content:' ';display:block;width:16px;height:16px;border:1px solid #d9d9d9;border-radius:2px}reneco-hierarchized-picker .treejs .treejs-checkbox:hover:before{-webkit-box-shadow:0 0 2px 1px #1890ff;box-shadow:0 0 2px 1px #1890ff}reneco-hierarchized-picker .treejs .treejs-node__checked>.treejs-checkbox:before{background-color:#1890ff;border-color:#1890ff}reneco-hierarchized-picker .treejs .treejs-node__checked>.treejs-checkbox:after{position:absolute;content:' ';display:block;top:4px;left:5px;width:5px;height:9px;border:2px solid #fff;border-top:none;border-left:none;-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}reneco-hierarchized-picker .treejs .treejs-node__halfchecked>.treejs-checkbox:before{background-color:#1890ff;border-color:#1890ff}reneco-hierarchized-picker .treejs .treejs-node__halfchecked>.treejs-checkbox:after{position:absolute;content:' ';display:block;top:9px;left:3px;width:10px;height:2px;background-color:#fff}reneco-hierarchized-picker .treejs .treejs-node__disabled{cursor:not-allowed;color:rgba(0, 0, 0, 0.25)}reneco-hierarchized-picker .treejs .treejs-node__disabled .treejs-checkbox{cursor:not-allowed}reneco-hierarchized-picker .treejs .treejs-node__disabled .treejs-checkbox:before{cursor:not-allowed;border-color:#d9d9d9 !important;background-color:#f5f5f5 !important}reneco-hierarchized-picker .treejs .treejs-node__disabled .treejs-checkbox:hover:before{-webkit-box-shadow:none !important;box-shadow:none !important}reneco-hierarchized-picker .treejs .treejs-node__disabled .treejs-node__checked>.treejs-checkbox:after{border-color:#d9d9d9}reneco-hierarchized-picker .treejs .treejs-node__disabled .treejs-node__halfchecked>.treejs-checkbox:after{background-color:#d9d9d9}reneco-hierarchized-picker .treejs .treejs-node__disabled.treejs-node__checked>.treejs-checkbox:after{border-color:#d9d9d9}reneco-hierarchized-picker .treejs .treejs-node__disabled.treejs-node__halfchecked>.treejs-checkbox:after{background-color:#d9d9d9}reneco-hierarchized-picker .treejs .treejs-label{vertical-align:middle}reneco-hierarchized-picker .treejs .treejs-node__deprecated>.treejs-label{text-decoration:line-through}reneco-hierarchized-picker .treejs .treejs-node__desaturated>.treejs-label{opacity:.5}reneco-hierarchized-picker .treejs .treejs-node__searchmatch>.treejs-label{font-weight:bolder}reneco-hierarchized-picker .treejs .dragging{background:yellow;display:inline;opacity:.9;padding:11px 0px;display:block}reneco-hierarchized-picker .treejs .dragover{background:#CCC}reneco-hierarchized-picker .treejs .dragover-over::after{content:\"\";display:block;width:2px;height:100%;position:absolute;top:0;left:0;background:red}reneco-hierarchized-picker .treejs .dragover-before::after{content:\"\";display:block;height:2px;width:100%;position:absolute;top:0;left:0;background:red}reneco-hierarchized-picker .treejs .dragover-after::after{content:\"\";display:block;height:2px;width:100%;position:absolute;bottom:0;left:0;background:red}reneco-hierarchized-picker .fieldError{color:red !important}reneco-hierarchized-picker .hidden{display:none;opacity:0}reneco-hierarchized-picker ul.treejs-nodes:first-child{padding-left:0px !important;margin-top:0px !important;margin-left:0px !important}reneco-hierarchized-picker ul.treejs-nodes:not(:first-child){margin:0 !important;padding-left:15px !important;background-color:var(--ion-color-light-tint, #FFF)}reneco-hierarchized-picker ul.treejs-nodes{margin-left:15px !important;padding-left:0px !important}reneco-hierarchized-picker .hierarchized-picker-raw-tree li.treejs-node ul.treejs-nodes{margin:11px 0 0 0 !important}reneco-hierarchized-picker .hierarchized-picker-raw-tree li.treejs-node__close ul.treejs-nodes{margin:0 !important}reneco-hierarchized-picker li.treejs-node__close{background-color:var(--ion-color-light, #FAFAFA)}reneco-hierarchized-picker li:not(.treejs-node__close){background-color:var(--ion-color-medium, #bdbdbd7d);padding-bottom:0px !important}reneco-hierarchized-picker li:not(.treejs-node__close) ul.treejs-nodes li{margin-top:2px !important}reneco-hierarchized-picker ul li:last-child{margin-bottom:0px !important}reneco-hierarchized-picker li.treejs-node__checked{background-color:var(--ion-color-background, var(--mui-palette-background-default, rgba(221, 169, 37, 0.18)))}reneco-hierarchized-picker li.treejs-node{padding:2px 0px;margin-bottom:2px}reneco-hierarchized-picker .treejs-node.readonly_node{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;color:darkgrey}reneco-hierarchized-picker .treejs-node:not(.readonly_node){-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;color:black}reneco-hierarchized-picker .hierarchized-picker-container{position:relative;width:100%}reneco-hierarchized-picker .hierarchized-picker-input-area{background-color:transparent !important;display:inline;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center}reneco-hierarchized-picker .hierarchized-picker-input-area .input-wrapper{padding-left:10px !important}reneco-hierarchized-picker .hierarchized-picker-input{-ms-flex:2;flex:2}reneco-hierarchized-picker .hierarchized-picker-input.readonly{pointer-events:none;cursor:initial}reneco-hierarchized-picker .hierarchized-picker-input.hierarchized-picker-icon{margin-left:8px}reneco-hierarchized-picker .hierarchized-picker-label{position:stacked;margin-left:5px}reneco-hierarchized-picker .hierarchized-picker-input input,reneco-hierarchized-picker .hierarchized-picker-search input{padding-left:5px !important;text-overflow:ellipsis !important;border:0;background:transparent;outline:none}reneco-hierarchized-picker .hierarchized-picker-search input{width:90%}reneco-hierarchized-picker .hierarchized-picker-search{background-color:var(--ion-color-medium-tint, #E0E0E0);position:absolute !important;width:333px !important;margin-top:10px;border-radius:4px;padding:8.5px}reneco-hierarchized-picker .hierarchized-picker-tree-area{width:333px !important;padding-top:48px}reneco-hierarchized-picker .hierarchized-picker-modal-area{background-color:var(--ion-color-light-tint, #FFF) !important;position:absolute;z-index:10;padding-left:15px;overflow:scroll;top:20px;min-height:100px;max-height:200px;-webkit-box-shadow:0 0px 15px 0 rgba(0, 0, 0, 0.2);box-shadow:0 0px 15px 0 rgba(0, 0, 0, 0.2);border-radius:4px;margin-right:0px !important}reneco-hierarchized-picker .hierarchized-picker-modal{display:inline-block;width:357px}reneco-hierarchized-picker .hierarchized-picker{display:-ms-flexbox;display:flex;width:100%;font-family:'Roboto', sans-serif}reneco-hierarchized-picker .hierarchized-picker-spinner{margin:35px 0px 0px 145px}reneco-hierarchized-picker .reneco:before{position:relative;top:1px}reneco-hierarchized-picker .hierarchized-picker-input-area span.reneco{padding:10px 15px}reneco-hierarchized-picker .hierarchized-picker-input-area span.reneco:hover{cursor:pointer}reneco-hierarchized-picker .hierarchized-picker-input-area span.reneco-close{-webkit-transform:translate(5px, -8px);transform:translate(5px, -8px);color:var(--ion-color-danger, red) !important}reneco-hierarchized-picker .treejs .treejs-switcher:before{border-top:4px solid var(--ion-color-dark-shade, #121212)}reneco-hierarchized-picker .treejs .treejs-checkbox:before{-webkit-box-shadow:none !important;box-shadow:none !important}reneco-hierarchized-picker .treejs .treejs-node__checked>.treejs-checkbox:before,reneco-hierarchized-picker .treejs .treejs-node__halfchecked>.treejs-checkbox:before{background-color:var(--ion-color-primary, var(--mui-palette-primary-main, #d58433)) !important;border-color:var(--ion-color-primary, var(--mui-palette-primary-main, #d58433)) !important;-webkit-box-shadow:none !important;box-shadow:none !important}reneco-hierarchized-picker #searchInTree{padding:8.5px 8px;background:var(--ion-color-background, var(--mui-palette-background-default, rgba(221, 169, 37, 0.18)));border:none !important;border-radius:4px}reneco-hierarchized-picker #searchInTree:focus{border:none !important;outline:none !important;-webkit-box-shadow:none !important;box-shadow:none !important}reneco-hierarchized-picker #autocomplete-results-area{position:absolute;margin-top:48px;background-color:white;left:15px;z-index:10;padding:0px 5px;max-width:340px;max-height:110px;overflow:auto}reneco-hierarchized-picker #autocomplete-results-area li{list-style-type:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;margin:1px}reneco-hierarchized-picker .hierarchized-picker-raw-tree-area li.treejs-node{padding:11px 0px;display:block}.hierarchized-picker-raw-tree-area.readonly li.treejs-node{cursor:initial;pointer-events:none}.hierarchized-picker-raw-tree-area.readonly li.treejs-node .treejs-switcher{pointer-events:all}::-webkit-scrollbar-thumb{background:var(--ion-color-primary, var(--mui-palette-primary-main, #d58433));width:8px;margin:5px;border-radius:5px}::-webkit-scrollbar{background:var(--ion-color-medium-tint, #E0E0E0);width:8px;height:8px;margin:5px;cursor:pointer;border-radius:5px}::-webkit-scrollbar-corner{background-color:var(--ion-color-light-tint, #FFF)}[class$=\"-dark\"] reneco-hierarchized-picker li.treejs-node__close{background-color:var(--ion-color-dark-tint, #424242);color:var(--ion-color-dark-contrast, #fff)}[class$=\"-dark\"] reneco-hierarchized-picker li:not(.treejs-node__close){background-color:var(--ion-color-dark, #212121);color:var(--ion-color-dark-contrast, #fff)}[class$=\"-dark\"] reneco-hierarchized-picker li.treejs-node__checked{background-color:var(--ion-color-background, var(--mui-palette-background-default, rgba(221, 169, 37, 0.18)));color:var(--ion-color-primary-contrast, #fff) !important}[class$=\"-dark\"] reneco-hierarchized-picker .treejs-switcher:before{border-top-color:var(--ion-color-dark-contrast, #fff) !important}[class$=\"-dark\"] reneco-hierarchized-picker li.treejs-node__checked .treejs-switcher:before{color:var(--ion-color-light-contrast, #111111) !important}[class$=\"-dark\"] reneco-hierarchized-picker ul.treejs-nodes:not(:first-child){background-color:var(--ion-color-light-contrast, #111111) !important}";
17852
17781
 
17853
- const waitBeforeTriggerSearch = 200;
17782
+ const waitBeforeTriggerSearch = 1000;
17854
17783
  function isNumeric(n) {
17855
17784
  return !isNaN(parseFloat(n)) && isFinite(n);
17856
17785
  }
17857
- const MyComponent = class {
17786
+ function replacer(key, value) {
17787
+ if (typeof value === "object" && value !== null) {
17788
+ if (value instanceof browser) {
17789
+ return "[XMLHttpRequest object]";
17790
+ }
17791
+ }
17792
+ return value;
17793
+ }
17794
+ const HierarchizedPickerComponent = class {
17858
17795
  constructor(hostRef) {
17859
17796
  index.registerInstance(this, hostRef);
17860
17797
  this.valueChange = index.createEvent(this, "valueChange", 7);
@@ -17866,9 +17803,19 @@ const MyComponent = class {
17866
17803
  this.ignoreOptionsChanges = true; // Determines wether the options @Prop under @Watch will be ignored (to avoid circular calls)
17867
17804
  this.setValueOnClick = true; // Tells wether we edit the picker value on click in the tree
17868
17805
  this.mylog = console.log; // Custom log function for debug purposes
17806
+ // Used to control wether we're draging over the same node, prevents the same event to be called multiple times
17807
+ this.lastDragedOverNodeId = null;
17808
+ // Used to control wether an event is being triggered one extra unwanted time on anscend of the targeted element
17809
+ this.lastDragedOverTimeForAscendent = new Date().getTime();
17810
+ // Used to remember when was last triggered the event over the target
17811
+ this.lastDragedOverTimeForLevel = new Date().getTime();
17812
+ // Used to accept the event being triggered on the same node multiple times after a delay to allow different drop modes
17813
+ this.acceptableDelayBetweenSimilarActions = 300;
17869
17814
  this.options = undefined;
17870
17815
  this.valueChangeCallback = undefined;
17871
17816
  this.disabled = undefined;
17817
+ this.isDisabled = undefined;
17818
+ this.theOptions = undefined;
17872
17819
  this.newoptions = undefined;
17873
17820
  this.newfilter = undefined;
17874
17821
  this.componentID = undefined;
@@ -17882,8 +17829,8 @@ const MyComponent = class {
17882
17829
  }
17883
17830
  getValue() {
17884
17831
  var _a, _b, _c, _d;
17885
- if (!this.options.output) {
17886
- if (this.options.multiple) {
17832
+ if (!this.theOptions.output) {
17833
+ if (this.theOptions.multiple) {
17887
17834
  return Promise.resolve(this.value);
17888
17835
  }
17889
17836
  else {
@@ -17891,33 +17838,37 @@ const MyComponent = class {
17891
17838
  }
17892
17839
  }
17893
17840
  else {
17894
- if (this.options.multiple) {
17895
- return Promise.resolve((_b = this.value) === null || _b === void 0 ? void 0 : _b.map(item => item[this.options.output]));
17841
+ if (this.theOptions.multiple) {
17842
+ return Promise.resolve((_b = this.value) === null || _b === void 0 ? void 0 : _b.map(item => item[this.theOptions.output]));
17896
17843
  }
17897
17844
  else {
17898
- return Promise.resolve((_d = (_c = this.value) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d[this.options.output]);
17845
+ return Promise.resolve((_d = (_c = this.value) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d[this.theOptions.output]);
17899
17846
  }
17900
17847
  }
17901
17848
  }
17902
17849
  logError(messageToLog) {
17903
- console.error('--- Hierarchized picker ' + this.componentID + ' ERROR ---', messageToLog);
17850
+ try {
17851
+ console.error('--- Hierarchized picker ' + this.componentID + ' ERROR ---', messageToLog);
17852
+ }
17853
+ catch (_a) {
17854
+ console.error('--- Hierarchized picker generic ERROR ---');
17855
+ }
17904
17856
  }
17905
17857
  reloadCurrentValues() {
17906
17858
  let savedValues = this.value;
17907
- debugger;
17908
17859
  this.value = [];
17909
17860
  savedValues.forEach(element => {
17910
17861
  this.editValue(element.nodeid);
17911
17862
  });
17912
17863
  }
17913
- setNewOption(newValue, oldValue = null) {
17864
+ async setNewOption(newValue, oldValue = null) {
17914
17865
  this.canload = true;
17915
- this.options = newValue;
17916
- if (this.options.source != "file") {
17866
+ this.theOptions = newValue;
17867
+ if (this.theOptions.source != "file") {
17917
17868
  this.rawData = null;
17918
17869
  }
17919
17870
  this.ready = false;
17920
- this.loadHierarchizedPicker();
17871
+ await this.loadHierarchizedPicker();
17921
17872
  this.displayWhenLoaded();
17922
17873
  //NOTE: This could work in a synchronous environment => this.reloadCurrentValues();
17923
17874
  }
@@ -17928,14 +17879,14 @@ const MyComponent = class {
17928
17879
  this.filterTree(newfilter);
17929
17880
  }
17930
17881
  optionsChange(newValue) {
17931
- if (!this.options || !this.ready || this.ignoreOptionsChanges) {
17882
+ if (!this.theOptions || !this.ready || this.ignoreOptionsChanges) {
17932
17883
  return;
17933
17884
  }
17934
17885
  this.setNewOption(newValue);
17935
17886
  }
17936
17887
  isChangeInOptions(newV, oldV) {
17937
17888
  const isEqual = lodash.isEqual(newV, oldV);
17938
- const changeDefaultValue = !(newV.defaultValue.length == oldV.defaultValue.length && newV.defaultValue.every((value) => oldV.defaultValue.includes(value)));
17889
+ const changeDefaultValue = !(newV.defaultValue.length == oldV.defaultValue.length && newV.defaultValue.every(value => oldV.defaultValue.includes(value)));
17939
17890
  if (!isEqual && changeDefaultValue) {
17940
17891
  return changeDefaultValue;
17941
17892
  }
@@ -17957,14 +17908,15 @@ const MyComponent = class {
17957
17908
  this.errorToLog = "options.source value '" + object.source + "' doesn't meet interface IConf requirements";
17958
17909
  }
17959
17910
  else {
17960
- if (!((object.source != 'webservice') || (object.source == 'webservice' && object.url && typeof object.url == 'string'))) {
17911
+ if (!(object.source != 'webservice' || (object.source == 'webservice' && object.url && typeof object.url == 'string'))) {
17961
17912
  toret = false;
17962
17913
  this.errorToLog = "options.url value '" + object.url + "' doesn't meet interface IConf requirements, is wrongly formated or doesn't match option.source value";
17963
17914
  }
17964
17915
  //TODO allow Function along with string
17965
- if (!((object.source != 'webservice' && !object.token) || (object.source == 'webservice' && object.token && (typeof object.token == 'string' || typeof object.token == 'function')))) {
17916
+ if (!((object.source != 'webservice' && !object.token) ||
17917
+ (object.source == 'webservice' && object.token && (typeof object.token == 'string' || typeof object.token == 'function')))) {
17966
17918
  toret = false;
17967
- this.errorToLog = "options.token value doesn't meet interface IConf requirements or doesn't match option.source value";
17919
+ this.errorToLog = "options.token value doesn't meet interface IConf requirements or doesn't match option.source value :: typeof object.token == " + typeof object.token;
17968
17920
  }
17969
17921
  if (!((object.source != 'webservice' && !object.options) || (object.source == 'webservice' && object.options && typeof object.options == 'object'))) {
17970
17922
  toret = false;
@@ -17974,7 +17926,7 @@ const MyComponent = class {
17974
17926
  toret = false;
17975
17927
  this.errorToLog = "options.data value doesn't meet interface IConf requirements or doesn't match option.source value";
17976
17928
  }
17977
- if (!((object.source != 'file') || (object.source == 'file' && object.url && typeof object.url == 'string'))) {
17929
+ if (!(object.source != 'file' || (object.source == 'file' && object.url && typeof object.url == 'string'))) {
17978
17930
  toret = false;
17979
17931
  this.errorToLog = "options.url value '" + object.url + "' doesn't meet interface IConf requirements or doesn't match option.source value";
17980
17932
  }
@@ -17983,89 +17935,112 @@ const MyComponent = class {
17983
17935
  toret = false;
17984
17936
  this.errorToLog = "options.origin value '" + object.origin + "' doesn't meet interface IConf requirements";
17985
17937
  }
17986
- if (!((!object.output && typeof object.output != "boolean") || (typeof object.output == 'string' && ['fullpath', 'nodeid'].indexOf(object.output) > -1))) {
17938
+ if (!((!object.output && typeof object.output != 'boolean') || (typeof object.output == 'string' && ['fullpath', 'nodeid'].indexOf(object.output) > -1))) {
17987
17939
  toret = false;
17988
17940
  this.errorToLog = "options.output value '" + object.output + "' doesn't meet interface IConf requirements";
17989
17941
  }
17990
- if (!((!object.multiple && typeof object.multiple != "boolean") || typeof object.multiple == 'boolean')) {
17942
+ if (!((!object.multiple && typeof object.multiple != 'boolean') || typeof object.multiple == 'boolean')) {
17991
17943
  toret = false;
17992
17944
  this.errorToLog = "options.multiple value '" + object.multiple + "' doesn't meet interface IConf requirements";
17993
17945
  }
17994
- if (!((!object.mode && typeof object.mode != "boolean") || (typeof object.mode == 'string' && ['tree', 'input'].indexOf(object.mode) > -1))) {
17946
+ if (!((!object.mode && typeof object.mode != 'boolean') || (typeof object.mode == 'string' && ['tree', 'input'].indexOf(object.mode) > -1))) {
17995
17947
  this.errorToLog = "options.mode value '" + object.mode + "' doesn't meet interface IConf requirements";
17996
17948
  }
17997
17949
  if (!((!object.label && typeof object.label != "boolean") || typeof object.label == 'string')) {
17998
17950
  toret = false;
17999
17951
  this.errorToLog = "options.label value '" + object.label + "' doesn't meet interface IConf requirements";
18000
17952
  }
18001
- if (!((!object.searchPlaceholder && typeof object.searchPlaceholder != "boolean") || typeof object.searchPlaceholder == 'string')) {
17953
+ if (!((!object.searchPlaceholder && typeof object.searchPlaceholder != 'boolean') || typeof object.searchPlaceholder == 'string')) {
18002
17954
  toret = false;
18003
17955
  this.errorToLog = "options.searchPlaceholder value '" + object.searchPlaceholder + "' doesn't meet interface IConf requirements";
18004
17956
  }
18005
- if (!((!object.defaultValue && typeof object.defaultValue != "boolean") ||
18006
- ((typeof object.defaultValue == 'object' && (object.multiple == true || object.defaultValue.length <= 1)) ||
18007
- typeof object.defaultValue == 'string' ||
18008
- typeof object.defaultValue == 'number'))) {
17957
+ if (!((!object.defaultValue && typeof object.defaultValue != 'boolean') ||
17958
+ (typeof object.defaultValue == 'object' && (object.multiple == true || object.defaultValue.length <= 1)) ||
17959
+ typeof object.defaultValue == 'string' ||
17960
+ typeof object.defaultValue == 'number')) {
18009
17961
  toret = false;
18010
17962
  this.errorToLog = "options.defaultValue value '" + object.defaultValue + "' doesn't meet interface IConf requirements or doesn't match option.multiple value";
18011
17963
  }
18012
- if (!((!object.disabled && typeof object.disabled != "boolean") || typeof object.disabled == 'boolean')) {
17964
+ if (!((!object.readonly && typeof object.readonly != "boolean") || typeof object.readonly == 'boolean')) {
18013
17965
  toret = false;
18014
17966
  this.errorToLog = "readonly value '" + object.readonly + "' doesn't meet interface IConf requirements";
18015
17967
  }
18016
- if (!((!object.loading && typeof object.loading != "boolean") || (typeof object.loading == 'string' && ['display', 'click'].indexOf(object.loading) > -1))) {
17968
+ if (!((!object.loading && typeof object.loading != 'boolean') || (typeof object.loading == 'string' && ['display', 'click'].indexOf(object.loading) > -1))) {
18017
17969
  toret = false;
18018
17970
  this.errorToLog = "options.loading value '" + object.loading + "' doesn't meet interface IConf requirements";
18019
17971
  }
18020
- if (!((!object.displayTree && typeof object.displayTree != "boolean") || typeof object.displayTree == 'boolean')) {
17972
+ if (!((!object.displayTree && typeof object.displayTree != 'boolean') || typeof object.displayTree == 'boolean')) {
18021
17973
  toret = false;
18022
17974
  this.errorToLog = "options.displayTree value '" + object.displayTree + "' doesn't meet interface IConf requirements";
18023
17975
  }
18024
- if (!((!object.minDepth && typeof object.minDepth != "number") || typeof object.minDepth == 'number') || (object.maxDepth && object.maxDepth < object.minDepth)) {
17976
+ if (!((!object.minDepth && typeof object.minDepth != 'number') || typeof object.minDepth == 'number') || (object.maxDepth && object.maxDepth < object.minDepth)) {
18025
17977
  toret = false;
18026
17978
  this.errorToLog = "options.minDepth value '" + object.minDepth + "' doesn't meet interface IConf requirements or mismatches with maxDepth value";
18027
17979
  }
18028
- if (!((!object.minDepth && typeof object.maxDepth != "number") || typeof object.maxDepth == 'number') || (object.minDepth && object.minDepth > object.maxDepth)) {
17980
+ if (!((!object.maxDepth && typeof object.maxDepth != "number") || typeof object.maxDepth == 'number') || (object.minDepth && object.minDepth > object.maxDepth)) {
18029
17981
  toret = false;
18030
17982
  this.errorToLog = "options.maxDepth value '" + object.maxDepth + "' doesn't meet interface IConf requirements or mismatches with minDepth value";
18031
17983
  }
18032
- if (!((!object.isFullpath && typeof object.isFullpath != "boolean") || typeof object.isFullpath == 'boolean')) {
17984
+ if (!((!object.isFullpath && typeof object.isFullpath != 'boolean') || typeof object.isFullpath == 'boolean')) {
18033
17985
  toret = false;
18034
17986
  this.errorToLog = "options.isFullpath value '" + object.isFullpath + "' doesn't meet interface IConf requirements";
18035
17987
  }
18036
- if (!((!object.showAutocomplete && typeof object.showAutocomplete != "boolean") || typeof object.showAutocomplete == 'boolean')) {
17988
+ if (!((!object.showAutocomplete && typeof object.showAutocomplete != 'boolean') || typeof object.showAutocomplete == 'boolean')) {
18037
17989
  toret = false;
18038
17990
  this.errorToLog = "options.showAutocomplete value '" + object.showAutocomplete + "' doesn't meet interface IConf requirements";
18039
17991
  }
18040
- if (!((!object.openTreeWhenLoaded && typeof object.openTreeWhenLoaded != "boolean") || typeof object.openTreeWhenLoaded == 'boolean')) {
17992
+ if (!((!object.openTreeWhenLoaded && typeof object.openTreeWhenLoaded != 'boolean') || typeof object.openTreeWhenLoaded == 'boolean')) {
18041
17993
  toret = false;
18042
17994
  this.errorToLog = "options.openTreeWhenLoaded value '" + object.openTreeWhenLoaded + "' doesn't meet interface IConf requirements";
18043
17995
  }
17996
+ if (!((!object.displayRootNode && typeof object.displayRootNode != "boolean") || typeof object.displayRootNode == 'boolean')) {
17997
+ toret = false;
17998
+ this.errorToLog = "options.displayRootNode value '" + object.displayRootNode + "' doesn't meet interface IConf requirements";
17999
+ }
18000
+ if (!((!object.dragAndDropEnabled && typeof object.dragAndDropEnabled != "boolean") || typeof object.dragAndDropEnabled == 'boolean')) {
18001
+ toret = false;
18002
+ this.errorToLog = "options.dragAndDropEnabled value '" + object.dragAndDropEnabled + "' doesn't meet interface IConf requirements";
18003
+ }
18004
+ if (!((!object.contextMenu && typeof object.contextMenu != 'object') || typeof object.contextMenu == 'object')) {
18005
+ toret = false;
18006
+ this.errorToLog = "options.contextMenu value doesn't meet interface IConf requirements";
18007
+ }
18008
+ if (!((!object.searchResultPresentsUnMatched && typeof object.searchResultPresentsUnMatched != "boolean") || typeof object.searchResultPresentsUnMatched == 'boolean')) {
18009
+ toret = false;
18010
+ this.errorToLog = "options.searchResultPresentsUnMatched value '" + object.searchResultPresentsUnMatched + "' doesn't meet interface IConf requirements";
18011
+ }
18044
18012
  return toret;
18045
18013
  }
18046
- initComponent() {
18014
+ async initComponent() {
18047
18015
  // Setup default values
18048
- if (!this.options.multiple)
18049
- this.options.multiple = false;
18050
- if (!this.options.mode)
18051
- this.options.mode = 'input';
18052
- if (!this.options.defaultValue) {
18053
- this.options.defaultValue = [];
18016
+ if (!this.theOptions.multiple)
18017
+ this.theOptions.multiple = false;
18018
+ if (!this.theOptions.mode)
18019
+ this.theOptions.mode = 'input';
18020
+ if (!this.theOptions.defaultValue) {
18021
+ this.theOptions.defaultValue = [];
18054
18022
  }
18055
- else if (typeof this.options.defaultValue != 'object') {
18056
- this.options.defaultValue = [this.options.defaultValue];
18023
+ else if (typeof this.theOptions.defaultValue != 'object') {
18024
+ this.theOptions.defaultValue = [this.theOptions.defaultValue];
18057
18025
  }
18058
- let isNumeric = function (str) {
18026
+ let strIsNumeric = function (str) {
18059
18027
  if (typeof str != "string")
18060
18028
  return false;
18061
18029
  return !isNaN(str) &&
18062
18030
  !isNaN(parseFloat(str));
18063
18031
  };
18064
18032
  let autoAssignReach = true;
18065
- let defaultFromFullpaths = [];
18066
- this.options.defaultValue.forEach(element => {
18067
- if (!(typeof element == 'number') && !isNumeric(element)) {
18068
- if (this.options.source != "webservice") {
18033
+ let defaultFromFullpaths = undefined;
18034
+ try {
18035
+ this.theOptions.defaultValue.map(() => { });
18036
+ }
18037
+ catch (error) {
18038
+ this.errorToLog = "There's an issue with your defaultValue format: " + this.theOptions.defaultValue.toString();
18039
+ return;
18040
+ }
18041
+ await Promise.all(this.theOptions.defaultValue.map(async (element) => {
18042
+ if (!(typeof element == 'number') && !strIsNumeric(element)) {
18043
+ if (this.theOptions.source !== "webservice") {
18069
18044
  let errormsg = 'The loading of nodes based on fullpath is only available on webservice mode for now!';
18070
18045
  this.displayPickerError(errormsg);
18071
18046
  this.errorToLog = errormsg;
@@ -18073,101 +18048,127 @@ const MyComponent = class {
18073
18048
  return;
18074
18049
  }
18075
18050
  else {
18076
- defaultFromFullpaths.push(this.getNodeIdFromFullpath(element));
18051
+ if (!defaultFromFullpaths) {
18052
+ defaultFromFullpaths = [];
18053
+ }
18054
+ const valtopush = await this.getNodeIdFromFullpath(element).catch((err) => { });
18055
+ if (valtopush) {
18056
+ defaultFromFullpaths.push(valtopush);
18057
+ }
18077
18058
  }
18078
18059
  }
18079
- });
18080
- if (defaultFromFullpaths.length > 0) {
18081
- this.options.defaultValue = defaultFromFullpaths;
18060
+ }));
18061
+ if (defaultFromFullpaths) {
18062
+ this.theOptions.defaultValue = defaultFromFullpaths;
18082
18063
  }
18083
- if (this.options.options) {
18084
- if (!this.options.options.Reach && this.options.defaultValue.length > 0) {
18064
+ if (this.theOptions.options) {
18065
+ if (!this.theOptions.options.Reach && this.theOptions.defaultValue.length > 0) {
18085
18066
  if (autoAssignReach) {
18086
- this.options.options.Reach = this.options.defaultValue.map(element => {
18067
+ this.theOptions.options.Reach = this.theOptions.defaultValue.map(element => {
18087
18068
  return Number(element);
18088
18069
  });
18089
18070
  }
18090
18071
  else {
18091
- this.errorToLog = "options.options.Reach is undefined and can't be auto-assigned: either specify a 'Reach' option " +
18092
- " in your webservice call options or make sure the defaultValue property contains node IDs and not fullpath values.";
18072
+ this.errorToLog =
18073
+ "theOptions.options.Reach is undefined and can't be auto-assigned: either specify a 'Reach' option " +
18074
+ ' in your webservice call options or make sure the defaultValue property contains node IDs and not fullpath values.';
18093
18075
  }
18094
18076
  }
18095
18077
  }
18096
- if (!this.disabled)
18097
- this.disabled = false;
18098
- if (!this.options.loading)
18099
- this.options.loading = "display";
18100
- if (!this.options.displayTree && this.options.displayTree != false)
18101
- this.options.displayTree = true;
18078
+ if (!this.isDisabled)
18079
+ this.isDisabled = false;
18080
+ if (this.theOptions.readonly !== undefined)
18081
+ this.isDisabled = this.theOptions.readonly;
18082
+ if (!this.theOptions.loading)
18083
+ this.theOptions.loading = "display";
18084
+ if (!this.theOptions.displayTree && this.theOptions.displayTree != false)
18085
+ this.theOptions.displayTree = true;
18102
18086
  if (!this.hasFocus)
18103
18087
  this.hasFocus = [];
18104
- if (!this.options.isFullpath && this.options.isFullpath != false)
18105
- this.options.isFullpath = true;
18106
- if (!this.options.showAutocomplete)
18107
- this.options.showAutocomplete = false;
18108
- if (!this.options.openTreeWhenLoaded)
18109
- this.options.openTreeWhenLoaded = false;
18110
- if (!this.options.displayRootNode)
18111
- this.options.displayRootNode = false;
18088
+ if (!this.theOptions.isFullpath && this.theOptions.isFullpath != false)
18089
+ this.theOptions.isFullpath = true;
18090
+ if (!this.theOptions.showAutocomplete)
18091
+ this.theOptions.showAutocomplete = false;
18092
+ if (!this.theOptions.openTreeWhenLoaded)
18093
+ this.theOptions.openTreeWhenLoaded = false;
18094
+ if (!this.theOptions.displayRootNode)
18095
+ this.theOptions.displayRootNode = false;
18096
+ if (!this.theOptions.dragAndDropEnabled)
18097
+ this.theOptions.dragAndDropEnabled = false;
18098
+ if (!this.theOptions.errorsInInput && this.theOptions.errorsInInput !== false)
18099
+ this.theOptions.errorsInInput = true;
18112
18100
  }
18113
- loadHierarchizedPicker() {
18101
+ async loadHierarchizedPicker() {
18114
18102
  if (this.el.getAttribute("options") && typeof this.el.getAttribute("options") == "string") {
18115
- this.options = JSON.parse(this.el.getAttribute("options"));
18103
+ this.theOptions = JSON.parse(this.el.getAttribute("options"));
18116
18104
  }
18117
- let that = this;
18118
18105
  // If not in a debug mode, disable logs
18119
18106
  {
18120
18107
  this.mylog = function () { };
18121
18108
  console.time = function () { };
18109
+ console.timeEnd = function () { };
18122
18110
  }
18123
18111
  // Setup component unique ID
18124
- if (this.options.id)
18125
- this.componentID = this.options.id;
18112
+ if (this.theOptions && this.theOptions.id)
18113
+ this.componentID = this.theOptions.id;
18126
18114
  else if (!this.componentID)
18127
- this.componentID = (document.querySelectorAll('[id^="tree-area-"]').length + 1).toString();
18128
- if (!this.options)
18115
+ this.componentID = (Array.from(document.querySelectorAll('reneco-hierarchized-picker')).indexOf(this.el) + 1).toString();
18116
+ if (!this.theOptions)
18129
18117
  return;
18130
- if (this.options.defaultValue != undefined && this.options.defaultValue.length === 0) {
18131
- delete this.options.defaultValue;
18118
+ if (this.theOptions.defaultValue != undefined && this.theOptions.defaultValue.length === 0) {
18119
+ delete this.theOptions.defaultValue;
18132
18120
  }
18133
- this.canload = this.isInstanceOfIConf(this.options);
18134
- this.initComponent();
18121
+ this.canload = this.isInstanceOfIConf(this.theOptions);
18122
+ await this.initComponent();
18135
18123
  // Displays option values
18136
- this.mylog(this.options);
18137
- window.addEventListener("click", function (evt) {
18138
- let myself = that.amIFocusedByEvent(evt);
18139
- if (!myself && that.options.mode != "tree") {
18140
- that.showTree("hide");
18124
+ this.mylog(this.theOptions);
18125
+ window.addEventListener("click", (evt) => {
18126
+ let myself = this.amIFocusedByEvent(evt);
18127
+ if (!myself && this.theOptions.mode != "tree") {
18128
+ this.showTree("hide");
18141
18129
  }
18142
18130
  });
18131
+ this.el.addEventListener('dragover', event => {
18132
+ event.preventDefault();
18133
+ });
18134
+ this.el.addEventListener('dragenter', event => {
18135
+ event.preventDefault();
18136
+ });
18143
18137
  }
18144
- componentWillLoad() {
18145
- this.loadHierarchizedPicker();
18146
- this.mylog("----- componentWillLoad ending");
18138
+ async componentWillLoad() {
18139
+ this.isDisabled = this.disabled;
18140
+ this.theOptions = this.options;
18141
+ await this.loadHierarchizedPicker();
18142
+ this.mylog("----- componentWillLoad ending -----");
18147
18143
  }
18148
18144
  amIFocusedByEvent(evt) {
18149
- let that = this;
18150
18145
  let myself = false;
18151
- evt.composedPath().forEach(function (value, _index) {
18152
- if (value.id == 'hierarchized-picker-' + that.componentID) {
18146
+ evt.composedPath().forEach((value, _index) => {
18147
+ if (value.id == 'hierarchized-picker-' + this.componentID) {
18153
18148
  myself = true;
18154
18149
  }
18155
18150
  });
18156
- return (myself);
18151
+ return myself;
18157
18152
  }
18158
18153
  amIFocused() {
18159
18154
  return (document.activeElement == document.querySelector('#hierarchized-picker-input-' + this.componentID + ' input') ||
18160
18155
  document.activeElement == document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search input'));
18161
18156
  }
18162
18157
  amIShowingMyTree() {
18163
- return (document.querySelectorAll("#hierarchized-picker-" + this.componentID + " .hierarchized-picker-modal-area:not(.hidden)").length > 0);
18158
+ return document.querySelectorAll('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-modal-area:not(.hidden)').length > 0;
18164
18159
  }
18165
18160
  async getToken() {
18166
- if (typeof this.options.token == 'string') {
18167
- return this.options.token;
18161
+ if (typeof this.theOptions.token == 'string') {
18162
+ //IF token is not a token, get the token from the local storage
18163
+ if (this.theOptions.token.length > 200) {
18164
+ return this.theOptions.token;
18165
+ }
18166
+ else {
18167
+ return window.localStorage.getItem(this.theOptions.token);
18168
+ }
18168
18169
  }
18169
- if (typeof this.options.token == 'function') {
18170
- return await this.options.token();
18170
+ if (typeof this.theOptions.token == 'function') {
18171
+ return await this.theOptions.token();
18171
18172
  }
18172
18173
  }
18173
18174
  mergeData(source, toadd) {
@@ -18215,86 +18216,135 @@ const MyComponent = class {
18215
18216
  });
18216
18217
  return source;
18217
18218
  }
18218
- getNodeIdFromFullpath(fullpath) {
18219
- let toret = null;
18220
- let that = this;
18221
- let token = this.options.token;
18222
- let xhr = new XMLHttpRequest();
18223
- xhr.open('POST', this.getApiNodeFromFullpathURL(), false);
18224
- xhr.setRequestHeader('Authorization', 'Bearer ' + token);
18225
- xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
18226
- xhr.onload = function (e) {
18227
- that.mylog('XHR ONLOAD', e, xhr.statusText);
18228
- if (xhr.readyState === 4) {
18229
- if (xhr.status === 200) {
18230
- that.mylog('XHR 200', JSON.parse(xhr.responseText));
18231
- if (that.options.origin == 'thesaurus') {
18232
- toret = (JSON.parse(xhr.responseText).topic.TTop_PK_ID);
18219
+ searchAndMergeDataClassification(source, toadd) {
18220
+ let terminate = false;
18221
+ source.children.forEach((element, index) => {
18222
+ if (terminate) {
18223
+ return source;
18224
+ }
18225
+ if (source.ID == toadd.ID) {
18226
+ let subterminate = false;
18227
+ toadd.children.forEach((taelement, index) => {
18228
+ if (subterminate) {
18229
+ return;
18233
18230
  }
18234
- else if (that.options.origin == 'position') {
18235
- let result = JSON.parse(xhr.responseText);
18236
- if (result.exist) {
18237
- toret = (result.position.ID);
18238
- }
18239
- else {
18240
- that.errorToLog = "The fullpath passed for defaultValue does not exist!";
18241
- }
18231
+ if (element.ID == taelement.ID) {
18232
+ element = this.mergeData(element, taelement);
18233
+ subterminate = true;
18234
+ return;
18242
18235
  }
18243
- // TODO -> this does not exist, set accordingly to future API
18244
- else if (that.options.origin == 'classification') {
18245
- let result = JSON.parse(xhr.responseText);
18246
- if (result.exist) {
18247
- toret = (result.node.ID);
18236
+ });
18237
+ }
18238
+ else {
18239
+ if (element.ID == toadd.ID) {
18240
+ element = this.mergeData(element, toadd);
18241
+ terminate = true;
18242
+ return source;
18243
+ }
18244
+ else {
18245
+ this.searchAndMergeDataClassification(element, toadd);
18246
+ }
18247
+ }
18248
+ });
18249
+ return source;
18250
+ }
18251
+ getNodeIdFromFullpath(fullpath) {
18252
+ return new Promise((resolve, reject) => {
18253
+ let token = this.theOptions.token;
18254
+ let xhr = new browser();
18255
+ xhr.open('POST', this.getApiNodeFromFullpathURL(), true);
18256
+ xhr.setRequestHeader('Authorization', 'Bearer ' + token);
18257
+ xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
18258
+ xhr.onload = (e) => {
18259
+ try {
18260
+ this.mylog('getNodeIdFromFullpath XHR ONLOAD', e, xhr.statusText);
18261
+ if (xhr.readyState === 4) {
18262
+ if (xhr.status === 200) {
18263
+ this.mylog('getNodeIdFromFullpath XHR 200', JSON.parse(xhr.responseText));
18264
+ let result = JSON.parse(xhr.responseText);
18265
+ if (result.exist) {
18266
+ if (this.theOptions.origin == "thesaurus") {
18267
+ resolve(result.topic.TTop_PK_ID);
18268
+ }
18269
+ else if (this.theOptions.origin == 'position') {
18270
+ resolve(result.position.ID);
18271
+ }
18272
+ // TODO -> this does not exist, set accordingly to future API
18273
+ else if (this.theOptions.origin == 'classification') {
18274
+ resolve(result.node.ID);
18275
+ }
18276
+ }
18277
+ else {
18278
+ this.errorToLog = "The fullpath passed for defaultValue does not exist!";
18279
+ if (!this.theOptions.multiple && !this.theOptions.errorsInInput) {
18280
+ this.displayedValue = fullpath;
18281
+ }
18282
+ reject("null 1");
18283
+ }
18248
18284
  }
18249
18285
  else {
18250
- that.errorToLog = "The fullpath passed for defaultValue does not exist!";
18286
+ this.logError(['getNodeIdFromFullpath XHR NOT 200', xhr.statusText]);
18287
+ reject("null 2");
18251
18288
  }
18252
18289
  }
18253
18290
  }
18254
- else {
18255
- that.logError(['XHR NOT 200', xhr.statusText]);
18291
+ catch (error) {
18292
+ this.logError("There has been an issue with xhr.onload in getNodeIdFromFullpath: " + error.toString());
18293
+ reject("null 3");
18294
+ }
18295
+ };
18296
+ xhr.onerror = (e) => {
18297
+ var _a;
18298
+ (_a = this.loader) === null || _a === void 0 ? void 0 : _a.classList.remove('loading');
18299
+ this.logError(['getNodeIdFromFullpath XHR ERROR', e, xhr.statusText]);
18300
+ reject("null 4");
18301
+ };
18302
+ if (this.theOptions.origin == 'thesaurus') {
18303
+ let payload = {
18304
+ "sValue": fullpath,
18305
+ "sTypeField": "fullpath"
18306
+ };
18307
+ if (this.theOptions && this.theOptions.options && this.theOptions.options.StartNodeID) {
18308
+ payload.iStartNode = parseInt(this.theOptions.options.StartNodeID.toString());
18256
18309
  }
18310
+ // if (this.theOptions && this.theOptions.options && this.theOptions.options.lng){
18311
+ // payload.sLng = this.theOptions.options.lng;
18312
+ // }
18313
+ xhr.send(JSON.stringify(payload));
18257
18314
  }
18258
- };
18259
- xhr.onerror = function (e) {
18260
- var _a;
18261
- (_a = that.loader) === null || _a === void 0 ? void 0 : _a.classList.remove('loading');
18262
- that.logError(['XHR ERROR', e, xhr.statusText]);
18263
- };
18264
- if (this.options.origin == 'thesaurus') {
18265
- xhr.send(JSON.stringify({
18266
- "sValue": fullpath,
18267
- "sTypeField": "fullpath"
18268
- }));
18269
- }
18270
- else if (this.options.origin == 'position') {
18271
- xhr.send(JSON.stringify({
18272
- "value": fullpath
18273
- }));
18274
- }
18275
- // TODO -> this does not exist, set accordingly to future API
18276
- else if (this.options.origin == 'classification') {
18277
- xhr.send(JSON.stringify({
18278
- "fullpath_system": fullpath
18279
- }));
18280
- }
18281
- return toret;
18315
+ else if (this.theOptions.origin == 'position') {
18316
+ let payload = {
18317
+ "value": fullpath
18318
+ };
18319
+ if (this.theOptions && this.theOptions.options && this.theOptions.options.StartNodeID) {
18320
+ payload.startNode = this.theOptions.options.StartNodeID;
18321
+ }
18322
+ xhr.send(JSON.stringify(payload));
18323
+ }
18324
+ // TODO -> this does not exist, set accordingly to future API
18325
+ else if (this.theOptions.origin == 'classification') {
18326
+ xhr.send(JSON.stringify({
18327
+ fullpath_system: fullpath,
18328
+ }));
18329
+ }
18330
+ // CHECK return toret;
18331
+ });
18282
18332
  }
18283
18333
  // Triggers a XHR request and stores the result in this.rawData
18284
18334
  getDataFromSourceClassification(url, options, init = false) {
18285
18335
  var _a;
18286
18336
  let that = this;
18287
18337
  (_a = this.loader) === null || _a === void 0 ? void 0 : _a.classList.add('loading');
18288
- let targetURL = url + "/" + options.startNode;
18289
- if (options.searchedValue) {
18290
- targetURL += "/" + options.searchedValue;
18291
- }
18338
+ let targetURL = url + '/' + options.startNode;
18339
+ // if (options.searchedValue) {
18340
+ // targetURL += '/' + options.searchedValue;
18341
+ // }
18292
18342
  let getDataPromise = new Promise((resolve, reject) => {
18293
- this.getToken().then((token) => {
18294
- let xhr = new XMLHttpRequest();
18343
+ this.getToken().then(token => {
18344
+ let xhr = new browser();
18295
18345
  xhr.open('GET', targetURL);
18296
- xhr.setRequestHeader('Authorization', 'Bearer ' + token);
18297
- xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
18346
+ // xhr.setRequestHeader('Authorization', 'Bearer ' + token);
18347
+ // xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
18298
18348
  xhr.onload = function (e) {
18299
18349
  var _a;
18300
18350
  (_a = that.loader) === null || _a === void 0 ? void 0 : _a.classList.remove('loading');
@@ -18303,7 +18353,7 @@ const MyComponent = class {
18303
18353
  if (xhr.status === 200) {
18304
18354
  that.mylog('XHR 200', JSON.parse(xhr.responseText));
18305
18355
  if (that.rawData) {
18306
- that.rawData = that.searchAndMergeData(that.rawData, JSON.parse(xhr.responseText));
18356
+ that.rawData = that.searchAndMergeDataClassification(that.rawData, JSON.parse(xhr.responseText));
18307
18357
  }
18308
18358
  else {
18309
18359
  that.rawData = JSON.parse(xhr.responseText);
@@ -18337,49 +18387,57 @@ const MyComponent = class {
18337
18387
  // Triggers a XHR request and stores the result in this.rawData
18338
18388
  getDataFromSource(url, options, init = false) {
18339
18389
  var _a;
18340
- let that = this;
18341
18390
  (_a = this.loader) === null || _a === void 0 ? void 0 : _a.classList.add('loading');
18391
+ // if (options.searchedValue) {
18392
+ // targetURL += '/' + options.searchedValue;
18393
+ // }
18342
18394
  let getDataPromise = new Promise((resolve, reject) => {
18343
- this.getToken().then((token) => {
18344
- let xhr = new XMLHttpRequest();
18395
+ this.getToken().then(token => {
18396
+ let xhr = new browser();
18345
18397
  xhr.open('POST', url);
18346
18398
  xhr.setRequestHeader('Authorization', 'Bearer ' + token);
18347
18399
  xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
18348
- xhr.onload = function (e) {
18400
+ xhr.onload = (e) => {
18349
18401
  var _a;
18350
- (_a = that.loader) === null || _a === void 0 ? void 0 : _a.classList.remove('loading');
18351
- that.mylog('XHR ONLOAD', e, xhr.statusText);
18352
- if (xhr.readyState === 4) {
18353
- if (xhr.status === 200) {
18354
- that.mylog('XHR 200', JSON.parse(xhr.responseText));
18355
- if (that.rawData) {
18356
- that.rawData = that.searchAndMergeData(that.rawData, JSON.parse(xhr.responseText));
18402
+ try {
18403
+ (_a = this.loader) === null || _a === void 0 ? void 0 : _a.classList.remove('loading');
18404
+ this.mylog('getDataFromSource XHR ONLOAD', e, xhr.statusText);
18405
+ if (xhr.readyState === 4) {
18406
+ if (xhr.status === 200) {
18407
+ this.mylog('getDataFromSource XHR 200', JSON.parse(xhr.responseText));
18408
+ if (this.rawData) {
18409
+ this.rawData = this.searchAndMergeData(this.rawData, JSON.parse(xhr.responseText));
18410
+ }
18411
+ else {
18412
+ this.rawData = JSON.parse(xhr.responseText);
18413
+ }
18414
+ resolve(JSON.parse(xhr.responseText));
18415
+ this.ready = true;
18357
18416
  }
18358
18417
  else {
18359
- that.rawData = JSON.parse(xhr.responseText);
18418
+ this.logError(['getDataFromSource XHR NOT 200', xhr.statusText]);
18419
+ this.errorLoadingXHR();
18420
+ reject('getDataFromSource XHR NOT 200');
18360
18421
  }
18361
- resolve(JSON.parse(xhr.responseText));
18362
- if (init) {
18363
- that.formatDefaultValue();
18364
- that.showSelectedNodes();
18365
- }
18366
- that.ready = true;
18367
- }
18368
- else {
18369
- that.logError(['XHR NOT 200', xhr.statusText]);
18370
- that.errorLoadingXHR();
18371
- reject();
18372
18422
  }
18373
18423
  }
18424
+ catch (error) {
18425
+ this.logError("There has been an issue with xhr.onload in getDataFromSource: " + error.toString());
18426
+ }
18374
18427
  };
18375
- xhr.onerror = function (e) {
18428
+ xhr.onerror = (e) => {
18376
18429
  var _a;
18377
- (_a = that.loader) === null || _a === void 0 ? void 0 : _a.classList.remove('loading');
18378
- that.logError(['XHR ERROR', e, xhr.statusText]);
18379
- that.errorLoadingXHR();
18380
- reject();
18430
+ (_a = this.loader) === null || _a === void 0 ? void 0 : _a.classList.remove('loading');
18431
+ this.logError(['getDataFromSource XHR ERROR', e, xhr.statusText]);
18432
+ this.errorLoadingXHR();
18433
+ reject(e);
18381
18434
  };
18382
- xhr.send(JSON.stringify(options));
18435
+ try {
18436
+ xhr.send(JSON.stringify(options));
18437
+ }
18438
+ catch (error) {
18439
+ this.logError("There has been an issue with xhr.send in getDataFromSource: " + error.toString());
18440
+ }
18383
18441
  });
18384
18442
  });
18385
18443
  return getDataPromise;
@@ -18388,46 +18446,45 @@ const MyComponent = class {
18388
18446
  errorLoadingXHR() {
18389
18447
  var _a;
18390
18448
  this.displayPickerError('Error loading webservice data!');
18391
- document.querySelector('#tree-area-' + this.componentID).innerHTML = 'Error loading webservice data!';
18392
- // NB: Maybe shouldnt be removed but hidden ...
18393
- (_a = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search input')) === null || _a === void 0 ? void 0 : _a.remove();
18394
- this.canload = false;
18395
- this.showTree("hide");
18396
- this.ready = true;
18397
- this.ignoreOptionsChanges = false;
18449
+ try {
18450
+ document.querySelector('#tree-area-' + this.componentID).innerHTML = 'Error loading webservice data!';
18451
+ // NB: Maybe shouldnt be removed but hidden ...
18452
+ (_a = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search input')) === null || _a === void 0 ? void 0 : _a.remove();
18453
+ this.canload = false;
18454
+ this.showTree("hide");
18455
+ this.ready = true;
18456
+ this.ignoreOptionsChanges = false;
18457
+ }
18458
+ catch (_b) {
18459
+ console.error('Error loading webservice data!');
18460
+ }
18398
18461
  }
18399
18462
  getApiSearchURL() {
18400
- if (this.options.origin == "classification") {
18401
- return (this.options.url.substring(0, this.options.url.lastIndexOf("/")) + '/search-tree');
18463
+ if (this.theOptions.origin == 'classification') {
18464
+ return this.theOptions.url;
18465
+ // return this.theOptions.url.substring(0, this.theOptions.url.lastIndexOf('/'));
18402
18466
  }
18403
18467
  else {
18404
- return (this.options.url.substring(0, this.options.url.lastIndexOf("/")) + '/GetTreeFromSearch');
18468
+ return this.theOptions.url.substring(0, this.theOptions.url.lastIndexOf('/')) + '/GetTreeFromSearch';
18405
18469
  }
18406
18470
  }
18407
18471
  getApiNodeFromFullpathURL() {
18408
- if (this.options.origin == 'thesaurus') {
18409
- return (this.options.url.substring(0, this.options.url.lastIndexOf("/")) + '/existBy');
18472
+ if (this.theOptions.origin == 'thesaurus') {
18473
+ return (this.theOptions.url.substring(0, this.theOptions.url.lastIndexOf("/")) + '/existBy');
18410
18474
  }
18411
- else if (this.options.origin == 'position') {
18412
- return (this.options.url.substring(0, this.options.url.lastIndexOf("/")) + '/PositionExistByFp');
18475
+ else if (this.theOptions.origin == 'position') {
18476
+ return (this.theOptions.url.substring(0, this.theOptions.url.lastIndexOf("/")) + '/PositionExistByFp');
18413
18477
  }
18414
18478
  // TODO -> this does not exist, set accordingly to future API
18415
- else if (this.options.origin == 'classification') {
18416
- return (this.options.url.substring(0, this.options.url.lastIndexOf("/")) + '/exists');
18479
+ else if (this.theOptions.origin == 'classification') {
18480
+ return this.theOptions.url.substring(0, this.theOptions.url.lastIndexOf('/')) + '/exists';
18417
18481
  }
18418
18482
  }
18419
18483
  rawDataWatcher(dataToLoad) {
18420
- let rootnode = 0;
18421
- if (this.options.origin == "classification") {
18422
- rootnode = this.options.options.startNode;
18423
- }
18424
- else {
18425
- rootnode = this.options.options.StartNodeID;
18426
- }
18427
18484
  //This makes the tree to be created only once after the rawData loading
18428
18485
  if (!this.ready) {
18429
- this.translateDataForTree(dataToLoad, rootnode);
18430
- if (this.options.openTreeWhenLoaded) {
18486
+ this.translateDataForTree(dataToLoad);
18487
+ if (this.theOptions.openTreeWhenLoaded) {
18431
18488
  this.showTree("modale");
18432
18489
  }
18433
18490
  }
@@ -18454,25 +18511,24 @@ const MyComponent = class {
18454
18511
  return toret;
18455
18512
  }
18456
18513
  displayAutocompleteWithResults(data, searched) {
18457
- if (data && this.options.showAutocomplete) {
18458
- var that = this;
18514
+ if (data && this.theOptions.showAutocomplete) {
18459
18515
  var nodes = this.getNodesFromSearch(data, searched);
18460
18516
  nodes = nodes.sort(function (a, b) {
18461
18517
  var textA = a.text.toUpperCase();
18462
18518
  var textB = b.text.toUpperCase();
18463
- return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;
18519
+ return textA < textB ? -1 : textA > textB ? 1 : 0;
18464
18520
  });
18465
18521
  this.clearAutocomplete();
18466
- let autocomplete_results = document.getElementById("autocomplete-results-area");
18522
+ let autocomplete_results = document.getElementById('autocomplete-results-area');
18467
18523
  autocomplete_results.innerHTML = '';
18468
18524
  if (data && searched && searched.length > 0) {
18469
18525
  for (let i = 0; i < nodes.length; i++) {
18470
18526
  autocomplete_results.innerHTML += '<li title="' + nodes[i].text + '" nodeid="' + nodes[i].id + '">' + nodes[i].text + '</li>';
18471
18527
  }
18472
18528
  autocomplete_results.querySelectorAll("li").forEach((item) => {
18473
- item.addEventListener("click", function (evt) {
18474
- that.editValue(that.findNodeById(that.loadedTreeJs, this.attributes.getNamedItem("nodeid").value));
18475
- that.showTree("hide");
18529
+ item.addEventListener("click", (evt) => {
18530
+ this.editValue(this.findNodeById(this.loadedTreeJs, item.attributes.getNamedItem("nodeid").value));
18531
+ this.showTree("hide");
18476
18532
  });
18477
18533
  });
18478
18534
  this.showAutocomplete();
@@ -18480,34 +18536,35 @@ const MyComponent = class {
18480
18536
  }
18481
18537
  }
18482
18538
  showAutocomplete() {
18483
- if (this.options.showAutocomplete) {
18539
+ if (this.theOptions.showAutocomplete) {
18484
18540
  let autocomplete_results = document.getElementById("autocomplete-results-area");
18485
18541
  autocomplete_results.style.display = 'block';
18486
18542
  }
18487
18543
  }
18488
18544
  clearAutocomplete(eraseResults = false) {
18489
- if (this.options.showAutocomplete) {
18545
+ if (this.theOptions.showAutocomplete) {
18490
18546
  // setTimeout(() => {
18491
- let autocomplete_results = document.getElementById("autocomplete-results-area");
18547
+ let autocomplete_results = document.getElementById('autocomplete-results-area');
18492
18548
  autocomplete_results.style.display = 'none';
18493
18549
  if (eraseResults) {
18494
- autocomplete_results.innerHTML = "";
18550
+ autocomplete_results.innerHTML = '';
18495
18551
  }
18496
18552
  // }, 0);
18497
18553
  }
18498
18554
  }
18499
- loadSearchDataInCurrentTree(dataToLoad, rootnode, searched) {
18555
+ loadSearchDataInCurrentTree(dataToLoad, searchID, searched) {
18500
18556
  let displayResults = () => {
18501
- if (this.searchToDisplay > -1) {
18557
+ if (this.searchToDisplay > -1 && searchID == this.searchToDisplay) {
18502
18558
  this.rawData.children.forEach((value, index) => {
18503
- this.completeCurrentTreeWithTree(value, rootnode);
18559
+ // this.completeCurrentTreeWithTree(value, dataToLoad);
18560
+ this.completeCurrentTreeWithTree(dataToLoad);
18504
18561
  });
18505
18562
  this.triggerTreeDisplay(this.rawData, searched);
18506
18563
  this.displayAutocompleteWithResults(this.rawData, searched);
18507
18564
  // Deploys all nodes
18508
18565
  document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node').forEach((item) => {
18509
18566
  var _a;
18510
- const childspans = Array.prototype.slice.call(item.querySelectorAll(":scope > ul > li > span"));
18567
+ const childspans = Array.prototype.slice.call(item.querySelectorAll("ul > li > span"));
18511
18568
  let hasUndefinedchild = childspans.filter((ele) => {
18512
18569
  return ele.textContent === "undefined";
18513
18570
  });
@@ -18517,31 +18574,37 @@ const MyComponent = class {
18517
18574
  });
18518
18575
  }
18519
18576
  };
18520
- if (this.options.source == 'webservice') {
18521
- if (this.options.origin == "classification") {
18577
+ if (this.theOptions.source == 'webservice') {
18578
+ if (this.theOptions.origin == 'classification') {
18522
18579
  // WS Call
18523
18580
  this.getDataFromSourceClassification(this.getApiSearchURL(), {
18524
- startNode: this.options.options.startNode,
18581
+ startNode: this.theOptions.options.startNode,
18525
18582
  searchedValue: searched,
18526
18583
  // searchNameOnly: true,
18527
18584
  // deprecated: false
18528
18585
  }).then(displayResults),
18529
- (err) => {
18586
+ err => {
18530
18587
  console.error('err', err);
18531
18588
  };
18532
18589
  }
18533
18590
  else {
18534
18591
  // WS Call
18535
18592
  this.getDataFromSource(this.getApiSearchURL(), {
18536
- StartNodeID: this.options.options.StartNodeID,
18537
- lng: this.options.options.lng,
18593
+ StartNodeID: this.theOptions.options.StartNodeID,
18594
+ lng: this.theOptions.options.lng,
18538
18595
  searchedValue: searched,
18539
18596
  searchNameOnly: true,
18540
18597
  deprecated: false
18541
- }).then(displayResults),
18542
- (err) => {
18543
- console.error('err', err);
18544
- };
18598
+ })
18599
+ .then(displayResults)
18600
+ .catch((error) => {
18601
+ try {
18602
+ this.errorToLog = "getDataFromSource 1 rejected:" + JSON.stringify(error, replacer, 2);
18603
+ }
18604
+ catch (_a) {
18605
+ console.error("getDataFromSource 2 rejected:", JSON.stringify(error, replacer, 2));
18606
+ }
18607
+ });
18545
18608
  }
18546
18609
  }
18547
18610
  else {
@@ -18549,19 +18612,19 @@ const MyComponent = class {
18549
18612
  }
18550
18613
  }
18551
18614
  triggerTreeDisplay(dataToLoad, searched) {
18552
- if (this.options.origin == 'thesaurus') {
18615
+ if (this.theOptions.origin == 'thesaurus') {
18553
18616
  this.translateDataFromThesaurus(dataToLoad, searched);
18554
18617
  }
18555
- if (this.options.origin == 'position') {
18618
+ if (this.theOptions.origin == 'position') {
18556
18619
  this.translateDataFromPosition(dataToLoad, searched);
18557
18620
  }
18558
- if (this.options.origin == 'classification') {
18621
+ if (this.theOptions.origin == 'classification') {
18559
18622
  this.translateDataFromClassification(dataToLoad, searched);
18560
18623
  }
18561
18624
  }
18562
- translateDataForTree(dataToLoad, rootnode, searched = null) {
18625
+ translateDataForTree(dataToLoad, searchID = null, searched = null) {
18563
18626
  if (searched != null) {
18564
- this.loadSearchDataInCurrentTree(dataToLoad, rootnode, searched);
18627
+ this.loadSearchDataInCurrentTree(dataToLoad, searchID, searched);
18565
18628
  }
18566
18629
  else {
18567
18630
  this.triggerTreeDisplay(dataToLoad, searched);
@@ -18570,7 +18633,7 @@ const MyComponent = class {
18570
18633
  getPropertyFromNode(node, property, logerror = true) {
18571
18634
  property = property.trim();
18572
18635
  if (!node || !property) {
18573
- return "";
18636
+ return '';
18574
18637
  }
18575
18638
  if (node[property] || node[property] === 0) {
18576
18639
  return node[property];
@@ -18584,39 +18647,39 @@ const MyComponent = class {
18584
18647
  }
18585
18648
  // Translates datas from Thesaurus into an understandable object to pass to treejs dependency
18586
18649
  translateDataFromThesaurus(dataToLoad, searched = null) {
18587
- if (this.options.origin != 'thesaurus' || !dataToLoad)
18650
+ if (this.theOptions.origin != 'thesaurus' || !dataToLoad)
18588
18651
  return;
18589
- this.mylog('Translate from Thesaurus ! (' + this.options.source + ')', dataToLoad);
18652
+ this.mylog('Translate from Thesaurus ! (' + this.theOptions.source + ')', dataToLoad);
18590
18653
  let fillTreeWithObject = (tree, object, depth = 0) => {
18591
18654
  if (object && object.length) {
18592
18655
  object.forEach((value, _index) => {
18593
- let keyPropFromNode = this.getPropertyFromNode(value, "key");
18594
- let valueTranslatedPropFromNode = this.getPropertyFromNode(value, "valueTranslated");
18595
- let fullpathPropFromNode = this.getPropertyFromNode(value, "fullpath");
18596
- let fullpathTranslatedPropFromNode = this.getPropertyFromNode(value, "fullpathTranslated");
18597
- let hasChildrenPropFromNode = this.getPropertyFromNode(value, "hasChildren", false);
18598
- let childrenPropFromNode = this.getPropertyFromNode(value, "children", false);
18599
- let deprecated = this.getPropertyFromNode(value, "deprecated", false);
18656
+ let keyPropFromNode = this.getPropertyFromNode(value, 'key');
18657
+ let valueTranslatedPropFromNode = this.getPropertyFromNode(value, 'valueTranslated');
18658
+ let fullpathPropFromNode = this.getPropertyFromNode(value, 'fullpath');
18659
+ let fullpathTranslatedPropFromNode = this.getPropertyFromNode(value, 'fullpathTranslated');
18660
+ let childrenPropFromNode = this.getPropertyFromNode(value, 'children', false);
18661
+ let deprecated = this.getPropertyFromNode(value, 'deprecated', false);
18600
18662
  let objToPush = {
18601
18663
  id: keyPropFromNode,
18602
18664
  depth: depth,
18603
18665
  text: valueTranslatedPropFromNode,
18604
18666
  fullpath: fullpathPropFromNode,
18605
18667
  fullpathTranslated: fullpathTranslatedPropFromNode,
18606
- children: (hasChildrenPropFromNode && childrenPropFromNode && childrenPropFromNode.length == 0 ? [{}] : []),
18668
+ children: this.getPropertyFromNode(value, 'hasChildren', false) && childrenPropFromNode && childrenPropFromNode.length == 0 ? [{}] : [],
18607
18669
  deprecated: deprecated,
18608
18670
  isDesaturated: false,
18671
+ searchMatch: false
18609
18672
  };
18610
18673
  let childTree = fillTreeWithObject(objToPush.children, childrenPropFromNode, depth + 1);
18611
18674
  let pushMe = false;
18612
- let searchValue = (obj) => {
18675
+ let searchValue = (obj, strict) => {
18613
18676
  let toret = false;
18614
18677
  if (obj.text.toLowerCase().indexOf(searched.toLowerCase()) > -1) {
18615
18678
  toret = true;
18616
18679
  }
18617
- else if (obj.children.length > 0 && Object.keys(obj.children[0]).length != 0) {
18618
- obj.children.forEach((descend) => {
18619
- if (searchValue(descend)) {
18680
+ else if (!strict && obj.children.length > 0 && Object.keys(obj.children[0]).length != 0) {
18681
+ obj.children.forEach(descend => {
18682
+ if (searchValue(descend, strict)) {
18620
18683
  toret = true;
18621
18684
  }
18622
18685
  });
@@ -18624,9 +18687,10 @@ const MyComponent = class {
18624
18687
  return toret;
18625
18688
  };
18626
18689
  if (searched) {
18627
- const matched = searchValue(objToPush);
18690
+ const matched = searchValue(objToPush, false);
18628
18691
  objToPush.isDesaturated = !matched;
18629
- pushMe = matched || this.options.searchResultPresentsUnMatched;
18692
+ objToPush.searchMatch = searchValue(objToPush, true);
18693
+ pushMe = matched || this.theOptions.searchResultPresentsUnMatched;
18630
18694
  }
18631
18695
  else {
18632
18696
  pushMe = true;
@@ -18639,36 +18703,37 @@ const MyComponent = class {
18639
18703
  }
18640
18704
  return tree;
18641
18705
  };
18642
- this.displayTree(fillTreeWithObject([], !this.options.displayRootNode ? dataToLoad.children : [dataToLoad]));
18706
+ this.displayTree(fillTreeWithObject([], !this.theOptions.displayRootNode ? dataToLoad.children : [dataToLoad]));
18643
18707
  }
18644
18708
  // Translates datas from Position into an understandable object to pass to treejs dependency
18645
18709
  translateDataFromPosition(dataToLoad, searched = null) {
18646
- if (this.options.origin != 'position' || !dataToLoad)
18710
+ if (this.theOptions.origin != 'position' || !dataToLoad)
18647
18711
  return;
18648
- let that = this;
18649
- let fillTreeWithObject = function (tree, object, depth = 0) {
18712
+ let fillTreeWithObject = (tree, object, depth = 0) => {
18650
18713
  if (object.length) {
18651
- object.forEach(function (value, _index) {
18714
+ object.forEach((value, _index) => {
18652
18715
  let objToPush = {
18653
- id: that.getPropertyFromNode(value, "key"),
18716
+ id: this.getPropertyFromNode(value, "key"),
18654
18717
  depth: depth,
18655
- text: that.getPropertyFromNode(value, "valueTranslated"),
18656
- fullpath: that.getPropertyFromNode(value, "fullpath"),
18657
- fullpathTranslated: that.getPropertyFromNode(value, "fullpathTranslated"),
18658
- children: (that.getPropertyFromNode(value, "hasChildren", false) &&
18659
- that.getPropertyFromNode(value, "children").length == 0 ? [{}] : []),
18660
- deprecated: that.getPropertyFromNode(value, "deprecated", false),
18718
+ text: this.getPropertyFromNode(value, "valueTranslated"),
18719
+ fullpath: this.getPropertyFromNode(value, "fullpath"),
18720
+ fullpathTranslated: this.getPropertyFromNode(value, "fullpathTranslated"),
18721
+ children: (this.getPropertyFromNode(value, "hasChildren", false) &&
18722
+ this.getPropertyFromNode(value, "children").length == 0 ? [{}] : []),
18723
+ deprecated: this.getPropertyFromNode(value, "deprecated", false),
18724
+ isDesaturated: false,
18725
+ searchMatch: false
18661
18726
  };
18662
- let childTree = fillTreeWithObject(objToPush.children, that.getPropertyFromNode(value, "children", false), depth + 1);
18727
+ let childTree = fillTreeWithObject(objToPush.children, this.getPropertyFromNode(value, 'children', false), depth + 1);
18663
18728
  let pushMe = false;
18664
- let searchValue = function (obj) {
18729
+ let searchValue = (obj, strict) => {
18665
18730
  let toret = false;
18666
18731
  if (obj.text.toLowerCase().indexOf(searched.toLowerCase()) > -1) {
18667
18732
  toret = true;
18668
18733
  }
18669
- else if (obj.children.length > 0 && Object.keys(obj.children[0]).length != 0) {
18734
+ else if (!strict && obj.children.length > 0 && Object.keys(obj.children[0]).length != 0) {
18670
18735
  obj.children.forEach((descend) => {
18671
- if (searchValue(descend)) {
18736
+ if (searchValue(descend, strict)) {
18672
18737
  toret = true;
18673
18738
  }
18674
18739
  });
@@ -18676,7 +18741,10 @@ const MyComponent = class {
18676
18741
  return toret;
18677
18742
  };
18678
18743
  if (searched) {
18679
- pushMe = searchValue(objToPush);
18744
+ const matched = searchValue(objToPush, false);
18745
+ objToPush.isDesaturated = !matched;
18746
+ objToPush.searchMatch = searchValue(objToPush, true);
18747
+ pushMe = matched || this.theOptions.searchResultPresentsUnMatched;
18680
18748
  }
18681
18749
  else {
18682
18750
  pushMe = true;
@@ -18689,35 +18757,37 @@ const MyComponent = class {
18689
18757
  }
18690
18758
  return tree;
18691
18759
  };
18692
- this.displayTree(fillTreeWithObject([], !this.options.displayRootNode ? dataToLoad.children : [dataToLoad]));
18760
+ this.displayTree(fillTreeWithObject([], !this.theOptions.displayRootNode ? dataToLoad.children : [dataToLoad]));
18693
18761
  }
18694
18762
  translateDataFromClassification(dataToLoad, searched = null) {
18695
- if (this.options.origin != 'classification' || !dataToLoad)
18763
+ if (this.theOptions.origin != 'classification' || !dataToLoad)
18696
18764
  return;
18697
18765
  let that = this;
18698
18766
  let fillTreeWithObject = function (tree, object, depth = 0) {
18699
18767
  if (object.length) {
18700
18768
  object.forEach(function (value, _index) {
18701
18769
  let objToPush = {
18702
- id: that.getPropertyFromNode(value, "ID"),
18770
+ id: that.getPropertyFromNode(value, 'ID'),
18703
18771
  depth: depth,
18704
- text: that.getPropertyFromNode(value, "Name"),
18705
- fullpath: that.getPropertyFromNode(value, "FullPath"),
18706
- fullpathTranslated: that.getPropertyFromNode(value, "FullPath"),
18707
- children: (that.getPropertyFromNode(value, "children", false).length > 0 &&
18772
+ text: that.getPropertyFromNode(value, 'Name'),
18773
+ fullpath: that.getPropertyFromNode(value, 'Properties').FullPath,
18774
+ fullpathTranslated: that.getPropertyFromNode(value, 'Properties').FullPath,
18775
+ children: (that.getPropertyFromNode(value, "hasChildren", false) &&
18708
18776
  that.getPropertyFromNode(value, "children").length == 0 ? [{}] : []),
18709
- deprecated: that.getPropertyFromNode(value, "IsDeprecated", false),
18777
+ deprecated: that.getPropertyFromNode(value, 'IsDeprecated', false),
18778
+ isDesaturated: false,
18779
+ searchMatch: false
18710
18780
  };
18711
- let childTree = fillTreeWithObject(objToPush.children, that.getPropertyFromNode(value, "children", false), depth + 1);
18781
+ let childTree = fillTreeWithObject(objToPush.children, that.getPropertyFromNode(value, 'children', false), depth + 1);
18712
18782
  let pushMe = false;
18713
- let searchValue = function (obj) {
18783
+ let searchValue = (obj, strict) => {
18714
18784
  let toret = false;
18715
18785
  if (obj.text.toLowerCase().indexOf(searched.toLowerCase()) > -1) {
18716
18786
  toret = true;
18717
18787
  }
18718
- else if (obj.children.length > 0 && Object.keys(obj.children[0]).length != 0) {
18719
- obj.children.forEach((descend) => {
18720
- if (searchValue(descend)) {
18788
+ else if (!strict && obj.children.length > 0 && Object.keys(obj.children[0]).length != 0) {
18789
+ obj.children.forEach(descend => {
18790
+ if (searchValue(descend, strict)) {
18721
18791
  toret = true;
18722
18792
  }
18723
18793
  });
@@ -18725,7 +18795,10 @@ const MyComponent = class {
18725
18795
  return toret;
18726
18796
  };
18727
18797
  if (searched) {
18728
- pushMe = searchValue(objToPush);
18798
+ const matched = searchValue(objToPush, false);
18799
+ objToPush.isDesaturated = !matched;
18800
+ objToPush.searchMatch = searchValue(objToPush, true);
18801
+ pushMe = matched || this.theOptions.searchResultPresentsUnMatched;
18729
18802
  }
18730
18803
  else {
18731
18804
  pushMe = true;
@@ -18738,66 +18811,60 @@ const MyComponent = class {
18738
18811
  }
18739
18812
  return tree;
18740
18813
  };
18741
- this.displayTree(fillTreeWithObject([], !this.options.displayRootNode ? dataToLoad.children : [dataToLoad]));
18814
+ this.displayTree(fillTreeWithObject([], !this.theOptions.displayRootNode ? dataToLoad.children : [dataToLoad]));
18742
18815
  }
18743
18816
  findNodeById(myTree, nodeId) {
18744
- let node = myTree.nodesById[nodeId];
18745
- if (!node) {
18746
- return null;
18747
- }
18748
- return myTree.nodesById[nodeId];
18817
+ return !myTree.nodesById[nodeId] ? null : myTree.nodesById[nodeId];
18749
18818
  }
18750
18819
  // Finds the root of the new tree in the current tree (wherever it may be), and adds the children of the new tree to it
18751
- completeCurrentTreeWithTree(newTree, rootnode) {
18820
+ completeCurrentTreeWithTree(newTree) {
18752
18821
  let that = this;
18753
18822
  // Creates a new tree with results from WS call
18754
18823
  let shortFillTreeWithObject = function (parent, tree, object, first, depth) {
18755
18824
  // If passed node has elements
18756
18825
  if ((first || (tree && tree.length != 0)) && object && Object.keys(object).length != 0 && object.length) {
18757
- object.forEach(function (value, _index) {
18826
+ object.forEach((value, _index) => {
18758
18827
  let objToPush = value;
18759
- if (that.options.origin == "classification") {
18760
- if (that.getPropertyFromNode(value, "ID", false) != null) {
18828
+ if (that.theOptions.origin == 'classification') {
18829
+ if (that.getPropertyFromNode(value, 'ID', false) != null) {
18761
18830
  objToPush = {
18762
- id: that.getPropertyFromNode(value, "ID"),
18831
+ id: that.getPropertyFromNode(value, 'ID'),
18763
18832
  depth: depth,
18764
18833
  parent: parent,
18765
- text: that.getPropertyFromNode(value, "Name"),
18766
- fullpath: that.getPropertyFromNode(value, "FullPath"),
18767
- fullpathTranslated: that.getPropertyFromNode(value, "FullPath"),
18768
- children: (that.getPropertyFromNode(value, "children", false).length > 0 &&
18769
- that.getPropertyFromNode(value, "children").length == 0 ? [{}] : []),
18770
- deprecated: that.getPropertyFromNode(value, "IsDeprecated", false),
18834
+ text: that.getPropertyFromNode(value, 'Name'),
18835
+ fullpath: that.getPropertyFromNode(value.Properties, 'FullPath'),
18836
+ fullpathTranslated: that.getPropertyFromNode(value.Properties, 'FullPath'),
18837
+ children: that.getPropertyFromNode(value, 'hasChildren', false) && that.getPropertyFromNode(value, 'children').length == 0 ? [{}] : [],
18838
+ deprecated: that.getPropertyFromNode(value.Properties, 'IsDeprecated', false),
18771
18839
  };
18772
18840
  }
18773
18841
  }
18774
18842
  else {
18775
- if (that.getPropertyFromNode(value, "key", false) != null) {
18843
+ if (that.getPropertyFromNode(value, 'key', false) != null) {
18776
18844
  objToPush = {
18777
- id: that.getPropertyFromNode(value, "key"),
18845
+ id: that.getPropertyFromNode(value, 'key'),
18778
18846
  depth: depth,
18779
18847
  parent: parent,
18780
- text: that.getPropertyFromNode(value, "valueTranslated"),
18781
- fullpath: that.getPropertyFromNode(value, "fullpath"),
18782
- fullpathTranslated: that.getPropertyFromNode(value, "fullpathTranslated"),
18783
- children: (that.getPropertyFromNode(value, "hasChildren", false) &&
18784
- that.getPropertyFromNode(value, "children").length == 0 ? [{}] : []),
18785
- deprecated: that.getPropertyFromNode(value, "deprecated", false),
18848
+ text: that.getPropertyFromNode(value, 'valueTranslated'),
18849
+ fullpath: that.getPropertyFromNode(value, 'fullpath'),
18850
+ fullpathTranslated: that.getPropertyFromNode(value, 'fullpathTranslated'),
18851
+ children: that.getPropertyFromNode(value, 'hasChildren', false) && that.getPropertyFromNode(value, 'children').length == 0 ? [{}] : [],
18852
+ deprecated: that.getPropertyFromNode(value, 'deprecated', false),
18786
18853
  };
18787
18854
  }
18788
18855
  }
18789
- objToPush.children = shortFillTreeWithObject(objToPush, objToPush.children, that.getPropertyFromNode(value, "children", false), false, depth + 1);
18856
+ objToPush.children = shortFillTreeWithObject(objToPush, objToPush.children, that.getPropertyFromNode(value, 'children', false), false, depth + 1);
18790
18857
  tree.push(objToPush);
18791
18858
  });
18792
18859
  }
18793
18860
  return tree;
18794
18861
  };
18795
18862
  // targetNode = an object stored by the library
18796
- let targetNode = this.findNodeById(this.loadedTreeJs, rootnode);
18863
+ let targetNode = this.findNodeById(this.loadedTreeJs, newTree.key);
18797
18864
  if (targetNode != null) {
18798
18865
  // empty the children of the node in the library
18799
18866
  targetNode.children = [];
18800
- let liElmID = rootnode;
18867
+ let liElmID = (newTree.key ? newTree.key : (newTree.id ? newTree.id : newTree.ID));
18801
18868
  var ulElem = this.loadedTreeJs.liElementsById[liElmID].querySelector('ul');
18802
18869
  let filledtree = shortFillTreeWithObject({
18803
18870
  id: liElmID,
@@ -18806,12 +18873,12 @@ const MyComponent = class {
18806
18873
  text: this.loadedTreeJs.nodesById[liElmID].text,
18807
18874
  fullpath: this.loadedTreeJs.nodesById[liElmID].fullpath,
18808
18875
  fullpathTranslated: this.loadedTreeJs.nodesById[liElmID].fullpathTranslated,
18809
- children: this.loadedTreeJs.nodesById[liElmID].children
18876
+ children: this.loadedTreeJs.nodesById[liElmID].children,
18810
18877
  }, [], newTree.children, true, targetNode.depth + 1);
18811
18878
  if (filledtree.length > 0) {
18812
- ulElem.innerHTML = "";
18879
+ ulElem.innerHTML = '';
18813
18880
  }
18814
- // that.rawData = result from WS call
18881
+ // this.rawData = result from WS call
18815
18882
  (filledtree).forEach((item) => {
18816
18883
  if (Object.keys(item).length != 0) {
18817
18884
  //Foreach item in the newly created tree, create the DOM elements to inject - BEGIN
@@ -18825,10 +18892,10 @@ const MyComponent = class {
18825
18892
  this.loadedTreeJs.treeNodes.push(item);
18826
18893
  //If has children, prepare sub elements
18827
18894
  if (item.children && item.children.length > 0) {
18828
- var liElems = ulElem.querySelectorAll("li");
18895
+ var liElems = ulElem.querySelectorAll('li');
18829
18896
  liElems[liElems.length - 1].appendChild(this.loadedTreeJs.createUlEle());
18830
- liElems[liElems.length - 1].querySelector("ul").appendChild(this.loadedTreeJs.createLiEle(item.children));
18831
- that.completeCurrentTreeWithTree(item, item.id);
18897
+ liElems[liElems.length - 1].querySelector('ul').appendChild(this.loadedTreeJs.createLiEle(item.children));
18898
+ this.completeCurrentTreeWithTree(item);
18832
18899
  }
18833
18900
  }
18834
18901
  });
@@ -18836,10 +18903,10 @@ const MyComponent = class {
18836
18903
  this.deactivateNodesOutOfDepthSettings();
18837
18904
  }
18838
18905
  deactivateNodesOutOfDepthSettings() {
18839
- if (this.options.maxDepth || this.options.minDepth) {
18906
+ if (this.theOptions.maxDepth != undefined || this.theOptions.minDepth != undefined) {
18840
18907
  for (let index in this.loadedTreeJs.nodesById) {
18841
18908
  let element = this.loadedTreeJs.nodesById[index];
18842
- if (element.depth < this.options.minDepth || element.depth > this.options.maxDepth) {
18909
+ if (element.depth < this.theOptions.minDepth || element.depth > this.theOptions.maxDepth) {
18843
18910
  this.loadedTreeJs.liElementsById[element.id].classList.add('readonly_node');
18844
18911
  }
18845
18912
  }
@@ -18859,6 +18926,20 @@ const MyComponent = class {
18859
18926
  });
18860
18927
  }
18861
18928
  onItemDragOver(el, e) {
18929
+ let now = new Date().getTime();
18930
+ if (now - this.lastDragedOverTimeForAscendent < 50 && el.nodeId != this.lastDragedOverNodeId) {
18931
+ return;
18932
+ }
18933
+ this.lastDragedOverTimeForAscendent = now;
18934
+ if (el.nodeId == this.lastDragedOverNodeId) {
18935
+ if (now - this.lastDragedOverTimeForLevel < this.acceptableDelayBetweenSimilarActions) {
18936
+ return;
18937
+ }
18938
+ this.lastDragedOverTimeForLevel = now;
18939
+ }
18940
+ else {
18941
+ this.lastDragedOverNodeId = el.nodeId;
18942
+ }
18862
18943
  this.clearDragOverPos(el);
18863
18944
  if (el == this.curDraggingItem) {
18864
18945
  el.classList.remove('dragover');
@@ -18887,7 +18968,7 @@ const MyComponent = class {
18887
18968
  this.itemDropped.emit({
18888
18969
  dragEl: this.curDraggingItem,
18889
18970
  dropEl: el,
18890
- position: this.getDragOverPos(el, e)
18971
+ position: this.getDragOverPos(el, e),
18891
18972
  });
18892
18973
  }
18893
18974
  getDragOverPos(el, e) {
@@ -18919,30 +19000,29 @@ const MyComponent = class {
18919
19000
  }
18920
19001
  // Displays the tree
18921
19002
  async displayTree(treeData) {
18922
- let that = this;
18923
- if (!this.options.displayTree && this.ready)
19003
+ if (!this.theOptions.displayTree && this.ready)
18924
19004
  return;
18925
19005
  if (treeData.length == 0) {
18926
- document.querySelector('#tree-area-' + this.componentID).innerHTML = 'No search results ...';
19006
+ this.el.querySelector('.hierarchized-picker-tree').innerHTML = 'No search results ...';
18927
19007
  return;
18928
19008
  }
18929
19009
  let myTree = new Tree('#tree-area-' + this.componentID, {
18930
19010
  parentApi: this,
18931
19011
  data: treeData,
18932
- onChange: async function () {
19012
+ onChange: async () => {
18933
19013
  let oldValue;
18934
19014
  try {
18935
- oldValue = await that.getValue();
19015
+ oldValue = await this.getValue();
18936
19016
  }
18937
19017
  catch (error) {
18938
19018
  oldValue = null;
18939
19019
  }
18940
19020
  let emitValueChange = async () => {
18941
- let newValue = await that.getValue();
18942
- if (that.valueChangeCallback && that.ready && !that.shownTree) {
18943
- that.valueChangeCallback(newValue);
19021
+ let newValue = await this.getValue();
19022
+ if (this.valueChangeCallback && this.ready && !this.shownTree) {
19023
+ this.valueChangeCallback(newValue);
18944
19024
  }
18945
- that.valueChange.emit({ oldValue: oldValue, newValue: newValue, value: newValue });
19025
+ this.valueChange.emit({ oldValue: oldValue, newValue: newValue, value: newValue });
18946
19026
  };
18947
19027
  // TODO > Try to find why this has been previously added
18948
19028
  // setTimeout(() => {
@@ -18961,13 +19041,13 @@ const MyComponent = class {
18961
19041
  this.showSelectedNodes();
18962
19042
  this.deactivateNodesOutOfDepthSettings();
18963
19043
  // Hides checkboxes in non multiple context
18964
- if (!this.options.multiple) {
19044
+ if (!this.theOptions.multiple) {
18965
19045
  document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = 'none'));
18966
19046
  }
18967
19047
  }
18968
19048
  async setNodeAsSelected(id, treeToUpdate, userClick) {
18969
- if ((this.disabled && this.shownTree && this.setValueOnClick) ||
18970
- this.loadedTreeJs.liElementsById[id].classList.value.indexOf("readonly_node") != -1)
19049
+ if ((this.isDisabled && this.shownTree && this.setValueOnClick) ||
19050
+ (this.loadedTreeJs.liElementsById[id].classList.value && this.loadedTreeJs.liElementsById[id].classList.value.indexOf("readonly_node") != -1))
18971
19051
  return;
18972
19052
  this.ignoreOptionsChanges = true;
18973
19053
  // Override of treejs normal workaround =>> DONT EDIT IT!
@@ -18984,7 +19064,7 @@ const MyComponent = class {
18984
19064
  this.editValue(node);
18985
19065
  if (this.shownTree && userClick) {
18986
19066
  await this.focusMainInput();
18987
- if (!this.options.multiple) {
19067
+ if (!this.theOptions.multiple) {
18988
19068
  this.showTree("hide");
18989
19069
  }
18990
19070
  }
@@ -18992,21 +19072,21 @@ const MyComponent = class {
18992
19072
  this.ignoreOptionsChanges = false;
18993
19073
  }
18994
19074
  async focusSearchInput() {
18995
- this.mylog("focusSearchInput");
19075
+ this.mylog('focusSearchInput');
18996
19076
  let searchInput = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search input');
18997
19077
  if (searchInput) {
18998
19078
  await searchInput.focus();
18999
19079
  }
19000
19080
  }
19001
19081
  async focusMainInput() {
19002
- this.mylog("focusMainInput");
19082
+ this.mylog('focusMainInput');
19003
19083
  let mainInput = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-input');
19004
19084
  if (mainInput) {
19005
19085
  await mainInput.focus();
19006
19086
  }
19007
19087
  }
19008
19088
  async focusModal() {
19009
- this.mylog("focusModal");
19089
+ this.mylog('focusModal');
19010
19090
  let modalArea = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-modal-area');
19011
19091
  if (modalArea) {
19012
19092
  await modalArea.focus();
@@ -19017,71 +19097,91 @@ const MyComponent = class {
19017
19097
  document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node').forEach((item) => item.classList.add('treejs-node__close'));
19018
19098
  }
19019
19099
  // Displays all selected nodes by deploying nodes that contain selected
19020
- showSelectedNodes() {
19021
- let scrollToValue = 0;
19022
- let removeClosedAndLookUp = (element) => {
19023
- var _a, _b, _c, _d;
19024
- const nodeId = element === null || element === void 0 ? void 0 : element.nodeId;
19025
- if (!element || !nodeId) {
19026
- return;
19100
+ async showSelectedNodes(addDelay = false) {
19101
+ if (this.theOptions.multiple) {
19102
+ console.warn("You are not allowed to scroll to selected nodes in multiple mode");
19103
+ return;
19104
+ }
19105
+ const scrollToNode = () => {
19106
+ let scrollToValue = 0;
19107
+ let removeClosedAndLookUp = (element) => {
19108
+ var _a, _b, _c, _d;
19109
+ const nodeId = element === null || element === void 0 ? void 0 : element.nodeId;
19110
+ if (!element || !nodeId) {
19111
+ return;
19112
+ }
19113
+ const node = this.loadedTreeJs.nodesById[nodeId];
19114
+ if ((_b = (_a = node === null || node === void 0 ? void 0 : node.children) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id) {
19115
+ (_c = element.classList) === null || _c === void 0 ? void 0 : _c.remove('treejs-node__close');
19116
+ }
19117
+ scrollToValue += element.offsetTop;
19118
+ const parent = (_d = element.parentNode) === null || _d === void 0 ? void 0 : _d.closest('.treejs-node');
19119
+ if (parent) {
19120
+ removeClosedAndLookUp(parent);
19121
+ }
19122
+ };
19123
+ try {
19124
+ const checkeds = document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node__checked');
19125
+ checkeds.forEach((item) => removeClosedAndLookUp(item));
19027
19126
  }
19028
- const node = this.loadedTreeJs.nodesById[nodeId];
19029
- if ((_b = (_a = node === null || node === void 0 ? void 0 : node.children) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id) {
19030
- (_c = element.classList) === null || _c === void 0 ? void 0 : _c.remove('treejs-node__close');
19127
+ catch (err) {
19031
19128
  }
19032
- scrollToValue += element.offsetTop;
19033
- const parent = (_d = element.parentNode) === null || _d === void 0 ? void 0 : _d.closest('.treejs-node');
19034
- if (parent) {
19035
- removeClosedAndLookUp(parent);
19129
+ if (scrollToValue && this.scrollable) {
19130
+ this.scrollable.scrollTop = scrollToValue;
19036
19131
  }
19037
19132
  };
19038
- const checkeds = document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node__checked');
19039
- checkeds.forEach((item) => removeClosedAndLookUp(item));
19040
- if (scrollToValue && this.scrollable) {
19041
- this.scrollable.scrollTop = scrollToValue;
19133
+ if (addDelay) {
19134
+ setTimeout(() => {
19135
+ scrollToNode();
19136
+ }, 200);
19137
+ }
19138
+ else {
19139
+ scrollToNode();
19042
19140
  }
19043
19141
  }
19044
19142
  // Event to manage the Display/Hide of the tree
19045
19143
  showTree(focused) {
19144
+ if (!this.hasFocus)
19145
+ this.hasFocus = [];
19046
19146
  this.clearAutocomplete();
19047
- if (!this.canload || !this.options.displayTree)
19147
+ if (!this.canload || !this.theOptions.displayTree)
19048
19148
  return;
19049
19149
  this.mylog("--------- showTree-" + this.componentID, focused, this.hasFocus);
19050
19150
  // hide tree when asked to or when it is disabled
19051
- if (focused == "hide" || this.disabled) {
19052
- this.hasFocus = ["hide"];
19151
+ if (focused == 'hide' || this.isDisabled) {
19152
+ this.hasFocus = ['hide'];
19053
19153
  let elem = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search input');
19054
19154
  if (elem) {
19055
- elem.value = "";
19155
+ elem.value = '';
19056
19156
  }
19057
- // this.search("");
19157
+ this.search("");
19058
19158
  }
19059
19159
  else {
19060
- if (this.hasFocus.indexOf(focused) == -1 && this.hasFocus.indexOf("hide") == -1) {
19160
+ if (this.hasFocus.indexOf(focused) == -1 && this.hasFocus.indexOf('hide') == -1) {
19061
19161
  this.hasFocus.push(focused);
19062
19162
  }
19063
19163
  }
19064
- if (!this.shownTree && this.options.loading == "click") {
19164
+ if (!this.shownTree && this.theOptions.loading == "click") {
19065
19165
  this.loadDataForTree();
19066
19166
  }
19067
- if (this.hasFocus.indexOf("hide") > -1) {
19167
+ if (this.hasFocus.indexOf('hide') > -1) {
19068
19168
  this.hasFocus = [];
19069
19169
  }
19070
19170
  let previousShownTree = this.shownTree;
19071
19171
  this.shownTree = this.hasFocus.length > 0;
19072
- if (!previousShownTree && this.shownTree) {
19073
- this.showSelectedNodes();
19074
- }
19075
19172
  if (!this.shownTree) {
19076
19173
  this.collapseAllNodes();
19077
19174
  this.clearAutocomplete(true);
19078
19175
  }
19079
- if (focused == "picker") {
19176
+ if (focused == 'picker') {
19080
19177
  this.focusSearchInput();
19081
19178
  }
19082
19179
  else {
19083
19180
  this.focusModal();
19084
19181
  }
19182
+ if (!previousShownTree && this.shownTree) {
19183
+ this.showSelectedNodes(true);
19184
+ }
19085
19185
  }
19086
19186
  // Changes the value of the component with passed node
19087
19187
  editValue(node) {
@@ -19097,7 +19197,7 @@ const MyComponent = class {
19097
19197
  this.value.splice(result, 1);
19098
19198
  } // Else, add the node to the array of values
19099
19199
  else {
19100
- if (this.options.multiple) {
19200
+ if (this.theOptions.multiple) {
19101
19201
  this.value = [...this.value, {
19102
19202
  nodeid: node.id,
19103
19203
  fullpath: node.fullpath,
@@ -19110,7 +19210,7 @@ const MyComponent = class {
19110
19210
  nodeid: node.id,
19111
19211
  fullpath: node.fullpath,
19112
19212
  fullpathTranslated: node.fullpathTranslated,
19113
- shortpathTranslated: node.text
19213
+ shortpathTranslated: node.text,
19114
19214
  };
19115
19215
  }
19116
19216
  }
@@ -19120,7 +19220,7 @@ const MyComponent = class {
19120
19220
  setDisplayedValue(value = null) {
19121
19221
  if (!value)
19122
19222
  value = this.value;
19123
- this.displayedValue = value.map(item => (this.options.isFullpath
19223
+ this.displayedValue = value.map(item => (this.theOptions.isFullpath
19124
19224
  ?
19125
19225
  item.fullpathTranslated
19126
19226
  :
@@ -19128,15 +19228,16 @@ const MyComponent = class {
19128
19228
  }
19129
19229
  // Search a value in the tree and triggers a search when necessary
19130
19230
  search(searched) {
19131
- if (this.options.mode == 'input') {
19132
- document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search input').classList.remove('fieldError');
19231
+ let searchinput = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search input');
19232
+ if (this.theOptions.mode == 'input' && searchinput) {
19233
+ searchinput.classList.remove('fieldError');
19133
19234
  }
19134
19235
  if (searched.length > 2) {
19135
19236
  this.searchToDisplay += 1;
19136
19237
  let me = this.searchToDisplay;
19137
19238
  setTimeout(() => {
19138
19239
  if (this.searchToDisplay == me) {
19139
- this.triggerSearch(searched);
19240
+ this.triggerSearch(searched, me);
19140
19241
  //Recheck previously selected fields ?
19141
19242
  this.checkFields(this.value, false);
19142
19243
  }
@@ -19144,55 +19245,67 @@ const MyComponent = class {
19144
19245
  }
19145
19246
  else {
19146
19247
  this.searchToDisplay = -1;
19147
- let rootnode = 0;
19148
- if (this.options.origin == "classification") {
19149
- rootnode = this.options.options.startNode;
19248
+ if (this.theOptions.source == "webservice") {
19249
+ let rootnode = 0;
19250
+ if (this.theOptions.origin == 'classification') {
19251
+ rootnode = this.theOptions.options.startNode;
19252
+ }
19253
+ else {
19254
+ rootnode = this.theOptions.options.StartNodeID;
19255
+ }
19256
+ //Displays the full tree
19257
+ this.translateDataForTree(this.rawData, rootnode);
19150
19258
  }
19151
19259
  else {
19152
- rootnode = this.options.options.StartNodeID;
19260
+ this.translateDataForTree(this.rawData);
19153
19261
  }
19154
- //Displays the full tree
19155
- this.translateDataForTree(this.rawData, rootnode);
19156
19262
  //Reset autocomplete
19157
- this.displayAutocompleteWithResults(null, "");
19263
+ this.displayAutocompleteWithResults(null, '');
19158
19264
  //Recheck previously selected fields ?
19159
19265
  this.checkFields(this.value, false);
19160
19266
  }
19161
19267
  }
19162
19268
  // Refresh the tree with search results
19163
- triggerSearch(searched) {
19164
- let rootnode = 0;
19165
- if (this.options.origin == "classification") {
19166
- rootnode = this.options.options.startNode;
19167
- }
19168
- else {
19169
- rootnode = this.options.options.StartNodeID;
19170
- }
19171
- this.translateDataForTree(this.rawData, rootnode, searched);
19269
+ triggerSearch(searched, searchID) {
19270
+ this.translateDataForTree(this.rawData, searchID, searched);
19172
19271
  }
19173
19272
  displayPickerError(errorMsg = "") {
19174
- document.querySelector('#hierarchized-picker-' + this.componentID).classList.add('fieldError');
19175
- if (errorMsg == "") {
19176
- errorMsg = "There has been an error ... [Generic]";
19273
+ try {
19274
+ document.querySelector('#hierarchized-picker-' + this.componentID).classList.add('fieldError');
19275
+ if (this.theOptions.errorsInInput) {
19276
+ if (errorMsg == "") {
19277
+ errorMsg = "There has been an error ... > [Generic error]";
19278
+ }
19279
+ this.displayedValue = errorMsg;
19280
+ // this.isDisabled = true;
19281
+ this.errorToLog = errorMsg;
19282
+ }
19283
+ }
19284
+ catch (_a) {
19285
+ console.error(errorMsg);
19177
19286
  }
19178
- this.displayedValue = errorMsg;
19179
19287
  }
19180
19288
  setRawDataFromFile(filePath) {
19181
19289
  try {
19182
- var rawFile = new XMLHttpRequest();
19290
+ var rawFile = new browser();
19183
19291
  rawFile.open("GET", filePath);
19184
19292
  rawFile.onreadystatechange = () => {
19185
- if (rawFile.readyState === 4) {
19186
- if (rawFile.status === 200 || rawFile.status == 0) {
19187
- var allText = rawFile.responseText;
19188
- this.rawData = JSON.parse(allText);
19189
- this.formatDefaultValue();
19190
- this.showSelectedNodes();
19191
- }
19192
- else {
19193
- this.displayPickerError('Error loading Data from path "' + filePath + '"!');
19293
+ try {
19294
+ if (rawFile.readyState === 4) {
19295
+ if (rawFile.status === 200 || rawFile.status == 0) {
19296
+ var allText = rawFile.responseText;
19297
+ this.rawData = JSON.parse(allText);
19298
+ this.formatDefaultValue();
19299
+ this.showSelectedNodes();
19300
+ }
19301
+ else {
19302
+ this.displayPickerError('Error loading Data from path "' + filePath + '"!');
19303
+ }
19194
19304
  }
19195
19305
  }
19306
+ catch (err) {
19307
+ this.displayPickerError('Error loading Data from path "' + filePath + '"!');
19308
+ }
19196
19309
  };
19197
19310
  if (!this.rawData) {
19198
19311
  rawFile.send(null);
@@ -19209,48 +19322,67 @@ const MyComponent = class {
19209
19322
  }
19210
19323
  }
19211
19324
  loadDataForTree(init = false) {
19212
- if (this.options.source == 'webservice') {
19213
- if (this.options.origin == "classification") {
19214
- this.getDataFromSourceClassification(this.options.url, this.options.options, init);
19325
+ if (this.theOptions.source == 'webservice') {
19326
+ if (this.theOptions.origin == 'classification') {
19327
+ this.getDataFromSourceClassification(this.theOptions.url, this.theOptions.options, init);
19215
19328
  }
19216
19329
  else {
19217
- this.getDataFromSource(this.options.url, this.options.options, init);
19330
+ this.getDataFromSource(this.theOptions.url, this.theOptions.options, init)
19331
+ .then(() => {
19332
+ if (init) {
19333
+ this.formatDefaultValue();
19334
+ this.showSelectedNodes();
19335
+ }
19336
+ })
19337
+ .catch((error) => {
19338
+ try {
19339
+ this.errorToLog = "getDataFromSource 3 rejected:" + JSON.stringify(error, replacer, 2);
19340
+ }
19341
+ catch (_a) {
19342
+ console.error("getDataFromSource 4 rejected:", JSON.stringify(error, replacer, 2));
19343
+ }
19344
+ });
19218
19345
  }
19219
19346
  }
19220
- if (this.options.source == 'data') {
19221
- this.rawData = typeof this.options.data === 'object' ? this.options.data : JSON.parse(this.options.data);
19347
+ if (this.theOptions.source == 'data') {
19348
+ this.rawData = typeof this.theOptions.data === 'object' ? this.theOptions.data : JSON.parse(this.theOptions.data);
19349
+ this.formatDefaultValue();
19222
19350
  }
19223
- if (this.options.source == 'file') {
19224
- this.setRawDataFromFile(this.options.url);
19351
+ if (this.theOptions.source == 'file') {
19352
+ this.setRawDataFromFile(this.theOptions.url);
19225
19353
  }
19226
19354
  }
19227
19355
  componentWillRender() {
19228
- this.mylog("----- componentWillRender beginning");
19356
+ this.mylog("----- componentWillRender beginning -----");
19229
19357
  }
19230
19358
  componentDidRender() {
19231
- this.mylog("----- componentDidRender beginning");
19359
+ this.mylog("----- componentDidRender beginning -----");
19232
19360
  }
19233
19361
  displayWhenLoaded() {
19234
19362
  if (!this.canload) {
19235
19363
  this.displayPickerError('Error(s) in the picker configuration!');
19236
19364
  return;
19237
19365
  }
19238
- if (this.options && this.options.loading == "display") {
19366
+ if (this.theOptions && this.theOptions.loading == "display") {
19239
19367
  this.loadDataForTree(true);
19240
19368
  }
19241
19369
  }
19242
19370
  componentDidLoad() {
19243
- this.mylog("----- componentDidLoad beginning");
19371
+ this.mylog("----- componentDidLoad beginning -----");
19244
19372
  this.displayWhenLoaded();
19245
19373
  }
19246
19374
  checkFields(values, allowSetValueOnClick = true) {
19247
- let that = this;
19248
19375
  this.setValueOnClick = allowSetValueOnClick;
19249
19376
  if (values) {
19250
- values.forEach(element => {
19251
- if (Object.keys(this.loadedTreeJs.liElementsById).indexOf(element.nodeid.toString()) > -1) {
19252
- if (this.loadedTreeJs.liElementsById[element.nodeid].classList.value.indexOf("treejs-node__checked") == -1) {
19253
- that.setNodeAsSelected(element.nodeid, this.loadedTreeJs, false);
19377
+ values.forEach((element) => {
19378
+ let intNodeid = element.nodeid;
19379
+ if (typeof intNodeid == "string" && isNumeric(intNodeid)) {
19380
+ intNodeid = parseInt(intNodeid);
19381
+ }
19382
+ if (Object.keys(this.loadedTreeJs.liElementsById).indexOf(element.nodeid) > -1) {
19383
+ if ((this.loadedTreeJs.liElementsById[element.nodeid].classList.value && this.loadedTreeJs.liElementsById[element.nodeid].classList.value.indexOf("treejs-node__checked") == -1) ||
19384
+ this.theOptions.defaultValue.indexOf(intNodeid) != -1) {
19385
+ this.setNodeAsSelected(element.nodeid, this.loadedTreeJs, false);
19254
19386
  }
19255
19387
  }
19256
19388
  });
@@ -19258,25 +19390,25 @@ const MyComponent = class {
19258
19390
  this.setValueOnClick = true;
19259
19391
  }
19260
19392
  formatDefaultValue() {
19261
- let that = this;
19262
19393
  let found = 0;
19394
+ let that = this;
19263
19395
  let recursive = function (children) {
19264
- children.forEach(element => {
19265
- that.options.defaultValue.forEach(dfValue => {
19396
+ children.forEach((element) => {
19397
+ that.theOptions.defaultValue.forEach(dfValue => {
19266
19398
  if (typeof dfValue == 'string' && isNumeric(dfValue)) {
19267
19399
  dfValue = parseInt(dfValue);
19268
19400
  }
19269
- if (that.options.origin == "classification") {
19270
- if ((typeof dfValue == 'string' && that.getPropertyFromNode(element, "FullPath") == dfValue) ||
19271
- (typeof dfValue == 'number' && that.getPropertyFromNode(element, "ID") == dfValue)) {
19401
+ if (that.theOptions.origin == 'classification') {
19402
+ if ((typeof dfValue == 'string' && that.getPropertyFromNode(element, 'Properties.FullPath') == dfValue) ||
19403
+ (typeof dfValue == 'number' && that.getPropertyFromNode(element, 'ID') == dfValue)) {
19272
19404
  element.nodeid = element.id;
19273
19405
  that.checkFields([element]);
19274
19406
  found++;
19275
19407
  }
19276
19408
  }
19277
19409
  else {
19278
- if ((typeof dfValue == 'string' && that.getPropertyFromNode(element, "fullpathTranslated") == dfValue) ||
19279
- (typeof dfValue == 'number' && that.getPropertyFromNode(element, "key") == dfValue)) {
19410
+ if ((typeof dfValue == 'string' && that.getPropertyFromNode(element, 'fullpathTranslated') == dfValue) ||
19411
+ (typeof dfValue == 'number' && that.getPropertyFromNode(element, 'key') == dfValue)) {
19280
19412
  element.nodeid = element.key;
19281
19413
  that.checkFields([element]);
19282
19414
  found++;
@@ -19290,14 +19422,20 @@ const MyComponent = class {
19290
19422
  if (this.rawData) {
19291
19423
  recursive([this.rawData]);
19292
19424
  }
19293
- if (this.options.defaultValue.length != found) {
19425
+ if (this.theOptions.defaultValue.length != found) {
19294
19426
  if (found == 0) {
19295
- this.errorToLog = "The loaded tree doesn't contain the nodes passed to options.defaultValue : " +
19296
- this.options.defaultValue.map(item => item).join(',');
19427
+ try {
19428
+ this.errorToLog = "The loaded tree doesn't contain the nodes passed to options.defaultValue : " +
19429
+ this.theOptions.defaultValue.map(item => item).join(',');
19430
+ }
19431
+ catch (_a) {
19432
+ this.errorToLog = "The loaded tree doesn't contain the nodes passed to options.defaultValue : there's an issue with your defaultValue > " +
19433
+ this.theOptions.defaultValue.toString();
19434
+ }
19297
19435
  }
19298
19436
  else {
19299
19437
  this.errorToLog = "The loaded tree contains multiple nodes of what has been passed to options.defaultValue : " +
19300
- this.options.defaultValue.map(item => item).join(',');
19438
+ this.theOptions.defaultValue.map(item => item).join(',');
19301
19439
  }
19302
19440
  this.displayPickerError('Error(s) when loading tree default value(s)!');
19303
19441
  }
@@ -19343,42 +19481,46 @@ const MyComponent = class {
19343
19481
  this.search(event.target.value);
19344
19482
  }
19345
19483
  render() {
19346
- return (this.options ?
19347
- index.h("div", { id: 'hierarchized-picker-' + this.componentID, class: "hierarchized-picker " + (this.disabled ? "readonly-mode" : "") }, (this.options.mode == "input" ?
19348
- index.h("div", { class: "hierarchized-picker-container" }, index.h("div", { style: { display: "none" }, ref: (el => {
19349
- this.loader = el;
19350
- }) }, "TODO"), index.h("div", { class: "hierarchized-picker-input-area" }, this.options.label ? index.h("label", { class: "hierarchized-picker-label" }, this.options.label) : '', index.h("span", { class: 'hierarchized-picker-input ' + (this.options.icon && this.options.icon.length > 0 ? "hierarchized-picker-icon" : "") +
19351
- ' reneco ' + (this.options.icon ? this.options.icon : "") + (this.disabled ? " readonly " : "") +
19352
- ' sc-ion-input-md-h sc-ion-input-md-s md ', id: 'hierarchized-picker-input-' + this.componentID, onClick: _event => {
19353
- this.showTree("picker");
19354
- }, onFocusin: _event => {
19355
- this.showTree("modale");
19356
- } }, index.h("input", { class: "native-input sc-ion-input-md", "aria-labelledby": "ion-input-13-lbl", autocapitalize: "off", autocomplete: "off", autocorrect: "off", name: "ion-input-13", placeholder: "", readonly: "", spellcheck: "false", type: "text", value: this.displayedValue })), (this.displayedValue && !this.disabled && this.canload) ?
19357
- index.h("span", { class: "reneco reneco-close", onClick: () => this.clearPicker() })
19358
- : ''), index.h("div", { class: 'hierarchized-picker-modal-area ' + (!this.shownTree ? ' hidden ' : ''), onClick: event => {
19359
- this.clickPickerModalArea(event);
19360
- } }, index.h("div", { class: 'hierarchized-picker-modal ' + (!this.ready ? 'hidden' : '') }, index.h("div", { id: 'hierarchized-picker-input-search-' + this.componentID, class: "hierarchized-picker-search reneco reneco-search" +
19361
- " sc-ion-input-md-h sc-ion-input-md-s md", onKeyUp: event => {
19362
- this.keyUpPickerSearchInput(event);
19363
- }, onFocusin: event => {
19364
- setTimeout(() => {
19365
- this.showAutocomplete();
19366
- }, 500);
19367
- if (this.hasFocus.length == 0)
19368
- this.focusInSearchEvent(event);
19369
- }, onFocusout: event => {
19370
- this.focusOutSearchEvent(event);
19371
- } }, index.h("input", { class: "native-input sc-ion-input-md", autocapitalize: "off", autocomplete: "off", autocorrect: "off", name: "ion-input-0", placeholder: this.options.searchPlaceholder, spellcheck: "false", type: "text" })), index.h("ul", { id: "autocomplete-results-area" }), index.h("div", { id: 'tree-area-' + this.componentID, class: 'hierarchized-picker-tree-area ' + this.pickerClass }))))
19372
- :
19373
- index.h("div", { class: 'hierarchized-picker-raw-tree-area', onClick: event => {
19374
- this.clickPickerModalArea(event);
19375
- } }, index.h("div", { class: "loader", ref: (el => {
19376
- this.loader = el;
19377
- }) }, index.h("div", { class: "loader-inner" }, "Loading...")), index.h("div", { ref: (el) => {
19378
- this.scrollable = el;
19379
- }, id: 'tree-area-' + this.componentID, class: 'scrollable hierarchized-picker-raw-tree ' + this.pickerClass }))))
19380
- :
19381
- index.h("div", { class: "fieldError" }, "Generic loading issue..."));
19484
+ return (this.theOptions
19485
+ ?
19486
+ index.h("div", { id: 'hierarchized-picker-' + this.componentID, class: "hierarchized-picker " + (this.isDisabled ? "readonly-mode" : "") }, (this.theOptions.mode == "input"
19487
+ ?
19488
+ index.h("div", { class: "hierarchized-picker-container" }, index.h("div", { style: { display: "none" }, ref: (el => {
19489
+ this.loader = el;
19490
+ }) }), index.h("div", { class: "hierarchized-picker-input-area" }, this.theOptions.label ? index.h("label", { class: "hierarchized-picker-label" }, this.theOptions.label) : '', index.h("span", { class: 'hierarchized-picker-input ' + (this.theOptions.icon && this.theOptions.icon.length > 0 ? "hierarchized-picker-icon" : "") +
19491
+ ' reneco ' + (this.theOptions.icon ? this.theOptions.icon : "") + (this.isDisabled ? " readonly " : "") +
19492
+ ' sc-ion-input-md-h sc-ion-input-md-s md ', id: 'hierarchized-picker-input-' + this.componentID, onClick: _event => {
19493
+ this.showTree("picker");
19494
+ }, onFocusin: _event => {
19495
+ this.showTree("modale");
19496
+ } }, index.h("input", { class: "native-input sc-ion-input-md", "aria-labelledby": "ion-input-13-lbl", autocapitalize: "off", autocomplete: "off", autocorrect: "off", name: "ion-input-13", placeholder: "", readonly: "", spellcheck: "false", type: "text", value: this.displayedValue })), (this.displayedValue && !this.isDisabled && this.canload) ?
19497
+ index.h("span", { class: "reneco reneco-close", onClick: () => this.clearPicker() })
19498
+ : ''), index.h("div", { ref: (el) => {
19499
+ // Uncomment if you want the modale of picker in input mode to scroll to selected node on openning >>>
19500
+ this.scrollable = el;
19501
+ }, class: 'hierarchized-picker-modal-area ' + (!this.shownTree ? ' hidden ' : ''), onClick: event => {
19502
+ this.clickPickerModalArea(event);
19503
+ } }, index.h("div", { class: 'hierarchized-picker-modal ' + (!this.ready ? 'hidden' : '') }, index.h("div", { id: 'hierarchized-picker-input-search-' + this.componentID, class: "hierarchized-picker-search reneco reneco-search" +
19504
+ " sc-ion-input-md-h sc-ion-input-md-s md", onKeyUp: event => {
19505
+ this.keyUpPickerSearchInput(event);
19506
+ }, onFocusin: event => {
19507
+ setTimeout(() => {
19508
+ this.showAutocomplete();
19509
+ }, 500);
19510
+ if (this.hasFocus.length == 0)
19511
+ this.focusInSearchEvent(event);
19512
+ }, onFocusout: event => {
19513
+ this.focusOutSearchEvent(event);
19514
+ } }, index.h("input", { class: "native-input sc-ion-input-md", autocapitalize: "off", autocomplete: "off", autocorrect: "off", name: "ion-input-0", placeholder: this.theOptions.searchPlaceholder, spellcheck: "false", type: "text" })), 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 }))))
19515
+ :
19516
+ index.h("div", { class: 'hierarchized-picker-raw-tree-area' + (this.isDisabled ? " readonly" : ""), onClick: event => {
19517
+ this.clickPickerModalArea(event);
19518
+ } }, index.h("div", { class: "loader", ref: (el => {
19519
+ this.loader = el;
19520
+ }) }, index.h("div", { class: "loader-inner" }, "Loading...")), index.h("div", { ref: (el) => {
19521
+ this.scrollable = el;
19522
+ }, id: 'tree-area-' + this.componentID, class: 'hierarchized-picker-tree scrollable hierarchized-picker-raw-tree ' + this.pickerClass }))))
19523
+ : (index.h("div", { class: "fieldError" }, "Generic loading issue...")));
19382
19524
  }
19383
19525
  get el() { return index.getElement(this); }
19384
19526
  static get watchers() { return {
@@ -19389,6 +19531,6 @@ const MyComponent = class {
19389
19531
  "rawData": ["rawDataWatcher"]
19390
19532
  }; }
19391
19533
  };
19392
- MyComponent.style = hierarchizedPickerCss;
19534
+ HierarchizedPickerComponent.style = hierarchizedPickerCss;
19393
19535
 
19394
- exports.reneco_hierarchized_picker = MyComponent;
19536
+ exports.reneco_hierarchized_picker = HierarchizedPickerComponent;