reneco-hierarchized-picker 0.4.3-beta.2 → 0.4.3-beta.20
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 +452 -246
- package/dist/collection/components/hierarchized-picker/hierarchized-picker.css +42 -19
- package/dist/collection/components/hierarchized-picker/hierarchized-picker.js +324 -108
- package/dist/collection/components/search-input/search-input.css +13 -17
- package/dist/collection/components/search-input/search-input.js +2 -2
- package/dist/collection/components/treejs/index.js +50 -50
- package/dist/collection/core/options-manager.js +2 -0
- package/dist/collection/core/raw-data-manager.js +4 -0
- package/dist/collection/features/events/focus-handlers.js +15 -11
- package/dist/collection/features/keyboard-navigation/keyboard-navigation.js +93 -60
- 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 +11 -3
- package/dist/collection/utils/theme-utils.js +5 -1
- package/dist/custom-elements/index.js +452 -246
- 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 +452 -246
- 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-0df46cca.system.entry.js +3 -0
- package/dist/reneco-hierarchized-picker/p-73168a50.system.js +1 -1
- package/dist/reneco-hierarchized-picker/p-cc9ee330.entry.js +1 -0
- package/dist/reneco-hierarchized-picker/reneco-hierarchized-picker.esm.js +1 -1
- package/dist/types/components/hierarchized-picker/hierarchized-picker.d.ts +19 -2
- package/dist/types/components.d.ts +10 -0
- package/dist/types/core/options-manager.d.ts +1 -1
- package/dist/types/features/keyboard-navigation/keyboard-navigation.d.ts +3 -1
- package/dist/types/features/tree/tree-utils.d.ts +1 -1
- package/dist/types/utils/constants.d.ts +7 -0
- package/dist/types/utils/utils.d.ts +1 -0
- package/package.json +1 -1
- package/dist/reneco-hierarchized-picker/p-170e1b20.system.entry.js +0 -3
- package/dist/reneco-hierarchized-picker/p-763a27e0.entry.js +0 -1
|
@@ -2,6 +2,7 @@ import { HTMLElement, createEvent, h, proxyCustomElement } from '@stencil/core/i
|
|
|
2
2
|
export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
|
|
3
3
|
|
|
4
4
|
function applyPickerTheme(theme, defaultTheme) {
|
|
5
|
+
var _a;
|
|
5
6
|
const docstyle = document.documentElement.style;
|
|
6
7
|
docstyle.setProperty('--hpicker-theme-palette-primary-main', (theme === null || theme === void 0 ? void 0 : theme.palette.primary.main) || defaultTheme.palette.primary.main);
|
|
7
8
|
docstyle.setProperty('--hpicker-theme-palette-primary-light', (theme === null || theme === void 0 ? void 0 : theme.palette.primary.light) || defaultTheme.palette.primary.light);
|
|
@@ -9,9 +10,12 @@ function applyPickerTheme(theme, defaultTheme) {
|
|
|
9
10
|
docstyle.setProperty('--hpicker-theme-palette-background-default', (theme === null || theme === void 0 ? void 0 : theme.palette.background.default) || defaultTheme.palette.background.default);
|
|
10
11
|
docstyle.setProperty('--hpicker-theme-palette-background-light', (theme === null || theme === void 0 ? void 0 : theme.palette.background.light) || defaultTheme.palette.background.light);
|
|
11
12
|
docstyle.setProperty('--hpicker-theme-palette-background-dark', (theme === null || theme === void 0 ? void 0 : theme.palette.background.dark) || defaultTheme.palette.background.dark);
|
|
13
|
+
docstyle.setProperty('--hpicker-theme-palette-font-color', (theme === null || theme === void 0 ? void 0 : theme.palette.text.primary) || defaultTheme.palette.text.primary);
|
|
14
|
+
docstyle.setProperty('--hpicker-theme-palette-input-background-color', (theme === null || theme === void 0 ? void 0 : theme.palette.input.background) || defaultTheme.palette.input.background);
|
|
15
|
+
docstyle.setProperty('--hpicker-theme-palette-input-border-style', (theme === null || theme === void 0 ? void 0 : theme.palette.input.borderStyle) || defaultTheme.palette.input.borderStyle);
|
|
12
16
|
docstyle.setProperty('--hpicker-theme-typography-body-font-size', (theme === null || theme === void 0 ? void 0 : theme.typography.body.fontSize) || defaultTheme.typography.body.fontSize);
|
|
13
17
|
docstyle.setProperty('--hpicker-theme-typography-body-font-weight', (theme === null || theme === void 0 ? void 0 : theme.typography.body.fontWeight) || defaultTheme.typography.body.fontWeight);
|
|
14
|
-
docstyle.setProperty('--hpicker-theme-
|
|
18
|
+
docstyle.setProperty('--hpicker-theme-modal-height', ((_a = theme === null || theme === void 0 ? void 0 : theme.modale) === null || _a === void 0 ? void 0 : _a.height) || defaultTheme.modale.height);
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -317,59 +321,15 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
317
321
|
else if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher')) {
|
|
318
322
|
this.onSwitcherClick(target);
|
|
319
323
|
}
|
|
320
|
-
const hasUndefinedchild = e.target.parentNode.querySelectorAll(".treejs-switcher").length > 0 && e.target.parentNode.querySelectorAll('ul').length == 0;
|
|
321
|
-
//CUSTOM
|
|
322
|
-
const childspans = Array.prototype.slice.call(e.target.parentNode.querySelectorAll('ul > li > span.treejs-label')).filter((ele) => {
|
|
323
|
-
return ele.parentNode.parentNode.parentNode === e.target.parentNode;
|
|
324
|
-
});
|
|
325
|
-
let undefinedChildren = [];
|
|
326
|
-
//This may be a problem the day a node value is "undefined"
|
|
327
|
-
undefinedChildren = childspans.filter(ele => {
|
|
328
|
-
return ele.textContent === 'undefined';
|
|
329
|
-
});
|
|
330
|
-
// If the user clicked on an unloaded node
|
|
331
|
-
if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher') && (undefinedChildren.length > 0 || hasUndefinedchild)) {
|
|
332
|
-
// Clear the subnode HTML
|
|
333
|
-
if (undefinedChildren.length > 0) {
|
|
334
|
-
e.target.parentNode.querySelector('ul').innerHTML = '';
|
|
335
|
-
}
|
|
336
|
-
// If source is webservice (it shouldn't be something else)
|
|
337
|
-
if (this.options.parentApi.theOptions.source == 'webservice') {
|
|
338
|
-
if (this.options.parentApi.theOptions.origin == 'classification') {
|
|
339
|
-
const contextualApiParams = this.options.parentApi.getContextualApiParams(Object.assign(Object.assign({}, this.options.parentApi.theOptions.options), { startNode: target.parentNode.nodeId }));
|
|
340
|
-
const contextualApiURL = this.options.parentApi.getContextualApiURL();
|
|
341
|
-
// WS Call
|
|
342
|
-
this.options.rawDataManager
|
|
343
|
-
.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
344
|
-
.then(data => {
|
|
345
|
-
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
// WS Call
|
|
350
|
-
this.options.rawDataManager
|
|
351
|
-
.getFromSource(this.options.parentApi.theOptions.url, {
|
|
352
|
-
StartNodeID: target.parentNode.nodeId,
|
|
353
|
-
lng: this.options.parentApi.theOptions.options.lng,
|
|
354
|
-
IsDeprecated: this.options.parentApi.theOptions.options.IsDeprecated,
|
|
355
|
-
}, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
356
|
-
.then(data => {
|
|
357
|
-
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
this.onSwitcherClick(target);
|
|
362
|
-
}
|
|
363
324
|
}, false);
|
|
364
325
|
};
|
|
365
326
|
Tree.prototype.onItemClick = async function (id, rightclick = false) {
|
|
366
327
|
// TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
|
|
328
|
+
console.log("coucou");
|
|
367
329
|
if (this.options.parentApi.isDisabled && this.options.parentApi.optionsManager.getOptions().mode != "tree")
|
|
368
330
|
return;
|
|
369
331
|
const pickerValue = await this.options.parentApi.getValue();
|
|
370
332
|
if (!rightclick || !pickerValue || pickerValue.nodeid != id) {
|
|
371
|
-
if (!this.options.parentApi.theOptions.multiple)
|
|
372
|
-
this.emptyNodesCheckStatus();
|
|
373
333
|
this.options.parentApi.setNodeAsSelected(id, this, true);
|
|
374
334
|
}
|
|
375
335
|
};
|
|
@@ -496,6 +456,48 @@ Tree.prototype.markWillUpdateNode = function (node) {
|
|
|
496
456
|
this.willUpdateNodesById[node.id] = node;
|
|
497
457
|
};
|
|
498
458
|
Tree.prototype.onSwitcherClick = function (target) {
|
|
459
|
+
const hasUndefinedchild = target.parentNode.querySelectorAll(".treejs-switcher").length > 0 && target.parentNode.querySelectorAll('ul').length == 0;
|
|
460
|
+
//CUSTOM
|
|
461
|
+
const childspans = Array.prototype.slice.call(target.parentNode.querySelectorAll('ul > li > span.treejs-label')).filter((ele) => {
|
|
462
|
+
return ele.parentNode.parentNode.parentNode === target.parentNode;
|
|
463
|
+
});
|
|
464
|
+
let undefinedChildren = [];
|
|
465
|
+
//This may be a problem the day a node value is "undefined"
|
|
466
|
+
undefinedChildren = childspans.filter(ele => {
|
|
467
|
+
return ele.textContent === 'undefined';
|
|
468
|
+
});
|
|
469
|
+
// If the user clicked on an unloaded node
|
|
470
|
+
if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher') && (undefinedChildren.length > 0 || hasUndefinedchild)) {
|
|
471
|
+
// Clear the subnode HTML
|
|
472
|
+
if (undefinedChildren.length > 0) {
|
|
473
|
+
target.parentNode.querySelector('ul').innerHTML = '';
|
|
474
|
+
}
|
|
475
|
+
// If source is webservice (it shouldn't be something else)
|
|
476
|
+
if (this.options.parentApi.theOptions.source == 'webservice') {
|
|
477
|
+
if (this.options.parentApi.theOptions.origin == 'classification') {
|
|
478
|
+
const contextualApiParams = this.options.parentApi.getContextualApiParams(Object.assign(Object.assign({}, this.options.parentApi.theOptions.options), { startNode: target.parentNode.nodeId }));
|
|
479
|
+
const contextualApiURL = this.options.parentApi.getContextualApiURL();
|
|
480
|
+
// WS Call
|
|
481
|
+
this.options.rawDataManager
|
|
482
|
+
.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
483
|
+
.then(data => {
|
|
484
|
+
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
// WS Call
|
|
489
|
+
this.options.rawDataManager
|
|
490
|
+
.getFromSource(this.options.parentApi.theOptions.url, {
|
|
491
|
+
StartNodeID: target.parentNode.nodeId,
|
|
492
|
+
lng: this.options.parentApi.theOptions.options.lng,
|
|
493
|
+
IsDeprecated: this.options.parentApi.theOptions.options.IsDeprecated,
|
|
494
|
+
}, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
495
|
+
.then(data => {
|
|
496
|
+
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
499
501
|
const liEle = target.parentNode;
|
|
500
502
|
const ele = liEle.lastChild;
|
|
501
503
|
const height = ele.scrollHeight;
|
|
@@ -533,6 +535,9 @@ Tree.prototype.onSwitcherClick = function (target) {
|
|
|
533
535
|
},
|
|
534
536
|
});
|
|
535
537
|
}
|
|
538
|
+
return new Promise((resolve) => {
|
|
539
|
+
resolve(this);
|
|
540
|
+
});
|
|
536
541
|
};
|
|
537
542
|
Tree.prototype.walkUp = function (node, changeState) {
|
|
538
543
|
const { parent } = node;
|
|
@@ -664,11 +669,10 @@ Tree.prototype.createLiEle = function (node, closed) {
|
|
|
664
669
|
else {
|
|
665
670
|
li.classList.add('treejs-placeholder');
|
|
666
671
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
+
const checkbox = document.createElement('span');
|
|
673
|
+
checkbox.classList.add('treejs-checkbox');
|
|
674
|
+
checkbox.style.display = ((!this.options.parentApi || (this.options.parentApi && this.options.parentApi.theOptions.multiple)) ? "inline-block" : "none");
|
|
675
|
+
li.appendChild(checkbox);
|
|
672
676
|
const label = document.createElement('span');
|
|
673
677
|
label.classList.add('treejs-label');
|
|
674
678
|
const text = document.createTextNode(node.text);
|
|
@@ -17989,6 +17993,10 @@ function isInstanceOfIConf(object) {
|
|
|
17989
17993
|
toret = false;
|
|
17990
17994
|
errorToLog = "options.displayRootNode value '" + object.displayRootNode + "' doesn't meet interface IConf requirements";
|
|
17991
17995
|
}
|
|
17996
|
+
if (!((!object.keyboardNavigation && typeof object.keyboardNavigation != 'boolean') || typeof object.keyboardNavigation == 'boolean')) {
|
|
17997
|
+
toret = false;
|
|
17998
|
+
errorToLog = "options.keyboardNavigation value '" + object.keyboardNavigation + "' doesn't meet interface IConf requirements";
|
|
17999
|
+
}
|
|
17992
18000
|
if (!((!object.dragAndDropEnabled && typeof object.dragAndDropEnabled != 'boolean') || typeof object.dragAndDropEnabled == 'boolean')) {
|
|
17993
18001
|
toret = false;
|
|
17994
18002
|
errorToLog = "options.dragAndDropEnabled value '" + object.dragAndDropEnabled + "' doesn't meet interface IConf requirements";
|
|
@@ -18085,17 +18093,22 @@ const defaultPickerTheme = {
|
|
|
18085
18093
|
primary: {
|
|
18086
18094
|
main: '#888',
|
|
18087
18095
|
light: '#888',
|
|
18088
|
-
contrastText: '#000',
|
|
18096
|
+
contrastText: '#000', // Text color of the selected node
|
|
18089
18097
|
},
|
|
18090
18098
|
background: {
|
|
18091
18099
|
default: '#ccc',
|
|
18092
18100
|
light: '#eee',
|
|
18093
18101
|
main: '#000',
|
|
18094
|
-
dark: '#fff',
|
|
18102
|
+
dark: '#fff', // Background of the whole tree
|
|
18095
18103
|
},
|
|
18096
18104
|
text: {
|
|
18097
|
-
primary: '#000',
|
|
18105
|
+
primary: '#000', // Text color
|
|
18098
18106
|
},
|
|
18107
|
+
// For all inputs in the component, includes in modale mode the display input and the search input
|
|
18108
|
+
input: {
|
|
18109
|
+
background: '#fff',
|
|
18110
|
+
borderStyle: 'none'
|
|
18111
|
+
}
|
|
18099
18112
|
},
|
|
18100
18113
|
typography: {
|
|
18101
18114
|
body: {
|
|
@@ -18103,6 +18116,9 @@ const defaultPickerTheme = {
|
|
|
18103
18116
|
fontWeight: '400',
|
|
18104
18117
|
},
|
|
18105
18118
|
},
|
|
18119
|
+
modale: {
|
|
18120
|
+
height: "200px",
|
|
18121
|
+
}
|
|
18106
18122
|
};
|
|
18107
18123
|
// const defaultPickerTheme = {
|
|
18108
18124
|
// palette: {
|
|
@@ -18188,6 +18204,10 @@ class RawDataManager {
|
|
|
18188
18204
|
async getFromClassification(endpoint, options, loader) {
|
|
18189
18205
|
let pathSegment = '';
|
|
18190
18206
|
const queryParams = [];
|
|
18207
|
+
if (options['Reach']) {
|
|
18208
|
+
queryParams.push(`id=${options['Reach'].join('&id=')}`);
|
|
18209
|
+
delete options['Reach'];
|
|
18210
|
+
}
|
|
18191
18211
|
for (const key in options) {
|
|
18192
18212
|
if (!options.hasOwnProperty(key))
|
|
18193
18213
|
continue;
|
|
@@ -18345,10 +18365,12 @@ class OptionsManager {
|
|
|
18345
18365
|
showAutocomplete: false,
|
|
18346
18366
|
openTreeWhenLoaded: false,
|
|
18347
18367
|
displayRootNode: false,
|
|
18368
|
+
keyboardNavigation: false,
|
|
18348
18369
|
dragAndDropEnabled: false,
|
|
18349
18370
|
errorsInInput: true,
|
|
18350
18371
|
isFullpath: true,
|
|
18351
18372
|
defaultValue: [],
|
|
18373
|
+
defaultValueIsFullpath: false,
|
|
18352
18374
|
};
|
|
18353
18375
|
const validatedOptions = Object.assign(Object.assign({}, defaults), options);
|
|
18354
18376
|
// Validate specific fields
|
|
@@ -18435,7 +18457,7 @@ function findNodeById(tree, nodeId) {
|
|
|
18435
18457
|
/**
|
|
18436
18458
|
* Fills the tree with nodes based on the provided object.
|
|
18437
18459
|
*/
|
|
18438
|
-
function fillTreeWithObject(tree, myObject, searched, options
|
|
18460
|
+
function fillTreeWithObject(tree, myObject, searched, options) {
|
|
18439
18461
|
const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
|
|
18440
18462
|
if (myObject && myObject.length) {
|
|
18441
18463
|
myObject.forEach(value => {
|
|
@@ -18467,7 +18489,6 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
|
|
|
18467
18489
|
const objToPush = {
|
|
18468
18490
|
id: keyPropFromNode,
|
|
18469
18491
|
nodeId: keyPropFromNode,
|
|
18470
|
-
depth,
|
|
18471
18492
|
text: valueTranslatedPropFromNode,
|
|
18472
18493
|
fullpath: fullpathPropFromNode,
|
|
18473
18494
|
fullpathTranslated: fullpathTranslatedPropFromNode,
|
|
@@ -18476,7 +18497,7 @@ function fillTreeWithObject(tree, myObject, searched, options, depth = 0) {
|
|
|
18476
18497
|
isDesaturated: false,
|
|
18477
18498
|
searchMatch: false,
|
|
18478
18499
|
};
|
|
18479
|
-
const childTree = fillTreeWithObject(objToPush.children, childrenPropFromNode, searched, options
|
|
18500
|
+
const childTree = fillTreeWithObject(objToPush.children, childrenPropFromNode, searched, options);
|
|
18480
18501
|
let pushMe = false;
|
|
18481
18502
|
if (searched) {
|
|
18482
18503
|
const matched = searchValue(objToPush, false, searched);
|
|
@@ -18502,6 +18523,11 @@ function completeCurrentTreeWithTree(treeJsInstance, newTree, options) {
|
|
|
18502
18523
|
var _a;
|
|
18503
18524
|
const ElmID = newTree.key || newTree.id || newTree.ID;
|
|
18504
18525
|
const targetNode = findNodeById(treeJsInstance, ElmID);
|
|
18526
|
+
if (ElmID == 0 && newTree.children && newTree.children.length > 0) {
|
|
18527
|
+
newTree.children.forEach(child => {
|
|
18528
|
+
completeCurrentTreeWithTree(treeJsInstance, child, options);
|
|
18529
|
+
});
|
|
18530
|
+
}
|
|
18505
18531
|
if (targetNode) {
|
|
18506
18532
|
targetNode.children = [];
|
|
18507
18533
|
let ulElem = (_a = treeJsInstance.liElementsById[ElmID]) === null || _a === void 0 ? void 0 : _a.querySelector('ul');
|
|
@@ -18517,6 +18543,11 @@ function completeCurrentTreeWithTree(treeJsInstance, newTree, options) {
|
|
|
18517
18543
|
targetNode.children.push(item);
|
|
18518
18544
|
treeJsInstance.nodesById[item.id] = item;
|
|
18519
18545
|
treeJsInstance.liElementsById[item.id] = liElm;
|
|
18546
|
+
if (item.children && item.children.some(child => Object.keys(child).length > 0)) {
|
|
18547
|
+
newTree.children.forEach(child => {
|
|
18548
|
+
completeCurrentTreeWithTree(treeJsInstance, child, options);
|
|
18549
|
+
});
|
|
18550
|
+
}
|
|
18520
18551
|
});
|
|
18521
18552
|
}
|
|
18522
18553
|
}
|
|
@@ -18559,6 +18590,105 @@ function clearAutocomplete(eraseResults = false) {
|
|
|
18559
18590
|
}
|
|
18560
18591
|
}
|
|
18561
18592
|
|
|
18593
|
+
let focusedNodeIndex = 0;
|
|
18594
|
+
function setupKeyboardNavigation(component, optionsManager, navigateInTree) {
|
|
18595
|
+
if (!optionsManager.getOptions().keyboardNavigation)
|
|
18596
|
+
return;
|
|
18597
|
+
const treeArea = component.el.querySelector('.hierarchized-picker-tree-area') || component.el.querySelector('.hierarchized-picker-raw-tree-area');
|
|
18598
|
+
if (!treeArea)
|
|
18599
|
+
return;
|
|
18600
|
+
function focusNode(allLiElements, liElementToFocus) {
|
|
18601
|
+
Object.values(allLiElements).forEach((liNode) => {
|
|
18602
|
+
liNode.classList.remove('treejs-node__focused');
|
|
18603
|
+
});
|
|
18604
|
+
liElementToFocus.classList.add('treejs-node__focused');
|
|
18605
|
+
}
|
|
18606
|
+
function findAllTreeNodes(treeNodes, liElementsById) {
|
|
18607
|
+
let allNodes = [];
|
|
18608
|
+
const traverse = (nodes) => {
|
|
18609
|
+
nodes.forEach(node => {
|
|
18610
|
+
allNodes.push(node);
|
|
18611
|
+
if (node.children && node.children.length > 0 && !liElementsById[node.id].classList.contains("treejs-node__close")) {
|
|
18612
|
+
traverse(node.children);
|
|
18613
|
+
}
|
|
18614
|
+
});
|
|
18615
|
+
};
|
|
18616
|
+
traverse(treeNodes);
|
|
18617
|
+
return allNodes;
|
|
18618
|
+
}
|
|
18619
|
+
focusedNodeIndex = 0;
|
|
18620
|
+
if (component && component.loadedTreeJs && component.loadedTreeJs.liElementsById && component.loadedTreeJs.treeNodes) {
|
|
18621
|
+
focusNode(component.loadedTreeJs.liElementsById, component.loadedTreeJs.liElementsById[component.loadedTreeJs.treeNodes[focusedNodeIndex].id]);
|
|
18622
|
+
}
|
|
18623
|
+
//todo, put back ?
|
|
18624
|
+
// if ((component.el as any)._hasKeydownListener) {
|
|
18625
|
+
// return;
|
|
18626
|
+
// }
|
|
18627
|
+
component.el._hasKeydownListener = true;
|
|
18628
|
+
if (!component._keydownListenerAdded) {
|
|
18629
|
+
component._keydownListenerAdded = true;
|
|
18630
|
+
component.el.addEventListener('keydown', (event) => {
|
|
18631
|
+
var _a, _b;
|
|
18632
|
+
console.log("Navigation 01", event);
|
|
18633
|
+
event.stopPropagation();
|
|
18634
|
+
console.log("Navigation 02");
|
|
18635
|
+
const tree = component.loadedTreeJs;
|
|
18636
|
+
let treeNodesFromTree = findAllTreeNodes(tree.treeNodes, tree.liElementsById);
|
|
18637
|
+
console.log("Navigation 03");
|
|
18638
|
+
if (!tree || !treeNodesFromTree.length)
|
|
18639
|
+
return;
|
|
18640
|
+
let spaceNode = treeNodesFromTree[focusedNodeIndex];
|
|
18641
|
+
let activeNode = treeNodesFromTree[focusedNodeIndex];
|
|
18642
|
+
let liElement = tree.liElementsById[activeNode.id];
|
|
18643
|
+
const handledEvents = ['tab', '0', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright'];
|
|
18644
|
+
console.log("Navigation 04", event.key);
|
|
18645
|
+
switch (event.key.toLowerCase()) {
|
|
18646
|
+
case 'tab':
|
|
18647
|
+
case '0':
|
|
18648
|
+
event.preventDefault();
|
|
18649
|
+
{ //(spaceNode?.nodeId) {
|
|
18650
|
+
component.setNodeAsSelected(spaceNode.nodeId, component.loadedTreeJs, true);
|
|
18651
|
+
component.showTree('hide');
|
|
18652
|
+
setTimeout(() => focusMainInput(), 100);
|
|
18653
|
+
}
|
|
18654
|
+
break;
|
|
18655
|
+
case 'arrowup':
|
|
18656
|
+
event.preventDefault();
|
|
18657
|
+
focusedNodeIndex = Math.max(focusedNodeIndex - 1, 0);
|
|
18658
|
+
const newActiveNodeUp = treeNodesFromTree[focusedNodeIndex];
|
|
18659
|
+
const newLiElementUp = tree.liElementsById[newActiveNodeUp.id];
|
|
18660
|
+
newLiElementUp.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
18661
|
+
focusNode(tree.liElementsById, newLiElementUp);
|
|
18662
|
+
break;
|
|
18663
|
+
case 'arrowdown':
|
|
18664
|
+
event.preventDefault();
|
|
18665
|
+
focusedNodeIndex = Math.min(focusedNodeIndex + 1, treeNodesFromTree.length - 1);
|
|
18666
|
+
const newActiveNodeDown = treeNodesFromTree[focusedNodeIndex];
|
|
18667
|
+
const newLiElementDown = tree.liElementsById[newActiveNodeDown.id];
|
|
18668
|
+
focusNode(tree.liElementsById, newLiElementDown);
|
|
18669
|
+
newLiElementDown.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
18670
|
+
break;
|
|
18671
|
+
case 'arrowleft':
|
|
18672
|
+
event.preventDefault();
|
|
18673
|
+
const leftSwitcher = liElement.querySelector('.treejs-switcher');
|
|
18674
|
+
if (leftSwitcher) {
|
|
18675
|
+
(_a = component.loadedTreeJs) === null || _a === void 0 ? void 0 : _a.onSwitcherClick(leftSwitcher);
|
|
18676
|
+
}
|
|
18677
|
+
break;
|
|
18678
|
+
case 'arrowright':
|
|
18679
|
+
event.preventDefault();
|
|
18680
|
+
const rightSwitcher = liElement.querySelector('.treejs-switcher');
|
|
18681
|
+
if (rightSwitcher) {
|
|
18682
|
+
(_b = component.loadedTreeJs) === null || _b === void 0 ? void 0 : _b.onSwitcherClick(rightSwitcher);
|
|
18683
|
+
}
|
|
18684
|
+
break;
|
|
18685
|
+
}
|
|
18686
|
+
if (handledEvents.includes(event.key.toLowerCase()))
|
|
18687
|
+
navigateInTree.emit(event);
|
|
18688
|
+
});
|
|
18689
|
+
}
|
|
18690
|
+
}
|
|
18691
|
+
|
|
18562
18692
|
// Utility functions
|
|
18563
18693
|
function isInsidePicker(component, target) {
|
|
18564
18694
|
return target !== null && component.el.contains(target);
|
|
@@ -18593,19 +18723,6 @@ function handleFocusEvent(component, type) {
|
|
|
18593
18723
|
component.showTree('hide');
|
|
18594
18724
|
}
|
|
18595
18725
|
}
|
|
18596
|
-
function manageFocusOut(component, event) {
|
|
18597
|
-
const relatedTarget = event.relatedTarget;
|
|
18598
|
-
if (!isInsidePicker(component, relatedTarget)) {
|
|
18599
|
-
setTimeout(() => {
|
|
18600
|
-
if (!isInsidePicker(component, document.activeElement)) {
|
|
18601
|
-
handleFocusEvent(component, 'hide');
|
|
18602
|
-
}
|
|
18603
|
-
}, 100);
|
|
18604
|
-
}
|
|
18605
|
-
else {
|
|
18606
|
-
handleFocusEvent(component, 'search');
|
|
18607
|
-
}
|
|
18608
|
-
}
|
|
18609
18726
|
function clickPickerModalArea(component, _event) {
|
|
18610
18727
|
if (component.pickerClass === 'fieldError') {
|
|
18611
18728
|
component.showTree('hide');
|
|
@@ -18616,82 +18733,18 @@ function clickPickerModalArea(component, _event) {
|
|
|
18616
18733
|
else {
|
|
18617
18734
|
component.mylog('Ignored modal click');
|
|
18618
18735
|
}
|
|
18736
|
+
if (component.theOptions.mode == 'tree') {
|
|
18737
|
+
setupKeyboardNavigation(component, component.optionsManager, component.navigateInTree);
|
|
18738
|
+
}
|
|
18619
18739
|
}
|
|
18620
18740
|
// Exposed event handlers
|
|
18621
18741
|
function focusInSearchEvent(component) {
|
|
18622
18742
|
handleFocusEvent(component, 'search');
|
|
18623
18743
|
}
|
|
18624
18744
|
function focusOutSearchEvent(component, event) {
|
|
18625
|
-
manageFocusOut(component, event);
|
|
18626
|
-
}
|
|
18627
|
-
|
|
18628
|
-
function setupKeyboardNavigation(component) {
|
|
18629
|
-
const treeArea = component.el.querySelector('.hierarchized-picker-tree-area');
|
|
18630
|
-
if (!treeArea)
|
|
18631
|
-
return;
|
|
18632
|
-
let focusedNodeIndex = 0;
|
|
18633
|
-
const treeNodes = Array.from(treeArea.querySelectorAll('.treejs-node'));
|
|
18634
|
-
function focusNode(index) {
|
|
18635
|
-
treeNodes.forEach(node => node.classList.remove('treejs-node__checked'));
|
|
18636
|
-
const targetNode = treeNodes[index];
|
|
18637
|
-
if (targetNode) {
|
|
18638
|
-
targetNode.classList.add('treejs-node__checked');
|
|
18639
|
-
targetNode.scrollIntoView({ block: 'nearest' });
|
|
18640
|
-
}
|
|
18641
|
-
}
|
|
18642
|
-
component.el.addEventListener('keydown', (event) => {
|
|
18643
|
-
var _a, _b, _c;
|
|
18644
|
-
event.stopPropagation();
|
|
18645
|
-
const tree = component.loadedTreeJs;
|
|
18646
|
-
if (!tree || !treeNodes.length)
|
|
18647
|
-
return;
|
|
18648
|
-
switch (event.key) {
|
|
18649
|
-
case 'Tab':
|
|
18650
|
-
event.preventDefault();
|
|
18651
|
-
component.showTree('hide');
|
|
18652
|
-
setTimeout(() => focusMainInput(), 10);
|
|
18653
|
-
break;
|
|
18654
|
-
case 'ArrowUp':
|
|
18655
|
-
event.preventDefault();
|
|
18656
|
-
focusedNodeIndex = Math.max(focusedNodeIndex - 1, 0);
|
|
18657
|
-
focusNode(focusedNodeIndex);
|
|
18658
|
-
break;
|
|
18659
|
-
case 'ArrowDown':
|
|
18660
|
-
event.preventDefault();
|
|
18661
|
-
focusedNodeIndex = Math.min(focusedNodeIndex + 1, treeNodes.length - 1);
|
|
18662
|
-
focusNode(focusedNodeIndex);
|
|
18663
|
-
break;
|
|
18664
|
-
case 'ArrowLeft':
|
|
18665
|
-
event.preventDefault();
|
|
18666
|
-
const leftSwitcher = (_a = treeNodes[focusedNodeIndex]) === null || _a === void 0 ? void 0 : _a.querySelector('.treejs-switcher');
|
|
18667
|
-
if (leftSwitcher) {
|
|
18668
|
-
(_b = component.loadedTreeJs) === null || _b === void 0 ? void 0 : _b.onSwitcherClick(leftSwitcher);
|
|
18669
|
-
component.showTree('hide');
|
|
18670
|
-
}
|
|
18671
|
-
break;
|
|
18672
|
-
case 'ArrowRight':
|
|
18673
|
-
event.preventDefault();
|
|
18674
|
-
const activeNode = treeNodes[focusedNodeIndex];
|
|
18675
|
-
const rightSwitcher = activeNode === null || activeNode === void 0 ? void 0 : activeNode.querySelector('.treejs-switcher');
|
|
18676
|
-
if (rightSwitcher) {
|
|
18677
|
-
(_c = component.loadedTreeJs) === null || _c === void 0 ? void 0 : _c.onSwitcherClick(rightSwitcher);
|
|
18678
|
-
}
|
|
18679
|
-
break;
|
|
18680
|
-
case '0':
|
|
18681
|
-
event.preventDefault();
|
|
18682
|
-
const spaceNode = treeNodes[focusedNodeIndex];
|
|
18683
|
-
if (spaceNode === null || spaceNode === void 0 ? void 0 : spaceNode.nodeId) {
|
|
18684
|
-
component.setNodeAsSelected(spaceNode.nodeId, component.loadedTreeJs, true);
|
|
18685
|
-
component.showTree('hide');
|
|
18686
|
-
setTimeout(() => focusMainInput(), 10);
|
|
18687
|
-
}
|
|
18688
|
-
break;
|
|
18689
|
-
}
|
|
18690
|
-
});
|
|
18691
|
-
focusNode(focusedNodeIndex);
|
|
18692
18745
|
}
|
|
18693
18746
|
|
|
18694
|
-
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 .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:inline;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center}reneco-hierarchized-picker .hierarchized-picker-input-area .input-wrapper{padding-left:10px !important}reneco-hierarchized-picker .hierarchized-picker-input{-ms-flex:2;flex:2}reneco-hierarchized-picker .hierarchized-picker-input.readonly{pointer-events:none;cursor:initial}reneco-hierarchized-picker .hierarchized-picker-input.hierarchized-picker-icon{margin-left:8px}reneco-hierarchized-picker .hierarchized-picker-label{position:stacked;margin-left:5px}reneco-hierarchized-picker .hierarchized-picker-tree-area{width:333px !important;padding-top:48px}reneco-hierarchized-picker .hierarchized-picker-modal-area{background-color:var(--hpicker-theme-palette-background-dark, var(--mui-palette-background-dark, var(--ion-color-light-tint, #FFF))) !important;position:absolute;z-index:10;padding-left:15px;overflow:scroll;top:20px;min-height:100px;max-height:200px;-webkit-box-shadow:0 0px 15px 0 rgba(0, 0, 0, 0.2);box-shadow:0 0px 15px 0 rgba(0, 0, 0, 0.2);border-radius:4px;margin-right:0px !important}reneco-hierarchized-picker .hierarchized-picker-modal{display:inline-block;width:357px}reneco-hierarchized-picker .hierarchized-picker{display:-ms-flexbox;display:flex;width:100%;font-family:'Roboto', sans-serif}reneco-hierarchized-picker .hierarchized-picker-spinner{margin:35px 0px 0px 145px}reneco-hierarchized-picker .reneco:before{position:relative;top:1px}reneco-hierarchized-picker .hierarchized-picker-input-area span.reneco{padding:10px 15px}reneco-hierarchized-picker .hierarchized-picker-input-area span.reneco:hover{cursor:pointer}reneco-hierarchized-picker .hierarchized-picker-input-area span.reneco-close{-webkit-transform:translate(5px, -8px);transform:translate(5px, -8px);color:var(--ion-color-danger, red) !important}reneco-hierarchized-picker .treejs .treejs-switcher:before{border-top:4px solid var(--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}.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}";
|
|
18747
|
+
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}";
|
|
18695
18748
|
|
|
18696
18749
|
const HierarchizedPickerComponent = class extends HTMLElement {
|
|
18697
18750
|
/**
|
|
@@ -18760,14 +18813,42 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18760
18813
|
logError(messageToLog) {
|
|
18761
18814
|
try {
|
|
18762
18815
|
console.error('--- Hierarchized picker ' + this.componentID + ' ERROR ---', messageToLog);
|
|
18816
|
+
this.lastErrorMessage = messageToLog;
|
|
18763
18817
|
}
|
|
18764
18818
|
catch (_a) {
|
|
18765
|
-
|
|
18819
|
+
const genericErrorMessage = '--- Hierarchized picker generic ERROR ---';
|
|
18820
|
+
this.lastErrorMessage = genericErrorMessage;
|
|
18821
|
+
console.error(genericErrorMessage);
|
|
18766
18822
|
}
|
|
18823
|
+
this.errorRaised.emit(this.lastErrorMessage);
|
|
18767
18824
|
}
|
|
18768
18825
|
get theOptions() {
|
|
18769
18826
|
return this.optionsManager.getOptions();
|
|
18770
18827
|
}
|
|
18828
|
+
diffKeys(obj1, obj2, prefix = '') {
|
|
18829
|
+
const diffs = [];
|
|
18830
|
+
const commonKeys = Object.keys(obj1 || {}).filter(key => obj2 && Object.prototype.hasOwnProperty.call(obj2, key));
|
|
18831
|
+
for (const key of commonKeys) {
|
|
18832
|
+
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
18833
|
+
const val1 = obj1[key];
|
|
18834
|
+
const val2 = obj2[key];
|
|
18835
|
+
if (Array.isArray(val1) && Array.isArray(val2)) {
|
|
18836
|
+
if (val1.length !== val2.length || val1.some((v, i) => v !== val2[i])) {
|
|
18837
|
+
diffs.push(fullKey);
|
|
18838
|
+
}
|
|
18839
|
+
}
|
|
18840
|
+
else if (val1 &&
|
|
18841
|
+
val2 &&
|
|
18842
|
+
typeof val1 === 'object' &&
|
|
18843
|
+
typeof val2 === 'object') {
|
|
18844
|
+
diffs.push(...this.diffKeys(val1, val2, fullKey));
|
|
18845
|
+
}
|
|
18846
|
+
else if (val1 !== val2) {
|
|
18847
|
+
diffs.push(fullKey);
|
|
18848
|
+
}
|
|
18849
|
+
}
|
|
18850
|
+
return diffs;
|
|
18851
|
+
}
|
|
18771
18852
|
async setNewOption(newValue, oldValue = null) {
|
|
18772
18853
|
this.ready = false;
|
|
18773
18854
|
// --------------------------------------- DEPRECATED ?
|
|
@@ -18786,6 +18867,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18786
18867
|
// });
|
|
18787
18868
|
// ---------------------------------------
|
|
18788
18869
|
// this.theOptions = newValue;
|
|
18870
|
+
const savedOldValue = Object.assign({}, this.theOptions);
|
|
18789
18871
|
if (oldValue && JSON.stringify(newValue.options) == JSON.stringify(oldValue.options)) {
|
|
18790
18872
|
this.ready = true;
|
|
18791
18873
|
return;
|
|
@@ -18794,6 +18876,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18794
18876
|
newValue = JSON.parse(newValue);
|
|
18795
18877
|
if (typeof oldValue == 'string')
|
|
18796
18878
|
oldValue = JSON.parse(oldValue);
|
|
18879
|
+
this.value = [];
|
|
18797
18880
|
this.optionsManager.updateOptions(newValue);
|
|
18798
18881
|
this.setDisplayedValue(this.value);
|
|
18799
18882
|
const originOrNodeIdAreDifferent = !oldValue || (newValue.origin != oldValue.origin || newValue.options.StartNodeID != oldValue.options.StartNodeID);
|
|
@@ -18811,11 +18894,29 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18811
18894
|
if (oldValue && JSON.stringify(newValue.options) != JSON.stringify(oldValue.options)) {
|
|
18812
18895
|
this.value = [];
|
|
18813
18896
|
}
|
|
18814
|
-
|
|
18897
|
+
console.log("Setnewoptions 01", newValue, oldValue);
|
|
18898
|
+
if ((newValue === null || newValue === void 0 ? void 0 : newValue.loading) == 'display' || (newValue && !newValue.loading)) {
|
|
18815
18899
|
if ((oldValue && this.isChangeInOptions(newValue, oldValue)) || !oldValue) {
|
|
18816
|
-
|
|
18817
|
-
|
|
18818
|
-
|
|
18900
|
+
if (!oldValue) {
|
|
18901
|
+
oldValue = savedOldValue;
|
|
18902
|
+
}
|
|
18903
|
+
console.log("Setnewoptions 02");
|
|
18904
|
+
const propDiffs = this.diffKeys(oldValue, this.optionsManager.initializeOptions(newValue));
|
|
18905
|
+
const noReloadProps = ["multiple"];
|
|
18906
|
+
console.log("Setnewoptions 03", propDiffs);
|
|
18907
|
+
if (propDiffs.length == 1 && propDiffs.some(item => noReloadProps.includes(item))) {
|
|
18908
|
+
const propChanged = propDiffs[0];
|
|
18909
|
+
switch (propChanged) {
|
|
18910
|
+
case "multiple":
|
|
18911
|
+
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = (this.theOptions.multiple ? 'inline-block' : 'none')));
|
|
18912
|
+
break;
|
|
18913
|
+
}
|
|
18914
|
+
}
|
|
18915
|
+
else {
|
|
18916
|
+
this.rawDataManager = new RawDataManager(this.getOptionsAsIConf(this.optionsManager.getOptions()).token, this.optionsManager);
|
|
18917
|
+
await this.loadHierarchizedPicker(true);
|
|
18918
|
+
this.displayWhenLoaded();
|
|
18919
|
+
}
|
|
18819
18920
|
}
|
|
18820
18921
|
else {
|
|
18821
18922
|
this.ready = true;
|
|
@@ -18869,6 +18970,9 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18869
18970
|
async filterTree(searchedValue) {
|
|
18870
18971
|
this.search(searchedValue);
|
|
18871
18972
|
}
|
|
18973
|
+
async getError() {
|
|
18974
|
+
return Promise.resolve(this.lastErrorMessage);
|
|
18975
|
+
}
|
|
18872
18976
|
constructor() {
|
|
18873
18977
|
super();
|
|
18874
18978
|
this.__registerHost();
|
|
@@ -18876,6 +18980,10 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18876
18980
|
this.itemDropped = createEvent(this, "itemDropped", 7);
|
|
18877
18981
|
this.itemContextMenuItemClick = createEvent(this, "itemContextMenuItemClick", 7);
|
|
18878
18982
|
this.searchResult = createEvent(this, "searchResult", 7);
|
|
18983
|
+
this.navigateInTree = createEvent(this, "navigateInTree", 7);
|
|
18984
|
+
this.errorRaised = createEvent(this, "errorRaised", 7);
|
|
18985
|
+
this.modaleHeight = 200;
|
|
18986
|
+
this.modalePosition = 'bottom';
|
|
18879
18987
|
this.canload = true; // Determines wether the component may be loaded
|
|
18880
18988
|
this.ready = false; // State to determine if all the elements of the component have been loaded
|
|
18881
18989
|
this.searchToDisplay = 0; // Counter to trigger the research on proper time
|
|
@@ -18883,30 +18991,80 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18883
18991
|
this.lastSearchMatchCounter = 0; // Counter of number of matches for last search
|
|
18884
18992
|
this.setValueOnClick = true; // Tells wether we edit the picker value on click in the tree
|
|
18885
18993
|
this.mylog = console.log; // Custom log function for debug purposes
|
|
18994
|
+
this.lastErrorMessage = '';
|
|
18995
|
+
this.scrollToNode = (targetNodeId = null, displayChildren = false) => {
|
|
18996
|
+
var _a;
|
|
18997
|
+
let scrollToValue = 0;
|
|
18998
|
+
let removeClosedAndLookUp = (element, editScroll = false) => {
|
|
18999
|
+
var _a, _b, _c, _d;
|
|
19000
|
+
const nodeId = element === null || element === void 0 ? void 0 : element.nodeId;
|
|
19001
|
+
if (!element || !nodeId) {
|
|
19002
|
+
return;
|
|
19003
|
+
}
|
|
19004
|
+
const node = this.loadedTreeJs.nodesById[nodeId];
|
|
19005
|
+
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) {
|
|
19006
|
+
(_c = element.classList) === null || _c === void 0 ? void 0 : _c.remove('treejs-node__close');
|
|
19007
|
+
}
|
|
19008
|
+
if (editScroll) {
|
|
19009
|
+
scrollToValue += element.offsetTop;
|
|
19010
|
+
}
|
|
19011
|
+
const parent = (_d = element.parentNode) === null || _d === void 0 ? void 0 : _d.closest('.treejs-node');
|
|
19012
|
+
if (parent) {
|
|
19013
|
+
removeClosedAndLookUp(parent, editScroll);
|
|
19014
|
+
}
|
|
19015
|
+
};
|
|
19016
|
+
try {
|
|
19017
|
+
if (targetNodeId) {
|
|
19018
|
+
const targetNode = this.loadedTreeJs.liElementsById[targetNodeId];
|
|
19019
|
+
if (targetNode) {
|
|
19020
|
+
removeClosedAndLookUp(targetNode, true);
|
|
19021
|
+
if (displayChildren && targetNode.classList.contains('treejs-node__close')) {
|
|
19022
|
+
const leftSwitcher = targetNode.querySelector('.treejs-switcher');
|
|
19023
|
+
if (leftSwitcher) {
|
|
19024
|
+
(_a = this.loadedTreeJs) === null || _a === void 0 ? void 0 : _a.onSwitcherClick(leftSwitcher);
|
|
19025
|
+
}
|
|
19026
|
+
}
|
|
19027
|
+
}
|
|
19028
|
+
}
|
|
19029
|
+
else {
|
|
19030
|
+
const checkeds = document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node__checked');
|
|
19031
|
+
checkeds.forEach((item) => removeClosedAndLookUp(item, scrollToValue == 0));
|
|
19032
|
+
}
|
|
19033
|
+
}
|
|
19034
|
+
catch (err) {
|
|
19035
|
+
this.errorToLog = "Error in showSelectedNodes";
|
|
19036
|
+
}
|
|
19037
|
+
if (scrollToValue && this.scrollable) {
|
|
19038
|
+
this.scrollable.scrollTop = scrollToValue;
|
|
19039
|
+
}
|
|
19040
|
+
};
|
|
18886
19041
|
this.getShortenedFullpath = (realFullpath) => {
|
|
18887
19042
|
var _a, _b, _c, _d;
|
|
18888
19043
|
let toret = realFullpath;
|
|
18889
|
-
|
|
18890
|
-
|
|
18891
|
-
|
|
18892
|
-
|
|
18893
|
-
|
|
18894
|
-
|
|
18895
|
-
|
|
18896
|
-
|
|
18897
|
-
|
|
18898
|
-
|
|
18899
|
-
|
|
18900
|
-
|
|
18901
|
-
|
|
18902
|
-
|
|
19044
|
+
const rdmdata = this.rawDataManager.getData();
|
|
19045
|
+
if (rdmdata) {
|
|
19046
|
+
try {
|
|
19047
|
+
const property_nodeid = (this.optionsManager.getOptions().origin == 'classification' ? "startNode" : "StartNodeID");
|
|
19048
|
+
const property_value = this.optionsManager.getOptions().options[property_nodeid];
|
|
19049
|
+
if (property_value in ["0", 0])
|
|
19050
|
+
return toret;
|
|
19051
|
+
if (isNumeric(property_value)) {
|
|
19052
|
+
if (this.optionsManager.getOptions().origin == 'classification') {
|
|
19053
|
+
const { Translations, Properties } = rdmdata;
|
|
19054
|
+
const currentLanguage = this.optionsManager.getOptions().language;
|
|
19055
|
+
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), "");
|
|
19056
|
+
}
|
|
19057
|
+
else {
|
|
19058
|
+
const { fullpath, fullpathTranslated, title, valueTranslated } = rdmdata;
|
|
19059
|
+
toret = (valueTranslated !== null && valueTranslated !== void 0 ? valueTranslated : title) + realFullpath.replace((fullpathTranslated !== null && fullpathTranslated !== void 0 ? fullpathTranslated : fullpath), "");
|
|
19060
|
+
}
|
|
18903
19061
|
}
|
|
19062
|
+
else
|
|
19063
|
+
this.errorToLog = "Error in getFullpath : startnode is not number";
|
|
19064
|
+
}
|
|
19065
|
+
catch (error) {
|
|
19066
|
+
this.errorToLog = "Error in getFullpath " + error.toString();
|
|
18904
19067
|
}
|
|
18905
|
-
else
|
|
18906
|
-
this.errorToLog = "Error in getFullpath : startnode is not number";
|
|
18907
|
-
}
|
|
18908
|
-
catch (error) {
|
|
18909
|
-
this.errorToLog = "Error in getFullpath " + error.toString();
|
|
18910
19068
|
}
|
|
18911
19069
|
return toret;
|
|
18912
19070
|
};
|
|
@@ -18958,7 +19116,6 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
18958
19116
|
}
|
|
18959
19117
|
componentDidLoad() {
|
|
18960
19118
|
this.mylog('----- componentDidLoad beginning -----');
|
|
18961
|
-
setupKeyboardNavigation(this);
|
|
18962
19119
|
focusMainInput();
|
|
18963
19120
|
}
|
|
18964
19121
|
displayWhenLoaded() {
|
|
@@ -19002,6 +19159,8 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19002
19159
|
this.optionsManager.getOptions().openTreeWhenLoaded = false;
|
|
19003
19160
|
if (!this.optionsManager.getOptions().displayRootNode)
|
|
19004
19161
|
this.optionsManager.getOptions().displayRootNode = false;
|
|
19162
|
+
if (!this.optionsManager.getOptions().keyboardNavigation)
|
|
19163
|
+
this.optionsManager.getOptions().keyboardNavigation = false;
|
|
19005
19164
|
if (!this.optionsManager.getOptions().dragAndDropEnabled)
|
|
19006
19165
|
this.optionsManager.getOptions().dragAndDropEnabled = false;
|
|
19007
19166
|
if (!this.optionsManager.getOptions().defaultValueIsFullpath)
|
|
@@ -19041,7 +19200,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19041
19200
|
this.optionsManager.getOptions().defaultValue = defaultFromFullpaths;
|
|
19042
19201
|
}
|
|
19043
19202
|
if (this.optionsManager.getOptions().options) {
|
|
19044
|
-
if (
|
|
19203
|
+
if (this.optionsManager.getOptions().defaultValue.length > 0) {
|
|
19045
19204
|
if (autoAssignReach) {
|
|
19046
19205
|
this.optionsManager.getOptions().options.Reach = this.optionsManager.getOptions().defaultValue.map(element => {
|
|
19047
19206
|
return Number(element);
|
|
@@ -19070,8 +19229,13 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19070
19229
|
// Setup component unique ID
|
|
19071
19230
|
if (this.optionsManager.getOptions().id)
|
|
19072
19231
|
this.componentID = this.optionsManager.getOptions().id;
|
|
19073
|
-
else if (!this.componentID)
|
|
19074
|
-
|
|
19232
|
+
else if (!this.componentID) {
|
|
19233
|
+
let componentID = (Array.from(document.querySelectorAll('reneco-hierarchized-picker')).indexOf(this.el) + 1);
|
|
19234
|
+
while (document.querySelectorAll(`#hierarchized-picker-${componentID}`).length > 0) {
|
|
19235
|
+
componentID++;
|
|
19236
|
+
}
|
|
19237
|
+
this.componentID = componentID.toString();
|
|
19238
|
+
}
|
|
19075
19239
|
if (!this.optionsManager.getOptions())
|
|
19076
19240
|
return;
|
|
19077
19241
|
this.optionsManager.updateDefaultValue();
|
|
@@ -19079,7 +19243,9 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19079
19243
|
this.canload = result.toret;
|
|
19080
19244
|
this.errorToLog = result.errorToLog;
|
|
19081
19245
|
await this.initComponent();
|
|
19082
|
-
|
|
19246
|
+
let defaultPickerThemeForInit = defaultPickerTheme;
|
|
19247
|
+
defaultPickerTheme.modale.height = this.modaleHeight + "px";
|
|
19248
|
+
applyPickerTheme(this.optionsManager.getOptions().theme, defaultPickerThemeForInit);
|
|
19083
19249
|
// Displays option values
|
|
19084
19250
|
this.mylog(this.optionsManager.getOptions());
|
|
19085
19251
|
window.addEventListener('click', (evt) => {
|
|
@@ -19137,7 +19303,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19137
19303
|
this.ignoreOptionsChanges = false;
|
|
19138
19304
|
}
|
|
19139
19305
|
catch (_b) {
|
|
19140
|
-
|
|
19306
|
+
this.errorToLog = 'Error loading webservice data!';
|
|
19141
19307
|
}
|
|
19142
19308
|
}
|
|
19143
19309
|
displayPickerError(errorMsg = '') {
|
|
@@ -19149,11 +19315,11 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19149
19315
|
}
|
|
19150
19316
|
this.displayedValue = errorMsg;
|
|
19151
19317
|
this.isDisabled = true;
|
|
19152
|
-
|
|
19318
|
+
this.errorToLog = errorMsg;
|
|
19153
19319
|
}
|
|
19154
19320
|
}
|
|
19155
19321
|
catch (_a) {
|
|
19156
|
-
|
|
19322
|
+
this.errorToLog = errorMsg;
|
|
19157
19323
|
}
|
|
19158
19324
|
}
|
|
19159
19325
|
getApiSearchURL() {
|
|
@@ -19173,17 +19339,17 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19173
19339
|
}
|
|
19174
19340
|
}
|
|
19175
19341
|
// TODO > Celine would rather like the context (thesaurus or position) to be extracted another way
|
|
19176
|
-
getContextualApiURL(init = false) {
|
|
19177
|
-
const { options, url } = this.optionsManager.getOptions();
|
|
19342
|
+
getContextualApiURL(init = false, forcedOptions = null) {
|
|
19343
|
+
const { options, url } = forcedOptions || this.optionsManager.getOptions();
|
|
19178
19344
|
if (init && options.Reach) {
|
|
19179
|
-
|
|
19180
|
-
const base = window.location.origin; // fallback for relative URLs
|
|
19345
|
+
const base = window.location.origin;
|
|
19181
19346
|
const parsedUrl = new URL(url, base);
|
|
19182
|
-
const pathSegments = parsedUrl.pathname.split('/');
|
|
19183
|
-
|
|
19184
|
-
if (
|
|
19185
|
-
|
|
19186
|
-
|
|
19347
|
+
const pathSegments = parsedUrl.pathname.split('/').filter(Boolean);
|
|
19348
|
+
const idx = pathSegments.indexOf("getTree");
|
|
19349
|
+
if (idx !== -1) {
|
|
19350
|
+
pathSegments[idx] = "reach";
|
|
19351
|
+
}
|
|
19352
|
+
const newPathname = "/" + pathSegments.join("/");
|
|
19187
19353
|
return `${parsedUrl.origin}${newPathname}`;
|
|
19188
19354
|
}
|
|
19189
19355
|
return url;
|
|
@@ -19195,7 +19361,6 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19195
19361
|
if (!init)
|
|
19196
19362
|
delete optionsToReturn.Reach;
|
|
19197
19363
|
if (optionsToReturn.Reach) {
|
|
19198
|
-
delete optionsToReturn.Reach;
|
|
19199
19364
|
if ("startNode" in optionsToReturn) {
|
|
19200
19365
|
optionsToReturn.startingnode = optionsToReturn.startNode;
|
|
19201
19366
|
delete optionsToReturn.startNode;
|
|
@@ -19255,7 +19420,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19255
19420
|
}
|
|
19256
19421
|
})
|
|
19257
19422
|
.catch(err => {
|
|
19258
|
-
|
|
19423
|
+
this.errorToLog = err;
|
|
19259
19424
|
});
|
|
19260
19425
|
}
|
|
19261
19426
|
else {
|
|
@@ -19274,12 +19439,12 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19274
19439
|
}
|
|
19275
19440
|
})
|
|
19276
19441
|
.catch(error => {
|
|
19277
|
-
|
|
19442
|
+
this.errorToLog = error;
|
|
19278
19443
|
try {
|
|
19279
19444
|
this.errorToLog = 'getDataFromSource 1 rejected:' + JSON.stringify(error, replacer, 2);
|
|
19280
19445
|
}
|
|
19281
19446
|
catch (_a) {
|
|
19282
|
-
|
|
19447
|
+
this.errorToLog = JSON.stringify(error, replacer, 2);
|
|
19283
19448
|
}
|
|
19284
19449
|
});
|
|
19285
19450
|
}
|
|
@@ -19360,9 +19525,11 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19360
19525
|
this.ignoreOptionsChanges = false;
|
|
19361
19526
|
},
|
|
19362
19527
|
});
|
|
19363
|
-
|
|
19364
|
-
|
|
19365
|
-
|
|
19528
|
+
if (this.searchResultData.length == 0) {
|
|
19529
|
+
Object.values(myTree.liElementsById).forEach((el) => {
|
|
19530
|
+
el.classList.remove('treejs-node__searchmatch');
|
|
19531
|
+
});
|
|
19532
|
+
}
|
|
19366
19533
|
this.loadedTreeJs = myTree;
|
|
19367
19534
|
this.collapseAllNodes();
|
|
19368
19535
|
// TODO Make something that makes sense, this is a temporary quick fix :
|
|
@@ -19376,21 +19543,44 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19376
19543
|
this.showSelectedNodes();
|
|
19377
19544
|
this.deactivateNodesOutOfDepthSettings();
|
|
19378
19545
|
// Hides checkboxes in non multiple context
|
|
19379
|
-
|
|
19380
|
-
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = 'none'));
|
|
19381
|
-
}
|
|
19546
|
+
document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-checkbox').forEach((item) => (item.style.display = (this.theOptions.multiple ? 'inline-block' : 'none')));
|
|
19382
19547
|
}
|
|
19383
19548
|
onItemContextMenuItemClick(e) {
|
|
19549
|
+
if (e.target && e.target.id) {
|
|
19550
|
+
function getDirectParentAndDepth(nodesById, targetId) {
|
|
19551
|
+
// Find the direct parent
|
|
19552
|
+
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;
|
|
19553
|
+
if (!nodesById[targetId])
|
|
19554
|
+
return null; // target not found
|
|
19555
|
+
// Depth is 0 for root nodes, 1 for children of root, etc.
|
|
19556
|
+
let depth = 0;
|
|
19557
|
+
let current = targetId;
|
|
19558
|
+
while (true) {
|
|
19559
|
+
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); });
|
|
19560
|
+
if (!directParent)
|
|
19561
|
+
break;
|
|
19562
|
+
depth++;
|
|
19563
|
+
current = directParent.id;
|
|
19564
|
+
}
|
|
19565
|
+
return { parent, depth };
|
|
19566
|
+
}
|
|
19567
|
+
const result = getDirectParentAndDepth(this.loadedTreeJs.nodesById, e.target.id);
|
|
19568
|
+
e.target.depth = result.depth;
|
|
19569
|
+
e.target.parentId = result.parent.id;
|
|
19570
|
+
}
|
|
19384
19571
|
this.itemContextMenuItemClick.emit(e);
|
|
19385
19572
|
}
|
|
19386
19573
|
setNodeAsSelected(id, treeToUpdate, userClick) {
|
|
19574
|
+
console.log("setNodeAsSelected", id);
|
|
19387
19575
|
// TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
|
|
19388
19576
|
if (((this.isDisabled && this.optionsManager.getOptions().mode != "tree") && this.shownTree && this.setValueOnClick) ||
|
|
19389
19577
|
(this.loadedTreeJs.liElementsById[id] && this.loadedTreeJs.liElementsById[id].classList.value && this.loadedTreeJs.liElementsById[id].classList.value.indexOf('readonly_node') != -1)) {
|
|
19390
19578
|
return;
|
|
19391
19579
|
}
|
|
19392
|
-
if (treeToUpdate.getValues().indexOf(id.toString()) != -1)
|
|
19580
|
+
if (!userClick && treeToUpdate.getValues().indexOf(id.toString()) != -1)
|
|
19393
19581
|
return;
|
|
19582
|
+
if (this.loadedTreeJs && !this.theOptions.multiple)
|
|
19583
|
+
this.loadedTreeJs.emptyNodesCheckStatus();
|
|
19394
19584
|
this.ignoreOptionsChanges = true;
|
|
19395
19585
|
// Override of treejs normal workaround =>> DONT EDIT IT!
|
|
19396
19586
|
// ----- BEGIN -----
|
|
@@ -19427,46 +19617,29 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19427
19617
|
* This method display the current selected node to the user by expanding all it's parent nodes and scrolling inside the tree
|
|
19428
19618
|
*/
|
|
19429
19619
|
async showSelectedNodes(addDelay = false) {
|
|
19430
|
-
if (this.optionsManager.getOptions().multiple) {
|
|
19431
|
-
|
|
19432
|
-
|
|
19433
|
-
}
|
|
19434
|
-
const scrollToNode = () => {
|
|
19435
|
-
let scrollToValue = 0;
|
|
19436
|
-
let removeClosedAndLookUp = (element) => {
|
|
19437
|
-
var _a, _b, _c, _d;
|
|
19438
|
-
const nodeId = element === null || element === void 0 ? void 0 : element.nodeId;
|
|
19439
|
-
if (!element || !nodeId) {
|
|
19440
|
-
return;
|
|
19441
|
-
}
|
|
19442
|
-
const node = this.loadedTreeJs.nodesById[nodeId];
|
|
19443
|
-
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) {
|
|
19444
|
-
(_c = element.classList) === null || _c === void 0 ? void 0 : _c.remove('treejs-node__close');
|
|
19445
|
-
}
|
|
19446
|
-
scrollToValue += element.offsetTop;
|
|
19447
|
-
const parent = (_d = element.parentNode) === null || _d === void 0 ? void 0 : _d.closest('.treejs-node');
|
|
19448
|
-
if (parent) {
|
|
19449
|
-
removeClosedAndLookUp(parent);
|
|
19450
|
-
}
|
|
19451
|
-
};
|
|
19452
|
-
try {
|
|
19453
|
-
const checkeds = document.querySelectorAll('#tree-area-' + this.componentID + ' .treejs-node__checked');
|
|
19454
|
-
checkeds.forEach((item) => removeClosedAndLookUp(item));
|
|
19455
|
-
}
|
|
19456
|
-
catch (err) {
|
|
19457
|
-
// console.error("Error in showSelectedNodes", err);
|
|
19458
|
-
}
|
|
19459
|
-
if (scrollToValue && this.scrollable) {
|
|
19460
|
-
this.scrollable.scrollTop = scrollToValue;
|
|
19461
|
-
}
|
|
19462
|
-
};
|
|
19620
|
+
// if (this.optionsManager.getOptions().multiple) {
|
|
19621
|
+
// console.warn('You are not allowed to scroll to selected nodes in multiple mode');
|
|
19622
|
+
// return;
|
|
19623
|
+
// }
|
|
19463
19624
|
if (addDelay) {
|
|
19464
19625
|
setTimeout(() => {
|
|
19465
|
-
scrollToNode();
|
|
19626
|
+
this.scrollToNode();
|
|
19466
19627
|
}, 200);
|
|
19467
19628
|
}
|
|
19468
19629
|
else {
|
|
19469
|
-
scrollToNode();
|
|
19630
|
+
this.scrollToNode();
|
|
19631
|
+
}
|
|
19632
|
+
}
|
|
19633
|
+
async scrollToNodeWithId(targetNodeId, displayChildren = false) {
|
|
19634
|
+
const targetNode = this.loadedTreeJs.liElementsById[targetNodeId];
|
|
19635
|
+
if (!targetNode) {
|
|
19636
|
+
const contextualApiParams = this.getContextualApiParams(Object.assign(Object.assign({}, this.theOptions.options), { Reach: [targetNodeId] }), null, true);
|
|
19637
|
+
const contextualApiURL = this.getContextualApiURL(true, Object.assign(Object.assign({}, this.theOptions), { options: contextualApiParams }));
|
|
19638
|
+
this.rawDataManager.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.componentID + " .loader"))
|
|
19639
|
+
.then(data => {
|
|
19640
|
+
completeCurrentTreeWithTree(this.loadedTreeJs, data, this.theOptions);
|
|
19641
|
+
this.scrollToNode(targetNodeId, displayChildren);
|
|
19642
|
+
});
|
|
19470
19643
|
}
|
|
19471
19644
|
}
|
|
19472
19645
|
showTree(focused) {
|
|
@@ -19478,7 +19651,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19478
19651
|
const isStillInsidePicker = isInsidePicker(this, document.activeElement);
|
|
19479
19652
|
if ((focused === 'hide' || this.isDisabled) && !isStillInsidePicker) {
|
|
19480
19653
|
this.hasFocus = ['hide'];
|
|
19481
|
-
const elem = document.querySelector('#hierarchized-picker-' + this.componentID + ' .hierarchized-picker-search
|
|
19654
|
+
const elem = document.querySelector('#hierarchized-picker-' + this.componentID + ' input.hierarchized-picker-search');
|
|
19482
19655
|
if (elem) {
|
|
19483
19656
|
elem.value = '';
|
|
19484
19657
|
}
|
|
@@ -19499,8 +19672,16 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19499
19672
|
}
|
|
19500
19673
|
const previousShownTree = this.shownTree;
|
|
19501
19674
|
this.shownTree = this.hasFocus.length > 0;
|
|
19502
|
-
if (this.shownTree && !previousShownTree) {
|
|
19503
|
-
|
|
19675
|
+
if (this.shownTree && !previousShownTree && this.optionsManager.getOptions().mode == 'input') {
|
|
19676
|
+
if (this.shouldOpenModalAbove(document.querySelector('#hierarchized-picker-input-' + this.componentID), this.modaleHeight)) {
|
|
19677
|
+
this.modalePosition = 'top';
|
|
19678
|
+
}
|
|
19679
|
+
else {
|
|
19680
|
+
this.modalePosition = 'bottom';
|
|
19681
|
+
}
|
|
19682
|
+
setTimeout(() => focusSearchInput(this), 100);
|
|
19683
|
+
//TODO, this this at the good location ?
|
|
19684
|
+
setupKeyboardNavigation(this, this.optionsManager, this.navigateInTree);
|
|
19504
19685
|
}
|
|
19505
19686
|
}
|
|
19506
19687
|
// Changes the value of the component with passed node
|
|
@@ -19513,9 +19694,12 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19513
19694
|
return item.nodeid == node.id;
|
|
19514
19695
|
});
|
|
19515
19696
|
// If the passed node already exists in the array of values, remove it
|
|
19516
|
-
if (
|
|
19517
|
-
|
|
19518
|
-
|
|
19697
|
+
if (result > -1) {
|
|
19698
|
+
if (userClick)
|
|
19699
|
+
this.value.splice(result, 1);
|
|
19700
|
+
else
|
|
19701
|
+
return;
|
|
19702
|
+
}
|
|
19519
19703
|
else {
|
|
19520
19704
|
if (this.optionsManager.getOptions().multiple) {
|
|
19521
19705
|
this.value = [
|
|
@@ -19544,10 +19728,11 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19544
19728
|
setDisplayedValue(value = null) {
|
|
19545
19729
|
if (!value)
|
|
19546
19730
|
value = this.value;
|
|
19547
|
-
|
|
19731
|
+
const toDisplay = value.map(item => {
|
|
19548
19732
|
var _a, _b;
|
|
19549
19733
|
return (_b = (this.optionsManager.getOptions().isFullpath ? this.getShortenedFullpath((_a = item.fullpathTranslated) !== null && _a !== void 0 ? _a : item.fullpath) : item.shortpathTranslated)) !== null && _b !== void 0 ? _b : `Node ${item.nodeid}`;
|
|
19550
19734
|
}).join(';');
|
|
19735
|
+
this.displayedValue = toDisplay;
|
|
19551
19736
|
}
|
|
19552
19737
|
// Search a value in the tree and triggers a search when necessary
|
|
19553
19738
|
search(searched) {
|
|
@@ -19614,10 +19799,11 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19614
19799
|
if (init) {
|
|
19615
19800
|
this.formatDefaultValue();
|
|
19616
19801
|
this.showSelectedNodes();
|
|
19802
|
+
this.checkFields(this.value);
|
|
19617
19803
|
}
|
|
19618
19804
|
})
|
|
19619
19805
|
.catch(error => {
|
|
19620
|
-
|
|
19806
|
+
this.errorToLog = error;
|
|
19621
19807
|
});
|
|
19622
19808
|
}
|
|
19623
19809
|
else {
|
|
@@ -19630,7 +19816,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19630
19816
|
}
|
|
19631
19817
|
})
|
|
19632
19818
|
.catch(error => {
|
|
19633
|
-
|
|
19819
|
+
this.errorToLog = error;
|
|
19634
19820
|
});
|
|
19635
19821
|
}
|
|
19636
19822
|
}
|
|
@@ -19645,13 +19831,14 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19645
19831
|
this.translateDataForTree(this.rawDataManager.getData());
|
|
19646
19832
|
}
|
|
19647
19833
|
checkFields(values, allowSetValueOnClick = true) {
|
|
19834
|
+
console.log("checkFields", values);
|
|
19648
19835
|
if (!this.loadedTreeJs)
|
|
19649
19836
|
return;
|
|
19650
19837
|
this.setValueOnClick = allowSetValueOnClick;
|
|
19651
19838
|
let enrichedValues = [];
|
|
19652
19839
|
if (values) {
|
|
19653
19840
|
values.forEach(element => {
|
|
19654
|
-
var _a, _b;
|
|
19841
|
+
var _a, _b, _c;
|
|
19655
19842
|
let intNodeid = element.nodeid || element.ID || element.key || undefined;
|
|
19656
19843
|
if (typeof intNodeid === 'string' && isNumeric(intNodeid)) {
|
|
19657
19844
|
intNodeid = parseInt(intNodeid);
|
|
@@ -19661,15 +19848,15 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19661
19848
|
enrichedValues.push({
|
|
19662
19849
|
nodeid: intNodeid,
|
|
19663
19850
|
shortpathTranslated: (_a = treeNode.text) !== null && _a !== void 0 ? _a : `Node ${intNodeid}`,
|
|
19664
|
-
fullpathTranslated: (_b = treeNode.
|
|
19851
|
+
fullpathTranslated: (_b = treeNode.fullpathTranslated) !== null && _b !== void 0 ? _b : null,
|
|
19852
|
+
fullpath: (_c = treeNode.fullpath) !== null && _c !== void 0 ? _c : null,
|
|
19665
19853
|
hasChildren: treeNode.children && treeNode.children.length > 0
|
|
19666
19854
|
});
|
|
19667
|
-
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
19668
19855
|
}
|
|
19669
19856
|
else {
|
|
19670
|
-
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
19671
19857
|
console.warn("Node not found in Tree for:", intNodeid);
|
|
19672
19858
|
}
|
|
19859
|
+
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
19673
19860
|
});
|
|
19674
19861
|
}
|
|
19675
19862
|
this.setDisplayedValue(enrichedValues);
|
|
@@ -19679,8 +19866,19 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19679
19866
|
formatDefaultValue() {
|
|
19680
19867
|
let found = 0;
|
|
19681
19868
|
let that = this;
|
|
19869
|
+
let fieldsToCheck = [];
|
|
19870
|
+
function addToFieldsToCheck(item) {
|
|
19871
|
+
if (Array.isArray(item)) {
|
|
19872
|
+
item.forEach(el => addToFieldsToCheck(el));
|
|
19873
|
+
}
|
|
19874
|
+
else {
|
|
19875
|
+
const exists = fieldsToCheck.some(el => (el.nodeid || el.ID) == (item.nodeid || item.ID));
|
|
19876
|
+
if (!exists) {
|
|
19877
|
+
fieldsToCheck.push(item);
|
|
19878
|
+
}
|
|
19879
|
+
}
|
|
19880
|
+
}
|
|
19682
19881
|
let recursive = function (children) {
|
|
19683
|
-
//158424
|
|
19684
19882
|
children.forEach(element => {
|
|
19685
19883
|
that.theOptions.defaultValue.forEach(dfValue => {
|
|
19686
19884
|
if (typeof dfValue == 'string' && isNumeric(dfValue)) {
|
|
@@ -19690,7 +19888,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19690
19888
|
if ((typeof dfValue == 'string' && getPropertyFromNode(element, 'Properties').FullPath == dfValue) ||
|
|
19691
19889
|
(typeof dfValue == 'number' && getPropertyFromNode(element, 'ID') == dfValue)) {
|
|
19692
19890
|
element.nodeid = element.id;
|
|
19693
|
-
|
|
19891
|
+
addToFieldsToCheck([element]);
|
|
19694
19892
|
found++;
|
|
19695
19893
|
}
|
|
19696
19894
|
}
|
|
@@ -19700,7 +19898,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19700
19898
|
(typeof dfValue == 'string' && getPropertyFromNode(element, 'fullpathTranslated') == dfValue) ||
|
|
19701
19899
|
(typeof dfValue == 'number' && getPropertyFromNode(element, 'key') == dfValue)) {
|
|
19702
19900
|
element.nodeid = element.key;
|
|
19703
|
-
|
|
19901
|
+
addToFieldsToCheck([element]);
|
|
19704
19902
|
found++;
|
|
19705
19903
|
}
|
|
19706
19904
|
}
|
|
@@ -19712,6 +19910,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19712
19910
|
if (this.rawDataManager.getData()) {
|
|
19713
19911
|
recursive([this.rawDataManager.getData()]);
|
|
19714
19912
|
}
|
|
19913
|
+
that.checkFields(fieldsToCheck);
|
|
19715
19914
|
if (this.theOptions.defaultValue.length != found) {
|
|
19716
19915
|
if (found == 0) {
|
|
19717
19916
|
try {
|
|
@@ -19736,6 +19935,13 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19736
19935
|
.map(item => { var _a, _b; return (_b = (_a = this.getShortenedFullpath(item.fullpathTranslated)) !== null && _a !== void 0 ? _a : item.fullpath) !== null && _b !== void 0 ? _b : `Node ${item.nodeid}`; })
|
|
19737
19936
|
.join('; ');
|
|
19738
19937
|
}
|
|
19938
|
+
shouldOpenModalAbove(inputElement, modaleHeight) {
|
|
19939
|
+
if (this.optionsManager.getOptions().mode != 'input')
|
|
19940
|
+
return false;
|
|
19941
|
+
const inputRect = inputElement.getBoundingClientRect();
|
|
19942
|
+
const spaceLeft = window.innerHeight - inputRect.y;
|
|
19943
|
+
return spaceLeft < modaleHeight;
|
|
19944
|
+
}
|
|
19739
19945
|
render() {
|
|
19740
19946
|
return this.optionsManager.getOptions() ? (h("div", { id: 'hierarchized-picker-' + this.componentID, class: 'hierarchized-picker ' + (this.isDisabled ? 'readonly-mode' : '') }, this.optionsManager.getOptions().mode == 'input' ? (h("div", { class: "hierarchized-picker-container" }, h("div", { style: { display: 'none' }, ref: el => {
|
|
19741
19947
|
this.loader = el;
|
|
@@ -19751,11 +19957,11 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19751
19957
|
} }, h("input", { class: "native-input sc-ion-input-md", "aria-labelledby": "ion-input-13-lbl", autocapitalize: "off", autocomplete: "off", autocorrect: "off", name: "ion-input-13", placeholder: "", readonly: "", spellcheck: "false", type: "text", value: this.displayedValue, title: this.getFullpathTooltip() })), this.displayedValue && !this.isDisabled && this.canload ? h("span", { class: "reneco reneco-close", onClick: () => this.clearPicker() }) : ''), h("div", { ref: el => {
|
|
19752
19958
|
// Uncomment if you want the modale of picker in input mode to scroll to selected node on openning >>>
|
|
19753
19959
|
this.scrollable = el;
|
|
19754
|
-
}, class:
|
|
19960
|
+
}, class: `hierarchized-picker-modal-area ${!this.shownTree ? ' hidden ' : ''} ${this.modalePosition == 'top' ? "display-modale-top" : ""}`, onClick: event => {
|
|
19755
19961
|
clickPickerModalArea(this);
|
|
19756
19962
|
} }, h("div", { class: "loader", ref: el => {
|
|
19757
19963
|
this.loader = el;
|
|
19758
|
-
} }, h("div", { class: "loader-inner" }, "Loading...")), h("div", { class:
|
|
19964
|
+
} }, h("div", { class: "loader-inner" }, "Loading...")), h("div", { class: `hierarchized-picker-modal ${!this.ready ? 'hidden' : ''}`, tabindex: "" + this.componentID }, h("search-input", { placeholder: getLanguageValue(this.optionsManager.getOptions().searchPlaceholder, this.optionsManager.getOptions().language, defaultLanguage), onInputFocus: () => focusInSearchEvent(this), onInputBlur: () => focusOutSearchEvent(this, event), onSearch: (event) => this.search(event.detail) }), h("ul", { id: "autocomplete-results-area" }), h("div", { id: 'tree-area-' + this.componentID, class: 'hierarchized-picker-tree hierarchized-picker-tree-area ' + this.pickerClass }))))) : (h("div", { class: 'hierarchized-picker-raw-tree-area' + (this.isDisabled ? ' readonly' : ''), tabindex: "" + this.componentID, onClick: event => {
|
|
19759
19965
|
clickPickerModalArea(this);
|
|
19760
19966
|
} }, h("div", { class: "loader", ref: el => {
|
|
19761
19967
|
this.loader = el;
|
|
@@ -19775,7 +19981,7 @@ const HierarchizedPickerComponent = class extends HTMLElement {
|
|
|
19775
19981
|
static get style() { return hierarchizedPickerCss; }
|
|
19776
19982
|
};
|
|
19777
19983
|
|
|
19778
|
-
const searchInputCss = ".search-input-container{
|
|
19984
|
+
const searchInputCss = ".search-input-container{display:-ms-flexbox;display:flex;gap:8px;margin-top:10px}.search-input-container .reneco-search{margin-top:3px}.search-input-container input{border-radius:4px;padding:5px}.search-input{width:100%;border:none}.search-input:focus{border:none !important;outline:none !important;-webkit-box-shadow:none !important;box-shadow:none !important}reneco-hierarchized-picker .hierarchized-picker-input-area .input-wrapper{padding-left:10px !important}reneco-hierarchized-picker .hierarchized-picker-input input,reneco-hierarchized-picker .hierarchized-picker-search input{font-size:var(--hpicker-theme-typography-body-font-size, var(--mui-typography-body-font-size, 14px)) !important;font-weight:var(--hpicker-theme-typography-body-font-weight, var(--mui-typography-body-font-weight, 400)) !important}reneco-hierarchized-picker .hierarchized-picker-search input{color:var(--hpicker-theme-palette-font-color, var(--mui-palette-font-color, var(--ion-color-light-tint, #fff))) !important}reneco-hierarchized-picker #searchInTree{padding:8.5px 8px;background:var(--hpicker-theme-palette-background-default, var(--mui-palette-background-default, var(--ion-color-background, rgba(221, 169, 37, 0.18))));border:none !important;border-radius:4px}reneco-hierarchized-picker #searchInTree:focus{border:none !important;outline:none !important;-webkit-box-shadow:none !important;box-shadow:none !important}";
|
|
19779
19985
|
|
|
19780
19986
|
const SearchInput$1 = class extends HTMLElement {
|
|
19781
19987
|
constructor() {
|
|
@@ -19812,9 +20018,9 @@ const SearchInput$1 = class extends HTMLElement {
|
|
|
19812
20018
|
}
|
|
19813
20019
|
}
|
|
19814
20020
|
render() {
|
|
19815
|
-
return (h("div", { id: "hierarchized-picker-input-search
|
|
20021
|
+
return (h("div", { id: "hierarchized-picker-input-search",
|
|
19816
20022
|
// TODO: need component ID ?
|
|
19817
|
-
class: "search-input-container
|
|
20023
|
+
class: "search-input-container", ref: (el) => (this.rootElement = el) }, h("div", { class: "reneco reneco-search" }), h("input", { ref: (el) => (this.inputElement = el), type: "text", class: "native-input sc-ion-input-md-h sc-ion-input-md-s md search-input hierarchized-picker-search", placeholder: this.placeholder, onFocus: () => this.handleFocus(), onBlur: (event) => this.handleBlur(event), onInput: (event) => this.handleInput(event) })));
|
|
19818
20024
|
}
|
|
19819
20025
|
static get style() { return searchInputCss; }
|
|
19820
20026
|
};
|