@coreui/coreui 4.0.5 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/README.md +4 -7
  2. package/dist/css/coreui-grid.css +254 -205
  3. package/dist/css/coreui-grid.css.map +1 -1
  4. package/dist/css/coreui-grid.min.css +2 -2
  5. package/dist/css/coreui-grid.min.css.map +1 -1
  6. package/dist/css/coreui-grid.rtl.css +255 -206
  7. package/dist/css/coreui-grid.rtl.css.map +1 -1
  8. package/dist/css/coreui-grid.rtl.min.css +3 -3
  9. package/dist/css/coreui-grid.rtl.min.css.map +1 -1
  10. package/dist/css/coreui-reboot.css +63 -8
  11. package/dist/css/coreui-reboot.css.map +1 -1
  12. package/dist/css/coreui-reboot.min.css +2 -2
  13. package/dist/css/coreui-reboot.min.css.map +1 -1
  14. package/dist/css/coreui-reboot.rtl.css +64 -9
  15. package/dist/css/coreui-reboot.rtl.css.map +1 -1
  16. package/dist/css/coreui-reboot.rtl.min.css +3 -3
  17. package/dist/css/coreui-reboot.rtl.min.css.map +1 -1
  18. package/dist/css/coreui-utilities.css +181 -81
  19. package/dist/css/coreui-utilities.css.map +1 -1
  20. package/dist/css/coreui-utilities.min.css +2 -2
  21. package/dist/css/coreui-utilities.min.css.map +1 -1
  22. package/dist/css/coreui-utilities.rtl.css +182 -82
  23. package/dist/css/coreui-utilities.rtl.css.map +1 -1
  24. package/dist/css/coreui-utilities.rtl.min.css +3 -3
  25. package/dist/css/coreui-utilities.rtl.min.css.map +1 -1
  26. package/dist/css/coreui.css +713 -346
  27. package/dist/css/coreui.css.map +1 -1
  28. package/dist/css/coreui.min.css +2 -2
  29. package/dist/css/coreui.min.css.map +1 -1
  30. package/dist/css/coreui.rtl.css +699 -347
  31. package/dist/css/coreui.rtl.css.map +1 -1
  32. package/dist/css/coreui.rtl.min.css +3 -3
  33. package/dist/css/coreui.rtl.min.css.map +1 -1
  34. package/dist/js/coreui.bundle.js +851 -746
  35. package/dist/js/coreui.bundle.js.map +1 -1
  36. package/dist/js/coreui.bundle.min.js +3 -3
  37. package/dist/js/coreui.bundle.min.js.map +1 -1
  38. package/dist/js/coreui.esm.js +704 -644
  39. package/dist/js/coreui.esm.js.map +1 -1
  40. package/dist/js/coreui.esm.min.js +3 -3
  41. package/dist/js/coreui.esm.min.js.map +1 -1
  42. package/dist/js/coreui.js +714 -656
  43. package/dist/js/coreui.js.map +1 -1
  44. package/dist/js/coreui.min.js +3 -3
  45. package/dist/js/coreui.min.js.map +1 -1
  46. package/js/dist/alert.js +82 -49
  47. package/js/dist/alert.js.map +1 -1
  48. package/js/dist/base-component.js +26 -18
  49. package/js/dist/base-component.js.map +1 -1
  50. package/js/dist/button.js +23 -13
  51. package/js/dist/button.js.map +1 -1
  52. package/js/dist/carousel.js +95 -50
  53. package/js/dist/carousel.js.map +1 -1
  54. package/js/dist/collapse.js +125 -139
  55. package/js/dist/collapse.js.map +1 -1
  56. package/js/dist/dom/data.js +6 -6
  57. package/js/dist/dom/data.js.map +1 -1
  58. package/js/dist/dom/event-handler.js +15 -6
  59. package/js/dist/dom/event-handler.js.map +1 -1
  60. package/js/dist/dom/manipulator.js +7 -7
  61. package/js/dist/dom/manipulator.js.map +1 -1
  62. package/js/dist/dom/selector-engine.js +74 -9
  63. package/js/dist/dom/selector-engine.js.map +1 -1
  64. package/js/dist/dropdown.js +125 -112
  65. package/js/dist/dropdown.js.map +1 -1
  66. package/js/dist/modal.js +270 -93
  67. package/js/dist/modal.js.map +1 -1
  68. package/js/dist/offcanvas.js +231 -62
  69. package/js/dist/offcanvas.js.map +1 -1
  70. package/js/dist/popover.js +29 -59
  71. package/js/dist/popover.js.map +1 -1
  72. package/js/dist/scrollspy.js +45 -35
  73. package/js/dist/scrollspy.js.map +1 -1
  74. package/js/dist/tab.js +45 -23
  75. package/js/dist/tab.js.map +1 -1
  76. package/js/dist/toast.js +132 -34
  77. package/js/dist/toast.js.map +1 -1
  78. package/js/dist/tooltip.js +127 -109
  79. package/js/dist/tooltip.js.map +1 -1
  80. package/js/src/alert.js +21 -47
  81. package/js/src/base-component.js +3 -3
  82. package/js/src/button.js +1 -1
  83. package/js/src/carousel.js +10 -4
  84. package/js/src/collapse.js +66 -119
  85. package/js/src/dom/data.js +1 -1
  86. package/js/src/dom/event-handler.js +1 -2
  87. package/js/src/dom/manipulator.js +3 -3
  88. package/js/src/dom/selector-engine.js +18 -1
  89. package/js/src/dropdown.js +53 -68
  90. package/js/src/modal.js +24 -35
  91. package/js/src/navigation.js +1 -1
  92. package/js/src/offcanvas.js +16 -18
  93. package/js/src/popover.js +7 -49
  94. package/js/src/scrollspy.js +1 -1
  95. package/js/src/sidebar.js +21 -27
  96. package/js/src/tab.js +1 -1
  97. package/js/src/toast.js +11 -11
  98. package/js/src/tooltip.js +66 -50
  99. package/js/src/util/backdrop.js +6 -5
  100. package/js/src/util/component-functions.js +34 -0
  101. package/js/src/util/focustrap.js +105 -0
  102. package/js/src/util/index.js +39 -11
  103. package/js/src/util/sanitizer.js +21 -22
  104. package/js/src/util/scrollbar.js +1 -1
  105. package/package.json +54 -55
  106. package/scss/_buttons.scss +1 -2
  107. package/scss/_card.scss +2 -1
  108. package/scss/_dropdown.scss +1 -1
  109. package/scss/_functions.scss +51 -12
  110. package/scss/_grid.scss +0 -23
  111. package/scss/_helpers.scss +2 -0
  112. package/scss/_mixins.scss +1 -0
  113. package/scss/_modal.scss +2 -12
  114. package/scss/_nav.scss +1 -2
  115. package/scss/_navbar.scss +30 -1
  116. package/scss/_offcanvas.scss +6 -2
  117. package/scss/_placeholders.scss +51 -0
  118. package/scss/_reboot.scss +12 -8
  119. package/scss/_root.scss +36 -7
  120. package/scss/_tables.scss +9 -5
  121. package/scss/_toasts.scss +2 -2
  122. package/scss/_transitions.scss +6 -0
  123. package/scss/_utilities.scss +31 -8
  124. package/scss/_variables.scss +188 -13
  125. package/scss/coreui-grid.rtl.scss +1 -1
  126. package/scss/coreui-grid.scss +3 -1
  127. package/scss/coreui-reboot.rtl.scss +1 -1
  128. package/scss/coreui-reboot.scss +2 -4
  129. package/scss/coreui-utilities.rtl.scss +1 -1
  130. package/scss/coreui-utilities.scss +1 -1
  131. package/scss/coreui.rtl.scss +1 -1
  132. package/scss/coreui.scss +2 -1
  133. package/scss/forms/_form-control.scss +1 -1
  134. package/scss/forms/_form-select.scss +2 -0
  135. package/scss/helpers/_stacks.scss +15 -0
  136. package/scss/helpers/_vr.scss +8 -0
  137. package/scss/mixins/_backdrop.scss +14 -0
  138. package/scss/mixins/_grid.scss +26 -7
  139. package/scss/mixins/_ltr-rtl.scss +21 -0
  140. package/scss/mixins/_reset-text.scss +1 -1
  141. package/scss/mixins/_utilities.scss +28 -33
  142. package/scss/mixins/_visually-hidden.scss +1 -1
  143. package/scss/sidebar/_sidebar-nav.scss +1 -0
