@coreui/coreui 4.2.2 → 4.2.3

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 (163) hide show
  1. package/README.md +1 -1
  2. package/dist/css/coreui-grid.css +61 -61
  3. package/dist/css/coreui-grid.css.map +1 -1
  4. package/dist/css/coreui-grid.min.css +1 -1
  5. package/dist/css/coreui-grid.min.css.map +1 -1
  6. package/dist/css/coreui-grid.rtl.css +62 -62
  7. package/dist/css/coreui-grid.rtl.css.map +1 -1
  8. package/dist/css/coreui-grid.rtl.min.css +2 -2
  9. package/dist/css/coreui-grid.rtl.min.css.map +1 -1
  10. package/dist/css/coreui-reboot.css +1 -1
  11. package/dist/css/coreui-reboot.css.map +1 -1
  12. package/dist/css/coreui-reboot.min.css +1 -1
  13. package/dist/css/coreui-reboot.min.css.map +1 -1
  14. package/dist/css/coreui-reboot.rtl.css +2 -2
  15. package/dist/css/coreui-reboot.rtl.css.map +1 -1
  16. package/dist/css/coreui-reboot.rtl.min.css +2 -2
  17. package/dist/css/coreui-reboot.rtl.min.css.map +1 -1
  18. package/dist/css/coreui-utilities.css +72 -2
  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 +73 -3
  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 +192 -208
  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 +193 -169
  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 +704 -1534
  35. package/dist/js/coreui.bundle.js.map +1 -1
  36. package/dist/js/coreui.bundle.min.js +2 -2
  37. package/dist/js/coreui.bundle.min.js.map +1 -1
  38. package/dist/js/coreui.esm.js +641 -1482
  39. package/dist/js/coreui.esm.js.map +1 -1
  40. package/dist/js/coreui.esm.min.js +2 -2
  41. package/dist/js/coreui.esm.min.js.map +1 -1
  42. package/dist/js/coreui.js +642 -1483
  43. package/dist/js/coreui.js.map +1 -1
  44. package/dist/js/coreui.min.js +2 -2
  45. package/dist/js/coreui.min.js.map +1 -1
  46. package/js/dist/alert.js +15 -21
  47. package/js/dist/alert.js.map +1 -1
  48. package/js/dist/base-component.js +14 -25
  49. package/js/dist/base-component.js.map +1 -1
  50. package/js/dist/button.js +13 -12
  51. package/js/dist/button.js.map +1 -1
  52. package/js/dist/carousel.js +27 -103
  53. package/js/dist/carousel.js.map +1 -1
  54. package/js/dist/collapse.js +27 -84
  55. package/js/dist/collapse.js.map +1 -1
  56. package/js/dist/dom/data.js +8 -12
  57. package/js/dist/dom/data.js.map +1 -1
  58. package/js/dist/dom/event-handler.js +32 -69
  59. package/js/dist/dom/event-handler.js.map +1 -1
  60. package/js/dist/dom/manipulator.js +4 -17
  61. package/js/dist/dom/manipulator.js.map +1 -1
  62. package/js/dist/dom/selector-engine.js +41 -24
  63. package/js/dist/dom/selector-engine.js.map +1 -1
  64. package/js/dist/dropdown.js +55 -118
  65. package/js/dist/dropdown.js.map +1 -1
  66. package/js/dist/modal.js +42 -109
  67. package/js/dist/modal.js.map +1 -1
  68. package/js/dist/navigation.js +27 -59
  69. package/js/dist/navigation.js.map +1 -1
  70. package/js/dist/offcanvas.js +26 -70
  71. package/js/dist/offcanvas.js.map +1 -1
  72. package/js/dist/popover.js +18 -21
  73. package/js/dist/popover.js.map +1 -1
  74. package/js/dist/scrollspy.js +43 -71
  75. package/js/dist/scrollspy.js.map +1 -1
  76. package/js/dist/sidebar.js +21 -65
  77. package/js/dist/sidebar.js.map +1 -1
  78. package/js/dist/tab.js +41 -105
  79. package/js/dist/tab.js.map +1 -1
  80. package/js/dist/toast.js +26 -60
  81. package/js/dist/toast.js.map +1 -1
  82. package/js/dist/tooltip.js +88 -201
  83. package/js/dist/tooltip.js.map +1 -1
  84. package/js/dist/util/backdrop.js +24 -43
  85. package/js/dist/util/backdrop.js.map +1 -1
  86. package/js/dist/util/component-functions.js +14 -12
  87. package/js/dist/util/component-functions.js.map +1 -1
  88. package/js/dist/util/config.js +14 -20
  89. package/js/dist/util/config.js.map +1 -1
  90. package/js/dist/util/focustrap.js +15 -23
  91. package/js/dist/util/focustrap.js.map +1 -1
  92. package/js/dist/util/index.js +41 -110
  93. package/js/dist/util/index.js.map +1 -1
  94. package/js/dist/util/sanitizer.js +10 -20
  95. package/js/dist/util/sanitizer.js.map +1 -1
  96. package/js/dist/util/scrollbar.js +20 -39
  97. package/js/dist/util/scrollbar.js.map +1 -1
  98. package/js/dist/util/swipe.js +19 -33
  99. package/js/dist/util/swipe.js.map +1 -1
  100. package/js/dist/util/template-factory.js +22 -42
  101. package/js/dist/util/template-factory.js.map +1 -1
  102. package/js/src/alert.js +5 -5
  103. package/js/src/base-component.js +6 -6
  104. package/js/src/button.js +4 -6
  105. package/js/src/carousel.js +8 -9
  106. package/js/src/collapse.js +9 -14
  107. package/js/src/dom/data.js +2 -2
  108. package/js/src/dom/event-handler.js +19 -16
  109. package/js/src/dom/manipulator.js +2 -2
  110. package/js/src/dom/selector-engine.js +49 -6
  111. package/js/src/dropdown.js +19 -9
  112. package/js/src/modal.js +26 -22
  113. package/js/src/navigation.js +7 -7
  114. package/js/src/offcanvas.js +11 -12
  115. package/js/src/popover.js +3 -3
  116. package/js/src/scrollspy.js +14 -10
  117. package/js/src/sidebar.js +7 -7
  118. package/js/src/tab.js +13 -23
  119. package/js/src/toast.js +13 -8
  120. package/js/src/tooltip.js +53 -75
  121. package/js/src/util/backdrop.js +7 -4
  122. package/js/src/util/component-functions.js +8 -4
  123. package/js/src/util/config.js +7 -5
  124. package/js/src/util/focustrap.js +7 -4
  125. package/js/src/util/index.js +21 -51
  126. package/js/src/util/sanitizer.js +4 -4
  127. package/js/src/util/scrollbar.js +7 -4
  128. package/js/src/util/swipe.js +7 -4
  129. package/js/src/util/template-factory.js +9 -6
  130. package/package.json +31 -30
  131. package/scss/_accordion.scss +7 -3
  132. package/scss/_button-group.scss +1 -1
  133. package/scss/_buttons.scss +31 -6
  134. package/scss/_carousel.scss +0 -3
  135. package/scss/_dropdown.scss +2 -1
  136. package/scss/_functions.scss +2 -2
  137. package/scss/_icon.scss +1 -1
  138. package/scss/_list-group.scss +6 -5
  139. package/scss/_modal.scss +1 -1
  140. package/scss/_nav.scss +2 -2
  141. package/scss/_navbar.scss +3 -1
  142. package/scss/_offcanvas.scss +5 -4
  143. package/scss/_pagination.scss +1 -1
  144. package/scss/_placeholders.scss +1 -1
  145. package/scss/_popover.scss +5 -5
  146. package/scss/_spinners.scss +2 -2
  147. package/scss/_toasts.scss +5 -2
  148. package/scss/_variables.scss +18 -16
  149. package/scss/coreui-grid.rtl.scss +1 -1
  150. package/scss/coreui-grid.scss +1 -1
  151. package/scss/coreui-reboot.rtl.scss +1 -1
  152. package/scss/coreui-reboot.scss +1 -1
  153. package/scss/coreui-utilities.rtl.scss +1 -1
  154. package/scss/coreui-utilities.scss +4 -1
  155. package/scss/coreui.rtl.scss +1 -1
  156. package/scss/coreui.scss +1 -1
  157. package/scss/forms/_floating-labels.scss +1 -0
  158. package/scss/forms/_input-group.scss +19 -8
  159. package/scss/helpers/_vr.scss +1 -1
  160. package/scss/mixins/_forms.scss +10 -11
  161. package/scss/mixins/_table-variants.scss +2 -2
  162. package/scss/mixins/_utilities.scss +1 -1
  163. package/scss/sidebar/_sidebar-nav.scss +2 -2
