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
@@ -1,106 +1,234 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap collapse.js
|
3
|
-
* Copyright 2011-
|
2
|
+
* Bootstrap collapse.js v5.0.0 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2021 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('
|
8
|
-
typeof define === 'function' && define.amd ? define(['
|
9
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Collapse = factory(global.
|
10
|
-
}
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./base-component.js')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['./dom/data', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Collapse = factory(global.Data, global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base));
|
10
|
+
}(this, (function (Data, EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict';
|
11
11
|
|
12
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
13
13
|
|
14
|
-
var
|
15
|
-
var
|
14
|
+
var Data__default = /*#__PURE__*/_interopDefaultLegacy(Data);
|
15
|
+
var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
|
16
|
+
var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
|
17
|
+
var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
|
18
|
+
var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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}`;
|
24
32
|
}
|
25
|
-
}
|
26
33
|
|
27
|
-
|
28
|
-
|
29
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
30
|
-
Object.defineProperty(Constructor, "prototype", {
|
31
|
-
writable: false
|
32
|
-
});
|
33
|
-
return Constructor;
|
34
|
-
}
|
34
|
+
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
|
35
|
+
};
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
for (var i = 1; i < arguments.length; i++) {
|
39
|
-
var source = arguments[i];
|
37
|
+
const getSelector = element => {
|
38
|
+
let selector = element.getAttribute('data-bs-target');
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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]}`;
|
46
53
|
}
|
47
54
|
|
48
|
-
|
49
|
-
}
|
50
|
-
|
51
|
-
|
55
|
+
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
|
56
|
+
}
|
57
|
+
|
58
|
+
return selector;
|
59
|
+
};
|
52
60
|
|
61
|
+
const getSelectorFromElement = element => {
|
62
|
+
const selector = getSelector(element);
|
63
|
+
|
64
|
+
if (selector) {
|
65
|
+
return document.querySelector(selector) ? selector : null;
|
66
|
+
}
|
67
|
+
|
68
|
+
return null;
|
69
|
+
};
|
70
|
+
|
71
|
+
const getElementFromSelector = element => {
|
72
|
+
const selector = getSelector(element);
|
73
|
+
return selector ? document.querySelector(selector) : null;
|
74
|
+
};
|
75
|
+
|
76
|
+
const getTransitionDurationFromElement = element => {
|
77
|
+
if (!element) {
|
78
|
+
return 0;
|
79
|
+
} // Get transition-duration of the element
|
80
|
+
|
81
|
+
|
82
|
+
let {
|
83
|
+
transitionDuration,
|
84
|
+
transitionDelay
|
85
|
+
} = window.getComputedStyle(element);
|
86
|
+
const floatTransitionDuration = Number.parseFloat(transitionDuration);
|
87
|
+
const floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
|
88
|
+
|
89
|
+
if (!floatTransitionDuration && !floatTransitionDelay) {
|
90
|
+
return 0;
|
91
|
+
} // If multiple durations are defined, take the first
|
92
|
+
|
93
|
+
|
94
|
+
transitionDuration = transitionDuration.split(',')[0];
|
95
|
+
transitionDelay = transitionDelay.split(',')[0];
|
96
|
+
return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
|
97
|
+
};
|
98
|
+
|
99
|
+
const triggerTransitionEnd = element => {
|
100
|
+
element.dispatchEvent(new Event(TRANSITION_END));
|
101
|
+
};
|
102
|
+
|
103
|
+
const isElement = obj => (obj[0] || obj).nodeType;
|
104
|
+
|
105
|
+
const emulateTransitionEnd = (element, duration) => {
|
106
|
+
let called = false;
|
107
|
+
const durationPadding = 5;
|
108
|
+
const emulatedDuration = duration + durationPadding;
|
109
|
+
|
110
|
+
function listener() {
|
111
|
+
called = true;
|
112
|
+
element.removeEventListener(TRANSITION_END, listener);
|
113
|
+
}
|
114
|
+
|
115
|
+
element.addEventListener(TRANSITION_END, listener);
|
116
|
+
setTimeout(() => {
|
117
|
+
if (!called) {
|
118
|
+
triggerTransitionEnd(element);
|
119
|
+
}
|
120
|
+
}, emulatedDuration);
|
121
|
+
};
|
122
|
+
|
123
|
+
const typeCheckConfig = (componentName, config, configTypes) => {
|
124
|
+
Object.keys(configTypes).forEach(property => {
|
125
|
+
const expectedTypes = configTypes[property];
|
126
|
+
const value = config[property];
|
127
|
+
const valueType = value && isElement(value) ? 'element' : toType(value);
|
128
|
+
|
129
|
+
if (!new RegExp(expectedTypes).test(valueType)) {
|
130
|
+
throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
|
131
|
+
}
|
132
|
+
});
|
133
|
+
};
|
134
|
+
|
135
|
+
const reflow = element => element.offsetHeight;
|
136
|
+
|
137
|
+
const getjQuery = () => {
|
138
|
+
const {
|
139
|
+
jQuery
|
140
|
+
} = window;
|
141
|
+
|
142
|
+
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
|
143
|
+
return jQuery;
|
144
|
+
}
|
145
|
+
|
146
|
+
return null;
|
147
|
+
};
|
148
|
+
|
149
|
+
const onDOMContentLoaded = callback => {
|
150
|
+
if (document.readyState === 'loading') {
|
151
|
+
document.addEventListener('DOMContentLoaded', callback);
|
152
|
+
} else {
|
153
|
+
callback();
|
154
|
+
}
|
155
|
+
};
|
156
|
+
|
157
|
+
const defineJQueryPlugin = (name, plugin) => {
|
158
|
+
onDOMContentLoaded(() => {
|
159
|
+
const $ = getjQuery();
|
160
|
+
/* istanbul ignore if */
|
161
|
+
|
162
|
+
if ($) {
|
163
|
+
const JQUERY_NO_CONFLICT = $.fn[name];
|
164
|
+
$.fn[name] = plugin.jQueryInterface;
|
165
|
+
$.fn[name].Constructor = plugin;
|
166
|
+
|
167
|
+
$.fn[name].noConflict = () => {
|
168
|
+
$.fn[name] = JQUERY_NO_CONFLICT;
|
169
|
+
return plugin.jQueryInterface;
|
170
|
+
};
|
171
|
+
}
|
172
|
+
});
|
173
|
+
};
|
174
|
+
|
175
|
+
/**
|
176
|
+
* --------------------------------------------------------------------------
|
177
|
+
* Bootstrap (v5.0.0): collapse.js
|
178
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
179
|
+
* --------------------------------------------------------------------------
|
180
|
+
*/
|
53
181
|
/**
|
182
|
+
* ------------------------------------------------------------------------
|
54
183
|
* Constants
|
184
|
+
* ------------------------------------------------------------------------
|
55
185
|
*/
|
56
186
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
var JQUERY_NO_CONFLICT = $__default["default"].fn[NAME];
|
63
|
-
var CLASS_NAME_SHOW = 'show';
|
64
|
-
var CLASS_NAME_COLLAPSE = 'collapse';
|
65
|
-
var CLASS_NAME_COLLAPSING = 'collapsing';
|
66
|
-
var CLASS_NAME_COLLAPSED = 'collapsed';
|
67
|
-
var DIMENSION_WIDTH = 'width';
|
68
|
-
var DIMENSION_HEIGHT = 'height';
|
69
|
-
var EVENT_SHOW = "show" + EVENT_KEY;
|
70
|
-
var EVENT_SHOWN = "shown" + EVENT_KEY;
|
71
|
-
var EVENT_HIDE = "hide" + EVENT_KEY;
|
72
|
-
var EVENT_HIDDEN = "hidden" + EVENT_KEY;
|
73
|
-
var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
|
74
|
-
var SELECTOR_ACTIVES = '.show, .collapsing';
|
75
|
-
var SELECTOR_DATA_TOGGLE = '[data-toggle="collapse"]';
|
76
|
-
var Default = {
|
187
|
+
const NAME = 'collapse';
|
188
|
+
const DATA_KEY = 'bs.collapse';
|
189
|
+
const EVENT_KEY = `.${DATA_KEY}`;
|
190
|
+
const DATA_API_KEY = '.data-api';
|
191
|
+
const Default = {
|
77
192
|
toggle: true,
|
78
193
|
parent: ''
|
79
194
|
};
|
80
|
-
|
195
|
+
const DefaultType = {
|
81
196
|
toggle: 'boolean',
|
82
197
|
parent: '(string|element)'
|
83
198
|
};
|
199
|
+
const EVENT_SHOW = `show${EVENT_KEY}`;
|
200
|
+
const EVENT_SHOWN = `shown${EVENT_KEY}`;
|
201
|
+
const EVENT_HIDE = `hide${EVENT_KEY}`;
|
202
|
+
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
|
203
|
+
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
|
204
|
+
const CLASS_NAME_SHOW = 'show';
|
205
|
+
const CLASS_NAME_COLLAPSE = 'collapse';
|
206
|
+
const CLASS_NAME_COLLAPSING = 'collapsing';
|
207
|
+
const CLASS_NAME_COLLAPSED = 'collapsed';
|
208
|
+
const WIDTH = 'width';
|
209
|
+
const HEIGHT = 'height';
|
210
|
+
const SELECTOR_ACTIVES = '.show, .collapsing';
|
211
|
+
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="collapse"]';
|
84
212
|
/**
|
85
|
-
*
|
213
|
+
* ------------------------------------------------------------------------
|
214
|
+
* Class Definition
|
215
|
+
* ------------------------------------------------------------------------
|
86
216
|
*/
|
87
217
|
|
88
|
-
|
89
|
-
|
218
|
+
class Collapse extends BaseComponent__default['default'] {
|
219
|
+
constructor(element, config) {
|
220
|
+
super(element);
|
90
221
|
this._isTransitioning = false;
|
91
|
-
this._element = element;
|
92
222
|
this._config = this._getConfig(config);
|
93
|
-
this._triggerArray = [].
|
94
|
-
|
95
|
-
|
96
|
-
for (
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
return foundElem === element;
|
101
|
-
});
|
223
|
+
this._triggerArray = SelectorEngine__default['default'].find(`${SELECTOR_DATA_TOGGLE}[href="#${this._element.id}"],` + `${SELECTOR_DATA_TOGGLE}[data-bs-target="#${this._element.id}"]`);
|
224
|
+
const toggleList = SelectorEngine__default['default'].find(SELECTOR_DATA_TOGGLE);
|
225
|
+
|
226
|
+
for (let i = 0, len = toggleList.length; i < len; i++) {
|
227
|
+
const elem = toggleList[i];
|
228
|
+
const selector = getSelectorFromElement(elem);
|
229
|
+
const filterElement = SelectorEngine__default['default'].find(selector).filter(foundElem => foundElem === this._element);
|
102
230
|
|
103
|
-
if (selector !== null && filterElement.length
|
231
|
+
if (selector !== null && filterElement.length) {
|
104
232
|
this._selector = selector;
|
105
233
|
|
106
234
|
this._triggerArray.push(elem);
|
@@ -119,31 +247,35 @@
|
|
119
247
|
} // Getters
|
120
248
|
|
121
249
|
|
122
|
-
|
250
|
+
static get Default() {
|
251
|
+
return Default;
|
252
|
+
}
|
253
|
+
|
254
|
+
static get DATA_KEY() {
|
255
|
+
return DATA_KEY;
|
256
|
+
} // Public
|
257
|
+
|
123
258
|
|
124
|
-
|
125
|
-
|
126
|
-
if ($__default["default"](this._element).hasClass(CLASS_NAME_SHOW)) {
|
259
|
+
toggle() {
|
260
|
+
if (this._element.classList.contains(CLASS_NAME_SHOW)) {
|
127
261
|
this.hide();
|
128
262
|
} else {
|
129
263
|
this.show();
|
130
264
|
}
|
131
|
-
}
|
132
|
-
|
133
|
-
_proto.show = function show() {
|
134
|
-
var _this = this;
|
265
|
+
}
|
135
266
|
|
136
|
-
|
267
|
+
show() {
|
268
|
+
if (this._isTransitioning || this._element.classList.contains(CLASS_NAME_SHOW)) {
|
137
269
|
return;
|
138
270
|
}
|
139
271
|
|
140
|
-
|
141
|
-
|
272
|
+
let actives;
|
273
|
+
let activesData;
|
142
274
|
|
143
275
|
if (this._parent) {
|
144
|
-
actives = [].
|
145
|
-
if (typeof
|
146
|
-
return elem.getAttribute('data-parent') ===
|
276
|
+
actives = SelectorEngine__default['default'].find(SELECTOR_ACTIVES, this._parent).filter(elem => {
|
277
|
+
if (typeof this._config.parent === 'string') {
|
278
|
+
return elem.getAttribute('data-bs-parent') === this._config.parent;
|
147
279
|
}
|
148
280
|
|
149
281
|
return elem.classList.contains(CLASS_NAME_COLLAPSE);
|
@@ -154,243 +286,265 @@
|
|
154
286
|
}
|
155
287
|
}
|
156
288
|
|
289
|
+
const container = SelectorEngine__default['default'].findOne(this._selector);
|
290
|
+
|
157
291
|
if (actives) {
|
158
|
-
|
292
|
+
const tempActiveData = actives.find(elem => container !== elem);
|
293
|
+
activesData = tempActiveData ? Data__default['default'].get(tempActiveData, DATA_KEY) : null;
|
159
294
|
|
160
295
|
if (activesData && activesData._isTransitioning) {
|
161
296
|
return;
|
162
297
|
}
|
163
298
|
}
|
164
299
|
|
165
|
-
|
166
|
-
$__default["default"](this._element).trigger(startEvent);
|
300
|
+
const startEvent = EventHandler__default['default'].trigger(this._element, EVENT_SHOW);
|
167
301
|
|
168
|
-
if (startEvent.
|
302
|
+
if (startEvent.defaultPrevented) {
|
169
303
|
return;
|
170
304
|
}
|
171
305
|
|
172
306
|
if (actives) {
|
173
|
-
|
307
|
+
actives.forEach(elemActive => {
|
308
|
+
if (container !== elemActive) {
|
309
|
+
Collapse.collapseInterface(elemActive, 'hide');
|
310
|
+
}
|
174
311
|
|
175
|
-
|
176
|
-
|
177
|
-
|
312
|
+
if (!activesData) {
|
313
|
+
Data__default['default'].set(elemActive, DATA_KEY, null);
|
314
|
+
}
|
315
|
+
});
|
178
316
|
}
|
179
317
|
|
180
|
-
|
318
|
+
const dimension = this._getDimension();
|
319
|
+
|
320
|
+
this._element.classList.remove(CLASS_NAME_COLLAPSE);
|
321
|
+
|
322
|
+
this._element.classList.add(CLASS_NAME_COLLAPSING);
|
181
323
|
|
182
|
-
$__default["default"](this._element).removeClass(CLASS_NAME_COLLAPSE).addClass(CLASS_NAME_COLLAPSING);
|
183
324
|
this._element.style[dimension] = 0;
|
184
325
|
|
185
326
|
if (this._triggerArray.length) {
|
186
|
-
|
327
|
+
this._triggerArray.forEach(element => {
|
328
|
+
element.classList.remove(CLASS_NAME_COLLAPSED);
|
329
|
+
element.setAttribute('aria-expanded', true);
|
330
|
+
});
|
187
331
|
}
|
188
332
|
|
189
333
|
this.setTransitioning(true);
|
190
334
|
|
191
|
-
|
192
|
-
|
193
|
-
_this._element.style[dimension] = '';
|
335
|
+
const complete = () => {
|
336
|
+
this._element.classList.remove(CLASS_NAME_COLLAPSING);
|
194
337
|
|
195
|
-
|
338
|
+
this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW);
|
196
339
|
|
197
|
-
|
340
|
+
this._element.style[dimension] = '';
|
341
|
+
this.setTransitioning(false);
|
342
|
+
EventHandler__default['default'].trigger(this._element, EVENT_SHOWN);
|
198
343
|
};
|
199
344
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
this._element
|
205
|
-
|
206
|
-
|
207
|
-
_proto.hide = function hide() {
|
208
|
-
var _this2 = this;
|
345
|
+
const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
|
346
|
+
const scrollSize = `scroll${capitalizedDimension}`;
|
347
|
+
const transitionDuration = getTransitionDurationFromElement(this._element);
|
348
|
+
EventHandler__default['default'].one(this._element, 'transitionend', complete);
|
349
|
+
emulateTransitionEnd(this._element, transitionDuration);
|
350
|
+
this._element.style[dimension] = `${this._element[scrollSize]}px`;
|
351
|
+
}
|
209
352
|
|
210
|
-
|
353
|
+
hide() {
|
354
|
+
if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW)) {
|
211
355
|
return;
|
212
356
|
}
|
213
357
|
|
214
|
-
|
215
|
-
$__default["default"](this._element).trigger(startEvent);
|
358
|
+
const startEvent = EventHandler__default['default'].trigger(this._element, EVENT_HIDE);
|
216
359
|
|
217
|
-
if (startEvent.
|
360
|
+
if (startEvent.defaultPrevented) {
|
218
361
|
return;
|
219
362
|
}
|
220
363
|
|
221
|
-
|
364
|
+
const dimension = this._getDimension();
|
222
365
|
|
223
|
-
this._element.style[dimension] = this._element.getBoundingClientRect()[dimension]
|
224
|
-
|
225
|
-
$__default["default"](this._element).addClass(CLASS_NAME_COLLAPSING).removeClass(CLASS_NAME_COLLAPSE + " " + CLASS_NAME_SHOW);
|
226
|
-
var triggerArrayLength = this._triggerArray.length;
|
366
|
+
this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`;
|
367
|
+
reflow(this._element);
|
227
368
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
var selector = Util__default["default"].getSelectorFromElement(trigger);
|
369
|
+
this._element.classList.add(CLASS_NAME_COLLAPSING);
|
370
|
+
|
371
|
+
this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW);
|
232
372
|
|
233
|
-
|
234
|
-
var $elem = $__default["default"]([].slice.call(document.querySelectorAll(selector)));
|
373
|
+
const triggerArrayLength = this._triggerArray.length;
|
235
374
|
|
236
|
-
|
237
|
-
|
238
|
-
|
375
|
+
if (triggerArrayLength > 0) {
|
376
|
+
for (let i = 0; i < triggerArrayLength; i++) {
|
377
|
+
const trigger = this._triggerArray[i];
|
378
|
+
const elem = getElementFromSelector(trigger);
|
379
|
+
|
380
|
+
if (elem && !elem.classList.contains(CLASS_NAME_SHOW)) {
|
381
|
+
trigger.classList.add(CLASS_NAME_COLLAPSED);
|
382
|
+
trigger.setAttribute('aria-expanded', false);
|
239
383
|
}
|
240
384
|
}
|
241
385
|
}
|
242
386
|
|
243
387
|
this.setTransitioning(true);
|
244
388
|
|
245
|
-
|
246
|
-
|
389
|
+
const complete = () => {
|
390
|
+
this.setTransitioning(false);
|
391
|
+
|
392
|
+
this._element.classList.remove(CLASS_NAME_COLLAPSING);
|
393
|
+
|
394
|
+
this._element.classList.add(CLASS_NAME_COLLAPSE);
|
247
395
|
|
248
|
-
|
396
|
+
EventHandler__default['default'].trigger(this._element, EVENT_HIDDEN);
|
249
397
|
};
|
250
398
|
|
251
399
|
this._element.style[dimension] = '';
|
252
|
-
|
253
|
-
|
254
|
-
|
400
|
+
const transitionDuration = getTransitionDurationFromElement(this._element);
|
401
|
+
EventHandler__default['default'].one(this._element, 'transitionend', complete);
|
402
|
+
emulateTransitionEnd(this._element, transitionDuration);
|
403
|
+
}
|
255
404
|
|
256
|
-
|
405
|
+
setTransitioning(isTransitioning) {
|
257
406
|
this._isTransitioning = isTransitioning;
|
258
|
-
}
|
407
|
+
}
|
259
408
|
|
260
|
-
|
261
|
-
|
409
|
+
dispose() {
|
410
|
+
super.dispose();
|
262
411
|
this._config = null;
|
263
412
|
this._parent = null;
|
264
|
-
this._element = null;
|
265
413
|
this._triggerArray = null;
|
266
414
|
this._isTransitioning = null;
|
267
415
|
} // Private
|
268
|
-
;
|
269
416
|
|
270
|
-
|
271
|
-
|
417
|
+
|
418
|
+
_getConfig(config) {
|
419
|
+
config = { ...Default,
|
420
|
+
...config
|
421
|
+
};
|
272
422
|
config.toggle = Boolean(config.toggle); // Coerce string values
|
273
423
|
|
274
|
-
|
424
|
+
typeCheckConfig(NAME, config, DefaultType);
|
275
425
|
return config;
|
276
|
-
}
|
277
|
-
|
278
|
-
_proto._getDimension = function _getDimension() {
|
279
|
-
var hasWidth = $__default["default"](this._element).hasClass(DIMENSION_WIDTH);
|
280
|
-
return hasWidth ? DIMENSION_WIDTH : DIMENSION_HEIGHT;
|
281
|
-
};
|
282
|
-
|
283
|
-
_proto._getParent = function _getParent() {
|
284
|
-
var _this3 = this;
|
426
|
+
}
|
285
427
|
|
286
|
-
|
428
|
+
_getDimension() {
|
429
|
+
return this._element.classList.contains(WIDTH) ? WIDTH : HEIGHT;
|
430
|
+
}
|
287
431
|
|
288
|
-
|
289
|
-
|
432
|
+
_getParent() {
|
433
|
+
let {
|
434
|
+
parent
|
435
|
+
} = this._config;
|
290
436
|
|
291
|
-
|
292
|
-
|
437
|
+
if (isElement(parent)) {
|
438
|
+
// it's a jQuery object
|
439
|
+
if (typeof parent.jquery !== 'undefined' || typeof parent[0] !== 'undefined') {
|
440
|
+
parent = parent[0];
|
293
441
|
}
|
294
442
|
} else {
|
295
|
-
parent =
|
443
|
+
parent = SelectorEngine__default['default'].findOne(parent);
|
296
444
|
}
|
297
445
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
446
|
+
const selector = `${SELECTOR_DATA_TOGGLE}[data-bs-parent="${parent}"]`;
|
447
|
+
SelectorEngine__default['default'].find(selector, parent).forEach(element => {
|
448
|
+
const selected = getElementFromSelector(element);
|
449
|
+
|
450
|
+
this._addAriaAndCollapsedClass(selected, [element]);
|
302
451
|
});
|
303
452
|
return parent;
|
304
|
-
}
|
305
|
-
|
306
|
-
_proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
|
307
|
-
var isOpen = $__default["default"](element).hasClass(CLASS_NAME_SHOW);
|
453
|
+
}
|
308
454
|
|
309
|
-
|
310
|
-
|
455
|
+
_addAriaAndCollapsedClass(element, triggerArray) {
|
456
|
+
if (!element || !triggerArray.length) {
|
457
|
+
return;
|
311
458
|
}
|
312
|
-
} // Static
|
313
|
-
;
|
314
459
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
460
|
+
const isOpen = element.classList.contains(CLASS_NAME_SHOW);
|
461
|
+
triggerArray.forEach(elem => {
|
462
|
+
if (isOpen) {
|
463
|
+
elem.classList.remove(CLASS_NAME_COLLAPSED);
|
464
|
+
} else {
|
465
|
+
elem.classList.add(CLASS_NAME_COLLAPSED);
|
466
|
+
}
|
319
467
|
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
var data = $element.data(DATA_KEY);
|
468
|
+
elem.setAttribute('aria-expanded', isOpen);
|
469
|
+
});
|
470
|
+
} // Static
|
324
471
|
|
325
|
-
var _config = _extends({}, Default, $element.data(), typeof config === 'object' && config ? config : {});
|
326
472
|
|
327
|
-
|
328
|
-
|
329
|
-
|
473
|
+
static collapseInterface(element, config) {
|
474
|
+
let data = Data__default['default'].get(element, DATA_KEY);
|
475
|
+
const _config = { ...Default,
|
476
|
+
...Manipulator__default['default'].getDataAttributes(element),
|
477
|
+
...(typeof config === 'object' && config ? config : {})
|
478
|
+
};
|
330
479
|
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
}
|
480
|
+
if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) {
|
481
|
+
_config.toggle = false;
|
482
|
+
}
|
335
483
|
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
}
|
484
|
+
if (!data) {
|
485
|
+
data = new Collapse(element, _config);
|
486
|
+
}
|
340
487
|
|
341
|
-
|
488
|
+
if (typeof config === 'string') {
|
489
|
+
if (typeof data[config] === 'undefined') {
|
490
|
+
throw new TypeError(`No method named "${config}"`);
|
342
491
|
}
|
343
|
-
});
|
344
|
-
};
|
345
492
|
|
346
|
-
|
347
|
-
key: "VERSION",
|
348
|
-
get: function get() {
|
349
|
-
return VERSION;
|
493
|
+
data[config]();
|
350
494
|
}
|
351
|
-
}
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
495
|
+
}
|
496
|
+
|
497
|
+
static jQueryInterface(config) {
|
498
|
+
return this.each(function () {
|
499
|
+
Collapse.collapseInterface(this, config);
|
500
|
+
});
|
501
|
+
}
|
357
502
|
|
358
|
-
|
359
|
-
}();
|
503
|
+
}
|
360
504
|
/**
|
361
|
-
*
|
505
|
+
* ------------------------------------------------------------------------
|
506
|
+
* Data Api implementation
|
507
|
+
* ------------------------------------------------------------------------
|
362
508
|
*/
|
363
509
|
|
364
510
|
|
365
|
-
|
511
|
+
EventHandler__default['default'].on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
366
512
|
// preventDefault only for <a> elements (which change the URL) not inside the collapsible element
|
367
|
-
if (event.
|
513
|
+
if (event.target.tagName === 'A' || event.delegateTarget && event.delegateTarget.tagName === 'A') {
|
368
514
|
event.preventDefault();
|
369
515
|
}
|
370
516
|
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
517
|
+
const triggerData = Manipulator__default['default'].getDataAttributes(this);
|
518
|
+
const selector = getSelectorFromElement(this);
|
519
|
+
const selectorElements = SelectorEngine__default['default'].find(selector);
|
520
|
+
selectorElements.forEach(element => {
|
521
|
+
const data = Data__default['default'].get(element, DATA_KEY);
|
522
|
+
let config;
|
523
|
+
|
524
|
+
if (data) {
|
525
|
+
// update parent attribute
|
526
|
+
if (data._parent === null && typeof triggerData.parent === 'string') {
|
527
|
+
data._config.parent = triggerData.parent;
|
528
|
+
data._parent = data._getParent();
|
529
|
+
}
|
378
530
|
|
379
|
-
|
531
|
+
config = 'toggle';
|
532
|
+
} else {
|
533
|
+
config = triggerData;
|
534
|
+
}
|
535
|
+
|
536
|
+
Collapse.collapseInterface(element, config);
|
380
537
|
});
|
381
538
|
});
|
382
539
|
/**
|
540
|
+
* ------------------------------------------------------------------------
|
383
541
|
* jQuery
|
542
|
+
* ------------------------------------------------------------------------
|
543
|
+
* add .Collapse to jQuery only if jQuery is present
|
384
544
|
*/
|
385
545
|
|
386
|
-
|
387
|
-
$__default["default"].fn[NAME].Constructor = Collapse;
|
388
|
-
|
389
|
-
$__default["default"].fn[NAME].noConflict = function () {
|
390
|
-
$__default["default"].fn[NAME] = JQUERY_NO_CONFLICT;
|
391
|
-
return Collapse._jQueryInterface;
|
392
|
-
};
|
546
|
+
defineJQueryPlugin(NAME, Collapse);
|
393
547
|
|
394
548
|
return Collapse;
|
395
549
|
|
396
|
-
}));
|
550
|
+
})));
|