bootstrap 5.1.3 → 5.2.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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -4
  3. data/assets/javascripts/bootstrap/alert.js +11 -146
  4. data/assets/javascripts/bootstrap/base-component.js +37 -120
  5. data/assets/javascripts/bootstrap/button.js +10 -74
  6. data/assets/javascripts/bootstrap/carousel.js +213 -485
  7. data/assets/javascripts/bootstrap/collapse.js +65 -249
  8. data/assets/javascripts/bootstrap/dom/data.js +3 -5
  9. data/assets/javascripts/bootstrap/dom/event-handler.js +94 -132
  10. data/assets/javascripts/bootstrap/dom/manipulator.js +23 -27
  11. data/assets/javascripts/bootstrap/dom/selector-engine.js +16 -58
  12. data/assets/javascripts/bootstrap/dropdown.js +103 -317
  13. data/assets/javascripts/bootstrap/modal.js +107 -749
  14. data/assets/javascripts/bootstrap/offcanvas.js +90 -659
  15. data/assets/javascripts/bootstrap/popover.js +36 -118
  16. data/assets/javascripts/bootstrap/scrollspy.js +183 -262
  17. data/assets/javascripts/bootstrap/tab.js +215 -214
  18. data/assets/javascripts/bootstrap/toast.js +36 -218
  19. data/assets/javascripts/bootstrap/tooltip.js +280 -629
  20. data/assets/javascripts/bootstrap/util/backdrop.js +165 -0
  21. data/assets/javascripts/bootstrap/util/component-functions.js +46 -0
  22. data/assets/javascripts/bootstrap/util/config.js +79 -0
  23. data/assets/javascripts/bootstrap/util/focustrap.js +129 -0
  24. data/assets/javascripts/bootstrap/util/index.js +350 -0
  25. data/assets/javascripts/bootstrap/util/sanitizer.js +122 -0
  26. data/assets/javascripts/bootstrap/util/scrollbar.js +138 -0
  27. data/assets/javascripts/bootstrap/util/swipe.js +155 -0
  28. data/assets/javascripts/bootstrap/util/template-factory.js +177 -0
  29. data/assets/javascripts/bootstrap-global-this-define.js +1 -1
  30. data/assets/javascripts/bootstrap-sprockets.js +17 -8
  31. data/assets/javascripts/bootstrap.js +2093 -1881
  32. data/assets/javascripts/bootstrap.min.js +3 -3
  33. data/assets/stylesheets/_bootstrap-grid.scss +3 -6
  34. data/assets/stylesheets/_bootstrap-reboot.scss +3 -7
  35. data/assets/stylesheets/_bootstrap.scss +4 -6
  36. data/assets/stylesheets/bootstrap/_accordion.scss +56 -25
  37. data/assets/stylesheets/bootstrap/_alert.scss +18 -4
  38. data/assets/stylesheets/bootstrap/_badge.scss +14 -5
  39. data/assets/stylesheets/bootstrap/_breadcrumb.scss +22 -10
  40. data/assets/stylesheets/bootstrap/_button-group.scss +4 -1
  41. data/assets/stylesheets/bootstrap/_buttons.scss +125 -29
  42. data/assets/stylesheets/bootstrap/_card.scss +55 -37
  43. data/assets/stylesheets/bootstrap/_close.scss +1 -1
  44. data/assets/stylesheets/bootstrap/_containers.scss +1 -1
  45. data/assets/stylesheets/bootstrap/_dropdown.scss +85 -76
  46. data/assets/stylesheets/bootstrap/_functions.scss +8 -8
  47. data/assets/stylesheets/bootstrap/_grid.scss +3 -3
  48. data/assets/stylesheets/bootstrap/_helpers.scss +1 -0
  49. data/assets/stylesheets/bootstrap/_list-group.scss +48 -30
  50. data/assets/stylesheets/bootstrap/_maps.scss +54 -0
  51. data/assets/stylesheets/bootstrap/_modal.scss +71 -43
  52. data/assets/stylesheets/bootstrap/_nav.scss +53 -20
  53. data/assets/stylesheets/bootstrap/_navbar.scss +93 -150
  54. data/assets/stylesheets/bootstrap/_offcanvas.scss +120 -59
  55. data/assets/stylesheets/bootstrap/_pagination.scss +66 -21
  56. data/assets/stylesheets/bootstrap/_placeholders.scss +1 -1
  57. data/assets/stylesheets/bootstrap/_popover.scss +90 -52
  58. data/assets/stylesheets/bootstrap/_progress.scss +20 -9
  59. data/assets/stylesheets/bootstrap/_reboot.scss +25 -40
  60. data/assets/stylesheets/bootstrap/_root.scss +40 -21
  61. data/assets/stylesheets/bootstrap/_spinners.scss +38 -22
  62. data/assets/stylesheets/bootstrap/_tables.scss +32 -23
  63. data/assets/stylesheets/bootstrap/_toasts.scss +38 -16
  64. data/assets/stylesheets/bootstrap/_tooltip.scss +61 -56
  65. data/assets/stylesheets/bootstrap/_type.scss +2 -0
  66. data/assets/stylesheets/bootstrap/_utilities.scss +43 -26
  67. data/assets/stylesheets/bootstrap/_variables.scss +128 -135
  68. data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +3 -6
  69. data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +15 -3
  70. data/assets/stylesheets/bootstrap/forms/_form-check.scss +28 -5
  71. data/assets/stylesheets/bootstrap/forms/_form-control.scss +12 -37
  72. data/assets/stylesheets/bootstrap/forms/_form-select.scss +0 -1
  73. data/assets/stylesheets/bootstrap/forms/_input-group.scss +19 -8
  74. data/assets/stylesheets/bootstrap/helpers/_color-bg.scss +10 -0
  75. data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +2 -2
  76. data/assets/stylesheets/bootstrap/helpers/_position.scss +7 -1
  77. data/assets/stylesheets/bootstrap/helpers/_ratio.scss +2 -2
  78. data/assets/stylesheets/bootstrap/helpers/_vr.scss +1 -1
  79. data/assets/stylesheets/bootstrap/mixins/_alert.scss +7 -3
  80. data/assets/stylesheets/bootstrap/mixins/_banner.scss +9 -0
  81. data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +8 -8
  82. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +32 -95
  83. data/assets/stylesheets/bootstrap/mixins/_container.scss +4 -2
  84. data/assets/stylesheets/bootstrap/mixins/_forms.scss +18 -10
  85. data/assets/stylesheets/bootstrap/mixins/_gradients.scss +1 -1
  86. data/assets/stylesheets/bootstrap/mixins/_grid.scss +12 -12
  87. data/assets/stylesheets/bootstrap/mixins/_pagination.scss +4 -25
  88. data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +1 -1
  89. data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +12 -9
  90. data/assets/stylesheets/bootstrap/mixins/_utilities.scss +13 -5
  91. data/bootstrap.gemspec +1 -1
  92. data/lib/bootstrap/version.rb +2 -2
  93. data/tasks/updater/js.rb +10 -5
  94. data/tasks/updater.rb +2 -2
  95. metadata +16 -4
