bootstrap 4.1.3 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +17 -2
  3. data/CHANGELOG.md +2 -14
  4. data/README.md +7 -4
  5. data/Rakefile +2 -2
  6. data/assets/javascripts/bootstrap/alert.js +226 -166
  7. data/assets/javascripts/bootstrap/base-component.js +63 -0
  8. data/assets/javascripts/bootstrap/button.js +119 -165
  9. data/assets/javascripts/bootstrap/carousel.js +634 -445
  10. data/assets/javascripts/bootstrap/collapse.js +447 -327
  11. data/assets/javascripts/bootstrap/dom/data.js +68 -0
  12. data/assets/javascripts/bootstrap/dom/event-handler.js +322 -0
  13. data/assets/javascripts/bootstrap/dom/manipulator.js +88 -0
  14. data/assets/javascripts/bootstrap/dom/selector-engine.js +85 -0
  15. data/assets/javascripts/bootstrap/dropdown.js +550 -425
  16. data/assets/javascripts/bootstrap/modal.js +695 -492
  17. data/assets/javascripts/bootstrap/offcanvas.js +671 -0
  18. data/assets/javascripts/bootstrap/popover.js +167 -217
  19. data/assets/javascripts/bootstrap/scrollspy.js +319 -302
  20. data/assets/javascripts/bootstrap/tab.js +303 -221
  21. data/assets/javascripts/bootstrap/toast.js +333 -0
  22. data/assets/javascripts/bootstrap/tooltip.js +896 -577
  23. data/assets/javascripts/bootstrap-global-this-define.js +6 -0
  24. data/assets/javascripts/bootstrap-global-this-undefine.js +2 -0
  25. data/assets/javascripts/bootstrap-sprockets.js +15 -7
  26. data/assets/javascripts/bootstrap.js +4262 -3163
  27. data/assets/javascripts/bootstrap.min.js +4 -4
  28. data/assets/stylesheets/_bootstrap-grid.scss +54 -21
  29. data/assets/stylesheets/_bootstrap-reboot.scss +7 -4
  30. data/assets/stylesheets/_bootstrap.scss +21 -11
  31. data/assets/stylesheets/bootstrap/_accordion.scss +118 -0
  32. data/assets/stylesheets/bootstrap/_alert.scss +15 -9
  33. data/assets/stylesheets/bootstrap/_badge.scss +3 -21
  34. data/assets/stylesheets/bootstrap/_breadcrumb.scss +5 -18
  35. data/assets/stylesheets/bootstrap/_button-group.scss +29 -62
  36. data/assets/stylesheets/bootstrap/_buttons.scss +33 -65
  37. data/assets/stylesheets/bootstrap/_card.scss +55 -141
  38. data/assets/stylesheets/bootstrap/_carousel.scss +94 -101
  39. data/assets/stylesheets/bootstrap/_close.scss +33 -28
  40. data/assets/stylesheets/bootstrap/_containers.scss +41 -0
  41. data/assets/stylesheets/bootstrap/_dropdown.scss +114 -40
  42. data/assets/stylesheets/bootstrap/_forms.scss +9 -333
  43. data/assets/stylesheets/bootstrap/_functions.scss +148 -29
  44. data/assets/stylesheets/bootstrap/_grid.scss +4 -34
  45. data/assets/stylesheets/bootstrap/_helpers.scss +7 -0
  46. data/assets/stylesheets/bootstrap/_images.scss +4 -4
  47. data/assets/stylesheets/bootstrap/_list-group.scss +86 -27
  48. data/assets/stylesheets/bootstrap/_mixins.scss +17 -16
  49. data/assets/stylesheets/bootstrap/_modal.scss +90 -42
  50. data/assets/stylesheets/bootstrap/_nav.scss +31 -10
  51. data/assets/stylesheets/bootstrap/_navbar.scss +68 -61
  52. data/assets/stylesheets/bootstrap/_offcanvas.scss +77 -0
  53. data/assets/stylesheets/bootstrap/_pagination.scss +13 -27
  54. data/assets/stylesheets/bootstrap/_popover.scss +63 -88
  55. data/assets/stylesheets/bootstrap/_progress.scss +20 -6
  56. data/assets/stylesheets/bootstrap/_reboot.scss +349 -211
  57. data/assets/stylesheets/bootstrap/_root.scss +5 -8
  58. data/assets/stylesheets/bootstrap/_spinners.scss +69 -0
  59. data/assets/stylesheets/bootstrap/_tables.scss +79 -116
  60. data/assets/stylesheets/bootstrap/_toasts.scss +51 -0
  61. data/assets/stylesheets/bootstrap/_tooltip.scss +18 -18
  62. data/assets/stylesheets/bootstrap/_transitions.scss +2 -3
  63. data/assets/stylesheets/bootstrap/_type.scss +42 -63
  64. data/assets/stylesheets/bootstrap/_utilities.scss +594 -15
  65. data/assets/stylesheets/bootstrap/_variables.scss +952 -440
  66. data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +18 -0
  67. data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +61 -0
  68. data/assets/stylesheets/bootstrap/forms/_form-check.scss +152 -0
  69. data/assets/stylesheets/bootstrap/forms/_form-control.scss +219 -0
  70. data/assets/stylesheets/bootstrap/forms/_form-range.scss +91 -0
  71. data/assets/stylesheets/bootstrap/forms/_form-select.scss +67 -0
  72. data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
  73. data/assets/stylesheets/bootstrap/forms/_input-group.scss +121 -0
  74. data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
  75. data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
  76. data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +12 -0
  77. data/assets/stylesheets/bootstrap/helpers/_position.scss +30 -0
  78. data/assets/stylesheets/bootstrap/helpers/_ratio.scss +26 -0
  79. data/assets/stylesheets/bootstrap/helpers/_stretched-link.scss +15 -0
  80. data/assets/stylesheets/bootstrap/helpers/_text-truncation.scss +7 -0
  81. data/assets/stylesheets/bootstrap/helpers/_visually-hidden.scss +8 -0
  82. data/assets/stylesheets/bootstrap/mixins/_alert.scss +3 -5
  83. data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +57 -14
  84. data/assets/stylesheets/bootstrap/mixins/_box-shadow.scss +14 -1
  85. data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +13 -9
  86. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +77 -53
  87. data/assets/stylesheets/bootstrap/mixins/_caret.scss +14 -16
  88. data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +2 -0
  89. data/assets/stylesheets/bootstrap/mixins/_color-scheme.scss +7 -0
  90. data/assets/stylesheets/bootstrap/mixins/_container.scss +9 -0
  91. data/assets/stylesheets/bootstrap/mixins/_deprecate.scss +10 -0
  92. data/assets/stylesheets/bootstrap/mixins/_forms.scss +87 -97
  93. data/assets/stylesheets/bootstrap/mixins/_gradients.scss +13 -11
  94. data/assets/stylesheets/bootstrap/mixins/_grid.scss +106 -33
  95. data/assets/stylesheets/bootstrap/mixins/_image.scss +0 -20
  96. data/assets/stylesheets/bootstrap/mixins/_list-group.scss +5 -2
  97. data/assets/stylesheets/bootstrap/mixins/_pagination.scss +18 -9
  98. data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +2 -2
  99. data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +21 -0
  100. data/assets/stylesheets/bootstrap/mixins/_transition.scss +19 -6
  101. data/assets/stylesheets/bootstrap/mixins/_utilities.scss +68 -0
  102. data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +29 -0
  103. data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
  104. data/assets/stylesheets/bootstrap/vendor/_rfs.scss +312 -0
  105. data/bootstrap.gemspec +7 -6
  106. data/lib/bootstrap/engine.rb +3 -0
  107. data/lib/bootstrap/version.rb +4 -2
  108. data/lib/bootstrap.rb +10 -7
  109. data/tasks/updater/js.rb +20 -5
  110. data/tasks/updater/network.rb +8 -2
  111. data/test/dummy_rails/app/assets/config/manifest.js +3 -0
  112. data/test/dummy_rails/app/assets/javascripts/application.js +4 -3
  113. data/test/dummy_rails/app/assets/stylesheets/.browserslistrc +1 -0
  114. data/test/dummy_rails/app/views/layouts/application.html.erb +3 -1
  115. data/test/dummy_rails/app/views/pages/root.html +89 -0
  116. data/test/dummy_rails/config/application.rb +0 -3
  117. data/test/gemfiles/rails_6_0.gemfile +7 -0
  118. data/test/gemfiles/rails_6_1.gemfile +7 -0
  119. data/test/support/dummy_rails_integration.rb +3 -1
  120. data/test/test_helper.rb +18 -13
  121. metadata +64 -79
  122. data/assets/javascripts/bootstrap/util.js +0 -143
  123. data/assets/stylesheets/bootstrap/_code.scss +0 -48
  124. data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -433
  125. data/assets/stylesheets/bootstrap/_input-group.scss +0 -173
  126. data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -16
  127. data/assets/stylesheets/bootstrap/_media.scss +0 -8
  128. data/assets/stylesheets/bootstrap/_print.scss +0 -141
  129. data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +0 -21
  130. data/assets/stylesheets/bootstrap/mixins/_badge.scss +0 -12
  131. data/assets/stylesheets/bootstrap/mixins/_float.scss +0 -11
  132. data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +0 -67
  133. data/assets/stylesheets/bootstrap/mixins/_hover.scss +0 -37
  134. data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -10
  135. data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +0 -33
  136. data/assets/stylesheets/bootstrap/mixins/_size.scss +0 -6
  137. data/assets/stylesheets/bootstrap/mixins/_table-row.scss +0 -30
  138. data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +0 -14
  139. data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +0 -13
  140. data/assets/stylesheets/bootstrap/mixins/_visibility.scss +0 -7
  141. data/assets/stylesheets/bootstrap/utilities/_align.scss +0 -8
  142. data/assets/stylesheets/bootstrap/utilities/_background.scss +0 -19
  143. data/assets/stylesheets/bootstrap/utilities/_borders.scss +0 -59
  144. data/assets/stylesheets/bootstrap/utilities/_display.scss +0 -38
  145. data/assets/stylesheets/bootstrap/utilities/_embed.scss +0 -52
  146. data/assets/stylesheets/bootstrap/utilities/_flex.scss +0 -51
  147. data/assets/stylesheets/bootstrap/utilities/_float.scss +0 -9
  148. data/assets/stylesheets/bootstrap/utilities/_position.scss +0 -37
  149. data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +0 -11
  150. data/assets/stylesheets/bootstrap/utilities/_shadows.scss +0 -6
  151. data/assets/stylesheets/bootstrap/utilities/_sizing.scss +0 -12
  152. data/assets/stylesheets/bootstrap/utilities/_spacing.scss +0 -51
  153. data/assets/stylesheets/bootstrap/utilities/_text.scss +0 -58
  154. data/assets/stylesheets/bootstrap/utilities/_visibility.scss +0 -11
  155. data/test/dummy_rails/app/views/pages/root.html.slim +0 -58
  156. /data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
