bootstrap 5.1.3 → 5.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -4
- data/assets/javascripts/bootstrap/alert.js +11 -146
- data/assets/javascripts/bootstrap/base-component.js +37 -120
- data/assets/javascripts/bootstrap/button.js +10 -74
- data/assets/javascripts/bootstrap/carousel.js +213 -485
- data/assets/javascripts/bootstrap/collapse.js +65 -249
- data/assets/javascripts/bootstrap/dom/data.js +3 -5
- data/assets/javascripts/bootstrap/dom/event-handler.js +94 -132
- data/assets/javascripts/bootstrap/dom/manipulator.js +23 -27
- data/assets/javascripts/bootstrap/dom/selector-engine.js +16 -58
- data/assets/javascripts/bootstrap/dropdown.js +103 -317
- data/assets/javascripts/bootstrap/modal.js +107 -749
- data/assets/javascripts/bootstrap/offcanvas.js +90 -659
- data/assets/javascripts/bootstrap/popover.js +36 -118
- data/assets/javascripts/bootstrap/scrollspy.js +183 -262
- data/assets/javascripts/bootstrap/tab.js +215 -214
- data/assets/javascripts/bootstrap/toast.js +28 -214
- data/assets/javascripts/bootstrap/tooltip.js +272 -611
- data/assets/javascripts/bootstrap/util/backdrop.js +165 -0
- data/assets/javascripts/bootstrap/util/component-functions.js +46 -0
- data/assets/javascripts/bootstrap/util/config.js +79 -0
- data/assets/javascripts/bootstrap/util/focustrap.js +129 -0
- data/assets/javascripts/bootstrap/util/index.js +350 -0
- data/assets/javascripts/bootstrap/util/sanitizer.js +122 -0
- data/assets/javascripts/bootstrap/util/scrollbar.js +138 -0
- data/assets/javascripts/bootstrap/util/swipe.js +155 -0
- data/assets/javascripts/bootstrap/util/template-factory.js +177 -0
- data/assets/javascripts/bootstrap-global-this-define.js +1 -1
- data/assets/javascripts/bootstrap-sprockets.js +10 -1
- data/assets/javascripts/bootstrap.js +2077 -1859
- data/assets/javascripts/bootstrap.min.js +3 -3
- data/assets/stylesheets/_bootstrap-grid.scss +3 -6
- data/assets/stylesheets/_bootstrap-reboot.scss +3 -7
- data/assets/stylesheets/_bootstrap.scss +4 -6
- data/assets/stylesheets/bootstrap/_accordion.scss +56 -25
- data/assets/stylesheets/bootstrap/_alert.scss +18 -4
- data/assets/stylesheets/bootstrap/_badge.scss +14 -5
- data/assets/stylesheets/bootstrap/_breadcrumb.scss +22 -10
- data/assets/stylesheets/bootstrap/_button-group.scss +4 -1
- data/assets/stylesheets/bootstrap/_buttons.scss +120 -30
- data/assets/stylesheets/bootstrap/_card.scss +55 -37
- data/assets/stylesheets/bootstrap/_close.scss +1 -1
- data/assets/stylesheets/bootstrap/_containers.scss +1 -1
- data/assets/stylesheets/bootstrap/_dropdown.scss +85 -76
- data/assets/stylesheets/bootstrap/_functions.scss +8 -8
- data/assets/stylesheets/bootstrap/_grid.scss +3 -3
- data/assets/stylesheets/bootstrap/_helpers.scss +1 -0
- data/assets/stylesheets/bootstrap/_list-group.scss +48 -30
- data/assets/stylesheets/bootstrap/_maps.scss +54 -0
- data/assets/stylesheets/bootstrap/_modal.scss +71 -43
- data/assets/stylesheets/bootstrap/_nav.scss +53 -20
- data/assets/stylesheets/bootstrap/_navbar.scss +93 -150
- data/assets/stylesheets/bootstrap/_offcanvas.scss +120 -59
- data/assets/stylesheets/bootstrap/_pagination.scss +66 -21
- data/assets/stylesheets/bootstrap/_placeholders.scss +1 -1
- data/assets/stylesheets/bootstrap/_popover.scss +90 -52
- data/assets/stylesheets/bootstrap/_progress.scss +20 -9
- data/assets/stylesheets/bootstrap/_reboot.scss +25 -40
- data/assets/stylesheets/bootstrap/_root.scss +40 -21
- data/assets/stylesheets/bootstrap/_spinners.scss +38 -22
- data/assets/stylesheets/bootstrap/_tables.scss +32 -23
- data/assets/stylesheets/bootstrap/_toasts.scss +36 -16
- data/assets/stylesheets/bootstrap/_tooltip.scss +61 -56
- data/assets/stylesheets/bootstrap/_type.scss +2 -0
- data/assets/stylesheets/bootstrap/_utilities.scss +43 -26
- data/assets/stylesheets/bootstrap/_variables.scss +128 -135
- data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +3 -6
- data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +15 -3
- data/assets/stylesheets/bootstrap/forms/_form-check.scss +28 -5
- data/assets/stylesheets/bootstrap/forms/_form-control.scss +12 -37
- data/assets/stylesheets/bootstrap/forms/_form-select.scss +0 -1
- data/assets/stylesheets/bootstrap/forms/_input-group.scss +19 -8
- data/assets/stylesheets/bootstrap/helpers/_color-bg.scss +10 -0
- data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +2 -2
- data/assets/stylesheets/bootstrap/helpers/_position.scss +7 -1
- data/assets/stylesheets/bootstrap/helpers/_ratio.scss +2 -2
- data/assets/stylesheets/bootstrap/helpers/_vr.scss +1 -1
- data/assets/stylesheets/bootstrap/mixins/_alert.scss +7 -3
- data/assets/stylesheets/bootstrap/mixins/_banner.scss +9 -0
- data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +8 -8
- data/assets/stylesheets/bootstrap/mixins/_buttons.scss +32 -95
- data/assets/stylesheets/bootstrap/mixins/_container.scss +4 -2
- data/assets/stylesheets/bootstrap/mixins/_forms.scss +18 -10
- data/assets/stylesheets/bootstrap/mixins/_gradients.scss +1 -1
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +12 -12
- data/assets/stylesheets/bootstrap/mixins/_pagination.scss +4 -25
- data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +1 -1
- data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +12 -9
- data/assets/stylesheets/bootstrap/mixins/_utilities.scss +13 -5
- data/bootstrap.gemspec +1 -1
- data/lib/bootstrap/version.rb +2 -2
- data/tasks/updater/js.rb +10 -5
- metadata +16 -4
@@ -0,0 +1,350 @@
|
|
1
|
+
/*!
|
2
|
+
* Bootstrap index.js v5.2.1 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
|
+
*/
|
6
|
+
(function (global, factory) {
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Index = {}));
|
10
|
+
})(this, (function (exports) { 'use strict';
|
11
|
+
|
12
|
+
/**
|
13
|
+
* --------------------------------------------------------------------------
|
14
|
+
* Bootstrap (v5.2.1): util/index.js
|
15
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
16
|
+
* --------------------------------------------------------------------------
|
17
|
+
*/
|
18
|
+
const MAX_UID = 1000000;
|
19
|
+
const MILLISECONDS_MULTIPLIER = 1000;
|
20
|
+
const TRANSITION_END = 'transitionend'; // Shout-out Angus Croll (https://goo.gl/pxwQGp)
|
21
|
+
|
22
|
+
const toType = object => {
|
23
|
+
if (object === null || object === undefined) {
|
24
|
+
return `${object}`;
|
25
|
+
}
|
26
|
+
|
27
|
+
return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase();
|
28
|
+
};
|
29
|
+
/**
|
30
|
+
* Public Util API
|
31
|
+
*/
|
32
|
+
|
33
|
+
|
34
|
+
const getUID = prefix => {
|
35
|
+
do {
|
36
|
+
prefix += Math.floor(Math.random() * MAX_UID);
|
37
|
+
} while (document.getElementById(prefix));
|
38
|
+
|
39
|
+
return prefix;
|
40
|
+
};
|
41
|
+
|
42
|
+
const getSelector = element => {
|
43
|
+
let selector = element.getAttribute('data-bs-target');
|
44
|
+
|
45
|
+
if (!selector || selector === '#') {
|
46
|
+
let hrefAttribute = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
|
47
|
+
// so everything starting with `#` or `.`. If a "real" URL is used as the selector,
|
48
|
+
// `document.querySelector` will rightfully complain it is invalid.
|
49
|
+
// See https://github.com/twbs/bootstrap/issues/32273
|
50
|
+
|
51
|
+
if (!hrefAttribute || !hrefAttribute.includes('#') && !hrefAttribute.startsWith('.')) {
|
52
|
+
return null;
|
53
|
+
} // Just in case some CMS puts out a full URL with the anchor appended
|
54
|
+
|
55
|
+
|
56
|
+
if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) {
|
57
|
+
hrefAttribute = `#${hrefAttribute.split('#')[1]}`;
|
58
|
+
}
|
59
|
+
|
60
|
+
selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null;
|
61
|
+
}
|
62
|
+
|
63
|
+
return selector;
|
64
|
+
};
|
65
|
+
|
66
|
+
const getSelectorFromElement = element => {
|
67
|
+
const selector = getSelector(element);
|
68
|
+
|
69
|
+
if (selector) {
|
70
|
+
return document.querySelector(selector) ? selector : null;
|
71
|
+
}
|
72
|
+
|
73
|
+
return null;
|
74
|
+
};
|
75
|
+
|
76
|
+
const getElementFromSelector = element => {
|
77
|
+
const selector = getSelector(element);
|
78
|
+
return selector ? document.querySelector(selector) : null;
|
79
|
+
};
|
80
|
+
|
81
|
+
const getTransitionDurationFromElement = element => {
|
82
|
+
if (!element) {
|
83
|
+
return 0;
|
84
|
+
} // Get transition-duration of the element
|
85
|
+
|
86
|
+
|
87
|
+
let {
|
88
|
+
transitionDuration,
|
89
|
+
transitionDelay
|
90
|
+
} = window.getComputedStyle(element);
|
91
|
+
const floatTransitionDuration = Number.parseFloat(transitionDuration);
|
92
|
+
const floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
|
93
|
+
|
94
|
+
if (!floatTransitionDuration && !floatTransitionDelay) {
|
95
|
+
return 0;
|
96
|
+
} // If multiple durations are defined, take the first
|
97
|
+
|
98
|
+
|
99
|
+
transitionDuration = transitionDuration.split(',')[0];
|
100
|
+
transitionDelay = transitionDelay.split(',')[0];
|
101
|
+
return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
|
102
|
+
};
|
103
|
+
|
104
|
+
const triggerTransitionEnd = element => {
|
105
|
+
element.dispatchEvent(new Event(TRANSITION_END));
|
106
|
+
};
|
107
|
+
|
108
|
+
const isElement = object => {
|
109
|
+
if (!object || typeof object !== 'object') {
|
110
|
+
return false;
|
111
|
+
}
|
112
|
+
|
113
|
+
if (typeof object.jquery !== 'undefined') {
|
114
|
+
object = object[0];
|
115
|
+
}
|
116
|
+
|
117
|
+
return typeof object.nodeType !== 'undefined';
|
118
|
+
};
|
119
|
+
|
120
|
+
const getElement = object => {
|
121
|
+
// it's a jQuery object or a node element
|
122
|
+
if (isElement(object)) {
|
123
|
+
return object.jquery ? object[0] : object;
|
124
|
+
}
|
125
|
+
|
126
|
+
if (typeof object === 'string' && object.length > 0) {
|
127
|
+
return document.querySelector(object);
|
128
|
+
}
|
129
|
+
|
130
|
+
return null;
|
131
|
+
};
|
132
|
+
|
133
|
+
const isVisible = element => {
|
134
|
+
if (!isElement(element) || element.getClientRects().length === 0) {
|
135
|
+
return false;
|
136
|
+
}
|
137
|
+
|
138
|
+
const elementIsVisible = getComputedStyle(element).getPropertyValue('visibility') === 'visible'; // Handle `details` element as its content may falsie appear visible when it is closed
|
139
|
+
|
140
|
+
const closedDetails = element.closest('details:not([open])');
|
141
|
+
|
142
|
+
if (!closedDetails) {
|
143
|
+
return elementIsVisible;
|
144
|
+
}
|
145
|
+
|
146
|
+
if (closedDetails !== element) {
|
147
|
+
const summary = element.closest('summary');
|
148
|
+
|
149
|
+
if (summary && summary.parentNode !== closedDetails) {
|
150
|
+
return false;
|
151
|
+
}
|
152
|
+
|
153
|
+
if (summary === null) {
|
154
|
+
return false;
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
return elementIsVisible;
|
159
|
+
};
|
160
|
+
|
161
|
+
const isDisabled = element => {
|
162
|
+
if (!element || element.nodeType !== Node.ELEMENT_NODE) {
|
163
|
+
return true;
|
164
|
+
}
|
165
|
+
|
166
|
+
if (element.classList.contains('disabled')) {
|
167
|
+
return true;
|
168
|
+
}
|
169
|
+
|
170
|
+
if (typeof element.disabled !== 'undefined') {
|
171
|
+
return element.disabled;
|
172
|
+
}
|
173
|
+
|
174
|
+
return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
|
175
|
+
};
|
176
|
+
|
177
|
+
const findShadowRoot = element => {
|
178
|
+
if (!document.documentElement.attachShadow) {
|
179
|
+
return null;
|
180
|
+
} // Can find the shadow root otherwise it'll return the document
|
181
|
+
|
182
|
+
|
183
|
+
if (typeof element.getRootNode === 'function') {
|
184
|
+
const root = element.getRootNode();
|
185
|
+
return root instanceof ShadowRoot ? root : null;
|
186
|
+
}
|
187
|
+
|
188
|
+
if (element instanceof ShadowRoot) {
|
189
|
+
return element;
|
190
|
+
} // when we don't find a shadow root
|
191
|
+
|
192
|
+
|
193
|
+
if (!element.parentNode) {
|
194
|
+
return null;
|
195
|
+
}
|
196
|
+
|
197
|
+
return findShadowRoot(element.parentNode);
|
198
|
+
};
|
199
|
+
|
200
|
+
const noop = () => {};
|
201
|
+
/**
|
202
|
+
* Trick to restart an element's animation
|
203
|
+
*
|
204
|
+
* @param {HTMLElement} element
|
205
|
+
* @return void
|
206
|
+
*
|
207
|
+
* @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
|
208
|
+
*/
|
209
|
+
|
210
|
+
|
211
|
+
const reflow = element => {
|
212
|
+
element.offsetHeight; // eslint-disable-line no-unused-expressions
|
213
|
+
};
|
214
|
+
|
215
|
+
const getjQuery = () => {
|
216
|
+
if (window.jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
|
217
|
+
return window.jQuery;
|
218
|
+
}
|
219
|
+
|
220
|
+
return null;
|
221
|
+
};
|
222
|
+
|
223
|
+
const DOMContentLoadedCallbacks = [];
|
224
|
+
|
225
|
+
const onDOMContentLoaded = callback => {
|
226
|
+
if (document.readyState === 'loading') {
|
227
|
+
// add listener on the first call when the document is in loading state
|
228
|
+
if (!DOMContentLoadedCallbacks.length) {
|
229
|
+
document.addEventListener('DOMContentLoaded', () => {
|
230
|
+
for (const callback of DOMContentLoadedCallbacks) {
|
231
|
+
callback();
|
232
|
+
}
|
233
|
+
});
|
234
|
+
}
|
235
|
+
|
236
|
+
DOMContentLoadedCallbacks.push(callback);
|
237
|
+
} else {
|
238
|
+
callback();
|
239
|
+
}
|
240
|
+
};
|
241
|
+
|
242
|
+
const isRTL = () => document.documentElement.dir === 'rtl';
|
243
|
+
|
244
|
+
const defineJQueryPlugin = plugin => {
|
245
|
+
onDOMContentLoaded(() => {
|
246
|
+
const $ = getjQuery();
|
247
|
+
/* istanbul ignore if */
|
248
|
+
|
249
|
+
if ($) {
|
250
|
+
const name = plugin.NAME;
|
251
|
+
const JQUERY_NO_CONFLICT = $.fn[name];
|
252
|
+
$.fn[name] = plugin.jQueryInterface;
|
253
|
+
$.fn[name].Constructor = plugin;
|
254
|
+
|
255
|
+
$.fn[name].noConflict = () => {
|
256
|
+
$.fn[name] = JQUERY_NO_CONFLICT;
|
257
|
+
return plugin.jQueryInterface;
|
258
|
+
};
|
259
|
+
}
|
260
|
+
});
|
261
|
+
};
|
262
|
+
|
263
|
+
const execute = callback => {
|
264
|
+
if (typeof callback === 'function') {
|
265
|
+
callback();
|
266
|
+
}
|
267
|
+
};
|
268
|
+
|
269
|
+
const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
|
270
|
+
if (!waitForTransition) {
|
271
|
+
execute(callback);
|
272
|
+
return;
|
273
|
+
}
|
274
|
+
|
275
|
+
const durationPadding = 5;
|
276
|
+
const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
|
277
|
+
let called = false;
|
278
|
+
|
279
|
+
const handler = ({
|
280
|
+
target
|
281
|
+
}) => {
|
282
|
+
if (target !== transitionElement) {
|
283
|
+
return;
|
284
|
+
}
|
285
|
+
|
286
|
+
called = true;
|
287
|
+
transitionElement.removeEventListener(TRANSITION_END, handler);
|
288
|
+
execute(callback);
|
289
|
+
};
|
290
|
+
|
291
|
+
transitionElement.addEventListener(TRANSITION_END, handler);
|
292
|
+
setTimeout(() => {
|
293
|
+
if (!called) {
|
294
|
+
triggerTransitionEnd(transitionElement);
|
295
|
+
}
|
296
|
+
}, emulatedDuration);
|
297
|
+
};
|
298
|
+
/**
|
299
|
+
* Return the previous/next element of a list.
|
300
|
+
*
|
301
|
+
* @param {array} list The list of elements
|
302
|
+
* @param activeElement The active element
|
303
|
+
* @param shouldGetNext Choose to get next or previous element
|
304
|
+
* @param isCycleAllowed
|
305
|
+
* @return {Element|elem} The proper element
|
306
|
+
*/
|
307
|
+
|
308
|
+
|
309
|
+
const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
|
310
|
+
const listLength = list.length;
|
311
|
+
let index = list.indexOf(activeElement); // if the element does not exist in the list return an element
|
312
|
+
// depending on the direction and if cycle is allowed
|
313
|
+
|
314
|
+
if (index === -1) {
|
315
|
+
return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0];
|
316
|
+
}
|
317
|
+
|
318
|
+
index += shouldGetNext ? 1 : -1;
|
319
|
+
|
320
|
+
if (isCycleAllowed) {
|
321
|
+
index = (index + listLength) % listLength;
|
322
|
+
}
|
323
|
+
|
324
|
+
return list[Math.max(0, Math.min(index, listLength - 1))];
|
325
|
+
};
|
326
|
+
|
327
|
+
exports.defineJQueryPlugin = defineJQueryPlugin;
|
328
|
+
exports.execute = execute;
|
329
|
+
exports.executeAfterTransition = executeAfterTransition;
|
330
|
+
exports.findShadowRoot = findShadowRoot;
|
331
|
+
exports.getElement = getElement;
|
332
|
+
exports.getElementFromSelector = getElementFromSelector;
|
333
|
+
exports.getNextActiveElement = getNextActiveElement;
|
334
|
+
exports.getSelectorFromElement = getSelectorFromElement;
|
335
|
+
exports.getTransitionDurationFromElement = getTransitionDurationFromElement;
|
336
|
+
exports.getUID = getUID;
|
337
|
+
exports.getjQuery = getjQuery;
|
338
|
+
exports.isDisabled = isDisabled;
|
339
|
+
exports.isElement = isElement;
|
340
|
+
exports.isRTL = isRTL;
|
341
|
+
exports.isVisible = isVisible;
|
342
|
+
exports.noop = noop;
|
343
|
+
exports.onDOMContentLoaded = onDOMContentLoaded;
|
344
|
+
exports.reflow = reflow;
|
345
|
+
exports.toType = toType;
|
346
|
+
exports.triggerTransitionEnd = triggerTransitionEnd;
|
347
|
+
|
348
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
349
|
+
|
350
|
+
}));
|
@@ -0,0 +1,122 @@
|
|
1
|
+
/*!
|
2
|
+
* Bootstrap sanitizer.js v5.2.1 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
|
+
*/
|
6
|
+
(function (global, factory) {
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Sanitizer = {}));
|
10
|
+
})(this, (function (exports) { 'use strict';
|
11
|
+
|
12
|
+
/**
|
13
|
+
* --------------------------------------------------------------------------
|
14
|
+
* Bootstrap (v5.2.1): util/sanitizer.js
|
15
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
16
|
+
* --------------------------------------------------------------------------
|
17
|
+
*/
|
18
|
+
const uriAttributes = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']);
|
19
|
+
const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
|
20
|
+
/**
|
21
|
+
* A pattern that recognizes a commonly useful subset of URLs that are safe.
|
22
|
+
*
|
23
|
+
* Shout-out to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
|
24
|
+
*/
|
25
|
+
|
26
|
+
const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i;
|
27
|
+
/**
|
28
|
+
* A pattern that matches safe data URLs. Only matches image, video and audio types.
|
29
|
+
*
|
30
|
+
* Shout-out to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts
|
31
|
+
*/
|
32
|
+
|
33
|
+
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;
|
34
|
+
|
35
|
+
const allowedAttribute = (attribute, allowedAttributeList) => {
|
36
|
+
const attributeName = attribute.nodeName.toLowerCase();
|
37
|
+
|
38
|
+
if (allowedAttributeList.includes(attributeName)) {
|
39
|
+
if (uriAttributes.has(attributeName)) {
|
40
|
+
return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue) || DATA_URL_PATTERN.test(attribute.nodeValue));
|
41
|
+
}
|
42
|
+
|
43
|
+
return true;
|
44
|
+
} // Check if a regular expression validates the attribute.
|
45
|
+
|
46
|
+
|
47
|
+
return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp).some(regex => regex.test(attributeName));
|
48
|
+
};
|
49
|
+
|
50
|
+
const DefaultAllowlist = {
|
51
|
+
// Global attributes allowed on any supplied element below.
|
52
|
+
'*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
|
53
|
+
a: ['target', 'href', 'title', 'rel'],
|
54
|
+
area: [],
|
55
|
+
b: [],
|
56
|
+
br: [],
|
57
|
+
col: [],
|
58
|
+
code: [],
|
59
|
+
div: [],
|
60
|
+
em: [],
|
61
|
+
hr: [],
|
62
|
+
h1: [],
|
63
|
+
h2: [],
|
64
|
+
h3: [],
|
65
|
+
h4: [],
|
66
|
+
h5: [],
|
67
|
+
h6: [],
|
68
|
+
i: [],
|
69
|
+
img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
|
70
|
+
li: [],
|
71
|
+
ol: [],
|
72
|
+
p: [],
|
73
|
+
pre: [],
|
74
|
+
s: [],
|
75
|
+
small: [],
|
76
|
+
span: [],
|
77
|
+
sub: [],
|
78
|
+
sup: [],
|
79
|
+
strong: [],
|
80
|
+
u: [],
|
81
|
+
ul: []
|
82
|
+
};
|
83
|
+
function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) {
|
84
|
+
if (!unsafeHtml.length) {
|
85
|
+
return unsafeHtml;
|
86
|
+
}
|
87
|
+
|
88
|
+
if (sanitizeFunction && typeof sanitizeFunction === 'function') {
|
89
|
+
return sanitizeFunction(unsafeHtml);
|
90
|
+
}
|
91
|
+
|
92
|
+
const domParser = new window.DOMParser();
|
93
|
+
const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
|
94
|
+
const elements = [].concat(...createdDocument.body.querySelectorAll('*'));
|
95
|
+
|
96
|
+
for (const element of elements) {
|
97
|
+
const elementName = element.nodeName.toLowerCase();
|
98
|
+
|
99
|
+
if (!Object.keys(allowList).includes(elementName)) {
|
100
|
+
element.remove();
|
101
|
+
continue;
|
102
|
+
}
|
103
|
+
|
104
|
+
const attributeList = [].concat(...element.attributes);
|
105
|
+
const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []);
|
106
|
+
|
107
|
+
for (const attribute of attributeList) {
|
108
|
+
if (!allowedAttribute(attribute, allowedAttributes)) {
|
109
|
+
element.removeAttribute(attribute.nodeName);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
return createdDocument.body.innerHTML;
|
115
|
+
}
|
116
|
+
|
117
|
+
exports.DefaultAllowlist = DefaultAllowlist;
|
118
|
+
exports.sanitizeHtml = sanitizeHtml;
|
119
|
+
|
120
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
121
|
+
|
122
|
+
}));
|
@@ -0,0 +1,138 @@
|
|
1
|
+
/*!
|
2
|
+
* Bootstrap scrollbar.js v5.2.1 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
|
+
*/
|
6
|
+
(function (global, factory) {
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../dom/selector-engine'), require('../dom/manipulator'), require('./index')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['../dom/selector-engine', '../dom/manipulator', './index'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Scrollbar = factory(global.SelectorEngine, global.Manipulator, global.Index));
|
10
|
+
})(this, (function (SelectorEngine, Manipulator, index) { 'use strict';
|
11
|
+
|
12
|
+
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
13
|
+
|
14
|
+
const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
|
15
|
+
const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
|
16
|
+
|
17
|
+
/**
|
18
|
+
* --------------------------------------------------------------------------
|
19
|
+
* Bootstrap (v5.2.1): util/scrollBar.js
|
20
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
21
|
+
* --------------------------------------------------------------------------
|
22
|
+
*/
|
23
|
+
/**
|
24
|
+
* Constants
|
25
|
+
*/
|
26
|
+
|
27
|
+
const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
|
28
|
+
const SELECTOR_STICKY_CONTENT = '.sticky-top';
|
29
|
+
const PROPERTY_PADDING = 'padding-right';
|
30
|
+
const PROPERTY_MARGIN = 'margin-right';
|
31
|
+
/**
|
32
|
+
* Class definition
|
33
|
+
*/
|
34
|
+
|
35
|
+
class ScrollBarHelper {
|
36
|
+
constructor() {
|
37
|
+
this._element = document.body;
|
38
|
+
} // Public
|
39
|
+
|
40
|
+
|
41
|
+
getWidth() {
|
42
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
|
43
|
+
const documentWidth = document.documentElement.clientWidth;
|
44
|
+
return Math.abs(window.innerWidth - documentWidth);
|
45
|
+
}
|
46
|
+
|
47
|
+
hide() {
|
48
|
+
const width = this.getWidth();
|
49
|
+
|
50
|
+
this._disableOverFlow(); // give padding to element to balance the hidden scrollbar width
|
51
|
+
|
52
|
+
|
53
|
+
this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth
|
54
|
+
|
55
|
+
|
56
|
+
this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
|
57
|
+
|
58
|
+
this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width);
|
59
|
+
}
|
60
|
+
|
61
|
+
reset() {
|
62
|
+
this._resetElementAttributes(this._element, 'overflow');
|
63
|
+
|
64
|
+
this._resetElementAttributes(this._element, PROPERTY_PADDING);
|
65
|
+
|
66
|
+
this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING);
|
67
|
+
|
68
|
+
this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN);
|
69
|
+
}
|
70
|
+
|
71
|
+
isOverflowing() {
|
72
|
+
return this.getWidth() > 0;
|
73
|
+
} // Private
|
74
|
+
|
75
|
+
|
76
|
+
_disableOverFlow() {
|
77
|
+
this._saveInitialAttribute(this._element, 'overflow');
|
78
|
+
|
79
|
+
this._element.style.overflow = 'hidden';
|
80
|
+
}
|
81
|
+
|
82
|
+
_setElementAttributes(selector, styleProperty, callback) {
|
83
|
+
const scrollbarWidth = this.getWidth();
|
84
|
+
|
85
|
+
const manipulationCallBack = element => {
|
86
|
+
if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
|
87
|
+
return;
|
88
|
+
}
|
89
|
+
|
90
|
+
this._saveInitialAttribute(element, styleProperty);
|
91
|
+
|
92
|
+
const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty);
|
93
|
+
element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`);
|
94
|
+
};
|
95
|
+
|
96
|
+
this._applyManipulationCallback(selector, manipulationCallBack);
|
97
|
+
}
|
98
|
+
|
99
|
+
_saveInitialAttribute(element, styleProperty) {
|
100
|
+
const actualValue = element.style.getPropertyValue(styleProperty);
|
101
|
+
|
102
|
+
if (actualValue) {
|
103
|
+
Manipulator__default.default.setDataAttribute(element, styleProperty, actualValue);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
_resetElementAttributes(selector, styleProperty) {
|
108
|
+
const manipulationCallBack = element => {
|
109
|
+
const value = Manipulator__default.default.getDataAttribute(element, styleProperty); // We only want to remove the property if the value is `null`; the value can also be zero
|
110
|
+
|
111
|
+
if (value === null) {
|
112
|
+
element.style.removeProperty(styleProperty);
|
113
|
+
return;
|
114
|
+
}
|
115
|
+
|
116
|
+
Manipulator__default.default.removeDataAttribute(element, styleProperty);
|
117
|
+
element.style.setProperty(styleProperty, value);
|
118
|
+
};
|
119
|
+
|
120
|
+
this._applyManipulationCallback(selector, manipulationCallBack);
|
121
|
+
}
|
122
|
+
|
123
|
+
_applyManipulationCallback(selector, callBack) {
|
124
|
+
if (index.isElement(selector)) {
|
125
|
+
callBack(selector);
|
126
|
+
return;
|
127
|
+
}
|
128
|
+
|
129
|
+
for (const sel of SelectorEngine__default.default.find(selector, this._element)) {
|
130
|
+
callBack(sel);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
}
|
135
|
+
|
136
|
+
return ScrollBarHelper;
|
137
|
+
|
138
|
+
}));
|