@agorapulse/ui-components 20.1.5 → 20.1.7
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/agorapulse-ui-components-20.1.7.tgz +0 -0
- package/fesm2022/agorapulse-ui-components-nav-selector.mjs +61 -10
- package/fesm2022/agorapulse-ui-components-nav-selector.mjs.map +1 -1
- package/nav-selector/index.d.ts +1 -0
- package/package.json +1 -1
- package/agorapulse-ui-components-20.1.5.tgz +0 -0
|
Binary file
|
|
@@ -403,6 +403,18 @@ const computeNumberOfDisplayableChildrenOnUnfold = (entry) => {
|
|
|
403
403
|
}
|
|
404
404
|
return 0;
|
|
405
405
|
};
|
|
406
|
+
const computeSelectableUids = (entries) => {
|
|
407
|
+
return entries.flatMap(entry => computeSelectableUidsByEntry(entry));
|
|
408
|
+
};
|
|
409
|
+
const computeSelectableUidsByEntry = (entry) => {
|
|
410
|
+
if (isInternalNavSelectorEntryALeaf(entry) && !entry.disabled) {
|
|
411
|
+
return [entry.uid, ...entry.details.filter(detail => !detail.hidden).map(detail => detail.uid)];
|
|
412
|
+
}
|
|
413
|
+
if (isInternalNavSelectorEntryANode(entry)) {
|
|
414
|
+
return [entry.uid, ...entry.children.flatMap(child => computeSelectableUidsByEntry(child))];
|
|
415
|
+
}
|
|
416
|
+
return [];
|
|
417
|
+
};
|
|
406
418
|
|
|
407
419
|
/**
|
|
408
420
|
* Class to handle the folding and unfolding of nav selector entries.
|
|
@@ -1718,15 +1730,47 @@ class NavSelectorState {
|
|
|
1718
1730
|
if (!leaf.selectable) {
|
|
1719
1731
|
return;
|
|
1720
1732
|
}
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1733
|
+
this.entries.update(entries => {
|
|
1734
|
+
let updatedEntries = entries;
|
|
1735
|
+
if (leaf.foldable) {
|
|
1736
|
+
const options = this.getFoldingOptions();
|
|
1737
|
+
const unfoldedLeafUids = this.findUnfoldedLeafUids(entries);
|
|
1738
|
+
for (const uid of unfoldedLeafUids) {
|
|
1739
|
+
updatedEntries = NavSelectorFolding.fold(updatedEntries, uid, options);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
if (this.multipleModeEnabled()) {
|
|
1743
|
+
return NavSelectorMultiSelect.selectInMultipleMode(updatedEntries, leaf.uid);
|
|
1744
|
+
}
|
|
1745
|
+
else {
|
|
1746
|
+
return NavSelectorSingleSelect.select(updatedEntries, leaf.uid);
|
|
1747
|
+
}
|
|
1748
|
+
});
|
|
1727
1749
|
}
|
|
1728
1750
|
onLeafToggleFolding(leaf) {
|
|
1729
|
-
this.entries.update(entries =>
|
|
1751
|
+
this.entries.update(entries => {
|
|
1752
|
+
const options = this.getFoldingOptions();
|
|
1753
|
+
// Find all unfolded leaves and fold them first
|
|
1754
|
+
let updatedEntries = entries;
|
|
1755
|
+
const unfoldedLeafUids = this.findUnfoldedLeafUids(entries);
|
|
1756
|
+
for (const uid of unfoldedLeafUids) {
|
|
1757
|
+
updatedEntries = NavSelectorFolding.fold(updatedEntries, uid, options);
|
|
1758
|
+
}
|
|
1759
|
+
// Then unfold the clicked leaf
|
|
1760
|
+
return NavSelectorFolding.toggleFolding(updatedEntries, leaf.uid, options);
|
|
1761
|
+
});
|
|
1762
|
+
}
|
|
1763
|
+
findUnfoldedLeafUids(entries) {
|
|
1764
|
+
const unfoldedUids = [];
|
|
1765
|
+
for (const entry of entries) {
|
|
1766
|
+
if (isInternalNavSelectorEntryALeaf(entry) && entry.foldable && !entry.folded) {
|
|
1767
|
+
unfoldedUids.push(entry.uid);
|
|
1768
|
+
}
|
|
1769
|
+
else if (isInternalNavSelectorEntryANode(entry)) {
|
|
1770
|
+
unfoldedUids.push(...this.findUnfoldedLeafUids(entry.children));
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
return unfoldedUids;
|
|
1730
1774
|
}
|
|
1731
1775
|
onLeafDetailClicked(leafDetail) {
|
|
1732
1776
|
this.entries.update(entries => NavSelectorSingleSelect.select(entries, leafDetail.uid));
|
|
@@ -1776,12 +1820,18 @@ class NavSelectorState {
|
|
|
1776
1820
|
entries = NavSelectorMultiSelect.selectInMultipleMode(entries, uid);
|
|
1777
1821
|
}
|
|
1778
1822
|
for (const uid of uidToSelect) {
|
|
1779
|
-
entries = NavSelectorFolding.unfoldParents(entries, uid, {
|
|
1823
|
+
entries = NavSelectorFolding.unfoldParents(entries, uid, {
|
|
1824
|
+
multipleMode: true,
|
|
1825
|
+
minified: !this.expanded(),
|
|
1826
|
+
});
|
|
1780
1827
|
}
|
|
1781
1828
|
}
|
|
1782
1829
|
else {
|
|
1783
1830
|
entries = NavSelectorSingleSelect.select(entries, uids[0]);
|
|
1784
|
-
entries = NavSelectorFolding.unfoldParents(entries, uids[0], {
|
|
1831
|
+
entries = NavSelectorFolding.unfoldParents(entries, uids[0], {
|
|
1832
|
+
multipleMode: false,
|
|
1833
|
+
minified: !this.expanded(),
|
|
1834
|
+
});
|
|
1785
1835
|
}
|
|
1786
1836
|
this.entries.set(entries);
|
|
1787
1837
|
}
|
|
@@ -2783,8 +2833,9 @@ class NavSelectorComponent {
|
|
|
2783
2833
|
untracked(() => this.navSelectorState.updateDetailsDisplayedLimit(detailsDisplayedLimit));
|
|
2784
2834
|
});
|
|
2785
2835
|
effect(() => {
|
|
2786
|
-
const selectedEntryUids = this.selectedEntryUids();
|
|
2787
2836
|
const isInit = !!this.navSelectorState.entries().length;
|
|
2837
|
+
const selectableEntryUids = computeSelectableUids(this.navSelectorState.entries());
|
|
2838
|
+
const selectedEntryUids = this.selectedEntryUids().filter(uid => selectableEntryUids.includes(uid));
|
|
2788
2839
|
untracked(() => isInit && this.navSelectorState.onSelectionChange(selectedEntryUids));
|
|
2789
2840
|
});
|
|
2790
2841
|
effect(() => {
|