bootstrap 4.3.1 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +55 -0
  3. data/CHANGELOG.md +2 -14
  4. data/README.md +28 -5
  5. data/assets/javascripts/bootstrap/alert.js +54 -163
  6. data/assets/javascripts/bootstrap/base-component.js +83 -0
  7. data/assets/javascripts/bootstrap/button.js +44 -152
  8. data/assets/javascripts/bootstrap/carousel.js +289 -569
  9. data/assets/javascripts/bootstrap/collapse.js +170 -349
  10. data/assets/javascripts/bootstrap/dom/data.js +62 -0
  11. data/assets/javascripts/bootstrap/dom/event-handler.js +236 -0
  12. data/assets/javascripts/bootstrap/dom/manipulator.js +71 -0
  13. data/assets/javascripts/bootstrap/dom/selector-engine.js +103 -0
  14. data/assets/javascripts/bootstrap/dropdown.js +303 -496
  15. data/assets/javascripts/bootstrap/modal.js +229 -559
  16. data/assets/javascripts/bootstrap/offcanvas.js +245 -0
  17. data/assets/javascripts/bootstrap/popover.js +61 -226
  18. data/assets/javascripts/bootstrap/scrollspy.js +217 -317
  19. data/assets/javascripts/bootstrap/tab.js +220 -212
  20. data/assets/javascripts/bootstrap/toast.js +145 -229
  21. data/assets/javascripts/bootstrap/tooltip.js +421 -782
  22. data/assets/javascripts/bootstrap/util/backdrop.js +139 -0
  23. data/assets/javascripts/bootstrap/util/component-functions.js +41 -0
  24. data/assets/javascripts/bootstrap/util/config.js +67 -0
  25. data/assets/javascripts/bootstrap/util/focustrap.js +113 -0
  26. data/assets/javascripts/bootstrap/util/index.js +281 -0
  27. data/assets/javascripts/bootstrap/util/sanitizer.js +110 -0
  28. data/assets/javascripts/bootstrap/util/scrollbar.js +112 -0
  29. data/assets/javascripts/bootstrap/util/swipe.js +134 -0
  30. data/assets/javascripts/bootstrap/util/template-factory.js +150 -0
  31. data/assets/javascripts/bootstrap-global-this-define.js +6 -0
  32. data/assets/javascripts/bootstrap-global-this-undefine.js +2 -0
  33. data/assets/javascripts/bootstrap-sprockets.js +23 -7
  34. data/assets/javascripts/bootstrap.js +3690 -3639
  35. data/assets/javascripts/bootstrap.min.js +4 -4
  36. data/assets/stylesheets/_bootstrap-grid.scss +53 -20
  37. data/assets/stylesheets/_bootstrap-reboot.scss +5 -7
  38. data/assets/stylesheets/_bootstrap.scss +21 -13
  39. data/assets/stylesheets/bootstrap/_accordion.scss +158 -0
  40. data/assets/stylesheets/bootstrap/_alert.scss +32 -15
  41. data/assets/stylesheets/bootstrap/_badge.scss +15 -31
  42. data/assets/stylesheets/bootstrap/_breadcrumb.scss +23 -24
  43. data/assets/stylesheets/bootstrap/_button-group.scss +27 -48
  44. data/assets/stylesheets/bootstrap/_buttons.scss +139 -69
  45. data/assets/stylesheets/bootstrap/_card.scss +91 -141
  46. data/assets/stylesheets/bootstrap/_carousel.scss +86 -39
  47. data/assets/stylesheets/bootstrap/_close.scss +51 -29
  48. data/assets/stylesheets/bootstrap/_containers.scss +41 -0
  49. data/assets/stylesheets/bootstrap/_dropdown.scss +131 -72
  50. data/assets/stylesheets/bootstrap/_forms.scss +9 -330
  51. data/assets/stylesheets/bootstrap/_functions.scss +244 -28
  52. data/assets/stylesheets/bootstrap/_grid.scss +18 -31
  53. data/assets/stylesheets/bootstrap/_helpers.scss +12 -0
  54. data/assets/stylesheets/bootstrap/_images.scss +3 -3
  55. data/assets/stylesheets/bootstrap/_list-group.scss +101 -53
  56. data/assets/stylesheets/bootstrap/_maps.scss +174 -0
  57. data/assets/stylesheets/bootstrap/_mixins.scss +13 -18
  58. data/assets/stylesheets/bootstrap/_modal.scss +120 -112
  59. data/assets/stylesheets/bootstrap/_nav.scss +113 -24
  60. data/assets/stylesheets/bootstrap/_navbar.scss +145 -150
  61. data/assets/stylesheets/bootstrap/_offcanvas.scss +146 -0
  62. data/assets/stylesheets/bootstrap/_pagination.scss +74 -38
  63. data/assets/stylesheets/bootstrap/_placeholders.scss +51 -0
  64. data/assets/stylesheets/bootstrap/_popover.scss +99 -74
  65. data/assets/stylesheets/bootstrap/_progress.scss +40 -15
  66. data/assets/stylesheets/bootstrap/_reboot.scss +342 -215
  67. data/assets/stylesheets/bootstrap/_root.scss +174 -9
  68. data/assets/stylesheets/bootstrap/_spinners.scss +52 -22
  69. data/assets/stylesheets/bootstrap/_tables.scss +101 -115
  70. data/assets/stylesheets/bootstrap/_toasts.scss +54 -25
  71. data/assets/stylesheets/bootstrap/_tooltip.scss +67 -63
  72. data/assets/stylesheets/bootstrap/_transitions.scss +8 -1
  73. data/assets/stylesheets/bootstrap/_type.scss +42 -61
  74. data/assets/stylesheets/bootstrap/_utilities.scss +806 -17
  75. data/assets/stylesheets/bootstrap/_variables-dark.scss +85 -0
  76. data/assets/stylesheets/bootstrap/_variables.scss +1235 -615
  77. data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +19 -0
  78. data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +94 -0
  79. data/assets/stylesheets/bootstrap/forms/_form-check.scss +188 -0
  80. data/assets/stylesheets/bootstrap/forms/_form-control.scss +214 -0
  81. data/assets/stylesheets/bootstrap/forms/_form-range.scss +91 -0
  82. data/assets/stylesheets/bootstrap/forms/_form-select.scss +80 -0
  83. data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
  84. data/assets/stylesheets/bootstrap/forms/_input-group.scss +132 -0
  85. data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
  86. data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
  87. data/assets/stylesheets/bootstrap/helpers/_color-bg.scss +8 -0
  88. data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +30 -0
  89. data/assets/stylesheets/bootstrap/helpers/_focus-ring.scss +5 -0
  90. data/assets/stylesheets/bootstrap/helpers/_icon-link.scss +25 -0
  91. data/assets/stylesheets/bootstrap/helpers/_position.scss +36 -0
  92. data/assets/stylesheets/bootstrap/helpers/_ratio.scss +26 -0
  93. data/assets/stylesheets/bootstrap/helpers/_stacks.scss +15 -0
  94. data/assets/stylesheets/bootstrap/helpers/_stretched-link.scss +15 -0
  95. data/assets/stylesheets/bootstrap/helpers/_text-truncation.scss +7 -0
  96. data/assets/stylesheets/bootstrap/helpers/_visually-hidden.scss +8 -0
  97. data/assets/stylesheets/bootstrap/helpers/_vr.scss +8 -0
  98. data/assets/stylesheets/bootstrap/mixins/_alert.scss +11 -6
  99. data/assets/stylesheets/bootstrap/mixins/_backdrop.scss +14 -0
  100. data/assets/stylesheets/bootstrap/mixins/_banner.scss +7 -0
  101. data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +37 -22
  102. data/assets/stylesheets/bootstrap/mixins/_box-shadow.scss +7 -9
  103. data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +20 -16
  104. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +60 -97
  105. data/assets/stylesheets/bootstrap/mixins/_caret.scss +34 -27
  106. data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +2 -0
  107. data/assets/stylesheets/bootstrap/mixins/_color-mode.scss +21 -0
  108. data/assets/stylesheets/bootstrap/mixins/_color-scheme.scss +7 -0
  109. data/assets/stylesheets/bootstrap/mixins/_container.scss +11 -0
  110. data/assets/stylesheets/bootstrap/mixins/_forms.scss +77 -116
  111. data/assets/stylesheets/bootstrap/mixins/_gradients.scss +13 -11
  112. data/assets/stylesheets/bootstrap/mixins/_grid.scss +133 -33
  113. data/assets/stylesheets/bootstrap/mixins/_image.scss +0 -20
  114. data/assets/stylesheets/bootstrap/mixins/_list-group.scss +7 -2
  115. data/assets/stylesheets/bootstrap/mixins/_pagination.scss +7 -19
  116. data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +2 -2
  117. data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +24 -0
  118. data/assets/stylesheets/bootstrap/mixins/_transition.scss +18 -8
  119. data/assets/stylesheets/bootstrap/mixins/_utilities.scss +97 -0
  120. data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +33 -0
  121. data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
  122. data/assets/stylesheets/bootstrap/vendor/_rfs.scss +276 -132
  123. data/bootstrap.gemspec +4 -6
  124. data/lib/bootstrap/version.rb +2 -2
  125. data/tasks/updater/js.rb +31 -7
  126. data/tasks/updater/network.rb +10 -4
  127. data/tasks/updater/scss.rb +1 -1
  128. data/tasks/updater.rb +2 -2
  129. data/test/dummy_rails/app/assets/config/manifest.js +3 -0
  130. data/test/dummy_rails/app/assets/javascripts/application.js +4 -3
  131. data/test/dummy_rails/app/assets/stylesheets/.browserslistrc +1 -0
  132. data/test/dummy_rails/app/views/layouts/application.html.erb +3 -1
  133. data/test/dummy_rails/app/views/pages/root.html +89 -0
  134. data/test/dummy_rails/config/application.rb +0 -3
  135. data/test/gemfiles/rails_5_2.gemfile +8 -0
  136. data/test/gemfiles/rails_6_0.gemfile +7 -0
  137. data/test/gemfiles/rails_6_1.gemfile +7 -0
  138. data/test/gemfiles/rails_7_0.gemfile +7 -0
  139. data/test/support/dummy_rails_integration.rb +3 -1
  140. data/test/test_helper.rb +18 -12
  141. metadata +86 -84
  142. data/.travis.yml +0 -17
  143. data/assets/javascripts/bootstrap/util.js +0 -171
  144. data/assets/stylesheets/bootstrap/_code.scss +0 -48
  145. data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -507
  146. data/assets/stylesheets/bootstrap/_input-group.scss +0 -193
  147. data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -17
  148. data/assets/stylesheets/bootstrap/_media.scss +0 -8
  149. data/assets/stylesheets/bootstrap/_print.scss +0 -141
  150. data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +0 -21
  151. data/assets/stylesheets/bootstrap/mixins/_badge.scss +0 -17
  152. data/assets/stylesheets/bootstrap/mixins/_float.scss +0 -14
  153. data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +0 -66
  154. data/assets/stylesheets/bootstrap/mixins/_hover.scss +0 -37
  155. data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -10
  156. data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +0 -33
  157. data/assets/stylesheets/bootstrap/mixins/_size.scss +0 -7
  158. data/assets/stylesheets/bootstrap/mixins/_table-row.scss +0 -39
  159. data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +0 -16
  160. data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +0 -11
  161. data/assets/stylesheets/bootstrap/mixins/_visibility.scss +0 -8
  162. data/assets/stylesheets/bootstrap/utilities/_align.scss +0 -8
  163. data/assets/stylesheets/bootstrap/utilities/_background.scss +0 -19
  164. data/assets/stylesheets/bootstrap/utilities/_borders.scss +0 -75
  165. data/assets/stylesheets/bootstrap/utilities/_display.scss +0 -26
  166. data/assets/stylesheets/bootstrap/utilities/_embed.scss +0 -39
  167. data/assets/stylesheets/bootstrap/utilities/_flex.scss +0 -51
  168. data/assets/stylesheets/bootstrap/utilities/_float.scss +0 -11
  169. data/assets/stylesheets/bootstrap/utilities/_overflow.scss +0 -5
  170. data/assets/stylesheets/bootstrap/utilities/_position.scss +0 -32
  171. data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +0 -11
  172. data/assets/stylesheets/bootstrap/utilities/_shadows.scss +0 -6
  173. data/assets/stylesheets/bootstrap/utilities/_sizing.scss +0 -20
  174. data/assets/stylesheets/bootstrap/utilities/_spacing.scss +0 -73
  175. data/assets/stylesheets/bootstrap/utilities/_stretched-link.scss +0 -19
  176. data/assets/stylesheets/bootstrap/utilities/_text.scss +0 -72
  177. data/assets/stylesheets/bootstrap/utilities/_visibility.scss +0 -13
  178. data/test/dummy_rails/app/views/pages/root.html.slim +0 -58
  179. /data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
