bootstrap-italia 2.12.1 → 2.13.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.
- package/README.EN.md +1 -1
- package/README.md +1 -1
- package/dist/bootstrap-italia.esm.js +1 -1
- package/dist/css/bootstrap-italia.min.css +9 -1
- package/dist/css/bootstrap-italia.min.css.map +1 -1
- package/dist/js/bootstrap-italia.bundle.min.js +19 -23
- package/dist/js/bootstrap-italia.min.js +18 -2
- package/dist/plugins/accept-overlay.js +19 -9
- package/dist/plugins/accept-overlay.js.map +1 -1
- package/dist/plugins/accordion.js +19 -24
- package/dist/plugins/accordion.js.map +1 -1
- package/dist/plugins/alert.js +67 -2
- package/dist/plugins/alert.js.map +1 -1
- package/dist/plugins/{backToTop.js → back-to-top.js} +14 -5
- package/dist/plugins/back-to-top.js.map +1 -0
- package/dist/plugins/base-component.js +91 -0
- package/dist/plugins/base-component.js.map +1 -0
- package/dist/plugins/button.js +58 -2
- package/dist/plugins/button.js.map +1 -1
- package/dist/plugins/carousel-bi.js +19 -9
- package/dist/plugins/carousel-bi.js.map +1 -1
- package/dist/plugins/carousel.js +445 -2
- package/dist/plugins/carousel.js.map +1 -1
- package/dist/plugins/collapse.js +273 -2
- package/dist/plugins/collapse.js.map +1 -1
- package/dist/plugins/cookiebar.js +39 -52
- package/dist/plugins/cookiebar.js.map +1 -1
- package/dist/plugins/dimmer.js +19 -8
- package/dist/plugins/dimmer.js.map +1 -1
- package/dist/plugins/dom/data.js +61 -0
- package/dist/plugins/dom/data.js.map +1 -0
- package/dist/plugins/dom/event-handler.js +296 -0
- package/dist/plugins/dom/event-handler.js.map +1 -0
- package/dist/plugins/dom/manipulator.js +76 -0
- package/dist/plugins/dom/manipulator.js.map +1 -0
- package/dist/plugins/dom/selector-engine.js +82 -0
- package/dist/plugins/dom/selector-engine.js.map +1 -0
- package/dist/plugins/dropdown.js +433 -2
- package/dist/plugins/dropdown.js.map +1 -1
- package/dist/plugins/fonts-loader.js +9 -1
- package/dist/plugins/fonts-loader.js.map +1 -1
- package/dist/plugins/form-validate.js +22 -8
- package/dist/plugins/form-validate.js.map +1 -1
- package/dist/plugins/forward.js +21 -18
- package/dist/plugins/forward.js.map +1 -1
- package/dist/plugins/header-sticky.js +11 -2
- package/dist/plugins/header-sticky.js.map +1 -1
- package/dist/plugins/history-back.js +17 -17
- package/dist/plugins/history-back.js.map +1 -1
- package/dist/plugins/init.js +9 -0
- package/dist/plugins/init.js.map +1 -1
- package/dist/plugins/input-label.js +14 -3
- package/dist/plugins/input-label.js.map +1 -1
- package/dist/plugins/input-number.js +13 -4
- package/dist/plugins/input-number.js.map +1 -1
- package/dist/plugins/input-password.js +48 -37
- package/dist/plugins/input-password.js.map +1 -1
- package/dist/plugins/input-search-autocomplete.js +9 -11
- package/dist/plugins/input-search-autocomplete.js.map +1 -1
- package/dist/plugins/input.js +12 -3
- package/dist/plugins/input.js.map +1 -1
- package/dist/plugins/list.js +23 -12
- package/dist/plugins/list.js.map +1 -1
- package/dist/plugins/masonry.js +29 -29
- package/dist/plugins/masonry.js.map +1 -1
- package/dist/plugins/modal.js +358 -2
- package/dist/plugins/modal.js.map +1 -1
- package/dist/plugins/navbar-collapsible.js +55 -45
- package/dist/plugins/navbar-collapsible.js.map +1 -1
- package/dist/plugins/navscroll.js +16 -23
- package/dist/plugins/navscroll.js.map +1 -1
- package/dist/plugins/notification.js +34 -23
- package/dist/plugins/notification.js.map +1 -1
- package/dist/plugins/offcanvas.js +259 -2
- package/dist/plugins/offcanvas.js.map +1 -1
- package/dist/plugins/popover.js +76 -2
- package/dist/plugins/popover.js.map +1 -1
- package/dist/plugins/progress-donut.js +19 -12
- package/dist/plugins/progress-donut.js.map +1 -1
- package/dist/plugins/scrollspy.js +273 -2
- package/dist/plugins/scrollspy.js.map +1 -1
- package/dist/plugins/select-autocomplete.js +10 -1
- package/dist/plugins/select-autocomplete.js.map +1 -1
- package/dist/plugins/sticky.js +21 -18
- package/dist/plugins/sticky.js.map +1 -1
- package/dist/plugins/tab.js +244 -27
- package/dist/plugins/tab.js.map +1 -1
- package/dist/plugins/toast.js +203 -2
- package/dist/plugins/toast.js.map +1 -1
- package/dist/plugins/tooltip.js +602 -2
- package/dist/plugins/tooltip.js.map +1 -1
- package/dist/plugins/track-focus.js +8 -0
- package/dist/plugins/track-focus.js.map +1 -1
- package/dist/plugins/transfer.js +11 -16
- package/dist/plugins/transfer.js.map +1 -1
- package/dist/plugins/upload-dragdrop.js +13 -4
- package/dist/plugins/upload-dragdrop.js.map +1 -1
- package/dist/plugins/util/backdrop.js +155 -0
- package/dist/plugins/util/backdrop.js.map +1 -0
- package/dist/plugins/util/component-functions.js +38 -0
- package/dist/plugins/util/component-functions.js.map +1 -0
- package/dist/plugins/util/config.js +70 -0
- package/dist/plugins/util/config.js.map +1 -0
- package/dist/plugins/util/cookies.js +8 -0
- package/dist/plugins/util/cookies.js.map +1 -1
- package/dist/plugins/util/device.js +0 -3
- package/dist/plugins/util/device.js.map +1 -1
- package/dist/plugins/util/dom.js +8 -0
- package/dist/plugins/util/dom.js.map +1 -1
- package/dist/plugins/util/focustrap.js +121 -0
- package/dist/plugins/util/focustrap.js.map +1 -0
- package/dist/plugins/util/index.js +280 -0
- package/dist/plugins/util/index.js.map +1 -0
- package/dist/plugins/util/observer.js +8 -0
- package/dist/plugins/util/observer.js.map +1 -1
- package/dist/plugins/util/on-document-scroll.js +20 -9
- package/dist/plugins/util/on-document-scroll.js.map +1 -1
- package/dist/plugins/util/pageScroll.js +8 -0
- package/dist/plugins/util/pageScroll.js.map +1 -1
- package/dist/plugins/util/sanitizer.js +115 -0
- package/dist/plugins/util/sanitizer.js.map +1 -0
- package/dist/plugins/util/scrollbar.js +120 -0
- package/dist/plugins/util/scrollbar.js.map +1 -0
- package/dist/plugins/util/swipe.js +150 -0
- package/dist/plugins/util/swipe.js.map +1 -0
- package/dist/plugins/util/template-factory.js +166 -0
- package/dist/plugins/util/template-factory.js.map +1 -0
- package/dist/plugins/util/tween.js +10 -1
- package/dist/plugins/util/tween.js.map +1 -1
- package/dist/plugins/util/youtube-video.js +12 -21
- package/dist/plugins/util/youtube-video.js.map +1 -1
- package/dist/plugins/videoplayer.js +19 -8
- package/dist/plugins/videoplayer.js.map +1 -1
- package/dist/version.js +10 -3
- package/dist/version.js.map +1 -1
- package/package.json +6 -7
- package/src/js/bootstrap-italia.entry.js +8 -0
- package/src/js/bootstrap-italia.esm.js +9 -1
- package/src/js/icons.js +8 -0
- package/src/js/load-plugin.js +8 -0
- package/src/js/plugins/accept-overlay.js +18 -10
- package/src/js/plugins/accordion.js +16 -22
- package/src/js/plugins/alert.js +66 -2
- package/src/js/plugins/{backToTop.js → back-to-top.js} +12 -4
- package/src/js/plugins/base-component.js +89 -0
- package/src/js/plugins/button.js +57 -2
- package/src/js/plugins/carousel-bi.js +18 -9
- package/src/js/plugins/carousel.js +444 -2
- package/src/js/plugins/collapse.js +272 -2
- package/src/js/plugins/cookiebar.js +37 -60
- package/src/js/plugins/dimmer.js +18 -8
- package/src/js/plugins/dom/data.js +58 -0
- package/src/js/plugins/dom/event-handler.js +301 -0
- package/src/js/plugins/dom/manipulator.js +75 -0
- package/src/js/plugins/dom/selector-engine.js +80 -0
- package/src/js/plugins/dropdown.js +432 -2
- package/src/js/plugins/fonts-loader.js +9 -1
- package/src/js/plugins/form-validate.js +21 -8
- package/src/js/plugins/form.js +11 -3
- package/src/js/plugins/forward.js +18 -16
- package/src/js/plugins/header-sticky.js +10 -2
- package/src/js/plugins/history-back.js +14 -14
- package/src/js/plugins/init.js +8 -0
- package/src/js/plugins/input-label.js +13 -3
- package/src/js/plugins/input-number.js +12 -4
- package/src/js/plugins/input-password.js +46 -36
- package/src/js/plugins/input-search-autocomplete.js +9 -13
- package/src/js/plugins/input.js +11 -3
- package/src/js/plugins/list.js +22 -12
- package/src/js/plugins/masonry.js +26 -27
- package/src/js/plugins/modal.js +357 -2
- package/src/js/plugins/navbar-collapsible.js +55 -53
- package/src/js/plugins/navscroll.js +16 -23
- package/src/js/plugins/notification.js +33 -23
- package/src/js/plugins/offcanvas.js +258 -2
- package/src/js/plugins/popover.js +75 -2
- package/src/js/plugins/progress-donut.js +17 -13
- package/src/js/plugins/scrollspy.js +272 -2
- package/src/js/plugins/select-autocomplete.js +9 -1
- package/src/js/plugins/sticky.js +21 -23
- package/src/js/plugins/tab.js +243 -27
- package/src/js/plugins/toast.js +206 -2
- package/src/js/plugins/tooltip.js +601 -2
- package/src/js/plugins/track-focus.js +8 -0
- package/src/js/plugins/transfer.js +12 -24
- package/src/js/plugins/upload-dragdrop.js +12 -4
- package/src/js/plugins/util/backdrop.js +153 -0
- package/src/js/plugins/util/component-functions.js +36 -0
- package/src/js/plugins/util/config.js +68 -0
- package/src/js/plugins/util/cookies.js +8 -0
- package/src/js/plugins/util/device.js +0 -3
- package/src/js/plugins/util/dom.js +8 -0
- package/src/js/plugins/util/focustrap.js +119 -0
- package/src/js/plugins/util/index.js +317 -0
- package/src/js/plugins/util/observer.js +8 -0
- package/src/js/plugins/util/on-document-scroll.js +19 -9
- package/src/js/plugins/util/pageScroll.js +8 -0
- package/src/js/plugins/util/sanitizer.js +112 -0
- package/src/js/plugins/util/scrollbar.js +118 -0
- package/src/js/plugins/util/swipe.js +148 -0
- package/src/js/plugins/util/template-factory.js +164 -0
- package/src/js/plugins/util/tween.js +9 -1
- package/src/js/plugins/util/youtube-video.js +12 -21
- package/src/js/plugins/videoplayer.js +18 -8
- package/src/js/version.js +10 -3
- package/src/scss/base/_containers.scss +41 -0
- package/src/scss/base/_functions.scss +373 -0
- package/src/scss/base/_helpers.scss +10 -0
- package/src/scss/base/_maps.scss +54 -0
- package/src/scss/base/_mixins.scss +44 -0
- package/src/scss/base/_reboot.scss +590 -0
- package/src/scss/base/_root.scss +73 -0
- package/src/scss/base/_transitions.scss +27 -0
- package/src/scss/base/_utilities.scss +742 -0
- package/src/scss/base/_variables.scss +2123 -0
- package/src/scss/base/_version.scss +3 -0
- package/src/scss/base/helpers/_clearfix.scss +3 -0
- package/src/scss/base/helpers/_color-bg.scss +10 -0
- package/src/scss/base/helpers/_colored-links.scss +16 -0
- package/src/scss/base/helpers/_position.scss +36 -0
- package/src/scss/base/helpers/_ratio.scss +26 -0
- package/src/scss/base/helpers/_stacks.scss +15 -0
- package/src/scss/base/helpers/_stretched-link.scss +15 -0
- package/src/scss/base/helpers/_text-truncation.scss +7 -0
- package/src/scss/base/helpers/_visually-hidden.scss +8 -0
- package/src/scss/base/helpers/_vr.scss +8 -0
- package/src/scss/base/mixins/_alert.scss +15 -0
- package/src/scss/base/mixins/_backdrop.scss +18 -0
- package/src/scss/base/mixins/_banner.scss +11 -0
- package/src/scss/base/mixins/_border-radius.scss +77 -0
- package/src/scss/base/mixins/_box-shadow.scss +18 -0
- package/src/scss/base/mixins/_breakpoints.scss +127 -0
- package/src/scss/base/mixins/_buttons.scss +141 -0
- package/src/scss/base/mixins/_caret.scss +64 -0
- package/src/scss/base/mixins/_clearfix.scss +9 -0
- package/src/scss/base/mixins/_color-scheme.scss +7 -0
- package/src/scss/base/mixins/_container.scss +11 -0
- package/src/scss/base/mixins/_deprecate.scss +10 -0
- package/src/scss/base/mixins/_forms.scss +152 -0
- package/src/scss/base/mixins/_gradients.scss +47 -0
- package/src/scss/base/mixins/_grid.scss +151 -0
- package/src/scss/base/mixins/_image.scss +15 -0
- package/src/scss/base/mixins/_list-group.scss +24 -0
- package/src/scss/base/mixins/_lists.scss +7 -0
- package/src/scss/base/mixins/_pagination.scss +10 -0
- package/src/scss/base/mixins/_reset-text.scss +17 -0
- package/src/scss/base/mixins/_resize.scss +6 -0
- package/src/scss/base/mixins/_table-variants.scss +24 -0
- package/src/scss/base/mixins/_text-truncate.scss +8 -0
- package/src/scss/base/mixins/_transition.scss +26 -0
- package/src/scss/base/mixins/_utilities.scss +96 -0
- package/src/scss/base/mixins/_visually-hidden.scss +29 -0
- package/src/scss/base/utilities/_api.scss +45 -0
- package/src/scss/base/vendor/_rfs.scss +337 -0
- package/src/scss/bootstrap-italia.scss +137 -156
- package/src/scss/components/_accordion.scss +297 -0
- package/src/scss/components/_badge.scss +60 -0
- package/src/scss/components/_breadcrumb.scss +95 -0
- package/src/scss/components/_button-group.scss +143 -0
- package/src/scss/components/_buttons.scss +467 -0
- package/src/scss/{custom → components}/_card.scss +228 -0
- package/src/scss/{custom → components}/_carousel.scss +225 -3
- package/src/scss/components/_dropdown.scss +480 -0
- package/src/scss/{custom → components}/_grid.scss +33 -0
- package/src/scss/{custom → components}/_gridlist.scss +7 -0
- package/src/scss/{custom → components}/_hero.scss +23 -57
- package/src/scss/components/_images.scss +48 -0
- package/src/scss/{custom → components}/_linklist.scss +0 -1
- package/src/scss/components/_list-group.scss +190 -0
- package/src/scss/components/_modal.scss +475 -0
- package/src/scss/components/_nav.scss +169 -0
- package/src/scss/components/_navbar.scss +273 -0
- package/src/scss/components/_offcanvas.scss +144 -0
- package/src/scss/components/_pagination.scss +108 -0
- package/src/scss/components/_placeholders.scss +51 -0
- package/src/scss/components/_popover.scss +298 -0
- package/src/scss/components/_progress-bars.scss +126 -0
- package/src/scss/{custom → components}/_steppers.scss +2 -2
- package/src/scss/{custom → components}/_tab.scss +3 -7
- package/src/scss/components/_tables.scss +171 -0
- package/src/scss/components/_toasts.scss +73 -0
- package/src/scss/{custom → components}/_toolbar.scss +19 -12
- package/src/scss/components/_tooltip.scss +139 -0
- package/src/scss/{custom → components}/_type.scss +92 -0
- package/src/scss/forms/_accessible-autocomplete.scss +188 -0
- package/src/scss/forms/_floating-labels.scss +75 -0
- package/src/scss/forms/_form-check.scss +175 -0
- package/src/scss/forms/_form-control.scss +201 -0
- package/src/scss/forms/_form-range.scss +95 -0
- package/src/scss/{custom → forms}/_form-select.scss +72 -0
- package/src/scss/forms/_form-text.scss +11 -0
- package/src/scss/{custom → forms}/_forms.scss +8 -12
- package/src/scss/forms/_input-group.scss +129 -0
- package/src/scss/forms/_labels.scss +36 -0
- package/src/scss/forms/_validation.scss +12 -0
- package/src/scss/utilities/icons.scss +5 -5
- package/types/index.d.ts +4 -1
- package/types/plugins/video.ts +33 -0
- package/dist/plugins/backToTop.js.map +0 -1
- package/src/scss/_functions.scss +0 -38
- package/src/scss/_variables.scss +0 -639
- package/src/scss/custom/_accessible-autocomplete.scss +0 -30
- package/src/scss/custom/_accordion.scss +0 -176
- package/src/scss/custom/_badge.scss +0 -29
- package/src/scss/custom/_breadcrumb.scss +0 -51
- package/src/scss/custom/_buttons.scss +0 -235
- package/src/scss/custom/_componente-base.scss +0 -6
- package/src/scss/custom/_dropdown.scss +0 -248
- package/src/scss/custom/_form-datepicker.scss +0 -604
- package/src/scss/custom/_images.scss +0 -10
- package/src/scss/custom/_modal.scss +0 -248
- package/src/scss/custom/_popover.scss +0 -106
- package/src/scss/custom/_progress-bars.scss +0 -70
- package/src/scss/custom/_tables.scss +0 -11
- package/src/scss/custom/_timepicker.scss +0 -252
- package/src/scss/custom/_tooltip.scss +0 -33
- package/src/scss/custom/_version.scss +0 -3
- package/src/scss/custom/mixins/_buttons.scss +0 -67
- package/src/scss/utilities/colors_vars.scss +0 -426
- /package/src/scss/{custom → base}/mixins/_text-emphasis.scss +0 -0
- /package/src/scss/{custom → components}/_accept-overlay.scss +0 -0
- /package/src/scss/{custom → components}/_affix.scss +0 -0
- /package/src/scss/{custom → components}/_alert.scss +0 -0
- /package/src/scss/{custom → components}/_anchor.scss +0 -0
- /package/src/scss/{custom → components}/_avatar.scss +0 -0
- /package/src/scss/{custom → components}/_back-to-top.scss +0 -0
- /package/src/scss/{custom → components}/_bottomnav.scss +0 -0
- /package/src/scss/{custom → components}/_calendar.scss +0 -0
- /package/src/scss/{custom → components}/_callout.scss +0 -0
- /package/src/scss/{custom → components}/_chips.scss +0 -0
- /package/src/scss/{custom → components}/_code.scss +0 -0
- /package/src/scss/{custom → components}/_cookiebar.scss +0 -0
- /package/src/scss/{custom → components}/_dimmer.scss +0 -0
- /package/src/scss/{custom → components}/_figcaption.scss +0 -0
- /package/src/scss/{custom → components}/_font.scss +0 -0
- /package/src/scss/{custom → components}/_footer.scss +0 -0
- /package/src/scss/{custom → components}/_forward.scss +0 -0
- /package/src/scss/{custom → components}/_header.scss +0 -0
- /package/src/scss/{custom → components}/_headercenter.scss +0 -0
- /package/src/scss/{custom → components}/_headercentertheme.scss +0 -0
- /package/src/scss/{custom → components}/_headernavbar.scss +0 -0
- /package/src/scss/{custom → components}/_headernavbartheme.scss +0 -0
- /package/src/scss/{custom → components}/_headerslim.scss +0 -0
- /package/src/scss/{custom → components}/_headerslimtheme.scss +0 -0
- /package/src/scss/{custom → components}/_imgresponsive.scss +0 -0
- /package/src/scss/{custom → components}/_list.scss +0 -0
- /package/src/scss/{custom → components}/_map.scss +0 -0
- /package/src/scss/{custom → components}/_masonry-loader.scss +0 -0
- /package/src/scss/{custom → components}/_megamenu.scss +0 -0
- /package/src/scss/{custom → components}/_navigation.scss +0 -0
- /package/src/scss/{custom → components}/_navigationtheme.scss +0 -0
- /package/src/scss/{custom → components}/_navscroll.scss +0 -0
- /package/src/scss/{custom → components}/_navscrolltheme.scss +0 -0
- /package/src/scss/{custom → components}/_notifications.scss +0 -0
- /package/src/scss/{custom → components}/_overlay-panel.scss +0 -0
- /package/src/scss/{custom → components}/_page-scroll.scss +0 -0
- /package/src/scss/{custom → components}/_pager.scss +0 -0
- /package/src/scss/{custom → components}/_point-list.scss +0 -0
- /package/src/scss/{custom → components}/_print.scss +0 -0
- /package/src/scss/{custom → components}/_progress-donuts.scss +0 -0
- /package/src/scss/{custom → components}/_progress-spinners.scss +0 -0
- /package/src/scss/{custom → components}/_rating-list.scss +0 -0
- /package/src/scss/{custom → components}/_rating.scss +0 -0
- /package/src/scss/{custom → components}/_sections.scss +0 -0
- /package/src/scss/{custom → components}/_sidebar.scss +0 -0
- /package/src/scss/{custom → components}/_sidebarthemes.scss +0 -0
- /package/src/scss/{custom → components}/_skiplinks.scss +0 -0
- /package/src/scss/{custom → components}/_sticky.scss +0 -0
- /package/src/scss/{custom → components}/_thumbnav.scss +0 -0
- /package/src/scss/{custom → components}/_timeline.scss +0 -0
- /package/src/scss/{custom → components}/_videoplayer.scss +0 -0
- /package/src/scss/{custom → forms}/_autocomplete.scss +0 -0
- /package/src/scss/{custom → forms}/_form-input-file.scss +0 -0
- /package/src/scss/{custom → forms}/_form-input-number.scss +0 -0
- /package/src/scss/{custom → forms}/_form-input-upload.scss +0 -0
- /package/src/scss/{custom → forms}/_form-password.scss +0 -0
- /package/src/scss/{custom → forms}/_form-toggles.scss +0 -0
- /package/src/scss/{custom → forms}/_form-transfer.scss +0 -0
- /package/src/scss/{custom → forms}/_just-validate.scss +0 -0
- /package/types/plugins/{backToTop.d.ts → back-to-top.d.ts} +0 -0
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
|
|
4
|
+
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
|
|
5
|
+
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
|
|
6
|
+
* --------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import BaseComponent from './base-component'
|
|
10
|
+
import EventHandler from './dom/event-handler'
|
|
11
|
+
import SelectorEngine from './dom/selector-engine'
|
|
4
12
|
|
|
5
13
|
import InputLabel from './input-label'
|
|
6
14
|
|
|
@@ -127,7 +135,7 @@ const createInput = (element) => {
|
|
|
127
135
|
return null
|
|
128
136
|
}
|
|
129
137
|
|
|
130
|
-
if (typeof document !== 'undefined') {
|
|
138
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
131
139
|
document.addEventListener('DOMContentLoaded', function () {
|
|
132
140
|
var frmel = document.querySelectorAll(SELECTOR_INPUT + ', label')
|
|
133
141
|
frmel.forEach(function (item) {
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
|
|
4
|
+
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
|
|
5
|
+
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
|
|
6
|
+
* --------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import BaseComponent from './base-component'
|
|
10
|
+
import EventHandler from './dom/event-handler'
|
|
11
|
+
import SelectorEngine from './dom/selector-engine'
|
|
12
|
+
import Manipulator from './dom/manipulator'
|
|
5
13
|
|
|
6
14
|
import InputLabel from './input-label'
|
|
7
15
|
|
|
@@ -439,42 +447,44 @@ class InputPassword extends BaseComponent {
|
|
|
439
447
|
* ------------------------------------------------------------------------
|
|
440
448
|
*/
|
|
441
449
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
450
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
451
|
+
const createInput = (element) => {
|
|
452
|
+
if (element && element.matches(SELECTOR_PASSWORD)) {
|
|
453
|
+
return InputPassword.getOrCreateInstance(element)
|
|
454
|
+
}
|
|
455
|
+
return null
|
|
445
456
|
}
|
|
446
|
-
return null
|
|
447
|
-
}
|
|
448
457
|
|
|
449
|
-
const initInputPassword = () => {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
458
|
+
const initInputPassword = () => {
|
|
459
|
+
const element = SelectorEngine.findOne(SELECTOR_PASSWORD)
|
|
460
|
+
if (element) {
|
|
461
|
+
InputPassword.getOrCreateInstance(element)
|
|
462
|
+
}
|
|
453
463
|
}
|
|
454
|
-
}
|
|
455
464
|
|
|
456
|
-
if (document.readyState !== 'loading') {
|
|
457
|
-
|
|
458
|
-
} else {
|
|
459
|
-
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
EventHandler.on(document, EVENT_MOUSEDOWN_DATA_API, SELECTOR_PASSWORD + ', label', function () {
|
|
463
|
-
const target = InputLabel.getInputFromLabel(this) || this
|
|
464
|
-
createInput(target)
|
|
465
|
-
})
|
|
466
|
-
EventHandler.on(document, EVENT_KEYUP_DATA_API, SELECTOR_PASSWORD + ', label', function () {
|
|
467
|
-
const target = InputLabel.getInputFromLabel(this) || this
|
|
468
|
-
const element = createInput(target)
|
|
469
|
-
if (element && element._label) {
|
|
470
|
-
element._label._labelOut()
|
|
465
|
+
if (document.readyState !== 'loading') {
|
|
466
|
+
initInputPassword()
|
|
467
|
+
} else {
|
|
468
|
+
document.addEventListener('DOMContentLoaded', initInputPassword)
|
|
471
469
|
}
|
|
472
|
-
|
|
473
|
-
EventHandler.on(document,
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
470
|
+
|
|
471
|
+
EventHandler.on(document, EVENT_MOUSEDOWN_DATA_API, SELECTOR_PASSWORD + ', label', function () {
|
|
472
|
+
const target = InputLabel.getInputFromLabel(this) || this
|
|
473
|
+
createInput(target)
|
|
474
|
+
})
|
|
475
|
+
EventHandler.on(document, EVENT_KEYUP_DATA_API, SELECTOR_PASSWORD + ', label', function () {
|
|
476
|
+
const target = InputLabel.getInputFromLabel(this) || this
|
|
477
|
+
const element = createInput(target)
|
|
478
|
+
if (element && element._label) {
|
|
479
|
+
element._label._labelOut()
|
|
480
|
+
}
|
|
481
|
+
})
|
|
482
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_BTN_SHOW_PWD, function () {
|
|
483
|
+
const target = this.parentNode && this.parentNode.querySelector(SELECTOR_PASSWORD)
|
|
484
|
+
if (target) {
|
|
485
|
+
InputPassword.getOrCreateInstance(target)
|
|
486
|
+
}
|
|
487
|
+
})
|
|
488
|
+
}
|
|
479
489
|
|
|
480
490
|
export default InputPassword
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
|
|
4
|
+
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
|
|
5
|
+
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
|
|
6
|
+
* --------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
6
8
|
|
|
9
|
+
import BaseComponent from './base-component'
|
|
10
|
+
import EventHandler from './dom/event-handler'
|
|
7
11
|
import InputLabel from './input-label'
|
|
8
12
|
|
|
9
13
|
const NAME = 'inputsearchautocomplete'
|
|
@@ -125,14 +129,6 @@ class InputSearch extends BaseComponent {
|
|
|
125
129
|
* ------------------------------------------------------------------------
|
|
126
130
|
*/
|
|
127
131
|
|
|
128
|
-
/*const inputs = SelectorEngine.find(SELECTOR_SEARCH)
|
|
129
|
-
inputs.forEach((input) => {
|
|
130
|
-
EventHandler.one(input, EVENT_KEYUP_DATA_API, () => {
|
|
131
|
-
const searchInput = InputSearch.getOrCreateInstance(input)
|
|
132
|
-
searchInput.search()
|
|
133
|
-
})
|
|
134
|
-
})*/
|
|
135
|
-
|
|
136
132
|
const createInput = (element) => {
|
|
137
133
|
if (element && element.matches(SELECTOR_SEARCH)) {
|
|
138
134
|
return InputSearch.getOrCreateInstance(element)
|
package/src/js/plugins/input.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
|
|
4
|
+
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
|
|
5
|
+
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
|
|
6
|
+
* --------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import BaseComponent from './base-component.js'
|
|
2
10
|
|
|
3
|
-
import EventHandler from '
|
|
4
|
-
import SelectorEngine from '
|
|
11
|
+
import EventHandler from './dom/event-handler'
|
|
12
|
+
import SelectorEngine from './dom/selector-engine'
|
|
5
13
|
|
|
6
14
|
import InputLabel from './input-label'
|
|
7
15
|
|
package/src/js/plugins/list.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
|
|
4
|
+
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
|
|
5
|
+
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
|
|
6
|
+
* --------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
2
8
|
|
|
3
|
-
import
|
|
4
|
-
|
|
9
|
+
import BaseComponent from './base-component.js'
|
|
10
|
+
|
|
11
|
+
import SelectorEngine from './dom/selector-engine'
|
|
12
|
+
import EventHandler from './dom/event-handler'
|
|
5
13
|
|
|
6
14
|
const NAME = 'list'
|
|
7
15
|
const DATA_KEY = 'bs.list'
|
|
@@ -63,16 +71,18 @@ class List extends BaseComponent {
|
|
|
63
71
|
* ------------------------------------------------------------------------
|
|
64
72
|
*/
|
|
65
73
|
|
|
66
|
-
|
|
67
|
-
SelectorEngine.find(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
75
|
+
SelectorEngine.find(SELECTOR_LIST).forEach((list) => {
|
|
76
|
+
SelectorEngine.find(SELECTOR_ITEM_CHECKBOX, list).forEach((checkbox) => {
|
|
77
|
+
EventHandler.one(checkbox.closest('a'), EVENT_CLICK_DATA_API, (evt) => {
|
|
78
|
+
if (!List.getInstance(list)) {
|
|
79
|
+
evt.preventDefault()
|
|
80
|
+
const listObj = List.getOrCreateInstance(list)
|
|
81
|
+
listObj.toggleCheckbox(evt.currentTarget)
|
|
82
|
+
}
|
|
83
|
+
})
|
|
74
84
|
})
|
|
75
85
|
})
|
|
76
|
-
}
|
|
86
|
+
}
|
|
77
87
|
|
|
78
88
|
export default List
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
|
|
4
|
+
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
|
|
5
|
+
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
|
|
6
|
+
* --------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import BaseComponent from './base-component.js'
|
|
2
10
|
|
|
3
|
-
import SelectorEngine from '
|
|
4
|
-
import Manipulator from '
|
|
11
|
+
import SelectorEngine from './dom/selector-engine'
|
|
12
|
+
import Manipulator from './dom/manipulator'
|
|
5
13
|
|
|
6
|
-
import
|
|
14
|
+
import MiniMasonry from 'minimasonry/src/minimasonry'
|
|
7
15
|
|
|
8
16
|
const NAME = 'masonry'
|
|
9
|
-
//const DATA_KEY = 'bs.masonry'
|
|
10
|
-
//const EVENT_KEY = `.${DATA_KEY}`
|
|
11
|
-
//const DATA_API_KEY = '.data-api'
|
|
12
17
|
|
|
13
18
|
const CLASS_NAME_SHOW = 'show'
|
|
14
19
|
const CLASS_NAME_LOADER = 'masonry-loader'
|
|
@@ -24,13 +29,13 @@ class Masonry extends BaseComponent {
|
|
|
24
29
|
constructor(element, config) {
|
|
25
30
|
super(element)
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
33
|
+
this._config = this._getConfig(config)
|
|
34
|
+
this._masonry = null
|
|
35
|
+
this._images = SelectorEngine.find('img', this._element)
|
|
36
|
+
this._loadCounter = 0
|
|
37
|
+
this._init()
|
|
38
|
+
}
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
// Getters
|
|
@@ -61,8 +66,6 @@ class Masonry extends BaseComponent {
|
|
|
61
66
|
|
|
62
67
|
_init() {
|
|
63
68
|
if (this._images.length > 0) {
|
|
64
|
-
//this._showLoader()
|
|
65
|
-
|
|
66
69
|
this._images.forEach((img) => {
|
|
67
70
|
const imgDummy = new Image()
|
|
68
71
|
imgDummy.onload = () => this._onLoadEnd()
|
|
@@ -76,13 +79,14 @@ class Masonry extends BaseComponent {
|
|
|
76
79
|
_onLoadEnd() {
|
|
77
80
|
this._loadCounter++
|
|
78
81
|
if (this._loadCounter >= this._images.length) {
|
|
79
|
-
//this._hideLoader()
|
|
80
82
|
this._initMasonry()
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
_initMasonry() {
|
|
85
|
-
|
|
87
|
+
const config = this._config
|
|
88
|
+
config.container = this._element
|
|
89
|
+
this._masonry = new MiniMasonry(config) //new MasonryPlugin(this._element, this._config)
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
_createLoader() {
|
|
@@ -123,18 +127,13 @@ class Masonry extends BaseComponent {
|
|
|
123
127
|
* ------------------------------------------------------------------------
|
|
124
128
|
*/
|
|
125
129
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
console.warn('[Masonry] Masonry component needs Masonry library to work properly')
|
|
130
|
-
} else {
|
|
130
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
131
|
+
const masonries = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
|
|
132
|
+
if (masonries.length > 0) {
|
|
131
133
|
masonries.forEach((masonry) => {
|
|
132
134
|
Masonry.getOrCreateInstance(masonry)
|
|
133
135
|
})
|
|
134
|
-
}
|
|
135
|
-
masonries.forEach((masonry) => {
|
|
136
|
-
Masonry.getOrCreateInstance(masonry)
|
|
137
|
-
})
|
|
136
|
+
}
|
|
138
137
|
}
|
|
139
138
|
|
|
140
139
|
export default Masonry
|
package/src/js/plugins/modal.js
CHANGED
|
@@ -1,5 +1,360 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* --------------------------------------------------------------------------
|
|
3
|
+
* Bootstrap Italia (https://italia.github.io/bootstrap-italia/)
|
|
4
|
+
* Authors: https://github.com/italia/bootstrap-italia/blob/main/AUTHORS
|
|
5
|
+
* Licensed under BSD-3-Clause license (https://github.com/italia/bootstrap-italia/blob/main/LICENSE)
|
|
6
|
+
* This a fork of Bootstrap: Initial license and original file name below
|
|
7
|
+
* Bootstrap (v5.2.3): modal.js
|
|
8
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
9
|
+
* --------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
2
11
|
|
|
3
|
-
|
|
12
|
+
import { getElementFromSelector, isRTL, isVisible, reflow } from './util/index'
|
|
13
|
+
import EventHandler from './dom/event-handler'
|
|
14
|
+
import SelectorEngine from './dom/selector-engine'
|
|
15
|
+
import ScrollBarHelper from './util/scrollbar'
|
|
16
|
+
import BaseComponent from './base-component'
|
|
17
|
+
import Backdrop from './util/backdrop'
|
|
18
|
+
import FocusTrap from './util/focustrap'
|
|
19
|
+
import { enableDismissTrigger } from './util/component-functions'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Constants
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const NAME = 'modal'
|
|
26
|
+
const DATA_KEY = 'bs.modal'
|
|
27
|
+
const EVENT_KEY = `.${DATA_KEY}`
|
|
28
|
+
const DATA_API_KEY = '.data-api'
|
|
29
|
+
const ESCAPE_KEY = 'Escape'
|
|
30
|
+
|
|
31
|
+
const EVENT_HIDE = `hide${EVENT_KEY}`
|
|
32
|
+
const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY}`
|
|
33
|
+
const EVENT_HIDDEN = `hidden${EVENT_KEY}`
|
|
34
|
+
const EVENT_SHOW = `show${EVENT_KEY}`
|
|
35
|
+
const EVENT_SHOWN = `shown${EVENT_KEY}`
|
|
36
|
+
const EVENT_RESIZE = `resize${EVENT_KEY}`
|
|
37
|
+
const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`
|
|
38
|
+
const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY}`
|
|
39
|
+
const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`
|
|
40
|
+
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
|
|
41
|
+
|
|
42
|
+
const CLASS_NAME_OPEN = 'modal-open'
|
|
43
|
+
const CLASS_NAME_FADE = 'fade'
|
|
44
|
+
const CLASS_NAME_SHOW = 'show'
|
|
45
|
+
const CLASS_NAME_STATIC = 'modal-static'
|
|
46
|
+
|
|
47
|
+
const OPEN_SELECTOR = '.modal.show'
|
|
48
|
+
const SELECTOR_DIALOG = '.modal-dialog'
|
|
49
|
+
const SELECTOR_MODAL_BODY = '.modal-body'
|
|
50
|
+
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="modal"]'
|
|
51
|
+
|
|
52
|
+
const Default = {
|
|
53
|
+
backdrop: true,
|
|
54
|
+
focus: true,
|
|
55
|
+
keyboard: true,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const DefaultType = {
|
|
59
|
+
backdrop: '(boolean|string)',
|
|
60
|
+
focus: 'boolean',
|
|
61
|
+
keyboard: 'boolean',
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Class definition
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
class Modal extends BaseComponent {
|
|
69
|
+
constructor(element, config) {
|
|
70
|
+
super(element, config)
|
|
71
|
+
|
|
72
|
+
this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element)
|
|
73
|
+
this._backdrop = this._initializeBackDrop()
|
|
74
|
+
this._focustrap = this._initializeFocusTrap()
|
|
75
|
+
this._isShown = false
|
|
76
|
+
this._isTransitioning = false
|
|
77
|
+
this._scrollBar = new ScrollBarHelper()
|
|
78
|
+
|
|
79
|
+
this._addEventListeners()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Getters
|
|
83
|
+
static get Default() {
|
|
84
|
+
return Default
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static get DefaultType() {
|
|
88
|
+
return DefaultType
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static get NAME() {
|
|
92
|
+
return NAME
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Public
|
|
96
|
+
toggle(relatedTarget) {
|
|
97
|
+
return this._isShown ? this.hide() : this.show(relatedTarget)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
show(relatedTarget) {
|
|
101
|
+
if (this._isShown || this._isTransitioning) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, {
|
|
106
|
+
relatedTarget,
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
if (showEvent.defaultPrevented) {
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
this._isShown = true
|
|
114
|
+
this._isTransitioning = true
|
|
115
|
+
|
|
116
|
+
this._scrollBar.hide()
|
|
117
|
+
|
|
118
|
+
document.body.classList.add(CLASS_NAME_OPEN)
|
|
119
|
+
|
|
120
|
+
this._adjustDialog()
|
|
121
|
+
|
|
122
|
+
this._backdrop.show(() => this._showElement(relatedTarget))
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
hide() {
|
|
126
|
+
if (!this._isShown || this._isTransitioning) {
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE)
|
|
131
|
+
|
|
132
|
+
if (hideEvent.defaultPrevented) {
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
this._isShown = false
|
|
137
|
+
this._isTransitioning = true
|
|
138
|
+
this._focustrap.deactivate()
|
|
139
|
+
|
|
140
|
+
this._element.classList.remove(CLASS_NAME_SHOW)
|
|
141
|
+
|
|
142
|
+
this._queueCallback(() => this._hideModal(), this._element, this._isAnimated())
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
dispose() {
|
|
146
|
+
for (const htmlElement of [window, this._dialog]) {
|
|
147
|
+
EventHandler.off(htmlElement, EVENT_KEY)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
this._backdrop.dispose()
|
|
151
|
+
this._focustrap.deactivate()
|
|
152
|
+
super.dispose()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
handleUpdate() {
|
|
156
|
+
this._adjustDialog()
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Private
|
|
160
|
+
_initializeBackDrop() {
|
|
161
|
+
return new Backdrop({
|
|
162
|
+
isVisible: Boolean(this._config.backdrop), // 'static' option will be translated to true, and booleans will keep their value,
|
|
163
|
+
isAnimated: this._isAnimated(),
|
|
164
|
+
})
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
_initializeFocusTrap() {
|
|
168
|
+
return new FocusTrap({
|
|
169
|
+
trapElement: this._element,
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
_showElement(relatedTarget) {
|
|
174
|
+
// try to append dynamic modal
|
|
175
|
+
if (!document.body.contains(this._element)) {
|
|
176
|
+
document.body.append(this._element)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
this._element.style.display = 'block'
|
|
180
|
+
this._element.removeAttribute('aria-hidden')
|
|
181
|
+
this._element.setAttribute('aria-modal', true)
|
|
182
|
+
this._element.setAttribute('role', 'dialog')
|
|
183
|
+
this._element.scrollTop = 0
|
|
184
|
+
|
|
185
|
+
const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog)
|
|
186
|
+
if (modalBody) {
|
|
187
|
+
modalBody.scrollTop = 0
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
reflow(this._element)
|
|
191
|
+
|
|
192
|
+
this._element.classList.add(CLASS_NAME_SHOW)
|
|
193
|
+
|
|
194
|
+
const transitionComplete = () => {
|
|
195
|
+
if (this._config.focus) {
|
|
196
|
+
this._focustrap.activate()
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
this._isTransitioning = false
|
|
200
|
+
EventHandler.trigger(this._element, EVENT_SHOWN, {
|
|
201
|
+
relatedTarget,
|
|
202
|
+
})
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
this._queueCallback(transitionComplete, this._dialog, this._isAnimated())
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
_addEventListeners() {
|
|
209
|
+
EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, (event) => {
|
|
210
|
+
if (event.key !== ESCAPE_KEY) {
|
|
211
|
+
return
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (this._config.keyboard) {
|
|
215
|
+
event.preventDefault()
|
|
216
|
+
this.hide()
|
|
217
|
+
return
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
this._triggerBackdropTransition()
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
EventHandler.on(window, EVENT_RESIZE, () => {
|
|
224
|
+
if (this._isShown && !this._isTransitioning) {
|
|
225
|
+
this._adjustDialog()
|
|
226
|
+
}
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
EventHandler.on(this._element, EVENT_MOUSEDOWN_DISMISS, (event) => {
|
|
230
|
+
// a bad trick to segregate clicks that may start inside dialog but end outside, and avoid listen to scrollbar clicks
|
|
231
|
+
EventHandler.one(this._element, EVENT_CLICK_DISMISS, (event2) => {
|
|
232
|
+
if (this._element !== event.target || this._element !== event2.target) {
|
|
233
|
+
return
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (this._config.backdrop === 'static') {
|
|
237
|
+
this._triggerBackdropTransition()
|
|
238
|
+
return
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (this._config.backdrop) {
|
|
242
|
+
this.hide()
|
|
243
|
+
}
|
|
244
|
+
})
|
|
245
|
+
})
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
_hideModal() {
|
|
249
|
+
this._element.style.display = 'none'
|
|
250
|
+
this._element.setAttribute('aria-hidden', true)
|
|
251
|
+
this._element.removeAttribute('aria-modal')
|
|
252
|
+
this._element.removeAttribute('role')
|
|
253
|
+
this._isTransitioning = false
|
|
254
|
+
|
|
255
|
+
this._backdrop.hide(() => {
|
|
256
|
+
document.body.classList.remove(CLASS_NAME_OPEN)
|
|
257
|
+
this._resetAdjustments()
|
|
258
|
+
this._scrollBar.reset()
|
|
259
|
+
EventHandler.trigger(this._element, EVENT_HIDDEN)
|
|
260
|
+
})
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
_isAnimated() {
|
|
264
|
+
return this._element.classList.contains(CLASS_NAME_FADE)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
_triggerBackdropTransition() {
|
|
268
|
+
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED)
|
|
269
|
+
if (hideEvent.defaultPrevented) {
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight
|
|
274
|
+
const initialOverflowY = this._element.style.overflowY
|
|
275
|
+
// return if the following background transition hasn't yet completed
|
|
276
|
+
if (initialOverflowY === 'hidden' || this._element.classList.contains(CLASS_NAME_STATIC)) {
|
|
277
|
+
return
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (!isModalOverflowing) {
|
|
281
|
+
this._element.style.overflowY = 'hidden'
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
this._element.classList.add(CLASS_NAME_STATIC)
|
|
285
|
+
this._queueCallback(() => {
|
|
286
|
+
this._element.classList.remove(CLASS_NAME_STATIC)
|
|
287
|
+
this._queueCallback(() => {
|
|
288
|
+
this._element.style.overflowY = initialOverflowY
|
|
289
|
+
}, this._dialog)
|
|
290
|
+
}, this._dialog)
|
|
291
|
+
|
|
292
|
+
this._element.focus()
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* The following methods are used to handle overflowing modals
|
|
297
|
+
*/
|
|
298
|
+
|
|
299
|
+
_adjustDialog() {
|
|
300
|
+
const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight
|
|
301
|
+
const scrollbarWidth = this._scrollBar.getWidth()
|
|
302
|
+
const isBodyOverflowing = scrollbarWidth > 0
|
|
303
|
+
|
|
304
|
+
if (isBodyOverflowing && !isModalOverflowing) {
|
|
305
|
+
const property = isRTL() ? 'paddingLeft' : 'paddingRight'
|
|
306
|
+
this._element.style[property] = `${scrollbarWidth}px`
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (!isBodyOverflowing && isModalOverflowing) {
|
|
310
|
+
const property = isRTL() ? 'paddingRight' : 'paddingLeft'
|
|
311
|
+
this._element.style[property] = `${scrollbarWidth}px`
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
_resetAdjustments() {
|
|
316
|
+
this._element.style.paddingLeft = ''
|
|
317
|
+
this._element.style.paddingRight = ''
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Data API implementation
|
|
323
|
+
*/
|
|
324
|
+
|
|
325
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
326
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
|
327
|
+
const target = getElementFromSelector(this)
|
|
328
|
+
|
|
329
|
+
if (['A', 'AREA'].includes(this.tagName)) {
|
|
330
|
+
event.preventDefault()
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
EventHandler.one(target, EVENT_SHOW, (showEvent) => {
|
|
334
|
+
if (showEvent.defaultPrevented) {
|
|
335
|
+
// only register focus restorer if modal will actually get shown
|
|
336
|
+
return
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
EventHandler.one(target, EVENT_HIDDEN, () => {
|
|
340
|
+
if (isVisible(this)) {
|
|
341
|
+
this.focus()
|
|
342
|
+
}
|
|
343
|
+
})
|
|
344
|
+
})
|
|
345
|
+
|
|
346
|
+
// avoid conflict when clicking modal toggler while another one is open
|
|
347
|
+
const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR)
|
|
348
|
+
if (alreadyOpen) {
|
|
349
|
+
Modal.getInstance(alreadyOpen).hide()
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const data = Modal.getOrCreateInstance(target)
|
|
353
|
+
|
|
354
|
+
data.toggle(this)
|
|
355
|
+
})
|
|
356
|
+
|
|
357
|
+
enableDismissTrigger(Modal)
|
|
358
|
+
}
|
|
4
359
|
|
|
5
360
|
export default Modal
|