reneco-hierarchized-picker 0.4.3-beta.19 → 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 +54 -28
- package/dist/collection/components/hierarchized-picker/hierarchized-picker.js +73 -20
- package/dist/collection/components/treejs/index.js +1 -2
- package/dist/collection/features/keyboard-navigation/keyboard-navigation.js +10 -6
- package/dist/custom-elements/index.js +54 -28
- 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 +54 -28
- 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 +1 -1
- 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 +6 -0
- package/dist/types/components.d.ts +5 -0
- package/package.json +1 -1
- package/dist/reneco-hierarchized-picker/p-711d3319.entry.js +0 -1
- package/dist/reneco-hierarchized-picker/p-c45cf4da.system.entry.js +0 -3
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["reneco-hierarchized-picker_2.cjs",[[0,"reneco-hierarchized-picker",{"options":[1],"valueChangeCallback":[16],"disabled":[4],"newoptions":[1],"newfilter":[1],"activatedDragAndDrop":[4,"activated-drag-and-drop"],"isDisabled":[32],"componentID":[32],"rawData":[32],"pickerClass":[32],"displayedValue":[32],"value":[32],"shownTree":[32],"searchResultData":[32],"hasFocus":[32],"errorToLog":[32],"getValue":[64],"refreshPicker":[64],"setOptions":[64],"getSearchResult":[64],"filterTree":[64],"clearPicker":[64],"showSelectedNodes":[64],"scrollToNodeWithId":[64]}],[0,"search-input",{"placeholder":[1],"setFocus":[64]}]]]], options);
|
|
17
|
+
return index.bootstrapLazy([["reneco-hierarchized-picker_2.cjs",[[0,"reneco-hierarchized-picker",{"options":[1],"valueChangeCallback":[16],"disabled":[4],"newoptions":[1],"newfilter":[1],"activatedDragAndDrop":[4,"activated-drag-and-drop"],"isDisabled":[32],"componentID":[32],"rawData":[32],"pickerClass":[32],"displayedValue":[32],"value":[32],"shownTree":[32],"searchResultData":[32],"hasFocus":[32],"errorToLog":[32],"getValue":[64],"refreshPicker":[64],"setOptions":[64],"getSearchResult":[64],"filterTree":[64],"getError":[64],"clearPicker":[64],"showSelectedNodes":[64],"scrollToNodeWithId":[64]}],[0,"search-input",{"placeholder":[1],"setFocus":[64]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -17,7 +17,7 @@ const patchBrowser = () => {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
patchBrowser().then(options => {
|
|
20
|
-
return index.bootstrapLazy([["reneco-hierarchized-picker_2.cjs",[[0,"reneco-hierarchized-picker",{"options":[1],"valueChangeCallback":[16],"disabled":[4],"newoptions":[1],"newfilter":[1],"activatedDragAndDrop":[4,"activated-drag-and-drop"],"isDisabled":[32],"componentID":[32],"rawData":[32],"pickerClass":[32],"displayedValue":[32],"value":[32],"shownTree":[32],"searchResultData":[32],"hasFocus":[32],"errorToLog":[32],"getValue":[64],"refreshPicker":[64],"setOptions":[64],"getSearchResult":[64],"filterTree":[64],"clearPicker":[64],"showSelectedNodes":[64],"scrollToNodeWithId":[64]}],[0,"search-input",{"placeholder":[1],"setFocus":[64]}]]]], options);
|
|
20
|
+
return index.bootstrapLazy([["reneco-hierarchized-picker_2.cjs",[[0,"reneco-hierarchized-picker",{"options":[1],"valueChangeCallback":[16],"disabled":[4],"newoptions":[1],"newfilter":[1],"activatedDragAndDrop":[4,"activated-drag-and-drop"],"isDisabled":[32],"componentID":[32],"rawData":[32],"pickerClass":[32],"displayedValue":[32],"value":[32],"shownTree":[32],"searchResultData":[32],"hasFocus":[32],"errorToLog":[32],"getValue":[64],"refreshPicker":[64],"setOptions":[64],"getSearchResult":[64],"filterTree":[64],"getError":[64],"clearPicker":[64],"showSelectedNodes":[64],"scrollToNodeWithId":[64]}],[0,"search-input",{"placeholder":[1],"setFocus":[64]}]]]], options);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
exports.setNonce = index.setNonce;
|
|
@@ -328,12 +328,11 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
328
328
|
};
|
|
329
329
|
Tree.prototype.onItemClick = async function (id, rightclick = false) {
|
|
330
330
|
// TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
|
|
331
|
+
console.log("coucou");
|
|
331
332
|
if (this.options.parentApi.isDisabled && this.options.parentApi.optionsManager.getOptions().mode != "tree")
|
|
332
333
|
return;
|
|
333
334
|
const pickerValue = await this.options.parentApi.getValue();
|
|
334
335
|
if (!rightclick || !pickerValue || pickerValue.nodeid != id) {
|
|
335
|
-
if (!this.options.parentApi.theOptions.multiple)
|
|
336
|
-
this.emptyNodesCheckStatus();
|
|
337
336
|
this.options.parentApi.setNodeAsSelected(id, this, true);
|
|
338
337
|
}
|
|
339
338
|
};
|
|
@@ -18633,17 +18632,21 @@ function setupKeyboardNavigation(component, optionsManager, navigateInTree) {
|
|
|
18633
18632
|
component._keydownListenerAdded = true;
|
|
18634
18633
|
component.el.addEventListener('keydown', (event) => {
|
|
18635
18634
|
var _a, _b;
|
|
18635
|
+
console.log("Navigation 01", event);
|
|
18636
18636
|
event.stopPropagation();
|
|
18637
|
+
console.log("Navigation 02");
|
|
18637
18638
|
const tree = component.loadedTreeJs;
|
|
18638
18639
|
let treeNodesFromTree = findAllTreeNodes(tree.treeNodes, tree.liElementsById);
|
|
18640
|
+
console.log("Navigation 03");
|
|
18639
18641
|
if (!tree || !treeNodesFromTree.length)
|
|
18640
18642
|
return;
|
|
18641
18643
|
let spaceNode = treeNodesFromTree[focusedNodeIndex];
|
|
18642
18644
|
let activeNode = treeNodesFromTree[focusedNodeIndex];
|
|
18643
18645
|
let liElement = tree.liElementsById[activeNode.id];
|
|
18644
18646
|
const handledEvents = ['tab', '0', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright'];
|
|
18645
|
-
|
|
18646
|
-
|
|
18647
|
+
console.log("Navigation 04", event.key);
|
|
18648
|
+
switch (event.key.toLowerCase()) {
|
|
18649
|
+
case 'tab':
|
|
18647
18650
|
case '0':
|
|
18648
18651
|
event.preventDefault();
|
|
18649
18652
|
{ //(spaceNode?.nodeId) {
|
|
@@ -18652,7 +18655,7 @@ function setupKeyboardNavigation(component, optionsManager, navigateInTree) {
|
|
|
18652
18655
|
setTimeout(() => focusMainInput(), 100);
|
|
18653
18656
|
}
|
|
18654
18657
|
break;
|
|
18655
|
-
case '
|
|
18658
|
+
case 'arrowup':
|
|
18656
18659
|
event.preventDefault();
|
|
18657
18660
|
focusedNodeIndex = Math.max(focusedNodeIndex - 1, 0);
|
|
18658
18661
|
const newActiveNodeUp = treeNodesFromTree[focusedNodeIndex];
|
|
@@ -18660,7 +18663,7 @@ function setupKeyboardNavigation(component, optionsManager, navigateInTree) {
|
|
|
18660
18663
|
newLiElementUp.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
18661
18664
|
focusNode(tree.liElementsById, newLiElementUp);
|
|
18662
18665
|
break;
|
|
18663
|
-
case '
|
|
18666
|
+
case 'arrowdown':
|
|
18664
18667
|
event.preventDefault();
|
|
18665
18668
|
focusedNodeIndex = Math.min(focusedNodeIndex + 1, treeNodesFromTree.length - 1);
|
|
18666
18669
|
const newActiveNodeDown = treeNodesFromTree[focusedNodeIndex];
|
|
@@ -18668,14 +18671,14 @@ function setupKeyboardNavigation(component, optionsManager, navigateInTree) {
|
|
|
18668
18671
|
focusNode(tree.liElementsById, newLiElementDown);
|
|
18669
18672
|
newLiElementDown.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
18670
18673
|
break;
|
|
18671
|
-
case '
|
|
18674
|
+
case 'arrowleft':
|
|
18672
18675
|
event.preventDefault();
|
|
18673
18676
|
const leftSwitcher = liElement.querySelector('.treejs-switcher');
|
|
18674
18677
|
if (leftSwitcher) {
|
|
18675
18678
|
(_a = component.loadedTreeJs) === null || _a === void 0 ? void 0 : _a.onSwitcherClick(leftSwitcher);
|
|
18676
18679
|
}
|
|
18677
18680
|
break;
|
|
18678
|
-
case '
|
|
18681
|
+
case 'arrowright':
|
|
18679
18682
|
event.preventDefault();
|
|
18680
18683
|
const rightSwitcher = liElement.querySelector('.treejs-switcher');
|
|
18681
18684
|
if (rightSwitcher) {
|
|
@@ -18813,27 +18816,37 @@ const HierarchizedPickerComponent = class {
|
|
|
18813
18816
|
logError(messageToLog) {
|
|
18814
18817
|
try {
|
|
18815
18818
|
console.error('--- Hierarchized picker ' + this.componentID + ' ERROR ---', messageToLog);
|
|
18819
|
+
this.lastErrorMessage = messageToLog;
|
|
18816
18820
|
}
|
|
18817
18821
|
catch (_a) {
|
|
18818
|
-
|
|
18822
|
+
const genericErrorMessage = '--- Hierarchized picker generic ERROR ---';
|
|
18823
|
+
this.lastErrorMessage = genericErrorMessage;
|
|
18824
|
+
console.error(genericErrorMessage);
|
|
18819
18825
|
}
|
|
18826
|
+
this.errorRaised.emit(this.lastErrorMessage);
|
|
18820
18827
|
}
|
|
18821
18828
|
get theOptions() {
|
|
18822
18829
|
return this.optionsManager.getOptions();
|
|
18823
18830
|
}
|
|
18824
18831
|
diffKeys(obj1, obj2, prefix = '') {
|
|
18825
18832
|
const diffs = [];
|
|
18826
|
-
const
|
|
18827
|
-
for (const key of
|
|
18833
|
+
const commonKeys = Object.keys(obj1 || {}).filter(key => obj2 && Object.prototype.hasOwnProperty.call(obj2, key));
|
|
18834
|
+
for (const key of commonKeys) {
|
|
18828
18835
|
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
18829
|
-
const val1 = obj1
|
|
18830
|
-
const val2 = obj2
|
|
18831
|
-
if (
|
|
18832
|
-
|
|
18836
|
+
const val1 = obj1[key];
|
|
18837
|
+
const val2 = obj2[key];
|
|
18838
|
+
if (Array.isArray(val1) && Array.isArray(val2)) {
|
|
18839
|
+
if (val1.length !== val2.length || val1.some((v, i) => v !== val2[i])) {
|
|
18840
|
+
diffs.push(fullKey);
|
|
18841
|
+
}
|
|
18842
|
+
}
|
|
18843
|
+
else if (val1 &&
|
|
18844
|
+
val2 &&
|
|
18845
|
+
typeof val1 === 'object' &&
|
|
18846
|
+
typeof val2 === 'object') {
|
|
18833
18847
|
diffs.push(...this.diffKeys(val1, val2, fullKey));
|
|
18834
18848
|
}
|
|
18835
18849
|
else if (val1 !== val2) {
|
|
18836
|
-
// Valeurs différentes ou propriété manquante
|
|
18837
18850
|
diffs.push(fullKey);
|
|
18838
18851
|
}
|
|
18839
18852
|
}
|
|
@@ -18884,13 +18897,16 @@ const HierarchizedPickerComponent = class {
|
|
|
18884
18897
|
if (oldValue && JSON.stringify(newValue.options) != JSON.stringify(oldValue.options)) {
|
|
18885
18898
|
this.value = [];
|
|
18886
18899
|
}
|
|
18900
|
+
console.log("Setnewoptions 01", newValue, oldValue);
|
|
18887
18901
|
if ((newValue === null || newValue === void 0 ? void 0 : newValue.loading) == 'display' || (newValue && !newValue.loading)) {
|
|
18888
18902
|
if ((oldValue && this.isChangeInOptions(newValue, oldValue)) || !oldValue) {
|
|
18889
18903
|
if (!oldValue) {
|
|
18890
18904
|
oldValue = savedOldValue;
|
|
18891
18905
|
}
|
|
18906
|
+
console.log("Setnewoptions 02");
|
|
18892
18907
|
const propDiffs = this.diffKeys(oldValue, this.optionsManager.initializeOptions(newValue));
|
|
18893
18908
|
const noReloadProps = ["multiple"];
|
|
18909
|
+
console.log("Setnewoptions 03", propDiffs);
|
|
18894
18910
|
if (propDiffs.length == 1 && propDiffs.some(item => noReloadProps.includes(item))) {
|
|
18895
18911
|
const propChanged = propDiffs[0];
|
|
18896
18912
|
switch (propChanged) {
|
|
@@ -18957,6 +18973,9 @@ const HierarchizedPickerComponent = class {
|
|
|
18957
18973
|
async filterTree(searchedValue) {
|
|
18958
18974
|
this.search(searchedValue);
|
|
18959
18975
|
}
|
|
18976
|
+
async getError() {
|
|
18977
|
+
return Promise.resolve(this.lastErrorMessage);
|
|
18978
|
+
}
|
|
18960
18979
|
constructor(hostRef) {
|
|
18961
18980
|
index.registerInstance(this, hostRef);
|
|
18962
18981
|
this.valueChange = index.createEvent(this, "valueChange", 7);
|
|
@@ -18964,6 +18983,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18964
18983
|
this.itemContextMenuItemClick = index.createEvent(this, "itemContextMenuItemClick", 7);
|
|
18965
18984
|
this.searchResult = index.createEvent(this, "searchResult", 7);
|
|
18966
18985
|
this.navigateInTree = index.createEvent(this, "navigateInTree", 7);
|
|
18986
|
+
this.errorRaised = index.createEvent(this, "errorRaised", 7);
|
|
18967
18987
|
this.modaleHeight = 200;
|
|
18968
18988
|
this.modalePosition = 'bottom';
|
|
18969
18989
|
this.canload = true; // Determines wether the component may be loaded
|
|
@@ -18973,6 +18993,7 @@ const HierarchizedPickerComponent = class {
|
|
|
18973
18993
|
this.lastSearchMatchCounter = 0; // Counter of number of matches for last search
|
|
18974
18994
|
this.setValueOnClick = true; // Tells wether we edit the picker value on click in the tree
|
|
18975
18995
|
this.mylog = console.log; // Custom log function for debug purposes
|
|
18996
|
+
this.lastErrorMessage = '';
|
|
18976
18997
|
this.scrollToNode = (targetNodeId = null, displayChildren = false) => {
|
|
18977
18998
|
var _a;
|
|
18978
18999
|
let scrollToValue = 0;
|
|
@@ -19013,7 +19034,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19013
19034
|
}
|
|
19014
19035
|
}
|
|
19015
19036
|
catch (err) {
|
|
19016
|
-
|
|
19037
|
+
this.errorToLog = "Error in showSelectedNodes";
|
|
19017
19038
|
}
|
|
19018
19039
|
if (scrollToValue && this.scrollable) {
|
|
19019
19040
|
this.scrollable.scrollTop = scrollToValue;
|
|
@@ -19284,7 +19305,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19284
19305
|
this.ignoreOptionsChanges = false;
|
|
19285
19306
|
}
|
|
19286
19307
|
catch (_b) {
|
|
19287
|
-
|
|
19308
|
+
this.errorToLog = 'Error loading webservice data!';
|
|
19288
19309
|
}
|
|
19289
19310
|
}
|
|
19290
19311
|
displayPickerError(errorMsg = '') {
|
|
@@ -19296,11 +19317,11 @@ const HierarchizedPickerComponent = class {
|
|
|
19296
19317
|
}
|
|
19297
19318
|
this.displayedValue = errorMsg;
|
|
19298
19319
|
this.isDisabled = true;
|
|
19299
|
-
|
|
19320
|
+
this.errorToLog = errorMsg;
|
|
19300
19321
|
}
|
|
19301
19322
|
}
|
|
19302
19323
|
catch (_a) {
|
|
19303
|
-
|
|
19324
|
+
this.errorToLog = errorMsg;
|
|
19304
19325
|
}
|
|
19305
19326
|
}
|
|
19306
19327
|
getApiSearchURL() {
|
|
@@ -19401,7 +19422,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19401
19422
|
}
|
|
19402
19423
|
})
|
|
19403
19424
|
.catch(err => {
|
|
19404
|
-
|
|
19425
|
+
this.errorToLog = err;
|
|
19405
19426
|
});
|
|
19406
19427
|
}
|
|
19407
19428
|
else {
|
|
@@ -19420,12 +19441,12 @@ const HierarchizedPickerComponent = class {
|
|
|
19420
19441
|
}
|
|
19421
19442
|
})
|
|
19422
19443
|
.catch(error => {
|
|
19423
|
-
|
|
19444
|
+
this.errorToLog = error;
|
|
19424
19445
|
try {
|
|
19425
19446
|
this.errorToLog = 'getDataFromSource 1 rejected:' + JSON.stringify(error, replacer, 2);
|
|
19426
19447
|
}
|
|
19427
19448
|
catch (_a) {
|
|
19428
|
-
|
|
19449
|
+
this.errorToLog = JSON.stringify(error, replacer, 2);
|
|
19429
19450
|
}
|
|
19430
19451
|
});
|
|
19431
19452
|
}
|
|
@@ -19552,6 +19573,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19552
19573
|
this.itemContextMenuItemClick.emit(e);
|
|
19553
19574
|
}
|
|
19554
19575
|
setNodeAsSelected(id, treeToUpdate, userClick) {
|
|
19576
|
+
console.log("setNodeAsSelected", id);
|
|
19555
19577
|
// TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
|
|
19556
19578
|
if (((this.isDisabled && this.optionsManager.getOptions().mode != "tree") && this.shownTree && this.setValueOnClick) ||
|
|
19557
19579
|
(this.loadedTreeJs.liElementsById[id] && this.loadedTreeJs.liElementsById[id].classList.value && this.loadedTreeJs.liElementsById[id].classList.value.indexOf('readonly_node') != -1)) {
|
|
@@ -19559,6 +19581,8 @@ const HierarchizedPickerComponent = class {
|
|
|
19559
19581
|
}
|
|
19560
19582
|
if (!userClick && treeToUpdate.getValues().indexOf(id.toString()) != -1)
|
|
19561
19583
|
return;
|
|
19584
|
+
if (this.loadedTreeJs && !this.theOptions.multiple)
|
|
19585
|
+
this.loadedTreeJs.emptyNodesCheckStatus();
|
|
19562
19586
|
this.ignoreOptionsChanges = true;
|
|
19563
19587
|
// Override of treejs normal workaround =>> DONT EDIT IT!
|
|
19564
19588
|
// ----- BEGIN -----
|
|
@@ -19650,7 +19674,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19650
19674
|
}
|
|
19651
19675
|
const previousShownTree = this.shownTree;
|
|
19652
19676
|
this.shownTree = this.hasFocus.length > 0;
|
|
19653
|
-
if (this.shownTree && !previousShownTree) {
|
|
19677
|
+
if (this.shownTree && !previousShownTree && this.optionsManager.getOptions().mode == 'input') {
|
|
19654
19678
|
if (this.shouldOpenModalAbove(document.querySelector('#hierarchized-picker-input-' + this.componentID), this.modaleHeight)) {
|
|
19655
19679
|
this.modalePosition = 'top';
|
|
19656
19680
|
}
|
|
@@ -19781,7 +19805,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19781
19805
|
}
|
|
19782
19806
|
})
|
|
19783
19807
|
.catch(error => {
|
|
19784
|
-
|
|
19808
|
+
this.errorToLog = error;
|
|
19785
19809
|
});
|
|
19786
19810
|
}
|
|
19787
19811
|
else {
|
|
@@ -19794,7 +19818,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19794
19818
|
}
|
|
19795
19819
|
})
|
|
19796
19820
|
.catch(error => {
|
|
19797
|
-
|
|
19821
|
+
this.errorToLog = error;
|
|
19798
19822
|
});
|
|
19799
19823
|
}
|
|
19800
19824
|
}
|
|
@@ -19809,6 +19833,7 @@ const HierarchizedPickerComponent = class {
|
|
|
19809
19833
|
this.translateDataForTree(this.rawDataManager.getData());
|
|
19810
19834
|
}
|
|
19811
19835
|
checkFields(values, allowSetValueOnClick = true) {
|
|
19836
|
+
console.log("checkFields", values);
|
|
19812
19837
|
if (!this.loadedTreeJs)
|
|
19813
19838
|
return;
|
|
19814
19839
|
this.setValueOnClick = allowSetValueOnClick;
|
|
@@ -19829,12 +19854,11 @@ const HierarchizedPickerComponent = class {
|
|
|
19829
19854
|
fullpath: (_c = treeNode.fullpath) !== null && _c !== void 0 ? _c : null,
|
|
19830
19855
|
hasChildren: treeNode.children && treeNode.children.length > 0
|
|
19831
19856
|
});
|
|
19832
|
-
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
19833
19857
|
}
|
|
19834
19858
|
else {
|
|
19835
|
-
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
19836
19859
|
console.warn("Node not found in Tree for:", intNodeid);
|
|
19837
19860
|
}
|
|
19861
|
+
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
19838
19862
|
});
|
|
19839
19863
|
}
|
|
19840
19864
|
this.setDisplayedValue(enrichedValues);
|
|
@@ -19914,6 +19938,8 @@ const HierarchizedPickerComponent = class {
|
|
|
19914
19938
|
.join('; ');
|
|
19915
19939
|
}
|
|
19916
19940
|
shouldOpenModalAbove(inputElement, modaleHeight) {
|
|
19941
|
+
if (this.optionsManager.getOptions().mode != 'input')
|
|
19942
|
+
return false;
|
|
19917
19943
|
const inputRect = inputElement.getBoundingClientRect();
|
|
19918
19944
|
const spaceLeft = window.innerHeight - inputRect.y;
|
|
19919
19945
|
return spaceLeft < modaleHeight;
|
|
@@ -78,27 +78,37 @@ export class HierarchizedPickerComponent {
|
|
|
78
78
|
logError(messageToLog) {
|
|
79
79
|
try {
|
|
80
80
|
console.error('--- Hierarchized picker ' + this.componentID + ' ERROR ---', messageToLog);
|
|
81
|
+
this.lastErrorMessage = messageToLog;
|
|
81
82
|
}
|
|
82
83
|
catch (_a) {
|
|
83
|
-
|
|
84
|
+
const genericErrorMessage = '--- Hierarchized picker generic ERROR ---';
|
|
85
|
+
this.lastErrorMessage = genericErrorMessage;
|
|
86
|
+
console.error(genericErrorMessage);
|
|
84
87
|
}
|
|
88
|
+
this.errorRaised.emit(this.lastErrorMessage);
|
|
85
89
|
}
|
|
86
90
|
get theOptions() {
|
|
87
91
|
return this.optionsManager.getOptions();
|
|
88
92
|
}
|
|
89
93
|
diffKeys(obj1, obj2, prefix = '') {
|
|
90
94
|
const diffs = [];
|
|
91
|
-
const
|
|
92
|
-
for (const key of
|
|
95
|
+
const commonKeys = Object.keys(obj1 || {}).filter(key => obj2 && Object.prototype.hasOwnProperty.call(obj2, key));
|
|
96
|
+
for (const key of commonKeys) {
|
|
93
97
|
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
94
|
-
const val1 = obj1
|
|
95
|
-
const val2 = obj2
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
+
const val1 = obj1[key];
|
|
99
|
+
const val2 = obj2[key];
|
|
100
|
+
if (Array.isArray(val1) && Array.isArray(val2)) {
|
|
101
|
+
if (val1.length !== val2.length || val1.some((v, i) => v !== val2[i])) {
|
|
102
|
+
diffs.push(fullKey);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else if (val1 &&
|
|
106
|
+
val2 &&
|
|
107
|
+
typeof val1 === 'object' &&
|
|
108
|
+
typeof val2 === 'object') {
|
|
98
109
|
diffs.push(...this.diffKeys(val1, val2, fullKey));
|
|
99
110
|
}
|
|
100
111
|
else if (val1 !== val2) {
|
|
101
|
-
// Valeurs différentes ou propriété manquante
|
|
102
112
|
diffs.push(fullKey);
|
|
103
113
|
}
|
|
104
114
|
}
|
|
@@ -149,13 +159,16 @@ export class HierarchizedPickerComponent {
|
|
|
149
159
|
if (oldValue && JSON.stringify(newValue.options) != JSON.stringify(oldValue.options)) {
|
|
150
160
|
this.value = [];
|
|
151
161
|
}
|
|
162
|
+
console.log("Setnewoptions 01", newValue, oldValue);
|
|
152
163
|
if ((newValue === null || newValue === void 0 ? void 0 : newValue.loading) == 'display' || (newValue && !newValue.loading)) {
|
|
153
164
|
if ((oldValue && this.isChangeInOptions(newValue, oldValue)) || !oldValue) {
|
|
154
165
|
if (!oldValue) {
|
|
155
166
|
oldValue = savedOldValue;
|
|
156
167
|
}
|
|
168
|
+
console.log("Setnewoptions 02");
|
|
157
169
|
const propDiffs = this.diffKeys(oldValue, this.optionsManager.initializeOptions(newValue));
|
|
158
170
|
const noReloadProps = ["multiple"];
|
|
171
|
+
console.log("Setnewoptions 03", propDiffs);
|
|
159
172
|
if (propDiffs.length == 1 && propDiffs.some(item => noReloadProps.includes(item))) {
|
|
160
173
|
const propChanged = propDiffs[0];
|
|
161
174
|
switch (propChanged) {
|
|
@@ -222,6 +235,9 @@ export class HierarchizedPickerComponent {
|
|
|
222
235
|
async filterTree(searchedValue) {
|
|
223
236
|
this.search(searchedValue);
|
|
224
237
|
}
|
|
238
|
+
async getError() {
|
|
239
|
+
return Promise.resolve(this.lastErrorMessage);
|
|
240
|
+
}
|
|
225
241
|
constructor() {
|
|
226
242
|
this.modaleHeight = 200;
|
|
227
243
|
this.modalePosition = 'bottom';
|
|
@@ -232,6 +248,7 @@ export class HierarchizedPickerComponent {
|
|
|
232
248
|
this.lastSearchMatchCounter = 0; // Counter of number of matches for last search
|
|
233
249
|
this.setValueOnClick = true; // Tells wether we edit the picker value on click in the tree
|
|
234
250
|
this.mylog = console.log; // Custom log function for debug purposes
|
|
251
|
+
this.lastErrorMessage = '';
|
|
235
252
|
this.scrollToNode = (targetNodeId = null, displayChildren = false) => {
|
|
236
253
|
var _a;
|
|
237
254
|
let scrollToValue = 0;
|
|
@@ -272,7 +289,7 @@ export class HierarchizedPickerComponent {
|
|
|
272
289
|
}
|
|
273
290
|
}
|
|
274
291
|
catch (err) {
|
|
275
|
-
|
|
292
|
+
this.errorToLog = "Error in showSelectedNodes";
|
|
276
293
|
}
|
|
277
294
|
if (scrollToValue && this.scrollable) {
|
|
278
295
|
this.scrollable.scrollTop = scrollToValue;
|
|
@@ -546,7 +563,7 @@ export class HierarchizedPickerComponent {
|
|
|
546
563
|
this.ignoreOptionsChanges = false;
|
|
547
564
|
}
|
|
548
565
|
catch (_b) {
|
|
549
|
-
|
|
566
|
+
this.errorToLog = 'Error loading webservice data!';
|
|
550
567
|
}
|
|
551
568
|
}
|
|
552
569
|
displayPickerError(errorMsg = '') {
|
|
@@ -558,11 +575,11 @@ export class HierarchizedPickerComponent {
|
|
|
558
575
|
}
|
|
559
576
|
this.displayedValue = errorMsg;
|
|
560
577
|
this.isDisabled = true;
|
|
561
|
-
|
|
578
|
+
this.errorToLog = errorMsg;
|
|
562
579
|
}
|
|
563
580
|
}
|
|
564
581
|
catch (_a) {
|
|
565
|
-
|
|
582
|
+
this.errorToLog = errorMsg;
|
|
566
583
|
}
|
|
567
584
|
}
|
|
568
585
|
getApiSearchURL() {
|
|
@@ -663,7 +680,7 @@ export class HierarchizedPickerComponent {
|
|
|
663
680
|
}
|
|
664
681
|
})
|
|
665
682
|
.catch(err => {
|
|
666
|
-
|
|
683
|
+
this.errorToLog = err;
|
|
667
684
|
});
|
|
668
685
|
}
|
|
669
686
|
else {
|
|
@@ -682,12 +699,12 @@ export class HierarchizedPickerComponent {
|
|
|
682
699
|
}
|
|
683
700
|
})
|
|
684
701
|
.catch(error => {
|
|
685
|
-
|
|
702
|
+
this.errorToLog = error;
|
|
686
703
|
try {
|
|
687
704
|
this.errorToLog = 'getDataFromSource 1 rejected:' + JSON.stringify(error, replacer, 2);
|
|
688
705
|
}
|
|
689
706
|
catch (_a) {
|
|
690
|
-
|
|
707
|
+
this.errorToLog = JSON.stringify(error, replacer, 2);
|
|
691
708
|
}
|
|
692
709
|
});
|
|
693
710
|
}
|
|
@@ -814,6 +831,7 @@ export class HierarchizedPickerComponent {
|
|
|
814
831
|
this.itemContextMenuItemClick.emit(e);
|
|
815
832
|
}
|
|
816
833
|
setNodeAsSelected(id, treeToUpdate, userClick) {
|
|
834
|
+
console.log("setNodeAsSelected", id);
|
|
817
835
|
// TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
|
|
818
836
|
if (((this.isDisabled && this.optionsManager.getOptions().mode != "tree") && this.shownTree && this.setValueOnClick) ||
|
|
819
837
|
(this.loadedTreeJs.liElementsById[id] && this.loadedTreeJs.liElementsById[id].classList.value && this.loadedTreeJs.liElementsById[id].classList.value.indexOf('readonly_node') != -1)) {
|
|
@@ -821,6 +839,8 @@ export class HierarchizedPickerComponent {
|
|
|
821
839
|
}
|
|
822
840
|
if (!userClick && treeToUpdate.getValues().indexOf(id.toString()) != -1)
|
|
823
841
|
return;
|
|
842
|
+
if (this.loadedTreeJs && !this.theOptions.multiple)
|
|
843
|
+
this.loadedTreeJs.emptyNodesCheckStatus();
|
|
824
844
|
this.ignoreOptionsChanges = true;
|
|
825
845
|
// Override of treejs normal workaround =>> DONT EDIT IT!
|
|
826
846
|
// ----- BEGIN -----
|
|
@@ -912,7 +932,7 @@ export class HierarchizedPickerComponent {
|
|
|
912
932
|
}
|
|
913
933
|
const previousShownTree = this.shownTree;
|
|
914
934
|
this.shownTree = this.hasFocus.length > 0;
|
|
915
|
-
if (this.shownTree && !previousShownTree) {
|
|
935
|
+
if (this.shownTree && !previousShownTree && this.optionsManager.getOptions().mode == 'input') {
|
|
916
936
|
if (this.shouldOpenModalAbove(document.querySelector('#hierarchized-picker-input-' + this.componentID), this.modaleHeight)) {
|
|
917
937
|
this.modalePosition = 'top';
|
|
918
938
|
}
|
|
@@ -1043,7 +1063,7 @@ export class HierarchizedPickerComponent {
|
|
|
1043
1063
|
}
|
|
1044
1064
|
})
|
|
1045
1065
|
.catch(error => {
|
|
1046
|
-
|
|
1066
|
+
this.errorToLog = error;
|
|
1047
1067
|
});
|
|
1048
1068
|
}
|
|
1049
1069
|
else {
|
|
@@ -1056,7 +1076,7 @@ export class HierarchizedPickerComponent {
|
|
|
1056
1076
|
}
|
|
1057
1077
|
})
|
|
1058
1078
|
.catch(error => {
|
|
1059
|
-
|
|
1079
|
+
this.errorToLog = error;
|
|
1060
1080
|
});
|
|
1061
1081
|
}
|
|
1062
1082
|
}
|
|
@@ -1071,6 +1091,7 @@ export class HierarchizedPickerComponent {
|
|
|
1071
1091
|
this.translateDataForTree(this.rawDataManager.getData());
|
|
1072
1092
|
}
|
|
1073
1093
|
checkFields(values, allowSetValueOnClick = true) {
|
|
1094
|
+
console.log("checkFields", values);
|
|
1074
1095
|
if (!this.loadedTreeJs)
|
|
1075
1096
|
return;
|
|
1076
1097
|
this.setValueOnClick = allowSetValueOnClick;
|
|
@@ -1091,12 +1112,11 @@ export class HierarchizedPickerComponent {
|
|
|
1091
1112
|
fullpath: (_c = treeNode.fullpath) !== null && _c !== void 0 ? _c : null,
|
|
1092
1113
|
hasChildren: treeNode.children && treeNode.children.length > 0
|
|
1093
1114
|
});
|
|
1094
|
-
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
1095
1115
|
}
|
|
1096
1116
|
else {
|
|
1097
|
-
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
1098
1117
|
console.warn("Node not found in Tree for:", intNodeid);
|
|
1099
1118
|
}
|
|
1119
|
+
this.setNodeAsSelected(intNodeid, this.loadedTreeJs, false);
|
|
1100
1120
|
});
|
|
1101
1121
|
}
|
|
1102
1122
|
this.setDisplayedValue(enrichedValues);
|
|
@@ -1176,6 +1196,8 @@ export class HierarchizedPickerComponent {
|
|
|
1176
1196
|
.join('; ');
|
|
1177
1197
|
}
|
|
1178
1198
|
shouldOpenModalAbove(inputElement, modaleHeight) {
|
|
1199
|
+
if (this.optionsManager.getOptions().mode != 'input')
|
|
1200
|
+
return false;
|
|
1179
1201
|
const inputRect = inputElement.getBoundingClientRect();
|
|
1180
1202
|
const spaceLeft = window.innerHeight - inputRect.y;
|
|
1181
1203
|
return spaceLeft < modaleHeight;
|
|
@@ -1422,6 +1444,21 @@ export class HierarchizedPickerComponent {
|
|
|
1422
1444
|
"resolved": "any",
|
|
1423
1445
|
"references": {}
|
|
1424
1446
|
}
|
|
1447
|
+
}, {
|
|
1448
|
+
"method": "errorRaised",
|
|
1449
|
+
"name": "errorRaised",
|
|
1450
|
+
"bubbles": true,
|
|
1451
|
+
"cancelable": true,
|
|
1452
|
+
"composed": true,
|
|
1453
|
+
"docs": {
|
|
1454
|
+
"tags": [],
|
|
1455
|
+
"text": "This event is emitted when the picker suffers an error"
|
|
1456
|
+
},
|
|
1457
|
+
"complexType": {
|
|
1458
|
+
"original": "any",
|
|
1459
|
+
"resolved": "any",
|
|
1460
|
+
"references": {}
|
|
1461
|
+
}
|
|
1425
1462
|
}];
|
|
1426
1463
|
}
|
|
1427
1464
|
static get methods() {
|
|
@@ -1519,6 +1556,22 @@ export class HierarchizedPickerComponent {
|
|
|
1519
1556
|
"tags": []
|
|
1520
1557
|
}
|
|
1521
1558
|
},
|
|
1559
|
+
"getError": {
|
|
1560
|
+
"complexType": {
|
|
1561
|
+
"signature": "() => Promise<string>",
|
|
1562
|
+
"parameters": [],
|
|
1563
|
+
"references": {
|
|
1564
|
+
"Promise": {
|
|
1565
|
+
"location": "global"
|
|
1566
|
+
}
|
|
1567
|
+
},
|
|
1568
|
+
"return": "Promise<string>"
|
|
1569
|
+
},
|
|
1570
|
+
"docs": {
|
|
1571
|
+
"text": "",
|
|
1572
|
+
"tags": []
|
|
1573
|
+
}
|
|
1574
|
+
},
|
|
1522
1575
|
"clearPicker": {
|
|
1523
1576
|
"complexType": {
|
|
1524
1577
|
"signature": "() => Promise<void>",
|
|
@@ -192,12 +192,11 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
192
192
|
};
|
|
193
193
|
Tree.prototype.onItemClick = async function (id, rightclick = false) {
|
|
194
194
|
// TODO Temporarily ignores disabled mode for selecting nodes if mode is tree
|
|
195
|
+
console.log("coucou");
|
|
195
196
|
if (this.options.parentApi.isDisabled && this.options.parentApi.optionsManager.getOptions().mode != "tree")
|
|
196
197
|
return;
|
|
197
198
|
const pickerValue = await this.options.parentApi.getValue();
|
|
198
199
|
if (!rightclick || !pickerValue || pickerValue.nodeid != id) {
|
|
199
|
-
if (!this.options.parentApi.theOptions.multiple)
|
|
200
|
-
this.emptyNodesCheckStatus();
|
|
201
200
|
this.options.parentApi.setNodeAsSelected(id, this, true);
|
|
202
201
|
}
|
|
203
202
|
};
|
|
@@ -38,17 +38,21 @@ export function setupKeyboardNavigation(component, optionsManager, navigateInTre
|
|
|
38
38
|
component._keydownListenerAdded = true;
|
|
39
39
|
component.el.addEventListener('keydown', (event) => {
|
|
40
40
|
var _a, _b;
|
|
41
|
+
console.log("Navigation 01", event);
|
|
41
42
|
event.stopPropagation();
|
|
43
|
+
console.log("Navigation 02");
|
|
42
44
|
const tree = component.loadedTreeJs;
|
|
43
45
|
let treeNodesFromTree = findAllTreeNodes(tree.treeNodes, tree.liElementsById);
|
|
46
|
+
console.log("Navigation 03");
|
|
44
47
|
if (!tree || !treeNodesFromTree.length)
|
|
45
48
|
return;
|
|
46
49
|
let spaceNode = treeNodesFromTree[focusedNodeIndex];
|
|
47
50
|
let activeNode = treeNodesFromTree[focusedNodeIndex];
|
|
48
51
|
let liElement = tree.liElementsById[activeNode.id];
|
|
49
52
|
const handledEvents = ['tab', '0', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright'];
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
console.log("Navigation 04", event.key);
|
|
54
|
+
switch (event.key.toLowerCase()) {
|
|
55
|
+
case 'tab':
|
|
52
56
|
case '0':
|
|
53
57
|
event.preventDefault();
|
|
54
58
|
if (true) { //(spaceNode?.nodeId) {
|
|
@@ -57,7 +61,7 @@ export function setupKeyboardNavigation(component, optionsManager, navigateInTre
|
|
|
57
61
|
setTimeout(() => focusMainInput(component), 100);
|
|
58
62
|
}
|
|
59
63
|
break;
|
|
60
|
-
case '
|
|
64
|
+
case 'arrowup':
|
|
61
65
|
event.preventDefault();
|
|
62
66
|
focusedNodeIndex = Math.max(focusedNodeIndex - 1, 0);
|
|
63
67
|
const newActiveNodeUp = treeNodesFromTree[focusedNodeIndex];
|
|
@@ -65,7 +69,7 @@ export function setupKeyboardNavigation(component, optionsManager, navigateInTre
|
|
|
65
69
|
newLiElementUp.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
66
70
|
focusNode(tree.liElementsById, newLiElementUp);
|
|
67
71
|
break;
|
|
68
|
-
case '
|
|
72
|
+
case 'arrowdown':
|
|
69
73
|
event.preventDefault();
|
|
70
74
|
focusedNodeIndex = Math.min(focusedNodeIndex + 1, treeNodesFromTree.length - 1);
|
|
71
75
|
const newActiveNodeDown = treeNodesFromTree[focusedNodeIndex];
|
|
@@ -73,14 +77,14 @@ export function setupKeyboardNavigation(component, optionsManager, navigateInTre
|
|
|
73
77
|
focusNode(tree.liElementsById, newLiElementDown);
|
|
74
78
|
newLiElementDown.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
75
79
|
break;
|
|
76
|
-
case '
|
|
80
|
+
case 'arrowleft':
|
|
77
81
|
event.preventDefault();
|
|
78
82
|
const leftSwitcher = liElement.querySelector('.treejs-switcher');
|
|
79
83
|
if (leftSwitcher) {
|
|
80
84
|
(_a = component.loadedTreeJs) === null || _a === void 0 ? void 0 : _a.onSwitcherClick(leftSwitcher);
|
|
81
85
|
}
|
|
82
86
|
break;
|
|
83
|
-
case '
|
|
87
|
+
case 'arrowright':
|
|
84
88
|
event.preventDefault();
|
|
85
89
|
const rightSwitcher = liElement.querySelector('.treejs-switcher');
|
|
86
90
|
if (rightSwitcher) {
|