publishing_platform_publishing_components 0.1.0
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 +7 -0
- data/LICENSE +22 -0
- data/README.md +2 -0
- data/Rakefile +41 -0
- data/app/assets/builds/gemkeep +0 -0
- data/app/assets/config/publishing_platform_publishing_components_manifest.js +2 -0
- data/app/assets/images/publishing_platform_publishing_components/gemkeep +0 -0
- data/app/assets/stylesheets/publishing_platform_publishing_components/_all_components.scss +3 -0
- data/app/assets/stylesheets/publishing_platform_publishing_components/components/_attachment.scss +117 -0
- data/app/assets/stylesheets/publishing_platform_publishing_components/components/_summary-list.scss +169 -0
- data/app/controllers/publishing_platform_publishing_components/application_controller.rb +4 -0
- data/app/helpers/publishing_platform_publishing_components/application_helper.rb +4 -0
- data/app/models/publishing_platform_publishing_components/component_doc.rb +90 -0
- data/app/models/publishing_platform_publishing_components/component_docs.rb +57 -0
- data/app/models/publishing_platform_publishing_components/component_example.rb +104 -0
- data/app/models/publishing_platform_publishing_components/shared_accessibility_criteria.rb +37 -0
- data/app/views/publishing_platform_publishing_components/component_doc/_component_output.html.erb +15 -0
- data/app/views/publishing_platform_publishing_components/components/_attachment.html.erb +91 -0
- data/app/views/publishing_platform_publishing_components/components/_error_summary.html.erb +38 -0
- data/app/views/publishing_platform_publishing_components/components/_summary_list.html.erb +135 -0
- data/app/views/publishing_platform_publishing_components/components/attachment/_thumbnail_document.html.erb +3 -0
- data/app/views/publishing_platform_publishing_components/components/attachment/_thumbnail_external.html.erb +3 -0
- data/app/views/publishing_platform_publishing_components/components/attachment/_thumbnail_generic.html.erb +4 -0
- data/app/views/publishing_platform_publishing_components/components/attachment/_thumbnail_html.html.erb +3 -0
- data/app/views/publishing_platform_publishing_components/components/attachment/_thumbnail_pdf.html.erb +3 -0
- data/app/views/publishing_platform_publishing_components/components/attachment/_thumbnail_spreadsheet.html.erb +5 -0
- data/app/views/publishing_platform_publishing_components/components/docs/attachment.yml +104 -0
- data/app/views/publishing_platform_publishing_components/components/docs/error_summary.yml +51 -0
- data/app/views/publishing_platform_publishing_components/components/docs/summary_list.yml +137 -0
- data/config/initializers/assets.rb +24 -0
- data/config/routes.rb +2 -0
- data/lib/publishing_platform_publishing_components/config.rb +25 -0
- data/lib/publishing_platform_publishing_components/engine.rb +5 -0
- data/lib/publishing_platform_publishing_components/presenters/attachment_helper.rb +176 -0
- data/lib/publishing_platform_publishing_components/presenters/component_wrapper_helper.rb +290 -0
- data/lib/publishing_platform_publishing_components/presenters/shared_helper.rb +24 -0
- data/lib/publishing_platform_publishing_components/version.rb +3 -0
- data/lib/publishing_platform_publishing_components.rb +10 -0
- data/lib/tasks/publishing_platform_publishing_components_tasks.rake +4 -0
- data/node_modules/bootstrap/LICENSE +21 -0
- data/node_modules/bootstrap/README.md +246 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.css +4085 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.min.css +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.rtl.css +4084 -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 +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap-grid.rtl.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.css +601 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.min.css +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.rtl.css +598 -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 +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap-reboot.rtl.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.css +5406 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.min.css +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.rtl.css +5397 -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 +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap-utilities.rtl.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap.css +12048 -0
- data/node_modules/bootstrap/dist/css/bootstrap.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap.min.css +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap.min.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap.rtl.css +12021 -0
- data/node_modules/bootstrap/dist/css/bootstrap.rtl.css.map +1 -0
- data/node_modules/bootstrap/dist/css/bootstrap.rtl.min.css +6 -0
- data/node_modules/bootstrap/dist/css/bootstrap.rtl.min.css.map +1 -0
- data/node_modules/bootstrap/dist/js/bootstrap.bundle.js +6312 -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 +4447 -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 +4494 -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 +90 -0
- data/node_modules/bootstrap/js/dist/alert.js.map +1 -0
- data/node_modules/bootstrap/js/dist/base-component.js +86 -0
- data/node_modules/bootstrap/js/dist/base-component.js.map +1 -0
- data/node_modules/bootstrap/js/dist/button.js +79 -0
- data/node_modules/bootstrap/js/dist/button.js.map +1 -0
- data/node_modules/bootstrap/js/dist/carousel.js +388 -0
- data/node_modules/bootstrap/js/dist/carousel.js.map +1 -0
- data/node_modules/bootstrap/js/dist/collapse.js +249 -0
- data/node_modules/bootstrap/js/dist/collapse.js.map +1 -0
- data/node_modules/bootstrap/js/dist/dom/data.js +63 -0
- data/node_modules/bootstrap/js/dist/dom/data.js.map +1 -0
- data/node_modules/bootstrap/js/dist/dom/event-handler.js +237 -0
- data/node_modules/bootstrap/js/dist/dom/event-handler.js.map +1 -0
- data/node_modules/bootstrap/js/dist/dom/manipulator.js +72 -0
- data/node_modules/bootstrap/js/dist/dom/manipulator.js.map +1 -0
- data/node_modules/bootstrap/js/dist/dom/selector-engine.js +104 -0
- data/node_modules/bootstrap/js/dist/dom/selector-engine.js.map +1 -0
- data/node_modules/bootstrap/js/dist/dropdown.js +402 -0
- data/node_modules/bootstrap/js/dist/dropdown.js.map +1 -0
- data/node_modules/bootstrap/js/dist/modal.js +320 -0
- data/node_modules/bootstrap/js/dist/modal.js.map +1 -0
- data/node_modules/bootstrap/js/dist/offcanvas.js +246 -0
- data/node_modules/bootstrap/js/dist/offcanvas.js.map +1 -0
- data/node_modules/bootstrap/js/dist/popover.js +96 -0
- data/node_modules/bootstrap/js/dist/popover.js.map +1 -0
- data/node_modules/bootstrap/js/dist/scrollspy.js +275 -0
- data/node_modules/bootstrap/js/dist/scrollspy.js.map +1 -0
- data/node_modules/bootstrap/js/dist/tab.js +285 -0
- data/node_modules/bootstrap/js/dist/tab.js.map +1 -0
- data/node_modules/bootstrap/js/dist/toast.js +198 -0
- data/node_modules/bootstrap/js/dist/toast.js.map +1 -0
- data/node_modules/bootstrap/js/dist/tooltip.js +546 -0
- data/node_modules/bootstrap/js/dist/tooltip.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/backdrop.js +139 -0
- data/node_modules/bootstrap/js/dist/util/backdrop.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/component-functions.js +42 -0
- data/node_modules/bootstrap/js/dist/util/component-functions.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/config.js +68 -0
- data/node_modules/bootstrap/js/dist/util/config.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/focustrap.js +113 -0
- data/node_modules/bootstrap/js/dist/util/focustrap.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/index.js +281 -0
- data/node_modules/bootstrap/js/dist/util/index.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/sanitizer.js +113 -0
- data/node_modules/bootstrap/js/dist/util/sanitizer.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/scrollbar.js +113 -0
- data/node_modules/bootstrap/js/dist/util/scrollbar.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/swipe.js +135 -0
- data/node_modules/bootstrap/js/dist/util/swipe.js.map +1 -0
- data/node_modules/bootstrap/js/dist/util/template-factory.js +151 -0
- data/node_modules/bootstrap/js/dist/util/template-factory.js.map +1 -0
- data/node_modules/bootstrap/js/index.esm.js +19 -0
- data/node_modules/bootstrap/js/index.umd.js +34 -0
- data/node_modules/bootstrap/js/src/alert.js +87 -0
- data/node_modules/bootstrap/js/src/base-component.js +86 -0
- data/node_modules/bootstrap/js/src/button.js +72 -0
- data/node_modules/bootstrap/js/src/carousel.js +474 -0
- data/node_modules/bootstrap/js/src/collapse.js +297 -0
- data/node_modules/bootstrap/js/src/dom/data.js +55 -0
- data/node_modules/bootstrap/js/src/dom/event-handler.js +317 -0
- data/node_modules/bootstrap/js/src/dom/manipulator.js +71 -0
- data/node_modules/bootstrap/js/src/dom/selector-engine.js +126 -0
- data/node_modules/bootstrap/js/src/dropdown.js +455 -0
- data/node_modules/bootstrap/js/src/modal.js +378 -0
- data/node_modules/bootstrap/js/src/offcanvas.js +282 -0
- data/node_modules/bootstrap/js/src/popover.js +97 -0
- data/node_modules/bootstrap/js/src/scrollspy.js +296 -0
- data/node_modules/bootstrap/js/src/tab.js +315 -0
- data/node_modules/bootstrap/js/src/toast.js +224 -0
- data/node_modules/bootstrap/js/src/tooltip.js +633 -0
- data/node_modules/bootstrap/js/src/util/backdrop.js +151 -0
- data/node_modules/bootstrap/js/src/util/component-functions.js +35 -0
- data/node_modules/bootstrap/js/src/util/config.js +65 -0
- data/node_modules/bootstrap/js/src/util/focustrap.js +115 -0
- data/node_modules/bootstrap/js/src/util/index.js +306 -0
- data/node_modules/bootstrap/js/src/util/sanitizer.js +116 -0
- data/node_modules/bootstrap/js/src/util/scrollbar.js +114 -0
- data/node_modules/bootstrap/js/src/util/swipe.js +146 -0
- data/node_modules/bootstrap/js/src/util/template-factory.js +160 -0
- data/node_modules/bootstrap/package.json +210 -0
- data/node_modules/bootstrap/scss/_accordion.scss +153 -0
- data/node_modules/bootstrap/scss/_alert.scss +68 -0
- data/node_modules/bootstrap/scss/_badge.scss +38 -0
- data/node_modules/bootstrap/scss/_breadcrumb.scss +40 -0
- data/node_modules/bootstrap/scss/_button-group.scss +147 -0
- data/node_modules/bootstrap/scss/_buttons.scss +216 -0
- data/node_modules/bootstrap/scss/_card.scss +238 -0
- data/node_modules/bootstrap/scss/_carousel.scss +226 -0
- data/node_modules/bootstrap/scss/_close.scss +66 -0
- data/node_modules/bootstrap/scss/_containers.scss +41 -0
- data/node_modules/bootstrap/scss/_dropdown.scss +250 -0
- data/node_modules/bootstrap/scss/_forms.scss +9 -0
- data/node_modules/bootstrap/scss/_functions.scss +302 -0
- data/node_modules/bootstrap/scss/_grid.scss +39 -0
- data/node_modules/bootstrap/scss/_helpers.scss +12 -0
- data/node_modules/bootstrap/scss/_images.scss +42 -0
- data/node_modules/bootstrap/scss/_list-group.scss +199 -0
- data/node_modules/bootstrap/scss/_maps.scss +174 -0
- data/node_modules/bootstrap/scss/_mixins.scss +42 -0
- data/node_modules/bootstrap/scss/_modal.scss +240 -0
- data/node_modules/bootstrap/scss/_nav.scss +197 -0
- data/node_modules/bootstrap/scss/_navbar.scss +289 -0
- data/node_modules/bootstrap/scss/_offcanvas.scss +147 -0
- data/node_modules/bootstrap/scss/_pagination.scss +109 -0
- data/node_modules/bootstrap/scss/_placeholders.scss +51 -0
- data/node_modules/bootstrap/scss/_popover.scss +196 -0
- data/node_modules/bootstrap/scss/_progress.scss +68 -0
- data/node_modules/bootstrap/scss/_reboot.scss +617 -0
- data/node_modules/bootstrap/scss/_root.scss +187 -0
- data/node_modules/bootstrap/scss/_spinners.scss +86 -0
- data/node_modules/bootstrap/scss/_tables.scss +171 -0
- data/node_modules/bootstrap/scss/_toasts.scss +73 -0
- data/node_modules/bootstrap/scss/_tooltip.scss +119 -0
- data/node_modules/bootstrap/scss/_transitions.scss +27 -0
- data/node_modules/bootstrap/scss/_type.scss +106 -0
- data/node_modules/bootstrap/scss/_utilities.scss +806 -0
- data/node_modules/bootstrap/scss/_variables-dark.scss +102 -0
- data/node_modules/bootstrap/scss/_variables.scss +1753 -0
- data/node_modules/bootstrap/scss/bootstrap-grid.scss +62 -0
- data/node_modules/bootstrap/scss/bootstrap-reboot.scss +10 -0
- data/node_modules/bootstrap/scss/bootstrap-utilities.scss +19 -0
- data/node_modules/bootstrap/scss/bootstrap.scss +52 -0
- data/node_modules/bootstrap/scss/forms/_floating-labels.scss +97 -0
- data/node_modules/bootstrap/scss/forms/_form-check.scss +189 -0
- data/node_modules/bootstrap/scss/forms/_form-control.scss +214 -0
- data/node_modules/bootstrap/scss/forms/_form-range.scss +91 -0
- data/node_modules/bootstrap/scss/forms/_form-select.scss +80 -0
- data/node_modules/bootstrap/scss/forms/_form-text.scss +11 -0
- data/node_modules/bootstrap/scss/forms/_input-group.scss +132 -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/_color-bg.scss +7 -0
- data/node_modules/bootstrap/scss/helpers/_colored-links.scss +30 -0
- data/node_modules/bootstrap/scss/helpers/_focus-ring.scss +5 -0
- data/node_modules/bootstrap/scss/helpers/_icon-link.scss +25 -0
- data/node_modules/bootstrap/scss/helpers/_position.scss +36 -0
- data/node_modules/bootstrap/scss/helpers/_ratio.scss +26 -0
- data/node_modules/bootstrap/scss/helpers/_stacks.scss +15 -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/helpers/_vr.scss +8 -0
- data/node_modules/bootstrap/scss/mixins/_alert.scss +18 -0
- data/node_modules/bootstrap/scss/mixins/_backdrop.scss +14 -0
- data/node_modules/bootstrap/scss/mixins/_banner.scss +7 -0
- data/node_modules/bootstrap/scss/mixins/_border-radius.scss +78 -0
- data/node_modules/bootstrap/scss/mixins/_box-shadow.scss +24 -0
- data/node_modules/bootstrap/scss/mixins/_breakpoints.scss +127 -0
- data/node_modules/bootstrap/scss/mixins/_buttons.scss +70 -0
- data/node_modules/bootstrap/scss/mixins/_caret.scss +69 -0
- data/node_modules/bootstrap/scss/mixins/_clearfix.scss +9 -0
- data/node_modules/bootstrap/scss/mixins/_color-mode.scss +21 -0
- data/node_modules/bootstrap/scss/mixins/_color-scheme.scss +7 -0
- data/node_modules/bootstrap/scss/mixins/_container.scss +11 -0
- data/node_modules/bootstrap/scss/mixins/_deprecate.scss +10 -0
- data/node_modules/bootstrap/scss/mixins/_forms.scss +163 -0
- data/node_modules/bootstrap/scss/mixins/_gradients.scss +47 -0
- data/node_modules/bootstrap/scss/mixins/_grid.scss +151 -0
- data/node_modules/bootstrap/scss/mixins/_image.scss +16 -0
- data/node_modules/bootstrap/scss/mixins/_list-group.scss +26 -0
- data/node_modules/bootstrap/scss/mixins/_lists.scss +7 -0
- data/node_modules/bootstrap/scss/mixins/_pagination.scss +10 -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 +24 -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 +97 -0
- data/node_modules/bootstrap/scss/mixins/_visually-hidden.scss +38 -0
- data/node_modules/bootstrap/scss/utilities/_api.scss +47 -0
- data/node_modules/bootstrap/scss/vendor/_rfs.scss +348 -0
- metadata +448 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap util/sanitizer.js
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
* --------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// js-docs-start allow-list
|
|
9
|
+
const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
|
|
10
|
+
|
|
11
|
+
export const DefaultAllowlist = {
|
|
12
|
+
// Global attributes allowed on any supplied element below.
|
|
13
|
+
'*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
|
|
14
|
+
a: ['target', 'href', 'title', 'rel'],
|
|
15
|
+
area: [],
|
|
16
|
+
b: [],
|
|
17
|
+
br: [],
|
|
18
|
+
col: [],
|
|
19
|
+
code: [],
|
|
20
|
+
dd: [],
|
|
21
|
+
div: [],
|
|
22
|
+
dl: [],
|
|
23
|
+
dt: [],
|
|
24
|
+
em: [],
|
|
25
|
+
hr: [],
|
|
26
|
+
h1: [],
|
|
27
|
+
h2: [],
|
|
28
|
+
h3: [],
|
|
29
|
+
h4: [],
|
|
30
|
+
h5: [],
|
|
31
|
+
h6: [],
|
|
32
|
+
i: [],
|
|
33
|
+
img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
|
|
34
|
+
li: [],
|
|
35
|
+
ol: [],
|
|
36
|
+
p: [],
|
|
37
|
+
pre: [],
|
|
38
|
+
s: [],
|
|
39
|
+
small: [],
|
|
40
|
+
span: [],
|
|
41
|
+
sub: [],
|
|
42
|
+
sup: [],
|
|
43
|
+
strong: [],
|
|
44
|
+
u: [],
|
|
45
|
+
ul: []
|
|
46
|
+
}
|
|
47
|
+
// js-docs-end allow-list
|
|
48
|
+
|
|
49
|
+
const uriAttributes = new Set([
|
|
50
|
+
'background',
|
|
51
|
+
'cite',
|
|
52
|
+
'href',
|
|
53
|
+
'itemtype',
|
|
54
|
+
'longdesc',
|
|
55
|
+
'poster',
|
|
56
|
+
'src',
|
|
57
|
+
'xlink:href'
|
|
58
|
+
])
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A pattern that recognizes URLs that are safe wrt. XSS in URL navigation
|
|
62
|
+
* contexts.
|
|
63
|
+
*
|
|
64
|
+
* Shout-out to Angular https://github.com/angular/angular/blob/15.2.8/packages/core/src/sanitization/url_sanitizer.ts#L38
|
|
65
|
+
*/
|
|
66
|
+
const SAFE_URL_PATTERN = /^(?!javascript:)(?:[a-z0-9+.-]+:|[^&:/?#]*(?:[/?#]|$))/i
|
|
67
|
+
|
|
68
|
+
const allowedAttribute = (attribute, allowedAttributeList) => {
|
|
69
|
+
const attributeName = attribute.nodeName.toLowerCase()
|
|
70
|
+
|
|
71
|
+
if (allowedAttributeList.includes(attributeName)) {
|
|
72
|
+
if (uriAttributes.has(attributeName)) {
|
|
73
|
+
return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue))
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return true
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Check if a regular expression validates the attribute.
|
|
80
|
+
return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp)
|
|
81
|
+
.some(regex => regex.test(attributeName))
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) {
|
|
85
|
+
if (!unsafeHtml.length) {
|
|
86
|
+
return unsafeHtml
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (sanitizeFunction && typeof sanitizeFunction === 'function') {
|
|
90
|
+
return sanitizeFunction(unsafeHtml)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const domParser = new window.DOMParser()
|
|
94
|
+
const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html')
|
|
95
|
+
const elements = [].concat(...createdDocument.body.querySelectorAll('*'))
|
|
96
|
+
|
|
97
|
+
for (const element of elements) {
|
|
98
|
+
const elementName = element.nodeName.toLowerCase()
|
|
99
|
+
|
|
100
|
+
if (!Object.keys(allowList).includes(elementName)) {
|
|
101
|
+
element.remove()
|
|
102
|
+
continue
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const attributeList = [].concat(...element.attributes)
|
|
106
|
+
const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || [])
|
|
107
|
+
|
|
108
|
+
for (const attribute of attributeList) {
|
|
109
|
+
if (!allowedAttribute(attribute, allowedAttributes)) {
|
|
110
|
+
element.removeAttribute(attribute.nodeName)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return createdDocument.body.innerHTML
|
|
116
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap util/scrollBar.js
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
* --------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import Manipulator from '../dom/manipulator.js'
|
|
9
|
+
import SelectorEngine from '../dom/selector-engine.js'
|
|
10
|
+
import { isElement } from './index.js'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Constants
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'
|
|
17
|
+
const SELECTOR_STICKY_CONTENT = '.sticky-top'
|
|
18
|
+
const PROPERTY_PADDING = 'padding-right'
|
|
19
|
+
const PROPERTY_MARGIN = 'margin-right'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Class definition
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
class ScrollBarHelper {
|
|
26
|
+
constructor() {
|
|
27
|
+
this._element = document.body
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Public
|
|
31
|
+
getWidth() {
|
|
32
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
|
|
33
|
+
const documentWidth = document.documentElement.clientWidth
|
|
34
|
+
return Math.abs(window.innerWidth - documentWidth)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
hide() {
|
|
38
|
+
const width = this.getWidth()
|
|
39
|
+
this._disableOverFlow()
|
|
40
|
+
// give padding to element to balance the hidden scrollbar width
|
|
41
|
+
this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width)
|
|
42
|
+
// trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth
|
|
43
|
+
this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width)
|
|
44
|
+
this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
reset() {
|
|
48
|
+
this._resetElementAttributes(this._element, 'overflow')
|
|
49
|
+
this._resetElementAttributes(this._element, PROPERTY_PADDING)
|
|
50
|
+
this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING)
|
|
51
|
+
this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
isOverflowing() {
|
|
55
|
+
return this.getWidth() > 0
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Private
|
|
59
|
+
_disableOverFlow() {
|
|
60
|
+
this._saveInitialAttribute(this._element, 'overflow')
|
|
61
|
+
this._element.style.overflow = 'hidden'
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
_setElementAttributes(selector, styleProperty, callback) {
|
|
65
|
+
const scrollbarWidth = this.getWidth()
|
|
66
|
+
const manipulationCallBack = element => {
|
|
67
|
+
if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this._saveInitialAttribute(element, styleProperty)
|
|
72
|
+
const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty)
|
|
73
|
+
element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this._applyManipulationCallback(selector, manipulationCallBack)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
_saveInitialAttribute(element, styleProperty) {
|
|
80
|
+
const actualValue = element.style.getPropertyValue(styleProperty)
|
|
81
|
+
if (actualValue) {
|
|
82
|
+
Manipulator.setDataAttribute(element, styleProperty, actualValue)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
_resetElementAttributes(selector, styleProperty) {
|
|
87
|
+
const manipulationCallBack = element => {
|
|
88
|
+
const value = Manipulator.getDataAttribute(element, styleProperty)
|
|
89
|
+
// We only want to remove the property if the value is `null`; the value can also be zero
|
|
90
|
+
if (value === null) {
|
|
91
|
+
element.style.removeProperty(styleProperty)
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
Manipulator.removeDataAttribute(element, styleProperty)
|
|
96
|
+
element.style.setProperty(styleProperty, value)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
this._applyManipulationCallback(selector, manipulationCallBack)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
_applyManipulationCallback(selector, callBack) {
|
|
103
|
+
if (isElement(selector)) {
|
|
104
|
+
callBack(selector)
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
for (const sel of SelectorEngine.find(selector, this._element)) {
|
|
109
|
+
callBack(sel)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export default ScrollBarHelper
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap util/swipe.js
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
* --------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import EventHandler from '../dom/event-handler.js'
|
|
9
|
+
import Config from './config.js'
|
|
10
|
+
import { execute } from './index.js'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Constants
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const NAME = 'swipe'
|
|
17
|
+
const EVENT_KEY = '.bs.swipe'
|
|
18
|
+
const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`
|
|
19
|
+
const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`
|
|
20
|
+
const EVENT_TOUCHEND = `touchend${EVENT_KEY}`
|
|
21
|
+
const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY}`
|
|
22
|
+
const EVENT_POINTERUP = `pointerup${EVENT_KEY}`
|
|
23
|
+
const POINTER_TYPE_TOUCH = 'touch'
|
|
24
|
+
const POINTER_TYPE_PEN = 'pen'
|
|
25
|
+
const CLASS_NAME_POINTER_EVENT = 'pointer-event'
|
|
26
|
+
const SWIPE_THRESHOLD = 40
|
|
27
|
+
|
|
28
|
+
const Default = {
|
|
29
|
+
endCallback: null,
|
|
30
|
+
leftCallback: null,
|
|
31
|
+
rightCallback: null
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const DefaultType = {
|
|
35
|
+
endCallback: '(function|null)',
|
|
36
|
+
leftCallback: '(function|null)',
|
|
37
|
+
rightCallback: '(function|null)'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Class definition
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
class Swipe extends Config {
|
|
45
|
+
constructor(element, config) {
|
|
46
|
+
super()
|
|
47
|
+
this._element = element
|
|
48
|
+
|
|
49
|
+
if (!element || !Swipe.isSupported()) {
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
this._config = this._getConfig(config)
|
|
54
|
+
this._deltaX = 0
|
|
55
|
+
this._supportPointerEvents = Boolean(window.PointerEvent)
|
|
56
|
+
this._initEvents()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Getters
|
|
60
|
+
static get Default() {
|
|
61
|
+
return Default
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static get DefaultType() {
|
|
65
|
+
return DefaultType
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static get NAME() {
|
|
69
|
+
return NAME
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Public
|
|
73
|
+
dispose() {
|
|
74
|
+
EventHandler.off(this._element, EVENT_KEY)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Private
|
|
78
|
+
_start(event) {
|
|
79
|
+
if (!this._supportPointerEvents) {
|
|
80
|
+
this._deltaX = event.touches[0].clientX
|
|
81
|
+
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (this._eventIsPointerPenTouch(event)) {
|
|
86
|
+
this._deltaX = event.clientX
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
_end(event) {
|
|
91
|
+
if (this._eventIsPointerPenTouch(event)) {
|
|
92
|
+
this._deltaX = event.clientX - this._deltaX
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
this._handleSwipe()
|
|
96
|
+
execute(this._config.endCallback)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
_move(event) {
|
|
100
|
+
this._deltaX = event.touches && event.touches.length > 1 ?
|
|
101
|
+
0 :
|
|
102
|
+
event.touches[0].clientX - this._deltaX
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_handleSwipe() {
|
|
106
|
+
const absDeltaX = Math.abs(this._deltaX)
|
|
107
|
+
|
|
108
|
+
if (absDeltaX <= SWIPE_THRESHOLD) {
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const direction = absDeltaX / this._deltaX
|
|
113
|
+
|
|
114
|
+
this._deltaX = 0
|
|
115
|
+
|
|
116
|
+
if (!direction) {
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
_initEvents() {
|
|
124
|
+
if (this._supportPointerEvents) {
|
|
125
|
+
EventHandler.on(this._element, EVENT_POINTERDOWN, event => this._start(event))
|
|
126
|
+
EventHandler.on(this._element, EVENT_POINTERUP, event => this._end(event))
|
|
127
|
+
|
|
128
|
+
this._element.classList.add(CLASS_NAME_POINTER_EVENT)
|
|
129
|
+
} else {
|
|
130
|
+
EventHandler.on(this._element, EVENT_TOUCHSTART, event => this._start(event))
|
|
131
|
+
EventHandler.on(this._element, EVENT_TOUCHMOVE, event => this._move(event))
|
|
132
|
+
EventHandler.on(this._element, EVENT_TOUCHEND, event => this._end(event))
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
_eventIsPointerPenTouch(event) {
|
|
137
|
+
return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Static
|
|
141
|
+
static isSupported() {
|
|
142
|
+
return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export default Swipe
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap util/template-factory.js
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
* --------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import SelectorEngine from '../dom/selector-engine.js'
|
|
9
|
+
import Config from './config.js'
|
|
10
|
+
import { DefaultAllowlist, sanitizeHtml } from './sanitizer.js'
|
|
11
|
+
import { execute, getElement, isElement } from './index.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Constants
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const NAME = 'TemplateFactory'
|
|
18
|
+
|
|
19
|
+
const Default = {
|
|
20
|
+
allowList: DefaultAllowlist,
|
|
21
|
+
content: {}, // { selector : text , selector2 : text2 , }
|
|
22
|
+
extraClass: '',
|
|
23
|
+
html: false,
|
|
24
|
+
sanitize: true,
|
|
25
|
+
sanitizeFn: null,
|
|
26
|
+
template: '<div></div>'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const DefaultType = {
|
|
30
|
+
allowList: 'object',
|
|
31
|
+
content: 'object',
|
|
32
|
+
extraClass: '(string|function)',
|
|
33
|
+
html: 'boolean',
|
|
34
|
+
sanitize: 'boolean',
|
|
35
|
+
sanitizeFn: '(null|function)',
|
|
36
|
+
template: 'string'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const DefaultContentType = {
|
|
40
|
+
entry: '(string|element|function|null)',
|
|
41
|
+
selector: '(string|element)'
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Class definition
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
class TemplateFactory extends Config {
|
|
49
|
+
constructor(config) {
|
|
50
|
+
super()
|
|
51
|
+
this._config = this._getConfig(config)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Getters
|
|
55
|
+
static get Default() {
|
|
56
|
+
return Default
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static get DefaultType() {
|
|
60
|
+
return DefaultType
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static get NAME() {
|
|
64
|
+
return NAME
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Public
|
|
68
|
+
getContent() {
|
|
69
|
+
return Object.values(this._config.content)
|
|
70
|
+
.map(config => this._resolvePossibleFunction(config))
|
|
71
|
+
.filter(Boolean)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
hasContent() {
|
|
75
|
+
return this.getContent().length > 0
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
changeContent(content) {
|
|
79
|
+
this._checkContent(content)
|
|
80
|
+
this._config.content = { ...this._config.content, ...content }
|
|
81
|
+
return this
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
toHtml() {
|
|
85
|
+
const templateWrapper = document.createElement('div')
|
|
86
|
+
templateWrapper.innerHTML = this._maybeSanitize(this._config.template)
|
|
87
|
+
|
|
88
|
+
for (const [selector, text] of Object.entries(this._config.content)) {
|
|
89
|
+
this._setContent(templateWrapper, text, selector)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const template = templateWrapper.children[0]
|
|
93
|
+
const extraClass = this._resolvePossibleFunction(this._config.extraClass)
|
|
94
|
+
|
|
95
|
+
if (extraClass) {
|
|
96
|
+
template.classList.add(...extraClass.split(' '))
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return template
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Private
|
|
103
|
+
_typeCheckConfig(config) {
|
|
104
|
+
super._typeCheckConfig(config)
|
|
105
|
+
this._checkContent(config.content)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
_checkContent(arg) {
|
|
109
|
+
for (const [selector, content] of Object.entries(arg)) {
|
|
110
|
+
super._typeCheckConfig({ selector, entry: content }, DefaultContentType)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
_setContent(template, content, selector) {
|
|
115
|
+
const templateElement = SelectorEngine.findOne(selector, template)
|
|
116
|
+
|
|
117
|
+
if (!templateElement) {
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
content = this._resolvePossibleFunction(content)
|
|
122
|
+
|
|
123
|
+
if (!content) {
|
|
124
|
+
templateElement.remove()
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (isElement(content)) {
|
|
129
|
+
this._putElementInTemplate(getElement(content), templateElement)
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (this._config.html) {
|
|
134
|
+
templateElement.innerHTML = this._maybeSanitize(content)
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
templateElement.textContent = content
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
_maybeSanitize(arg) {
|
|
142
|
+
return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
_resolvePossibleFunction(arg) {
|
|
146
|
+
return execute(arg, [undefined, this])
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
_putElementInTemplate(element, templateElement) {
|
|
150
|
+
if (this._config.html) {
|
|
151
|
+
templateElement.innerHTML = ''
|
|
152
|
+
templateElement.append(element)
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
templateElement.textContent = element.textContent
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export default TemplateFactory
|