@openeuropa/bcl-bootstrap 0.14.0 → 0.18.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.
- package/bin/build-plugins.js +77 -160
- package/bootstrap-icons.js +211 -1
- package/js/dist/alert.js +6 -137
- package/js/dist/alert.js.map +1 -1
- package/js/dist/base-component.js +7 -109
- package/js/dist/base-component.js.map +1 -1
- package/js/dist/button.js +5 -65
- package/js/dist/button.js.map +1 -1
- package/js/dist/carousel.js +13 -190
- package/js/dist/carousel.js.map +1 -1
- package/js/dist/collapse.js +12 -170
- package/js/dist/collapse.js.map +1 -1
- package/js/dist/dom/data.js +0 -5
- package/js/dist/dom/data.js.map +1 -1
- package/js/dist/dom/event-handler.js +5 -29
- package/js/dist/dom/event-handler.js.map +1 -1
- package/js/dist/dom/manipulator.js +0 -5
- package/js/dist/dom/manipulator.js.map +1 -1
- package/js/dist/dom/selector-engine.js +5 -53
- package/js/dist/dom/selector-engine.js.map +1 -1
- package/js/dist/dropdown.js +23 -212
- package/js/dist/dropdown.js.map +1 -1
- package/js/dist/modal.js +18 -611
- package/js/dist/modal.js.map +1 -1
- package/js/dist/offcanvas.js +19 -610
- package/js/dist/offcanvas.js.map +1 -1
- package/js/dist/popover.js +5 -65
- package/js/dist/popover.js.map +1 -1
- package/js/dist/scrollspy.js +8 -147
- package/js/dist/scrollspy.js.map +1 -1
- package/js/dist/tab.js +8 -127
- package/js/dist/tab.js.map +1 -1
- package/js/dist/toast.js +8 -185
- package/js/dist/toast.js.map +1 -1
- package/js/dist/tooltip.js +18 -277
- package/js/dist/tooltip.js.map +1 -1
- package/js/dist/util/backdrop.js +138 -0
- package/js/dist/util/backdrop.js.map +1 -0
- package/js/dist/util/component-functions.js +42 -0
- package/js/dist/util/component-functions.js.map +1 -0
- package/js/dist/util/focustrap.js +118 -0
- package/js/dist/util/focustrap.js.map +1 -0
- package/js/dist/util/index.js +342 -0
- package/js/dist/util/index.js.map +1 -0
- package/js/dist/util/sanitizer.js +125 -0
- package/js/dist/util/sanitizer.js.map +1 -0
- package/js/dist/util/scrollbar.js +119 -0
- package/js/dist/util/scrollbar.js.map +1 -0
- package/package.json +4 -3
- package/plugins/alert.js +0 -230
- package/plugins/alert.js.map +0 -1
- package/plugins/base-component.js +0 -178
- package/plugins/base-component.js.map +0 -1
- package/plugins/button.js +0 -141
- package/plugins/button.js.map +0 -1
- package/plugins/carousel.js +0 -738
- package/plugins/carousel.js.map +0 -1
- package/plugins/collapse.js +0 -490
- package/plugins/collapse.js.map +0 -1
- package/plugins/dom/data.js +0 -64
- package/plugins/dom/data.js.map +0 -1
- package/plugins/dom/event-handler.js +0 -317
- package/plugins/dom/event-handler.js.map +0 -1
- package/plugins/dom/manipulator.js +0 -84
- package/plugins/dom/manipulator.js.map +0 -1
- package/plugins/dom/selector-engine.js +0 -123
- package/plugins/dom/selector-engine.js.map +0 -1
- package/plugins/dropdown.js +0 -682
- package/plugins/dropdown.js.map +0 -1
- package/plugins/modal.js +0 -1037
- package/plugins/modal.js.map +0 -1
- package/plugins/popover.js +0 -179
- package/plugins/popover.js.map +0 -1
- package/plugins/scrollspy.js +0 -386
- package/plugins/scrollspy.js.map +0 -1
- package/plugins/tab.js +0 -328
- package/plugins/tab.js.map +0 -1
- package/plugins/toast.js +0 -418
- package/plugins/toast.js.map +0 -1
- package/plugins/tooltip.js +0 -1001
- package/plugins/tooltip.js.map +0 -1
package/plugins/tooltip.js
DELETED
|
@@ -1,1001 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core'), require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./base-component.js')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['@popperjs/core', './dom/data', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tooltip = factory(global.Popper, global.Data, global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base));
|
|
5
|
-
})(this, (function (Popper, Data, EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict';
|
|
6
|
-
|
|
7
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
-
|
|
9
|
-
function _interopNamespace(e) {
|
|
10
|
-
if (e && e.__esModule) return e;
|
|
11
|
-
var n = Object.create(null);
|
|
12
|
-
if (e) {
|
|
13
|
-
Object.keys(e).forEach(function (k) {
|
|
14
|
-
if (k !== 'default') {
|
|
15
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () { return e[k]; }
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
n["default"] = e;
|
|
24
|
-
return Object.freeze(n);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var Popper__namespace = /*#__PURE__*/_interopNamespace(Popper);
|
|
28
|
-
var Data__default = /*#__PURE__*/_interopDefaultLegacy(Data);
|
|
29
|
-
var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
|
|
30
|
-
var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
|
|
31
|
-
var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
|
|
32
|
-
var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* --------------------------------------------------------------------------
|
|
36
|
-
* Bootstrap (v5.1.3): util/index.js
|
|
37
|
-
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
38
|
-
* --------------------------------------------------------------------------
|
|
39
|
-
*/
|
|
40
|
-
const MAX_UID = 1000000;
|
|
41
|
-
|
|
42
|
-
const toType = obj => {
|
|
43
|
-
if (obj === null || obj === undefined) {
|
|
44
|
-
return `${obj}`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* --------------------------------------------------------------------------
|
|
51
|
-
* Public Util Api
|
|
52
|
-
* --------------------------------------------------------------------------
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const getUID = prefix => {
|
|
57
|
-
do {
|
|
58
|
-
prefix += Math.floor(Math.random() * MAX_UID);
|
|
59
|
-
} while (document.getElementById(prefix));
|
|
60
|
-
|
|
61
|
-
return prefix;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const isElement = obj => {
|
|
65
|
-
if (!obj || typeof obj !== 'object') {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (typeof obj.jquery !== 'undefined') {
|
|
70
|
-
obj = obj[0];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return typeof obj.nodeType !== 'undefined';
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const getElement = obj => {
|
|
77
|
-
if (isElement(obj)) {
|
|
78
|
-
// it's a jQuery object or a node element
|
|
79
|
-
return obj.jquery ? obj[0] : obj;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (typeof obj === 'string' && obj.length > 0) {
|
|
83
|
-
return document.querySelector(obj);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return null;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const typeCheckConfig = (componentName, config, configTypes) => {
|
|
90
|
-
Object.keys(configTypes).forEach(property => {
|
|
91
|
-
const expectedTypes = configTypes[property];
|
|
92
|
-
const value = config[property];
|
|
93
|
-
const valueType = value && isElement(value) ? 'element' : toType(value);
|
|
94
|
-
|
|
95
|
-
if (!new RegExp(expectedTypes).test(valueType)) {
|
|
96
|
-
throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const findShadowRoot = element => {
|
|
102
|
-
if (!document.documentElement.attachShadow) {
|
|
103
|
-
return null;
|
|
104
|
-
} // Can find the shadow root otherwise it'll return the document
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (typeof element.getRootNode === 'function') {
|
|
108
|
-
const root = element.getRootNode();
|
|
109
|
-
return root instanceof ShadowRoot ? root : null;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (element instanceof ShadowRoot) {
|
|
113
|
-
return element;
|
|
114
|
-
} // when we don't find a shadow root
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (!element.parentNode) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return findShadowRoot(element.parentNode);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const noop = () => {};
|
|
125
|
-
|
|
126
|
-
const getjQuery = () => {
|
|
127
|
-
const {
|
|
128
|
-
jQuery
|
|
129
|
-
} = window;
|
|
130
|
-
|
|
131
|
-
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
|
|
132
|
-
return jQuery;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return null;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const DOMContentLoadedCallbacks = [];
|
|
139
|
-
|
|
140
|
-
const onDOMContentLoaded = callback => {
|
|
141
|
-
if (document.readyState === 'loading') {
|
|
142
|
-
// add listener on the first call when the document is in loading state
|
|
143
|
-
if (!DOMContentLoadedCallbacks.length) {
|
|
144
|
-
document.addEventListener('DOMContentLoaded', () => {
|
|
145
|
-
DOMContentLoadedCallbacks.forEach(callback => callback());
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
DOMContentLoadedCallbacks.push(callback);
|
|
150
|
-
} else {
|
|
151
|
-
callback();
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
const isRTL = () => document.documentElement.dir === 'rtl';
|
|
156
|
-
|
|
157
|
-
const defineJQueryPlugin = plugin => {
|
|
158
|
-
onDOMContentLoaded(() => {
|
|
159
|
-
const $ = getjQuery();
|
|
160
|
-
/* istanbul ignore if */
|
|
161
|
-
|
|
162
|
-
if ($) {
|
|
163
|
-
const name = plugin.NAME;
|
|
164
|
-
const JQUERY_NO_CONFLICT = $.fn[name];
|
|
165
|
-
$.fn[name] = plugin.jQueryInterface;
|
|
166
|
-
$.fn[name].Constructor = plugin;
|
|
167
|
-
|
|
168
|
-
$.fn[name].noConflict = () => {
|
|
169
|
-
$.fn[name] = JQUERY_NO_CONFLICT;
|
|
170
|
-
return plugin.jQueryInterface;
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* --------------------------------------------------------------------------
|
|
178
|
-
* Bootstrap (v5.1.3): util/sanitizer.js
|
|
179
|
-
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
180
|
-
* --------------------------------------------------------------------------
|
|
181
|
-
*/
|
|
182
|
-
const uriAttributes = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']);
|
|
183
|
-
const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
|
|
184
|
-
/**
|
|
185
|
-
* A pattern that recognizes a commonly useful subset of URLs that are safe.
|
|
186
|
-
*
|
|
187
|
-
* Shoutout to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
|
|
188
|
-
*/
|
|
189
|
-
|
|
190
|
-
const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i;
|
|
191
|
-
/**
|
|
192
|
-
* A pattern that matches safe data URLs. Only matches image, video and audio types.
|
|
193
|
-
*
|
|
194
|
-
* Shoutout to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
|
|
195
|
-
*/
|
|
196
|
-
|
|
197
|
-
const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i;
|
|
198
|
-
|
|
199
|
-
const allowedAttribute = (attribute, allowedAttributeList) => {
|
|
200
|
-
const attributeName = attribute.nodeName.toLowerCase();
|
|
201
|
-
|
|
202
|
-
if (allowedAttributeList.includes(attributeName)) {
|
|
203
|
-
if (uriAttributes.has(attributeName)) {
|
|
204
|
-
return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue) || DATA_URL_PATTERN.test(attribute.nodeValue));
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return true;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const regExp = allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp); // Check if a regular expression validates the attribute.
|
|
211
|
-
|
|
212
|
-
for (let i = 0, len = regExp.length; i < len; i++) {
|
|
213
|
-
if (regExp[i].test(attributeName)) {
|
|
214
|
-
return true;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return false;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
const DefaultAllowlist = {
|
|
222
|
-
// Global attributes allowed on any supplied element below.
|
|
223
|
-
'*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
|
|
224
|
-
a: ['target', 'href', 'title', 'rel'],
|
|
225
|
-
area: [],
|
|
226
|
-
b: [],
|
|
227
|
-
br: [],
|
|
228
|
-
col: [],
|
|
229
|
-
code: [],
|
|
230
|
-
div: [],
|
|
231
|
-
em: [],
|
|
232
|
-
hr: [],
|
|
233
|
-
h1: [],
|
|
234
|
-
h2: [],
|
|
235
|
-
h3: [],
|
|
236
|
-
h4: [],
|
|
237
|
-
h5: [],
|
|
238
|
-
h6: [],
|
|
239
|
-
i: [],
|
|
240
|
-
img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
|
|
241
|
-
li: [],
|
|
242
|
-
ol: [],
|
|
243
|
-
p: [],
|
|
244
|
-
pre: [],
|
|
245
|
-
s: [],
|
|
246
|
-
small: [],
|
|
247
|
-
span: [],
|
|
248
|
-
sub: [],
|
|
249
|
-
sup: [],
|
|
250
|
-
strong: [],
|
|
251
|
-
u: [],
|
|
252
|
-
ul: []
|
|
253
|
-
};
|
|
254
|
-
function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) {
|
|
255
|
-
if (!unsafeHtml.length) {
|
|
256
|
-
return unsafeHtml;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (sanitizeFn && typeof sanitizeFn === 'function') {
|
|
260
|
-
return sanitizeFn(unsafeHtml);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
const domParser = new window.DOMParser();
|
|
264
|
-
const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
|
|
265
|
-
const elements = [].concat(...createdDocument.body.querySelectorAll('*'));
|
|
266
|
-
|
|
267
|
-
for (let i = 0, len = elements.length; i < len; i++) {
|
|
268
|
-
const element = elements[i];
|
|
269
|
-
const elementName = element.nodeName.toLowerCase();
|
|
270
|
-
|
|
271
|
-
if (!Object.keys(allowList).includes(elementName)) {
|
|
272
|
-
element.remove();
|
|
273
|
-
continue;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
const attributeList = [].concat(...element.attributes);
|
|
277
|
-
const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []);
|
|
278
|
-
attributeList.forEach(attribute => {
|
|
279
|
-
if (!allowedAttribute(attribute, allowedAttributes)) {
|
|
280
|
-
element.removeAttribute(attribute.nodeName);
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
return createdDocument.body.innerHTML;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* --------------------------------------------------------------------------
|
|
290
|
-
* Bootstrap (v5.1.3): tooltip.js
|
|
291
|
-
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
292
|
-
* --------------------------------------------------------------------------
|
|
293
|
-
*/
|
|
294
|
-
/**
|
|
295
|
-
* ------------------------------------------------------------------------
|
|
296
|
-
* Constants
|
|
297
|
-
* ------------------------------------------------------------------------
|
|
298
|
-
*/
|
|
299
|
-
|
|
300
|
-
const NAME = 'tooltip';
|
|
301
|
-
const DATA_KEY = 'bs.tooltip';
|
|
302
|
-
const EVENT_KEY = `.${DATA_KEY}`;
|
|
303
|
-
const CLASS_PREFIX = 'bs-tooltip';
|
|
304
|
-
const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
|
|
305
|
-
const DefaultType = {
|
|
306
|
-
animation: 'boolean',
|
|
307
|
-
template: 'string',
|
|
308
|
-
title: '(string|element|function)',
|
|
309
|
-
trigger: 'string',
|
|
310
|
-
delay: '(number|object)',
|
|
311
|
-
html: 'boolean',
|
|
312
|
-
selector: '(string|boolean)',
|
|
313
|
-
placement: '(string|function)',
|
|
314
|
-
offset: '(array|string|function)',
|
|
315
|
-
container: '(string|element|boolean)',
|
|
316
|
-
fallbackPlacements: 'array',
|
|
317
|
-
boundary: '(string|element)',
|
|
318
|
-
customClass: '(string|function)',
|
|
319
|
-
sanitize: 'boolean',
|
|
320
|
-
sanitizeFn: '(null|function)',
|
|
321
|
-
allowList: 'object',
|
|
322
|
-
popperConfig: '(null|object|function)'
|
|
323
|
-
};
|
|
324
|
-
const AttachmentMap = {
|
|
325
|
-
AUTO: 'auto',
|
|
326
|
-
TOP: 'top',
|
|
327
|
-
RIGHT: isRTL() ? 'left' : 'right',
|
|
328
|
-
BOTTOM: 'bottom',
|
|
329
|
-
LEFT: isRTL() ? 'right' : 'left'
|
|
330
|
-
};
|
|
331
|
-
const Default = {
|
|
332
|
-
animation: true,
|
|
333
|
-
template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>',
|
|
334
|
-
trigger: 'hover focus',
|
|
335
|
-
title: '',
|
|
336
|
-
delay: 0,
|
|
337
|
-
html: false,
|
|
338
|
-
selector: false,
|
|
339
|
-
placement: 'top',
|
|
340
|
-
offset: [0, 0],
|
|
341
|
-
container: false,
|
|
342
|
-
fallbackPlacements: ['top', 'right', 'bottom', 'left'],
|
|
343
|
-
boundary: 'clippingParents',
|
|
344
|
-
customClass: '',
|
|
345
|
-
sanitize: true,
|
|
346
|
-
sanitizeFn: null,
|
|
347
|
-
allowList: DefaultAllowlist,
|
|
348
|
-
popperConfig: null
|
|
349
|
-
};
|
|
350
|
-
const Event = {
|
|
351
|
-
HIDE: `hide${EVENT_KEY}`,
|
|
352
|
-
HIDDEN: `hidden${EVENT_KEY}`,
|
|
353
|
-
SHOW: `show${EVENT_KEY}`,
|
|
354
|
-
SHOWN: `shown${EVENT_KEY}`,
|
|
355
|
-
INSERTED: `inserted${EVENT_KEY}`,
|
|
356
|
-
CLICK: `click${EVENT_KEY}`,
|
|
357
|
-
FOCUSIN: `focusin${EVENT_KEY}`,
|
|
358
|
-
FOCUSOUT: `focusout${EVENT_KEY}`,
|
|
359
|
-
MOUSEENTER: `mouseenter${EVENT_KEY}`,
|
|
360
|
-
MOUSELEAVE: `mouseleave${EVENT_KEY}`
|
|
361
|
-
};
|
|
362
|
-
const CLASS_NAME_FADE = 'fade';
|
|
363
|
-
const CLASS_NAME_MODAL = 'modal';
|
|
364
|
-
const CLASS_NAME_SHOW = 'show';
|
|
365
|
-
const HOVER_STATE_SHOW = 'show';
|
|
366
|
-
const HOVER_STATE_OUT = 'out';
|
|
367
|
-
const SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
|
|
368
|
-
const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
|
|
369
|
-
const EVENT_MODAL_HIDE = 'hide.bs.modal';
|
|
370
|
-
const TRIGGER_HOVER = 'hover';
|
|
371
|
-
const TRIGGER_FOCUS = 'focus';
|
|
372
|
-
const TRIGGER_CLICK = 'click';
|
|
373
|
-
const TRIGGER_MANUAL = 'manual';
|
|
374
|
-
/**
|
|
375
|
-
* ------------------------------------------------------------------------
|
|
376
|
-
* Class Definition
|
|
377
|
-
* ------------------------------------------------------------------------
|
|
378
|
-
*/
|
|
379
|
-
|
|
380
|
-
class Tooltip extends BaseComponent__default["default"] {
|
|
381
|
-
constructor(element, config) {
|
|
382
|
-
if (typeof Popper__namespace === 'undefined') {
|
|
383
|
-
throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
super(element); // private
|
|
387
|
-
|
|
388
|
-
this._isEnabled = true;
|
|
389
|
-
this._timeout = 0;
|
|
390
|
-
this._hoverState = '';
|
|
391
|
-
this._activeTrigger = {};
|
|
392
|
-
this._popper = null; // Protected
|
|
393
|
-
|
|
394
|
-
this._config = this._getConfig(config);
|
|
395
|
-
this.tip = null;
|
|
396
|
-
|
|
397
|
-
this._setListeners();
|
|
398
|
-
} // Getters
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
static get Default() {
|
|
402
|
-
return Default;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
static get NAME() {
|
|
406
|
-
return NAME;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
static get Event() {
|
|
410
|
-
return Event;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
static get DefaultType() {
|
|
414
|
-
return DefaultType;
|
|
415
|
-
} // Public
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
enable() {
|
|
419
|
-
this._isEnabled = true;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
disable() {
|
|
423
|
-
this._isEnabled = false;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
toggleEnabled() {
|
|
427
|
-
this._isEnabled = !this._isEnabled;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
toggle(event) {
|
|
431
|
-
if (!this._isEnabled) {
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
if (event) {
|
|
436
|
-
const context = this._initializeOnDelegatedTarget(event);
|
|
437
|
-
|
|
438
|
-
context._activeTrigger.click = !context._activeTrigger.click;
|
|
439
|
-
|
|
440
|
-
if (context._isWithActiveTrigger()) {
|
|
441
|
-
context._enter(null, context);
|
|
442
|
-
} else {
|
|
443
|
-
context._leave(null, context);
|
|
444
|
-
}
|
|
445
|
-
} else {
|
|
446
|
-
if (this.getTipElement().classList.contains(CLASS_NAME_SHOW)) {
|
|
447
|
-
this._leave(null, this);
|
|
448
|
-
|
|
449
|
-
return;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
this._enter(null, this);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
dispose() {
|
|
457
|
-
clearTimeout(this._timeout);
|
|
458
|
-
EventHandler__default["default"].off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
|
|
459
|
-
|
|
460
|
-
if (this.tip) {
|
|
461
|
-
this.tip.remove();
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
this._disposePopper();
|
|
465
|
-
|
|
466
|
-
super.dispose();
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
show() {
|
|
470
|
-
if (this._element.style.display === 'none') {
|
|
471
|
-
throw new Error('Please use show on visible elements');
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
if (!(this.isWithContent() && this._isEnabled)) {
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
const showEvent = EventHandler__default["default"].trigger(this._element, this.constructor.Event.SHOW);
|
|
479
|
-
const shadowRoot = findShadowRoot(this._element);
|
|
480
|
-
const isInTheDom = shadowRoot === null ? this._element.ownerDocument.documentElement.contains(this._element) : shadowRoot.contains(this._element);
|
|
481
|
-
|
|
482
|
-
if (showEvent.defaultPrevented || !isInTheDom) {
|
|
483
|
-
return;
|
|
484
|
-
} // A trick to recreate a tooltip in case a new title is given by using the NOT documented `data-bs-original-title`
|
|
485
|
-
// This will be removed later in favor of a `setContent` method
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
if (this.constructor.NAME === 'tooltip' && this.tip && this.getTitle() !== this.tip.querySelector(SELECTOR_TOOLTIP_INNER).innerHTML) {
|
|
489
|
-
this._disposePopper();
|
|
490
|
-
|
|
491
|
-
this.tip.remove();
|
|
492
|
-
this.tip = null;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
const tip = this.getTipElement();
|
|
496
|
-
const tipId = getUID(this.constructor.NAME);
|
|
497
|
-
tip.setAttribute('id', tipId);
|
|
498
|
-
|
|
499
|
-
this._element.setAttribute('aria-describedby', tipId);
|
|
500
|
-
|
|
501
|
-
if (this._config.animation) {
|
|
502
|
-
tip.classList.add(CLASS_NAME_FADE);
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
const placement = typeof this._config.placement === 'function' ? this._config.placement.call(this, tip, this._element) : this._config.placement;
|
|
506
|
-
|
|
507
|
-
const attachment = this._getAttachment(placement);
|
|
508
|
-
|
|
509
|
-
this._addAttachmentClass(attachment);
|
|
510
|
-
|
|
511
|
-
const {
|
|
512
|
-
container
|
|
513
|
-
} = this._config;
|
|
514
|
-
Data__default["default"].set(tip, this.constructor.DATA_KEY, this);
|
|
515
|
-
|
|
516
|
-
if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
|
|
517
|
-
container.append(tip);
|
|
518
|
-
EventHandler__default["default"].trigger(this._element, this.constructor.Event.INSERTED);
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
if (this._popper) {
|
|
522
|
-
this._popper.update();
|
|
523
|
-
} else {
|
|
524
|
-
this._popper = Popper__namespace.createPopper(this._element, tip, this._getPopperConfig(attachment));
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
tip.classList.add(CLASS_NAME_SHOW);
|
|
528
|
-
|
|
529
|
-
const customClass = this._resolvePossibleFunction(this._config.customClass);
|
|
530
|
-
|
|
531
|
-
if (customClass) {
|
|
532
|
-
tip.classList.add(...customClass.split(' '));
|
|
533
|
-
} // If this is a touch-enabled device we add extra
|
|
534
|
-
// empty mouseover listeners to the body's immediate children;
|
|
535
|
-
// only needed because of broken event delegation on iOS
|
|
536
|
-
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
if ('ontouchstart' in document.documentElement) {
|
|
540
|
-
[].concat(...document.body.children).forEach(element => {
|
|
541
|
-
EventHandler__default["default"].on(element, 'mouseover', noop);
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
const complete = () => {
|
|
546
|
-
const prevHoverState = this._hoverState;
|
|
547
|
-
this._hoverState = null;
|
|
548
|
-
EventHandler__default["default"].trigger(this._element, this.constructor.Event.SHOWN);
|
|
549
|
-
|
|
550
|
-
if (prevHoverState === HOVER_STATE_OUT) {
|
|
551
|
-
this._leave(null, this);
|
|
552
|
-
}
|
|
553
|
-
};
|
|
554
|
-
|
|
555
|
-
const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE);
|
|
556
|
-
|
|
557
|
-
this._queueCallback(complete, this.tip, isAnimated);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
hide() {
|
|
561
|
-
if (!this._popper) {
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
const tip = this.getTipElement();
|
|
566
|
-
|
|
567
|
-
const complete = () => {
|
|
568
|
-
if (this._isWithActiveTrigger()) {
|
|
569
|
-
return;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
if (this._hoverState !== HOVER_STATE_SHOW) {
|
|
573
|
-
tip.remove();
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
this._cleanTipClass();
|
|
577
|
-
|
|
578
|
-
this._element.removeAttribute('aria-describedby');
|
|
579
|
-
|
|
580
|
-
EventHandler__default["default"].trigger(this._element, this.constructor.Event.HIDDEN);
|
|
581
|
-
|
|
582
|
-
this._disposePopper();
|
|
583
|
-
};
|
|
584
|
-
|
|
585
|
-
const hideEvent = EventHandler__default["default"].trigger(this._element, this.constructor.Event.HIDE);
|
|
586
|
-
|
|
587
|
-
if (hideEvent.defaultPrevented) {
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
tip.classList.remove(CLASS_NAME_SHOW); // If this is a touch-enabled device we remove the extra
|
|
592
|
-
// empty mouseover listeners we added for iOS support
|
|
593
|
-
|
|
594
|
-
if ('ontouchstart' in document.documentElement) {
|
|
595
|
-
[].concat(...document.body.children).forEach(element => EventHandler__default["default"].off(element, 'mouseover', noop));
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
this._activeTrigger[TRIGGER_CLICK] = false;
|
|
599
|
-
this._activeTrigger[TRIGGER_FOCUS] = false;
|
|
600
|
-
this._activeTrigger[TRIGGER_HOVER] = false;
|
|
601
|
-
const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE);
|
|
602
|
-
|
|
603
|
-
this._queueCallback(complete, this.tip, isAnimated);
|
|
604
|
-
|
|
605
|
-
this._hoverState = '';
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
update() {
|
|
609
|
-
if (this._popper !== null) {
|
|
610
|
-
this._popper.update();
|
|
611
|
-
}
|
|
612
|
-
} // Protected
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
isWithContent() {
|
|
616
|
-
return Boolean(this.getTitle());
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
getTipElement() {
|
|
620
|
-
if (this.tip) {
|
|
621
|
-
return this.tip;
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
const element = document.createElement('div');
|
|
625
|
-
element.innerHTML = this._config.template;
|
|
626
|
-
const tip = element.children[0];
|
|
627
|
-
this.setContent(tip);
|
|
628
|
-
tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW);
|
|
629
|
-
this.tip = tip;
|
|
630
|
-
return this.tip;
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
setContent(tip) {
|
|
634
|
-
this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TOOLTIP_INNER);
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
_sanitizeAndSetContent(template, content, selector) {
|
|
638
|
-
const templateElement = SelectorEngine__default["default"].findOne(selector, template);
|
|
639
|
-
|
|
640
|
-
if (!content && templateElement) {
|
|
641
|
-
templateElement.remove();
|
|
642
|
-
return;
|
|
643
|
-
} // we use append for html objects to maintain js events
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
this.setElementContent(templateElement, content);
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
setElementContent(element, content) {
|
|
650
|
-
if (element === null) {
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
if (isElement(content)) {
|
|
655
|
-
content = getElement(content); // content is a DOM node or a jQuery
|
|
656
|
-
|
|
657
|
-
if (this._config.html) {
|
|
658
|
-
if (content.parentNode !== element) {
|
|
659
|
-
element.innerHTML = '';
|
|
660
|
-
element.append(content);
|
|
661
|
-
}
|
|
662
|
-
} else {
|
|
663
|
-
element.textContent = content.textContent;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
return;
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
if (this._config.html) {
|
|
670
|
-
if (this._config.sanitize) {
|
|
671
|
-
content = sanitizeHtml(content, this._config.allowList, this._config.sanitizeFn);
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
element.innerHTML = content;
|
|
675
|
-
} else {
|
|
676
|
-
element.textContent = content;
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
getTitle() {
|
|
681
|
-
const title = this._element.getAttribute('data-bs-original-title') || this._config.title;
|
|
682
|
-
|
|
683
|
-
return this._resolvePossibleFunction(title);
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
updateAttachment(attachment) {
|
|
687
|
-
if (attachment === 'right') {
|
|
688
|
-
return 'end';
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
if (attachment === 'left') {
|
|
692
|
-
return 'start';
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
return attachment;
|
|
696
|
-
} // Private
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
_initializeOnDelegatedTarget(event, context) {
|
|
700
|
-
return context || this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
_getOffset() {
|
|
704
|
-
const {
|
|
705
|
-
offset
|
|
706
|
-
} = this._config;
|
|
707
|
-
|
|
708
|
-
if (typeof offset === 'string') {
|
|
709
|
-
return offset.split(',').map(val => Number.parseInt(val, 10));
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
if (typeof offset === 'function') {
|
|
713
|
-
return popperData => offset(popperData, this._element);
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
return offset;
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
_resolvePossibleFunction(content) {
|
|
720
|
-
return typeof content === 'function' ? content.call(this._element) : content;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
_getPopperConfig(attachment) {
|
|
724
|
-
const defaultBsPopperConfig = {
|
|
725
|
-
placement: attachment,
|
|
726
|
-
modifiers: [{
|
|
727
|
-
name: 'flip',
|
|
728
|
-
options: {
|
|
729
|
-
fallbackPlacements: this._config.fallbackPlacements
|
|
730
|
-
}
|
|
731
|
-
}, {
|
|
732
|
-
name: 'offset',
|
|
733
|
-
options: {
|
|
734
|
-
offset: this._getOffset()
|
|
735
|
-
}
|
|
736
|
-
}, {
|
|
737
|
-
name: 'preventOverflow',
|
|
738
|
-
options: {
|
|
739
|
-
boundary: this._config.boundary
|
|
740
|
-
}
|
|
741
|
-
}, {
|
|
742
|
-
name: 'arrow',
|
|
743
|
-
options: {
|
|
744
|
-
element: `.${this.constructor.NAME}-arrow`
|
|
745
|
-
}
|
|
746
|
-
}, {
|
|
747
|
-
name: 'onChange',
|
|
748
|
-
enabled: true,
|
|
749
|
-
phase: 'afterWrite',
|
|
750
|
-
fn: data => this._handlePopperPlacementChange(data)
|
|
751
|
-
}],
|
|
752
|
-
onFirstUpdate: data => {
|
|
753
|
-
if (data.options.placement !== data.placement) {
|
|
754
|
-
this._handlePopperPlacementChange(data);
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
};
|
|
758
|
-
return { ...defaultBsPopperConfig,
|
|
759
|
-
...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig)
|
|
760
|
-
};
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
_addAttachmentClass(attachment) {
|
|
764
|
-
this.getTipElement().classList.add(`${this._getBasicClassPrefix()}-${this.updateAttachment(attachment)}`);
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
_getAttachment(placement) {
|
|
768
|
-
return AttachmentMap[placement.toUpperCase()];
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
_setListeners() {
|
|
772
|
-
const triggers = this._config.trigger.split(' ');
|
|
773
|
-
|
|
774
|
-
triggers.forEach(trigger => {
|
|
775
|
-
if (trigger === 'click') {
|
|
776
|
-
EventHandler__default["default"].on(this._element, this.constructor.Event.CLICK, this._config.selector, event => this.toggle(event));
|
|
777
|
-
} else if (trigger !== TRIGGER_MANUAL) {
|
|
778
|
-
const eventIn = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSEENTER : this.constructor.Event.FOCUSIN;
|
|
779
|
-
const eventOut = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSELEAVE : this.constructor.Event.FOCUSOUT;
|
|
780
|
-
EventHandler__default["default"].on(this._element, eventIn, this._config.selector, event => this._enter(event));
|
|
781
|
-
EventHandler__default["default"].on(this._element, eventOut, this._config.selector, event => this._leave(event));
|
|
782
|
-
}
|
|
783
|
-
});
|
|
784
|
-
|
|
785
|
-
this._hideModalHandler = () => {
|
|
786
|
-
if (this._element) {
|
|
787
|
-
this.hide();
|
|
788
|
-
}
|
|
789
|
-
};
|
|
790
|
-
|
|
791
|
-
EventHandler__default["default"].on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
|
|
792
|
-
|
|
793
|
-
if (this._config.selector) {
|
|
794
|
-
this._config = { ...this._config,
|
|
795
|
-
trigger: 'manual',
|
|
796
|
-
selector: ''
|
|
797
|
-
};
|
|
798
|
-
} else {
|
|
799
|
-
this._fixTitle();
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
_fixTitle() {
|
|
804
|
-
const title = this._element.getAttribute('title');
|
|
805
|
-
|
|
806
|
-
const originalTitleType = typeof this._element.getAttribute('data-bs-original-title');
|
|
807
|
-
|
|
808
|
-
if (title || originalTitleType !== 'string') {
|
|
809
|
-
this._element.setAttribute('data-bs-original-title', title || '');
|
|
810
|
-
|
|
811
|
-
if (title && !this._element.getAttribute('aria-label') && !this._element.textContent) {
|
|
812
|
-
this._element.setAttribute('aria-label', title);
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
this._element.setAttribute('title', '');
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
_enter(event, context) {
|
|
820
|
-
context = this._initializeOnDelegatedTarget(event, context);
|
|
821
|
-
|
|
822
|
-
if (event) {
|
|
823
|
-
context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
if (context.getTipElement().classList.contains(CLASS_NAME_SHOW) || context._hoverState === HOVER_STATE_SHOW) {
|
|
827
|
-
context._hoverState = HOVER_STATE_SHOW;
|
|
828
|
-
return;
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
clearTimeout(context._timeout);
|
|
832
|
-
context._hoverState = HOVER_STATE_SHOW;
|
|
833
|
-
|
|
834
|
-
if (!context._config.delay || !context._config.delay.show) {
|
|
835
|
-
context.show();
|
|
836
|
-
return;
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
context._timeout = setTimeout(() => {
|
|
840
|
-
if (context._hoverState === HOVER_STATE_SHOW) {
|
|
841
|
-
context.show();
|
|
842
|
-
}
|
|
843
|
-
}, context._config.delay.show);
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
_leave(event, context) {
|
|
847
|
-
context = this._initializeOnDelegatedTarget(event, context);
|
|
848
|
-
|
|
849
|
-
if (event) {
|
|
850
|
-
context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget);
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
if (context._isWithActiveTrigger()) {
|
|
854
|
-
return;
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
clearTimeout(context._timeout);
|
|
858
|
-
context._hoverState = HOVER_STATE_OUT;
|
|
859
|
-
|
|
860
|
-
if (!context._config.delay || !context._config.delay.hide) {
|
|
861
|
-
context.hide();
|
|
862
|
-
return;
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
context._timeout = setTimeout(() => {
|
|
866
|
-
if (context._hoverState === HOVER_STATE_OUT) {
|
|
867
|
-
context.hide();
|
|
868
|
-
}
|
|
869
|
-
}, context._config.delay.hide);
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
_isWithActiveTrigger() {
|
|
873
|
-
for (const trigger in this._activeTrigger) {
|
|
874
|
-
if (this._activeTrigger[trigger]) {
|
|
875
|
-
return true;
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
return false;
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
_getConfig(config) {
|
|
883
|
-
const dataAttributes = Manipulator__default["default"].getDataAttributes(this._element);
|
|
884
|
-
Object.keys(dataAttributes).forEach(dataAttr => {
|
|
885
|
-
if (DISALLOWED_ATTRIBUTES.has(dataAttr)) {
|
|
886
|
-
delete dataAttributes[dataAttr];
|
|
887
|
-
}
|
|
888
|
-
});
|
|
889
|
-
config = { ...this.constructor.Default,
|
|
890
|
-
...dataAttributes,
|
|
891
|
-
...(typeof config === 'object' && config ? config : {})
|
|
892
|
-
};
|
|
893
|
-
config.container = config.container === false ? document.body : getElement(config.container);
|
|
894
|
-
|
|
895
|
-
if (typeof config.delay === 'number') {
|
|
896
|
-
config.delay = {
|
|
897
|
-
show: config.delay,
|
|
898
|
-
hide: config.delay
|
|
899
|
-
};
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
if (typeof config.title === 'number') {
|
|
903
|
-
config.title = config.title.toString();
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
if (typeof config.content === 'number') {
|
|
907
|
-
config.content = config.content.toString();
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
typeCheckConfig(NAME, config, this.constructor.DefaultType);
|
|
911
|
-
|
|
912
|
-
if (config.sanitize) {
|
|
913
|
-
config.template = sanitizeHtml(config.template, config.allowList, config.sanitizeFn);
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
return config;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
_getDelegateConfig() {
|
|
920
|
-
const config = {};
|
|
921
|
-
|
|
922
|
-
for (const key in this._config) {
|
|
923
|
-
if (this.constructor.Default[key] !== this._config[key]) {
|
|
924
|
-
config[key] = this._config[key];
|
|
925
|
-
}
|
|
926
|
-
} // In the future can be replaced with:
|
|
927
|
-
// const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]])
|
|
928
|
-
// `Object.fromEntries(keysWithDifferentValues)`
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
return config;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
_cleanTipClass() {
|
|
935
|
-
const tip = this.getTipElement();
|
|
936
|
-
const basicClassPrefixRegex = new RegExp(`(^|\\s)${this._getBasicClassPrefix()}\\S+`, 'g');
|
|
937
|
-
const tabClass = tip.getAttribute('class').match(basicClassPrefixRegex);
|
|
938
|
-
|
|
939
|
-
if (tabClass !== null && tabClass.length > 0) {
|
|
940
|
-
tabClass.map(token => token.trim()).forEach(tClass => tip.classList.remove(tClass));
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
_getBasicClassPrefix() {
|
|
945
|
-
return CLASS_PREFIX;
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
_handlePopperPlacementChange(popperData) {
|
|
949
|
-
const {
|
|
950
|
-
state
|
|
951
|
-
} = popperData;
|
|
952
|
-
|
|
953
|
-
if (!state) {
|
|
954
|
-
return;
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
this.tip = state.elements.popper;
|
|
958
|
-
|
|
959
|
-
this._cleanTipClass();
|
|
960
|
-
|
|
961
|
-
this._addAttachmentClass(this._getAttachment(state.placement));
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
_disposePopper() {
|
|
965
|
-
if (this._popper) {
|
|
966
|
-
this._popper.destroy();
|
|
967
|
-
|
|
968
|
-
this._popper = null;
|
|
969
|
-
}
|
|
970
|
-
} // Static
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
static jQueryInterface(config) {
|
|
974
|
-
return this.each(function () {
|
|
975
|
-
const data = Tooltip.getOrCreateInstance(this, config);
|
|
976
|
-
|
|
977
|
-
if (typeof config === 'string') {
|
|
978
|
-
if (typeof data[config] === 'undefined') {
|
|
979
|
-
throw new TypeError(`No method named "${config}"`);
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
data[config]();
|
|
983
|
-
}
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
}
|
|
988
|
-
/**
|
|
989
|
-
* ------------------------------------------------------------------------
|
|
990
|
-
* jQuery
|
|
991
|
-
* ------------------------------------------------------------------------
|
|
992
|
-
* add .Tooltip to jQuery only if jQuery is present
|
|
993
|
-
*/
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
defineJQueryPlugin(Tooltip);
|
|
997
|
-
|
|
998
|
-
return Tooltip;
|
|
999
|
-
|
|
1000
|
-
}));
|
|
1001
|
-
//# sourceMappingURL=tooltip.js.map
|