@openeuropa/bcl-theme-default 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.
Files changed (37) hide show
  1. package/css/oe-bcl-ckeditor5.min.css +1 -1
  2. package/css/oe-bcl-ckeditor5.min.css.map +1 -1
  3. package/css/oe-bcl-default.css +1034 -124
  4. package/css/oe-bcl-default.css.map +1 -1
  5. package/css/oe-bcl-default.min.css +1 -1
  6. package/css/oe-bcl-default.min.css.map +1 -1
  7. package/js/oe-bcl-default.bundle.js +124 -74
  8. package/js/oe-bcl-default.bundle.js.map +1 -1
  9. package/js/oe-bcl-default.bundle.min.js +1 -1
  10. package/js/oe-bcl-default.bundle.min.js.map +1 -1
  11. package/js/oe-bcl-default.esm.js +124 -74
  12. package/js/oe-bcl-default.esm.js.map +1 -1
  13. package/js/oe-bcl-default.esm.min.js +1 -1
  14. package/js/oe-bcl-default.esm.min.js.map +1 -1
  15. package/js/oe-bcl-default.umd.js +124 -74
  16. package/js/oe-bcl-default.umd.js.map +1 -1
  17. package/js/oe-bcl-default.umd.min.js +1 -1
  18. package/js/oe-bcl-default.umd.min.js.map +1 -1
  19. package/package.json +8 -7
  20. package/src/js/accessible-toggle/accessible-toggle.js +11 -3
  21. package/src/js/gallery/gallery.js +118 -62
  22. package/src/scss/_accordion.scss +4 -0
  23. package/src/scss/_inpage-navigation.scss +7 -0
  24. package/src/scss/_multiselect-2.scss +1 -1
  25. package/src/scss/_multiselect.scss +21 -0
  26. package/src/scss/_timeline.scss +2 -0
  27. package/src/scss/base/_layout.scss +6 -3
  28. package/src/scss/base/_variables.scss +2 -3
  29. package/templates/bcl-accordion/accordion.html.twig +8 -3
  30. package/templates/bcl-dropdown/dropdown.html.twig +1 -1
  31. package/templates/bcl-file/file-translations.html.twig +2 -2
  32. package/templates/bcl-gallery/gallery-item.html.twig +1 -0
  33. package/templates/bcl-gallery/gallery.html.twig +2 -2
  34. package/templates/bcl-inpage-navigation/inpage-navigation.html.twig +14 -10
  35. package/templates/bcl-language-switcher/language-switcher.html.twig +2 -2
  36. package/templates/bcl-modal/modal.html.twig +2 -2
  37. package/templates/bcl-timeline/timeline.html.twig +2 -2
@@ -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) {
@@ -4786,7 +4791,7 @@
4786
4791
  return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg;
4787
4792
  }
4788
4793
  _resolvePossibleFunction(arg) {
4789
- return execute(arg, [this]);
4794
+ return execute(arg, [undefined, this]);
4790
4795
  }
