reneco-hierarchized-picker 0.4.3-beta.9 → 0.5.1
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.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/reneco-hierarchized-picker.cjs.js +1 -1
- package/dist/cjs/reneco-hierarchized-picker_2.cjs.entry.js +520 -285
- package/dist/collection/components/hierarchized-picker/hierarchized-picker.css +10 -2
- package/dist/collection/components/hierarchized-picker/hierarchized-picker.js +403 -144
- package/dist/collection/components/search-input/search-input.js +1 -3
- package/dist/collection/components/treejs/index.js +49 -50
- package/dist/collection/core/options-manager.js +2 -0
- package/dist/collection/features/events/focus-handlers.js +15 -11
- package/dist/collection/features/keyboard-navigation/keyboard-navigation.js +82 -57
- package/dist/collection/features/tree/tree-utils.js +12 -3
- package/dist/collection/utils/conf-helper.js +4 -0
- package/dist/collection/utils/constants.js +4 -3
- package/dist/collection/utils/theme-utils.js +1 -0
- package/dist/custom-elements/index.js +520 -285
- package/dist/esm/loader.js +1 -1
- package/dist/esm/reneco-hierarchized-picker.js +1 -1
- package/dist/esm/reneco-hierarchized-picker_2.entry.js +520 -285
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/reneco-hierarchized-picker.js +1 -1
- package/dist/esm-es5/reneco-hierarchized-picker_2.entry.js +2 -2
- package/dist/reneco-hierarchized-picker/p-73168a50.system.js +1 -1
- package/dist/reneco-hierarchized-picker/p-ca142f5a.entry.js +1 -0
- package/dist/reneco-hierarchized-picker/p-d6a25038.system.entry.js +3 -0
- package/dist/reneco-hierarchized-picker/reneco-hierarchized-picker.esm.js +1 -1
- package/dist/types/components/hierarchized-picker/hierarchized-picker.d.ts +13 -2
- package/dist/types/components.d.ts +6 -0
- package/dist/types/core/options-manager.d.ts +1 -1
- package/dist/types/features/keyboard-navigation/keyboard-navigation.d.ts +2 -1
- package/dist/types/features/tree/tree-utils.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +1 -0
- package/package.json +1 -1
- package/dist/reneco-hierarchized-picker/p-934e9cf8.entry.js +0 -1
- package/dist/reneco-hierarchized-picker/p-9ddab37d.system.entry.js +0 -3
|
@@ -9,6 +9,7 @@ function applyPickerTheme(theme, defaultTheme) {
|
|
|
9
9
|
docstyle.setProperty('--hpicker-theme-palette-background-default', (theme === null || theme === void 0 ? void 0 : theme.palette.background.default) || defaultTheme.palette.background.default);
|
|
10
10
|
docstyle.setProperty('--hpicker-theme-palette-background-light', (theme === null || theme === void 0 ? void 0 : theme.palette.background.light) || defaultTheme.palette.background.light);
|
|
11
11
|
docstyle.setProperty('--hpicker-theme-palette-background-dark', (theme === null || theme === void 0 ? void 0 : theme.palette.background.dark) || defaultTheme.palette.background.dark);
|
|
12
|
+
docstyle.setProperty('--hpicker-theme-palette-font-color', (theme === null || theme === void 0 ? void 0 : theme.palette.text.primary) || defaultTheme.palette.text.primary);
|
|
12
13
|
docstyle.setProperty('--hpicker-theme-palette-input-background-color', (theme === null || theme === void 0 ? void 0 : theme.palette.input.background) || defaultTheme.palette.input.background);
|
|
13
14
|
docstyle.setProperty('--hpicker-theme-palette-input-border-style', (theme === null || theme === void 0 ? void 0 : theme.palette.input.borderStyle) || defaultTheme.palette.input.borderStyle);
|
|
14
15
|
docstyle.setProperty('--hpicker-theme-typography-body-font-size', (theme === null || theme === void 0 ? void 0 : theme.typography.body.fontSize) || defaultTheme.typography.body.fontSize);
|
|
@@ -319,49 +320,6 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
319
320
|
else if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher')) {
|
|
320
321
|
this.onSwitcherClick(target);
|
|
321
322
|
}
|
|
322
|
-
const hasUndefinedchild = e.target.parentNode.querySelectorAll(".treejs-switcher").length > 0 && e.target.parentNode.querySelectorAll('ul').length == 0;
|
|
323
|
-
//CUSTOM
|
|
324
|
-
const childspans = Array.prototype.slice.call(e.target.parentNode.querySelectorAll('ul > li > span.treejs-label')).filter((ele) => {
|
|
325
|
-
return ele.parentNode.parentNode.parentNode === e.target.parentNode;
|
|
326
|
-
});
|
|
327
|
-
let undefinedChildren = [];
|
|
328
|
-
//This may be a problem the day a node value is "undefined"
|
|
329
|
-
undefinedChildren = childspans.filter(ele => {
|
|
330
|
-
return ele.textContent === 'undefined';
|
|
331
|
-
});
|
|
332
|
-
// If the user clicked on an unloaded node
|
|
333
|
-
if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher') && (undefinedChildren.length > 0 || hasUndefinedchild)) {
|
|
334
|
-
// Clear the subnode HTML
|
|
335
|
-
if (undefinedChildren.length > 0) {
|
|
336
|
-
e.target.parentNode.querySelector('ul').innerHTML = '';
|
|
337
|
-
}
|
|
338
|
-
// If source is webservice (it shouldn't be something else)
|
|
339
|
-
if (this.options.parentApi.theOptions.source == 'webservice') {
|
|
340
|
-
if (this.options.parentApi.theOptions.origin == 'classification') {
|
|
341
|
-
const contextualApiParams = this.options.parentApi.getContextualApiParams(Object.assign(Object.assign({}, this.options.parentApi.theOptions.options), { startNode: target.parentNode.nodeId }));
|
|
342
|
-
const contextualApiURL = this.options.parentApi.getContextualApiURL();
|
|
343
|
-
// WS Call
|
|
344
|
-
this.options.rawDataManager
|
|
345
|
-
.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
346
|
-
.then(data => {
|
|
347
|
-
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
else {
|
|
351
|
-
// WS Call
|
|
352
|
-
this.options.rawDataManager
|
|
353
|
-
.getFromSource(this.options.parentApi.theOptions.url, {
|
|
354
|
-
StartNodeID: target.parentNode.nodeId,
|
|
355
|
-
lng: this.options.parentApi.theOptions.options.lng,
|
|
356
|
-
IsDeprecated: this.options.parentApi.theOptions.options.IsDeprecated,
|
|
357
|
-
}, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
358
|
-
.then(data => {
|
|
359
|
-
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
this.onSwitcherClick(target);
|
|
364
|
-
}
|
|
365
323
|
}, false);
|
|
366
324
|
};
|
|
367
325
|
Tree.prototype.onItemClick = async function (id, rightclick = false) {
|
|
@@ -370,8 +328,6 @@ Tree.prototype.onItemClick = async function (id, rightclick = false) {
|
|
|
370
328
|
return;
|
|
371
329
|
const pickerValue = await this.options.parentApi.getValue();
|
|
372
330
|
if (!rightclick || !pickerValue || pickerValue.nodeid != id) {
|
|
373
|
-
if (!this.options.parentApi.theOptions.multiple)
|
|
374
|
-
this.emptyNodesCheckStatus();
|
|
375
331
|
this.options.parentApi.setNodeAsSelected(id, this, true);
|
|
376
332
|
}
|
|
377
333
|
};
|
|
@@ -498,6 +454,48 @@ Tree.prototype.markWillUpdateNode = function (node) {
|
|
|
498
454
|
this.willUpdateNodesById[node.id] = node;
|
|
499
455
|
};
|
|
500
456
|
Tree.prototype.onSwitcherClick = function (target) {
|
|
457
|
+
const hasUndefinedchild = target.parentNode.querySelectorAll(".treejs-switcher").length > 0 && target.parentNode.querySelectorAll('ul').length == 0;
|
|
458
|
+
//CUSTOM
|
|
459
|
+
const childspans = Array.prototype.slice.call(target.parentNode.querySelectorAll('ul > li > span.treejs-label')).filter((ele) => {
|
|
460
|
+
return ele.parentNode.parentNode.parentNode === target.parentNode;
|
|
461
|
+
});
|
|
462
|
+
let undefinedChildren = [];
|
|
463
|
+
//This may be a problem the day a node value is "undefined"
|
|
464
|
+
undefinedChildren = childspans.filter(ele => {
|
|
465
|
+
return ele.textContent === 'undefined';
|
|
466
|
+
});
|
|
467
|
+
// If the user clicked on an unloaded node
|
|
468
|
+
if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher') && (undefinedChildren.length > 0 || hasUndefinedchild)) {
|
|
469
|
+
// Clear the subnode HTML
|
|
470
|
+
if (undefinedChildren.length > 0) {
|
|
471
|
+
target.parentNode.querySelector('ul').innerHTML = '';
|
|
472
|
+
}
|
|
473
|
+
// If source is webservice (it shouldn't be something else)
|
|
474
|
+
if (this.options.parentApi.theOptions.source == 'webservice') {
|
|
475
|
+
if (this.options.parentApi.theOptions.origin == 'classification') {
|
|
476
|
+
const contextualApiParams = this.options.parentApi.getContextualApiParams(Object.assign(Object.assign({}, this.options.parentApi.theOptions.options), { startNode: target.parentNode.nodeId }));
|
|
477
|
+
const contextualApiURL = this.options.parentApi.getContextualApiURL();
|
|
478
|
+
// WS Call
|
|
479
|
+
this.options.rawDataManager
|
|
480
|
+
.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
481
|
+
.then(data => {
|
|
482
|
+
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
// WS Call
|
|
487
|
+
this.options.rawDataManager
|
|
488
|
+
.getFromSource(this.options.parentApi.theOptions.url, {
|
|
489
|
+
StartNodeID: target.parentNode.nodeId,
|
|
490
|
+
lng: this.options.parentApi.theOptions.options.lng,
|
|
491
|
+
IsDeprecated: this.options.parentApi.theOptions.options.IsDeprecated,
|
|
492
|
+
}, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
493
|
+
.then(data => {
|
|
494
|
+
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
501
499
|
const liEle = target.parentNode;
|
|
502
500
|
const ele = liEle.lastChild;
|
|
503
501
|
const height = ele.scrollHeight;
|
|
@@ -535,6 +533,9 @@ Tree.prototype.onSwitcherClick = function (target) {
|
|
|
535
533
|
},
|
|
536
534
|
});
|
|
537
535
|
}
|
|
536
|
+
return new Promise((resolve) => {
|
|
537
|
+
resolve(this);
|
|
538
|
+
});
|
|
538
539
|
};
|
|
539
540
|
Tree.prototype.walkUp = function (node, changeState) {
|
|
540
541
|
const { parent } = node;
|
|
@@ -666,11 +667,10 @@ Tree.prototype.createLiEle = function (node, closed) {
|
|
|
666
667
|
else {
|
|
667
668
|
li.classList.add('treejs-placeholder');
|
|
668
669
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
}
|
|
670
|
+
const checkbox = document.createElement('span');
|
|
671
|
+
checkbox.classList.add('treejs-checkbox');
|
|
672
|
+
checkbox.style.display = ((!this.options.parentApi || (this.options.parentApi && this.options.parentApi.theOptions.multiple)) ? "inline-block" : "none");
|
|
673
|
+
li.appendChild(checkbox);
|
|
674
674
|
const label = document.createElement('span');
|
|
675
675
|
label.classList.add('treejs-label');
|
|
676
676
|
const text = document.createTextNode(node.text);
|
|
@@ -17991,6 +17991,10 @@ function isInstanceOfIConf(object) {
|
|
|
17991
17991
|
toret = false;
|
|
17992
17992
|
errorToLog = "options.displayRootNode value '" + object.displayRootNode + "' doesn't meet interface IConf requirements";
|
|
17993
17993
|
}
|
|
17994
|
+
if (!((!object.keyboardNavigation && typeof object.keyboardNavigation != 'boolean') || typeof object.keyboardNavigation == 'boolean')) {
|
|
17995
|
+
toret = false;
|
|
17996
|
+
errorToLog = "options.keyboardNavigation value '" + object.keyboardNavigation + "' doesn't meet interface IConf requirements";
|
|
17997
|
+
}
|
|
17994
17998
|
if (!((!object.dragAndDropEnabled && typeof object.dragAndDropEnabled != 'boolean') || typeof object.dragAndDropEnabled == 'boolean')) {
|
|
17995
17999
|
toret = false;
|
|
17996
18000
|
errorToLog = "options.dragAndDropEnabled value '" + object.dragAndDropEnabled + "' doesn't meet interface IConf requirements";
|
|
@@ -18087,17 +18091,18 @@ const defaultPickerTheme = {
|
|
|
18087
18091
|
primary: {
|
|
18088
18092
|
main: '#888',
|
|
18089
18093
|
light: '#888',
|
|
18090
|
-
contrastText: '#000',
|
|
18094
|
+
contrastText: '#000', // Text color of the selected node
|
|
18091
18095
|
},
|
|
18092
18096
|
background: {
|
|
18093
18097
|
default: '#ccc',
|
|
18094
18098
|
light: '#eee',
|
|
18095
18099
|
main: '#000',
|
|
18096
|
-
dark: '#fff',
|
|
18100
|
+
dark: '#fff', // Background of the whole tree
|
|
18097
18101
|
},
|
|
18098
18102
|
text: {
|
|
18099
|
-
primary: '#000',
|
|
18103
|
+
primary: '#000', // Text color
|
|
18100
18104
|
},
|
|
18105
|
+
// For all inputs in the component, includes in modale mode the display input and the search input
|
|
18101
18106
|
input: {
|
|
18102
18107
|
background: '#fff',
|
|
18103
18108
|
borderStyle: 'none'
|
|
@@ -18358,10 +18363,12 @@ class OptionsManager {
|
|
|
18358
18363
|
showAutocomplete: false,
|
|
18359
18364
|
openTreeWhenLoaded: false,
|
|
18360
18365
|
displayRootNode: false,
|
|
18366
|
+
keyboardNavigation: false,
|
|
18361
18367
|
dragAndDropEnabled: false,
|
|
18362
18368
|
errorsInInput: true,
|
|
18363
18369
|
isFullpath: true,
|
|
18364
18370
|
defaultValue: [],
|
|
18371
|
+
defaultValueIsFullpath: false,
|
|
18365
18372
|
};
|
|
18366
18373
|
const validatedOptions = Object.assign(Object.assign({}, defaults), options);
|
|
18367
18374
|
// Validate specific fields
|
|
@@ -18448,7 +18455,7 @@ function findNodeById(tree, nodeId) {
|
|
|
18448
18455
|
/**
|
|
18449
18456
|
* Fills the tree with nodes based on the provided object.
|
|
18450
18457
|
*/
|
|
18451
|
-
function fillTreeWithObject(tree, myObject, searched, options
|
|
18458
|
+
function fillTreeWithObject(tree, myObject, searched, options) {
|
|
18452
18459
|
const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
|
|
18453
18460
|
if (myObject && myObject.length) {
|
|
18454
18461
|
myObject.forEach(value => {
|
|
@@ -18480,7 +18487,6 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
|
|
|
18480
18487
|
const objToPush = {
|
|
18481
18488
|
id: keyPropFromNode,
|
|
18482
18489
|
nodeId: keyPropFromNode,
|
|
18483
|
-
depth,
|
|
18484
18490
|
text: valueTranslatedPropFromNode,
|
|
18485
18491
|
fullpath: fullpathPropFromNode,
|
|
18486
18492
|
fullpathTranslated: fullpathTranslatedPropFromNode,
|
|
@@ -18489,7 +18495,7 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
|
|
|
18489
18495
|
isDesaturated: false,
|
|
18490
18496
|
searchMatch: false,
|
|
18491
18497
|
};
|
|
18492
|
-
const childTree = fillTreeWithObject(objToPush.children, childrenPropFromNode, searched, options
|
|
18498
|
+
const childTree = fillTreeWithObject(objToPush.children, childrenPropFromNode, searched, options);
|
|
18493
18499
|
let pushMe = false;
|
|
18494
18500
|
if (searched) {
|
|
18495
18501
|
const matched = searchValue(objToPush, false, searched);
|
|
@@ -18515,6 +18521,11 @@ function completeCurrentTreeWithTree(treeJsInstance, newTree, options) {
|
|
|
18515
18521
|
var _a;
|
|
18516
18522
|
const ElmID = newTree.key || newTree.id || newTree.ID;
|
|
18517
18523
|
const targetNode = findNodeById(treeJsInstance, ElmID);
|
|
18524
|
+
if (ElmID == 0 && newTree.children && newTree.children.length > 0) {
|
|
18525
|
+
newTree.children.forEach(child => {
|
|
18526
|
+
completeCurrentTreeWithTree(treeJsInstance, child, options);
|
|
18527
|
+
});
|
|
18528
|
+
}
|
|
18518
18529
|
if (targetNode) {
|
|
18519
18530
|
targetNode.children = [];
|
|
18520
18531
|
let ulElem = (_a = treeJsInstance.liElementsById[ElmID]) === null || _a === void 0 ? void 0 : _a.querySelector('ul');
|
|
@@ -18530,6 +18541,11 @@ function completeCurrentTreeWithTree(treeJsInstance, newTree, options) {
|
|
|
18530
18541
|
targetNode.children.push(item);
|
|
18531
18542
|
treeJsInstance.nodesById[item.id] = item;
|
|
18532
18543
|
treeJsInstance.liElementsById[item.id] = liElm;
|
|
18544
|
+
if (item.children && item.children.some(child => Object.keys(child).length > 0)) {
|
|
18545
|
+
newTree.children.forEach(child => {
|
|
18546
|
+
completeCurrentTreeWithTree(treeJsInstance, child, options);
|
|
18547
|
+
});
|
|
18548
|
+
}
|
|
18533
18549
|
});
|
|
18534
18550
|
}
|
|
18535
18551
|
}
|
|
@@ -18572,10 +18588,99 @@ function clearAutocomplete(eraseResults = false) {
|
|
|
18572
18588
|
}
|
|
18573
18589
|
}
|
|
18574
18590
|
|
|
18575
|
-
|
|
18576
|
-
function
|
|
18577
|
-
|
|
18578
|
-
|
|
18591
|
+
let focusedNodeIndex = 0;
|
|
18592
|
+
function setupKeyboardNavigation(component, optionsManager, navigateInTree) {
|
|
18593
|
+
if (!optionsManager.getOptions().keyboardNavigation)
|
|
18594
|
+
return;
|
|
18595
|
+
const treeArea = component.el.querySelector('.hierarchized-picker-tree-area') || component.el.querySelector('.hierarchized-picker-raw-tree-area');
|
|
18596
|
+
if (!treeArea)
|
|
18597
|
+
return;
|
|
18598
|
+
function focusNode(allLiElements, liElementToFocus) {
|
|
18599
|
+
Object.values(allLiElements).forEach((liNode) => {
|
|
18600
|
+
liNode.classList.remove('treejs-node__focused');
|
|
18601
|
+
});
|
|
18602
|
+
liElementToFocus.classList.add('treejs-node__focused');
|
|
18603
|
+
}
|
|
18604
|
+
function findAllTreeNodes(treeNodes, liElementsById) {
|
|
18605
|
+
let allNodes = [];
|
|
18606
|
+
const traverse = (nodes) => {
|
|
18607
|
+
nodes.forEach(node => {
|
|
18608
|
+
allNodes.push(node);
|
|
18609
|
+
if (node.children && node.children.length > 0 && !liElementsById[node.id].classList.contains("treejs-node__close")) {
|
|
18610
|
+
traverse(node.children);
|
|
18611
|
+
}
|
|
18612
|
+
});
|
|
18613
|
+
};
|
|
18614
|
+
traverse(treeNodes);
|
|
18615
|
+
return allNodes;
|
|
18616
|
+
}
|
|
18617
|
+
focusedNodeIndex = 0;
|
|
18618
|
+
if (component && component.loadedTreeJs && component.loadedTreeJs.liElementsById && component.loadedTreeJs.treeNodes) {
|
|
18619
|
+
focusNode(component.loadedTreeJs.liElementsById, component.loadedTreeJs.liElementsById[component.loadedTreeJs.treeNodes[focusedNodeIndex].id]);
|
|
18620
|
+
}
|
|
18621
|
+
if (!component._keydownListenerAdded) {
|
|
18622
|
+
component._keydownListenerAdded = true;
|
|
18623
|
+
component.el.addEventListener('keydown', (event) => {
|
|
18624
|
+
var _a, _b;
|
|
18625
|
+
event.stopPropagation();
|
|
18626
|
+
const tree = component.loadedTreeJs;
|
|
18627
|
+
let treeNodesFromTree = findAllTreeNodes(tree.treeNodes, tree.liElementsById);
|
|
18628
|
+
if (!tree || !treeNodesFromTree.length)
|
|
18629
|
+
return;
|
|
18630
|
+
let spaceNode = treeNodesFromTree[focusedNodeIndex];
|
|
18631
|
+
let activeNode = treeNodesFromTree[focusedNodeIndex];
|
|
18632
|
+
let liElement = tree.liElementsById[activeNode.id];
|
|
18633
|
+
const handledEvents = ['tab', '0', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright'];
|
|
18634
|
+
switch (event.key.toLowerCase()) {
|
|
18635
|
+
case 'tab':
|
|
18636
|
+
case '0':
|
|
18637
|
+
event.preventDefault();
|
|
18638
|
+
{ //(spaceNode?.nodeId) {
|
|
18639
|
+
component.setNodeAsSelected(spaceNode.nodeId, component.loadedTreeJs, true);
|
|
18640
|
+
if (optionsManager.getOptions().mode != "tree" && !optionsManager.getOptions().multiple) {
|
|
18641
|
+
setTimeout(() => {
|
|
18642
|
+
component.showTree('hide');
|
|
18643
|
+
}, 100);
|
|
18644
|
+
}
|
|
18645
|
+
}
|
|
18646
|
+
break;
|
|
18647
|
+
case 'arrowup':
|
|
18648
|
+
event.preventDefault();
|
|
18649
|
+
focusedNodeIndex = Math.max(focusedNodeIndex - 1, 0);
|
|
18650
|
+
const newActiveNodeUp = treeNodesFromTree[focusedNodeIndex];
|
|
18651
|
+
const newLiElementUp = tree.liElementsById[newActiveNodeUp.id];
|
|
18652
|
+
newLiElementUp.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
18653
|
+
focusNode(tree.liElementsById, newLiElementUp);
|
|
18654
|
+
break;
|
|
18655
|
+
case 'arrowdown':
|
|
18656
|
+
event.preventDefault();
|
|
18657
|
+
focusedNodeIndex = Math.min(focusedNodeIndex + 1, treeNodesFromTree.length - 1);
|
|
18658
|
+
const newActiveNodeDown = treeNodesFromTree[focusedNodeIndex];
|
|
18659
|
+
const newLiElementDown = tree.liElementsById[newActiveNodeDown.id];
|
|
18660
|
+
focusNode(tree.liElementsById, newLiElementDown);
|
|
18661
|
+
newLiElementDown.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
18662
|
+
break;
|
|
18663
|
+
case 'arrowleft':
|
|
18664
|
+
event.preventDefault();
|
|
18665
|
+
const leftSwitcher = liElement.querySelector('.treejs-switcher');
|
|
18666
|
+
if (leftSwitcher) {
|
|
18667
|
+
(_a = component.loadedTreeJs) === null || _a === void 0 ? void 0 : _a.onSwitcherClick(leftSwitcher);
|
|
18668
|
+
}
|
|
18669
|
+
break;
|
|
18670
|
+
case 'arrowright':
|
|
18671
|
+
event.preventDefault();
|
|
18672
|
+
const rightSwitcher = liElement.querySelector('.treejs-switcher');
|
|
18673
|
+
if (rightSwitcher) {
|
|
18674
|
+
(_b = component.loadedTreeJs) === null || _b === void 0 ? void 0 : _b.onSwitcherClick(rightSwitcher);
|
|
18675
|
+
}
|
|
18676
|
+
break;
|
|
18677
|
+
}
|
|
18678
|
+
if (handledEvents.includes(event.key.toLowerCase()))
|
|
18679
|
+
navigateInTree.emit(event);
|
|
18680
|
+
});
|
|
18681
|
+
}
|
|
18682
|
+
}
|
|
18683
|
+
|
|
18579
18684
|
// Focus management
|
|
18580
18685
|
async function focusSearchInput(component) {
|
|
18581
18686
|
const searchInput = component.el.querySelector('search-input input');
|
|
@@ -18606,19 +18711,6 @@ function handleFocusEvent(component, type) {
|
|
|
18606
18711
|
component.showTree('hide');
|
|
18607
18712
|
}
|
|
18608
18713
|
}
|
|
18609
|
-
function manageFocusOut(component, event) {
|
|
18610
|
-
const relatedTarget = event.relatedTarget;
|
|
18611
|
-
if (!isInsidePicker(component, relatedTarget)) {
|
|
18612
|
-
setTimeout(() => {
|
|
18613
|
-
if (!isInsidePicker(component, document.activeElement)) {
|
|
18614
|
-
handleFocusEvent(component, 'hide');
|
|
18615
|
-
}
|
|
18616
|
-
}, 100);
|
|
18617
|
-
}
|
|
18618
|
-
else {
|
|
18619
|
-
handleFocusEvent(component, 'search');
|
|
18620
|
-
}
|
|
18621
|
-
}
|
|
18622
18714
|
function clickPickerModalArea(component, _event) {
|
|
18623
18715
|
if (component.pickerClass === 'fieldError') {
|
|
18624
18716
|
component.showTree('hide');
|
|
@@ -18629,83 +18721,18 @@ function clickPickerModalArea(component, _event) {
|
|
|
18629
18721
|
else {
|
|
18630
18722
|
component.mylog('Ignored modal click');
|
|
18631
18723
|
}
|
|
18724
|
+
if (component.theOptions.mode == 'tree') {
|
|
18725
|
+
setupKeyboardNavigation(component, component.optionsManager, component.navigateInTree);
|
|
18726
|
+
}
|
|
18632
18727
|
}
|
|
18633
18728
|
// Exposed event handlers
|
|
18634
18729
|
function focusInSearchEvent(component) {
|
|
18635
18730
|
handleFocusEvent(component, 'search');
|
|
18636
18731
|
}
|
|
18637
18732
|
function focusOutSearchEvent(component, event) {
|
|
18638
|
-
manageFocusOut(component, event);
|
|
18639
18733
|
}
|
|
18640
18734
|
|
|
18641
|
-
function setupKeyboardNavigation(component, navigateInTree) {
|
|
18642
|
-
const treeArea = component.el.querySelector('.hierarchized-picker-tree-area');
|
|
18643
|
-
if (!treeArea)
|
|
18644
|
-
return;
|
|
18645
|
-
let focusedNodeIndex = 0;
|
|
18646
|
-
function focusNode(allLiElements, liElementToFocus) {
|
|
18647
|
-
Object.values(allLiElements).forEach((liNode) => {
|
|
18648
|
-
liNode.classList.remove('treejs-node__focused');
|
|
18649
|
-
});
|
|
18650
|
-
liElementToFocus.classList.add('treejs-node__focused');
|
|
18651
|
-
}
|
|
18652
|
-
component.el.addEventListener('keydown', (event) => {
|
|
18653
|
-
var _a, _b;
|
|
18654
|
-
event.stopPropagation();
|
|
18655
|
-
const tree = component.loadedTreeJs;
|
|
18656
|
-
const treeNodesFromTree = tree.treeNodes;
|
|
18657
|
-
if (!tree || !treeNodesFromTree.length)
|
|
18658
|
-
return;
|
|
18659
|
-
const spaceNode = treeNodesFromTree[focusedNodeIndex];
|
|
18660
|
-
const activeNode = treeNodesFromTree[focusedNodeIndex];
|
|
18661
|
-
const liElement = tree.liElementsById[activeNode.id];
|
|
18662
|
-
switch (event.key) {
|
|
18663
|
-
case 'Tab':
|
|
18664
|
-
case '0':
|
|
18665
|
-
event.preventDefault();
|
|
18666
|
-
{ //(spaceNode?.nodeId) {
|
|
18667
|
-
component.setNodeAsSelected(spaceNode.nodeId, component.loadedTreeJs, true);
|
|
18668
|
-
component.showTree('hide');
|
|
18669
|
-
setTimeout(() => focusMainInput(), 100);
|
|
18670
|
-
}
|
|
18671
|
-
break;
|
|
18672
|
-
case 'ArrowUp':
|
|
18673
|
-
event.preventDefault();
|
|
18674
|
-
focusedNodeIndex = Math.max(focusedNodeIndex - 1, 0);
|
|
18675
|
-
const newActiveNodeUp = treeNodesFromTree[focusedNodeIndex];
|
|
18676
|
-
const newLiElementUp = tree.liElementsById[newActiveNodeUp.id];
|
|
18677
|
-
focusNode(tree.liElementsById, newLiElementUp);
|
|
18678
|
-
break;
|
|
18679
|
-
case 'ArrowDown':
|
|
18680
|
-
event.preventDefault();
|
|
18681
|
-
focusedNodeIndex = Math.min(focusedNodeIndex + 1, treeNodesFromTree.length - 1);
|
|
18682
|
-
const newActiveNodeDown = treeNodesFromTree[focusedNodeIndex];
|
|
18683
|
-
const newLiElementDown = tree.liElementsById[newActiveNodeDown.id];
|
|
18684
|
-
focusNode(tree.liElementsById, newLiElementDown);
|
|
18685
|
-
break;
|
|
18686
|
-
case 'ArrowLeft':
|
|
18687
|
-
event.preventDefault();
|
|
18688
|
-
const leftSwitcher = liElement.querySelector('.treejs-switcher');
|
|
18689
|
-
if (leftSwitcher) {
|
|
18690
|
-
(_a = component.loadedTreeJs) === null || _a === void 0 ? void 0 : _a.onSwitcherClick(leftSwitcher);
|
|
18691
|
-
component.showTree('hide');
|
|
18692
|
-
}
|
|
18693
|
-
break;
|
|
18694
|
-
case 'ArrowRight':
|
|
18695
|
-
event.preventDefault();
|
|
18696
|
-
const rightSwitcher = liElement.querySelector('.treejs-switcher');
|
|
18697
|
-
if (rightSwitcher) {
|
|
18698
|
-
(_b = component.loadedTreeJs) === null || _b === void 0 ? void 0 : _b.onSwitcherClick(rightSwitcher);
|
|
18699
|
-
}
|
|
18700
|
-
break;
|
|
18701
|
-
}
|
|
18702
|
-
navigateInTree.emit(event.key);
|
|
18703
|
-
});
|
|
18704
|
-
if (component && component.loadedTreeJs && component.loadedTreeJs.liElementsById && component.loadedTreeJs.treeNodes)
|
|
18705
|
-
setTimeout(() => focusNode(component.loadedTreeJs.liElementsById, component.loadedTreeJs.liElementsById[component.loadedTreeJs.treeNodes[focusedNodeIndex].id]), 100);
|
|
18706
|
-
}
|
|
18707
|
-
|
|
18708
|
-
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:var(--hpicker-theme-typography-tree-font-size, 14px) !important;font-weight:var(--hpicker-theme-typography-tree-font-weight, 400) !important}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 var(--hpicker-theme-palette-font-color)}reneco-hierarchized-picker .treejs-node__checked>.treejs-switcher:before{border-top:4px solid var(--hpicker-theme-palette-primary-contrastText) !important}reneco-hierarchized-picker .treejs-node__focused{text-decoration:underline;text-decoration-thickness:2px;text-underline-offset:2px}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{background-color:var(--hpicker-theme-palette-background-default, var(--mui-palette-background-default, #e8a86c))}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:var(--hpicker-theme-palette-background-light, var(--mui-palette-background-light, #e8a86c));display:inline;opacity:.9;padding:11px 0px;display:block}reneco-hierarchized-picker .treejs .dragover{background:var(--hpicker-theme-palette-background-light, var(--mui-palette-background-light, #e8a86c))}reneco-hierarchized-picker .treejs .dragover-over::after{content:\"\";display:block;width:2px;height:100%;position:absolute;top:0;left:0;background:var(--hpicker-theme-palette-primary-main, var(--mui-palette-primary-main, #d58433))}reneco-hierarchized-picker .treejs .dragover-before::after{content:\"\";display:block;height:2px;width:100%;position:absolute;top:0;left:0;background:var(--hpicker-theme-palette-primary-main, var(--mui-palette-primary-main, #d58433))}reneco-hierarchized-picker .treejs .dragover-after::after{content:\"\";display:block;height:2px;width:100%;position:absolute;bottom:0;left:0;background:var(--hpicker-theme-palette-primary-main, var(--mui-palette-primary-main, #d58433))}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;background-color:var(--hpicker-theme-palette-background-dark)}reneco-hierarchized-picker ul.treejs-nodes:not(:first-child){margin:0 !important;padding-left:15px !important;background-color:var(--hpicker-theme-palette-background-dark, var(--mui-palette-background-dark, 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(--hpicker-theme-palette-background-light, var(--mui-palette-background-light, var(--ion-color-light, #FAFAFA)))}reneco-hierarchized-picker li:not(.treejs-node__close){background-color:var(--hpicker-theme-palette-background-default, var(--mui-palette-background-default, #e8a86c));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(--hpicker-theme-palette-primary-light) !important;color:var(--hpicker-theme-palette-primary-ContrastText, var(--mui-palette-primary-ContrastText, var(--ion-color-primary-contrast, #000)))!important}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:var(--hpicker-theme-palette-font-color, var(--mui-palette-font-color, black))}reneco-hierarchized-picker .hierarchized-picker-container{position:relative;width:100%}reneco-hierarchized-picker .hierarchized-picker-input-area{background-color:transparent !important;display:-ms-flexbox;display:flex;width:100%;-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 input{width:100%}reneco-hierarchized-picker .hierarchized-picker-input.readonly{pointer-events:none;cursor:initial}reneco-hierarchized-picker .hierarchized-picker-label{position:stacked;margin-left:5px}reneco-hierarchized-picker .hierarchized-picker-tree-area{padding-top:10px}reneco-hierarchized-picker .hierarchized-picker-modal-area{position:absolute;width:100%;background-color:var(--hpicker-theme-palette-background-dark, var(--mui-palette-background-dark, var(--ion-color-light-tint, #FFF))) !important;z-index:10;overflow:scroll;top:20px;min-height:100px;max-height:var(--hpicker-theme-modal-height, \"200px\") !important;-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-area.display-modale-top{bottom:30px !important;top:unset !important}reneco-hierarchized-picker .hierarchized-picker-modal{padding:0px 15px}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:hover{cursor:pointer}reneco-hierarchized-picker .hierarchized-picker-input-area span.reneco-close{color:var(--ion-color-danger, red) !important;padding-left:10px}reneco-hierarchized-picker .treejs .treejs-switcher:before{border-top:4px solid var(--hpicker-theme-palette-font-color, var(--mui-palette-font-color, 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(--hpicker-theme-palette-primary-main, var(--mui-palette-primary-main, var(--ion-color-primary, #d58433))) !important;border-color:var(--hpicker-theme-palette-primary-main, var(--mui-palette-primary-main, var(--ion-color-primary, #d58433))) !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}reneco-hierarchized-picker input[title]{text-overflow:ellipsis;overflow:hidden;white-space:nowrap}reneco-hierarchized-picker input{background-color:var(--hpicker-theme-palette-input-background-color, #eeeeee);border-style:var(--hpicker-theme-palette-input-border-style, solid)}reneco-hierarchized-picker input:focus-visible{outline-color:unset !important}.hierarchized-picker-raw-tree-area.readonly li.treejs-node .treejs-switcher{pointer-events:all}::-webkit-scrollbar-thumb{background:var(--hpicker-theme-palette-primary-main, var(--mui-palette-primary-main, var(--ion-color-primary, #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(--hpicker-theme-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}";
|
|
18735
|
+
const hierarchizedPickerCss = "reneco-hierarchized-picker .hierarchized-picker-raw-tree-area{position:relative;-webkit-box-sizing:border-box;box-sizing:border-box}reneco-hierarchized-picker div:focus{outline:none}reneco-hierarchized-picker .loader{color:var(--hpicker-theme-palette-font-color, var(--mui-palette-font-color, black)) !important;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:var(--hpicker-theme-palette-background-light, var(--mui-palette-background-light, var(--ion-color-light, #FAFAFA))) !important;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:var(--hpicker-theme-typography-tree-font-size, 14px) !important;font-weight:var(--hpicker-theme-typography-tree-font-weight, 400) !important}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 var(--hpicker-theme-palette-font-color)}reneco-hierarchized-picker .treejs-node__checked>.treejs-switcher:before{border-top:4px solid var(--hpicker-theme-palette-primary-contrastText) !important}reneco-hierarchized-picker .treejs-node__focused{text-decoration:underline;text-decoration-thickness:2px;text-underline-offset:2px}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{background-color:var(--hpicker-theme-palette-background-default, var(--mui-palette-background-default, #e8a86c))}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:var(--hpicker-theme-palette-background-light, var(--mui-palette-background-light, #e8a86c));display:inline;opacity:.9;padding:11px 0px;display:block}reneco-hierarchized-picker .treejs .dragover{background:var(--hpicker-theme-palette-background-light, var(--mui-palette-background-light, #e8a86c))}reneco-hierarchized-picker .treejs .dragover-over::after{content:\"\";display:block;width:2px;height:100%;position:absolute;top:0;left:0;background:var(--hpicker-theme-palette-primary-main, var(--mui-palette-primary-main, #d58433))}reneco-hierarchized-picker .treejs .dragover-before::after{content:\"\";display:block;height:2px;width:100%;position:absolute;top:0;left:0;background:var(--hpicker-theme-palette-primary-main, var(--mui-palette-primary-main, #d58433))}reneco-hierarchized-picker .treejs .dragover-after::after{content:\"\";display:block;height:2px;width:100%;position:absolute;bottom:0;left:0;background:var(--hpicker-theme-palette-primary-main, var(--mui-palette-primary-main, #d58433))}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;background-color:var(--hpicker-theme-palette-background-dark)}reneco-hierarchized-picker ul.treejs-nodes:not(:first-child){margin:0 !important;padding-left:15px !important;background-color:var(--hpicker-theme-palette-background-dark, var(--mui-palette-background-dark, 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(--hpicker-theme-palette-background-light, var(--mui-palette-background-light, var(--ion-color-light, #FAFAFA)))}reneco-hierarchized-picker li:not(.treejs-node__close){background-color:var(--hpicker-theme-palette-background-default, var(--mui-palette-background-default, #e8a86c));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(--hpicker-theme-palette-primary-light) !important;color:var(--hpicker-theme-palette-primary-contrastText, var(--mui-palette-primary-ContrastText, var(--ion-color-primary-contrast, #000)))!important}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:var(--hpicker-theme-palette-font-color, var(--mui-palette-font-color, black))}reneco-hierarchized-picker .hierarchized-picker-container{position:relative;width:100%}reneco-hierarchized-picker .hierarchized-picker-input-area{background-color:transparent !important;display:-ms-flexbox;display:flex;width:100%;-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 input{width:100%}reneco-hierarchized-picker .hierarchized-picker-input.readonly{pointer-events:none;cursor:initial}reneco-hierarchized-picker .hierarchized-picker-label{position:stacked;margin-left:5px}reneco-hierarchized-picker .hierarchized-picker-tree-area{padding-top:10px}reneco-hierarchized-picker .hierarchized-picker-modal-area{position:absolute;width:100%;background-color:var(--hpicker-theme-palette-background-dark, var(--mui-palette-background-dark, var(--ion-color-light-tint, #FFF))) !important;z-index:10;overflow:scroll;top:20px;min-height:100px;max-height:var(--hpicker-theme-modal-height, \"200px\") !important;-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-area.display-modale-top{bottom:30px !important;top:unset !important}reneco-hierarchized-picker .hierarchized-picker-modal{padding:0px 15px}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:hover{cursor:pointer}reneco-hierarchized-picker .hierarchized-picker-input-area span.reneco-close{color:var(--ion-color-danger, red) !important;padding-left:10px}reneco-hierarchized-picker .treejs .treejs-switcher:before{border-top:4px solid var(--hpicker-theme-palette-font-color, var(--mui-palette-font-color, 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(--hpicker-theme-palette-primary-main, var(--mui-palette-primary-main, var(--ion-color-primary, #d58433))) !important;border-color:var(--hpicker-theme-palette-primary-main, var(--mui-palette-primary-main, var(--ion-color-primary, #d58433))) !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}reneco-hierarchized-picker input[title]{text-overflow:ellipsis;overflow:hidden;white-space:nowrap}reneco-hierarchized-picker input{background-color:var(--hpicker-theme-palette-input-background-color, #eeeeee);border-style:var(--hpicker-theme-palette-input-border-style, solid);color:var(--hpicker-theme-palette-font-color, var(--mui-palette-font-color, black))}reneco-hierarchized-picker input:focus-visible{outline:unset !important;outline-color:unset !important;outline-style:unset !important}.hierarchized-picker-raw-tree-area.readonly li.treejs-node .treejs-switcher{pointer-events:all}::-webkit-scrollbar-thumb{background:var(--hpicker-theme-palette-primary-main, var(--mui-palette-primary-main, var(--ion-color-primary, #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(--hpicker-theme-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}";
|
|
18709
18736
|
|
|
18710
18737
|
const HierarchizedPickerComponent = class {
|
|
18711
18738
|
/**
|
|
@@ -18774,14 +18801,66 @@ const HierarchizedPickerComponent = class {
|
|
|
18774
18801
|
logError(messageToLog) {
|
|
18775
18802
|
try {
|
|
18776
18803
|
console.error('--- Hierarchized picker ' + this.componentID + ' ERROR ---', messageToLog);
|
|
18804
|
+
this.lastErrorMessage = messageToLog;
|
|
18777
18805
|
}
|
|
18778
18806
|
catch (_a) {
|
|
18779
|
-
|
|
18807
|
+
const genericErrorMessage = '--- Hierarchized picker generic ERROR ---';
|
|
18808
|
+
this.lastErrorMessage = genericErrorMessage;
|
|
18809
|
+
console.error(genericErrorMessage);
|
|
18780
18810
|
}
|
|
18811
|
+
this.errorRaised.emit(this.lastErrorMessage);
|
|
18781
18812
|
}
|
|
18782
18813
|
get theOptions() {
|
|
18783
18814
|
return this.optionsManager.getOptions();
|
|
18784
18815
|
}
|
|
18816
|
+
diffKeys(obj1, obj2, prefix = '') {
|
|
18817
|
+
const diffs = [];
|
|
18818
|
+
const commonKeys = Object.keys(obj1 || {}).filter(key => obj2 && Object.prototype.hasOwnProperty.call(obj2, key));
|
|
18819
|
+
for (const key of commonKeys) {
|
|
18820
|
+
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
18821
|
+
const val1 = obj1[key];
|
|
18822
|
+
const val2 = obj2[key];
|
|
18823
|
+
if (Array.isArray(val1) && Array.isArray(val2)) {
|
|
18824
|
+
// Compare array length
|
|
18825
|
+
if (val1.length !== val2.length) {
|
|
18826
|
+
diffs.push(fullKey);
|
|
18827
|
+
continue;
|
|
18828
|
+
}
|
|
18829
|
+
// Compare each element deeply
|
|
18830
|
+
for (let i = 0; i < val1.length; i++) {
|
|
18831
|
+
const v1 = val1[i];
|
|
18832
|
+
const v2 = val2[i];
|
|
18833
|
+
if (typeof v1 === 'object' &&
|
|
18834
|
+
v1 !== null &&
|
|
18835
|
+
typeof v2 === 'object' &&
|
|
18836
|
+
v2 !== null) {
|
|
18837
|
+
const subDiffs = this.diffKeys(v1, v2, `${fullKey}[${i}]`);
|
|
18838
|
+
if (subDiffs.length > 0) {
|
|
18839
|
+
diffs.push(fullKey);
|
|
18840
|
+
break; // stop at first mismatch in array
|
|
18841
|
+
}
|
|
18842
|
+
}
|
|
18843
|
+
else if (v1 !== v2) {
|
|
18844
|
+
diffs.push(fullKey);
|
|
18845
|
+
break;
|
|
18846
|
+
}
|
|
18847
|
+
}
|
|
18848
|
+
}
|
|
18849
|
+
else if (val1 &&
|
|
18850
|
+
val2 &&
|
|
18851
|
+
typeof val1 === 'object' &&
|
|
18852
|
+
typeof val2 === 'object') {
|
|
18853
|
+
// Recursive deep object comparison
|
|
18854
|
+
const subDiffs = this.diffKeys(val1, val2, fullKey);
|
|
18855
|
+
if (subDiffs.length > 0)
|
|
18856
|
+
diffs.push(...subDiffs);
|
|
18857
|
+
}
|
|
18858
|
+
else if (val1 !== val2) {
|
|
18859
|
+
diffs.push(fullKey);
|
|
18860
|
+
}
|
|
18861
|
+
}
|
|
18862
|
+
return diffs;
|
|
18863
|
+
}
|
|
18785
18864
|
async setNewOption(newValue, oldValue = null) {
|
|
18786
18865
|
this.ready = false;
|
|
18787
18866
|
// --------------------------------------- DEPRECATED ?
|
|
@@ -18800,6 +18879,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18800
18879
|
// });
|
|
18801
18880
|
// ---------------------------------------
|
|
18802
18881
|
// this.theOptions = newValue;
|
|
18882
|
+
const savedOldValue = Object.assign({}, this.theOptions);
|
|
18803
18883
|
if (oldValue && JSON.stringify(newValue.options) == JSON.stringify(oldValue.options)) {
|
|
18804
18884
|
this.ready = true;
|
|
18805
18885
|
return;
|
|
@@ -18808,6 +18888,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18808
18888
|
newValue = JSON.parse(newValue);
|
|
18809
18889
|
if (typeof oldValue == 'string')
|
|
18810
18890
|
oldValue = JSON.parse(oldValue);
|
|
18891
|
+
this.value = [];
|
|
18811
18892
|
this.optionsManager.updateOptions(newValue);
|
|
18812
18893
|
this.setDisplayedValue(this.value);
|
|
18813
18894
|
const originOrNodeIdAreDifferent = !oldValue || (newValue.origin != oldValue.origin || newValue.options.StartNodeID != oldValue.options.StartNodeID);
|
|
@@ -18825,11 +18906,28 @@ const HierarchizedPickerComponent = class {
|
|
|
18825
18906
|
if (oldValue && JSON.stringify(newValue.options) != JSON.stringify(oldValue.options)) {
|
|
18826
18907
|
this.value = [];
|
|
18827
18908
|
}
|
|
18828
|
-
if ((newValue === null || newValue === void 0 ? void 0 : newValue.loading) == 'display') {
|
|
18909
|
+
if ((newValue === null || newValue === void 0 ? void 0 : newValue.loading) == 'display' || (newValue && !newValue.loading)) {
|
|
18829
18910
|
if ((oldValue && this.isChangeInOptions(newValue, oldValue)) || !oldValue) {
|
|
18830
|
-
|
|
18831
|
-
|
|
18832
|
-
|
|
18911
|
+
if (!oldValue) {
|
|
18912
|
+
oldValue = savedOldValue;
|
|
18913
|
+
}
|
|
18914
|
+
const propDiffs = this.diffKeys(oldValue, this.optionsManager.initializeOptions(newValue));
|
|
18915
|
+
const noReloadProps = ["multiple"];
|
|
18916
|
+
const ignoredProps = ["token"];
|
|
18917
|
+
const filteredDiffs = propDiffs.filter(prop => !ignoredProps.includes(prop));
|
|
18918
|
+
if (filteredDiffs.length == 1 && filteredDiffs.some(item => noReloadProps.includes(item))) {
|
|
18919
|
+
const propChanged = filteredDiffs[0];
|
|
18920
|
+
switch (propChanged) {
|
|
18921
|
+
case "multiple":
|
|
18922
|
+
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = (this.theOptions.multiple ? 'inline-block' : 'none')));
|
|
18923
|
+
break;
|
|
18924
|
+
}
|
|
18925
|
+
}
|
|
18926
|
+
else {
|
|
18927
|
+
this.rawDataManager = new RawDataManager(this.getOptionsAsIConf(this.optionsManager.getOptions()).token, this.optionsManager);
|
|
18928
|
+
await this.loadHierarchizedPicker(true);
|
|
18929
|
+
this.displayWhenLoaded();
|
|
18930
|
+
}
|
|
18833
18931
|
}
|
|
18834
18932
|
else {
|
|
18835
18933
|
this.ready = true;
|
|
@@ -18883,6 +18981,9 @@ const HierarchizedPickerComponent = class {
|
|
|
18883
18981
|
async filterTree(searchedValue) {
|
|
18884
18982
|
this.search(searchedValue);
|
|
18885
18983
|
}
|
|
18984
|
+
async getError() {
|
|
18985
|
+
return Promise.resolve(this.lastErrorMessage);
|
|
18986
|
+
}
|
|
18886
18987
|
constructor(hostRef) {
|
|
18887
18988
|
registerInstance(this, hostRef);
|
|
18888
18989
|
this.valueChange = createEvent(this, "valueChange", 7);
|
|
@@ -18890,6 +18991,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18890
18991
|
this.itemContextMenuItemClick = createEvent(this, "itemContextMenuItemClick", 7);
|
|
18891
18992
|
this.searchResult = createEvent(this, "searchResult", 7);
|
|
18892
18993
|
this.navigateInTree = createEvent(this, "navigateInTree", 7);
|
|
18994
|
+
this.errorRaised = createEvent(this, "errorRaised", 7);
|
|
18893
18995
|
this.modaleHeight = 200;
|
|
18894
18996
|
this.modalePosition = 'bottom';
|
|
18895
18997
|
this.canload = true; // Determines wether the component may be loaded
|
|
@@ -18899,30 +19001,101 @@ const HierarchizedPickerComponent = class {
|
|
|
18899
19001
|
this.lastSearchMatchCounter = 0; // Counter of number of matches for last search
|
|
18900
19002
|
this.setValueOnClick = true; // Tells wether we edit the picker value on click in the tree
|
|
18901
19003
|
this.mylog = console.log; // Custom log function for debug purposes
|
|
19004
|
+
this.lastErrorMessage = '';
|
|
19005
|
+
this.scrollToNode = (targetNodeId = null, displayChildren = false) => {
|
|
19006
|
+
var _a;
|
|
19007
|
+
let scrollToValue = 0;
|
|
19008
|
+
let removeClosedAndLookUp = (element, editScroll = false) => {
|
|
19009
|
+
var _a, _b, _c, _d;
|
|
19010
|
+
const nodeId = element === null || element === void 0 ? void 0 : element.nodeId;
|
|
19011
|
+
if (!element || !nodeId) {
|
|
19012
|
+
return;
|
|
19013
|
+
}
|
|
19014
|
+
const node = this.loadedTreeJs.nodesById[nodeId];
|
|
19015
|
+
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) {
|
|
19016
|
+
(_c = element.classList) === null || _c === void 0 ? void 0 : _c.remove('treejs-node__close');
|
|
19017
|
+
}
|
|
19018
|
+
if (editScroll) {
|
|
19019
|
+
scrollToValue += element.offsetTop;
|
|
19020
|
+
}
|
|
19021
|
+
const parent = (_d = element.parentNode) === null || _d === void 0 ? void 0 : _d.closest('.treejs-node');
|
|
19022
|
+
if (parent) {
|
|
19023
|
+
removeClosedAndLookUp(parent, editScroll);
|
|
19024
|
+
}
|
|
19025
|
+
};
|
|
19026
|
+
try {
|
|
19027
|
+
if (targetNodeId) {
|
|
19028
|
+
const targetNode = this.loadedTreeJs.liElementsById[targetNodeId];
|
|
19029
|
+
if (targetNode) {
|
|
19030
|
+
removeClosedAndLookUp(targetNode, true);
|
|
19031
|
+
if (displayChildren && targetNode.classList.contains('treejs-node__close')) {
|
|
19032
|
+
const leftSwitcher = targetNode.querySelector('.treejs-switcher');
|
|
19033
|
+
if (leftSwitcher) {
|
|
19034
|
+
(_a = this.loadedTreeJs) === null || _a === void 0 ? void 0 : _a.onSwitcherClick(leftSwitcher);
|
|
19035
|
+
}
|
|
19036
|
+
}
|
|
19037
|
+
}
|
|
19038
|
+
}
|
|
19039
|
+
else {
|
|
19040
|
+
const checkeds = document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node__checked');
|
|
19041
|
+
checkeds.forEach((item) => removeClosedAndLookUp(item, scrollToValue == 0));
|
|
19042
|
+
}
|
|
19043
|
+
}
|
|
19044
|
+
catch (err) {
|
|
19045
|
+
this.errorToLog = "Error in showSelectedNodes";
|
|
19046
|
+
}
|
|
19047
|
+
if (scrollToValue && this.scrollable) {
|
|
19048
|
+
this.scrollable.scrollTop = scrollToValue;
|
|
19049
|
+
}
|
|
19050
|
+
};
|
|
18902
19051
|
this.getShortenedFullpath = (realFullpath) => {
|
|
18903
19052
|
var _a, _b, _c, _d;
|
|
19053
|
+
if (!realFullpath)
|
|
19054
|
+
return realFullpath;
|
|
19055
|
+
//TODO if one day we want shortenedfulpaths from data loading :
|
|
19056
|
+
// const rdmdata = (this.optionsManager.getOptions().source == "webservice" ? this.rawDataManager.getData() : this.rawDataManager.getData().data ?? null);
|
|
19057
|
+
//TODO but for now we're doing :
|
|
19058
|
+
if (this.optionsManager.getOptions().source !== "webservice")
|
|
19059
|
+
return realFullpath;
|
|
18904
19060
|
let toret = realFullpath;
|
|
18905
|
-
|
|
18906
|
-
|
|
18907
|
-
|
|
18908
|
-
|
|
18909
|
-
|
|
18910
|
-
|
|
18911
|
-
|
|
18912
|
-
|
|
18913
|
-
|
|
18914
|
-
|
|
19061
|
+
const rdmdata = this.rawDataManager.getData();
|
|
19062
|
+
if (rdmdata) {
|
|
19063
|
+
try {
|
|
19064
|
+
const propertyName_nodeid = (this.optionsManager.getOptions().origin == 'classification' ? "startNode" : "StartNodeID");
|
|
19065
|
+
let propertyValue_nodeid = 0;
|
|
19066
|
+
switch (this.optionsManager.getOptions().source) {
|
|
19067
|
+
case "file":
|
|
19068
|
+
//TODO maybe someday ... someday far !
|
|
19069
|
+
return realFullpath;
|
|
19070
|
+
case "data":
|
|
19071
|
+
//TODO maybe someday ... someday far !
|
|
19072
|
+
if (this.optionsManager.getOptions().origin == 'classification')
|
|
19073
|
+
return realFullpath;
|
|
19074
|
+
propertyValue_nodeid = this.theOptions.data.key;
|
|
19075
|
+
break;
|
|
19076
|
+
case "webservice":
|
|
19077
|
+
propertyValue_nodeid = this.optionsManager.getOptions().options[propertyName_nodeid];
|
|
19078
|
+
break;
|
|
18915
19079
|
}
|
|
18916
|
-
|
|
18917
|
-
|
|
18918
|
-
|
|
19080
|
+
if (["0", 0].includes(propertyValue_nodeid))
|
|
19081
|
+
return toret;
|
|
19082
|
+
if (isNumeric(propertyValue_nodeid)) {
|
|
19083
|
+
if (this.optionsManager.getOptions().origin == 'classification') {
|
|
19084
|
+
const { Translations, Properties } = rdmdata;
|
|
19085
|
+
const currentLanguage = this.optionsManager.getOptions().language;
|
|
19086
|
+
toret = ((_b = (_a = Translations[currentLanguage]) === null || _a === void 0 ? void 0 : _a.translated_name) !== null && _b !== void 0 ? _b : Properties === null || Properties === void 0 ? void 0 : Properties.System_Name) + realFullpath.replace(((_d = (_c = Translations[currentLanguage]) === null || _c === void 0 ? void 0 : _c.translated_fullpath) !== null && _d !== void 0 ? _d : Properties === null || Properties === void 0 ? void 0 : Properties.System_Fullpath), "");
|
|
19087
|
+
}
|
|
19088
|
+
else {
|
|
19089
|
+
const { fullpath, fullpathTranslated, title, valueTranslated } = rdmdata;
|
|
19090
|
+
toret = (valueTranslated !== null && valueTranslated !== void 0 ? valueTranslated : title) + realFullpath.replace((fullpathTranslated !== null && fullpathTranslated !== void 0 ? fullpathTranslated : fullpath), "");
|
|
19091
|
+
}
|
|
18919
19092
|
}
|
|
19093
|
+
else
|
|
19094
|
+
this.errorToLog = "Error in getShortenedFullpath : startnode is not number";
|
|
19095
|
+
}
|
|
19096
|
+
catch (error) {
|
|
19097
|
+
this.errorToLog = "Error in getShortenedFullpath " + error.toString();
|
|
18920
19098
|
}
|
|
18921
|
-
else
|
|
18922
|
-
this.errorToLog = "Error in getFullpath : startnode is not number";
|
|
18923
|
-
}
|
|
18924
|
-
catch (error) {
|
|
18925
|
-
this.errorToLog = "Error in getFullpath " + error.toString();
|
|
18926
19099
|
}
|
|
18927
19100
|
return toret;
|
|
18928
19101
|
};
|
|
@@ -18974,7 +19147,6 @@ const HierarchizedPickerComponent = class {
|
|
|
18974
19147
|
}
|
|
18975
19148
|
componentDidLoad() {
|
|
18976
19149
|
this.mylog('----- componentDidLoad beginning -----');
|
|
18977
|
-
setupKeyboardNavigation(this, this.navigateInTree);
|
|
18978
19150
|
focusMainInput();
|
|
18979
19151
|
}
|
|
18980
19152
|
displayWhenLoaded() {
|
|
@@ -19018,6 +19190,8 @@ const HierarchizedPickerComponent = class {
|
|
|
19018
19190
|
this.optionsManager.getOptions().openTreeWhenLoaded = false;
|
|
19019
19191
|
if (!this.optionsManager.getOptions().displayRootNode)
|
|
19020
19192
|
this.optionsManager.getOptions().displayRootNode = false;
|
|
19193
|
+
if (!this.optionsManager.getOptions().keyboardNavigation)
|
|
19194
|
+
this.optionsManager.getOptions().keyboardNavigation = false;
|
|
19021
19195
|
if (!this.optionsManager.getOptions().dragAndDropEnabled)
|
|
19022
19196
|
this.optionsManager.getOptions().dragAndDropEnabled = false;
|
|
19023
19197
|
if (!this.optionsManager.getOptions().defaultValueIsFullpath)
|
|
@@ -19035,21 +19209,50 @@ const HierarchizedPickerComponent = class {
|
|
|
19035
19209
|
}
|
|
19036
19210
|
await Promise.all(this.optionsManager.getOptions().defaultValue.map(async (element) => {
|
|
19037
19211
|
if (this.optionsManager.getOptions().defaultValueIsFullpath || (!(typeof element == 'number') && !strIsNumeric(element))) {
|
|
19038
|
-
if (
|
|
19039
|
-
|
|
19212
|
+
if (!defaultFromFullpaths) {
|
|
19213
|
+
defaultFromFullpaths = [];
|
|
19214
|
+
}
|
|
19215
|
+
let errormsg = '';
|
|
19216
|
+
switch (this.optionsManager.getOptions().source) {
|
|
19217
|
+
case 'file':
|
|
19218
|
+
errormsg = 'The loading of nodes based on fullpath is not available on file mode for now!';
|
|
19219
|
+
break;
|
|
19220
|
+
case 'data':
|
|
19221
|
+
if (this.theOptions.origin == 'classification') {
|
|
19222
|
+
errormsg = 'The loading of nodes based on fullpath is not available on file mode for the classification context for now!';
|
|
19223
|
+
break;
|
|
19224
|
+
}
|
|
19225
|
+
const searchIdInData = function (treeData) {
|
|
19226
|
+
if (treeData.data.fullpath === element || treeData.data.fullpathTranslated === element) {
|
|
19227
|
+
return treeData.key;
|
|
19228
|
+
}
|
|
19229
|
+
if (treeData.children && treeData.children.length > 0) {
|
|
19230
|
+
for (const childTree of treeData.children) {
|
|
19231
|
+
const foundId = searchIdInData(childTree);
|
|
19232
|
+
if (foundId) {
|
|
19233
|
+
return foundId;
|
|
19234
|
+
}
|
|
19235
|
+
}
|
|
19236
|
+
}
|
|
19237
|
+
return null;
|
|
19238
|
+
};
|
|
19239
|
+
if (element) {
|
|
19240
|
+
const foundId = searchIdInData(this.theOptions.data);
|
|
19241
|
+
if (foundId)
|
|
19242
|
+
defaultFromFullpaths.push(foundId);
|
|
19243
|
+
}
|
|
19244
|
+
break;
|
|
19245
|
+
case 'webservice':
|
|
19246
|
+
const valtopush = await this.rawDataManager.fetchNodeIdFromFullpath(element, this.optionsManager.getOptions()).catch(err => { this.displayPickerError(err); });
|
|
19247
|
+
if (valtopush) {
|
|
19248
|
+
defaultFromFullpaths.push(valtopush);
|
|
19249
|
+
}
|
|
19250
|
+
break;
|
|
19251
|
+
}
|
|
19252
|
+
if (errormsg.length > 0) {
|
|
19040
19253
|
this.displayPickerError(errormsg);
|
|
19041
19254
|
this.errorToLog = errormsg;
|
|
19042
19255
|
autoAssignReach = false;
|
|
19043
|
-
return;
|
|
19044
|
-
}
|
|
19045
|
-
else {
|
|
19046
|
-
if (!defaultFromFullpaths) {
|
|
19047
|
-
defaultFromFullpaths = [];
|
|
19048
|
-
}
|
|
19049
|
-
const valtopush = await this.rawDataManager.fetchNodeIdFromFullpath(element, this.optionsManager.getOptions()).catch(err => { this.displayPickerError(err); });
|
|
19050
|
-
if (valtopush) {
|
|
19051
|
-
defaultFromFullpaths.push(valtopush);
|
|
19052
|
-
}
|
|
19053
19256
|
}
|
|
19054
19257
|
}
|
|
19055
19258
|
}));
|
|
@@ -19057,7 +19260,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19057
19260
|
this.optionsManager.getOptions().defaultValue = defaultFromFullpaths;
|
|
19058
19261
|
}
|
|
19059
19262
|
if (this.optionsManager.getOptions().options) {
|
|
19060
|
-
if (
|
|
19263
|
+
if (this.optionsManager.getOptions().defaultValue.length > 0) {
|
|
19061
19264
|
if (autoAssignReach) {
|
|
19062
19265
|
this.optionsManager.getOptions().options.Reach = this.optionsManager.getOptions().defaultValue.map(element => {
|
|
19063
19266
|
return Number(element);
|
|
@@ -19084,10 +19287,16 @@ const HierarchizedPickerComponent = class {
|
|
|
19084
19287
|
console.timeEnd = function () { };
|
|
19085
19288
|
}
|
|
19086
19289
|
// Setup component unique ID
|
|
19087
|
-
if (this.optionsManager.getOptions().id)
|
|
19290
|
+
if (this.optionsManager.getOptions().id) {
|
|
19088
19291
|
this.componentID = this.optionsManager.getOptions().id;
|
|
19089
|
-
|
|
19090
|
-
|
|
19292
|
+
}
|
|
19293
|
+
else if (!this.componentID) {
|
|
19294
|
+
let componentID = (Array.from(document.querySelectorAll('reneco-hierarchized-picker')).indexOf(this.el) + 1);
|
|
19295
|
+
while (document.querySelectorAll(`#hierarchized-picker-${componentID}`).length > 0) {
|
|
19296
|
+
componentID++;
|
|
19297
|
+
}
|
|
19298
|
+
this.componentID = componentID.toString();
|
|
19299
|
+
}
|
|
19091
19300
|
if (!this.optionsManager.getOptions())
|
|
19092
19301
|
return;
|
|
19093
19302
|
this.optionsManager.updateDefaultValue();
|
|
@@ -19155,7 +19364,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19155
19364
|
this.ignoreOptionsChanges = false;
|
|
19156
19365
|
}
|
|
19157
19366
|
catch (_b) {
|
|
19158
|
-
|
|
19367
|
+
this.errorToLog = 'Error loading webservice data!';
|
|
19159
19368
|
}
|
|
19160
19369
|
}
|
|
19161
19370
|
displayPickerError(errorMsg = '') {
|
|
@@ -19167,11 +19376,11 @@ const HierarchizedPickerComponent = class {
|
|
|
19167
19376
|
}
|
|
19168
19377
|
this.displayedValue = errorMsg;
|
|
19169
19378
|
this.isDisabled = true;
|
|
19170
|
-
|
|
19379
|
+
this.errorToLog = errorMsg;
|
|
19171
19380
|
}
|
|
19172
19381
|
}
|
|
19173
19382
|
catch (_a) {
|
|
19174
|
-
|
|
19383
|
+
this.errorToLog = errorMsg;
|
|
19175
19384
|
}
|
|
19176
19385
|
}
|
|
19177
19386
|
getApiSearchURL() {
|
|
@@ -19191,17 +19400,17 @@ const HierarchizedPickerComponent = class {
|
|
|
19191
19400
|
}
|
|
19192
19401
|
}
|
|
19193
19402
|
// TODO > Celine would rather like the context (thesaurus or position) to be extracted another way
|
|
19194
|
-
getContextualApiURL(init = false) {
|
|
19195
|
-
const { options, url } = this.optionsManager.getOptions();
|
|
19403
|
+
getContextualApiURL(init = false, forcedOptions = null) {
|
|
19404
|
+
const { options, url } = forcedOptions || this.optionsManager.getOptions();
|
|
19196
19405
|
if (init && options.Reach) {
|
|
19197
|
-
|
|
19198
|
-
const base = window.location.origin; // fallback for relative URLs
|
|
19406
|
+
const base = window.location.origin;
|
|
19199
19407
|
const parsedUrl = new URL(url, base);
|
|
19200
|
-
const pathSegments = parsedUrl.pathname.split('/');
|
|
19201
|
-
|
|
19202
|
-
if (
|
|
19203
|
-
|
|
19204
|
-
|
|
19408
|
+
const pathSegments = parsedUrl.pathname.split('/').filter(Boolean);
|
|
19409
|
+
const idx = pathSegments.indexOf("getTree");
|
|
19410
|
+
if (idx !== -1) {
|
|
19411
|
+
pathSegments[idx] = "reach";
|
|
19412
|
+
}
|
|
19413
|
+
const newPathname = "/" + pathSegments.join("/");
|
|
19205
19414
|
return `${parsedUrl.origin}${newPathname}`;
|
|
19206
19415
|
}
|
|
19207
19416
|
return url;
|
|
@@ -19240,12 +19449,10 @@ const HierarchizedPickerComponent = class {
|
|
|
19240
19449
|
}
|
|
19241
19450
|
}
|
|
19242
19451
|
loadSearchDataInCurrentTree(searchID, searched) {
|
|
19243
|
-
|
|
19244
|
-
if (this.searchToDisplay > -1) {
|
|
19245
|
-
|
|
19246
|
-
|
|
19247
|
-
completeCurrentTreeWithTree(this.loadedTreeJs, value, this.optionsManager.getOptions());
|
|
19248
|
-
});
|
|
19452
|
+
const displayResults = () => {
|
|
19453
|
+
if (this.searchToDisplay > -1) {
|
|
19454
|
+
if (!searched)
|
|
19455
|
+
this.setSearchResults([]);
|
|
19249
19456
|
this.triggerTreeDisplay(this.rawDataManager.getData(), searched);
|
|
19250
19457
|
displayAutocompleteWithResults(this.rawDataManager.getData(), searched, this.optionsManager, this.editValue.bind(this), this.showTree.bind(this));
|
|
19251
19458
|
// Deploys all nodes
|
|
@@ -19261,18 +19468,24 @@ const HierarchizedPickerComponent = class {
|
|
|
19261
19468
|
});
|
|
19262
19469
|
}
|
|
19263
19470
|
};
|
|
19471
|
+
const completeLocalTree = (newtree) => {
|
|
19472
|
+
if (this.searchToDisplay > -1) { // TODO > Not working anymore after refact, prevents issues in displaying results when running multiple researchs at the same time && searchID == this.searchToDisplay) {
|
|
19473
|
+
this.rawDataManager.mergeData(newtree, this.theOptions.origin == 'classification' ? "ID" : "key");
|
|
19474
|
+
newtree.children.forEach((value, index) => {
|
|
19475
|
+
completeCurrentTreeWithTree(this.loadedTreeJs, value, this.optionsManager.getOptions());
|
|
19476
|
+
});
|
|
19477
|
+
displayResults();
|
|
19478
|
+
}
|
|
19479
|
+
};
|
|
19264
19480
|
if (this.theOptions.source == 'webservice') {
|
|
19265
19481
|
if (this.theOptions.origin == 'classification') {
|
|
19266
19482
|
// WS Call
|
|
19267
19483
|
this.rawDataManager.getFromClassification(this.getApiSearchURL(), Object.assign({}, this.getContextualApiParams(null, searched)), document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"))
|
|
19268
19484
|
.then((data) => {
|
|
19269
|
-
|
|
19270
|
-
if (!searched) {
|
|
19271
|
-
this.setSearchResults([]);
|
|
19272
|
-
}
|
|
19485
|
+
completeLocalTree(data);
|
|
19273
19486
|
})
|
|
19274
19487
|
.catch(err => {
|
|
19275
|
-
|
|
19488
|
+
this.errorToLog = err;
|
|
19276
19489
|
});
|
|
19277
19490
|
}
|
|
19278
19491
|
else {
|
|
@@ -19285,35 +19498,26 @@ const HierarchizedPickerComponent = class {
|
|
|
19285
19498
|
deprecated: false,
|
|
19286
19499
|
}, document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"))
|
|
19287
19500
|
.then((data) => {
|
|
19288
|
-
|
|
19289
|
-
if (!searched) {
|
|
19290
|
-
this.setSearchResults([]);
|
|
19291
|
-
}
|
|
19501
|
+
completeLocalTree(data);
|
|
19292
19502
|
})
|
|
19293
19503
|
.catch(error => {
|
|
19294
|
-
|
|
19504
|
+
this.errorToLog = error;
|
|
19295
19505
|
try {
|
|
19296
19506
|
this.errorToLog = 'getDataFromSource 1 rejected:' + JSON.stringify(error, replacer, 2);
|
|
19297
19507
|
}
|
|
19298
19508
|
catch (_a) {
|
|
19299
|
-
|
|
19509
|
+
this.errorToLog = JSON.stringify(error, replacer, 2);
|
|
19300
19510
|
}
|
|
19301
19511
|
});
|
|
19302
19512
|
}
|
|
19303
19513
|
}
|
|
19304
19514
|
else {
|
|
19305
|
-
if (this.
|
|
19306
|
-
|
|
19307
|
-
completeCurrentTreeWithTree(this.loadedTreeJs, value, this.optionsManager.getOptions());
|
|
19308
|
-
});
|
|
19309
|
-
displayAutocompleteWithResults(this.rawDataManager.getData(), searched, this.optionsManager, this.editValue.bind(this), this.showTree.bind(this));
|
|
19515
|
+
if (this.optionsManager.getOptions().source == 'data') {
|
|
19516
|
+
displayResults();
|
|
19310
19517
|
}
|
|
19311
|
-
|
|
19312
|
-
|
|
19313
|
-
if (searched) {
|
|
19314
|
-
this.setSearchResults(treeToDisplay);
|
|
19518
|
+
else {
|
|
19519
|
+
console.error("Unhandled picker settings for search scenario !!");
|
|
19315
19520
|
}
|
|
19316
|
-
this.displayTree(treeToDisplay);
|
|
19317
19521
|
}
|
|
19318
19522
|
}
|
|
19319
19523
|
async triggerTreeDisplay(dataToLoad, searched) {
|
|
@@ -19395,11 +19599,31 @@ const HierarchizedPickerComponent = class {
|
|
|
19395
19599
|
this.showSelectedNodes();
|
|
19396
19600
|
this.deactivateNodesOutOfDepthSettings();
|
|
19397
19601
|
// Hides checkboxes in non multiple context
|
|
19398
|
-
|
|
19399
|
-
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = 'none'));
|
|
19400
|
-
}
|
|
19602
|
+
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = (this.theOptions.multiple ? 'inline-block' : 'none')));
|
|
19401
19603
|
}
|
|
19402
19604
|
onItemContextMenuItemClick(e) {
|
|
19605
|
+
if (e.target && e.target.id) {
|
|
19606
|
+
function getDirectParentAndDepth(nodesById, targetId) {
|
|
19607
|
+
// Find the direct parent
|
|
19608
|
+
const parent = Object.values(nodesById).find(node => { var _a; return (_a = node.children) === null || _a === void 0 ? void 0 : _a.some(child => child.id === targetId); }) || null;
|
|
19609
|
+
if (!nodesById[targetId])
|
|
19610
|
+
return null; // target not found
|
|
19611
|
+
// Depth is 0 for root nodes, 1 for children of root, etc.
|
|
19612
|
+
let depth = 0;
|
|
19613
|
+
let current = targetId;
|
|
19614
|
+
while (true) {
|
|
19615
|
+
const directParent = Object.values(nodesById).find(node => { var _a; return (_a = node.children) === null || _a === void 0 ? void 0 : _a.some(child => child.id === current); });
|
|
19616
|
+
if (!directParent)
|
|
19617
|
+
break;
|
|
19618
|
+
depth++;
|
|
19619
|
+
current = directParent.id;
|
|
19620
|
+
}
|
|
19621
|
+
return { parent, depth };
|
|
19622
|
+
}
|
|
19623
|
+
const result = getDirectParentAndDepth(this.loadedTreeJs.nodesById, e.target.id);
|
|
19624
|
+
e.target.depth = result.depth;
|
|
19625
|
+
e.target.parentId = result.parent.id;
|
|
19626
|
+
}
|
|
19403
19627
|
this.itemContextMenuItemClick.emit(e);
|
|
19404
19628
|
}
|
|
19405
19629
|
setNodeAsSelected(id, treeToUpdate, userClick) {
|
|
@@ -19408,8 +19632,10 @@ const HierarchizedPickerComponent = class {
|
|
|
19408
19632
|
(this.loadedTreeJs.liElementsById[id] && this.loadedTreeJs.liElementsById[id].classList.value && this.loadedTreeJs.liElementsById[id].classList.value.indexOf('readonly_node') != -1)) {
|
|
19409
19633
|
return;
|
|
19410
19634
|
}
|
|
19411
|
-
if (treeToUpdate.getValues().indexOf(id.toString()) != -1)
|
|
19635
|
+
if (!userClick && treeToUpdate.getValues().indexOf(id.toString()) != -1)
|
|
19412
19636
|
return;
|
|
19637
|
+
if (this.loadedTreeJs && !this.theOptions.multiple)
|
|
19638
|
+
this.loadedTreeJs.emptyNodesCheckStatus();
|
|
19413
19639
|
this.ignoreOptionsChanges = true;
|
|
19414
19640
|
// Override of treejs normal workaround =>> DONT EDIT IT!
|
|
19415
19641
|
// ----- BEGIN -----
|
|
@@ -19446,46 +19672,29 @@ const HierarchizedPickerComponent = class {
|
|
|
19446
19672
|
* This method display the current selected node to the user by expanding all it's parent nodes and scrolling inside the tree
|
|
19447
19673
|
*/
|
|
19448
19674
|
async showSelectedNodes(addDelay = false) {
|
|
19449
|
-
if (this.optionsManager.getOptions().multiple) {
|
|
19450
|
-
|
|
19451
|
-
|
|
19452
|
-
}
|
|
19453
|
-
const scrollToNode = () => {
|
|
19454
|
-
let scrollToValue = 0;
|
|
19455
|
-
let removeClosedAndLookUp = (element) => {
|
|
19456
|
-
var _a, _b, _c, _d;
|
|
19457
|
-
const nodeId = element === null || element === void 0 ? void 0 : element.nodeId;
|
|
19458
|
-
if (!element || !nodeId) {
|
|
19459
|
-
return;
|
|
19460
|
-
}
|
|
19461
|
-
const node = this.loadedTreeJs.nodesById[nodeId];
|
|
19462
|
-
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) {
|
|
19463
|
-
(_c = element.classList) === null || _c === void 0 ? void 0 : _c.remove('treejs-node__close');
|
|
19464
|
-
}
|
|
19465
|
-
scrollToValue += element.offsetTop;
|
|
19466
|
-
const parent = (_d = element.parentNode) === null || _d === void 0 ? void 0 : _d.closest('.treejs-node');
|
|
19467
|
-
if (parent) {
|
|
19468
|
-
removeClosedAndLookUp(parent);
|
|
19469
|
-
}
|
|
19470
|
-
};
|
|
19471
|
-
try {
|
|
19472
|
-
const checkeds = document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node__checked');
|
|
19473
|
-
checkeds.forEach((item) => removeClosedAndLookUp(item));
|
|
19474
|
-
}
|
|
19475
|
-
catch (err) {
|
|
19476
|
-
// console.error("Error in showSelectedNodes", err);
|
|
19477
|
-
}
|
|
19478
|
-
if (scrollToValue && this.scrollable) {
|
|
19479
|
-
this.scrollable.scrollTop = scrollToValue;
|
|
19480
|
-
}
|
|
19481
|
-
};
|
|
19675
|
+
// if (this.optionsManager.getOptions().multiple) {
|
|
19676
|
+
// console.warn('You are not allowed to scroll to selected nodes in multiple mode');
|
|
19677
|
+
// return;
|
|
19678
|
+
// }
|
|
19482
19679
|
if (addDelay) {
|
|
19483
19680
|
setTimeout(() => {
|
|
19484
|
-
scrollToNode();
|
|
19681
|
+
this.scrollToNode();
|
|
19485
19682
|
}, 200);
|
|
19486
19683
|
}
|
|
19487
19684
|
else {
|
|
19488
|
-
scrollToNode();
|
|
19685
|
+
this.scrollToNode();
|
|
19686
|
+
}
|
|
19687
|
+
}
|
|
19688
|
+
async scrollToNodeWithId(targetNodeId, displayChildren = false) {
|
|
19689
|
+
const targetNode = this.loadedTreeJs.liElementsById[targetNodeId];
|
|
19690
|
+
if (!targetNode) {
|
|
19691
|
+
const contextualApiParams = this.getContextualApiParams(Object.assign(Object.assign({}, this.theOptions.options), { Reach: [targetNodeId] }), null, true);
|
|
19692
|
+
const contextualApiURL = this.getContextualApiURL(true, Object.assign(Object.assign({}, this.theOptions), { options: contextualApiParams }));
|
|
19693
|
+
this.rawDataManager.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"))
|
|
19694
|
+
.then(data => {
|
|
19695
|
+
completeCurrentTreeWithTree(this.loadedTreeJs, data, this.theOptions);
|
|
19696
|
+
this.scrollToNode(targetNodeId, displayChildren);
|
|
19697
|
+
});
|
|
19489
19698
|
}
|
|
19490
19699
|
}
|
|
19491
19700
|
showTree(focused) {
|
|
@@ -19494,10 +19703,10 @@ const HierarchizedPickerComponent = class {
|
|
|
19494
19703
|
clearAutocomplete();
|
|
19495
19704
|
if (!this.canload || !this.optionsManager.getOptions().displayTree)
|
|
19496
19705
|
return;
|
|
19497
|
-
const isStillInsidePicker = isInsidePicker(this, document.activeElement);
|
|
19706
|
+
const isStillInsidePicker = false; // TODO put back? >> isInsidePicker(this, document.activeElement);
|
|
19498
19707
|
if ((focused === 'hide' || this.isDisabled) && !isStillInsidePicker) {
|
|
19499
19708
|
this.hasFocus = ['hide'];
|
|
19500
|
-
const elem = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search
|
|
19709
|
+
const elem = document.querySelector('#hierarchized-picker-' + this.componentID + ' input.hierarchized-picker-search');
|
|
19501
19710
|
if (elem) {
|
|
19502
19711
|
elem.value = '';
|
|
19503
19712
|
}
|
|
@@ -19518,16 +19727,16 @@ const HierarchizedPickerComponent = class {
|
|
|
19518
19727
|
}
|
|
19519
19728
|
const previousShownTree = this.shownTree;
|
|
19520
19729
|
this.shownTree = this.hasFocus.length > 0;
|
|
19521
|
-
if (this.shownTree && !previousShownTree) {
|
|
19522
|
-
console.log("component value", document.querySelector('#hierarchized-picker-input-' + this.componentID));
|
|
19523
|
-
console.log("shouldOpenModalAbove", this.shouldOpenModalAbove(document.querySelector('#hierarchized-picker-input-' + this.componentID), this.modaleHeight));
|
|
19730
|
+
if (this.shownTree && !previousShownTree && this.optionsManager.getOptions().mode == 'input') {
|
|
19524
19731
|
if (this.shouldOpenModalAbove(document.querySelector('#hierarchized-picker-input-' + this.componentID), this.modaleHeight)) {
|
|
19525
19732
|
this.modalePosition = 'top';
|
|
19526
19733
|
}
|
|
19527
19734
|
else {
|
|
19528
19735
|
this.modalePosition = 'bottom';
|
|
19529
19736
|
}
|
|
19530
|
-
focusSearchInput(this);
|
|
19737
|
+
setTimeout(() => focusSearchInput(this), 100);
|
|
19738
|
+
//TODO, this this at the good location ?
|
|
19739
|
+
setupKeyboardNavigation(this, this.optionsManager, this.navigateInTree);
|
|
19531
19740
|
}
|
|
19532
19741
|
}
|
|
19533
19742
|
// Changes the value of the component with passed node
|
|
@@ -19540,9 +19749,12 @@ const HierarchizedPickerComponent = class {
|
|
|
19540
19749
|
return item.nodeid == node.id;
|
|
19541
19750
|
});
|
|
19542
19751
|
// If the passed node already exists in the array of values, remove it
|
|
19543
|
-
if (
|
|
19544
|
-
|
|
19545
|
-
|
|
19752
|
+
if (result > -1) {
|
|
19753
|
+
if (userClick)
|
|
19754
|
+
this.value.splice(result, 1);
|
|
19755
|
+
else
|
|
19756
|
+
return;
|
|
19757
|
+
}
|
|
19546
19758
|
else {
|
|
19547
19759
|
if (this.optionsManager.getOptions().multiple) {
|
|
19548
19760
|
this.value = [
|
|
@@ -19568,13 +19780,23 @@ const HierarchizedPickerComponent = class {
|
|
|
19568
19780
|
}
|
|
19569
19781
|
this.setDisplayedValue(this.value);
|
|
19570
19782
|
}
|
|
19783
|
+
getShortpathFromFullpath(fullpath) {
|
|
19784
|
+
if (!fullpath || fullpath.indexOf('>') == -1)
|
|
19785
|
+
return fullpath;
|
|
19786
|
+
return fullpath.substring(fullpath.lastIndexOf(">") + 1);
|
|
19787
|
+
}
|
|
19571
19788
|
setDisplayedValue(value = null) {
|
|
19572
19789
|
if (!value)
|
|
19573
19790
|
value = this.value;
|
|
19574
|
-
|
|
19575
|
-
var _a, _b;
|
|
19576
|
-
return (
|
|
19791
|
+
const toDisplay = value.map(item => {
|
|
19792
|
+
var _a, _b, _c;
|
|
19793
|
+
return (this.optionsManager.getOptions().source == 'data'
|
|
19794
|
+
?
|
|
19795
|
+
(_a = (this.optionsManager.getOptions().language == 'fr' ? this.getShortpathFromFullpath(item.fullpathTranslated) : this.getShortpathFromFullpath(item.fullpath))) !== null && _a !== void 0 ? _a : `Node ${item.nodeid}`
|
|
19796
|
+
:
|
|
19797
|
+
(_c = (this.optionsManager.getOptions().isFullpath ? this.getShortenedFullpath((_b = item.fullpathTranslated) !== null && _b !== void 0 ? _b : item.fullpath) : item.shortpathTranslated)) !== null && _c !== void 0 ? _c : `Node ${item.nodeid}`);
|
|
19577
19798
|
}).join(';');
|
|
19799
|
+
this.displayedValue = toDisplay;
|
|
19578
19800
|
}
|
|
19579
19801
|
// Search a value in the tree and triggers a search when necessary
|
|
19580
19802
|
search(searched) {
|
|
@@ -19641,10 +19863,11 @@ const HierarchizedPickerComponent = class {
|
|
|
19641
19863
|
if (init) {
|
|
19642
19864
|
this.formatDefaultValue();
|
|
19643
19865
|
this.showSelectedNodes();
|
|
19866
|
+
this.checkFields(this.value);
|
|
19644
19867
|
}
|
|
19645
19868
|
})
|
|
19646
19869
|
.catch(error => {
|
|
19647
|
-
|
|
19870
|
+
this.errorToLog = error;
|
|
19648
19871
|
});
|
|
19649
19872
|
}
|
|
19650
19873
|
else {
|
|
@@ -19657,7 +19880,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19657
19880
|
}
|
|
19658
19881
|
})
|
|
19659
19882
|
.catch(error => {
|
|
19660
|
-
|
|
19883
|
+
this.errorToLog = error;
|
|
19661
19884
|
});
|
|
19662
19885
|
}
|
|
19663
19886
|
}
|
|
@@ -19678,7 +19901,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19678
19901
|
let enrichedValues = [];
|
|
19679
19902
|
if (values) {
|
|
19680
19903
|
values.forEach(element => {
|
|
19681
|
-
var _a, _b;
|
|
19904
|
+
var _a, _b, _c;
|
|
19682
19905
|
let intNodeid = element.nodeid || element.ID || element.key || undefined;
|
|
19683
19906
|
if (typeof intNodeid === 'string' && isNumeric(intNodeid)) {
|
|
19684
19907
|
intNodeid = parseInt(intNodeid);
|
|
@@ -19688,15 +19911,15 @@ const HierarchizedPickerComponent = class {
|
|
|
19688
19911
|
enrichedValues.push({
|
|
19689
19912
|
nodeid: intNodeid,
|
|
19690
19913
|
shortpathTranslated: (_a = treeNode.text) !== null && _a !== void 0 ? _a : `Node ${intNodeid}`,
|
|
19691
|
-
fullpathTranslated: (_b = treeNode.
|
|
19914
|
+
fullpathTranslated: (_b = treeNode.fullpathTranslated) !== null && _b !== void 0 ? _b : null,
|
|
19915
|
+
fullpath: (_c = treeNode.fullpath) !== null && _c !== void 0 ? _c : null,
|
|
19692
19916
|
hasChildren: treeNode.children && treeNode.children.length > 0
|
|
19693
19917
|
});
|
|
19694
|
-
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
19695
19918
|
}
|
|
19696
19919
|
else {
|
|
19697
|
-
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
19698
19920
|
console.warn("Node not found in Tree for:", intNodeid);
|
|
19699
19921
|
}
|
|
19922
|
+
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
19700
19923
|
});
|
|
19701
19924
|
}
|
|
19702
19925
|
this.setDisplayedValue(enrichedValues);
|
|
@@ -19706,8 +19929,19 @@ const HierarchizedPickerComponent = class {
|
|
|
19706
19929
|
formatDefaultValue() {
|
|
19707
19930
|
let found = 0;
|
|
19708
19931
|
let that = this;
|
|
19932
|
+
let fieldsToCheck = [];
|
|
19933
|
+
function addToFieldsToCheck(item) {
|
|
19934
|
+
if (Array.isArray(item)) {
|
|
19935
|
+
item.forEach(el => addToFieldsToCheck(el));
|
|
19936
|
+
}
|
|
19937
|
+
else {
|
|
19938
|
+
const exists = fieldsToCheck.some(el => (el.nodeid || el.ID) == (item.nodeid || item.ID));
|
|
19939
|
+
if (!exists) {
|
|
19940
|
+
fieldsToCheck.push(item);
|
|
19941
|
+
}
|
|
19942
|
+
}
|
|
19943
|
+
}
|
|
19709
19944
|
let recursive = function (children) {
|
|
19710
|
-
//158424
|
|
19711
19945
|
children.forEach(element => {
|
|
19712
19946
|
that.theOptions.defaultValue.forEach(dfValue => {
|
|
19713
19947
|
if (typeof dfValue == 'string' && isNumeric(dfValue)) {
|
|
@@ -19717,7 +19951,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19717
19951
|
if ((typeof dfValue == 'string' && getPropertyFromNode(element, 'Properties').FullPath == dfValue) ||
|
|
19718
19952
|
(typeof dfValue == 'number' && getPropertyFromNode(element, 'ID') == dfValue)) {
|
|
19719
19953
|
element.nodeid = element.id;
|
|
19720
|
-
|
|
19954
|
+
addToFieldsToCheck([element]);
|
|
19721
19955
|
found++;
|
|
19722
19956
|
}
|
|
19723
19957
|
}
|
|
@@ -19727,7 +19961,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19727
19961
|
(typeof dfValue == 'string' && getPropertyFromNode(element, 'fullpathTranslated') == dfValue) ||
|
|
19728
19962
|
(typeof dfValue == 'number' && getPropertyFromNode(element, 'key') == dfValue)) {
|
|
19729
19963
|
element.nodeid = element.key;
|
|
19730
|
-
|
|
19964
|
+
addToFieldsToCheck([element]);
|
|
19731
19965
|
found++;
|
|
19732
19966
|
}
|
|
19733
19967
|
}
|
|
@@ -19739,6 +19973,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19739
19973
|
if (this.rawDataManager.getData()) {
|
|
19740
19974
|
recursive([this.rawDataManager.getData()]);
|
|
19741
19975
|
}
|
|
19976
|
+
that.checkFields(fieldsToCheck);
|
|
19742
19977
|
if (this.theOptions.defaultValue.length != found) {
|
|
19743
19978
|
if (found == 0) {
|
|
19744
19979
|
try {
|
|
@@ -19764,6 +19999,8 @@ const HierarchizedPickerComponent = class {
|
|
|
19764
19999
|
.join('; ');
|
|
19765
20000
|
}
|
|
19766
20001
|
shouldOpenModalAbove(inputElement, modaleHeight) {
|
|
20002
|
+
if (this.optionsManager.getOptions().mode != 'input')
|
|
20003
|
+
return false;
|
|
19767
20004
|
const inputRect = inputElement.getBoundingClientRect();
|
|
19768
20005
|
const spaceLeft = window.innerHeight - inputRect.y;
|
|
19769
20006
|
return spaceLeft < modaleHeight;
|
|
@@ -19787,7 +20024,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19787
20024
|
clickPickerModalArea(this);
|
|
19788
20025
|
} }, h("div", { class: "loader", ref: el => {
|
|
19789
20026
|
this.loader = el;
|
|
19790
|
-
} }, h("div", { class: "loader-inner" }, "Loading...")), h("div", { class: `hierarchized-picker-modal ${!this.ready ? 'hidden' : ''}
|
|
20027
|
+
} }, h("div", { class: "loader-inner" }, "Loading...")), h("div", { class: `hierarchized-picker-modal ${!this.ready ? 'hidden' : ''}`, tabindex: "0" }, h("search-input", { placeholder: getLanguageValue(this.optionsManager.getOptions().searchPlaceholder, this.optionsManager.getOptions().language, defaultLanguage), onInputFocus: () => focusInSearchEvent(this), onInputBlur: () => focusOutSearchEvent(this, event), onSearch: (event) => this.search(event.detail) }), h("ul", { id: "autocomplete-results-area" }), h("div", { id: 'tree-area-' + this.componentID, class: 'hierarchized-picker-tree hierarchized-picker-tree-area ' + this.pickerClass }))))) : (h("div", { class: 'hierarchized-picker-raw-tree-area' + (this.isDisabled ? ' readonly' : ''), tabindex: "0", onClick: event => {
|
|
19791
20028
|
clickPickerModalArea(this);
|
|
19792
20029
|
} }, h("div", { class: "loader", ref: el => {
|
|
19793
20030
|
this.loader = el;
|
|
@@ -19845,9 +20082,7 @@ const SearchInput = class {
|
|
|
19845
20082
|
render() {
|
|
19846
20083
|
return (h("div", { id: "hierarchized-picker-input-search",
|
|
19847
20084
|
// TODO: need component ID ?
|
|
19848
|
-
class: "search-input-container", ref: (el) => (this.rootElement = el) }, h("div", { class: "reneco reneco-search" }), h("input", { ref: (el) => (this.inputElement = el), type: "text", class: "native-input sc-ion-input-md-h sc-ion-input-md-s md search-input hierarchized-picker-search",
|
|
19849
|
-
//class="native-input search-input hierarchized-picker-search sc-ion-input-md-h sc-ion-input-md-s md"
|
|
19850
|
-
placeholder: this.placeholder, onFocus: () => this.handleFocus(), onBlur: (event) => this.handleBlur(event), onInput: (event) => this.handleInput(event) })));
|
|
20085
|
+
class: "search-input-container", ref: (el) => (this.rootElement = el) }, h("div", { class: "reneco reneco-search" }), h("input", { ref: (el) => (this.inputElement = el), type: "text", class: "native-input sc-ion-input-md-h sc-ion-input-md-s md search-input hierarchized-picker-search", placeholder: this.placeholder, onFocus: () => this.handleFocus(), onBlur: (event) => this.handleBlur(event), onInput: (event) => this.handleInput(event) })));
|
|
19851
20086
|
}
|
|
19852
20087
|
};
|
|
19853
20088
|
SearchInput.style = searchInputCss;
|