@openeuropa/bcl-theme-joinup 1.10.0 → 1.10.2

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.
@@ -200,7 +200,7 @@
200
200
  * @param {HTMLElement} element
201
201
  * @return void
202
202
  *
203
- * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
203
+ * @see https://www.harrytheo.com/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
204
204
  */
205
205
  const reflow = element => {
206
206
  element.offsetHeight; // eslint-disable-line no-unused-expressions
@@ -245,7 +245,7 @@
245
245
  });
246
246
  };
247
247
  const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {
248
- return typeof possibleCallback === 'function' ? possibleCallback(...args) : defaultValue;
248
+ return typeof possibleCallback === 'function' ? possibleCallback.call(...args) : defaultValue;
249
249
  };
250
250
  const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
251
251
  if (!waitForTransition) {
@@ -567,7 +567,7 @@
567
567
  const bsKeys = Object.keys(element.dataset).filter(key => key.startsWith('bs') && !key.startsWith('bsConfig'));
568
568
  for (const key of bsKeys) {
569
569
  let pureKey = key.replace(/^bs/, '');
570
- pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
570
+ pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1);
571
571
  attributes[pureKey] = normalizeData$1(element.dataset[key]);
572
572
  }
573
573
  return attributes;
@@ -642,7 +642,7 @@
642
642
  * Constants
643
643
  */
644
644
 
645
- const VERSION = '5.3.3';
645
+ const VERSION = '5.3.6';
646
646
 
647
647
  /**
648
648
  * Class definition
@@ -668,6 +668,8 @@
668
668
  this[propertyName] = null;
669
669
  }
670
670
  }
671
+
672
+ // Private
671
673
  _queueCallback(callback, element, isAnimated = true) {
672
674
  executeAfterTransition(callback, element, isAnimated);
673
675
  }
@@ -1599,11 +1601,11 @@
1599
1601
  this._element.style[dimension] = '';
1600
1602
  this._queueCallback(complete, this._element, true);
1601
1603
  }
1604
+
1605
+ // Private
1602
1606
  _isShown(element = this._element) {
1603
1607
  return element.classList.contains(CLASS_NAME_SHOW$7);
1604
1608
  }
1605
-
1606
- // Private
1607
1609
  _configAfterMerge(config) {
1608
1610
  config.toggle = Boolean(config.toggle); // Coerce string values
1609
1611
  config.parent = getElement$1(config.parent);
@@ -3369,7 +3371,7 @@
3369
3371
  const EVENT_SHOW$5 = `show${EVENT_KEY$8}`;
3370
3372
  const EVENT_SHOWN$5 = `shown${EVENT_KEY$8}`;
3371
3373
  const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$8}${DATA_API_KEY$5}`;
3372
- const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$8}${DATA_API_KEY$5}`;
3374
+ const EVENT_KEYDOWN_DATA_API$1 = `keydown${EVENT_KEY$8}${DATA_API_KEY$5}`;
3373
3375
  const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$8}${DATA_API_KEY$5}`;
3374
3376
  const CLASS_NAME_SHOW$6 = 'show';
3375
3377
  const CLASS_NAME_DROPUP = 'dropup';
@@ -3509,6 +3511,9 @@
3509
3511
  this._element.setAttribute('aria-expanded', 'false');
3510
3512
  Manipulator$1.removeDataAttribute(this._menu, 'popper');
3511
3513
  EventHandler.trigger(this._element, EVENT_HIDDEN$5, relatedTarget);
3514
+
3515
+ // Explicitly return focus to the trigger element
3516
+ this._element.focus();
3512
3517
  }
3513
3518
  _getConfig(config) {
3514
3519
  config = super._getConfig(config);
@@ -3520,7 +3525,7 @@
3520
3525
  }
3521
3526
  _createPopper() {
3522
3527
  if (typeof Popper === 'undefined') {
3523
- throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
3528
+ throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org/docs/v2/)');
3524
3529
  }
3525
3530
  let referenceElement = this._element;
3526
3531
  if (this._config.reference === 'parent') {
@@ -3599,7 +3604,7 @@
3599
3604
  }
3600
3605
  return {
3601
3606
  ...defaultBsPopperConfig,
3602
- ...execute(this._config.popperConfig, [defaultBsPopperConfig])
3607
+ ...execute(this._config.popperConfig, [undefined, defaultBsPopperConfig])
3603
3608
  };
3604
3609
  }
3605
3610
  _selectMenuItem({
@@ -3695,8 +3700,8 @@
3695
3700
  * Data API implementation
3696
3701
  */
3697
3702
 
