@openeuropa/bcl-theme-joinup 1.5.0 → 1.7.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.
@@ -4697,6 +4697,50 @@
4697
4697
 
4698
4698
  defineJQueryPlugin(Offcanvas);
4699
4699
 
4700
+ /**
4701
+ * AccessibleToggle enhances Bootstrap Modal and Offcanvas components by:
4702
+ * - Adding ARIA attributes for improved accessibility.
4703
+ * - Updating `aria-expanded` on trigger elements based on visibility.
4704
+ * Automatically initializes all modal and offcanvas triggers on the page.
4705
+ */
4706
+ class AccessibleToggle {
4707
+ constructor(triggerElement, type) {
4708
+ this.triggerElement = triggerElement;
4709
+ this.type = type;
4710
+ const target = triggerElement.getAttribute("data-bs-target") || triggerElement.getAttribute("href");
4711
+ this.targetElement = SelectorEngine.findOne(target);
4712
+ if (this.type === "modal") {
4713
+ this.instance = Modal.getOrCreateInstance(this.targetElement);
4714
+ } else if (this.type === "offcanvas") {
4715
+ this.instance = Offcanvas.getOrCreateInstance(this.targetElement);
4716
+ }
4717
+ this.addAriaAttributes();
4718
+ this.addEventListeners();
4719
+ }
4720
+ addAriaAttributes() {
4721
+ if (this.triggerElement) {
4722
+ this.triggerElement.setAttribute("aria-haspopup", "true");
4723
+ this.triggerElement.setAttribute("aria-expanded", "false");
4724
+ }
4725
+ }
4726
+ addEventListeners() {
4727
+ const showEvent = this.type === "modal" ? "show.bs.modal" : "show.bs.offcanvas";
4728
+ const hideEvent = this.type === "modal" ? "hide.bs.modal" : "hide.bs.offcanvas";
4729
+ EventHandler.on(this.targetElement, showEvent, () => {
4730
+ this.triggerElement.setAttribute("aria-expanded", "true");
4731
+ });
4732
+ EventHandler.on(this.targetElement, hideEvent, () => {
4733
+ this.triggerElement.setAttribute("aria-expanded", "false");
4734
+ });
4735
+ }
4736
+ static init(toggles) {
4737
+ toggles.forEach(toggle => {
4738
+ const triggerElements = SelectorEngine.find(toggle.selector);
4739
+ triggerElements.forEach(triggerElement => new AccessibleToggle(triggerElement, toggle.type));
4740
+ });
4741
+ }
4742
+ }
4743
+
4700
4744
  /**
4701
4745
  * --------------------------------------------------------------------------
4702
4746
  * Bootstrap (v5.2.3): util/sanitizer.js
@@ -6511,6 +6555,7 @@
6511
6555
  Dropdown,
6512
6556
  Gallery,
6513
6557
  Modal,
6558
+ AccessibleToggle,
6514
6559
  Offcanvas,
6515
6560
  Popover,
6516
6561
  ScrollSpyV2: ScrollSpy$1,