@@ -1,620 +1,31 @@
1
1
  /*!
2
- * Bootstrap offcanvas.js v5.1.3 (https://getbootstrap.com/)
3
- * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
2
+ * Bootstrap offcanvas.js v5.2.2 (https://getbootstrap.com/)
3
+ * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4
4
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
5
  */
6
6
  (function (global, factory) {
7
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/selector-engine.js'), require('./dom/manipulator.js'), require('./dom/event-handler.js'), require('./base-component.js')) :
8
- typeof define === 'function' && define.amd ? define(['./dom/selector-engine', './dom/manipulator', './dom/event-handler', './base-component'], factory) :
9
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Offcanvas = factory(global.SelectorEngine, global.Manipulator, global.EventHandler, global.Base));
10
- })(this, (function (SelectorEngine, Manipulator, EventHandler, BaseComponent) { 'use strict';
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./util/index'), require('./util/scrollbar'), require('./dom/event-handler'), require('./base-component'), require('./dom/selector-engine'), require('./util/backdrop'), require('./util/focustrap'), require('./util/component-functions')) :
8
+ typeof define === 'function' && define.amd ? define(['./util/index', './util/scrollbar', './dom/event-handler', './base-component', './dom/selector-engine', './util/backdrop', './util/focustrap', './util/component-functions'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Offcanvas = factory(global.Index, global.Scrollbar, global.EventHandler, global.BaseComponent, global.SelectorEngine, global.Backdrop, global.Focustrap, global.ComponentFunctions));
10
+ })(this, (function (index, ScrollBarHelper, EventHandler, BaseComponent, SelectorEngine, Backdrop, FocusTrap, componentFunctions) { 'use strict';
11
11
 
12
12
  const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
13
13
 
14
- const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
15
- const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
14
+ const ScrollBarHelper__default = /*#__PURE__*/_interopDefaultLegacy(ScrollBarHelper);
16
15
  const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
17
16
  const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
17
+ const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
18
+ const Backdrop__default = /*#__PURE__*/_interopDefaultLegacy(Backdrop);
19
+ const FocusTrap__default = /*#__PURE__*/_interopDefaultLegacy(FocusTrap);
18
20
 
19
21
  /**
20
22
  * --------------------------------------------------------------------------
21
- * Bootstrap (v5.1.3): util/index.js
22
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
23
- * --------------------------------------------------------------------------
24
- */
25
- const MILLISECONDS_MULTIPLIER = 1000;
26
- const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
27
-
28
- const toType = obj => {
29
- if (obj === null || obj === undefined) {
30
- return `${obj}`;
31
- }
32
-
33
- return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
34
- };
35
-
36
- const getSelector = element => {
37
- let selector = element.getAttribute('data-bs-target');
38
-
39
- if (!selector || selector === '#') {
40
- let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
41
- // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
42
- // `document.querySelector` will rightfully complain it is invalid.
43
- // See https://github.com/twbs/bootstrap/issues/32273
44
-
45
- if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) {
46
- return null;
47
- } // Just in case some CMS puts out a full URL with the anchor appended
48
-
49
-
50
- if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
51
- hrefAttr = `#${hrefAttr.split('#')[1]}`;
52
- }
53
-
54
- selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
55
- }
56
-
57
- return selector;
58
- };
59
-
60
- const getElementFromSelector = element => {
61
- const selector = getSelector(element);
62
- return selector ? document.querySelector(selector) : null;
63
- };
64
-
65
- const getTransitionDurationFromElement = element => {
66
- if (!element) {
67
- return 0;
68
- } // Get transition-duration of the element
69
-
70
-
71
- let {
72
- transitionDuration,
73
- transitionDelay
74
- } = window.getComputedStyle(element);
75
- const floatTransitionDuration = Number.parseFloat(transitionDuration);
76
- const floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
77
-
78
- if (!floatTransitionDuration && !floatTransitionDelay) {
79
- return 0;
80
- } // If multiple durations are defined, take the first
81
-
82
-
83
- transitionDuration = transitionDuration.split(',')[0];
84
- transitionDelay = transitionDelay.split(',')[0];
85
- return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
86
- };
87
-
88
- const triggerTransitionEnd = element => {
89
- element.dispatchEvent(new Event(TRANSITION_END));
90
- };
91
-
92
- const isElement = obj => {
93
- if (!obj || typeof obj !== 'object') {
94
- return false;
95
- }
96
-
97
- if (typeof obj.jquery !== 'undefined') {
98
- obj = obj[0];
99
- }
100
-
101
- return typeof obj.nodeType !== 'undefined';
102
- };
103
-
104
- const getElement = obj => {
105
- if (isElement(obj)) {
106
- // it's a jQuery object or a node element
107
- return obj.jquery ? obj[0] : obj;
108
- }
109
-
110
- if (typeof obj === 'string' && obj.length > 0) {
111
- return document.querySelector(obj);
112
- }
113
-
114
- return null;
115
- };
116
-
117
- const typeCheckConfig = (componentName, config, configTypes) => {
118
- Object.keys(configTypes).forEach(property => {
119
- const expectedTypes = configTypes[property];
120
- const value = config[property];
121
- const valueType = value && isElement(value) ? 'element' : toType(value);
122
-
123
- if (!new RegExp(expectedTypes).test(valueType)) {
124
- throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
125
- }
126
- });
127
- };
128
-
129
- const isVisible = element => {
130
- if (!isElement(element) || element.getClientRects().length === 0) {
131
- return false;
132
- }
133
-
134
- return getComputedStyle(element).getPropertyValue('visibility') === 'visible';
135
- };
136
-
137
- const isDisabled = element => {
138
- if (!element || element.nodeType !== Node.ELEMENT_NODE) {
139
- return true;
140
- }
141
-
142
- if (element.classList.contains('disabled')) {
143
- return true;
144
- }
145
-
146
- if (typeof element.disabled !== 'undefined') {
147
- return element.disabled;
148
- }
149
-
150
- return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
151
- };
152
- /**
153
- * Trick to restart an element's animation
154
- *
155
- * @param {HTMLElement} element
156
- * @return void
157
- *
158
- * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
159
- */
160
-
161
-
162
- const reflow = element => {
163
- // eslint-disable-next-line no-unused-expressions
164
- element.offsetHeight;
165
- };
166
-
167
- const getjQuery = () => {
168
- const {
169
- jQuery
170
- } = window;
171
-
172
- if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
173
- return jQuery;
174
- }
175
-
176
- return null;
177
- };
178
-
179
- const DOMContentLoadedCallbacks = [];
180
-
181
- const onDOMContentLoaded = callback => {
182
- if (document.readyState === 'loading') {
183
- // add listener on the first call when the document is in loading state
184
- if (!DOMContentLoadedCallbacks.length) {
185
- document.addEventListener('DOMContentLoaded', () => {
186
- DOMContentLoadedCallbacks.forEach(callback => callback());
187
- });
188
- }
189
-
190
- DOMContentLoadedCallbacks.push(callback);
191
- } else {
192
- callback();
193
- }
194
- };
195
-
196
- const defineJQueryPlugin = plugin => {
197
- onDOMContentLoaded(() => {
198
- const $ = getjQuery();
199
- /* istanbul ignore if */
200
-
201
- if ($) {
202
- const name = plugin.NAME;
203
- const JQUERY_NO_CONFLICT = $.fn[name];
204
- $.fn[name] = plugin.jQueryInterface;
205
- $.fn[name].Constructor = plugin;
206
-
207
- $.fn[name].noConflict = () => {
208
- $.fn[name] = JQUERY_NO_CONFLICT;
209
- return plugin.jQueryInterface;
210
- };
211
- }
212
- });
213
- };
214
-
215
- const execute = callback => {
216
- if (typeof callback === 'function') {
217
- callback();
218
- }
219
- };
220
-
221
- const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
222
- if (!waitForTransition) {
223
- execute(callback);
224
- return;
225
- }
226
-
227
- const durationPadding = 5;
228
- const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
229
- let called = false;
230
-
231
- const handler = ({
232
- target
233
- }) => {
234
- if (target !== transitionElement) {
235
- return;
236
- }
237
-
238
- called = true;
239
- transitionElement.removeEventListener(TRANSITION_END, handler);
240
- execute(callback);
241
- };
242
-
243
- transitionElement.addEventListener(TRANSITION_END, handler);
244
- setTimeout(() => {
245
- if (!called) {
246
- triggerTransitionEnd(transitionElement);
247
- }
248
- }, emulatedDuration);
249
- };
250
-
251
- /**
252
- * --------------------------------------------------------------------------
253
- * Bootstrap (v5.1.3): util/scrollBar.js
254
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
255
- * --------------------------------------------------------------------------
256
- */
257
- const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
258
- const SELECTOR_STICKY_CONTENT = '.sticky-top';
259
-
260
- class ScrollBarHelper {
261
- constructor() {
262
- this._element = document.body;
263
- }
264
-
265
- getWidth() {
266
- // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
267
- const documentWidth = document.documentElement.clientWidth;
268
- return Math.abs(window.innerWidth - documentWidth);
269
- }
270
-
271
- hide() {
272
- const width = this.getWidth();
273
-
274
- this._disableOverFlow(); // give padding to element to balance the hidden scrollbar width
275
-
276
-
277
- this._setElementAttributes(this._element, 'paddingRight', calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth
278
-
279
-
280
- this._setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width);
281
-
282
- this._setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width);
283
- }
284
-
285
- _disableOverFlow() {
286
- this._saveInitialAttribute(this._element, 'overflow');
287
-
288
- this._element.style.overflow = 'hidden';
289
- }
290
-
291
- _setElementAttributes(selector, styleProp, callback) {
292
- const scrollbarWidth = this.getWidth();
293
-
294
- const manipulationCallBack = element => {
295
- if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
296
- return;
297
- }
298
-
299
- this._saveInitialAttribute(element, styleProp);
300
-
301
- const calculatedValue = window.getComputedStyle(element)[styleProp];
302
- element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`;
303
- };
304
-
305
- this._applyManipulationCallback(selector, manipulationCallBack);
306
- }
307
-
308
- reset() {
309
- this._resetElementAttributes(this._element, 'overflow');
310
-
311
- this._resetElementAttributes(this._element, 'paddingRight');
312
-
313
- this._resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight');
314
-
315
- this._resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight');
316
- }
317
-
318
- _saveInitialAttribute(element, styleProp) {
319
- const actualValue = element.style[styleProp];
320
-
321
- if (actualValue) {
322
- Manipulator__default.default.setDataAttribute(element, styleProp, actualValue);
323
- }
324
- }
325
-
326
- _resetElementAttributes(selector, styleProp) {
327
- const manipulationCallBack = element => {
328
- const value = Manipulator__default.default.getDataAttribute(element, styleProp);
329
-
330
- if (typeof value === 'undefined') {
331
- element.style.removeProperty(styleProp);
332
- } else {
333
- Manipulator__default.default.removeDataAttribute(element, styleProp);
334
- element.style[styleProp] = value;
335
- }
336
- };
337
-
338
- this._applyManipulationCallback(selector, manipulationCallBack);
339
- }
340
-
341
- _applyManipulationCallback(selector, callBack) {
342
- if (isElement(selector)) {
343
- callBack(selector);
344
- } else {
345
- SelectorEngine__default.default.find(selector, this._element).forEach(callBack);
346
- }
347
- }
348
-
349
- isOverflowing() {
350
- return this.getWidth() > 0;
351
- }
352
-
353
- }
354
-
355
- /**
356
- * --------------------------------------------------------------------------
357
- * Bootstrap (v5.1.3): util/backdrop.js
358
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
359
- * --------------------------------------------------------------------------
360
- */
361
- const Default$2 = {
362
- className: 'modal-backdrop',
363
- isVisible: true,
364
- // if false, we use the backdrop helper without adding any element to the dom
365
- isAnimated: false,
366
- rootElement: 'body',
367
- // give the choice to place backdrop under different elements
368
- clickCallback: null
369
- };
370
- const DefaultType$2 = {
371
- className: 'string',
372
- isVisible: 'boolean',
373
- isAnimated: 'boolean',
374
- rootElement: '(element|string)',
375
- clickCallback: '(function|null)'
376
- };
377
- const NAME$2 = 'backdrop';
378
- const CLASS_NAME_FADE = 'fade';
379
- const CLASS_NAME_SHOW$1 = 'show';
380
- const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$2}`;
381
-
382
- class Backdrop {
383
- constructor(config) {
384
- this._config = this._getConfig(config);
385
- this._isAppended = false;
386
- this._element = null;
387
- }
388
-
389
- show(callback) {
390
- if (!this._config.isVisible) {
391
- execute(callback);
392
- return;
393
- }
394
-
395
- this._append();
396
-
397
- if (this._config.isAnimated) {
398
- reflow(this._getElement());
399
- }
400
-
401
- this._getElement().classList.add(CLASS_NAME_SHOW$1);
402
-
403
- this._emulateAnimation(() => {
404
- execute(callback);
405
- });
406
- }
407
-
408
- hide(callback) {
409
- if (!this._config.isVisible) {
410
- execute(callback);
411
- return;
412
- }
413
-
414
- this._getElement().classList.remove(CLASS_NAME_SHOW$1);
415
-
416
- this._emulateAnimation(() => {
417
- this.dispose();
418
- execute(callback);
419
- });
420
- } // Private
421
-
422
-
423
- _getElement() {
424
- if (!this._element) {
425
- const backdrop = document.createElement('div');
426
- backdrop.className = this._config.className;
427
-
428
- if (this._config.isAnimated) {
429
- backdrop.classList.add(CLASS_NAME_FADE);
430
- }
431
-
432
- this._element = backdrop;
433
- }
434
-
435
- return this._element;
436
- }
437
-
438
- _getConfig(config) {
439
- config = { ...Default$2,
440
- ...(typeof config === 'object' ? config : {})
441
- }; // use getElement() with the default "body" to get a fresh Element on each instantiation
442
-
443
- config.rootElement = getElement(config.rootElement);
444
- typeCheckConfig(NAME$2, config, DefaultType$2);
445
- return config;
446
- }
447
-
448
- _append() {
449
- if (this._isAppended) {
450
- return;
451
- }
452
-
453
- this._config.rootElement.append(this._getElement());
454
-
455
- EventHandler__default.default.on(this._getElement(), EVENT_MOUSEDOWN, () => {
456
- execute(this._config.clickCallback);
457
- });
458
- this._isAppended = true;
459
- }
460
-
461
- dispose() {
462
- if (!this._isAppended) {
463
- return;
464
- }
465
-
466
- EventHandler__default.default.off(this._element, EVENT_MOUSEDOWN);
467
-
468
- this._element.remove();
469
-
470
- this._isAppended = false;
471
- }
472
-
473
- _emulateAnimation(callback) {
474
- executeAfterTransition(callback, this._getElement(), this._config.isAnimated);
475
- }
476
-
477
- }
478
-
479
- /**
480
- * --------------------------------------------------------------------------
481
- * Bootstrap (v5.1.3): util/focustrap.js
482
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
483
- * --------------------------------------------------------------------------
484
- */
485
- const Default$1 = {
486
- trapElement: null,
487
- // The element to trap focus inside of
488
- autofocus: true
489
- };
490
- const DefaultType$1 = {
491
- trapElement: 'element',
492
- autofocus: 'boolean'
493
- };
494
- const NAME$1 = 'focustrap';
495
- const DATA_KEY$1 = 'bs.focustrap';
496
- const EVENT_KEY$1 = `.${DATA_KEY$1}`;
497
- const EVENT_FOCUSIN = `focusin${EVENT_KEY$1}`;
498
- const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$1}`;
499
- const TAB_KEY = 'Tab';
500
- const TAB_NAV_FORWARD = 'forward';
501
- const TAB_NAV_BACKWARD = 'backward';
502
-
503
- class FocusTrap {
504
- constructor(config) {
505
- this._config = this._getConfig(config);
506
- this._isActive = false;
507
- this._lastTabNavDirection = null;
508
- }
509
-
510
- activate() {
511
- const {
512
- trapElement,
513
- autofocus
514
- } = this._config;
515
-
516
- if (this._isActive) {
517
- return;
518
- }
519
-
520
- if (autofocus) {
521
- trapElement.focus();
522
- }
523
-
524
- EventHandler__default.default.off(document, EVENT_KEY$1); // guard against infinite focus loop
525
-
526
- EventHandler__default.default.on(document, EVENT_FOCUSIN, event => this._handleFocusin(event));
527
- EventHandler__default.default.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event));
528
- this._isActive = true;
529
- }
530
-
531
- deactivate() {
532
- if (!this._isActive) {
533
- return;
534
- }
535
-
536
- this._isActive = false;
537
- EventHandler__default.default.off(document, EVENT_KEY$1);
538
- } // Private
539
-
540
-
541
- _handleFocusin(event) {
542
- const {
543
- target
544
- } = event;
545
- const {
546
- trapElement
547
- } = this._config;
548
-
549
- if (target === document || target === trapElement || trapElement.contains(target)) {
550
- return;
551
- }
552
-
553
- const elements = SelectorEngine__default.default.focusableChildren(trapElement);
554
-
555
- if (elements.length === 0) {
556
- trapElement.focus();
557
- } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
558
- elements[elements.length - 1].focus();
559
- } else {
560
- elements[0].focus();
561
- }
562
- }
563
-
564
- _handleKeydown(event) {
565
- if (event.key !== TAB_KEY) {
566
- return;
567
- }
568
-
569
- this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD;
570
- }
571
-
572
- _getConfig(config) {
573
- config = { ...Default$1,
574
- ...(typeof config === 'object' ? config : {})
575
- };
576
- typeCheckConfig(NAME$1, config, DefaultType$1);
577
- return config;
578
- }
579
-
580
- }
581
-
582
- /**
583
- * --------------------------------------------------------------------------
584
- * Bootstrap (v5.1.3): util/component-functions.js
585
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
586
- * --------------------------------------------------------------------------
587
- */
588
-
589
- const enableDismissTrigger = (component, method = 'hide') => {
590
- const clickEvent = `click.dismiss${component.EVENT_KEY}`;
591
- const name = component.NAME;
592
- EventHandler__default.default.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
593
- if (['A', 'AREA'].includes(this.tagName)) {
594
- event.preventDefault();
595
- }
596
-
597
- if (isDisabled(this)) {
598
- return;
599
- }
600
-
601
- const target = getElementFromSelector(this) || this.closest(`.${name}`);
602
- const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
603
-
604
- instance[method]();
605
- });
606
- };
607
-
608
- /**
609
- * --------------------------------------------------------------------------
610
- * Bootstrap (v5.1.3): offcanvas.js
23
+ * Bootstrap (v5.2.2): offcanvas.js
611
24
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
612
25
  * --------------------------------------------------------------------------
613
26
  */
614
27
  /**
615
- * ------------------------------------------------------------------------
616
28
  * Constants
617
- * ------------------------------------------------------------------------
618
29
  */
619
30
 
620
31
  const NAME = 'offcanvas';
@@ -623,36 +34,37 @@
623
34
  const DATA_API_KEY = '.data-api';
624
35
  const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
625
36
  const ESCAPE_KEY = 'Escape';
626
- const Default = {
627
- backdrop: true,
628
- keyboard: true,
629
- scroll: false
630
- };
631
- const DefaultType = {
632
- backdrop: 'boolean',
633
- keyboard: 'boolean',
634
- scroll: 'boolean'
635
- };
636
37
  const CLASS_NAME_SHOW = 'show';
38
+ const CLASS_NAME_SHOWING = 'showing';
39
+ const CLASS_NAME_HIDING = 'hiding';
637
40
  const CLASS_NAME_BACKDROP = 'offcanvas-backdrop';
638
41
  const OPEN_SELECTOR = '.offcanvas.show';
639
42
  const EVENT_SHOW = `show${EVENT_KEY}`;
640
43
  const EVENT_SHOWN = `shown${EVENT_KEY}`;
641
44
  const EVENT_HIDE = `hide${EVENT_KEY}`;
45
+ const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY}`;
642
46
  const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
47
+ const EVENT_RESIZE = `resize${EVENT_KEY}`;
643
48
  const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
644
49
  const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`;
645
50
  const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="offcanvas"]';
51
+ const Default = {
52
+ backdrop: true,
53
+ keyboard: true,
54
+ scroll: false
55
+ };
56
+ const DefaultType = {
57
+ backdrop: '(boolean|string)',
58
+ keyboard: 'boolean',
59
+ scroll: 'boolean'
60
+ };
646
61
  /**
647
- * ------------------------------------------------------------------------
648
- * Class Definition
649
- * ------------------------------------------------------------------------
62
+ * Class definition
650
63
  */
651
64
 
652
65
  class Offcanvas extends BaseComponent__default.default {
653
66
  constructor(element, config) {
654
- super(element);
655
- this._config = this._getConfig(config);
67
+ super(element, config);
656
68
  this._isShown = false;
657
69
  this._backdrop = this._initializeBackDrop();
658
70
  this._focustrap = this._initializeFocusTrap();
@@ -661,12 +73,16 @@
661
73
  } // Getters
662
74
 
663
75
 
664
- static get NAME() {
665
- return NAME;
666
- }
667
-
668
76
  static get Default() {
669
77
  return Default;
78
+ }
79
+
80
+ static get DefaultType() {
81
+ return DefaultType;
82
+ }
83
+
84
+ static get NAME() {
85
+ return NAME;
670
86
  } // Public
671
87
 
672
88
 
@@ -688,27 +104,28 @@
688
104
  }
689
105
 
690
106
  this._isShown = true;
691
- this._element.style.visibility = 'visible';
692
107
 
693
108
  this._backdrop.show();
694
109
 
695
110
  if (!this._config.scroll) {
696
- new ScrollBarHelper().hide();
111
+ new ScrollBarHelper__default.default().hide();
697
112
  }
698
113
 
699
- this._element.removeAttribute('aria-hidden');
700
-
701
114
  this._element.setAttribute('aria-modal', true);
702
115
 
703
116
  this._element.setAttribute('role', 'dialog');
704
117
 
705
- this._element.classList.add(CLASS_NAME_SHOW);
118
+ this._element.classList.add(CLASS_NAME_SHOWING);
706
119
 
707
120
  const completeCallBack = () => {
708
- if (!this._config.scroll) {
121
+ if (!this._config.scroll || this._config.backdrop) {
709
122
  this._focustrap.activate();
710
123
  }
711
124
 
125
+ this._element.classList.add(CLASS_NAME_SHOW);
126
+
127
+ this._element.classList.remove(CLASS_NAME_SHOWING);
128
+
712
129
  EventHandler__default.default.trigger(this._element, EVENT_SHOWN, {
713
130
  relatedTarget
714
131
  });
@@ -734,21 +151,19 @@
734
151
 
735
152
  this._isShown = false;
736
153
 
737
- this._element.classList.remove(CLASS_NAME_SHOW);
154
+ this._element.classList.add(CLASS_NAME_HIDING);
738
155
 
739
156
  this._backdrop.hide();
740
157
 
741
158
  const completeCallback = () => {
742
- this._element.setAttribute('aria-hidden', true);
159
+ this._element.classList.remove(CLASS_NAME_SHOW, CLASS_NAME_HIDING);
743
160
 
744
161
  this._element.removeAttribute('aria-modal');
745
162
 
746
163
  this._element.removeAttribute('role');
747
164
 
748
- this._element.style.visibility = 'hidden';
749
-
750
165
  if (!this._config.scroll) {
751
- new ScrollBarHelper().reset();
166
+ new ScrollBarHelper__default.default().reset();
752
167
  }
753
168
 
754
169
  EventHandler__default.default.trigger(this._element, EVENT_HIDDEN);
@@ -766,36 +181,45 @@
766
181
  } // Private
767
182
 
768
183
 
769
- _getConfig(config) {
770
- config = { ...Default,
771
- ...Manipulator__default.default.getDataAttributes(this._element),
772
- ...(typeof config === 'object' ? config : {})
773
- };
774
- typeCheckConfig(NAME, config, DefaultType);
775
- return config;
776
- }
777
-
778
184
  _initializeBackDrop() {
779
- return new Backdrop({
185
+ const clickCallback = () => {
186
+ if (this._config.backdrop === 'static') {
187
+ EventHandler__default.default.trigger(this._element, EVENT_HIDE_PREVENTED);
188
+ return;
189
+ }
190
+
191
+ this.hide();
192
+ }; // 'static' option will be translated to true, and booleans will keep their value
193
+
194
+
195
+ const isVisible = Boolean(this._config.backdrop);
196
+ return new Backdrop__default.default({
780
197
  className: CLASS_NAME_BACKDROP,
781
- isVisible: this._config.backdrop,
198
+ isVisible,
782
199
  isAnimated: true,
783
200
  rootElement: this._element.parentNode,
784
- clickCallback: () => this.hide()
201
+ clickCallback: isVisible ? clickCallback : null
785
202
  });
786
203
  }
787
204
 
788
205
  _initializeFocusTrap() {
789
- return new FocusTrap({
206
+ return new FocusTrap__default.default({
790
207
  trapElement: this._element
791
208
  });
792
209
  }
793
210
 
794
211
  _addEventListeners() {
795
212
  EventHandler__default.default.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
796
- if (this._config.keyboard && event.key === ESCAPE_KEY) {
797
- this.hide();
213
+ if (event.key !== ESCAPE_KEY) {
214
+ return;
798
215
  }
216
+
217
+ if (!this._config.keyboard) {
218
+ EventHandler__default.default.trigger(this._element, EVENT_HIDE_PREVENTED);
219
+ return;
220
+ }
221
+
222
+ this.hide();
799
223
  });
800
224
  } // Static
801
225
 
@@ -818,48 +242,55 @@
818
242
 
819
243
  }
820
244
  /**
821
- * ------------------------------------------------------------------------
822
- * Data Api implementation
823
- * ------------------------------------------------------------------------
245
+ * Data API implementation
824
246
  */
825
247
 
826
248
 
827
249
  EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
828
- const target = getElementFromSelector(this);
250
+ const target = index.getElementFromSelector(this);
829
251
 
830
252
  if (['A', 'AREA'].includes(this.tagName)) {
831
253
  event.preventDefault();
832
254
  }
833
255
 
834
- if (isDisabled(this)) {
256
+ if (index.isDisabled(this)) {
835
257
  return;
836
258
  }
837
259
 
838
260
  EventHandler__default.default.one(target, EVENT_HIDDEN, () => {
839
261
  // focus on trigger when it is closed
840
- if (isVisible(this)) {
262
+ if (index.isVisible(this)) {
841
263
  this.focus();
842
264
  }
843
265
  }); // avoid conflict when clicking a toggler of an offcanvas, while another is open
844
266
 
845
- const allReadyOpen = SelectorEngine__default.default.findOne(OPEN_SELECTOR);
267
+ const alreadyOpen = SelectorEngine__default.default.findOne(OPEN_SELECTOR);
846
268
 
847
- if (allReadyOpen && allReadyOpen !== target) {
848
- Offcanvas.getInstance(allReadyOpen).hide();
269
+ if (alreadyOpen && alreadyOpen !== target) {
270
+ Offcanvas.getInstance(alreadyOpen).hide();
849
271
  }
850
272
 
851
273
  const data = Offcanvas.getOrCreateInstance(target);
852
274
  data.toggle(this);
853
275
  });
854
- EventHandler__default.default.on(window, EVENT_LOAD_DATA_API, () => SelectorEngine__default.default.find(OPEN_SELECTOR).forEach(el => Offcanvas.getOrCreateInstance(el).show()));
855
- enableDismissTrigger(Offcanvas);
276
+ EventHandler__default.default.on(window, EVENT_LOAD_DATA_API, () => {
277
+ for (const selector of SelectorEngine__default.default.find(OPEN_SELECTOR)) {
278
+ Offcanvas.getOrCreateInstance(selector).show();
279
+ }
280
+ });
281
+ EventHandler__default.default.on(window, EVENT_RESIZE, () => {
282
+ for (const element of SelectorEngine__default.default.find('[aria-modal][class*=show][class*=offcanvas-]')) {
283
+ if (getComputedStyle(element).position !== 'fixed') {
284
+ Offcanvas.getOrCreateInstance(element).hide();
285
+ }
286
+ }
287
+ });
288
+ componentFunctions.enableDismissTrigger(Offcanvas);
856
289
  /**
857
- * ------------------------------------------------------------------------
858
290
  * jQuery
859
- * ------------------------------------------------------------------------
860
291
  */
861
292
 
862
- defineJQueryPlugin(Offcanvas);
293
+ index.defineJQueryPlugin(Offcanvas);
863
294
 
864
295
  return Offcanvas;
865
296