bootstrap 5.2.0 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +55 -0
- data/README.md +25 -5
- data/assets/javascripts/bootstrap/alert.js +22 -32
- data/assets/javascripts/bootstrap/base-component.js +22 -38
- data/assets/javascripts/bootstrap/button.js +19 -22
- data/assets/javascripts/bootstrap/carousel.js +52 -135
- data/assets/javascripts/bootstrap/collapse.js +40 -102
- data/assets/javascripts/bootstrap/dom/data.js +8 -12
- data/assets/javascripts/bootstrap/dom/event-handler.js +19 -66
- data/assets/javascripts/bootstrap/dom/manipulator.js +4 -17
- data/assets/javascripts/bootstrap/dom/selector-engine.js +42 -24
- data/assets/javascripts/bootstrap/dropdown.js +74 -143
- data/assets/javascripts/bootstrap/modal.js +66 -143
- data/assets/javascripts/bootstrap/offcanvas.js +50 -102
- data/assets/javascripts/bootstrap/popover.js +23 -29
- data/assets/javascripts/bootstrap/scrollspy.js +64 -97
- data/assets/javascripts/bootstrap/tab.js +55 -112
- data/assets/javascripts/bootstrap/toast.js +39 -77
- data/assets/javascripts/bootstrap/tooltip.js +99 -216
- data/assets/javascripts/bootstrap/util/backdrop.js +28 -54
- data/assets/javascripts/bootstrap/util/component-functions.js +13 -18
- data/assets/javascripts/bootstrap/util/config.js +15 -27
- data/assets/javascripts/bootstrap/util/focustrap.js +20 -36
- data/assets/javascripts/bootstrap/util/index.js +42 -111
- data/assets/javascripts/bootstrap/util/sanitizer.js +30 -42
- data/assets/javascripts/bootstrap/util/scrollbar.js +24 -50
- data/assets/javascripts/bootstrap/util/swipe.js +27 -48
- data/assets/javascripts/bootstrap/util/template-factory.js +25 -52
- data/assets/javascripts/bootstrap-sprockets.js +12 -12
- data/assets/javascripts/bootstrap.js +764 -1529
- data/assets/javascripts/bootstrap.min.js +3 -3
- data/assets/stylesheets/_bootstrap-grid.scss +1 -3
- data/assets/stylesheets/_bootstrap-reboot.scss +1 -0
- data/assets/stylesheets/_bootstrap.scss +1 -0
- data/assets/stylesheets/bootstrap/_accordion.scss +16 -4
- data/assets/stylesheets/bootstrap/_alert.scss +8 -11
- data/assets/stylesheets/bootstrap/_button-group.scss +3 -3
- data/assets/stylesheets/bootstrap/_buttons.scss +31 -10
- data/assets/stylesheets/bootstrap/_card.scss +5 -0
- data/assets/stylesheets/bootstrap/_carousel.scss +20 -5
- data/assets/stylesheets/bootstrap/_close.scss +32 -9
- data/assets/stylesheets/bootstrap/_dropdown.scss +3 -1
- data/assets/stylesheets/bootstrap/_functions.scss +3 -3
- data/assets/stylesheets/bootstrap/_grid.scss +6 -0
- data/assets/stylesheets/bootstrap/_helpers.scss +2 -0
- data/assets/stylesheets/bootstrap/_list-group.scss +18 -12
- data/assets/stylesheets/bootstrap/_maps.scss +120 -0
- data/assets/stylesheets/bootstrap/_mixins.scss +1 -2
- data/assets/stylesheets/bootstrap/_modal.scss +1 -1
- data/assets/stylesheets/bootstrap/_nav.scss +42 -5
- data/assets/stylesheets/bootstrap/_navbar.scss +17 -4
- data/assets/stylesheets/bootstrap/_offcanvas.scss +9 -6
- data/assets/stylesheets/bootstrap/_pagination.scss +1 -1
- data/assets/stylesheets/bootstrap/_popover.scss +5 -5
- data/assets/stylesheets/bootstrap/_progress.scss +10 -1
- data/assets/stylesheets/bootstrap/_reboot.scss +3 -3
- data/assets/stylesheets/bootstrap/_root.scss +121 -10
- data/assets/stylesheets/bootstrap/_tables.scss +18 -11
- data/assets/stylesheets/bootstrap/_toasts.scss +5 -2
- data/assets/stylesheets/bootstrap/_tooltip.scss +4 -5
- data/assets/stylesheets/bootstrap/_utilities.scss +172 -13
- data/assets/stylesheets/bootstrap/_variables-dark.scss +85 -0
- data/assets/stylesheets/bootstrap/_variables.scss +272 -162
- data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +4 -0
- data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +23 -3
- data/assets/stylesheets/bootstrap/forms/_form-check.scss +24 -11
- data/assets/stylesheets/bootstrap/forms/_form-control.scss +23 -3
- data/assets/stylesheets/bootstrap/forms/_form-select.scss +11 -2
- data/assets/stylesheets/bootstrap/forms/_input-group.scss +7 -4
- data/assets/stylesheets/bootstrap/helpers/_color-bg.scss +0 -2
- data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +20 -2
- data/assets/stylesheets/bootstrap/helpers/_focus-ring.scss +5 -0
- data/assets/stylesheets/bootstrap/helpers/_icon-link.scss +25 -0
- data/assets/stylesheets/bootstrap/mixins/_alert.scss +4 -1
- data/assets/stylesheets/bootstrap/mixins/_banner.scss +3 -5
- data/assets/stylesheets/bootstrap/mixins/_caret.scss +30 -25
- data/assets/stylesheets/bootstrap/mixins/_color-mode.scss +21 -0
- data/assets/stylesheets/bootstrap/mixins/_forms.scss +18 -17
- data/assets/stylesheets/bootstrap/mixins/_list-group.scss +2 -0
- data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +2 -2
- data/assets/stylesheets/bootstrap/mixins/_utilities.scss +2 -2
- data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +5 -1
- data/assets/stylesheets/bootstrap/vendor/_rfs.scss +23 -29
- data/bootstrap.gemspec +1 -1
- data/lib/bootstrap/version.rb +2 -2
- data/tasks/updater/js.rb +2 -2
- data/tasks/updater/network.rb +2 -2
- data/tasks/updater/scss.rb +1 -1
- data/tasks/updater.rb +2 -2
- data/test/gemfiles/rails_5_2.gemfile +8 -0
- data/test/gemfiles/rails_7_0.gemfile +7 -0
- data/test/test_helper.rb +3 -2
- metadata +17 -9
- data/.travis.yml +0 -32
@@ -1,25 +1,22 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap backdrop.js v5.
|
3
|
-
* Copyright 2011-
|
2
|
+
* Bootstrap backdrop.js v5.3.0 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
4
4
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
5
|
*/
|
6
6
|
(function (global, factory) {
|
7
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../dom/event-handler'), require('./
|
8
|
-
typeof define === 'function' && define.amd ? define(['../dom/event-handler', './
|
9
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Backdrop = factory(global.EventHandler, global.
|
10
|
-
})(this, (function (EventHandler,
|
11
|
-
|
12
|
-
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
13
|
-
|
14
|
-
const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
|
15
|
-
const Config__default = /*#__PURE__*/_interopDefaultLegacy(Config);
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../dom/event-handler.js'), require('./config.js'), require('./index.js')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['../dom/event-handler', './config', './index'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Backdrop = factory(global.EventHandler, global.Config, global.Index));
|
10
|
+
})(this, (function (EventHandler, Config, index_js) { 'use strict';
|
16
11
|
|
17
12
|
/**
|
18
13
|
* --------------------------------------------------------------------------
|
19
|
-
* Bootstrap
|
14
|
+
* Bootstrap util/backdrop.js
|
20
15
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
21
16
|
* --------------------------------------------------------------------------
|
22
17
|
*/
|
18
|
+
|
19
|
+
|
23
20
|
/**
|
24
21
|
* Constants
|
25
22
|
*/
|
@@ -35,8 +32,8 @@
|
|
35
32
|
isVisible: true,
|
36
33
|
// if false, we use the backdrop helper without adding any element to the dom
|
37
34
|
rootElement: 'body' // give the choice to place backdrop under different elements
|
38
|
-
|
39
35
|
};
|
36
|
+
|
40
37
|
const DefaultType = {
|
41
38
|
className: 'string',
|
42
39
|
clickCallback: '(function|null)',
|
@@ -44,120 +41,97 @@
|
|
44
41
|
isVisible: 'boolean',
|
45
42
|
rootElement: '(element|string)'
|
46
43
|
};
|
44
|
+
|
47
45
|
/**
|
48
46
|
* Class definition
|
49
47
|
*/
|
50
48
|
|
51
|
-
class Backdrop extends
|
49
|
+
class Backdrop extends Config {
|
52
50
|
constructor(config) {
|
53
51
|
super();
|
54
52
|
this._config = this._getConfig(config);
|
55
53
|
this._isAppended = false;
|
56
54
|
this._element = null;
|
57
|
-
}
|
58
|
-
|
55
|
+
}
|
59
56
|
|
57
|
+
// Getters
|
60
58
|
static get Default() {
|
61
59
|
return Default;
|
62
60
|
}
|
63
|
-
|
64
61
|
static get DefaultType() {
|
65
62
|
return DefaultType;
|
66
63
|
}
|
67
|
-
|
68
64
|
static get NAME() {
|
69
65
|
return NAME;
|
70
|
-
}
|
71
|
-
|
66
|
+
}
|
72
67
|
|
68
|
+
// Public
|
73
69
|
show(callback) {
|
74
70
|
if (!this._config.isVisible) {
|
75
|
-
|
71
|
+
index_js.execute(callback);
|
76
72
|
return;
|
77
73
|
}
|
78
|
-
|
79
74
|
this._append();
|
80
|
-
|
81
75
|
const element = this._getElement();
|
82
|
-
|
83
76
|
if (this._config.isAnimated) {
|
84
|
-
|
77
|
+
index_js.reflow(element);
|
85
78
|
}
|
86
|
-
|
87
79
|
element.classList.add(CLASS_NAME_SHOW);
|
88
|
-
|
89
80
|
this._emulateAnimation(() => {
|
90
|
-
|
81
|
+
index_js.execute(callback);
|
91
82
|
});
|
92
83
|
}
|
93
|
-
|
94
84
|
hide(callback) {
|
95
85
|
if (!this._config.isVisible) {
|
96
|
-
|
86
|
+
index_js.execute(callback);
|
97
87
|
return;
|
98
88
|
}
|
99
|
-
|
100
89
|
this._getElement().classList.remove(CLASS_NAME_SHOW);
|
101
|
-
|
102
90
|
this._emulateAnimation(() => {
|
103
91
|
this.dispose();
|
104
|
-
|
92
|
+
index_js.execute(callback);
|
105
93
|
});
|
106
94
|
}
|
107
|
-
|
108
95
|
dispose() {
|
109
96
|
if (!this._isAppended) {
|
110
97
|
return;
|
111
98
|
}
|
112
|
-
|
113
|
-
EventHandler__default.default.off(this._element, EVENT_MOUSEDOWN);
|
114
|
-
|
99
|
+
EventHandler.off(this._element, EVENT_MOUSEDOWN);
|
115
100
|
this._element.remove();
|
116
|
-
|
117
101
|
this._isAppended = false;
|
118
|
-
}
|
119
|
-
|
102
|
+
}
|
120
103
|
|
104
|
+
// Private
|
121
105
|
_getElement() {
|
122
106
|
if (!this._element) {
|
123
107
|
const backdrop = document.createElement('div');
|
124
108
|
backdrop.className = this._config.className;
|
125
|
-
|
126
109
|
if (this._config.isAnimated) {
|
127
110
|
backdrop.classList.add(CLASS_NAME_FADE);
|
128
111
|
}
|
129
|
-
|
130
112
|
this._element = backdrop;
|
131
113
|
}
|
132
|
-
|
133
114
|
return this._element;
|
134
115
|
}
|
135
|
-
|
136
116
|
_configAfterMerge(config) {
|
137
117
|
// use getElement() with the default "body" to get a fresh Element on each instantiation
|
138
|
-
config.rootElement =
|
118
|
+
config.rootElement = index_js.getElement(config.rootElement);
|
139
119
|
return config;
|
140
120
|
}
|
141
|
-
|
142
121
|
_append() {
|
143
122
|
if (this._isAppended) {
|
144
123
|
return;
|
145
124
|
}
|
146
|
-
|
147
125
|
const element = this._getElement();
|
148
|
-
|
149
126
|
this._config.rootElement.append(element);
|
150
|
-
|
151
|
-
|
152
|
-
index.execute(this._config.clickCallback);
|
127
|
+
EventHandler.on(element, EVENT_MOUSEDOWN, () => {
|
128
|
+
index_js.execute(this._config.clickCallback);
|
153
129
|
});
|
154
130
|
this._isAppended = true;
|
155
131
|
}
|
156
|
-
|
157
132
|
_emulateAnimation(callback) {
|
158
|
-
|
133
|
+
index_js.executeAfterTransition(callback, this._getElement(), this._config.isAnimated);
|
159
134
|
}
|
160
|
-
|
161
135
|
}
|
162
136
|
|
163
137
|
return Backdrop;
|
@@ -1,21 +1,17 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap component-functions.js v5.
|
3
|
-
* Copyright 2011-
|
2
|
+
* Bootstrap component-functions.js v5.3.0 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2023 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' ? factory(exports, require('../dom/event-handler'), require('./index')) :
|
8
|
-
typeof define === 'function' && define.amd ? define(['exports', '../dom/event-handler', './index'], factory) :
|
9
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ComponentFunctions = {}, global.EventHandler, global.Index));
|
10
|
-
})(this, (function (exports, EventHandler,
|
11
|
-
|
12
|
-
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
13
|
-
|
14
|
-
const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('../dom/event-handler.js'), require('../dom/selector-engine.js'), require('./index.js')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['exports', '../dom/event-handler', '../dom/selector-engine', './index'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ComponentFunctions = {}, global.EventHandler, global.SelectorEngine, global.Index));
|
10
|
+
})(this, (function (exports, EventHandler, SelectorEngine, index_js) { 'use strict';
|
15
11
|
|
16
12
|
/**
|
17
13
|
* --------------------------------------------------------------------------
|
18
|
-
* Bootstrap
|
14
|
+
* Bootstrap util/component-functions.js
|
19
15
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
20
16
|
* --------------------------------------------------------------------------
|
21
17
|
*/
|
@@ -23,24 +19,23 @@
|
|
23
19
|
const enableDismissTrigger = (component, method = 'hide') => {
|
24
20
|
const clickEvent = `click.dismiss${component.EVENT_KEY}`;
|
25
21
|
const name = component.NAME;
|
26
|
-
|
22
|
+
EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
|
27
23
|
if (['A', 'AREA'].includes(this.tagName)) {
|
28
24
|
event.preventDefault();
|
29
25
|
}
|
30
|
-
|
31
|
-
if (index.isDisabled(this)) {
|
26
|
+
if (index_js.isDisabled(this)) {
|
32
27
|
return;
|
33
28
|
}
|
29
|
+
const target = SelectorEngine.getElementFromSelector(this) || this.closest(`.${name}`);
|
30
|
+
const instance = component.getOrCreateInstance(target);
|
34
31
|
|
35
|
-
|
36
|
-
const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
|
37
|
-
|
32
|
+
// Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
|
38
33
|
instance[method]();
|
39
34
|
});
|
40
35
|
};
|
41
36
|
|
42
37
|
exports.enableDismissTrigger = enableDismissTrigger;
|
43
38
|
|
44
|
-
Object.
|
39
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
45
40
|
|
46
41
|
}));
|
@@ -1,24 +1,22 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap config.js v5.
|
3
|
-
* Copyright 2011-
|
2
|
+
* Bootstrap config.js v5.3.0 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2023 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.Config = factory(global.
|
10
|
-
})(this, (function (
|
11
|
-
|
12
|
-
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
13
|
-
|
14
|
-
const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../dom/manipulator.js'), require('./index.js')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['../dom/manipulator', './index'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Config = factory(global.Manipulator, global.Index));
|
10
|
+
})(this, (function (Manipulator, index_js) { 'use strict';
|
15
11
|
|
16
12
|
/**
|
17
13
|
* --------------------------------------------------------------------------
|
18
|
-
* Bootstrap
|
14
|
+
* Bootstrap util/config.js
|
19
15
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
20
16
|
* --------------------------------------------------------------------------
|
21
17
|
*/
|
18
|
+
|
19
|
+
|
22
20
|
/**
|
23
21
|
* Class definition
|
24
22
|
*/
|
@@ -28,50 +26,40 @@
|
|
28
26
|
static get Default() {
|
29
27
|
return {};
|
30
28
|
}
|
31
|
-
|
32
29
|
static get DefaultType() {
|
33
30
|
return {};
|
34
31
|
}
|
35
|
-
|
36
32
|
static get NAME() {
|
37
33
|
throw new Error('You have to implement the static method "NAME", for each component!');
|
38
34
|
}
|
39
|
-
|
40
35
|
_getConfig(config) {
|
41
36
|
config = this._mergeConfigObj(config);
|
42
37
|
config = this._configAfterMerge(config);
|
43
|
-
|
44
38
|
this._typeCheckConfig(config);
|
45
|
-
|
46
39
|
return config;
|
47
40
|
}
|
48
|
-
|
49
41
|
_configAfterMerge(config) {
|
50
42
|
return config;
|
51
43
|
}
|
52
|
-
|
53
44
|
_mergeConfigObj(config, element) {
|
54
|
-
const jsonConfig =
|
45
|
+
const jsonConfig = index_js.isElement(element) ? Manipulator.getDataAttribute(element, 'config') : {}; // try to parse
|
55
46
|
|
56
|
-
return {
|
47
|
+
return {
|
48
|
+
...this.constructor.Default,
|
57
49
|
...(typeof jsonConfig === 'object' ? jsonConfig : {}),
|
58
|
-
...(
|
50
|
+
...(index_js.isElement(element) ? Manipulator.getDataAttributes(element) : {}),
|
59
51
|
...(typeof config === 'object' ? config : {})
|
60
52
|
};
|
61
53
|
}
|
62
|
-
|
63
54
|
_typeCheckConfig(config, configTypes = this.constructor.DefaultType) {
|
64
|
-
for (const property of Object.
|
65
|
-
const expectedTypes = configTypes[property];
|
55
|
+
for (const [property, expectedTypes] of Object.entries(configTypes)) {
|
66
56
|
const value = config[property];
|
67
|
-
const valueType =
|
68
|
-
|
57
|
+
const valueType = index_js.isElement(value) ? 'element' : index_js.toType(value);
|
69
58
|
if (!new RegExp(expectedTypes).test(valueType)) {
|
70
59
|
throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
|
71
60
|
}
|
72
61
|
}
|
73
62
|
}
|
74
|
-
|
75
63
|
}
|
76
64
|
|
77
65
|
return Config;
|
@@ -1,26 +1,22 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap focustrap.js v5.
|
3
|
-
* Copyright 2011-
|
2
|
+
* Bootstrap focustrap.js v5.3.0 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
4
4
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
5
|
*/
|
6
6
|
(function (global, factory) {
|
7
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../dom/event-handler'), require('../dom/selector-engine'), require('./config')) :
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../dom/event-handler.js'), require('../dom/selector-engine.js'), require('./config.js')) :
|
8
8
|
typeof define === 'function' && define.amd ? define(['../dom/event-handler', '../dom/selector-engine', './config'], factory) :
|
9
9
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Focustrap = factory(global.EventHandler, global.SelectorEngine, global.Config));
|
10
10
|
})(this, (function (EventHandler, SelectorEngine, Config) { 'use strict';
|
11
11
|
|
12
|
-
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
13
|
-
|
14
|
-
const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
|
15
|
-
const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
|
16
|
-
const Config__default = /*#__PURE__*/_interopDefaultLegacy(Config);
|
17
|
-
|
18
12
|
/**
|
19
13
|
* --------------------------------------------------------------------------
|
20
|
-
* Bootstrap
|
14
|
+
* Bootstrap util/focustrap.js
|
21
15
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
22
16
|
* --------------------------------------------------------------------------
|
23
17
|
*/
|
18
|
+
|
19
|
+
|
24
20
|
/**
|
25
21
|
* Constants
|
26
22
|
*/
|
@@ -36,75 +32,66 @@
|
|
36
32
|
const Default = {
|
37
33
|
autofocus: true,
|
38
34
|
trapElement: null // The element to trap focus inside of
|
39
|
-
|
40
35
|
};
|
36
|
+
|
41
37
|
const DefaultType = {
|
42
38
|
autofocus: 'boolean',
|
43
39
|
trapElement: 'element'
|
44
40
|
};
|
41
|
+
|
45
42
|
/**
|
46
43
|
* Class definition
|
47
44
|
*/
|
48
45
|
|
49
|
-
class FocusTrap extends
|
46
|
+
class FocusTrap extends Config {
|
50
47
|
constructor(config) {
|
51
48
|
super();
|
52
49
|
this._config = this._getConfig(config);
|
53
50
|
this._isActive = false;
|
54
51
|
this._lastTabNavDirection = null;
|
55
|
-
}
|
56
|
-
|
52
|
+
}
|
57
53
|
|
54
|
+
// Getters
|
58
55
|
static get Default() {
|
59
56
|
return Default;
|
60
57
|
}
|
61
|
-
|
62
58
|
static get DefaultType() {
|
63
59
|
return DefaultType;
|
64
60
|
}
|
65
|
-
|
66
61
|
static get NAME() {
|
67
62
|
return NAME;
|
68
|
-
}
|
69
|
-
|
63
|
+
}
|
70
64
|
|
65
|
+
// Public
|
71
66
|
activate() {
|
72
67
|
if (this._isActive) {
|
73
68
|
return;
|
74
69
|
}
|
75
|
-
|
76
70
|
if (this._config.autofocus) {
|
77
71
|
this._config.trapElement.focus();
|
78
72
|
}
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
EventHandler__default.default.on(document, EVENT_FOCUSIN, event => this._handleFocusin(event));
|
83
|
-
EventHandler__default.default.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event));
|
73
|
+
EventHandler.off(document, EVENT_KEY); // guard against infinite focus loop
|
74
|
+
EventHandler.on(document, EVENT_FOCUSIN, event => this._handleFocusin(event));
|
75
|
+
EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event));
|
84
76
|
this._isActive = true;
|
85
77
|
}
|
86
|
-
|
87
78
|
deactivate() {
|
88
79
|
if (!this._isActive) {
|
89
80
|
return;
|
90
81
|
}
|
91
|
-
|
92
82
|
this._isActive = false;
|
93
|
-
|
94
|
-
}
|
95
|
-
|
83
|
+
EventHandler.off(document, EVENT_KEY);
|
84
|
+
}
|
96
85
|
|
86
|
+
// Private
|
97
87
|
_handleFocusin(event) {
|
98
88
|
const {
|
99
89
|
trapElement
|
100
90
|
} = this._config;
|
101
|
-
|
102
91
|
if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) {
|
103
92
|
return;
|
104
93
|
}
|
105
|
-
|
106
|
-
const elements = SelectorEngine__default.default.focusableChildren(trapElement);
|
107
|
-
|
94
|
+
const elements = SelectorEngine.focusableChildren(trapElement);
|
108
95
|
if (elements.length === 0) {
|
109
96
|
trapElement.focus();
|
110
97
|
} else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
|
@@ -113,15 +100,12 @@
|
|
113
100
|
elements[0].focus();
|
114
101
|
}
|
115
102
|
}
|
116
|
-
|
117
103
|
_handleKeydown(event) {
|
118
104
|
if (event.key !== TAB_KEY) {
|
119
105
|
return;
|
120
106
|
}
|
121
|
-
|
122
107
|
this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD;
|
123
108
|
}
|
124
|
-
|
125
109
|
}
|
126
110
|
|
127
111
|
return FocusTrap;
|