@@ -1,905 +1,544 @@
1
1
  /*!
2
- * Bootstrap tooltip.js v4.3.1 (https://getbootstrap.com/)
3
- * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
2
+ * Bootstrap tooltip.js v5.3.0 (https://getbootstrap.com/)
3
+ * Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
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('jquery'), require('popper.js'), require('./util.js')) :
8
- typeof define === 'function' && define.amd ? define(['jquery', 'popper.js', './util.js'], factory) :
9
- (global = global || self, global.Tooltip = factory(global.jQuery, global.Popper, global.Util));
10
- }(this, function ($, Popper, Util) { 'use strict';
11
-
12
- $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
13
- Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
14
- Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
15
-
16
- function _defineProperties(target, props) {
17
- for (var i = 0; i < props.length; i++) {
18
- var descriptor = props[i];
19
- descriptor.enumerable = descriptor.enumerable || false;
20
- descriptor.configurable = true;
21
- if ("value" in descriptor) descriptor.writable = true;
22
- Object.defineProperty(target, descriptor.key, descriptor);
23
- }
24
- }
25
-
26
- function _createClass(Constructor, protoProps, staticProps) {
27
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
28
- if (staticProps) _defineProperties(Constructor, staticProps);
29
- return Constructor;
30
- }
31
-
32
- function _defineProperty(obj, key, value) {
33
- if (key in obj) {
34
- Object.defineProperty(obj, key, {
35
- value: value,
36
- enumerable: true,
37
- configurable: true,
38
- writable: true
39
- });
40
- } else {
41
- obj[key] = value;
42
- }
43
-
44
- return obj;
45
- }
46
-
47
- function _objectSpread(target) {
48
- for (var i = 1; i < arguments.length; i++) {
49
- var source = arguments[i] != null ? arguments[i] : {};
50
- var ownKeys = Object.keys(source);
51
-
52
- if (typeof Object.getOwnPropertySymbols === 'function') {
53
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
54
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
55
- }));
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core'), require('./base-component.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./util/index.js'), require('./util/sanitizer.js'), require('./util/template-factory.js')) :
8
+ typeof define === 'function' && define.amd ? define(['@popperjs/core', './base-component', './dom/event-handler', './dom/manipulator', './util/index', './util/sanitizer', './util/template-factory'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tooltip = factory(global["@popperjs/core"], global.BaseComponent, global.EventHandler, global.Manipulator, global.Index, global.Sanitizer, global.TemplateFactory));
10
+ })(this, (function (Popper, BaseComponent, EventHandler, Manipulator, index_js, sanitizer_js, TemplateFactory) { 'use strict';
11
+
12
+ function _interopNamespaceDefault(e) {
13
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
14
+ if (e) {
15
+ for (const k in e) {
16
+ if (k !== 'default') {
17
+ const d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: () => e[k]
21
+ });
22
+ }
56
23
  }
57
-
58
- ownKeys.forEach(function (key) {
59
- _defineProperty(target, key, source[key]);
60
- });
61
24
  }
62
-
63
- return target;
25
+ n.default = e;
26
+ return Object.freeze(n);
64
27
  }
65
28
 
29
+ const Popper__namespace = /*#__PURE__*/_interopNamespaceDefault(Popper);
30
+
66
31
  /**
67
32
  * --------------------------------------------------------------------------
68
- * Bootstrap (v4.3.1): tools/sanitizer.js
69
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
33
+ * Bootstrap tooltip.js
34
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
70
35
  * --------------------------------------------------------------------------
71
36
  */
