administrate-bootstrap-theme 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -4
  3. data/app/assets/javascripts/administrate-bootstrap-theme/bootstrap/bootstrap.bundle.js +6714 -0
  4. data/app/assets/javascripts/administrate-bootstrap-theme/flatpickr/flatpickr.js +2673 -0
  5. data/app/assets/javascripts/administrate-bootstrap-theme/theme.js +21 -1
  6. data/app/assets/stylesheets/administrate-bootstrap-theme/_base.scss +5 -1
  7. data/app/assets/stylesheets/administrate-bootstrap-theme/_variables.scss +4 -1
  8. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_accordion.scss +0 -0
  9. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_alert.scss +0 -0
  10. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_badge.scss +0 -0
  11. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_breadcrumb.scss +0 -0
  12. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_button-group.scss +0 -0
  13. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_buttons.scss +0 -0
  14. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_card.scss +0 -0
  15. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_carousel.scss +0 -0
  16. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_close.scss +0 -0
  17. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_containers.scss +0 -0
  18. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_dropdown.scss +0 -0
  19. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_forms.scss +0 -0
  20. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_functions.scss +0 -0
  21. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_grid.scss +0 -0
  22. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_helpers.scss +0 -0
  23. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_images.scss +0 -0
  24. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_list-group.scss +0 -0
  25. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_mixins.scss +0 -0
  26. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_modal.scss +0 -0
  27. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_nav.scss +0 -0
  28. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_navbar.scss +0 -0
  29. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_offcanvas.scss +0 -0
  30. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_pagination.scss +0 -0
  31. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_popover.scss +0 -0
  32. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_progress.scss +0 -0
  33. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_reboot.scss +0 -0
  34. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_root.scss +0 -0
  35. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_spinners.scss +0 -0
  36. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_tables.scss +0 -0
  37. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_toasts.scss +0 -0
  38. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_tooltip.scss +0 -0
  39. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_transitions.scss +0 -0
  40. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_type.scss +0 -0
  41. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_utilities.scss +0 -0
  42. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/_variables.scss +0 -0
  43. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap-grid.scss +0 -0
  44. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap-reboot.scss +0 -0
  45. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap-utilities.scss +0 -0
  46. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/bootstrap.scss +0 -0
  47. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_floating-labels.scss +0 -0
  48. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-check.scss +0 -0
  49. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-control.scss +0 -0
  50. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-range.scss +0 -0
  51. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-select.scss +0 -0
  52. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_form-text.scss +0 -0
  53. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_input-group.scss +0 -0
  54. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_labels.scss +0 -0
  55. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/forms/_validation.scss +0 -0
  56. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_clearfix.scss +0 -0
  57. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_colored-links.scss +0 -0
  58. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_position.scss +0 -0
  59. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_ratio.scss +0 -0
  60. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_stretched-link.scss +0 -0
  61. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_text-truncation.scss +0 -0
  62. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/helpers/_visually-hidden.scss +0 -0
  63. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_alert.scss +0 -0
  64. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_border-radius.scss +0 -0
  65. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_box-shadow.scss +0 -0
  66. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_breakpoints.scss +0 -0
  67. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_buttons.scss +0 -0
  68. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_caret.scss +0 -0
  69. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_clearfix.scss +0 -0
  70. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_container.scss +0 -0
  71. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_deprecate.scss +0 -0
  72. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_forms.scss +0 -0
  73. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_gradients.scss +0 -0
  74. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_grid.scss +0 -0
  75. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_image.scss +0 -0
  76. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_list-group.scss +0 -0
  77. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_lists.scss +0 -0
  78. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_pagination.scss +0 -0
  79. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_reset-text.scss +0 -0
  80. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_resize.scss +0 -0
  81. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_table-variants.scss +0 -0
  82. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_text-truncate.scss +0 -0
  83. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_transition.scss +0 -0
  84. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_utilities.scss +0 -0
  85. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/mixins/_visually-hidden.scss +0 -0
  86. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/utilities/_api.scss +0 -0
  87. data/{node_modules/bootstrap/scss → app/assets/stylesheets/administrate-bootstrap-theme/bootstrap}/vendor/_rfs.scss +0 -0
  88. data/app/assets/stylesheets/administrate-bootstrap-theme/components/_navigation.scss +1 -5
  89. data/app/assets/stylesheets/administrate-bootstrap-theme/flatpickr/flatpickr.css +791 -0
  90. data/app/assets/stylesheets/administrate-bootstrap-theme/theme.scss +11 -1
  91. data/lib/administrate-bootstrap-theme/engine.rb +0 -2
  92. data/lib/administrate-bootstrap-theme/version.rb +1 -1
  93. metadata +88 -105
  94. data/node_modules/bootstrap/js/src/alert.js +0 -141
  95. data/node_modules/bootstrap/js/src/base-component.js +0 -46
  96. data/node_modules/bootstrap/js/src/button.js +0 -95
  97. data/node_modules/bootstrap/js/src/carousel.js +0 -624
  98. data/node_modules/bootstrap/js/src/collapse.js +0 -410
  99. data/node_modules/bootstrap/js/src/dom/data.js +0 -57
  100. data/node_modules/bootstrap/js/src/dom/event-handler.js +0 -331
  101. data/node_modules/bootstrap/js/src/dom/manipulator.js +0 -80
  102. data/node_modules/bootstrap/js/src/dom/selector-engine.js +0 -75
  103. data/node_modules/bootstrap/js/src/dropdown.js +0 -543
  104. data/node_modules/bootstrap/js/src/modal.js +0 -582
  105. data/node_modules/bootstrap/js/src/offcanvas.js +0 -279
  106. data/node_modules/bootstrap/js/src/popover.js +0 -171
  107. data/node_modules/bootstrap/js/src/scrollspy.js +0 -319
  108. data/node_modules/bootstrap/js/src/tab.js +0 -220
  109. data/node_modules/bootstrap/js/src/toast.js +0 -219
  110. data/node_modules/bootstrap/js/src/tooltip.js +0 -802
  111. data/node_modules/bootstrap/js/src/util/index.js +0 -253
  112. data/node_modules/bootstrap/js/src/util/sanitizer.js +0 -127
  113. data/node_modules/bootstrap/js/src/util/scrollbar.js +0 -70
@@ -1,253 +0,0 @@
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
- }
@@ -1,127 +0,0 @@
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
- }
@@ -1,70 +0,0 @@
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
- }