@@ -1,632 +1,835 @@
1
+ /*!
2
+ * Bootstrap modal.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
+ */
1
6
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./util.js')) :
3
- typeof define === 'function' && define.amd ? define(['jquery', './util.js'], factory) :
4
- (global.Modal = factory(global.jQuery,global.Util));
5
- }(this, (function ($,Util) { 'use strict';
6
-
7
- $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
8
- Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
9
-
10
- function _defineProperties(target, props) {
11
- for (var i = 0; i < props.length; i++) {
12
- var descriptor = props[i];
13
- descriptor.enumerable = descriptor.enumerable || false;
14
- descriptor.configurable = true;
15
- if ("value" in descriptor) descriptor.writable = true;
16
- Object.defineProperty(target, descriptor.key, descriptor);
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(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/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Modal = factory(global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base));
10
+ }(this, (function (EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict';
11
+
12
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
+
14
+ var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
15
+ var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
16
+ var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
17
+ var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
18
+
19
+ /**
20
+ * --------------------------------------------------------------------------
21
+ * Bootstrap (v5.0.0): 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}`;
17
31
  }
18
- }
19
32
 
20
- function _createClass(Constructor, protoProps, staticProps) {
21
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
22
- if (staticProps) _defineProperties(Constructor, staticProps);
23
- return Constructor;
24
- }
33
+ return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
34
+ };
25
35
 
26
- function _defineProperty(obj, key, value) {
27
- if (key in obj) {
28
- Object.defineProperty(obj, key, {
29
- value: value,
30
- enumerable: true,
31
- configurable: true,
32
- writable: true
33
- });
34
- } else {
35
- obj[key] = value;
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;
36
55
  }
37
56
 
38
- return obj;
39
- }
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
40
81
 
41
- function _objectSpread(target) {
42
- for (var i = 1; i < arguments.length; i++) {
43
- var source = arguments[i] != null ? arguments[i] : {};
44
- var ownKeys = Object.keys(source);
45
82
 
46
- if (typeof Object.getOwnPropertySymbols === 'function') {
47
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
48
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
49
- }));
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 => (obj[0] || obj).nodeType;
93
+
94
+ const emulateTransitionEnd = (element, duration) => {
95
+ let called = false;
96
+ const durationPadding = 5;
97
+ const emulatedDuration = duration + durationPadding;
98
+
99
+ function listener() {
100
+ called = true;
101
+ element.removeEventListener(TRANSITION_END, listener);
102
+ }
103
+
104
+ element.addEventListener(TRANSITION_END, listener);
105
+ setTimeout(() => {
106
+ if (!called) {
107
+ triggerTransitionEnd(element);
50
108
  }
109
+ }, emulatedDuration);
110
+ };
51
111
 
52
- ownKeys.forEach(function (key) {
53
- _defineProperty(target, key, source[key]);
54
- });
112
+ const typeCheckConfig = (componentName, config, configTypes) => {
113
+ Object.keys(configTypes).forEach(property => {
114
+ const expectedTypes = configTypes[property];
115
+ const value = config[property];
116
+ const valueType = value && isElement(value) ? 'element' : toType(value);
117
+
118
+ if (!new RegExp(expectedTypes).test(valueType)) {
119
+ throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
120
+ }
121
+ });
122
+ };
123
+
124
+ const isVisible = element => {
125
+ if (!element) {
126
+ return false;
55
127
  }
56
128
 
57
- return target;
58
- }
129
+ if (element.style && element.parentNode && element.parentNode.style) {
130
+ const elementStyle = getComputedStyle(element);
131
+ const parentNodeStyle = getComputedStyle(element.parentNode);
132
+ return elementStyle.display !== 'none' && parentNodeStyle.display !== 'none' && elementStyle.visibility !== 'hidden';
133
+ }
134
+
135
+ return false;
136
+ };
137
+
138
+ const reflow = element => element.offsetHeight;
139
+
140
+ const getjQuery = () => {
141
+ const {
142
+ jQuery
143
+ } = window;
144
+
145
+ if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
146
+ return jQuery;
147
+ }
148
+
149
+ return null;
150
+ };
151
+
152
+ const onDOMContentLoaded = callback => {
153
+ if (document.readyState === 'loading') {
154
+ document.addEventListener('DOMContentLoaded', callback);
155
+ } else {
156
+ callback();
157
+ }
158
+ };
159
+
160
+ const isRTL = () => document.documentElement.dir === 'rtl';
161
+
162
+ const defineJQueryPlugin = (name, plugin) => {
163
+ onDOMContentLoaded(() => {
164
+ const $ = getjQuery();
165
+ /* istanbul ignore if */
166
+
167
+ if ($) {
168
+ const JQUERY_NO_CONFLICT = $.fn[name];
169
+ $.fn[name] = plugin.jQueryInterface;
170
+ $.fn[name].Constructor = plugin;
171
+
172
+ $.fn[name].noConflict = () => {
173
+ $.fn[name] = JQUERY_NO_CONFLICT;
174
+ return plugin.jQueryInterface;
175
+ };
176
+ }
177
+ });
178
+ };
179
+
180
+ const execute = callback => {
181
+ if (typeof callback === 'function') {
182
+ callback();
183
+ }
184
+ };
59
185
 
60
186
  /**
61
187
  * --------------------------------------------------------------------------
62
- * Bootstrap (v4.1.3): modal.js
63
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
188
+ * Bootstrap (v5.0.0): util/scrollBar.js
189
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
64
190
  * --------------------------------------------------------------------------
65
191
  */
192
+ const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
193
+ const SELECTOR_STICKY_CONTENT = '.sticky-top';
66
194
 
67
- var Modal = function ($$$1) {
68
- /**
69
- * ------------------------------------------------------------------------
70
- * Constants
71
- * ------------------------------------------------------------------------
72
- */
73
- var NAME = 'modal';
74
- var VERSION = '4.1.3';
75
- var DATA_KEY = 'bs.modal';
76
- var EVENT_KEY = "." + DATA_KEY;
77
- var DATA_API_KEY = '.data-api';
78
- var JQUERY_NO_CONFLICT = $$$1.fn[NAME];
79
- var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
80
-
81
- var Default = {
82
- backdrop: true,
83
- keyboard: true,
84
- focus: true,
85
- show: true
86
- };
87
- var DefaultType = {
88
- backdrop: '(boolean|string)',
89
- keyboard: 'boolean',
90
- focus: 'boolean',
91
- show: 'boolean'
92
- };
93
- var Event = {
94
- HIDE: "hide" + EVENT_KEY,
95
- HIDDEN: "hidden" + EVENT_KEY,
96
- SHOW: "show" + EVENT_KEY,
97
- SHOWN: "shown" + EVENT_KEY,
98
- FOCUSIN: "focusin" + EVENT_KEY,
99
- RESIZE: "resize" + EVENT_KEY,
100
- CLICK_DISMISS: "click.dismiss" + EVENT_KEY,
101
- KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY,
102
- MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY,
103
- MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY,
104
- CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
105
- };
106
- var ClassName = {
107
- SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
108
- BACKDROP: 'modal-backdrop',
109
- OPEN: 'modal-open',
110
- FADE: 'fade',
111
- SHOW: 'show'
112
- };
113
- var Selector = {
114
- DIALOG: '.modal-dialog',
115
- DATA_TOGGLE: '[data-toggle="modal"]',
116
- DATA_DISMISS: '[data-dismiss="modal"]',
117
- FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
118
- STICKY_CONTENT: '.sticky-top'
119
- /**
120
- * ------------------------------------------------------------------------
121
- * Class Definition
122
- * ------------------------------------------------------------------------
123
- */
195
+ const getWidth = () => {
196
+ // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
197
+ const documentWidth = document.documentElement.clientWidth;
198
+ return Math.abs(window.innerWidth - documentWidth);
199
+ };
124
200
 
125
- };
201
+ const hide = (width = getWidth()) => {
202
+ _disableOverFlow(); // give padding to element to balances the hidden scrollbar width
126
203
 
127
- var Modal =
128
- /*#__PURE__*/
129
- function () {
130
- function Modal(element, config) {
131
- this._config = this._getConfig(config);
132
- this._element = element;
133
- this._dialog = element.querySelector(Selector.DIALOG);
134
- this._backdrop = null;
135
- this._isShown = false;
136
- this._isBodyOverflowing = false;
137
- this._ignoreBackdropClick = false;
138
- this._scrollbarWidth = 0;
139
- } // Getters
140
204
 
205
+ _setElementAttributes('body', 'paddingRight', calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements, to keep shown fullwidth
141
206
 
142
- var _proto = Modal.prototype;
143
-
144
- // Public
145
- _proto.toggle = function toggle(relatedTarget) {
146
- return this._isShown ? this.hide() : this.show(relatedTarget);
147
- };
148
207
 
149
- _proto.show = function show(relatedTarget) {
150
- var _this = this;
208
+ _setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width);
151
209
 
152
- if (this._isTransitioning || this._isShown) {
153
- return;
154
- }
210
+ _setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width);
211
+ };
155
212
 
156
- if ($$$1(this._element).hasClass(ClassName.FADE)) {
157
- this._isTransitioning = true;
158
- }
213
+ const _disableOverFlow = () => {
214
+ const actualValue = document.body.style.overflow;
159
215
 
160
- var showEvent = $$$1.Event(Event.SHOW, {
161
- relatedTarget: relatedTarget
162
- });
163
- $$$1(this._element).trigger(showEvent);
216
+ if (actualValue) {
217
+ Manipulator__default['default'].setDataAttribute(document.body, 'overflow', actualValue);
218
+ }
164
219
 
165
- if (this._isShown || showEvent.isDefaultPrevented()) {
166
- return;
167
- }
220
+ document.body.style.overflow = 'hidden';
221
+ };
168
222
 
169
- this._isShown = true;
223
+ const _setElementAttributes = (selector, styleProp, callback) => {
224
+ const scrollbarWidth = getWidth();
225
+ SelectorEngine__default['default'].find(selector).forEach(element => {
226
+ if (element !== document.body && window.innerWidth > element.clientWidth + scrollbarWidth) {
227
+ return;
228
+ }
170
229
 
171
- this._checkScrollbar();
230
+ const actualValue = element.style[styleProp];
231
+ const calculatedValue = window.getComputedStyle(element)[styleProp];
232
+ Manipulator__default['default'].setDataAttribute(element, styleProp, actualValue);
233
+ element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`;
234
+ });
235
+ };
172
236
 
173
- this._setScrollbar();
237
+ const reset = () => {
238
+ _resetElementAttributes('body', 'overflow');
174
239
 
175
- this._adjustDialog();
240
+ _resetElementAttributes('body', 'paddingRight');
176
241
 
177
- $$$1(document.body).addClass(ClassName.OPEN);
242
+ _resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight');
178
243
 
179
- this._setEscapeEvent();
244
+ _resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight');
245
+ };
180
246
 
181
- this._setResizeEvent();
247
+ const _resetElementAttributes = (selector, styleProp) => {
248
+ SelectorEngine__default['default'].find(selector).forEach(element => {
249
+ const value = Manipulator__default['default'].getDataAttribute(element, styleProp);
182
250
 
183
- $$$1(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, function (event) {
184
- return _this.hide(event);
185
- });
186
- $$$1(this._dialog).on(Event.MOUSEDOWN_DISMISS, function () {
187
- $$$1(_this._element).one(Event.MOUSEUP_DISMISS, function (event) {
188
- if ($$$1(event.target).is(_this._element)) {
189
- _this._ignoreBackdropClick = true;
190
- }
191
- });
192
- });
251
+ if (typeof value === 'undefined') {
252
+ element.style.removeProperty(styleProp);
253
+ } else {
254
+ Manipulator__default['default'].removeDataAttribute(element, styleProp);
255
+ element.style[styleProp] = value;
256
+ }
257
+ });
258
+ };
193
259
 
194
- this._showBackdrop(function () {
195
- return _this._showElement(relatedTarget);
196
- });
197
- };
260
+ /**
261
+ * --------------------------------------------------------------------------
262
+ * Bootstrap (v5.0.0): util/backdrop.js
263
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
264
+ * --------------------------------------------------------------------------
265
+ */
266
+ const Default$1 = {
267
+ isVisible: true,
268
+ // if false, we use the backdrop helper without adding any element to the dom
269
+ isAnimated: false,
270
+ rootElement: document.body,
271
+ // give the choice to place backdrop under different elements
272
+ clickCallback: null
273
+ };
274
+ const DefaultType$1 = {
275
+ isVisible: 'boolean',
276
+ isAnimated: 'boolean',
277
+ rootElement: 'element',
278
+ clickCallback: '(function|null)'
279
+ };
280
+ const NAME$1 = 'backdrop';
281
+ const CLASS_NAME_BACKDROP = 'modal-backdrop';
282
+ const CLASS_NAME_FADE$1 = 'fade';
283
+ const CLASS_NAME_SHOW$1 = 'show';
284
+ const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$1}`;
285
+
286
+ class Backdrop {
287
+ constructor(config) {
288
+ this._config = this._getConfig(config);
289
+ this._isAppended = false;
290
+ this._element = null;
291
+ }
198
292
 
199
- _proto.hide = function hide(event) {
200
- var _this2 = this;
293
+ show(callback) {
294
+ if (!this._config.isVisible) {
295
+ execute(callback);
296
+ return;
297
+ }
201
298
 
202
- if (event) {
203
- event.preventDefault();
204
- }
299
+ this._append();
205
300
 
206
- if (this._isTransitioning || !this._isShown) {
207
- return;
208
- }
301
+ if (this._config.isAnimated) {
302
+ reflow(this._getElement());
303
+ }
209
304
 
210
- var hideEvent = $$$1.Event(Event.HIDE);
211
- $$$1(this._element).trigger(hideEvent);
305
+ this._getElement().classList.add(CLASS_NAME_SHOW$1);
212
306
 
213
- if (!this._isShown || hideEvent.isDefaultPrevented()) {
214
- return;
215
- }
307
+ this._emulateAnimation(() => {
308
+ execute(callback);
309
+ });
310
+ }
216
311
 
217
- this._isShown = false;
218
- var transition = $$$1(this._element).hasClass(ClassName.FADE);
312
+ hide(callback) {
313
+ if (!this._config.isVisible) {
314
+ execute(callback);
315
+ return;
316
+ }
219
317
 
220
- if (transition) {
221
- this._isTransitioning = true;
222
- }
318
+ this._getElement().classList.remove(CLASS_NAME_SHOW$1);
223
319
 
224
- this._setEscapeEvent();
320
+ this._emulateAnimation(() => {
321
+ this.dispose();
322
+ execute(callback);
323
+ });
324
+ } // Private
225
325
 
226
- this._setResizeEvent();
227
326
 
228
- $$$1(document).off(Event.FOCUSIN);
229
- $$$1(this._element).removeClass(ClassName.SHOW);
230
- $$$1(this._element).off(Event.CLICK_DISMISS);
231
- $$$1(this._dialog).off(Event.MOUSEDOWN_DISMISS);
327
+ _getElement() {
328
+ if (!this._element) {
329
+ const backdrop = document.createElement('div');
330
+ backdrop.className = CLASS_NAME_BACKDROP;
232
331
 
233
- if (transition) {
234
- var transitionDuration = Util.getTransitionDurationFromElement(this._element);
235
- $$$1(this._element).one(Util.TRANSITION_END, function (event) {
236
- return _this2._hideModal(event);
237
- }).emulateTransitionEnd(transitionDuration);
238
- } else {
239
- this._hideModal();
332
+ if (this._config.isAnimated) {
333
+ backdrop.classList.add(CLASS_NAME_FADE$1);
240
334
  }
241
- };
242
335
 
243
- _proto.dispose = function dispose() {
244
- $$$1.removeData(this._element, DATA_KEY);
245
- $$$1(window, document, this._element, this._backdrop).off(EVENT_KEY);
246
- this._config = null;
247
- this._element = null;
248
- this._dialog = null;
249
- this._backdrop = null;
250
- this._isShown = null;
251
- this._isBodyOverflowing = null;
252
- this._ignoreBackdropClick = null;
253
- this._scrollbarWidth = null;
336
+ this._element = backdrop;
337
+ }
338
+
339
+ return this._element;
340
+ }
341
+
342
+ _getConfig(config) {
343
+ config = { ...Default$1,
344
+ ...(typeof config === 'object' ? config : {})
254
345
  };
346
+ typeCheckConfig(NAME$1, config, DefaultType$1);
347
+ return config;
348
+ }
255
349
 
256
- _proto.handleUpdate = function handleUpdate() {
257
- this._adjustDialog();
258
- }; // Private
350
+ _append() {
351
+ if (this._isAppended) {
352
+ return;
353
+ }
259
354
 
355
+ this._config.rootElement.appendChild(this._getElement());
260
356
 
261
- _proto._getConfig = function _getConfig(config) {
262
- config = _objectSpread({}, Default, config);
263
- Util.typeCheckConfig(NAME, config, DefaultType);
264
- return config;
265
- };
357
+ EventHandler__default['default'].on(this._getElement(), EVENT_MOUSEDOWN, () => {
358
+ execute(this._config.clickCallback);
359
+ });
360
+ this._isAppended = true;
361
+ }
266
362
 
267
- _proto._showElement = function _showElement(relatedTarget) {
268
- var _this3 = this;
363
+ dispose() {
364
+ if (!this._isAppended) {
365
+ return;
366
+ }
269
367
 
270
- var transition = $$$1(this._element).hasClass(ClassName.FADE);
368
+ EventHandler__default['default'].off(this._element, EVENT_MOUSEDOWN);
271
369
 
272
- if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
273
- // Don't move modal's DOM position
274
- document.body.appendChild(this._element);
275
- }
370
+ this._getElement().parentNode.removeChild(this._element);
276
371
 
277
- this._element.style.display = 'block';
372
+ this._isAppended = false;
373
+ }
278
374
 
279
- this._element.removeAttribute('aria-hidden');
375
+ _emulateAnimation(callback) {
376
+ if (!this._config.isAnimated) {
377
+ execute(callback);
378
+ return;
379
+ }
280
380
 
281
- this._element.scrollTop = 0;
381
+ const backdropTransitionDuration = getTransitionDurationFromElement(this._getElement());
382
+ EventHandler__default['default'].one(this._getElement(), 'transitionend', () => execute(callback));
383
+ emulateTransitionEnd(this._getElement(), backdropTransitionDuration);
384
+ }
282
385
 
283
- if (transition) {
284
- Util.reflow(this._element);
285
- }
386
+ }
286
387
 
287
- $$$1(this._element).addClass(ClassName.SHOW);
388
+ /**
389
+ * --------------------------------------------------------------------------
390
+ * Bootstrap (v5.0.0): modal.js
391
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
392
+ * --------------------------------------------------------------------------
393
+ */
394
+ /**
395
+ * ------------------------------------------------------------------------
396
+ * Constants
397
+ * ------------------------------------------------------------------------
398
+ */
288
399
 
289
- if (this._config.focus) {
290
- this._enforceFocus();
291
- }
400
+ const NAME = 'modal';
401
+ const DATA_KEY = 'bs.modal';
402
+ const EVENT_KEY = `.${DATA_KEY}`;
403
+ const DATA_API_KEY = '.data-api';
404
+ const ESCAPE_KEY = 'Escape';
405
+ const Default = {
406
+ backdrop: true,
407
+ keyboard: true,
408
+ focus: true
409
+ };
410
+ const DefaultType = {
411
+ backdrop: '(boolean|string)',
412
+ keyboard: 'boolean',
413
+ focus: 'boolean'
414
+ };
415
+ const EVENT_HIDE = `hide${EVENT_KEY}`;
416
+ const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY}`;
417
+ const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
418
+ const EVENT_SHOW = `show${EVENT_KEY}`;
419
+ const EVENT_SHOWN = `shown${EVENT_KEY}`;
420
+ const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
421
+ const EVENT_RESIZE = `resize${EVENT_KEY}`;
422
+ const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`;
423
+ const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`;
424
+ const EVENT_MOUSEUP_DISMISS = `mouseup.dismiss${EVENT_KEY}`;
425
+ const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY}`;
426
+ const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
427
+ const CLASS_NAME_OPEN = 'modal-open';
428
+ const CLASS_NAME_FADE = 'fade';
429
+ const CLASS_NAME_SHOW = 'show';
430
+ const CLASS_NAME_STATIC = 'modal-static';
431
+ const SELECTOR_DIALOG = '.modal-dialog';
432
+ const SELECTOR_MODAL_BODY = '.modal-body';
433
+ const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="modal"]';
434
+ const SELECTOR_DATA_DISMISS = '[data-bs-dismiss="modal"]';
435
+ /**
436
+ * ------------------------------------------------------------------------
437
+ * Class Definition
438
+ * ------------------------------------------------------------------------
439
+ */
292
440
 
293
- var shownEvent = $$$1.Event(Event.SHOWN, {
294
- relatedTarget: relatedTarget
295
- });
441
+ class Modal extends BaseComponent__default['default'] {
442
+ constructor(element, config) {
443
+ super(element);
444
+ this._config = this._getConfig(config);
445
+ this._dialog = SelectorEngine__default['default'].findOne(SELECTOR_DIALOG, this._element);
446
+ this._backdrop = this._initializeBackDrop();
447
+ this._isShown = false;
448
+ this._ignoreBackdropClick = false;
449
+ this._isTransitioning = false;
450
+ } // Getters
296
451
 
297
- var transitionComplete = function transitionComplete() {
298
- if (_this3._config.focus) {
299
- _this3._element.focus();
300
- }
301
452
 
302
- _this3._isTransitioning = false;
303
- $$$1(_this3._element).trigger(shownEvent);
304
- };
453
+ static get Default() {
454
+ return Default;
455
+ }
305
456
 
306
- if (transition) {
307
- var transitionDuration = Util.getTransitionDurationFromElement(this._element);
308
- $$$1(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
309
- } else {
310
- transitionComplete();
311
- }
312
- };
457
+ static get DATA_KEY() {
458
+ return DATA_KEY;
459
+ } // Public
313
460
 
314
- _proto._enforceFocus = function _enforceFocus() {
315
- var _this4 = this;
316
461
 
317
- $$$1(document).off(Event.FOCUSIN) // Guard against infinite focus loop
318
- .on(Event.FOCUSIN, function (event) {
319
- if (document !== event.target && _this4._element !== event.target && $$$1(_this4._element).has(event.target).length === 0) {
320
- _this4._element.focus();
462
+ toggle(relatedTarget) {
463
+ return this._isShown ? this.hide() : this.show(relatedTarget);
464
+ }
465
+
466
+ show(relatedTarget) {
467
+ if (this._isShown || this._isTransitioning) {
468
+ return;
469
+ }
470
+
471
+ if (this._isAnimated()) {
472
+ this._isTransitioning = true;
473
+ }
474
+
475
+ const showEvent = EventHandler__default['default'].trigger(this._element, EVENT_SHOW, {
476
+ relatedTarget
477
+ });
478
+
479
+ if (this._isShown || showEvent.defaultPrevented) {
480
+ return;
481
+ }
482
+
483
+ this._isShown = true;
484
+ hide();
485
+ document.body.classList.add(CLASS_NAME_OPEN);
486
+
487
+ this._adjustDialog();
488
+
489
+ this._setEscapeEvent();
490
+
491
+ this._setResizeEvent();
492
+
493
+ EventHandler__default['default'].on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, event => this.hide(event));
494
+ EventHandler__default['default'].on(this._dialog, EVENT_MOUSEDOWN_DISMISS, () => {
495
+ EventHandler__default['default'].one(this._element, EVENT_MOUSEUP_DISMISS, event => {
496
+ if (event.target === this._element) {
497
+ this._ignoreBackdropClick = true;
321
498
  }
322
499
  });
323
- };
500
+ });
324
501
 
325
- _proto._setEscapeEvent = function _setEscapeEvent() {
326
- var _this5 = this;
502
+ this._showBackdrop(() => this._showElement(relatedTarget));
503
+ }
327
504
 
328
- if (this._isShown && this._config.keyboard) {
329
- $$$1(this._element).on(Event.KEYDOWN_DISMISS, function (event) {
330
- if (event.which === ESCAPE_KEYCODE) {
331
- event.preventDefault();
505
+ hide(event) {
506
+ if (event) {
507
+ event.preventDefault();
508
+ }
332
509
 
333
- _this5.hide();
334
- }
335
- });
336
- } else if (!this._isShown) {
337
- $$$1(this._element).off(Event.KEYDOWN_DISMISS);
338
- }
339
- };
510
+ if (!this._isShown || this._isTransitioning) {
511
+ return;
512
+ }
340
513
 
341
- _proto._setResizeEvent = function _setResizeEvent() {
342
- var _this6 = this;
514
+ const hideEvent = EventHandler__default['default'].trigger(this._element, EVENT_HIDE);
343
515
 
344
- if (this._isShown) {
345
- $$$1(window).on(Event.RESIZE, function (event) {
346
- return _this6.handleUpdate(event);
347
- });
348
- } else {
349
- $$$1(window).off(Event.RESIZE);
350
- }
351
- };
516
+ if (hideEvent.defaultPrevented) {
517
+ return;
518
+ }
352
519
 
353
- _proto._hideModal = function _hideModal() {
354
- var _this7 = this;
520
+ this._isShown = false;
355
521
 
356
- this._element.style.display = 'none';
522
+ const isAnimated = this._isAnimated();
357
523
 
358
- this._element.setAttribute('aria-hidden', true);
524
+ if (isAnimated) {
525
+ this._isTransitioning = true;
526
+ }
359
527
 
360
- this._isTransitioning = false;
528
+ this._setEscapeEvent();
361
529
 
362
- this._showBackdrop(function () {
363
- $$$1(document.body).removeClass(ClassName.OPEN);
530
+ this._setResizeEvent();
364
531
 
365
- _this7._resetAdjustments();
532
+ EventHandler__default['default'].off(document, EVENT_FOCUSIN);
366
533
 
367
- _this7._resetScrollbar();
534
+ this._element.classList.remove(CLASS_NAME_SHOW);
368
535
 
369
- $$$1(_this7._element).trigger(Event.HIDDEN);
370
- });
371
- };
536
+ EventHandler__default['default'].off(this._element, EVENT_CLICK_DISMISS);
537
+ EventHandler__default['default'].off(this._dialog, EVENT_MOUSEDOWN_DISMISS);
372
538
 
373
- _proto._removeBackdrop = function _removeBackdrop() {
374
- if (this._backdrop) {
375
- $$$1(this._backdrop).remove();
376
- this._backdrop = null;
377
- }
378
- };
539
+ if (isAnimated) {
540
+ const transitionDuration = getTransitionDurationFromElement(this._element);
541
+ EventHandler__default['default'].one(this._element, 'transitionend', event => this._hideModal(event));
542
+ emulateTransitionEnd(this._element, transitionDuration);
543
+ } else {
544
+ this._hideModal();
545
+ }
546
+ }
379
547
 
380
- _proto._showBackdrop = function _showBackdrop(callback) {
381
- var _this8 = this;
548
+ dispose() {
549
+ [window, this._dialog].forEach(htmlElement => EventHandler__default['default'].off(htmlElement, EVENT_KEY));
550
+ super.dispose();
551
+ /**
552
+ * `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API`
553
+ * Do not move `document` in `htmlElements` array
554
+ * It will remove `EVENT_CLICK_DATA_API` event that should remain
555
+ */
382
556
 
383
- var animate = $$$1(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : '';
557
+ EventHandler__default['default'].off(document, EVENT_FOCUSIN);
558
+ this._config = null;
559
+ this._dialog = null;
384
560
 
385
- if (this._isShown && this._config.backdrop) {
386
- this._backdrop = document.createElement('div');
387
- this._backdrop.className = ClassName.BACKDROP;
561
+ this._backdrop.dispose();
388
562
 
389
- if (animate) {
390
- this._backdrop.classList.add(animate);
391
- }
563
+ this._backdrop = null;
564
+ this._isShown = null;
565
+ this._ignoreBackdropClick = null;
566
+ this._isTransitioning = null;
567
+ }
392
568
 
393
- $$$1(this._backdrop).appendTo(document.body);
394
- $$$1(this._element).on(Event.CLICK_DISMISS, function (event) {
395
- if (_this8._ignoreBackdropClick) {
396
- _this8._ignoreBackdropClick = false;
397
- return;
398
- }
399
-
400
- if (event.target !== event.currentTarget) {
401
- return;
402
- }
403
-
404
- if (_this8._config.backdrop === 'static') {
405
- _this8._element.focus();
406
- } else {
407
- _this8.hide();
408
- }
409
- });
569
+ handleUpdate() {
570
+ this._adjustDialog();
571
+ } // Private
410
572
 
411
- if (animate) {
412
- Util.reflow(this._backdrop);
413
- }
414
573
 
415
- $$$1(this._backdrop).addClass(ClassName.SHOW);
574
+ _initializeBackDrop() {
575
+ return new Backdrop({
576
+ isVisible: Boolean(this._config.backdrop),
577
+ // 'static' option will be translated to true, and booleans will keep their value
578
+ isAnimated: this._isAnimated()
579
+ });
580
+ }
416
581
 
417
- if (!callback) {
418
- return;
419
- }
582
+ _getConfig(config) {
583
+ config = { ...Default,
584
+ ...Manipulator__default['default'].getDataAttributes(this._element),
585
+ ...config
586
+ };
587
+ typeCheckConfig(NAME, config, DefaultType);
588
+ return config;
589
+ }
420
590
 
421
- if (!animate) {
422
- callback();
423
- return;
424
- }
591
+ _showElement(relatedTarget) {
592
+ const isAnimated = this._isAnimated();
425
593
 
426
- var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
427
- $$$1(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
428
- } else if (!this._isShown && this._backdrop) {
429
- $$$1(this._backdrop).removeClass(ClassName.SHOW);
594
+ const modalBody = SelectorEngine__default['default'].findOne(SELECTOR_MODAL_BODY, this._dialog);
430
595
 
431
- var callbackRemove = function callbackRemove() {
432
- _this8._removeBackdrop();
596
+ if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
597
+ // Don't move modal's DOM position
598
+ document.body.appendChild(this._element);
599
+ }
433
600
 
434
- if (callback) {
435
- callback();
436
- }
437
- };
601
+ this._element.style.display = 'block';
438
602
 
439
- if ($$$1(this._element).hasClass(ClassName.FADE)) {
440
- var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
603
+ this._element.removeAttribute('aria-hidden');
441
604
 
442
- $$$1(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
443
- } else {
444
- callbackRemove();
445
- }
446
- } else if (callback) {
447
- callback();
448
- }
449
- }; // ----------------------------------------------------------------------
450
- // the following methods are used to handle overflowing modals
451
- // todo (fat): these should probably be refactored out of modal.js
452
- // ----------------------------------------------------------------------
605
+ this._element.setAttribute('aria-modal', true);
453
606
 
607
+ this._element.setAttribute('role', 'dialog');
454
608
 
455
- _proto._adjustDialog = function _adjustDialog() {
456
- var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
609
+ this._element.scrollTop = 0;
457
610
 
458
- if (!this._isBodyOverflowing && isModalOverflowing) {
459
- this._element.style.paddingLeft = this._scrollbarWidth + "px";
460
- }
611
+ if (modalBody) {
612
+ modalBody.scrollTop = 0;
613
+ }
461
614
 
462
- if (this._isBodyOverflowing && !isModalOverflowing) {
463
- this._element.style.paddingRight = this._scrollbarWidth + "px";
615
+ if (isAnimated) {
616
+ reflow(this._element);
617
+ }
618
+
619
+ this._element.classList.add(CLASS_NAME_SHOW);
620
+
621
+ if (this._config.focus) {
622
+ this._enforceFocus();
623
+ }
624
+
625
+ const transitionComplete = () => {
626
+ if (this._config.focus) {
627
+ this._element.focus();
464
628
  }
465
- };
466
629
 
467
- _proto._resetAdjustments = function _resetAdjustments() {
468
- this._element.style.paddingLeft = '';
469
- this._element.style.paddingRight = '';
630
+ this._isTransitioning = false;
631
+ EventHandler__default['default'].trigger(this._element, EVENT_SHOWN, {
632
+ relatedTarget
633
+ });
470
634
  };
471
635
 
472
- _proto._checkScrollbar = function _checkScrollbar() {
473
- var rect = document.body.getBoundingClientRect();
474
- this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
475
- this._scrollbarWidth = this._getScrollbarWidth();
476
- };
636
+ if (isAnimated) {
637
+ const transitionDuration = getTransitionDurationFromElement(this._dialog);
638
+ EventHandler__default['default'].one(this._dialog, 'transitionend', transitionComplete);
639
+ emulateTransitionEnd(this._dialog, transitionDuration);
640
+ } else {
641
+ transitionComplete();
642
+ }
643
+ }
644
+
645
+ _enforceFocus() {
646
+ EventHandler__default['default'].off(document, EVENT_FOCUSIN); // guard against infinite focus loop
477
647
 
478
- _proto._setScrollbar = function _setScrollbar() {
479
- var _this9 = this;
480
-
481
- if (this._isBodyOverflowing) {
482
- // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
483
- // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
484
- var fixedContent = [].slice.call(document.querySelectorAll(Selector.FIXED_CONTENT));
485
- var stickyContent = [].slice.call(document.querySelectorAll(Selector.STICKY_CONTENT)); // Adjust fixed content padding
486
-
487
- $$$1(fixedContent).each(function (index, element) {
488
- var actualPadding = element.style.paddingRight;
489
- var calculatedPadding = $$$1(element).css('padding-right');
490
- $$$1(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this9._scrollbarWidth + "px");
491
- }); // Adjust sticky content margin
492
-
493
- $$$1(stickyContent).each(function (index, element) {
494
- var actualMargin = element.style.marginRight;
495
- var calculatedMargin = $$$1(element).css('margin-right');
496
- $$$1(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this9._scrollbarWidth + "px");
497
- }); // Adjust body padding
498
-
499
- var actualPadding = document.body.style.paddingRight;
500
- var calculatedPadding = $$$1(document.body).css('padding-right');
501
- $$$1(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
648
+ EventHandler__default['default'].on(document, EVENT_FOCUSIN, event => {
649
+ if (document !== event.target && this._element !== event.target && !this._element.contains(event.target)) {
650
+ this._element.focus();
502
651
  }
503
- };
652
+ });
653
+ }
504
654
 
505
- _proto._resetScrollbar = function _resetScrollbar() {
506
- // Restore fixed content padding
507
- var fixedContent = [].slice.call(document.querySelectorAll(Selector.FIXED_CONTENT));
508
- $$$1(fixedContent).each(function (index, element) {
509
- var padding = $$$1(element).data('padding-right');
510
- $$$1(element).removeData('padding-right');
511
- element.style.paddingRight = padding ? padding : '';
512
- }); // Restore sticky content
513
-
514
- var elements = [].slice.call(document.querySelectorAll("" + Selector.STICKY_CONTENT));
515
- $$$1(elements).each(function (index, element) {
516
- var margin = $$$1(element).data('margin-right');
517
-
518
- if (typeof margin !== 'undefined') {
519
- $$$1(element).css('margin-right', margin).removeData('margin-right');
655
+ _setEscapeEvent() {
656
+ if (this._isShown) {
657
+ EventHandler__default['default'].on(this._element, EVENT_KEYDOWN_DISMISS, event => {
658
+ if (this._config.keyboard && event.key === ESCAPE_KEY) {
659
+ event.preventDefault();
660
+ this.hide();
661
+ } else if (!this._config.keyboard && event.key === ESCAPE_KEY) {
662
+ this._triggerBackdropTransition();
520
663
  }
521
- }); // Restore body padding
664
+ });
665
+ } else {
666
+ EventHandler__default['default'].off(this._element, EVENT_KEYDOWN_DISMISS);
667
+ }
668
+ }
522
669
 
523
- var padding = $$$1(document.body).data('padding-right');
524
- $$$1(document.body).removeData('padding-right');
525
- document.body.style.paddingRight = padding ? padding : '';
526
- };
670
+ _setResizeEvent() {
671
+ if (this._isShown) {
672
+ EventHandler__default['default'].on(window, EVENT_RESIZE, () => this._adjustDialog());
673
+ } else {
674
+ EventHandler__default['default'].off(window, EVENT_RESIZE);
675
+ }
676
+ }
527
677
 
528
- _proto._getScrollbarWidth = function _getScrollbarWidth() {
529
- // thx d.walsh
530
- var scrollDiv = document.createElement('div');
531
- scrollDiv.className = ClassName.SCROLLBAR_MEASURER;
532
- document.body.appendChild(scrollDiv);
533
- var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
534
- document.body.removeChild(scrollDiv);
535
- return scrollbarWidth;
536
- }; // Static
678
+ _hideModal() {
679
+ this._element.style.display = 'none';
537
680
 
681
+ this._element.setAttribute('aria-hidden', true);
538
682
 
539
- Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
540
- return this.each(function () {
541
- var data = $$$1(this).data(DATA_KEY);
683
+ this._element.removeAttribute('aria-modal');
542
684
 
543
- var _config = _objectSpread({}, Default, $$$1(this).data(), typeof config === 'object' && config ? config : {});
685
+ this._element.removeAttribute('role');
544
686
 
545
- if (!data) {
546
- data = new Modal(this, _config);
547
- $$$1(this).data(DATA_KEY, data);
548
- }
687
+ this._isTransitioning = false;
549
688
 
550
- if (typeof config === 'string') {
551
- if (typeof data[config] === 'undefined') {
552
- throw new TypeError("No method named \"" + config + "\"");
553
- }
689
+ this._backdrop.hide(() => {
690
+ document.body.classList.remove(CLASS_NAME_OPEN);
554
691
 
555
- data[config](relatedTarget);
556
- } else if (_config.show) {
557
- data.show(relatedTarget);
558
- }
559
- });
560
- };
692
+ this._resetAdjustments();
693
+
694
+ reset();
695
+ EventHandler__default['default'].trigger(this._element, EVENT_HIDDEN);
696
+ });
697
+ }
561
698
 
562
- _createClass(Modal, null, [{
563
- key: "VERSION",
564
- get: function get() {
565
- return VERSION;
699
+ _showBackdrop(callback) {
700
+ EventHandler__default['default'].on(this._element, EVENT_CLICK_DISMISS, event => {
701
+ if (this._ignoreBackdropClick) {
702
+ this._ignoreBackdropClick = false;
703
+ return;
566
704
  }
567
- }, {
568
- key: "Default",
569
- get: function get() {
570
- return Default;
705
+
706
+ if (event.target !== event.currentTarget) {
707
+ return;
571
708
  }
572
- }]);
573
709
 
574
- return Modal;
575
- }();
576
- /**
577
- * ------------------------------------------------------------------------
578
- * Data Api implementation
579
- * ------------------------------------------------------------------------
580
- */
710
+ if (this._config.backdrop === true) {
711
+ this.hide();
712
+ } else if (this._config.backdrop === 'static') {
713
+ this._triggerBackdropTransition();
714
+ }
715
+ });
581
716
 
717
+ this._backdrop.show(callback);
718
+ }
582
719
 
583
- $$$1(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
584
- var _this10 = this;
720
+ _isAnimated() {
721
+ return this._element.classList.contains(CLASS_NAME_FADE);
722
+ }
585
723
 
586
- var target;
587
- var selector = Util.getSelectorFromElement(this);
724
+ _triggerBackdropTransition() {
725
+ const hideEvent = EventHandler__default['default'].trigger(this._element, EVENT_HIDE_PREVENTED);
588
726
 
589
- if (selector) {
590
- target = document.querySelector(selector);
727
+ if (hideEvent.defaultPrevented) {
728
+ return;
591
729
  }
592
730
 
593
- var config = $$$1(target).data(DATA_KEY) ? 'toggle' : _objectSpread({}, $$$1(target).data(), $$$1(this).data());
731
+ const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
594
732
 
595
- if (this.tagName === 'A' || this.tagName === 'AREA') {
596
- event.preventDefault();
733
+ if (!isModalOverflowing) {
734
+ this._element.style.overflowY = 'hidden';
597
735
  }
598
736
 
599
- var $target = $$$1(target).one(Event.SHOW, function (showEvent) {
600
- if (showEvent.isDefaultPrevented()) {
601
- // Only register focus restorer if modal will actually get shown
737
+ this._element.classList.add(CLASS_NAME_STATIC);
738
+
739
+ const modalTransitionDuration = getTransitionDurationFromElement(this._dialog);
740
+ EventHandler__default['default'].off(this._element, 'transitionend');
741
+ EventHandler__default['default'].one(this._element, 'transitionend', () => {
742
+ this._element.classList.remove(CLASS_NAME_STATIC);
743
+
744
+ if (!isModalOverflowing) {
745
+ EventHandler__default['default'].one(this._element, 'transitionend', () => {
746
+ this._element.style.overflowY = '';
747
+ });
748
+ emulateTransitionEnd(this._element, modalTransitionDuration);
749
+ }
750
+ });
751
+ emulateTransitionEnd(this._element, modalTransitionDuration);
752
+
753
+ this._element.focus();
754
+ } // ----------------------------------------------------------------------
755
+ // the following methods are used to handle overflowing modals
756
+ // ----------------------------------------------------------------------
757
+
758
+
759
+ _adjustDialog() {
760
+ const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
761
+ const scrollbarWidth = getWidth();
762
+ const isBodyOverflowing = scrollbarWidth > 0;
763
+
764
+ if (!isBodyOverflowing && isModalOverflowing && !isRTL() || isBodyOverflowing && !isModalOverflowing && isRTL()) {
765
+ this._element.style.paddingLeft = `${scrollbarWidth}px`;
766
+ }
767
+
768
+ if (isBodyOverflowing && !isModalOverflowing && !isRTL() || !isBodyOverflowing && isModalOverflowing && isRTL()) {
769
+ this._element.style.paddingRight = `${scrollbarWidth}px`;
770
+ }
771
+ }
772
+
773
+ _resetAdjustments() {
774
+ this._element.style.paddingLeft = '';
775
+ this._element.style.paddingRight = '';
776
+ } // Static
777
+
778
+
779
+ static jQueryInterface(config, relatedTarget) {
780
+ return this.each(function () {
781
+ const data = Modal.getInstance(this) || new Modal(this, typeof config === 'object' ? config : {});
782
+
783
+ if (typeof config !== 'string') {
602
784
  return;
603
785
  }
604
786
 
605
- $target.one(Event.HIDDEN, function () {
606
- if ($$$1(_this10).is(':visible')) {
607
- _this10.focus();
608
- }
609
- });
787
+ if (typeof data[config] === 'undefined') {
788
+ throw new TypeError(`No method named "${config}"`);
789
+ }
790
+
791
+ data[config](relatedTarget);
610
792
  });
793
+ }
611
794
 
612
- Modal._jQueryInterface.call($$$1(target), config, this);
795
+ }
796
+ /**
797
+ * ------------------------------------------------------------------------
798
+ * Data Api implementation
799
+ * ------------------------------------------------------------------------
800
+ */
801
+
802
+
803
+ EventHandler__default['default'].on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
804
+ const target = getElementFromSelector(this);
805
+
806
+ if (['A', 'AREA'].includes(this.tagName)) {
807
+ event.preventDefault();
808
+ }
809
+
810
+ EventHandler__default['default'].one(target, EVENT_SHOW, showEvent => {
811
+ if (showEvent.defaultPrevented) {
812
+ // only register focus restorer if modal will actually get shown
813
+ return;
814
+ }
815
+
816
+ EventHandler__default['default'].one(target, EVENT_HIDDEN, () => {
817
+ if (isVisible(this)) {
818
+ this.focus();
819
+ }
820
+ });
613
821
  });
614
- /**
615
- * ------------------------------------------------------------------------
616
- * jQuery
617
- * ------------------------------------------------------------------------
618
- */
619
-
620
- $$$1.fn[NAME] = Modal._jQueryInterface;
621
- $$$1.fn[NAME].Constructor = Modal;
622
-
623
- $$$1.fn[NAME].noConflict = function () {
624
- $$$1.fn[NAME] = JQUERY_NO_CONFLICT;
625
- return Modal._jQueryInterface;
626
- };
627
-
628
- return Modal;
629
- }($);
822
+ const data = Modal.getInstance(target) || new Modal(target);
823
+ data.toggle(this);
824
+ });
825
+ /**
826
+ * ------------------------------------------------------------------------
827
+ * jQuery
828
+ * ------------------------------------------------------------------------
829
+ * add .Modal to jQuery only if jQuery is present
830
+ */
831
+
832
+ defineJQueryPlugin(NAME, Modal);
630
833
 
631
834
  return Modal;
632
835