72
- var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
73
- var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
74
- var DefaultWhitelist = {
75
- // Global attributes allowed on any supplied element below.
76
- '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
77
- a: ['target', 'href', 'title', 'rel'],
78
- area: [],
79
- b: [],
80
- br: [],
81
- col: [],
82
- code: [],
83
- div: [],
84
- em: [],
85
- hr: [],
86
- h1: [],
87
- h2: [],
88
- h3: [],
89
- h4: [],
90
- h5: [],
91
- h6: [],
92
- i: [],
93
- img: ['src', 'alt', 'title', 'width', 'height'],
94
- li: [],
95
- ol: [],
96
- p: [],
97
- pre: [],
98
- s: [],
99
- small: [],
100
- span: [],
101
- sub: [],
102
- sup: [],
103
- strong: [],
104
- u: [],
105
- ul: []
106
- /**
107
- * A pattern that recognizes a commonly useful subset of URLs that are safe.
108
- *
109
- * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
110
- */
111
37
 
112
- };
113
- var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
114
- /**
115
- * A pattern that matches safe data URLs. Only matches image, video and audio types.
116
- *
117
- * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
118
- */
119
-
120
- var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;
121
-
122
- function allowedAttribute(attr, allowedAttributeList) {
123
- var attrName = attr.nodeName.toLowerCase();
124
-
125
- if (allowedAttributeList.indexOf(attrName) !== -1) {
126
- if (uriAttrs.indexOf(attrName) !== -1) {
127
- return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
128
- }
129
-
130
- return true;
131
- }
132
-
133
- var regExp = allowedAttributeList.filter(function (attrRegex) {
134
- return attrRegex instanceof RegExp;
135
- }); // Check if a regular expression validates the attribute.
136
-
137
- for (var i = 0, l = regExp.length; i < l; i++) {
138
- if (attrName.match(regExp[i])) {
139
- return true;
140
- }
141
- }
142
-
143
- return false;
144
- }
145
-
146
- function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
147
- if (unsafeHtml.length === 0) {
148
- return unsafeHtml;
149
- }
150
-
151
- if (sanitizeFn && typeof sanitizeFn === 'function') {
152
- return sanitizeFn(unsafeHtml);
153
- }
154
-
155
- var domParser = new window.DOMParser();
156
- var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
157
- var whitelistKeys = Object.keys(whiteList);
158
- var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
159
-
160
- var _loop = function _loop(i, len) {
161
- var el = elements[i];
162
- var elName = el.nodeName.toLowerCase();
163
-
164
- if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
165
- el.parentNode.removeChild(el);
166
- return "continue";
167
- }
168
-
169
- var attributeList = [].slice.call(el.attributes);
170
- var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
171
- attributeList.forEach(function (attr) {
172
- if (!allowedAttribute(attr, whitelistedAttributes)) {
173
- el.removeAttribute(attr.nodeName);
174
- }
175
- });
176
- };
177
-
178
- for (var i = 0, len = elements.length; i < len; i++) {
179
- var _ret = _loop(i, len);
180
-
181
- if (_ret === "continue") continue;
182
- }
183
-
184
- return createdDocument.body.innerHTML;
185
- }
186
38
 
187
39
  /**
188
- * ------------------------------------------------------------------------
189
40
  * Constants
190
- * ------------------------------------------------------------------------
191
41
  */
192
42
 
