administrate-bootstrap-theme 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/administrate-bootstrap-theme/_base.scss +14 -0
- data/app/assets/stylesheets/administrate-bootstrap-theme/components/_form.scss +16 -0
- data/lib/administrate-bootstrap-theme/version.rb +1 -1
- data/node_modules/bootstrap/LICENSE +22 -0
- data/node_modules/bootstrap/README.md +239 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.css +4997 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.min.css +7 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.rtl.css +4996 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.rtl.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.rtl.min.css +7 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.rtl.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.css +426 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.min.css +8 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.rtl.css +423 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.rtl.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.rtl.min.css +8 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.rtl.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.css +4752 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.min.css +7 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.rtl.css +4743 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.rtl.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.rtl.min.css +7 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.rtl.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap.css +10819 -0
- data/node_modules/bootstrap/dist/css/bootstrap.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap.min.css +7 -0
- data/node_modules/bootstrap/dist/css/bootstrap.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap.rtl.css +10795 -0
- data/node_modules/bootstrap/dist/css/bootstrap.rtl.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap.rtl.min.css +7 -0
- data/node_modules/bootstrap/dist/css/bootstrap.rtl.min.css.map +1 -0
- data/node_modules/bootstrap/dist/js/bootstrap.bundle.js +6714 -0
- data/node_modules/bootstrap/dist/js/bootstrap.bundle.js.map +1 -0
- data/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js +7 -0
- data/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js.map +1 -0
- data/node_modules/bootstrap/dist/js/bootstrap.esm.js +4944 -0
- data/node_modules/bootstrap/dist/js/bootstrap.esm.js.map +1 -0
- data/node_modules/bootstrap/dist/js/bootstrap.esm.min.js +7 -0
- data/node_modules/bootstrap/dist/js/bootstrap.esm.min.js.map +1 -0
- data/node_modules/bootstrap/dist/js/bootstrap.js +4993 -0
- data/node_modules/bootstrap/dist/js/bootstrap.js.map +1 -0
- data/node_modules/bootstrap/dist/js/bootstrap.min.js +7 -0
- data/node_modules/bootstrap/dist/js/bootstrap.min.js.map +1 -0
- data/node_modules/bootstrap/js/dist/alert.js +264 -0
- data/node_modules/bootstrap/js/dist/alert.js.map +1 -0
- data/node_modules/bootstrap/js/dist/base-component.js +62 -0
- data/node_modules/bootstrap/js/dist/base-component.js.map +1 -0
- data/node_modules/bootstrap/js/dist/button.js +146 -0
- data/node_modules/bootstrap/js/dist/button.js.map +1 -0
- data/node_modules/bootstrap/js/dist/carousel.js +757 -0
- data/node_modules/bootstrap/js/dist/carousel.js.map +1 -0
- data/node_modules/bootstrap/js/dist/collapse.js +551 -0
- data/node_modules/bootstrap/js/dist/collapse.js.map +1 -0
- data/node_modules/bootstrap/js/dist/dom/data.js +69 -0
- data/node_modules/bootstrap/js/dist/dom/data.js.map +1 -0
- data/node_modules/bootstrap/js/dist/dom/event-handler.js +305 -0
- data/node_modules/bootstrap/js/dist/dom/event-handler.js.map +1 -0
- data/node_modules/bootstrap/js/dist/dom/manipulator.js +89 -0
- data/node_modules/bootstrap/js/dist/dom/manipulator.js.map +1 -0
- data/node_modules/bootstrap/js/dist/dom/selector-engine.js +86 -0
- data/node_modules/bootstrap/js/dist/dom/selector-engine.js.map +1 -0
- data/node_modules/bootstrap/js/dist/dropdown.js +662 -0
- data/node_modules/bootstrap/js/dist/dropdown.js.map +1 -0
- data/node_modules/bootstrap/js/dist/modal.js +752 -0
- data/node_modules/bootstrap/js/dist/modal.js.map +1 -0
- data/node_modules/bootstrap/js/dist/offcanvas.js +509 -0
- data/node_modules/bootstrap/js/dist/offcanvas.js.map +1 -0
- data/node_modules/bootstrap/js/dist/popover.js +216 -0
- data/node_modules/bootstrap/js/dist/popover.js.map +1 -0
- data/node_modules/bootstrap/js/dist/scrollspy.js +400 -0
- data/node_modules/bootstrap/js/dist/scrollspy.js.map +1 -0
- data/node_modules/bootstrap/js/dist/tab.js +347 -0
- data/node_modules/bootstrap/js/dist/tab.js.map +1 -0
- data/node_modules/bootstrap/js/dist/toast.js +335 -0
- data/node_modules/bootstrap/js/dist/toast.js.map +1 -0
- data/node_modules/bootstrap/js/dist/tooltip.js +1055 -0
- data/node_modules/bootstrap/js/dist/tooltip.js.map +1 -0
- data/node_modules/bootstrap/js/src/alert.js +141 -0
- data/node_modules/bootstrap/js/src/base-component.js +46 -0
- data/node_modules/bootstrap/js/src/button.js +95 -0
- data/node_modules/bootstrap/js/src/carousel.js +624 -0
- data/node_modules/bootstrap/js/src/collapse.js +410 -0
- data/node_modules/bootstrap/js/src/dom/data.js +57 -0
- data/node_modules/bootstrap/js/src/dom/event-handler.js +331 -0
- data/node_modules/bootstrap/js/src/dom/manipulator.js +80 -0
- data/node_modules/bootstrap/js/src/dom/selector-engine.js +75 -0
- data/node_modules/bootstrap/js/src/dropdown.js +543 -0
- data/node_modules/bootstrap/js/src/modal.js +582 -0
- data/node_modules/bootstrap/js/src/offcanvas.js +279 -0
- data/node_modules/bootstrap/js/src/popover.js +171 -0
- data/node_modules/bootstrap/js/src/scrollspy.js +319 -0
- data/node_modules/bootstrap/js/src/tab.js +220 -0
- data/node_modules/bootstrap/js/src/toast.js +219 -0
- data/node_modules/bootstrap/js/src/tooltip.js +802 -0
- data/node_modules/bootstrap/js/src/util/index.js +253 -0
- data/node_modules/bootstrap/js/src/util/sanitizer.js +127 -0
- data/node_modules/bootstrap/js/src/util/scrollbar.js +70 -0
- data/node_modules/bootstrap/package.json +177 -0
- data/node_modules/bootstrap/scss/_accordion.scss +116 -0
- data/node_modules/bootstrap/scss/_alert.scss +57 -0
- data/node_modules/bootstrap/scss/_badge.scss +29 -0
- data/node_modules/bootstrap/scss/_breadcrumb.scss +28 -0
- data/node_modules/bootstrap/scss/_button-group.scss +139 -0
- data/node_modules/bootstrap/scss/_buttons.scss +111 -0
- data/node_modules/bootstrap/scss/_card.scss +215 -0
- data/node_modules/bootstrap/scss/_carousel.scss +229 -0
- data/node_modules/bootstrap/scss/_close.scss +40 -0
- data/node_modules/bootstrap/scss/_containers.scss +41 -0
- data/node_modules/bootstrap/scss/_dropdown.scss +246 -0
- data/node_modules/bootstrap/scss/_forms.scss +9 -0
- data/node_modules/bootstrap/scss/_functions.scss +205 -0
- data/node_modules/bootstrap/scss/_grid.scss +22 -0
- data/node_modules/bootstrap/scss/_helpers.scss +7 -0
- data/node_modules/bootstrap/scss/_images.scss +42 -0
- data/node_modules/bootstrap/scss/_list-group.scss +174 -0
- data/node_modules/bootstrap/scss/_mixins.scss +41 -0
- data/node_modules/bootstrap/scss/_modal.scss +237 -0
- data/node_modules/bootstrap/scss/_nav.scss +139 -0
- data/node_modules/bootstrap/scss/_navbar.scss +306 -0
- data/node_modules/bootstrap/scss/_offcanvas.scss +77 -0
- data/node_modules/bootstrap/scss/_pagination.scss +64 -0
- data/node_modules/bootstrap/scss/_popover.scss +158 -0
- data/node_modules/bootstrap/scss/_progress.scss +48 -0
- data/node_modules/bootstrap/scss/_reboot.scss +621 -0
- data/node_modules/bootstrap/scss/_root.scss +16 -0
- data/node_modules/bootstrap/scss/_spinners.scss +69 -0
- data/node_modules/bootstrap/scss/_tables.scss +150 -0
- data/node_modules/bootstrap/scss/_toasts.scss +51 -0
- data/node_modules/bootstrap/scss/_tooltip.scss +115 -0
- data/node_modules/bootstrap/scss/_transitions.scss +21 -0
- data/node_modules/bootstrap/scss/_type.scss +104 -0
- data/node_modules/bootstrap/scss/_utilities.scss +594 -0
- data/node_modules/bootstrap/scss/_variables.scss +1464 -0
- data/node_modules/bootstrap/scss/bootstrap-grid.scss +65 -0
- data/node_modules/bootstrap/scss/bootstrap-reboot.scss +15 -0
- data/node_modules/bootstrap/scss/bootstrap-utilities.scss +18 -0
- data/node_modules/bootstrap/scss/bootstrap.scss +52 -0
- data/node_modules/bootstrap/scss/forms/_floating-labels.scss +61 -0
- data/node_modules/bootstrap/scss/forms/_form-check.scss +152 -0
- data/node_modules/bootstrap/scss/forms/_form-control.scss +219 -0
- data/node_modules/bootstrap/scss/forms/_form-range.scss +91 -0
- data/node_modules/bootstrap/scss/forms/_form-select.scss +67 -0
- data/node_modules/bootstrap/scss/forms/_form-text.scss +11 -0
- data/node_modules/bootstrap/scss/forms/_input-group.scss +121 -0
- data/node_modules/bootstrap/scss/forms/_labels.scss +36 -0
- data/node_modules/bootstrap/scss/forms/_validation.scss +12 -0
- data/node_modules/bootstrap/scss/helpers/_clearfix.scss +3 -0
- data/node_modules/bootstrap/scss/helpers/_colored-links.scss +12 -0
- data/node_modules/bootstrap/scss/helpers/_position.scss +30 -0
- data/node_modules/bootstrap/scss/helpers/_ratio.scss +26 -0
- data/node_modules/bootstrap/scss/helpers/_stretched-link.scss +15 -0
- data/node_modules/bootstrap/scss/helpers/_text-truncation.scss +7 -0
- data/node_modules/bootstrap/scss/helpers/_visually-hidden.scss +8 -0
- data/node_modules/bootstrap/scss/mixins/_alert.scss +11 -0
- data/node_modules/bootstrap/scss/mixins/_border-radius.scss +78 -0
- data/node_modules/bootstrap/scss/mixins/_box-shadow.scss +18 -0
- data/node_modules/bootstrap/scss/mixins/_breakpoints.scss +127 -0
- data/node_modules/bootstrap/scss/mixins/_buttons.scss +133 -0
- data/node_modules/bootstrap/scss/mixins/_caret.scss +64 -0
- data/node_modules/bootstrap/scss/mixins/_clearfix.scss +9 -0
- data/node_modules/bootstrap/scss/mixins/_container.scss +9 -0
- data/node_modules/bootstrap/scss/mixins/_deprecate.scss +10 -0
- data/node_modules/bootstrap/scss/mixins/_forms.scss +134 -0
- data/node_modules/bootstrap/scss/mixins/_gradients.scss +47 -0
- data/node_modules/bootstrap/scss/mixins/_grid.scss +120 -0
- data/node_modules/bootstrap/scss/mixins/_image.scss +16 -0
- data/node_modules/bootstrap/scss/mixins/_list-group.scss +24 -0
- data/node_modules/bootstrap/scss/mixins/_lists.scss +7 -0
- data/node_modules/bootstrap/scss/mixins/_pagination.scss +31 -0
- data/node_modules/bootstrap/scss/mixins/_reset-text.scss +17 -0
- data/node_modules/bootstrap/scss/mixins/_resize.scss +6 -0
- data/node_modules/bootstrap/scss/mixins/_table-variants.scss +21 -0
- data/node_modules/bootstrap/scss/mixins/_text-truncate.scss +8 -0
- data/node_modules/bootstrap/scss/mixins/_transition.scss +26 -0
- data/node_modules/bootstrap/scss/mixins/_utilities.scss +68 -0
- data/node_modules/bootstrap/scss/mixins/_visually-hidden.scss +29 -0
- data/node_modules/bootstrap/scss/utilities/_api.scss +47 -0
- data/node_modules/bootstrap/scss/vendor/_rfs.scss +312 -0
- metadata +182 -1
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap (v5.0.0-beta3): util/index.js
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
* --------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const MAX_UID = 1000000
|
|
9
|
+
const MILLISECONDS_MULTIPLIER = 1000
|
|
10
|
+
const TRANSITION_END = 'transitionend'
|
|
11
|
+
|
|
12
|
+
// Shoutout AngusCroll (https://goo.gl/pxwQGp)
|
|
13
|
+
const toType = obj => {
|
|
14
|
+
if (obj === null || obj === undefined) {
|
|
15
|
+
return `${obj}`
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* --------------------------------------------------------------------------
|
|
23
|
+
* Public Util Api
|
|
24
|
+
* --------------------------------------------------------------------------
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const getUID = prefix => {
|
|
28
|
+
do {
|
|
29
|
+
prefix += Math.floor(Math.random() * MAX_UID)
|
|
30
|
+
} while (document.getElementById(prefix))
|
|
31
|
+
|
|
32
|
+
return prefix
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const getSelector = element => {
|
|
36
|
+
let selector = element.getAttribute('data-bs-target')
|
|
37
|
+
|
|
38
|
+
if (!selector || selector === '#') {
|
|
39
|
+
let hrefAttr = element.getAttribute('href')
|
|
40
|
+
|
|
41
|
+
// The only valid content that could double as a selector are IDs or classes,
|
|
42
|
+
// so everything starting with `#` or `.`. If a "real" URL is used as the selector,
|
|
43
|
+
// `document.querySelector` will rightfully complain it is invalid.
|
|
44
|
+
// See https://github.com/twbs/bootstrap/issues/32273
|
|
45
|
+
if (!hrefAttr || (!hrefAttr.includes('#') && !hrefAttr.startsWith('.'))) {
|
|
46
|
+
return null
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Just in case some CMS puts out a full URL with the anchor appended
|
|
50
|
+
if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
|
|
51
|
+
hrefAttr = '#' + hrefAttr.split('#')[1]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return selector
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const getSelectorFromElement = element => {
|
|
61
|
+
const selector = getSelector(element)
|
|
62
|
+
|
|
63
|
+
if (selector) {
|
|
64
|
+
return document.querySelector(selector) ? selector : null
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return null
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const getElementFromSelector = element => {
|
|
71
|
+
const selector = getSelector(element)
|
|
72
|
+
|
|
73
|
+
return selector ? document.querySelector(selector) : null
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const getTransitionDurationFromElement = element => {
|
|
77
|
+
if (!element) {
|
|
78
|
+
return 0
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Get transition-duration of the element
|
|
82
|
+
let { transitionDuration, transitionDelay } = window.getComputedStyle(element)
|
|
83
|
+
|
|
84
|
+
const floatTransitionDuration = Number.parseFloat(transitionDuration)
|
|
85
|
+
const floatTransitionDelay = Number.parseFloat(transitionDelay)
|
|
86
|
+
|
|
87
|
+
// Return 0 if element or transition duration is not found
|
|
88
|
+
if (!floatTransitionDuration && !floatTransitionDelay) {
|
|
89
|
+
return 0
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// If multiple durations are defined, take the first
|
|
93
|
+
transitionDuration = transitionDuration.split(',')[0]
|
|
94
|
+
transitionDelay = transitionDelay.split(',')[0]
|
|
95
|
+
|
|
96
|
+
return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const triggerTransitionEnd = element => {
|
|
100
|
+
element.dispatchEvent(new Event(TRANSITION_END))
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const isElement = obj => (obj[0] || obj).nodeType
|
|
104
|
+
|
|
105
|
+
const emulateTransitionEnd = (element, duration) => {
|
|
106
|
+
let called = false
|
|
107
|
+
const durationPadding = 5
|
|
108
|
+
const emulatedDuration = duration + durationPadding
|
|
109
|
+
|
|
110
|
+
function listener() {
|
|
111
|
+
called = true
|
|
112
|
+
element.removeEventListener(TRANSITION_END, listener)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
element.addEventListener(TRANSITION_END, listener)
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
if (!called) {
|
|
118
|
+
triggerTransitionEnd(element)
|
|
119
|
+
}
|
|
120
|
+
}, emulatedDuration)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const typeCheckConfig = (componentName, config, configTypes) => {
|
|
124
|
+
Object.keys(configTypes).forEach(property => {
|
|
125
|
+
const expectedTypes = configTypes[property]
|
|
126
|
+
const value = config[property]
|
|
127
|
+
const valueType = value && isElement(value) ? 'element' : toType(value)
|
|
128
|
+
|
|
129
|
+
if (!new RegExp(expectedTypes).test(valueType)) {
|
|
130
|
+
throw new TypeError(
|
|
131
|
+
`${componentName.toUpperCase()}: ` +
|
|
132
|
+
`Option "${property}" provided type "${valueType}" ` +
|
|
133
|
+
`but expected type "${expectedTypes}".`
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const isVisible = element => {
|
|
140
|
+
if (!element) {
|
|
141
|
+
return false
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (element.style && element.parentNode && element.parentNode.style) {
|
|
145
|
+
const elementStyle = getComputedStyle(element)
|
|
146
|
+
const parentNodeStyle = getComputedStyle(element.parentNode)
|
|
147
|
+
|
|
148
|
+
return elementStyle.display !== 'none' &&
|
|
149
|
+
parentNodeStyle.display !== 'none' &&
|
|
150
|
+
elementStyle.visibility !== 'hidden'
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return false
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const isDisabled = element => {
|
|
157
|
+
if (!element || element.nodeType !== Node.ELEMENT_NODE) {
|
|
158
|
+
return true
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (element.classList.contains('disabled')) {
|
|
162
|
+
return true
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (typeof element.disabled !== 'undefined') {
|
|
166
|
+
return element.disabled
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const findShadowRoot = element => {
|
|
173
|
+
if (!document.documentElement.attachShadow) {
|
|
174
|
+
return null
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Can find the shadow root otherwise it'll return the document
|
|
178
|
+
if (typeof element.getRootNode === 'function') {
|
|
179
|
+
const root = element.getRootNode()
|
|
180
|
+
return root instanceof ShadowRoot ? root : null
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (element instanceof ShadowRoot) {
|
|
184
|
+
return element
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// when we don't find a shadow root
|
|
188
|
+
if (!element.parentNode) {
|
|
189
|
+
return null
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return findShadowRoot(element.parentNode)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const noop = () => function () {}
|
|
196
|
+
|
|
197
|
+
const reflow = element => element.offsetHeight
|
|
198
|
+
|
|
199
|
+
const getjQuery = () => {
|
|
200
|
+
const { jQuery } = window
|
|
201
|
+
|
|
202
|
+
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
|
|
203
|
+
return jQuery
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return null
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const onDOMContentLoaded = callback => {
|
|
210
|
+
if (document.readyState === 'loading') {
|
|
211
|
+
document.addEventListener('DOMContentLoaded', callback)
|
|
212
|
+
} else {
|
|
213
|
+
callback()
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const isRTL = () => document.documentElement.dir === 'rtl'
|
|
218
|
+
|
|
219
|
+
const defineJQueryPlugin = (name, plugin) => {
|
|
220
|
+
onDOMContentLoaded(() => {
|
|
221
|
+
const $ = getjQuery()
|
|
222
|
+
/* istanbul ignore if */
|
|
223
|
+
if ($) {
|
|
224
|
+
const JQUERY_NO_CONFLICT = $.fn[name]
|
|
225
|
+
$.fn[name] = plugin.jQueryInterface
|
|
226
|
+
$.fn[name].Constructor = plugin
|
|
227
|
+
$.fn[name].noConflict = () => {
|
|
228
|
+
$.fn[name] = JQUERY_NO_CONFLICT
|
|
229
|
+
return plugin.jQueryInterface
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export {
|
|
236
|
+
getUID,
|
|
237
|
+
getSelectorFromElement,
|
|
238
|
+
getElementFromSelector,
|
|
239
|
+
getTransitionDurationFromElement,
|
|
240
|
+
triggerTransitionEnd,
|
|
241
|
+
isElement,
|
|
242
|
+
emulateTransitionEnd,
|
|
243
|
+
typeCheckConfig,
|
|
244
|
+
isVisible,
|
|
245
|
+
isDisabled,
|
|
246
|
+
findShadowRoot,
|
|
247
|
+
noop,
|
|
248
|
+
reflow,
|
|
249
|
+
getjQuery,
|
|
250
|
+
onDOMContentLoaded,
|
|
251
|
+
isRTL,
|
|
252
|
+
defineJQueryPlugin
|
|
253
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap (v5.0.0-beta3): util/sanitizer.js
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
* --------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const uriAttrs = new Set([
|
|
9
|
+
'background',
|
|
10
|
+
'cite',
|
|
11
|
+
'href',
|
|
12
|
+
'itemtype',
|
|
13
|
+
'longdesc',
|
|
14
|
+
'poster',
|
|
15
|
+
'src',
|
|
16
|
+
'xlink:href'
|
|
17
|
+
])
|
|
18
|
+
|
|
19
|
+
const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A pattern that recognizes a commonly useful subset of URLs that are safe.
|
|
23
|
+
*
|
|
24
|
+
* Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
|
|
25
|
+
*/
|
|
26
|
+
const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/i
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A pattern that matches safe data URLs. Only matches image, video and audio types.
|
|
30
|
+
*
|
|
31
|
+
* Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
|
|
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 = (attr, allowedAttributeList) => {
|
|
36
|
+
const attrName = attr.nodeName.toLowerCase()
|
|
37
|
+
|
|
38
|
+
if (allowedAttributeList.includes(attrName)) {
|
|
39
|
+
if (uriAttrs.has(attrName)) {
|
|
40
|
+
return Boolean(SAFE_URL_PATTERN.test(attr.nodeValue) || DATA_URL_PATTERN.test(attr.nodeValue))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return true
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const regExp = allowedAttributeList.filter(attrRegex => attrRegex instanceof RegExp)
|
|
47
|
+
|
|
48
|
+
// Check if a regular expression validates the attribute.
|
|
49
|
+
for (let i = 0, len = regExp.length; i < len; i++) {
|
|
50
|
+
if (regExp[i].test(attrName)) {
|
|
51
|
+
return true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return false
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const DefaultAllowlist = {
|
|
59
|
+
// Global attributes allowed on any supplied element below.
|
|
60
|
+
'*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
|
|
61
|
+
a: ['target', 'href', 'title', 'rel'],
|
|
62
|
+
area: [],
|
|
63
|
+
b: [],
|
|
64
|
+
br: [],
|
|
65
|
+
col: [],
|
|
66
|
+
code: [],
|
|
67
|
+
div: [],
|
|
68
|
+
em: [],
|
|
69
|
+
hr: [],
|
|
70
|
+
h1: [],
|
|
71
|
+
h2: [],
|
|
72
|
+
h3: [],
|
|
73
|
+
h4: [],
|
|
74
|
+
h5: [],
|
|
75
|
+
h6: [],
|
|
76
|
+
i: [],
|
|
77
|
+
img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
|
|
78
|
+
li: [],
|
|
79
|
+
ol: [],
|
|
80
|
+
p: [],
|
|
81
|
+
pre: [],
|
|
82
|
+
s: [],
|
|
83
|
+
small: [],
|
|
84
|
+
span: [],
|
|
85
|
+
sub: [],
|
|
86
|
+
sup: [],
|
|
87
|
+
strong: [],
|
|
88
|
+
u: [],
|
|
89
|
+
ul: []
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) {
|
|
93
|
+
if (!unsafeHtml.length) {
|
|
94
|
+
return unsafeHtml
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (sanitizeFn && typeof sanitizeFn === 'function') {
|
|
98
|
+
return sanitizeFn(unsafeHtml)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const domParser = new window.DOMParser()
|
|
102
|
+
const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html')
|
|
103
|
+
const allowlistKeys = Object.keys(allowList)
|
|
104
|
+
const elements = [].concat(...createdDocument.body.querySelectorAll('*'))
|
|
105
|
+
|
|
106
|
+
for (let i = 0, len = elements.length; i < len; i++) {
|
|
107
|
+
const el = elements[i]
|
|
108
|
+
const elName = el.nodeName.toLowerCase()
|
|
109
|
+
|
|
110
|
+
if (!allowlistKeys.includes(elName)) {
|
|
111
|
+
el.parentNode.removeChild(el)
|
|
112
|
+
|
|
113
|
+
continue
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const attributeList = [].concat(...el.attributes)
|
|
117
|
+
const allowedAttributes = [].concat(allowList['*'] || [], allowList[elName] || [])
|
|
118
|
+
|
|
119
|
+
attributeList.forEach(attr => {
|
|
120
|
+
if (!allowedAttribute(attr, allowedAttributes)) {
|
|
121
|
+
el.removeAttribute(attr.nodeName)
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return createdDocument.body.innerHTML
|
|
127
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap (v5.0.0-beta3): util/scrollBar.js
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
* --------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import SelectorEngine from '../dom/selector-engine'
|
|
9
|
+
import Manipulator from '../dom/manipulator'
|
|
10
|
+
|
|
11
|
+
const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed'
|
|
12
|
+
const SELECTOR_STICKY_CONTENT = '.sticky-top'
|
|
13
|
+
|
|
14
|
+
const getWidth = () => {
|
|
15
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
|
|
16
|
+
const documentWidth = document.documentElement.clientWidth
|
|
17
|
+
return Math.abs(window.innerWidth - documentWidth)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const hide = (width = getWidth()) => {
|
|
21
|
+
document.body.style.overflow = 'hidden'
|
|
22
|
+
_setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width)
|
|
23
|
+
_setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width)
|
|
24
|
+
_setElementAttributes('body', 'paddingRight', calculatedValue => calculatedValue + width)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const _setElementAttributes = (selector, styleProp, callback) => {
|
|
28
|
+
const scrollbarWidth = getWidth()
|
|
29
|
+
SelectorEngine.find(selector)
|
|
30
|
+
.forEach(element => {
|
|
31
|
+
if (element !== document.body && window.innerWidth > element.clientWidth + scrollbarWidth) {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const actualValue = element.style[styleProp]
|
|
36
|
+
const calculatedValue = window.getComputedStyle(element)[styleProp]
|
|
37
|
+
Manipulator.setDataAttribute(element, styleProp, actualValue)
|
|
38
|
+
element.style[styleProp] = callback(Number.parseFloat(calculatedValue)) + 'px'
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const reset = () => {
|
|
43
|
+
document.body.style.overflow = 'auto'
|
|
44
|
+
_resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight')
|
|
45
|
+
_resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight')
|
|
46
|
+
_resetElementAttributes('body', 'paddingRight')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const _resetElementAttributes = (selector, styleProp) => {
|
|
50
|
+
SelectorEngine.find(selector).forEach(element => {
|
|
51
|
+
const value = Manipulator.getDataAttribute(element, styleProp)
|
|
52
|
+
if (typeof value === 'undefined' && element === document.body) {
|
|
53
|
+
element.style.removeProperty(styleProp)
|
|
54
|
+
} else {
|
|
55
|
+
Manipulator.removeDataAttribute(element, styleProp)
|
|
56
|
+
element.style[styleProp] = value
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const isBodyOverflowing = () => {
|
|
62
|
+
return getWidth() > 0
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
getWidth,
|
|
67
|
+
hide,
|
|
68
|
+
isBodyOverflowing,
|
|
69
|
+
reset
|
|
70
|
+
}
|