package/js/src/tooltip.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * --------------------------------------------------------------------------
3
- * CoreUI (v4.2.2): tooltip.js
3
+ * CoreUI (v4.2.3): tooltip.js
4
4
  * Licensed under MIT (https://coreui.io/license)
5
5
  *
6
6
  * This component is a modified version of the Bootstrap's tooltip.js
@@ -9,12 +9,12 @@
9
9
  */
10
10
 
11
11
  import * as Popper from '@popperjs/core'
12
- import { defineJQueryPlugin, findShadowRoot, getElement, getUID, isRTL, noop } from './util/index'
13
- import { DefaultAllowlist } from './util/sanitizer'
14
- import EventHandler from './dom/event-handler'
15
- import Manipulator from './dom/manipulator'
16
- import BaseComponent from './base-component'
17
- import TemplateFactory from './util/template-factory'
12
+ import { defineJQueryPlugin, execute, findShadowRoot, getElement, getUID, isRTL, noop } from './util/index.js'
13
+ import { DefaultAllowlist } from './util/sanitizer.js'
14
+ import EventHandler from './dom/event-handler.js'
15
+ import Manipulator from './dom/manipulator.js'
16
+ import BaseComponent from './base-component.js'
17
+ import TemplateFactory from './util/template-factory.js'
18
18
 
19
19
  /**
20
20
  * Constants
@@ -114,15 +114,20 @@ class Tooltip extends BaseComponent {
114
114
  // Private
115
115
  this._isEnabled = true
116
116
  this._timeout = 0
117
- this._isHovered = false
117
+ this._isHovered = null
118
118
  this._activeTrigger = {}
119
119
  this._popper = null
120
120
  this._templateFactory = null
121
+ this._newContent = null
121
122
 
122
123
  // Protected
123
124
  this.tip = null
124
125
 
125
126
  this._setListeners()
127
+
128
+ if (!this._config.selector) {
129
+ this._fixTitle()
130
+ }
126
131
  }
127
132
 
128
133
  // Getters
@@ -151,25 +156,12 @@ class Tooltip extends BaseComponent {
151
156
  this._isEnabled = !this._isEnabled
152
157
  }
153
158
 
154
- toggle(event) {
159
+ toggle() {
155
160
  if (!this._isEnabled) {
156
161
  return
157
162
  }
158
163
 
159
- if (event) {
160
- const context = this._initializeOnDelegatedTarget(event)
161
-
162
- context._activeTrigger.click = !context._activeTrigger.click
163
-
164
- if (context._isWithActiveTrigger()) {
165
- context._enter()
166
- } else {
167
- context._leave()
168
- }
169
-
170
- return
171
- }
172
-
164
+ this._activeTrigger.click = !this._activeTrigger.click
173
165
  if (this._isShown()) {
174
166
  this._leave()
175
167
  return
@@ -183,8 +175,8 @@ class Tooltip extends BaseComponent {
183
175
 
184
176
  EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler)
185
177
 
186
- if (this.tip) {
187
- this.tip.remove()
178
+ if (this._element.getAttribute('data-coreui-original-title')) {
179
+ this._element.setAttribute('title', this._element.getAttribute('data-coreui-original-title'))
188
180
  }
189
181
 
190
182
  this._disposePopper()
@@ -208,6 +200,9 @@ class Tooltip extends BaseComponent {
208
200
  return
209
201
  }
210
202
 
203
+ // todo v6 remove this OR make it optional
204
+ this._disposePopper()
205
+
211
206
  const tip = this._getTipElement()
212
207
 
213
208
  this._element.setAttribute('aria-describedby', tip.getAttribute('id'))
@@ -219,11 +214,7 @@ class Tooltip extends BaseComponent {
219
214
  EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED))
220
215
  }
221
216
 
222
- if (this._popper) {
223
- this._popper.update()
224
- } else {
225
- this._createPopper(tip)
226
- }
217
+ this._popper = this._createPopper(tip)
227
218
 
228
219
  tip.classList.add(CLASS_NAME_SHOW)
229
220
 
@@ -238,14 +229,13 @@ class Tooltip extends BaseComponent {
238
229
  }
239
230
 
240
231
  const complete = () => {
241
- const previousHoverState = this._isHovered
242
-
243
- this._isHovered = false
244
232
  EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN))
245
233
 
246
- if (previousHoverState) {
234
+ if (this._isHovered === false) {
247
235
  this._leave()
248
236
  }
237
+
238
+ this._isHovered = false
249
239
  }
250
240
 
251
241
  this._queueCallback(complete, this.tip, this._isAnimated())
@@ -275,7 +265,7 @@ class Tooltip extends BaseComponent {
275
265
  this._activeTrigger[TRIGGER_CLICK] = false
276
266
  this._activeTrigger[TRIGGER_FOCUS] = false
277
267
  this._activeTrigger[TRIGGER_HOVER] = false
278
- this._isHovered = false
268
+ this._isHovered = null // it is a trick to support manual triggering
279
269
 
280
270
  const complete = () => {
281
271
  if (this._isWithActiveTrigger()) {
@@ -283,13 +273,11 @@ class Tooltip extends BaseComponent {
283
273
  }
284
274
 
285
275
  if (!this._isHovered) {
286
- tip.remove()
276
+ this._disposePopper()
287
277
  }
288
278
 
289
279
  this._element.removeAttribute('aria-describedby')
290
280
  EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN))
291
-
292
- this._disposePopper()
293
281
  }
294
282
 
295
283
  this._queueCallback(complete, this.tip, this._isAnimated())
@@ -308,7 +296,7 @@ class Tooltip extends BaseComponent {
308
296
 
309
297
  _getTipElement() {
310
298
  if (!this.tip) {
311
- this.tip = this._createTipElement(this._getContentForTemplate())
299
+ this.tip = this._createTipElement(this._newContent || this._getContentForTemplate())
312
300
  }
313
301
 
314
302
  return this.tip
@@ -338,17 +326,9 @@ class Tooltip extends BaseComponent {
338
326
  }
339
327
 
340
328
  setContent(content) {
341
- let isShown = false
342
- if (this.tip) {
343
- isShown = this._isShown()
344
- this.tip.remove()
345
- this.tip = null
346
- }
347
-
348
- this._disposePopper()
349
- this.tip = this._createTipElement(content)
350
-
351
- if (isShown) {
329
+ this._newContent = content
330
+ if (this._isShown()) {
331
+ this._disposePopper()
352
332
  this.show()
353
333
  }
354
334
  }
@@ -376,7 +356,7 @@ class Tooltip extends BaseComponent {
376
356
  }
377
357
 
378
358
  _getTitle() {
379
- return this._config.title
359
+ return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('data-coreui-original-title')
380
360
  }
381
361
 
382
362
  // Private
@@ -393,11 +373,9 @@ class Tooltip extends BaseComponent {
393
373
  }
394
374
 
395
375
  _createPopper(tip) {
396
- const placement = typeof this._config.placement === 'function' ?
397
- this._config.placement.call(this, tip, this._element) :
398
- this._config.placement
376
+ const placement = execute(this._config.placement, [this, tip, this._element])
399
377
  const attachment = AttachmentMap[placement.toUpperCase()]
400
- this._popper = Popper.createPopper(this._element, tip, this._getPopperConfig(attachment))
378
+ return Popper.createPopper(this._element, tip, this._getPopperConfig(attachment))
401
379
  }
402
380
 
403
381
  _getOffset() {
@@ -415,7 +393,7 @@ class Tooltip extends BaseComponent {
415
393
  }
416
394
 
417
395
  _resolvePossibleFunction(arg) {
418
- return typeof arg === 'function' ? arg.call(this._element) : arg
396
+ return execute(arg, [this._element])
419
397
  }
420
398
 
421
399
  _getPopperConfig(attachment) {
@@ -461,7 +439,7 @@ class Tooltip extends BaseComponent {
461
439
 
462
440
  return {
463
441
  ...defaultBsPopperConfig,
464
- ...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig)
442
+ ...execute(this._config.popperConfig, [defaultBsPopperConfig])
465
443
  }
466
444
  }
467
445
 
@@ -470,7 +448,10 @@ class Tooltip extends BaseComponent {
470
448
 
471
449
  for (const trigger of triggers) {
472
450
  if (trigger === 'click') {
473
- EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK), this._config.selector, event => this.toggle(event))
451
+ EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK), this._config.selector, event => {
452
+ const context = this._initializeOnDelegatedTarget(event)
453
+ context.toggle()
454
+ })
474
455
  } else if (trigger !== TRIGGER_MANUAL) {
475
456
  const eventIn = trigger === TRIGGER_HOVER ?
476
457
  this.constructor.eventName(EVENT_MOUSEENTER) :
@@ -501,29 +482,20 @@ class Tooltip extends BaseComponent {
501
482
  }
502
483
 
503
484
  EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler)
504
-
505
- if (this._config.selector) {
506
- this._config = {
507
- ...this._config,
508
- trigger: 'manual',
509
- selector: ''
510
- }
511
- } else {
512
- this._fixTitle()
513
- }
514
485
  }
515
486
 
516
487
  _fixTitle() {
517
- const title = this._config.originalTitle
488
+ const title = this._element.getAttribute('title')
518
489
 
519
490
  if (!title) {
520
491
  return
521
492
  }
522
493
 
523
- if (!this._element.getAttribute('aria-label') && !this._element.textContent) {
494
+ if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) {
524
495
  this._element.setAttribute('aria-label', title)
525
496
  }
526
497
 
498
+ this._element.setAttribute('data-coreui-original-title', title) // DO NOT USE IT. Is only for backwards compatibility
527
499
  this._element.removeAttribute('title')
528
500
  }
529
501
 
@@ -594,8 +566,6 @@ class Tooltip extends BaseComponent {
594
566
  }
595
567
  }
596
568
 
597
- config.originalTitle = this._element.getAttribute('title') || ''
598
- config.title = this._resolvePossibleFunction(config.title) || config.originalTitle
599
569
  if (typeof config.title === 'number') {
600
570
  config.title = config.title.toString()
601
571
  }
@@ -610,12 +580,15 @@ class Tooltip extends BaseComponent {
610
580
  _getDelegateConfig() {
611
581
  const config = {}
612
582
 
613
- for (const key in this._config) {
614
- if (this.constructor.Default[key] !== this._config[key]) {
615
- config[key] = this._config[key]
583
+ for (const [key, value] of Object.entries(this._config)) {
584
+ if (this.constructor.Default[key] !== value) {
585
+ config[key] = value
616
586
  }
617
587
  }
618
588
 
589
+ config.selector = false
590
+ config.trigger = 'manual'
591
+
619
592
  // In the future can be replaced with:
620
593
  // const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]])
621
594
  // `Object.fromEntries(keysWithDifferentValues)`
@@ -627,6 +600,11 @@ class Tooltip extends BaseComponent {
627
600
  this._popper.destroy()
628
601
  this._popper = null
629
602
  }
603
+
604
+ if (this.tip) {
605
+ this.tip.remove()
606
+ this.tip = null
607
+ }
630
608
  }
631
609
 
632
610
  // Static
@@ -1,13 +1,16 @@
1
1
  /**
2
2
  * --------------------------------------------------------------------------
3
- * Bootstrap (v5.2.0-beta1): util/backdrop.js
3
+ * CoreUI (v4.2.3): tab.js
4
+ * Licensed under MIT (https://coreui.io/license)
5
+ *
6
+ * This is a modified version of the Bootstrap's util/backdrop.js
4
7
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
8
  * --------------------------------------------------------------------------
6
9
  */
7
10
 
8
- import EventHandler from '../dom/event-handler'
9
- import { execute, executeAfterTransition, getElement, reflow } from './index'
10
- import Config from './config'
11
+ import EventHandler from '../dom/event-handler.js'
12
+ import { execute, executeAfterTransition, getElement, reflow } from './index.js'
13
+ import Config from './config.js'
11
14
 
12
15
  /**
13
16
  * Constants
@@ -1,12 +1,16 @@
1
1
  /**
2
2
  * --------------------------------------------------------------------------
3
- * Bootstrap (v5.2.0-beta1): util/component-functions.js
3
+ * CoreUI (v4.2.3): tab.js
4
+ * Licensed under MIT (https://coreui.io/license)
5
+ *
6
+ * This is a modified version of the Bootstrap's util/component-functions.js
4
7
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
8
  * --------------------------------------------------------------------------
6
9
  */
7
10
 
8
- import EventHandler from '../dom/event-handler'
9
- import { getElementFromSelector, isDisabled } from './index'
11
+ import EventHandler from '../dom/event-handler.js'
12
+ import { isDisabled } from './index.js'
13
+ import SelectorEngine from '../dom/selector-engine.js'
10
14
 
11
15
  const enableDismissTrigger = (component, method = 'hide') => {
12
16
  const clickEvent = `click.dismiss${component.EVENT_KEY}`
@@ -21,7 +25,7 @@ const enableDismissTrigger = (component, method = 'hide') => {
21
25
  return
22
26
  }
23
27
 
24
- const target = getElementFromSelector(this) || this.closest(`.${name}`)
28
+ const target = SelectorEngine.getElementFromSelector(this) || this.closest(`.${name}`)
25
29
  const instance = component.getOrCreateInstance(target)
26
30
 
27
31
  // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
@@ -1,12 +1,15 @@
1
1
  /**
2
2
  * --------------------------------------------------------------------------
3
- * Bootstrap (v5.2.0-beta1): util/config.js
3
+ * CoreUI (v4.2.3): tab.js
4
+ * Licensed under MIT (https://coreui.io/license)
5
+ *
6
+ * This is a modified version of the Bootstrap's util/config.js
4
7
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
8
  * --------------------------------------------------------------------------
6
9
  */
7
10
 
8
- import { isElement, toType } from './index'
9
- import Manipulator from '../dom/manipulator'
11
+ import { isElement, toType } from './index.js'
12
+ import Manipulator from '../dom/manipulator.js'
10
13
 
11
14
  /**
12
15
  * Class definition
@@ -49,8 +52,7 @@ class Config {
49
52
  }
50
53
 
51
54
  _typeCheckConfig(config, configTypes = this.constructor.DefaultType) {
52
- for (const property of Object.keys(configTypes)) {
53
- const expectedTypes = configTypes[property]
55
+ for (const [property, expectedTypes] of Object.entries(configTypes)) {
54
56
  const value = config[property]
55
57
  const valueType = isElement(value) ? 'element' : toType(value)
56
58
 
@@ -1,13 +1,16 @@
1
1
  /**
2
2
  * --------------------------------------------------------------------------
3
- * Bootstrap (v5.2.0-beta1): util/focustrap.js
3
+ * CoreUI (v4.2.3): tab.js
4
+ * Licensed under MIT (https://coreui.io/license)
5
+ *
6
+ * This is a modified version of the Bootstrap's util/focustrap.js
4
7
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
8
  * --------------------------------------------------------------------------
6
9
  */
7
10
 
8
- import EventHandler from '../dom/event-handler'
9
- import SelectorEngine from '../dom/selector-engine'
10
- import Config from './config'
11
+ import EventHandler from '../dom/event-handler.js'
12
+ import SelectorEngine from '../dom/selector-engine.js'
13
+ import Config from './config.js'
11
14
 
12
15
  /**
13
16
  * Constants
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * --------------------------------------------------------------------------
3
- * CoreUI (v4.2.2): alert.js
3
+ * CoreUI (v4.2.3): tab.js
4
4
  * Licensed under MIT (https://coreui.io/license)
5
5
  *
6
- * This component is a modified version of the Bootstrap's util/index.js
6
+ * This is a modified version of the Bootstrap's util/index.js
7
7
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
8
8
  * --------------------------------------------------------------------------
9
9
  */
@@ -12,7 +12,21 @@ const MAX_UID = 1_000_000
12
12
  const MILLISECONDS_MULTIPLIER = 1000
13
13
  const TRANSITION_END = 'transitionend'
14
14
 
15
- // Shoutout AngusCroll (https://goo.gl/pxwQGp)
15
+ /**
16
+ * Properly escape IDs selectors to handle weird IDs
17
+ * @param {string} selector
18
+ * @returns {string}
19
+ */
20
+ const parseSelector = selector => {
21
+ if (selector && window.CSS && window.CSS.escape) {
22
+ // document.querySelector needs escaping to handle IDs (html5+) containing for instance /
23
+ selector = selector.replace(/#([^\s"#']+)/g, (match, id) => `#${CSS.escape(id)}`)
24
+ }
25
+
26
+ return selector
27
+ }
28
+
29
+ // Shout-out Angus Croll (https://goo.gl/pxwQGp)
16
30
  const toType = object => {
17
31
  if (object === null || object === undefined) {
18
32
  return `${object}`
@@ -33,47 +47,6 @@ const getUID = prefix => {
33
47
  return prefix
34
48
  }
35
49
 
36
- const getSelector = element => {
37
- let selector = element.getAttribute('data-coreui-target')
38
-
39
- if (!selector || selector === '#') {
40
- let hrefAttribute = element.getAttribute('href')
41
-
42
- // The only valid content that could double as a selector are IDs or classes,
43
- // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
44
- // `document.querySelector` will rightfully complain it is invalid.
45
- // See https://github.com/twbs/bootstrap/issues/32273
46
- if (!hrefAttribute || (!hrefAttribute.includes('#') && !hrefAttribute.startsWith('.'))) {
47
- return null
48
- }
49
-
50
- // Just in case some CMS puts out a full URL with the anchor appended
51
- if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) {
52
- hrefAttribute = `#${hrefAttribute.split('#')[1]}`
53
- }
54
-
55
- selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null
56
- }
57
-
58
- return selector
59
- }
60
-
61
- const getSelectorFromElement = element => {
62
- const selector = getSelector(element)
63
-
64
- if (selector) {
65
- return document.querySelector(selector) ? selector : null
66
- }
67
-
68
- return null
69
- }
70
-
71
- const getElementFromSelector = element => {
72
- const selector = getSelector(element)
73
-
74
- return selector ? document.querySelector(selector) : null
75
- }
76
-
77
50
  const getTransitionDurationFromElement = element => {
78
51
  if (!element) {
79
52
  return 0
@@ -120,7 +93,7 @@ const getElement = object => {
120
93
  }
121
94
 
122
95
  if (typeof object === 'string' && object.length > 0) {
123
- return document.querySelector(object)
96
+ return document.querySelector(parseSelector(object))
124
97
  }
125
98
 
126
99
  return null
@@ -252,10 +225,8 @@ const defineJQueryPlugin = plugin => {
252
225
  })
253
226
  }
254
227
 
255
- const execute = callback => {
256
- if (typeof callback === 'function') {
257
- callback()
258
- }
228
+ const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {
229
+ return typeof possibleCallback === 'function' ? possibleCallback(...args) : defaultValue
259
230
  }
260
231
 
261
232
  const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
@@ -321,10 +292,8 @@ export {
321
292
  executeAfterTransition,
322
293
  findShadowRoot,
323
294
  getElement,
324
- getElementFromSelector,
325
295
  getjQuery,
326
296
  getNextActiveElement,
327
- getSelectorFromElement,
328
297
  getTransitionDurationFromElement,
329
298
  getUID,
330
299
  isDisabled,
@@ -333,6 +302,7 @@ export {
333
302
  isVisible,
334
303
  noop,
335
304
  onDOMContentLoaded,
305
+ parseSelector,
336
306
  reflow,
337
307
  triggerTransitionEnd,
338
308
  toType
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * --------------------------------------------------------------------------
3
- * CoreUI (v4.2.2): alert.js
3
+ * CoreUI (v4.2.3): tab.js
4
4
  * Licensed under MIT (https://coreui.io/license)
5
5
  *
6
- * This component is a modified version of the Bootstrap's util/sanitizer.js
6
+ * This is a modified version of the Bootstrap's util/sanitizer.js
7
7
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
8
8
  * --------------------------------------------------------------------------
9
9
  */
@@ -24,14 +24,14 @@ const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
24
24
  /**
25
25
  * A pattern that recognizes a commonly useful subset of URLs that are safe.
26
26
  *
27
- * Shoutout to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
27
+ * Shout-out to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
28
28
  */
29
29
  const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i
30
30
 
31
31
  /**
32
32
  * A pattern that matches safe data URLs. Only matches image, video and audio types.
33
33
  *
34
- * Shoutout to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
34
+ * Shout-out to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
35
35
  */
36
36
  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
37
37
 
@@ -1,13 +1,16 @@
1
1
  /**
2
2
  * --------------------------------------------------------------------------
3
- * Bootstrap (v5.2.0-beta1): util/scrollBar.js
3
+ * CoreUI (v4.2.3): tab.js
4
+ * Licensed under MIT (https://coreui.io/license)
5
+ *
6
+ * This is a modified version of the Bootstrap's util/scrollBar.js
4
7
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
8
  * --------------------------------------------------------------------------
6
9
  */
7
10
 
8
- import SelectorEngine from '../dom/selector-engine'
9
- import Manipulator from '../dom/manipulator'
10
- import { isElement } from './index'
11
+ import SelectorEngine from '../dom/selector-engine.js'
12
+ import Manipulator from '../dom/manipulator.js'
13
+ import { isElement } from './index.js'
11
14
 
12
15
  /**
13
16
  * Constants
@@ -1,13 +1,16 @@
1
1
  /**
2
2
  * --------------------------------------------------------------------------
3
- * Bootstrap (v5.2.0-beta1): util/swipe.js
3
+ * CoreUI (v4.2.3): tab.js
4
+ * Licensed under MIT (https://coreui.io/license)
5
+ *
6
+ * This is a modified version of the Bootstrap's util/swipe.js
4
7
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
8
  * --------------------------------------------------------------------------
6
9
  */
7
10
 
8
- import Config from './config'
9
- import EventHandler from '../dom/event-handler'
10
- import { execute } from './index'
11
+ import Config from './config.js'
12
+ import EventHandler from '../dom/event-handler.js'
13
+ import { execute } from './index.js'
11
14
 
12
15
  /**
13
16
  * Constants
@@ -1,14 +1,17 @@
1
1
  /**
2
2
  * --------------------------------------------------------------------------
3
- * Bootstrap (v5.2.0-beta1): util/template-factory.js
3
+ * CoreUI (v4.2.3): tab.js
4
+ * Licensed under MIT (https://coreui.io/license)
5
+ *
6
+ * This is a modified version of the Bootstrap's util/template-factory.js
4
7
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
8
  * --------------------------------------------------------------------------
6
9
  */
7
10
 
8
- import { DefaultAllowlist, sanitizeHtml } from './sanitizer'
9
- import { getElement, isElement } from '../util/index'
10
- import SelectorEngine from '../dom/selector-engine'
11
- import Config from './config'
11
+ import { DefaultAllowlist, sanitizeHtml } from './sanitizer.js'
12
+ import { execute, getElement, isElement } from './index.js'
13
+ import SelectorEngine from '../dom/selector-engine.js'
14
+ import Config from './config.js'
12
15
 
13
16
  /**
14
17
  * Constants
@@ -143,7 +146,7 @@ class TemplateFactory extends Config {
143
146
  }
144
147
 
145
148
  _resolvePossibleFunction(arg) {
146
- return typeof arg === 'function' ? arg(this) : arg
149
+ return execute(arg, [this])
147
150
  }
148
151
 
149
152
  _putElementInTemplate(element, templateElement) {