3698
- EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler);
3699
- EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
3703
+ EventHandler.on(document, EVENT_KEYDOWN_DATA_API$1, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler);
3704
+ EventHandler.on(document, EVENT_KEYDOWN_DATA_API$1, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
3700
3705
  EventHandler.on(document, EVENT_CLICK_DATA_API$4, Dropdown.clearMenus);
3701
3706
  EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
3702
3707
  EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$3, function (event) {
@@ -3712,23 +3717,16 @@
3712
3717
 
3713
3718
  /**
3714
3719
  * --------------------------------------------------------------------------
3715
- * Bootstrap (v5.1.3): gallery.js
3720
+ * Bootstrap (v5.1.3): gallery.js (Refactored)
3716
3721
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
3717
3722
  * --------------------------------------------------------------------------
3718
3723
  */
3719
3724
 
3720
-
3721
- /**
3722
- * ------------------------------------------------------------------------
3723
- * Constants
3724
- * ------------------------------------------------------------------------
3725
- */
3726
-
3727
- const Default$a = {};
3728
3725
  const NAME$b = 'gallery';
3729
3726
  const DATA_KEY$7 = 'bs.gallery';
3730
3727
  const EVENT_KEY$7 = `.${DATA_KEY$7}`;
3731
3728
  const DATA_API_KEY$4 = '.data-api';
3729
+ const Default$a = {};
3732
3730
  const CAROUSEL_SELECTOR = '.carousel';
3733
3731
  const CAROUSEL_PAGER_SELECTOR = '.carousel-pager span';
3734
3732
  const CAROUSEL_ACTIVE_SELECTOR = '.carousel-item.active';
@@ -3738,72 +3736,115 @@
3738
3736
  const EVENT_MODAL_HIDE$1 = 'hide.bs.modal';
3739
3737
  const CAROUSEL_EVENT = 'slide.bs.carousel';
3740
3738
  const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`;
3741
-
3742
- /**
3743
- * ------------------------------------------------------------------------
3744
- * Class Definition
3745
- * ------------------------------------------------------------------------
3746
- */
3747
-
3739
+ const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$7}${DATA_API_KEY$4}`;
3748
3740
  class Gallery extends BaseComponent {
3749
3741
  constructor(element, config) {
3750
3742
  super(element, config);
3751
- /* eslint no-underscore-dangle: ["error", { "allow": ["_element"] }] */
3752
3743
  this.carousel = SelectorEngine.findOne(CAROUSEL_SELECTOR, this._element);
3753
3744
  this.carouselPager = SelectorEngine.findOne(CAROUSEL_PAGER_SELECTOR, this._element);
3754
- this.carouselStartIndex = element.getAttribute('data-gallery-start');
3755
- this.carouselActiveItem = SelectorEngine.find(CAROUSEL_ITEM_SELECTOR, this.carousel)[this.carouselStartIndex];
3756
- this.carouselPager.textContent = Number(this.carouselStartIndex) + 1;
3757
3745
  this.modal = SelectorEngine.findOne(MODAL_SELECTOR, this._element);
3758
- this.addEventListeners();
3759
- this.carouselLazyLoad(this.carouselActiveItem);
3746
+ this.carouselStartIndex = element.getAttribute('data-gallery-start') || 0;
3747
+ const allCarouselItems = SelectorEngine.find(CAROUSEL_ITEM_SELECTOR, this.carousel);
3748
+ const startIndexNum = Math.max(0, Math.min(Number(this.carouselStartIndex), allCarouselItems.length - 1));
3749
+ this.carouselPager.textContent = startIndexNum + 1;
3750
+ this.carouselActiveItem = allCarouselItems[startIndexNum];
3751
+ this._carouselLazyLoad(this.carouselActiveItem);
3752
+ EventHandler.on(this.carousel, CAROUSEL_EVENT, event => this._handleCarouselSlide(event));
3753
+ EventHandler.on(this.modal, EVENT_MODAL_HIDE$1, () => this._stopSlide());
3760
3754
  }
3761
3755
 
3762
3756
  // Getters
3763
3757
  static get NAME() {
3764
3758
  return NAME$b;
3765
3759
  }
3760
+ static get Default() {
3761
+ return Default$a;
3762
+ }
3766
3763
 
3767
- // Public
3768
- setSlide(event) {
3769
- const slideFrom = SelectorEngine.findOne(CAROUSEL_ACTIVE_SELECTOR, this.carousel);
3770
- const slideTo = event.relatedTarget;
3771
- this.carouselLazyLoad(slideTo);
3764
+ /**
3765
+ * Handle the carousel "slide.bs.carousel" event
3766
+ * @param {Event} event
3767
+ */
3768
+ _handleCarouselSlide(event) {
3769
+ const previousSlide = SelectorEngine.findOne(CAROUSEL_ACTIVE_SELECTOR, this.carousel);
3770
+ const currentSlide = event.relatedTarget;
3771
+ this._carouselLazyLoad(currentSlide);
3772
3772
  this.carouselPager.textContent = event.to + 1;
3773
- this.stopVideo(slideFrom);
3773
+ this._stopVideo(previousSlide);
3774
3774
  }
3775
- stopSlide() {
3775
+
3776
+ /**
3777
+ * Stop the current carousel slide (when modal hides or component is disposed)
3778
+ */
3779
+ _stopSlide() {
3776
3780
  const currentSlide = SelectorEngine.findOne(CAROUSEL_ACTIVE_SELECTOR, this.carousel);
3777
- this.stopVideo(currentSlide);
3781
+ this._stopVideo(currentSlide);
3778
3782
  }
3779
- stopVideo(slide) {
3783
+
3784
+ /**
3785
+ * Stop any video or iframe in the given slide
3786
+ * @param {HTMLElement} slide
3787
+ */
3788
+ _stopVideo(slide) {
3789
+ if (!slide) {
3790
+ return;
3791
+ }
3780
3792
  const iframe = SelectorEngine.findOne('iframe', slide);
3781
3793
  const video = SelectorEngine.findOne('video', slide);
3782
- if (iframe) {
3794
+ if (iframe && iframe.dataset.src) {
3783
3795
  iframe.src = iframe.dataset.src;
3784
3796
  } else if (video) {
3785
3797
  video.pause();
3786
3798
  }
3787
3799
  }
3788
3800
 
3789
- // Private
3790
- carouselLazyLoad(slide) {
3801
+ /**
3802
+ * Lazy load media (img, iframe, video, etc.) by copying data-src into src
3803
+ * @param {HTMLElement} slide
3804
+ */
3805
+ _carouselLazyLoad(slide) {
3806
+ if (!slide) {
3807
+ return;
3808
+ }
3791
3809
  const media = SelectorEngine.findOne('[data-src]', slide);
3792
3810
  if (media && !media.src) {
3793
3811
  media.src = media.dataset.src;
3794
3812
  }
3795
3813
  }
3796
- addEventListeners() {
3797
- EventHandler.on(this.carousel, CAROUSEL_EVENT, event => this.setSlide(event));
3798
- EventHandler.on(this.modal, EVENT_MODAL_HIDE$1, event => this.stopSlide(event));
3799
- }
3800
3814
 
3801
- // Static
3802
- static get Default() {
3803
- return Default$a;
3815
+ /**
3816
+ * Internal helper to open the modal and jump to a specific slide
3817
+ * @param {HTMLElement} gallery
3818
+ * @param {HTMLElement} targetLink
3819
+ */
3820
+ static _openModalAndShowSlide(gallery, targetLink) {
3821
+ if (!gallery || !targetLink) {
3822
+ return;
3823
+ }
3824
+ const firstSlide = Number(targetLink.getAttribute('data-bs-slide-to') || 0);
3825
+ gallery.dataset.galleryStart = firstSlide;
3826
+ const instance = Gallery.getOrCreateInstance(gallery);
3827
+ const overlay = SelectorEngine.findOne('.bcl-gallery__item-overlay', targetLink);
3828
+ if (overlay) {
3829
+ const modalId = overlay.getAttribute('data-bs-target');
3830
+ const modalElement = document.querySelector(modalId);
3831
+ if (modalElement) {
3832
+ const modal = bootstrap.Modal.getOrCreateInstance(modalElement);
3833
+ modal.show();
3834
+ }
3835
+ }
3836
+ setTimeout(() => {
3837
+ const carousel = SelectorEngine.findOne(CAROUSEL_SELECTOR, instance._element);
3838
+ const carouselInstance = bootstrap.Carousel.getOrCreateInstance(carousel);
3839
+ carouselInstance.to(firstSlide);
3840
+ const pager = SelectorEngine.findOne(CAROUSEL_PAGER_SELECTOR, instance._element);
3841
+ if (pager) {
3842
+ pager.textContent = firstSlide + 1;
3843
+ }
3844
+ }, 50);
3804
3845
  }
3805
3846
  static jQueryInterface(config) {
3806
- return this.each(function jInterface() {
3847
+ return this.each(function () {
3807
3848
  const data = Gallery.getOrCreateInstance(this);
3808
3849
  if (typeof config !== 'string') {
3809
3850
  return;
@@ -3818,24 +3859,28 @@
3818
3859
 
3819
3860
  /**
3820
3861
  * ------------------------------------------------------------------------
3821
- * Data Api implementation
3862
+ * Data API implementation
3822
3863
  * ------------------------------------------------------------------------
3823
3864
  */
3824
3865
 
3866
+ const isEnterOrSpace = event => {
3867
+ return event.key === 'Enter' || event.key === ' ';
3868
+ };
3825
3869
  EventHandler.on(document, EVENT_CLICK_DATA_API$3, THUMBNAIL_SELECTOR, event => {
3870
+ event.preventDefault();
3871
+ const targetLink = event.target.closest('a');
3826
3872
  const gallery = event.target.closest('div.bcl-gallery');
3827
- const firstSlide = event.target.parentNode.getAttribute('data-bs-slide-to');
3828
- gallery.dataset.galleryStart = firstSlide;
3829
- Gallery.getOrCreateInstance(gallery);
3873
+ Gallery._openModalAndShowSlide(gallery, targetLink);
3874
+ });
3875
+ EventHandler.on(document, EVENT_KEYDOWN_DATA_API, THUMBNAIL_SELECTOR, event => {
3876
+ if (!isEnterOrSpace(event)) {
3877
+ return;
3878
+ }
3879
+ event.preventDefault();
3880
+ const targetLink = event.target.closest('a');
3881
+ const gallery = event.target.closest('div.bcl-gallery');
3882
+ Gallery._openModalAndShowSlide(gallery, targetLink);
3830
3883
  });
3831
-
3832
- /**
3833
- * ------------------------------------------------------------------------
3834
- * jQuery
3835
- * ------------------------------------------------------------------------
3836
- * add .gallery to jQuery only if jQuery is present
3837
- */
3838
-
3839
3884
  defineJQueryPlugin$1(Gallery);
3840
3885
 
3841
3886
  /**
@@ -4721,9 +4766,16 @@
4721
4766
  this.addEventListeners();
4722
4767
  }
4723
4768
  addAriaAttributes() {
4724
- if (this.triggerElement) {
4725
- this.triggerElement.setAttribute("aria-haspopup", "true");
4726
- this.triggerElement.setAttribute("aria-expanded", "false");
4769
+ if (this.type === 'modal') {
4770
+ if (this.triggerElement) {
4771
+ this.triggerElement.setAttribute('aria-haspopup', 'dialog');
4772
+ }
4773
+ }
4774
+ if (this.type === 'offcanvas') {
4775
+ if (this.triggerElement) {
4776
+ this.triggerElement.setAttribute('aria-haspopup', 'dialog');
4777
+ this.triggerElement.setAttribute('aria-expanded', 'false');
4778
+ }
4727
4779
  }
4728
4780
  }
4729
4781
  addEventListeners() {
@@ -5002,7 +5054,7 @@
5002
5054
  return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg;
5003
5055
  }
5004
5056
  _resolvePossibleFunction(arg) {
5005
- return execute(arg, [this]);
5057
+ return execute(arg, [undefined, this]);
5006
5058
  }
5007
5059
  _putElementInTemplate(element, templateElement) {
5008
5060
  if (this._config.html) {
@@ -5101,7 +5153,7 @@
5101
5153
  class Tooltip extends BaseComponent {
5102
5154
  constructor(element, config) {
5103
5155
  if (typeof Popper === 'undefined') {
5104
- throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
5156
+ throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org/docs/v2/)');
5105
5157
  }
5106
5158
  super(element, config);
5107
5159
 
@@ -5147,7 +5199,6 @@
5147
5199
  if (!this._isEnabled) {
5148
5200
  return;
5149
5201
  }
5150
- this._activeTrigger.click = !this._activeTrigger.click;
5151
5202
  if (this._isShown()) {
5152
5203
  this._leave();
5153
5204
  return;
@@ -5335,7 +5386,7 @@
5335
5386
  return offset;
5336
5387
  }
5337
5388
  _resolvePossibleFunction(arg) {
5338
- return execute(arg, [this._element]);
5389
+ return execute(arg, [this._element, this._element]);
5339
5390
  }
5340
5391
  _getPopperConfig(attachment) {
5341
5392
  const defaultBsPopperConfig = {
@@ -5373,7 +5424,7 @@
5373
5424
  };
5374
5425
  return {
5375
5426
  ...defaultBsPopperConfig,
5376
- ...execute(this._config.popperConfig, [defaultBsPopperConfig])
5427
+ ...execute(this._config.popperConfig, [undefined, defaultBsPopperConfig])
5377
5428
  };
5378
5429
  }
5379
5430
  _setListeners() {
@@ -6609,7 +6660,6 @@
6609
6660
  }
6610
6661
 
6611
6662
  // Private
6612
-
6613
6663
  _maybeScheduleHide() {
6614
6664
  if (!this._config.autohide) {
6615
6665
  return;