@graupl/graupl 1.0.0-alpha.9 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/codeql-analysis.yml +3 -3
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/CHANGELOG.md +153 -0
- package/build.js +7 -0
- package/dist/css/base/button.css +2 -0
- package/dist/css/base/button.css.map +1 -0
- package/dist/css/base/form.css +2 -0
- package/dist/css/base/form.css.map +1 -0
- package/dist/css/base/link.css +2 -0
- package/dist/css/base/link.css.map +1 -0
- package/dist/css/base/table.css +2 -0
- package/dist/css/base/table.css.map +1 -0
- package/dist/css/base.css +2 -0
- package/dist/css/base.css.map +1 -0
- package/dist/css/component/accordion.css +2 -0
- package/dist/css/component/accordion.css.map +1 -0
- package/dist/css/component/alert.css +2 -0
- package/dist/css/component/alert.css.map +1 -0
- package/dist/css/component/card.css +2 -0
- package/dist/css/component/card.css.map +1 -0
- package/dist/css/component/carousel.css +2 -0
- package/dist/css/component/carousel.css.map +1 -0
- package/dist/{component → css/component}/input-group.css +1 -1
- package/dist/css/component/input-group.css.map +1 -0
- package/dist/css/component/menu.css +2 -0
- package/dist/css/component/menu.css.map +1 -0
- package/dist/css/component/navigation.css +2 -0
- package/dist/css/component/navigation.css.map +1 -0
- package/dist/css/component.css +2 -0
- package/dist/css/component.css.map +1 -0
- package/dist/css/graupl.css +2 -0
- package/dist/css/graupl.css.map +1 -0
- package/dist/css/init.css +2 -0
- package/dist/css/init.css.map +1 -0
- package/dist/css/layout/columns.css +2 -0
- package/dist/css/layout/columns.css.map +1 -0
- package/dist/css/layout/container.css.map +1 -0
- package/dist/css/layout/flex-columns.css +2 -0
- package/dist/css/layout/flex-columns.css.map +1 -0
- package/dist/css/layout.css +2 -0
- package/dist/css/layout.css.map +1 -0
- package/dist/css/normalize.css +2 -0
- package/dist/css/normalize.css.map +1 -0
- package/dist/css/state/focus.css +2 -0
- package/dist/css/state/focus.css.map +1 -0
- package/dist/css/state.css +2 -0
- package/dist/css/state.css.map +1 -0
- package/dist/css/theme/color.css +2 -0
- package/dist/css/theme/color.css.map +1 -0
- package/dist/css/theme/typography.css +2 -0
- package/dist/css/theme/typography.css.map +1 -0
- package/dist/css/theme.css +2 -0
- package/dist/css/theme.css.map +1 -0
- package/dist/css/utilities/alignment.css +2 -0
- package/dist/css/utilities/alignment.css.map +1 -0
- package/dist/{utilities/colors.css → css/utilities/color.css} +2 -2
- package/dist/css/utilities/color.css.map +1 -0
- package/dist/css/utilities/display.css +2 -0
- package/dist/css/utilities/display.css.map +1 -0
- package/dist/css/utilities/flex.css +2 -0
- package/dist/css/utilities/flex.css.map +1 -0
- package/dist/css/utilities/height.css +2 -0
- package/dist/css/utilities/height.css.map +1 -0
- package/dist/css/utilities/inset.css +2 -0
- package/dist/css/utilities/inset.css.map +1 -0
- package/dist/css/utilities/justification.css +2 -0
- package/dist/css/utilities/justification.css.map +1 -0
- package/dist/css/utilities/list.css +2 -0
- package/dist/css/utilities/list.css.map +1 -0
- package/dist/css/utilities/order.css +2 -0
- package/dist/css/utilities/order.css.map +1 -0
- package/dist/css/utilities/postion.css +2 -0
- package/dist/css/utilities/postion.css.map +1 -0
- package/dist/css/utilities/ratio.css +2 -0
- package/dist/css/utilities/ratio.css.map +1 -0
- package/dist/css/utilities/spacing.css +2 -0
- package/dist/css/utilities/spacing.css.map +1 -0
- package/dist/css/utilities/typography.css +2 -0
- package/dist/css/utilities/typography.css.map +1 -0
- package/dist/css/utilities/visibility.css +2 -0
- package/dist/css/utilities/visibility.css.map +1 -0
- package/dist/css/utilities/width.css +2 -0
- package/dist/css/utilities/width.css.map +1 -0
- package/dist/css/utilities.css +2 -0
- package/dist/css/utilities.css.map +1 -0
- package/dist/js/component/accordion.cjs.js +3 -0
- package/dist/js/component/accordion.esm.js +1289 -0
- package/dist/js/component/accordion.iife.js +3 -0
- package/dist/js/component/alert.cjs.js +3 -0
- package/dist/js/component/alert.esm.js +529 -0
- package/dist/js/component/alert.iife.js +3 -0
- package/dist/js/component/carousel.cjs.js +3 -0
- package/dist/js/component/carousel.esm.js +1110 -0
- package/dist/js/component/carousel.iife.js +3 -0
- package/dist/js/graupl.cjs.js +5 -0
- package/dist/js/graupl.esm.js +1462 -0
- package/dist/js/graupl.iife.js +5 -0
- package/docs/.vitepress/config.js +39 -12
- package/docs/components/alert.md +130 -0
- package/docs/components/button.md +84 -0
- package/docs/components/card.md +369 -0
- package/docs/components/index.md +1 -0
- package/docs/components/inputgroup.md +159 -0
- package/docs/components/menu.md +326 -0
- package/docs/components/navigation.md +158 -0
- package/docs/content.md +237 -0
- package/docs/defaults.md +121 -0
- package/docs/forms.md +79 -0
- package/docs/functions.md +9 -0
- package/docs/getting-started.md +1 -0
- package/docs/index.md +1 -7
- package/docs/introduction.md +22 -2
- package/docs/layout.md +200 -0
- package/docs/mixins.md +47 -0
- package/docs/state.md +67 -0
- package/docs/theme.md +258 -0
- package/docs/utilities.md +357 -0
- package/eslint.config.js +1 -0
- package/index.html +816 -327
- package/index.js +12 -0
- package/package.json +31 -10
- package/scss/base/button.scss +3 -0
- 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 +3 -0
- package/scss/component/alert.scss +3 -0
- package/scss/component/card.scss +3 -0
- package/scss/component/carousel.scss +3 -0
- package/scss/component/input-group.scss +1 -1
- package/scss/component/menu.scss +3 -0
- package/scss/component/navigation.scss +3 -0
- package/scss/component.scss +1 -1
- package/scss/graupl.scss +1 -3
- package/scss/init.scss +3 -0
- package/scss/layout/columns.scss +1 -1
- package/scss/layout/container.scss +1 -1
- package/scss/layout/flex-columns.scss +3 -0
- package/scss/layout.scss +1 -1
- package/scss/normalize.scss +3 -0
- 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 +3 -0
- package/scss/utilities/color.scss +3 -0
- package/scss/utilities/display.scss +3 -0
- package/scss/utilities/flex.scss +3 -0
- package/scss/utilities/height.scss +3 -0
- package/scss/utilities/inset.scss +3 -0
- package/scss/utilities/justification.scss +3 -0
- package/scss/utilities/list.scss +3 -0
- package/scss/utilities/order.scss +3 -0
- package/scss/utilities/postion.scss +3 -0
- package/scss/utilities/ratio.scss +3 -0
- package/scss/utilities/spacing.scss +1 -1
- package/scss/utilities/typography.scss +1 -1
- package/scss/utilities/visibility.scss +3 -0
- package/scss/utilities/width.scss +3 -0
- package/scss/utilities.scss +1 -1
- package/src/js/accordion/Accordion.js +1163 -0
- package/src/js/accordion/AccordionItem.js +496 -0
- package/src/js/accordion/index.js +10 -0
- package/src/js/alert/Alert.js +581 -0
- package/src/js/alert/index.js +11 -0
- package/src/js/carousel/Carousel.js +1427 -0
- package/src/js/carousel/index.js +10 -0
- package/src/js/domHelpers.js +37 -0
- package/src/js/eventHandlers.js +39 -0
- package/src/js/navigation/index.js +36 -0
- package/src/js/storage.js +106 -0
- package/src/js/validate.js +225 -0
- package/src/scss/_defaults.scss +74 -5
- package/src/scss/_index.scss +4 -3
- package/src/scss/_init.scss +2 -2
- package/src/scss/_normalize.scss +197 -0
- package/src/scss/_variables.scss +7 -7
- package/src/scss/base/_index.scss +2 -1
- package/src/scss/base/button/_defaults.scss +60 -0
- package/src/scss/base/button/_index.scss +107 -0
- package/src/scss/base/button/_mixins.scss +166 -0
- package/src/scss/{component → base}/button/_variables.scss +64 -19
- package/src/scss/base/form/_defaults.scss +14 -4
- package/src/scss/base/form/_index.scss +23 -20
- package/src/scss/base/form/_variables.scss +14 -2
- package/src/scss/base/link/_defaults.scss +48 -5
- package/src/scss/base/link/_index.scss +111 -10
- package/src/scss/base/link/_variables.scss +234 -4
- package/src/scss/base/table/_defaults.scss +49 -4
- package/src/scss/base/table/_index.scss +102 -8
- package/src/scss/base/table/_variables.scss +75 -5
- package/src/scss/component/_index.scss +7 -3
- package/src/scss/component/accordion/_defaults.scss +40 -0
- package/src/scss/component/accordion/_index.scss +180 -0
- package/src/scss/component/accordion/_variables.scss +316 -0
- package/src/scss/component/alert/_defaults.scss +49 -0
- package/src/scss/component/alert/_index.scss +118 -0
- package/src/scss/component/alert/_variables.scss +173 -0
- package/src/scss/component/card/_defaults.scss +32 -0
- package/src/scss/component/card/_index.scss +178 -0
- package/src/scss/component/card/_variables.scss +186 -0
- package/src/scss/component/carousel/_defaults.scss +43 -0
- package/src/scss/component/carousel/_index.scss +188 -0
- package/src/scss/component/carousel/_variables.scss +104 -0
- package/src/scss/component/input-group/_defaults.scss +11 -4
- package/src/scss/component/input-group/_index.scss +13 -11
- package/src/scss/component/input-group/_variables.scss +4 -1
- package/src/scss/component/menu/_defaults.scss +66 -0
- package/src/scss/component/menu/_index.scss +305 -0
- package/src/scss/component/menu/_variables.scss +500 -0
- package/src/scss/component/navigation/_defaults.scss +29 -0
- package/src/scss/component/navigation/_index.scss +189 -0
- package/src/scss/component/navigation/_variables.scss +237 -0
- package/src/scss/functions/_important.scss +2 -0
- package/src/scss/functions/_screen.scss +30 -0
- package/src/scss/functions/_theme.scss +28 -7
- package/src/scss/layout/_index.scss +2 -1
- package/src/scss/layout/columns/_defaults.scss +12 -4
- package/src/scss/layout/columns/_index.scss +29 -7
- package/src/scss/layout/columns/_variables.scss +6 -2
- package/src/scss/layout/container/_defaults.scss +13 -4
- package/src/scss/layout/container/_index.scss +12 -7
- package/src/scss/layout/container/_variables.scss +4 -1
- package/src/scss/layout/flex-columns/_defaults.scss +18 -0
- package/src/scss/layout/flex-columns/_index.scss +80 -0
- package/src/scss/layout/flex-columns/_variables.scss +26 -0
- package/src/scss/mixins/_animation.scss +15 -0
- package/src/scss/mixins/_layer.scss +3 -5
- package/src/scss/mixins/_screen.scss +56 -0
- package/src/scss/mixins/_utility.scss +30 -0
- package/src/scss/mixins/_visually-hidden.scss +20 -0
- package/src/scss/state/_index.scss +1 -1
- package/src/scss/state/focus/_defaults.scss +6 -4
- package/src/scss/state/focus/_index.scss +7 -7
- package/src/scss/state/focus/_mixins.scss +15 -0
- package/src/scss/state/focus/_variables.scss +6 -2
- package/src/scss/theme/_index.scss +1 -1
- package/src/scss/theme/color/_defaults.scss +101 -19
- package/src/scss/theme/color/_index.scss +17 -17
- package/src/scss/theme/color/_variables.scss +72 -64
- package/src/scss/theme/typography/_defaults.scss +7 -5
- package/src/scss/theme/typography/_index.scss +1 -1
- package/src/scss/theme/typography/_variables.scss +11 -7
- package/src/scss/utilities/_index.scss +14 -2
- package/src/scss/utilities/alignment/_defaults.scss +62 -0
- package/src/scss/utilities/alignment/_index.scss +75 -0
- package/src/scss/utilities/alignment/_variables.scss +6 -0
- package/src/scss/utilities/color/_defaults.scss +35 -0
- package/src/scss/utilities/color/_index.scss +91 -0
- package/src/scss/utilities/color/_variables.scss +6 -0
- package/src/scss/utilities/display/_defaults.scss +32 -0
- package/src/scss/utilities/display/_index.scss +61 -0
- package/src/scss/utilities/display/_variables.scss +6 -0
- package/src/scss/utilities/flex/_defaults.scss +63 -0
- package/src/scss/utilities/flex/_index.scss +71 -0
- package/src/scss/utilities/flex/_variables.scss +6 -0
- package/src/scss/utilities/height/_defaults.scss +41 -0
- package/src/scss/utilities/height/_index.scss +98 -0
- package/src/scss/utilities/height/_variables.scss +6 -0
- package/src/scss/utilities/inset/_defaults.scss +41 -0
- package/src/scss/utilities/inset/_index.scss +37 -0
- package/src/scss/utilities/inset/_variables.scss +6 -0
- package/src/scss/utilities/justification/_defaults.scss +59 -0
- package/src/scss/utilities/justification/_index.scss +75 -0
- package/src/scss/utilities/justification/_variables.scss +6 -0
- package/src/scss/utilities/list/_defaults.scss +39 -0
- package/src/scss/utilities/list/_index.scss +56 -0
- package/src/scss/utilities/list/_variables.scss +6 -0
- package/src/scss/utilities/order/_defaults.scss +22 -0
- package/src/scss/utilities/order/_index.scss +63 -0
- package/src/scss/utilities/order/_variables.scss +6 -0
- package/src/scss/utilities/position/_defaults.scss +26 -0
- package/src/scss/utilities/position/_index.scss +37 -0
- package/src/scss/utilities/position/_variables.scss +6 -0
- package/src/scss/utilities/ratio/_defaults.scss +28 -0
- package/src/scss/utilities/ratio/_index.scss +52 -0
- package/src/scss/utilities/ratio/_variables.scss +9 -0
- package/src/scss/utilities/spacing/_defaults.scss +9 -4
- package/src/scss/utilities/spacing/_index.scss +134 -29
- package/src/scss/utilities/spacing/_variables.scss +5 -2
- package/src/scss/utilities/typography/_defaults.scss +29 -4
- package/src/scss/utilities/typography/_index.scss +155 -23
- package/src/scss/utilities/typography/_variables.scss +5 -2
- package/src/scss/utilities/visibility/_defaults.scss +25 -0
- package/src/scss/utilities/visibility/_index.scss +36 -0
- package/src/scss/utilities/visibility/_variables.scss +6 -0
- package/src/scss/utilities/width/_defaults.scss +41 -0
- package/src/scss/utilities/width/_index.scss +98 -0
- package/src/scss/utilities/width/_variables.scss +6 -0
- package/stylelint.config.js +5 -0
- package/vite.config.js +57 -0
- package/dist/base/form.css +0 -2
- package/dist/base/form.css.map +0 -1
- package/dist/base/link.css +0 -2
- package/dist/base/link.css.map +0 -1
- package/dist/base/table.css +0 -2
- package/dist/base/table.css.map +0 -1
- package/dist/base.css +0 -2
- package/dist/base.css.map +0 -1
- package/dist/component/button.css +0 -2
- package/dist/component/button.css.map +0 -1
- package/dist/component/input-group.css.map +0 -1
- package/dist/component/table.css +0 -2
- package/dist/component/table.css.map +0 -1
- package/dist/component.css +0 -2
- package/dist/component.css.map +0 -1
- package/dist/graupl.css +0 -2
- package/dist/graupl.css.map +0 -1
- package/dist/layout/columns.css +0 -2
- package/dist/layout/columns.css.map +0 -1
- package/dist/layout/container.css.map +0 -1
- package/dist/layout.css +0 -2
- package/dist/layout.css.map +0 -1
- package/dist/state/focus.css +0 -2
- package/dist/state/focus.css.map +0 -1
- package/dist/state.css +0 -2
- package/dist/state.css.map +0 -1
- package/dist/theme/color.css +0 -2
- package/dist/theme/color.css.map +0 -1
- package/dist/theme/typography.css +0 -2
- package/dist/theme/typography.css.map +0 -1
- package/dist/theme.css +0 -2
- package/dist/theme.css.map +0 -1
- package/dist/utilities/colors.css.map +0 -1
- package/dist/utilities/spacing.css +0 -2
- package/dist/utilities/spacing.css.map +0 -1
- package/dist/utilities/typography.css +0 -2
- package/dist/utilities/typography.css.map +0 -1
- package/dist/utilities.css +0 -2
- package/dist/utilities.css.map +0 -1
- package/scss/component/button.scss +0 -3
- package/scss/component/table.scss +0 -3
- package/scss/utilities/colors.scss +0 -3
- package/src/scss/component/button/_defaults.scss +0 -39
- package/src/scss/component/button/_index.scss +0 -98
- package/src/scss/component/table/_defaults.scss +0 -30
- package/src/scss/component/table/_index.scss +0 -77
- package/src/scss/component/table/_variables.scss +0 -64
- package/src/scss/mixins/_media-queries.scss +0 -26
- package/src/scss/utilities/colors/_defaults.scss +0 -5
- package/src/scss/utilities/colors/_index.scss +0 -22
- package/src/scss/utilities/colors/_variables.scss +0 -3
- /package/dist/{layout → css/layout}/container.css +0 -0
|
@@ -0,0 +1,1462 @@
|
|
|
1
|
+
var F = Object.defineProperty;
|
|
2
|
+
var O = (e, t, s) => t in e ? F(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
+
var r = (e, t, s) => O(e, typeof t != "symbol" ? t + "" : t, s);
|
|
4
|
+
function f(e, t) {
|
|
5
|
+
try {
|
|
6
|
+
if (typeof t != "object") {
|
|
7
|
+
const s = typeof t;
|
|
8
|
+
throw new TypeError(
|
|
9
|
+
`Elements given to isValidInstance() must be inside of an object. "${s}" given.`
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
for (const s in t)
|
|
13
|
+
if (!(t[s] instanceof e)) {
|
|
14
|
+
const i = typeof t[s];
|
|
15
|
+
throw new TypeError(
|
|
16
|
+
`${s} must be an instance of ${e.name}. "${i}" given.`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
status: !0,
|
|
21
|
+
error: null
|
|
22
|
+
};
|
|
23
|
+
} catch (s) {
|
|
24
|
+
return {
|
|
25
|
+
status: !1,
|
|
26
|
+
error: s
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function a(e, t) {
|
|
31
|
+
try {
|
|
32
|
+
if (typeof t != "object") {
|
|
33
|
+
const s = typeof t;
|
|
34
|
+
throw new TypeError(
|
|
35
|
+
`Values given to isValidType() must be inside of an object. "${s}" given.`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
for (const s in t) {
|
|
39
|
+
const i = typeof t[s];
|
|
40
|
+
if (i !== e)
|
|
41
|
+
throw new TypeError(`${s} must be a ${e}. "${i}" given.`);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
status: !0,
|
|
45
|
+
error: null
|
|
46
|
+
};
|
|
47
|
+
} catch (s) {
|
|
48
|
+
return {
|
|
49
|
+
status: !1,
|
|
50
|
+
error: s
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function w(e) {
|
|
55
|
+
try {
|
|
56
|
+
if (typeof e != "object") {
|
|
57
|
+
const t = typeof e;
|
|
58
|
+
throw new TypeError(
|
|
59
|
+
`Values given to isQuerySelector() must be inside of an object. "${t}" given.`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
for (const t in e)
|
|
63
|
+
try {
|
|
64
|
+
if (e[t] === null)
|
|
65
|
+
throw new Error();
|
|
66
|
+
document.querySelector(e[t]);
|
|
67
|
+
} catch {
|
|
68
|
+
throw new TypeError(
|
|
69
|
+
`${t} must be a valid query selector. "${e[t]}" given.`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
status: !0,
|
|
74
|
+
error: null
|
|
75
|
+
};
|
|
76
|
+
} catch (t) {
|
|
77
|
+
return {
|
|
78
|
+
status: !1,
|
|
79
|
+
error: t
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function h(e) {
|
|
84
|
+
try {
|
|
85
|
+
if (typeof e != "object" || Array.isArray(e)) {
|
|
86
|
+
const t = typeof e;
|
|
87
|
+
throw new TypeError(
|
|
88
|
+
`Values given to isValidClassList() must be inside of an object. "${t}" given.`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
for (const t in e) {
|
|
92
|
+
const s = typeof e[t];
|
|
93
|
+
if (s !== "string")
|
|
94
|
+
if (Array.isArray(e[t]))
|
|
95
|
+
e[t].forEach((i) => {
|
|
96
|
+
if (typeof i != "string")
|
|
97
|
+
throw new TypeError(
|
|
98
|
+
`${t} must be a string or an array of strings. An array containing non-strings given.`
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
else
|
|
102
|
+
throw new TypeError(
|
|
103
|
+
`${t} must be a string or an array of strings. "${s}" given.`
|
|
104
|
+
);
|
|
105
|
+
else {
|
|
106
|
+
const i = {};
|
|
107
|
+
i[t] = e[t], w(i);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
status: !0,
|
|
112
|
+
error: null
|
|
113
|
+
};
|
|
114
|
+
} catch (t) {
|
|
115
|
+
return {
|
|
116
|
+
status: !1,
|
|
117
|
+
error: t
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function g(e, t) {
|
|
122
|
+
if (a("string", { tagName: e }).status && f(HTMLElement, t).status) {
|
|
123
|
+
const s = e.toLowerCase();
|
|
124
|
+
let i = !0;
|
|
125
|
+
for (const n in t)
|
|
126
|
+
t[n].tagName.toLowerCase() !== s && (i = !1);
|
|
127
|
+
return i;
|
|
128
|
+
} else
|
|
129
|
+
return !1;
|
|
130
|
+
}
|
|
131
|
+
function u(e, t) {
|
|
132
|
+
e === "" || e.length === 0 || (typeof e == "string" ? t.classList.add(e) : t.classList.add(...e));
|
|
133
|
+
}
|
|
134
|
+
function c(e, t) {
|
|
135
|
+
e === "" || e.length === 0 || (typeof e == "string" ? t.classList.remove(e) : t.classList.remove(...e));
|
|
136
|
+
}
|
|
137
|
+
function m(e) {
|
|
138
|
+
try {
|
|
139
|
+
const t = e.key || e.keyCode, s = {
|
|
140
|
+
Enter: t === "Enter" || t === 13,
|
|
141
|
+
Space: t === " " || t === "Spacebar" || t === 32,
|
|
142
|
+
Escape: t === "Escape" || t === "Esc" || t === 27,
|
|
143
|
+
ArrowUp: t === "ArrowUp" || t === "Up" || t === 38,
|
|
144
|
+
ArrowRight: t === "ArrowRight" || t === "Right" || t === 39,
|
|
145
|
+
ArrowDown: t === "ArrowDown" || t === "Down" || t === 40,
|
|
146
|
+
ArrowLeft: t === "ArrowLeft" || t === "Left" || t === 37,
|
|
147
|
+
Home: t === "Home" || t === 36,
|
|
148
|
+
End: t === "End" || t === 35,
|
|
149
|
+
Tab: t === "Tab" || t === 9
|
|
150
|
+
};
|
|
151
|
+
return Object.keys(s).find((i) => s[i] === !0) || "";
|
|
152
|
+
} catch {
|
|
153
|
+
return "";
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function _(e) {
|
|
157
|
+
e.preventDefault(), e.stopPropagation();
|
|
158
|
+
}
|
|
159
|
+
function q(e = null) {
|
|
160
|
+
window.Graupl = window.Graupl || {}, a("string", { type: e }) && (window.Graupl[e] = window.Graupl[e] || {});
|
|
161
|
+
}
|
|
162
|
+
function j(e = null) {
|
|
163
|
+
return a("string", { type: e }) ? window.Graupl[e] : window.Graupl;
|
|
164
|
+
}
|
|
165
|
+
function K(e, t = {}) {
|
|
166
|
+
a("string", { type: e }) && a("object", { data: t }) && (window.Graupl[e] = t);
|
|
167
|
+
}
|
|
168
|
+
function z(e) {
|
|
169
|
+
a("string", { type: e }) && (window.Graupl[e] = {});
|
|
170
|
+
}
|
|
171
|
+
function H(e, t, s) {
|
|
172
|
+
a("string", { type: e, key: t }) && (window.Graupl[e][t] = s);
|
|
173
|
+
}
|
|
174
|
+
function P(e, t) {
|
|
175
|
+
return a("string", { type: e, key: t }) ? window.Graupl[e][t] : null;
|
|
176
|
+
}
|
|
177
|
+
function V(e, t) {
|
|
178
|
+
a("string", { type: e, key: t }) && delete window.Graupl[e][t];
|
|
179
|
+
}
|
|
180
|
+
const C = {
|
|
181
|
+
initializeStorage: q,
|
|
182
|
+
getStorage: j,
|
|
183
|
+
setStorage: K,
|
|
184
|
+
clearStorage: z,
|
|
185
|
+
pushToStorage: H,
|
|
186
|
+
getFromStorage: P,
|
|
187
|
+
removeFromStorage: V
|
|
188
|
+
};
|
|
189
|
+
class R {
|
|
190
|
+
/**
|
|
191
|
+
* Constructs a new `Alert`.
|
|
192
|
+
*
|
|
193
|
+
* @param {object} options - The options object.
|
|
194
|
+
* @param {HTMLElement} options.alertElement - The alert element.
|
|
195
|
+
* @param {?HTMLElement} [options.controllerElement = null] - The controller element.
|
|
196
|
+
* @param {string|string[]|null} [options.showClass = show] - The class to add when the alert is shown.
|
|
197
|
+
* @param {string|string[]|null} [options.hideClass = hide] - The class to add when
|
|
198
|
+
* @param {string|string[]|null} [options.transitionClass = transitioning] - The class to add when the alert is transitioning between shown and hidden.
|
|
199
|
+
* @param {number} [options.transitionTimer = 150] - The time in milliseconds the transition will take.
|
|
200
|
+
* @param {boolean} [options.isHidden = false] - A flag to determine the initial state of the alert.
|
|
201
|
+
* @param {?string} [options.key = null] - The key used to generate IDs throughout the alert.
|
|
202
|
+
* @param {boolean} [options.initialize = false] - AA flag to initialize the alert immediately upon creation.
|
|
203
|
+
*/
|
|
204
|
+
constructor({
|
|
205
|
+
alertElement: t,
|
|
206
|
+
controllerElement: s = null,
|
|
207
|
+
showClass: i = "show",
|
|
208
|
+
hideClass: n = "hide",
|
|
209
|
+
transitionClass: l = "transitioning",
|
|
210
|
+
transitionTimer: d = 150,
|
|
211
|
+
isHidden: p = !1,
|
|
212
|
+
key: o = null,
|
|
213
|
+
initialize: y = !1
|
|
214
|
+
}) {
|
|
215
|
+
/**
|
|
216
|
+
* The HTML elements for the alert in the DOM.
|
|
217
|
+
*
|
|
218
|
+
* @protected
|
|
219
|
+
*
|
|
220
|
+
* @type {Object<HTMLElement>}
|
|
221
|
+
*/
|
|
222
|
+
r(this, "_dom", {
|
|
223
|
+
alert: null,
|
|
224
|
+
controller: null
|
|
225
|
+
});
|
|
226
|
+
/**
|
|
227
|
+
* A flag to determine if the alert is hidden.
|
|
228
|
+
*
|
|
229
|
+
* @protected
|
|
230
|
+
*
|
|
231
|
+
* @type {boolean}
|
|
232
|
+
*/
|
|
233
|
+
r(this, "_hidden", !1);
|
|
234
|
+
/**
|
|
235
|
+
* The class to use to show the alert.
|
|
236
|
+
*
|
|
237
|
+
* @protected
|
|
238
|
+
*
|
|
239
|
+
* @type {string|string[]}
|
|
240
|
+
*/
|
|
241
|
+
r(this, "_showClass", "");
|
|
242
|
+
/**
|
|
243
|
+
* The class to use to hide the alert.
|
|
244
|
+
*
|
|
245
|
+
* @protected
|
|
246
|
+
*
|
|
247
|
+
* @type {string|string[]}
|
|
248
|
+
*/
|
|
249
|
+
r(this, "_hideClass", "");
|
|
250
|
+
/**
|
|
251
|
+
* The class to use when transitioning the alert.
|
|
252
|
+
*
|
|
253
|
+
* @protected
|
|
254
|
+
*
|
|
255
|
+
* @type {string|string[]}
|
|
256
|
+
*/
|
|
257
|
+
r(this, "_transitionClass", "");
|
|
258
|
+
/**
|
|
259
|
+
* The time in milliseconds the transition will take.
|
|
260
|
+
*
|
|
261
|
+
* @protected
|
|
262
|
+
*
|
|
263
|
+
* @type {number}
|
|
264
|
+
*/
|
|
265
|
+
r(this, "_transitionTimer", 150);
|
|
266
|
+
/**
|
|
267
|
+
* The key used to generate IDs throughout the carousel.
|
|
268
|
+
*
|
|
269
|
+
* @protected
|
|
270
|
+
*
|
|
271
|
+
* @type {string}
|
|
272
|
+
*/
|
|
273
|
+
r(this, "_key", "");
|
|
274
|
+
/**
|
|
275
|
+
* An array of error messages generated by the alert.
|
|
276
|
+
*
|
|
277
|
+
* @protected
|
|
278
|
+
*
|
|
279
|
+
* @type {string[]}
|
|
280
|
+
*/
|
|
281
|
+
r(this, "_errors", []);
|
|
282
|
+
/**
|
|
283
|
+
* The event that is triggered when the alert is shown.
|
|
284
|
+
*
|
|
285
|
+
* @protected
|
|
286
|
+
*
|
|
287
|
+
* @event grauplAlertShow
|
|
288
|
+
*
|
|
289
|
+
* @type {CustomEvent}
|
|
290
|
+
*
|
|
291
|
+
* @property {boolean} bubbles - A flag to bubble the event.
|
|
292
|
+
* @property {Object<Alert>} detail - The details object container the Alert itself.
|
|
293
|
+
*/
|
|
294
|
+
r(this, "_showEvent", new CustomEvent("grauplAlertShow", {
|
|
295
|
+
bubbles: !0,
|
|
296
|
+
detail: { alert: this }
|
|
297
|
+
}));
|
|
298
|
+
/**
|
|
299
|
+
* The event that is triggered when the alert is hidden.
|
|
300
|
+
*
|
|
301
|
+
* @protected
|
|
302
|
+
*
|
|
303
|
+
* @event grauplAlertHide
|
|
304
|
+
*
|
|
305
|
+
* @type {CustomEvent}
|
|
306
|
+
*
|
|
307
|
+
* @property {boolean} bubbles - A flag to bubble the event.
|
|
308
|
+
* @property {Object<Alert>} detail - The details object containing the Alert itself.
|
|
309
|
+
*/
|
|
310
|
+
r(this, "_hideEvent", new CustomEvent("grauplAlertHide", {
|
|
311
|
+
bubbles: !0,
|
|
312
|
+
detail: { alert: this }
|
|
313
|
+
}));
|
|
314
|
+
this._dom.alert = t, this._dom.controller = s, this._showClass = i || "", this._hideClass = n || "", this._transitionClass = l || "", this._transitionTimer = d, this._hidden = p, this._key = o || "", y && this.initialize();
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Initializes the alert.
|
|
318
|
+
*/
|
|
319
|
+
initialize() {
|
|
320
|
+
try {
|
|
321
|
+
if (!this._validate())
|
|
322
|
+
throw new Error(
|
|
323
|
+
`Graupl Alert: cannot initialize alert. The following errors have been found:
|
|
324
|
+
- ${this.errors.join(
|
|
325
|
+
`
|
|
326
|
+
- `
|
|
327
|
+
)}`
|
|
328
|
+
);
|
|
329
|
+
this._generateKey(), this._setIds(), this._handleClick(), this._handleKeydown(), this._handleKeyup(), C.initializeStorage("alerts"), C.pushToStorage("alerts", this.dom.alert.id, this);
|
|
330
|
+
} catch (t) {
|
|
331
|
+
console.error(t);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* The HTML elements for the alert in the DOM.
|
|
336
|
+
*
|
|
337
|
+
* @readonly
|
|
338
|
+
*
|
|
339
|
+
* @see _dom
|
|
340
|
+
*
|
|
341
|
+
* @type {object}
|
|
342
|
+
*/
|
|
343
|
+
get dom() {
|
|
344
|
+
return this._dom;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* The class to use the show the alert.
|
|
348
|
+
*
|
|
349
|
+
* @type {string|string[]}
|
|
350
|
+
*
|
|
351
|
+
* @see _showClass
|
|
352
|
+
*/
|
|
353
|
+
get showClass() {
|
|
354
|
+
return this._showClass;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* The class to use to hide the alert.
|
|
358
|
+
*
|
|
359
|
+
* @type {string|string[]}
|
|
360
|
+
*
|
|
361
|
+
* @see _hideClass
|
|
362
|
+
*/
|
|
363
|
+
get hideClass() {
|
|
364
|
+
return this._hideClass;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* The class to use when transitioning the alert.
|
|
368
|
+
*
|
|
369
|
+
* @type {string|string[]}
|
|
370
|
+
*
|
|
371
|
+
* @see _transitionClass
|
|
372
|
+
*/
|
|
373
|
+
get transitionClass() {
|
|
374
|
+
return this._transitionClass;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* The time in milliseconds the transition will take.
|
|
378
|
+
*
|
|
379
|
+
* @type {number}
|
|
380
|
+
*
|
|
381
|
+
* @see _transitionTimer
|
|
382
|
+
*/
|
|
383
|
+
get transitionTimer() {
|
|
384
|
+
return this._transitionTimer;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* The key used to generate IDs throughout the accordion.
|
|
388
|
+
*
|
|
389
|
+
* @type {string}
|
|
390
|
+
*
|
|
391
|
+
* @see _key
|
|
392
|
+
*/
|
|
393
|
+
get key() {
|
|
394
|
+
return this._key;
|
|
395
|
+
}
|
|
396
|
+
set showClass(t) {
|
|
397
|
+
h({ showClass: t }), this._showClass !== t && (this._showClass = t);
|
|
398
|
+
}
|
|
399
|
+
set hideClass(t) {
|
|
400
|
+
h({ hideClass: t }), this._hideClass !== t && (this._hideClass = t);
|
|
401
|
+
}
|
|
402
|
+
set transitionClass(t) {
|
|
403
|
+
h({ transitionClass: t }), this._transitionClass !== t && (this._transitionClass = t);
|
|
404
|
+
}
|
|
405
|
+
set transitionTimer(t) {
|
|
406
|
+
a("number", { transitionTimer: t }), this._transitionTimer !== t && (this._transitionTimer = t);
|
|
407
|
+
}
|
|
408
|
+
set key(t) {
|
|
409
|
+
a("string", { value: t }), this._key !== t && (this._key = t);
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Validates all aspects of the alert to ensure proper functionality.
|
|
413
|
+
*
|
|
414
|
+
* @protected
|
|
415
|
+
*
|
|
416
|
+
* @return {boolean} - The result of the validation.
|
|
417
|
+
*/
|
|
418
|
+
_validate() {
|
|
419
|
+
let t = !0, s;
|
|
420
|
+
if (this._dom.controller !== null ? s = f(HTMLElement, {
|
|
421
|
+
alertElement: this._dom.alert,
|
|
422
|
+
controllerElement: this._dom.controller
|
|
423
|
+
}) : s = f(HTMLElement, {
|
|
424
|
+
alertElement: this._dom.alert
|
|
425
|
+
}), s.status || (this._errors.push(s.message), t = !1), this._showClass !== "") {
|
|
426
|
+
const l = h({ showClass: this._showClass });
|
|
427
|
+
l.status || (this._errors.push(l.message), t = !1);
|
|
428
|
+
}
|
|
429
|
+
if (this._hideClass !== "") {
|
|
430
|
+
const l = h({ hideClass: this._hideClass });
|
|
431
|
+
l.status || (this._errors.push(l.message), t = !1);
|
|
432
|
+
}
|
|
433
|
+
if (this._transitionClass !== "") {
|
|
434
|
+
const l = h({
|
|
435
|
+
transitionClass: this._transitionClass
|
|
436
|
+
});
|
|
437
|
+
l.status || (this._errors.push(l.message), t = !1);
|
|
438
|
+
}
|
|
439
|
+
const i = a("number", {
|
|
440
|
+
transitionTimer: this._transitionTimer
|
|
441
|
+
});
|
|
442
|
+
i.status || (this._errors.push(i.message), t = !1);
|
|
443
|
+
const n = a("boolean", { isHidden: this._hidden });
|
|
444
|
+
return n.status || (this._errors.push(n.message), t = !1), t;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Generates a key for the alert.
|
|
448
|
+
*
|
|
449
|
+
* @param {boolean} [regenerate = false] - A flag to determine if the key should be regenerated.
|
|
450
|
+
*/
|
|
451
|
+
_generateKey(t = !1) {
|
|
452
|
+
(this.key === "" || t) && (this.key = Math.random().toString(36).replace(/[^a-z]+/g, "").substring(0, 10));
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Sets the IDs of the alert and it's children if they do not already exist.
|
|
456
|
+
*
|
|
457
|
+
* The generated IDs use the key and follow the format:
|
|
458
|
+
* - alert: `alert-${key}`
|
|
459
|
+
* - controller: `alert-controller-${key}`
|
|
460
|
+
*/
|
|
461
|
+
_setIds() {
|
|
462
|
+
this.dom.alert.id = this.dom.alert.id || `alert-${this.key}`, this.dom.controller.id = this.dom.controller.id || `alert-controller-${this.key}`;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Shows the alert.
|
|
466
|
+
*
|
|
467
|
+
* @fires grauplAlertShow
|
|
468
|
+
*
|
|
469
|
+
* @param {boolean} [emit = true] - A toggle to emit the show event once shown.
|
|
470
|
+
*/
|
|
471
|
+
show(t = !0) {
|
|
472
|
+
this._hidden && (this.transitionClass !== "" ? (u(this.transitionClass, this.dom.alert), requestAnimationFrame(() => {
|
|
473
|
+
this.hideClass !== "" && c(this.hideClass, this.dom.alert), requestAnimationFrame(() => {
|
|
474
|
+
this.showClass !== "" && u(this.showClass, this.dom.alert), requestAnimationFrame(() => {
|
|
475
|
+
c(this.transitionClass, this.dom.alert);
|
|
476
|
+
});
|
|
477
|
+
});
|
|
478
|
+
})) : (this.showClass !== "" && u(this.showClass, this.dom.alert), this.hideClass !== "" && c(this.hideClass, this.dom.alert)), this._hidden = !1, t && this.dom.alert.dispatchEvent(this._hideEvent));
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Hides the alert.
|
|
482
|
+
*
|
|
483
|
+
* @fires grauplAlertHide
|
|
484
|
+
*
|
|
485
|
+
* @param {boolean} [emit = true] - A toggle to emit the hide event once shown.
|
|
486
|
+
*/
|
|
487
|
+
hide(t = !0) {
|
|
488
|
+
this._hidden || (this.transitionClass !== "" ? (u(this.transitionClass, this.dom.alert), requestAnimationFrame(() => {
|
|
489
|
+
this.showClass !== "" && c(this.showClass, this.dom.alert), requestAnimationFrame(() => {
|
|
490
|
+
this.transitionTimer > 0 ? setTimeout(() => {
|
|
491
|
+
this.hideClass !== "" && u(this.hideClass, this.dom.alert), requestAnimationFrame(() => {
|
|
492
|
+
c(this.transitionClass, this.dom.alert);
|
|
493
|
+
});
|
|
494
|
+
}, this.transitionTimer) : (this.hideClass !== "" && u(this.hideClass, this.dom.alert), requestAnimationFrame(() => {
|
|
495
|
+
c(this.transitionClass, this.dom.alert);
|
|
496
|
+
}));
|
|
497
|
+
});
|
|
498
|
+
})) : (this.hideClass !== "" && u(this.hideClass, this.dom.alert), this.showClass !== "" && c(this.showClass, this.dom.alert)), this._hidden = !0, t && this.dom.alert.dispatchEvent(this._hideEvent));
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Handles click events throughout the alert for proper use.
|
|
502
|
+
*
|
|
503
|
+
* - Adds a `pointerup` listener to the controller that will hide the alert.
|
|
504
|
+
*
|
|
505
|
+
* @protected
|
|
506
|
+
*/
|
|
507
|
+
_handleClick() {
|
|
508
|
+
this.dom.controller !== null && this.dom.controller.addEventListener("pointerup", () => this.hide());
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Handles keydown events throughout the alert for proper use.
|
|
512
|
+
*
|
|
513
|
+
* This method exists to assist the _handleKeyup method.
|
|
514
|
+
*
|
|
515
|
+
* - Adds a `keydown` listener to the controller (if it exists).
|
|
516
|
+
* - Blocks propagation on "Space" and "Enter" keys.
|
|
517
|
+
*/
|
|
518
|
+
_handleKeydown() {
|
|
519
|
+
this.dom.controller !== null && this.dom.controller.addEventListener("keydown", (t) => {
|
|
520
|
+
const s = m(t);
|
|
521
|
+
(s === "Space" || s === "Enter") && _(t);
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Handles keyup events throughout the alert for proper use.
|
|
526
|
+
*
|
|
527
|
+
* - Adds a `keyup` listener to the controller (if it exists).
|
|
528
|
+
* - Hides the alert when the user hits "Space" or "Enter".
|
|
529
|
+
*/
|
|
530
|
+
_handleKeyup() {
|
|
531
|
+
this.dom.controller !== null && this.dom.controller.addEventListener("keyup", (t) => {
|
|
532
|
+
const s = m(t);
|
|
533
|
+
(s === "Space" || s === "Enter") && this.hide();
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
class U {
|
|
538
|
+
/**
|
|
539
|
+
* Contructs a new `Carousel`.
|
|
540
|
+
*
|
|
541
|
+
* @param {object} options - The options for the generated carousel.
|
|
542
|
+
* @param {HTMLElement} options.carouselElement - The carousel element in the DOM.
|
|
543
|
+
* @param {string} [options.carouselItemSelector = .carousel-item] - The query selector string for carousel items.
|
|
544
|
+
* @param {string} [options.carouselItemContainerSelector = .carousel-item-container] - The query selector string for the carousel item container.
|
|
545
|
+
* @param {string} [options.carouselControlSelector = .carousel-control] - The query selector string for carousel controls.
|
|
546
|
+
* @param {string} [options.carouselControlContainerSelector = .carousel-control-container] - The query selector string for carousel control container.
|
|
547
|
+
* @param {string} [options.carouselTabSelector = .carousel-tab] - The query selector string for carousel tabs.
|
|
548
|
+
* @param {string} [options.carouselTabContainerSelector = .carousel-tab-container] - The query selector string for the carousel tab container.
|
|
549
|
+
* @param {string} [options.autoplaySelector = .autoplay] - The query selector string for the autoplay button.
|
|
550
|
+
* @param {string} [options.nextSelector = .next] - The query selector string for the next button.
|
|
551
|
+
* @param {string} [options.previousSelector = .previous] - The query selector string for the previous button.
|
|
552
|
+
* @param {?(string|string[])} [options.activeClass = active] - The class(es) to apply when a carousel item is active.
|
|
553
|
+
* @param {?(string|string[])} [options.previousClass = previous] - The class(es) to apply to a carousel item that is the previously active item.
|
|
554
|
+
* @param {?(string|string[])} [options.nextClass = next] - The class(es) to apply to a carousel item that is the next active item.
|
|
555
|
+
* @param {?(string|string[])} [options.playClass = play] - The class(es) to apply to the autoplay button when the carousel is paused.
|
|
556
|
+
* @param {?(string|string[])} [options.pauseClass = pause] - The class(es) to apply to the autoplay button when the carousel is playing.
|
|
557
|
+
* @param {boolean} [options.autoplay = true] - A flag to indicate if the carousel should autoplay.
|
|
558
|
+
* @param {number} [options.transitionDelay = 10000] - A flag to initialize the carousel immediately upon creation.
|
|
559
|
+
* @param {number} [options.transitionDuration = 500] - The duration time (in milliseconds) for the transition between carousel items.
|
|
560
|
+
* @param {?string} [options.playText = Play] - The text to use for the play button.
|
|
561
|
+
* @param {?string} [options.pauseText = Pause] - The text to use for the pause button.
|
|
562
|
+
* @param {?string} [options.prefix = graupl-] - The prefix to use for CSS custom properties.
|
|
563
|
+
* @param {?string} [options.key = null] - The key used to generate IDs throughout the carousel.
|
|
564
|
+
* @param {boolean} [options.initialize = false] - A flag to initialize the carousel immediately upon creation.
|
|
565
|
+
*/
|
|
566
|
+
constructor({
|
|
567
|
+
carouselElement: t,
|
|
568
|
+
carouselItemSelector: s = ".carousel-item",
|
|
569
|
+
carouselItemContainerSelector: i = ".carousel-item-container",
|
|
570
|
+
carouselControlSelector: n = ".carousel-control",
|
|
571
|
+
carouselControlContainerSelector: l = ".carousel-control-container",
|
|
572
|
+
carouselTabSelector: d = ".carousel-tab",
|
|
573
|
+
carouselTabContainerSelector: p = ".carousel-tab-container",
|
|
574
|
+
autoplaySelector: o = ".autoplay",
|
|
575
|
+
nextSelector: y = ".next",
|
|
576
|
+
previousSelector: b = ".previous",
|
|
577
|
+
activeClass: E = "active",
|
|
578
|
+
previousClass: T = "previous",
|
|
579
|
+
nextClass: I = "next",
|
|
580
|
+
playClass: k = "play",
|
|
581
|
+
pauseClass: v = "pause",
|
|
582
|
+
autoplay: x = !0,
|
|
583
|
+
transitionDelay: A = 1e4,
|
|
584
|
+
transitionDuration: D = 500,
|
|
585
|
+
playText: S = "Play",
|
|
586
|
+
pauseText: L = "Pause",
|
|
587
|
+
prefix: $ = "graupl-",
|
|
588
|
+
key: M = null,
|
|
589
|
+
initialize: G = !1
|
|
590
|
+
}) {
|
|
591
|
+
/**
|
|
592
|
+
* The DOM elements within the carousel.
|
|
593
|
+
*
|
|
594
|
+
* @protected
|
|
595
|
+
*
|
|
596
|
+
* @type {Object<HTMLElement, HTMLElement[]>}
|
|
597
|
+
*
|
|
598
|
+
* @property {HTMLElement} carousel - The carousel element.
|
|
599
|
+
* @property {HTMLElement[]} carouselItems - The carousel items.
|
|
600
|
+
* @property {HTMLElement} carouselItemContainer - The carousel item container.
|
|
601
|
+
* @property {HTMLElement[]} carouselControls - The carousel controls.
|
|
602
|
+
* @property {HTMLElement} carouselControlContainer - The carousel control container.
|
|
603
|
+
* @property {HTMLElement[]} carouselTabs - The carousel tabs.
|
|
604
|
+
* @property {HTMLElement} carouselTabContainer - The carousel tab container.
|
|
605
|
+
* @property {HTMLElement} autoplay - The autoplay button.
|
|
606
|
+
* @property {HTMLElement} next - The next button.
|
|
607
|
+
* @property {HTMLElement} previous - The previous button.
|
|
608
|
+
*/
|
|
609
|
+
r(this, "_dom", {
|
|
610
|
+
carousel: null,
|
|
611
|
+
carouselItems: [],
|
|
612
|
+
carouselItemContainer: null,
|
|
613
|
+
carouselControls: [],
|
|
614
|
+
carouselControlContainer: null,
|
|
615
|
+
carouselTabs: [],
|
|
616
|
+
carouselTabContainer: null,
|
|
617
|
+
autoplay: null,
|
|
618
|
+
next: null,
|
|
619
|
+
previous: null
|
|
620
|
+
});
|
|
621
|
+
/**
|
|
622
|
+
* The query selectors used by the carousel to populate the dom.
|
|
623
|
+
*
|
|
624
|
+
* @protected
|
|
625
|
+
*
|
|
626
|
+
* @type {Object<string>}
|
|
627
|
+
*
|
|
628
|
+
* @property {string} carouselItems - The query selector string for carousel items.
|
|
629
|
+
* @property {string} carouselItemContainer - The query selector string for the carousel item container.
|
|
630
|
+
* @property {string} carouselControls - The query selector string for carousel controls.
|
|
631
|
+
* @property {string} carouselControlContainer - The query selector string for carousel control container.
|
|
632
|
+
* @property {string} carouselTabs - The query selector string for the carousel tabs.
|
|
633
|
+
* @property {string} carouselTabContainer - The query selector string for the carousel tab container.
|
|
634
|
+
* @property {string} autoplay - The query selector string for the autoplay button.
|
|
635
|
+
* @property {string} next - The query selector string for the next button.
|
|
636
|
+
* @property {string} previous - The query selector string for the previous button.
|
|
637
|
+
*/
|
|
638
|
+
r(this, "_selectors", {
|
|
639
|
+
carouselItems: "",
|
|
640
|
+
carouselItemContainer: "",
|
|
641
|
+
carouselControls: "",
|
|
642
|
+
carouselControlContainer: "",
|
|
643
|
+
carouselTabs: "",
|
|
644
|
+
carouselTabContainer: "",
|
|
645
|
+
autoplay: "",
|
|
646
|
+
next: "",
|
|
647
|
+
previous: ""
|
|
648
|
+
});
|
|
649
|
+
/**
|
|
650
|
+
* The class(es) to apply when a carousel item is active.
|
|
651
|
+
*
|
|
652
|
+
* @protected
|
|
653
|
+
*
|
|
654
|
+
* @type {string|string[]}
|
|
655
|
+
*/
|
|
656
|
+
r(this, "_activeClass", "active");
|
|
657
|
+
/**
|
|
658
|
+
* The class(es) to apply to a carousel item that is the previously active item.
|
|
659
|
+
*
|
|
660
|
+
* @protected
|
|
661
|
+
*
|
|
662
|
+
* @type {string|string[]}
|
|
663
|
+
*/
|
|
664
|
+
r(this, "_previousClass", "previous");
|
|
665
|
+
/**
|
|
666
|
+
* The class(es) to apply to a carousel item that is the next active item.
|
|
667
|
+
*
|
|
668
|
+
* @protected
|
|
669
|
+
*
|
|
670
|
+
* @type {string|string[]}
|
|
671
|
+
*/
|
|
672
|
+
r(this, "_nextClass", "next");
|
|
673
|
+
/**
|
|
674
|
+
* The class(es) to apply to the autoplay button when the carousel is paused.
|
|
675
|
+
*
|
|
676
|
+
* @protected
|
|
677
|
+
*
|
|
678
|
+
* @type {string|string[]}
|
|
679
|
+
*/
|
|
680
|
+
r(this, "_playClass", "play");
|
|
681
|
+
/**
|
|
682
|
+
* The class(es) to apply to the autoplay button when the carousel is playing.
|
|
683
|
+
*
|
|
684
|
+
* @protected
|
|
685
|
+
*
|
|
686
|
+
* @type {string|string[]}
|
|
687
|
+
*/
|
|
688
|
+
r(this, "_pauseClass", "pause");
|
|
689
|
+
/**
|
|
690
|
+
* The index of the currently active carousel item.
|
|
691
|
+
*
|
|
692
|
+
* @protected
|
|
693
|
+
*
|
|
694
|
+
* @type {number}
|
|
695
|
+
*/
|
|
696
|
+
r(this, "_currentItem", 0);
|
|
697
|
+
/**
|
|
698
|
+
* A flag to indicate if the carousel is currently playing.
|
|
699
|
+
*
|
|
700
|
+
* @protected
|
|
701
|
+
*
|
|
702
|
+
* @type {boolean}
|
|
703
|
+
*/
|
|
704
|
+
r(this, "_autoplay", !0);
|
|
705
|
+
/**
|
|
706
|
+
* A variable to delay transition slides in milliseconds.
|
|
707
|
+
*
|
|
708
|
+
* @protected
|
|
709
|
+
*
|
|
710
|
+
* @type {number}
|
|
711
|
+
*/
|
|
712
|
+
r(this, "_transitionDelay", 1e4);
|
|
713
|
+
/**
|
|
714
|
+
* The duration time (in milliseconds) for the transition between carousel items.
|
|
715
|
+
*
|
|
716
|
+
* @protected
|
|
717
|
+
*
|
|
718
|
+
* @type {number}
|
|
719
|
+
*/
|
|
720
|
+
r(this, "_transitionDuration", 500);
|
|
721
|
+
/**
|
|
722
|
+
* The label for the autoplay button when the carousel is paused.
|
|
723
|
+
*
|
|
724
|
+
* @protected
|
|
725
|
+
*
|
|
726
|
+
* @type {string}
|
|
727
|
+
*/
|
|
728
|
+
r(this, "_playText", "Play");
|
|
729
|
+
/**
|
|
730
|
+
* The label for the autoplay button when the carousel is playing.
|
|
731
|
+
*
|
|
732
|
+
* @protected
|
|
733
|
+
*
|
|
734
|
+
* @type {string}
|
|
735
|
+
*/
|
|
736
|
+
r(this, "_pauseText", "Pause");
|
|
737
|
+
/**
|
|
738
|
+
* The current action being performed by the carousel.
|
|
739
|
+
*
|
|
740
|
+
* @protected
|
|
741
|
+
*
|
|
742
|
+
* @type {string}
|
|
743
|
+
*/
|
|
744
|
+
r(this, "_currentAction", "next");
|
|
745
|
+
/**
|
|
746
|
+
* The stored interval callback for autoplaying the carousel.
|
|
747
|
+
*
|
|
748
|
+
* @protected
|
|
749
|
+
*
|
|
750
|
+
* @type {?Function}
|
|
751
|
+
*/
|
|
752
|
+
r(this, "_autoplayInterval", null);
|
|
753
|
+
/**
|
|
754
|
+
* The prefix to use for CSS custom properties.
|
|
755
|
+
*
|
|
756
|
+
* @protected
|
|
757
|
+
*
|
|
758
|
+
* @type {string}
|
|
759
|
+
*/
|
|
760
|
+
r(this, "_prefix", "graupl-");
|
|
761
|
+
/**
|
|
762
|
+
* The key used to generate IDs throughout the carousel.
|
|
763
|
+
*
|
|
764
|
+
* @protected
|
|
765
|
+
*
|
|
766
|
+
* @type {string}
|
|
767
|
+
*/
|
|
768
|
+
r(this, "_key", "");
|
|
769
|
+
/**
|
|
770
|
+
* An array of error messages generated by the carousel.
|
|
771
|
+
*
|
|
772
|
+
* @protected
|
|
773
|
+
*
|
|
774
|
+
* @type {string[]}
|
|
775
|
+
*/
|
|
776
|
+
r(this, "_errors", []);
|
|
777
|
+
this._dom.carousel = t, this._selectors.carouselItems = s, this._selectors.carouselItemContainer = i, this._selectors.carouselControls = n, this._selectors.carouselControlContainer = l, this._selectors.carouselTabs = d, this._selectors.carouselTabContainer = p, this._selectors.autoplay = o, this._selectors.next = y, this._selectors.previous = b, this._activeClass = E || "", this._previousClass = T || "", this._nextClass = I || "", this._playClass = k || "", this._pauseClass = v || "", this._autoplay = x, this._transitionDelay = A, this._transitionDuration = D, this._playText = S || "", this._pauseText = L || "", this._prefix = $ || "", this._key = M || "", G && this.initialize();
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Initializes the carousel.
|
|
781
|
+
*/
|
|
782
|
+
initialize() {
|
|
783
|
+
try {
|
|
784
|
+
if (!this._validate())
|
|
785
|
+
throw new Error(
|
|
786
|
+
`Graupl Carousel: cannot initialize carousel. The following errors have been found:
|
|
787
|
+
- ${this.errors.join(
|
|
788
|
+
`
|
|
789
|
+
- `
|
|
790
|
+
)}`
|
|
791
|
+
);
|
|
792
|
+
this._generateKey(), this._setDOMElements(), this._setIds(), this._setAriaAttributes(), this.activateFirstItem(), this._handleAutoplay(), this._handleFocus(), this._handleClick(), this._handleHover(), this._handleKeydown(), this._handleKeyup(), this._setTransitionDuration(), C.initializeStorage("carousels"), C.pushToStorage("carousels", this.dom.carousel.id, this);
|
|
793
|
+
} catch (t) {
|
|
794
|
+
console.error(t);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* The HTML elements for the carousel in the DOM.
|
|
799
|
+
*
|
|
800
|
+
* @readonly
|
|
801
|
+
*
|
|
802
|
+
* @type {Object<HTMLElement>}
|
|
803
|
+
*
|
|
804
|
+
* @see _dom
|
|
805
|
+
*/
|
|
806
|
+
get dom() {
|
|
807
|
+
return this._dom;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* The query selectors used by the carousel to populate the dom.
|
|
811
|
+
*
|
|
812
|
+
* @readonly
|
|
813
|
+
*
|
|
814
|
+
* @type {Object<string>}
|
|
815
|
+
*
|
|
816
|
+
* @see _selectors
|
|
817
|
+
*/
|
|
818
|
+
get selectors() {
|
|
819
|
+
return this._selectors;
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* The class(es) to apply when a carousel item is active.
|
|
823
|
+
*
|
|
824
|
+
* @type {string|string[]}
|
|
825
|
+
*
|
|
826
|
+
* @see _activeClass
|
|
827
|
+
*/
|
|
828
|
+
get activeClass() {
|
|
829
|
+
return this._activeClass;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* The class(es) to apply to a carousel item that is the next active item.
|
|
833
|
+
*
|
|
834
|
+
* @type {string|string[]}
|
|
835
|
+
*
|
|
836
|
+
* @see _previousClass
|
|
837
|
+
*/
|
|
838
|
+
get previousClass() {
|
|
839
|
+
return this._previousClass;
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* The class(es) to apply to a carousel item that is the next active item.
|
|
843
|
+
*
|
|
844
|
+
* @type {string|string[]}
|
|
845
|
+
*
|
|
846
|
+
* @see _nextClass
|
|
847
|
+
*/
|
|
848
|
+
get nextClass() {
|
|
849
|
+
return this._nextClass;
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* The class(es) to apply to the autoplay button when the carousel is paused.
|
|
853
|
+
*
|
|
854
|
+
* @type {string|string[]}
|
|
855
|
+
*
|
|
856
|
+
* @see _playClass
|
|
857
|
+
*/
|
|
858
|
+
get playClass() {
|
|
859
|
+
return this._playClass;
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* The class(es) to apply to the autoplay button when the carousel is playing.
|
|
863
|
+
*
|
|
864
|
+
* @type {string|string[]}
|
|
865
|
+
*
|
|
866
|
+
* @see _pauseClass
|
|
867
|
+
*/
|
|
868
|
+
get pauseClass() {
|
|
869
|
+
return this._pauseClass;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* The index of the currently active carousel item.
|
|
873
|
+
*
|
|
874
|
+
* @type {number}
|
|
875
|
+
*
|
|
876
|
+
* @see _currentItem
|
|
877
|
+
*/
|
|
878
|
+
get currentItem() {
|
|
879
|
+
return this._currentItem;
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* The currently active carousel item.
|
|
883
|
+
*
|
|
884
|
+
* @readonly
|
|
885
|
+
*
|
|
886
|
+
* @type {HTMLElement}
|
|
887
|
+
*/
|
|
888
|
+
get currentCarouselItem() {
|
|
889
|
+
return this.dom.carouselItems[this.currentItem];
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* The currently active carousel tab.
|
|
893
|
+
*
|
|
894
|
+
* @readonly
|
|
895
|
+
*
|
|
896
|
+
* @type {HTMLElement}
|
|
897
|
+
*/
|
|
898
|
+
get currentCarouselTab() {
|
|
899
|
+
return this.dom.carouselTabs[this.currentItem];
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* A flag to indicate if the carousel is currently playing.
|
|
903
|
+
*
|
|
904
|
+
* @type {boolean}
|
|
905
|
+
*
|
|
906
|
+
* @see _autoplay
|
|
907
|
+
*/
|
|
908
|
+
get autoplay() {
|
|
909
|
+
return this._autoplay;
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* The delay in milliseconds before transitioning slides.
|
|
913
|
+
*
|
|
914
|
+
* @type {number}
|
|
915
|
+
*
|
|
916
|
+
* @see _transitionDelay
|
|
917
|
+
*/
|
|
918
|
+
get transitionDelay() {
|
|
919
|
+
return this._transitionDelay;
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* The duration time (in milliseconds) for the transition between carousel items.
|
|
923
|
+
*
|
|
924
|
+
* @type {number}
|
|
925
|
+
*
|
|
926
|
+
* @see _transitionDuration
|
|
927
|
+
*/
|
|
928
|
+
get transitionDuration() {
|
|
929
|
+
return this._transitionDuration;
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* The label for the autoplay button when the carousel is paused.
|
|
933
|
+
*
|
|
934
|
+
* @type {string}
|
|
935
|
+
*
|
|
936
|
+
* @see _playText
|
|
937
|
+
*/
|
|
938
|
+
get playText() {
|
|
939
|
+
return this._playText;
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* The label for the autoplay button when the carousel is playing.
|
|
943
|
+
*
|
|
944
|
+
* @type {string}
|
|
945
|
+
*
|
|
946
|
+
* @see _pauseText
|
|
947
|
+
*/
|
|
948
|
+
get pauseText() {
|
|
949
|
+
return this._pauseText;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* The prefix to use for CSS custom properties.
|
|
953
|
+
*
|
|
954
|
+
* @type {string}
|
|
955
|
+
*
|
|
956
|
+
* @see _prefix
|
|
957
|
+
*/
|
|
958
|
+
get prefix() {
|
|
959
|
+
return this._prefix;
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* The key used to generate IDs throughout the accordion.
|
|
963
|
+
*
|
|
964
|
+
* @type {string}
|
|
965
|
+
*
|
|
966
|
+
* @see _key
|
|
967
|
+
*/
|
|
968
|
+
get key() {
|
|
969
|
+
return this._key;
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* The current action being performed by the carousel.
|
|
973
|
+
*
|
|
974
|
+
* @type {string}
|
|
975
|
+
*
|
|
976
|
+
* @see _currentAction
|
|
977
|
+
*/
|
|
978
|
+
get currentAction() {
|
|
979
|
+
return this._currentAction;
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* An array of error messages generated by the carousel.
|
|
983
|
+
*
|
|
984
|
+
* @readonly
|
|
985
|
+
*
|
|
986
|
+
* @type {string[]}
|
|
987
|
+
*
|
|
988
|
+
* @see _errors
|
|
989
|
+
*/
|
|
990
|
+
get errors() {
|
|
991
|
+
return this._errors;
|
|
992
|
+
}
|
|
993
|
+
set currentItem(t) {
|
|
994
|
+
if (a("number", { value: t }), t === this.currentItem)
|
|
995
|
+
return;
|
|
996
|
+
t < 0 ? this._currentItem = 0 : t >= this.dom.carouselItems.length ? this._currentItem = this.dom.carouselItems.length - 1 : this._currentItem = t, this._dom.carousel.querySelectorAll(
|
|
997
|
+
this.selectors.carouselTab
|
|
998
|
+
) && this.dom.carouselItems.forEach((i, n) => {
|
|
999
|
+
i.setAttribute("aria-selected", n === this._currentItem);
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
set autoplay(t) {
|
|
1003
|
+
a("boolean", { value: t }), this._autoplay !== t && (this._autoplay = t);
|
|
1004
|
+
}
|
|
1005
|
+
set activeClass(t) {
|
|
1006
|
+
h({ activeClass: t }), this._activeClass !== t && (this._activeClass = t);
|
|
1007
|
+
}
|
|
1008
|
+
set previousClass(t) {
|
|
1009
|
+
h({ previousClass: t }), this._previousClass !== t && (this._previousClass = t);
|
|
1010
|
+
}
|
|
1011
|
+
set nextClass(t) {
|
|
1012
|
+
h({ nextClass: t }), this._nextClass !== t && (this._nextClass = t);
|
|
1013
|
+
}
|
|
1014
|
+
set playClass(t) {
|
|
1015
|
+
h({ playClass: t }), this._playClass !== t && (this._playClass = t);
|
|
1016
|
+
}
|
|
1017
|
+
set pauseClass(t) {
|
|
1018
|
+
h({ pauseClass: t }), this._pauseClass !== t && (this._pauseClass = t);
|
|
1019
|
+
}
|
|
1020
|
+
set transitionDelay(t) {
|
|
1021
|
+
a("number", { value: t }), t !== this.transitionDelay && t >= 0 && (this._currentItem = t);
|
|
1022
|
+
}
|
|
1023
|
+
set transitionDuration(t) {
|
|
1024
|
+
a("number", { value: t }), this._transitionDuration !== t && t >= 0 && (this._transitionDuration = t, this._setTransitionDuration());
|
|
1025
|
+
}
|
|
1026
|
+
set playText(t) {
|
|
1027
|
+
a("string", { value: t }), this._playText !== t && (this._playText = t);
|
|
1028
|
+
}
|
|
1029
|
+
set pauseText(t) {
|
|
1030
|
+
a("string", { value: t }), this._pauseText !== t && (this._pauseText = t);
|
|
1031
|
+
}
|
|
1032
|
+
set prefix(t) {
|
|
1033
|
+
a("string", { value: t }), this._prefix !== t && (this._prefix = t);
|
|
1034
|
+
}
|
|
1035
|
+
set key(t) {
|
|
1036
|
+
a("string", { value: t }), this._key !== t && (this._key = t);
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Validates all aspects of the carousel to ensure proper functionality.
|
|
1040
|
+
*
|
|
1041
|
+
* @protected
|
|
1042
|
+
*
|
|
1043
|
+
* @return {boolean} - The results of the validation.
|
|
1044
|
+
*/
|
|
1045
|
+
_validate() {
|
|
1046
|
+
let t = !0;
|
|
1047
|
+
const s = f(HTMLElement, {
|
|
1048
|
+
carousel: this.dom.carousel
|
|
1049
|
+
});
|
|
1050
|
+
s || (this._errors.push(s.message), t = !1);
|
|
1051
|
+
const i = w({
|
|
1052
|
+
carouselItemsSelector: this._selectors.carouselItems,
|
|
1053
|
+
carouselItemContainerSelector: this._selectors.carouselItemContainer,
|
|
1054
|
+
carouselControlsSelector: this._selectors.carouselControls,
|
|
1055
|
+
carouselControlContainerSelector: this._selectors.carouselControlContainer,
|
|
1056
|
+
carouselTabsSelector: this._selectors.carouselTabs,
|
|
1057
|
+
carouselTabContainerSelector: this._selectors.carouselTabContainer,
|
|
1058
|
+
autoplaySelector: this._selectors.autoplay,
|
|
1059
|
+
nextSelector: this._selectors.next,
|
|
1060
|
+
previousSelector: this._selectors.previous
|
|
1061
|
+
});
|
|
1062
|
+
i || (this._errors.push(i.message), t = !1);
|
|
1063
|
+
const n = a("boolean", { autoplay: this.autoplay });
|
|
1064
|
+
n || (this._errors.push(n.message), t = !1);
|
|
1065
|
+
const l = a("number", {
|
|
1066
|
+
transitionDelay: this._transitionDelay
|
|
1067
|
+
});
|
|
1068
|
+
l || (this._errors.push(l.message), t = !1);
|
|
1069
|
+
const d = a("number", {
|
|
1070
|
+
transitionDuration: this._transitionDuration
|
|
1071
|
+
});
|
|
1072
|
+
if (d || (this._errors.push(d.message), t = !1), this._activeClass !== "") {
|
|
1073
|
+
const o = h({
|
|
1074
|
+
activeClass: this._activeClass
|
|
1075
|
+
});
|
|
1076
|
+
o || (this._errors.push(o.message), t = !1);
|
|
1077
|
+
}
|
|
1078
|
+
if (this._previousClass !== "") {
|
|
1079
|
+
const o = h({
|
|
1080
|
+
previousClass: this._previousClass
|
|
1081
|
+
});
|
|
1082
|
+
o || (this._errors.push(o.message), t = !1);
|
|
1083
|
+
}
|
|
1084
|
+
if (this._nextClass !== "") {
|
|
1085
|
+
const o = h({
|
|
1086
|
+
nextClass: this._nextClass
|
|
1087
|
+
});
|
|
1088
|
+
o || (this._errors.push(o.message), t = !1);
|
|
1089
|
+
}
|
|
1090
|
+
if (this._playClass !== "") {
|
|
1091
|
+
const o = h({
|
|
1092
|
+
playClass: this._playClass
|
|
1093
|
+
});
|
|
1094
|
+
o || (this._errors.push(o.message), t = !1);
|
|
1095
|
+
}
|
|
1096
|
+
if (this._pauseClass !== "") {
|
|
1097
|
+
const o = h({
|
|
1098
|
+
pauseClass: this._pauseClass
|
|
1099
|
+
});
|
|
1100
|
+
o || (this._errors.push(o.message), t = !1);
|
|
1101
|
+
}
|
|
1102
|
+
if (this._playText !== "") {
|
|
1103
|
+
const o = a("string", {
|
|
1104
|
+
playText: this._playText
|
|
1105
|
+
});
|
|
1106
|
+
o || (this._errors.push(o.message), t = !1);
|
|
1107
|
+
}
|
|
1108
|
+
if (this._pauseText !== "") {
|
|
1109
|
+
const o = a("string", {
|
|
1110
|
+
pauseText: this._pauseText
|
|
1111
|
+
});
|
|
1112
|
+
o || (this._errors.push(o.message), t = !1);
|
|
1113
|
+
}
|
|
1114
|
+
const p = a("string", { prefix: this._prefix });
|
|
1115
|
+
return p || (this._errors.push(p.message), t = !1), t;
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Sets DOM elements within the carousel.
|
|
1119
|
+
*
|
|
1120
|
+
* The carousel element _cannot_ be set through this method.
|
|
1121
|
+
*
|
|
1122
|
+
* @protected
|
|
1123
|
+
*
|
|
1124
|
+
* @param {string} elementType - The type of element to populate.
|
|
1125
|
+
* @param {HTMLElement} [base = this.dom.carousel] - The element used as the base for the querySelector.
|
|
1126
|
+
* @param {boolean} [overwrite = true] - A flag to set if the existing elements will be overwritten.
|
|
1127
|
+
*/
|
|
1128
|
+
_setDOMElementType(t, s = this.dom.carousel, i = !0) {
|
|
1129
|
+
if (typeof this.selectors[t] == "string") {
|
|
1130
|
+
if (t === "carousel")
|
|
1131
|
+
throw new Error(
|
|
1132
|
+
`Graupl Carousel: "${t}" element cannot be set through _setDOMElementType.`
|
|
1133
|
+
);
|
|
1134
|
+
if (s !== this.dom.carousel && f(HTMLElement, { base: s }), Array.isArray(this._dom[t])) {
|
|
1135
|
+
const l = Array.from(
|
|
1136
|
+
s.querySelectorAll(this.selectors[t])
|
|
1137
|
+
).filter(
|
|
1138
|
+
(d) => d.parentElement === s
|
|
1139
|
+
);
|
|
1140
|
+
i ? this._dom[t] = l : this._dom[t] = [
|
|
1141
|
+
...this._dom[t],
|
|
1142
|
+
...l
|
|
1143
|
+
];
|
|
1144
|
+
} else {
|
|
1145
|
+
const n = s.querySelector(this.selectors[t]);
|
|
1146
|
+
if (n && n.parentElement !== s)
|
|
1147
|
+
return;
|
|
1148
|
+
i && (this._dom[t] = n);
|
|
1149
|
+
}
|
|
1150
|
+
} else
|
|
1151
|
+
throw new Error(
|
|
1152
|
+
`Graupl Carousel: "${t}" is not a valid element type within the carousel.`
|
|
1153
|
+
);
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Resets DOM elements within the menu.
|
|
1157
|
+
*
|
|
1158
|
+
* The carousel element _cannot_ be reset through this method.
|
|
1159
|
+
*
|
|
1160
|
+
* @protected
|
|
1161
|
+
*
|
|
1162
|
+
* @param {string} elementType - The type of element to clear.
|
|
1163
|
+
*/
|
|
1164
|
+
_resetDOMElementType(t) {
|
|
1165
|
+
if (typeof this.selectors[t] == "string") {
|
|
1166
|
+
if (t === "carousel")
|
|
1167
|
+
throw new Error(
|
|
1168
|
+
`Graupl Carousel: "${t}" element cannot be reset through _resetDOMElementType.`
|
|
1169
|
+
);
|
|
1170
|
+
Array.isArray(this._dom[t]) ? this._dom[t] = [] : this._dom[t] = null;
|
|
1171
|
+
} else
|
|
1172
|
+
throw new Error(
|
|
1173
|
+
`Graupl Carousel: "${t}" is not a valid element type within the carousel.`
|
|
1174
|
+
);
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Sets all DOM elements within the carousel.
|
|
1178
|
+
*
|
|
1179
|
+
* Utilizes _setDOMElementType and _resetDOMElementType.
|
|
1180
|
+
*
|
|
1181
|
+
* @protected
|
|
1182
|
+
*/
|
|
1183
|
+
_setDOMElements() {
|
|
1184
|
+
this._setDOMElementType("carouselItemContainer"), this._setDOMElementType("carouselControlContainer"), this._setDOMElementType("carouselTabContainer"), this.dom.carouselItemContainer && this._setDOMElementType("carouselItems", this.dom.carouselItemContainer), this.dom.carouselControlContainer && (this._setDOMElementType(
|
|
1185
|
+
"carouselControls",
|
|
1186
|
+
this.dom.carouselControlContainer
|
|
1187
|
+
), this._setDOMElementType("autoplay", this.dom.carouselControlContainer), this._setDOMElementType("next", this.dom.carouselControlContainer), this._setDOMElementType("previous", this.dom.carouselControlContainer)), this._dom.carouselTabContainer && this._setDOMElementType("carouselTabs", this.dom.carouselTabContainer);
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* Generates a key for the carousel.
|
|
1191
|
+
*
|
|
1192
|
+
* @param {boolean} [regenerate = false] - A flag to determine if the key should be regenerated.
|
|
1193
|
+
*/
|
|
1194
|
+
_generateKey(t = !1) {
|
|
1195
|
+
(this.key === "" || t) && (this.key = Math.random().toString(36).replace(/[^a-z]+/g, "").substring(0, 10));
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Sets the IDs of the carousel and it's children if they do not already exist.
|
|
1199
|
+
*
|
|
1200
|
+
* The generated IDs use the key and follow the format:
|
|
1201
|
+
* - carousel: `carousel-${key}`
|
|
1202
|
+
* - carousel items: `carousel-item-${key}-${index}`
|
|
1203
|
+
* - carousel tabs: `carousel-tab-${key}-${index}`
|
|
1204
|
+
*/
|
|
1205
|
+
_setIds() {
|
|
1206
|
+
this.dom.carousel.id = this.dom.carousel.id || `carousel-${this.key}`, this.dom.carouselItems.forEach((t, s) => {
|
|
1207
|
+
t.id = t.id || `carousel-item-${this.key}-${s}`;
|
|
1208
|
+
}), this.dom.carouselTabs.forEach((t, s) => {
|
|
1209
|
+
t.id = t.id || `carousel-tab-${this.key}-${s}`;
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1213
|
+
* Sets the aria attributes for the carousel.
|
|
1214
|
+
*/
|
|
1215
|
+
_setAriaAttributes() {
|
|
1216
|
+
!g("section", { carousel: this.dom.carousel }) && !this.dom.carousel.getAttribute("role") !== "region" && this.dom.carousel.setAttribute("role", "group"), this._dom.carousel.setAttribute("aria-roledescription", "carousel"), this.dom.carouselTabContainer && this.dom.carouselTabContainer.setAttribute("role", "tablist"), this.dom.carouselTabs.forEach((t, s) => {
|
|
1217
|
+
g("button", { tab: t }) || t.setAttribute("role", "button"), t.setAttribute("aria-selected", s === 0), t.setAttribute("aria-controls", this.dom.carouselItems[s].id);
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Sets the interval for autoplaying the carousel.
|
|
1222
|
+
*
|
|
1223
|
+
* @protected
|
|
1224
|
+
*/
|
|
1225
|
+
_setInterval() {
|
|
1226
|
+
this._clearInterval(), this._autoplayInterval = setInterval(() => {
|
|
1227
|
+
this.activateNextItem();
|
|
1228
|
+
}, this.transitionDelay);
|
|
1229
|
+
}
|
|
1230
|
+
/**
|
|
1231
|
+
* Clears the interval for autoplaying the carousel.
|
|
1232
|
+
*
|
|
1233
|
+
* @protected
|
|
1234
|
+
*/
|
|
1235
|
+
_clearInterval() {
|
|
1236
|
+
clearInterval(this._autoplayInterval);
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Handles the autoplay functionality of the carousel.
|
|
1240
|
+
*
|
|
1241
|
+
* - Adds the appropriate class to the autoplay button.
|
|
1242
|
+
* - Removes the appropriate class from the autoplay button.
|
|
1243
|
+
* - Sets the appropriate aria-label for the autoplay button.
|
|
1244
|
+
* - Sets the appropriate aria-live for the carousel.
|
|
1245
|
+
* - Sets/clears the interval for autoplaying the carousel.
|
|
1246
|
+
*
|
|
1247
|
+
* @protected
|
|
1248
|
+
*/
|
|
1249
|
+
_handleAutoplay() {
|
|
1250
|
+
this.autoplay ? (u(this.pauseClass, this.dom.autoplay), c(this.playClass, this.dom.autoplay), this.dom.autoplay.setAttribute("aria-label", this.pauseText), this.dom.carousel.setAttribute("aria-live", "off"), this._setInterval()) : (u(this.playClass, this.dom.autoplay), c(this.pauseClass, this.dom.autoplay), this.dom.autoplay.setAttribute("aria-label", this.playText), this.dom.carousel.setAttribute("aria-live", "polite"), this._clearInterval());
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Handles the focus events throughout the carousel for proper use.
|
|
1254
|
+
*
|
|
1255
|
+
* - Adds a `focusin` listener to the carousel element to pause autoplay.
|
|
1256
|
+
* - Adds a `focusout` listener to the carousel element to resume autoplay.
|
|
1257
|
+
*/
|
|
1258
|
+
_handleFocus() {
|
|
1259
|
+
this.dom.carousel.addEventListener("focusin", () => {
|
|
1260
|
+
this.autoplay && this._clearInterval();
|
|
1261
|
+
}), this.dom.carousel.addEventListener("focusout", () => {
|
|
1262
|
+
this.autoplay && this._setInterval();
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Handles the click events throughout the carousel.
|
|
1267
|
+
*
|
|
1268
|
+
* - Adds a `pointerup` listener to the next control to activate the next item.
|
|
1269
|
+
* - Adds a `pointerup` listener to the previous control to activate the previous item.
|
|
1270
|
+
* - Adds a `pointerup` listener to the autoplay control to toggle autoplay.
|
|
1271
|
+
* - Adds a `pointerup` listener to each tab control to activate the corresponding item.
|
|
1272
|
+
*/
|
|
1273
|
+
_handleClick() {
|
|
1274
|
+
this.dom.next.addEventListener("pointerup", () => {
|
|
1275
|
+
this.activateNextItem();
|
|
1276
|
+
}), this.dom.previous.addEventListener("pointerup", () => {
|
|
1277
|
+
this.activatePreviousItem();
|
|
1278
|
+
}), this.dom.autoplay.addEventListener("pointerup", () => {
|
|
1279
|
+
this.toggleAutoplay();
|
|
1280
|
+
}), this.dom.carouselTabs.forEach((t, s) => {
|
|
1281
|
+
t.addEventListener("pointerup", () => {
|
|
1282
|
+
this.currentItem > s ? this._currentAction = "previous" : this._currentAction = "next", this.activateItem(s);
|
|
1283
|
+
});
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Handles the hover events throughout the carousel for proper use.
|
|
1288
|
+
*
|
|
1289
|
+
* - Adds a `pointerover` listener to the carousel to pause autoplay.
|
|
1290
|
+
* - Adds a `pointerleave` listener to the carousel to resume autoplay.
|
|
1291
|
+
*/
|
|
1292
|
+
_handleHover() {
|
|
1293
|
+
this.dom.carousel.addEventListener("pointerover", () => {
|
|
1294
|
+
this.autoplay && this._clearInterval();
|
|
1295
|
+
}), this.dom.carousel.addEventListener("pointerleave", () => {
|
|
1296
|
+
this.autoplay && this._setInterval();
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Handles keydown events throughout the carousel item for proper use.
|
|
1301
|
+
*
|
|
1302
|
+
* - Adds a `keydown` listener to all control elements.
|
|
1303
|
+
* - Prevents Space and Enter key events.
|
|
1304
|
+
* - Adds a `keydown` listener to all tab elements.
|
|
1305
|
+
* - Prevents Space and Enter key events.
|
|
1306
|
+
*/
|
|
1307
|
+
_handleKeydown() {
|
|
1308
|
+
this.dom.carouselControls.forEach((t) => {
|
|
1309
|
+
t.addEventListener("keydown", (s) => {
|
|
1310
|
+
switch (m(s)) {
|
|
1311
|
+
case "Space":
|
|
1312
|
+
case "Enter":
|
|
1313
|
+
_(s);
|
|
1314
|
+
break;
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
}), this.dom.carouselTabs.forEach((t) => {
|
|
1318
|
+
t.addEventListener("keydown", (s) => {
|
|
1319
|
+
switch (m(s)) {
|
|
1320
|
+
case "Space":
|
|
1321
|
+
case "Enter":
|
|
1322
|
+
_(s);
|
|
1323
|
+
break;
|
|
1324
|
+
}
|
|
1325
|
+
});
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Handles keyup events throughout the carousel item for proper use.
|
|
1330
|
+
*
|
|
1331
|
+
* - Adds a `keyup` listener to all control elements.
|
|
1332
|
+
* - Activates the next/previous item depending on which control is pressed.
|
|
1333
|
+
* - Toggles autoplay if the autoplay control is pressed.
|
|
1334
|
+
*
|
|
1335
|
+
*/
|
|
1336
|
+
_handleKeyup() {
|
|
1337
|
+
this.dom.next.addEventListener("keyup", (t) => {
|
|
1338
|
+
switch (m(t)) {
|
|
1339
|
+
case "Space":
|
|
1340
|
+
case "Enter":
|
|
1341
|
+
this.activateNextItem(), _(t);
|
|
1342
|
+
break;
|
|
1343
|
+
}
|
|
1344
|
+
}), this.dom.previous.addEventListener("keyup", (t) => {
|
|
1345
|
+
switch (m(t)) {
|
|
1346
|
+
case "Space":
|
|
1347
|
+
case "Enter":
|
|
1348
|
+
this.activatePreviousItem(), _(t);
|
|
1349
|
+
break;
|
|
1350
|
+
}
|
|
1351
|
+
}), this.dom.autoplay.addEventListener("keyup", (t) => {
|
|
1352
|
+
switch (m(t)) {
|
|
1353
|
+
case "Space":
|
|
1354
|
+
case "Enter":
|
|
1355
|
+
this.toggleAutoplay(), _(t);
|
|
1356
|
+
break;
|
|
1357
|
+
}
|
|
1358
|
+
}), this.dom.carouselTabs.forEach((t, s) => {
|
|
1359
|
+
t.addEventListener("keyup", (i) => {
|
|
1360
|
+
switch (m(i)) {
|
|
1361
|
+
case "Space":
|
|
1362
|
+
case "Enter":
|
|
1363
|
+
this.activateItem(s), _(i);
|
|
1364
|
+
break;
|
|
1365
|
+
}
|
|
1366
|
+
});
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
/**
|
|
1370
|
+
* Sets the transition duration for the carousel as a CSS custom property.
|
|
1371
|
+
*
|
|
1372
|
+
* The custom property is set as `--graupl-carousel-transition-duration`.
|
|
1373
|
+
*
|
|
1374
|
+
* @protected
|
|
1375
|
+
*/
|
|
1376
|
+
_setTransitionDuration() {
|
|
1377
|
+
this.dom.carousel.style.setProperty(
|
|
1378
|
+
`--${this.prefix}carousel-transition-duration`,
|
|
1379
|
+
`${this.transitionDuration}ms`
|
|
1380
|
+
);
|
|
1381
|
+
}
|
|
1382
|
+
/**
|
|
1383
|
+
* Activates the current carousel item.
|
|
1384
|
+
*
|
|
1385
|
+
* @public
|
|
1386
|
+
*/
|
|
1387
|
+
activateCurrentItem() {
|
|
1388
|
+
u(this.activeClass, this.currentCarouselItem), this.currentCarouselTab && (this.currentCarouselTab.setAttribute("aria-selected", !0), u(this.activeClass, this.currentCarouselTab));
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Deactivates the current carousel item.
|
|
1392
|
+
*
|
|
1393
|
+
* @public
|
|
1394
|
+
*/
|
|
1395
|
+
deactivateCurrentItem() {
|
|
1396
|
+
c(this.activeClass, this.currentCarouselItem), this.currentCarouselTab && (this.currentCarouselTab.setAttribute("aria-selected", !1), c(this.activeClass, this.currentCarouselTab));
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Activates the carousel item at a given index.
|
|
1400
|
+
*
|
|
1401
|
+
* @public
|
|
1402
|
+
*
|
|
1403
|
+
* @param {number} index - The index of the carousel item to activate.
|
|
1404
|
+
*/
|
|
1405
|
+
activateItem(t) {
|
|
1406
|
+
const s = this.currentItem;
|
|
1407
|
+
this.dom.carousel.dataset.grauplAction = this._currentAction, this.autoplay && this._clearInterval(), u(this.previousClass, this.currentCarouselItem), u(this.nextClass, this.dom.carouselItems[t]), requestAnimationFrame(() => {
|
|
1408
|
+
this.deactivateCurrentItem(), this.currentItem = t, this.activateCurrentItem(), requestAnimationFrame(() => {
|
|
1409
|
+
setTimeout(() => {
|
|
1410
|
+
c(this.previousClass, this.dom.carouselItems[s]), c(this.nextClass, this.currentCarouselItem);
|
|
1411
|
+
}, this.transitionDuration);
|
|
1412
|
+
});
|
|
1413
|
+
}), this.autoplay && this._setInterval();
|
|
1414
|
+
}
|
|
1415
|
+
/**
|
|
1416
|
+
* Activates the first carousel item.
|
|
1417
|
+
*
|
|
1418
|
+
* @public
|
|
1419
|
+
*/
|
|
1420
|
+
activateFirstItem() {
|
|
1421
|
+
this.activateItem(0);
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Activates the last carousel item.
|
|
1425
|
+
*
|
|
1426
|
+
* @public
|
|
1427
|
+
*/
|
|
1428
|
+
activateLastItem() {
|
|
1429
|
+
this.activateItem(this.dom.carouselItems.length - 1);
|
|
1430
|
+
}
|
|
1431
|
+
/**
|
|
1432
|
+
* Activates the next carousel item.
|
|
1433
|
+
*
|
|
1434
|
+
* @public
|
|
1435
|
+
*/
|
|
1436
|
+
activateNextItem() {
|
|
1437
|
+
this._currentAction = "next", this.currentItem + 1 >= this.dom.carouselItems.length ? this.activateFirstItem() : this.activateItem(this.currentItem + 1);
|
|
1438
|
+
}
|
|
1439
|
+
/**
|
|
1440
|
+
* Activates the previous carousel item.
|
|
1441
|
+
*
|
|
1442
|
+
* @public
|
|
1443
|
+
*/
|
|
1444
|
+
activatePreviousItem() {
|
|
1445
|
+
this._currentAction = "previous", this.currentItem - 1 < 0 ? this.activateLastItem() : this.activateItem(this.currentItem - 1);
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Toggles autoplay on the carousel.
|
|
1449
|
+
*
|
|
1450
|
+
* @public
|
|
1451
|
+
*/
|
|
1452
|
+
toggleAutoplay() {
|
|
1453
|
+
this.autoplay = !this.autoplay, this._handleAutoplay();
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
const B = {
|
|
1457
|
+
Alert: R,
|
|
1458
|
+
Carousel: U
|
|
1459
|
+
};
|
|
1460
|
+
export {
|
|
1461
|
+
B as default
|
|
1462
|
+
};
|