@coreui/coreui 4.2.1 → 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.
- package/README.md +1 -1
- package/dist/css/coreui-grid.css +61 -61
- package/dist/css/coreui-grid.css.map +1 -1
- package/dist/css/coreui-grid.min.css +1 -1
- package/dist/css/coreui-grid.min.css.map +1 -1
- package/dist/css/coreui-grid.rtl.css +62 -62
- package/dist/css/coreui-grid.rtl.css.map +1 -1
- package/dist/css/coreui-grid.rtl.min.css +2 -2
- package/dist/css/coreui-grid.rtl.min.css.map +1 -1
- package/dist/css/coreui-reboot.css +1 -1
- package/dist/css/coreui-reboot.css.map +1 -1
- package/dist/css/coreui-reboot.min.css +1 -1
- package/dist/css/coreui-reboot.min.css.map +1 -1
- package/dist/css/coreui-reboot.rtl.css +2 -2
- package/dist/css/coreui-reboot.rtl.css.map +1 -1
- package/dist/css/coreui-reboot.rtl.min.css +2 -2
- package/dist/css/coreui-reboot.rtl.min.css.map +1 -1
- package/dist/css/coreui-utilities.css +72 -2
- package/dist/css/coreui-utilities.css.map +1 -1
- package/dist/css/coreui-utilities.min.css +2 -2
- package/dist/css/coreui-utilities.min.css.map +1 -1
- package/dist/css/coreui-utilities.rtl.css +73 -3
- package/dist/css/coreui-utilities.rtl.css.map +1 -1
- package/dist/css/coreui-utilities.rtl.min.css +3 -3
- package/dist/css/coreui-utilities.rtl.min.css.map +1 -1
- package/dist/css/coreui.css +195 -208
- package/dist/css/coreui.css.map +1 -1
- package/dist/css/coreui.min.css +2 -2
- package/dist/css/coreui.min.css.map +1 -1
- package/dist/css/coreui.rtl.css +196 -169
- package/dist/css/coreui.rtl.css.map +1 -1
- package/dist/css/coreui.rtl.min.css +3 -3
- package/dist/css/coreui.rtl.min.css.map +1 -1
- package/dist/js/coreui.bundle.js +704 -1534
- package/dist/js/coreui.bundle.js.map +1 -1
- package/dist/js/coreui.bundle.min.js +2 -2
- package/dist/js/coreui.bundle.min.js.map +1 -1
- package/dist/js/coreui.esm.js +641 -1482
- package/dist/js/coreui.esm.js.map +1 -1
- package/dist/js/coreui.esm.min.js +2 -2
- package/dist/js/coreui.esm.min.js.map +1 -1
- package/dist/js/coreui.js +642 -1483
- package/dist/js/coreui.js.map +1 -1
- package/dist/js/coreui.min.js +2 -2
- package/dist/js/coreui.min.js.map +1 -1
- package/js/dist/alert.js +15 -21
- package/js/dist/alert.js.map +1 -1
- package/js/dist/base-component.js +14 -25
- package/js/dist/base-component.js.map +1 -1
- package/js/dist/button.js +13 -12
- package/js/dist/button.js.map +1 -1
- package/js/dist/carousel.js +27 -103
- package/js/dist/carousel.js.map +1 -1
- package/js/dist/collapse.js +27 -84
- package/js/dist/collapse.js.map +1 -1
- package/js/dist/dom/data.js +8 -12
- package/js/dist/dom/data.js.map +1 -1
- package/js/dist/dom/event-handler.js +32 -69
- package/js/dist/dom/event-handler.js.map +1 -1
- package/js/dist/dom/manipulator.js +4 -17
- package/js/dist/dom/manipulator.js.map +1 -1
- package/js/dist/dom/selector-engine.js +41 -24
- package/js/dist/dom/selector-engine.js.map +1 -1
- package/js/dist/dropdown.js +55 -118
- package/js/dist/dropdown.js.map +1 -1
- package/js/dist/modal.js +42 -109
- package/js/dist/modal.js.map +1 -1
- package/js/dist/navigation.js +27 -59
- package/js/dist/navigation.js.map +1 -1
- package/js/dist/offcanvas.js +26 -70
- package/js/dist/offcanvas.js.map +1 -1
- package/js/dist/popover.js +18 -21
- package/js/dist/popover.js.map +1 -1
- package/js/dist/scrollspy.js +43 -71
- package/js/dist/scrollspy.js.map +1 -1
- package/js/dist/sidebar.js +21 -65
- package/js/dist/sidebar.js.map +1 -1
- package/js/dist/tab.js +41 -105
- package/js/dist/tab.js.map +1 -1
- package/js/dist/toast.js +26 -60
- package/js/dist/toast.js.map +1 -1
- package/js/dist/tooltip.js +88 -201
- package/js/dist/tooltip.js.map +1 -1
- package/js/dist/util/backdrop.js +24 -43
- package/js/dist/util/backdrop.js.map +1 -1
- package/js/dist/util/component-functions.js +14 -12
- package/js/dist/util/component-functions.js.map +1 -1
- package/js/dist/util/config.js +14 -20
- package/js/dist/util/config.js.map +1 -1
- package/js/dist/util/focustrap.js +15 -23
- package/js/dist/util/focustrap.js.map +1 -1
- package/js/dist/util/index.js +41 -110
- package/js/dist/util/index.js.map +1 -1
- package/js/dist/util/sanitizer.js +10 -20
- package/js/dist/util/sanitizer.js.map +1 -1
- package/js/dist/util/scrollbar.js +20 -39
- package/js/dist/util/scrollbar.js.map +1 -1
- package/js/dist/util/swipe.js +19 -33
- package/js/dist/util/swipe.js.map +1 -1
- package/js/dist/util/template-factory.js +22 -42
- package/js/dist/util/template-factory.js.map +1 -1
- package/js/src/alert.js +5 -5
- package/js/src/base-component.js +6 -6
- package/js/src/button.js +4 -6
- package/js/src/carousel.js +8 -9
- package/js/src/collapse.js +9 -14
- package/js/src/dom/data.js +2 -2
- package/js/src/dom/event-handler.js +19 -16
- package/js/src/dom/manipulator.js +2 -2
- package/js/src/dom/selector-engine.js +49 -6
- package/js/src/dropdown.js +19 -9
- package/js/src/modal.js +26 -22
- package/js/src/navigation.js +7 -7
- package/js/src/offcanvas.js +11 -12
- package/js/src/popover.js +3 -3
- package/js/src/scrollspy.js +14 -10
- package/js/src/sidebar.js +7 -7
- package/js/src/tab.js +13 -23
- package/js/src/toast.js +13 -8
- package/js/src/tooltip.js +53 -75
- package/js/src/util/backdrop.js +7 -4
- package/js/src/util/component-functions.js +8 -4
- package/js/src/util/config.js +7 -5
- package/js/src/util/focustrap.js +7 -4
- package/js/src/util/index.js +21 -51
- package/js/src/util/sanitizer.js +4 -4
- package/js/src/util/scrollbar.js +7 -4
- package/js/src/util/swipe.js +7 -4
- package/js/src/util/template-factory.js +9 -6
- package/package.json +31 -30
- package/scss/_accordion.scss +7 -3
- package/scss/_button-group.scss +1 -1
- package/scss/_buttons.scss +31 -6
- package/scss/_carousel.scss +0 -3
- package/scss/_dropdown.scss +2 -1
- package/scss/_functions.scss +2 -2
- package/scss/_icon.scss +1 -1
- package/scss/_list-group.scss +6 -5
- package/scss/_modal.scss +1 -1
- package/scss/_nav.scss +2 -2
- package/scss/_navbar.scss +3 -1
- package/scss/_offcanvas.scss +5 -4
- package/scss/_pagination.scss +1 -1
- package/scss/_placeholders.scss +1 -1
- package/scss/_popover.scss +5 -5
- package/scss/_spinners.scss +2 -2
- package/scss/_toasts.scss +5 -2
- package/scss/_variables.scss +18 -16
- package/scss/coreui-grid.rtl.scss +1 -1
- package/scss/coreui-grid.scss +1 -1
- package/scss/coreui-reboot.rtl.scss +1 -1
- package/scss/coreui-reboot.scss +1 -1
- package/scss/coreui-utilities.rtl.scss +1 -1
- package/scss/coreui-utilities.scss +4 -1
- package/scss/coreui.rtl.scss +1 -1
- package/scss/coreui.scss +1 -1
- package/scss/forms/_floating-labels.scss +1 -0
- package/scss/forms/_input-group.scss +19 -8
- package/scss/helpers/_vr.scss +1 -1
- package/scss/mixins/_forms.scss +10 -11
- package/scss/mixins/_table-variants.scss +2 -2
- package/scss/mixins/_utilities.scss +1 -1
- package/scss/sidebar/_sidebar-nav.scss +5 -1
package/js/src/tooltip.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* --------------------------------------------------------------------------
|
|
3
|
-
* CoreUI (v4.2.
|
|
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 =
|
|
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(
|
|
159
|
+
toggle() {
|
|
155
160
|
if (!this._isEnabled) {
|
|
156
161
|
return
|
|
157
162
|
}
|
|
158
163
|
|
|
159
|
-
|
|
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.
|
|
187
|
-
this.
|
|
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
|
-
|
|
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 (
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
342
|
-
if (this.
|
|
343
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
|
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
|
-
...(
|
|
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 =>
|
|
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.
|
|
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
|
|
614
|
-
if (this.constructor.Default[key] !==
|
|
615
|
-
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
|
package/js/src/util/backdrop.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* --------------------------------------------------------------------------
|
|
3
|
-
*
|
|
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
|
-
*
|
|
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 {
|
|
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
|
package/js/src/util/config.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* --------------------------------------------------------------------------
|
|
3
|
-
*
|
|
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.
|
|
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
|
|
package/js/src/util/focustrap.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* --------------------------------------------------------------------------
|
|
3
|
-
*
|
|
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
|
package/js/src/util/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* --------------------------------------------------------------------------
|
|
3
|
-
* CoreUI (v4.2.
|
|
3
|
+
* CoreUI (v4.2.3): tab.js
|
|
4
4
|
* Licensed under MIT (https://coreui.io/license)
|
|
5
5
|
*
|
|
6
|
-
* This
|
|
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
|
-
|
|
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 =
|
|
256
|
-
|
|
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
|
package/js/src/util/sanitizer.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* --------------------------------------------------------------------------
|
|
3
|
-
* CoreUI (v4.2.
|
|
3
|
+
* CoreUI (v4.2.3): tab.js
|
|
4
4
|
* Licensed under MIT (https://coreui.io/license)
|
|
5
5
|
*
|
|
6
|
-
* This
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
package/js/src/util/scrollbar.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* --------------------------------------------------------------------------
|
|
3
|
-
*
|
|
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
|
package/js/src/util/swipe.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* --------------------------------------------------------------------------
|
|
3
|
-
*
|
|
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
|
-
*
|
|
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 '
|
|
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
|
|
149
|
+
return execute(arg, [this])
|
|
147
150
|
}
|
|
148
151
|
|
|
149
152
|
_putElementInTemplate(element, templateElement) {
|