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.
Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/administrate-bootstrap-theme/_base.scss +14 -0
  3. data/app/assets/stylesheets/administrate-bootstrap-theme/components/_form.scss +16 -0
  4. data/lib/administrate-bootstrap-theme/version.rb +1 -1
  5. data/node_modules/bootstrap/LICENSE +22 -0
  6. data/node_modules/bootstrap/README.md +239 -0
  7. data/node_modules/bootstrap/dist/css/bootstrap-grid.css +4997 -0
  8. data/node_modules/bootstrap/dist/css/bootstrap-grid.css.map +1 -0
  9. data/node_modules/bootstrap/dist/css/bootstrap-grid.min.css +7 -0
  10. data/node_modules/bootstrap/dist/css/bootstrap-grid.min.css.map +1 -0
  11. data/node_modules/bootstrap/dist/css/bootstrap-grid.rtl.css +4996 -0
  12. data/node_modules/bootstrap/dist/css/bootstrap-grid.rtl.css.map +1 -0
  13. data/node_modules/bootstrap/dist/css/bootstrap-grid.rtl.min.css +7 -0
  14. data/node_modules/bootstrap/dist/css/bootstrap-grid.rtl.min.css.map +1 -0
  15. data/node_modules/bootstrap/dist/css/bootstrap-reboot.css +426 -0
  16. data/node_modules/bootstrap/dist/css/bootstrap-reboot.css.map +1 -0
  17. data/node_modules/bootstrap/dist/css/bootstrap-reboot.min.css +8 -0
  18. data/node_modules/bootstrap/dist/css/bootstrap-reboot.min.css.map +1 -0
  19. data/node_modules/bootstrap/dist/css/bootstrap-reboot.rtl.css +423 -0
  20. data/node_modules/bootstrap/dist/css/bootstrap-reboot.rtl.css.map +1 -0
  21. data/node_modules/bootstrap/dist/css/bootstrap-reboot.rtl.min.css +8 -0
  22. data/node_modules/bootstrap/dist/css/bootstrap-reboot.rtl.min.css.map +1 -0
  23. data/node_modules/bootstrap/dist/css/bootstrap-utilities.css +4752 -0
  24. data/node_modules/bootstrap/dist/css/bootstrap-utilities.css.map +1 -0
  25. data/node_modules/bootstrap/dist/css/bootstrap-utilities.min.css +7 -0
  26. data/node_modules/bootstrap/dist/css/bootstrap-utilities.min.css.map +1 -0
  27. data/node_modules/bootstrap/dist/css/bootstrap-utilities.rtl.css +4743 -0
  28. data/node_modules/bootstrap/dist/css/bootstrap-utilities.rtl.css.map +1 -0
  29. data/node_modules/bootstrap/dist/css/bootstrap-utilities.rtl.min.css +7 -0
  30. data/node_modules/bootstrap/dist/css/bootstrap-utilities.rtl.min.css.map +1 -0
  31. data/node_modules/bootstrap/dist/css/bootstrap.css +10819 -0
  32. data/node_modules/bootstrap/dist/css/bootstrap.css.map +1 -0
  33. data/node_modules/bootstrap/dist/css/bootstrap.min.css +7 -0
  34. data/node_modules/bootstrap/dist/css/bootstrap.min.css.map +1 -0
  35. data/node_modules/bootstrap/dist/css/bootstrap.rtl.css +10795 -0
  36. data/node_modules/bootstrap/dist/css/bootstrap.rtl.css.map +1 -0
  37. data/node_modules/bootstrap/dist/css/bootstrap.rtl.min.css +7 -0
  38. data/node_modules/bootstrap/dist/css/bootstrap.rtl.min.css.map +1 -0
  39. data/node_modules/bootstrap/dist/js/bootstrap.bundle.js +6714 -0
  40. data/node_modules/bootstrap/dist/js/bootstrap.bundle.js.map +1 -0
  41. data/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js +7 -0
  42. data/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js.map +1 -0
  43. data/node_modules/bootstrap/dist/js/bootstrap.esm.js +4944 -0
  44. data/node_modules/bootstrap/dist/js/bootstrap.esm.js.map +1 -0
  45. data/node_modules/bootstrap/dist/js/bootstrap.esm.min.js +7 -0
  46. data/node_modules/bootstrap/dist/js/bootstrap.esm.min.js.map +1 -0
  47. data/node_modules/bootstrap/dist/js/bootstrap.js +4993 -0
  48. data/node_modules/bootstrap/dist/js/bootstrap.js.map +1 -0
  49. data/node_modules/bootstrap/dist/js/bootstrap.min.js +7 -0
  50. data/node_modules/bootstrap/dist/js/bootstrap.min.js.map +1 -0
  51. data/node_modules/bootstrap/js/dist/alert.js +264 -0
  52. data/node_modules/bootstrap/js/dist/alert.js.map +1 -0
  53. data/node_modules/bootstrap/js/dist/base-component.js +62 -0
  54. data/node_modules/bootstrap/js/dist/base-component.js.map +1 -0
  55. data/node_modules/bootstrap/js/dist/button.js +146 -0
  56. data/node_modules/bootstrap/js/dist/button.js.map +1 -0
  57. data/node_modules/bootstrap/js/dist/carousel.js +757 -0
  58. data/node_modules/bootstrap/js/dist/carousel.js.map +1 -0
  59. data/node_modules/bootstrap/js/dist/collapse.js +551 -0
  60. data/node_modules/bootstrap/js/dist/collapse.js.map +1 -0
  61. data/node_modules/bootstrap/js/dist/dom/data.js +69 -0
  62. data/node_modules/bootstrap/js/dist/dom/data.js.map +1 -0
  63. data/node_modules/bootstrap/js/dist/dom/event-handler.js +305 -0
  64. data/node_modules/bootstrap/js/dist/dom/event-handler.js.map +1 -0
  65. data/node_modules/bootstrap/js/dist/dom/manipulator.js +89 -0
  66. data/node_modules/bootstrap/js/dist/dom/manipulator.js.map +1 -0
  67. data/node_modules/bootstrap/js/dist/dom/selector-engine.js +86 -0
  68. data/node_modules/bootstrap/js/dist/dom/selector-engine.js.map +1 -0
  69. data/node_modules/bootstrap/js/dist/dropdown.js +662 -0
  70. data/node_modules/bootstrap/js/dist/dropdown.js.map +1 -0
  71. data/node_modules/bootstrap/js/dist/modal.js +752 -0
  72. data/node_modules/bootstrap/js/dist/modal.js.map +1 -0
  73. data/node_modules/bootstrap/js/dist/offcanvas.js +509 -0
  74. data/node_modules/bootstrap/js/dist/offcanvas.js.map +1 -0
  75. data/node_modules/bootstrap/js/dist/popover.js +216 -0
  76. data/node_modules/bootstrap/js/dist/popover.js.map +1 -0
  77. data/node_modules/bootstrap/js/dist/scrollspy.js +400 -0
  78. data/node_modules/bootstrap/js/dist/scrollspy.js.map +1 -0
  79. data/node_modules/bootstrap/js/dist/tab.js +347 -0
  80. data/node_modules/bootstrap/js/dist/tab.js.map +1 -0
  81. data/node_modules/bootstrap/js/dist/toast.js +335 -0
  82. data/node_modules/bootstrap/js/dist/toast.js.map +1 -0
  83. data/node_modules/bootstrap/js/dist/tooltip.js +1055 -0
  84. data/node_modules/bootstrap/js/dist/tooltip.js.map +1 -0
  85. data/node_modules/bootstrap/js/src/alert.js +141 -0
  86. data/node_modules/bootstrap/js/src/base-component.js +46 -0
  87. data/node_modules/bootstrap/js/src/button.js +95 -0
  88. data/node_modules/bootstrap/js/src/carousel.js +624 -0
  89. data/node_modules/bootstrap/js/src/collapse.js +410 -0
  90. data/node_modules/bootstrap/js/src/dom/data.js +57 -0
  91. data/node_modules/bootstrap/js/src/dom/event-handler.js +331 -0
  92. data/node_modules/bootstrap/js/src/dom/manipulator.js +80 -0
  93. data/node_modules/bootstrap/js/src/dom/selector-engine.js +75 -0
  94. data/node_modules/bootstrap/js/src/dropdown.js +543 -0
  95. data/node_modules/bootstrap/js/src/modal.js +582 -0
  96. data/node_modules/bootstrap/js/src/offcanvas.js +279 -0
  97. data/node_modules/bootstrap/js/src/popover.js +171 -0
  98. data/node_modules/bootstrap/js/src/scrollspy.js +319 -0
  99. data/node_modules/bootstrap/js/src/tab.js +220 -0
  100. data/node_modules/bootstrap/js/src/toast.js +219 -0
  101. data/node_modules/bootstrap/js/src/tooltip.js +802 -0
  102. data/node_modules/bootstrap/js/src/util/index.js +253 -0
  103. data/node_modules/bootstrap/js/src/util/sanitizer.js +127 -0
  104. data/node_modules/bootstrap/js/src/util/scrollbar.js +70 -0
  105. data/node_modules/bootstrap/package.json +177 -0
  106. data/node_modules/bootstrap/scss/_accordion.scss +116 -0
  107. data/node_modules/bootstrap/scss/_alert.scss +57 -0
  108. data/node_modules/bootstrap/scss/_badge.scss +29 -0
  109. data/node_modules/bootstrap/scss/_breadcrumb.scss +28 -0
  110. data/node_modules/bootstrap/scss/_button-group.scss +139 -0
  111. data/node_modules/bootstrap/scss/_buttons.scss +111 -0
  112. data/node_modules/bootstrap/scss/_card.scss +215 -0
  113. data/node_modules/bootstrap/scss/_carousel.scss +229 -0
  114. data/node_modules/bootstrap/scss/_close.scss +40 -0
  115. data/node_modules/bootstrap/scss/_containers.scss +41 -0
  116. data/node_modules/bootstrap/scss/_dropdown.scss +246 -0
  117. data/node_modules/bootstrap/scss/_forms.scss +9 -0
  118. data/node_modules/bootstrap/scss/_functions.scss +205 -0
  119. data/node_modules/bootstrap/scss/_grid.scss +22 -0
  120. data/node_modules/bootstrap/scss/_helpers.scss +7 -0
  121. data/node_modules/bootstrap/scss/_images.scss +42 -0
  122. data/node_modules/bootstrap/scss/_list-group.scss +174 -0
  123. data/node_modules/bootstrap/scss/_mixins.scss +41 -0
  124. data/node_modules/bootstrap/scss/_modal.scss +237 -0
  125. data/node_modules/bootstrap/scss/_nav.scss +139 -0
  126. data/node_modules/bootstrap/scss/_navbar.scss +306 -0
  127. data/node_modules/bootstrap/scss/_offcanvas.scss +77 -0
  128. data/node_modules/bootstrap/scss/_pagination.scss +64 -0
  129. data/node_modules/bootstrap/scss/_popover.scss +158 -0
  130. data/node_modules/bootstrap/scss/_progress.scss +48 -0
  131. data/node_modules/bootstrap/scss/_reboot.scss +621 -0
  132. data/node_modules/bootstrap/scss/_root.scss +16 -0
  133. data/node_modules/bootstrap/scss/_spinners.scss +69 -0
  134. data/node_modules/bootstrap/scss/_tables.scss +150 -0
  135. data/node_modules/bootstrap/scss/_toasts.scss +51 -0
  136. data/node_modules/bootstrap/scss/_tooltip.scss +115 -0
  137. data/node_modules/bootstrap/scss/_transitions.scss +21 -0
  138. data/node_modules/bootstrap/scss/_type.scss +104 -0
  139. data/node_modules/bootstrap/scss/_utilities.scss +594 -0
  140. data/node_modules/bootstrap/scss/_variables.scss +1464 -0
  141. data/node_modules/bootstrap/scss/bootstrap-grid.scss +65 -0
  142. data/node_modules/bootstrap/scss/bootstrap-reboot.scss +15 -0
  143. data/node_modules/bootstrap/scss/bootstrap-utilities.scss +18 -0
  144. data/node_modules/bootstrap/scss/bootstrap.scss +52 -0
  145. data/node_modules/bootstrap/scss/forms/_floating-labels.scss +61 -0
  146. data/node_modules/bootstrap/scss/forms/_form-check.scss +152 -0
  147. data/node_modules/bootstrap/scss/forms/_form-control.scss +219 -0
  148. data/node_modules/bootstrap/scss/forms/_form-range.scss +91 -0
  149. data/node_modules/bootstrap/scss/forms/_form-select.scss +67 -0
  150. data/node_modules/bootstrap/scss/forms/_form-text.scss +11 -0
  151. data/node_modules/bootstrap/scss/forms/_input-group.scss +121 -0
  152. data/node_modules/bootstrap/scss/forms/_labels.scss +36 -0
  153. data/node_modules/bootstrap/scss/forms/_validation.scss +12 -0
  154. data/node_modules/bootstrap/scss/helpers/_clearfix.scss +3 -0
  155. data/node_modules/bootstrap/scss/helpers/_colored-links.scss +12 -0
  156. data/node_modules/bootstrap/scss/helpers/_position.scss +30 -0
  157. data/node_modules/bootstrap/scss/helpers/_ratio.scss +26 -0
  158. data/node_modules/bootstrap/scss/helpers/_stretched-link.scss +15 -0
  159. data/node_modules/bootstrap/scss/helpers/_text-truncation.scss +7 -0
  160. data/node_modules/bootstrap/scss/helpers/_visually-hidden.scss +8 -0
  161. data/node_modules/bootstrap/scss/mixins/_alert.scss +11 -0
  162. data/node_modules/bootstrap/scss/mixins/_border-radius.scss +78 -0
  163. data/node_modules/bootstrap/scss/mixins/_box-shadow.scss +18 -0
  164. data/node_modules/bootstrap/scss/mixins/_breakpoints.scss +127 -0
  165. data/node_modules/bootstrap/scss/mixins/_buttons.scss +133 -0
  166. data/node_modules/bootstrap/scss/mixins/_caret.scss +64 -0
  167. data/node_modules/bootstrap/scss/mixins/_clearfix.scss +9 -0
  168. data/node_modules/bootstrap/scss/mixins/_container.scss +9 -0
  169. data/node_modules/bootstrap/scss/mixins/_deprecate.scss +10 -0
  170. data/node_modules/bootstrap/scss/mixins/_forms.scss +134 -0
  171. data/node_modules/bootstrap/scss/mixins/_gradients.scss +47 -0
  172. data/node_modules/bootstrap/scss/mixins/_grid.scss +120 -0
  173. data/node_modules/bootstrap/scss/mixins/_image.scss +16 -0
  174. data/node_modules/bootstrap/scss/mixins/_list-group.scss +24 -0
  175. data/node_modules/bootstrap/scss/mixins/_lists.scss +7 -0
  176. data/node_modules/bootstrap/scss/mixins/_pagination.scss +31 -0
  177. data/node_modules/bootstrap/scss/mixins/_reset-text.scss +17 -0
  178. data/node_modules/bootstrap/scss/mixins/_resize.scss +6 -0
  179. data/node_modules/bootstrap/scss/mixins/_table-variants.scss +21 -0
  180. data/node_modules/bootstrap/scss/mixins/_text-truncate.scss +8 -0
  181. data/node_modules/bootstrap/scss/mixins/_transition.scss +26 -0
  182. data/node_modules/bootstrap/scss/mixins/_utilities.scss +68 -0
  183. data/node_modules/bootstrap/scss/mixins/_visually-hidden.scss +29 -0
  184. data/node_modules/bootstrap/scss/utilities/_api.scss +47 -0
  185. data/node_modules/bootstrap/scss/vendor/_rfs.scss +312 -0
  186. 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
+ }