reneco-hierarchized-picker 0.4.3-beta.8 → 0.5.0
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 +509 -270
- package/dist/collection/components/hierarchized-picker/hierarchized-picker.css +10 -2
- package/dist/collection/components/hierarchized-picker/hierarchized-picker.js +391 -130
- 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 +83 -56
- 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 +509 -270
- 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 +509 -270
- 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-0e305bec.entry.js +1 -0
- package/dist/reneco-hierarchized-picker/p-73168a50.system.js +1 -1
- package/dist/reneco-hierarchized-picker/p-9027f23a.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-57a928cc.entry.js +0 -1
- package/dist/reneco-hierarchized-picker/p-eea99162.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,100 @@ 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
|
+
// TODO put back? >> focusMainInput(component);
|
|
18644
|
+
}, 100);
|
|
18645
|
+
}
|
|
18646
|
+
}
|
|
18647
|
+
break;
|
|
18648
|
+
case 'arrowup':
|
|
18649
|
+
event.preventDefault();
|
|
18650
|
+
focusedNodeIndex = Math.max(focusedNodeIndex - 1, 0);
|
|
18651
|
+
const newActiveNodeUp = treeNodesFromTree[focusedNodeIndex];
|
|
18652
|
+
const newLiElementUp = tree.liElementsById[newActiveNodeUp.id];
|
|
18653
|
+
newLiElementUp.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
18654
|
+
focusNode(tree.liElementsById, newLiElementUp);
|
|
18655
|
+
break;
|
|
18656
|
+
case 'arrowdown':
|
|
18657
|
+
event.preventDefault();
|
|
18658
|
+
focusedNodeIndex = Math.min(focusedNodeIndex + 1, treeNodesFromTree.length - 1);
|
|
18659
|
+
const newActiveNodeDown = treeNodesFromTree[focusedNodeIndex];
|
|
18660
|
+
const newLiElementDown = tree.liElementsById[newActiveNodeDown.id];
|
|
18661
|
+
focusNode(tree.liElementsById, newLiElementDown);
|
|
18662
|
+
newLiElementDown.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
18663
|
+
break;
|
|
18664
|
+
case 'arrowleft':
|
|
18665
|
+
event.preventDefault();
|
|
18666
|
+
const leftSwitcher = liElement.querySelector('.treejs-switcher');
|
|
18667
|
+
if (leftSwitcher) {
|
|
18668
|
+
(_a = component.loadedTreeJs) === null || _a === void 0 ? void 0 : _a.onSwitcherClick(leftSwitcher);
|
|
18669
|
+
}
|
|
18670
|
+
break;
|
|
18671
|
+
case 'arrowright':
|
|
18672
|
+
event.preventDefault();
|
|
18673
|
+
const rightSwitcher = liElement.querySelector('.treejs-switcher');
|
|
18674
|
+
if (rightSwitcher) {
|
|
18675
|
+
(_b = component.loadedTreeJs) === null || _b === void 0 ? void 0 : _b.onSwitcherClick(rightSwitcher);
|
|
18676
|
+
}
|
|
18677
|
+
break;
|
|
18678
|
+
}
|
|
18679
|
+
if (handledEvents.includes(event.key.toLowerCase()))
|
|
18680
|
+
navigateInTree.emit(event);
|
|
18681
|
+
});
|
|
18682
|
+
}
|
|
18683
|
+
}
|
|
18684
|
+
|
|
18579
18685
|
// Focus management
|
|
18580
18686
|
async function focusSearchInput(component) {
|
|
18581
18687
|
const searchInput = component.el.querySelector('search-input input');
|
|
@@ -18606,19 +18712,6 @@ function handleFocusEvent(component, type) {
|
|
|
18606
18712
|
component.showTree('hide');
|
|
18607
18713
|
}
|
|
18608
18714
|
}
|
|
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
18715
|
function clickPickerModalArea(component, _event) {
|
|
18623
18716
|
if (component.pickerClass === 'fieldError') {
|
|
18624
18717
|
component.showTree('hide');
|
|
@@ -18629,82 +18722,18 @@ function clickPickerModalArea(component, _event) {
|
|
|
18629
18722
|
else {
|
|
18630
18723
|
component.mylog('Ignored modal click');
|
|
18631
18724
|
}
|
|
18725
|
+
if (component.theOptions.mode == 'tree') {
|
|
18726
|
+
setupKeyboardNavigation(component, component.optionsManager, component.navigateInTree);
|
|
18727
|
+
}
|
|
18632
18728
|
}
|
|
18633
18729
|
// Exposed event handlers
|
|
18634
18730
|
function focusInSearchEvent(component) {
|
|
18635
18731
|
handleFocusEvent(component, 'search');
|
|
18636
18732
|
}
|
|
18637
18733
|
function focusOutSearchEvent(component, event) {
|
|
18638
|
-
manageFocusOut(component, event);
|
|
18639
|
-
}
|
|
18640
|
-
|
|
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
|
-
setTimeout(() => focusNode(component.loadedTreeJs.liElementsById, component.loadedTreeJs.liElementsById[component.loadedTreeJs.treeNodes[focusedNodeIndex].id]), 100);
|
|
18705
18734
|
}
|
|
18706
18735
|
|
|
18707
|
-
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}";
|
|
18736
|
+
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}";
|
|
18708
18737
|
|
|
18709
18738
|
const HierarchizedPickerComponent = class {
|
|
18710
18739
|
/**
|
|
@@ -18773,14 +18802,66 @@ const HierarchizedPickerComponent = class {
|
|
|
18773
18802
|
logError(messageToLog) {
|
|
18774
18803
|
try {
|
|
18775
18804
|
console.error('--- Hierarchized picker ' + this.componentID + ' ERROR ---', messageToLog);
|
|
18805
|
+
this.lastErrorMessage = messageToLog;
|
|
18776
18806
|
}
|
|
18777
18807
|
catch (_a) {
|
|
18778
|
-
|
|
18808
|
+
const genericErrorMessage = '--- Hierarchized picker generic ERROR ---';
|
|
18809
|
+
this.lastErrorMessage = genericErrorMessage;
|
|
18810
|
+
console.error(genericErrorMessage);
|
|
18779
18811
|
}
|
|
18812
|
+
this.errorRaised.emit(this.lastErrorMessage);
|
|
18780
18813
|
}
|
|
18781
18814
|
get theOptions() {
|
|
18782
18815
|
return this.optionsManager.getOptions();
|
|
18783
18816
|
}
|
|
18817
|
+
diffKeys(obj1, obj2, prefix = '') {
|
|
18818
|
+
const diffs = [];
|
|
18819
|
+
const commonKeys = Object.keys(obj1 || {}).filter(key => obj2 && Object.prototype.hasOwnProperty.call(obj2, key));
|
|
18820
|
+
for (const key of commonKeys) {
|
|
18821
|
+
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
18822
|
+
const val1 = obj1[key];
|
|
18823
|
+
const val2 = obj2[key];
|
|
18824
|
+
if (Array.isArray(val1) && Array.isArray(val2)) {
|
|
18825
|
+
// Compare array length
|
|
18826
|
+
if (val1.length !== val2.length) {
|
|
18827
|
+
diffs.push(fullKey);
|
|
18828
|
+
continue;
|
|
18829
|
+
}
|
|
18830
|
+
// Compare each element deeply
|
|
18831
|
+
for (let i = 0; i < val1.length; i++) {
|
|
18832
|
+
const v1 = val1[i];
|
|
18833
|
+
const v2 = val2[i];
|
|
18834
|
+
if (typeof v1 === 'object' &&
|
|
18835
|
+
v1 !== null &&
|
|
18836
|
+
typeof v2 === 'object' &&
|
|
18837
|
+
v2 !== null) {
|
|
18838
|
+
const subDiffs = this.diffKeys(v1, v2, `${fullKey}[${i}]`);
|
|
18839
|
+
if (subDiffs.length > 0) {
|
|
18840
|
+
diffs.push(fullKey);
|
|
18841
|
+
break; // stop at first mismatch in array
|
|
18842
|
+
}
|
|
18843
|
+
}
|
|
18844
|
+
else if (v1 !== v2) {
|
|
18845
|
+
diffs.push(fullKey);
|
|
18846
|
+
break;
|
|
18847
|
+
}
|
|
18848
|
+
}
|
|
18849
|
+
}
|
|
18850
|
+
else if (val1 &&
|
|
18851
|
+
val2 &&
|
|
18852
|
+
typeof val1 === 'object' &&
|
|
18853
|
+
typeof val2 === 'object') {
|
|
18854
|
+
// Recursive deep object comparison
|
|
18855
|
+
const subDiffs = this.diffKeys(val1, val2, fullKey);
|
|
18856
|
+
if (subDiffs.length > 0)
|
|
18857
|
+
diffs.push(...subDiffs);
|
|
18858
|
+
}
|
|
18859
|
+
else if (val1 !== val2) {
|
|
18860
|
+
diffs.push(fullKey);
|
|
18861
|
+
}
|
|
18862
|
+
}
|
|
18863
|
+
return diffs;
|
|
18864
|
+
}
|
|
18784
18865
|
async setNewOption(newValue, oldValue = null) {
|
|
18785
18866
|
this.ready = false;
|
|
18786
18867
|
// --------------------------------------- DEPRECATED ?
|
|
@@ -18799,6 +18880,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18799
18880
|
// });
|
|
18800
18881
|
// ---------------------------------------
|
|
18801
18882
|
// this.theOptions = newValue;
|
|
18883
|
+
const savedOldValue = Object.assign({}, this.theOptions);
|
|
18802
18884
|
if (oldValue && JSON.stringify(newValue.options) == JSON.stringify(oldValue.options)) {
|
|
18803
18885
|
this.ready = true;
|
|
18804
18886
|
return;
|
|
@@ -18807,6 +18889,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18807
18889
|
newValue = JSON.parse(newValue);
|
|
18808
18890
|
if (typeof oldValue == 'string')
|
|
18809
18891
|
oldValue = JSON.parse(oldValue);
|
|
18892
|
+
this.value = [];
|
|
18810
18893
|
this.optionsManager.updateOptions(newValue);
|
|
18811
18894
|
this.setDisplayedValue(this.value);
|
|
18812
18895
|
const originOrNodeIdAreDifferent = !oldValue || (newValue.origin != oldValue.origin || newValue.options.StartNodeID != oldValue.options.StartNodeID);
|
|
@@ -18824,11 +18907,28 @@ const HierarchizedPickerComponent = class {
|
|
|
18824
18907
|
if (oldValue && JSON.stringify(newValue.options) != JSON.stringify(oldValue.options)) {
|
|
18825
18908
|
this.value = [];
|
|
18826
18909
|
}
|
|
18827
|
-
if ((newValue === null || newValue === void 0 ? void 0 : newValue.loading) == 'display') {
|
|
18910
|
+
if ((newValue === null || newValue === void 0 ? void 0 : newValue.loading) == 'display' || (newValue && !newValue.loading)) {
|
|
18828
18911
|
if ((oldValue && this.isChangeInOptions(newValue, oldValue)) || !oldValue) {
|
|
18829
|
-
|
|
18830
|
-
|
|
18831
|
-
|
|
18912
|
+
if (!oldValue) {
|
|
18913
|
+
oldValue = savedOldValue;
|
|
18914
|
+
}
|
|
18915
|
+
const propDiffs = this.diffKeys(oldValue, this.optionsManager.initializeOptions(newValue));
|
|
18916
|
+
const noReloadProps = ["multiple"];
|
|
18917
|
+
const ignoredProps = ["token"];
|
|
18918
|
+
const filteredDiffs = propDiffs.filter(prop => !ignoredProps.includes(prop));
|
|
18919
|
+
if (filteredDiffs.length == 1 && filteredDiffs.some(item => noReloadProps.includes(item))) {
|
|
18920
|
+
const propChanged = filteredDiffs[0];
|
|
18921
|
+
switch (propChanged) {
|
|
18922
|
+
case "multiple":
|
|
18923
|
+
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = (this.theOptions.multiple ? 'inline-block' : 'none')));
|
|
18924
|
+
break;
|
|
18925
|
+
}
|
|
18926
|
+
}
|
|
18927
|
+
else {
|
|
18928
|
+
this.rawDataManager = new RawDataManager(this.getOptionsAsIConf(this.optionsManager.getOptions()).token, this.optionsManager);
|
|
18929
|
+
await this.loadHierarchizedPicker(true);
|
|
18930
|
+
this.displayWhenLoaded();
|
|
18931
|
+
}
|
|
18832
18932
|
}
|
|
18833
18933
|
else {
|
|
18834
18934
|
this.ready = true;
|
|
@@ -18882,6 +18982,9 @@ const HierarchizedPickerComponent = class {
|
|
|
18882
18982
|
async filterTree(searchedValue) {
|
|
18883
18983
|
this.search(searchedValue);
|
|
18884
18984
|
}
|
|
18985
|
+
async getError() {
|
|
18986
|
+
return Promise.resolve(this.lastErrorMessage);
|
|
18987
|
+
}
|
|
18885
18988
|
constructor(hostRef) {
|
|
18886
18989
|
registerInstance(this, hostRef);
|
|
18887
18990
|
this.valueChange = createEvent(this, "valueChange", 7);
|
|
@@ -18889,6 +18992,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18889
18992
|
this.itemContextMenuItemClick = createEvent(this, "itemContextMenuItemClick", 7);
|
|
18890
18993
|
this.searchResult = createEvent(this, "searchResult", 7);
|
|
18891
18994
|
this.navigateInTree = createEvent(this, "navigateInTree", 7);
|
|
18995
|
+
this.errorRaised = createEvent(this, "errorRaised", 7);
|
|
18892
18996
|
this.modaleHeight = 200;
|
|
18893
18997
|
this.modalePosition = 'bottom';
|
|
18894
18998
|
this.canload = true; // Determines wether the component may be loaded
|
|
@@ -18898,30 +19002,101 @@ const HierarchizedPickerComponent = class {
|
|
|
18898
19002
|
this.lastSearchMatchCounter = 0; // Counter of number of matches for last search
|
|
18899
19003
|
this.setValueOnClick = true; // Tells wether we edit the picker value on click in the tree
|
|
18900
19004
|
this.mylog = console.log; // Custom log function for debug purposes
|
|
19005
|
+
this.lastErrorMessage = '';
|
|
19006
|
+
this.scrollToNode = (targetNodeId = null, displayChildren = false) => {
|
|
19007
|
+
var _a;
|
|
19008
|
+
let scrollToValue = 0;
|
|
19009
|
+
let removeClosedAndLookUp = (element, editScroll = false) => {
|
|
19010
|
+
var _a, _b, _c, _d;
|
|
19011
|
+
const nodeId = element === null || element === void 0 ? void 0 : element.nodeId;
|
|
19012
|
+
if (!element || !nodeId) {
|
|
19013
|
+
return;
|
|
19014
|
+
}
|
|
19015
|
+
const node = this.loadedTreeJs.nodesById[nodeId];
|
|
19016
|
+
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) {
|
|
19017
|
+
(_c = element.classList) === null || _c === void 0 ? void 0 : _c.remove('treejs-node__close');
|
|
19018
|
+
}
|
|
19019
|
+
if (editScroll) {
|
|
19020
|
+
scrollToValue += element.offsetTop;
|
|
19021
|
+
}
|
|
19022
|
+
const parent = (_d = element.parentNode) === null || _d === void 0 ? void 0 : _d.closest('.treejs-node');
|
|
19023
|
+
if (parent) {
|
|
19024
|
+
removeClosedAndLookUp(parent, editScroll);
|
|
19025
|
+
}
|
|
19026
|
+
};
|
|
19027
|
+
try {
|
|
19028
|
+
if (targetNodeId) {
|
|
19029
|
+
const targetNode = this.loadedTreeJs.liElementsById[targetNodeId];
|
|
19030
|
+
if (targetNode) {
|
|
19031
|
+
removeClosedAndLookUp(targetNode, true);
|
|
19032
|
+
if (displayChildren && targetNode.classList.contains('treejs-node__close')) {
|
|
19033
|
+
const leftSwitcher = targetNode.querySelector('.treejs-switcher');
|
|
19034
|
+
if (leftSwitcher) {
|
|
19035
|
+
(_a = this.loadedTreeJs) === null || _a === void 0 ? void 0 : _a.onSwitcherClick(leftSwitcher);
|
|
19036
|
+
}
|
|
19037
|
+
}
|
|
19038
|
+
}
|
|
19039
|
+
}
|
|
19040
|
+
else {
|
|
19041
|
+
const checkeds = document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node__checked');
|
|
19042
|
+
checkeds.forEach((item) => removeClosedAndLookUp(item, scrollToValue == 0));
|
|
19043
|
+
}
|
|
19044
|
+
}
|
|
19045
|
+
catch (err) {
|
|
19046
|
+
this.errorToLog = "Error in showSelectedNodes";
|
|
19047
|
+
}
|
|
19048
|
+
if (scrollToValue && this.scrollable) {
|
|
19049
|
+
this.scrollable.scrollTop = scrollToValue;
|
|
19050
|
+
}
|
|
19051
|
+
};
|
|
18901
19052
|
this.getShortenedFullpath = (realFullpath) => {
|
|
18902
19053
|
var _a, _b, _c, _d;
|
|
19054
|
+
if (!realFullpath)
|
|
19055
|
+
return realFullpath;
|
|
19056
|
+
//TODO if one day we want shortenedfulpaths from data loading :
|
|
19057
|
+
// const rdmdata = (this.optionsManager.getOptions().source == "webservice" ? this.rawDataManager.getData() : this.rawDataManager.getData().data ?? null);
|
|
19058
|
+
//TODO but for now we're doing :
|
|
19059
|
+
if (this.optionsManager.getOptions().source !== "webservice")
|
|
19060
|
+
return realFullpath;
|
|
18903
19061
|
let toret = realFullpath;
|
|
18904
|
-
|
|
18905
|
-
|
|
18906
|
-
|
|
18907
|
-
|
|
18908
|
-
|
|
18909
|
-
|
|
18910
|
-
|
|
18911
|
-
|
|
18912
|
-
|
|
18913
|
-
|
|
19062
|
+
const rdmdata = this.rawDataManager.getData();
|
|
19063
|
+
if (rdmdata) {
|
|
19064
|
+
try {
|
|
19065
|
+
const propertyName_nodeid = (this.optionsManager.getOptions().origin == 'classification' ? "startNode" : "StartNodeID");
|
|
19066
|
+
let propertyValue_nodeid = 0;
|
|
19067
|
+
switch (this.optionsManager.getOptions().source) {
|
|
19068
|
+
case "file":
|
|
19069
|
+
//TODO maybe someday ... someday far !
|
|
19070
|
+
return realFullpath;
|
|
19071
|
+
case "data":
|
|
19072
|
+
//TODO maybe someday ... someday far !
|
|
19073
|
+
if (this.optionsManager.getOptions().origin == 'classification')
|
|
19074
|
+
return realFullpath;
|
|
19075
|
+
propertyValue_nodeid = this.theOptions.data.key;
|
|
19076
|
+
break;
|
|
19077
|
+
case "webservice":
|
|
19078
|
+
propertyValue_nodeid = this.optionsManager.getOptions().options[propertyName_nodeid];
|
|
19079
|
+
break;
|
|
18914
19080
|
}
|
|
18915
|
-
|
|
18916
|
-
|
|
18917
|
-
|
|
19081
|
+
if (["0", 0].includes(propertyValue_nodeid))
|
|
19082
|
+
return toret;
|
|
19083
|
+
if (isNumeric(propertyValue_nodeid)) {
|
|
19084
|
+
if (this.optionsManager.getOptions().origin == 'classification') {
|
|
19085
|
+
const { Translations, Properties } = rdmdata;
|
|
19086
|
+
const currentLanguage = this.optionsManager.getOptions().language;
|
|
19087
|
+
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), "");
|
|
19088
|
+
}
|
|
19089
|
+
else {
|
|
19090
|
+
const { fullpath, fullpathTranslated, title, valueTranslated } = rdmdata;
|
|
19091
|
+
toret = (valueTranslated !== null && valueTranslated !== void 0 ? valueTranslated : title) + realFullpath.replace((fullpathTranslated !== null && fullpathTranslated !== void 0 ? fullpathTranslated : fullpath), "");
|
|
19092
|
+
}
|
|
18918
19093
|
}
|
|
19094
|
+
else
|
|
19095
|
+
this.errorToLog = "Error in getShortenedFullpath : startnode is not number";
|
|
19096
|
+
}
|
|
19097
|
+
catch (error) {
|
|
19098
|
+
this.errorToLog = "Error in getShortenedFullpath " + error.toString();
|
|
18919
19099
|
}
|
|
18920
|
-
else
|
|
18921
|
-
this.errorToLog = "Error in getFullpath : startnode is not number";
|
|
18922
|
-
}
|
|
18923
|
-
catch (error) {
|
|
18924
|
-
this.errorToLog = "Error in getFullpath " + error.toString();
|
|
18925
19100
|
}
|
|
18926
19101
|
return toret;
|
|
18927
19102
|
};
|
|
@@ -18973,7 +19148,6 @@ const HierarchizedPickerComponent = class {
|
|
|
18973
19148
|
}
|
|
18974
19149
|
componentDidLoad() {
|
|
18975
19150
|
this.mylog('----- componentDidLoad beginning -----');
|
|
18976
|
-
setupKeyboardNavigation(this, this.navigateInTree);
|
|
18977
19151
|
focusMainInput();
|
|
18978
19152
|
}
|
|
18979
19153
|
displayWhenLoaded() {
|
|
@@ -19017,6 +19191,8 @@ const HierarchizedPickerComponent = class {
|
|
|
19017
19191
|
this.optionsManager.getOptions().openTreeWhenLoaded = false;
|
|
19018
19192
|
if (!this.optionsManager.getOptions().displayRootNode)
|
|
19019
19193
|
this.optionsManager.getOptions().displayRootNode = false;
|
|
19194
|
+
if (!this.optionsManager.getOptions().keyboardNavigation)
|
|
19195
|
+
this.optionsManager.getOptions().keyboardNavigation = false;
|
|
19020
19196
|
if (!this.optionsManager.getOptions().dragAndDropEnabled)
|
|
19021
19197
|
this.optionsManager.getOptions().dragAndDropEnabled = false;
|
|
19022
19198
|
if (!this.optionsManager.getOptions().defaultValueIsFullpath)
|
|
@@ -19034,21 +19210,50 @@ const HierarchizedPickerComponent = class {
|
|
|
19034
19210
|
}
|
|
19035
19211
|
await Promise.all(this.optionsManager.getOptions().defaultValue.map(async (element) => {
|
|
19036
19212
|
if (this.optionsManager.getOptions().defaultValueIsFullpath || (!(typeof element == 'number') && !strIsNumeric(element))) {
|
|
19037
|
-
if (
|
|
19038
|
-
|
|
19213
|
+
if (!defaultFromFullpaths) {
|
|
19214
|
+
defaultFromFullpaths = [];
|
|
19215
|
+
}
|
|
19216
|
+
let errormsg = '';
|
|
19217
|
+
switch (this.optionsManager.getOptions().source) {
|
|
19218
|
+
case 'file':
|
|
19219
|
+
errormsg = 'The loading of nodes based on fullpath is not available on file mode for now!';
|
|
19220
|
+
break;
|
|
19221
|
+
case 'data':
|
|
19222
|
+
if (this.theOptions.origin == 'classification') {
|
|
19223
|
+
errormsg = 'The loading of nodes based on fullpath is not available on file mode for the classification context for now!';
|
|
19224
|
+
break;
|
|
19225
|
+
}
|
|
19226
|
+
const searchIdInData = function (treeData) {
|
|
19227
|
+
if (treeData.data.fullpath === element || treeData.data.fullpathTranslated === element) {
|
|
19228
|
+
return treeData.key;
|
|
19229
|
+
}
|
|
19230
|
+
if (treeData.children && treeData.children.length > 0) {
|
|
19231
|
+
for (const childTree of treeData.children) {
|
|
19232
|
+
const foundId = searchIdInData(childTree);
|
|
19233
|
+
if (foundId) {
|
|
19234
|
+
return foundId;
|
|
19235
|
+
}
|
|
19236
|
+
}
|
|
19237
|
+
}
|
|
19238
|
+
return null;
|
|
19239
|
+
};
|
|
19240
|
+
if (element) {
|
|
19241
|
+
const foundId = searchIdInData(this.theOptions.data);
|
|
19242
|
+
if (foundId)
|
|
19243
|
+
defaultFromFullpaths.push(foundId);
|
|
19244
|
+
}
|
|
19245
|
+
break;
|
|
19246
|
+
case 'webservice':
|
|
19247
|
+
const valtopush = await this.rawDataManager.fetchNodeIdFromFullpath(element, this.optionsManager.getOptions()).catch(err => { this.displayPickerError(err); });
|
|
19248
|
+
if (valtopush) {
|
|
19249
|
+
defaultFromFullpaths.push(valtopush);
|
|
19250
|
+
}
|
|
19251
|
+
break;
|
|
19252
|
+
}
|
|
19253
|
+
if (errormsg.length > 0) {
|
|
19039
19254
|
this.displayPickerError(errormsg);
|
|
19040
19255
|
this.errorToLog = errormsg;
|
|
19041
19256
|
autoAssignReach = false;
|
|
19042
|
-
return;
|
|
19043
|
-
}
|
|
19044
|
-
else {
|
|
19045
|
-
if (!defaultFromFullpaths) {
|
|
19046
|
-
defaultFromFullpaths = [];
|
|
19047
|
-
}
|
|
19048
|
-
const valtopush = await this.rawDataManager.fetchNodeIdFromFullpath(element, this.optionsManager.getOptions()).catch(err => { this.displayPickerError(err); });
|
|
19049
|
-
if (valtopush) {
|
|
19050
|
-
defaultFromFullpaths.push(valtopush);
|
|
19051
|
-
}
|
|
19052
19257
|
}
|
|
19053
19258
|
}
|
|
19054
19259
|
}));
|
|
@@ -19056,7 +19261,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19056
19261
|
this.optionsManager.getOptions().defaultValue = defaultFromFullpaths;
|
|
19057
19262
|
}
|
|
19058
19263
|
if (this.optionsManager.getOptions().options) {
|
|
19059
|
-
if (
|
|
19264
|
+
if (this.optionsManager.getOptions().defaultValue.length > 0) {
|
|
19060
19265
|
if (autoAssignReach) {
|
|
19061
19266
|
this.optionsManager.getOptions().options.Reach = this.optionsManager.getOptions().defaultValue.map(element => {
|
|
19062
19267
|
return Number(element);
|
|
@@ -19083,10 +19288,16 @@ const HierarchizedPickerComponent = class {
|
|
|
19083
19288
|
console.timeEnd = function () { };
|
|
19084
19289
|
}
|
|
19085
19290
|
// Setup component unique ID
|
|
19086
|
-
if (this.optionsManager.getOptions().id)
|
|
19291
|
+
if (this.optionsManager.getOptions().id) {
|
|
19087
19292
|
this.componentID = this.optionsManager.getOptions().id;
|
|
19088
|
-
|
|
19089
|
-
|
|
19293
|
+
}
|
|
19294
|
+
else if (!this.componentID) {
|
|
19295
|
+
let componentID = (Array.from(document.querySelectorAll('reneco-hierarchized-picker')).indexOf(this.el) + 1);
|
|
19296
|
+
while (document.querySelectorAll(`#hierarchized-picker-${componentID}`).length > 0) {
|
|
19297
|
+
componentID++;
|
|
19298
|
+
}
|
|
19299
|
+
this.componentID = componentID.toString();
|
|
19300
|
+
}
|
|
19090
19301
|
if (!this.optionsManager.getOptions())
|
|
19091
19302
|
return;
|
|
19092
19303
|
this.optionsManager.updateDefaultValue();
|
|
@@ -19154,7 +19365,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19154
19365
|
this.ignoreOptionsChanges = false;
|
|
19155
19366
|
}
|
|
19156
19367
|
catch (_b) {
|
|
19157
|
-
|
|
19368
|
+
this.errorToLog = 'Error loading webservice data!';
|
|
19158
19369
|
}
|
|
19159
19370
|
}
|
|
19160
19371
|
displayPickerError(errorMsg = '') {
|
|
@@ -19166,11 +19377,11 @@ const HierarchizedPickerComponent = class {
|
|
|
19166
19377
|
}
|
|
19167
19378
|
this.displayedValue = errorMsg;
|
|
19168
19379
|
this.isDisabled = true;
|
|
19169
|
-
|
|
19380
|
+
this.errorToLog = errorMsg;
|
|
19170
19381
|
}
|
|
19171
19382
|
}
|
|
19172
19383
|
catch (_a) {
|
|
19173
|
-
|
|
19384
|
+
this.errorToLog = errorMsg;
|
|
19174
19385
|
}
|
|
19175
19386
|
}
|
|
19176
19387
|
getApiSearchURL() {
|
|
@@ -19190,17 +19401,17 @@ const HierarchizedPickerComponent = class {
|
|
|
19190
19401
|
}
|
|
19191
19402
|
}
|
|
19192
19403
|
// TODO > Celine would rather like the context (thesaurus or position) to be extracted another way
|
|
19193
|
-
getContextualApiURL(init = false) {
|
|
19194
|
-
const { options, url } = this.optionsManager.getOptions();
|
|
19404
|
+
getContextualApiURL(init = false, forcedOptions = null) {
|
|
19405
|
+
const { options, url } = forcedOptions || this.optionsManager.getOptions();
|
|
19195
19406
|
if (init && options.Reach) {
|
|
19196
|
-
|
|
19197
|
-
const base = window.location.origin; // fallback for relative URLs
|
|
19407
|
+
const base = window.location.origin;
|
|
19198
19408
|
const parsedUrl = new URL(url, base);
|
|
19199
|
-
const pathSegments = parsedUrl.pathname.split('/');
|
|
19200
|
-
|
|
19201
|
-
if (
|
|
19202
|
-
|
|
19203
|
-
|
|
19409
|
+
const pathSegments = parsedUrl.pathname.split('/').filter(Boolean);
|
|
19410
|
+
const idx = pathSegments.indexOf("getTree");
|
|
19411
|
+
if (idx !== -1) {
|
|
19412
|
+
pathSegments[idx] = "reach";
|
|
19413
|
+
}
|
|
19414
|
+
const newPathname = "/" + pathSegments.join("/");
|
|
19204
19415
|
return `${parsedUrl.origin}${newPathname}`;
|
|
19205
19416
|
}
|
|
19206
19417
|
return url;
|
|
@@ -19271,7 +19482,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19271
19482
|
}
|
|
19272
19483
|
})
|
|
19273
19484
|
.catch(err => {
|
|
19274
|
-
|
|
19485
|
+
this.errorToLog = err;
|
|
19275
19486
|
});
|
|
19276
19487
|
}
|
|
19277
19488
|
else {
|
|
@@ -19290,29 +19501,26 @@ const HierarchizedPickerComponent = class {
|
|
|
19290
19501
|
}
|
|
19291
19502
|
})
|
|
19292
19503
|
.catch(error => {
|
|
19293
|
-
|
|
19504
|
+
this.errorToLog = error;
|
|
19294
19505
|
try {
|
|
19295
19506
|
this.errorToLog = 'getDataFromSource 1 rejected:' + JSON.stringify(error, replacer, 2);
|
|
19296
19507
|
}
|
|
19297
19508
|
catch (_a) {
|
|
19298
|
-
|
|
19509
|
+
this.errorToLog = JSON.stringify(error, replacer, 2);
|
|
19299
19510
|
}
|
|
19300
19511
|
});
|
|
19301
19512
|
}
|
|
19302
19513
|
}
|
|
19303
19514
|
else {
|
|
19304
|
-
if (this.
|
|
19305
|
-
this.rawDataManager.getData()
|
|
19306
|
-
|
|
19307
|
-
|
|
19308
|
-
|
|
19515
|
+
if (this.optionsManager.getOptions().source == 'data') {
|
|
19516
|
+
displayResults(this.rawDataManager.getData());
|
|
19517
|
+
if (!searched) {
|
|
19518
|
+
this.setSearchResults([]);
|
|
19519
|
+
}
|
|
19309
19520
|
}
|
|
19310
|
-
|
|
19311
|
-
|
|
19312
|
-
if (searched) {
|
|
19313
|
-
this.setSearchResults(treeToDisplay);
|
|
19521
|
+
else {
|
|
19522
|
+
console.error("Unhandled picker settings for search scenario !!");
|
|
19314
19523
|
}
|
|
19315
|
-
this.displayTree(treeToDisplay);
|
|
19316
19524
|
}
|
|
19317
19525
|
}
|
|
19318
19526
|
async triggerTreeDisplay(dataToLoad, searched) {
|
|
@@ -19394,11 +19602,31 @@ const HierarchizedPickerComponent = class {
|
|
|
19394
19602
|
this.showSelectedNodes();
|
|
19395
19603
|
this.deactivateNodesOutOfDepthSettings();
|
|
19396
19604
|
// Hides checkboxes in non multiple context
|
|
19397
|
-
|
|
19398
|
-
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = 'none'));
|
|
19399
|
-
}
|
|
19605
|
+
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = (this.theOptions.multiple ? 'inline-block' : 'none')));
|
|
19400
19606
|
}
|
|
19401
19607
|
onItemContextMenuItemClick(e) {
|
|
19608
|
+
if (e.target && e.target.id) {
|
|
19609
|
+
function getDirectParentAndDepth(nodesById, targetId) {
|
|
19610
|
+
// Find the direct parent
|
|
19611
|
+
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;
|
|
19612
|
+
if (!nodesById[targetId])
|
|
19613
|
+
return null; // target not found
|
|
19614
|
+
// Depth is 0 for root nodes, 1 for children of root, etc.
|
|
19615
|
+
let depth = 0;
|
|
19616
|
+
let current = targetId;
|
|
19617
|
+
while (true) {
|
|
19618
|
+
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); });
|
|
19619
|
+
if (!directParent)
|
|
19620
|
+
break;
|
|
19621
|
+
depth++;
|
|
19622
|
+
current = directParent.id;
|
|
19623
|
+
}
|
|
19624
|
+
return { parent, depth };
|
|
19625
|
+
}
|
|
19626
|
+
const result = getDirectParentAndDepth(this.loadedTreeJs.nodesById, e.target.id);
|
|
19627
|
+
e.target.depth = result.depth;
|
|
19628
|
+
e.target.parentId = result.parent.id;
|
|
19629
|
+
}
|
|
19402
19630
|
this.itemContextMenuItemClick.emit(e);
|
|
19403
19631
|
}
|
|
19404
19632
|
setNodeAsSelected(id, treeToUpdate, userClick) {
|
|
@@ -19407,8 +19635,10 @@ const HierarchizedPickerComponent = class {
|
|
|
19407
19635
|
(this.loadedTreeJs.liElementsById[id] && this.loadedTreeJs.liElementsById[id].classList.value && this.loadedTreeJs.liElementsById[id].classList.value.indexOf('readonly_node') != -1)) {
|
|
19408
19636
|
return;
|
|
19409
19637
|
}
|
|
19410
|
-
if (treeToUpdate.getValues().indexOf(id.toString()) != -1)
|
|
19638
|
+
if (!userClick && treeToUpdate.getValues().indexOf(id.toString()) != -1)
|
|
19411
19639
|
return;
|
|
19640
|
+
if (this.loadedTreeJs && !this.theOptions.multiple)
|
|
19641
|
+
this.loadedTreeJs.emptyNodesCheckStatus();
|
|
19412
19642
|
this.ignoreOptionsChanges = true;
|
|
19413
19643
|
// Override of treejs normal workaround =>> DONT EDIT IT!
|
|
19414
19644
|
// ----- BEGIN -----
|
|
@@ -19445,46 +19675,29 @@ const HierarchizedPickerComponent = class {
|
|
|
19445
19675
|
* This method display the current selected node to the user by expanding all it's parent nodes and scrolling inside the tree
|
|
19446
19676
|
*/
|
|
19447
19677
|
async showSelectedNodes(addDelay = false) {
|
|
19448
|
-
if (this.optionsManager.getOptions().multiple) {
|
|
19449
|
-
|
|
19450
|
-
|
|
19451
|
-
}
|
|
19452
|
-
const scrollToNode = () => {
|
|
19453
|
-
let scrollToValue = 0;
|
|
19454
|
-
let removeClosedAndLookUp = (element) => {
|
|
19455
|
-
var _a, _b, _c, _d;
|
|
19456
|
-
const nodeId = element === null || element === void 0 ? void 0 : element.nodeId;
|
|
19457
|
-
if (!element || !nodeId) {
|
|
19458
|
-
return;
|
|
19459
|
-
}
|
|
19460
|
-
const node = this.loadedTreeJs.nodesById[nodeId];
|
|
19461
|
-
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) {
|
|
19462
|
-
(_c = element.classList) === null || _c === void 0 ? void 0 : _c.remove('treejs-node__close');
|
|
19463
|
-
}
|
|
19464
|
-
scrollToValue += element.offsetTop;
|
|
19465
|
-
const parent = (_d = element.parentNode) === null || _d === void 0 ? void 0 : _d.closest('.treejs-node');
|
|
19466
|
-
if (parent) {
|
|
19467
|
-
removeClosedAndLookUp(parent);
|
|
19468
|
-
}
|
|
19469
|
-
};
|
|
19470
|
-
try {
|
|
19471
|
-
const checkeds = document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node__checked');
|
|
19472
|
-
checkeds.forEach((item) => removeClosedAndLookUp(item));
|
|
19473
|
-
}
|
|
19474
|
-
catch (err) {
|
|
19475
|
-
// console.error("Error in showSelectedNodes", err);
|
|
19476
|
-
}
|
|
19477
|
-
if (scrollToValue && this.scrollable) {
|
|
19478
|
-
this.scrollable.scrollTop = scrollToValue;
|
|
19479
|
-
}
|
|
19480
|
-
};
|
|
19678
|
+
// if (this.optionsManager.getOptions().multiple) {
|
|
19679
|
+
// console.warn('You are not allowed to scroll to selected nodes in multiple mode');
|
|
19680
|
+
// return;
|
|
19681
|
+
// }
|
|
19481
19682
|
if (addDelay) {
|
|
19482
19683
|
setTimeout(() => {
|
|
19483
|
-
scrollToNode();
|
|
19684
|
+
this.scrollToNode();
|
|
19484
19685
|
}, 200);
|
|
19485
19686
|
}
|
|
19486
19687
|
else {
|
|
19487
|
-
scrollToNode();
|
|
19688
|
+
this.scrollToNode();
|
|
19689
|
+
}
|
|
19690
|
+
}
|
|
19691
|
+
async scrollToNodeWithId(targetNodeId, displayChildren = false) {
|
|
19692
|
+
const targetNode = this.loadedTreeJs.liElementsById[targetNodeId];
|
|
19693
|
+
if (!targetNode) {
|
|
19694
|
+
const contextualApiParams = this.getContextualApiParams(Object.assign(Object.assign({}, this.theOptions.options), { Reach: [targetNodeId] }), null, true);
|
|
19695
|
+
const contextualApiURL = this.getContextualApiURL(true, Object.assign(Object.assign({}, this.theOptions), { options: contextualApiParams }));
|
|
19696
|
+
this.rawDataManager.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"))
|
|
19697
|
+
.then(data => {
|
|
19698
|
+
completeCurrentTreeWithTree(this.loadedTreeJs, data, this.theOptions);
|
|
19699
|
+
this.scrollToNode(targetNodeId, displayChildren);
|
|
19700
|
+
});
|
|
19488
19701
|
}
|
|
19489
19702
|
}
|
|
19490
19703
|
showTree(focused) {
|
|
@@ -19493,10 +19706,10 @@ const HierarchizedPickerComponent = class {
|
|
|
19493
19706
|
clearAutocomplete();
|
|
19494
19707
|
if (!this.canload || !this.optionsManager.getOptions().displayTree)
|
|
19495
19708
|
return;
|
|
19496
|
-
const isStillInsidePicker = isInsidePicker(this, document.activeElement);
|
|
19709
|
+
const isStillInsidePicker = false; // TODO put back? >> isInsidePicker(this, document.activeElement);
|
|
19497
19710
|
if ((focused === 'hide' || this.isDisabled) && !isStillInsidePicker) {
|
|
19498
19711
|
this.hasFocus = ['hide'];
|
|
19499
|
-
const elem = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search
|
|
19712
|
+
const elem = document.querySelector('#hierarchized-picker-' + this.componentID + ' input.hierarchized-picker-search');
|
|
19500
19713
|
if (elem) {
|
|
19501
19714
|
elem.value = '';
|
|
19502
19715
|
}
|
|
@@ -19517,16 +19730,16 @@ const HierarchizedPickerComponent = class {
|
|
|
19517
19730
|
}
|
|
19518
19731
|
const previousShownTree = this.shownTree;
|
|
19519
19732
|
this.shownTree = this.hasFocus.length > 0;
|
|
19520
|
-
if (this.shownTree && !previousShownTree) {
|
|
19521
|
-
console.log("component value", document.querySelector('#hierarchized-picker-input-' + this.componentID));
|
|
19522
|
-
console.log("shouldOpenModalAbove", this.shouldOpenModalAbove(document.querySelector('#hierarchized-picker-input-' + this.componentID), this.modaleHeight));
|
|
19733
|
+
if (this.shownTree && !previousShownTree && this.optionsManager.getOptions().mode == 'input') {
|
|
19523
19734
|
if (this.shouldOpenModalAbove(document.querySelector('#hierarchized-picker-input-' + this.componentID), this.modaleHeight)) {
|
|
19524
19735
|
this.modalePosition = 'top';
|
|
19525
19736
|
}
|
|
19526
19737
|
else {
|
|
19527
19738
|
this.modalePosition = 'bottom';
|
|
19528
19739
|
}
|
|
19529
|
-
focusSearchInput(this);
|
|
19740
|
+
setTimeout(() => focusSearchInput(this), 100);
|
|
19741
|
+
//TODO, this this at the good location ?
|
|
19742
|
+
setupKeyboardNavigation(this, this.optionsManager, this.navigateInTree);
|
|
19530
19743
|
}
|
|
19531
19744
|
}
|
|
19532
19745
|
// Changes the value of the component with passed node
|
|
@@ -19539,9 +19752,12 @@ const HierarchizedPickerComponent = class {
|
|
|
19539
19752
|
return item.nodeid == node.id;
|
|
19540
19753
|
});
|
|
19541
19754
|
// If the passed node already exists in the array of values, remove it
|
|
19542
|
-
if (
|
|
19543
|
-
|
|
19544
|
-
|
|
19755
|
+
if (result > -1) {
|
|
19756
|
+
if (userClick)
|
|
19757
|
+
this.value.splice(result, 1);
|
|
19758
|
+
else
|
|
19759
|
+
return;
|
|
19760
|
+
}
|
|
19545
19761
|
else {
|
|
19546
19762
|
if (this.optionsManager.getOptions().multiple) {
|
|
19547
19763
|
this.value = [
|
|
@@ -19567,13 +19783,23 @@ const HierarchizedPickerComponent = class {
|
|
|
19567
19783
|
}
|
|
19568
19784
|
this.setDisplayedValue(this.value);
|
|
19569
19785
|
}
|
|
19786
|
+
getShortpathFromFullpath(fullpath) {
|
|
19787
|
+
if (!fullpath || fullpath.indexOf('>') == -1)
|
|
19788
|
+
return fullpath;
|
|
19789
|
+
return fullpath.substring(fullpath.lastIndexOf(">") + 1);
|
|
19790
|
+
}
|
|
19570
19791
|
setDisplayedValue(value = null) {
|
|
19571
19792
|
if (!value)
|
|
19572
19793
|
value = this.value;
|
|
19573
|
-
|
|
19574
|
-
var _a, _b;
|
|
19575
|
-
return (
|
|
19794
|
+
const toDisplay = value.map(item => {
|
|
19795
|
+
var _a, _b, _c;
|
|
19796
|
+
return (this.optionsManager.getOptions().source == 'data'
|
|
19797
|
+
?
|
|
19798
|
+
(_a = (this.optionsManager.getOptions().language == 'fr' ? this.getShortpathFromFullpath(item.fullpathTranslated) : this.getShortpathFromFullpath(item.fullpath))) !== null && _a !== void 0 ? _a : `Node ${item.nodeid}`
|
|
19799
|
+
:
|
|
19800
|
+
(_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}`);
|
|
19576
19801
|
}).join(';');
|
|
19802
|
+
this.displayedValue = toDisplay;
|
|
19577
19803
|
}
|
|
19578
19804
|
// Search a value in the tree and triggers a search when necessary
|
|
19579
19805
|
search(searched) {
|
|
@@ -19640,10 +19866,11 @@ const HierarchizedPickerComponent = class {
|
|
|
19640
19866
|
if (init) {
|
|
19641
19867
|
this.formatDefaultValue();
|
|
19642
19868
|
this.showSelectedNodes();
|
|
19869
|
+
this.checkFields(this.value);
|
|
19643
19870
|
}
|
|
19644
19871
|
})
|
|
19645
19872
|
.catch(error => {
|
|
19646
|
-
|
|
19873
|
+
this.errorToLog = error;
|
|
19647
19874
|
});
|
|
19648
19875
|
}
|
|
19649
19876
|
else {
|
|
@@ -19656,7 +19883,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19656
19883
|
}
|
|
19657
19884
|
})
|
|
19658
19885
|
.catch(error => {
|
|
19659
|
-
|
|
19886
|
+
this.errorToLog = error;
|
|
19660
19887
|
});
|
|
19661
19888
|
}
|
|
19662
19889
|
}
|
|
@@ -19677,7 +19904,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19677
19904
|
let enrichedValues = [];
|
|
19678
19905
|
if (values) {
|
|
19679
19906
|
values.forEach(element => {
|
|
19680
|
-
var _a, _b;
|
|
19907
|
+
var _a, _b, _c;
|
|
19681
19908
|
let intNodeid = element.nodeid || element.ID || element.key || undefined;
|
|
19682
19909
|
if (typeof intNodeid === 'string' && isNumeric(intNodeid)) {
|
|
19683
19910
|
intNodeid = parseInt(intNodeid);
|
|
@@ -19687,15 +19914,15 @@ const HierarchizedPickerComponent = class {
|
|
|
19687
19914
|
enrichedValues.push({
|
|
19688
19915
|
nodeid: intNodeid,
|
|
19689
19916
|
shortpathTranslated: (_a = treeNode.text) !== null && _a !== void 0 ? _a : `Node ${intNodeid}`,
|
|
19690
|
-
fullpathTranslated: (_b = treeNode.
|
|
19917
|
+
fullpathTranslated: (_b = treeNode.fullpathTranslated) !== null && _b !== void 0 ? _b : null,
|
|
19918
|
+
fullpath: (_c = treeNode.fullpath) !== null && _c !== void 0 ? _c : null,
|
|
19691
19919
|
hasChildren: treeNode.children && treeNode.children.length > 0
|
|
19692
19920
|
});
|
|
19693
|
-
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
19694
19921
|
}
|
|
19695
19922
|
else {
|
|
19696
|
-
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
19697
19923
|
console.warn("Node not found in Tree for:", intNodeid);
|
|
19698
19924
|
}
|
|
19925
|
+
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
19699
19926
|
});
|
|
19700
19927
|
}
|
|
19701
19928
|
this.setDisplayedValue(enrichedValues);
|
|
@@ -19705,8 +19932,19 @@ const HierarchizedPickerComponent = class {
|
|
|
19705
19932
|
formatDefaultValue() {
|
|
19706
19933
|
let found = 0;
|
|
19707
19934
|
let that = this;
|
|
19935
|
+
let fieldsToCheck = [];
|
|
19936
|
+
function addToFieldsToCheck(item) {
|
|
19937
|
+
if (Array.isArray(item)) {
|
|
19938
|
+
item.forEach(el => addToFieldsToCheck(el));
|
|
19939
|
+
}
|
|
19940
|
+
else {
|
|
19941
|
+
const exists = fieldsToCheck.some(el => (el.nodeid || el.ID) == (item.nodeid || item.ID));
|
|
19942
|
+
if (!exists) {
|
|
19943
|
+
fieldsToCheck.push(item);
|
|
19944
|
+
}
|
|
19945
|
+
}
|
|
19946
|
+
}
|
|
19708
19947
|
let recursive = function (children) {
|
|
19709
|
-
//158424
|
|
19710
19948
|
children.forEach(element => {
|
|
19711
19949
|
that.theOptions.defaultValue.forEach(dfValue => {
|
|
19712
19950
|
if (typeof dfValue == 'string' && isNumeric(dfValue)) {
|
|
@@ -19716,7 +19954,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19716
19954
|
if ((typeof dfValue == 'string' && getPropertyFromNode(element, 'Properties').FullPath == dfValue) ||
|
|
19717
19955
|
(typeof dfValue == 'number' && getPropertyFromNode(element, 'ID') == dfValue)) {
|
|
19718
19956
|
element.nodeid = element.id;
|
|
19719
|
-
|
|
19957
|
+
addToFieldsToCheck([element]);
|
|
19720
19958
|
found++;
|
|
19721
19959
|
}
|
|
19722
19960
|
}
|
|
@@ -19726,7 +19964,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19726
19964
|
(typeof dfValue == 'string' && getPropertyFromNode(element, 'fullpathTranslated') == dfValue) ||
|
|
19727
19965
|
(typeof dfValue == 'number' && getPropertyFromNode(element, 'key') == dfValue)) {
|
|
19728
19966
|
element.nodeid = element.key;
|
|
19729
|
-
|
|
19967
|
+
addToFieldsToCheck([element]);
|
|
19730
19968
|
found++;
|
|
19731
19969
|
}
|
|
19732
19970
|
}
|
|
@@ -19738,6 +19976,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19738
19976
|
if (this.rawDataManager.getData()) {
|
|
19739
19977
|
recursive([this.rawDataManager.getData()]);
|
|
19740
19978
|
}
|
|
19979
|
+
that.checkFields(fieldsToCheck);
|
|
19741
19980
|
if (this.theOptions.defaultValue.length != found) {
|
|
19742
19981
|
if (found == 0) {
|
|
19743
19982
|
try {
|
|
@@ -19763,6 +20002,8 @@ const HierarchizedPickerComponent = class {
|
|
|
19763
20002
|
.join('; ');
|
|
19764
20003
|
}
|
|
19765
20004
|
shouldOpenModalAbove(inputElement, modaleHeight) {
|
|
20005
|
+
if (this.optionsManager.getOptions().mode != 'input')
|
|
20006
|
+
return false;
|
|
19766
20007
|
const inputRect = inputElement.getBoundingClientRect();
|
|
19767
20008
|
const spaceLeft = window.innerHeight - inputRect.y;
|
|
19768
20009
|
return spaceLeft < modaleHeight;
|
|
@@ -19786,7 +20027,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19786
20027
|
clickPickerModalArea(this);
|
|
19787
20028
|
} }, h("div", { class: "loader", ref: el => {
|
|
19788
20029
|
this.loader = el;
|
|
19789
|
-
} }, h("div", { class: "loader-inner" }, "Loading...")), h("div", { class: `hierarchized-picker-modal ${!this.ready ? 'hidden' : ''}
|
|
20030
|
+
} }, 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 => {
|
|
19790
20031
|
clickPickerModalArea(this);
|
|
19791
20032
|
} }, h("div", { class: "loader", ref: el => {
|
|
19792
20033
|
this.loader = el;
|
|
@@ -19844,9 +20085,7 @@ const SearchInput = class {
|
|
|
19844
20085
|
render() {
|
|
19845
20086
|
return (h("div", { id: "hierarchized-picker-input-search",
|
|
19846
20087
|
// TODO: need component ID ?
|
|
19847
|
-
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",
|
|
19848
|
-
//class="native-input search-input hierarchized-picker-search sc-ion-input-md-h sc-ion-input-md-s md"
|
|
19849
|
-
placeholder: this.placeholder, onFocus: () => this.handleFocus(), onBlur: (event) => this.handleBlur(event), onInput: (event) => this.handleInput(event) })));
|
|
20088
|
+
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) })));
|
|
19850
20089
|
}
|
|
19851
20090
|
};
|
|
19852
20091
|
SearchInput.style = searchInputCss;
|