@openeuropa/bcl-bootstrap 0.24.1 → 0.26.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.
Files changed (142) hide show
  1. package/bootstrap-icons.svg +1 -1
  2. package/icons/apple.svg +2 -2
  3. package/icons/boombox-fill.svg +2 -2
  4. package/icons/cup-fill.svg +1 -1
  5. package/icons/cup.svg +1 -1
  6. package/js/dist/alert.js +3 -12
  7. package/js/dist/alert.js.map +1 -1
  8. package/js/dist/base-component.js +32 -18
  9. package/js/dist/base-component.js.map +1 -1
  10. package/js/dist/button.js +3 -12
  11. package/js/dist/button.js.map +1 -1
  12. package/js/dist/carousel.js +207 -307
  13. package/js/dist/carousel.js.map +1 -1
  14. package/js/dist/collapse.js +57 -88
  15. package/js/dist/collapse.js.map +1 -1
  16. package/js/dist/dom/data.js +1 -3
  17. package/js/dist/dom/data.js.map +1 -1
  18. package/js/dist/dom/event-handler.js +87 -106
  19. package/js/dist/dom/event-handler.js.map +1 -1
  20. package/js/dist/dom/manipulator.js +21 -25
  21. package/js/dist/dom/manipulator.js.map +1 -1
  22. package/js/dist/dom/selector-engine.js +11 -10
  23. package/js/dist/dom/selector-engine.js.map +1 -1
  24. package/js/dist/dropdown.js +83 -115
  25. package/js/dist/dropdown.js.map +1 -1
  26. package/js/dist/modal.js +95 -152
  27. package/js/dist/modal.js.map +1 -1
  28. package/js/dist/offcanvas.js +75 -58
  29. package/js/dist/offcanvas.js.map +1 -1
  30. package/js/dist/popover.js +29 -56
  31. package/js/dist/popover.js.map +1 -1
  32. package/js/dist/scrollspy.js +176 -125
  33. package/js/dist/scrollspy.js.map +1 -1
  34. package/js/dist/tab.js +207 -92
  35. package/js/dist/tab.js.map +1 -1
  36. package/js/dist/toast.js +23 -37
  37. package/js/dist/toast.js.map +1 -1
  38. package/js/dist/tooltip.js +259 -348
  39. package/js/dist/tooltip.js.map +1 -1
  40. package/js/dist/util/backdrop.js +62 -39
  41. package/js/dist/util/backdrop.js.map +1 -1
  42. package/js/dist/util/component-functions.js +1 -1
  43. package/js/dist/util/component-functions.js.map +1 -1
  44. package/js/dist/util/config.js +75 -0
  45. package/js/dist/util/config.js.map +1 -0
  46. package/js/dist/util/focustrap.js +41 -34
  47. package/js/dist/util/focustrap.js.map +1 -1
  48. package/js/dist/util/index.js +56 -52
  49. package/js/dist/util/index.js.map +1 -1
  50. package/js/dist/util/sanitizer.js +12 -19
  51. package/js/dist/util/sanitizer.js.map +1 -1
  52. package/js/dist/util/scrollbar.js +49 -34
  53. package/js/dist/util/scrollbar.js.map +1 -1
  54. package/js/dist/util/swipe.js +151 -0
  55. package/js/dist/util/swipe.js.map +1 -0
  56. package/js/dist/util/template-factory.js +173 -0
  57. package/js/dist/util/template-factory.js.map +1 -0
  58. package/js/src/alert.js +3 -15
  59. package/js/src/base-component.js +28 -18
  60. package/js/src/button.js +3 -17
  61. package/js/src/carousel.js +203 -319
  62. package/js/src/collapse.js +61 -94
  63. package/js/src/dom/data.js +1 -3
  64. package/js/src/dom/event-handler.js +80 -108
  65. package/js/src/dom/manipulator.js +22 -31
  66. package/js/src/dom/selector-engine.js +10 -19
  67. package/js/src/dropdown.js +84 -138
  68. package/js/src/modal.js +94 -158
  69. package/js/src/offcanvas.js +72 -61
  70. package/js/src/popover.js +31 -62
  71. package/js/src/scrollspy.js +166 -171
  72. package/js/src/tab.js +193 -110
  73. package/js/src/toast.js +19 -41
  74. package/js/src/tooltip.js +259 -371
  75. package/js/src/util/backdrop.js +55 -36
  76. package/js/src/util/component-functions.js +1 -1
  77. package/js/src/util/config.js +66 -0
  78. package/js/src/util/focustrap.js +38 -28
  79. package/js/src/util/index.js +67 -64
  80. package/js/src/util/sanitizer.js +11 -19
  81. package/js/src/util/scrollbar.js +47 -30
  82. package/js/src/util/swipe.js +146 -0
  83. package/js/src/util/template-factory.js +160 -0
  84. package/package.json +4 -4
  85. package/scss/_accordion.scss +52 -24
  86. package/scss/_alert.scss +18 -4
  87. package/scss/_badge.scss +14 -5
  88. package/scss/_breadcrumb.scss +22 -10
  89. package/scss/_button-group.scss +3 -0
  90. package/scss/_buttons.scss +97 -22
  91. package/scss/_card.scss +55 -37
  92. package/scss/_close.scss +1 -1
  93. package/scss/_containers.scss +1 -1
  94. package/scss/_dropdown.scss +83 -75
  95. package/scss/_functions.scss +7 -7
  96. package/scss/_grid.scss +3 -3
  97. package/scss/_helpers.scss +1 -0
  98. package/scss/_list-group.scss +44 -27
  99. package/scss/_maps.scss +54 -0
  100. package/scss/_modal.scss +71 -43
  101. package/scss/_nav.scss +53 -20
  102. package/scss/_navbar.scss +91 -150
  103. package/scss/_offcanvas.scss +119 -59
  104. package/scss/_pagination.scss +66 -21
  105. package/scss/_placeholders.scss +1 -1
  106. package/scss/_popover.scss +90 -52
  107. package/scss/_progress.scss +20 -9
  108. package/scss/_reboot.scss +25 -40
  109. package/scss/_root.scss +40 -21
  110. package/scss/_spinners.scss +38 -22
  111. package/scss/_tables.scss +32 -23
  112. package/scss/_toasts.scss +35 -16
  113. package/scss/_tooltip.scss +61 -56
  114. package/scss/_type.scss +2 -0
  115. package/scss/_utilities.scss +43 -26
  116. package/scss/_variables.scss +113 -121
  117. package/scss/bootstrap-grid.scss +3 -6
  118. package/scss/bootstrap-reboot.scss +3 -7
  119. package/scss/bootstrap-utilities.scss +3 -6
  120. package/scss/bootstrap.scss +4 -6
  121. package/scss/forms/_floating-labels.scss +14 -3
  122. package/scss/forms/_form-check.scss +28 -5
  123. package/scss/forms/_form-control.scss +12 -37
  124. package/scss/forms/_form-select.scss +0 -1
  125. package/scss/forms/_input-group.scss +15 -7
  126. package/scss/helpers/_color-bg.scss +10 -0
  127. package/scss/helpers/_colored-links.scss +2 -2
  128. package/scss/helpers/_position.scss +7 -1
  129. package/scss/helpers/_ratio.scss +2 -2
  130. package/scss/helpers/_vr.scss +1 -1
  131. package/scss/mixins/_alert.scss +7 -3
  132. package/scss/mixins/_banner.scss +9 -0
  133. package/scss/mixins/_breakpoints.scss +8 -8
  134. package/scss/mixins/_buttons.scss +32 -95
  135. package/scss/mixins/_container.scss +4 -2
  136. package/scss/mixins/_forms.scss +8 -0
  137. package/scss/mixins/_gradients.scss +1 -1
  138. package/scss/mixins/_grid.scss +12 -12
  139. package/scss/mixins/_pagination.scss +4 -25
  140. package/scss/mixins/_reset-text.scss +1 -1
  141. package/scss/mixins/_table-variants.scss +12 -9
  142. package/scss/mixins/_utilities.scss +12 -4
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * --------------------------------------------------------------------------
3
- * Bootstrap (v5.1.3): offcanvas.js
3
+ * Bootstrap (v5.2.0): offcanvas.js
4
4
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
5
  * --------------------------------------------------------------------------
