bootstrap-italia 2.12.1 → 2.13.1
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/{custom → components}/_accept-overlay.scss +2 -1
- 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 +274 -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 +163 -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}/_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,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 { isDisabled, getElementFromSelector, reflow } from './util/index'
|
|
12
|
+
import EventHandler from './dom/event-handler'
|
|
5
13
|
|
|
6
14
|
/**
|
|
7
15
|
* ------------------------------------------------------------------------
|
|
@@ -14,7 +22,6 @@ const VERSION = '5.0.0'
|
|
|
14
22
|
const DATA_KEY = 'bs.cookiebar'
|
|
15
23
|
const EVENT_KEY = `.${DATA_KEY}`
|
|
16
24
|
const DATA_API_KEY = '.data-api'
|
|
17
|
-
//const JQUERY_NO_CONFLICT = $.fn[NAME]
|
|
18
25
|
const COOKIE_NAME = 'cookies_consent'
|
|
19
26
|
const COOKIE_VALUE = 'true'
|
|
20
27
|
const COOKIE_EXPIRE = 30
|
|
@@ -193,27 +200,6 @@ class Cookiebar extends BaseComponent {
|
|
|
193
200
|
this.dispose()
|
|
194
201
|
}
|
|
195
202
|
|
|
196
|
-
// Static
|
|
197
|
-
|
|
198
|
-
/*static _jQueryInterface(config) {
|
|
199
|
-
return this.each(function () {
|
|
200
|
-
const $element = $(this)
|
|
201
|
-
let data = $element.data(DATA_KEY)
|
|
202
|
-
|
|
203
|
-
if (!data) {
|
|
204
|
-
data = new Cookiebar(this)
|
|
205
|
-
$element.data(DATA_KEY, data)
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (typeof config === 'string') {
|
|
209
|
-
if (typeof data[config] === 'undefined') {
|
|
210
|
-
throw new TypeError(`No method named "${config}"`)
|
|
211
|
-
}
|
|
212
|
-
data[config](this)
|
|
213
|
-
}
|
|
214
|
-
})
|
|
215
|
-
}*/
|
|
216
|
-
|
|
217
203
|
static _handleAccept(cookiebarInstance) {
|
|
218
204
|
return function (event) {
|
|
219
205
|
if (event) {
|
|
@@ -259,44 +245,35 @@ class Cookiebar extends BaseComponent {
|
|
|
259
245
|
* ------------------------------------------------------------------------
|
|
260
246
|
*/
|
|
261
247
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (isDisabled(this)) {
|
|
270
|
-
return
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
const target = getElementFromSelector(this) || this.closest(`.${NAME}`)
|
|
274
|
-
const instance = Cookiebar.getOrCreateInstance(target)
|
|
275
|
-
instance.accept()
|
|
276
|
-
//Cookiebar._handleAccept(new Cookiebar())
|
|
277
|
-
})
|
|
248
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
249
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_ACCEPT, function (event) {
|
|
250
|
+
if (['A', 'AREA'].includes(this.tagName)) {
|
|
251
|
+
event.preventDefault()
|
|
252
|
+
}
|
|
278
253
|
|
|
279
|
-
|
|
280
|
-
const consent = Cookiebar._getCookieEU()
|
|
281
|
-
if (!consent) {
|
|
282
|
-
if (typeof document === 'undefined') {
|
|
254
|
+
if (isDisabled(this)) {
|
|
283
255
|
return
|
|
284
256
|
}
|
|
285
|
-
const cookiebars = document.querySelectorAll(SELECTOR_COOKIE_BAR)
|
|
286
|
-
cookiebars.forEach((bar) => {
|
|
287
|
-
const instance = Cookiebar.getOrCreateInstance(bar)
|
|
288
|
-
instance.show()
|
|
289
|
-
})
|
|
290
|
-
}
|
|
291
|
-
})
|
|
292
257
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
258
|
+
const target = getElementFromSelector(this) || this.closest(`.${NAME}`)
|
|
259
|
+
const instance = Cookiebar.getOrCreateInstance(target)
|
|
260
|
+
instance.accept()
|
|
261
|
+
//Cookiebar._handleAccept(new Cookiebar())
|
|
262
|
+
})
|
|
263
|
+
|
|
264
|
+
EventHandler.on(window, EVENT_LOAD_DATA_API, function () {
|
|
265
|
+
const consent = Cookiebar._getCookieEU()
|
|
266
|
+
if (!consent) {
|
|
267
|
+
if (typeof document === 'undefined') {
|
|
268
|
+
return
|
|
269
|
+
}
|
|
270
|
+
const cookiebars = document.querySelectorAll(SELECTOR_COOKIE_BAR)
|
|
271
|
+
cookiebars.forEach((bar) => {
|
|
272
|
+
const instance = Cookiebar.getOrCreateInstance(bar)
|
|
273
|
+
instance.show()
|
|
274
|
+
})
|
|
275
|
+
}
|
|
276
|
+
})
|
|
277
|
+
}
|
|
301
278
|
|
|
302
279
|
export default Cookiebar
|
package/src/js/plugins/dimmer.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 { reflow, getElementFromSelector } from './util/index'
|
|
12
|
+
import EventHandler from './dom/event-handler'
|
|
5
13
|
|
|
6
14
|
const NAME = 'dimmer'
|
|
7
15
|
const DATA_KEY = 'bs.dimmer'
|
|
@@ -105,11 +113,13 @@ class Dimmer extends BaseComponent {
|
|
|
105
113
|
* ------------------------------------------------------------------------
|
|
106
114
|
*/
|
|
107
115
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
116
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
117
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function () {
|
|
118
|
+
const dimmerElement = getElementFromSelector(this)
|
|
119
|
+
const dimmer = Dimmer.getOrCreateInstance(dimmerElement)
|
|
111
120
|
|
|
112
|
-
|
|
113
|
-
})
|
|
121
|
+
this.checked ? dimmer.show() : dimmer.hide()
|
|
122
|
+
})
|
|
123
|
+
}
|
|
114
124
|
|
|
115
125
|
export default Dimmer
|
|
@@ -0,0 +1,58 @@
|
|
|
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): dom/data.js
|
|
8
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
9
|
+
* --------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Constants
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const elementMap = new Map()
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
set(element, key, instance) {
|
|
20
|
+
if (!elementMap.has(element)) {
|
|
21
|
+
elementMap.set(element, new Map())
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const instanceMap = elementMap.get(element)
|
|
25
|
+
|
|
26
|
+
// make it clear we only want one instance per element
|
|
27
|
+
// can be removed later when multiple key/instances are fine to be used
|
|
28
|
+
if (!instanceMap.has(key) && instanceMap.size !== 0) {
|
|
29
|
+
console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`)
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
instanceMap.set(key, instance)
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
get(element, key) {
|
|
37
|
+
if (elementMap.has(element)) {
|
|
38
|
+
return elementMap.get(element).get(key) || null
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return null
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
remove(element, key) {
|
|
45
|
+
if (!elementMap.has(element)) {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const instanceMap = elementMap.get(element)
|
|
50
|
+
|
|
51
|
+
instanceMap.delete(key)
|
|
52
|
+
|
|
53
|
+
// free up element references if there are no instances left for an element
|
|
54
|
+
if (instanceMap.size === 0) {
|
|
55
|
+
elementMap.delete(element)
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
}
|
|
@@ -0,0 +1,301 @@
|
|
|
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): dom/event-handler.js
|
|
8
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
9
|
+
* --------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Constants
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const namespaceRegex = /[^.]*(?=\..*)\.|.*/
|
|
17
|
+
const stripNameRegex = /\..*/
|
|
18
|
+
const stripUidRegex = /::\d+$/
|
|
19
|
+
const eventRegistry = {} // Events storage
|
|
20
|
+
let uidEvent = 1
|
|
21
|
+
const customEvents = {
|
|
22
|
+
mouseenter: 'mouseover',
|
|
23
|
+
mouseleave: 'mouseout',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const nativeEvents = new Set([
|
|
27
|
+
'click',
|
|
28
|
+
'dblclick',
|
|
29
|
+
'mouseup',
|
|
30
|
+
'mousedown',
|
|
31
|
+
'contextmenu',
|
|
32
|
+
'mousewheel',
|
|
33
|
+
'DOMMouseScroll',
|
|
34
|
+
'mouseover',
|
|
35
|
+
'mouseout',
|
|
36
|
+
'mousemove',
|
|
37
|
+
'selectstart',
|
|
38
|
+
'selectend',
|
|
39
|
+
'keydown',
|
|
40
|
+
'keypress',
|
|
41
|
+
'keyup',
|
|
42
|
+
'orientationchange',
|
|
43
|
+
'touchstart',
|
|
44
|
+
'touchmove',
|
|
45
|
+
'touchend',
|
|
46
|
+
'touchcancel',
|
|
47
|
+
'pointerdown',
|
|
48
|
+
'pointermove',
|
|
49
|
+
'pointerup',
|
|
50
|
+
'pointerleave',
|
|
51
|
+
'pointercancel',
|
|
52
|
+
'gesturestart',
|
|
53
|
+
'gesturechange',
|
|
54
|
+
'gestureend',
|
|
55
|
+
'focus',
|
|
56
|
+
'blur',
|
|
57
|
+
'change',
|
|
58
|
+
'reset',
|
|
59
|
+
'select',
|
|
60
|
+
'submit',
|
|
61
|
+
'focusin',
|
|
62
|
+
'focusout',
|
|
63
|
+
'load',
|
|
64
|
+
'unload',
|
|
65
|
+
'beforeunload',
|
|
66
|
+
'resize',
|
|
67
|
+
'move',
|
|
68
|
+
'DOMContentLoaded',
|
|
69
|
+
'readystatechange',
|
|
70
|
+
'error',
|
|
71
|
+
'abort',
|
|
72
|
+
'scroll',
|
|
73
|
+
])
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Private methods
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
function makeEventUid(element, uid) {
|
|
80
|
+
return (uid && `${uid}::${uidEvent++}`) || element.uidEvent || uidEvent++
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getElementEvents(element) {
|
|
84
|
+
const uid = makeEventUid(element)
|
|
85
|
+
|
|
86
|
+
element.uidEvent = uid
|
|
87
|
+
eventRegistry[uid] = eventRegistry[uid] || {}
|
|
88
|
+
|
|
89
|
+
return eventRegistry[uid]
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function bootstrapHandler(element, fn) {
|
|
93
|
+
return function handler(event) {
|
|
94
|
+
hydrateObj(event, { delegateTarget: element })
|
|
95
|
+
|
|
96
|
+
if (handler.oneOff) {
|
|
97
|
+
EventHandler.off(element, event.type, fn)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return fn.apply(element, [event])
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function bootstrapDelegationHandler(element, selector, fn) {
|
|
105
|
+
return function handler(event) {
|
|
106
|
+
const domElements = element.querySelectorAll(selector)
|
|
107
|
+
|
|
108
|
+
for (let { target } = event; target && target !== this; target = target.parentNode) {
|
|
109
|
+
for (const domElement of domElements) {
|
|
110
|
+
if (domElement !== target) {
|
|
111
|
+
continue
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
hydrateObj(event, { delegateTarget: target })
|
|
115
|
+
|
|
116
|
+
if (handler.oneOff) {
|
|
117
|
+
EventHandler.off(element, event.type, selector, fn)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return fn.apply(target, [event])
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function findHandler(events, callable, delegationSelector = null) {
|
|
127
|
+
return Object.values(events).find((event) => event.callable === callable && event.delegationSelector === delegationSelector)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function normalizeParameters(originalTypeEvent, handler, delegationFunction) {
|
|
131
|
+
const isDelegated = typeof handler === 'string'
|
|
132
|
+
// todo: tooltip passes `false` instead of selector, so we need to check
|
|
133
|
+
const callable = isDelegated ? delegationFunction : handler || delegationFunction
|
|
134
|
+
let typeEvent = getTypeEvent(originalTypeEvent)
|
|
135
|
+
|
|
136
|
+
if (!nativeEvents.has(typeEvent)) {
|
|
137
|
+
typeEvent = originalTypeEvent
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return [isDelegated, callable, typeEvent]
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function addHandler(element, originalTypeEvent, handler, delegationFunction, oneOff) {
|
|
144
|
+
if (typeof originalTypeEvent !== 'string' || !element) {
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
let [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction)
|
|
149
|
+
|
|
150
|
+
// in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position
|
|
151
|
+
// this prevents the handler from being dispatched the same way as mouseover or mouseout does
|
|
152
|
+
if (originalTypeEvent in customEvents) {
|
|
153
|
+
const wrapFunction = (fn) => {
|
|
154
|
+
return function (event) {
|
|
155
|
+
if (!event.relatedTarget || (event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget))) {
|
|
156
|
+
return fn.call(this, event)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
callable = wrapFunction(callable)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const events = getElementEvents(element)
|
|
165
|
+
const handlers = events[typeEvent] || (events[typeEvent] = {})
|
|
166
|
+
const previousFunction = findHandler(handlers, callable, isDelegated ? handler : null)
|
|
167
|
+
|
|
168
|
+
if (previousFunction) {
|
|
169
|
+
previousFunction.oneOff = previousFunction.oneOff && oneOff
|
|
170
|
+
|
|
171
|
+
return
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const uid = makeEventUid(callable, originalTypeEvent.replace(namespaceRegex, ''))
|
|
175
|
+
const fn = isDelegated ? bootstrapDelegationHandler(element, handler, callable) : bootstrapHandler(element, callable)
|
|
176
|
+
|
|
177
|
+
fn.delegationSelector = isDelegated ? handler : null
|
|
178
|
+
fn.callable = callable
|
|
179
|
+
fn.oneOff = oneOff
|
|
180
|
+
fn.uidEvent = uid
|
|
181
|
+
handlers[uid] = fn
|
|
182
|
+
|
|
183
|
+
element.addEventListener(typeEvent, fn, isDelegated)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function removeHandler(element, events, typeEvent, handler, delegationSelector) {
|
|
187
|
+
const fn = findHandler(events[typeEvent], handler, delegationSelector)
|
|
188
|
+
|
|
189
|
+
if (!fn) {
|
|
190
|
+
return
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
element.removeEventListener(typeEvent, fn, Boolean(delegationSelector))
|
|
194
|
+
delete events[typeEvent][fn.uidEvent]
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function removeNamespacedHandlers(element, events, typeEvent, namespace) {
|
|
198
|
+
const storeElementEvent = events[typeEvent] || {}
|
|
199
|
+
|
|
200
|
+
for (const handlerKey of Object.keys(storeElementEvent)) {
|
|
201
|
+
if (handlerKey.includes(namespace)) {
|
|
202
|
+
const event = storeElementEvent[handlerKey]
|
|
203
|
+
removeHandler(element, events, typeEvent, event.callable, event.delegationSelector)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function getTypeEvent(event) {
|
|
209
|
+
// allow to get the native events from namespaced events ('click.bs.button' --> 'click')
|
|
210
|
+
event = event.replace(stripNameRegex, '')
|
|
211
|
+
return customEvents[event] || event
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const EventHandler = {
|
|
215
|
+
on(element, event, handler, delegationFunction) {
|
|
216
|
+
addHandler(element, event, handler, delegationFunction, false)
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
one(element, event, handler, delegationFunction) {
|
|
220
|
+
addHandler(element, event, handler, delegationFunction, true)
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
off(element, originalTypeEvent, handler, delegationFunction) {
|
|
224
|
+
if (typeof originalTypeEvent !== 'string' || !element) {
|
|
225
|
+
return
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction)
|
|
229
|
+
const inNamespace = typeEvent !== originalTypeEvent
|
|
230
|
+
const events = getElementEvents(element)
|
|
231
|
+
const storeElementEvent = events[typeEvent] || {}
|
|
232
|
+
const isNamespace = originalTypeEvent.startsWith('.')
|
|
233
|
+
|
|
234
|
+
if (typeof callable !== 'undefined') {
|
|
235
|
+
// Simplest case: handler is passed, remove that listener ONLY.
|
|
236
|
+
if (!Object.keys(storeElementEvent).length) {
|
|
237
|
+
return
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
removeHandler(element, events, typeEvent, callable, isDelegated ? handler : null)
|
|
241
|
+
return
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (isNamespace) {
|
|
245
|
+
for (const elementEvent of Object.keys(events)) {
|
|
246
|
+
removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1))
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
for (const keyHandlers of Object.keys(storeElementEvent)) {
|
|
251
|
+
const handlerKey = keyHandlers.replace(stripUidRegex, '')
|
|
252
|
+
|
|
253
|
+
if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
|
|
254
|
+
const event = storeElementEvent[keyHandlers]
|
|
255
|
+
removeHandler(element, events, typeEvent, event.callable, event.delegationSelector)
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
trigger(element, event, args) {
|
|
261
|
+
if (typeof event !== 'string' || !element) {
|
|
262
|
+
return null
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
let bubbles = true
|
|
266
|
+
let nativeDispatch = true
|
|
267
|
+
let defaultPrevented = false
|
|
268
|
+
|
|
269
|
+
let evt = new Event(event, { bubbles, cancelable: true })
|
|
270
|
+
evt = hydrateObj(evt, args)
|
|
271
|
+
|
|
272
|
+
if (defaultPrevented) {
|
|
273
|
+
evt.preventDefault()
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (nativeDispatch) {
|
|
277
|
+
element.dispatchEvent(evt)
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return evt
|
|
281
|
+
},
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function hydrateObj(obj, meta) {
|
|
285
|
+
for (const [key, value] of Object.entries(meta || {})) {
|
|
286
|
+
try {
|
|
287
|
+
obj[key] = value
|
|
288
|
+
} catch {
|
|
289
|
+
Object.defineProperty(obj, key, {
|
|
290
|
+
configurable: true,
|
|
291
|
+
get() {
|
|
292
|
+
return value
|
|
293
|
+
},
|
|
294
|
+
})
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return obj
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export default EventHandler
|
|
@@ -0,0 +1,75 @@
|
|
|
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): dom/manipulator.js
|
|
8
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
9
|
+
* --------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
function normalizeData(value) {
|
|
13
|
+
if (value === 'true') {
|
|
14
|
+
return true
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (value === 'false') {
|
|
18
|
+
return false
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (value === Number(value).toString()) {
|
|
22
|
+
return Number(value)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (value === '' || value === 'null') {
|
|
26
|
+
return null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (typeof value !== 'string') {
|
|
30
|
+
return value
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(decodeURIComponent(value))
|
|
35
|
+
} catch {
|
|
36
|
+
return value
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function normalizeDataKey(key) {
|
|
41
|
+
return key.replace(/[A-Z]/g, (chr) => `-${chr.toLowerCase()}`)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const Manipulator = {
|
|
45
|
+
setDataAttribute(element, key, value) {
|
|
46
|
+
element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value)
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
removeDataAttribute(element, key) {
|
|
50
|
+
element.removeAttribute(`data-bs-${normalizeDataKey(key)}`)
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
getDataAttributes(element) {
|
|
54
|
+
if (!element) {
|
|
55
|
+
return {}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const attributes = {}
|
|
59
|
+
const bsKeys = Object.keys(element.dataset).filter((key) => key.startsWith('bs') && !key.startsWith('bsConfig'))
|
|
60
|
+
|
|
61
|
+
for (const key of bsKeys) {
|
|
62
|
+
let pureKey = key.replace(/^bs/, '')
|
|
63
|
+
pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length)
|
|
64
|
+
attributes[pureKey] = normalizeData(element.dataset[key])
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return attributes
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
getDataAttribute(element, key) {
|
|
71
|
+
return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`))
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default Manipulator
|
|
@@ -0,0 +1,80 @@
|
|
|
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): dom/selector-engine.js
|
|
8
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
9
|
+
* --------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { isDisabled, isVisible } from '../util/index'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Constants
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const SelectorEngine = {
|
|
19
|
+
find(selector, element = document.documentElement) {
|
|
20
|
+
return [].concat(...Element.prototype.querySelectorAll.call(element, selector))
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
findOne(selector, element = document.documentElement) {
|
|
24
|
+
return Element.prototype.querySelector.call(element, selector)
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
children(element, selector) {
|
|
28
|
+
return [].concat(...element.children).filter((child) => child.matches(selector))
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
parents(element, selector) {
|
|
32
|
+
const parents = []
|
|
33
|
+
let ancestor = element.parentNode.closest(selector)
|
|
34
|
+
|
|
35
|
+
while (ancestor) {
|
|
36
|
+
parents.push(ancestor)
|
|
37
|
+
ancestor = ancestor.parentNode.closest(selector)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return parents
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
prev(element, selector) {
|
|
44
|
+
let previous = element.previousElementSibling
|
|
45
|
+
|
|
46
|
+
while (previous) {
|
|
47
|
+
if (previous.matches(selector)) {
|
|
48
|
+
return [previous]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
previous = previous.previousElementSibling
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return []
|
|
55
|
+
},
|
|
56
|
+
// TODO: this is now unused; remove later along with prev()
|
|
57
|
+
next(element, selector) {
|
|
58
|
+
let next = element.nextElementSibling
|
|
59
|
+
|
|
60
|
+
while (next) {
|
|
61
|
+
if (next.matches(selector)) {
|
|
62
|
+
return [next]
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
next = next.nextElementSibling
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return []
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
focusableChildren(element) {
|
|
72
|
+
const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]']
|
|
73
|
+
.map((selector) => `${selector}:not([tabindex^="-"])`)
|
|
74
|
+
.join(',')
|
|
75
|
+
|
|
76
|
+
return this.find(focusables, element).filter((el) => !isDisabled(el) && isVisible(el))
|
|
77
|
+
},
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default SelectorEngine
|