@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.
- 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 +192 -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 +193 -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 +2 -2
package/js/dist/tooltip.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* CoreUI tooltip.js v4.2.
|
|
2
|
+
* CoreUI tooltip.js v4.2.3 (https://coreui.io)
|
|
3
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('./util/index'), require('./util/sanitizer'), require('./dom/event-handler'), require('./dom/manipulator'), require('./base-component'), require('./util/template-factory')) :
|
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core'), require('./util/index.js'), require('./util/sanitizer.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./base-component.js'), require('./util/template-factory.js')) :
|
|
8
8
|
typeof define === 'function' && define.amd ? define(['@popperjs/core', './util/index', './util/sanitizer', './dom/event-handler', './dom/manipulator', './base-component', './util/template-factory'], factory) :
|
|
9
9
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tooltip = factory(global["@popperjs/core"], global.Index, global.Sanitizer, global.EventHandler, global.Manipulator, global.BaseComponent, global.TemplateFactory));
|
|
10
|
-
})(this, (function (Popper,
|
|
10
|
+
})(this, (function (Popper, index_js, sanitizer_js, EventHandler, Manipulator, BaseComponent, TemplateFactory) { 'use strict';
|
|
11
11
|
|
|
12
12
|
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
|
13
13
|
|
|
@@ -37,13 +37,14 @@
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* --------------------------------------------------------------------------
|
|
40
|
-
* CoreUI (v4.2.
|
|
40
|
+
* CoreUI (v4.2.3): tooltip.js
|
|
41
41
|
* Licensed under MIT (https://coreui.io/license)
|
|
42
42
|
*
|
|
43
43
|
* This component is a modified version of the Bootstrap's tooltip.js
|
|
44
44
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
45
45
|
* --------------------------------------------------------------------------
|
|
46
46
|
*/
|
|
47
|
+
|
|
47
48
|
/**
|
|
48
49
|
* Constants
|
|
49
50
|
*/
|
|
@@ -73,12 +74,12 @@
|
|
|
73
74
|
const AttachmentMap = {
|
|
74
75
|
AUTO: 'auto',
|
|
75
76
|
TOP: 'top',
|
|
76
|
-
RIGHT:
|
|
77
|
+
RIGHT: index_js.isRTL() ? 'left' : 'right',
|
|
77
78
|
BOTTOM: 'bottom',
|
|
78
|
-
LEFT:
|
|
79
|
+
LEFT: index_js.isRTL() ? 'right' : 'left'
|
|
79
80
|
};
|
|
80
81
|
const Default = {
|
|
81
|
-
allowList:
|
|
82
|
+
allowList: sanitizer_js.DefaultAllowlist,
|
|
82
83
|
animation: true,
|
|
83
84
|
boundary: 'clippingParents',
|
|
84
85
|
container: false,
|
|
@@ -115,6 +116,7 @@
|
|
|
115
116
|
title: '(string|element|function)',
|
|
116
117
|
trigger: 'string'
|
|
117
118
|
};
|
|
119
|
+
|
|
118
120
|
/**
|
|
119
121
|
* Class definition
|
|
120
122
|
*/
|
|
@@ -124,317 +126,240 @@
|
|
|
124
126
|
if (typeof Popper__namespace === 'undefined') {
|
|
125
127
|
throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
|
|
126
128
|
}
|
|
129
|
+
super(element, config);
|
|
127
130
|
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
// Private
|
|
130
132
|
this._isEnabled = true;
|
|
131
133
|
this._timeout = 0;
|
|
132
|
-
this._isHovered =
|
|
134
|
+
this._isHovered = null;
|
|
133
135
|
this._activeTrigger = {};
|
|
134
136
|
this._popper = null;
|
|
135
|
-
this._templateFactory = null;
|
|
137
|
+
this._templateFactory = null;
|
|
138
|
+
this._newContent = null;
|
|
136
139
|
|
|
140
|
+
// Protected
|
|
137
141
|
this.tip = null;
|
|
138
|
-
|
|
139
142
|
this._setListeners();
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
if (!this._config.selector) {
|
|
144
|
+
this._fixTitle();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
142
147
|
|
|
148
|
+
// Getters
|
|
143
149
|
static get Default() {
|
|
144
150
|
return Default;
|
|
145
151
|
}
|
|
146
|
-
|
|
147
152
|
static get DefaultType() {
|
|
148
153
|
return DefaultType;
|
|
149
154
|
}
|
|
150
|
-
|
|
151
155
|
static get NAME() {
|
|
152
156
|
return NAME;
|
|
153
|
-
}
|
|
154
|
-
|
|
157
|
+
}
|
|
155
158
|
|
|
159
|
+
// Public
|
|
156
160
|
enable() {
|
|
157
161
|
this._isEnabled = true;
|
|
158
162
|
}
|
|
159
|
-
|
|
160
163
|
disable() {
|
|
161
164
|
this._isEnabled = false;
|
|
162
165
|
}
|
|
163
|
-
|
|
164
166
|
toggleEnabled() {
|
|
165
167
|
this._isEnabled = !this._isEnabled;
|
|
166
168
|
}
|
|
167
|
-
|
|
168
|
-
toggle(event) {
|
|
169
|
+
toggle() {
|
|
169
170
|
if (!this._isEnabled) {
|
|
170
171
|
return;
|
|
171
172
|
}
|
|
172
|
-
|
|
173
|
-
if (event) {
|
|
174
|
-
const context = this._initializeOnDelegatedTarget(event);
|
|
175
|
-
|
|
176
|
-
context._activeTrigger.click = !context._activeTrigger.click;
|
|
177
|
-
|
|
178
|
-
if (context._isWithActiveTrigger()) {
|
|
179
|
-
context._enter();
|
|
180
|
-
} else {
|
|
181
|
-
context._leave();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
|
|
173
|
+
this._activeTrigger.click = !this._activeTrigger.click;
|
|
187
174
|
if (this._isShown()) {
|
|
188
175
|
this._leave();
|
|
189
|
-
|
|
190
176
|
return;
|
|
191
177
|
}
|
|
192
|
-
|
|
193
178
|
this._enter();
|
|
194
179
|
}
|
|
195
|
-
|
|
196
180
|
dispose() {
|
|
197
181
|
clearTimeout(this._timeout);
|
|
198
182
|
EventHandler__default.default.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
this.tip.remove();
|
|
183
|
+
if (this._element.getAttribute('data-coreui-original-title')) {
|
|
184
|
+
this._element.setAttribute('title', this._element.getAttribute('data-coreui-original-title'));
|
|
202
185
|
}
|
|
203
|
-
|
|
204
186
|
this._disposePopper();
|
|
205
|
-
|
|
206
187
|
super.dispose();
|
|
207
188
|
}
|
|
208
|
-
|
|
209
189
|
show() {
|
|
210
190
|
if (this._element.style.display === 'none') {
|
|
211
191
|
throw new Error('Please use show on visible elements');
|
|
212
192
|
}
|
|
213
|
-
|
|
214
193
|
if (!(this._isWithContent() && this._isEnabled)) {
|
|
215
194
|
return;
|
|
216
195
|
}
|
|
217
|
-
|
|
218
196
|
const showEvent = EventHandler__default.default.trigger(this._element, this.constructor.eventName(EVENT_SHOW));
|
|
219
|
-
const shadowRoot =
|
|
220
|
-
|
|
197
|
+
const shadowRoot = index_js.findShadowRoot(this._element);
|
|
221
198
|
const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element);
|
|
222
|
-
|
|
223
199
|
if (showEvent.defaultPrevented || !isInTheDom) {
|
|
224
200
|
return;
|
|
225
201
|
}
|
|
226
202
|
|
|
203
|
+
// todo v6 remove this OR make it optional
|
|
204
|
+
this._disposePopper();
|
|
227
205
|
const tip = this._getTipElement();
|
|
228
|
-
|
|
229
206
|
this._element.setAttribute('aria-describedby', tip.getAttribute('id'));
|
|
230
|
-
|
|
231
207
|
const {
|
|
232
208
|
container
|
|
233
209
|
} = this._config;
|
|
234
|
-
|
|
235
210
|
if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
|
|
236
211
|
container.append(tip);
|
|
237
212
|
EventHandler__default.default.trigger(this._element, this.constructor.eventName(EVENT_INSERTED));
|
|
238
213
|
}
|
|
214
|
+
this._popper = this._createPopper(tip);
|
|
215
|
+
tip.classList.add(CLASS_NAME_SHOW);
|
|
239
216
|
|
|
240
|
-
|
|
241
|
-
this._popper.update();
|
|
242
|
-
} else {
|
|
243
|
-
this._createPopper(tip);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
tip.classList.add(CLASS_NAME_SHOW); // If this is a touch-enabled device we add extra
|
|
217
|
+
// If this is a touch-enabled device we add extra
|
|
247
218
|
// empty mouseover listeners to the body's immediate children;
|
|
248
219
|
// only needed because of broken event delegation on iOS
|
|
249
220
|
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
|
|
250
|
-
|
|
251
221
|
if ('ontouchstart' in document.documentElement) {
|
|
252
222
|
for (const element of [].concat(...document.body.children)) {
|
|
253
|
-
EventHandler__default.default.on(element, 'mouseover',
|
|
223
|
+
EventHandler__default.default.on(element, 'mouseover', index_js.noop);
|
|
254
224
|
}
|
|
255
225
|
}
|
|
256
|
-
|
|
257
226
|
const complete = () => {
|
|
258
|
-
const previousHoverState = this._isHovered;
|
|
259
|
-
this._isHovered = false;
|
|
260
227
|
EventHandler__default.default.trigger(this._element, this.constructor.eventName(EVENT_SHOWN));
|
|
261
|
-
|
|
262
|
-
if (previousHoverState) {
|
|
228
|
+
if (this._isHovered === false) {
|
|
263
229
|
this._leave();
|
|
264
230
|
}
|
|
231
|
+
this._isHovered = false;
|
|
265
232
|
};
|
|
266
|
-
|
|
267
233
|
this._queueCallback(complete, this.tip, this._isAnimated());
|
|
268
234
|
}
|
|
269
|
-
|
|
270
235
|
hide() {
|
|
271
236
|
if (!this._isShown()) {
|
|
272
237
|
return;
|
|
273
238
|
}
|
|
274
|
-
|
|
275
239
|
const hideEvent = EventHandler__default.default.trigger(this._element, this.constructor.eventName(EVENT_HIDE));
|
|
276
|
-
|
|
277
240
|
if (hideEvent.defaultPrevented) {
|
|
278
241
|
return;
|
|
279
242
|
}
|
|
280
|
-
|
|
281
243
|
const tip = this._getTipElement();
|
|
244
|
+
tip.classList.remove(CLASS_NAME_SHOW);
|
|
282
245
|
|
|
283
|
-
|
|
246
|
+
// If this is a touch-enabled device we remove the extra
|
|
284
247
|
// empty mouseover listeners we added for iOS support
|
|
285
|
-
|
|
286
248
|
if ('ontouchstart' in document.documentElement) {
|
|
287
249
|
for (const element of [].concat(...document.body.children)) {
|
|
288
|
-
EventHandler__default.default.off(element, 'mouseover',
|
|
250
|
+
EventHandler__default.default.off(element, 'mouseover', index_js.noop);
|
|
289
251
|
}
|
|
290
252
|
}
|
|
291
|
-
|
|
292
253
|
this._activeTrigger[TRIGGER_CLICK] = false;
|
|
293
254
|
this._activeTrigger[TRIGGER_FOCUS] = false;
|
|
294
255
|
this._activeTrigger[TRIGGER_HOVER] = false;
|
|
295
|
-
this._isHovered =
|
|
256
|
+
this._isHovered = null; // it is a trick to support manual triggering
|
|
296
257
|
|
|
297
258
|
const complete = () => {
|
|
298
259
|
if (this._isWithActiveTrigger()) {
|
|
299
260
|
return;
|
|
300
261
|
}
|
|
301
|
-
|
|
302
262
|
if (!this._isHovered) {
|
|
303
|
-
|
|
263
|
+
this._disposePopper();
|
|
304
264
|
}
|
|
305
|
-
|
|
306
265
|
this._element.removeAttribute('aria-describedby');
|
|
307
|
-
|
|
308
266
|
EventHandler__default.default.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN));
|
|
309
|
-
|
|
310
|
-
this._disposePopper();
|
|
311
267
|
};
|
|
312
|
-
|
|
313
268
|
this._queueCallback(complete, this.tip, this._isAnimated());
|
|
314
269
|
}
|
|
315
|
-
|
|
316
270
|
update() {
|
|
317
271
|
if (this._popper) {
|
|
318
272
|
this._popper.update();
|
|
319
273
|
}
|
|
320
|
-
}
|
|
321
|
-
|
|
274
|
+
}
|
|
322
275
|
|
|
276
|
+
// Protected
|
|
323
277
|
_isWithContent() {
|
|
324
278
|
return Boolean(this._getTitle());
|
|
325
279
|
}
|
|
326
|
-
|
|
327
280
|
_getTipElement() {
|
|
328
281
|
if (!this.tip) {
|
|
329
|
-
this.tip = this._createTipElement(this._getContentForTemplate());
|
|
282
|
+
this.tip = this._createTipElement(this._newContent || this._getContentForTemplate());
|
|
330
283
|
}
|
|
331
|
-
|
|
332
284
|
return this.tip;
|
|
333
285
|
}
|
|
334
|
-
|
|
335
286
|
_createTipElement(content) {
|
|
336
|
-
const tip = this._getTemplateFactory(content).toHtml();
|
|
337
|
-
|
|
287
|
+
const tip = this._getTemplateFactory(content).toHtml();
|
|
338
288
|
|
|
289
|
+
// todo: remove this check on v6
|
|
339
290
|
if (!tip) {
|
|
340
291
|
return null;
|
|
341
292
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
293
|
+
tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW);
|
|
294
|
+
// todo: on v6 the following can be achieved with CSS only
|
|
345
295
|
tip.classList.add(`bs-${this.constructor.NAME}-auto`);
|
|
346
|
-
const tipId =
|
|
296
|
+
const tipId = index_js.getUID(this.constructor.NAME).toString();
|
|
347
297
|
tip.setAttribute('id', tipId);
|
|
348
|
-
|
|
349
298
|
if (this._isAnimated()) {
|
|
350
299
|
tip.classList.add(CLASS_NAME_FADE);
|
|
351
300
|
}
|
|
352
|
-
|
|
353
301
|
return tip;
|
|
354
302
|
}
|
|
355
|
-
|
|
356
303
|
setContent(content) {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
isShown = this._isShown();
|
|
361
|
-
this.tip.remove();
|
|
362
|
-
this.tip = null;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
this._disposePopper();
|
|
366
|
-
|
|
367
|
-
this.tip = this._createTipElement(content);
|
|
368
|
-
|
|
369
|
-
if (isShown) {
|
|
304
|
+
this._newContent = content;
|
|
305
|
+
if (this._isShown()) {
|
|
306
|
+
this._disposePopper();
|
|
370
307
|
this.show();
|
|
371
308
|
}
|
|
372
309
|
}
|
|
373
|
-
|
|
374
310
|
_getTemplateFactory(content) {
|
|
375
311
|
if (this._templateFactory) {
|
|
376
312
|
this._templateFactory.changeContent(content);
|
|
377
313
|
} else {
|
|
378
|
-
this._templateFactory = new TemplateFactory__default.default({
|
|
314
|
+
this._templateFactory = new TemplateFactory__default.default({
|
|
315
|
+
...this._config,
|
|
379
316
|
// the `content` var has to be after `this._config`
|
|
380
317
|
// to override config.content in case of popover
|
|
381
318
|
content,
|
|
382
319
|
extraClass: this._resolvePossibleFunction(this._config.customClass)
|
|
383
320
|
});
|
|
384
321
|
}
|
|
385
|
-
|
|
386
322
|
return this._templateFactory;
|
|
387
323
|
}
|
|
388
|
-
|
|
389
324
|
_getContentForTemplate() {
|
|
390
325
|
return {
|
|
391
326
|
[SELECTOR_TOOLTIP_INNER]: this._getTitle()
|
|
392
327
|
};
|
|
393
328
|
}
|
|
394
|
-
|
|
395
329
|
_getTitle() {
|
|
396
|
-
return this._config.title;
|
|
397
|
-
}
|
|
398
|
-
|
|
330
|
+
return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('data-coreui-original-title');
|
|
331
|
+
}
|
|
399
332
|
|
|
333
|
+
// Private
|
|
400
334
|
_initializeOnDelegatedTarget(event) {
|
|
401
335
|
return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
|
|
402
336
|
}
|
|
403
|
-
|
|
404
337
|
_isAnimated() {
|
|
405
338
|
return this._config.animation || this.tip && this.tip.classList.contains(CLASS_NAME_FADE);
|
|
406
339
|
}
|
|
407
|
-
|
|
408
340
|
_isShown() {
|
|
409
341
|
return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW);
|
|
410
342
|
}
|
|
411
|
-
|
|
412
343
|
_createPopper(tip) {
|
|
413
|
-
const placement =
|
|
344
|
+
const placement = index_js.execute(this._config.placement, [this, tip, this._element]);
|
|
414
345
|
const attachment = AttachmentMap[placement.toUpperCase()];
|
|
415
|
-
|
|
346
|
+
return Popper__namespace.createPopper(this._element, tip, this._getPopperConfig(attachment));
|
|
416
347
|
}
|
|
417
|
-
|
|
418
348
|
_getOffset() {
|
|
419
349
|
const {
|
|
420
350
|
offset
|
|
421
351
|
} = this._config;
|
|
422
|
-
|
|
423
352
|
if (typeof offset === 'string') {
|
|
424
353
|
return offset.split(',').map(value => Number.parseInt(value, 10));
|
|
425
354
|
}
|
|
426
|
-
|
|
427
355
|
if (typeof offset === 'function') {
|
|
428
356
|
return popperData => offset(popperData, this._element);
|
|
429
357
|
}
|
|
430
|
-
|
|
431
358
|
return offset;
|
|
432
359
|
}
|
|
433
|
-
|
|
434
360
|
_resolvePossibleFunction(arg) {
|
|
435
|
-
return
|
|
361
|
+
return index_js.execute(arg, [this._element]);
|
|
436
362
|
}
|
|
437
|
-
|
|
438
363
|
_getPopperConfig(attachment) {
|
|
439
364
|
const defaultBsPopperConfig = {
|
|
440
365
|
placement: attachment,
|
|
@@ -469,198 +394,160 @@
|
|
|
469
394
|
}
|
|
470
395
|
}]
|
|
471
396
|
};
|
|
472
|
-
return {
|
|
473
|
-
...
|
|
397
|
+
return {
|
|
398
|
+
...defaultBsPopperConfig,
|
|
399
|
+
...index_js.execute(this._config.popperConfig, [defaultBsPopperConfig])
|
|
474
400
|
};
|
|
475
401
|
}
|
|
476
|
-
|
|
477
402
|
_setListeners() {
|
|
478
403
|
const triggers = this._config.trigger.split(' ');
|
|
479
|
-
|
|
480
404
|
for (const trigger of triggers) {
|
|
481
405
|
if (trigger === 'click') {
|
|
482
|
-
EventHandler__default.default.on(this._element, this.constructor.eventName(EVENT_CLICK), this._config.selector, event =>
|
|
406
|
+
EventHandler__default.default.on(this._element, this.constructor.eventName(EVENT_CLICK), this._config.selector, event => {
|
|
407
|
+
const context = this._initializeOnDelegatedTarget(event);
|
|
408
|
+
context.toggle();
|
|
409
|
+
});
|
|
483
410
|
} else if (trigger !== TRIGGER_MANUAL) {
|
|
484
411
|
const eventIn = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : this.constructor.eventName(EVENT_FOCUSIN);
|
|
485
412
|
const eventOut = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSELEAVE) : this.constructor.eventName(EVENT_FOCUSOUT);
|
|
486
413
|
EventHandler__default.default.on(this._element, eventIn, this._config.selector, event => {
|
|
487
414
|
const context = this._initializeOnDelegatedTarget(event);
|
|
488
|
-
|
|
489
415
|
context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
|
|
490
|
-
|
|
491
416
|
context._enter();
|
|
492
417
|
});
|
|
493
418
|
EventHandler__default.default.on(this._element, eventOut, this._config.selector, event => {
|
|
494
419
|
const context = this._initializeOnDelegatedTarget(event);
|
|
495
|
-
|
|
496
420
|
context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget);
|
|
497
|
-
|
|
498
421
|
context._leave();
|
|
499
422
|
});
|
|
500
423
|
}
|
|
501
424
|
}
|
|
502
|
-
|
|
503
425
|
this._hideModalHandler = () => {
|
|
504
426
|
if (this._element) {
|
|
505
427
|
this.hide();
|
|
506
428
|
}
|
|
507
429
|
};
|
|
508
|
-
|
|
509
430
|
EventHandler__default.default.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
|
|
510
|
-
|
|
511
|
-
if (this._config.selector) {
|
|
512
|
-
this._config = { ...this._config,
|
|
513
|
-
trigger: 'manual',
|
|
514
|
-
selector: ''
|
|
515
|
-
};
|
|
516
|
-
} else {
|
|
517
|
-
this._fixTitle();
|
|
518
|
-
}
|
|
519
431
|
}
|
|
520
|
-
|
|
521
432
|
_fixTitle() {
|
|
522
|
-
const title = this.
|
|
523
|
-
|
|
433
|
+
const title = this._element.getAttribute('title');
|
|
524
434
|
if (!title) {
|
|
525
435
|
return;
|
|
526
436
|
}
|
|
527
|
-
|
|
528
|
-
if (!this._element.getAttribute('aria-label') && !this._element.textContent) {
|
|
437
|
+
if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) {
|
|
529
438
|
this._element.setAttribute('aria-label', title);
|
|
530
439
|
}
|
|
531
|
-
|
|
440
|
+
this._element.setAttribute('data-coreui-original-title', title); // DO NOT USE IT. Is only for backwards compatibility
|
|
532
441
|
this._element.removeAttribute('title');
|
|
533
442
|
}
|
|
534
|
-
|
|
535
443
|
_enter() {
|
|
536
444
|
if (this._isShown() || this._isHovered) {
|
|
537
445
|
this._isHovered = true;
|
|
538
446
|
return;
|
|
539
447
|
}
|
|
540
|
-
|
|
541
448
|
this._isHovered = true;
|
|
542
|
-
|
|
543
449
|
this._setTimeout(() => {
|
|
544
450
|
if (this._isHovered) {
|
|
545
451
|
this.show();
|
|
546
452
|
}
|
|
547
453
|
}, this._config.delay.show);
|
|
548
454
|
}
|
|
549
|
-
|
|
550
455
|
_leave() {
|
|
551
456
|
if (this._isWithActiveTrigger()) {
|
|
552
457
|
return;
|
|
553
458
|
}
|
|
554
|
-
|
|
555
459
|
this._isHovered = false;
|
|
556
|
-
|
|
557
460
|
this._setTimeout(() => {
|
|
558
461
|
if (!this._isHovered) {
|
|
559
462
|
this.hide();
|
|
560
463
|
}
|
|
561
464
|
}, this._config.delay.hide);
|
|
562
465
|
}
|
|
563
|
-
|
|
564
466
|
_setTimeout(handler, timeout) {
|
|
565
467
|
clearTimeout(this._timeout);
|
|
566
468
|
this._timeout = setTimeout(handler, timeout);
|
|
567
469
|
}
|
|
568
|
-
|
|
569
470
|
_isWithActiveTrigger() {
|
|
570
471
|
return Object.values(this._activeTrigger).includes(true);
|
|
571
472
|
}
|
|
572
|
-
|
|
573
473
|
_getConfig(config) {
|
|
574
474
|
const dataAttributes = Manipulator__default.default.getDataAttributes(this._element);
|
|
575
|
-
|
|
576
475
|
for (const dataAttribute of Object.keys(dataAttributes)) {
|
|
577
476
|
if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) {
|
|
578
477
|
delete dataAttributes[dataAttribute];
|
|
579
478
|
}
|
|
580
479
|
}
|
|
581
|
-
|
|
582
|
-
|
|
480
|
+
config = {
|
|
481
|
+
...dataAttributes,
|
|
583
482
|
...(typeof config === 'object' && config ? config : {})
|
|
584
483
|
};
|
|
585
484
|
config = this._mergeConfigObj(config);
|
|
586
485
|
config = this._configAfterMerge(config);
|
|
587
|
-
|
|
588
486
|
this._typeCheckConfig(config);
|
|
589
|
-
|
|
590
487
|
return config;
|
|
591
488
|
}
|
|
592
|
-
|
|
593
489
|
_configAfterMerge(config) {
|
|
594
|
-
config.container = config.container === false ? document.body :
|
|
595
|
-
|
|
490
|
+
config.container = config.container === false ? document.body : index_js.getElement(config.container);
|
|
596
491
|
if (typeof config.delay === 'number') {
|
|
597
492
|
config.delay = {
|
|
598
493
|
show: config.delay,
|
|
599
494
|
hide: config.delay
|
|
600
495
|
};
|
|
601
496
|
}
|
|
602
|
-
|
|
603
|
-
config.originalTitle = this._element.getAttribute('title') || '';
|
|
604
|
-
config.title = this._resolvePossibleFunction(config.title) || config.originalTitle;
|
|
605
|
-
|
|
606
497
|
if (typeof config.title === 'number') {
|
|
607
498
|
config.title = config.title.toString();
|
|
608
499
|
}
|
|
609
|
-
|
|
610
500
|
if (typeof config.content === 'number') {
|
|
611
501
|
config.content = config.content.toString();
|
|
612
502
|
}
|
|
613
|
-
|
|
614
503
|
return config;
|
|
615
504
|
}
|
|
616
|
-
|
|
617
505
|
_getDelegateConfig() {
|
|
618
506
|
const config = {};
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
config[key] = this._config[key];
|
|
507
|
+
for (const [key, value] of Object.entries(this._config)) {
|
|
508
|
+
if (this.constructor.Default[key] !== value) {
|
|
509
|
+
config[key] = value;
|
|
623
510
|
}
|
|
624
|
-
}
|
|
511
|
+
}
|
|
512
|
+
config.selector = false;
|
|
513
|
+
config.trigger = 'manual';
|
|
514
|
+
|
|
515
|
+
// In the future can be replaced with:
|
|
625
516
|
// const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]])
|
|
626
517
|
// `Object.fromEntries(keysWithDifferentValues)`
|
|
627
|
-
|
|
628
|
-
|
|
629
518
|
return config;
|
|
630
519
|
}
|
|
631
|
-
|
|
632
520
|
_disposePopper() {
|
|
633
521
|
if (this._popper) {
|
|
634
522
|
this._popper.destroy();
|
|
635
|
-
|
|
636
523
|
this._popper = null;
|
|
637
524
|
}
|
|
638
|
-
|
|
639
|
-
|
|
525
|
+
if (this.tip) {
|
|
526
|
+
this.tip.remove();
|
|
527
|
+
this.tip = null;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
640
530
|
|
|
531
|
+
// Static
|
|
641
532
|
static jQueryInterface(config) {
|
|
642
533
|
return this.each(function () {
|
|
643
534
|
const data = Tooltip.getOrCreateInstance(this, config);
|
|
644
|
-
|
|
645
535
|
if (typeof config !== 'string') {
|
|
646
536
|
return;
|
|
647
537
|
}
|
|
648
|
-
|
|
649
538
|
if (typeof data[config] === 'undefined') {
|
|
650
539
|
throw new TypeError(`No method named "${config}"`);
|
|
651
540
|
}
|
|
652
|
-
|
|
653
541
|
data[config]();
|
|
654
542
|
});
|
|
655
543
|
}
|
|
656
|
-
|
|
657
544
|
}
|
|
545
|
+
|
|
658
546
|
/**
|
|
659
547
|
* jQuery
|
|
660
548
|
*/
|
|
661
549
|
|
|
662
|
-
|
|
663
|
-
index.defineJQueryPlugin(Tooltip);
|
|
550
|
+
index_js.defineJQueryPlugin(Tooltip);
|
|
664
551
|
|
|
665
552
|
return Tooltip;
|
|
666
553
|
|