bootstrap 4.6.2 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/README.md +7 -4
- data/assets/javascripts/bootstrap/alert.js +192 -115
- data/assets/javascripts/bootstrap/base-component.js +63 -0
- data/assets/javascripts/bootstrap/button.js +96 -179
- data/assets/javascripts/bootstrap/carousel.js +472 -359
- data/assets/javascripts/bootstrap/collapse.js +379 -225
- data/assets/javascripts/bootstrap/dom/data.js +68 -0
- data/assets/javascripts/bootstrap/dom/event-handler.js +322 -0
- data/assets/javascripts/bootstrap/dom/manipulator.js +88 -0
- data/assets/javascripts/bootstrap/dom/selector-engine.js +85 -0
- data/assets/javascripts/bootstrap/dropdown.js +472 -355
- data/assets/javascripts/bootstrap/modal.js +612 -438
- data/assets/javascripts/bootstrap/offcanvas.js +671 -0
- data/assets/javascripts/bootstrap/popover.js +138 -167
- data/assets/javascripts/bootstrap/scrollspy.js +250 -192
- data/assets/javascripts/bootstrap/tab.js +241 -144
- data/assets/javascripts/bootstrap/toast.js +223 -157
- data/assets/javascripts/bootstrap/tooltip.js +651 -487
- data/assets/javascripts/bootstrap-global-this-define.js +6 -0
- data/assets/javascripts/bootstrap-global-this-undefine.js +2 -0
- data/assets/javascripts/bootstrap-sprockets.js +8 -1
- data/assets/javascripts/bootstrap.js +3277 -2590
- data/assets/javascripts/bootstrap.min.js +3 -3
- data/assets/stylesheets/_bootstrap-grid.scss +53 -18
- data/assets/stylesheets/_bootstrap-reboot.scss +6 -3
- data/assets/stylesheets/_bootstrap.scss +18 -10
- data/assets/stylesheets/bootstrap/_accordion.scss +118 -0
- data/assets/stylesheets/bootstrap/_alert.scss +15 -10
- data/assets/stylesheets/bootstrap/_badge.scss +2 -27
- data/assets/stylesheets/bootstrap/_breadcrumb.scss +3 -17
- data/assets/stylesheets/bootstrap/_button-group.scss +21 -45
- data/assets/stylesheets/bootstrap/_buttons.scss +29 -60
- data/assets/stylesheets/bootstrap/_card.scss +20 -91
- data/assets/stylesheets/bootstrap/_carousel.scss +64 -35
- data/assets/stylesheets/bootstrap/_close.scss +30 -30
- data/assets/stylesheets/bootstrap/_containers.scss +41 -0
- data/assets/stylesheets/bootstrap/_dropdown.scss +84 -36
- data/assets/stylesheets/bootstrap/_forms.scss +9 -347
- data/assets/stylesheets/bootstrap/_functions.scss +84 -69
- data/assets/stylesheets/bootstrap/_grid.scss +3 -54
- data/assets/stylesheets/bootstrap/_helpers.scss +7 -0
- data/assets/stylesheets/bootstrap/_images.scss +1 -1
- data/assets/stylesheets/bootstrap/_list-group.scss +28 -8
- data/assets/stylesheets/bootstrap/_mixins.scss +8 -13
- data/assets/stylesheets/bootstrap/_modal.scss +45 -57
- data/assets/stylesheets/bootstrap/_nav.scss +20 -6
- data/assets/stylesheets/bootstrap/_navbar.scss +45 -71
- data/assets/stylesheets/bootstrap/_offcanvas.scss +77 -0
- data/assets/stylesheets/bootstrap/_pagination.scss +10 -20
- data/assets/stylesheets/bootstrap/_popover.scss +24 -36
- data/assets/stylesheets/bootstrap/_progress.scss +5 -4
- data/assets/stylesheets/bootstrap/_reboot.scss +316 -179
- data/assets/stylesheets/bootstrap/_root.scss +5 -8
- data/assets/stylesheets/bootstrap/_spinners.scss +11 -7
- data/assets/stylesheets/bootstrap/_tables.scss +79 -114
- data/assets/stylesheets/bootstrap/_toasts.scss +20 -15
- data/assets/stylesheets/bootstrap/_tooltip.scss +21 -21
- data/assets/stylesheets/bootstrap/_transitions.scss +2 -7
- data/assets/stylesheets/bootstrap/_type.scss +38 -59
- data/assets/stylesheets/bootstrap/_utilities.scss +594 -18
- data/assets/stylesheets/bootstrap/_variables.scss +800 -485
- data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +18 -0
- data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +61 -0
- data/assets/stylesheets/bootstrap/forms/_form-check.scss +152 -0
- data/assets/stylesheets/bootstrap/forms/_form-control.scss +219 -0
- data/assets/stylesheets/bootstrap/forms/_form-range.scss +91 -0
- data/assets/stylesheets/bootstrap/forms/_form-select.scss +67 -0
- data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
- data/assets/stylesheets/bootstrap/forms/_input-group.scss +121 -0
- data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
- data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
- data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +12 -0
- data/assets/stylesheets/bootstrap/helpers/_position.scss +30 -0
- data/assets/stylesheets/bootstrap/helpers/_ratio.scss +26 -0
- data/assets/stylesheets/bootstrap/helpers/_stretched-link.scss +15 -0
- data/assets/stylesheets/bootstrap/helpers/_text-truncation.scss +7 -0
- data/assets/stylesheets/bootstrap/helpers/_visually-hidden.scss +8 -0
- data/assets/stylesheets/bootstrap/mixins/_alert.scss +3 -5
- data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +10 -8
- data/assets/stylesheets/bootstrap/mixins/_box-shadow.scss +7 -9
- data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +14 -10
- data/assets/stylesheets/bootstrap/mixins/_buttons.scss +71 -48
- data/assets/stylesheets/bootstrap/mixins/_caret.scss +10 -8
- data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +2 -0
- data/assets/stylesheets/bootstrap/mixins/_color-scheme.scss +7 -0
- data/assets/stylesheets/bootstrap/mixins/_container.scss +9 -0
- data/assets/stylesheets/bootstrap/mixins/_forms.scss +39 -97
- data/assets/stylesheets/bootstrap/mixins/_gradients.scss +13 -11
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +90 -34
- data/assets/stylesheets/bootstrap/mixins/_image.scss +1 -21
- data/assets/stylesheets/bootstrap/mixins/_list-group.scss +5 -2
- data/assets/stylesheets/bootstrap/mixins/_lists.scss +1 -1
- data/assets/stylesheets/bootstrap/mixins/_pagination.scss +17 -8
- data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +3 -3
- data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +21 -0
- data/assets/stylesheets/bootstrap/mixins/_transition.scss +1 -1
- data/assets/stylesheets/bootstrap/mixins/_utilities.scss +68 -0
- data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +29 -0
- data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
- data/assets/stylesheets/bootstrap/vendor/_rfs.scss +214 -130
- data/bootstrap.gemspec +1 -3
- data/lib/bootstrap/version.rb +2 -2
- data/tasks/updater/js.rb +19 -16
- data/test/dummy_rails/app/assets/javascripts/application.js +4 -3
- data/test/dummy_rails/app/views/layouts/application.html.erb +3 -1
- data/test/dummy_rails/app/views/pages/root.html +89 -0
- data/test/dummy_rails/config/application.rb +0 -3
- data/test/gemfiles/rails_6_1.gemfile +7 -0
- metadata +45 -73
- data/assets/javascripts/bootstrap/util.js +0 -189
- data/assets/stylesheets/bootstrap/_code.scss +0 -48
- data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -526
- data/assets/stylesheets/bootstrap/_input-group.scss +0 -211
- data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -17
- data/assets/stylesheets/bootstrap/_media.scss +0 -8
- data/assets/stylesheets/bootstrap/_print.scss +0 -132
- data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +0 -23
- data/assets/stylesheets/bootstrap/mixins/_badge.scss +0 -17
- data/assets/stylesheets/bootstrap/mixins/_float.scss +0 -14
- data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +0 -80
- data/assets/stylesheets/bootstrap/mixins/_hover.scss +0 -37
- data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -11
- data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +0 -34
- data/assets/stylesheets/bootstrap/mixins/_size.scss +0 -7
- data/assets/stylesheets/bootstrap/mixins/_table-row.scss +0 -39
- data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +0 -17
- data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +0 -11
- data/assets/stylesheets/bootstrap/mixins/_visibility.scss +0 -8
- data/assets/stylesheets/bootstrap/utilities/_align.scss +0 -8
- data/assets/stylesheets/bootstrap/utilities/_background.scss +0 -19
- data/assets/stylesheets/bootstrap/utilities/_borders.scss +0 -75
- data/assets/stylesheets/bootstrap/utilities/_display.scss +0 -26
- data/assets/stylesheets/bootstrap/utilities/_embed.scss +0 -39
- data/assets/stylesheets/bootstrap/utilities/_flex.scss +0 -51
- data/assets/stylesheets/bootstrap/utilities/_float.scss +0 -11
- data/assets/stylesheets/bootstrap/utilities/_interactions.scss +0 -5
- data/assets/stylesheets/bootstrap/utilities/_overflow.scss +0 -5
- data/assets/stylesheets/bootstrap/utilities/_position.scss +0 -32
- data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +0 -11
- data/assets/stylesheets/bootstrap/utilities/_shadows.scss +0 -6
- data/assets/stylesheets/bootstrap/utilities/_sizing.scss +0 -20
- data/assets/stylesheets/bootstrap/utilities/_spacing.scss +0 -73
- data/assets/stylesheets/bootstrap/utilities/_stretched-link.scss +0 -19
- data/assets/stylesheets/bootstrap/utilities/_text.scss +0 -72
- data/assets/stylesheets/bootstrap/utilities/_visibility.scss +0 -13
- data/test/dummy_rails/app/views/pages/root.html.slim +0 -58
- /data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
@@ -0,0 +1,671 @@
|
|
1
|
+
/*!
|
2
|
+
* Bootstrap offcanvas.js v5.0.0 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
|
+
*/
|
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/data.js'), require('./dom/event-handler.js'), require('./base-component.js')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['./dom/selector-engine', './dom/manipulator', './dom/data', './dom/event-handler', './base-component'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Offcanvas = factory(global.SelectorEngine, global.Manipulator, global.Data, global.EventHandler, global.Base));
|
10
|
+
}(this, (function (SelectorEngine, Manipulator, Data, EventHandler, BaseComponent) { 'use strict';
|
11
|
+
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
13
|
+
|
14
|
+
var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
|
15
|
+
var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
|
16
|
+
var Data__default = /*#__PURE__*/_interopDefaultLegacy(Data);
|
17
|
+
var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
|
18
|
+
var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
|
19
|
+
|
20
|
+
/**
|
21
|
+
* --------------------------------------------------------------------------
|
22
|
+
* Bootstrap (v5.0.0): util/index.js
|
23
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
24
|
+
* --------------------------------------------------------------------------
|
25
|
+
*/
|
26
|
+
const MILLISECONDS_MULTIPLIER = 1000;
|
27
|
+
const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
|
28
|
+
|
29
|
+
const toType = obj => {
|
30
|
+
if (obj === null || obj === undefined) {
|
31
|
+
return `${obj}`;
|
32
|
+
}
|
33
|
+
|
34
|
+
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
|
35
|
+
};
|
36
|
+
|
37
|
+
const getSelector = element => {
|
38
|
+
let selector = element.getAttribute('data-bs-target');
|
39
|
+
|
40
|
+
if (!selector || selector === '#') {
|
41
|
+
let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
|
42
|
+
// so everything starting with `#` or `.`. If a "real" URL is used as the selector,
|
43
|
+
// `document.querySelector` will rightfully complain it is invalid.
|
44
|
+
// See https://github.com/twbs/bootstrap/issues/32273
|
45
|
+
|
46
|
+
if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) {
|
47
|
+
return null;
|
48
|
+
} // Just in case some CMS puts out a full URL with the anchor appended
|
49
|
+
|
50
|
+
|
51
|
+
if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
|
52
|
+
hrefAttr = `#${hrefAttr.split('#')[1]}`;
|
53
|
+
}
|
54
|
+
|
55
|
+
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
|
56
|
+
}
|
57
|
+
|
58
|
+
return selector;
|
59
|
+
};
|
60
|
+
|
61
|
+
const getElementFromSelector = element => {
|
62
|
+
const selector = getSelector(element);
|
63
|
+
return selector ? document.querySelector(selector) : null;
|
64
|
+
};
|
65
|
+
|
66
|
+
const getTransitionDurationFromElement = element => {
|
67
|
+
if (!element) {
|
68
|
+
return 0;
|
69
|
+
} // Get transition-duration of the element
|
70
|
+
|
71
|
+
|
72
|
+
let {
|
73
|
+
transitionDuration,
|
74
|
+
transitionDelay
|
75
|
+
} = window.getComputedStyle(element);
|
76
|
+
const floatTransitionDuration = Number.parseFloat(transitionDuration);
|
77
|
+
const floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
|
78
|
+
|
79
|
+
if (!floatTransitionDuration && !floatTransitionDelay) {
|
80
|
+
return 0;
|
81
|
+
} // If multiple durations are defined, take the first
|
82
|
+
|
83
|
+
|
84
|
+
transitionDuration = transitionDuration.split(',')[0];
|
85
|
+
transitionDelay = transitionDelay.split(',')[0];
|
86
|
+
return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
|
87
|
+
};
|
88
|
+
|
89
|
+
const triggerTransitionEnd = element => {
|
90
|
+
element.dispatchEvent(new Event(TRANSITION_END));
|
91
|
+
};
|
92
|
+
|
93
|
+
const isElement = obj => (obj[0] || obj).nodeType;
|
94
|
+
|
95
|
+
const emulateTransitionEnd = (element, duration) => {
|
96
|
+
let called = false;
|
97
|
+
const durationPadding = 5;
|
98
|
+
const emulatedDuration = duration + durationPadding;
|
99
|
+
|
100
|
+
function listener() {
|
101
|
+
called = true;
|
102
|
+
element.removeEventListener(TRANSITION_END, listener);
|
103
|
+
}
|
104
|
+
|
105
|
+
element.addEventListener(TRANSITION_END, listener);
|
106
|
+
setTimeout(() => {
|
107
|
+
if (!called) {
|
108
|
+
triggerTransitionEnd(element);
|
109
|
+
}
|
110
|
+
}, emulatedDuration);
|
111
|
+
};
|
112
|
+
|
113
|
+
const typeCheckConfig = (componentName, config, configTypes) => {
|
114
|
+
Object.keys(configTypes).forEach(property => {
|
115
|
+
const expectedTypes = configTypes[property];
|
116
|
+
const value = config[property];
|
117
|
+
const valueType = value && isElement(value) ? 'element' : toType(value);
|
118
|
+
|
119
|
+
if (!new RegExp(expectedTypes).test(valueType)) {
|
120
|
+
throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
|
121
|
+
}
|
122
|
+
});
|
123
|
+
};
|
124
|
+
|
125
|
+
const isVisible = element => {
|
126
|
+
if (!element) {
|
127
|
+
return false;
|
128
|
+
}
|
129
|
+
|
130
|
+
if (element.style && element.parentNode && element.parentNode.style) {
|
131
|
+
const elementStyle = getComputedStyle(element);
|
132
|
+
const parentNodeStyle = getComputedStyle(element.parentNode);
|
133
|
+
return elementStyle.display !== 'none' && parentNodeStyle.display !== 'none' && elementStyle.visibility !== 'hidden';
|
134
|
+
}
|
135
|
+
|
136
|
+
return false;
|
137
|
+
};
|
138
|
+
|
139
|
+
const isDisabled = element => {
|
140
|
+
if (!element || element.nodeType !== Node.ELEMENT_NODE) {
|
141
|
+
return true;
|
142
|
+
}
|
143
|
+
|
144
|
+
if (element.classList.contains('disabled')) {
|
145
|
+
return true;
|
146
|
+
}
|
147
|
+
|
148
|
+
if (typeof element.disabled !== 'undefined') {
|
149
|
+
return element.disabled;
|
150
|
+
}
|
151
|
+
|
152
|
+
return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
|
153
|
+
};
|
154
|
+
|
155
|
+
const reflow = element => element.offsetHeight;
|
156
|
+
|
157
|
+
const getjQuery = () => {
|
158
|
+
const {
|
159
|
+
jQuery
|
160
|
+
} = window;
|
161
|
+
|
162
|
+
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
|
163
|
+
return jQuery;
|
164
|
+
}
|
165
|
+
|
166
|
+
return null;
|
167
|
+
};
|
168
|
+
|
169
|
+
const onDOMContentLoaded = callback => {
|
170
|
+
if (document.readyState === 'loading') {
|
171
|
+
document.addEventListener('DOMContentLoaded', callback);
|
172
|
+
} else {
|
173
|
+
callback();
|
174
|
+
}
|
175
|
+
};
|
176
|
+
|
177
|
+
const defineJQueryPlugin = (name, plugin) => {
|
178
|
+
onDOMContentLoaded(() => {
|
179
|
+
const $ = getjQuery();
|
180
|
+
/* istanbul ignore if */
|
181
|
+
|
182
|
+
if ($) {
|
183
|
+
const JQUERY_NO_CONFLICT = $.fn[name];
|
184
|
+
$.fn[name] = plugin.jQueryInterface;
|
185
|
+
$.fn[name].Constructor = plugin;
|
186
|
+
|
187
|
+
$.fn[name].noConflict = () => {
|
188
|
+
$.fn[name] = JQUERY_NO_CONFLICT;
|
189
|
+
return plugin.jQueryInterface;
|
190
|
+
};
|
191
|
+
}
|
192
|
+
});
|
193
|
+
};
|
194
|
+
|
195
|
+
const execute = callback => {
|
196
|
+
if (typeof callback === 'function') {
|
197
|
+
callback();
|
198
|
+
}
|
199
|
+
};
|
200
|
+
|
201
|
+
/**
|
202
|
+
* --------------------------------------------------------------------------
|
203
|
+
* Bootstrap (v5.0.0): util/scrollBar.js
|
204
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
205
|
+
* --------------------------------------------------------------------------
|
206
|
+
*/
|
207
|
+
const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
|
208
|
+
const SELECTOR_STICKY_CONTENT = '.sticky-top';
|
209
|
+
|
210
|
+
const getWidth = () => {
|
211
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
|
212
|
+
const documentWidth = document.documentElement.clientWidth;
|
213
|
+
return Math.abs(window.innerWidth - documentWidth);
|
214
|
+
};
|
215
|
+
|
216
|
+
const hide = (width = getWidth()) => {
|
217
|
+
_disableOverFlow(); // give padding to element to balances the hidden scrollbar width
|
218
|
+
|
219
|
+
|
220
|
+
_setElementAttributes('body', 'paddingRight', calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements, to keep shown fullwidth
|
221
|
+
|
222
|
+
|
223
|
+
_setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width);
|
224
|
+
|
225
|
+
_setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width);
|
226
|
+
};
|
227
|
+
|
228
|
+
const _disableOverFlow = () => {
|
229
|
+
const actualValue = document.body.style.overflow;
|
230
|
+
|
231
|
+
if (actualValue) {
|
232
|
+
Manipulator__default['default'].setDataAttribute(document.body, 'overflow', actualValue);
|
233
|
+
}
|
234
|
+
|
235
|
+
document.body.style.overflow = 'hidden';
|
236
|
+
};
|
237
|
+
|
238
|
+
const _setElementAttributes = (selector, styleProp, callback) => {
|
239
|
+
const scrollbarWidth = getWidth();
|
240
|
+
SelectorEngine__default['default'].find(selector).forEach(element => {
|
241
|
+
if (element !== document.body && window.innerWidth > element.clientWidth + scrollbarWidth) {
|
242
|
+
return;
|
243
|
+
}
|
244
|
+
|
245
|
+
const actualValue = element.style[styleProp];
|
246
|
+
const calculatedValue = window.getComputedStyle(element)[styleProp];
|
247
|
+
Manipulator__default['default'].setDataAttribute(element, styleProp, actualValue);
|
248
|
+
element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`;
|
249
|
+
});
|
250
|
+
};
|
251
|
+
|
252
|
+
const reset = () => {
|
253
|
+
_resetElementAttributes('body', 'overflow');
|
254
|
+
|
255
|
+
_resetElementAttributes('body', 'paddingRight');
|
256
|
+
|
257
|
+
_resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight');
|
258
|
+
|
259
|
+
_resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight');
|
260
|
+
};
|
261
|
+
|
262
|
+
const _resetElementAttributes = (selector, styleProp) => {
|
263
|
+
SelectorEngine__default['default'].find(selector).forEach(element => {
|
264
|
+
const value = Manipulator__default['default'].getDataAttribute(element, styleProp);
|
265
|
+
|
266
|
+
if (typeof value === 'undefined') {
|
267
|
+
element.style.removeProperty(styleProp);
|
268
|
+
} else {
|
269
|
+
Manipulator__default['default'].removeDataAttribute(element, styleProp);
|
270
|
+
element.style[styleProp] = value;
|
271
|
+
}
|
272
|
+
});
|
273
|
+
};
|
274
|
+
|
275
|
+
/**
|
276
|
+
* --------------------------------------------------------------------------
|
277
|
+
* Bootstrap (v5.0.0): util/backdrop.js
|
278
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
279
|
+
* --------------------------------------------------------------------------
|
280
|
+
*/
|
281
|
+
const Default$1 = {
|
282
|
+
isVisible: true,
|
283
|
+
// if false, we use the backdrop helper without adding any element to the dom
|
284
|
+
isAnimated: false,
|
285
|
+
rootElement: document.body,
|
286
|
+
// give the choice to place backdrop under different elements
|
287
|
+
clickCallback: null
|
288
|
+
};
|
289
|
+
const DefaultType$1 = {
|
290
|
+
isVisible: 'boolean',
|
291
|
+
isAnimated: 'boolean',
|
292
|
+
rootElement: 'element',
|
293
|
+
clickCallback: '(function|null)'
|
294
|
+
};
|
295
|
+
const NAME$1 = 'backdrop';
|
296
|
+
const CLASS_NAME_BACKDROP = 'modal-backdrop';
|
297
|
+
const CLASS_NAME_FADE = 'fade';
|
298
|
+
const CLASS_NAME_SHOW$1 = 'show';
|
299
|
+
const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$1}`;
|
300
|
+
|
301
|
+
class Backdrop {
|
302
|
+
constructor(config) {
|
303
|
+
this._config = this._getConfig(config);
|
304
|
+
this._isAppended = false;
|
305
|
+
this._element = null;
|
306
|
+
}
|
307
|
+
|
308
|
+
show(callback) {
|
309
|
+
if (!this._config.isVisible) {
|
310
|
+
execute(callback);
|
311
|
+
return;
|
312
|
+
}
|
313
|
+
|
314
|
+
this._append();
|
315
|
+
|
316
|
+
if (this._config.isAnimated) {
|
317
|
+
reflow(this._getElement());
|
318
|
+
}
|
319
|
+
|
320
|
+
this._getElement().classList.add(CLASS_NAME_SHOW$1);
|
321
|
+
|
322
|
+
this._emulateAnimation(() => {
|
323
|
+
execute(callback);
|
324
|
+
});
|
325
|
+
}
|
326
|
+
|
327
|
+
hide(callback) {
|
328
|
+
if (!this._config.isVisible) {
|
329
|
+
execute(callback);
|
330
|
+
return;
|
331
|
+
}
|
332
|
+
|
333
|
+
this._getElement().classList.remove(CLASS_NAME_SHOW$1);
|
334
|
+
|
335
|
+
this._emulateAnimation(() => {
|
336
|
+
this.dispose();
|
337
|
+
execute(callback);
|
338
|
+
});
|
339
|
+
} // Private
|
340
|
+
|
341
|
+
|
342
|
+
_getElement() {
|
343
|
+
if (!this._element) {
|
344
|
+
const backdrop = document.createElement('div');
|
345
|
+
backdrop.className = CLASS_NAME_BACKDROP;
|
346
|
+
|
347
|
+
if (this._config.isAnimated) {
|
348
|
+
backdrop.classList.add(CLASS_NAME_FADE);
|
349
|
+
}
|
350
|
+
|
351
|
+
this._element = backdrop;
|
352
|
+
}
|
353
|
+
|
354
|
+
return this._element;
|
355
|
+
}
|
356
|
+
|
357
|
+
_getConfig(config) {
|
358
|
+
config = { ...Default$1,
|
359
|
+
...(typeof config === 'object' ? config : {})
|
360
|
+
};
|
361
|
+
typeCheckConfig(NAME$1, config, DefaultType$1);
|
362
|
+
return config;
|
363
|
+
}
|
364
|
+
|
365
|
+
_append() {
|
366
|
+
if (this._isAppended) {
|
367
|
+
return;
|
368
|
+
}
|
369
|
+
|
370
|
+
this._config.rootElement.appendChild(this._getElement());
|
371
|
+
|
372
|
+
EventHandler__default['default'].on(this._getElement(), EVENT_MOUSEDOWN, () => {
|
373
|
+
execute(this._config.clickCallback);
|
374
|
+
});
|
375
|
+
this._isAppended = true;
|
376
|
+
}
|
377
|
+
|
378
|
+
dispose() {
|
379
|
+
if (!this._isAppended) {
|
380
|
+
return;
|
381
|
+
}
|
382
|
+
|
383
|
+
EventHandler__default['default'].off(this._element, EVENT_MOUSEDOWN);
|
384
|
+
|
385
|
+
this._getElement().parentNode.removeChild(this._element);
|
386
|
+
|
387
|
+
this._isAppended = false;
|
388
|
+
}
|
389
|
+
|
390
|
+
_emulateAnimation(callback) {
|
391
|
+
if (!this._config.isAnimated) {
|
392
|
+
execute(callback);
|
393
|
+
return;
|
394
|
+
}
|
395
|
+
|
396
|
+
const backdropTransitionDuration = getTransitionDurationFromElement(this._getElement());
|
397
|
+
EventHandler__default['default'].one(this._getElement(), 'transitionend', () => execute(callback));
|
398
|
+
emulateTransitionEnd(this._getElement(), backdropTransitionDuration);
|
399
|
+
}
|
400
|
+
|
401
|
+
}
|
402
|
+
|
403
|
+
/**
|
404
|
+
* --------------------------------------------------------------------------
|
405
|
+
* Bootstrap (v5.0.0): offcanvas.js
|
406
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
407
|
+
* --------------------------------------------------------------------------
|
408
|
+
*/
|
409
|
+
/**
|
410
|
+
* ------------------------------------------------------------------------
|
411
|
+
* Constants
|
412
|
+
* ------------------------------------------------------------------------
|
413
|
+
*/
|
414
|
+
|
415
|
+
const NAME = 'offcanvas';
|
416
|
+
const DATA_KEY = 'bs.offcanvas';
|
417
|
+
const EVENT_KEY = `.${DATA_KEY}`;
|
418
|
+
const DATA_API_KEY = '.data-api';
|
419
|
+
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
|
420
|
+
const ESCAPE_KEY = 'Escape';
|
421
|
+
const Default = {
|
422
|
+
backdrop: true,
|
423
|
+
keyboard: true,
|
424
|
+
scroll: false
|
425
|
+
};
|
426
|
+
const DefaultType = {
|
427
|
+
backdrop: 'boolean',
|
428
|
+
keyboard: 'boolean',
|
429
|
+
scroll: 'boolean'
|
430
|
+
};
|
431
|
+
const CLASS_NAME_SHOW = 'show';
|
432
|
+
const OPEN_SELECTOR = '.offcanvas.show';
|
433
|
+
const EVENT_SHOW = `show${EVENT_KEY}`;
|
434
|
+
const EVENT_SHOWN = `shown${EVENT_KEY}`;
|
435
|
+
const EVENT_HIDE = `hide${EVENT_KEY}`;
|
436
|
+
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
|
437
|
+
const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
|
438
|
+
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
|
439
|
+
const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`;
|
440
|
+
const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`;
|
441
|
+
const SELECTOR_DATA_DISMISS = '[data-bs-dismiss="offcanvas"]';
|
442
|
+
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="offcanvas"]';
|
443
|
+
/**
|
444
|
+
* ------------------------------------------------------------------------
|
445
|
+
* Class Definition
|
446
|
+
* ------------------------------------------------------------------------
|
447
|
+
*/
|
448
|
+
|
449
|
+
class Offcanvas extends BaseComponent__default['default'] {
|
450
|
+
constructor(element, config) {
|
451
|
+
super(element);
|
452
|
+
this._config = this._getConfig(config);
|
453
|
+
this._isShown = false;
|
454
|
+
this._backdrop = this._initializeBackDrop();
|
455
|
+
|
456
|
+
this._addEventListeners();
|
457
|
+
} // Getters
|
458
|
+
|
459
|
+
|
460
|
+
static get Default() {
|
461
|
+
return Default;
|
462
|
+
}
|
463
|
+
|
464
|
+
static get DATA_KEY() {
|
465
|
+
return DATA_KEY;
|
466
|
+
} // Public
|
467
|
+
|
468
|
+
|
469
|
+
toggle(relatedTarget) {
|
470
|
+
return this._isShown ? this.hide() : this.show(relatedTarget);
|
471
|
+
}
|
472
|
+
|
473
|
+
show(relatedTarget) {
|
474
|
+
if (this._isShown) {
|
475
|
+
return;
|
476
|
+
}
|
477
|
+
|
478
|
+
const showEvent = EventHandler__default['default'].trigger(this._element, EVENT_SHOW, {
|
479
|
+
relatedTarget
|
480
|
+
});
|
481
|
+
|
482
|
+
if (showEvent.defaultPrevented) {
|
483
|
+
return;
|
484
|
+
}
|
485
|
+
|
486
|
+
this._isShown = true;
|
487
|
+
this._element.style.visibility = 'visible';
|
488
|
+
|
489
|
+
this._backdrop.show();
|
490
|
+
|
491
|
+
if (!this._config.scroll) {
|
492
|
+
hide();
|
493
|
+
|
494
|
+
this._enforceFocusOnElement(this._element);
|
495
|
+
}
|
496
|
+
|
497
|
+
this._element.removeAttribute('aria-hidden');
|
498
|
+
|
499
|
+
this._element.setAttribute('aria-modal', true);
|
500
|
+
|
501
|
+
this._element.setAttribute('role', 'dialog');
|
502
|
+
|
503
|
+
this._element.classList.add(CLASS_NAME_SHOW);
|
504
|
+
|
505
|
+
const completeCallBack = () => {
|
506
|
+
EventHandler__default['default'].trigger(this._element, EVENT_SHOWN, {
|
507
|
+
relatedTarget
|
508
|
+
});
|
509
|
+
};
|
510
|
+
|
511
|
+
const transitionDuration = getTransitionDurationFromElement(this._element);
|
512
|
+
EventHandler__default['default'].one(this._element, 'transitionend', completeCallBack);
|
513
|
+
emulateTransitionEnd(this._element, transitionDuration);
|
514
|
+
}
|
515
|
+
|
516
|
+
hide() {
|
517
|
+
if (!this._isShown) {
|
518
|
+
return;
|
519
|
+
}
|
520
|
+
|
521
|
+
const hideEvent = EventHandler__default['default'].trigger(this._element, EVENT_HIDE);
|
522
|
+
|
523
|
+
if (hideEvent.defaultPrevented) {
|
524
|
+
return;
|
525
|
+
}
|
526
|
+
|
527
|
+
EventHandler__default['default'].off(document, EVENT_FOCUSIN);
|
528
|
+
|
529
|
+
this._element.blur();
|
530
|
+
|
531
|
+
this._isShown = false;
|
532
|
+
|
533
|
+
this._element.classList.remove(CLASS_NAME_SHOW);
|
534
|
+
|
535
|
+
this._backdrop.hide();
|
536
|
+
|
537
|
+
const completeCallback = () => {
|
538
|
+
this._element.setAttribute('aria-hidden', true);
|
539
|
+
|
540
|
+
this._element.removeAttribute('aria-modal');
|
541
|
+
|
542
|
+
this._element.removeAttribute('role');
|
543
|
+
|
544
|
+
this._element.style.visibility = 'hidden';
|
545
|
+
|
546
|
+
if (!this._config.scroll) {
|
547
|
+
reset();
|
548
|
+
}
|
549
|
+
|
550
|
+
EventHandler__default['default'].trigger(this._element, EVENT_HIDDEN);
|
551
|
+
};
|
552
|
+
|
553
|
+
const transitionDuration = getTransitionDurationFromElement(this._element);
|
554
|
+
EventHandler__default['default'].one(this._element, 'transitionend', completeCallback);
|
555
|
+
emulateTransitionEnd(this._element, transitionDuration);
|
556
|
+
}
|
557
|
+
|
558
|
+
dispose() {
|
559
|
+
this._backdrop.dispose();
|
560
|
+
|
561
|
+
super.dispose();
|
562
|
+
EventHandler__default['default'].off(document, EVENT_FOCUSIN);
|
563
|
+
this._config = null;
|
564
|
+
this._backdrop = null;
|
565
|
+
} // Private
|
566
|
+
|
567
|
+
|
568
|
+
_getConfig(config) {
|
569
|
+
config = { ...Default,
|
570
|
+
...Manipulator__default['default'].getDataAttributes(this._element),
|
571
|
+
...(typeof config === 'object' ? config : {})
|
572
|
+
};
|
573
|
+
typeCheckConfig(NAME, config, DefaultType);
|
574
|
+
return config;
|
575
|
+
}
|
576
|
+
|
577
|
+
_initializeBackDrop() {
|
578
|
+
return new Backdrop({
|
579
|
+
isVisible: this._config.backdrop,
|
580
|
+
isAnimated: true,
|
581
|
+
rootElement: this._element.parentNode,
|
582
|
+
clickCallback: () => this.hide()
|
583
|
+
});
|
584
|
+
}
|
585
|
+
|
586
|
+
_enforceFocusOnElement(element) {
|
587
|
+
EventHandler__default['default'].off(document, EVENT_FOCUSIN); // guard against infinite focus loop
|
588
|
+
|
589
|
+
EventHandler__default['default'].on(document, EVENT_FOCUSIN, event => {
|
590
|
+
if (document !== event.target && element !== event.target && !element.contains(event.target)) {
|
591
|
+
element.focus();
|
592
|
+
}
|
593
|
+
});
|
594
|
+
element.focus();
|
595
|
+
}
|
596
|
+
|
597
|
+
_addEventListeners() {
|
598
|
+
EventHandler__default['default'].on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, () => this.hide());
|
599
|
+
EventHandler__default['default'].on(this._element, EVENT_KEYDOWN_DISMISS, event => {
|
600
|
+
if (this._config.keyboard && event.key === ESCAPE_KEY) {
|
601
|
+
this.hide();
|
602
|
+
}
|
603
|
+
});
|
604
|
+
} // Static
|
605
|
+
|
606
|
+
|
607
|
+
static jQueryInterface(config) {
|
608
|
+
return this.each(function () {
|
609
|
+
const data = Data__default['default'].get(this, DATA_KEY) || new Offcanvas(this, typeof config === 'object' ? config : {});
|
610
|
+
|
611
|
+
if (typeof config !== 'string') {
|
612
|
+
return;
|
613
|
+
}
|
614
|
+
|
615
|
+
if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
|
616
|
+
throw new TypeError(`No method named "${config}"`);
|
617
|
+
}
|
618
|
+
|
619
|
+
data[config](this);
|
620
|
+
});
|
621
|
+
}
|
622
|
+
|
623
|
+
}
|
624
|
+
/**
|
625
|
+
* ------------------------------------------------------------------------
|
626
|
+
* Data Api implementation
|
627
|
+
* ------------------------------------------------------------------------
|
628
|
+
*/
|
629
|
+
|
630
|
+
|
631
|
+
EventHandler__default['default'].on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
632
|
+
const target = getElementFromSelector(this);
|
633
|
+
|
634
|
+
if (['A', 'AREA'].includes(this.tagName)) {
|
635
|
+
event.preventDefault();
|
636
|
+
}
|
637
|
+
|
638
|
+
if (isDisabled(this)) {
|
639
|
+
return;
|
640
|
+
}
|
641
|
+
|
642
|
+
EventHandler__default['default'].one(target, EVENT_HIDDEN, () => {
|
643
|
+
// focus on trigger when it is closed
|
644
|
+
if (isVisible(this)) {
|
645
|
+
this.focus();
|
646
|
+
}
|
647
|
+
}); // avoid conflict when clicking a toggler of an offcanvas, while another is open
|
648
|
+
|
649
|
+
const allReadyOpen = SelectorEngine__default['default'].findOne(OPEN_SELECTOR);
|
650
|
+
|
651
|
+
if (allReadyOpen && allReadyOpen !== target) {
|
652
|
+
Offcanvas.getInstance(allReadyOpen).hide();
|
653
|
+
}
|
654
|
+
|
655
|
+
const data = Data__default['default'].get(target, DATA_KEY) || new Offcanvas(target);
|
656
|
+
data.toggle(this);
|
657
|
+
});
|
658
|
+
EventHandler__default['default'].on(window, EVENT_LOAD_DATA_API, () => {
|
659
|
+
SelectorEngine__default['default'].find(OPEN_SELECTOR).forEach(el => (Data__default['default'].get(el, DATA_KEY) || new Offcanvas(el)).show());
|
660
|
+
});
|
661
|
+
/**
|
662
|
+
* ------------------------------------------------------------------------
|
663
|
+
* jQuery
|
664
|
+
* ------------------------------------------------------------------------
|
665
|
+
*/
|
666
|
+
|
667
|
+
defineJQueryPlugin(NAME, Offcanvas);
|
668
|
+
|
669
|
+
return Offcanvas;
|
670
|
+
|
671
|
+
})));
|