reneco-hierarchized-picker 0.4.3-beta.9 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/reneco-hierarchized-picker.cjs.js +1 -1
- package/dist/cjs/reneco-hierarchized-picker_2.cjs.entry.js +509 -271
- package/dist/collection/components/hierarchized-picker/hierarchized-picker.css +10 -2
- package/dist/collection/components/hierarchized-picker/hierarchized-picker.js +391 -130
- package/dist/collection/components/search-input/search-input.js +1 -3
- package/dist/collection/components/treejs/index.js +49 -50
- package/dist/collection/core/options-manager.js +2 -0
- package/dist/collection/features/events/focus-handlers.js +15 -11
- package/dist/collection/features/keyboard-navigation/keyboard-navigation.js +83 -57
- package/dist/collection/features/tree/tree-utils.js +12 -3
- package/dist/collection/utils/conf-helper.js +4 -0
- package/dist/collection/utils/constants.js +4 -3
- package/dist/collection/utils/theme-utils.js +1 -0
- package/dist/custom-elements/index.js +509 -271
- package/dist/esm/loader.js +1 -1
- package/dist/esm/reneco-hierarchized-picker.js +1 -1
- package/dist/esm/reneco-hierarchized-picker_2.entry.js +509 -271
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/reneco-hierarchized-picker.js +1 -1
- package/dist/esm-es5/reneco-hierarchized-picker_2.entry.js +2 -2
- package/dist/reneco-hierarchized-picker/p-0e305bec.entry.js +1 -0
- package/dist/reneco-hierarchized-picker/p-73168a50.system.js +1 -1
- package/dist/reneco-hierarchized-picker/p-9027f23a.system.entry.js +3 -0
- package/dist/reneco-hierarchized-picker/reneco-hierarchized-picker.esm.js +1 -1
- package/dist/types/components/hierarchized-picker/hierarchized-picker.d.ts +13 -2
- package/dist/types/components.d.ts +6 -0
- package/dist/types/core/options-manager.d.ts +1 -1
- package/dist/types/features/keyboard-navigation/keyboard-navigation.d.ts +2 -1
- package/dist/types/features/tree/tree-utils.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +1 -0
- package/package.json +1 -1
- package/dist/reneco-hierarchized-picker/p-934e9cf8.entry.js +0 -1
- package/dist/reneco-hierarchized-picker/p-9ddab37d.system.entry.js +0 -3
|
@@ -31,9 +31,7 @@ export class SearchInput {
|
|
|
31
31
|
render() {
|
|
32
32
|
return (h("div", { id: "hierarchized-picker-input-search",
|
|
33
33
|
// TODO: need component ID ?
|
|
34
|
-
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",
|
|
35
|
-
//class="native-input search-input hierarchized-picker-search sc-ion-input-md-h sc-ion-input-md-s md"
|
|
36
|
-
placeholder: this.placeholder, onFocus: () => this.handleFocus(), onBlur: (event) => this.handleBlur(event), onInput: (event) => this.handleInput(event) })));
|
|
34
|
+
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) })));
|
|
37
35
|
}
|
|
38
36
|
static get is() { return "search-input"; }
|
|
39
37
|
static get originalStyleUrls() {
|
|
@@ -188,49 +188,6 @@ Tree.prototype.bindEvent = function (ele) {
|
|
|
188
188
|
else if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher')) {
|
|
189
189
|
this.onSwitcherClick(target);
|
|
190
190
|
}
|
|
191
|
-
const hasUndefinedchild = e.target.parentNode.querySelectorAll(".treejs-switcher").length > 0 && e.target.parentNode.querySelectorAll('ul').length == 0;
|
|
192
|
-
//CUSTOM
|
|
193
|
-
const childspans = Array.prototype.slice.call(e.target.parentNode.querySelectorAll('ul > li > span.treejs-label')).filter((ele) => {
|
|
194
|
-
return ele.parentNode.parentNode.parentNode === e.target.parentNode;
|
|
195
|
-
});
|
|
196
|
-
let undefinedChildren = [];
|
|
197
|
-
//This may be a problem the day a node value is "undefined"
|
|
198
|
-
undefinedChildren = childspans.filter(ele => {
|
|
199
|
-
return ele.textContent === 'undefined';
|
|
200
|
-
});
|
|
201
|
-
// If the user clicked on an unloaded node
|
|
202
|
-
if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher') && (undefinedChildren.length > 0 || hasUndefinedchild)) {
|
|
203
|
-
// Clear the subnode HTML
|
|
204
|
-
if (undefinedChildren.length > 0) {
|
|
205
|
-
e.target.parentNode.querySelector('ul').innerHTML = '';
|
|
206
|
-
}
|
|
207
|
-
// If source is webservice (it shouldn't be something else)
|
|
208
|
-
if (this.options.parentApi.theOptions.source == 'webservice') {
|
|
209
|
-
if (this.options.parentApi.theOptions.origin == 'classification') {
|
|
210
|
-
const contextualApiParams = this.options.parentApi.getContextualApiParams(Object.assign(Object.assign({}, this.options.parentApi.theOptions.options), { startNode: target.parentNode.nodeId }));
|
|
211
|
-
const contextualApiURL = this.options.parentApi.getContextualApiURL();
|
|
212
|
-
// WS Call
|
|
213
|
-
this.options.rawDataManager
|
|
214
|
-
.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
215
|
-
.then(data => {
|
|
216
|
-
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
// WS Call
|
|
221
|
-
this.options.rawDataManager
|
|
222
|
-
.getFromSource(this.options.parentApi.theOptions.url, {
|
|
223
|
-
StartNodeID: target.parentNode.nodeId,
|
|
224
|
-
lng: this.options.parentApi.theOptions.options.lng,
|
|
225
|
-
IsDeprecated: this.options.parentApi.theOptions.options.IsDeprecated,
|
|
226
|
-
}, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
227
|
-
.then(data => {
|
|
228
|
-
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
this.onSwitcherClick(target);
|
|
233
|
-
}
|
|
234
191
|
}, false);
|
|
235
192
|
};
|
|
236
193
|
Tree.prototype.onItemClick = async function (id, rightclick = false) {
|
|
@@ -239,8 +196,6 @@ Tree.prototype.onItemClick = async function (id, rightclick = false) {
|
|
|
239
196
|
return;
|
|
240
197
|
const pickerValue = await this.options.parentApi.getValue();
|
|
241
198
|
if (!rightclick || !pickerValue || pickerValue.nodeid != id) {
|
|
242
|
-
if (!this.options.parentApi.theOptions.multiple)
|
|
243
|
-
this.emptyNodesCheckStatus();
|
|
244
199
|
this.options.parentApi.setNodeAsSelected(id, this, true);
|
|
245
200
|
}
|
|
246
201
|
};
|
|
@@ -367,6 +322,48 @@ Tree.prototype.markWillUpdateNode = function (node) {
|
|
|
367
322
|
this.willUpdateNodesById[node.id] = node;
|
|
368
323
|
};
|
|
369
324
|
Tree.prototype.onSwitcherClick = function (target) {
|
|
325
|
+
const hasUndefinedchild = target.parentNode.querySelectorAll(".treejs-switcher").length > 0 && target.parentNode.querySelectorAll('ul').length == 0;
|
|
326
|
+
//CUSTOM
|
|
327
|
+
const childspans = Array.prototype.slice.call(target.parentNode.querySelectorAll('ul > li > span.treejs-label')).filter((ele) => {
|
|
328
|
+
return ele.parentNode.parentNode.parentNode === target.parentNode;
|
|
329
|
+
});
|
|
330
|
+
let undefinedChildren = [];
|
|
331
|
+
//This may be a problem the day a node value is "undefined"
|
|
332
|
+
undefinedChildren = childspans.filter(ele => {
|
|
333
|
+
return ele.textContent === 'undefined';
|
|
334
|
+
});
|
|
335
|
+
// If the user clicked on an unloaded node
|
|
336
|
+
if (target.nodeName === 'SPAN' && target.classList.contains('treejs-switcher') && (undefinedChildren.length > 0 || hasUndefinedchild)) {
|
|
337
|
+
// Clear the subnode HTML
|
|
338
|
+
if (undefinedChildren.length > 0) {
|
|
339
|
+
target.parentNode.querySelector('ul').innerHTML = '';
|
|
340
|
+
}
|
|
341
|
+
// If source is webservice (it shouldn't be something else)
|
|
342
|
+
if (this.options.parentApi.theOptions.source == 'webservice') {
|
|
343
|
+
if (this.options.parentApi.theOptions.origin == 'classification') {
|
|
344
|
+
const contextualApiParams = this.options.parentApi.getContextualApiParams(Object.assign(Object.assign({}, this.options.parentApi.theOptions.options), { startNode: target.parentNode.nodeId }));
|
|
345
|
+
const contextualApiURL = this.options.parentApi.getContextualApiURL();
|
|
346
|
+
// WS Call
|
|
347
|
+
this.options.rawDataManager
|
|
348
|
+
.getFromClassification(contextualApiURL, contextualApiParams, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
349
|
+
.then(data => {
|
|
350
|
+
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
// WS Call
|
|
355
|
+
this.options.rawDataManager
|
|
356
|
+
.getFromSource(this.options.parentApi.theOptions.url, {
|
|
357
|
+
StartNodeID: target.parentNode.nodeId,
|
|
358
|
+
lng: this.options.parentApi.theOptions.options.lng,
|
|
359
|
+
IsDeprecated: this.options.parentApi.theOptions.options.IsDeprecated,
|
|
360
|
+
}, document.querySelector("#hierarchized-picker-" + this.options.parentApi.componentID + " .loader"))
|
|
361
|
+
.then(data => {
|
|
362
|
+
this.options.completeCurrentTreeWithTree(this, data, this.options.parentApi.theOptions);
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
370
367
|
const liEle = target.parentNode;
|
|
371
368
|
const ele = liEle.lastChild;
|
|
372
369
|
const height = ele.scrollHeight;
|
|
@@ -404,6 +401,9 @@ Tree.prototype.onSwitcherClick = function (target) {
|
|
|
404
401
|
},
|
|
405
402
|
});
|
|
406
403
|
}
|
|
404
|
+
return new Promise((resolve) => {
|
|
405
|
+
resolve(this);
|
|
406
|
+
});
|
|
407
407
|
};
|
|
408
408
|
Tree.prototype.walkUp = function (node, changeState) {
|
|
409
409
|
const { parent } = node;
|
|
@@ -536,11 +536,10 @@ Tree.prototype.createLiEle = function (node, closed) {
|
|
|
536
536
|
else {
|
|
537
537
|
li.classList.add('treejs-placeholder');
|
|
538
538
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}
|
|
539
|
+
const checkbox = document.createElement('span');
|
|
540
|
+
checkbox.classList.add('treejs-checkbox');
|
|
541
|
+
checkbox.style.display = ((!this.options.parentApi || (this.options.parentApi && this.options.parentApi.theOptions.multiple)) ? "inline-block" : "none");
|
|
542
|
+
li.appendChild(checkbox);
|
|
544
543
|
const label = document.createElement('span');
|
|
545
544
|
label.classList.add('treejs-label');
|
|
546
545
|
const text = document.createTextNode(node.text);
|
|
@@ -11,10 +11,12 @@ export class OptionsManager {
|
|
|
11
11
|
showAutocomplete: false,
|
|
12
12
|
openTreeWhenLoaded: false,
|
|
13
13
|
displayRootNode: false,
|
|
14
|
+
keyboardNavigation: false,
|
|
14
15
|
dragAndDropEnabled: false,
|
|
15
16
|
errorsInInput: true,
|
|
16
17
|
isFullpath: true,
|
|
17
18
|
defaultValue: [],
|
|
19
|
+
defaultValueIsFullpath: false,
|
|
18
20
|
};
|
|
19
21
|
const validatedOptions = Object.assign(Object.assign({}, defaults), options);
|
|
20
22
|
// Validate specific fields
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setupKeyboardNavigation } from '../../features/keyboard-navigation/keyboard-navigation';
|
|
1
2
|
// Utility functions
|
|
2
3
|
export function isInsidePicker(component, target) {
|
|
3
4
|
return target !== null && component.el.contains(target);
|
|
@@ -36,17 +37,17 @@ export function handleFocusEvent(component, type) {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
export function manageFocusOut(component, event) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
|
|
49
|
-
}
|
|
40
|
+
// TODO > REVIEW THIS, IT SEEMS TO PREVENT PROPER FOCUS MANAGEMENT RATHER THAN IMPROVING IT
|
|
41
|
+
// const relatedTarget = (event.relatedTarget || event.target) as HTMLElement;
|
|
42
|
+
// if (!isInsidePicker(component, relatedTarget)) {
|
|
43
|
+
// setTimeout(() => {
|
|
44
|
+
// if (!isInsidePicker(component, document.activeElement)) {
|
|
45
|
+
// handleFocusEvent(component, 'hide');
|
|
46
|
+
// }
|
|
47
|
+
// }, 100);
|
|
48
|
+
// } else {
|
|
49
|
+
// handleFocusEvent(component, 'search');
|
|
50
|
+
// }
|
|
50
51
|
}
|
|
51
52
|
export function clickPickerModalArea(component, _event) {
|
|
52
53
|
if (component.pickerClass === 'fieldError') {
|
|
@@ -58,6 +59,9 @@ export function clickPickerModalArea(component, _event) {
|
|
|
58
59
|
else {
|
|
59
60
|
component.mylog('Ignored modal click');
|
|
60
61
|
}
|
|
62
|
+
if (component.theOptions.mode == 'tree') {
|
|
63
|
+
setupKeyboardNavigation(component, component.optionsManager, component.navigateInTree);
|
|
64
|
+
}
|
|
61
65
|
}
|
|
62
66
|
// Exposed event handlers
|
|
63
67
|
export function focusInSearchEvent(component) {
|
|
@@ -1,67 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
export function setupKeyboardNavigation(component, navigateInTree) {
|
|
3
|
-
|
|
1
|
+
let focusedNodeIndex = 0;
|
|
2
|
+
export function setupKeyboardNavigation(component, optionsManager, navigateInTree) {
|
|
3
|
+
if (!optionsManager.getOptions().keyboardNavigation)
|
|
4
|
+
return;
|
|
5
|
+
const treeArea = component.el.querySelector('.hierarchized-picker-tree-area') || component.el.querySelector('.hierarchized-picker-raw-tree-area');
|
|
4
6
|
if (!treeArea)
|
|
5
7
|
return;
|
|
6
|
-
let focusedNodeIndex = 0;
|
|
7
8
|
function focusNode(allLiElements, liElementToFocus) {
|
|
8
9
|
Object.values(allLiElements).forEach((liNode) => {
|
|
9
10
|
liNode.classList.remove('treejs-node__focused');
|
|
10
11
|
});
|
|
11
12
|
liElementToFocus.classList.add('treejs-node__focused');
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const spaceNode = treeNodesFromTree[focusedNodeIndex];
|
|
21
|
-
const activeNode = treeNodesFromTree[focusedNodeIndex];
|
|
22
|
-
const liElement = tree.liElementsById[activeNode.id];
|
|
23
|
-
switch (event.key) {
|
|
24
|
-
case 'Tab':
|
|
25
|
-
case '0':
|
|
26
|
-
event.preventDefault();
|
|
27
|
-
if (true) { //(spaceNode?.nodeId) {
|
|
28
|
-
component.setNodeAsSelected(spaceNode.nodeId, component.loadedTreeJs, true);
|
|
29
|
-
component.showTree('hide');
|
|
30
|
-
setTimeout(() => focusMainInput(component), 100);
|
|
31
|
-
}
|
|
32
|
-
break;
|
|
33
|
-
case 'ArrowUp':
|
|
34
|
-
event.preventDefault();
|
|
35
|
-
focusedNodeIndex = Math.max(focusedNodeIndex - 1, 0);
|
|
36
|
-
const newActiveNodeUp = treeNodesFromTree[focusedNodeIndex];
|
|
37
|
-
const newLiElementUp = tree.liElementsById[newActiveNodeUp.id];
|
|
38
|
-
focusNode(tree.liElementsById, newLiElementUp);
|
|
39
|
-
break;
|
|
40
|
-
case 'ArrowDown':
|
|
41
|
-
event.preventDefault();
|
|
42
|
-
focusedNodeIndex = Math.min(focusedNodeIndex + 1, treeNodesFromTree.length - 1);
|
|
43
|
-
const newActiveNodeDown = treeNodesFromTree[focusedNodeIndex];
|
|
44
|
-
const newLiElementDown = tree.liElementsById[newActiveNodeDown.id];
|
|
45
|
-
focusNode(tree.liElementsById, newLiElementDown);
|
|
46
|
-
break;
|
|
47
|
-
case 'ArrowLeft':
|
|
48
|
-
event.preventDefault();
|
|
49
|
-
const leftSwitcher = liElement.querySelector('.treejs-switcher');
|
|
50
|
-
if (leftSwitcher) {
|
|
51
|
-
(_a = component.loadedTreeJs) === null || _a === void 0 ? void 0 : _a.onSwitcherClick(leftSwitcher);
|
|
52
|
-
component.showTree('hide');
|
|
14
|
+
function findAllTreeNodes(treeNodes, liElementsById) {
|
|
15
|
+
let allNodes = [];
|
|
16
|
+
const traverse = (nodes) => {
|
|
17
|
+
nodes.forEach(node => {
|
|
18
|
+
allNodes.push(node);
|
|
19
|
+
if (node.children && node.children.length > 0 && !liElementsById[node.id].classList.contains("treejs-node__close")) {
|
|
20
|
+
traverse(node.children);
|
|
53
21
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
traverse(treeNodes);
|
|
25
|
+
return allNodes;
|
|
26
|
+
}
|
|
27
|
+
focusedNodeIndex = 0;
|
|
28
|
+
if (component && component.loadedTreeJs && component.loadedTreeJs.liElementsById && component.loadedTreeJs.treeNodes) {
|
|
29
|
+
focusNode(component.loadedTreeJs.liElementsById, component.loadedTreeJs.liElementsById[component.loadedTreeJs.treeNodes[focusedNodeIndex].id]);
|
|
30
|
+
}
|
|
31
|
+
if (!component._keydownListenerAdded) {
|
|
32
|
+
component._keydownListenerAdded = true;
|
|
33
|
+
component.el.addEventListener('keydown', (event) => {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
event.stopPropagation();
|
|
36
|
+
const tree = component.loadedTreeJs;
|
|
37
|
+
let treeNodesFromTree = findAllTreeNodes(tree.treeNodes, tree.liElementsById);
|
|
38
|
+
if (!tree || !treeNodesFromTree.length)
|
|
39
|
+
return;
|
|
40
|
+
let spaceNode = treeNodesFromTree[focusedNodeIndex];
|
|
41
|
+
let activeNode = treeNodesFromTree[focusedNodeIndex];
|
|
42
|
+
let liElement = tree.liElementsById[activeNode.id];
|
|
43
|
+
const handledEvents = ['tab', '0', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright'];
|
|
44
|
+
switch (event.key.toLowerCase()) {
|
|
45
|
+
case 'tab':
|
|
46
|
+
case '0':
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
if (true) { //(spaceNode?.nodeId) {
|
|
49
|
+
component.setNodeAsSelected(spaceNode.nodeId, component.loadedTreeJs, true);
|
|
50
|
+
if (optionsManager.getOptions().mode != "tree" && !optionsManager.getOptions().multiple) {
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
component.showTree('hide');
|
|
53
|
+
// TODO put back? >> focusMainInput(component);
|
|
54
|
+
}, 100);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
case 'arrowup':
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
focusedNodeIndex = Math.max(focusedNodeIndex - 1, 0);
|
|
61
|
+
const newActiveNodeUp = treeNodesFromTree[focusedNodeIndex];
|
|
62
|
+
const newLiElementUp = tree.liElementsById[newActiveNodeUp.id];
|
|
63
|
+
newLiElementUp.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
64
|
+
focusNode(tree.liElementsById, newLiElementUp);
|
|
65
|
+
break;
|
|
66
|
+
case 'arrowdown':
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
focusedNodeIndex = Math.min(focusedNodeIndex + 1, treeNodesFromTree.length - 1);
|
|
69
|
+
const newActiveNodeDown = treeNodesFromTree[focusedNodeIndex];
|
|
70
|
+
const newLiElementDown = tree.liElementsById[newActiveNodeDown.id];
|
|
71
|
+
focusNode(tree.liElementsById, newLiElementDown);
|
|
72
|
+
newLiElementDown.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
73
|
+
break;
|
|
74
|
+
case 'arrowleft':
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
const leftSwitcher = liElement.querySelector('.treejs-switcher');
|
|
77
|
+
if (leftSwitcher) {
|
|
78
|
+
(_a = component.loadedTreeJs) === null || _a === void 0 ? void 0 : _a.onSwitcherClick(leftSwitcher);
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
case 'arrowright':
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
const rightSwitcher = liElement.querySelector('.treejs-switcher');
|
|
84
|
+
if (rightSwitcher) {
|
|
85
|
+
(_b = component.loadedTreeJs) === null || _b === void 0 ? void 0 : _b.onSwitcherClick(rightSwitcher);
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
if (handledEvents.includes(event.key.toLowerCase()))
|
|
90
|
+
navigateInTree.emit(event);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
67
93
|
}
|
|
@@ -47,7 +47,7 @@ export function findNodeById(tree, nodeId) {
|
|
|
47
47
|
/**
|
|
48
48
|
* Fills the tree with nodes based on the provided object.
|
|
49
49
|
*/
|
|
50
|
-
export function fillTreeWithObject(tree, myObject, searched, options
|
|
50
|
+
export function fillTreeWithObject(tree, myObject, searched, options) {
|
|
51
51
|
const searchResultPresentsUnMatched = options.searchResultPresentsUnMatched;
|
|
52
52
|
if (myObject && myObject.length) {
|
|
53
53
|
myObject.forEach(value => {
|
|
@@ -79,7 +79,6 @@ export function fillTreeWithObject(tree, myObject, searched, options, depth = 0)
|
|
|
79
79
|
const objToPush = {
|
|
80
80
|
id: keyPropFromNode,
|
|
81
81
|
nodeId: keyPropFromNode,
|
|
82
|
-
depth,
|
|
83
82
|
text: valueTranslatedPropFromNode,
|
|
84
83
|
fullpath: fullpathPropFromNode,
|
|
85
84
|
fullpathTranslated: fullpathTranslatedPropFromNode,
|
|
@@ -88,7 +87,7 @@ export function fillTreeWithObject(tree, myObject, searched, options, depth = 0)
|
|
|
88
87
|
isDesaturated: false,
|
|
89
88
|
searchMatch: false,
|
|
90
89
|
};
|
|
91
|
-
const childTree = fillTreeWithObject(objToPush.children, childrenPropFromNode, searched, options
|
|
90
|
+
const childTree = fillTreeWithObject(objToPush.children, childrenPropFromNode, searched, options);
|
|
92
91
|
let pushMe = false;
|
|
93
92
|
if (searched) {
|
|
94
93
|
const matched = searchValue(objToPush, false, searched);
|
|
@@ -114,6 +113,11 @@ export function completeCurrentTreeWithTree(treeJsInstance, newTree, options) {
|
|
|
114
113
|
var _a;
|
|
115
114
|
const ElmID = newTree.key || newTree.id || newTree.ID;
|
|
116
115
|
const targetNode = findNodeById(treeJsInstance, ElmID);
|
|
116
|
+
if (ElmID == 0 && newTree.children && newTree.children.length > 0) {
|
|
117
|
+
newTree.children.forEach(child => {
|
|
118
|
+
completeCurrentTreeWithTree(treeJsInstance, child, options);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
117
121
|
if (targetNode) {
|
|
118
122
|
targetNode.children = [];
|
|
119
123
|
let ulElem = (_a = treeJsInstance.liElementsById[ElmID]) === null || _a === void 0 ? void 0 : _a.querySelector('ul');
|
|
@@ -129,6 +133,11 @@ export function completeCurrentTreeWithTree(treeJsInstance, newTree, options) {
|
|
|
129
133
|
targetNode.children.push(item);
|
|
130
134
|
treeJsInstance.nodesById[item.id] = item;
|
|
131
135
|
treeJsInstance.liElementsById[item.id] = liElm;
|
|
136
|
+
if (item.children && item.children.some(child => Object.keys(child).length > 0)) {
|
|
137
|
+
newTree.children.forEach(child => {
|
|
138
|
+
completeCurrentTreeWithTree(treeJsInstance, child, options);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
132
141
|
});
|
|
133
142
|
}
|
|
134
143
|
}
|
|
@@ -99,6 +99,10 @@ export function isInstanceOfIConf(object) {
|
|
|
99
99
|
toret = false;
|
|
100
100
|
errorToLog = "options.displayRootNode value '" + object.displayRootNode + "' doesn't meet interface IConf requirements";
|
|
101
101
|
}
|
|
102
|
+
if (!((!object.keyboardNavigation && typeof object.keyboardNavigation != 'boolean') || typeof object.keyboardNavigation == 'boolean')) {
|
|
103
|
+
toret = false;
|
|
104
|
+
errorToLog = "options.keyboardNavigation value '" + object.keyboardNavigation + "' doesn't meet interface IConf requirements";
|
|
105
|
+
}
|
|
102
106
|
if (!((!object.dragAndDropEnabled && typeof object.dragAndDropEnabled != 'boolean') || typeof object.dragAndDropEnabled == 'boolean')) {
|
|
103
107
|
toret = false;
|
|
104
108
|
errorToLog = "options.dragAndDropEnabled value '" + object.dragAndDropEnabled + "' doesn't meet interface IConf requirements";
|
|
@@ -6,17 +6,18 @@ export const defaultPickerTheme = {
|
|
|
6
6
|
primary: {
|
|
7
7
|
main: '#888',
|
|
8
8
|
light: '#888',
|
|
9
|
-
contrastText: '#000',
|
|
9
|
+
contrastText: '#000', // Text color of the selected node
|
|
10
10
|
},
|
|
11
11
|
background: {
|
|
12
12
|
default: '#ccc',
|
|
13
13
|
light: '#eee',
|
|
14
14
|
main: '#000',
|
|
15
|
-
dark: '#fff',
|
|
15
|
+
dark: '#fff', // Background of the whole tree
|
|
16
16
|
},
|
|
17
17
|
text: {
|
|
18
|
-
primary: '#000',
|
|
18
|
+
primary: '#000', // Text color
|
|
19
19
|
},
|
|
20
|
+
// For all inputs in the component, includes in modale mode the display input and the search input
|
|
20
21
|
input: {
|
|
21
22
|
background: '#fff',
|
|
22
23
|
borderStyle: 'none'
|
|
@@ -7,6 +7,7 @@ export function applyPickerTheme(theme, defaultTheme) {
|
|
|
7
7
|
docstyle.setProperty('--hpicker-theme-palette-background-default', (theme === null || theme === void 0 ? void 0 : theme.palette.background.default) || defaultTheme.palette.background.default);
|
|
8
8
|
docstyle.setProperty('--hpicker-theme-palette-background-light', (theme === null || theme === void 0 ? void 0 : theme.palette.background.light) || defaultTheme.palette.background.light);
|
|
9
9
|
docstyle.setProperty('--hpicker-theme-palette-background-dark', (theme === null || theme === void 0 ? void 0 : theme.palette.background.dark) || defaultTheme.palette.background.dark);
|
|
10
|
+
docstyle.setProperty('--hpicker-theme-palette-font-color', (theme === null || theme === void 0 ? void 0 : theme.palette.text.primary) || defaultTheme.palette.text.primary);
|
|
10
11
|
docstyle.setProperty('--hpicker-theme-palette-input-background-color', (theme === null || theme === void 0 ? void 0 : theme.palette.input.background) || defaultTheme.palette.input.background);
|
|
11
12
|
docstyle.setProperty('--hpicker-theme-palette-input-border-style', (theme === null || theme === void 0 ? void 0 : theme.palette.input.borderStyle) || defaultTheme.palette.input.borderStyle);
|
|
12
13
|
docstyle.setProperty('--hpicker-theme-typography-body-font-size', (theme === null || theme === void 0 ? void 0 : theme.typography.body.fontSize) || defaultTheme.typography.body.fontSize);
|