reneco-hierarchized-picker 0.4.3-beta.9 → 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 -271
- 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 -57
- package/dist/collection/features/tree/tree-utils.js +12 -3
- package/dist/collection/utils/conf-helper.js +4 -0
- package/dist/collection/utils/constants.js +4 -3
- package/dist/collection/utils/theme-utils.js +1 -0
- package/dist/custom-elements/index.js +509 -271
- 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 -271
- 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-934e9cf8.entry.js +0 -1
- package/dist/reneco-hierarchized-picker/p-9ddab37d.system.entry.js +0 -3
|
@@ -13,6 +13,7 @@ function applyPickerTheme(theme, defaultTheme) {
|
|
|
13
13
|
docstyle.setProperty('--hpicker-theme-palette-background-default', (theme === null || theme === void 0 ? void 0 : theme.palette.background.default) || defaultTheme.palette.background.default);
|
|
14
14
|
docstyle.setProperty('--hpicker-theme-palette-background-light', (theme === null || theme === void 0 ? void 0 : theme.palette.background.light) || defaultTheme.palette.background.light);
|
|
15
15
|
docstyle.setProperty('--hpicker-theme-palette-background-dark', (theme === null || theme === void 0 ? void 0 : theme.palette.background.dark) || defaultTheme.palette.background.dark);
|
|
16
|
+
docstyle.setProperty('--hpicker-theme-palette-font-color', (theme === null || theme === void 0 ? void 0 : theme.palette.text.primary) || defaultTheme.palette.text.primary);
|
|
16
17
|
docstyle.setProperty('--hpicker-theme-palette-input-background-color', (theme === null || theme === void 0 ? void 0 : theme.palette.input.background) || defaultTheme.palette.input.background);
|
|
17
18
|
docstyle.setProperty('--hpicker-theme-palette-input-border-style', (theme === null || theme === void 0 ? void 0 : theme.palette.input.borderStyle) || defaultTheme.palette.input.borderStyle);
|
|
18
19
|
docstyle.setProperty('--hpicker-theme-typography-body-font-size', (theme === null || theme === void 0 ? void 0 : theme.typography.body.fontSize) || defaultTheme.typography.body.fontSize);
|
|
@@ -323,49 +324,6 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
323
324
|
else if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher')) {
|
|
324
325
|
this.onSwitcherClick(target);
|
|
325
326
|
}
|
|
326
|
-
const hasUndefinedchild = e.target.parentNode.querySelectorAll(".treejs-switcher").length > 0 && e.target.parentNode.querySelectorAll('ul').length == 0;
|
|
327
|
-
//CUSTOM
|
|
328
|
-
const childspans = Array.prototype.slice.call(e.target.parentNode.querySelectorAll('ul > li > span.treejs-label')).filter((ele) => {
|
|
329
|
-
return ele.parentNode.parentNode.parentNode === e.target.parentNode;
|
|
330
|
-
});
|
|
331
|
-
let undefinedChildren = [];
|
|
332
|
-
//This may be a problem the day a node value is "undefined"
|
|
333
|
-
undefinedChildren = childspans.filter(ele => {
|
|
334
|
-
return ele.textContent === 'undefined';
|
|
335
|
-
});
|
|
336
|
-
// If the user clicked on an unloaded node
|
|
337
|
-
if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher') && (undefinedChildren.length > 0 || hasUndefinedchild)) {
|
|
338
|
-
// Clear the subnode HTML
|
|
339
|
-
if (undefinedChildren.length > 0) {
|
|
340
|
-
e.target.parentNode.querySelector('ul').innerHTML = '';
|
|
341
|
-
}
|
|
342
|
-
// If source is webservice (it shouldn't be something else)
|
|
343
|
-
if (this.options.parentApi.theOptions.source == 'webservice') {
|
|
344
|
-
if (this.options.parentApi.theOptions.origin == 'classification') {
|
|
345
|
-
const contextualApiParams = this.options.parentApi.getContextualApiParams(Object.assign(Object.assign({}, this.options.parentApi.theOptions.options), { startNode: target.parentNode.nodeId }));
|
|
346
|
-
const contextualApiURL = this.options.parentApi.getContextualApiURL();
|
|
347
|
-
// WS Call
|
|
348
|
-
this.options.rawDataManager
|
|
349
|
-
.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
350
|
-
.then(data => {
|
|
351
|
-
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
else {
|
|
355
|
-
// WS Call
|
|
356
|
-
this.options.rawDataManager
|
|
357
|
-
.getFromSource(this.options.parentApi.theOptions.url, {
|
|
358
|
-
StartNodeID: target.parentNode.nodeId,
|
|
359
|
-
lng: this.options.parentApi.theOptions.options.lng,
|
|
360
|
-
IsDeprecated: this.options.parentApi.theOptions.options.IsDeprecated,
|
|
361
|
-
}, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
362
|
-
.then(data => {
|
|
363
|
-
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
this.onSwitcherClick(target);
|
|
368
|
-
}
|
|
369
327
|
}, false);
|
|
370
328
|
};
|
|
371
329
|
Tree.prototype.onItemClick = async function (id, rightclick = false) {
|
|
@@ -374,8 +332,6 @@ Tree.prototype.onItemClick = async function (id, rightclick = false) {
|
|
|
374
332
|
return;
|
|
375
333
|
const pickerValue = await this.options.parentApi.getValue();
|
|
376
334
|
if (!rightclick || !pickerValue || pickerValue.nodeid != id) {
|
|
377
|
-
if (!this.options.parentApi.theOptions.multiple)
|
|
378
|
-
this.emptyNodesCheckStatus();
|
|
379
335
|
this.options.parentApi.setNodeAsSelected(id, this, true);
|
|
380
336
|
}
|
|
381
337
|
};
|
|
@@ -502,6 +458,48 @@ Tree.prototype.markWillUpdateNode = function (node) {
|
|
|
502
458
|
this.willUpdateNodesById[node.id] = node;
|
|
503
459
|
};
|
|
504
460
|
Tree.prototype.onSwitcherClick = function (target) {
|
|
461
|
+
const hasUndefinedchild = target.parentNode.querySelectorAll(".treejs-switcher").length > 0 && target.parentNode.querySelectorAll('ul').length == 0;
|
|
462
|
+
//CUSTOM
|
|
463
|
+
const childspans = Array.prototype.slice.call(target.parentNode.querySelectorAll('ul > li > span.treejs-label')).filter((ele) => {
|
|
464
|
+
return ele.parentNode.parentNode.parentNode === target.parentNode;
|
|
465
|
+
});
|
|
466
|
+
let undefinedChildren = [];
|
|
467
|
+
//This may be a problem the day a node value is "undefined"
|
|
468
|
+
undefinedChildren = childspans.filter(ele => {
|
|
469
|
+
return ele.textContent === 'undefined';
|
|
470
|
+
});
|
|
471
|
+
// If the user clicked on an unloaded node
|
|
472
|
+
if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher') && (undefinedChildren.length > 0 || hasUndefinedchild)) {
|
|
473
|
+
// Clear the subnode HTML
|
|
474
|
+
if (undefinedChildren.length > 0) {
|
|
475
|
+
target.parentNode.querySelector('ul').innerHTML = '';
|
|
476
|
+
}
|
|
477
|
+
// If source is webservice (it shouldn't be something else)
|
|
478
|
+
if (this.options.parentApi.theOptions.source == 'webservice') {
|
|
479
|
+
if (this.options.parentApi.theOptions.origin == 'classification') {
|
|
480
|
+
const contextualApiParams = this.options.parentApi.getContextualApiParams(Object.assign(Object.assign({}, this.options.parentApi.theOptions.options), { startNode: target.parentNode.nodeId }));
|
|
481
|
+
const contextualApiURL = this.options.parentApi.getContextualApiURL();
|
|
482
|
+
// WS Call
|
|
483
|
+
this.options.rawDataManager
|
|
484
|
+
.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
485
|
+
.then(data => {
|
|
486
|
+
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
// WS Call
|
|
491
|
+
this.options.rawDataManager
|
|
492
|
+
.getFromSource(this.options.parentApi.theOptions.url, {
|
|
493
|
+
StartNodeID: target.parentNode.nodeId,
|
|
494
|
+
lng: this.options.parentApi.theOptions.options.lng,
|
|
495
|
+
IsDeprecated: this.options.parentApi.theOptions.options.IsDeprecated,
|
|
496
|
+
}, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
497
|
+
.then(data => {
|
|
498
|
+
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
505
503
|
const liEle = target.parentNode;
|
|
506
504
|
const ele = liEle.lastChild;
|
|
507
505
|
const height = ele.scrollHeight;
|
|
@@ -539,6 +537,9 @@ Tree.prototype.onSwitcherClick = function (target) {
|
|
|
539
537
|
},
|
|
540
538
|
});
|
|
541
539
|
}
|
|
540
|
+
return new Promise((resolve) => {
|
|
541
|
+
resolve(this);
|
|
542
|
+
});
|
|
542
543
|
};
|
|
543
544
|
Tree.prototype.walkUp = function (node, changeState) {
|
|
544
545
|
const { parent } = node;
|
|
@@ -670,11 +671,10 @@ Tree.prototype.createLiEle = function (node, closed) {
|
|
|
670
671
|
else {
|
|
671
672
|
li.classList.add('treejs-placeholder');
|
|
672
673
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
}
|
|
674
|
+
const checkbox = document.createElement('span');
|
|
675
|
+
checkbox.classList.add('treejs-checkbox');
|
|
676
|
+
checkbox.style.display = ((!this.options.parentApi || (this.options.parentApi && this.options.parentApi.theOptions.multiple)) ? "inline-block" : "none");
|
|
677
|
+
li.appendChild(checkbox);
|
|
678
678
|
const label = document.createElement('span');
|
|
679
679
|
label.classList.add('treejs-label');
|
|
680
680
|
const text = document.createTextNode(node.text);
|
|
@@ -17995,6 +17995,10 @@ function isInstanceOfIConf(object) {
|
|
|
17995
17995
|
toret = false;
|
|
17996
17996
|
errorToLog = "options.displayRootNode value '" + object.displayRootNode + "' doesn't meet interface IConf requirements";
|
|
17997
17997
|
}
|
|
17998
|
+
if (!((!object.keyboardNavigation && typeof object.keyboardNavigation != 'boolean') || typeof object.keyboardNavigation == 'boolean')) {
|
|
17999
|
+
toret = false;
|
|
18000
|
+
errorToLog = "options.keyboardNavigation value '" + object.keyboardNavigation + "' doesn't meet interface IConf requirements";
|
|
18001
|
+
}
|
|
17998
18002
|
if (!((!object.dragAndDropEnabled && typeof object.dragAndDropEnabled != 'boolean') || typeof object.dragAndDropEnabled == 'boolean')) {
|
|
17999
18003
|
toret = false;
|
|
18000
18004
|
errorToLog = "options.dragAndDropEnabled value '" + object.dragAndDropEnabled + "' doesn't meet interface IConf requirements";
|
|
@@ -18091,17 +18095,18 @@ const defaultPickerTheme = {
|
|
|
18091
18095
|
primary: {
|
|
18092
18096
|
main: '#888',
|
|
18093
18097
|
light: '#888',
|
|
18094
|
-
contrastText: '#000',
|
|
18098
|
+
contrastText: '#000', // Text color of the selected node
|
|
18095
18099
|
},
|
|
18096
18100
|
background: {
|
|
18097
18101
|
default: '#ccc',
|
|
18098
18102
|
light: '#eee',
|
|
18099
18103
|
main: '#000',
|
|
18100
|
-
dark: '#fff',
|
|
18104
|
+
dark: '#fff', // Background of the whole tree
|
|
18101
18105
|
},
|
|
18102
18106
|
text: {
|
|
18103
|
-
primary: '#000',
|
|
18107
|
+
primary: '#000', // Text color
|
|
18104
18108
|
},
|
|
18109
|
+
// For all inputs in the component, includes in modale mode the display input and the search input
|
|
18105
18110
|
input: {
|
|
18106
18111
|
background: '#fff',
|
|
18107
18112
|
borderStyle: 'none'
|
|
@@ -18362,10 +18367,12 @@ class OptionsManager {
|
|
|
18362
18367
|
showAutocomplete: false,
|
|
18363
18368
|
openTreeWhenLoaded: false,
|
|
18364
18369
|
displayRootNode: false,
|
|
18370
|
+
keyboardNavigation: false,
|
|
18365
18371
|
dragAndDropEnabled: false,
|
|
18366
18372
|
errorsInInput: true,
|
|
18367
18373
|
isFullpath: true,
|
|
18368
18374
|
defaultValue: [],
|
|
18375
|
+
defaultValueIsFullpath: false,
|
|
18369
18376
|
};
|
|
18370
18377
|
const validatedOptions = Object.assign(Object.assign({}, defaults), options);
|
|
18371
18378
|
// Validate specific fields
|
|
@@ -18452,7 +18459,7 @@ function findNodeById(tree, nodeId) {
|
|
|
18452
18459
|
/**
|
|
18453
18460
|
* Fills the tree with nodes based on the provided object.
|
|
18454
18461
|
*/
|
|
18455
|
-
function fillTreeWithObject(tree, myObject, searched, options
|
|
18462
|
+
function fillTreeWithObject(tree, myObject, searched, options) {
|
|
18456
18463
|
const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
|
|
18457
18464
|
if (myObject && myObject.length) {
|
|
18458
18465
|
myObject.forEach(value => {
|
|
@@ -18484,7 +18491,6 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
|
|
|
18484
18491
|
const objToPush = {
|
|
18485
18492
|
id: keyPropFromNode,
|
|
18486
18493
|
nodeId: keyPropFromNode,
|
|
18487
|
-
depth,
|
|
18488
18494
|
text: valueTranslatedPropFromNode,
|
|
18489
18495
|
fullpath: fullpathPropFromNode,
|
|
18490
18496
|
fullpathTranslated: fullpathTranslatedPropFromNode,
|
|
@@ -18493,7 +18499,7 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
|
|
|
18493
18499
|
isDesaturated: false,
|
|
18494
18500
|
searchMatch: false,
|
|
18495
18501
|
};
|
|
18496
|
-
const childTree = fillTreeWithObject(objToPush.children, childrenPropFromNode, searched, options
|
|
18502
|
+
const childTree = fillTreeWithObject(objToPush.children, childrenPropFromNode, searched, options);
|
|
18497
18503
|
let pushMe = false;
|
|
18498
18504
|
if (searched) {
|
|
18499
18505
|
const matched = searchValue(objToPush, false, searched);
|
|
@@ -18519,6 +18525,11 @@ function completeCurrentTreeWithTree(treeJsInstance, newTree, options) {
|
|
|
18519
18525
|
var _a;
|
|
18520
18526
|
const ElmID = newTree.key || newTree.id || newTree.ID;
|
|
18521
18527
|
const targetNode = findNodeById(treeJsInstance, ElmID);
|
|
18528
|
+
if (ElmID == 0 && newTree.children && newTree.children.length > 0) {
|
|
18529
|
+
newTree.children.forEach(child => {
|
|
18530
|
+
completeCurrentTreeWithTree(treeJsInstance, child, options);
|
|
18531
|
+
});
|
|
18532
|
+
}
|
|
18522
18533
|
if (targetNode) {
|
|
18523
18534
|
targetNode.children = [];
|
|
18524
18535
|
let ulElem = (_a = treeJsInstance.liElementsById[ElmID]) === null || _a === void 0 ? void 0 : _a.querySelector('ul');
|
|
@@ -18534,6 +18545,11 @@ function completeCurrentTreeWithTree(treeJsInstance, newTree, options) {
|
|
|
18534
18545
|
targetNode.children.push(item);
|
|
18535
18546
|
treeJsInstance.nodesById[item.id] = item;
|
|
18536
18547
|
treeJsInstance.liElementsById[item.id] = liElm;
|
|
18548
|
+
if (item.children && item.children.some(child => Object.keys(child).length > 0)) {
|
|
18549
|
+
newTree.children.forEach(child => {
|
|
18550
|
+
completeCurrentTreeWithTree(treeJsInstance, child, options);
|
|
18551
|
+
});
|
|
18552
|
+
}
|
|
18537
18553
|
});
|
|
18538
18554
|
}
|
|
18539
18555
|
}
|
|
@@ -18576,10 +18592,100 @@ function clearAutocomplete(eraseResults = false) {
|
|
|
18576
18592
|
}
|
|
18577
18593
|
}
|
|
18578
18594
|
|
|
18579
|
-
|
|
18580
|
-
function
|
|
18581
|
-
|
|
18582
|
-
|
|
18595
|
+
let focusedNodeIndex = 0;
|
|
18596
|
+
function setupKeyboardNavigation(component, optionsManager, navigateInTree) {
|
|
18597
|
+
if (!optionsManager.getOptions().keyboardNavigation)
|
|
18598
|
+
return;
|
|
18599
|
+
const treeArea = component.el.querySelector('.hierarchized-picker-tree-area') || component.el.querySelector('.hierarchized-picker-raw-tree-area');
|
|
18600
|
+
if (!treeArea)
|
|
18601
|
+
return;
|
|
18602
|
+
function focusNode(allLiElements, liElementToFocus) {
|
|
18603
|
+
Object.values(allLiElements).forEach((liNode) => {
|
|
18604
|
+
liNode.classList.remove('treejs-node__focused');
|
|
18605
|
+
});
|
|
18606
|
+
liElementToFocus.classList.add('treejs-node__focused');
|
|
18607
|
+
}
|
|
18608
|
+
function findAllTreeNodes(treeNodes, liElementsById) {
|
|
18609
|
+
let allNodes = [];
|
|
18610
|
+
const traverse = (nodes) => {
|
|
18611
|
+
nodes.forEach(node => {
|
|
18612
|
+
allNodes.push(node);
|
|
18613
|
+
if (node.children && node.children.length > 0 && !liElementsById[node.id].classList.contains("treejs-node__close")) {
|
|
18614
|
+
traverse(node.children);
|
|
18615
|
+
}
|
|
18616
|
+
});
|
|
18617
|
+
};
|
|
18618
|
+
traverse(treeNodes);
|
|
18619
|
+
return allNodes;
|
|
18620
|
+
}
|
|
18621
|
+
focusedNodeIndex = 0;
|
|
18622
|
+
if (component && component.loadedTreeJs && component.loadedTreeJs.liElementsById && component.loadedTreeJs.treeNodes) {
|
|
18623
|
+
focusNode(component.loadedTreeJs.liElementsById, component.loadedTreeJs.liElementsById[component.loadedTreeJs.treeNodes[focusedNodeIndex].id]);
|
|
18624
|
+
}
|
|
18625
|
+
if (!component._keydownListenerAdded) {
|
|
18626
|
+
component._keydownListenerAdded = true;
|
|
18627
|
+
component.el.addEventListener('keydown', (event) => {
|
|
18628
|
+
var _a, _b;
|
|
18629
|
+
event.stopPropagation();
|
|
18630
|
+
const tree = component.loadedTreeJs;
|
|
18631
|
+
let treeNodesFromTree = findAllTreeNodes(tree.treeNodes, tree.liElementsById);
|
|
18632
|
+
if (!tree || !treeNodesFromTree.length)
|
|
18633
|
+
return;
|
|
18634
|
+
let spaceNode = treeNodesFromTree[focusedNodeIndex];
|
|
18635
|
+
let activeNode = treeNodesFromTree[focusedNodeIndex];
|
|
18636
|
+
let liElement = tree.liElementsById[activeNode.id];
|
|
18637
|
+
const handledEvents = ['tab', '0', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright'];
|
|
18638
|
+
switch (event.key.toLowerCase()) {
|
|
18639
|
+
case 'tab':
|
|
18640
|
+
case '0':
|
|
18641
|
+
event.preventDefault();
|
|
18642
|
+
{ //(spaceNode?.nodeId) {
|
|
18643
|
+
component.setNodeAsSelected(spaceNode.nodeId, component.loadedTreeJs, true);
|
|
18644
|
+
if (optionsManager.getOptions().mode != "tree" && !optionsManager.getOptions().multiple) {
|
|
18645
|
+
setTimeout(() => {
|
|
18646
|
+
component.showTree('hide');
|
|
18647
|
+
// TODO put back? >> focusMainInput(component);
|
|
18648
|
+
}, 100);
|
|
18649
|
+
}
|
|
18650
|
+
}
|
|
18651
|
+
break;
|
|
18652
|
+
case 'arrowup':
|
|
18653
|
+
event.preventDefault();
|
|
18654
|
+
focusedNodeIndex = Math.max(focusedNodeIndex - 1, 0);
|
|
18655
|
+
const newActiveNodeUp = treeNodesFromTree[focusedNodeIndex];
|
|
18656
|
+
const newLiElementUp = tree.liElementsById[newActiveNodeUp.id];
|
|
18657
|
+
newLiElementUp.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
18658
|
+
focusNode(tree.liElementsById, newLiElementUp);
|
|
18659
|
+
break;
|
|
18660
|
+
case 'arrowdown':
|
|
18661
|
+
event.preventDefault();
|
|
18662
|
+
focusedNodeIndex = Math.min(focusedNodeIndex + 1, treeNodesFromTree.length - 1);
|
|
18663
|
+
const newActiveNodeDown = treeNodesFromTree[focusedNodeIndex];
|
|
18664
|
+
const newLiElementDown = tree.liElementsById[newActiveNodeDown.id];
|
|
18665
|
+
focusNode(tree.liElementsById, newLiElementDown);
|
|
18666
|
+
newLiElementDown.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
18667
|
+
break;
|
|
18668
|
+
case 'arrowleft':
|
|
18669
|
+
event.preventDefault();
|
|
18670
|
+
const leftSwitcher = liElement.querySelector('.treejs-switcher');
|
|
18671
|
+
if (leftSwitcher) {
|
|
18672
|
+
(_a = component.loadedTreeJs) === null || _a === void 0 ? void 0 : _a.onSwitcherClick(leftSwitcher);
|
|
18673
|
+
}
|
|
18674
|
+
break;
|
|
18675
|
+
case 'arrowright':
|
|
18676
|
+
event.preventDefault();
|
|
18677
|
+
const rightSwitcher = liElement.querySelector('.treejs-switcher');
|
|
18678
|
+
if (rightSwitcher) {
|
|
18679
|
+
(_b = component.loadedTreeJs) === null || _b === void 0 ? void 0 : _b.onSwitcherClick(rightSwitcher);
|
|
18680
|
+
}
|
|
18681
|
+
break;
|
|
18682
|
+
}
|
|
18683
|
+
if (handledEvents.includes(event.key.toLowerCase()))
|
|
18684
|
+
navigateInTree.emit(event);
|
|
18685
|
+
});
|
|
18686
|
+
}
|
|
18687
|
+
}
|
|
18688
|
+
|
|
18583
18689
|
// Focus management
|
|
18584
18690
|
async function focusSearchInput(component) {
|
|
18585
18691
|
const searchInput = component.el.querySelector('search-input input');
|
|
@@ -18610,19 +18716,6 @@ function handleFocusEvent(component, type) {
|
|
|
18610
18716
|
component.showTree('hide');
|
|
18611
18717
|
}
|
|
18612
18718
|
}
|
|
18613
|
-
function manageFocusOut(component, event) {
|
|
18614
|
-
const relatedTarget = event.relatedTarget;
|
|
18615
|
-
if (!isInsidePicker(component, relatedTarget)) {
|
|
18616
|
-
setTimeout(() => {
|
|
18617
|
-
if (!isInsidePicker(component, document.activeElement)) {
|
|
18618
|
-
handleFocusEvent(component, 'hide');
|
|
18619
|
-
}
|
|
18620
|
-
}, 100);
|
|
18621
|
-
}
|
|
18622
|
-
else {
|
|
18623
|
-
handleFocusEvent(component, 'search');
|
|
18624
|
-
}
|
|
18625
|
-
}
|
|
18626
18719
|
function clickPickerModalArea(component, _event) {
|
|
18627
18720
|
if (component.pickerClass === 'fieldError') {
|
|
18628
18721
|
component.showTree('hide');
|
|
@@ -18633,83 +18726,18 @@ function clickPickerModalArea(component, _event) {
|
|
|
18633
18726
|
else {
|
|
18634
18727
|
component.mylog('Ignored modal click');
|
|
18635
18728
|
}
|
|
18729
|
+
if (component.theOptions.mode == 'tree') {
|
|
18730
|
+
setupKeyboardNavigation(component, component.optionsManager, component.navigateInTree);
|
|
18731
|
+
}
|
|
18636
18732
|
}
|
|
18637
18733
|
// Exposed event handlers
|
|
18638
18734
|
function focusInSearchEvent(component) {
|
|
18639
18735
|
handleFocusEvent(component, 'search');
|
|
18640
18736
|
}
|
|
18641
18737
|
function focusOutSearchEvent(component, event) {
|
|
18642
|
-
manageFocusOut(component, event);
|
|
18643
|
-
}
|
|
18644
|
-
|
|
18645
|
-
function setupKeyboardNavigation(component, navigateInTree) {
|
|
18646
|
-
const treeArea = component.el.querySelector('.hierarchized-picker-tree-area');
|
|
18647
|
-
if (!treeArea)
|
|
18648
|
-
return;
|
|
18649
|
-
let focusedNodeIndex = 0;
|
|
18650
|
-
function focusNode(allLiElements, liElementToFocus) {
|
|
18651
|
-
Object.values(allLiElements).forEach((liNode) => {
|
|
18652
|
-
liNode.classList.remove('treejs-node__focused');
|
|
18653
|
-
});
|
|
18654
|
-
liElementToFocus.classList.add('treejs-node__focused');
|
|
18655
|
-
}
|
|
18656
|
-
component.el.addEventListener('keydown', (event) => {
|
|
18657
|
-
var _a, _b;
|
|
18658
|
-
event.stopPropagation();
|
|
18659
|
-
const tree = component.loadedTreeJs;
|
|
18660
|
-
const treeNodesFromTree = tree.treeNodes;
|
|
18661
|
-
if (!tree || !treeNodesFromTree.length)
|
|
18662
|
-
return;
|
|
18663
|
-
const spaceNode = treeNodesFromTree[focusedNodeIndex];
|
|
18664
|
-
const activeNode = treeNodesFromTree[focusedNodeIndex];
|
|
18665
|
-
const liElement = tree.liElementsById[activeNode.id];
|
|
18666
|
-
switch (event.key) {
|
|
18667
|
-
case 'Tab':
|
|
18668
|
-
case '0':
|
|
18669
|
-
event.preventDefault();
|
|
18670
|
-
{ //(spaceNode?.nodeId) {
|
|
18671
|
-
component.setNodeAsSelected(spaceNode.nodeId, component.loadedTreeJs, true);
|
|
18672
|
-
component.showTree('hide');
|
|
18673
|
-
setTimeout(() => focusMainInput(), 100);
|
|
18674
|
-
}
|
|
18675
|
-
break;
|
|
18676
|
-
case 'ArrowUp':
|
|
18677
|
-
event.preventDefault();
|
|
18678
|
-
focusedNodeIndex = Math.max(focusedNodeIndex - 1, 0);
|
|
18679
|
-
const newActiveNodeUp = treeNodesFromTree[focusedNodeIndex];
|
|
18680
|
-
const newLiElementUp = tree.liElementsById[newActiveNodeUp.id];
|
|
18681
|
-
focusNode(tree.liElementsById, newLiElementUp);
|
|
18682
|
-
break;
|
|
18683
|
-
case 'ArrowDown':
|
|
18684
|
-
event.preventDefault();
|
|
18685
|
-
focusedNodeIndex = Math.min(focusedNodeIndex + 1, treeNodesFromTree.length - 1);
|
|
18686
|
-
const newActiveNodeDown = treeNodesFromTree[focusedNodeIndex];
|
|
18687
|
-
const newLiElementDown = tree.liElementsById[newActiveNodeDown.id];
|
|
18688
|
-
focusNode(tree.liElementsById, newLiElementDown);
|
|
18689
|
-
break;
|
|
18690
|
-
case 'ArrowLeft':
|
|
18691
|
-
event.preventDefault();
|
|
18692
|
-
const leftSwitcher = liElement.querySelector('.treejs-switcher');
|
|
18693
|
-
if (leftSwitcher) {
|
|
18694
|
-
(_a = component.loadedTreeJs) === null || _a === void 0 ? void 0 : _a.onSwitcherClick(leftSwitcher);
|
|
18695
|
-
component.showTree('hide');
|
|
18696
|
-
}
|
|
18697
|
-
break;
|
|
18698
|
-
case 'ArrowRight':
|
|
18699
|
-
event.preventDefault();
|
|
18700
|
-
const rightSwitcher = liElement.querySelector('.treejs-switcher');
|
|
18701
|
-
if (rightSwitcher) {
|
|
18702
|
-
(_b = component.loadedTreeJs) === null || _b === void 0 ? void 0 : _b.onSwitcherClick(rightSwitcher);
|
|
18703
|
-
}
|
|
18704
|
-
break;
|
|
18705
|
-
}
|
|
18706
|
-
navigateInTree.emit(event.key);
|
|
18707
|
-
});
|
|
18708
|
-
if (component && component.loadedTreeJs && component.loadedTreeJs.liElementsById && component.loadedTreeJs.treeNodes)
|
|
18709
|
-
setTimeout(() => focusNode(component.loadedTreeJs.liElementsById, component.loadedTreeJs.liElementsById[component.loadedTreeJs.treeNodes[focusedNodeIndex].id]), 100);
|
|
18710
18738
|
}
|
|
18711
18739
|
|
|
18712
|
-
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}";
|
|
18740
|
+
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}";
|
|
18713
18741
|
|
|
18714
18742
|
const HierarchizedPickerComponent = class {
|
|
18715
18743
|
/**
|
|
@@ -18778,14 +18806,66 @@ const HierarchizedPickerComponent = class {
|
|
|
18778
18806
|
logError(messageToLog) {
|
|
18779
18807
|
try {
|
|
18780
18808
|
console.error('--- Hierarchized picker ' + this.componentID + ' ERROR ---', messageToLog);
|
|
18809
|
+
this.lastErrorMessage = messageToLog;
|
|
18781
18810
|
}
|
|
18782
18811
|
catch (_a) {
|
|
18783
|
-
|
|
18812
|
+
const genericErrorMessage = '--- Hierarchized picker generic ERROR ---';
|
|
18813
|
+
this.lastErrorMessage = genericErrorMessage;
|
|
18814
|
+
console.error(genericErrorMessage);
|
|
18784
18815
|
}
|
|
18816
|
+
this.errorRaised.emit(this.lastErrorMessage);
|
|
18785
18817
|
}
|
|
18786
18818
|
get theOptions() {
|
|
18787
18819
|
return this.optionsManager.getOptions();
|
|
18788
18820
|
}
|
|
18821
|
+
diffKeys(obj1, obj2, prefix = '') {
|
|
18822
|
+
const diffs = [];
|
|
18823
|
+
const commonKeys = Object.keys(obj1 || {}).filter(key => obj2 && Object.prototype.hasOwnProperty.call(obj2, key));
|
|
18824
|
+
for (const key of commonKeys) {
|
|
18825
|
+
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
18826
|
+
const val1 = obj1[key];
|
|
18827
|
+
const val2 = obj2[key];
|
|
18828
|
+
if (Array.isArray(val1) && Array.isArray(val2)) {
|
|
18829
|
+
// Compare array length
|
|
18830
|
+
if (val1.length !== val2.length) {
|
|
18831
|
+
diffs.push(fullKey);
|
|
18832
|
+
continue;
|
|
18833
|
+
}
|
|
18834
|
+
// Compare each element deeply
|
|
18835
|
+
for (let i = 0; i < val1.length; i++) {
|
|
18836
|
+
const v1 = val1[i];
|
|
18837
|
+
const v2 = val2[i];
|
|
18838
|
+
if (typeof v1 === 'object' &&
|
|
18839
|
+
v1 !== null &&
|
|
18840
|
+
typeof v2 === 'object' &&
|
|
18841
|
+
v2 !== null) {
|
|
18842
|
+
const subDiffs = this.diffKeys(v1, v2, `${fullKey}[${i}]`);
|
|
18843
|
+
if (subDiffs.length > 0) {
|
|
18844
|
+
diffs.push(fullKey);
|
|
18845
|
+
break; // stop at first mismatch in array
|
|
18846
|
+
}
|
|
18847
|
+
}
|
|
18848
|
+
else if (v1 !== v2) {
|
|
18849
|
+
diffs.push(fullKey);
|
|
18850
|
+
break;
|
|
18851
|
+
}
|
|
18852
|
+
}
|
|
18853
|
+
}
|
|
18854
|
+
else if (val1 &&
|
|
18855
|
+
val2 &&
|
|
18856
|
+
typeof val1 === 'object' &&
|
|
18857
|
+
typeof val2 === 'object') {
|
|
18858
|
+
// Recursive deep object comparison
|
|
18859
|
+
const subDiffs = this.diffKeys(val1, val2, fullKey);
|
|
18860
|
+
if (subDiffs.length > 0)
|
|
18861
|
+
diffs.push(...subDiffs);
|
|
18862
|
+
}
|
|
18863
|
+
else if (val1 !== val2) {
|
|
18864
|
+
diffs.push(fullKey);
|
|
18865
|
+
}
|
|
18866
|
+
}
|
|
18867
|
+
return diffs;
|
|
18868
|
+
}
|
|
18789
18869
|
async setNewOption(newValue, oldValue = null) {
|
|
18790
18870
|
this.ready = false;
|
|
18791
18871
|
// --------------------------------------- DEPRECATED ?
|
|
@@ -18804,6 +18884,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18804
18884
|
// });
|
|
18805
18885
|
// ---------------------------------------
|
|
18806
18886
|
// this.theOptions = newValue;
|
|
18887
|
+
const savedOldValue = Object.assign({}, this.theOptions);
|
|
18807
18888
|
if (oldValue && JSON.stringify(newValue.options) == JSON.stringify(oldValue.options)) {
|
|
18808
18889
|
this.ready = true;
|
|
18809
18890
|
return;
|
|
@@ -18812,6 +18893,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18812
18893
|
newValue = JSON.parse(newValue);
|
|
18813
18894
|
if (typeof oldValue == 'string')
|
|
18814
18895
|
oldValue = JSON.parse(oldValue);
|
|
18896
|
+
this.value = [];
|
|
18815
18897
|
this.optionsManager.updateOptions(newValue);
|
|
18816
18898
|
this.setDisplayedValue(this.value);
|
|
18817
18899
|
const originOrNodeIdAreDifferent = !oldValue || (newValue.origin != oldValue.origin || newValue.options.StartNodeID != oldValue.options.StartNodeID);
|
|
@@ -18829,11 +18911,28 @@ const HierarchizedPickerComponent = class {
|
|
|
18829
18911
|
if (oldValue && JSON.stringify(newValue.options) != JSON.stringify(oldValue.options)) {
|
|
18830
18912
|
this.value = [];
|
|
18831
18913
|
}
|
|
18832
|
-
if ((newValue === null || newValue === void 0 ? void 0 : newValue.loading) == 'display') {
|
|
18914
|
+
if ((newValue === null || newValue === void 0 ? void 0 : newValue.loading) == 'display' || (newValue && !newValue.loading)) {
|
|
18833
18915
|
if ((oldValue && this.isChangeInOptions(newValue, oldValue)) || !oldValue) {
|
|
18834
|
-
|
|
18835
|
-
|
|
18836
|
-
|
|
18916
|
+
if (!oldValue) {
|
|
18917
|
+
oldValue = savedOldValue;
|
|
18918
|
+
}
|
|
18919
|
+
const propDiffs = this.diffKeys(oldValue, this.optionsManager.initializeOptions(newValue));
|
|
18920
|
+
const noReloadProps = ["multiple"];
|
|
18921
|
+
const ignoredProps = ["token"];
|
|
18922
|
+
const filteredDiffs = propDiffs.filter(prop => !ignoredProps.includes(prop));
|
|
18923
|
+
if (filteredDiffs.length == 1 && filteredDiffs.some(item => noReloadProps.includes(item))) {
|
|
18924
|
+
const propChanged = filteredDiffs[0];
|
|
18925
|
+
switch (propChanged) {
|
|
18926
|
+
case "multiple":
|
|
18927
|
+
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = (this.theOptions.multiple ? 'inline-block' : 'none')));
|
|
18928
|
+
break;
|
|
18929
|
+
}
|
|
18930
|
+
}
|
|
18931
|
+
else {
|
|
18932
|
+
this.rawDataManager = new RawDataManager(this.getOptionsAsIConf(this.optionsManager.getOptions()).token, this.optionsManager);
|
|
18933
|
+
await this.loadHierarchizedPicker(true);
|
|
18934
|
+
this.displayWhenLoaded();
|
|
18935
|
+
}
|
|
18837
18936
|
}
|
|
18838
18937
|
else {
|
|
18839
18938
|
this.ready = true;
|
|
@@ -18887,6 +18986,9 @@ const HierarchizedPickerComponent = class {
|
|
|
18887
18986
|
async filterTree(searchedValue) {
|
|
18888
18987
|
this.search(searchedValue);
|
|
18889
18988
|
}
|
|
18989
|
+
async getError() {
|
|
18990
|
+
return Promise.resolve(this.lastErrorMessage);
|
|
18991
|
+
}
|
|
18890
18992
|
constructor(hostRef) {
|
|
18891
18993
|
index.registerInstance(this, hostRef);
|
|
18892
18994
|
this.valueChange = index.createEvent(this, "valueChange", 7);
|
|
@@ -18894,6 +18996,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18894
18996
|
this.itemContextMenuItemClick = index.createEvent(this, "itemContextMenuItemClick", 7);
|
|
18895
18997
|
this.searchResult = index.createEvent(this, "searchResult", 7);
|
|
18896
18998
|
this.navigateInTree = index.createEvent(this, "navigateInTree", 7);
|
|
18999
|
+
this.errorRaised = index.createEvent(this, "errorRaised", 7);
|
|
18897
19000
|
this.modaleHeight = 200;
|
|
18898
19001
|
this.modalePosition = 'bottom';
|
|
18899
19002
|
this.canload = true; // Determines wether the component may be loaded
|
|
@@ -18903,30 +19006,101 @@ const HierarchizedPickerComponent = class {
|
|
|
18903
19006
|
this.lastSearchMatchCounter = 0; // Counter of number of matches for last search
|
|
18904
19007
|
this.setValueOnClick = true; // Tells wether we edit the picker value on click in the tree
|
|
18905
19008
|
this.mylog = console.log; // Custom log function for debug purposes
|
|
19009
|
+
this.lastErrorMessage = '';
|
|
19010
|
+
this.scrollToNode = (targetNodeId = null, displayChildren = false) => {
|
|
19011
|
+
var _a;
|
|
19012
|
+
let scrollToValue = 0;
|
|
19013
|
+
let removeClosedAndLookUp = (element, editScroll = false) => {
|
|
19014
|
+
var _a, _b, _c, _d;
|
|
19015
|
+
const nodeId = element === null || element === void 0 ? void 0 : element.nodeId;
|
|
19016
|
+
if (!element || !nodeId) {
|
|
19017
|
+
return;
|
|
19018
|
+
}
|
|
19019
|
+
const node = this.loadedTreeJs.nodesById[nodeId];
|
|
19020
|
+
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) {
|
|
19021
|
+
(_c = element.classList) === null || _c === void 0 ? void 0 : _c.remove('treejs-node__close');
|
|
19022
|
+
}
|
|
19023
|
+
if (editScroll) {
|
|
19024
|
+
scrollToValue += element.offsetTop;
|
|
19025
|
+
}
|
|
19026
|
+
const parent = (_d = element.parentNode) === null || _d === void 0 ? void 0 : _d.closest('.treejs-node');
|
|
19027
|
+
if (parent) {
|
|
19028
|
+
removeClosedAndLookUp(parent, editScroll);
|
|
19029
|
+
}
|
|
19030
|
+
};
|
|
19031
|
+
try {
|
|
19032
|
+
if (targetNodeId) {
|
|
19033
|
+
const targetNode = this.loadedTreeJs.liElementsById[targetNodeId];
|
|
19034
|
+
if (targetNode) {
|
|
19035
|
+
removeClosedAndLookUp(targetNode, true);
|
|
19036
|
+
if (displayChildren && targetNode.classList.contains('treejs-node__close')) {
|
|
19037
|
+
const leftSwitcher = targetNode.querySelector('.treejs-switcher');
|
|
19038
|
+
if (leftSwitcher) {
|
|
19039
|
+
(_a = this.loadedTreeJs) === null || _a === void 0 ? void 0 : _a.onSwitcherClick(leftSwitcher);
|
|
19040
|
+
}
|
|
19041
|
+
}
|
|
19042
|
+
}
|
|
19043
|
+
}
|
|
19044
|
+
else {
|
|
19045
|
+
const checkeds = document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node__checked');
|
|
19046
|
+
checkeds.forEach((item) => removeClosedAndLookUp(item, scrollToValue == 0));
|
|
19047
|
+
}
|
|
19048
|
+
}
|
|
19049
|
+
catch (err) {
|
|
19050
|
+
this.errorToLog = "Error in showSelectedNodes";
|
|
19051
|
+
}
|
|
19052
|
+
if (scrollToValue && this.scrollable) {
|
|
19053
|
+
this.scrollable.scrollTop = scrollToValue;
|
|
19054
|
+
}
|
|
19055
|
+
};
|
|
18906
19056
|
this.getShortenedFullpath = (realFullpath) => {
|
|
18907
19057
|
var _a, _b, _c, _d;
|
|
19058
|
+
if (!realFullpath)
|
|
19059
|
+
return realFullpath;
|
|
19060
|
+
//TODO if one day we want shortenedfulpaths from data loading :
|
|
19061
|
+
// const rdmdata = (this.optionsManager.getOptions().source == "webservice" ? this.rawDataManager.getData() : this.rawDataManager.getData().data ?? null);
|
|
19062
|
+
//TODO but for now we're doing :
|
|
19063
|
+
if (this.optionsManager.getOptions().source !== "webservice")
|
|
19064
|
+
return realFullpath;
|
|
18908
19065
|
let toret = realFullpath;
|
|
18909
|
-
|
|
18910
|
-
|
|
18911
|
-
|
|
18912
|
-
|
|
18913
|
-
|
|
18914
|
-
|
|
18915
|
-
|
|
18916
|
-
|
|
18917
|
-
|
|
18918
|
-
|
|
19066
|
+
const rdmdata = this.rawDataManager.getData();
|
|
19067
|
+
if (rdmdata) {
|
|
19068
|
+
try {
|
|
19069
|
+
const propertyName_nodeid = (this.optionsManager.getOptions().origin == 'classification' ? "startNode" : "StartNodeID");
|
|
19070
|
+
let propertyValue_nodeid = 0;
|
|
19071
|
+
switch (this.optionsManager.getOptions().source) {
|
|
19072
|
+
case "file":
|
|
19073
|
+
//TODO maybe someday ... someday far !
|
|
19074
|
+
return realFullpath;
|
|
19075
|
+
case "data":
|
|
19076
|
+
//TODO maybe someday ... someday far !
|
|
19077
|
+
if (this.optionsManager.getOptions().origin == 'classification')
|
|
19078
|
+
return realFullpath;
|
|
19079
|
+
propertyValue_nodeid = this.theOptions.data.key;
|
|
19080
|
+
break;
|
|
19081
|
+
case "webservice":
|
|
19082
|
+
propertyValue_nodeid = this.optionsManager.getOptions().options[propertyName_nodeid];
|
|
19083
|
+
break;
|
|
18919
19084
|
}
|
|
18920
|
-
|
|
18921
|
-
|
|
18922
|
-
|
|
19085
|
+
if (["0", 0].includes(propertyValue_nodeid))
|
|
19086
|
+
return toret;
|
|
19087
|
+
if (isNumeric(propertyValue_nodeid)) {
|
|
19088
|
+
if (this.optionsManager.getOptions().origin == 'classification') {
|
|
19089
|
+
const { Translations, Properties } = rdmdata;
|
|
19090
|
+
const currentLanguage = this.optionsManager.getOptions().language;
|
|
19091
|
+
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), "");
|
|
19092
|
+
}
|
|
19093
|
+
else {
|
|
19094
|
+
const { fullpath, fullpathTranslated, title, valueTranslated } = rdmdata;
|
|
19095
|
+
toret = (valueTranslated !== null && valueTranslated !== void 0 ? valueTranslated : title) + realFullpath.replace((fullpathTranslated !== null && fullpathTranslated !== void 0 ? fullpathTranslated : fullpath), "");
|
|
19096
|
+
}
|
|
18923
19097
|
}
|
|
19098
|
+
else
|
|
19099
|
+
this.errorToLog = "Error in getShortenedFullpath : startnode is not number";
|
|
19100
|
+
}
|
|
19101
|
+
catch (error) {
|
|
19102
|
+
this.errorToLog = "Error in getShortenedFullpath " + error.toString();
|
|
18924
19103
|
}
|
|
18925
|
-
else
|
|
18926
|
-
this.errorToLog = "Error in getFullpath : startnode is not number";
|
|
18927
|
-
}
|
|
18928
|
-
catch (error) {
|
|
18929
|
-
this.errorToLog = "Error in getFullpath " + error.toString();
|
|
18930
19104
|
}
|
|
18931
19105
|
return toret;
|
|
18932
19106
|
};
|
|
@@ -18978,7 +19152,6 @@ const HierarchizedPickerComponent = class {
|
|
|
18978
19152
|
}
|
|
18979
19153
|
componentDidLoad() {
|
|
18980
19154
|
this.mylog('----- componentDidLoad beginning -----');
|
|
18981
|
-
setupKeyboardNavigation(this, this.navigateInTree);
|
|
18982
19155
|
focusMainInput();
|
|
18983
19156
|
}
|
|
18984
19157
|
displayWhenLoaded() {
|
|
@@ -19022,6 +19195,8 @@ const HierarchizedPickerComponent = class {
|
|
|
19022
19195
|
this.optionsManager.getOptions().openTreeWhenLoaded = false;
|
|
19023
19196
|
if (!this.optionsManager.getOptions().displayRootNode)
|
|
19024
19197
|
this.optionsManager.getOptions().displayRootNode = false;
|
|
19198
|
+
if (!this.optionsManager.getOptions().keyboardNavigation)
|
|
19199
|
+
this.optionsManager.getOptions().keyboardNavigation = false;
|
|
19025
19200
|
if (!this.optionsManager.getOptions().dragAndDropEnabled)
|
|
19026
19201
|
this.optionsManager.getOptions().dragAndDropEnabled = false;
|
|
19027
19202
|
if (!this.optionsManager.getOptions().defaultValueIsFullpath)
|
|
@@ -19039,21 +19214,50 @@ const HierarchizedPickerComponent = class {
|
|
|
19039
19214
|
}
|
|
19040
19215
|
await Promise.all(this.optionsManager.getOptions().defaultValue.map(async (element) => {
|
|
19041
19216
|
if (this.optionsManager.getOptions().defaultValueIsFullpath || (!(typeof element == 'number') && !strIsNumeric(element))) {
|
|
19042
|
-
if (
|
|
19043
|
-
|
|
19217
|
+
if (!defaultFromFullpaths) {
|
|
19218
|
+
defaultFromFullpaths = [];
|
|
19219
|
+
}
|
|
19220
|
+
let errormsg = '';
|
|
19221
|
+
switch (this.optionsManager.getOptions().source) {
|
|
19222
|
+
case 'file':
|
|
19223
|
+
errormsg = 'The loading of nodes based on fullpath is not available on file mode for now!';
|
|
19224
|
+
break;
|
|
19225
|
+
case 'data':
|
|
19226
|
+
if (this.theOptions.origin == 'classification') {
|
|
19227
|
+
errormsg = 'The loading of nodes based on fullpath is not available on file mode for the classification context for now!';
|
|
19228
|
+
break;
|
|
19229
|
+
}
|
|
19230
|
+
const searchIdInData = function (treeData) {
|
|
19231
|
+
if (treeData.data.fullpath === element || treeData.data.fullpathTranslated === element) {
|
|
19232
|
+
return treeData.key;
|
|
19233
|
+
}
|
|
19234
|
+
if (treeData.children && treeData.children.length > 0) {
|
|
19235
|
+
for (const childTree of treeData.children) {
|
|
19236
|
+
const foundId = searchIdInData(childTree);
|
|
19237
|
+
if (foundId) {
|
|
19238
|
+
return foundId;
|
|
19239
|
+
}
|
|
19240
|
+
}
|
|
19241
|
+
}
|
|
19242
|
+
return null;
|
|
19243
|
+
};
|
|
19244
|
+
if (element) {
|
|
19245
|
+
const foundId = searchIdInData(this.theOptions.data);
|
|
19246
|
+
if (foundId)
|
|
19247
|
+
defaultFromFullpaths.push(foundId);
|
|
19248
|
+
}
|
|
19249
|
+
break;
|
|
19250
|
+
case 'webservice':
|
|
19251
|
+
const valtopush = await this.rawDataManager.fetchNodeIdFromFullpath(element, this.optionsManager.getOptions()).catch(err => { this.displayPickerError(err); });
|
|
19252
|
+
if (valtopush) {
|
|
19253
|
+
defaultFromFullpaths.push(valtopush);
|
|
19254
|
+
}
|
|
19255
|
+
break;
|
|
19256
|
+
}
|
|
19257
|
+
if (errormsg.length > 0) {
|
|
19044
19258
|
this.displayPickerError(errormsg);
|
|
19045
19259
|
this.errorToLog = errormsg;
|
|
19046
19260
|
autoAssignReach = false;
|
|
19047
|
-
return;
|
|
19048
|
-
}
|
|
19049
|
-
else {
|
|
19050
|
-
if (!defaultFromFullpaths) {
|
|
19051
|
-
defaultFromFullpaths = [];
|
|
19052
|
-
}
|
|
19053
|
-
const valtopush = await this.rawDataManager.fetchNodeIdFromFullpath(element, this.optionsManager.getOptions()).catch(err => { this.displayPickerError(err); });
|
|
19054
|
-
if (valtopush) {
|
|
19055
|
-
defaultFromFullpaths.push(valtopush);
|
|
19056
|
-
}
|
|
19057
19261
|
}
|
|
19058
19262
|
}
|
|
19059
19263
|
}));
|
|
@@ -19061,7 +19265,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19061
19265
|
this.optionsManager.getOptions().defaultValue = defaultFromFullpaths;
|
|
19062
19266
|
}
|
|
19063
19267
|
if (this.optionsManager.getOptions().options) {
|
|
19064
|
-
if (
|
|
19268
|
+
if (this.optionsManager.getOptions().defaultValue.length > 0) {
|
|
19065
19269
|
if (autoAssignReach) {
|
|
19066
19270
|
this.optionsManager.getOptions().options.Reach = this.optionsManager.getOptions().defaultValue.map(element => {
|
|
19067
19271
|
return Number(element);
|
|
@@ -19088,10 +19292,16 @@ const HierarchizedPickerComponent = class {
|
|
|
19088
19292
|
console.timeEnd = function () { };
|
|
19089
19293
|
}
|
|
19090
19294
|
// Setup component unique ID
|
|
19091
|
-
if (this.optionsManager.getOptions().id)
|
|
19295
|
+
if (this.optionsManager.getOptions().id) {
|
|
19092
19296
|
this.componentID = this.optionsManager.getOptions().id;
|
|
19093
|
-
|
|
19094
|
-
|
|
19297
|
+
}
|
|
19298
|
+
else if (!this.componentID) {
|
|
19299
|
+
let componentID = (Array.from(document.querySelectorAll('reneco-hierarchized-picker')).indexOf(this.el) + 1);
|
|
19300
|
+
while (document.querySelectorAll(`#hierarchized-picker-${componentID}`).length > 0) {
|
|
19301
|
+
componentID++;
|
|
19302
|
+
}
|
|
19303
|
+
this.componentID = componentID.toString();
|
|
19304
|
+
}
|
|
19095
19305
|
if (!this.optionsManager.getOptions())
|
|
19096
19306
|
return;
|
|
19097
19307
|
this.optionsManager.updateDefaultValue();
|
|
@@ -19159,7 +19369,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19159
19369
|
this.ignoreOptionsChanges = false;
|
|
19160
19370
|
}
|
|
19161
19371
|
catch (_b) {
|
|
19162
|
-
|
|
19372
|
+
this.errorToLog = 'Error loading webservice data!';
|
|
19163
19373
|
}
|
|
19164
19374
|
}
|
|
19165
19375
|
displayPickerError(errorMsg = '') {
|
|
@@ -19171,11 +19381,11 @@ const HierarchizedPickerComponent = class {
|
|
|
19171
19381
|
}
|
|
19172
19382
|
this.displayedValue = errorMsg;
|
|
19173
19383
|
this.isDisabled = true;
|
|
19174
|
-
|
|
19384
|
+
this.errorToLog = errorMsg;
|
|
19175
19385
|
}
|
|
19176
19386
|
}
|
|
19177
19387
|
catch (_a) {
|
|
19178
|
-
|
|
19388
|
+
this.errorToLog = errorMsg;
|
|
19179
19389
|
}
|
|
19180
19390
|
}
|
|
19181
19391
|
getApiSearchURL() {
|
|
@@ -19195,17 +19405,17 @@ const HierarchizedPickerComponent = class {
|
|
|
19195
19405
|
}
|
|
19196
19406
|
}
|
|
19197
19407
|
// TODO > Celine would rather like the context (thesaurus or position) to be extracted another way
|
|
19198
|
-
getContextualApiURL(init = false) {
|
|
19199
|
-
const { options, url } = this.optionsManager.getOptions();
|
|
19408
|
+
getContextualApiURL(init = false, forcedOptions = null) {
|
|
19409
|
+
const { options, url } = forcedOptions || this.optionsManager.getOptions();
|
|
19200
19410
|
if (init && options.Reach) {
|
|
19201
|
-
|
|
19202
|
-
const base = window.location.origin; // fallback for relative URLs
|
|
19411
|
+
const base = window.location.origin;
|
|
19203
19412
|
const parsedUrl = new URL(url, base);
|
|
19204
|
-
const pathSegments = parsedUrl.pathname.split('/');
|
|
19205
|
-
|
|
19206
|
-
if (
|
|
19207
|
-
|
|
19208
|
-
|
|
19413
|
+
const pathSegments = parsedUrl.pathname.split('/').filter(Boolean);
|
|
19414
|
+
const idx = pathSegments.indexOf("getTree");
|
|
19415
|
+
if (idx !== -1) {
|
|
19416
|
+
pathSegments[idx] = "reach";
|
|
19417
|
+
}
|
|
19418
|
+
const newPathname = "/" + pathSegments.join("/");
|
|
19209
19419
|
return `${parsedUrl.origin}${newPathname}`;
|
|
19210
19420
|
}
|
|
19211
19421
|
return url;
|
|
@@ -19276,7 +19486,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19276
19486
|
}
|
|
19277
19487
|
})
|
|
19278
19488
|
.catch(err => {
|
|
19279
|
-
|
|
19489
|
+
this.errorToLog = err;
|
|
19280
19490
|
});
|
|
19281
19491
|
}
|
|
19282
19492
|
else {
|
|
@@ -19295,29 +19505,26 @@ const HierarchizedPickerComponent = class {
|
|
|
19295
19505
|
}
|
|
19296
19506
|
})
|
|
19297
19507
|
.catch(error => {
|
|
19298
|
-
|
|
19508
|
+
this.errorToLog = error;
|
|
19299
19509
|
try {
|
|
19300
19510
|
this.errorToLog = 'getDataFromSource 1 rejected:' + JSON.stringify(error, replacer, 2);
|
|
19301
19511
|
}
|
|
19302
19512
|
catch (_a) {
|
|
19303
|
-
|
|
19513
|
+
this.errorToLog = JSON.stringify(error, replacer, 2);
|
|
19304
19514
|
}
|
|
19305
19515
|
});
|
|
19306
19516
|
}
|
|
19307
19517
|
}
|
|
19308
19518
|
else {
|
|
19309
|
-
if (this.
|
|
19310
|
-
this.rawDataManager.getData()
|
|
19311
|
-
|
|
19312
|
-
|
|
19313
|
-
|
|
19519
|
+
if (this.optionsManager.getOptions().source == 'data') {
|
|
19520
|
+
displayResults(this.rawDataManager.getData());
|
|
19521
|
+
if (!searched) {
|
|
19522
|
+
this.setSearchResults([]);
|
|
19523
|
+
}
|
|
19314
19524
|
}
|
|
19315
|
-
|
|
19316
|
-
|
|
19317
|
-
if (searched) {
|
|
19318
|
-
this.setSearchResults(treeToDisplay);
|
|
19525
|
+
else {
|
|
19526
|
+
console.error("Unhandled picker settings for search scenario !!");
|
|
19319
19527
|
}
|
|
19320
|
-
this.displayTree(treeToDisplay);
|
|
19321
19528
|
}
|
|
19322
19529
|
}
|
|
19323
19530
|
async triggerTreeDisplay(dataToLoad, searched) {
|
|
@@ -19399,11 +19606,31 @@ const HierarchizedPickerComponent = class {
|
|
|
19399
19606
|
this.showSelectedNodes();
|
|
19400
19607
|
this.deactivateNodesOutOfDepthSettings();
|
|
19401
19608
|
// Hides checkboxes in non multiple context
|
|
19402
|
-
|
|
19403
|
-
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = 'none'));
|
|
19404
|
-
}
|
|
19609
|
+
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = (this.theOptions.multiple ? 'inline-block' : 'none')));
|
|
19405
19610
|
}
|
|
19406
19611
|
onItemContextMenuItemClick(e) {
|
|
19612
|
+
if (e.target && e.target.id) {
|
|
19613
|
+
function getDirectParentAndDepth(nodesById, targetId) {
|
|
19614
|
+
// Find the direct parent
|
|
19615
|
+
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;
|
|
19616
|
+
if (!nodesById[targetId])
|
|
19617
|
+
return null; // target not found
|
|
19618
|
+
// Depth is 0 for root nodes, 1 for children of root, etc.
|
|
19619
|
+
let depth = 0;
|
|
19620
|
+
let current = targetId;
|
|
19621
|
+
while (true) {
|
|
19622
|
+
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); });
|
|
19623
|
+
if (!directParent)
|
|
19624
|
+
break;
|
|
19625
|
+
depth++;
|
|
19626
|
+
current = directParent.id;
|
|
19627
|
+
}
|
|
19628
|
+
return { parent, depth };
|
|
19629
|
+
}
|
|
19630
|
+
const result = getDirectParentAndDepth(this.loadedTreeJs.nodesById, e.target.id);
|
|
19631
|
+
e.target.depth = result.depth;
|
|
19632
|
+
e.target.parentId = result.parent.id;
|
|
19633
|
+
}
|
|
19407
19634
|
this.itemContextMenuItemClick.emit(e);
|
|
19408
19635
|
}
|
|
19409
19636
|
setNodeAsSelected(id, treeToUpdate, userClick) {
|
|
@@ -19412,8 +19639,10 @@ const HierarchizedPickerComponent = class {
|
|
|
19412
19639
|
(this.loadedTreeJs.liElementsById[id] && this.loadedTreeJs.liElementsById[id].classList.value && this.loadedTreeJs.liElementsById[id].classList.value.indexOf('readonly_node') != -1)) {
|
|
19413
19640
|
return;
|
|
19414
19641
|
}
|
|
19415
|
-
if (treeToUpdate.getValues().indexOf(id.toString()) != -1)
|
|
19642
|
+
if (!userClick && treeToUpdate.getValues().indexOf(id.toString()) != -1)
|
|
19416
19643
|
return;
|
|
19644
|
+
if (this.loadedTreeJs && !this.theOptions.multiple)
|
|
19645
|
+
this.loadedTreeJs.emptyNodesCheckStatus();
|
|
19417
19646
|
this.ignoreOptionsChanges = true;
|
|
19418
19647
|
// Override of treejs normal workaround =>> DONT EDIT IT!
|
|
19419
19648
|
// ----- BEGIN -----
|
|
@@ -19450,46 +19679,29 @@ const HierarchizedPickerComponent = class {
|
|
|
19450
19679
|
* This method display the current selected node to the user by expanding all it's parent nodes and scrolling inside the tree
|
|
19451
19680
|
*/
|
|
19452
19681
|
async showSelectedNodes(addDelay = false) {
|
|
19453
|
-
if (this.optionsManager.getOptions().multiple) {
|
|
19454
|
-
|
|
19455
|
-
|
|
19456
|
-
}
|
|
19457
|
-
const scrollToNode = () => {
|
|
19458
|
-
let scrollToValue = 0;
|
|
19459
|
-
let removeClosedAndLookUp = (element) => {
|
|
19460
|
-
var _a, _b, _c, _d;
|
|
19461
|
-
const nodeId = element === null || element === void 0 ? void 0 : element.nodeId;
|
|
19462
|
-
if (!element || !nodeId) {
|
|
19463
|
-
return;
|
|
19464
|
-
}
|
|
19465
|
-
const node = this.loadedTreeJs.nodesById[nodeId];
|
|
19466
|
-
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) {
|
|
19467
|
-
(_c = element.classList) === null || _c === void 0 ? void 0 : _c.remove('treejs-node__close');
|
|
19468
|
-
}
|
|
19469
|
-
scrollToValue += element.offsetTop;
|
|
19470
|
-
const parent = (_d = element.parentNode) === null || _d === void 0 ? void 0 : _d.closest('.treejs-node');
|
|
19471
|
-
if (parent) {
|
|
19472
|
-
removeClosedAndLookUp(parent);
|
|
19473
|
-
}
|
|
19474
|
-
};
|
|
19475
|
-
try {
|
|
19476
|
-
const checkeds = document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node__checked');
|
|
19477
|
-
checkeds.forEach((item) => removeClosedAndLookUp(item));
|
|
19478
|
-
}
|
|
19479
|
-
catch (err) {
|
|
19480
|
-
// console.error("Error in showSelectedNodes", err);
|
|
19481
|
-
}
|
|
19482
|
-
if (scrollToValue && this.scrollable) {
|
|
19483
|
-
this.scrollable.scrollTop = scrollToValue;
|
|
19484
|
-
}
|
|
19485
|
-
};
|
|
19682
|
+
// if (this.optionsManager.getOptions().multiple) {
|
|
19683
|
+
// console.warn('You are not allowed to scroll to selected nodes in multiple mode');
|
|
19684
|
+
// return;
|
|
19685
|
+
// }
|
|
19486
19686
|
if (addDelay) {
|
|
19487
19687
|
setTimeout(() => {
|
|
19488
|
-
scrollToNode();
|
|
19688
|
+
this.scrollToNode();
|
|
19489
19689
|
}, 200);
|
|
19490
19690
|
}
|
|
19491
19691
|
else {
|
|
19492
|
-
scrollToNode();
|
|
19692
|
+
this.scrollToNode();
|
|
19693
|
+
}
|
|
19694
|
+
}
|
|
19695
|
+
async scrollToNodeWithId(targetNodeId, displayChildren = false) {
|
|
19696
|
+
const targetNode = this.loadedTreeJs.liElementsById[targetNodeId];
|
|
19697
|
+
if (!targetNode) {
|
|
19698
|
+
const contextualApiParams = this.getContextualApiParams(Object.assign(Object.assign({}, this.theOptions.options), { Reach: [targetNodeId] }), null, true);
|
|
19699
|
+
const contextualApiURL = this.getContextualApiURL(true, Object.assign(Object.assign({}, this.theOptions), { options: contextualApiParams }));
|
|
19700
|
+
this.rawDataManager.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"))
|
|
19701
|
+
.then(data => {
|
|
19702
|
+
completeCurrentTreeWithTree(this.loadedTreeJs, data, this.theOptions);
|
|
19703
|
+
this.scrollToNode(targetNodeId, displayChildren);
|
|
19704
|
+
});
|
|
19493
19705
|
}
|
|
19494
19706
|
}
|
|
19495
19707
|
showTree(focused) {
|
|
@@ -19498,10 +19710,10 @@ const HierarchizedPickerComponent = class {
|
|
|
19498
19710
|
clearAutocomplete();
|
|
19499
19711
|
if (!this.canload || !this.optionsManager.getOptions().displayTree)
|
|
19500
19712
|
return;
|
|
19501
|
-
const isStillInsidePicker = isInsidePicker(this, document.activeElement);
|
|
19713
|
+
const isStillInsidePicker = false; // TODO put back? >> isInsidePicker(this, document.activeElement);
|
|
19502
19714
|
if ((focused === 'hide' || this.isDisabled) && !isStillInsidePicker) {
|
|
19503
19715
|
this.hasFocus = ['hide'];
|
|
19504
|
-
const elem = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search
|
|
19716
|
+
const elem = document.querySelector('#hierarchized-picker-' + this.componentID + ' input.hierarchized-picker-search');
|
|
19505
19717
|
if (elem) {
|
|
19506
19718
|
elem.value = '';
|
|
19507
19719
|
}
|
|
@@ -19522,16 +19734,16 @@ const HierarchizedPickerComponent = class {
|
|
|
19522
19734
|
}
|
|
19523
19735
|
const previousShownTree = this.shownTree;
|
|
19524
19736
|
this.shownTree = this.hasFocus.length > 0;
|
|
19525
|
-
if (this.shownTree && !previousShownTree) {
|
|
19526
|
-
console.log("component value", document.querySelector('#hierarchized-picker-input-' + this.componentID));
|
|
19527
|
-
console.log("shouldOpenModalAbove", this.shouldOpenModalAbove(document.querySelector('#hierarchized-picker-input-' + this.componentID), this.modaleHeight));
|
|
19737
|
+
if (this.shownTree && !previousShownTree && this.optionsManager.getOptions().mode == 'input') {
|
|
19528
19738
|
if (this.shouldOpenModalAbove(document.querySelector('#hierarchized-picker-input-' + this.componentID), this.modaleHeight)) {
|
|
19529
19739
|
this.modalePosition = 'top';
|
|
19530
19740
|
}
|
|
19531
19741
|
else {
|
|
19532
19742
|
this.modalePosition = 'bottom';
|
|
19533
19743
|
}
|
|
19534
|
-
focusSearchInput(this);
|
|
19744
|
+
setTimeout(() => focusSearchInput(this), 100);
|
|
19745
|
+
//TODO, this this at the good location ?
|
|
19746
|
+
setupKeyboardNavigation(this, this.optionsManager, this.navigateInTree);
|
|
19535
19747
|
}
|
|
19536
19748
|
}
|
|
19537
19749
|
// Changes the value of the component with passed node
|
|
@@ -19544,9 +19756,12 @@ const HierarchizedPickerComponent = class {
|
|
|
19544
19756
|
return item.nodeid == node.id;
|
|
19545
19757
|
});
|
|
19546
19758
|
// If the passed node already exists in the array of values, remove it
|
|
19547
|
-
if (
|
|
19548
|
-
|
|
19549
|
-
|
|
19759
|
+
if (result > -1) {
|
|
19760
|
+
if (userClick)
|
|
19761
|
+
this.value.splice(result, 1);
|
|
19762
|
+
else
|
|
19763
|
+
return;
|
|
19764
|
+
}
|
|
19550
19765
|
else {
|
|
19551
19766
|
if (this.optionsManager.getOptions().multiple) {
|
|
19552
19767
|
this.value = [
|
|
@@ -19572,13 +19787,23 @@ const HierarchizedPickerComponent = class {
|
|
|
19572
19787
|
}
|
|
19573
19788
|
this.setDisplayedValue(this.value);
|
|
19574
19789
|
}
|
|
19790
|
+
getShortpathFromFullpath(fullpath) {
|
|
19791
|
+
if (!fullpath || fullpath.indexOf('>') == -1)
|
|
19792
|
+
return fullpath;
|
|
19793
|
+
return fullpath.substring(fullpath.lastIndexOf(">") + 1);
|
|
19794
|
+
}
|
|
19575
19795
|
setDisplayedValue(value = null) {
|
|
19576
19796
|
if (!value)
|
|
19577
19797
|
value = this.value;
|
|
19578
|
-
|
|
19579
|
-
var _a, _b;
|
|
19580
|
-
return (
|
|
19798
|
+
const toDisplay = value.map(item => {
|
|
19799
|
+
var _a, _b, _c;
|
|
19800
|
+
return (this.optionsManager.getOptions().source == 'data'
|
|
19801
|
+
?
|
|
19802
|
+
(_a = (this.optionsManager.getOptions().language == 'fr' ? this.getShortpathFromFullpath(item.fullpathTranslated) : this.getShortpathFromFullpath(item.fullpath))) !== null && _a !== void 0 ? _a : `Node ${item.nodeid}`
|
|
19803
|
+
:
|
|
19804
|
+
(_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}`);
|
|
19581
19805
|
}).join(';');
|
|
19806
|
+
this.displayedValue = toDisplay;
|
|
19582
19807
|
}
|
|
19583
19808
|
// Search a value in the tree and triggers a search when necessary
|
|
19584
19809
|
search(searched) {
|
|
@@ -19645,10 +19870,11 @@ const HierarchizedPickerComponent = class {
|
|
|
19645
19870
|
if (init) {
|
|
19646
19871
|
this.formatDefaultValue();
|
|
19647
19872
|
this.showSelectedNodes();
|
|
19873
|
+
this.checkFields(this.value);
|
|
19648
19874
|
}
|
|
19649
19875
|
})
|
|
19650
19876
|
.catch(error => {
|
|
19651
|
-
|
|
19877
|
+
this.errorToLog = error;
|
|
19652
19878
|
});
|
|
19653
19879
|
}
|
|
19654
19880
|
else {
|
|
@@ -19661,7 +19887,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19661
19887
|
}
|
|
19662
19888
|
})
|
|
19663
19889
|
.catch(error => {
|
|
19664
|
-
|
|
19890
|
+
this.errorToLog = error;
|
|
19665
19891
|
});
|
|
19666
19892
|
}
|
|
19667
19893
|
}
|
|
@@ -19682,7 +19908,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19682
19908
|
let enrichedValues = [];
|
|
19683
19909
|
if (values) {
|
|
19684
19910
|
values.forEach(element => {
|
|
19685
|
-
var _a, _b;
|
|
19911
|
+
var _a, _b, _c;
|
|
19686
19912
|
let intNodeid = element.nodeid || element.ID || element.key || undefined;
|
|
19687
19913
|
if (typeof intNodeid === 'string' && isNumeric(intNodeid)) {
|
|
19688
19914
|
intNodeid = parseInt(intNodeid);
|
|
@@ -19692,15 +19918,15 @@ const HierarchizedPickerComponent = class {
|
|
|
19692
19918
|
enrichedValues.push({
|
|
19693
19919
|
nodeid: intNodeid,
|
|
19694
19920
|
shortpathTranslated: (_a = treeNode.text) !== null && _a !== void 0 ? _a : `Node ${intNodeid}`,
|
|
19695
|
-
fullpathTranslated: (_b = treeNode.
|
|
19921
|
+
fullpathTranslated: (_b = treeNode.fullpathTranslated) !== null && _b !== void 0 ? _b : null,
|
|
19922
|
+
fullpath: (_c = treeNode.fullpath) !== null && _c !== void 0 ? _c : null,
|
|
19696
19923
|
hasChildren: treeNode.children && treeNode.children.length > 0
|
|
19697
19924
|
});
|
|
19698
|
-
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
19699
19925
|
}
|
|
19700
19926
|
else {
|
|
19701
|
-
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
19702
19927
|
console.warn("Node not found in Tree for:", intNodeid);
|
|
19703
19928
|
}
|
|
19929
|
+
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
19704
19930
|
});
|
|
19705
19931
|
}
|
|
19706
19932
|
this.setDisplayedValue(enrichedValues);
|
|
@@ -19710,8 +19936,19 @@ const HierarchizedPickerComponent = class {
|
|
|
19710
19936
|
formatDefaultValue() {
|
|
19711
19937
|
let found = 0;
|
|
19712
19938
|
let that = this;
|
|
19939
|
+
let fieldsToCheck = [];
|
|
19940
|
+
function addToFieldsToCheck(item) {
|
|
19941
|
+
if (Array.isArray(item)) {
|
|
19942
|
+
item.forEach(el => addToFieldsToCheck(el));
|
|
19943
|
+
}
|
|
19944
|
+
else {
|
|
19945
|
+
const exists = fieldsToCheck.some(el => (el.nodeid || el.ID) == (item.nodeid || item.ID));
|
|
19946
|
+
if (!exists) {
|
|
19947
|
+
fieldsToCheck.push(item);
|
|
19948
|
+
}
|
|
19949
|
+
}
|
|
19950
|
+
}
|
|
19713
19951
|
let recursive = function (children) {
|
|
19714
|
-
//158424
|
|
19715
19952
|
children.forEach(element => {
|
|
19716
19953
|
that.theOptions.defaultValue.forEach(dfValue => {
|
|
19717
19954
|
if (typeof dfValue == 'string' && isNumeric(dfValue)) {
|
|
@@ -19721,7 +19958,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19721
19958
|
if ((typeof dfValue == 'string' && getPropertyFromNode(element, 'Properties').FullPath == dfValue) ||
|
|
19722
19959
|
(typeof dfValue == 'number' && getPropertyFromNode(element, 'ID') == dfValue)) {
|
|
19723
19960
|
element.nodeid = element.id;
|
|
19724
|
-
|
|
19961
|
+
addToFieldsToCheck([element]);
|
|
19725
19962
|
found++;
|
|
19726
19963
|
}
|
|
19727
19964
|
}
|
|
@@ -19731,7 +19968,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19731
19968
|
(typeof dfValue == 'string' && getPropertyFromNode(element, 'fullpathTranslated') == dfValue) ||
|
|
19732
19969
|
(typeof dfValue == 'number' && getPropertyFromNode(element, 'key') == dfValue)) {
|
|
19733
19970
|
element.nodeid = element.key;
|
|
19734
|
-
|
|
19971
|
+
addToFieldsToCheck([element]);
|
|
19735
19972
|
found++;
|
|
19736
19973
|
}
|
|
19737
19974
|
}
|
|
@@ -19743,6 +19980,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19743
19980
|
if (this.rawDataManager.getData()) {
|
|
19744
19981
|
recursive([this.rawDataManager.getData()]);
|
|
19745
19982
|
}
|
|
19983
|
+
that.checkFields(fieldsToCheck);
|
|
19746
19984
|
if (this.theOptions.defaultValue.length != found) {
|
|
19747
19985
|
if (found == 0) {
|
|
19748
19986
|
try {
|
|
@@ -19768,6 +20006,8 @@ const HierarchizedPickerComponent = class {
|
|
|
19768
20006
|
.join('; ');
|
|
19769
20007
|
}
|
|
19770
20008
|
shouldOpenModalAbove(inputElement, modaleHeight) {
|
|
20009
|
+
if (this.optionsManager.getOptions().mode != 'input')
|
|
20010
|
+
return false;
|
|
19771
20011
|
const inputRect = inputElement.getBoundingClientRect();
|
|
19772
20012
|
const spaceLeft = window.innerHeight - inputRect.y;
|
|
19773
20013
|
return spaceLeft < modaleHeight;
|
|
@@ -19791,7 +20031,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19791
20031
|
clickPickerModalArea(this);
|
|
19792
20032
|
} }, index.h("div", { class: "loader", ref: el => {
|
|
19793
20033
|
this.loader = el;
|
|
19794
|
-
} }, index.h("div", { class: "loader-inner" }, "Loading...")), index.h("div", { class: `hierarchized-picker-modal ${!this.ready ? 'hidden' : ''}
|
|
20034
|
+
} }, index.h("div", { class: "loader-inner" }, "Loading...")), index.h("div", { class: `hierarchized-picker-modal ${!this.ready ? 'hidden' : ''}`, tabindex: "0" }, index.h("search-input", { placeholder: getLanguageValue(this.optionsManager.getOptions().searchPlaceholder, this.optionsManager.getOptions().language, defaultLanguage), onInputFocus: () => focusInSearchEvent(this), onInputBlur: () => focusOutSearchEvent(this, event), onSearch: (event) => this.search(event.detail) }), index.h("ul", { id: "autocomplete-results-area" }), index.h("div", { id: 'tree-area-' + this.componentID, class: 'hierarchized-picker-tree hierarchized-picker-tree-area ' + this.pickerClass }))))) : (index.h("div", { class: 'hierarchized-picker-raw-tree-area' + (this.isDisabled ? ' readonly' : ''), tabindex: "0", onClick: event => {
|
|
19795
20035
|
clickPickerModalArea(this);
|
|
19796
20036
|
} }, index.h("div", { class: "loader", ref: el => {
|
|
19797
20037
|
this.loader = el;
|
|
@@ -19849,9 +20089,7 @@ const SearchInput = class {
|
|
|
19849
20089
|
render() {
|
|
19850
20090
|
return (index.h("div", { id: "hierarchized-picker-input-search",
|
|
19851
20091
|
// TODO: need component ID ?
|
|
19852
|
-
class: "search-input-container", ref: (el) => (this.rootElement = el) }, index.h("div", { class: "reneco reneco-search" }), index.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",
|
|
19853
|
-
//class="native-input search-input hierarchized-picker-search sc-ion-input-md-h sc-ion-input-md-s md"
|
|
19854
|
-
placeholder: this.placeholder, onFocus: () => this.handleFocus(), onBlur: (event) => this.handleBlur(event), onInput: (event) => this.handleInput(event) })));
|
|
20092
|
+
class: "search-input-container", ref: (el) => (this.rootElement = el) }, index.h("div", { class: "reneco reneco-search" }), index.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) })));
|
|
19855
20093
|
}
|
|
19856
20094
|
};
|
|
19857
20095
|
SearchInput.style = searchInputCss;
|