6
6
  */
@@ -9,22 +9,18 @@ import {
9
9
  defineJQueryPlugin,
10
10
  getElementFromSelector,
11
11
  isDisabled,
12
- isVisible,
13
- typeCheckConfig
12
+ isVisible
14
13
  } from './util/index'
15
14
  import ScrollBarHelper from './util/scrollbar'
16
15
  import EventHandler from './dom/event-handler'
17
16
  import BaseComponent from './base-component'
18
17
  import SelectorEngine from './dom/selector-engine'
19
- import Manipulator from './dom/manipulator'
20
18
  import Backdrop from './util/backdrop'
21
19
  import FocusTrap from './util/focustrap'
22
20
  import { enableDismissTrigger } from './util/component-functions'
23
21
 
24
22
  /**
25
- * ------------------------------------------------------------------------
26
23
  * Constants
27
- * ------------------------------------------------------------------------
28
24
  */
29
25
 
30
26
  const NAME = 'offcanvas'
@@ -34,42 +30,43 @@ const DATA_API_KEY = '.data-api'
34
30
  const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
35
31
  const ESCAPE_KEY = 'Escape'
36
32
 
37
- const Default = {
38
- backdrop: true,
39
- keyboard: true,
40
- scroll: false
41
- }
42
-
43
- const DefaultType = {
44
- backdrop: 'boolean',
45
- keyboard: 'boolean',
46
- scroll: 'boolean'
47
- }
48
-
49
33
  const CLASS_NAME_SHOW = 'show'