193
- var NAME = 'tooltip';
194
- var VERSION = '4.3.1';
195
- var DATA_KEY = 'bs.tooltip';
196
- var EVENT_KEY = "." + DATA_KEY;
197
- var JQUERY_NO_CONFLICT = $.fn[NAME];
198
- var CLASS_PREFIX = 'bs-tooltip';
199
- var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
200
- var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
201
- var DefaultType = {
202
- animation: 'boolean',
203
- template: 'string',
204
- title: '(string|element|function)',
205
- trigger: 'string',
206
- delay: '(number|object)',
207
- html: 'boolean',
208
- selector: '(string|boolean)',
209
- placement: '(string|function)',
210
- offset: '(number|string|function)',
211
- container: '(string|element|boolean)',
212
- fallbackPlacement: '(string|array)',
213
- boundary: '(string|element)',
214
- sanitize: 'boolean',
215
- sanitizeFn: '(null|function)',
216
- whiteList: 'object'
217
- };
218
- var AttachmentMap = {
43
+ const NAME = 'tooltip';
44
+ const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
45
+ const CLASS_NAME_FADE = 'fade';
46
+ const CLASS_NAME_MODAL = 'modal';
47
+ const CLASS_NAME_SHOW = 'show';
48
+ const SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
49
+ const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
50
+ const EVENT_MODAL_HIDE = 'hide.bs.modal';
51
+ const TRIGGER_HOVER = 'hover';
52
+ const TRIGGER_FOCUS = 'focus';
53
+ const TRIGGER_CLICK = 'click';
54
+ const TRIGGER_MANUAL = 'manual';
55
+ const EVENT_HIDE = 'hide';
56
+ const EVENT_HIDDEN = 'hidden';
57
+ const EVENT_SHOW = 'show';
58
+ const EVENT_SHOWN = 'shown';
59
+ const EVENT_INSERTED = 'inserted';
60
+ const EVENT_CLICK = 'click';
61
+ const EVENT_FOCUSIN = 'focusin';
62
+ const EVENT_FOCUSOUT = 'focusout';
63
+ const EVENT_MOUSEENTER = 'mouseenter';
64
+ const EVENT_MOUSELEAVE = 'mouseleave';
65
+ const AttachmentMap = {
219
66
  AUTO: 'auto',
220
67
  TOP: 'top',
221
- RIGHT: 'right',
68
+ RIGHT: index_js.isRTL() ? 'left' : 'right',
222
69
  BOTTOM: 'bottom',
223
- LEFT: 'left'
70
+ LEFT: index_js.isRTL() ? 'right' : 'left'
224
71
  };
225
- var Default = {
72
+ const Default = {
73
+ allowList: sanitizer_js.DefaultAllowlist,
226
74
  animation: true,
227
- template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
228
- trigger: 'hover focus',
229
- title: '',
75
+ boundary: 'clippingParents',
76
+ container: false,
77
+ customClass: '',
230
78
  delay: 0,
79
+ fallbackPlacements: ['top', 'right', 'bottom', 'left'],
231
80
  html: false,
232
- selector: false,
81
+ offset: [0, 6],
233
82
  placement: 'top',
234
- offset: 0,
235
- container: false,
236
- fallbackPlacement: 'flip',
237
- boundary: 'scrollParent',
83
+ popperConfig: null,
238
84
  sanitize: true,
239
85
  sanitizeFn: null,
240
- whiteList: DefaultWhitelist
241
- };
242
- var HoverState = {
243
- SHOW: 'show',
244
- OUT: 'out'
245
- };
246
- var Event = {
247
- HIDE: "hide" + EVENT_KEY,
248
- HIDDEN: "hidden" + EVENT_KEY,
249
- SHOW: "show" + EVENT_KEY,
250
- SHOWN: "shown" + EVENT_KEY,
251
- INSERTED: "inserted" + EVENT_KEY,
252
- CLICK: "click" + EVENT_KEY,
253
- FOCUSIN: "focusin" + EVENT_KEY,
254
- FOCUSOUT: "focusout" + EVENT_KEY,
255
- MOUSEENTER: "mouseenter" + EVENT_KEY,
256
- MOUSELEAVE: "mouseleave" + EVENT_KEY
257
- };
258
- var ClassName = {
259
- FADE: 'fade',
260
- SHOW: 'show'
261
- };
262
- var Selector = {
263
- TOOLTIP: '.tooltip',
264
- TOOLTIP_INNER: '.tooltip-inner',
265
- ARROW: '.arrow'
86
+ selector: false,
87
+ template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>',
88
+ title: '',
89
+ trigger: 'hover focus'
266
90
  };
267
- var Trigger = {
268
- HOVER: 'hover',
269
- FOCUS: 'focus',
270
- CLICK: 'click',
271
- MANUAL: 'manual'
272
- /**
273
- * ------------------------------------------------------------------------
274
- * Class Definition
275
- * ------------------------------------------------------------------------
276
- */
277
-
91
+ const DefaultType = {
92
+ allowList: 'object',
93
+ animation: 'boolean',
94
+ boundary: '(string|element)',
95
+ container: '(string|element|boolean)',
96
+ customClass: '(string|function)',
97
+ delay: '(number|object)',
98
+ fallbackPlacements: 'array',
99
+ html: 'boolean',
100
+ offset: '(array|string|function)',
101
+ placement: '(string|function)',
102
+ popperConfig: '(null|object|function)',
103
+ sanitize: 'boolean',
104
+ sanitizeFn: '(null|function)',
105
+ selector: '(string|boolean)',
106
+ template: 'string',
107
+ title: '(string|element|function)',
108
+ trigger: 'string'
278
109
  };
279
110
 
280
- var Tooltip =
281
- /*#__PURE__*/
282
- function () {
283
- function Tooltip(element, config) {
284
- /**
285
- * Check for Popper dependency
286
- * Popper - https://popper.js.org
287
- */
288
- if (typeof Popper === 'undefined') {
289
- throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
290
- } // private
111
+ /**
112
+ * Class definition
113
+ */
291
114
 
115
+ class Tooltip extends BaseComponent {
116
+ constructor(element, config) {
117
+ if (typeof Popper__namespace === 'undefined') {
118
+ throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
119
+ }
120
+ super(element, config);
292
121
 
122
+ // Private
293
123
  this._isEnabled = true;
294
124
  this._timeout = 0;
295
- this._hoverState = '';
125
+ this._isHovered = null;
296
126
  this._activeTrigger = {};
297
- this._popper = null; // Protected
127
+ this._popper = null;
128
+ this._templateFactory = null;
129
+ this._newContent = null;
298
130
 
299
- this.element = element;
300
- this.config = this._getConfig(config);
131
+ // Protected
301
132
  this.tip = null;
302
-
303
133
  this._setListeners();
304
- } // Getters
305
-
134
+ if (!this._config.selector) {
135
+ this._fixTitle();
136
+ }
137
+ }
306
138
 
307
- var _proto = Tooltip.prototype;
139
+ // Getters
140
+ static get Default() {
141
+ return Default;
142
+ }
143
+ static get DefaultType() {
144
+ return DefaultType;
145
+ }
146
+ static get NAME() {
147
+ return NAME;
148
+ }
308
149
 
309
150
  // Public
310
- _proto.enable = function enable() {
151
+ enable() {
311
152
  this._isEnabled = true;
312
- };
313
-
314
- _proto.disable = function disable() {
153
+ }
154
+ disable() {
315
155
  this._isEnabled = false;
316
- };
317
-
318
- _proto.toggleEnabled = function toggleEnabled() {
156
+ }
157
+ toggleEnabled() {
319
158
  this._isEnabled = !this._isEnabled;
320
- };
321
-
322
- _proto.toggle = function toggle(event) {
159
+ }
160
+ toggle() {
323
161
  if (!this._isEnabled) {
324
162
  return;
325
163
  }
326
-
327
- if (event) {
328
- var dataKey = this.constructor.DATA_KEY;
329
- var context = $(event.currentTarget).data(dataKey);
330
-
331
- if (!context) {
332
- context = new this.constructor(event.currentTarget, this._getDelegateConfig());
333
- $(event.currentTarget).data(dataKey, context);
334
- }
335
-
336
- context._activeTrigger.click = !context._activeTrigger.click;
337
-
338
- if (context._isWithActiveTrigger()) {
339
- context._enter(null, context);
340
- } else {
341
- context._leave(null, context);
342
- }
343
- } else {
344
- if ($(this.getTipElement()).hasClass(ClassName.SHOW)) {
345
- this._leave(null, this);
346
-
347
- return;
348
- }
349
-
350
- this._enter(null, this);
164
+ this._activeTrigger.click = !this._activeTrigger.click;
165
+ if (this._isShown()) {
166
+ this._leave();
167
+ return;
351
168
  }
352
- };
353
-
354
- _proto.dispose = function dispose() {
169
+ this._enter();
170
+ }
171
+ dispose() {
355
172
  clearTimeout(this._timeout);
356
- $.removeData(this.element, this.constructor.DATA_KEY);
357
- $(this.element).off(this.constructor.EVENT_KEY);
358
- $(this.element).closest('.modal').off('hide.bs.modal');
359
-
360
- if (this.tip) {
361
- $(this.tip).remove();
362
- }
363
-
364
- this._isEnabled = null;
365
- this._timeout = null;
366
- this._hoverState = null;
367
- this._activeTrigger = null;
368
-
369
- if (this._popper !== null) {
370
- this._popper.destroy();
173
+ EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
174
+ if (this._element.getAttribute('data-bs-original-title')) {
175
+ this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title'));
371
176
  }
372
-
373
- this._popper = null;
374
- this.element = null;
375
- this.config = null;
376
- this.tip = null;
377
- };
378
-
379
- _proto.show = function show() {
380
- var _this = this;
381
-
382
- if ($(this.element).css('display') === 'none') {
177
+ this._disposePopper();
178
+ super.dispose();
179
+ }
180
+ show() {
181
+ if (this._element.style.display === 'none') {
383
182
  throw new Error('Please use show on visible elements');
384
183
  }
385
-
386
- var showEvent = $.Event(this.constructor.Event.SHOW);
387
-
388
- if (this.isWithContent() && this._isEnabled) {
389
- $(this.element).trigger(showEvent);
390
- var shadowRoot = Util.findShadowRoot(this.element);
391
- var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
392
-
393
- if (showEvent.isDefaultPrevented() || !isInTheDom) {
394
- return;
395
- }
396
-
397
- var tip = this.getTipElement();
398
- var tipId = Util.getUID(this.constructor.NAME);
399
- tip.setAttribute('id', tipId);
400
- this.element.setAttribute('aria-describedby', tipId);
401
- this.setContent();
402
-
403
- if (this.config.animation) {
404
- $(tip).addClass(ClassName.FADE);
405
- }
406
-
407
- var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
408
-
409
- var attachment = this._getAttachment(placement);
410
-
411
- this.addAttachmentClass(attachment);
412
-
413
- var container = this._getContainer();
414
-
415
- $(tip).data(this.constructor.DATA_KEY, this);
416
-
417
- if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
418
- $(tip).appendTo(container);
419
- }
420
-
421
- $(this.element).trigger(this.constructor.Event.INSERTED);
422
- this._popper = new Popper(this.element, tip, {
423
- placement: attachment,
424
- modifiers: {
425
- offset: this._getOffset(),
426
- flip: {
427
- behavior: this.config.fallbackPlacement
428
- },
429
- arrow: {
430
- element: Selector.ARROW
431
- },
432
- preventOverflow: {
433
- boundariesElement: this.config.boundary
434
- }
435
- },
436
- onCreate: function onCreate(data) {
437
- if (data.originalPlacement !== data.placement) {
438
- _this._handlePopperPlacementChange(data);
439
- }
440
- },
441
- onUpdate: function onUpdate(data) {
442
- return _this._handlePopperPlacementChange(data);
443
- }
444
- });
445
- $(tip).addClass(ClassName.SHOW); // If this is a touch-enabled device we add extra
446
- // empty mouseover listeners to the body's immediate children;
447
- // only needed because of broken event delegation on iOS
448
- // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
449
-
450
- if ('ontouchstart' in document.documentElement) {
451
- $(document.body).children().on('mouseover', null, $.noop);
452
- }
453
-
454
- var complete = function complete() {
455
- if (_this.config.animation) {
456
- _this._fixTransition();
457
- }
458
-
459
- var prevHoverState = _this._hoverState;
460
- _this._hoverState = null;
461
- $(_this.element).trigger(_this.constructor.Event.SHOWN);
462
-
463
- if (prevHoverState === HoverState.OUT) {
464
- _this._leave(null, _this);
465
- }
466
- };
467
-
468
- if ($(this.tip).hasClass(ClassName.FADE)) {
469
- var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
470
- $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
471
- } else {
472
- complete();
473
- }
184
+ if (!(this._isWithContent() && this._isEnabled)) {
185
+ return;
186
+ }
187
+ const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW));
188
+ const shadowRoot = index_js.findShadowRoot(this._element);
189
+ const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element);
190
+ if (showEvent.defaultPrevented || !isInTheDom) {
191
+ return;
474
192
  }
475
- };
476
-
477
- _proto.hide = function hide(callback) {
478
- var _this2 = this;
479
-
480
- var tip = this.getTipElement();
481
- var hideEvent = $.Event(this.constructor.Event.HIDE);
482
-
483
- var complete = function complete() {
484
- if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
485
- tip.parentNode.removeChild(tip);
486
- }
487
-
488
- _this2._cleanTipClass();
489
-
490
- _this2.element.removeAttribute('aria-describedby');
491
-
492
- $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
493
193
 
494
- if (_this2._popper !== null) {
495
- _this2._popper.destroy();
194
+ // TODO: v6 remove this or make it optional
195
+ this._disposePopper();
196
+ const tip = this._getTipElement();
197
+ this._element.setAttribute('aria-describedby', tip.getAttribute('id'));
198
+ const {
199
+ container
200
+ } = this._config;
201
+ if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
202
+ container.append(tip);
203
+ EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED));
204
+ }
205
+ this._popper = this._createPopper(tip);
206
+ tip.classList.add(CLASS_NAME_SHOW);
207
+
208
+ // If this is a touch-enabled device we add extra
209
+ // empty mouseover listeners to the body's immediate children;
210
+ // only needed because of broken event delegation on iOS
211
+ // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
212
+ if ('ontouchstart' in document.documentElement) {
213
+ for (const element of [].concat(...document.body.children)) {
214
+ EventHandler.on(element, 'mouseover', index_js.noop);
496
215
  }
497
-
498
- if (callback) {
499
- callback();
216
+ }
217
+ const complete = () => {
218
+ EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN));
219
+ if (this._isHovered === false) {
220
+ this._leave();
500
221
  }
222
+ this._isHovered = false;
501
223
  };
502
-
503
- $(this.element).trigger(hideEvent);
504
-
505
- if (hideEvent.isDefaultPrevented()) {
224
+ this._queueCallback(complete, this.tip, this._isAnimated());
225
+ }
226
+ hide() {
227
+ if (!this._isShown()) {
506
228
  return;
507
229
  }
230
+ const hideEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE));
231
+ if (hideEvent.defaultPrevented) {
232
+ return;
233
+ }
234
+ const tip = this._getTipElement();
235
+ tip.classList.remove(CLASS_NAME_SHOW);
508
236
 
509
- $(tip).removeClass(ClassName.SHOW); // If this is a touch-enabled device we remove the extra
237
+ // If this is a touch-enabled device we remove the extra
510
238
  // empty mouseover listeners we added for iOS support
511
-
512
239
  if ('ontouchstart' in document.documentElement) {
513
- $(document.body).children().off('mouseover', null, $.noop);
240
+ for (const element of [].concat(...document.body.children)) {
241
+ EventHandler.off(element, 'mouseover', index_js.noop);
242
+ }
514
243
  }
244
+ this._activeTrigger[TRIGGER_CLICK] = false;
245
+ this._activeTrigger[TRIGGER_FOCUS] = false;
246
+ this._activeTrigger[TRIGGER_HOVER] = false;
247
+ this._isHovered = null; // it is a trick to support manual triggering
515
248
 
516
- this._activeTrigger[Trigger.CLICK] = false;
517
- this._activeTrigger[Trigger.FOCUS] = false;
518
- this._activeTrigger[Trigger.HOVER] = false;
519
-
520
- if ($(this.tip).hasClass(ClassName.FADE)) {
521
- var transitionDuration = Util.getTransitionDurationFromElement(tip);
522
- $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
523
- } else {
524
- complete();
249
+ const complete = () => {
250
+ if (this._isWithActiveTrigger()) {
251
+ return;
252
+ }
253
+ if (!this._isHovered) {
254
+ this._disposePopper();
255
+ }
256
+ this._element.removeAttribute('aria-describedby');
257
+ EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN));
258
+ };
259
+ this._queueCallback(complete, this.tip, this._isAnimated());
260
+ }
261
+ update() {
262
+ if (this._popper) {
263
+ this._popper.update();
525
264
  }
265
+ }
526
266
 
527
- this._hoverState = '';
528
- };
529
-
530
- _proto.update = function update() {
531
- if (this._popper !== null) {
532
- this._popper.scheduleUpdate();
267
+ // Protected
268
+ _isWithContent() {
269
+ return Boolean(this._getTitle());
270
+ }
271
+ _getTipElement() {
272
+ if (!this.tip) {
273
+ this.tip = this._createTipElement(this._newContent || this._getContentForTemplate());
533
274
  }
534
- } // Protected
535
- ;
536
-
537
- _proto.isWithContent = function isWithContent() {
538
- return Boolean(this.getTitle());
539
- };
540
-
541
- _proto.addAttachmentClass = function addAttachmentClass(attachment) {
542
- $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
543
- };
544
-
545
- _proto.getTipElement = function getTipElement() {
546
- this.tip = this.tip || $(this.config.template)[0];
547
275
  return this.tip;
548
- };
549
-
550
- _proto.setContent = function setContent() {
551
- var tip = this.getTipElement();
552
- this.setElementContent($(tip.querySelectorAll(Selector.TOOLTIP_INNER)), this.getTitle());
553
- $(tip).removeClass(ClassName.FADE + " " + ClassName.SHOW);
554
- };
555
-
556
- _proto.setElementContent = function setElementContent($element, content) {
557
- if (typeof content === 'object' && (content.nodeType || content.jquery)) {
558
- // Content is a DOM node or a jQuery
559
- if (this.config.html) {
560
- if (!$(content).parent().is($element)) {
561
- $element.empty().append(content);
562
- }
563
- } else {
564
- $element.text($(content).text());
565
- }
566
-
567
- return;
276
+ }
277
+ _createTipElement(content) {
278
+ const tip = this._getTemplateFactory(content).toHtml();
279
+
280
+ // TODO: remove this check in v6
281
+ if (!tip) {
282
+ return null;
283
+ }
284
+ tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW);
285
+ // TODO: v6 the following can be achieved with CSS only
286
+ tip.classList.add(`bs-${this.constructor.NAME}-auto`);
287
+ const tipId = index_js.getUID(this.constructor.NAME).toString();
288
+ tip.setAttribute('id', tipId);
289
+ if (this._isAnimated()) {
290
+ tip.classList.add(CLASS_NAME_FADE);
291
+ }
292
+ return tip;
293
+ }
294
+ setContent(content) {
295
+ this._newContent = content;
296
+ if (this._isShown()) {
297
+ this._disposePopper();
298
+ this.show();
568
299
  }
569
-
570
- if (this.config.html) {
571
- if (this.config.sanitize) {
572
- content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
573
- }
574
-
575
- $element.html(content);
300
+ }
301
+ _getTemplateFactory(content) {
302
+ if (this._templateFactory) {
303
+ this._templateFactory.changeContent(content);
576
304
  } else {
577
- $element.text(content);
305
+ this._templateFactory = new TemplateFactory({
306
+ ...this._config,
307
+ // the `content` var has to be after `this._config`
308
+ // to override config.content in case of popover
309
+ content,
310
+ extraClass: this._resolvePossibleFunction(this._config.customClass)
311
+ });
578
312
  }
579
- };
580
-
581
- _proto.getTitle = function getTitle() {
582
- var title = this.element.getAttribute('data-original-title');
313
+ return this._templateFactory;
314
+ }
315
+ _getContentForTemplate() {
316
+ return {
317
+ [SELECTOR_TOOLTIP_INNER]: this._getTitle()
318
+ };
319
+ }
320
+ _getTitle() {
321
+ return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('data-bs-original-title');
322
+ }
583
323
 
584
- if (!title) {
585
- title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
324
+ // Private
325
+ _initializeOnDelegatedTarget(event) {
326
+ return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
327
+ }
328
+ _isAnimated() {
329
+ return this._config.animation || this.tip && this.tip.classList.contains(CLASS_NAME_FADE);
330
+ }
331
+ _isShown() {
332
+ return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW);
333
+ }
334
+ _createPopper(tip) {
335
+ const placement = index_js.execute(this._config.placement, [this, tip, this._element]);
336
+ const attachment = AttachmentMap[placement.toUpperCase()];
337
+ return Popper__namespace.createPopper(this._element, tip, this._getPopperConfig(attachment));
338
+ }
339
+ _getOffset() {
340
+ const {
341
+ offset
342
+ } = this._config;
343
+ if (typeof offset === 'string') {
344
+ return offset.split(',').map(value => Number.parseInt(value, 10));
586
345
  }
587
-
588
- return title;
589
- } // Private
590
- ;
591
-
592
- _proto._getOffset = function _getOffset() {
593
- var _this3 = this;
594
-
595
- var offset = {};
596
-
597
- if (typeof this.config.offset === 'function') {
598
- offset.fn = function (data) {
599
- data.offsets = _objectSpread({}, data.offsets, _this3.config.offset(data.offsets, _this3.element) || {});
600
- return data;
601
- };
602
- } else {
603
- offset.offset = this.config.offset;
346
+ if (typeof offset === 'function') {
347
+ return popperData => offset(popperData, this._element);
604
348
  }
605
-
606
349
  return offset;
607
- };
608
-
609
- _proto._getContainer = function _getContainer() {
610
- if (this.config.container === false) {
611
- return document.body;
612
- }
613
-
614
- if (Util.isElement(this.config.container)) {
615
- return $(this.config.container);
616
- }
617
-
618
- return $(document).find(this.config.container);
619
- };
620
-
621
- _proto._getAttachment = function _getAttachment(placement) {
622
- return AttachmentMap[placement.toUpperCase()];
623
- };
624
-
625
- _proto._setListeners = function _setListeners() {
626
- var _this4 = this;
627
-
628
- var triggers = this.config.trigger.split(' ');
629
- triggers.forEach(function (trigger) {
350
+ }
351
+ _resolvePossibleFunction(arg) {
352
+ return index_js.execute(arg, [this._element]);
353
+ }
354
+ _getPopperConfig(attachment) {
355
+ const defaultBsPopperConfig = {
356
+ placement: attachment,
357
+ modifiers: [{
358
+ name: 'flip',
359
+ options: {
360
+ fallbackPlacements: this._config.fallbackPlacements
361
+ }
362
+ }, {
363
+ name: 'offset',
364
+ options: {
365
+ offset: this._getOffset()
366
+ }
367
+ }, {
368
+ name: 'preventOverflow',
369
+ options: {
370
+ boundary: this._config.boundary
371
+ }
372
+ }, {
373
+ name: 'arrow',
374
+ options: {
375
+ element: `.${this.constructor.NAME}-arrow`
376
+ }
377
+ }, {
378
+ name: 'preSetPlacement',
379
+ enabled: true,
380
+ phase: 'beforeMain',
381
+ fn: data => {
382
+ // Pre-set Popper's placement attribute in order to read the arrow sizes properly.
383
+ // Otherwise, Popper mixes up the width and height dimensions since the initial arrow style is for top placement
384
+ this._getTipElement().setAttribute('data-popper-placement', data.state.placement);
385
+ }
386
+ }]
387
+ };
388
+ return {
389
+ ...defaultBsPopperConfig,
390
+ ...index_js.execute(this._config.popperConfig, [defaultBsPopperConfig])
391
+ };
392
+ }
393
+ _setListeners() {
394
+ const triggers = this._config.trigger.split(' ');
395
+ for (const trigger of triggers) {
630
396
  if (trigger === 'click') {
631
- $(_this4.element).on(_this4.constructor.Event.CLICK, _this4.config.selector, function (event) {
632
- return _this4.toggle(event);
397
+ EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK), this._config.selector, event => {
398
+ const context = this._initializeOnDelegatedTarget(event);
399
+ context.toggle();
633
400
  });
634
- } else if (trigger !== Trigger.MANUAL) {
635
- var eventIn = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSEENTER : _this4.constructor.Event.FOCUSIN;
636
- var eventOut = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSELEAVE : _this4.constructor.Event.FOCUSOUT;
637
- $(_this4.element).on(eventIn, _this4.config.selector, function (event) {
638
- return _this4._enter(event);
639
- }).on(eventOut, _this4.config.selector, function (event) {
640
- return _this4._leave(event);
401
+ } else if (trigger !== TRIGGER_MANUAL) {
402
+ const eventIn = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : this.constructor.eventName(EVENT_FOCUSIN);
403
+ const eventOut = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSELEAVE) : this.constructor.eventName(EVENT_FOCUSOUT);
404
+ EventHandler.on(this._element, eventIn, this._config.selector, event => {
405
+ const context = this._initializeOnDelegatedTarget(event);
406
+ context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
407
+ context._enter();
408
+ });
409
+ EventHandler.on(this._element, eventOut, this._config.selector, event => {
410
+ const context = this._initializeOnDelegatedTarget(event);
411
+ context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget);
412
+ context._leave();
641
413
  });
642
414
  }
643
- });
644
- $(this.element).closest('.modal').on('hide.bs.modal', function () {
645
- if (_this4.element) {
646
- _this4.hide();
647
- }
648
- });
649
-
650
- if (this.config.selector) {
651
- this.config = _objectSpread({}, this.config, {
652
- trigger: 'manual',
653
- selector: ''
654
- });
655
- } else {
656
- this._fixTitle();
657
- }
658
- };
659
-
660
- _proto._fixTitle = function _fixTitle() {
661
- var titleType = typeof this.element.getAttribute('data-original-title');
662
-
663
- if (this.element.getAttribute('title') || titleType !== 'string') {
664
- this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
665
- this.element.setAttribute('title', '');
666
415
  }
667
- };
668
-
669
- _proto._enter = function _enter(event, context) {
670
- var dataKey = this.constructor.DATA_KEY;
671
- context = context || $(event.currentTarget).data(dataKey);
672
-
673
- if (!context) {
674
- context = new this.constructor(event.currentTarget, this._getDelegateConfig());
675
- $(event.currentTarget).data(dataKey, context);
676
- }
677
-
678
- if (event) {
679
- context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
680
- }
681
-
682
- if ($(context.getTipElement()).hasClass(ClassName.SHOW) || context._hoverState === HoverState.SHOW) {
683
- context._hoverState = HoverState.SHOW;
684
- return;
685
- }
686
-
687
- clearTimeout(context._timeout);
688
- context._hoverState = HoverState.SHOW;
689
-
690
- if (!context.config.delay || !context.config.delay.show) {
691
- context.show();
692
- return;
693
- }
694
-
695
- context._timeout = setTimeout(function () {
696
- if (context._hoverState === HoverState.SHOW) {
697
- context.show();
416
+ this._hideModalHandler = () => {
417
+ if (this._element) {
418
+ this.hide();
698
419
  }
699
- }, context.config.delay.show);
700
- };
701
-
702
- _proto._leave = function _leave(event, context) {
703
- var dataKey = this.constructor.DATA_KEY;
704
- context = context || $(event.currentTarget).data(dataKey);
705
-
706
- if (!context) {
707
- context = new this.constructor(event.currentTarget, this._getDelegateConfig());
708
- $(event.currentTarget).data(dataKey, context);
420
+ };
421
+ EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
422
+ }
423
+ _fixTitle() {
424
+ const title = this._element.getAttribute('title');
425
+ if (!title) {
426
+ return;
709
427
  }
710
-
711
- if (event) {
712
- context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
428
+ if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) {
429
+ this._element.setAttribute('aria-label', title);
713
430
  }
714
-
715
- if (context._isWithActiveTrigger()) {
431
+ this._element.setAttribute('data-bs-original-title', title); // DO NOT USE IT. Is only for backwards compatibility
432
+ this._element.removeAttribute('title');
433
+ }
434
+ _enter() {
435
+ if (this._isShown() || this._isHovered) {
436
+ this._isHovered = true;
716
437
  return;
717
438
  }
718
-
719
- clearTimeout(context._timeout);
720
- context._hoverState = HoverState.OUT;
721
-
722
- if (!context.config.delay || !context.config.delay.hide) {
723
- context.hide();
439
+ this._isHovered = true;
440
+ this._setTimeout(() => {
441
+ if (this._isHovered) {
442
+ this.show();
443
+ }
444
+ }, this._config.delay.show);
445
+ }
446
+ _leave() {
447
+ if (this._isWithActiveTrigger()) {
724
448
  return;
725
449
  }
726
-
727
- context._timeout = setTimeout(function () {
728
- if (context._hoverState === HoverState.OUT) {
729
- context.hide();
450
+ this._isHovered = false;
451
+ this._setTimeout(() => {
452
+ if (!this._isHovered) {
453
+ this.hide();
730
454
  }
731
- }, context.config.delay.hide);
732
- };
733
-
734
- _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
735
- for (var trigger in this._activeTrigger) {
736
- if (this._activeTrigger[trigger]) {
737
- return true;
455
+ }, this._config.delay.hide);
456
+ }
457
+ _setTimeout(handler, timeout) {
458
+ clearTimeout(this._timeout);
459
+ this._timeout = setTimeout(handler, timeout);
460
+ }
461
+ _isWithActiveTrigger() {
462
+ return Object.values(this._activeTrigger).includes(true);
463
+ }
464
+ _getConfig(config) {
465
+ const dataAttributes = Manipulator.getDataAttributes(this._element);
466
+ for (const dataAttribute of Object.keys(dataAttributes)) {
467
+ if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) {
468
+ delete dataAttributes[dataAttribute];
738
469
  }
739
470
  }
740
-
741
- return false;
742
- };
743
-
744
- _proto._getConfig = function _getConfig(config) {
745
- var dataAttributes = $(this.element).data();
746
- Object.keys(dataAttributes).forEach(function (dataAttr) {
747
- if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
748
- delete dataAttributes[dataAttr];
749
- }
750
- });
751
- config = _objectSpread({}, this.constructor.Default, dataAttributes, typeof config === 'object' && config ? config : {});
752
-
471
+ config = {
472
+ ...dataAttributes,
473
+ ...(typeof config === 'object' && config ? config : {})
474
+ };
475
+ config = this._mergeConfigObj(config);
476
+ config = this._configAfterMerge(config);
477
+ this._typeCheckConfig(config);
478
+ return config;
479
+ }
480
+ _configAfterMerge(config) {
481
+ config.container = config.container === false ? document.body : index_js.getElement(config.container);
753
482
  if (typeof config.delay === 'number') {
754
483
  config.delay = {
755
484
  show: config.delay,
756
485
  hide: config.delay
757
486
  };
758
487
  }
759
-
760
488
  if (typeof config.title === 'number') {
761
489
  config.title = config.title.toString();
762
490
  }
763
-
764
491
  if (typeof config.content === 'number') {
765
492
  config.content = config.content.toString();
766
493
  }
767
-
768
- Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);
769
-
770
- if (config.sanitize) {
771
- config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
772
- }
773
-
774
494
  return config;
775
- };
776
-
777
- _proto._getDelegateConfig = function _getDelegateConfig() {
778
- var config = {};
779
-
780
- if (this.config) {
781
- for (var key in this.config) {
782
- if (this.constructor.Default[key] !== this.config[key]) {
783
- config[key] = this.config[key];
784
- }
495
+ }
496
+ _getDelegateConfig() {
497
+ const config = {};
498
+ for (const [key, value] of Object.entries(this._config)) {
499
+ if (this.constructor.Default[key] !== value) {
500
+ config[key] = value;
785
501
  }
786
502
  }
503
+ config.selector = false;
504
+ config.trigger = 'manual';
787
505
 
506
+ // In the future can be replaced with:
507
+ // const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]])
508
+ // `Object.fromEntries(keysWithDifferentValues)`
788
509
  return config;
789
- };
790
-
791
- _proto._cleanTipClass = function _cleanTipClass() {
792
- var $tip = $(this.getTipElement());
793
- var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
794
-
795
- if (tabClass !== null && tabClass.length) {
796
- $tip.removeClass(tabClass.join(''));
510
+ }
511
+ _disposePopper() {
512
+ if (this._popper) {
513
+ this._popper.destroy();
514
+ this._popper = null;
797
515
  }
798
- };
799
-
800
- _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
801
- var popperInstance = popperData.instance;
802
- this.tip = popperInstance.popper;
803
-
804
- this._cleanTipClass();
805
-
806
- this.addAttachmentClass(this._getAttachment(popperData.placement));
807
- };
808
-
809
- _proto._fixTransition = function _fixTransition() {
810
- var tip = this.getTipElement();
811
- var initConfigAnimation = this.config.animation;
812
-
813
- if (tip.getAttribute('x-placement') !== null) {
814
- return;
516
+ if (this.tip) {
517
+ this.tip.remove();
518
+ this.tip = null;
815
519
  }
520
+ }
816
521
 
817
- $(tip).removeClass(ClassName.FADE);
818
- this.config.animation = false;
819
- this.hide();
820
- this.show();
821
- this.config.animation = initConfigAnimation;
822
- } // Static
823
- ;
824
-
825
- Tooltip._jQueryInterface = function _jQueryInterface(config) {
522
+ // Static
523
+ static jQueryInterface(config) {
826
524
  return this.each(function () {
827
- var data = $(this).data(DATA_KEY);
828
-
829
- var _config = typeof config === 'object' && config;
830
-
831
- if (!data && /dispose|hide/.test(config)) {
525
+ const data = Tooltip.getOrCreateInstance(this, config);
526
+ if (typeof config !== 'string') {
832
527
  return;
833
528
  }
834
-
835
- if (!data) {
836
- data = new Tooltip(this, _config);
837
- $(this).data(DATA_KEY, data);
838
- }
839
-
840
- if (typeof config === 'string') {
841
- if (typeof data[config] === 'undefined') {
842
- throw new TypeError("No method named \"" + config + "\"");
843
- }
844
-
845
- data[config]();
529
+ if (typeof data[config] === 'undefined') {
530
+ throw new TypeError(`No method named "${config}"`);
846
531
  }
532
+ data[config]();
847
533
  });
848
- };
849
-
850
- _createClass(Tooltip, null, [{
851
- key: "VERSION",
852
- get: function get() {
853
- return VERSION;
854
- }
855
- }, {
856
- key: "Default",
857
- get: function get() {
858
- return Default;
859
- }
860
- }, {
861
- key: "NAME",
862
- get: function get() {
863
- return NAME;
864
- }
865
- }, {
866
- key: "DATA_KEY",
867
- get: function get() {
868
- return DATA_KEY;
869
- }
870
- }, {
871
- key: "Event",
872
- get: function get() {
873
- return Event;
874
- }
875
- }, {
876
- key: "EVENT_KEY",
877
- get: function get() {
878
- return EVENT_KEY;
879
- }
880
- }, {
881
- key: "DefaultType",
882
- get: function get() {
883
- return DefaultType;
884
- }
885
- }]);
534
+ }
535
+ }
886
536
 
887
- return Tooltip;
888
- }();
889
537
  /**
890
- * ------------------------------------------------------------------------
891
538
  * jQuery
892
- * ------------------------------------------------------------------------
893
539
  */
894
540
 
895
-
896
- $.fn[NAME] = Tooltip._jQueryInterface;
897
- $.fn[NAME].Constructor = Tooltip;
898
-
899
- $.fn[NAME].noConflict = function () {
900
- $.fn[NAME] = JQUERY_NO_CONFLICT;
901
- return Tooltip._jQueryInterface;
902
- };
541
+ index_js.defineJQueryPlugin(Tooltip);
903
542
 
904
543
  return Tooltip;
905
544