@graupl/graupl 1.0.0-beta.2 → 1.0.0-beta.21
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.md +9 -0
- package/dist/css/base/button.css +1 -1
- package/dist/css/base/button.css.map +1 -1
- package/dist/css/base/form.css +1 -1
- package/dist/css/base/form.css.map +1 -1
- package/dist/css/base/link.css +1 -1
- package/dist/css/base/link.css.map +1 -1
- package/dist/css/base/table.css +1 -1
- package/dist/css/base/table.css.map +1 -1
- package/dist/css/base.css +1 -1
- package/dist/css/base.css.map +1 -1
- package/dist/css/component/accordion.css +4 -1
- package/dist/css/component/accordion.css.map +1 -1
- package/dist/css/component/alert.css +1 -1
- package/dist/css/component/alert.css.map +1 -1
- package/dist/css/component/badge.css +2 -0
- package/dist/css/component/badge.css.map +1 -0
- package/dist/css/component/card.css +1 -1
- package/dist/css/component/card.css.map +1 -1
- package/dist/css/component/carousel.css +1 -1
- package/dist/css/component/carousel.css.map +1 -1
- package/dist/css/component/disclosure.css +2 -0
- package/dist/css/component/disclosure.css.map +1 -0
- package/dist/css/component/input-group.css.map +1 -1
- package/dist/css/component/list.css +1 -1
- package/dist/css/component/list.css.map +1 -1
- package/dist/css/component/menu.css +1 -1
- package/dist/css/component/menu.css.map +1 -1
- package/dist/css/component/navigation.css +1 -1
- package/dist/css/component/navigation.css.map +1 -1
- package/dist/css/component.css +4 -1
- package/dist/css/component.css.map +1 -1
- package/dist/css/graupl.css +4 -1
- package/dist/css/graupl.css.map +1 -1
- package/dist/css/init.css.map +1 -1
- package/dist/css/layout/columns.css +1 -1
- package/dist/css/layout/columns.css.map +1 -1
- package/dist/css/layout/container.css +1 -1
- package/dist/css/layout/container.css.map +1 -1
- package/dist/css/layout/flex-columns.css +1 -1
- package/dist/css/layout/flex-columns.css.map +1 -1
- package/dist/css/layout.css +4 -1
- package/dist/css/layout.css.map +1 -1
- package/dist/css/normalize.css.map +1 -1
- package/dist/css/state/focus.css +1 -1
- package/dist/css/state/focus.css.map +1 -1
- package/dist/css/state.css +1 -1
- package/dist/css/state.css.map +1 -1
- package/dist/css/theme/color.css +1 -1
- package/dist/css/theme/color.css.map +1 -1
- package/dist/css/theme/typography.css +1 -1
- package/dist/css/theme/typography.css.map +1 -1
- package/dist/css/theme.css +1 -1
- package/dist/css/theme.css.map +1 -1
- package/dist/css/utilities/alignment.css.map +1 -1
- package/dist/css/utilities/background.css +2 -0
- package/dist/css/utilities/background.css.map +1 -0
- package/dist/css/utilities/border.css +1 -1
- package/dist/css/utilities/border.css.map +1 -1
- package/dist/css/utilities/color.css +1 -1
- package/dist/css/utilities/color.css.map +1 -1
- package/dist/css/utilities/container.css +2 -0
- package/dist/css/utilities/container.css.map +1 -0
- package/dist/css/utilities/display.css +1 -1
- package/dist/css/utilities/display.css.map +1 -1
- package/dist/css/utilities/flex.css.map +1 -1
- package/dist/css/utilities/gradient.css +2 -0
- package/dist/css/utilities/gradient.css.map +1 -0
- package/dist/css/utilities/height.css +1 -1
- package/dist/css/utilities/height.css.map +1 -1
- package/dist/css/utilities/inset.css.map +1 -1
- package/dist/css/utilities/justification.css.map +1 -1
- package/dist/css/utilities/list.css.map +1 -1
- package/dist/css/utilities/order.css.map +1 -1
- package/dist/css/utilities/position.css +2 -0
- package/dist/css/utilities/position.css.map +1 -0
- package/dist/css/utilities/ratio.css +1 -1
- package/dist/css/utilities/ratio.css.map +1 -1
- package/dist/css/utilities/spacing.css +1 -1
- package/dist/css/utilities/spacing.css.map +1 -1
- package/dist/css/utilities/typography.css +1 -1
- package/dist/css/utilities/typography.css.map +1 -1
- package/dist/css/utilities/visibility.css +1 -1
- package/dist/css/utilities/visibility.css.map +1 -1
- package/dist/css/utilities/visually-hidden.css +2 -0
- package/dist/css/utilities/visually-hidden.css.map +1 -0
- package/dist/css/utilities/width.css +1 -1
- package/dist/css/utilities/width.css.map +1 -1
- package/dist/css/utilities/z-index.css +2 -0
- package/dist/css/utilities/z-index.css.map +1 -0
- package/dist/css/utilities.css +1 -1
- package/dist/css/utilities.css.map +1 -1
- package/dist/js/accordion.js +5 -0
- package/dist/js/accordion.js.map +1 -0
- package/dist/js/alert.js +5 -0
- package/dist/js/alert.js.map +1 -0
- package/dist/js/carousel.js +5 -0
- package/dist/js/carousel.js.map +1 -0
- package/dist/js/component/accordion.cjs.js +4 -2
- package/dist/js/component/accordion.cjs.js.map +1 -0
- package/dist/js/component/accordion.es.js +5 -0
- package/dist/js/component/accordion.es.js.map +1 -0
- package/dist/js/component/accordion.iife.js +4 -2
- package/dist/js/component/accordion.iife.js.map +1 -0
- package/dist/js/component/alert.cjs.js +4 -2
- package/dist/js/component/alert.cjs.js.map +1 -0
- package/dist/js/component/alert.es.js +5 -0
- package/dist/js/component/alert.es.js.map +1 -0
- package/dist/js/component/alert.iife.js +4 -2
- package/dist/js/component/alert.iife.js.map +1 -0
- package/dist/js/component/carousel.cjs.js +4 -2
- package/dist/js/component/carousel.cjs.js.map +1 -0
- package/dist/js/component/carousel.es.js +5 -0
- package/dist/js/component/carousel.es.js.map +1 -0
- package/dist/js/component/carousel.iife.js +4 -2
- package/dist/js/component/carousel.iife.js.map +1 -0
- package/dist/js/component/disclosure.cjs.js +5 -0
- package/dist/js/component/disclosure.cjs.js.map +1 -0
- package/dist/js/component/disclosure.es.js +5 -0
- package/dist/js/component/disclosure.es.js.map +1 -0
- package/dist/js/component/disclosure.iife.js +5 -0
- package/dist/js/component/disclosure.iife.js.map +1 -0
- package/dist/js/generator/accordion.cjs.js +5 -0
- package/dist/js/generator/accordion.cjs.js.map +1 -0
- package/dist/js/generator/accordion.es.js +5 -0
- package/dist/js/generator/accordion.es.js.map +1 -0
- package/dist/js/generator/accordion.iife.js +5 -0
- package/dist/js/generator/accordion.iife.js.map +1 -0
- package/dist/js/generator/alert.cjs.js +5 -0
- package/dist/js/generator/alert.cjs.js.map +1 -0
- package/dist/js/generator/alert.es.js +5 -0
- package/dist/js/generator/alert.es.js.map +1 -0
- package/dist/js/generator/alert.iife.js +5 -0
- package/dist/js/generator/alert.iife.js.map +1 -0
- package/dist/js/generator/carousel.cjs.js +5 -0
- package/dist/js/generator/carousel.cjs.js.map +1 -0
- package/dist/js/generator/carousel.es.js +5 -0
- package/dist/js/generator/carousel.es.js.map +1 -0
- package/dist/js/generator/carousel.iife.js +5 -0
- package/dist/js/generator/carousel.iife.js.map +1 -0
- package/dist/js/generator/disclosure.cjs.js +5 -0
- package/dist/js/generator/disclosure.cjs.js.map +1 -0
- package/dist/js/generator/disclosure.es.js +5 -0
- package/dist/js/generator/disclosure.es.js.map +1 -0
- package/dist/js/generator/disclosure.iife.js +5 -0
- package/dist/js/generator/disclosure.iife.js.map +1 -0
- package/dist/js/generator/navigation.cjs.js +3 -0
- package/dist/js/generator/navigation.cjs.js.map +1 -0
- package/dist/js/generator/navigation.es.js +3 -0
- package/dist/js/generator/navigation.es.js.map +1 -0
- package/dist/js/generator/navigation.iife.js +3 -0
- package/dist/js/generator/navigation.iife.js.map +1 -0
- package/dist/js/graupl.js +11 -0
- package/dist/js/graupl.js.map +1 -0
- package/dist/js/navigation.js +3 -0
- package/dist/js/navigation.js.map +1 -0
- package/package.json +49 -41
- package/scss/base/button.scss +1 -1
- package/scss/base/form.scss +1 -1
- package/scss/base/link.scss +1 -1
- package/scss/base/table.scss +1 -1
- package/scss/base.scss +1 -1
- package/scss/component/accordion.scss +1 -1
- package/scss/component/alert.scss +1 -1
- package/scss/component/badge.scss +3 -0
- package/scss/component/card.scss +1 -1
- package/scss/component/carousel.scss +1 -1
- package/scss/component/disclosure.scss +3 -0
- package/scss/component/input-group.scss +1 -1
- package/scss/component/list.scss +1 -1
- package/scss/component/menu.scss +1 -1
- package/scss/component/navigation.scss +1 -1
- package/scss/component.scss +1 -1
- package/scss/graupl.scss +1 -1
- package/scss/init.scss +1 -1
- package/scss/layout/columns.scss +1 -1
- package/scss/layout/container.scss +1 -1
- package/scss/layout/flex-columns.scss +1 -1
- package/scss/layout.scss +1 -1
- package/scss/normalize.scss +1 -1
- package/scss/state/focus.scss +1 -1
- package/scss/state.scss +1 -1
- package/scss/theme/color.scss +1 -1
- package/scss/theme/typography.scss +1 -1
- package/scss/theme.scss +1 -1
- package/scss/utilities/alignment.scss +1 -1
- package/scss/utilities/background.scss +3 -0
- package/scss/utilities/border.scss +1 -1
- package/scss/utilities/color.scss +1 -1
- package/scss/utilities/container.scss +3 -0
- package/scss/utilities/display.scss +1 -1
- package/scss/utilities/flex.scss +1 -1
- package/scss/utilities/gradient.scss +3 -0
- package/scss/utilities/height.scss +1 -1
- package/scss/utilities/inset.scss +1 -1
- package/scss/utilities/justification.scss +1 -1
- package/scss/utilities/list.scss +1 -1
- package/scss/utilities/order.scss +1 -1
- package/scss/utilities/position.scss +3 -0
- package/scss/utilities/ratio.scss +1 -1
- package/scss/utilities/spacing.scss +1 -1
- package/scss/utilities/typography.scss +1 -1
- package/scss/utilities/visibility.scss +1 -1
- package/scss/utilities/visually-hidden.scss +3 -0
- package/scss/utilities/width.scss +1 -1
- package/scss/utilities/z-index.scss +3 -0
- package/scss/utilities.scss +1 -1
- package/.browserslistrc +0 -3
- package/.czrc +0 -3
- package/.editorconfig +0 -13
- package/.github/CODE_OF_CONDUCT.md +0 -73
- package/.github/COMMIT_CONVENTION.md +0 -17
- package/.github/CONTRIBUTING.md +0 -86
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -30
- package/.github/ISSUE_TEMPLATE/documentation.md +0 -20
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/SECURITY.md +0 -26
- package/.github/dependabot.yml +0 -17
- package/.github/pull_request_template.md +0 -5
- package/.github/workflows/codeql-analysis.yml +0 -71
- package/.github/workflows/docs.yml +0 -59
- package/.github/workflows/test.yml +0 -27
- package/.husky/commit-msg +0 -3
- package/.husky/pre-commit +0 -4
- package/.prettierignore +0 -12
- package/.stylelintignore +0 -9
- package/.versionrc.cjs +0 -61
- package/CHANGELOG.md +0 -392
- package/build.js +0 -7
- package/commitlint.config.js +0 -5
- package/dist/css/utilities/postion.css +0 -2
- package/dist/css/utilities/postion.css.map +0 -1
- package/dist/js/component/accordion.esm.js +0 -1289
- package/dist/js/component/alert.esm.js +0 -529
- package/dist/js/component/carousel.esm.js +0 -1110
- package/dist/js/graupl.cjs.js +0 -5
- package/dist/js/graupl.esm.js +0 -1462
- package/dist/js/graupl.iife.js +0 -5
- package/docs/.vitepress/config.js +0 -78
- package/docs/.vitepress/theme/custom.scss +0 -35
- package/docs/.vitepress/theme/index.js +0 -4
- package/docs/compiling-graupl.md +0 -56
- package/docs/components/alert.md +0 -130
- package/docs/components/button.md +0 -84
- package/docs/components/card.md +0 -369
- package/docs/components/index.md +0 -1
- package/docs/components/inputgroup.md +0 -159
- package/docs/components/menu.md +0 -326
- package/docs/components/navigation.md +0 -158
- package/docs/content.md +0 -237
- package/docs/defaults.md +0 -121
- package/docs/forms.md +0 -79
- package/docs/functions.md +0 -9
- package/docs/getting-started.md +0 -1
- package/docs/index.md +0 -1
- package/docs/introduction.md +0 -25
- package/docs/layout.md +0 -200
- package/docs/mixins.md +0 -47
- package/docs/state.md +0 -67
- package/docs/theme.md +0 -258
- package/docs/utilities.md +0 -357
- package/eslint.config.js +0 -74
- package/index.html +0 -923
- package/index.js +0 -12
- package/lint-staged.config.js +0 -6
- package/postcss.config.cjs +0 -12
- package/prettier.config.js +0 -16
- package/scss/utilities/postion.scss +0 -3
- package/src/js/accordion/Accordion.js +0 -1163
- package/src/js/accordion/AccordionItem.js +0 -496
- package/src/js/accordion/index.js +0 -10
- package/src/js/alert/Alert.js +0 -581
- package/src/js/alert/index.js +0 -11
- package/src/js/carousel/Carousel.js +0 -1427
- package/src/js/carousel/index.js +0 -10
- package/src/js/domHelpers.js +0 -37
- package/src/js/eventHandlers.js +0 -39
- package/src/js/navigation/index.js +0 -36
- package/src/js/storage.js +0 -106
- package/src/js/validate.js +0 -225
- package/src/scss/_defaults.scss +0 -145
- package/src/scss/_index.scss +0 -15
- package/src/scss/_init.scss +0 -3
- package/src/scss/_normalize.scss +0 -197
- package/src/scss/_variables.scss +0 -53
- package/src/scss/base/_index.scss +0 -6
- package/src/scss/base/button/_defaults.scss +0 -60
- package/src/scss/base/button/_index.scss +0 -107
- package/src/scss/base/button/_mixins.scss +0 -166
- package/src/scss/base/button/_variables.scss +0 -176
- package/src/scss/base/form/_defaults.scss +0 -17
- package/src/scss/base/form/_index.scss +0 -93
- package/src/scss/base/form/_variables.scss +0 -153
- package/src/scss/base/link/_defaults.scss +0 -50
- package/src/scss/base/link/_index.scss +0 -134
- package/src/scss/base/link/_variables.scss +0 -262
- package/src/scss/base/table/_defaults.scss +0 -53
- package/src/scss/base/table/_index.scss +0 -121
- package/src/scss/base/table/_variables.scss +0 -135
- package/src/scss/component/_index.scss +0 -10
- package/src/scss/component/accordion/_defaults.scss +0 -40
- package/src/scss/component/accordion/_index.scss +0 -180
- package/src/scss/component/accordion/_variables.scss +0 -316
- package/src/scss/component/alert/_defaults.scss +0 -49
- package/src/scss/component/alert/_index.scss +0 -118
- package/src/scss/component/alert/_variables.scss +0 -170
- package/src/scss/component/card/_defaults.scss +0 -32
- package/src/scss/component/card/_index.scss +0 -178
- package/src/scss/component/card/_variables.scss +0 -186
- package/src/scss/component/carousel/_defaults.scss +0 -43
- package/src/scss/component/carousel/_index.scss +0 -188
- package/src/scss/component/carousel/_variables.scss +0 -104
- package/src/scss/component/input-group/_defaults.scss +0 -30
- package/src/scss/component/input-group/_index.scss +0 -47
- package/src/scss/component/input-group/_variables.scss +0 -66
- package/src/scss/component/list/_defaults.scss +0 -15
- package/src/scss/component/list/_index.scss +0 -50
- package/src/scss/component/list/_variables.scss +0 -176
- package/src/scss/component/menu/_defaults.scss +0 -66
- package/src/scss/component/menu/_index.scss +0 -305
- package/src/scss/component/menu/_variables.scss +0 -500
- package/src/scss/component/navigation/_defaults.scss +0 -29
- package/src/scss/component/navigation/_index.scss +0 -189
- package/src/scss/component/navigation/_variables.scss +0 -237
- package/src/scss/functions/_important.scss +0 -13
- package/src/scss/functions/_screen.scss +0 -38
- package/src/scss/functions/_theme.scss +0 -39
- package/src/scss/functions/_utility.scss +0 -28
- package/src/scss/layout/_index.scss +0 -5
- package/src/scss/layout/columns/_defaults.scss +0 -19
- package/src/scss/layout/columns/_index.scss +0 -58
- package/src/scss/layout/columns/_variables.scss +0 -51
- package/src/scss/layout/container/_defaults.scss +0 -17
- package/src/scss/layout/container/_index.scss +0 -41
- package/src/scss/layout/container/_variables.scss +0 -50
- package/src/scss/layout/flex-columns/_defaults.scss +0 -18
- package/src/scss/layout/flex-columns/_index.scss +0 -80
- package/src/scss/layout/flex-columns/_variables.scss +0 -26
- package/src/scss/mixins/_animation.scss +0 -15
- package/src/scss/mixins/_layer.scss +0 -16
- package/src/scss/mixins/_screen.scss +0 -77
- package/src/scss/mixins/_state.scss +0 -18
- package/src/scss/mixins/_theme.scss +0 -15
- package/src/scss/mixins/_utility.scss +0 -132
- package/src/scss/mixins/_visually-hidden.scss +0 -20
- package/src/scss/state/_index.scss +0 -3
- package/src/scss/state/focus/_defaults.scss +0 -10
- package/src/scss/state/focus/_index.scss +0 -13
- package/src/scss/state/focus/_mixins.scss +0 -15
- package/src/scss/state/focus/_variables.scss +0 -44
- package/src/scss/theme/_index.scss +0 -4
- package/src/scss/theme/color/_defaults.scss +0 -143
- package/src/scss/theme/color/_index.scss +0 -42
- package/src/scss/theme/color/_variables.scss +0 -129
- package/src/scss/theme/typography/_defaults.scss +0 -54
- package/src/scss/theme/typography/_index.scss +0 -111
- package/src/scss/theme/typography/_variables.scss +0 -231
- package/src/scss/utilities/_index.scss +0 -18
- package/src/scss/utilities/alignment/_defaults.scss +0 -64
- package/src/scss/utilities/alignment/_index.scss +0 -168
- package/src/scss/utilities/alignment/_variables.scss +0 -6
- package/src/scss/utilities/border/_defaults.scss +0 -61
- package/src/scss/utilities/border/_index.scss +0 -269
- package/src/scss/utilities/border/_variables.scss +0 -6
- package/src/scss/utilities/color/_defaults.scss +0 -37
- package/src/scss/utilities/color/_index.scss +0 -202
- package/src/scss/utilities/color/_variables.scss +0 -6
- package/src/scss/utilities/display/_defaults.scss +0 -36
- package/src/scss/utilities/display/_index.scss +0 -134
- package/src/scss/utilities/display/_variables.scss +0 -6
- package/src/scss/utilities/flex/_defaults.scss +0 -87
- package/src/scss/utilities/flex/_index.scss +0 -255
- package/src/scss/utilities/flex/_variables.scss +0 -6
- package/src/scss/utilities/height/_defaults.scss +0 -43
- package/src/scss/utilities/height/_index.scss +0 -236
- package/src/scss/utilities/height/_variables.scss +0 -6
- package/src/scss/utilities/inset/_defaults.scss +0 -43
- package/src/scss/utilities/inset/_index.scss +0 -90
- package/src/scss/utilities/inset/_variables.scss +0 -6
- package/src/scss/utilities/justification/_defaults.scss +0 -61
- package/src/scss/utilities/justification/_index.scss +0 -168
- package/src/scss/utilities/justification/_variables.scss +0 -6
- package/src/scss/utilities/list/_defaults.scss +0 -41
- package/src/scss/utilities/list/_index.scss +0 -125
- package/src/scss/utilities/list/_variables.scss +0 -6
- package/src/scss/utilities/order/_defaults.scss +0 -24
- package/src/scss/utilities/order/_index.scss +0 -111
- package/src/scss/utilities/order/_variables.scss +0 -6
- package/src/scss/utilities/position/_defaults.scss +0 -28
- package/src/scss/utilities/position/_index.scss +0 -82
- package/src/scss/utilities/position/_variables.scss +0 -6
- package/src/scss/utilities/ratio/_defaults.scss +0 -30
- package/src/scss/utilities/ratio/_index.scss +0 -91
- package/src/scss/utilities/ratio/_variables.scss +0 -9
- package/src/scss/utilities/spacing/_defaults.scss +0 -51
- package/src/scss/utilities/spacing/_index.scss +0 -382
- package/src/scss/utilities/spacing/_variables.scss +0 -6
- package/src/scss/utilities/typography/_defaults.scss +0 -46
- package/src/scss/utilities/typography/_index.scss +0 -658
- package/src/scss/utilities/typography/_variables.scss +0 -6
- package/src/scss/utilities/visibility/_defaults.scss +0 -27
- package/src/scss/utilities/visibility/_index.scss +0 -82
- package/src/scss/utilities/visibility/_variables.scss +0 -6
- package/src/scss/utilities/width/_defaults.scss +0 -43
- package/src/scss/utilities/width/_index.scss +0 -236
- package/src/scss/utilities/width/_variables.scss +0 -6
- package/stylelint.config.js +0 -22
- package/vite.config.js +0 -57
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carousel.iife.js","names":["addClass","className","element","length","classList","add","removeClass","remove","selectAllFocusableElements","context","document","querySelector","elements","Array","from","querySelectorAll","tabbableElements","filter","check","getAttribute","selectFirstFocusableElement","selectLastFocusableElement","selectNextFocusableElement","index","indexOf","selectPreviousFocusableElement","keyPress","event","key","keyCode","keys","Enter","Space","Escape","ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End","Tab","Object","find","preventEvent","preventDefault","stopPropagation","isValidInstance","constructor","elements","elementsType","TypeError","key","elementType","name","status","error","isValidType","type","values","valuesType","valueType","isQuerySelector","Error","document","querySelector","isValidClassList","Array","isArray","forEach","value","obj","isValidHoverType","validTypes","includes","join","isTag","tagName","HTMLElement","tag","toLowerCase","check","isValidState","validStates","isValidEvent","validEvents","isValidType","initializeStorage","type","window","Graupl","getStorage","setStorage","data","clearStorage","pushToStorage","key","value","getFromStorage","removeFromStorage","addClass","removeClass","preventEvent","keyPress","storage","isQuerySelector","isTag","isValidClassList","isValidInstance","isValidType","Carousel","_dom","carousel","carouselItems","carouselItemContainer","carouselControls","carouselControlContainer","carouselTabs","carouselTabContainer","autoplay","next","previous","_selectors","_activeClass","_previousClass","_nextClass","_playClass","_pauseClass","_currentItem","_autoplay","_transitionDelay","_transitionDuration","_playText","_pauseText","_currentAction","_autoplayInterval","_prefix","_key","_errors","constructor","carouselElement","carouselItemSelector","carouselItemContainerSelector","carouselControlSelector","carouselControlContainerSelector","carouselTabSelector","carouselTabContainerSelector","autoplaySelector","nextSelector","previousSelector","activeClass","previousClass","nextClass","playClass","pauseClass","transitionDelay","transitionDuration","playText","pauseText","prefix","key","initialize","_validate","Error","errors","join","_generateKey","_setDOMElements","_setIds","_setAriaAttributes","activateFirstItem","_handleAutoplay","_handleFocus","_handleClick","_handleHover","_handleKeydown","_handleKeyup","_setTransitionDuration","initializeStorage","pushToStorage","dom","id","error","console","selectors","currentItem","currentCarouselItem","currentCarouselTab","currentAction","value","length","tabs","querySelectorAll","carouselTab","forEach","item","index","setAttribute","check","htmlElementChecks","HTMLElement","push","message","querySelectorChecks","carouselItemsSelector","carouselControlsSelector","carouselTabsSelector","autoplayChecks","delayCheck","durationCheck","activeClassChecks","previousClassChecks","nextClassChecks","playClassChecks","pauseClassChecks","playTextChecks","pauseTextChecks","prefixChecks","_setDOMElementType","elementType","base","overwrite","Array","isArray","domElements","from","filteredElements","filter","parentElement","domElement","querySelector","_resetDOMElementType","regenerate","Math","random","toString","replace","substring","tab","getAttribute","_setInterval","_clearInterval","setInterval","activateNextItem","clearInterval","addEventListener","activatePreviousItem","toggleAutoplay","activateItem","control","event","style","setProperty","activateCurrentItem","deactivateCurrentItem","currentIndex","dataset","grauplAction","requestAnimationFrame","setTimeout","activateLastItem","wsRE","attrName","doc","document","attr","element","op","value","attrSelector","id","TypeError","test","RangeError","checkElement","itemToCheck","Element","getElements","selector","context","elements","Document","DocumentFragment","querySelectorAll","Array","prototype","slice","call","filterAndModify","apply","filter","selected","matches","updateAttribute","add","remove","result","trim","split","forEach","item","indexOf","push","attribute","join","once","find","Carousel","once","generate","options","context","document","carouselSelector","forEach","carouselElement","carouselOptions","dataset","grauplCarouselOptions","JSON","parse","replace","initialize"],"sources":["../../../packages/core/src/js/domHelpers.js","../../../packages/core/src/js/eventHandlers.js","../../../packages/core/src/js/validate.js","../../../packages/core/src/js/storage.js","../../../packages/core/src/js/carousel/Carousel.js","../../../node_modules/@drupal/once/src/once.js","../../../packages/core/src/js/carousel/generator.js"],"sourcesContent":["/**\n * Add a class or array of classes to an element.\n *\n * @param {string|string[]} className - The class or classes to add.\n * @param {HTMLElement} element - The element to add the class to.\n */\nexport function addClass(className, element) {\n // Gracefully handle empty strings or arrays.\n if (className === \"\" || className.length === 0) {\n return;\n }\n\n if (typeof className === \"string\") {\n element.classList.add(className);\n } else {\n element.classList.add(...className);\n }\n}\n\n/**\n * Remove a class or array of classes from an element.\n *\n * @param {string|string[]} className - The class or classes to remove.\n * @param {HTMLElement} element - The element to remove the class from.\n */\nexport function removeClass(className, element) {\n // Gracefully handle empty strings or arrays.\n if (className === \"\" || className.length === 0) {\n return;\n }\n\n if (typeof className === \"string\") {\n element.classList.remove(className);\n } else {\n element.classList.remove(...className);\n }\n}\n\n/**\n * Select all focusable elements within a given context.\n *\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @return {HTMLElement[]} - An array of focusable elements.\n */\nexport function selectAllFocusableElements(context = document) {\n const querySelector =\n \"a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),[tabindex]\";\n const elements = Array.from(context.querySelectorAll(querySelector));\n\n const tabbableElements = elements.filter((element) => {\n let check = true;\n\n if (element.getAttribute(\"tabindex\") === \"-1\") check = false;\n\n return check;\n });\n\n return tabbableElements;\n}\n\n/**\n * Select the first focusable element within a given context.\n *\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @return {HTMLElement|boolean} - The first focusable element or false if none found.\n */\nexport function selectFirstFocusableElement(context = document) {\n const tabbableElements = selectAllFocusableElements(context);\n\n return tabbableElements[0] || false;\n}\n\n/**\n * Select the last focusable element within a given context.\n *\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @return {HTMLElement|boolean} - The last focusable element or false if none found.\n */\nexport function selectLastFocusableElement(context = document) {\n const tabbableElements = selectAllFocusableElements(context);\n\n return tabbableElements[tabbableElements.length - 1] || false;\n}\n\n/**\n * Select the next focusable element relative to the given element within a context.\n *\n * @param {HTMLElement} element - The reference element.\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @return {HTMLElement|boolean} - The next focusable element or false if none found.\n */\nexport function selectNextFocusableElement(element, context = document) {\n const tabbableElements = selectAllFocusableElements(context);\n const index = tabbableElements.indexOf(element);\n\n return index === tabbableElements.length - 1\n ? false\n : tabbableElements[index + 1];\n}\n\n/**\n * Select the previous focusable element relative to the given element within a context.\n *\n * @param {HTMLElement} element - The reference element.\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @return {HTMLElement|boolean} - The previous focusable element or false if none found.\n */\nexport function selectPreviousFocusableElement(element, context = document) {\n const tabbableElements = selectAllFocusableElements(context);\n const index = tabbableElements.indexOf(element);\n\n return index === 0 ? false : tabbableElements[index - 1];\n}\n","/**\n * Retrieves the pressed key from an event.\n *\n * @param {KeyboardEvent} event - The keyboard event.\n * @return {string} - The name of the key or an empty string.\n */\nexport function keyPress(event) {\n try {\n // Use event.key or event.keyCode to support older browsers.\n const key = event.key || event.keyCode;\n const keys = {\n Enter: key === \"Enter\" || key === 13,\n Space: key === \" \" || key === \"Spacebar\" || key === 32,\n Escape: key === \"Escape\" || key === \"Esc\" || key === 27,\n ArrowUp: key === \"ArrowUp\" || key === \"Up\" || key === 38,\n ArrowRight: key === \"ArrowRight\" || key === \"Right\" || key === 39,\n ArrowDown: key === \"ArrowDown\" || key === \"Down\" || key === 40,\n ArrowLeft: key === \"ArrowLeft\" || key === \"Left\" || key === 37,\n Home: key === \"Home\" || key === 36,\n End: key === \"End\" || key === 35,\n Tab: key === \"Tab\" || key === 9,\n };\n\n return Object.keys(keys).find((key) => keys[key] === true) || \"\";\n } catch {\n // Return an empty string if something goes wrong.\n return \"\";\n }\n}\n\n/**\n * Stops an event from taking action.\n *\n * @param {Event} event - The event.\n */\nexport function preventEvent(event) {\n event.preventDefault();\n event.stopPropagation();\n}\n","/**\n * Check to see if the provided elements have a specific constructor.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * This is essentially just a wrapper function around checking instanceof with\n * more descriptive error message to help debugging.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {object} constructor - The constructor to check for.\n * @param {object} elements - The element(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidInstance(constructor, elements) {\n try {\n if (typeof elements !== \"object\") {\n const elementsType = typeof elements;\n\n throw new TypeError(\n `Elements given to isValidInstance() must be inside of an object. \"${elementsType}\" given.`\n );\n }\n\n for (const key in elements) {\n if (!(elements[key] instanceof constructor)) {\n const elementType = typeof elements[key];\n throw new TypeError(\n `${key} must be an instance of ${constructor.name}. \"${elementType}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Check to see if the provided values are of a specific type.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * This is essentially just a wrapper function around checking typeof with\n * more descriptive error message to help debugging.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {string} type - The type to check for.\n * @param {object} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidType(type, values) {\n try {\n if (typeof values !== \"object\") {\n const valuesType = typeof values;\n\n throw new TypeError(\n `Values given to isValidType() must be inside of an object. \"${valuesType}\" given.`\n );\n }\n\n for (const key in values) {\n const valueType = typeof values[key];\n\n if (valueType !== type) {\n throw new TypeError(`${key} must be a ${type}. \"${valueType}\" given.`);\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Checks to see if the provided values are valid query selectors.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isQuerySelector(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isQuerySelector() must be inside of an object. \"${type}\" given.`\n );\n }\n\n for (const key in values) {\n try {\n if (values[key] === null) {\n throw new Error();\n }\n\n document.querySelector(values[key]);\n } catch {\n throw new TypeError(\n `${key} must be a valid query selector. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Checks to see if the provided value is either a string or an array of strings.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string, string[]>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidClassList(values) {\n try {\n if (typeof values !== \"object\" || Array.isArray(values)) {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidClassList() must be inside of an object. \"${type}\" given.`\n );\n }\n\n for (const key in values) {\n const type = typeof values[key];\n\n if (type !== \"string\") {\n if (Array.isArray(values[key])) {\n values[key].forEach((value) => {\n if (typeof value !== \"string\") {\n throw new TypeError(\n `${key} must be a string or an array of strings. An array containing non-strings given.`\n );\n }\n });\n } else {\n throw new TypeError(\n `${key} must be a string or an array of strings. \"${type}\" given.`\n );\n }\n } else {\n const obj = {};\n obj[key] = values[key];\n\n isQuerySelector(obj);\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Check to see if the provided values are valid hover types.\n *\n * Available types are: `\"off\"`, `\"on\"`, and `\"dynamic\"`.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidHoverType(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidHoverType() must be inside of an object. \"${type}\" given.`\n );\n }\n\n const validTypes = [\"off\", \"on\", \"dynamic\"];\n\n for (const key in values) {\n if (!validTypes.includes(values[key])) {\n throw new TypeError(\n `${key} must be one of the following values: ${validTypes.join(\n \", \"\n )}. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Checks to see if the provided elements are using a specific tag.\n *\n * The elements must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `true` if the check is successful.\n *\n * @param {string} tagName - The name of the tag.\n * @param {Object<HTMLElement>} elements - The element(s) to check.\n * @return {boolean} - The result of the check.\n */\nexport function isTag(tagName, elements) {\n if (\n isValidType(\"string\", { tagName }).status &&\n isValidInstance(HTMLElement, elements).status\n ) {\n const tag = tagName.toLowerCase();\n let check = true;\n\n for (const key in elements) {\n if (elements[key].tagName.toLowerCase() !== tag) check = false;\n }\n\n return check;\n } else {\n return false;\n }\n}\n\n/**\n * Check to see if the provided values are valid focus states for a menu.\n *\n * Available states are: `\"none\"`, `\"self\"`, and `\"child\"`.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidState(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidState() must be inside of an object. \"${type}\" given.`\n );\n }\n\n const validStates = [\"none\", \"self\", \"child\"];\n\n for (const key in values) {\n if (!validStates.includes(values[key])) {\n throw new TypeError(\n `${key} must be one of the following values: ${validStates.join(\n \", \"\n )}. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Check to see if the provided values are valid event types for a menu.\n *\n * Available events are: `\"none\"`, `\"mouse\"`, `\"keyboard\"`, and `\"character\"`.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidEvent(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidEvent() must be inside of an object. \"${type}\" given.`\n );\n }\n\n const validEvents = [\"none\", \"mouse\", \"keyboard\", \"character\"];\n\n for (const key in values) {\n if (!validEvents.includes(values[key])) {\n throw new TypeError(\n `${key} must be one of the following values: ${validEvents.join(\n \", \"\n )}. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n","/**\n * @file\n * Provides a system to get and store Graupl data in the browser.\n */\n\nimport { isValidType } from \"./validate.js\";\n\n/**\n * Initializes the storage system.\n *\n * @param {?string} [type = null] - The type of storage to initialize.\n */\nexport function initializeStorage(type = null) {\n window.Graupl = window.Graupl || {};\n\n if (isValidType(\"string\", { type })) {\n window.Graupl[type] = window.Graupl[type] || {};\n }\n}\n\n/**\n * Get the storage object.\n *\n * @param {?string} type - The type of storage to get.\n * @return {object} - The storage object.\n */\nexport function getStorage(type = null) {\n if (isValidType(\"string\", { type })) {\n return window.Graupl[type];\n }\n\n return window.Graupl;\n}\n\n/**\n * Set the storage object of a given type.\n *\n * @param {string} type - The type of storage to set.\n * @param {object} data - The data to set.\n */\nexport function setStorage(type, data = {}) {\n if (isValidType(\"string\", { type }) && isValidType(\"object\", { data })) {\n window.Graupl[type] = data;\n }\n}\n\n/**\n * Clear the storage object of a given type.\n *\n * @param {string} type - The type of storage to clear.\n */\nexport function clearStorage(type) {\n if (isValidType(\"string\", { type })) {\n window.Graupl[type] = {};\n }\n}\n\n/**\n * Push a value to the storage object.\n *\n * @param {string} type - The type of storage to push to.\n * @param {string} key - The key to use for the value.\n * @param {*} value - The value to store.\n */\nexport function pushToStorage(type, key, value) {\n if (isValidType(\"string\", { type, key })) {\n window.Graupl[type][key] = value;\n }\n}\n\n/**\n * Get a value from the storage object.\n *\n * @param {string }type - The type of storage to get from.\n * @param {string }key - The key to get the value from.\n * @return {*} - The value from the storage object.\n */\nexport function getFromStorage(type, key) {\n if (isValidType(\"string\", { type, key })) {\n return window.Graupl[type][key];\n }\n\n return null;\n}\n\n/**\n * Remove a value from the storage object.\n *\n * @param {string} type - The type of storage to remove from.\n * @param {string} key - The key to remove the value from.\n */\nexport function removeFromStorage(type, key) {\n if (isValidType(\"string\", { type, key })) {\n delete window.Graupl[type][key];\n }\n}\n\nexport default {\n initializeStorage,\n getStorage,\n setStorage,\n clearStorage,\n pushToStorage,\n getFromStorage,\n removeFromStorage,\n};\n","/**\n * @file\n * The carousel class.\n */\n\nimport { addClass, removeClass } from \"../domHelpers.js\";\nimport { preventEvent, keyPress } from \"../eventHandlers.js\";\nimport storage from \"../storage.js\";\nimport {\n isQuerySelector,\n isTag,\n isValidClassList,\n isValidInstance,\n isValidType,\n} from \"../validate.js\";\n\nclass Carousel {\n /**\n * The DOM elements within the carousel.\n *\n * @protected\n *\n * @type {Object<HTMLElement, HTMLElement[]>}\n *\n * @property {HTMLElement} carousel - The carousel element.\n * @property {HTMLElement[]} carouselItems - The carousel items.\n * @property {HTMLElement} carouselItemContainer - The carousel item container.\n * @property {HTMLElement[]} carouselControls - The carousel controls.\n * @property {HTMLElement} carouselControlContainer - The carousel control container.\n * @property {HTMLElement[]} carouselTabs - The carousel tabs.\n * @property {HTMLElement} carouselTabContainer - The carousel tab container.\n * @property {HTMLElement} autoplay - The autoplay button.\n * @property {HTMLElement} next - The next button.\n * @property {HTMLElement} previous - The previous button.\n */\n _dom = {\n carousel: null,\n carouselItems: [],\n carouselItemContainer: null,\n carouselControls: [],\n carouselControlContainer: null,\n carouselTabs: [],\n carouselTabContainer: null,\n autoplay: null,\n next: null,\n previous: null,\n };\n\n /**\n * The query selectors used by the carousel to populate the dom.\n *\n * @protected\n *\n * @type {Object<string>}\n *\n * @property {string} carouselItems - The query selector string for carousel items.\n * @property {string} carouselItemContainer - The query selector string for the carousel item container.\n * @property {string} carouselControls - The query selector string for carousel controls.\n * @property {string} carouselControlContainer - The query selector string for carousel control container.\n * @property {string} carouselTabs - The query selector string for the carousel tabs.\n * @property {string} carouselTabContainer - The query selector string for the carousel tab container.\n * @property {string} autoplay - The query selector string for the autoplay button.\n * @property {string} next - The query selector string for the next button.\n * @property {string} previous - The query selector string for the previous button.\n */\n _selectors = {\n carouselItems: \"\",\n carouselItemContainer: \"\",\n carouselControls: \"\",\n carouselControlContainer: \"\",\n carouselTabs: \"\",\n carouselTabContainer: \"\",\n autoplay: \"\",\n next: \"\",\n previous: \"\",\n };\n\n /**\n * The class(es) to apply when a carousel item is active.\n *\n * @protected\n *\n * @type {string|string[]}\n */\n _activeClass = \"active\";\n\n /**\n * The class(es) to apply to a carousel item that is the previously active item.\n *\n * @protected\n *\n * @type {string|string[]}\n */\n _previousClass = \"previous\";\n\n /**\n * The class(es) to apply to a carousel item that is the next active item.\n *\n * @protected\n *\n * @type {string|string[]}\n */\n _nextClass = \"next\";\n\n /**\n * The class(es) to apply to the autoplay button when the carousel is paused.\n *\n * @protected\n *\n * @type {string|string[]}\n */\n _playClass = \"play\";\n\n /**\n * The class(es) to apply to the autoplay button when the carousel is playing.\n *\n * @protected\n *\n * @type {string|string[]}\n */\n _pauseClass = \"pause\";\n\n /**\n * The index of the currently active carousel item.\n *\n * @protected\n *\n * @type {number}\n */\n _currentItem = 0;\n\n /**\n * A flag to indicate if the carousel is currently playing.\n *\n * @protected\n *\n * @type {boolean}\n */\n _autoplay = true;\n\n /**\n * A variable to delay transition slides in milliseconds.\n *\n * @protected\n *\n * @type {number}\n */\n _transitionDelay = 10000;\n\n /**\n * The duration time (in milliseconds) for the transition between carousel items.\n *\n * @protected\n *\n * @type {number}\n */\n _transitionDuration = 500;\n\n /**\n * The label for the autoplay button when the carousel is paused.\n *\n * @protected\n *\n * @type {string}\n */\n _playText = \"Play\";\n\n /**\n * The label for the autoplay button when the carousel is playing.\n *\n * @protected\n *\n * @type {string}\n */\n _pauseText = \"Pause\";\n\n /**\n * The current action being performed by the carousel.\n *\n * @protected\n *\n * @type {string}\n */\n _currentAction = \"next\";\n\n /**\n * The stored interval callback for autoplaying the carousel.\n *\n * @protected\n *\n * @type {?Function}\n */\n _autoplayInterval = null;\n\n /**\n * The prefix to use for CSS custom properties.\n *\n * @protected\n *\n * @type {string}\n */\n _prefix = \"graupl-\";\n\n /**\n * The key used to generate IDs throughout the carousel.\n *\n * @protected\n *\n * @type {string}\n */\n _key = \"\";\n\n /**\n * An array of error messages generated by the carousel.\n *\n * @protected\n *\n * @type {string[]}\n */\n _errors = [];\n\n /**\n * Constructs a new `Carousel`.\n *\n * @param {object} options - The options for the generated carousel.\n * @param {HTMLElement} options.carouselElement - The carousel element in the DOM.\n * @param {string} [options.carouselItemSelector = .carousel-item] - The query selector string for carousel items.\n * @param {string} [options.carouselItemContainerSelector = .carousel-item-container] - The query selector string for the carousel item container.\n * @param {string} [options.carouselControlSelector = .carousel-control] - The query selector string for carousel controls.\n * @param {string} [options.carouselControlContainerSelector = .carousel-control-container] - The query selector string for carousel control container.\n * @param {string} [options.carouselTabSelector = .carousel-tab] - The query selector string for carousel tabs.\n * @param {string} [options.carouselTabContainerSelector = .carousel-tab-container] - The query selector string for the carousel tab container.\n * @param {string} [options.autoplaySelector = .autoplay] - The query selector string for the autoplay button.\n * @param {string} [options.nextSelector = .next] - The query selector string for the next button.\n * @param {string} [options.previousSelector = .previous] - The query selector string for the previous button.\n * @param {?(string|string[])} [options.activeClass = active] - The class(es) to apply when a carousel item is active.\n * @param {?(string|string[])} [options.previousClass = previous] - The class(es) to apply to a carousel item that is the previously active item.\n * @param {?(string|string[])} [options.nextClass = next] - The class(es) to apply to a carousel item that is the next active item.\n * @param {?(string|string[])} [options.playClass = play] - The class(es) to apply to the autoplay button when the carousel is paused.\n * @param {?(string|string[])} [options.pauseClass = pause] - The class(es) to apply to the autoplay button when the carousel is playing.\n * @param {boolean} [options.autoplay = true] - A flag to indicate if the carousel should autoplay.\n * @param {number} [options.transitionDelay = 10000] - A flag to initialize the carousel immediately upon creation.\n * @param {number} [options.transitionDuration = 500] - The duration time (in milliseconds) for the transition between carousel items.\n * @param {?string} [options.playText = Play] - The text to use for the play button.\n * @param {?string} [options.pauseText = Pause] - The text to use for the pause button.\n * @param {?string} [options.prefix = graupl-] - The prefix to use for CSS custom properties.\n * @param {?string} [options.key = null] - The key used to generate IDs throughout the carousel.\n * @param {boolean} [options.initialize = false] - A flag to initialize the carousel immediately upon creation.\n */\n constructor({\n carouselElement,\n carouselItemSelector = \".carousel-item\",\n carouselItemContainerSelector = \".carousel-item-container\",\n carouselControlSelector = \".carousel-control\",\n carouselControlContainerSelector = \".carousel-control-container\",\n carouselTabSelector = \".carousel-tab\",\n carouselTabContainerSelector = \".carousel-tab-container\",\n autoplaySelector = \".autoplay\",\n nextSelector = \".next\",\n previousSelector = \".previous\",\n activeClass = \"active\",\n previousClass = \"previous\",\n nextClass = \"next\",\n playClass = \"play\",\n pauseClass = \"pause\",\n autoplay = true,\n transitionDelay = 10000,\n transitionDuration = 500,\n playText = \"Play\",\n pauseText = \"Pause\",\n prefix = \"graupl-\",\n key = null,\n initialize = false,\n }) {\n // Set DOM elements.\n this._dom.carousel = carouselElement;\n\n // Set query selectors.\n this._selectors.carouselItems = carouselItemSelector;\n this._selectors.carouselItemContainer = carouselItemContainerSelector;\n this._selectors.carouselControls = carouselControlSelector;\n this._selectors.carouselControlContainer = carouselControlContainerSelector;\n this._selectors.carouselTabs = carouselTabSelector;\n this._selectors.carouselTabContainer = carouselTabContainerSelector;\n this._selectors.autoplay = autoplaySelector;\n this._selectors.next = nextSelector;\n this._selectors.previous = previousSelector;\n\n // Set class names.\n this._activeClass = activeClass || \"\";\n this._previousClass = previousClass || \"\";\n this._nextClass = nextClass || \"\";\n this._playClass = playClass || \"\";\n this._pauseClass = pauseClass || \"\";\n\n // Set flags.\n this._autoplay = autoplay;\n\n // Set transition options.\n this._transitionDelay = transitionDelay;\n this._transitionDuration = transitionDuration;\n\n // Set labels.\n this._playText = playText || \"\";\n this._pauseText = pauseText || \"\";\n\n // Set prefix.\n this._prefix = prefix || \"\";\n\n // Set the key.\n this._key = key || \"\";\n\n if (initialize) {\n this.initialize();\n }\n }\n\n /**\n * Initializes the carousel.\n */\n initialize() {\n try {\n if (!this._validate()) {\n throw new Error(\n `Graupl Carousel: cannot initialize carousel. The following errors have been found:\\n - ${this.errors.join(\n \"\\n - \"\n )}`\n );\n }\n\n // Set up the DOM.\n this._generateKey();\n this._setDOMElements();\n this._setIds();\n this._setAriaAttributes();\n\n // Activate the first item.\n this.activateFirstItem();\n\n // Handle events.\n this._handleAutoplay();\n this._handleFocus();\n this._handleClick();\n this._handleHover();\n this._handleKeydown();\n this._handleKeyup();\n\n // Set the custom props.\n this._setTransitionDuration();\n\n // Set up the storage.\n storage.initializeStorage(\"carousels\");\n storage.pushToStorage(\"carousels\", this.dom.carousel.id, this);\n } catch (error) {\n console.error(error);\n }\n }\n\n /**\n * The HTML elements for the carousel in the DOM.\n *\n * @readonly\n *\n * @type {Object<HTMLElement>}\n *\n * @see _dom\n */\n get dom() {\n return this._dom;\n }\n\n /**\n * The query selectors used by the carousel to populate the dom.\n *\n * @readonly\n *\n * @type {Object<string>}\n *\n * @see _selectors\n */\n get selectors() {\n return this._selectors;\n }\n\n /**\n * The class(es) to apply when a carousel item is active.\n *\n * @type {string|string[]}\n *\n * @see _activeClass\n */\n get activeClass() {\n return this._activeClass;\n }\n\n /**\n * The class(es) to apply to a carousel item that is the next active item.\n *\n * @type {string|string[]}\n *\n * @see _previousClass\n */\n get previousClass() {\n return this._previousClass;\n }\n\n /**\n * The class(es) to apply to a carousel item that is the next active item.\n *\n * @type {string|string[]}\n *\n * @see _nextClass\n */\n get nextClass() {\n return this._nextClass;\n }\n\n /**\n * The class(es) to apply to the autoplay button when the carousel is paused.\n *\n * @type {string|string[]}\n *\n * @see _playClass\n */\n get playClass() {\n return this._playClass;\n }\n\n /**\n * The class(es) to apply to the autoplay button when the carousel is playing.\n *\n * @type {string|string[]}\n *\n * @see _pauseClass\n */\n get pauseClass() {\n return this._pauseClass;\n }\n\n /**\n * The index of the currently active carousel item.\n *\n * @type {number}\n *\n * @see _currentItem\n */\n get currentItem() {\n return this._currentItem;\n }\n\n /**\n * The currently active carousel item.\n *\n * @readonly\n *\n * @type {HTMLElement}\n */\n get currentCarouselItem() {\n return this.dom.carouselItems[this.currentItem];\n }\n\n /**\n * The currently active carousel tab.\n *\n * @readonly\n *\n * @type {HTMLElement}\n */\n get currentCarouselTab() {\n return this.dom.carouselTabs[this.currentItem];\n }\n\n /**\n * A flag to indicate if the carousel is currently playing.\n *\n * @type {boolean}\n *\n * @see _autoplay\n */\n get autoplay() {\n return this._autoplay;\n }\n\n /**\n * The delay in milliseconds before transitioning slides.\n *\n * @type {number}\n *\n * @see _transitionDelay\n */\n get transitionDelay() {\n return this._transitionDelay;\n }\n\n /**\n * The duration time (in milliseconds) for the transition between carousel items.\n *\n * @type {number}\n *\n * @see _transitionDuration\n */\n get transitionDuration() {\n return this._transitionDuration;\n }\n\n /**\n * The label for the autoplay button when the carousel is paused.\n *\n * @type {string}\n *\n * @see _playText\n */\n get playText() {\n return this._playText;\n }\n\n /**\n * The label for the autoplay button when the carousel is playing.\n *\n * @type {string}\n *\n * @see _pauseText\n */\n get pauseText() {\n return this._pauseText;\n }\n\n /**\n * The prefix to use for CSS custom properties.\n *\n * @type {string}\n *\n * @see _prefix\n */\n get prefix() {\n return this._prefix;\n }\n\n /**\n * The key used to generate IDs throughout the accordion.\n *\n * @type {string}\n *\n * @see _key\n */\n get key() {\n return this._key;\n }\n\n /**\n * The current action being performed by the carousel.\n *\n * @type {string}\n *\n * @see _currentAction\n */\n get currentAction() {\n return this._currentAction;\n }\n\n /**\n * An array of error messages generated by the carousel.\n *\n * @readonly\n *\n * @type {string[]}\n *\n * @see _errors\n */\n get errors() {\n return this._errors;\n }\n\n set currentItem(value) {\n isValidType(\"number\", { value });\n\n if (value === this.currentItem) {\n return;\n }\n\n if (value < 0) {\n this._currentItem = 0;\n } else if (value >= this.dom.carouselItems.length) {\n this._currentItem = this.dom.carouselItems.length - 1;\n } else {\n this._currentItem = value;\n }\n\n // Keep the aria selected in sync with the current item.\n const tabs = this._dom.carousel.querySelectorAll(\n this.selectors.carouselTab\n );\n if (tabs) {\n this.dom.carouselItems.forEach((item, index) => {\n item.setAttribute(\"aria-selected\", index === this._currentItem);\n });\n }\n }\n\n set autoplay(value) {\n isValidType(\"boolean\", { value });\n\n if (this._autoplay !== value) {\n this._autoplay = value;\n }\n }\n\n set activeClass(value) {\n isValidClassList({ activeClass: value });\n\n if (this._activeClass !== value) {\n this._activeClass = value;\n }\n }\n\n set previousClass(value) {\n isValidClassList({ previousClass: value });\n\n if (this._previousClass !== value) {\n this._previousClass = value;\n }\n }\n\n set nextClass(value) {\n isValidClassList({ nextClass: value });\n\n if (this._nextClass !== value) {\n this._nextClass = value;\n }\n }\n\n set playClass(value) {\n isValidClassList({ playClass: value });\n\n if (this._playClass !== value) {\n this._playClass = value;\n }\n }\n\n set pauseClass(value) {\n isValidClassList({ pauseClass: value });\n\n if (this._pauseClass !== value) {\n this._pauseClass = value;\n }\n }\n\n set transitionDelay(value) {\n isValidType(\"number\", { value });\n\n if (value !== this.transitionDelay && value >= 0) {\n this._currentItem = value;\n }\n }\n\n set transitionDuration(value) {\n isValidType(\"number\", { value });\n\n if (this._transitionDuration !== value && value >= 0) {\n this._transitionDuration = value;\n this._setTransitionDuration();\n }\n }\n\n set playText(value) {\n isValidType(\"string\", { value });\n\n if (this._playText !== value) {\n this._playText = value;\n }\n }\n\n set pauseText(value) {\n isValidType(\"string\", { value });\n\n if (this._pauseText !== value) {\n this._pauseText = value;\n }\n }\n\n set prefix(value) {\n isValidType(\"string\", { value });\n\n if (this._prefix !== value) {\n this._prefix = value;\n }\n }\n\n set key(value) {\n isValidType(\"string\", { value });\n\n if (this._key !== value) {\n this._key = value;\n }\n }\n\n /**\n * Validates all aspects of the carousel to ensure proper functionality.\n *\n * @protected\n *\n * @return {boolean} - The results of the validation.\n */\n _validate() {\n let check = true;\n\n // HTML element checks.\n const htmlElementChecks = isValidInstance(HTMLElement, {\n carousel: this.dom.carousel,\n });\n\n if (!htmlElementChecks) {\n this._errors.push(htmlElementChecks.message);\n check = false;\n }\n\n // Query selector checks.\n const querySelectorChecks = isQuerySelector({\n carouselItemsSelector: this._selectors.carouselItems,\n carouselItemContainerSelector: this._selectors.carouselItemContainer,\n carouselControlsSelector: this._selectors.carouselControls,\n carouselControlContainerSelector:\n this._selectors.carouselControlContainer,\n carouselTabsSelector: this._selectors.carouselTabs,\n carouselTabContainerSelector: this._selectors.carouselTabContainer,\n autoplaySelector: this._selectors.autoplay,\n nextSelector: this._selectors.next,\n previousSelector: this._selectors.previous,\n });\n\n if (!querySelectorChecks) {\n this._errors.push(querySelectorChecks.message);\n check = false;\n }\n\n // Autoplay checks.\n const autoplayChecks = isValidType(\"boolean\", { autoplay: this.autoplay });\n\n if (!autoplayChecks) {\n this._errors.push(autoplayChecks.message);\n check = false;\n }\n\n // Check delay is a valid value.\n const delayCheck = isValidType(\"number\", {\n transitionDelay: this._transitionDelay,\n });\n\n if (!delayCheck) {\n this._errors.push(delayCheck.message);\n check = false;\n }\n\n // Check duration is a valid value.\n const durationCheck = isValidType(\"number\", {\n transitionDuration: this._transitionDuration,\n });\n\n if (!durationCheck) {\n this._errors.push(durationCheck.message);\n check = false;\n }\n\n // Active class checks.\n if (this._activeClass !== \"\") {\n const activeClassChecks = isValidClassList({\n activeClass: this._activeClass,\n });\n\n if (!activeClassChecks) {\n this._errors.push(activeClassChecks.message);\n check = false;\n }\n }\n\n // Previous class checks.\n if (this._previousClass !== \"\") {\n const previousClassChecks = isValidClassList({\n previousClass: this._previousClass,\n });\n\n if (!previousClassChecks) {\n this._errors.push(previousClassChecks.message);\n check = false;\n }\n }\n\n // Next class checks.\n if (this._nextClass !== \"\") {\n const nextClassChecks = isValidClassList({\n nextClass: this._nextClass,\n });\n\n if (!nextClassChecks) {\n this._errors.push(nextClassChecks.message);\n check = false;\n }\n }\n\n // Play class checks.\n if (this._playClass !== \"\") {\n const playClassChecks = isValidClassList({\n playClass: this._playClass,\n });\n\n if (!playClassChecks) {\n this._errors.push(playClassChecks.message);\n check = false;\n }\n }\n\n // Pause class checks.\n if (this._pauseClass !== \"\") {\n const pauseClassChecks = isValidClassList({\n pauseClass: this._pauseClass,\n });\n\n if (!pauseClassChecks) {\n this._errors.push(pauseClassChecks.message);\n check = false;\n }\n }\n\n // Play text checks.\n if (this._playText !== \"\") {\n const playTextChecks = isValidType(\"string\", {\n playText: this._playText,\n });\n\n if (!playTextChecks) {\n this._errors.push(playTextChecks.message);\n check = false;\n }\n }\n\n // Pause text checks.\n if (this._pauseText !== \"\") {\n const pauseTextChecks = isValidType(\"string\", {\n pauseText: this._pauseText,\n });\n\n if (!pauseTextChecks) {\n this._errors.push(pauseTextChecks.message);\n check = false;\n }\n }\n\n // Prefix checks.\n const prefixChecks = isValidType(\"string\", { prefix: this._prefix });\n\n if (!prefixChecks) {\n this._errors.push(prefixChecks.message);\n check = false;\n }\n\n return check;\n }\n\n /**\n * Sets DOM elements within the carousel.\n *\n * The carousel element _cannot_ be set through this method.\n *\n * @protected\n *\n * @param {string} elementType - The type of element to populate.\n * @param {HTMLElement} [base = this.dom.carousel] - The element used as the base for the querySelector.\n * @param {boolean} [overwrite = true] - A flag to set if the existing elements will be overwritten.\n */\n _setDOMElementType(elementType, base = this.dom.carousel, overwrite = true) {\n if (typeof this.selectors[elementType] === \"string\") {\n if (elementType === \"carousel\") {\n throw new Error(\n `Graupl Carousel: \"${elementType}\" element cannot be set through _setDOMElementType.`\n );\n }\n\n if (base !== this.dom.carousel) isValidInstance(HTMLElement, { base });\n\n if (Array.isArray(this._dom[elementType])) {\n // Get all the elements matching the selector in the base.\n const domElements = Array.from(\n base.querySelectorAll(this.selectors[elementType])\n );\n\n // Filter the elements so only direct children of the base are kept.\n const filteredElements = domElements.filter(\n (item) => item.parentElement === base\n );\n\n if (overwrite) {\n this._dom[elementType] = filteredElements;\n } else {\n this._dom[elementType] = [\n ...this._dom[elementType],\n ...filteredElements,\n ];\n }\n } else {\n // Get the single element matching the selector in the base.\n const domElement = base.querySelector(this.selectors[elementType]);\n\n // Ensure the element is a direct child of the base.\n if (domElement && domElement.parentElement !== base) {\n return;\n }\n\n if (overwrite) {\n this._dom[elementType] = domElement;\n }\n }\n } else {\n throw new Error(\n `Graupl Carousel: \"${elementType}\" is not a valid element type within the carousel.`\n );\n }\n }\n\n /**\n * Resets DOM elements within the menu.\n *\n * The carousel element _cannot_ be reset through this method.\n *\n * @protected\n *\n * @param {string} elementType - The type of element to clear.\n */\n _resetDOMElementType(elementType) {\n if (typeof this.selectors[elementType] === \"string\") {\n if (elementType === \"carousel\") {\n throw new Error(\n `Graupl Carousel: \"${elementType}\" element cannot be reset through _resetDOMElementType.`\n );\n }\n\n if (Array.isArray(this._dom[elementType])) {\n this._dom[elementType] = [];\n } else {\n this._dom[elementType] = null;\n }\n } else {\n throw new Error(\n `Graupl Carousel: \"${elementType}\" is not a valid element type within the carousel.`\n );\n }\n }\n\n /**\n * Sets all DOM elements within the carousel.\n *\n * Utilizes _setDOMElementType and _resetDOMElementType.\n *\n * @protected\n */\n _setDOMElements() {\n this._setDOMElementType(\"carouselItemContainer\");\n this._setDOMElementType(\"carouselControlContainer\");\n this._setDOMElementType(\"carouselTabContainer\");\n\n if (this.dom.carouselItemContainer) {\n this._setDOMElementType(\"carouselItems\", this.dom.carouselItemContainer);\n }\n if (this.dom.carouselControlContainer) {\n this._setDOMElementType(\n \"carouselControls\",\n this.dom.carouselControlContainer\n );\n this._setDOMElementType(\"autoplay\", this.dom.carouselControlContainer);\n this._setDOMElementType(\"next\", this.dom.carouselControlContainer);\n this._setDOMElementType(\"previous\", this.dom.carouselControlContainer);\n }\n\n if (this._dom.carouselTabContainer) {\n this._setDOMElementType(\"carouselTabs\", this.dom.carouselTabContainer);\n }\n }\n\n /**\n * Generates a key for the carousel.\n *\n * @param {boolean} [regenerate = false] - A flag to determine if the key should be regenerated.\n */\n _generateKey(regenerate = false) {\n if (this.key === \"\" || regenerate) {\n this.key = Math.random()\n .toString(36)\n .replace(/[^a-z]+/g, \"\")\n .substring(0, 10);\n }\n }\n\n /**\n * Sets the IDs of the carousel and it's children if they do not already exist.\n *\n * The generated IDs use the key and follow the format:\n * - carousel: `carousel-${key}`\n * - carousel items: `carousel-item-${key}-${index}`\n * - carousel tabs: `carousel-tab-${key}-${index}`\n */\n _setIds() {\n this.dom.carousel.id = this.dom.carousel.id || `carousel-${this.key}`;\n\n this.dom.carouselItems.forEach((item, index) => {\n item.id = item.id || `carousel-item-${this.key}-${index}`;\n });\n\n this.dom.carouselTabs.forEach((tab, index) => {\n tab.id = tab.id || `carousel-tab-${this.key}-${index}`;\n });\n }\n\n /**\n * Sets the aria attributes for the carousel.\n */\n _setAriaAttributes() {\n // Make sure the carousel has a proper role.\n // Sections and role=\"region\" are acceptable in certain cases, so\n // we only need to fallback to role=\"group\" if neither of those are present.\n if (\n !isTag(\"section\", { carousel: this.dom.carousel }) &&\n !this.dom.carousel.getAttribute(\"role\") !== \"region\"\n ) {\n this.dom.carousel.setAttribute(\"role\", \"group\");\n }\n\n // Set the role description for the carousel.\n this._dom.carousel.setAttribute(\"aria-roledescription\", \"carousel\");\n\n if (this.dom.carouselTabContainer) {\n this.dom.carouselTabContainer.setAttribute(\"role\", \"tablist\");\n }\n\n this.dom.carouselTabs.forEach((tab, index) => {\n if (!isTag(\"button\", { tab: tab })) {\n tab.setAttribute(\"role\", \"button\");\n }\n\n tab.setAttribute(\"aria-selected\", index === 0);\n tab.setAttribute(\"aria-controls\", this.dom.carouselItems[index].id);\n });\n }\n\n /**\n * Sets the interval for autoplaying the carousel.\n *\n * @protected\n */\n _setInterval() {\n this._clearInterval();\n\n this._autoplayInterval = setInterval(() => {\n this.activateNextItem();\n }, this.transitionDelay);\n }\n\n /**\n * Clears the interval for autoplaying the carousel.\n *\n * @protected\n */\n _clearInterval() {\n clearInterval(this._autoplayInterval);\n }\n\n /**\n * Handles the autoplay functionality of the carousel.\n *\n * - Adds the appropriate class to the autoplay button.\n * - Removes the appropriate class from the autoplay button.\n * - Sets the appropriate aria-label for the autoplay button.\n * - Sets the appropriate aria-live for the carousel.\n * - Sets/clears the interval for autoplaying the carousel.\n *\n * @protected\n */\n _handleAutoplay() {\n if (this.autoplay) {\n addClass(this.pauseClass, this.dom.autoplay);\n removeClass(this.playClass, this.dom.autoplay);\n\n this.dom.autoplay.setAttribute(\"aria-label\", this.pauseText);\n this.dom.carousel.setAttribute(\"aria-live\", \"off\");\n\n this._setInterval();\n } else {\n addClass(this.playClass, this.dom.autoplay);\n removeClass(this.pauseClass, this.dom.autoplay);\n\n this.dom.autoplay.setAttribute(\"aria-label\", this.playText);\n this.dom.carousel.setAttribute(\"aria-live\", \"polite\");\n\n this._clearInterval();\n }\n }\n\n /**\n * Handles the focus events throughout the carousel for proper use.\n *\n * - Adds a `focusin` listener to the carousel element to pause autoplay.\n * - Adds a `focusout` listener to the carousel element to resume autoplay.\n */\n _handleFocus() {\n // Pause autoplay when anything in the carousel is focused.\n this.dom.carousel.addEventListener(\"focusin\", () => {\n if (this.autoplay) {\n this._clearInterval();\n }\n });\n\n this.dom.carousel.addEventListener(\"focusout\", () => {\n if (this.autoplay) {\n this._setInterval();\n }\n });\n }\n\n /**\n * Handles the click events throughout the carousel.\n *\n * - Adds a `pointerup` listener to the next control to activate the next item.\n * - Adds a `pointerup` listener to the previous control to activate the previous item.\n * - Adds a `pointerup` listener to the autoplay control to toggle autoplay.\n * - Adds a `pointerup` listener to each tab control to activate the corresponding item.\n */\n _handleClick() {\n this.dom.next.addEventListener(\"pointerup\", () => {\n this.activateNextItem();\n });\n\n this.dom.previous.addEventListener(\"pointerup\", () => {\n this.activatePreviousItem();\n });\n\n this.dom.autoplay.addEventListener(\"pointerup\", () => {\n this.toggleAutoplay();\n });\n\n this.dom.carouselTabs.forEach((tab, index) => {\n tab.addEventListener(\"pointerup\", () => {\n if (this.currentItem > index) {\n this._currentAction = \"previous\";\n } else {\n this._currentAction = \"next\";\n }\n\n this.activateItem(index);\n });\n });\n }\n\n /**\n * Handles the hover events throughout the carousel for proper use.\n *\n * - Adds a `pointerover` listener to the carousel to pause autoplay.\n * - Adds a `pointerleave` listener to the carousel to resume autoplay.\n */\n _handleHover() {\n // Pause autoplay when anything in the carousel is hovered.\n this.dom.carousel.addEventListener(\"pointerover\", () => {\n if (this.autoplay) {\n this._clearInterval();\n }\n });\n\n this.dom.carousel.addEventListener(\"pointerleave\", () => {\n if (this.autoplay) {\n this._setInterval();\n }\n });\n }\n\n /**\n * Handles keydown events throughout the carousel item for proper use.\n *\n * - Adds a `keydown` listener to all control elements.\n * - Prevents Space and Enter key events.\n * - Adds a `keydown` listener to all tab elements.\n * - Prevents Space and Enter key events.\n */\n _handleKeydown() {\n this.dom.carouselControls.forEach((control) => {\n control.addEventListener(\"keydown\", (event) => {\n const key = keyPress(event);\n\n switch (key) {\n case \"Space\":\n case \"Enter\":\n // Prevent the default action of the event.\n preventEvent(event);\n\n break;\n }\n });\n });\n\n this.dom.carouselTabs.forEach((tab) => {\n tab.addEventListener(\"keydown\", (event) => {\n const key = keyPress(event);\n\n switch (key) {\n case \"Space\":\n case \"Enter\":\n // Prevent the default action of the event.\n preventEvent(event);\n\n break;\n }\n });\n });\n }\n\n /**\n * Handles keyup events throughout the carousel item for proper use.\n *\n * - Adds a `keyup` listener to all control elements.\n * - Activates the next/previous item depending on which control is pressed.\n * - Toggles autoplay if the autoplay control is pressed.\n *\n */\n _handleKeyup() {\n // Activate the next item if the space or enter key on the next control.\n this.dom.next.addEventListener(\"keyup\", (event) => {\n const key = keyPress(event);\n\n switch (key) {\n case \"Space\":\n case \"Enter\":\n this.activateNextItem();\n\n // Prevent the default action of the event.\n preventEvent(event);\n\n break;\n }\n });\n\n // Activate the previous item if the space or enter key on the previous control.\n this.dom.previous.addEventListener(\"keyup\", (event) => {\n const key = keyPress(event);\n\n switch (key) {\n case \"Space\":\n case \"Enter\":\n this.activatePreviousItem();\n\n // Prevent the default action of the event.\n preventEvent(event);\n\n break;\n }\n });\n\n // Toggle autoplay if the space or enter key on the autoplay control.\n this.dom.autoplay.addEventListener(\"keyup\", (event) => {\n const key = keyPress(event);\n\n switch (key) {\n case \"Space\":\n case \"Enter\":\n this.toggleAutoplay();\n\n // Prevent the default action of the event.\n preventEvent(event);\n\n break;\n }\n });\n\n // Activate the item if the space or enter key on the tab control.\n this.dom.carouselTabs.forEach((tab, index) => {\n tab.addEventListener(\"keyup\", (event) => {\n const key = keyPress(event);\n\n switch (key) {\n case \"Space\":\n case \"Enter\":\n this.activateItem(index);\n\n // Prevent the default action of the event.\n preventEvent(event);\n\n break;\n }\n });\n });\n }\n\n /**\n * Sets the transition duration for the carousel as a CSS custom property.\n *\n * The custom property is set as `--graupl-carousel-transition-duration`.\n *\n * @protected\n */\n _setTransitionDuration() {\n this.dom.carousel.style.setProperty(\n `--${this.prefix}carousel-transition-duration`,\n `${this.transitionDuration}ms`\n );\n }\n\n /**\n * Activates the current carousel item.\n *\n * @public\n */\n activateCurrentItem() {\n addClass(this.activeClass, this.currentCarouselItem);\n\n if (this.currentCarouselTab) {\n this.currentCarouselTab.setAttribute(\"aria-selected\", true);\n addClass(this.activeClass, this.currentCarouselTab);\n }\n }\n\n /**\n * Deactivates the current carousel item.\n *\n * @public\n */\n deactivateCurrentItem() {\n removeClass(this.activeClass, this.currentCarouselItem);\n\n if (this.currentCarouselTab) {\n this.currentCarouselTab.setAttribute(\"aria-selected\", false);\n removeClass(this.activeClass, this.currentCarouselTab);\n }\n }\n\n /**\n * Activates the carousel item at a given index.\n *\n * @public\n *\n * @param {number} index - The index of the carousel item to activate.\n */\n activateItem(index) {\n const currentIndex = this.currentItem;\n\n this.dom.carousel.dataset.grauplAction = this._currentAction;\n\n if (this.autoplay) {\n this._clearInterval();\n }\n\n addClass(this.previousClass, this.currentCarouselItem);\n addClass(this.nextClass, this.dom.carouselItems[index]);\n\n requestAnimationFrame(() => {\n this.deactivateCurrentItem();\n this.currentItem = index;\n this.activateCurrentItem();\n\n requestAnimationFrame(() => {\n setTimeout(() => {\n removeClass(this.previousClass, this.dom.carouselItems[currentIndex]);\n removeClass(this.nextClass, this.currentCarouselItem);\n }, this.transitionDuration);\n });\n });\n\n if (this.autoplay) {\n this._setInterval();\n }\n }\n\n /**\n * Activates the first carousel item.\n *\n * @public\n */\n activateFirstItem() {\n this.activateItem(0);\n }\n\n /**\n * Activates the last carousel item.\n *\n * @public\n */\n activateLastItem() {\n this.activateItem(this.dom.carouselItems.length - 1);\n }\n\n /**\n * Activates the next carousel item.\n *\n * @public\n */\n activateNextItem() {\n this._currentAction = \"next\";\n\n if (this.currentItem + 1 >= this.dom.carouselItems.length) {\n this.activateFirstItem();\n } else {\n this.activateItem(this.currentItem + 1);\n }\n }\n\n /**\n * Activates the previous carousel item.\n *\n * @public\n */\n activatePreviousItem() {\n this._currentAction = \"previous\";\n\n if (this.currentItem - 1 < 0) {\n this.activateLastItem();\n } else {\n this.activateItem(this.currentItem - 1);\n }\n }\n\n /**\n * Toggles autoplay on the carousel.\n *\n * @public\n */\n toggleAutoplay() {\n this.autoplay = !this.autoplay;\n\n this._handleAutoplay();\n }\n}\n\nexport default Carousel;\n","/**\n * Mark DOM elements as processed to prevent multiple initializations.\n *\n * @module @drupal/once\n *\n * @example <!-- Use as a module -->\n * <script type=\"module\">\n * import once from 'https://unpkg.com/@drupal/once/src/once.js';\n * const elements = once('my-once-id', 'div');\n * // Initialize elements.\n * elements.forEach(el => el.innerHTML = 'processed');\n * </script>\n *\n * @example <!-- Use as a regular script -->\n * <script src=\"https://unpkg.com/@drupal/once\"></script>\n * <script>\n * const elements = once('my-once-id', 'div');\n * // Initialize elements.\n * elements.forEach(el => el.innerHTML = 'processed');\n * </script>\n * @example <!-- Using a single element as input-->\n * <script src=\"https://unpkg.com/@drupal/once\"></script>\n * <script>\n * // once methods always return an array, to simplify the use with a single\n * // element use destructuring or the shift method.\n * const [myElement] = once('my-once-id', document.body);\n * const myElement = once('my-once-id', document.body).shift();\n * </script>\n */\n\n/**\n * Illegal spaces in ids.\n *\n * @private\n *\n * @type {RegExp}\n */\nconst wsRE = /[\\11\\12\\14\\15\\40]+/;\n\n/**\n * Name of the HTML attribute containing an element's once ids.\n *\n * @private\n *\n * @type {string}\n */\nconst attrName = 'data-once';\n\n/**\n * Shortcut to access the html element.\n *\n * @private\n *\n * @type {HTMLElement}\n */\nconst doc = document;\n\n/**\n * Helper to access element attributes.\n *\n * @private\n *\n * @param {Element} element\n * The Element to access the data-once attribute from.\n * @param {string} op\n * The action to take on the element.\n * @param {string} [value]\n * Optional value for setAttribute.\n *\n * @return {string|undefined|null|boolean}\n * Result of the attribute method.\n */\nfunction attr(element, op, value) {\n return element[`${op}Attribute`](attrName, value);\n}\n\n/**\n * Return the attribute selector.\n *\n * @private\n *\n * @param {string} id\n * The id passed by a call to a once() function.\n *\n * @return {string}\n * The full CSS attribute selector.\n *\n * @throws {TypeError|RangeError}\n */\nfunction attrSelector(id) {\n // Verify the validity of the once id.\n if (typeof id !== 'string') {\n throw new TypeError('once ID must be a string');\n }\n if (id === '' || wsRE.test(id)) {\n throw new RangeError('once ID must not be empty or contain spaces');\n }\n // The id is valid, return the full CSS selector.\n return `[${attrName}~=\"${id}\"]`;\n}\n\n/**\n * Verifies that an item is an instance of Element.\n *\n * This function is used during filtering to ensure only DOM elements are\n * processed. once() makes use of get/setAttribute, which are methods\n * inherited from the Element object, so only of Element can be used.\n *\n * @private\n *\n * @param {*} itemToCheck\n * The item to check.\n *\n * @return {boolean}\n * True if the item is an instance of Element\n *\n * @throws {TypeError}\n */\nfunction checkElement(itemToCheck) {\n if (!(itemToCheck instanceof Element)) {\n throw new TypeError('The element must be an instance of Element');\n }\n return true;\n}\n\n/**\n * Process arguments, query the DOM if necessary.\n *\n * @private\n *\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements.\n * @param {Document|DocumentFragment|Element} [context=document]\n * An element or document object to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * An array with the processed Id and the list of elements to process.\n */\nfunction getElements(selector, context = doc) {\n // Assume selector is an array-like value.\n let elements = selector;\n\n // If selector is null it is most likely because of a call to querySelector\n // that didn't return a result.\n if (selector === null) {\n elements = [];\n }\n // The selector is undefined, error out.\n else if (!selector) {\n throw new TypeError('Selector must not be empty');\n }\n // Context doesn't implement querySelectorAll, error out.\n else if (\n !(\n context instanceof Document ||\n context instanceof DocumentFragment ||\n context instanceof Element\n )\n ) {\n throw new TypeError(\n 'Context must be an object of type \"Document\", \"DocumentFragment\", or \"Element\".',\n );\n }\n // This is a selector, query the elements.\n else if (typeof selector === 'string') {\n elements = context.querySelectorAll(selector);\n }\n // This is a single element.\n else if (selector instanceof Element) {\n elements = [selector];\n }\n\n // Make sure an array is returned and not a NodeList or an Array-like object.\n return Array.prototype.slice.call(elements);\n}\n\n/**\n * A helper for applying DOM changes to a filtered set of elements.\n *\n * This makes it possible to filter items that are not instances of Element,\n * then modify their DOM attributes in a single array traversal.\n *\n * @private\n *\n * @param {string} selector\n * A CSS selector to check against to each element in the array.\n * @param {Array.<Element>} elements\n * A NodeList or array of elements passed by a call to a once() function.\n * @param {function} [apply]\n * An optional function to apply on all matched elements.\n *\n * @return {Array.<Element>}\n * The array of elements that match the CSS selector.\n */\nfunction filterAndModify(selector, elements, apply) {\n return elements.filter((element) => {\n const selected = checkElement(element) && element.matches(selector);\n if (selected && apply) {\n apply(element);\n }\n return selected;\n });\n}\n\n/**\n * Add or remove an item from a list of once values.\n *\n * This function removes duplicates while adding or removing a once id in a\n * single array traversal.\n *\n * @private\n *\n * @param {Element} element\n * A space separated string of once ids from a data-drupal-once attribute.\n * @param {string} [add]\n * The once id to add to the list of values.\n * @param {string} [remove]\n * The once id to remove from the list of values.\n *\n * @return {undefined}\n * Nothing to return this is a callback in a foreach.\n */\nfunction updateAttribute(element, { add, remove }) {\n const result = [];\n if (attr(element, 'has')) {\n attr(element, 'get')\n .trim()\n .split(wsRE)\n .forEach((item) => {\n if (result.indexOf(item) < 0 && item !== remove) {\n result.push(item);\n }\n });\n }\n if (add) {\n result.push(add);\n }\n const attribute = result.join(' ');\n attr(element, attribute === '' ? 'remove' : 'set', attribute);\n}\n\n/**\n * Ensures a JavaScript callback is only executed once on a set of elements.\n *\n * Filters a NodeList or array of elements, removing those already processed\n * by a callback with a given id.\n * This method adds a `data-once` attribute on DOM elements. The value of\n * this attribute identifies if a given callback has been executed on that\n * element.\n *\n * @global\n *\n * @example <caption>Basic usage</caption>\n * const elements = once('my-once-id', '[data-myelement]');\n * @example <caption>Input parameters accepted</caption>\n * // NodeList.\n * once('my-once-id', document.querySelectorAll('[data-myelement]'));\n * // Array or Array-like of Element.\n * once('my-once-id', jQuery('[data-myelement]'));\n * // A CSS selector without a context.\n * once('my-once-id', '[data-myelement]');\n * // A CSS selector with a context.\n * once('my-once-id', '[data-myelement]', document.head);\n * // Single Element.\n * once('my-once-id', document.querySelector('#some-id'));\n * @example <caption>Using a single element</caption>\n * // Once always returns an array, even when passing a single element. Some\n * // forms that can be used to keep code readable.\n * // Destructuring:\n * const [myElement] = once('my-once-id', document.body);\n * // By changing the resulting array, es5 compatible.\n * const myElement = once('my-once-id', document.body).shift();\n *\n * @param {string} id\n * The id of the once call.\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements.\n * @param {Document|DocumentFragment|Element} [context=document]\n * An element or document object to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * An array of elements that have not yet been processed by a once call\n * with a given id.\n */\nfunction once(id, selector, context) {\n return filterAndModify(\n `:not(${attrSelector(id)})`,\n getElements(selector, context),\n (element) => updateAttribute(element, { add: id }),\n );\n}\n\n/**\n * Removes a once id from an element's data-drupal-once attribute value.\n *\n * If a once id is removed from an element's data-drupal-once attribute value,\n * the JavaScript callback associated with that id can be executed on that\n * element again.\n *\n * @method once.remove\n *\n * @example <caption>Basic usage</caption>\n * const elements = once.remove('my-once-id', '[data-myelement]');\n * @example <caption>Input parameters accepted</caption>\n * // NodeList.\n * once.remove('my-once-id', document.querySelectorAll('[data-myelement]'));\n * // Array or Array-like of Element.\n * once.remove('my-once-id', jQuery('[data-myelement]'));\n * // A CSS selector without a context.\n * once.remove('my-once-id', '[data-myelement]');\n * // A CSS selector with a context.\n * once.remove('my-once-id', '[data-myelement]', document.head);\n * // Single Element.\n * once.remove('my-once-id', document.querySelector('#some-id'));\n *\n * @param {string} id\n * The id of a once call.\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements to remove the once id from.\n * @param {Document|Element} [context=document]\n * An element to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * A filtered array of elements that had been processed by the provided id,\n * and are now able to be processed again.\n */\nonce.remove = (id, selector, context) => {\n return filterAndModify(\n attrSelector(id),\n getElements(selector, context),\n (element) => updateAttribute(element, { remove: id }),\n );\n};\n\n/**\n * Finds elements that have been processed by a given once id.\n *\n * Behaves like {@link once} and {@link once.remove} without changing the DOM.\n * To select all DOM nodes processed by a given id, use {@link once.find}.\n *\n * @method once.filter\n *\n * @example <caption>Basic usage</caption>\n * const filteredElements = once.filter('my-once-id', '[data-myelement]');\n * @example <caption>Input parameters accepted</caption>\n * // NodeList.\n * once.filter('my-once-id', document.querySelectorAll('[data-myelement]'));\n * // Array or Array-like of Element.\n * once.filter('my-once-id', jQuery('[data-myelement]'));\n * // A CSS selector without a context.\n * once.filter('my-once-id', '[data-myelement]');\n * // A CSS selector with a context.\n * once.filter('my-once-id', '[data-myelement]', document.head);\n * // Single Element.\n * once.filter('my-once-id', document.querySelector('#some-id'));\n *\n * @param {string} id\n * The id of the once call.\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements to remove the once id from.\n * @param {Document|Element} [context=document]\n * An element to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * A filtered array of elements that have already been processed by the\n * provided once id.\n */\nonce.filter = (id, selector, context) =>\n filterAndModify(attrSelector(id), getElements(selector, context));\n\n/**\n * Finds elements that have been processed by a given once id.\n *\n * Query the 'context' element for elements that already have the\n * corresponding once id value.\n *\n * @method once.find\n *\n * @example <caption>Basic usage</caption>\n * const oncedElements = once.find('my-once-id');\n * @example <caption>Input parameters accepted</caption>\n * // Call without parameters, return all elements with a `data-once` attribute.\n * once.find();\n * // Call without a context.\n * once.find('my-once-id');\n * // Call with a context.\n * once.find('my-once-id', document.head);\n *\n * @param {string} [id]\n * The id of the once call.\n * @param {Document|DocumentFragment|Element} [context=document]\n * Scope of the search for matching elements.\n *\n * @return {Array.<Element>}\n * A filtered array of elements that have already been processed by the\n * provided once id.\n */\nonce.find = (id, context) =>\n getElements(!id ? `[${attrName}]` : attrSelector(id), context);\n\nexport default once;\n","import Carousel from \"./Carousel.js\";\nimport once from \"@drupal/once\";\n\nconst generate = (\n options = {},\n context = document,\n carouselSelector = \".carousel\"\n) => {\n once(\"graupl-carousel-generator\", carouselSelector, context).forEach(\n (carouselElement) => {\n const carouselOptions = carouselElement.dataset.grauplCarouselOptions\n ? JSON.parse(\n carouselElement.dataset.grauplCarouselOptions.replace(/'/g, '\"')\n ) || {}\n : {};\n\n new Carousel({\n carouselElement,\n initialize: true,\n ...options,\n ...carouselOptions,\n });\n }\n );\n};\n\nexport default generate;\n"],"x_google_ignoreList":[5],"mappings":"kCAMA,SAAgBmG,EAASlG,EAAWwQ,EAAS,CAEvCxQ,IAAc,IAAMA,EAAU4L,SAAW,IAIzC,OAAO5L,GAAc,SACvBwQ,EAAQrQ,UAAUiS,IAAIpS,CAAAA,EAEtBwQ,EAAQrQ,UAAUiS,IAAI,GAAGpS,CAAAA,GAU7B,SAAgBmG,EAAYnG,EAAWwQ,EAAS,CAE1CxQ,IAAc,IAAMA,EAAU4L,SAAW,IAIzC,OAAO5L,GAAc,SACvBwQ,EAAQrQ,UAAUkS,OAAOrS,CAAAA,EAEzBwQ,EAAQrQ,UAAUkS,OAAO,GAAGrS,CAAAA,GC5BhC,SAAgBqG,EAASmJ,EAAO,CAC9B,GAAI,CAEF,MAAM1F,EAAM0F,EAAM1F,KAAO0F,EAAM5N,QACzBC,EAAO,CACXC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AAgBE,QAAQC,sBAAsBG,QAAQ,KAAM,GAAA,CAC9D,GAAK,CAAA,EACL,CAAA,EAEJ,IAAId,EAAS,CACXQ,gBAAAA,EACAO,WAAY,GACZ,GAAGZ,EACH,GAAGM,EACJ"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
function y(t,e){try{if(typeof e!="object"){const s=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${s}" given.`)}for(const s in e)if(!(e[s]instanceof t)){const i=typeof e[s];throw new TypeError(`${s} must be an instance of ${t.name}. "${i}" given.`)}return{status:!0,error:null}}catch(s){return{status:!1,error:s}}}function o(t,e){try{if(typeof e!="object"){const s=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${s}" given.`)}for(const s in e){const i=typeof e[s];if(i!==t)throw new TypeError(`${s} must be a ${t}. "${i}" given.`)}return{status:!0,error:null}}catch(s){return{status:!1,error:s}}}function A(t){try{if(typeof t!="object"){const e=typeof t;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in t)try{if(t[e]===null)throw new Error;document.querySelector(t[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${t[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function d(t){try{if(typeof t!="object"||Array.isArray(t)){const e=typeof t;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in t){const s=typeof t[e];if(s!=="string")if(Array.isArray(t[e]))t[e].forEach(i=>{if(typeof i!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${s}" given.`);else{const i={};i[e]=t[e],A(i)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function L(t,e){if(o("string",{tagName:t}).status&&y(HTMLElement,e).status){const s=t.toLowerCase();let i=!0;for(const r in e)e[r].tagName.toLowerCase()!==s&&(i=!1);return i}else return!1}function j(t){try{if(typeof t!="object"){const s=typeof t;throw new TypeError(`Values given to isValidState() must be inside of an object. "${s}" given.`)}const e=["none","self","child"];for(const s in t)if(!e.includes(t[s]))throw new TypeError(`${s} must be one of the following values: ${e.join(", ")}. "${t[s]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(t){try{if(typeof t!="object"){const s=typeof t;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${s}" given.`)}const e=["none","mouse","keyboard","character"];for(const s in t)if(!e.includes(t[s]))throw new TypeError(`${s} must be one of the following values: ${e.join(", ")}. "${t[s]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function u(t,e){t===""||t.length===0||(typeof t=="string"?e.classList.add(t):e.classList.add(...t))}function h(t,e){t===""||t.length===0||(typeof t=="string"?e.classList.remove(t):e.classList.remove(...t))}function p(t){try{const e=t.key||t.keyCode,s={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Tab:e==="Tab"||e===9};return Object.keys(s).find(i=>s[i]===!0)||""}catch{return""}}function f(t){t.preventDefault(),t.stopPropagation()}function G(t=null){window.Graupl=window.Graupl||{},o("string",{type:t})&&(window.Graupl[t]=window.Graupl[t]||{})}function F(t=null){return o("string",{type:t})?window.Graupl[t]:window.Graupl}function V(t,e={}){o("string",{type:t})&&o("object",{data:e})&&(window.Graupl[t]=e)}function B(t){o("string",{type:t})&&(window.Graupl[t]={})}function M(t,e,s){o("string",{type:t,key:e})&&(window.Graupl[t][e]=s)}function W(t,e){return o("string",{type:t,key:e})?window.Graupl[t][e]:null}function R(t,e){o("string",{type:t,key:e})&&delete window.Graupl[t][e]}var w={initializeStorage:G,getStorage:F,setStorage:V,clearStorage:B,pushToStorage:M,getFromStorage:W,removeFromStorage:R},I=class{constructor(t,e={}){this._equals=e.equals||Object.is,this._current=t,this._committed=t}get value(){return this._current}set value(t){this._current=t}get committed(){return this._committed}get isDirty(){return!this._equals(this._current,this._committed)}commit(){return this._committed=this._current,this}reset(){return this._current=this._committed,this}update(t){return this._current=t(this._current),this}},K=class{_dom={controller:null,disclosure:null,content:null};_domLock=["controller","disclosure"];_selectors={content:""};_classes={open:"show",close:"hide",transition:"transitioning",initialize:"initializing"};_durations={transition:5e3,open:-1,close:-1};_focusState="none";_currentEvent="none";_open=new I(!1);_shouldOpen=!1;_closeOnBlur=!1;_breakpointWidth=-1;_observer=null;_expandEvent=new CustomEvent("grauplDisclosureExpand",{bubbles:!0,detail:{disclosure:this}});_collapseEvent=new CustomEvent("grauplDisclosureCollapse",{bubbles:!0,detail:{disclosure:this}});_prefix="graupl-";_errors=[];constructor({disclosureElement:t,controllerElement:e,disclosureContentSelector:s=".disclosure-content",openClass:i="show",closeClass:r="hide",transitionClass:n="transitioning",transitionDuration:a=250,openDuration:c=-1,closeDuration:l=-1,closeOnBlur:S=!1,minWidth:O=-1,autoOpen:v=!1,prefix:T="graupl-",initializeClass:x="initializing",initialize:z=!1}){this._dom.disclosure=t,this._dom.controller=e,this._selectors.content=s,this._classes.open=i||"",this._classes.close=r||"",this._classes.transition=n||"",this._classes.initialize=x||"",this._durations.transition=a,this._durations.open=c,this._durations.close=l,this._closeOnBlur=S,this._breakpointWidth=O,this._shouldOpen=v,this._prefix=T,z&&this.initialize()}initialize(){try{if(!this._validate())throw new Error(`Graupl Disclosure: cannot initialize disclosure. The following errors have been found:
|
|
2
|
+
- ${this.errors.join(`
|
|
3
|
+
- `)}`);u(this._classes.initialize,this.dom.disclosure),this._generateKey(),this._setDOMElements(),this._setIds(),this._setAriaAttributes(),this._handleFocus(),this._handleClick(),this._handleKeydown(),this._handleKeyup(),this._handleResize(),this._setTransitionDurations(),w.initializeStorage("disclosures"),w.initializeStorage("disclosures"),w.pushToStorage("disclosures",this.dom.disclosure.id,this),this.dom.controller.getAttribute("aria-expanded")==="true"||this.shouldOpen&&window.matchMedia(this.openQuery).matches?this._expand(!1,!1):this._collapse(!1,!1),requestAnimationFrame(()=>{h(this._classes.initialize,this.dom.disclosure)})}catch(t){console.error(t)}}get dom(){return this._dom}get selectors(){return this._selectors}get openClass(){return this._classes.open}set openClass(t){d({openClass:t}),this._classes.open!==t&&(this._classes.open=t)}get closeClass(){return this._classes.close}set closeClass(t){d({closeClass:t}),this._classes.close!==t&&(this._classes.close=t)}get transitionClass(){return this._classes.transition}set transitionClass(t){d({transitionClass:t}),this._classes.transition!==t&&(this._classes.transition=t)}get initializeClass(){return this._classes.initialize}set initializeClass(t){d({initializeClass:t}),this._classes.initialize!==t&&(this._classes.initialize=t)}get transitionDuration(){return this._durations.transition}set transitionDuration(t){o("number",{value:t}),this._durations.transition!==t&&(this._durations.transition=t,this._setTransitionDurations())}get openDuration(){return this._durations.open===-1?this.transitionDuration:this._durations.open}set openDuration(t){o("number",{value:t}),this._durations.open!==t&&(this._durations.open=t,this._setTransitionDurations())}get closeDuration(){return this._durations.close===-1?this.transitionDuration:this._durations.close}set closeDuration(t){o("number",{value:t}),this._durations.close!==t&&(this._durations.close=t,this._setTransitionDurations())}get minWidth(){return this._breakpointWidth}set minWidth(t){o("number",{value:t}),this._breakpointWidth!==t&&(this._breakpointWidth=t)}get closeOnBlur(){return this._closeOnBlur}set closeOnBlur(t){o("boolean",{value:t}),this._closeOnBlur!==t&&(this._closeOnBlur=t)}get focusState(){return this._focusState}set focusState(t){j({value:t}),this._focusState!==t&&(this._focusState=t)}get currentEvent(){return this._currentEvent}set currentEvent(t){q({value:t}),this._currentEvent!==t&&(this._currentEvent=t)}get prefix(){return this._prefix}set prefix(t){o("string",{value:t}),this._prefix!==t&&(this._prefix=t,this._setTransitionDurations())}get isOpen(){return this._open.value}get hasOpened(){return this._open.committed}get shouldOpen(){return this._shouldOpen}set shouldOpen(t){o("boolean",{value:t}),this._shouldOpen!==t&&(this._shouldOpen=t)}get openQuery(){return this.minWidth===-1?"":`(width > ${this.minWidth}px)`}get closeQuery(){return this.minWidth===-1?"":`(width <= ${this.minWidth}px)`}get shouldFocus(){let t=!1;return this.currentEvent==="keyboard"&&(t=!0),t}get errors(){return this._errors}_validate(){let t=!0;const e=y(HTMLElement,{disclosureElement:this._dom.disclosure,controllerElement:this._dom.controller});e.status||(this._errors.push(e.error.message),t=!1);const s=A({disclosureContentSelector:this._selectors.content});s.status||(this._errors.push(s.error.message),t=!1);const i={};for(const l of Object.keys(this._classes))this._classes[l]!==""&&(i[`${l}Class`]=this._classes[l]);const r=d(i);r.status||(this._errors.push(r.error.message),t=!1);const n={};for(const l of Object.keys(this._durations))n[`${l}Duration`]=this._durations[l];const a=o("number",n);a.status||(this._errors.push(a.error.message),t=!1);const c=o("string",{prefix:this._prefix});return c.status||(this._errors.push(c.error.message),t=!1),t}_generateKey(t=!1){(this.key===""||t)&&(this.key=Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,10))}_setIds(){this.dom.disclosure.id=this.dom.disclosure.id||`disclosure-${this.key}`,this.dom.controller.id=this.dom.controller.id||`disclosure-controller-${this.key}`}_setAriaAttributes(){this.dom.controller.getAttribute("aria-expanded")!=="true"&&this.dom.controller.setAttribute("aria-expanded","false"),this.dom.controller.setAttribute("aria-controls",this.dom.disclosure.id),L("button",{controller:this.dom.controller})||this.dom.controller.setAttribute("role","button")}_setTransitionDurations(){this.dom.disclosure.style.setProperty(`--${this.prefix}disclosure-transition-duration`,`${this.transitionDuration}ms`),this.dom.disclosure.style.setProperty(`--${this.prefix}disclosure-open-transition-duration`,`${this.openDuration}ms`),this.dom.disclosure.style.setProperty(`--${this.prefix}disclosure-close-transition-duration`,`${this.closeDuration}ms`)}_setDOMElementType(t,{base:e=this.dom.disclosure,overwrite:s=!0,strict:i=!0}={}){if(typeof this.selectors[t]=="string"){if(this._domLock.includes(t))throw new Error(`Graupl ${this.constructor.name}: "${t}" element cannot be set through _setDOMElementType.`);e!==this.dom.disclosure&&y(HTMLElement,{base:e});const r=Array.from(e.querySelectorAll(this.selectors[t])).filter(n=>i?n.parentElement===e:!0);s?Array.isArray(this._dom[t])?this._dom[t]=r:this._dom[t]=r[0]||null:Array.isArray(this._dom[t])?this._dom[t]=[...this._dom[t],...r]:this._dom[t]=r[0]||null}else throw new Error(`Graupl ${this.constructor.name}: "${t}" is not a valid element type.`)}_resetDOMElementType(t){if(typeof this.selectors[t]=="string"){if(this._domLock.includes(t))throw new Error(`Graupl ${this.constructor.name}: "${t}" element cannot be reset through _resetDOMElementType.`);Array.isArray(this._dom[t])?this._dom[t]=[]:this._dom[t]=null}else throw new Error(`Graupl ${this.constructor.name}: "${t}" is not a valid element type.`)}_setDOMElements(){this._resetDOMElementType("content"),this._setDOMElementType("content")}_expand(t=!0,e=!0){this.dom.controller.setAttribute("aria-expanded","true"),e&&this.transitionlass!==""?(u(this.transitionClass,this.dom.disclosure),requestAnimationFrame(()=>{h(this.closeClass,this.dom.disclosure),requestAnimationFrame(()=>{u(this.openClass,this.dom.disclosure),requestAnimationFrame(()=>{setTimeout(()=>{h(this.transitionClass,this.dom.disclosure)},this.openDuration)})})})):(u(this.openClass,this.dom.disclosure),h(this.closeClass,this.dom.disclosure)),this.dom.content.removeAttribute("inert"),t&&this.dom.controller.dispatchEvent(this._expandEvent)}_collapse(t=!0,e=!0){this.dom.controller.setAttribute("aria-expanded","false"),e&&this.transitionClass!==""?(u(this.transitionClass,this.dom.disclosure),requestAnimationFrame(()=>{h(this.openClass,this.dom.disclosure),requestAnimationFrame(()=>{u(this.closeClass,this.dom.disclosure),requestAnimationFrame(()=>{setTimeout(()=>{h(this.transitionClass,this.dom.disclosure),this.dom.content.innert=!0},this.closeDuration)})})})):(u(this.closeClass,this.dom.disclosure),h(this.openClass,this.dom.disclosure)),this.dom.content.setAttribute("inert","true"),t&&this.dom.controller.dispatchEvent(this._collapseEvent)}_handleResize(){if(this._breakpointWidth<=0)return;let t=0;this._observer=new ResizeObserver(e=>{requestAnimationFrame(()=>{for(const s of e){const i=Array.isArray(s.contentBoxSize)?s.contentBoxSize[0]:s.contentBoxSize,r=i&&typeof i.inlineSize=="number"?i.inlineSize:s.contentRect.width;if(typeof r!="number"||t===r)continue;const n=r<=this.minWidth,a=r>this.minWidth;n&&this.isOpen?this.close({preserveState:!0}):a&&!this.isOpen&&(this.hasOpened||this.shouldOpen)&&this.open(),t=r}})}),this._observer.observe(document.body)}_handleFocus(){this.dom.disclosure.addEventListener("focusout",t=>{!this.closeOnBlur||this.currentEvent!=="keyboard"||t.relatedTarget===null||this.dom.disclosure.contains(t.relatedTarget)||this.dom.controller===t.relatedTarget||this.close()})}_handleClick(){this.dom.controller.addEventListener("pointerup",t=>{this.currentEvent="mouse",t.button===0&&(f(t),this.toggle())}),document.addEventListener("pointerup",t=>{this.focusState!=="self"||!this.closeOnBlur||(this.currentEvent="mouse",!this.dom.disclosure.contains(t.target)&&this.dom.controller!==t.target&&this.close())})}_handleKeydown(){this.dom.controller.addEventListener("keydown",t=>{switch(this.currentEvent="keyboard",p(t)){case"Space":case"Enter":f(t);break}}),this.dom.disclosure.addEventListener("keydown",t=>{switch(this.currentEvent="keyboard",p(t)){case"Escape":f(t);break}})}_handleKeyup(){this.dom.controller.addEventListener("keyup",t=>{switch(this.currentEvent="keyboard",p(t)){case"Space":case"Enter":this.toggle(),f(t);break}}),this.dom.disclosure.addEventListener("keyup",t=>{switch(this.currentEvent="keyboard",p(t)){case"Escape":this.close(),f(t);break}})}open({force:t=!1,preserveState:e=!1}={}){this.isOpen&&!t||(this.focusState="self",this._expand(),this._open.value=!0,e||this._open.commit())}preview({force:t=!1,preserveState:e=!1}={}){this.isOpen&&!t||(this.focusState="none",this._expand(),this._open.value=!0,e||this._open.commit())}close({force:t=!1,preserveState:e=!1}={}){!this.isOpen&&!t||(this.focusState="none",this._collapse(),this._open.value=!1,e||this._open.commit())}toggle({force:t=!1,preserveState:e=!1}={}){this.isOpen?this.close({force:t,preserveState:e}):this.open({force:t,preserveState:e})}},P=K;const D=/[\11\12\14\15\40]+/,b="data-once",H=document;function E(t,e,s){return t[`${e}Attribute`](b,s)}function m(t){if(typeof t!="string")throw new TypeError("once ID must be a string");if(t===""||D.test(t))throw new RangeError("once ID must not be empty or contain spaces");return`[${b}~="${t}"]`}function Q(t){if(!(t instanceof Element))throw new TypeError("The element must be an instance of Element");return!0}function _(t,e=H){let s=t;if(t===null)s=[];else if(t)if(e instanceof Document||e instanceof DocumentFragment||e instanceof Element)typeof t=="string"?s=e.querySelectorAll(t):t instanceof Element&&(s=[t]);else throw new TypeError('Context must be an object of type "Document", "DocumentFragment", or "Element".');else throw new TypeError("Selector must not be empty");return Array.prototype.slice.call(s)}function k(t,e,s){return e.filter(i=>{const r=Q(i)&&i.matches(t);return r&&s&&s(i),r})}function C(t,{add:e,remove:s}){const i=[];E(t,"has")&&E(t,"get").trim().split(D).forEach(n=>{i.indexOf(n)<0&&n!==s&&i.push(n)}),e&&i.push(e);const r=i.join(" ");E(t,r===""?"remove":"set",r)}function g(t,e,s){return k(`:not(${m(t)})`,_(e,s),i=>C(i,{add:t}))}g.remove=(t,e,s)=>k(m(t),_(e,s),i=>C(i,{remove:t})),g.filter=(t,e,s)=>k(m(t),_(e,s)),g.find=(t,e)=>_(t?m(t):`[${b}]`,e);var $=g;const U=({options:t={},context:e=document,disclosureSelector:s=".disclosure",controllerSelector:i=".disclosure-toggle"}={})=>{$("graupl-disclosure-generator",s,e).forEach(r=>{const n=r.dataset.grauplDisclosureOptions?JSON.parse(r.dataset.grauplDisclosureOptions.replace(/'/g,'"'))||{}:{},a=`${i}[data-graupl-disclosure-target="${r.id}"]`,[c]=$("graupl-disclosure-generator",a,e);if(!c){console.warn(`No controller found for disclosure with ID "${r.id}". Please ensure there is an element with the selector "${a}".`),$.remove("graupl-disclosure-generator",r);return}new P({disclosureElement:r,controllerElement:c,initialize:!0,...t,...n})})};var J=U;module.exports=J;
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=disclosure.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disclosure.cjs.js","names":["isValidInstance","constructor","elements","elementsType","TypeError","key","elementType","name","status","error","isValidType","type","values","valuesType","valueType","isQuerySelector","Error","document","querySelector","isValidClassList","Array","isArray","forEach","value","obj","isValidHoverType","validTypes","includes","join","isTag","tagName","HTMLElement","tag","toLowerCase","check","isValidState","validStates","isValidEvent","validEvents","addClass","className","element","length","classList","add","removeClass","remove","selectAllFocusableElements","context","document","querySelector","elements","Array","from","querySelectorAll","tabbableElements","filter","check","getAttribute","selectFirstFocusableElement","selectLastFocusableElement","selectNextFocusableElement","index","indexOf","selectPreviousFocusableElement","keyPress","event","key","keyCode","keys","Enter","Space","Escape","ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End","Tab","Object","find","preventEvent","preventDefault","stopPropagation","isValidType","initializeStorage","type","window","Graupl","getStorage","setStorage","data","clearStorage","pushToStorage","key","value","getFromStorage","removeFromStorage","TransactionalValue","constructor","initialValue","options","_equals","equals","Object","is","_current","_committed","value","val","committed","isDirty","commit","reset","update","fn","isValidInstance","isValidClassList","isValidType","isValidState","isValidEvent","isTag","isQuerySelector","addClass","removeClass","keyPress","preventEvent","storage","TransactionalValue","Disclosure","_dom","controller","disclosure","content","_domLock","_selectors","_classes","open","close","transition","initialize","_durations","_focusState","_currentEvent","_open","_shouldOpen","_closeOnBlur","_breakpointWidth","_observer","_expandEvent","CustomEvent","bubbles","detail","_collapseEvent","_prefix","_errors","constructor","disclosureElement","controllerElement","disclosureContentSelector","openClass","closeClass","transitionClass","transitionDuration","openDuration","closeDuration","closeOnBlur","minWidth","autoOpen","prefix","initializeClass","_validate","Error","errors","join","dom","_generateKey","_setDOMElements","_setIds","_setAriaAttributes","_handleFocus","_handleClick","_handleKeydown","_handleKeyup","_handleResize","_setTransitionDurations","initializeStorage","pushToStorage","id","getAttribute","shouldOpen","window","matchMedia","openQuery","matches","_expand","_collapse","requestAnimationFrame","error","console","selectors","value","focusState","currentEvent","isOpen","hasOpened","committed","closeQuery","shouldFocus","check","htmlElementChecks","HTMLElement","status","push","message","querySelectorChecks","classes","className","Object","keys","classListChecks","durations","durationName","durationChecks","prefixCheck","regenerate","key","Math","random","toString","replace","substring","setAttribute","style","setProperty","_setDOMElementType","elementType","base","overwrite","strict","includes","name","domElements","Array","from","querySelectorAll","filteredElements","filter","item","parentElement","isArray","_resetDOMElementType","emit","transitionlass","setTimeout","removeAttribute","dispatchEvent","innert","width","ResizeObserver","entries","entry","boxSize","contentBoxSize","inlineSize","contentRect","belowBreakpoint","aboveBreakpoint","preserveState","observe","document","body","addEventListener","event","relatedTarget","contains","button","toggle","target","force","commit","preview","wsRE","attrName","doc","document","attr","element","op","value","attrSelector","id","TypeError","test","RangeError","checkElement","itemToCheck","Element","getElements","selector","context","elements","Document","DocumentFragment","querySelectorAll","Array","prototype","slice","call","filterAndModify","apply","filter","selected","matches","updateAttribute","add","remove","result","trim","split","forEach","item","indexOf","push","attribute","join","once","find","Disclosure","once","generate","options","context","document","disclosureSelector","controllerSelector","forEach","disclosureElement","disclosureOptions","dataset","grauplDisclosureOptions","JSON","parse","replace","targettedControllerSelector","id","controllerElement","console","warn","remove","initialize"],"sources":["../../../packages/core/src/js/validate.js","../../../packages/core/src/js/domHelpers.js","../../../packages/core/src/js/eventHandlers.js","../../../packages/core/src/js/storage.js","../../../packages/core/src/js/TransactionalValue.js","../../../packages/core/src/js/disclosure/Disclosure.js","../../../node_modules/@drupal/once/src/once.js","../../../packages/core/src/js/disclosure/generator.js"],"sourcesContent":["/**\n * Check to see if the provided elements have a specific constructor.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * This is essentially just a wrapper function around checking instanceof with\n * more descriptive error message to help debugging.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {object} constructor - The constructor to check for.\n * @param {object} elements - The element(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidInstance(constructor, elements) {\n try {\n if (typeof elements !== \"object\") {\n const elementsType = typeof elements;\n\n throw new TypeError(\n `Elements given to isValidInstance() must be inside of an object. \"${elementsType}\" given.`\n );\n }\n\n for (const key in elements) {\n if (!(elements[key] instanceof constructor)) {\n const elementType = typeof elements[key];\n throw new TypeError(\n `${key} must be an instance of ${constructor.name}. \"${elementType}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Check to see if the provided values are of a specific type.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * This is essentially just a wrapper function around checking typeof with\n * more descriptive error message to help debugging.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {string} type - The type to check for.\n * @param {object} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidType(type, values) {\n try {\n if (typeof values !== \"object\") {\n const valuesType = typeof values;\n\n throw new TypeError(\n `Values given to isValidType() must be inside of an object. \"${valuesType}\" given.`\n );\n }\n\n for (const key in values) {\n const valueType = typeof values[key];\n\n if (valueType !== type) {\n throw new TypeError(`${key} must be a ${type}. \"${valueType}\" given.`);\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Checks to see if the provided values are valid query selectors.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isQuerySelector(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isQuerySelector() must be inside of an object. \"${type}\" given.`\n );\n }\n\n for (const key in values) {\n try {\n if (values[key] === null) {\n throw new Error();\n }\n\n document.querySelector(values[key]);\n } catch {\n throw new TypeError(\n `${key} must be a valid query selector. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Checks to see if the provided value is either a string or an array of strings.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string, string[]>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidClassList(values) {\n try {\n if (typeof values !== \"object\" || Array.isArray(values)) {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidClassList() must be inside of an object. \"${type}\" given.`\n );\n }\n\n for (const key in values) {\n const type = typeof values[key];\n\n if (type !== \"string\") {\n if (Array.isArray(values[key])) {\n values[key].forEach((value) => {\n if (typeof value !== \"string\") {\n throw new TypeError(\n `${key} must be a string or an array of strings. An array containing non-strings given.`\n );\n }\n });\n } else {\n throw new TypeError(\n `${key} must be a string or an array of strings. \"${type}\" given.`\n );\n }\n } else {\n const obj = {};\n obj[key] = values[key];\n\n isQuerySelector(obj);\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Check to see if the provided values are valid hover types.\n *\n * Available types are: `\"off\"`, `\"on\"`, and `\"dynamic\"`.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidHoverType(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidHoverType() must be inside of an object. \"${type}\" given.`\n );\n }\n\n const validTypes = [\"off\", \"on\", \"dynamic\"];\n\n for (const key in values) {\n if (!validTypes.includes(values[key])) {\n throw new TypeError(\n `${key} must be one of the following values: ${validTypes.join(\n \", \"\n )}. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Checks to see if the provided elements are using a specific tag.\n *\n * The elements must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `true` if the check is successful.\n *\n * @param {string} tagName - The name of the tag.\n * @param {Object<HTMLElement>} elements - The element(s) to check.\n * @return {boolean} - The result of the check.\n */\nexport function isTag(tagName, elements) {\n if (\n isValidType(\"string\", { tagName }).status &&\n isValidInstance(HTMLElement, elements).status\n ) {\n const tag = tagName.toLowerCase();\n let check = true;\n\n for (const key in elements) {\n if (elements[key].tagName.toLowerCase() !== tag) check = false;\n }\n\n return check;\n } else {\n return false;\n }\n}\n\n/**\n * Check to see if the provided values are valid focus states for a menu.\n *\n * Available states are: `\"none\"`, `\"self\"`, and `\"child\"`.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidState(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidState() must be inside of an object. \"${type}\" given.`\n );\n }\n\n const validStates = [\"none\", \"self\", \"child\"];\n\n for (const key in values) {\n if (!validStates.includes(values[key])) {\n throw new TypeError(\n `${key} must be one of the following values: ${validStates.join(\n \", \"\n )}. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Check to see if the provided values are valid event types for a menu.\n *\n * Available events are: `\"none\"`, `\"mouse\"`, `\"keyboard\"`, and `\"character\"`.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidEvent(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidEvent() must be inside of an object. \"${type}\" given.`\n );\n }\n\n const validEvents = [\"none\", \"mouse\", \"keyboard\", \"character\"];\n\n for (const key in values) {\n if (!validEvents.includes(values[key])) {\n throw new TypeError(\n `${key} must be one of the following values: ${validEvents.join(\n \", \"\n )}. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n","/**\n * Add a class or array of classes to an element.\n *\n * @param {string|string[]} className - The class or classes to add.\n * @param {HTMLElement} element - The element to add the class to.\n */\nexport function addClass(className, element) {\n // Gracefully handle empty strings or arrays.\n if (className === \"\" || className.length === 0) {\n return;\n }\n\n if (typeof className === \"string\") {\n element.classList.add(className);\n } else {\n element.classList.add(...className);\n }\n}\n\n/**\n * Remove a class or array of classes from an element.\n *\n * @param {string|string[]} className - The class or classes to remove.\n * @param {HTMLElement} element - The element to remove the class from.\n */\nexport function removeClass(className, element) {\n // Gracefully handle empty strings or arrays.\n if (className === \"\" || className.length === 0) {\n return;\n }\n\n if (typeof className === \"string\") {\n element.classList.remove(className);\n } else {\n element.classList.remove(...className);\n }\n}\n\n/**\n * Select all focusable elements within a given context.\n *\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @return {HTMLElement[]} - An array of focusable elements.\n */\nexport function selectAllFocusableElements(context = document) {\n const querySelector =\n \"a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),[tabindex]\";\n const elements = Array.from(context.querySelectorAll(querySelector));\n\n const tabbableElements = elements.filter((element) => {\n let check = true;\n\n if (element.getAttribute(\"tabindex\") === \"-1\") check = false;\n\n return check;\n });\n\n return tabbableElements;\n}\n\n/**\n * Select the first focusable element within a given context.\n *\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @return {HTMLElement|boolean} - The first focusable element or false if none found.\n */\nexport function selectFirstFocusableElement(context = document) {\n const tabbableElements = selectAllFocusableElements(context);\n\n return tabbableElements[0] || false;\n}\n\n/**\n * Select the last focusable element within a given context.\n *\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @return {HTMLElement|boolean} - The last focusable element or false if none found.\n */\nexport function selectLastFocusableElement(context = document) {\n const tabbableElements = selectAllFocusableElements(context);\n\n return tabbableElements[tabbableElements.length - 1] || false;\n}\n\n/**\n * Select the next focusable element relative to the given element within a context.\n *\n * @param {HTMLElement} element - The reference element.\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @return {HTMLElement|boolean} - The next focusable element or false if none found.\n */\nexport function selectNextFocusableElement(element, context = document) {\n const tabbableElements = selectAllFocusableElements(context);\n const index = tabbableElements.indexOf(element);\n\n return index === tabbableElements.length - 1\n ? false\n : tabbableElements[index + 1];\n}\n\n/**\n * Select the previous focusable element relative to the given element within a context.\n *\n * @param {HTMLElement} element - The reference element.\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @return {HTMLElement|boolean} - The previous focusable element or false if none found.\n */\nexport function selectPreviousFocusableElement(element, context = document) {\n const tabbableElements = selectAllFocusableElements(context);\n const index = tabbableElements.indexOf(element);\n\n return index === 0 ? false : tabbableElements[index - 1];\n}\n","/**\n * Retrieves the pressed key from an event.\n *\n * @param {KeyboardEvent} event - The keyboard event.\n * @return {string} - The name of the key or an empty string.\n */\nexport function keyPress(event) {\n try {\n // Use event.key or event.keyCode to support older browsers.\n const key = event.key || event.keyCode;\n const keys = {\n Enter: key === \"Enter\" || key === 13,\n Space: key === \" \" || key === \"Spacebar\" || key === 32,\n Escape: key === \"Escape\" || key === \"Esc\" || key === 27,\n ArrowUp: key === \"ArrowUp\" || key === \"Up\" || key === 38,\n ArrowRight: key === \"ArrowRight\" || key === \"Right\" || key === 39,\n ArrowDown: key === \"ArrowDown\" || key === \"Down\" || key === 40,\n ArrowLeft: key === \"ArrowLeft\" || key === \"Left\" || key === 37,\n Home: key === \"Home\" || key === 36,\n End: key === \"End\" || key === 35,\n Tab: key === \"Tab\" || key === 9,\n };\n\n return Object.keys(keys).find((key) => keys[key] === true) || \"\";\n } catch {\n // Return an empty string if something goes wrong.\n return \"\";\n }\n}\n\n/**\n * Stops an event from taking action.\n *\n * @param {Event} event - The event.\n */\nexport function preventEvent(event) {\n event.preventDefault();\n event.stopPropagation();\n}\n","/**\n * @file\n * Provides a system to get and store Graupl data in the browser.\n */\n\nimport { isValidType } from \"./validate.js\";\n\n/**\n * Initializes the storage system.\n *\n * @param {?string} [type = null] - The type of storage to initialize.\n */\nexport function initializeStorage(type = null) {\n window.Graupl = window.Graupl || {};\n\n if (isValidType(\"string\", { type })) {\n window.Graupl[type] = window.Graupl[type] || {};\n }\n}\n\n/**\n * Get the storage object.\n *\n * @param {?string} type - The type of storage to get.\n * @return {object} - The storage object.\n */\nexport function getStorage(type = null) {\n if (isValidType(\"string\", { type })) {\n return window.Graupl[type];\n }\n\n return window.Graupl;\n}\n\n/**\n * Set the storage object of a given type.\n *\n * @param {string} type - The type of storage to set.\n * @param {object} data - The data to set.\n */\nexport function setStorage(type, data = {}) {\n if (isValidType(\"string\", { type }) && isValidType(\"object\", { data })) {\n window.Graupl[type] = data;\n }\n}\n\n/**\n * Clear the storage object of a given type.\n *\n * @param {string} type - The type of storage to clear.\n */\nexport function clearStorage(type) {\n if (isValidType(\"string\", { type })) {\n window.Graupl[type] = {};\n }\n}\n\n/**\n * Push a value to the storage object.\n *\n * @param {string} type - The type of storage to push to.\n * @param {string} key - The key to use for the value.\n * @param {*} value - The value to store.\n */\nexport function pushToStorage(type, key, value) {\n if (isValidType(\"string\", { type, key })) {\n window.Graupl[type][key] = value;\n }\n}\n\n/**\n * Get a value from the storage object.\n *\n * @param {string }type - The type of storage to get from.\n * @param {string }key - The key to get the value from.\n * @return {*} - The value from the storage object.\n */\nexport function getFromStorage(type, key) {\n if (isValidType(\"string\", { type, key })) {\n return window.Graupl[type][key];\n }\n\n return null;\n}\n\n/**\n * Remove a value from the storage object.\n *\n * @param {string} type - The type of storage to remove from.\n * @param {string} key - The key to remove the value from.\n */\nexport function removeFromStorage(type, key) {\n if (isValidType(\"string\", { type, key })) {\n delete window.Graupl[type][key];\n }\n}\n\nexport default {\n initializeStorage,\n getStorage,\n setStorage,\n clearStorage,\n pushToStorage,\n getFromStorage,\n removeFromStorage,\n};\n","/**\n * A utility class that maintains a \"current\" value and a \"committed\" value.\n *\n * Useful when you need to:\n * - Track in-progress edits and revert to the last saved state.\n * - Compare pending and committed states.\n * - Know if a value has changed since last commit.\n *\n * @example\n * // Managing a form field\n * const username = new TransactionalValue(\"Nick\");\n * username.value = \"NickDJM\";\n * if (username.isDirty) {\n * console.log(\"Unsaved changes detected\");\n * username.commit(); // saves the new value\n * }\n *\n * @example\n * // Reverting edits\n * const counter = new TransactionalValue(10);\n * counter.value = 15;\n * counter.reset(); // reverts to 10\n */\nexport class TransactionalValue {\n /**\n * Creates a new TransactionalValue instance.\n *\n * @param {*} initialValue - The starting (and initially committed) value.\n * @param {{ equals?: function(*, *): boolean }} [options] - Optional config.\n * @param {function(*, *): boolean} [options.equals] - Custom equality comparator. Defaults to `Object.is`.\n */\n constructor(initialValue, options = {}) {\n /**\n * A comparator function used to check equality between\n * the current and committed values.\n *\n * @private\n *\n * @type {function(*, *): boolean}\n */\n this._equals = options.equals || Object.is;\n\n /**\n * The current, editable value.\n *\n * @private\n *\n * @type {*}\n */\n this._current = initialValue;\n\n /**\n * The last committed (baseline) value.\n *\n * @private\n *\n * @type {*}\n */\n this._committed = initialValue;\n }\n\n /**\n * Gets the current editable value.\n *\n * @return {*} The current value.\n *\n * @see _current\n */\n get value() {\n return this._current;\n }\n\n /**\n * Sets the current editable value.\n *\n * @param {*} val - The new value.\n */\n set value(val) {\n this._current = val;\n }\n\n /**\n * Gets the last committed (baseline) value.\n *\n * @readonly\n *\n * @return {*} The last committed value.\n *\n * @see _committed\n */\n get committed() {\n return this._committed;\n }\n\n /**\n * Checks whether the current value differs from the committed one.\n *\n * @readonly\n *\n * @return {boolean} `true` if current and committed values differ.\n */\n get isDirty() {\n return !this._equals(this._current, this._committed);\n }\n\n /**\n * Commits the current value, setting it as the new baseline.\n *\n * @return {TransactionalValue} The current instance.\n */\n commit() {\n this._committed = this._current;\n return this;\n }\n\n /**\n * Resets the current value to the committed baseline.\n *\n * @return {TransactionalValue} The current instance.\n */\n reset() {\n this._current = this._committed;\n return this;\n }\n\n /**\n * Applies a functional update to the current value.\n *\n * @param {function(*): *} fn - A function that receives the previous value and returns the new one.\n * @return {TransactionalValue} The current instance.\n *\n * @example\n * const t = new TransactionalValue(1);\n * t.update(n => n + 1); // 2\n */\n update(fn) {\n this._current = fn(this._current);\n return this;\n }\n}\n","/**\n * @file\n * The Disclosure class.\n */\n\nimport {\n isValidInstance,\n isValidClassList,\n isValidType,\n isValidState,\n isValidEvent,\n isTag,\n isQuerySelector,\n} from \"../validate.js\";\nimport { addClass, removeClass } from \"../domHelpers.js\";\nimport { keyPress, preventEvent } from \"../eventHandlers.js\";\nimport storage from \"../storage.js\";\nimport { TransactionalValue } from \"../TransactionalValue.js\";\n\nclass Disclosure {\n /**\n * The DOM elements within the disclosure.\n *\n * @protected\n *\n * @type {Object<HTMLElement>}\n *\n * @property {HTMLElement} controller - The disclosure toggle element.\n * @property {HTMLElement} disclosure - The disclosure element.\n * @property {HTMLElement} content - The disclosure content element.\n */\n _dom = {\n controller: null,\n disclosure: null,\n content: null,\n };\n\n /**\n * The DOM elements within the disclosure that cannot be reset or generated by the disclosure itself.\n *\n * @protected\n *\n * @type {string[]}\n */\n _domLock = [\"controller\", \"disclosure\"];\n\n /**\n * The query selectors used by the disclosure.\n *\n * @protected\n *\n * @type {Object<string>}\n *\n * @property {string} content - The query selector for the disclosure content.\n */\n _selectors = {\n content: \"\",\n };\n\n /**\n * The classes to apply when the disclosure is in various states.\n *\n * @protected\n *\n * @type {Object<string, string[]>}\n *\n * @property {string|string[]} open - The class(es) to apply when the disclosure is open.\n * @property {string|string[]} close - The class(es) to apply when the disclousre is closed.\n * @property {string|string[]} tranistion - The class(es) to apply when the disclosure is transitioning between states.\n * @property {string|string[]} initialize - The class(es) to apply when the disclosure is initializing.\n */\n _classes = {\n open: \"show\",\n close: \"hide\",\n transition: \"transitioning\",\n initialize: \"initializing\",\n };\n\n /**\n * The duration times (in milliseconds) for various things throughout the disclosure.\n *\n * @protected\n *\n * @type {Object<number>}\n *\n * @property {number} transition - The duration time (in milliseconds) for the transition between open and closed states.\n * @property {number} open - The duration time (in milliseconds) for the transition from closed to open states.\n * @property {number} close - The duration time (in milliseconds) for the transition from open to closed states.\n */\n _durations = {\n transition: 5000,\n open: -1,\n close: -1,\n };\n\n /**\n * The current state of the disclosure's focus.\n *\n * @protected\n *\n * @type {string}\n */\n _focusState = \"none\";\n\n /**\n * This last event triggered on the disclosure.\n *\n * @protected\n *\n * @type {string}\n */\n _currentEvent = \"none\";\n\n /**\n * The open state of the disclosure.\n *\n * @protected\n *\n * @type {TransactionalValue<boolean>}\n */\n _open = new TransactionalValue(false);\n\n /**\n * A value to force the disclosure open when the breakpoint width is passed.\n *\n * @protected\n *\n * @type {boolean}\n */\n _shouldOpen = false;\n\n /**\n * Whether or not to close the disclosure when it loses focus in the DOM.\n *\n * @protected\n *\n * @type {boolean}\n */\n _closeOnBlur = false;\n\n /**\n * The width of the screen (in pixels) that the disclosure will automatically open/close itself.\n *\n * @protected\n *\n * @type {number}\n */\n _breakpointWidth = -1;\n\n /**\n * This ResizeObserver for the disclosure.\n *\n * @protected\n *\n * @type {ResizeObserver|null}\n */\n _observer = null;\n\n /**\n * The event that is triggered when the disclosure expands.\n *\n * @protected\n *\n * @event grauplDisclosureExpand\n *\n * @type {CustomEvent}\n *\n * @property {boolean} bubbles - A flag to bubble the event.\n * @property {Object<Disclosure>} details - The details object containing the Disclosure itself.\n */\n _expandEvent = new CustomEvent(\"grauplDisclosureExpand\", {\n bubbles: true,\n detail: { disclosure: this },\n });\n\n /**\n * The event that is triggered when the disclosure collapses.\n *\n * @protected\n *\n * @event grauplDisclosureCollapse\n *\n * @type {CustomEvent}\n *\n * @property {boolean} bubbles - A flag to bubble the event.\n * @property {Object<Disclosure>} details - The details object containing the Disclosure itself.\n */\n _collapseEvent = new CustomEvent(\"grauplDisclosureCollapse\", {\n bubbles: true,\n detail: { disclosure: this },\n });\n\n /**\n * The prefix to use for CSS custom properties.\n *\n * @protected\n *\n * @type {string}\n */\n _prefix = \"graupl-\";\n\n /**\n * An array of error messages generated by the disclosure.\n *\n * @protected\n *\n * @type {string[]}\n */\n _errors = [];\n\n /**\n * Constructs a new `Disclosure`.\n *\n * @param {object} options - The options for generating the disclosure.\n * @param {HTMLElement} options.disclosureElement - The disclosure element in the DOM.\n * @param {HTMLElement} options.controllerElement - The disclosure toggle element in the DOM.\n * @param {string} [options.disclosureContentSelector = .disclosure-content] - The query selector string for the disclosure content.\n * @param {?(string|string[])} [options.openClass = show] - The class to apply when a disclosure is \"open\".\n * @param {?(string|string[])} [options.closeClass = hide] - The class to apply when a disclosure is \"closed\".\n * @param {?(string|string[])} [options.transitionClass = transitioning] - The class to apply when a disclosure is transitioning between \"open\" and \"closed\" states.\n * @param {number} [options.transitionDuration = 250] - The duration of the transition between \"open\" and \"closed\" states (in milliseconds).\n * @param {boolean} [options.openDuration = -1] - The duration of the transition from \"closed\" to \"open\" states (in milliseconds).\n * @param {boolean} [options.closeDuration = -1] - The duration of the transition from \"open\" to \"closed\" states (in milliseconds).\n * @param {boolean} [options.closeOnBlur = false] - Whether to close the disclosure when it loses focus in the dom.\n * @param {boolean} [options.minWidth = -1] - The width of the screen (in pixels) that the disclosure will automatically open/close itself.\n * @param {boolean} [options.autoOpen = false] - Whether to automatically open when above the minWidth.\n * @param {?string} [options.prefix = graupl-] - The prefix to use for CSS custom properties.\n * @param {?(string|string[])} [options.initializeClass = initializing] - The class to apply when a disclosure is initialzing.\n * @param {boolean} [options.initialize = false] - Whether to initialize the disclosure upon construction.\n */\n constructor({\n disclosureElement,\n controllerElement,\n disclosureContentSelector = \".disclosure-content\",\n openClass = \"show\",\n closeClass = \"hide\",\n transitionClass = \"transitioning\",\n transitionDuration = 250,\n openDuration = -1,\n closeDuration = -1,\n closeOnBlur = false,\n minWidth = -1,\n autoOpen = false,\n prefix = \"graupl-\",\n initializeClass = \"initializing\",\n initialize = false,\n }) {\n // Set the DOM elements.\n this._dom.disclosure = disclosureElement;\n this._dom.controller = controllerElement;\n\n // Set the DOM selectors.\n this._selectors.content = disclosureContentSelector;\n\n // Set the classes.\n this._classes.open = openClass || \"\";\n this._classes.close = closeClass || \"\";\n this._classes.transition = transitionClass || \"\";\n this._classes.initialize = initializeClass || \"\";\n\n // Set the transition durations.\n this._durations.transition = transitionDuration;\n this._durations.open = openDuration;\n this._durations.close = closeDuration;\n\n // Set close on blur.\n this._closeOnBlur = closeOnBlur;\n\n // Set collapse width and auto open functionality.\n this._breakpointWidth = minWidth;\n this._shouldOpen = autoOpen;\n\n // Set the prefix.\n this._prefix = prefix;\n\n if (initialize) {\n this.initialize();\n }\n }\n\n /**\n * Initializes the disclosure.\n */\n initialize() {\n try {\n if (!this._validate()) {\n throw new Error(\n `Graupl Disclosure: cannot initialize disclosure. The following errors have been found:\\n - ${this.errors.join(\n \"\\n - \"\n )}`\n );\n }\n\n addClass(this._classes.initialize, this.dom.disclosure);\n\n // Set up the DOM.\n this._generateKey();\n this._setDOMElements();\n this._setIds();\n this._setAriaAttributes();\n\n // Handle events.\n this._handleFocus();\n this._handleClick();\n this._handleKeydown();\n this._handleKeyup();\n this._handleResize();\n\n // Set the custom props.\n this._setTransitionDurations();\n\n // Set up the storage.\n storage.initializeStorage(\"disclosures\");\n storage.initializeStorage(\"disclosures\");\n storage.pushToStorage(\"disclosures\", this.dom.disclosure.id, this);\n\n if (\n this.dom.controller.getAttribute(\"aria-expanded\") === \"true\" ||\n (this.shouldOpen && window.matchMedia(this.openQuery).matches)\n ) {\n this._expand(false, false);\n } else {\n this._collapse(false, false);\n }\n\n requestAnimationFrame(() => {\n removeClass(this._classes.initialize, this.dom.disclosure);\n });\n } catch (error) {\n console.error(error);\n }\n }\n\n /**\n * The DOM elements within the disclosure.\n *\n * @readonly\n *\n * @type {Object<HTMLElement>}\n *\n * @see _dom\n */\n get dom() {\n return this._dom;\n }\n\n /**\n * The query selectors used by the disclosure.\n *\n * @readonly\n *\n * @type {Object<string>}\n *\n * @see _selectors\n */\n get selectors() {\n return this._selectors;\n }\n\n /**\n * The class(es) to apply when the disclosure is open.\n *\n * @type {string|string[]}\n *\n * @see _classes.open\n */\n get openClass() {\n return this._classes.open;\n }\n\n set openClass(value) {\n isValidClassList({ openClass: value });\n\n if (this._classes.open !== value) {\n this._classes.open = value;\n }\n }\n\n /**\n * The class(es) to apply when the disclosure is closed.\n *\n * @type {string|string[]}\n *\n * @see _classes.close\n */\n get closeClass() {\n return this._classes.close;\n }\n\n set closeClass(value) {\n isValidClassList({ closeClass: value });\n\n if (this._classes.close !== value) {\n this._classes.close = value;\n }\n }\n\n /**\n * The class(es) to apply when the disclosure is transitioning between open and closed.\n *\n * @type {string|string[]}\n *\n * @see _classes.transition\n */\n get transitionClass() {\n return this._classes.transition;\n }\n\n set transitionClass(value) {\n isValidClassList({ transitionClass: value });\n\n if (this._classes.transition !== value) {\n this._classes.transition = value;\n }\n }\n\n /**\n * The class(es) to apply to the shelf when the disclosure is initializing.\n *\n * @type {string|string[]}\n *\n * @see _classes\n */\n get initializeClass() {\n return this._classes.initialize;\n }\n\n set initializeClass(value) {\n isValidClassList({ initializeClass: value });\n\n if (this._classes.initialize !== value) {\n this._classes.initialize = value;\n }\n }\n\n /**\n * The duration time (in milliseconds) for the transition between open and closed states.\n *\n * Setting this value will also set the --graupl-transition-duration CSS custom property on the disclosure.\n *\n * @type {number}\n *\n * @see _durations.transition\n */\n get transitionDuration() {\n return this._durations.transition;\n }\n\n set transitionDuration(value) {\n isValidType(\"number\", { value });\n\n if (this._durations.transition !== value) {\n this._durations.transition = value;\n this._setTransitionDurations();\n }\n }\n\n /**\n * The duration time (in milliseconds) for the transition from closed to open states.\n *\n * If openDuration is set to -1, the transitionDuration value will be used instead.\n *\n * Setting this value will also set the --graupl-open-transition-duration CSS custom property on the disclosure.\n *\n * @type {number}\n *\n * @see _durations.open\n */\n get openDuration() {\n if (this._durations.open === -1) return this.transitionDuration;\n\n return this._durations.open;\n }\n\n set openDuration(value) {\n isValidType(\"number\", { value });\n\n if (this._durations.open !== value) {\n this._durations.open = value;\n this._setTransitionDurations();\n }\n }\n\n /**\n * The duration time (in milliseconds) for the transition from open to closed states.\n *\n * If closeDuration is set to -1, the transitionDuration value will be used instead.\n *\n * Setting this value will also set the --graupl-close-transition-duration CSS custom property on the disclosure.\n *\n * @type {number}\n *\n * @see _durations.close\n */\n get closeDuration() {\n if (this._durations.close === -1) return this.transitionDuration;\n\n return this._durations.close;\n }\n\n set closeDuration(value) {\n isValidType(\"number\", { value });\n\n if (this._durations.close !== value) {\n this._durations.close = value;\n this._setTransitionDurations();\n }\n }\n\n /**\n * The width of the screen (in pixels) that the disclosure will automatically open/close itself.\n *\n * @type {number}\n *\n * @see _breakpointWidth\n */\n get minWidth() {\n return this._breakpointWidth;\n }\n\n set minWidth(value) {\n isValidType(\"number\", { value });\n\n if (this._breakpointWidth !== value) {\n this._breakpointWidth = value;\n }\n }\n\n /**\n * Whether to close the disclosure when it loses focus in the DOM.\n *\n * @type {boolean}\n *\n * @see _closeOnBlur\n */\n get closeOnBlur() {\n return this._closeOnBlur;\n }\n\n set closeOnBlur(value) {\n isValidType(\"boolean\", { value });\n\n if (this._closeOnBlur !== value) {\n this._closeOnBlur = value;\n }\n }\n\n /**\n * The current state of the disclosure's focus.\n *\n * @type {string}\n *\n * @see _focusState\n */\n get focusState() {\n return this._focusState;\n }\n\n set focusState(value) {\n isValidState({ value });\n\n if (this._focusState !== value) {\n this._focusState = value;\n }\n }\n\n /**\n * The last event triggered on the disclosure.\n *\n * @type {string}\n *\n * @see _currentEvent\n */\n get currentEvent() {\n return this._currentEvent;\n }\n\n set currentEvent(value) {\n isValidEvent({ value });\n\n if (this._currentEvent !== value) {\n this._currentEvent = value;\n }\n }\n\n /**\n * The prefix to use for CSS custom properties.\n *\n * @type {string}\n *\n * @see _prefix\n */\n get prefix() {\n return this._prefix;\n }\n\n set prefix(value) {\n isValidType(\"string\", { value });\n\n if (this._prefix !== value) {\n this._prefix = value;\n this._setTransitionDurations();\n }\n }\n\n /**\n * The open state of the disclosure.\n *\n * @readonly\n *\n * @type {boolean}\n *\n * @see _open\n */\n get isOpen() {\n return this._open.value;\n }\n\n /**\n * The open state of the disclosure that the user specifically triggered.\n *\n * @readonly\n *\n * @type {boolean}\n *\n * @see _open\n */\n get hasOpened() {\n return this._open.committed;\n }\n\n /**\n * A value to force opening reguardless of user interaction.\n *\n * @type {boolean}\n *\n * @see _shouldOpen\n */\n get shouldOpen() {\n return this._shouldOpen;\n }\n\n set shouldOpen(value) {\n isValidType(\"boolean\", { value });\n\n if (this._shouldOpen !== value) {\n this._shouldOpen = value;\n }\n }\n\n /**\n * A media query for when the disclosure should open.\n *\n * Will return an empty string if no min width is set.\n *\n * @readonly\n *\n * @type {string}\n */\n get openQuery() {\n if (this.minWidth === -1) {\n return \"\";\n }\n\n return `(width > ${this.minWidth}px)`;\n }\n\n /**\n * A media query for when the disclosure should close.\n *\n * Will return an empty string if no min width is set.\n *\n * @readonly\n *\n * @type {string}\n */\n get closeQuery() {\n if (this.minWidth === -1) {\n return \"\";\n }\n\n return `(width <= ${this.minWidth}px)`;\n }\n\n /**\n * A flag to check if the disclosure's focus methods should _actually_ move the focus in the DOM.\n *\n * This will be `false` unless any of the following criteria are met:\n * - The disclosure's current event is \"keyboard\".\n *\n * @readonly\n *\n * @type {boolean}\n */\n get shouldFocus() {\n let check = false;\n\n if (this.currentEvent === \"keyboard\") {\n check = true;\n }\n\n return check;\n }\n\n /**\n * An array of error messages generated by the disclosure.\n *\n * @readonly\n *\n * @type {string[]}\n *\n * @see _errors\n */\n get errors() {\n return this._errors;\n }\n\n /**\n * Validates all aspects on the disclosure to ensure proper functionality.\n *\n * @protected\n *\n * @return {boolean} - The result of the validation.\n */\n _validate() {\n let check = true;\n\n // HTML element checks.\n const htmlElementChecks = isValidInstance(HTMLElement, {\n disclosureElement: this._dom.disclosure,\n controllerElement: this._dom.controller,\n });\n\n if (!htmlElementChecks.status) {\n this._errors.push(htmlElementChecks.error.message);\n check = false;\n }\n\n // Query selector checks.\n const querySelectorChecks = isQuerySelector({\n disclosureContentSelector: this._selectors.content,\n });\n\n if (!querySelectorChecks.status) {\n this._errors.push(querySelectorChecks.error.message);\n check = false;\n }\n\n // Class list checks.\n const classes = {};\n\n for (const className of Object.keys(this._classes)) {\n if (this._classes[className] === \"\") {\n continue;\n }\n\n classes[`${className}Class`] = this._classes[className];\n }\n\n const classListChecks = isValidClassList(classes);\n\n if (!classListChecks.status) {\n this._errors.push(classListChecks.error.message);\n check = false;\n }\n\n // Duration checks.\n const durations = {};\n\n for (const durationName of Object.keys(this._durations)) {\n durations[`${durationName}Duration`] = this._durations[durationName];\n }\n\n const durationChecks = isValidType(\"number\", durations);\n\n if (!durationChecks.status) {\n this._errors.push(durationChecks.error.message);\n check = false;\n }\n\n // Prefix check.\n const prefixCheck = isValidType(\"string\", { prefix: this._prefix });\n\n if (!prefixCheck.status) {\n this._errors.push(prefixCheck.error.message);\n check = false;\n }\n\n return check;\n }\n\n /**\n * Generates a key for the disclosure.\n *\n * @param {boolean} [regenerate = false] - A flag to determine if the key should be regenerated.\n */\n _generateKey(regenerate = false) {\n if (this.key === \"\" || regenerate) {\n this.key = Math.random()\n .toString(36)\n .replace(/[^a-z]+/g, \"\")\n .substring(0, 10);\n }\n }\n\n /**\n * Sets the IDs of the disclosure and it's controller if they do not already exist.\n *\n * The generated IDs use the key and follow the format:\n * - disclosure: `disclosure-${key}`\n * - controller: `disclosure-controller-${key}`\n *\n * @protected\n */\n _setIds() {\n this.dom.disclosure.id = this.dom.disclosure.id || `disclosure-${this.key}`;\n this.dom.controller.id =\n this.dom.controller.id || `disclosure-controller-${this.key}`;\n }\n\n /**\n * Sets the ARIA attributes on the disclosure and its controller.\n *\n * The first steps are to ensure that the controlled has `aria-expanded` set to \"false\"\n * if it's not already explicity set to \"true\".\n *\n * Then, set the `aria-controls` attribute on the controller to the disclosure's ID.\n *\n * Finally, ensure the controller element has a role of \"button\" if it is not a native button element.\n *\n * @protected\n */\n _setAriaAttributes() {\n // If the controller element doesn't have aria-expanded set to true, set it to false.\n if (this.dom.controller.getAttribute(\"aria-expanded\") !== \"true\") {\n this.dom.controller.setAttribute(\"aria-expanded\", \"false\");\n }\n\n // Set the aria-controls attribute on the controller to the disclosure's ID.\n this.dom.controller.setAttribute(\"aria-controls\", this.dom.disclosure.id);\n\n // If the controller element is not a button, set its role to button.\n if (!isTag(\"button\", { controller: this.dom.controller })) {\n this.dom.controller.setAttribute(\"role\", \"button\");\n }\n }\n\n /**\n * Sets the transition durations of the disclosure as a CSS custom properties.\n *\n * The custom properties are:\n * - `--graupl-disclosure-transition-duration`,\n * - `--graupl-disclosure-open-transition-duration`, and\n * - `--graupl-disclosure-close-transition-duration`.\n *\n * The prefix of `graupl-` can be changed by setting the disclosure's prefix value.\n *\n * @protected\n */\n _setTransitionDurations() {\n this.dom.disclosure.style.setProperty(\n `--${this.prefix}disclosure-transition-duration`,\n `${this.transitionDuration}ms`\n );\n\n this.dom.disclosure.style.setProperty(\n `--${this.prefix}disclosure-open-transition-duration`,\n `${this.openDuration}ms`\n );\n\n this.dom.disclosure.style.setProperty(\n `--${this.prefix}disclosure-close-transition-duration`,\n `${this.closeDuration}ms`\n );\n }\n\n /**\n * Sets DOM elements.\n *\n * Elements listed in _domLock cannot be set using this method.\n *\n * @protected\n *\n * @param {string} elementType - The type of element to populate.\n * @param {Object<HTMLElement,boolean>} [options = {}] - The options for setting the DOM element type.\n * @param {HTMLElement} [options.base = this.dom.disclosure] - The element used as the base for the querySelector.\n * @param {boolean} [options.overwrite = true] - A flag to set if the existing elements will be overwritten.\n * @param {boolean} [options.strict = true] - A flag to set if the elements must be direct children of the base.\n */\n _setDOMElementType(\n elementType,\n { base = this.dom.disclosure, overwrite = true, strict = true } = {}\n ) {\n if (typeof this.selectors[elementType] === \"string\") {\n if (this._domLock.includes(elementType)) {\n throw new Error(\n `Graupl ${this.constructor.name}: \"${elementType}\" element cannot be set through _setDOMElementType.`\n );\n }\n\n if (base !== this.dom.disclosure) isValidInstance(HTMLElement, { base });\n\n // Get the all elements matching the selector in the base.\n const domElements = Array.from(\n base.querySelectorAll(this.selectors[elementType])\n );\n\n // Filter the elements so only direct children of the base are kept.\n const filteredElements = domElements.filter((item) =>\n strict ? item.parentElement === base : true\n );\n\n if (overwrite) {\n if (Array.isArray(this._dom[elementType])) {\n this._dom[elementType] = filteredElements;\n } else {\n this._dom[elementType] = filteredElements[0] || null;\n }\n } else {\n if (Array.isArray(this._dom[elementType])) {\n this._dom[elementType] = [\n ...this._dom[elementType],\n ...filteredElements,\n ];\n } else {\n this._dom[elementType] = filteredElements[0] || null;\n }\n }\n } else {\n throw new Error(\n `Graupl ${this.constructor.name}: \"${elementType}\" is not a valid element type.`\n );\n }\n }\n\n /**\n * Resets DOM elements.\n *\n * Elements listed in _domLock cannot be reset using this method.\n *\n * @protected\n *\n * @param {string} elementType - The type of element to clear.\n */\n _resetDOMElementType(elementType) {\n if (typeof this.selectors[elementType] === \"string\") {\n if (this._domLock.includes(elementType)) {\n throw new Error(\n `Graupl ${this.constructor.name}: \"${elementType}\" element cannot be reset through _resetDOMElementType.`\n );\n }\n\n if (Array.isArray(this._dom[elementType])) {\n this._dom[elementType] = [];\n } else {\n this._dom[elementType] = null;\n }\n } else {\n throw new Error(\n `Graupl ${this.constructor.name}: \"${elementType}\" is not a valid element type.`\n );\n }\n }\n\n /**\n * Sets all DOM elements within the disclosure.\n *\n * Utilizes _setDOMElementType and\n * _resetDOMElementType.\n *\n * @protected\n */\n _setDOMElements() {\n this._resetDOMElementType(\"content\");\n this._setDOMElementType(\"content\");\n }\n\n /**\n * Expands the disclosure.\n *\n * Sets the controller's `aria-expanded` to \"true\", adds the\n * open class to the disclosure, and removes the closed class from the disclosure.\n *\n * @protected\n *\n * @fires grauplDisclosureExpand\n *\n * @param {boolean} [emit = true] - Emit the expand event once expanded.\n * @param {boolean} [transition = true] - Respect the transition class.\n */\n _expand(emit = true, transition = true) {\n this.dom.controller.setAttribute(\"aria-expanded\", \"true\");\n\n // If we're dealing with transition classes, then we need to utilize\n // requestAnimationFrame to add the transition class, remove the close class,\n // add the open class, and finally remove the transition class.\n if (transition && this.transitionlass !== \"\") {\n // this.dom.disclosure.style.height = `${this.dom.disclosure.getBoundingClientRect().height}px`;\n // console.log(this.dom.disclosure.style.height);\n addClass(this.transitionClass, this.dom.disclosure);\n\n requestAnimationFrame(() => {\n removeClass(this.closeClass, this.dom.disclosure);\n\n // this.dom.disclosure.style.height = `${this.dom.disclosure.getBoundingClientRect().height}px`;\n // console.log(this.dom.disclosure.style.height);\n\n requestAnimationFrame(() => {\n addClass(this.openClass, this.dom.disclosure);\n\n // this.dom.disclosure.style.height = `${this.dom.content.getBoundingClientRect().height}px`;\n // console.log(this.dom.disclosure.style.height);\n\n requestAnimationFrame(() => {\n setTimeout(() => {\n removeClass(this.transitionClass, this.dom.disclosure);\n\n // this.dom.disclosure.style.height = \"\";\n // console.log(this.dom.disclosure.style.height);\n }, this.openDuration);\n });\n });\n });\n } else {\n // Add the open class\n addClass(this.openClass, this.dom.disclosure);\n\n // Remove the close class.\n removeClass(this.closeClass, this.dom.disclosure);\n }\n\n this.dom.content.removeAttribute(\"inert\");\n\n if (emit) {\n this.dom.controller.dispatchEvent(this._expandEvent);\n }\n }\n\n /**\n * Collapses the disclosure.\n *\n * Sets the controller's `aria-expanded` to \"false\", adds the\n * close class to the disclosure, and removes the open class from the disclosure.\n *\n * @protected\n *\n * @fires grauplDisclosureCollapse\n *\n * @param {boolean} [emit = true] - Emit the collapse event once collapsed.\n * @param {boolean} [transition = true] - Respect the transition class.\n */\n _collapse(emit = true, transition = true) {\n this.dom.controller.setAttribute(\"aria-expanded\", \"false\");\n\n // If we're dealing with transition classes, then we need to utilize\n // requestAnimationFrame to add the transition class, remove the open class,\n // add the close class, and finally remove the transition class.\n if (transition && this.transitionClass !== \"\") {\n // this.dom.disclosure.style.height = `${this.dom.content.getBoundingClientRect().height}px`;\n // console.log(this.dom.disclosure.style.height);\n\n addClass(this.transitionClass, this.dom.disclosure);\n\n requestAnimationFrame(() => {\n removeClass(this.openClass, this.dom.disclosure);\n\n // this.dom.disclosure.style.height = `${this.dom.content.getBoundingClientRect().height}px`;\n // console.log(this.dom.disclosure.style.height);\n\n requestAnimationFrame(() => {\n addClass(this.closeClass, this.dom.disclosure);\n\n // this.dom.disclosure.style.height = `${this.dom.disclosure.getBoundingClientRect().height}px`;\n // console.log(this.dom.disclosure.style.height);\n\n requestAnimationFrame(() => {\n setTimeout(() => {\n removeClass(this.transitionClass, this.dom.disclosure);\n\n this.dom.content.innert = true;\n\n // this.dom.disclosure.style.height = \"\";\n // console.log(this.dom.disclosure.style.height);\n }, this.closeDuration);\n });\n });\n });\n } else {\n // Add the close class\n addClass(this.closeClass, this.dom.disclosure);\n\n // Remove the open class.\n removeClass(this.openClass, this.dom.disclosure);\n }\n\n this.dom.content.setAttribute(\"inert\", \"true\");\n\n if (emit) {\n this.dom.controller.dispatchEvent(this._collapseEvent);\n }\n }\n\n _handleResize() {\n if (this._breakpointWidth <= 0) {\n return;\n }\n\n let width = 0;\n\n this._observer = new ResizeObserver((entries) => {\n requestAnimationFrame(() => {\n for (const entry of entries) {\n const boxSize = Array.isArray(entry.contentBoxSize)\n ? entry.contentBoxSize[0]\n : entry.contentBoxSize;\n const inlineSize =\n boxSize && typeof boxSize.inlineSize === \"number\"\n ? boxSize.inlineSize\n : entry.contentRect.width;\n\n if (typeof inlineSize !== \"number\") continue;\n\n if (width === inlineSize) continue;\n\n const belowBreakpoint = inlineSize <= this.minWidth;\n const aboveBreakpoint = inlineSize > this.minWidth;\n\n if (belowBreakpoint && this.isOpen) {\n this.close({ preserveState: true });\n } else if (\n aboveBreakpoint &&\n !this.isOpen &&\n (this.hasOpened || this.shouldOpen)\n ) {\n this.open();\n }\n\n width = inlineSize;\n }\n });\n });\n this._observer.observe(document.body);\n }\n\n /**\n * Handles focus events throughout the disclosure.\n *\n * - Adds a `focusout` listener to the disclosure so when the disclosure loses focus it will close.\n */\n _handleFocus() {\n this.dom.disclosure.addEventListener(\"focusout\", (event) => {\n if (\n !this.closeOnBlur ||\n this.currentEvent !== \"keyboard\" ||\n event.relatedTarget === null ||\n this.dom.disclosure.contains(event.relatedTarget) ||\n this.dom.controller === event.relatedTarget\n ) {\n return;\n }\n\n this.close();\n });\n }\n\n /**\n * Handles click events throughout the disclosure.\n *\n * - Adds a `pointerup` listener to the controller that toggles the disclosure.\n * - Adds a `pointerup` listener to the `document` so if the user clicks outside the disclosure it will close.\n */\n _handleClick() {\n this.dom.controller.addEventListener(\"pointerup\", (event) => {\n this.currentEvent = \"mouse\";\n\n if (event.button !== 0) return;\n\n preventEvent(event);\n this.toggle();\n });\n\n document.addEventListener(\"pointerup\", (event) => {\n if (this.focusState !== \"self\" || !this.closeOnBlur) return;\n\n this.currentEvent = \"mouse\";\n\n if (\n !this.dom.disclosure.contains(event.target) &&\n this.dom.controller !== event.target\n ) {\n this.close();\n }\n });\n }\n\n /**\n * Handles keydown events throughout the disclosure.\n *\n * This method exists to assist the _handleKeyup method.\n *\n * - Adds a `keydown` listener to the controller.\n * - Blocks propagation on \"Space\" and \"Enter\" keys.\n * - Adds a `keydown` listener to the disclosure.\n * - Blocks propagation on \"Escape\" keys.\n */\n _handleKeydown() {\n this.dom.controller.addEventListener(\"keydown\", (event) => {\n this.currentEvent = \"keyboard\";\n\n const key = keyPress(event);\n\n switch (key) {\n case \"Space\":\n case \"Enter\":\n preventEvent(event);\n\n break;\n }\n });\n\n this.dom.disclosure.addEventListener(\"keydown\", (event) => {\n this.currentEvent = \"keyboard\";\n\n const key = keyPress(event);\n\n switch (key) {\n case \"Escape\":\n preventEvent(event);\n\n break;\n }\n });\n }\n\n /**\n * Handles keyup events throughout the disclosure.\n *\n * - Adds a `keyup` listener to the controller.\n * - Toggles the disclosure on \"Space\" and \"Enter\" keys.\n * - Adds a `keyup` listener to the disclosure.\n * - Closes the disclosure on \"Escape\" keys.\n */\n _handleKeyup() {\n this.dom.controller.addEventListener(\"keyup\", (event) => {\n this.currentEvent = \"keyboard\";\n\n const key = keyPress(event);\n\n switch (key) {\n case \"Space\":\n case \"Enter\":\n this.toggle();\n\n preventEvent(event);\n\n break;\n }\n });\n\n this.dom.disclosure.addEventListener(\"keyup\", (event) => {\n this.currentEvent = \"keyboard\";\n\n const key = keyPress(event);\n\n switch (key) {\n case \"Escape\":\n this.close();\n\n preventEvent(event);\n\n break;\n }\n });\n }\n\n /**\n * Opens the disclosure.\n *\n * Sets the disclosure's focus state to \"self\", calls expand, and sets isOpen to `true`.\n *\n * @public\n *\n * @param {Object<boolean>} [options = {}] - Options for opening the disclosure.\n * @param {boolean} [options.force = false] - Whether to force the open action.\n * @param {boolean} [options.preserveState = false] - Whether to preserve the open state.\n */\n open({ force = false, preserveState = false } = {}) {\n if (this.isOpen && !force) return;\n\n // Set the focus state.\n this.focusState = \"self\";\n\n // Expand the disclosure.\n this._expand();\n\n // Set the open state.\n this._open.value = true;\n\n if (!preserveState) {\n this._open.commit();\n }\n }\n\n /**\n * Opens the disclosure without entering it.\n *\n * Sets the disclosure's focus state to \"none\", calls expand, and sets isOpen to `true`.\n *\n * @public\n *\n * @param {Object<boolean>} [options = {}] - Options for previewing the disclosure.\n * @param {boolean} [options.force = false] - Whether to force the preview action.\n * @param {boolean} [options.preserveState = false] - Whether to preserve the open state.\n */\n preview({ force = false, preserveState = false } = {}) {\n if (this.isOpen && !force) return;\n\n // Set the focus state.\n this.focusState = \"none\";\n\n // Expand the disclosure.\n this._expand();\n\n // Set the open state.\n this._open.value = true;\n\n if (!preserveState) {\n this._open.commit();\n }\n }\n\n /**\n * Closes the disclosure.\n *\n * Sets the disclosure's focus state to \"none\", calls collapse, and sets isOpen to `false`.\n *\n * @public\n *\n * @param {Object<boolean>} [options = {}] - Options for closing the disclosure.\n * @param {boolean} [options.force = false] - Whether to force the close action.\n * @param {boolean} [options.preserveState = false] - Whether to preserve the open state.\n */\n close({ force = false, preserveState = false } = {}) {\n if (!this.isOpen && !force) return;\n\n // Set the focus state.\n this.focusState = \"none\";\n\n // Collapse the disclosure.\n this._collapse();\n\n // Set the open state.\n this._open.value = false;\n\n if (!preserveState) {\n this._open.commit();\n }\n }\n\n /**\n * Toggles the open state of the disclosure.\n *\n * @public\n *\n * @param {Object<boolean>} [options = {}] - Options for toggling the disclosure.\n * @param {boolean} [options.force = false] - Whether to force the open or close action.\n * @param {boolean} [options.preserveState = false] - Whether to preserve the open state.\n */\n toggle({ force = false, preserveState = false } = {}) {\n if (this.isOpen) {\n this.close({ force, preserveState });\n } else {\n this.open({ force, preserveState });\n }\n }\n}\n\nexport default Disclosure;\n","/**\n * Mark DOM elements as processed to prevent multiple initializations.\n *\n * @module @drupal/once\n *\n * @example <!-- Use as a module -->\n * <script type=\"module\">\n * import once from 'https://unpkg.com/@drupal/once/src/once.js';\n * const elements = once('my-once-id', 'div');\n * // Initialize elements.\n * elements.forEach(el => el.innerHTML = 'processed');\n * </script>\n *\n * @example <!-- Use as a regular script -->\n * <script src=\"https://unpkg.com/@drupal/once\"></script>\n * <script>\n * const elements = once('my-once-id', 'div');\n * // Initialize elements.\n * elements.forEach(el => el.innerHTML = 'processed');\n * </script>\n * @example <!-- Using a single element as input-->\n * <script src=\"https://unpkg.com/@drupal/once\"></script>\n * <script>\n * // once methods always return an array, to simplify the use with a single\n * // element use destructuring or the shift method.\n * const [myElement] = once('my-once-id', document.body);\n * const myElement = once('my-once-id', document.body).shift();\n * </script>\n */\n\n/**\n * Illegal spaces in ids.\n *\n * @private\n *\n * @type {RegExp}\n */\nconst wsRE = /[\\11\\12\\14\\15\\40]+/;\n\n/**\n * Name of the HTML attribute containing an element's once ids.\n *\n * @private\n *\n * @type {string}\n */\nconst attrName = 'data-once';\n\n/**\n * Shortcut to access the html element.\n *\n * @private\n *\n * @type {HTMLElement}\n */\nconst doc = document;\n\n/**\n * Helper to access element attributes.\n *\n * @private\n *\n * @param {Element} element\n * The Element to access the data-once attribute from.\n * @param {string} op\n * The action to take on the element.\n * @param {string} [value]\n * Optional value for setAttribute.\n *\n * @return {string|undefined|null|boolean}\n * Result of the attribute method.\n */\nfunction attr(element, op, value) {\n return element[`${op}Attribute`](attrName, value);\n}\n\n/**\n * Return the attribute selector.\n *\n * @private\n *\n * @param {string} id\n * The id passed by a call to a once() function.\n *\n * @return {string}\n * The full CSS attribute selector.\n *\n * @throws {TypeError|RangeError}\n */\nfunction attrSelector(id) {\n // Verify the validity of the once id.\n if (typeof id !== 'string') {\n throw new TypeError('once ID must be a string');\n }\n if (id === '' || wsRE.test(id)) {\n throw new RangeError('once ID must not be empty or contain spaces');\n }\n // The id is valid, return the full CSS selector.\n return `[${attrName}~=\"${id}\"]`;\n}\n\n/**\n * Verifies that an item is an instance of Element.\n *\n * This function is used during filtering to ensure only DOM elements are\n * processed. once() makes use of get/setAttribute, which are methods\n * inherited from the Element object, so only of Element can be used.\n *\n * @private\n *\n * @param {*} itemToCheck\n * The item to check.\n *\n * @return {boolean}\n * True if the item is an instance of Element\n *\n * @throws {TypeError}\n */\nfunction checkElement(itemToCheck) {\n if (!(itemToCheck instanceof Element)) {\n throw new TypeError('The element must be an instance of Element');\n }\n return true;\n}\n\n/**\n * Process arguments, query the DOM if necessary.\n *\n * @private\n *\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements.\n * @param {Document|DocumentFragment|Element} [context=document]\n * An element or document object to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * An array with the processed Id and the list of elements to process.\n */\nfunction getElements(selector, context = doc) {\n // Assume selector is an array-like value.\n let elements = selector;\n\n // If selector is null it is most likely because of a call to querySelector\n // that didn't return a result.\n if (selector === null) {\n elements = [];\n }\n // The selector is undefined, error out.\n else if (!selector) {\n throw new TypeError('Selector must not be empty');\n }\n // Context doesn't implement querySelectorAll, error out.\n else if (\n !(\n context instanceof Document ||\n context instanceof DocumentFragment ||\n context instanceof Element\n )\n ) {\n throw new TypeError(\n 'Context must be an object of type \"Document\", \"DocumentFragment\", or \"Element\".',\n );\n }\n // This is a selector, query the elements.\n else if (typeof selector === 'string') {\n elements = context.querySelectorAll(selector);\n }\n // This is a single element.\n else if (selector instanceof Element) {\n elements = [selector];\n }\n\n // Make sure an array is returned and not a NodeList or an Array-like object.\n return Array.prototype.slice.call(elements);\n}\n\n/**\n * A helper for applying DOM changes to a filtered set of elements.\n *\n * This makes it possible to filter items that are not instances of Element,\n * then modify their DOM attributes in a single array traversal.\n *\n * @private\n *\n * @param {string} selector\n * A CSS selector to check against to each element in the array.\n * @param {Array.<Element>} elements\n * A NodeList or array of elements passed by a call to a once() function.\n * @param {function} [apply]\n * An optional function to apply on all matched elements.\n *\n * @return {Array.<Element>}\n * The array of elements that match the CSS selector.\n */\nfunction filterAndModify(selector, elements, apply) {\n return elements.filter((element) => {\n const selected = checkElement(element) && element.matches(selector);\n if (selected && apply) {\n apply(element);\n }\n return selected;\n });\n}\n\n/**\n * Add or remove an item from a list of once values.\n *\n * This function removes duplicates while adding or removing a once id in a\n * single array traversal.\n *\n * @private\n *\n * @param {Element} element\n * A space separated string of once ids from a data-drupal-once attribute.\n * @param {string} [add]\n * The once id to add to the list of values.\n * @param {string} [remove]\n * The once id to remove from the list of values.\n *\n * @return {undefined}\n * Nothing to return this is a callback in a foreach.\n */\nfunction updateAttribute(element, { add, remove }) {\n const result = [];\n if (attr(element, 'has')) {\n attr(element, 'get')\n .trim()\n .split(wsRE)\n .forEach((item) => {\n if (result.indexOf(item) < 0 && item !== remove) {\n result.push(item);\n }\n });\n }\n if (add) {\n result.push(add);\n }\n const attribute = result.join(' ');\n attr(element, attribute === '' ? 'remove' : 'set', attribute);\n}\n\n/**\n * Ensures a JavaScript callback is only executed once on a set of elements.\n *\n * Filters a NodeList or array of elements, removing those already processed\n * by a callback with a given id.\n * This method adds a `data-once` attribute on DOM elements. The value of\n * this attribute identifies if a given callback has been executed on that\n * element.\n *\n * @global\n *\n * @example <caption>Basic usage</caption>\n * const elements = once('my-once-id', '[data-myelement]');\n * @example <caption>Input parameters accepted</caption>\n * // NodeList.\n * once('my-once-id', document.querySelectorAll('[data-myelement]'));\n * // Array or Array-like of Element.\n * once('my-once-id', jQuery('[data-myelement]'));\n * // A CSS selector without a context.\n * once('my-once-id', '[data-myelement]');\n * // A CSS selector with a context.\n * once('my-once-id', '[data-myelement]', document.head);\n * // Single Element.\n * once('my-once-id', document.querySelector('#some-id'));\n * @example <caption>Using a single element</caption>\n * // Once always returns an array, even when passing a single element. Some\n * // forms that can be used to keep code readable.\n * // Destructuring:\n * const [myElement] = once('my-once-id', document.body);\n * // By changing the resulting array, es5 compatible.\n * const myElement = once('my-once-id', document.body).shift();\n *\n * @param {string} id\n * The id of the once call.\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements.\n * @param {Document|DocumentFragment|Element} [context=document]\n * An element or document object to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * An array of elements that have not yet been processed by a once call\n * with a given id.\n */\nfunction once(id, selector, context) {\n return filterAndModify(\n `:not(${attrSelector(id)})`,\n getElements(selector, context),\n (element) => updateAttribute(element, { add: id }),\n );\n}\n\n/**\n * Removes a once id from an element's data-drupal-once attribute value.\n *\n * If a once id is removed from an element's data-drupal-once attribute value,\n * the JavaScript callback associated with that id can be executed on that\n * element again.\n *\n * @method once.remove\n *\n * @example <caption>Basic usage</caption>\n * const elements = once.remove('my-once-id', '[data-myelement]');\n * @example <caption>Input parameters accepted</caption>\n * // NodeList.\n * once.remove('my-once-id', document.querySelectorAll('[data-myelement]'));\n * // Array or Array-like of Element.\n * once.remove('my-once-id', jQuery('[data-myelement]'));\n * // A CSS selector without a context.\n * once.remove('my-once-id', '[data-myelement]');\n * // A CSS selector with a context.\n * once.remove('my-once-id', '[data-myelement]', document.head);\n * // Single Element.\n * once.remove('my-once-id', document.querySelector('#some-id'));\n *\n * @param {string} id\n * The id of a once call.\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements to remove the once id from.\n * @param {Document|Element} [context=document]\n * An element to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * A filtered array of elements that had been processed by the provided id,\n * and are now able to be processed again.\n */\nonce.remove = (id, selector, context) => {\n return filterAndModify(\n attrSelector(id),\n getElements(selector, context),\n (element) => updateAttribute(element, { remove: id }),\n );\n};\n\n/**\n * Finds elements that have been processed by a given once id.\n *\n * Behaves like {@link once} and {@link once.remove} without changing the DOM.\n * To select all DOM nodes processed by a given id, use {@link once.find}.\n *\n * @method once.filter\n *\n * @example <caption>Basic usage</caption>\n * const filteredElements = once.filter('my-once-id', '[data-myelement]');\n * @example <caption>Input parameters accepted</caption>\n * // NodeList.\n * once.filter('my-once-id', document.querySelectorAll('[data-myelement]'));\n * // Array or Array-like of Element.\n * once.filter('my-once-id', jQuery('[data-myelement]'));\n * // A CSS selector without a context.\n * once.filter('my-once-id', '[data-myelement]');\n * // A CSS selector with a context.\n * once.filter('my-once-id', '[data-myelement]', document.head);\n * // Single Element.\n * once.filter('my-once-id', document.querySelector('#some-id'));\n *\n * @param {string} id\n * The id of the once call.\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements to remove the once id from.\n * @param {Document|Element} [context=document]\n * An element to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * A filtered array of elements that have already been processed by the\n * provided once id.\n */\nonce.filter = (id, selector, context) =>\n filterAndModify(attrSelector(id), getElements(selector, context));\n\n/**\n * Finds elements that have been processed by a given once id.\n *\n * Query the 'context' element for elements that already have the\n * corresponding once id value.\n *\n * @method once.find\n *\n * @example <caption>Basic usage</caption>\n * const oncedElements = once.find('my-once-id');\n * @example <caption>Input parameters accepted</caption>\n * // Call without parameters, return all elements with a `data-once` attribute.\n * once.find();\n * // Call without a context.\n * once.find('my-once-id');\n * // Call with a context.\n * once.find('my-once-id', document.head);\n *\n * @param {string} [id]\n * The id of the once call.\n * @param {Document|DocumentFragment|Element} [context=document]\n * Scope of the search for matching elements.\n *\n * @return {Array.<Element>}\n * A filtered array of elements that have already been processed by the\n * provided once id.\n */\nonce.find = (id, context) =>\n getElements(!id ? `[${attrName}]` : attrSelector(id), context);\n\nexport default once;\n","import Disclosure from \"./Disclosure.js\";\nimport once from \"@drupal/once\";\n\nconst generate = ({\n options = {},\n context = document,\n disclosureSelector = \".disclosure\",\n controllerSelector = \".disclosure-toggle\",\n} = {}) => {\n once(\"graupl-disclosure-generator\", disclosureSelector, context).forEach(\n (disclosureElement) => {\n const disclosureOptions = disclosureElement.dataset\n .grauplDisclosureOptions\n ? JSON.parse(\n disclosureElement.dataset.grauplDisclosureOptions.replace(/'/g, '\"')\n ) || {}\n : {};\n\n const targettedControllerSelector = `${controllerSelector}[data-graupl-disclosure-target=\"${disclosureElement.id}\"]`;\n const [controllerElement] = once(\n \"graupl-disclosure-generator\",\n targettedControllerSelector,\n context\n );\n\n if (!controllerElement) {\n console.warn(\n `No controller found for disclosure with ID \"${disclosureElement.id}\". Please ensure there is an element with the selector \"${targettedControllerSelector}\".`\n );\n\n once.remove(\"graupl-disclosure-generator\", disclosureElement);\n\n return;\n }\n\n new Disclosure({\n disclosureElement,\n controllerElement,\n initialize: true,\n ...options,\n ...disclosureOptions,\n });\n }\n );\n};\n\nexport default generate;\n"],"x_google_ignoreList":[6],"mappings":"AAeA,SAAgBqH,EAAgBwC,EAAaiJ,EAAU,CACrD,GAAI,CACF,GAAI,OAAOA,GAAa,SAAU,CAChC,MAAM3S,EAAe,OAAO2S,EAE5B,MAAM,IAAIT,UACR,qEAAqElS,CAAAA,UAAY,EAIrF,UAAWgO,KAAO2E,EAChB,GAAI,EAAEA,EAAS3E,CAAAA,YAAgBtE,GAAc,CAC3C,MAAMgF,EAAc,OAAOiE,EAAS3E,CAAA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AAI,CACtD,EAoCFhB,EAAKlB,OAAAA,CAAUkC,EAAI9C,EAAUiC,IAC3BvB,EAAgBnB,EAAauD,CAAAA,EAAK/C,EAAYC,EAAUiC,CAAAA,CAAQ,EA6BlEH,EAAKF,KAAAA,CAAQkB,EAAIb,IACflC,EAAa+C,EAAuBvD,EAAauD,CAAAA,EAA/B,IAAI9D,CAAAA,IAAgCiD,CAAAA,EAExD,IAAA,EAAeH,EC7Yf,MAAMC,EAAAA,CAAY,CAChBC,QAAAA,EAAU,CAAA,EACVC,QAAAA,EAAUC,SACVC,mBAAAA,EAAqB,cACrBC,mBAAAA,EAAqB,oBAAA,EACnB,CAAA,IAAO,CACTN,EAAK,8BAA+BK,EAAoBF,CAAAA,EAASI,QAC9DC,GAAsB,CACrB,MAAMC,EAAoBD,EAAkBE,QACzCC,wBACCC,KAAKC,MACHL,EAAkBE,QAAQC,wBAAwBG,QAAQ,KAAM,GAAA,CAClE,GAAK,CAAA,EACL,CAAA,EAEEC,EAA8B,GAAGT,CAAAA,mCAAqDE,EAAkBQ,EAAAA,KACxG,CAACC,CAAAA,EAAqBjB,EAC1B,8BACAe,EACAZ,CAAAA,EAGF,GAAI,CAACc,EAAmB,CACtBC,QAAQC,KACN,+CAA+CX,EAAkBQ,EAAAA,2DAA6DD,CAAAA,IAA2B,EAG3Jf,EAAKoB,OAAO,8BAA+BZ,CAAAA,EAE3C,OAGF,IAAIT,EAAW,CACbS,kBAAAA,EACAS,kBAAAA,EACAI,WAAY,GACZ,GAAGnB,EACH,GAAGO,EACJ,KAKP,IAAA,EAAeR"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
function y(t,e){try{if(typeof e!="object"){const s=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${s}" given.`)}for(const s in e)if(!(e[s]instanceof t)){const i=typeof e[s];throw new TypeError(`${s} must be an instance of ${t.name}. "${i}" given.`)}return{status:!0,error:null}}catch(s){return{status:!1,error:s}}}function o(t,e){try{if(typeof e!="object"){const s=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${s}" given.`)}for(const s in e){const i=typeof e[s];if(i!==t)throw new TypeError(`${s} must be a ${t}. "${i}" given.`)}return{status:!0,error:null}}catch(s){return{status:!1,error:s}}}function A(t){try{if(typeof t!="object"){const e=typeof t;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in t)try{if(t[e]===null)throw new Error;document.querySelector(t[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${t[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function d(t){try{if(typeof t!="object"||Array.isArray(t)){const e=typeof t;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in t){const s=typeof t[e];if(s!=="string")if(Array.isArray(t[e]))t[e].forEach(i=>{if(typeof i!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${s}" given.`);else{const i={};i[e]=t[e],A(i)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function L(t,e){if(o("string",{tagName:t}).status&&y(HTMLElement,e).status){const s=t.toLowerCase();let i=!0;for(const r in e)e[r].tagName.toLowerCase()!==s&&(i=!1);return i}else return!1}function j(t){try{if(typeof t!="object"){const s=typeof t;throw new TypeError(`Values given to isValidState() must be inside of an object. "${s}" given.`)}const e=["none","self","child"];for(const s in t)if(!e.includes(t[s]))throw new TypeError(`${s} must be one of the following values: ${e.join(", ")}. "${t[s]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(t){try{if(typeof t!="object"){const s=typeof t;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${s}" given.`)}const e=["none","mouse","keyboard","character"];for(const s in t)if(!e.includes(t[s]))throw new TypeError(`${s} must be one of the following values: ${e.join(", ")}. "${t[s]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function u(t,e){t===""||t.length===0||(typeof t=="string"?e.classList.add(t):e.classList.add(...t))}function h(t,e){t===""||t.length===0||(typeof t=="string"?e.classList.remove(t):e.classList.remove(...t))}function p(t){try{const e=t.key||t.keyCode,s={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Tab:e==="Tab"||e===9};return Object.keys(s).find(i=>s[i]===!0)||""}catch{return""}}function f(t){t.preventDefault(),t.stopPropagation()}function G(t=null){window.Graupl=window.Graupl||{},o("string",{type:t})&&(window.Graupl[t]=window.Graupl[t]||{})}function F(t=null){return o("string",{type:t})?window.Graupl[t]:window.Graupl}function V(t,e={}){o("string",{type:t})&&o("object",{data:e})&&(window.Graupl[t]=e)}function B(t){o("string",{type:t})&&(window.Graupl[t]={})}function M(t,e,s){o("string",{type:t,key:e})&&(window.Graupl[t][e]=s)}function W(t,e){return o("string",{type:t,key:e})?window.Graupl[t][e]:null}function R(t,e){o("string",{type:t,key:e})&&delete window.Graupl[t][e]}var w={initializeStorage:G,getStorage:F,setStorage:V,clearStorage:B,pushToStorage:M,getFromStorage:W,removeFromStorage:R},I=class{constructor(t,e={}){this._equals=e.equals||Object.is,this._current=t,this._committed=t}get value(){return this._current}set value(t){this._current=t}get committed(){return this._committed}get isDirty(){return!this._equals(this._current,this._committed)}commit(){return this._committed=this._current,this}reset(){return this._current=this._committed,this}update(t){return this._current=t(this._current),this}},K=class{_dom={controller:null,disclosure:null,content:null};_domLock=["controller","disclosure"];_selectors={content:""};_classes={open:"show",close:"hide",transition:"transitioning",initialize:"initializing"};_durations={transition:5e3,open:-1,close:-1};_focusState="none";_currentEvent="none";_open=new I(!1);_shouldOpen=!1;_closeOnBlur=!1;_breakpointWidth=-1;_observer=null;_expandEvent=new CustomEvent("grauplDisclosureExpand",{bubbles:!0,detail:{disclosure:this}});_collapseEvent=new CustomEvent("grauplDisclosureCollapse",{bubbles:!0,detail:{disclosure:this}});_prefix="graupl-";_errors=[];constructor({disclosureElement:t,controllerElement:e,disclosureContentSelector:s=".disclosure-content",openClass:i="show",closeClass:r="hide",transitionClass:n="transitioning",transitionDuration:a=250,openDuration:c=-1,closeDuration:l=-1,closeOnBlur:S=!1,minWidth:O=-1,autoOpen:v=!1,prefix:T="graupl-",initializeClass:x="initializing",initialize:z=!1}){this._dom.disclosure=t,this._dom.controller=e,this._selectors.content=s,this._classes.open=i||"",this._classes.close=r||"",this._classes.transition=n||"",this._classes.initialize=x||"",this._durations.transition=a,this._durations.open=c,this._durations.close=l,this._closeOnBlur=S,this._breakpointWidth=O,this._shouldOpen=v,this._prefix=T,z&&this.initialize()}initialize(){try{if(!this._validate())throw new Error(`Graupl Disclosure: cannot initialize disclosure. The following errors have been found:
|
|
2
|
+
- ${this.errors.join(`
|
|
3
|
+
- `)}`);u(this._classes.initialize,this.dom.disclosure),this._generateKey(),this._setDOMElements(),this._setIds(),this._setAriaAttributes(),this._handleFocus(),this._handleClick(),this._handleKeydown(),this._handleKeyup(),this._handleResize(),this._setTransitionDurations(),w.initializeStorage("disclosures"),w.initializeStorage("disclosures"),w.pushToStorage("disclosures",this.dom.disclosure.id,this),this.dom.controller.getAttribute("aria-expanded")==="true"||this.shouldOpen&&window.matchMedia(this.openQuery).matches?this._expand(!1,!1):this._collapse(!1,!1),requestAnimationFrame(()=>{h(this._classes.initialize,this.dom.disclosure)})}catch(t){console.error(t)}}get dom(){return this._dom}get selectors(){return this._selectors}get openClass(){return this._classes.open}set openClass(t){d({openClass:t}),this._classes.open!==t&&(this._classes.open=t)}get closeClass(){return this._classes.close}set closeClass(t){d({closeClass:t}),this._classes.close!==t&&(this._classes.close=t)}get transitionClass(){return this._classes.transition}set transitionClass(t){d({transitionClass:t}),this._classes.transition!==t&&(this._classes.transition=t)}get initializeClass(){return this._classes.initialize}set initializeClass(t){d({initializeClass:t}),this._classes.initialize!==t&&(this._classes.initialize=t)}get transitionDuration(){return this._durations.transition}set transitionDuration(t){o("number",{value:t}),this._durations.transition!==t&&(this._durations.transition=t,this._setTransitionDurations())}get openDuration(){return this._durations.open===-1?this.transitionDuration:this._durations.open}set openDuration(t){o("number",{value:t}),this._durations.open!==t&&(this._durations.open=t,this._setTransitionDurations())}get closeDuration(){return this._durations.close===-1?this.transitionDuration:this._durations.close}set closeDuration(t){o("number",{value:t}),this._durations.close!==t&&(this._durations.close=t,this._setTransitionDurations())}get minWidth(){return this._breakpointWidth}set minWidth(t){o("number",{value:t}),this._breakpointWidth!==t&&(this._breakpointWidth=t)}get closeOnBlur(){return this._closeOnBlur}set closeOnBlur(t){o("boolean",{value:t}),this._closeOnBlur!==t&&(this._closeOnBlur=t)}get focusState(){return this._focusState}set focusState(t){j({value:t}),this._focusState!==t&&(this._focusState=t)}get currentEvent(){return this._currentEvent}set currentEvent(t){q({value:t}),this._currentEvent!==t&&(this._currentEvent=t)}get prefix(){return this._prefix}set prefix(t){o("string",{value:t}),this._prefix!==t&&(this._prefix=t,this._setTransitionDurations())}get isOpen(){return this._open.value}get hasOpened(){return this._open.committed}get shouldOpen(){return this._shouldOpen}set shouldOpen(t){o("boolean",{value:t}),this._shouldOpen!==t&&(this._shouldOpen=t)}get openQuery(){return this.minWidth===-1?"":`(width > ${this.minWidth}px)`}get closeQuery(){return this.minWidth===-1?"":`(width <= ${this.minWidth}px)`}get shouldFocus(){let t=!1;return this.currentEvent==="keyboard"&&(t=!0),t}get errors(){return this._errors}_validate(){let t=!0;const e=y(HTMLElement,{disclosureElement:this._dom.disclosure,controllerElement:this._dom.controller});e.status||(this._errors.push(e.error.message),t=!1);const s=A({disclosureContentSelector:this._selectors.content});s.status||(this._errors.push(s.error.message),t=!1);const i={};for(const l of Object.keys(this._classes))this._classes[l]!==""&&(i[`${l}Class`]=this._classes[l]);const r=d(i);r.status||(this._errors.push(r.error.message),t=!1);const n={};for(const l of Object.keys(this._durations))n[`${l}Duration`]=this._durations[l];const a=o("number",n);a.status||(this._errors.push(a.error.message),t=!1);const c=o("string",{prefix:this._prefix});return c.status||(this._errors.push(c.error.message),t=!1),t}_generateKey(t=!1){(this.key===""||t)&&(this.key=Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,10))}_setIds(){this.dom.disclosure.id=this.dom.disclosure.id||`disclosure-${this.key}`,this.dom.controller.id=this.dom.controller.id||`disclosure-controller-${this.key}`}_setAriaAttributes(){this.dom.controller.getAttribute("aria-expanded")!=="true"&&this.dom.controller.setAttribute("aria-expanded","false"),this.dom.controller.setAttribute("aria-controls",this.dom.disclosure.id),L("button",{controller:this.dom.controller})||this.dom.controller.setAttribute("role","button")}_setTransitionDurations(){this.dom.disclosure.style.setProperty(`--${this.prefix}disclosure-transition-duration`,`${this.transitionDuration}ms`),this.dom.disclosure.style.setProperty(`--${this.prefix}disclosure-open-transition-duration`,`${this.openDuration}ms`),this.dom.disclosure.style.setProperty(`--${this.prefix}disclosure-close-transition-duration`,`${this.closeDuration}ms`)}_setDOMElementType(t,{base:e=this.dom.disclosure,overwrite:s=!0,strict:i=!0}={}){if(typeof this.selectors[t]=="string"){if(this._domLock.includes(t))throw new Error(`Graupl ${this.constructor.name}: "${t}" element cannot be set through _setDOMElementType.`);e!==this.dom.disclosure&&y(HTMLElement,{base:e});const r=Array.from(e.querySelectorAll(this.selectors[t])).filter(n=>i?n.parentElement===e:!0);s?Array.isArray(this._dom[t])?this._dom[t]=r:this._dom[t]=r[0]||null:Array.isArray(this._dom[t])?this._dom[t]=[...this._dom[t],...r]:this._dom[t]=r[0]||null}else throw new Error(`Graupl ${this.constructor.name}: "${t}" is not a valid element type.`)}_resetDOMElementType(t){if(typeof this.selectors[t]=="string"){if(this._domLock.includes(t))throw new Error(`Graupl ${this.constructor.name}: "${t}" element cannot be reset through _resetDOMElementType.`);Array.isArray(this._dom[t])?this._dom[t]=[]:this._dom[t]=null}else throw new Error(`Graupl ${this.constructor.name}: "${t}" is not a valid element type.`)}_setDOMElements(){this._resetDOMElementType("content"),this._setDOMElementType("content")}_expand(t=!0,e=!0){this.dom.controller.setAttribute("aria-expanded","true"),e&&this.transitionlass!==""?(u(this.transitionClass,this.dom.disclosure),requestAnimationFrame(()=>{h(this.closeClass,this.dom.disclosure),requestAnimationFrame(()=>{u(this.openClass,this.dom.disclosure),requestAnimationFrame(()=>{setTimeout(()=>{h(this.transitionClass,this.dom.disclosure)},this.openDuration)})})})):(u(this.openClass,this.dom.disclosure),h(this.closeClass,this.dom.disclosure)),this.dom.content.removeAttribute("inert"),t&&this.dom.controller.dispatchEvent(this._expandEvent)}_collapse(t=!0,e=!0){this.dom.controller.setAttribute("aria-expanded","false"),e&&this.transitionClass!==""?(u(this.transitionClass,this.dom.disclosure),requestAnimationFrame(()=>{h(this.openClass,this.dom.disclosure),requestAnimationFrame(()=>{u(this.closeClass,this.dom.disclosure),requestAnimationFrame(()=>{setTimeout(()=>{h(this.transitionClass,this.dom.disclosure),this.dom.content.innert=!0},this.closeDuration)})})})):(u(this.closeClass,this.dom.disclosure),h(this.openClass,this.dom.disclosure)),this.dom.content.setAttribute("inert","true"),t&&this.dom.controller.dispatchEvent(this._collapseEvent)}_handleResize(){if(this._breakpointWidth<=0)return;let t=0;this._observer=new ResizeObserver(e=>{requestAnimationFrame(()=>{for(const s of e){const i=Array.isArray(s.contentBoxSize)?s.contentBoxSize[0]:s.contentBoxSize,r=i&&typeof i.inlineSize=="number"?i.inlineSize:s.contentRect.width;if(typeof r!="number"||t===r)continue;const n=r<=this.minWidth,a=r>this.minWidth;n&&this.isOpen?this.close({preserveState:!0}):a&&!this.isOpen&&(this.hasOpened||this.shouldOpen)&&this.open(),t=r}})}),this._observer.observe(document.body)}_handleFocus(){this.dom.disclosure.addEventListener("focusout",t=>{!this.closeOnBlur||this.currentEvent!=="keyboard"||t.relatedTarget===null||this.dom.disclosure.contains(t.relatedTarget)||this.dom.controller===t.relatedTarget||this.close()})}_handleClick(){this.dom.controller.addEventListener("pointerup",t=>{this.currentEvent="mouse",t.button===0&&(f(t),this.toggle())}),document.addEventListener("pointerup",t=>{this.focusState!=="self"||!this.closeOnBlur||(this.currentEvent="mouse",!this.dom.disclosure.contains(t.target)&&this.dom.controller!==t.target&&this.close())})}_handleKeydown(){this.dom.controller.addEventListener("keydown",t=>{switch(this.currentEvent="keyboard",p(t)){case"Space":case"Enter":f(t);break}}),this.dom.disclosure.addEventListener("keydown",t=>{switch(this.currentEvent="keyboard",p(t)){case"Escape":f(t);break}})}_handleKeyup(){this.dom.controller.addEventListener("keyup",t=>{switch(this.currentEvent="keyboard",p(t)){case"Space":case"Enter":this.toggle(),f(t);break}}),this.dom.disclosure.addEventListener("keyup",t=>{switch(this.currentEvent="keyboard",p(t)){case"Escape":this.close(),f(t);break}})}open({force:t=!1,preserveState:e=!1}={}){this.isOpen&&!t||(this.focusState="self",this._expand(),this._open.value=!0,e||this._open.commit())}preview({force:t=!1,preserveState:e=!1}={}){this.isOpen&&!t||(this.focusState="none",this._expand(),this._open.value=!0,e||this._open.commit())}close({force:t=!1,preserveState:e=!1}={}){!this.isOpen&&!t||(this.focusState="none",this._collapse(),this._open.value=!1,e||this._open.commit())}toggle({force:t=!1,preserveState:e=!1}={}){this.isOpen?this.close({force:t,preserveState:e}):this.open({force:t,preserveState:e})}},P=K;const D=/[\11\12\14\15\40]+/,b="data-once",H=document;function E(t,e,s){return t[`${e}Attribute`](b,s)}function m(t){if(typeof t!="string")throw new TypeError("once ID must be a string");if(t===""||D.test(t))throw new RangeError("once ID must not be empty or contain spaces");return`[${b}~="${t}"]`}function Q(t){if(!(t instanceof Element))throw new TypeError("The element must be an instance of Element");return!0}function _(t,e=H){let s=t;if(t===null)s=[];else if(t)if(e instanceof Document||e instanceof DocumentFragment||e instanceof Element)typeof t=="string"?s=e.querySelectorAll(t):t instanceof Element&&(s=[t]);else throw new TypeError('Context must be an object of type "Document", "DocumentFragment", or "Element".');else throw new TypeError("Selector must not be empty");return Array.prototype.slice.call(s)}function k(t,e,s){return e.filter(i=>{const r=Q(i)&&i.matches(t);return r&&s&&s(i),r})}function C(t,{add:e,remove:s}){const i=[];E(t,"has")&&E(t,"get").trim().split(D).forEach(n=>{i.indexOf(n)<0&&n!==s&&i.push(n)}),e&&i.push(e);const r=i.join(" ");E(t,r===""?"remove":"set",r)}function g(t,e,s){return k(`:not(${m(t)})`,_(e,s),i=>C(i,{add:t}))}g.remove=(t,e,s)=>k(m(t),_(e,s),i=>C(i,{remove:t})),g.filter=(t,e,s)=>k(m(t),_(e,s)),g.find=(t,e)=>_(t?m(t):`[${b}]`,e);var $=g;const U=({options:t={},context:e=document,disclosureSelector:s=".disclosure",controllerSelector:i=".disclosure-toggle"}={})=>{$("graupl-disclosure-generator",s,e).forEach(r=>{const n=r.dataset.grauplDisclosureOptions?JSON.parse(r.dataset.grauplDisclosureOptions.replace(/'/g,'"'))||{}:{},a=`${i}[data-graupl-disclosure-target="${r.id}"]`,[c]=$("graupl-disclosure-generator",a,e);if(!c){console.warn(`No controller found for disclosure with ID "${r.id}". Please ensure there is an element with the selector "${a}".`),$.remove("graupl-disclosure-generator",r);return}new P({disclosureElement:r,controllerElement:c,initialize:!0,...t,...n})})};var J=U;export{J as default};
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=disclosure.es.js.map
|