@openeuropa/bcl-theme-joinup 1.10.5 → 1.10.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/bcl-builder.config.js +2 -0
- package/css/oe-bcl-joinup.css +581 -91
- package/css/oe-bcl-joinup.css.map +1 -1
- package/css/oe-bcl-joinup.min.css +1 -1
- package/css/oe-bcl-joinup.min.css.map +1 -1
- package/js/oe-bcl-joinup.bundle.js +187 -0
- package/js/oe-bcl-joinup.bundle.js.map +1 -1
- package/js/oe-bcl-joinup.bundle.min.js +1 -1
- package/js/oe-bcl-joinup.bundle.min.js.map +1 -1
- package/js/oe-bcl-joinup.esm.js +186 -1
- package/js/oe-bcl-joinup.esm.js.map +1 -1
- package/js/oe-bcl-joinup.esm.min.js +1 -1
- package/js/oe-bcl-joinup.esm.min.js.map +1 -1
- package/js/oe-bcl-joinup.umd.js +187 -0
- package/js/oe-bcl-joinup.umd.js.map +1 -1
- package/js/oe-bcl-joinup.umd.min.js +1 -1
- package/js/oe-bcl-joinup.umd.min.js.map +1 -1
- package/js/slim-select-2/slimselect.min.js +1 -1
- package/package.json +6 -6
- package/src/js/index.esm.js +4 -0
- package/src/js/index.umd.js +4 -0
- package/src/scss/oe-bcl-joinup.scss +1 -0
- package/templates/bcl-button/button.html.twig +3 -2
- package/templates/bcl-header/header.html.twig +37 -6
- package/templates/bcl-mega-menu/mega-menu-items.html.twig +35 -0
- package/templates/bcl-mega-menu/mega-menu-submenu.html.twig +65 -0
- package/templates/bcl-mega-menu/mega-menu.html.twig +115 -0
- package/templates/bcl-navigation/navigation.html.twig +3 -1
- package/templates/bcl-offcanvas/offcanvas.html.twig +9 -6
package/js/oe-bcl-joinup.umd.js
CHANGED
|
@@ -4834,6 +4834,191 @@
|
|
|
4834
4834
|
}
|
|
4835
4835
|
}
|
|
4836
4836
|
|
|
4837
|
+
class MainNavigation {
|
|
4838
|
+
constructor(toggler) {
|
|
4839
|
+
this.toggler = toggler;
|
|
4840
|
+
this.top = 0;
|
|
4841
|
+
this.target = this.getTargetFromToggler(toggler);
|
|
4842
|
+
if (!this.target) return;
|
|
4843
|
+
this.addListeners();
|
|
4844
|
+
}
|
|
4845
|
+
getTargetFromToggler(toggler) {
|
|
4846
|
+
const selector = toggler.getAttribute("data-bs-target");
|
|
4847
|
+
if (!selector) return null;
|
|
4848
|
+
try {
|
|
4849
|
+
return document.querySelector(selector);
|
|
4850
|
+
} catch {
|
|
4851
|
+
return null;
|
|
4852
|
+
}
|
|
4853
|
+
}
|
|
4854
|
+
addListeners() {
|
|
4855
|
+
EventHandler.on(this.target, "show.bs.collapse", () => {
|
|
4856
|
+
window.scrollTo(0, this.top);
|
|
4857
|
+
});
|
|
4858
|
+
}
|
|
4859
|
+
static init(selector = ".bcl-toggler", options) {
|
|
4860
|
+
const togglers = SelectorEngine.find(selector);
|
|
4861
|
+
togglers.forEach(toggler => new MainNavigation(toggler, options));
|
|
4862
|
+
}
|
|
4863
|
+
}
|
|
4864
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
4865
|
+
// Run for all .bcl-toggler buttons
|
|
4866
|
+
MainNavigation.init(".bcl-navbar-toggler");
|
|
4867
|
+
});
|
|
4868
|
+
|
|
4869
|
+
class MegaMenu {
|
|
4870
|
+
constructor(root) {
|
|
4871
|
+
this.root = root;
|
|
4872
|
+
this.backButton = SelectorEngine.findOne(".back-button", this.root);
|
|
4873
|
+
this.trigger = SelectorEngine.findOne(':scope > .dropdown-toggle[data-bs-toggle="dropdown"]', this.root);
|
|
4874
|
+
this.ul = SelectorEngine.findOne('.bcl-mega-menu__items.__level-1', this.root);
|
|
4875
|
+
this.addSubmenuTriggerListeners();
|
|
4876
|
+
this.addBackButtonListener();
|
|
4877
|
+
this.addTriggerListeners();
|
|
4878
|
+
this.addEscapeKeyHandler();
|
|
4879
|
+
}
|
|
4880
|
+
getPanelForTrigger(trigger) {
|
|
4881
|
+
const id = trigger.getAttribute('aria-controls');
|
|
4882
|
+
return id ? document.getElementById(id) : null;
|
|
4883
|
+
}
|
|
4884
|
+
getFocusableChildren(container) {
|
|
4885
|
+
if (!container) return [];
|
|
4886
|
+
return Array.from(container.querySelectorAll('a[href], button:not([disabled]):not(.back-button), [tabindex]:not([tabindex="-1"])')).filter(el => !el.hasAttribute('disabled') && el.tabIndex !== -1);
|
|
4887
|
+
}
|
|
4888
|
+
focusFirstItemInPanel(trigger) {
|
|
4889
|
+
const panel = this.getPanelForTrigger(trigger);
|
|
4890
|
+
if (!panel) return;
|
|
4891
|
+
const list = SelectorEngine.findOne('ul.bcl-mega-menu__items', panel);
|
|
4892
|
+
if (!list) return;
|
|
4893
|
+
const first = this.getFocusableChildren(list)[0];
|
|
4894
|
+
if (first) first.focus();
|
|
4895
|
+
}
|
|
4896
|
+
addEscapeKeyHandler() {
|
|
4897
|
+
// Bootstrap attaches its dropdown keydown listener on `document` in the capture phase.
|
|
4898
|
+
// By listening on `window` in the capture phase, our handler runs *before* Bootstrap’s.
|
|
4899
|
+
// This lets us intercept Esc inside mega menu submenus and stop Bootstrap from closing
|
|
4900
|
+
// the entire dropdown.
|
|
4901
|
+
window.addEventListener('keydown', e => {
|
|
4902
|
+
if (e.key !== 'Escape') return;
|
|
4903
|
+
|
|
4904
|
+
// Only act if Esc originated inside THIS mega menu's open submenu
|
|
4905
|
+
const panel = e.target.closest('.bcl-mega-menu__submenu');
|
|
4906
|
+
if (!panel || panel.hidden || !this.root.contains(panel)) {
|
|
4907
|
+
// Not our submenu: let Bootstrap handle it normally
|
|
4908
|
+
return;
|
|
4909
|
+
}
|
|
4910
|
+
|
|
4911
|
+
// Stop the event BEFORE it reaches Bootstrap's document-capture handler
|
|
4912
|
+
e.preventDefault();
|
|
4913
|
+
e.stopImmediatePropagation();
|
|
4914
|
+
e.stopPropagation();
|
|
4915
|
+
|
|
4916
|
+
// Close only this submenu and focus its trigger
|
|
4917
|
+
const triggerId = panel.getAttribute('aria-labelledby');
|
|
4918
|
+
const trigger = triggerId ? document.getElementById(triggerId) : null;
|
|
4919
|
+
if (trigger) {
|
|
4920
|
+
this.closeSubmenu(trigger);
|
|
4921
|
+
trigger.focus();
|
|
4922
|
+
}
|
|
4923
|
+
}, true);
|
|
4924
|
+
}
|
|
4925
|
+
addTriggerListeners() {
|
|
4926
|
+
if (!this.trigger) return;
|
|
4927
|
+
|
|
4928
|
+
// When the mega menu is opened, focus the first item in the menu.
|
|
4929
|
+
EventHandler.on(this.trigger, 'shown.bs.dropdown', () => {
|
|
4930
|
+
const panelId = this.trigger.getAttribute('aria-controls');
|
|
4931
|
+
const panel = panelId ? document.getElementById(panelId) : null;
|
|
4932
|
+
const firstFocusable = panel ? this.getFocusableChildren(panel)[0] : null;
|
|
4933
|
+
if (firstFocusable) firstFocusable.focus();
|
|
4934
|
+
});
|
|
4935
|
+
|
|
4936
|
+
// When the mega menu is closed, close all submenus.
|
|
4937
|
+
EventHandler.on(this.trigger, 'hide.bs.dropdown', () => {
|
|
4938
|
+
this.closeAllSubmenus();
|
|
4939
|
+
});
|
|
4940
|
+
}
|
|
4941
|
+
addSubmenuTriggerListeners() {
|
|
4942
|
+
// Clicking/activating a parent item button toggles the submenu.
|
|
4943
|
+
SelectorEngine.find(':scope li > button[aria-expanded]', this.root).forEach(trigger => {
|
|
4944
|
+
EventHandler.on(trigger, "click", () => {
|
|
4945
|
+
const expanded = trigger.getAttribute('aria-expanded') === 'true';
|
|
4946
|
+
if (expanded) {
|
|
4947
|
+
// Close this submenu.
|
|
4948
|
+
this.closeSubmenu(trigger);
|
|
4949
|
+
} else {
|
|
4950
|
+
this.openSubmenu(trigger);
|
|
4951
|
+
// The back button is only visible in mobile / narrow viewport.
|
|
4952
|
+
if (this.backButton && this.backButton.offsetParent !== null) {
|
|
4953
|
+
this.backButton.focus();
|
|
4954
|
+
} else {
|
|
4955
|
+
this.focusFirstItemInPanel(trigger);
|
|
4956
|
+
}
|
|
4957
|
+
}
|
|
4958
|
+
});
|
|
4959
|
+
});
|
|
4960
|
+
}
|
|
4961
|
+
addBackButtonListener() {
|
|
4962
|
+
// Clicking a back button closes the submenu or the menu itself.
|
|
4963
|
+
if (!this.backButton) {
|
|
4964
|
+
return;
|
|
4965
|
+
}
|
|
4966
|
+
EventHandler.on(this.backButton, "click", () => {
|
|
4967
|
+
const submenusThatWereOpen = this.closeAllSubmenus();
|
|
4968
|
+
if (submenusThatWereOpen.length > 0) {
|
|
4969
|
+
// Focus the submenu trigger, to allow quick reopen by keystroke.
|
|
4970
|
+
submenusThatWereOpen[0].focus();
|
|
4971
|
+
return;
|
|
4972
|
+
}
|
|
4973
|
+
// Close the mega menu itself.
|
|
4974
|
+
if (this.trigger) {
|
|
4975
|
+
// Close using the Bootstrap dropdown API.
|
|
4976
|
+
Dropdown.getOrCreateInstance(this.trigger).hide();
|
|
4977
|
+
// Focus the main trigger, to allow quick reopen by keystroke.
|
|
4978
|
+
this.trigger.focus();
|
|
4979
|
+
}
|
|
4980
|
+
});
|
|
4981
|
+
}
|
|
4982
|
+
openSubmenu(trigger) {
|
|
4983
|
+
// Close all submenus, then open the current submenu.
|
|
4984
|
+
this.closeAllSubmenus();
|
|
4985
|
+
trigger.setAttribute('aria-expanded', 'true');
|
|
4986
|
+
const panel = this.getPanelForTrigger(trigger);
|
|
4987
|
+
if (panel) panel.hidden = false;
|
|
4988
|
+
}
|
|
4989
|
+
|
|
4990
|
+
/**
|
|
4991
|
+
* Closes all submenus.
|
|
4992
|
+
*
|
|
4993
|
+
* This is simple while there is only one submenu level.
|
|
4994
|
+
*
|
|
4995
|
+
* @returns {HTMLElement[]}
|
|
4996
|
+
* Triggers for submenus that were closed.
|
|
4997
|
+
* Usually this is either exactly one, or none.
|
|
4998
|
+
*/
|
|
4999
|
+
closeAllSubmenus() {
|
|
5000
|
+
if (!this.ul) {
|
|
5001
|
+
return;
|
|
5002
|
+
}
|
|
5003
|
+
const triggers = SelectorEngine.find(':scope > li > button[aria-expanded="true"]', this.ul);
|
|
5004
|
+
// Use arrow fn to keep `this` bound.
|
|
5005
|
+
triggers.forEach(t => this.closeSubmenu(t));
|
|
5006
|
+
return triggers;
|
|
5007
|
+
}
|
|
5008
|
+
closeSubmenu(trigger) {
|
|
5009
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
5010
|
+
const panel = this.getPanelForTrigger(trigger);
|
|
5011
|
+
if (panel) panel.hidden = true;
|
|
5012
|
+
}
|
|
5013
|
+
static init(selector = ".bcl-mega-menu") {
|
|
5014
|
+
const megaMenus = SelectorEngine.find(selector);
|
|
5015
|
+
megaMenus.forEach(menuEl => new MegaMenu(menuEl));
|
|
5016
|
+
}
|
|
5017
|
+
}
|
|
5018
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
5019
|
+
MegaMenu.init();
|
|
5020
|
+
});
|
|
5021
|
+
|
|
4837
5022
|
/**
|
|
4838
5023
|
* --------------------------------------------------------------------------
|
|
4839
5024
|
* Bootstrap util/sanitizer.js
|
|
@@ -6748,6 +6933,8 @@
|
|
|
6748
6933
|
Dropdown,
|
|
6749
6934
|
Gallery,
|
|
6750
6935
|
Modal,
|
|
6936
|
+
MainNavigation,
|
|
6937
|
+
MegaMenu,
|
|
6751
6938
|
AccessibleToggle,
|
|
6752
6939
|
AccordionToggle,
|
|
6753
6940
|
Offcanvas,
|