34
+ const CLASS_NAME_SHOWING = 'showing'
35
+ const CLASS_NAME_HIDING = 'hiding'
50
36
  const CLASS_NAME_BACKDROP = 'offcanvas-backdrop'
51
37
  const OPEN_SELECTOR = '.offcanvas.show'
52
38
 
53
39
  const EVENT_SHOW = `show${EVENT_KEY}`
54
40
  const EVENT_SHOWN = `shown${EVENT_KEY}`
55
41
  const EVENT_HIDE = `hide${EVENT_KEY}`
42
+ const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY}`
56
43
  const EVENT_HIDDEN = `hidden${EVENT_KEY}`
44
+ const EVENT_RESIZE = `resize${EVENT_KEY}`
57
45
  const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
58
46
  const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`
59
47
 
60
48
  const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="offcanvas"]'
61
49
 
50
+ const Default = {
51
+ backdrop: true,
52
+ keyboard: true,
53
+ scroll: false
54
+ }
55
+
56
+ const DefaultType = {
57
+ backdrop: '(boolean|string)',
58
+ keyboard: 'boolean',
59
+ scroll: 'boolean'
60
+ }
61
+
62
62
  /**
63
- * ------------------------------------------------------------------------
64
- * Class Definition
65
- * ------------------------------------------------------------------------
63
+ * Class definition
66
64
  */
67
65
 
