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,135 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Bootstrap swipe.js v5.3.8 (https://getbootstrap.com/)
|
|
3
|
+
* Copyright 2011-2025 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
*/
|
|
6
|
+
(function (global, factory) {
|
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../dom/event-handler.js'), require('./config.js'), require('./index.js')) :
|
|
8
|
+
typeof define === 'function' && define.amd ? define(['../dom/event-handler', './config', './index'], factory) :
|
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Swipe = factory(global.EventHandler, global.Config, global.Index));
|
|
10
|
+
})(this, (function (EventHandler, Config, index_js) { 'use strict';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* --------------------------------------------------------------------------
|
|
14
|
+
* Bootstrap util/swipe.js
|
|
15
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
16
|
+
* --------------------------------------------------------------------------
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Constants
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const NAME = 'swipe';
|
|
25
|
+
const EVENT_KEY = '.bs.swipe';
|
|
26
|
+
const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`;
|
|
27
|
+
const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`;
|
|
28
|
+
const EVENT_TOUCHEND = `touchend${EVENT_KEY}`;
|
|
29
|
+
const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY}`;
|
|
30
|
+
const EVENT_POINTERUP = `pointerup${EVENT_KEY}`;
|
|
31
|
+
const POINTER_TYPE_TOUCH = 'touch';
|
|
32
|
+
const POINTER_TYPE_PEN = 'pen';
|
|
33
|
+
const CLASS_NAME_POINTER_EVENT = 'pointer-event';
|
|
34
|
+
const SWIPE_THRESHOLD = 40;
|
|
35
|
+
const Default = {
|
|
36
|
+
endCallback: null,
|
|
37
|
+
leftCallback: null,
|
|
38
|
+
rightCallback: null
|
|
39
|
+
};
|
|
40
|
+
const DefaultType = {
|
|
41
|
+
endCallback: '(function|null)',
|
|
42
|
+
leftCallback: '(function|null)',
|
|
43
|
+
rightCallback: '(function|null)'
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Class definition
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
class Swipe extends Config {
|
|
51
|
+
constructor(element, config) {
|
|
52
|
+
super();
|
|
53
|
+
this._element = element;
|
|
54
|
+
if (!element || !Swipe.isSupported()) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
this._config = this._getConfig(config);
|
|
58
|
+
this._deltaX = 0;
|
|
59
|
+
this._supportPointerEvents = Boolean(window.PointerEvent);
|
|
60
|
+
this._initEvents();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Getters
|
|
64
|
+
static get Default() {
|
|
65
|
+
return Default;
|
|
66
|
+
}
|
|
67
|
+
static get DefaultType() {
|
|
68
|
+
return DefaultType;
|
|
69
|
+
}
|
|
70
|
+
static get NAME() {
|
|
71
|
+
return NAME;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Public
|
|
75
|
+
dispose() {
|
|
76
|
+
EventHandler.off(this._element, EVENT_KEY);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Private
|
|
80
|
+
_start(event) {
|
|
81
|
+
if (!this._supportPointerEvents) {
|
|
82
|
+
this._deltaX = event.touches[0].clientX;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (this._eventIsPointerPenTouch(event)) {
|
|
86
|
+
this._deltaX = event.clientX;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
_end(event) {
|
|
90
|
+
if (this._eventIsPointerPenTouch(event)) {
|
|
91
|
+
this._deltaX = event.clientX - this._deltaX;
|
|
92
|
+
}
|
|
93
|
+
this._handleSwipe();
|
|
94
|
+
index_js.execute(this._config.endCallback);
|
|
95
|
+
}
|
|
96
|
+
_move(event) {
|
|
97
|
+
this._deltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this._deltaX;
|
|
98
|
+
}
|
|
99
|
+
_handleSwipe() {
|
|
100
|
+
const absDeltaX = Math.abs(this._deltaX);
|
|
101
|
+
if (absDeltaX <= SWIPE_THRESHOLD) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const direction = absDeltaX / this._deltaX;
|
|
105
|
+
this._deltaX = 0;
|
|
106
|
+
if (!direction) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
index_js.execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback);
|
|
110
|
+
}
|
|
111
|
+
_initEvents() {
|
|
112
|
+
if (this._supportPointerEvents) {
|
|
113
|
+
EventHandler.on(this._element, EVENT_POINTERDOWN, event => this._start(event));
|
|
114
|
+
EventHandler.on(this._element, EVENT_POINTERUP, event => this._end(event));
|
|
115
|
+
this._element.classList.add(CLASS_NAME_POINTER_EVENT);
|
|
116
|
+
} else {
|
|
117
|
+
EventHandler.on(this._element, EVENT_TOUCHSTART, event => this._start(event));
|
|
118
|
+
EventHandler.on(this._element, EVENT_TOUCHMOVE, event => this._move(event));
|
|
119
|
+
EventHandler.on(this._element, EVENT_TOUCHEND, event => this._end(event));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
_eventIsPointerPenTouch(event) {
|
|
123
|
+
return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Static
|
|
127
|
+
static isSupported() {
|
|
128
|
+
return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return Swipe;
|
|
133
|
+
|
|
134
|
+
}));
|
|
135
|
+
//# sourceMappingURL=swipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swipe.js","sources":["../../src/util/swipe.js"],"sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap util/swipe.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport EventHandler from '../dom/event-handler.js'\nimport Config from './config.js'\nimport { execute } from './index.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'swipe'\nconst EVENT_KEY = '.bs.swipe'\nconst EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`\nconst EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`\nconst EVENT_TOUCHEND = `touchend${EVENT_KEY}`\nconst EVENT_POINTERDOWN = `pointerdown${EVENT_KEY}`\nconst EVENT_POINTERUP = `pointerup${EVENT_KEY}`\nconst POINTER_TYPE_TOUCH = 'touch'\nconst POINTER_TYPE_PEN = 'pen'\nconst CLASS_NAME_POINTER_EVENT = 'pointer-event'\nconst SWIPE_THRESHOLD = 40\n\nconst Default = {\n endCallback: null,\n leftCallback: null,\n rightCallback: null\n}\n\nconst DefaultType = {\n endCallback: '(function|null)',\n leftCallback: '(function|null)',\n rightCallback: '(function|null)'\n}\n\n/**\n * Class definition\n */\n\nclass Swipe extends Config {\n constructor(element, config) {\n super()\n this._element = element\n\n if (!element || !Swipe.isSupported()) {\n return\n }\n\n this._config = this._getConfig(config)\n this._deltaX = 0\n this._supportPointerEvents = Boolean(window.PointerEvent)\n this._initEvents()\n }\n\n // Getters\n static get Default() {\n return Default\n }\n\n static get DefaultType() {\n return DefaultType\n }\n\n static get NAME() {\n return NAME\n }\n\n // Public\n dispose() {\n EventHandler.off(this._element, EVENT_KEY)\n }\n\n // Private\n _start(event) {\n if (!this._supportPointerEvents) {\n this._deltaX = event.touches[0].clientX\n\n return\n }\n\n if (this._eventIsPointerPenTouch(event)) {\n this._deltaX = event.clientX\n }\n }\n\n _end(event) {\n if (this._eventIsPointerPenTouch(event)) {\n this._deltaX = event.clientX - this._deltaX\n }\n\n this._handleSwipe()\n execute(this._config.endCallback)\n }\n\n _move(event) {\n this._deltaX = event.touches && event.touches.length > 1 ?\n 0 :\n event.touches[0].clientX - this._deltaX\n }\n\n _handleSwipe() {\n const absDeltaX = Math.abs(this._deltaX)\n\n if (absDeltaX <= SWIPE_THRESHOLD) {\n return\n }\n\n const direction = absDeltaX / this._deltaX\n\n this._deltaX = 0\n\n if (!direction) {\n return\n }\n\n execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback)\n }\n\n _initEvents() {\n if (this._supportPointerEvents) {\n EventHandler.on(this._element, EVENT_POINTERDOWN, event => this._start(event))\n EventHandler.on(this._element, EVENT_POINTERUP, event => this._end(event))\n\n this._element.classList.add(CLASS_NAME_POINTER_EVENT)\n } else {\n EventHandler.on(this._element, EVENT_TOUCHSTART, event => this._start(event))\n EventHandler.on(this._element, EVENT_TOUCHMOVE, event => this._move(event))\n EventHandler.on(this._element, EVENT_TOUCHEND, event => this._end(event))\n }\n }\n\n _eventIsPointerPenTouch(event) {\n return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)\n }\n\n // Static\n static isSupported() {\n return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0\n }\n}\n\nexport default Swipe\n"],"names":["NAME","EVENT_KEY","EVENT_TOUCHSTART","EVENT_TOUCHMOVE","EVENT_TOUCHEND","EVENT_POINTERDOWN","EVENT_POINTERUP","POINTER_TYPE_TOUCH","POINTER_TYPE_PEN","CLASS_NAME_POINTER_EVENT","SWIPE_THRESHOLD","Default","endCallback","leftCallback","rightCallback","DefaultType","Swipe","Config","constructor","element","config","_element","isSupported","_config","_getConfig","_deltaX","_supportPointerEvents","Boolean","window","PointerEvent","_initEvents","dispose","EventHandler","off","_start","event","touches","clientX","_eventIsPointerPenTouch","_end","_handleSwipe","execute","_move","length","absDeltaX","Math","abs","direction","on","classList","add","pointerType","document","documentElement","navigator","maxTouchPoints"],"mappings":";;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;EACA;;;EAMA;EACA;EACA;;EAEA,MAAMA,IAAI,GAAG,OAAO;EACpB,MAAMC,SAAS,GAAG,WAAW;EAC7B,MAAMC,gBAAgB,GAAG,CAAA,UAAA,EAAaD,SAAS,CAAA,CAAE;EACjD,MAAME,eAAe,GAAG,CAAA,SAAA,EAAYF,SAAS,CAAA,CAAE;EAC/C,MAAMG,cAAc,GAAG,CAAA,QAAA,EAAWH,SAAS,CAAA,CAAE;EAC7C,MAAMI,iBAAiB,GAAG,CAAA,WAAA,EAAcJ,SAAS,CAAA,CAAE;EACnD,MAAMK,eAAe,GAAG,CAAA,SAAA,EAAYL,SAAS,CAAA,CAAE;EAC/C,MAAMM,kBAAkB,GAAG,OAAO;EAClC,MAAMC,gBAAgB,GAAG,KAAK;EAC9B,MAAMC,wBAAwB,GAAG,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strap template-factory.js v5.3.8 (https://getbootstrap.com/)
|
|
3
|
+
* Copyright 2011-2025 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
*/
|
|
6
|
+
(function (global, factory) {
|
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../dom/selector-engine.js'), require('./config.js'), require('./sanitizer.js'), require('./index.js')) :
|
|
8
|
+
typeof define === 'function' && define.amd ? define(['../dom/selector-engine', './config', './sanitizer', './index'], factory) :
|
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.TemplateFactory = factory(global.SelectorEngine, global.Config, global.Sanitizer, global.Index));
|
|
10
|
+
})(this, (function (SelectorEngine, Config, sanitizer_js, index_js) { 'use strict';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* --------------------------------------------------------------------------
|
|
14
|
+
* Bootstrap util/template-factory.js
|
|
15
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
16
|
+
* --------------------------------------------------------------------------
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Constants
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const NAME = 'TemplateFactory';
|
|
25
|
+
const Default = {
|
|
26
|
+
allowList: sanitizer_js.DefaultAllowlist,
|
|
27
|
+
content: {},
|
|
28
|
+
// { selector : text , selector2 : text2 , }
|
|
29
|
+
extraClass: '',
|
|
30
|
+
html: false,
|
|
31
|
+
sanitize: true,
|
|
32
|
+
sanitizeFn: null,
|
|
33
|
+
template: '<div></div>'
|
|
34
|
+
};
|
|
35
|
+
const DefaultType = {
|
|
36
|
+
allowList: 'object',
|
|
37
|
+
content: 'object',
|
|
38
|
+
extraClass: '(string|function)',
|
|
39
|
+
html: 'boolean',
|
|
40
|
+
sanitize: 'boolean',
|
|
41
|
+
sanitizeFn: '(null|function)',
|
|
42
|
+
template: 'string'
|
|
43
|
+
};
|
|
44
|
+
const DefaultContentType = {
|
|
45
|
+
entry: '(string|element|function|null)',
|
|
46
|
+
selector: '(string|element)'
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Class definition
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
class TemplateFactory extends Config {
|
|
54
|
+
constructor(config) {
|
|
55
|
+
super();
|
|
56
|
+
this._config = this._getConfig(config);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Getters
|
|
60
|
+
static get Default() {
|
|
61
|
+
return Default;
|
|
62
|
+
}
|
|
63
|
+
static get DefaultType() {
|
|
64
|
+
return DefaultType;
|
|
65
|
+
}
|
|
66
|
+
static get NAME() {
|
|
67
|
+
return NAME;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Public
|
|
71
|
+
getContent() {
|
|
72
|
+
return Object.values(this._config.content).map(config => this._resolvePossibleFunction(config)).filter(Boolean);
|
|
73
|
+
}
|
|
74
|
+
hasContent() {
|
|
75
|
+
return this.getContent().length > 0;
|
|
76
|
+
}
|
|
77
|
+
changeContent(content) {
|
|
78
|
+
this._checkContent(content);
|
|
79
|
+
this._config.content = {
|
|
80
|
+
...this._config.content,
|
|
81
|
+
...content
|
|
82
|
+
};
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
toHtml() {
|
|
86
|
+
const templateWrapper = document.createElement('div');
|
|
87
|
+
templateWrapper.innerHTML = this._maybeSanitize(this._config.template);
|
|
88
|
+
for (const [selector, text] of Object.entries(this._config.content)) {
|
|
89
|
+
this._setContent(templateWrapper, text, selector);
|
|
90
|
+
}
|
|
91
|
+
const template = templateWrapper.children[0];
|
|
92
|
+
const extraClass = this._resolvePossibleFunction(this._config.extraClass);
|
|
93
|
+
if (extraClass) {
|
|
94
|
+
template.classList.add(...extraClass.split(' '));
|
|
95
|
+
}
|
|
96
|
+
return template;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Private
|
|
100
|
+
_typeCheckConfig(config) {
|
|
101
|
+
super._typeCheckConfig(config);
|
|
102
|
+
this._checkContent(config.content);
|
|
103
|
+
}
|
|
104
|
+
_checkContent(arg) {
|
|
105
|
+
for (const [selector, content] of Object.entries(arg)) {
|
|
106
|
+
super._typeCheckConfig({
|
|
107
|
+
selector,
|
|
108
|
+
entry: content
|
|
109
|
+
}, DefaultContentType);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
_setContent(template, content, selector) {
|
|
113
|
+
const templateElement = SelectorEngine.findOne(selector, template);
|
|
114
|
+
if (!templateElement) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
content = this._resolvePossibleFunction(content);
|
|
118
|
+
if (!content) {
|
|
119
|
+
templateElement.remove();
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (index_js.isElement(content)) {
|
|
123
|
+
this._putElementInTemplate(index_js.getElement(content), templateElement);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (this._config.html) {
|
|
127
|
+
templateElement.innerHTML = this._maybeSanitize(content);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
templateElement.textContent = content;
|
|
131
|
+
}
|
|
132
|
+
_maybeSanitize(arg) {
|
|
133
|
+
return this._config.sanitize ? sanitizer_js.sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg;
|
|
134
|
+
}
|
|
135
|
+
_resolvePossibleFunction(arg) {
|
|
136
|
+
return index_js.execute(arg, [undefined, this]);
|
|
137
|
+
}
|
|
138
|
+
_putElementInTemplate(element, templateElement) {
|
|
139
|
+
if (this._config.html) {
|
|
140
|
+
templateElement.innerHTML = '';
|
|
141
|
+
templateElement.append(element);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
templateElement.textContent = element.textContent;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return TemplateFactory;
|
|
149
|
+
|
|
150
|
+
}));
|
|
151
|
+
//# sourceMappingURL=template-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-factory.js","sources":["../../src/util/template-factory.js"],"sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap util/template-factory.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport SelectorEngine from '../dom/selector-engine.js'\nimport Config from './config.js'\nimport { DefaultAllowlist, sanitizeHtml } from './sanitizer.js'\nimport { execute, getElement, isElement } from './index.js'\n\n/**\n * Constants\n */\n\nconst NAME = 'TemplateFactory'\n\nconst Default = {\n allowList: DefaultAllowlist,\n content: {}, // { selector : text , selector2 : text2 , }\n extraClass: '',\n html: false,\n sanitize: true,\n sanitizeFn: null,\n template: '<div></div>'\n}\n\nconst DefaultType = {\n allowList: 'object',\n content: 'object',\n extraClass: '(string|function)',\n html: 'boolean',\n sanitize: 'boolean',\n sanitizeFn: '(null|function)',\n template: 'string'\n}\n\nconst DefaultContentType = {\n entry: '(string|element|function|null)',\n selector: '(string|element)'\n}\n\n/**\n * Class definition\n */\n\nclass TemplateFactory extends Config {\n constructor(config) {\n super()\n this._config = this._getConfig(config)\n }\n\n // Getters\n static get Default() {\n return Default\n }\n\n static get DefaultType() {\n return DefaultType\n }\n\n static get NAME() {\n return NAME\n }\n\n // Public\n getContent() {\n return Object.values(this._config.content)\n .map(config => this._resolvePossibleFunction(config))\n .filter(Boolean)\n }\n\n hasContent() {\n return this.getContent().length > 0\n }\n\n changeContent(content) {\n this._checkContent(content)\n this._config.content = { ...this._config.content, ...content }\n return this\n }\n\n toHtml() {\n const templateWrapper = document.createElement('div')\n templateWrapper.innerHTML = this._maybeSanitize(this._config.template)\n\n for (const [selector, text] of Object.entries(this._config.content)) {\n this._setContent(templateWrapper, text, selector)\n }\n\n const template = templateWrapper.children[0]\n const extraClass = this._resolvePossibleFunction(this._config.extraClass)\n\n if (extraClass) {\n template.classList.add(...extraClass.split(' '))\n }\n\n return template\n }\n\n // Private\n _typeCheckConfig(config) {\n super._typeCheckConfig(config)\n this._checkContent(config.content)\n }\n\n _checkContent(arg) {\n for (const [selector, content] of Object.entries(arg)) {\n super._typeCheckConfig({ selector, entry: content }, DefaultContentType)\n }\n }\n\n _setContent(template, content, selector) {\n const templateElement = SelectorEngine.findOne(selector, template)\n\n if (!templateElement) {\n return\n }\n\n content = this._resolvePossibleFunction(content)\n\n if (!content) {\n templateElement.remove()\n return\n }\n\n if (isElement(content)) {\n this._putElementInTemplate(getElement(content), templateElement)\n return\n }\n\n if (this._config.html) {\n templateElement.innerHTML = this._maybeSanitize(content)\n return\n }\n\n templateElement.textContent = content\n }\n\n _maybeSanitize(arg) {\n return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg\n }\n\n _resolvePossibleFunction(arg) {\n return execute(arg, [undefined, this])\n }\n\n _putElementInTemplate(element, templateElement) {\n if (this._config.html) {\n templateElement.innerHTML = ''\n templateElement.append(element)\n return\n }\n\n templateElement.textContent = element.textContent\n }\n}\n\nexport default TemplateFactory\n"],"names":["NAME","Default","allowList","DefaultAllowlist","content","extraClass","html","sanitize","sanitizeFn","template","DefaultType","DefaultContentType","entry","selector","TemplateFactory","Config","constructor","config","_config","_getConfig","getContent","Object","values","map","_resolvePossibleFunction","filter","Boolean","hasContent","length","changeContent","_checkContent","toHtml","templateWrapper","document","createElement","innerHTML","_maybeSanitize","text","entries","_setContent","children","classList","add","split","_typeCheckConfig","arg","templateElement","SelectorEngine","findOne","remove","isElement","_putElementInTemplate","getElement","textContent","sanitizeHtml","execute","undefined","element","append"],"mappings":";;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;EACA;;;EAOA;EACA;EACA;;EAEA,MAAMA,IAAI,GAAG,iBAAiB;EAE9B,MAAMC,OAAO,GAAG;EACdC,EAAAA,SAAS,EAAEC,6BAAgB;IAC3BC,OAAO,EA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B,OAAOU,gBAAO,CAACV,GAAG,EAAE,CAACW,SAAS,EAAE,IAAI,CAAC,CAAC;EACxC,EAAA;EAEAL,EAAAA,qBAAqBA,CAACM,OAAO,EAAEX,eAAe,EAAE;EAC9C,IAAA,IAAI,IAAI,CAAC5B,OAAO,CAACZ,IAAI,EAAE;QACrBwC,eAAe,CAACX,SAAS,GAAG,EAAE;EAC9BW,MAAAA,eAAe,CAACY,MAAM,CAACD,OAAO,CAAC;EAC/B,MAAA;EACF,IAAA;EAEAX,IAAAA,eAAe,CAACO,WAAW,GAAGI,OAAO,CAACJ,WAAW;EACnD,EAAA;EACF;;;;;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap index.esm.js
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
* --------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export { default as Alert } from './src/alert.js'
|
|
9
|
+
export { default as Button } from './src/button.js'
|
|
10
|
+
export { default as Carousel } from './src/carousel.js'
|
|
11
|
+
export { default as Collapse } from './src/collapse.js'
|
|
12
|
+
export { default as Dropdown } from './src/dropdown.js'
|
|
13
|
+
export { default as Modal } from './src/modal.js'
|
|
14
|
+
export { default as Offcanvas } from './src/offcanvas.js'
|
|
15
|
+
export { default as Popover } from './src/popover.js'
|
|
16
|
+
export { default as ScrollSpy } from './src/scrollspy.js'
|
|
17
|
+
export { default as Tab } from './src/tab.js'
|
|
18
|
+
export { default as Toast } from './src/toast.js'
|
|
19
|
+
export { default as Tooltip } from './src/tooltip.js'
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap index.umd.js
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
* --------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import Alert from './src/alert.js'
|
|
9
|
+
import Button from './src/button.js'
|
|
10
|
+
import Carousel from './src/carousel.js'
|
|
11
|
+
import Collapse from './src/collapse.js'
|
|
12
|
+
import Dropdown from './src/dropdown.js'
|
|
13
|
+
import Modal from './src/modal.js'
|
|
14
|
+
import Offcanvas from './src/offcanvas.js'
|
|
15
|
+
import Popover from './src/popover.js'
|
|
16
|
+
import ScrollSpy from './src/scrollspy.js'
|
|
17
|
+
import Tab from './src/tab.js'
|
|
18
|
+
import Toast from './src/toast.js'
|
|
19
|
+
import Tooltip from './src/tooltip.js'
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
Alert,
|
|
23
|
+
Button,
|
|
24
|
+
Carousel,
|
|
25
|
+
Collapse,
|
|
26
|
+
Dropdown,
|
|
27
|
+
Modal,
|
|
28
|
+
Offcanvas,
|
|
29
|
+
Popover,
|
|
30
|
+
ScrollSpy,
|
|
31
|
+
Tab,
|
|
32
|
+
Toast,
|
|
33
|
+
Tooltip
|
|
34
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap alert.js
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
* --------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import BaseComponent from './base-component.js'
|
|
9
|
+
import EventHandler from './dom/event-handler.js'
|
|
10
|
+
import { enableDismissTrigger } from './util/component-functions.js'
|
|
11
|
+
import { defineJQueryPlugin } from './util/index.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Constants
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const NAME = 'alert'
|
|
18
|
+
const DATA_KEY = 'bs.alert'
|
|
19
|
+
const EVENT_KEY = `.${DATA_KEY}`
|
|
20
|
+
|
|
21
|
+
const EVENT_CLOSE = `close${EVENT_KEY}`
|
|
22
|
+
const EVENT_CLOSED = `closed${EVENT_KEY}`
|
|
23
|
+
const CLASS_NAME_FADE = 'fade'
|
|
24
|
+
const CLASS_NAME_SHOW = 'show'
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Class definition
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
class Alert extends BaseComponent {
|
|
31
|
+
// Getters
|
|
32
|
+
static get NAME() {
|
|
33
|
+
return NAME
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Public
|
|
37
|
+
close() {
|
|
38
|
+
const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE)
|
|
39
|
+
|
|
40
|
+
if (closeEvent.defaultPrevented) {
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
this._element.classList.remove(CLASS_NAME_SHOW)
|
|
45
|
+
|
|
46
|
+
const isAnimated = this._element.classList.contains(CLASS_NAME_FADE)
|
|
47
|
+
this._queueCallback(() => this._destroyElement(), this._element, isAnimated)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Private
|
|
51
|
+
_destroyElement() {
|
|
52
|
+
this._element.remove()
|
|
53
|
+
EventHandler.trigger(this._element, EVENT_CLOSED)
|
|
54
|
+
this.dispose()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Static
|
|
58
|
+
static jQueryInterface(config) {
|
|
59
|
+
return this.each(function () {
|
|
60
|
+
const data = Alert.getOrCreateInstance(this)
|
|
61
|
+
|
|
62
|
+
if (typeof config !== 'string') {
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
|
|
67
|
+
throw new TypeError(`No method named "${config}"`)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
data[config](this)
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Data API implementation
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
enableDismissTrigger(Alert, 'close')
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* jQuery
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
defineJQueryPlugin(Alert)
|
|
86
|
+
|
|
87
|
+
export default Alert
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap base-component.js
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
* --------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import Data from './dom/data.js'
|
|
9
|
+
import EventHandler from './dom/event-handler.js'
|
|
10
|
+
import Config from './util/config.js'
|
|
11
|
+
import { executeAfterTransition, getElement } from './util/index.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Constants
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const VERSION = '5.3.8'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Class definition
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
class BaseComponent extends Config {
|
|
24
|
+
constructor(element, config) {
|
|
25
|
+
super()
|
|
26
|
+
|
|
27
|
+
element = getElement(element)
|
|
28
|
+
if (!element) {
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
this._element = element
|
|
33
|
+
this._config = this._getConfig(config)
|
|
34
|
+
|
|
35
|
+
Data.set(this._element, this.constructor.DATA_KEY, this)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Public
|
|
39
|
+
dispose() {
|
|
40
|
+
Data.remove(this._element, this.constructor.DATA_KEY)
|
|
41
|
+
EventHandler.off(this._element, this.constructor.EVENT_KEY)
|
|
42
|
+
|
|
43
|
+
for (const propertyName of Object.getOwnPropertyNames(this)) {
|
|
44
|
+
this[propertyName] = null
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Private
|
|
49
|
+
_queueCallback(callback, element, isAnimated = true) {
|
|
50
|
+
executeAfterTransition(callback, element, isAnimated)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
_getConfig(config) {
|
|
54
|
+
config = this._mergeConfigObj(config, this._element)
|
|
55
|
+
config = this._configAfterMerge(config)
|
|
56
|
+
this._typeCheckConfig(config)
|
|
57
|
+
return config
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Static
|
|
61
|
+
static getInstance(element) {
|
|
62
|
+
return Data.get(getElement(element), this.DATA_KEY)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static getOrCreateInstance(element, config = {}) {
|
|
66
|
+
return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static get VERSION() {
|
|
70
|
+
return VERSION
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static get DATA_KEY() {
|
|
74
|
+
return `bs.${this.NAME}`
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static get EVENT_KEY() {
|
|
78
|
+
return `.${this.DATA_KEY}`
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static eventName(name) {
|
|
82
|
+
return `${name}${this.EVENT_KEY}`
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default BaseComponent
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap button.js
|
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
|
+
* --------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import BaseComponent from './base-component.js'
|
|
9
|
+
import EventHandler from './dom/event-handler.js'
|
|
10
|
+
import { defineJQueryPlugin } from './util/index.js'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Constants
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const NAME = 'button'
|
|
17
|
+
const DATA_KEY = 'bs.button'
|
|
18
|
+
const EVENT_KEY = `.${DATA_KEY}`
|
|
19
|
+
const DATA_API_KEY = '.data-api'
|
|
20
|
+
|
|
21
|
+
const CLASS_NAME_ACTIVE = 'active'
|
|
22
|
+
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="button"]'
|
|
23
|
+
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Class definition
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
class Button extends BaseComponent {
|
|
30
|
+
// Getters
|
|
31
|
+
static get NAME() {
|
|
32
|
+
return NAME
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Public
|
|
36
|
+
toggle() {
|
|
37
|
+
// Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
|
|
38
|
+
this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Static
|
|
42
|
+
static jQueryInterface(config) {
|
|
43
|
+
return this.each(function () {
|
|
44
|
+
const data = Button.getOrCreateInstance(this)
|
|
45
|
+
|
|
46
|
+
if (config === 'toggle') {
|
|
47
|
+
data[config]()
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Data API implementation
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, event => {
|
|
58
|
+
event.preventDefault()
|
|
59
|
+
|
|
60
|
+
const button = event.target.closest(SELECTOR_DATA_TOGGLE)
|
|
61
|
+
const data = Button.getOrCreateInstance(button)
|
|
62
|
+
|
|
63
|
+
data.toggle()
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* jQuery
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
defineJQueryPlugin(Button)
|
|
71
|
+
|
|
72
|
+
export default Button
|