@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.
@@ -196,7 +196,7 @@ const noop = () => {};
196
196
  * @param {HTMLElement} element
197
197
  * @return void
198
198
  *
199
- * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
199
+ * @see https://www.harrytheo.com/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
200
200
  */
201
201
  const reflow = element => {
202
202
  element.offsetHeight; // eslint-disable-line no-unused-expressions
@@ -241,7 +241,7 @@ const defineJQueryPlugin$1 = plugin => {
241
241
  });
242
242
  };
243
243
  const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {
244
- return typeof possibleCallback === 'function' ? possibleCallback(...args) : defaultValue;
244
+ return typeof possibleCallback === 'function' ? possibleCallback.call(...args) : defaultValue;
245
245
  };
246
246
  const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
247
247
  if (!waitForTransition) {
@@ -563,7 +563,7 @@ const Manipulator$1 = {
563
563
  const bsKeys = Object.keys(element.dataset).filter(key => key.startsWith('bs') && !key.startsWith('bsConfig'));
564
564
  for (const key of bsKeys) {
565
565
  let pureKey = key.replace(/^bs/, '');
566
- pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
566
+ pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1);
567
567
  attributes[pureKey] = normalizeData$1(element.dataset[key]);
568
568
  }
569
569
  return attributes;
@@ -638,7 +638,7 @@ class Config {
638
638
  * Constants
639
639
  */
640
640
 
641
- const VERSION = '5.3.3';
641
+ const VERSION = '5.3.6';
642
642
 
643
643
  /**
644
644
  * Class definition
@@ -664,6 +664,8 @@ class BaseComponent extends Config {
664
664
  this[propertyName] = null;
665
665
  }
666
666
  }
667
+
668
+ // Private
667
669
  _queueCallback(callback, element, isAnimated = true) {
668
670
  executeAfterTransition(callback, element, isAnimated);
669
671
  }
@@ -1595,11 +1597,11 @@ class Collapse extends BaseComponent {
1595
1597
  this._element.style[dimension] = '';
1596
1598
  this._queueCallback(complete, this._element, true);
1597
1599
  }
1600
+
1601
+ // Private
1598
1602
  _isShown(element = this._element) {
1599
1603
  return element.classList.contains(CLASS_NAME_SHOW$7);
1600
1604
  }
1601
-
1602
- // Private
1603
1605
  _configAfterMerge(config) {
1604
1606
  config.toggle = Boolean(config.toggle); // Coerce string values
1605
1607
  config.parent = getElement$1(config.parent);
@@ -1702,7 +1704,7 @@ const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$8}`;
1702
1704
  const EVENT_SHOW$5 = `show${EVENT_KEY$8}`;
1703
1705
  const EVENT_SHOWN$5 = `shown${EVENT_KEY$8}`;
1704
1706
  const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$8}${DATA_API_KEY$5}`;
1705
- const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$8}${DATA_API_KEY$5}`;
1707
+ const EVENT_KEYDOWN_DATA_API$1 = `keydown${EVENT_KEY$8}${DATA_API_KEY$5}`;
1706
1708
  const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$8}${DATA_API_KEY$5}`;
1707
1709
  const CLASS_NAME_SHOW$6 = 'show';
1708
1710
  const CLASS_NAME_DROPUP = 'dropup';
@@ -1842,6 +1844,9 @@ class Dropdown extends BaseComponent {
1842
1844
  this._element.setAttribute('aria-expanded', 'false');
1843
1845
  Manipulator$1.removeDataAttribute(this._menu, 'popper');
1844
1846
  EventHandler.trigger(this._element, EVENT_HIDDEN$5, relatedTarget);
1847
+
1848
+ // Explicitly return focus to the trigger element
1849
+ this._element.focus();
1845
1850
  }
1846
1851
  _getConfig(config) {
1847
1852
  config = super._getConfig(config);
@@ -1853,7 +1858,7 @@ class Dropdown extends BaseComponent {
1853
1858
  }
1854
1859
  _createPopper() {
1855
1860
  if (typeof Popper === 'undefined') {
1856
- throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
1861
+ throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org/docs/v2/)');
1857
1862
  }
1858
1863
  let referenceElement = this._element;
1859
1864
  if (this._config.reference === 'parent') {
@@ -1932,7 +1937,7 @@ class Dropdown extends BaseComponent {
1932
1937
  }
1933
1938
  return {
1934
1939
  ...defaultBsPopperConfig,
1935
- ...execute(this._config.popperConfig, [defaultBsPopperConfig])
1940
+ ...execute(this._config.popperConfig, [undefined, defaultBsPopperConfig])
1936
1941
  };
1937
1942
  }
1938
1943
  _selectMenuItem({
@@ -2028,8 +2033,8 @@ class Dropdown extends BaseComponent {
2028
2033
  * Data API implementation
2029
2034
  */
2030
2035
 
2031
- EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler);
2032
- EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
2036
+ EventHandler.on(document, EVENT_KEYDOWN_DATA_API$1, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler);
2037
+ EventHandler.on(document, EVENT_KEYDOWN_DATA_API$1, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
2033
2038
  EventHandler.on(document, EVENT_CLICK_DATA_API$4, Dropdown.clearMenus);
2034
2039
  EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
2035
2040
  EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$3, function (event) {
@@ -2045,23 +2050,16 @@ defineJQueryPlugin$1(Dropdown);
2045
2050
 
2046
2051
  /**
2047
2052
  * --------------------------------------------------------------------------
2048
- * Bootstrap (v5.1.3): gallery.js
2053
+ * Bootstrap (v5.1.3): gallery.js (Refactored)
2049
2054
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
2050
2055
  * --------------------------------------------------------------------------
2051
2056
  */
2052
2057
 
2053
-
2054
- /**
2055
- * ------------------------------------------------------------------------
2056
- * Constants
2057
- * ------------------------------------------------------------------------
2058
- */
2059
-
2060
- const Default$a = {};
2061
2058
  const NAME$b = 'gallery';
2062
2059
  const DATA_KEY$7 = 'bs.gallery';
2063
2060
  const EVENT_KEY$7 = `.${DATA_KEY$7}`;
2064
2061
  const DATA_API_KEY$4 = '.data-api';
2062
+ const Default$a = {};
2065
2063
  const CAROUSEL_SELECTOR = '.carousel';
2066
2064
  const CAROUSEL_PAGER_SELECTOR = '.carousel-pager span';
2067
2065
  const CAROUSEL_ACTIVE_SELECTOR = '.carousel-item.active';
@@ -2071,72 +2069,115 @@ const MODAL_SELECTOR = '.modal';
2071
2069
  const EVENT_MODAL_HIDE$1 = 'hide.bs.modal';
2072
2070
  const CAROUSEL_EVENT = 'slide.bs.carousel';
2073
2071
  const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`;
2074
-
2075
- /**
2076
- * ------------------------------------------------------------------------
2077
- * Class Definition
2078
- * ------------------------------------------------------------------------
2079
- */
2080
-
2072
+ const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$7}${DATA_API_KEY$4}`;
2081
2073
  class Gallery extends BaseComponent {
2082
2074
  constructor(element, config) {
2083
2075
  super(element, config);
2084
- /* eslint no-underscore-dangle: ["error", { "allow": ["_element"] }] */
2085
2076
  this.carousel = SelectorEngine.findOne(CAROUSEL_SELECTOR, this._element);
2086
2077
  this.carouselPager = SelectorEngine.findOne(CAROUSEL_PAGER_SELECTOR, this._element);
2087
- this.carouselStartIndex = element.getAttribute('data-gallery-start');
2088
- this.carouselActiveItem = SelectorEngine.find(CAROUSEL_ITEM_SELECTOR, this.carousel)[this.carouselStartIndex];
2089
- this.carouselPager.textContent = Number(this.carouselStartIndex) + 1;
2090
2078
  this.modal = SelectorEngine.findOne(MODAL_SELECTOR, this._element);
2091
- this.addEventListeners();
2092
- this.carouselLazyLoad(this.carouselActiveItem);
2079
+ this.carouselStartIndex = element.getAttribute('data-gallery-start') || 0;
2080
+ const allCarouselItems = SelectorEngine.find(CAROUSEL_ITEM_SELECTOR, this.carousel);
2081
+ const startIndexNum = Math.max(0, Math.min(Number(this.carouselStartIndex), allCarouselItems.length - 1));
2082
+ this.carouselPager.textContent = startIndexNum + 1;
2083
+ this.carouselActiveItem = allCarouselItems[startIndexNum];
2084
+ this._carouselLazyLoad(this.carouselActiveItem);
2085
+ EventHandler.on(this.carousel, CAROUSEL_EVENT, event => this._handleCarouselSlide(event));
2086
+ EventHandler.on(this.modal, EVENT_MODAL_HIDE$1, () => this._stopSlide());
2093
2087
  }
2094
2088
 
2095
2089
  // Getters
2096
2090
  static get NAME() {
2097
2091
  return NAME$b;
2098
2092
  }
2093
+ static get Default() {
2094
+ return Default$a;
2095
+ }
2099
2096
 
2100
- // Public
2101
- setSlide(event) {
2102
- const slideFrom = SelectorEngine.findOne(CAROUSEL_ACTIVE_SELECTOR, this.carousel);
2103
- const slideTo = event.relatedTarget;
2104
- this.carouselLazyLoad(slideTo);
2097
+ /**
2098
+ * Handle the carousel "slide.bs.carousel" event
2099
+ * @param {Event} event
2100
+ */
2101
+ _handleCarouselSlide(event) {
2102
+ const previousSlide = SelectorEngine.findOne(CAROUSEL_ACTIVE_SELECTOR, this.carousel);
2103
+ const currentSlide = event.relatedTarget;
2104
+ this._carouselLazyLoad(currentSlide);
2105
2105
  this.carouselPager.textContent = event.to + 1;
2106
- this.stopVideo(slideFrom);
2106
+ this._stopVideo(previousSlide);
2107
2107
  }
2108
- stopSlide() {
2108
+
2109
+ /**
2110
+ * Stop the current carousel slide (when modal hides or component is disposed)
2111
+ */
2112
+ _stopSlide() {
2109
2113
  const currentSlide = SelectorEngine.findOne(CAROUSEL_ACTIVE_SELECTOR, this.carousel);
2110
- this.stopVideo(currentSlide);
2114
+ this._stopVideo(currentSlide);
2111
2115
  }
2112
- stopVideo(slide) {
2116
+
2117
+ /**
2118
+ * Stop any video or iframe in the given slide
2119
+ * @param {HTMLElement} slide
2120
+ */
2121
+ _stopVideo(slide) {
2122
+ if (!slide) {
2123
+ return;
2124
+ }
2113
2125
  const iframe = SelectorEngine.findOne('iframe', slide);
2114
2126
  const video = SelectorEngine.findOne('video', slide);
2115
- if (iframe) {
2127
+ if (iframe && iframe.dataset.src) {
2116
2128
  iframe.src = iframe.dataset.src;
2117
2129
  } else if (video) {
2118
2130
  video.pause();
2119
2131
  }
2120
2132
  }
2121
2133
 
2122
- // Private
2123
- carouselLazyLoad(slide) {
2134
+ /**
2135
+ * Lazy load media (img, iframe, video, etc.) by copying data-src into src
2136
+ * @param {HTMLElement} slide
2137
+ */
2138
+ _carouselLazyLoad(slide) {
2139
+ if (!slide) {
2140
+ return;
2141
+ }
2124
2142
  const media = SelectorEngine.findOne('[data-src]', slide);
2125
2143
  if (media && !media.src) {
2126
2144
  media.src = media.dataset.src;
2127
2145
  }
2128
2146
  }
2129
- addEventListeners() {
2130
- EventHandler.on(this.carousel, CAROUSEL_EVENT, event => this.setSlide(event));
2131
- EventHandler.on(this.modal, EVENT_MODAL_HIDE$1, event => this.stopSlide(event));
2132
- }
2133
2147
 
2134
- // Static
2135
- static get Default() {
2136
- return Default$a;
2148
+ /**
2149
+ * Internal helper to open the modal and jump to a specific slide
2150
+ * @param {HTMLElement} gallery
2151
+ * @param {HTMLElement} targetLink
2152
+ */
2153
+ static _openModalAndShowSlide(gallery, targetLink) {
2154
+ if (!gallery || !targetLink) {
2155
+ return;
2156
+ }
2157
+ const firstSlide = Number(targetLink.getAttribute('data-bs-slide-to') || 0);
2158
+ gallery.dataset.galleryStart = firstSlide;
2159
+ const instance = Gallery.getOrCreateInstance(gallery);
2160
+ const overlay = SelectorEngine.findOne('.bcl-gallery__item-overlay', targetLink);
2161
+ if (overlay) {
2162
+ const modalId = overlay.getAttribute('data-bs-target');
2163
+ const modalElement = document.querySelector(modalId);
2164
+ if (modalElement) {
2165
+ const modal = bootstrap.Modal.getOrCreateInstance(modalElement);
2166
+ modal.show();
2167
+ }
2168
+ }
2169
+ setTimeout(() => {
2170
+ const carousel = SelectorEngine.findOne(CAROUSEL_SELECTOR, instance._element);
2171
+ const carouselInstance = bootstrap.Carousel.getOrCreateInstance(carousel);
2172
+ carouselInstance.to(firstSlide);
2173
+ const pager = SelectorEngine.findOne(CAROUSEL_PAGER_SELECTOR, instance._element);
2174
+ if (pager) {
2175
+ pager.textContent = firstSlide + 1;
2176
+ }
2177
+ }, 50);
2137
2178
  }
2138
2179
  static jQueryInterface(config) {
2139
- return this.each(function jInterface() {
2180
+ return this.each(function () {
2140
2181
  const data = Gallery.getOrCreateInstance(this);
2141
2182
  if (typeof config !== 'string') {
2142
2183
  return;
@@ -2151,24 +2192,28 @@ class Gallery extends BaseComponent {
2151
2192
 
2152
2193
  /**
2153
2194
  * ------------------------------------------------------------------------
2154
- * Data Api implementation
2195
+ * Data API implementation
2155
2196
  * ------------------------------------------------------------------------
2156
2197
  */
2157
2198
 
2199
+ const isEnterOrSpace = event => {
2200
+ return event.key === 'Enter' || event.key === ' ';
2201
+ };
2158
2202
  EventHandler.on(document, EVENT_CLICK_DATA_API$3, THUMBNAIL_SELECTOR, event => {
2203
+ event.preventDefault();
2204
+ const targetLink = event.target.closest('a');
2159
2205
  const gallery = event.target.closest('div.bcl-gallery');
2160
- const firstSlide = event.target.parentNode.getAttribute('data-bs-slide-to');
2161
- gallery.dataset.galleryStart = firstSlide;
2162
- Gallery.getOrCreateInstance(gallery);
2206
+ Gallery._openModalAndShowSlide(gallery, targetLink);
2207
+ });
2208
+ EventHandler.on(document, EVENT_KEYDOWN_DATA_API, THUMBNAIL_SELECTOR, event => {
2209
+ if (!isEnterOrSpace(event)) {
2210
+ return;
2211
+ }
2212
+ event.preventDefault();
2213
+ const targetLink = event.target.closest('a');
2214
+ const gallery = event.target.closest('div.bcl-gallery');
2215
+ Gallery._openModalAndShowSlide(gallery, targetLink);
2163
2216
  });
2164
-
2165
- /**
2166
- * ------------------------------------------------------------------------
2167
- * jQuery
2168
- * ------------------------------------------------------------------------
2169
- * add .gallery to jQuery only if jQuery is present
2170
- */
2171
-
2172
2217
  defineJQueryPlugin$1(Gallery);
2173
2218
 
2174
2219
  /**
@@ -3054,9 +3099,16 @@ class AccessibleToggle {
3054
3099
  this.addEventListeners();
3055
3100
  }
3056
3101
  addAriaAttributes() {
3057
- if (this.triggerElement) {
3058
- this.triggerElement.setAttribute("aria-haspopup", "true");
3059
- this.triggerElement.setAttribute("aria-expanded", "false");
3102
+ if (this.type === 'modal') {
3103
+ if (this.triggerElement) {
3104
+ this.triggerElement.setAttribute('aria-haspopup', 'dialog');
3105
+ }
3106
+ }
3107
+ if (this.type === 'offcanvas') {
3108
+ if (this.triggerElement) {
3109
+ this.triggerElement.setAttribute('aria-haspopup', 'dialog');
3110
+ this.triggerElement.setAttribute('aria-expanded', 'false');
3111
+ }
3060
3112
  }
3061
3113
  }
3062
3114
  addEventListeners() {
@@ -3335,7 +3387,7 @@ class TemplateFactory extends Config {
3335
3387
  return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg;
3336
3388
  }
3337
3389
  _resolvePossibleFunction(arg) {
3338
- return execute(arg, [this]);
3390
+ return execute(arg, [undefined, this]);
3339
3391
  }
3340
3392
  _putElementInTemplate(element, templateElement) {
3341
3393
  if (this._config.html) {
@@ -3434,7 +3486,7 @@ const DefaultType$3 = {
3434
3486
  class Tooltip extends BaseComponent {
3435
3487
  constructor(element, config) {
3436
3488
  if (typeof Popper === 'undefined') {
3437
- throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
3489
+ throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org/docs/v2/)');
3438
3490
  }
3439
3491
  super(element, config);
3440
3492
 
@@ -3480,7 +3532,6 @@ class Tooltip extends BaseComponent {
3480
3532
  if (!this._isEnabled) {
3481
3533
  return;
3482
3534
  }
3483
- this._activeTrigger.click = !this._activeTrigger.click;
3484
3535
  if (this._isShown()) {
3485
3536
  this._leave();
3486
3537
  return;
@@ -3668,7 +3719,7 @@ class Tooltip extends BaseComponent {
3668
3719
  return offset;
3669
3720
  }
3670
3721
  _resolvePossibleFunction(arg) {
3671
- return execute(arg, [this._element]);
3722
+ return execute(arg, [this._element, this._element]);
3672
3723
  }
3673
3724
  _getPopperConfig(attachment) {
3674
3725
  const defaultBsPopperConfig = {
@@ -3706,7 +3757,7 @@ class Tooltip extends BaseComponent {
3706
3757
  };
3707
3758
  return {
3708
3759
  ...defaultBsPopperConfig,
3709
- ...execute(this._config.popperConfig, [defaultBsPopperConfig])
3760
+ ...execute(this._config.popperConfig, [undefined, defaultBsPopperConfig])
3710
3761
  };
3711
3762
  }
3712
3763
  _setListeners() {
@@ -4942,7 +4993,6 @@ class Toast extends BaseComponent {
4942
4993
  }
4943
4994
 
4944
4995
  // Private
4945
-
4946
4996
  _maybeScheduleHide() {
4947
4997
  if (!this._config.autohide) {
4948
4998
  return;