68
66
  class Offcanvas extends BaseComponent {
69
67
  constructor(element, config) {
70
- super(element)
68
+ super(element, config)
71
69
 
72
- this._config = this._getConfig(config)
73
70
  this._isShown = false
74
71
  this._backdrop = this._initializeBackDrop()
75
72
  this._focustrap = this._initializeFocusTrap()
@@ -77,17 +74,19 @@ class Offcanvas extends BaseComponent {
77
74
  }
78
75
 
79
76
  // Getters
77
+ static get Default() {
78
+ return Default
79
+ }
80
80
 
81
- static get NAME() {
82
- return NAME
81
+ static get DefaultType() {
82
+ return DefaultType
83
83
  }
84
84
 
85
- static get Default() {
86
- return Default
85
+ static get NAME() {
86
+ return NAME
87
87
  }
88
88
 
89
89
  // Public
90
-
91
90
  toggle(relatedTarget) {
92
91
  return this._isShown ? this.hide() : this.show(relatedTarget)
93
92
  }
@@ -104,24 +103,23 @@ class Offcanvas extends BaseComponent {
104
103
  }
105
104
 
106
105
  this._isShown = true
107
- this._element.style.visibility = 'visible'
108
-
109
106
  this._backdrop.show()
110
107
 
111
108
  if (!this._config.scroll) {
112
109
  new ScrollBarHelper().hide()
113
110
  }
114
111
 
115
- this._element.removeAttribute('aria-hidden')
116
112
  this._element.setAttribute('aria-modal', true)
117
113
  this._element.setAttribute('role', 'dialog')
118
- this._element.classList.add(CLASS_NAME_SHOW)
114
+ this._element.classList.add(CLASS_NAME_SHOWING)
119
115
 
120
116
  const completeCallBack = () => {
121
- if (!this._config.scroll) {
117
+ if (!this._config.scroll || this._config.backdrop) {
122
118
  this._focustrap.activate()
123
119
  }
124
120
 
121
+ this._element.classList.add(CLASS_NAME_SHOW)
122
+ this._element.classList.remove(CLASS_NAME_SHOWING)
125
123
  EventHandler.trigger(this._element, EVENT_SHOWN, { relatedTarget })
126
124
  }
127
125
 
@@ -142,14 +140,13 @@ class Offcanvas extends BaseComponent {
142
140
  this._focustrap.deactivate()
143
141
  this._element.blur()
144
142
  this._isShown = false
145
- this._element.classList.remove(CLASS_NAME_SHOW)
143
+ this._element.classList.add(CLASS_NAME_HIDING)
146
144
  this._backdrop.hide()
147
145
 
148
146
  const completeCallback = () => {
149
- this._element.setAttribute('aria-hidden', true)
147
+ this._element.classList.remove(CLASS_NAME_SHOW, CLASS_NAME_HIDING)
150
148
  this._element.removeAttribute('aria-modal')
151
149
  this._element.removeAttribute('role')
152
- this._element.style.visibility = 'hidden'
153
150
 
154
151
  if (!this._config.scroll) {
155
152
  new ScrollBarHelper().reset()
@@ -168,24 +165,25 @@ class Offcanvas extends BaseComponent {
168
165
  }
169
166
 
170
167
  // Private
168
+ _initializeBackDrop() {
169
+ const clickCallback = () => {
170
+ if (this._config.backdrop === 'static') {
171
+ EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED)
172
+ return
173
+ }
171
174
 
172
- _getConfig(config) {
173
- config = {
174
- ...Default,
175
- ...Manipulator.getDataAttributes(this._element),
176
- ...(typeof config === 'object' ? config : {})
175
+ this.hide()
177
176
  }
178
- typeCheckConfig(NAME, config, DefaultType)
179
- return config
180
- }
181
177
 
182
- _initializeBackDrop() {
178
+ // 'static' option will be translated to true, and booleans will keep their value
179
+ const isVisible = Boolean(this._config.backdrop)
180
+
183
181
  return new Backdrop({
184
182
  className: CLASS_NAME_BACKDROP,
185
- isVisible: this._config.backdrop,
183
+ isVisible,
186
184
  isAnimated: true,
187
185
  rootElement: this._element.parentNode,
188
- clickCallback: () => this.hide()
186
+ clickCallback: isVisible ? clickCallback : null
189
187
  })
190
188
  }
191
189
 
@@ -197,14 +195,20 @@ class Offcanvas extends BaseComponent {
197
195
 
198
196
  _addEventListeners() {
199
197
  EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
200
- if (this._config.keyboard && event.key === ESCAPE_KEY) {
201
- this.hide()
198
+ if (event.key !== ESCAPE_KEY) {
199
+ return
200
+ }
201
+
202
+ if (!this._config.keyboard) {
203
+ EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED)
204
+ return
202
205
  }
206
+
207
+ this.hide()
203
208
  })
204
209
  }
205
210
 
206
211
  // Static
207
-
208
212
  static jQueryInterface(config) {
209
213
  return this.each(function () {
210
214
  const data = Offcanvas.getOrCreateInstance(this, config)
@@ -223,9 +227,7 @@ class Offcanvas extends BaseComponent {
223
227
  }
224
228
 
225
229
  /**
226
- * ------------------------------------------------------------------------
227
- * Data Api implementation
228
- * ------------------------------------------------------------------------
230
+ * Data API implementation
229
231
  */
230
232
 
231
233
  EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
@@ -247,24 +249,33 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
247
249
  })
248
250
 
249
251
  // avoid conflict when clicking a toggler of an offcanvas, while another is open
250
- const allReadyOpen = SelectorEngine.findOne(OPEN_SELECTOR)
251
- if (allReadyOpen && allReadyOpen !== target) {
252
- Offcanvas.getInstance(allReadyOpen).hide()
252
+ const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR)
253
+ if (alreadyOpen && alreadyOpen !== target) {
254
+ Offcanvas.getInstance(alreadyOpen).hide()
253
255
  }
254
256
 
255
257
  const data = Offcanvas.getOrCreateInstance(target)
256
258
  data.toggle(this)
257
259
  })
258
260
 
259
- EventHandler.on(window, EVENT_LOAD_DATA_API, () =>
260
- SelectorEngine.find(OPEN_SELECTOR).forEach(el => Offcanvas.getOrCreateInstance(el).show())
261
- )
261
+ EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
262
+ for (const selector of SelectorEngine.find(OPEN_SELECTOR)) {
263
+ Offcanvas.getOrCreateInstance(selector).show()
264
+ }
265
+ })
266
+
267
+ EventHandler.on(window, EVENT_RESIZE, () => {
268
+ for (const element of SelectorEngine.find('[aria-modal][class*=show][class*=offcanvas-]')) {
269
+ if (getComputedStyle(element).position !== 'fixed') {
270
+ Offcanvas.getOrCreateInstance(element).hide()
271
+ }
272
+ }
273
+ })
262
274
 
263
275
  enableDismissTrigger(Offcanvas)
276
+
264
277
  /**
265
- * ------------------------------------------------------------------------
266
278
  * jQuery
267
- * ------------------------------------------------------------------------
268
279
  */
269
280
 
270
281
  defineJQueryPlugin(Offcanvas)
package/js/src/popover.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * --------------------------------------------------------------------------
3
- * Bootstrap (v5.1.3): popover.js
3
+ * Bootstrap (v5.2.0): popover.js
4
4
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
5
  * --------------------------------------------------------------------------
6
6
  */
@@ -9,118 +9,87 @@ import { defineJQueryPlugin } from './util/index'
9
9
  import Tooltip from './tooltip'
10
10
 
11
11
  /**
12
- * ------------------------------------------------------------------------
13
12
  * Constants
14
- * ------------------------------------------------------------------------
15
13
  */
16
14
 
17
15
  const NAME = 'popover'
18
- const DATA_KEY = 'bs.popover'
19
- const EVENT_KEY = `.${DATA_KEY}`
20
- const CLASS_PREFIX = 'bs-popover'
16
+
17
+ const SELECTOR_TITLE = '.popover-header'
18
+ const SELECTOR_CONTENT = '.popover-body'
21
19
 
22
20
  const Default = {
23
21
  ...Tooltip.Default,
24
- placement: 'right',
25
- offset: [0, 8],
26
- trigger: 'click',
27
22
  content: '',
23
+ offset: [0, 8],
24
+ placement: 'right',
28
25
  template: '<div class="popover" role="tooltip">' +
29
- '<div class="popover-arrow"></div>' +
30
- '<h3 class="popover-header"></h3>' +
31
- '<div class="popover-body"></div>' +
32
- '</div>'
26
+ '<div class="popover-arrow"></div>' +
27
+ '<h3 class="popover-header"></h3>' +
28
+ '<div class="popover-body"></div>' +
29
+ '</div>',
30
+ trigger: 'click'
33
31
  }
34
32
 
35
33
  const DefaultType = {
36
34
  ...Tooltip.DefaultType,
37
- content: '(string|element|function)'
35
+ content: '(null|string|element|function)'
38
36
  }
39
37
 
40
- const Event = {
41
- HIDE: `hide${EVENT_KEY}`,
42
- HIDDEN: `hidden${EVENT_KEY}`,
43
- SHOW: `show${EVENT_KEY}`,
44
- SHOWN: `shown${EVENT_KEY}`,
45
- INSERTED: `inserted${EVENT_KEY}`,
46
- CLICK: `click${EVENT_KEY}`,
47
- FOCUSIN: `focusin${EVENT_KEY}`,
48
- FOCUSOUT: `focusout${EVENT_KEY}`,
49
- MOUSEENTER: `mouseenter${EVENT_KEY}`,
50
- MOUSELEAVE: `mouseleave${EVENT_KEY}`
51
- }
52
-
53
- const SELECTOR_TITLE = '.popover-header'
54
- const SELECTOR_CONTENT = '.popover-body'
55
-
56
38
  /**
57
- * ------------------------------------------------------------------------
58
- * Class Definition
59
- * ------------------------------------------------------------------------
39
+ * Class definition
60
40
  */
61
41
 
62
42
  class Popover extends Tooltip {
63
43
  // Getters
64
-
65
44
  static get Default() {
66
45
  return Default
67
46
  }
68
47
 
69
- static get NAME() {
70
- return NAME
71
- }
72
-
73
- static get Event() {
74
- return Event
75
- }
76
-
77
48
  static get DefaultType() {
78
49
  return DefaultType
79
50
  }
80
51
 
81
- // Overrides
82
-
83
- isWithContent() {
84
- return this.getTitle() || this._getContent()
52
+ static get NAME() {
53
+ return NAME
85
54
  }
86
55
 
87
- setContent(tip) {
88
- this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TITLE)
89
- this._sanitizeAndSetContent(tip, this._getContent(), SELECTOR_CONTENT)
56
+ // Overrides
57
+ _isWithContent() {
58
+ return this._getTitle() || this._getContent()
90
59
  }
91
60
 
92
61
  // Private
62
+ _getContentForTemplate() {
63
+ return {
64
+ [SELECTOR_TITLE]: this._getTitle(),
65
+ [SELECTOR_CONTENT]: this._getContent()
66
+ }
67
+ }
93
68
 
94
69
  _getContent() {
95
70
  return this._resolvePossibleFunction(this._config.content)
96
71
  }
97
72
 
98
- _getBasicClassPrefix() {
99
- return CLASS_PREFIX
100
- }
101
-
102
73
  // Static
103
-
104
74
  static jQueryInterface(config) {
105
75
  return this.each(function () {
106
76
  const data = Popover.getOrCreateInstance(this, config)
107
77
 
108
- if (typeof config === 'string') {
109
- if (typeof data[config] === 'undefined') {
110
- throw new TypeError(`No method named "${config}"`)
111
- }
78
+ if (typeof config !== 'string') {
79
+ return
80
+ }
112
81
 
113
- data[config]()
82
+ if (typeof data[config] === 'undefined') {
83
+ throw new TypeError(`No method named "${config}"`)
114
84
  }
85
+
86
+ data[config]()
115
87
  })
116
88
  }
117
89
  }
118
90
 
119
91
  /**
120
- * ------------------------------------------------------------------------
121
92
  * jQuery
122
- * ------------------------------------------------------------------------
123
- * add .Popover to jQuery only if jQuery is present
124
93
  */
125
94
 
126
95
  defineJQueryPlugin(Popover)