4791
4796
  _putElementInTemplate(element, templateElement) {
4792
4797
  if (this._config.html) {
@@ -4885,7 +4890,7 @@
4885
4890
  class Tooltip extends BaseComponent {
4886
4891
  constructor(element, config) {
4887
4892
  if (typeof Popper === 'undefined') {
4888
- throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
4893
+ throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org/docs/v2/)');
4889
4894
  }
4890
4895
  super(element, config);
4891
4896
 
@@ -4931,7 +4936,6 @@
4931
4936
  if (!this._isEnabled) {
4932
4937
  return;
4933
4938
  }
4934
- this._activeTrigger.click = !this._activeTrigger.click;
4935
4939
  if (this._isShown()) {
4936
4940
  this._leave();
4937
4941
  return;
@@ -5119,7 +5123,7 @@
5119
5123
  return offset;
5120
5124
  }
5121
5125
  _resolvePossibleFunction(arg) {
5122
- return execute(arg, [this._element]);
5126
+ return execute(arg, [this._element, this._element]);
5123
5127
  }
5124
5128
  _getPopperConfig(attachment) {
5125
5129
  const defaultBsPopperConfig = {
@@ -5157,7 +5161,7 @@
5157
5161
  };
5158
5162
  return {
5159
5163
  ...defaultBsPopperConfig,
5160
- ...execute(this._config.popperConfig, [defaultBsPopperConfig])
5164
+ ...execute(this._config.popperConfig, [undefined, defaultBsPopperConfig])
5161
5165
  };
5162
5166
  }
5163
5167
  _setListeners() {
@@ -6393,7 +6397,6 @@
6393
6397
  }
6394
6398
 
6395
6399
  // Private
6396
-
6397
6400
  _maybeScheduleHide() {
6398
6401
  if (!this._config.autohide) {
6399
6402
  return;
@@ -6507,23 +6510,16 @@
6507
6510
 
6508
6511
  /**
6509
6512
  * --------------------------------------------------------------------------
6510
- * Bootstrap (v5.1.3): gallery.js
6513
+ * Bootstrap (v5.1.3): gallery.js (Refactored)
6511
6514
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
6512
6515
  * --------------------------------------------------------------------------
6513
6516
  */
6514
6517
 
6515
-
6516
- /**
6517
- * ------------------------------------------------------------------------
6518
- * Constants
6519
- * ------------------------------------------------------------------------
6520
- */
6521
-
6522
- const Default = {};
6523
6518
  const NAME = 'gallery';
6524
6519
  const DATA_KEY = 'bs.gallery';
6525
6520
  const EVENT_KEY = `.${DATA_KEY}`;
6526
6521
  const DATA_API_KEY = '.data-api';
6522
+ const Default = {};
6527
6523
  const CAROUSEL_SELECTOR = '.carousel';
6528
6524
  const CAROUSEL_PAGER_SELECTOR = '.carousel-pager span';
6529
6525
  const CAROUSEL_ACTIVE_SELECTOR = '.carousel-item.active';
@@ -6533,72 +6529,115 @@
6533
6529
  const EVENT_MODAL_HIDE = 'hide.bs.modal';
6534
6530
  const CAROUSEL_EVENT = 'slide.bs.carousel';
6535
6531
  const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
6536
-
6537
- /**
6538
- * ------------------------------------------------------------------------
6539
- * Class Definition
6540
- * ------------------------------------------------------------------------
6541
- */
6542
-
6532
+ const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY}${DATA_API_KEY}`;
6543
6533
  class Gallery extends BaseComponent {
6544
6534
  constructor(element, config) {
6545
6535
  super(element, config);
6546
- /* eslint no-underscore-dangle: ["error", { "allow": ["_element"] }] */
6547
6536
  this.carousel = SelectorEngine.findOne(CAROUSEL_SELECTOR, this._element);
6548
6537
  this.carouselPager = SelectorEngine.findOne(CAROUSEL_PAGER_SELECTOR, this._element);
6549
- this.carouselStartIndex = element.getAttribute('data-gallery-start');
6550
- this.carouselActiveItem = SelectorEngine.find(CAROUSEL_ITEM_SELECTOR, this.carousel)[this.carouselStartIndex];
6551
- this.carouselPager.textContent = Number(this.carouselStartIndex) + 1;
6552
6538
  this.modal = SelectorEngine.findOne(MODAL_SELECTOR, this._element);
6553
- this.addEventListeners();
6554
- this.carouselLazyLoad(this.carouselActiveItem);
6539
+ this.carouselStartIndex = element.getAttribute('data-gallery-start') || 0;
6540
+ const allCarouselItems = SelectorEngine.find(CAROUSEL_ITEM_SELECTOR, this.carousel);
6541
+ const startIndexNum = Math.max(0, Math.min(Number(this.carouselStartIndex), allCarouselItems.length - 1));
6542
+ this.carouselPager.textContent = startIndexNum + 1;
6543
+ this.carouselActiveItem = allCarouselItems[startIndexNum];
6544
+ this._carouselLazyLoad(this.carouselActiveItem);
6545
+ EventHandler.on(this.carousel, CAROUSEL_EVENT, event => this._handleCarouselSlide(event));
6546
+ EventHandler.on(this.modal, EVENT_MODAL_HIDE, () => this._stopSlide());
6555
6547
  }
6556
6548
 
6557
6549
  // Getters
6558
6550
  static get NAME() {
6559
6551
  return NAME;
6560
6552
  }
6553
+ static get Default() {
6554
+ return Default;
6555
+ }
6561
6556
 
6562
- // Public
6563
- setSlide(event) {
6564
- const slideFrom = SelectorEngine.findOne(CAROUSEL_ACTIVE_SELECTOR, this.carousel);
6565
- const slideTo = event.relatedTarget;
6566
- this.carouselLazyLoad(slideTo);
6557
+ /**
6558
+ * Handle the carousel "slide.bs.carousel" event
6559
+ * @param {Event} event
6560
+ */
6561
+ _handleCarouselSlide(event) {
6562
+ const previousSlide = SelectorEngine.findOne(CAROUSEL_ACTIVE_SELECTOR, this.carousel);
6563
+ const currentSlide = event.relatedTarget;
6564
+ this._carouselLazyLoad(currentSlide);
6567
6565
  this.carouselPager.textContent = event.to + 1;
6568
- this.stopVideo(slideFrom);
6566
+ this._stopVideo(previousSlide);
6569
6567
  }
6570
- stopSlide() {
6568
+
6569
+ /**
6570
+ * Stop the current carousel slide (when modal hides or component is disposed)
6571
+ */
6572
+ _stopSlide() {
6571
6573
  const currentSlide = SelectorEngine.findOne(CAROUSEL_ACTIVE_SELECTOR, this.carousel);
6572
- this.stopVideo(currentSlide);
6574
+ this._stopVideo(currentSlide);
6573
6575
  }
6574
- stopVideo(slide) {
6576
+
6577
+ /**
6578
+ * Stop any video or iframe in the given slide
6579
+ * @param {HTMLElement} slide
6580
+ */
6581
+ _stopVideo(slide) {
6582
+ if (!slide) {
6583
+ return;
6584
+ }
6575
6585
  const iframe = SelectorEngine.findOne('iframe', slide);
6576
6586
  const video = SelectorEngine.findOne('video', slide);
6577
- if (iframe) {
6587
+ if (iframe && iframe.dataset.src) {
6578
6588
  iframe.src = iframe.dataset.src;
6579
6589
  } else if (video) {
6580
6590
  video.pause();
6581
6591
  }
6582
6592
  }
6583
6593
 
6584
- // Private
6585
- carouselLazyLoad(slide) {
6594
+ /**
6595
+ * Lazy load media (img, iframe, video, etc.) by copying data-src into src
6596
+ * @param {HTMLElement} slide
6597
+ */
6598
+ _carouselLazyLoad(slide) {
6599
+ if (!slide) {
6600
+ return;
6601
+ }
6586
6602
  const media = SelectorEngine.findOne('[data-src]', slide);
6587
6603
  if (media && !media.src) {
6588
6604
  media.src = media.dataset.src;
6589
6605
  }
6590
6606
  }
6591
- addEventListeners() {
6592
- EventHandler.on(this.carousel, CAROUSEL_EVENT, event => this.setSlide(event));
6593
- EventHandler.on(this.modal, EVENT_MODAL_HIDE, event => this.stopSlide(event));
6594
- }
6595
6607
 
6596
- // Static
6597
- static get Default() {
6598
- return Default;
6608
+ /**
6609
+ * Internal helper to open the modal and jump to a specific slide
6610
+ * @param {HTMLElement} gallery
6611
+ * @param {HTMLElement} targetLink
6612
+ */
6613
+ static _openModalAndShowSlide(gallery, targetLink) {
6614
+ if (!gallery || !targetLink) {
6615
+ return;
6616
+ }
6617
+ const firstSlide = Number(targetLink.getAttribute('data-bs-slide-to') || 0);
6618
+ gallery.dataset.galleryStart = firstSlide;
6619
+ const instance = Gallery.getOrCreateInstance(gallery);
6620
+ const overlay = SelectorEngine.findOne('.bcl-gallery__item-overlay', targetLink);
6621
+ if (overlay) {
6622
+ const modalId = overlay.getAttribute('data-bs-target');
6623
+ const modalElement = document.querySelector(modalId);
6624
+ if (modalElement) {
6625
+ const modal = bootstrap.Modal.getOrCreateInstance(modalElement);
6626
+ modal.show();
6627
+ }
6628
+ }
6629
+ setTimeout(() => {
6630
+ const carousel = SelectorEngine.findOne(CAROUSEL_SELECTOR, instance._element);
6631
+ const carouselInstance = bootstrap.Carousel.getOrCreateInstance(carousel);
6632
+ carouselInstance.to(firstSlide);
6633
+ const pager = SelectorEngine.findOne(CAROUSEL_PAGER_SELECTOR, instance._element);
6634
+ if (pager) {
6635
+ pager.textContent = firstSlide + 1;
6636
+ }
6637
+ }, 50);
6599
6638
  }
6600
6639
  static jQueryInterface(config) {
6601
- return this.each(function jInterface() {
6640
+ return this.each(function () {
6602
6641
  const data = Gallery.getOrCreateInstance(this);
6603
6642
  if (typeof config !== 'string') {
6604
6643
  return;
@@ -6613,24 +6652,28 @@
6613
6652
 
6614
6653
  /**
6615
6654
  * ------------------------------------------------------------------------
6616
- * Data Api implementation
6655
+ * Data API implementation
6617
6656
  * ------------------------------------------------------------------------
6618
6657
  */
6619
6658
 
6659
+ const isEnterOrSpace = event => {
6660
+ return event.key === 'Enter' || event.key === ' ';
6661
+ };
6620
6662
  EventHandler.on(document, EVENT_CLICK_DATA_API, THUMBNAIL_SELECTOR, event => {
6663
+ event.preventDefault();
6664
+ const targetLink = event.target.closest('a');
6621
6665
  const gallery = event.target.closest('div.bcl-gallery');
6622
- const firstSlide = event.target.parentNode.getAttribute('data-bs-slide-to');
6623
- gallery.dataset.galleryStart = firstSlide;
6624
- Gallery.getOrCreateInstance(gallery);
6666
+ Gallery._openModalAndShowSlide(gallery, targetLink);
6667
+ });
6668
+ EventHandler.on(document, EVENT_KEYDOWN_DATA_API, THUMBNAIL_SELECTOR, event => {
6669
+ if (!isEnterOrSpace(event)) {
6670
+ return;
6671
+ }
6672
+ event.preventDefault();
6673
+ const targetLink = event.target.closest('a');
6674
+ const gallery = event.target.closest('div.bcl-gallery');
6675
+ Gallery._openModalAndShowSlide(gallery, targetLink);
6625
6676
  });
6626
-
6627
- /**
6628
- * ------------------------------------------------------------------------
6629
- * jQuery
6630
- * ------------------------------------------------------------------------
6631
- * add .gallery to jQuery only if jQuery is present
6632
- */
6633
-
6634
6677
  defineJQueryPlugin$1(Gallery);
6635
6678
 
6636
6679
  /**
@@ -6660,9 +6703,16 @@
6660
6703
  this.addEventListeners();
6661
6704
  }
6662
6705
  addAriaAttributes() {
6663
- if (this.triggerElement) {
6664
- this.triggerElement.setAttribute("aria-haspopup", "true");
6665
- this.triggerElement.setAttribute("aria-expanded", "false");
6706
+ if (this.type === 'modal') {
6707
+ if (this.triggerElement) {
6708
+ this.triggerElement.setAttribute('aria-haspopup', 'dialog');
6709
+ }
6710
+ }
6711
+ if (this.type === 'offcanvas') {
6712
+ if (this.triggerElement) {
6713
+ this.triggerElement.setAttribute('aria-haspopup', 'dialog');
6714
+ this.triggerElement.setAttribute('aria-expanded', 'false');
6715
+ }
6666
6716
  }
6667
6717
  }
6668
6718
  addEventListeners() {