@@ -1,61 +1,58 @@
1
1
  /*!
2
- * CoreUI tooltip.js v4.0.5 (https://coreui.io)
3
- * Copyright 2021 The CoreUI Team (https://github.com/orgs/coreui/people)
2
+ * CoreUI tooltip.js v4.1.2 (https://coreui.io)
3
+ * Copyright 2022 The CoreUI Team (https://github.com/orgs/coreui/people)
4
4
  * Licensed under MIT (https://coreui.io)
5
5
  */
6
6
  (function (global, factory) {
7
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core'), require('./dom/selector-engine.js'), require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./base-component.js')) :
8
- typeof define === 'function' && define.amd ? define(['@popperjs/core', './dom/selector-engine', './dom/data', './dom/event-handler', './dom/manipulator', './base-component'], factory) :
9
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tooltip = factory(global.Popper, global.SelectorEngine, global.Data, global.EventHandler, global.Manipulator, global.Base));
10
- }(this, (function (Popper, SelectorEngine, Data, EventHandler, Manipulator, BaseComponent) { 'use strict';
7
+ 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')) :
8
+ typeof define === 'function' && define.amd ? define(['@popperjs/core', './dom/data', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tooltip = factory(global.Popper, global.Data, global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base));
10
+ })(this, (function (Popper, Data, EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict';
11
11
 
12
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
+ const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
13
13
 
14
14
  function _interopNamespace(e) {
15
15
  if (e && e.__esModule) return e;
16
- var n = Object.create(null);
16
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
17
17
  if (e) {
18
- Object.keys(e).forEach(function (k) {
18
+ for (const k in e) {
19
19
  if (k !== 'default') {
20
- var d = Object.getOwnPropertyDescriptor(e, k);
20
+ const d = Object.getOwnPropertyDescriptor(e, k);
21
21
  Object.defineProperty(n, k, d.get ? d : {
22
22
  enumerable: true,
23
- get: function () {
24
- return e[k];
25
- }
23
+ get: () => e[k]
26
24
  });
27
25
  }
28
- });
26
+ }
29
27
  }
30
- n['default'] = e;
28
+ n.default = e;
31
29
  return Object.freeze(n);
32
30
  }
33
31
 
34
- var Popper__namespace = /*#__PURE__*/_interopNamespace(Popper);
35
- var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
36
- var Data__default = /*#__PURE__*/_interopDefaultLegacy(Data);
37
- var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
38
- var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
39
- var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
32
+ const Popper__namespace = /*#__PURE__*/_interopNamespace(Popper);
33
+ const Data__default = /*#__PURE__*/_interopDefaultLegacy(Data);
34
+ const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
35
+ const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
36
+ const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
37
+ const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
40
38
 
41
39
  /**
42
40
  * --------------------------------------------------------------------------
43
- * CoreUI (v4.0.5): alert.js
41
+ * CoreUI (v4.1.2): alert.js
44
42
  * Licensed under MIT (https://coreui.io/license)
45
43
  *
46
44
  * This component is a modified version of the Bootstrap's util/index.js
47
45
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
48
46
  * --------------------------------------------------------------------------
49
47
  */
50
-
51
48
  const MAX_UID = 1000000;
52
49
 
53
- const toType = obj => {
54
- if (obj === null || obj === undefined) {
55
- return `${obj}`;
50
+ const toType = object => {
51
+ if (object === null || object === undefined) {
52
+ return `${object}`;
56
53
  }
57
54
 
58
- return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
55
+ return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase();
59
56
  };
60
57
  /**
61
58
  * --------------------------------------------------------------------------
@@ -91,7 +88,7 @@
91
88
  }
92
89
 
93
90
  if (typeof obj === 'string' && obj.length > 0) {
94
- return SelectorEngine__default['default'].findOne(obj);
91
+ return document.querySelector(obj);
95
92
  }
96
93
 
97
94
  return null;
@@ -186,45 +183,45 @@
186
183
 
187
184
  /**
188
185
  * --------------------------------------------------------------------------
189
- * CoreUI (v4.0.5): alert.js
186
+ * CoreUI (v4.1.2): alert.js
190
187
  * Licensed under MIT (https://coreui.io/license)
191
188
  *
192
189
  * This component is a modified version of the Bootstrap's util/sanitizer.js
193
190
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
194
191
  * --------------------------------------------------------------------------
195
192
  */
196
- const uriAttrs = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']);
193
+ const uriAttributes = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']);
197
194
  const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
198
195
  /**
199
196
  * A pattern that recognizes a commonly useful subset of URLs that are safe.
200
197
  *
201
- * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
198
+ * Shoutout to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
202
199
  */
203
200
 
204
- const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/i;
201
+ const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i;
205
202
  /**
206
203
  * A pattern that matches safe data URLs. Only matches image, video and audio types.
207
204
  *
208
- * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
205
+ * Shoutout to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
209
206
  */
210
207
 
211
208
  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;
212
209
 
213
- const allowedAttribute = (attr, allowedAttributeList) => {
214
- const attrName = attr.nodeName.toLowerCase();
210
+ const allowedAttribute = (attribute, allowedAttributeList) => {
211
+ const attributeName = attribute.nodeName.toLowerCase();
215
212
 
216
- if (allowedAttributeList.includes(attrName)) {
217
- if (uriAttrs.has(attrName)) {
218
- return Boolean(SAFE_URL_PATTERN.test(attr.nodeValue) || DATA_URL_PATTERN.test(attr.nodeValue));
213
+ if (allowedAttributeList.includes(attributeName)) {
214
+ if (uriAttributes.has(attributeName)) {
215
+ return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue) || DATA_URL_PATTERN.test(attribute.nodeValue));
219
216
  }
220
217
 
221
218
  return true;
222
219
  }
223
220
 
224
- const regExp = allowedAttributeList.filter(attrRegex => attrRegex instanceof RegExp); // Check if a regular expression validates the attribute.
221
+ const regExp = allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp); // Check if a regular expression validates the attribute.
225
222
 
226
223
  for (let i = 0, len = regExp.length; i < len; i++) {
227
- if (regExp[i].test(attrName)) {
224
+ if (regExp[i].test(attributeName)) {
228
225
  return true;
229
226
  }
230
227
  }
@@ -276,23 +273,22 @@
276
273
 
277
274
  const domParser = new window.DOMParser();
278
275
  const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
279
- const allowlistKeys = Object.keys(allowList);
280
276
  const elements = [].concat(...createdDocument.body.querySelectorAll('*'));
281
277
 
282
278
  for (let i = 0, len = elements.length; i < len; i++) {
283
- const el = elements[i];
284
- const elName = el.nodeName.toLowerCase();
279
+ const element = elements[i];
280
+ const elementName = element.nodeName.toLowerCase();
285
281
 
286
- if (!allowlistKeys.includes(elName)) {
287
- el.remove();
282
+ if (!Object.keys(allowList).includes(elementName)) {
283
+ element.remove();
288
284
  continue;
289
285
  }
290
286
 
291
- const attributeList = [].concat(...el.attributes);
292
- const allowedAttributes = [].concat(allowList['*'] || [], allowList[elName] || []);
293
- attributeList.forEach(attr => {
294
- if (!allowedAttribute(attr, allowedAttributes)) {
295
- el.removeAttribute(attr.nodeName);
287
+ const attributeList = [].concat(...element.attributes);
288
+ const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []);
289
+ attributeList.forEach(attribute => {
290
+ if (!allowedAttribute(attribute, allowedAttributes)) {
291
+ element.removeAttribute(attribute.nodeName);
296
292
  }
297
293
  });
298
294
  }
@@ -302,7 +298,7 @@
302
298
 
303
299
  /**
304
300
  * --------------------------------------------------------------------------
305
- * CoreUI (v4.0.5): tooltip.js
301
+ * CoreUI (v4.1.2): tooltip.js
306
302
  * Licensed under MIT (https://coreui.io/license)
307
303
  *
308
304
  * This component is a modified version of the Bootstrap's tooltip.js
@@ -319,7 +315,6 @@
319
315
  const DATA_KEY = 'coreui.tooltip';
320
316
  const EVENT_KEY = `.${DATA_KEY}`;
321
317
  const CLASS_PREFIX = 'bs-tooltip';
322
- const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g');
323
318
  const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
324
319
  const DefaultType = {
325
320
  animation: 'boolean',
@@ -384,6 +379,8 @@
384
379
  const HOVER_STATE_SHOW = 'show';
385
380
  const HOVER_STATE_OUT = 'out';
386
381
  const SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
382
+ const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
383
+ const EVENT_MODAL_HIDE = 'hide.coreui.modal';
387
384
  const TRIGGER_HOVER = 'hover';
388
385
  const TRIGGER_FOCUS = 'focus';
389
386
  const TRIGGER_CLICK = 'click';
@@ -394,7 +391,7 @@
394
391
  * ------------------------------------------------------------------------
395
392
  */
396
393
 
397
- class Tooltip extends BaseComponent__default['default'] {
394
+ class Tooltip extends BaseComponent__default.default {
398
395
  constructor(element, config) {
399
396
  if (typeof Popper__namespace === 'undefined') {
400
397
  throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
@@ -472,15 +469,13 @@
472
469
 
473
470
  dispose() {
474
471
  clearTimeout(this._timeout);
475
- EventHandler__default['default'].off(this._element.closest(`.${CLASS_NAME_MODAL}`), 'hide.coreui.modal', this._hideModalHandler);
472
+ EventHandler__default.default.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
476
473
 
477
474
  if (this.tip) {
478
475
  this.tip.remove();
479
476
  }
480
477
 
481
- if (this._popper) {
482
- this._popper.destroy();
483
- }
478
+ this._disposePopper();
484
479
 
485
480
  super.dispose();
486
481
  }
@@ -494,12 +489,21 @@
494
489
  return;
495
490
  }
496
491
 
497
- const showEvent = EventHandler__default['default'].trigger(this._element, this.constructor.Event.SHOW);
492
+ const showEvent = EventHandler__default.default.trigger(this._element, this.constructor.Event.SHOW);
498
493
  const shadowRoot = findShadowRoot(this._element);
499
494
  const isInTheDom = shadowRoot === null ? this._element.ownerDocument.documentElement.contains(this._element) : shadowRoot.contains(this._element);
500
495
 
501
496
  if (showEvent.defaultPrevented || !isInTheDom) {
502
497
  return;
498
+ } // A trick to recreate a tooltip in case a new title is given by using the NOT documented `data-coreui-original-title`
499
+ // This will be removed later in favor of a `setContent` method
500
+
501
+
502
+ if (this.constructor.NAME === 'tooltip' && this.tip && this.getTitle() !== this.tip.querySelector(SELECTOR_TOOLTIP_INNER).innerHTML) {
503
+ this._disposePopper();
504
+
505
+ this.tip.remove();
506
+ this.tip = null;
503
507
  }
504
508
 
505
509
  const tip = this.getTipElement();
@@ -508,8 +512,6 @@
508
512
 
509
513
  this._element.setAttribute('aria-describedby', tipId);
510
514
 
511
- this.setContent();
512
-
513
515
  if (this._config.animation) {
514
516
  tip.classList.add(CLASS_NAME_FADE);
515
517
  }
@@ -523,11 +525,11 @@
523
525
  const {
524
526
  container
525
527
  } = this._config;
526
- Data__default['default'].set(tip, this.constructor.DATA_KEY, this);
528
+ Data__default.default.set(tip, this.constructor.DATA_KEY, this);
527
529
 
528
530
  if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
529
- container.appendChild(tip);
530
- EventHandler__default['default'].trigger(this._element, this.constructor.Event.INSERTED);
531
+ container.append(tip);
532
+ EventHandler__default.default.trigger(this._element, this.constructor.Event.INSERTED);
531
533
  }
532
534
 
533
535
  if (this._popper) {
@@ -537,7 +539,8 @@
537
539
  }
538
540
 
539
541
  tip.classList.add(CLASS_NAME_SHOW);
540
- const customClass = typeof this._config.customClass === 'function' ? this._config.customClass() : this._config.customClass;
542
+
543
+ const customClass = this._resolvePossibleFunction(this._config.customClass);
541
544
 
542
545
  if (customClass) {
543
546
  tip.classList.add(...customClass.split(' '));
@@ -549,14 +552,14 @@
549
552
 
550
553
  if ('ontouchstart' in document.documentElement) {
551
554
  [].concat(...document.body.children).forEach(element => {
552
- EventHandler__default['default'].on(element, 'mouseover', noop);
555
+ EventHandler__default.default.on(element, 'mouseover', noop);
553
556
  });
554
557
  }
555
558
 
556
559
  const complete = () => {
557
560
  const prevHoverState = this._hoverState;
558
561
  this._hoverState = null;
559
- EventHandler__default['default'].trigger(this._element, this.constructor.Event.SHOWN);
562
+ EventHandler__default.default.trigger(this._element, this.constructor.Event.SHOWN);
560
563
 
561
564
  if (prevHoverState === HOVER_STATE_OUT) {
562
565
  this._leave(null, this);
@@ -588,16 +591,12 @@
588
591
 
589
592
  this._element.removeAttribute('aria-describedby');
590
593
 
591
- EventHandler__default['default'].trigger(this._element, this.constructor.Event.HIDDEN);
592
-
593
- if (this._popper) {
594
- this._popper.destroy();
594
+ EventHandler__default.default.trigger(this._element, this.constructor.Event.HIDDEN);
595
595
 
596
- this._popper = null;
597
- }
596
+ this._disposePopper();
598
597
  };
599
598
 
600
- const hideEvent = EventHandler__default['default'].trigger(this._element, this.constructor.Event.HIDE);
599
+ const hideEvent = EventHandler__default.default.trigger(this._element, this.constructor.Event.HIDE);
601
600
 
602
601
  if (hideEvent.defaultPrevented) {
603
602
  return;
@@ -607,7 +606,7 @@
607
606
  // empty mouseover listeners we added for iOS support
608
607
 
609
608
  if ('ontouchstart' in document.documentElement) {
610
- [].concat(...document.body.children).forEach(element => EventHandler__default['default'].off(element, 'mouseover', noop));
609
+ [].concat(...document.body.children).forEach(element => EventHandler__default.default.off(element, 'mouseover', noop));
611
610
  }
612
611
 
613
612
  this._activeTrigger[TRIGGER_CLICK] = false;
@@ -638,14 +637,27 @@
638
637
 
639
638
  const element = document.createElement('div');
640
639
  element.innerHTML = this._config.template;
641
- this.tip = element.children[0];
640
+ const tip = element.children[0];
641
+ this.setContent(tip);
642
+ tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW);
643
+ this.tip = tip;
642
644
  return this.tip;
643
645
  }
644
646
 
645
- setContent() {
646
- const tip = this.getTipElement();
647
- this.setElementContent(SelectorEngine__default['default'].findOne(SELECTOR_TOOLTIP_INNER, tip), this.getTitle());
648
- tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW);
647
+ setContent(tip) {
648
+ this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TOOLTIP_INNER);
649
+ }
650
+
651
+ _sanitizeAndSetContent(template, content, selector) {
652
+ const templateElement = SelectorEngine__default.default.findOne(selector, template);
653
+
654
+ if (!content && templateElement) {
655
+ templateElement.remove();
656
+ return;
657
+ } // we use append for html objects to maintain js events
658
+
659
+
660
+ this.setElementContent(templateElement, content);
649
661
  }
650
662
 
651
663
  setElementContent(element, content) {
@@ -659,7 +671,7 @@
659
671
  if (this._config.html) {
660
672
  if (content.parentNode !== element) {
661
673
  element.innerHTML = '';
662
- element.appendChild(content);
674
+ element.append(content);
663
675
  }
664
676
  } else {
665
677
  element.textContent = content.textContent;
@@ -680,13 +692,9 @@
680
692
  }
681
693
 
682
694
  getTitle() {
683
- let title = this._element.getAttribute('data-coreui-original-title');
695
+ const title = this._element.getAttribute('data-coreui-original-title') || this._config.title;
684
696
 
685
- if (!title) {
686
- title = typeof this._config.title === 'function' ? this._config.title.call(this._element) : this._config.title;
687
- }
688
-
689
- return title;
697
+ return this._resolvePossibleFunction(title);
690
698
  }
691
699
 
692
700
  updateAttachment(attachment) {
@@ -703,15 +711,7 @@
703
711
 
704
712
 
705
713
  _initializeOnDelegatedTarget(event, context) {
706
- const dataKey = this.constructor.DATA_KEY;
707
- context = context || Data__default['default'].get(event.delegateTarget, dataKey);
708
-
709
- if (!context) {
710
- context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
711
- Data__default['default'].set(event.delegateTarget, dataKey, context);
712
- }
713
-
714
- return context;
714
+ return context || this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
715
715
  }
716
716
 
717
717
  _getOffset() {
@@ -730,6 +730,10 @@
730
730
  return offset;
731
731
  }
732
732
 
733
+ _resolvePossibleFunction(content) {
734
+ return typeof content === 'function' ? content.call(this._element) : content;
735
+ }
736
+
733
737
  _getPopperConfig(attachment) {
734
738
  const defaultBsPopperConfig = {
735
739
  placement: attachment,
@@ -771,7 +775,7 @@
771
775
  }
772
776
 
773
777
  _addAttachmentClass(attachment) {
774
- this.getTipElement().classList.add(`${CLASS_PREFIX}-${this.updateAttachment(attachment)}`);
778
+ this.getTipElement().classList.add(`${this._getBasicClassPrefix()}-${this.updateAttachment(attachment)}`);
775
779
  }
776
780
 
777
781
  _getAttachment(placement) {
@@ -783,12 +787,12 @@
783
787
 
784
788
  triggers.forEach(trigger => {
785
789
  if (trigger === 'click') {
786
- EventHandler__default['default'].on(this._element, this.constructor.Event.CLICK, this._config.selector, event => this.toggle(event));
790
+ EventHandler__default.default.on(this._element, this.constructor.Event.CLICK, this._config.selector, event => this.toggle(event));
787
791
  } else if (trigger !== TRIGGER_MANUAL) {
788
792
  const eventIn = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSEENTER : this.constructor.Event.FOCUSIN;
789
793
  const eventOut = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSELEAVE : this.constructor.Event.FOCUSOUT;
790
- EventHandler__default['default'].on(this._element, eventIn, this._config.selector, event => this._enter(event));
791
- EventHandler__default['default'].on(this._element, eventOut, this._config.selector, event => this._leave(event));
794
+ EventHandler__default.default.on(this._element, eventIn, this._config.selector, event => this._enter(event));
795
+ EventHandler__default.default.on(this._element, eventOut, this._config.selector, event => this._leave(event));
792
796
  }
793
797
  });
794
798
 
@@ -798,7 +802,7 @@
798
802
  }
799
803
  };
800
804
 
801
- EventHandler__default['default'].on(this._element.closest(`.${CLASS_NAME_MODAL}`), 'hide.coreui.modal', this._hideModalHandler);
805
+ EventHandler__default.default.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
802
806
 
803
807
  if (this._config.selector) {
804
808
  this._config = { ...this._config,
@@ -890,7 +894,7 @@
890
894
  }
891
895
 
892
896
  _getConfig(config) {
893
- const dataAttributes = Manipulator__default['default'].getDataAttributes(this._element);
897
+ const dataAttributes = Manipulator__default.default.getDataAttributes(this._element);
894
898
  Object.keys(dataAttributes).forEach(dataAttr => {
895
899
  if (DISALLOWED_ATTRIBUTES.has(dataAttr)) {
896
900
  delete dataAttributes[dataAttr];
@@ -929,26 +933,32 @@
929
933
  _getDelegateConfig() {
930
934
  const config = {};
931
935
 
932
- if (this._config) {
933
- for (const key in this._config) {
934
- if (this.constructor.Default[key] !== this._config[key]) {
935
- config[key] = this._config[key];
936
- }
936
+ for (const key in this._config) {
937
+ if (this.constructor.Default[key] !== this._config[key]) {
938
+ config[key] = this._config[key];
937
939
  }
938
- }
940
+ } // In the future can be replaced with:
941
+ // const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]])
942
+ // `Object.fromEntries(keysWithDifferentValues)`
943
+
939
944
 
940
945
  return config;
941
946
  }
942
947
 
943
948
  _cleanTipClass() {
944
949
  const tip = this.getTipElement();
945
- const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX);
950
+ const basicClassPrefixRegex = new RegExp(`(^|\\s)${this._getBasicClassPrefix()}\\S+`, 'g');
951
+ const tabClass = tip.getAttribute('class').match(basicClassPrefixRegex);
946
952
 
947
953
  if (tabClass !== null && tabClass.length > 0) {
948
954
  tabClass.map(token => token.trim()).forEach(tClass => tip.classList.remove(tClass));
949
955
  }
950
956
  }
951
957
 
958
+ _getBasicClassPrefix() {
959
+ return CLASS_PREFIX;
960
+ }
961
+
952
962
  _handlePopperPlacementChange(popperData) {
953
963
  const {
954
964
  state
@@ -963,6 +973,14 @@
963
973
  this._cleanTipClass();
964
974
 
965
975
  this._addAttachmentClass(this._getAttachment(state.placement));
976
+ }
977
+
978
+ _disposePopper() {
979
+ if (this._popper) {
980
+ this._popper.destroy();
981
+
982
+ this._popper = null;
983
+ }
966
984
  } // Static
967
985
 
968
986
 
@@ -993,5 +1011,5 @@
993
1011
 
994
1012
  return Tooltip;
995
1013
 
996
- })));
1014
+ }));
997
1015
  //# sourceMappingURL=tooltip.js.map