bootstrap-italia 2.12.0 → 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/{custom → components}/_avatar.scss +75 -35
- 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}/_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,5 +1,275 @@
|
|
|
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): scrollspy.js
|
|
8
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
9
|
+
* --------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
2
11
|
|
|
3
|
-
|
|
12
|
+
import { getElement, isDisabled, isVisible } from './util/index'
|
|
13
|
+
import EventHandler from './dom/event-handler'
|
|
14
|
+
import SelectorEngine from './dom/selector-engine'
|
|
15
|
+
import BaseComponent from './base-component'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Constants
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const NAME = 'scrollspy'
|
|
22
|
+
const DATA_KEY = 'bs.scrollspy'
|
|
23
|
+
const EVENT_KEY = `.${DATA_KEY}`
|
|
24
|
+
const DATA_API_KEY = '.data-api'
|
|
25
|
+
|
|
26
|
+
const EVENT_ACTIVATE = `activate${EVENT_KEY}`
|
|
27
|
+
const EVENT_CLICK = `click${EVENT_KEY}`
|
|
28
|
+
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
|
|
29
|
+
|
|
30
|
+
const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item'
|
|
31
|
+
const CLASS_NAME_ACTIVE = 'active'
|
|
32
|
+
|
|
33
|
+
const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]'
|
|
34
|
+
const SELECTOR_TARGET_LINKS = '[href]'
|
|
35
|
+
const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group'
|
|
36
|
+
const SELECTOR_NAV_LINKS = '.nav-link'
|
|
37
|
+
const SELECTOR_NAV_ITEMS = '.nav-item'
|
|
38
|
+
const SELECTOR_LIST_ITEMS = '.list-group-item'
|
|
39
|
+
const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_NAV_ITEMS} > ${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`
|
|
40
|
+
const SELECTOR_DROPDOWN = '.dropdown'
|
|
41
|
+
const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'
|
|
42
|
+
|
|
43
|
+
const Default = {
|
|
44
|
+
offset: null, // TODO: v6 @deprecated, keep it for backwards compatibility reasons
|
|
45
|
+
rootMargin: '0px 0px -25%',
|
|
46
|
+
smoothScroll: false,
|
|
47
|
+
target: null,
|
|
48
|
+
threshold: [0.1, 0.5, 1],
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const DefaultType = {
|
|
52
|
+
offset: '(number|null)', // TODO v6 @deprecated, keep it for backwards compatibility reasons
|
|
53
|
+
rootMargin: 'string',
|
|
54
|
+
smoothScroll: 'boolean',
|
|
55
|
+
target: 'element',
|
|
56
|
+
threshold: 'array',
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Class definition
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
class ScrollSpy extends BaseComponent {
|
|
64
|
+
constructor(element, config) {
|
|
65
|
+
super(element, config)
|
|
66
|
+
|
|
67
|
+
// this._element is the observablesContainer and config.target the menu links wrapper
|
|
68
|
+
this._targetLinks = new Map()
|
|
69
|
+
this._observableSections = new Map()
|
|
70
|
+
this._rootElement = getComputedStyle(this._element).overflowY === 'visible' ? null : this._element
|
|
71
|
+
this._activeTarget = null
|
|
72
|
+
this._observer = null
|
|
73
|
+
this._previousScrollData = {
|
|
74
|
+
visibleEntryTop: 0,
|
|
75
|
+
parentScrollTop: 0,
|
|
76
|
+
}
|
|
77
|
+
this.refresh() // initialize
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Getters
|
|
81
|
+
static get Default() {
|
|
82
|
+
return Default
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static get DefaultType() {
|
|
86
|
+
return DefaultType
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static get NAME() {
|
|
90
|
+
return NAME
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Public
|
|
94
|
+
refresh() {
|
|
95
|
+
this._initializeTargetsAndObservables()
|
|
96
|
+
this._maybeEnableSmoothScroll()
|
|
97
|
+
|
|
98
|
+
if (this._observer) {
|
|
99
|
+
this._observer.disconnect()
|
|
100
|
+
} else {
|
|
101
|
+
this._observer = this._getNewObserver()
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
for (const section of this._observableSections.values()) {
|
|
105
|
+
this._observer.observe(section)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
dispose() {
|
|
110
|
+
this._observer.disconnect()
|
|
111
|
+
super.dispose()
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Private
|
|
115
|
+
_configAfterMerge(config) {
|
|
116
|
+
// TODO: on v6 target should be given explicitly & remove the {target: 'ss-target'} case
|
|
117
|
+
config.target = getElement(config.target) || document.body
|
|
118
|
+
|
|
119
|
+
// TODO: v6 Only for backwards compatibility reasons. Use rootMargin only
|
|
120
|
+
config.rootMargin = config.offset ? `${config.offset}px 0px -30%` : config.rootMargin
|
|
121
|
+
|
|
122
|
+
if (typeof config.threshold === 'string') {
|
|
123
|
+
config.threshold = config.threshold.split(',').map((value) => Number.parseFloat(value))
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return config
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
_maybeEnableSmoothScroll() {
|
|
130
|
+
if (!this._config.smoothScroll) {
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// unregister any previous listeners
|
|
135
|
+
EventHandler.off(this._config.target, EVENT_CLICK)
|
|
136
|
+
|
|
137
|
+
EventHandler.on(this._config.target, EVENT_CLICK, SELECTOR_TARGET_LINKS, (event) => {
|
|
138
|
+
const observableSection = this._observableSections.get(event.target.hash)
|
|
139
|
+
if (observableSection) {
|
|
140
|
+
event.preventDefault()
|
|
141
|
+
const root = this._rootElement || window
|
|
142
|
+
const height = observableSection.offsetTop - this._element.offsetTop
|
|
143
|
+
if (root.scrollTo) {
|
|
144
|
+
root.scrollTo({ top: height, behavior: 'smooth' })
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Chrome 60 doesn't support `scrollTo`
|
|
149
|
+
root.scrollTop = height
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
_getNewObserver() {
|
|
155
|
+
const options = {
|
|
156
|
+
root: this._rootElement,
|
|
157
|
+
threshold: this._config.threshold,
|
|
158
|
+
rootMargin: this._config.rootMargin,
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return new IntersectionObserver((entries) => this._observerCallback(entries), options)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// The logic of selection
|
|
165
|
+
_observerCallback(entries) {
|
|
166
|
+
const targetElement = (entry) => this._targetLinks.get(`#${entry.target.id}`)
|
|
167
|
+
const activate = (entry) => {
|
|
168
|
+
this._previousScrollData.visibleEntryTop = entry.target.offsetTop
|
|
169
|
+
this._process(targetElement(entry))
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const parentScrollTop = (this._rootElement || document.documentElement).scrollTop
|
|
173
|
+
const userScrollsDown = parentScrollTop >= this._previousScrollData.parentScrollTop
|
|
174
|
+
this._previousScrollData.parentScrollTop = parentScrollTop
|
|
175
|
+
|
|
176
|
+
for (const entry of entries) {
|
|
177
|
+
if (!entry.isIntersecting) {
|
|
178
|
+
this._activeTarget = null
|
|
179
|
+
this._clearActiveClass(targetElement(entry))
|
|
180
|
+
|
|
181
|
+
continue
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const entryIsLowerThanPrevious = entry.target.offsetTop >= this._previousScrollData.visibleEntryTop
|
|
185
|
+
// if we are scrolling down, pick the bigger offsetTop
|
|
186
|
+
if (userScrollsDown && entryIsLowerThanPrevious) {
|
|
187
|
+
activate(entry)
|
|
188
|
+
// if parent isn't scrolled, let's keep the first visible item, breaking the iteration
|
|
189
|
+
if (!parentScrollTop) {
|
|
190
|
+
return
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
continue
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// if we are scrolling up, pick the smallest offsetTop
|
|
197
|
+
if (!userScrollsDown && !entryIsLowerThanPrevious) {
|
|
198
|
+
activate(entry)
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
_initializeTargetsAndObservables() {
|
|
204
|
+
this._targetLinks = new Map()
|
|
205
|
+
this._observableSections = new Map()
|
|
206
|
+
|
|
207
|
+
const targetLinks = SelectorEngine.find(SELECTOR_TARGET_LINKS, this._config.target)
|
|
208
|
+
|
|
209
|
+
for (const anchor of targetLinks) {
|
|
210
|
+
// ensure that the anchor has an id and is not disabled
|
|
211
|
+
if (!anchor.hash || isDisabled(anchor)) {
|
|
212
|
+
continue
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const observableSection = SelectorEngine.findOne(anchor.hash, this._element)
|
|
216
|
+
|
|
217
|
+
// ensure that the observableSection exists & is visible
|
|
218
|
+
if (isVisible(observableSection)) {
|
|
219
|
+
this._targetLinks.set(anchor.hash, anchor)
|
|
220
|
+
this._observableSections.set(anchor.hash, observableSection)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
_process(target) {
|
|
226
|
+
if (this._activeTarget === target) {
|
|
227
|
+
return
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
this._clearActiveClass(this._config.target)
|
|
231
|
+
this._activeTarget = target
|
|
232
|
+
target.classList.add(CLASS_NAME_ACTIVE)
|
|
233
|
+
this._activateParents(target)
|
|
234
|
+
|
|
235
|
+
EventHandler.trigger(this._element, EVENT_ACTIVATE, { relatedTarget: target })
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
_activateParents(target) {
|
|
239
|
+
// Activate dropdown parents
|
|
240
|
+
if (target.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
|
|
241
|
+
SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE, target.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE)
|
|
242
|
+
return
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
for (const listGroup of SelectorEngine.parents(target, SELECTOR_NAV_LIST_GROUP)) {
|
|
246
|
+
// Set triggered links parents as active
|
|
247
|
+
// With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
|
|
248
|
+
for (const item of SelectorEngine.prev(listGroup, SELECTOR_LINK_ITEMS)) {
|
|
249
|
+
item.classList.add(CLASS_NAME_ACTIVE)
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
_clearActiveClass(parent) {
|
|
255
|
+
parent.classList.remove(CLASS_NAME_ACTIVE)
|
|
256
|
+
|
|
257
|
+
const activeNodes = SelectorEngine.find(`${SELECTOR_TARGET_LINKS}.${CLASS_NAME_ACTIVE}`, parent)
|
|
258
|
+
for (const node of activeNodes) {
|
|
259
|
+
node.classList.remove(CLASS_NAME_ACTIVE)
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Data API implementation
|
|
266
|
+
*/
|
|
267
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
268
|
+
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
|
|
269
|
+
for (const spy of SelectorEngine.find(SELECTOR_DATA_SPY)) {
|
|
270
|
+
ScrollSpy.getOrCreateInstance(spy)
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
}
|
|
4
274
|
|
|
5
275
|
export default ScrollSpy
|
|
@@ -1,6 +1,14 @@
|
|
|
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
|
+
|
|
1
9
|
import accessibleAutocomplete from 'accessible-autocomplete'
|
|
2
10
|
|
|
3
|
-
import BaseComponent from '
|
|
11
|
+
import BaseComponent from './base-component.js'
|
|
4
12
|
|
|
5
13
|
const NAME = 'selectautocomplete'
|
|
6
14
|
|
package/src/js/plugins/sticky.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import BaseComponent from '
|
|
1
|
+
import BaseComponent from './base-component.js'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
//defineJQueryPlugin,
|
|
5
|
-
//getElementFromSelector,
|
|
6
|
-
//isVisible,
|
|
7
|
-
//reflow,
|
|
8
|
-
//typeCheckConfig,
|
|
9
4
|
getSelectorFromElement, //in base al bs-target
|
|
10
|
-
} from '
|
|
11
|
-
import EventHandler from '
|
|
12
|
-
import SelectorEngine from '
|
|
13
|
-
import Manipulator from '
|
|
5
|
+
} from './util/index'
|
|
6
|
+
import EventHandler from './dom/event-handler'
|
|
7
|
+
import SelectorEngine from './dom/selector-engine'
|
|
8
|
+
import Manipulator from './dom/manipulator'
|
|
14
9
|
|
|
15
10
|
import { isScreenMobile } from './util/device'
|
|
16
11
|
import onDocumentScroll from './util/on-document-scroll'
|
|
@@ -18,9 +13,7 @@ import onDocumentScroll from './util/on-document-scroll'
|
|
|
18
13
|
const NAME = 'sticky'
|
|
19
14
|
const DATA_KEY = 'bs.sticky'
|
|
20
15
|
const EVENT_KEY = `.${DATA_KEY}`
|
|
21
|
-
//const DATA_API_KEY = '.data-api'
|
|
22
16
|
|
|
23
|
-
//const EVENT_SCROLL = `scroll${EVENT_KEY}`
|
|
24
17
|
const EVENT_RESIZE = `resize${EVENT_KEY}`
|
|
25
18
|
const EVENT_STICKY_ON = `on${EVENT_KEY}`
|
|
26
19
|
const EVENT_STICKY_OFF = `off${EVENT_KEY}`
|
|
@@ -66,10 +59,12 @@ class Sticky extends BaseComponent {
|
|
|
66
59
|
}
|
|
67
60
|
|
|
68
61
|
dispose() {
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
63
|
+
EventHandler.off(window, EVENT_RESIZE)
|
|
64
|
+
this._scrollCb.dispose()
|
|
71
65
|
|
|
72
|
-
|
|
66
|
+
super.dispose()
|
|
67
|
+
}
|
|
73
68
|
}
|
|
74
69
|
// Getters
|
|
75
70
|
|
|
@@ -90,9 +85,10 @@ class Sticky extends BaseComponent {
|
|
|
90
85
|
}
|
|
91
86
|
|
|
92
87
|
_bindEvents() {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
89
|
+
EventHandler.on(window, EVENT_RESIZE, () => this._onResize())
|
|
90
|
+
this._scrollCb = onDocumentScroll(() => this._onScroll())
|
|
91
|
+
}
|
|
96
92
|
}
|
|
97
93
|
|
|
98
94
|
_onResize() {
|
|
@@ -246,11 +242,13 @@ class Sticky extends BaseComponent {
|
|
|
246
242
|
* ------------------------------------------------------------------------
|
|
247
243
|
*/
|
|
248
244
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
245
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
246
|
+
onDocumentScroll(() => {
|
|
247
|
+
const stickies = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
|
|
248
|
+
stickies.map((sticky) => {
|
|
249
|
+
Sticky.getOrCreateInstance(sticky)
|
|
250
|
+
})
|
|
253
251
|
})
|
|
254
|
-
}
|
|
252
|
+
}
|
|
255
253
|
|
|
256
254
|
export default Sticky
|
package/src/js/plugins/tab.js
CHANGED
|
@@ -1,30 +1,157 @@
|
|
|
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
|
+
* This a fork of Bootstrap: Initial license and original file name below
|
|
7
|
+
* Bootstrap (v5.2.3): tab.js
|
|
8
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
9
|
+
* --------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { getElementFromSelector, getNextActiveElement, isDisabled } from './util/index'
|
|
13
|
+
import EventHandler from './dom/event-handler'
|
|
14
|
+
import SelectorEngine from './dom/selector-engine'
|
|
15
|
+
import BaseComponent from './base-component'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Constants
|
|
19
|
+
*/
|
|
5
20
|
|
|
21
|
+
const NAME = 'tab'
|
|
6
22
|
const DATA_KEY = 'bs.tab'
|
|
7
23
|
const EVENT_KEY = `.${DATA_KEY}`
|
|
8
24
|
|
|
25
|
+
const EVENT_HIDE = `hide${EVENT_KEY}`
|
|
26
|
+
const EVENT_HIDDEN = `hidden${EVENT_KEY}`
|
|
27
|
+
const EVENT_SHOW = `show${EVENT_KEY}`
|
|
28
|
+
const EVENT_SHOWN = `shown${EVENT_KEY}`
|
|
9
29
|
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}`
|
|
30
|
+
const EVENT_KEYDOWN = `keydown${EVENT_KEY}`
|
|
10
31
|
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}`
|
|
11
32
|
|
|
12
33
|
const ARROW_LEFT_KEY = 'ArrowLeft'
|
|
13
34
|
const ARROW_RIGHT_KEY = 'ArrowRight'
|
|
14
35
|
const ARROW_UP_KEY = 'ArrowUp'
|
|
15
36
|
const ARROW_DOWN_KEY = 'ArrowDown'
|
|
37
|
+
|
|
16
38
|
const ENTER_KEY = 'Enter'
|
|
17
39
|
const SPACE_BAR_KEY = ' '
|
|
18
40
|
|
|
19
41
|
const CLASS_NAME_ACTIVE = 'active'
|
|
42
|
+
const CLASS_NAME_FADE = 'fade'
|
|
43
|
+
const CLASS_NAME_SHOW = 'show'
|
|
44
|
+
const CLASS_DROPDOWN = 'dropdown'
|
|
45
|
+
|
|
46
|
+
const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'
|
|
47
|
+
const SELECTOR_DROPDOWN_MENU = '.dropdown-menu'
|
|
48
|
+
const NOT_SELECTOR_DROPDOWN_TOGGLE = ':not(.dropdown-toggle)'
|
|
20
49
|
|
|
50
|
+
const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]'
|
|
51
|
+
const SELECTOR_OUTER = '.nav-item, .list-group-item'
|
|
52
|
+
const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`
|
|
21
53
|
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]' // todo:v6: could be only `tab`
|
|
54
|
+
const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`
|
|
22
55
|
|
|
23
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Class definition
|
|
58
|
+
*/
|
|
24
59
|
|
|
25
|
-
class Tab extends
|
|
60
|
+
class Tab extends BaseComponent {
|
|
26
61
|
constructor(element) {
|
|
27
62
|
super(element)
|
|
63
|
+
this._parent = this._element.closest(SELECTOR_TAB_PANEL)
|
|
64
|
+
|
|
65
|
+
if (!this._parent) {
|
|
66
|
+
return
|
|
67
|
+
// todo: should Throw exception on v6
|
|
68
|
+
// throw new TypeError(`${element.outerHTML} has not a valid parent ${SELECTOR_INNER_ELEM}`)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Set up initial aria attributes
|
|
72
|
+
this._setInitialAttributes(this._parent, this._getChildren())
|
|
73
|
+
|
|
74
|
+
EventHandler.on(this._element, EVENT_KEYDOWN, (event) => this._keydown(event))
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Getters
|
|
78
|
+
static get NAME() {
|
|
79
|
+
return NAME
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Public
|
|
83
|
+
show() {
|
|
84
|
+
// Shows this elem and deactivate the active sibling if exists
|
|
85
|
+
const innerElem = this._element
|
|
86
|
+
if (this._elemIsActive(innerElem)) {
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Search for active tab on same parent to deactivate it
|
|
91
|
+
const active = this._getActiveElem()
|
|
92
|
+
|
|
93
|
+
const hideEvent = active ? EventHandler.trigger(active, EVENT_HIDE, { relatedTarget: innerElem }) : null
|
|
94
|
+
|
|
95
|
+
const showEvent = EventHandler.trigger(innerElem, EVENT_SHOW, { relatedTarget: active })
|
|
96
|
+
|
|
97
|
+
if (showEvent.defaultPrevented || (hideEvent && hideEvent.defaultPrevented)) {
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
this._deactivate(active, innerElem)
|
|
102
|
+
this._activate(innerElem, active)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Private
|
|
106
|
+
_activate(element, relatedElem) {
|
|
107
|
+
if (!element) {
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
element.classList.add(CLASS_NAME_ACTIVE)
|
|
112
|
+
|
|
113
|
+
this._activate(getElementFromSelector(element)) // Search and activate/show the proper section
|
|
114
|
+
|
|
115
|
+
const complete = () => {
|
|
116
|
+
if (element.getAttribute('role') !== 'tab') {
|
|
117
|
+
element.classList.add(CLASS_NAME_SHOW)
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
element.removeAttribute('tabindex')
|
|
122
|
+
element.setAttribute('aria-selected', true)
|
|
123
|
+
this._toggleDropDown(element, true)
|
|
124
|
+
EventHandler.trigger(element, EVENT_SHOWN, {
|
|
125
|
+
relatedTarget: relatedElem,
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE))
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
_deactivate(element, relatedElem) {
|
|
133
|
+
if (!element) {
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
element.classList.remove(CLASS_NAME_ACTIVE)
|
|
138
|
+
element.blur()
|
|
139
|
+
|
|
140
|
+
this._deactivate(getElementFromSelector(element)) // Search and deactivate the shown section too
|
|
141
|
+
|
|
142
|
+
const complete = () => {
|
|
143
|
+
if (element.getAttribute('role') !== 'tab') {
|
|
144
|
+
element.classList.remove(CLASS_NAME_SHOW)
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
element.setAttribute('aria-selected', false)
|
|
149
|
+
element.setAttribute('tabindex', '-1')
|
|
150
|
+
this._toggleDropDown(element, false)
|
|
151
|
+
EventHandler.trigger(element, EVENT_HIDDEN, { relatedTarget: relatedElem })
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE))
|
|
28
155
|
}
|
|
29
156
|
|
|
30
157
|
_keydown(event) {
|
|
@@ -51,36 +178,125 @@ class Tab extends BSTab {
|
|
|
51
178
|
nextActiveElement.focus({ preventScroll: true })
|
|
52
179
|
}
|
|
53
180
|
}
|
|
54
|
-
}
|
|
55
181
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
182
|
+
_getChildren() {
|
|
183
|
+
// collection of inner elements
|
|
184
|
+
return SelectorEngine.find(SELECTOR_INNER_ELEM, this._parent)
|
|
59
185
|
}
|
|
60
186
|
|
|
61
|
-
|
|
62
|
-
return
|
|
187
|
+
_getActiveElem() {
|
|
188
|
+
return this._getChildren().find((child) => this._elemIsActive(child)) || null
|
|
63
189
|
}
|
|
64
190
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Tab.getOrCreateInstance(this).show()
|
|
68
|
-
})
|
|
191
|
+
_setInitialAttributes(parent, children) {
|
|
192
|
+
this._setAttributeIfNotExists(parent, 'role', 'tablist')
|
|
69
193
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
194
|
+
for (const child of children) {
|
|
195
|
+
this._setInitialAttributesOnChild(child)
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
_setInitialAttributesOnChild(child) {
|
|
200
|
+
child = this._getInnerElement(child)
|
|
201
|
+
const isActive = this._elemIsActive(child)
|
|
202
|
+
const outerElem = this._getOuterElement(child)
|
|
203
|
+
child.setAttribute('aria-selected', isActive)
|
|
204
|
+
|
|
205
|
+
if (outerElem !== child) {
|
|
206
|
+
this._setAttributeIfNotExists(outerElem, 'role', 'presentation')
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (!isActive) {
|
|
210
|
+
child.setAttribute('tabindex', '-1')
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
this._setAttributeIfNotExists(child, 'role', 'tab')
|
|
214
|
+
|
|
215
|
+
// set attributes to the related panel too
|
|
216
|
+
this._setInitialAttributesOnTargetPanel(child)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
_setInitialAttributesOnTargetPanel(child) {
|
|
220
|
+
const target = getElementFromSelector(child)
|
|
221
|
+
|
|
222
|
+
if (!target) {
|
|
223
|
+
return
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
this._setAttributeIfNotExists(target, 'role', 'tabpanel')
|
|
227
|
+
|
|
228
|
+
if (child.id) {
|
|
229
|
+
this._setAttributeIfNotExists(target, 'aria-labelledby', `#${child.id}`)
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
_toggleDropDown(element, open) {
|
|
234
|
+
const outerElem = this._getOuterElement(element)
|
|
235
|
+
if (!outerElem.classList.contains(CLASS_DROPDOWN)) {
|
|
236
|
+
return
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const toggle = (selector, className) => {
|
|
240
|
+
const element = SelectorEngine.findOne(selector, outerElem)
|
|
241
|
+
if (element) {
|
|
242
|
+
element.classList.toggle(className, open)
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE)
|
|
247
|
+
toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW)
|
|
248
|
+
outerElem.setAttribute('aria-expanded', open)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
_setAttributeIfNotExists(element, attribute, value) {
|
|
252
|
+
if (!element.hasAttribute(attribute)) {
|
|
253
|
+
element.setAttribute(attribute, value)
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
_elemIsActive(elem) {
|
|
258
|
+
return elem.classList.contains(CLASS_NAME_ACTIVE)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Try to get the inner element (usually the .nav-link)
|
|
262
|
+
_getInnerElement(elem) {
|
|
263
|
+
return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine.findOne(SELECTOR_INNER_ELEM, elem)
|
|
78
264
|
}
|
|
79
|
-
|
|
265
|
+
|
|
266
|
+
// Try to get the outer element (usually the .nav-item)
|
|
267
|
+
_getOuterElement(elem) {
|
|
268
|
+
return elem.closest(SELECTOR_OUTER) || elem
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
80
272
|
/**
|
|
81
|
-
*
|
|
273
|
+
* Data API implementation
|
|
82
274
|
*/
|
|
83
275
|
|
|
84
|
-
|
|
276
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
277
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
|
278
|
+
if (['A', 'AREA'].includes(this.tagName)) {
|
|
279
|
+
event.preventDefault()
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (isDisabled(this)) {
|
|
283
|
+
return
|
|
284
|
+
}
|
|
285
|
+
const t = Tab.getOrCreateInstance(this)
|
|
286
|
+
t.dispose()
|
|
287
|
+
Tab.getOrCreateInstance(this).show()
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Initialize on focus
|
|
292
|
+
*/
|
|
293
|
+
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
|
|
294
|
+
for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE)) {
|
|
295
|
+
const t = Tab.getOrCreateInstance(element)
|
|
296
|
+
t.dispose()
|
|
297
|
+
Tab.getOrCreateInstance(element)
|
|
298
|
+
}
|
|
299
|
+
})
|
|
300
|
+
}
|
|
85
301
|
|
|
86
302
|
export default Tab
|