@graupl/graupl 1.0.0-beta.45 → 1.0.0-beta.47
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/dist/css/component/carousel.css +1 -1
- package/dist/css/component/carousel.css.map +1 -1
- package/dist/css/component.css +1 -1
- package/dist/css/component.css.map +1 -1
- package/dist/css/graupl.css +1 -1
- package/dist/css/graupl.css.map +1 -1
- package/dist/js/breadcrumb.js +30 -30
- package/dist/js/breadcrumb.js.map +1 -1
- package/dist/js/carousel.js +266 -145
- package/dist/js/carousel.js.map +1 -1
- package/dist/js/component/breadcrumb.cjs.js +22 -22
- package/dist/js/component/breadcrumb.cjs.js.map +1 -1
- package/dist/js/component/breadcrumb.es.js +22 -22
- package/dist/js/component/breadcrumb.es.js.map +1 -1
- package/dist/js/component/breadcrumb.iife.js +24 -24
- package/dist/js/component/breadcrumb.iife.js.map +1 -1
- package/dist/js/component/carousel.cjs.js +246 -125
- package/dist/js/component/carousel.cjs.js.map +1 -1
- package/dist/js/component/carousel.es.js +246 -125
- package/dist/js/component/carousel.es.js.map +1 -1
- package/dist/js/component/carousel.iife.js +243 -122
- package/dist/js/component/carousel.iife.js.map +1 -1
- package/dist/js/component/disclosure.cjs.js +1 -1
- package/dist/js/component/disclosure.cjs.js.map +1 -1
- package/dist/js/component/disclosure.es.js +1 -1
- package/dist/js/component/disclosure.es.js.map +1 -1
- package/dist/js/component/disclosure.iife.js +1 -1
- package/dist/js/component/disclosure.iife.js.map +1 -1
- package/dist/js/disclosure.js +12 -12
- package/dist/js/disclosure.js.map +1 -1
- package/dist/js/generator/breadcrumb.cjs.js +24 -24
- package/dist/js/generator/breadcrumb.cjs.js.map +1 -1
- package/dist/js/generator/breadcrumb.es.js +40 -40
- package/dist/js/generator/breadcrumb.es.js.map +1 -1
- package/dist/js/generator/breadcrumb.iife.js +46 -46
- package/dist/js/generator/breadcrumb.iife.js.map +1 -1
- package/dist/js/generator/carousel.cjs.js +262 -141
- package/dist/js/generator/carousel.cjs.js.map +1 -1
- package/dist/js/generator/carousel.es.js +262 -141
- package/dist/js/generator/carousel.es.js.map +1 -1
- package/dist/js/generator/carousel.iife.js +263 -142
- package/dist/js/generator/carousel.iife.js.map +1 -1
- package/dist/js/generator/disclosure.cjs.js +13 -13
- package/dist/js/generator/disclosure.cjs.js.map +1 -1
- package/dist/js/generator/disclosure.es.js +13 -13
- package/dist/js/generator/disclosure.es.js.map +1 -1
- package/dist/js/generator/disclosure.iife.js +12 -12
- package/dist/js/generator/disclosure.iife.js.map +1 -1
- package/dist/js/graupl.js +565 -444
- package/dist/js/graupl.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function
|
|
1
|
+
function m(t, e) {
|
|
2
2
|
t === "" || t.length === 0 || (typeof t == "string" ? e.classList.add(t) : e.classList.add(...t));
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function d(t, e) {
|
|
5
5
|
t === "" || t.length === 0 || (typeof t == "string" ? e.classList.remove(t) : e.classList.remove(...t));
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function u(t) {
|
|
8
8
|
try {
|
|
9
9
|
const e = t.key || t.keyCode, r = {
|
|
10
10
|
Enter: e === "Enter" || e === 13,
|
|
@@ -25,10 +25,10 @@ function d(t) {
|
|
|
25
25
|
return "";
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function h(t) {
|
|
29
29
|
t.preventDefault(), t.stopPropagation();
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function l(t, e, { shouldThrow: r = !0 } = {}) {
|
|
32
32
|
const s = {
|
|
33
33
|
status: !0,
|
|
34
34
|
errors: []
|
|
@@ -68,7 +68,7 @@ function a(t, e, { shouldThrow: r = !0 } = {}) {
|
|
|
68
68
|
if (r && !s.status) throw s.errors[0];
|
|
69
69
|
return s;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function v(t, { shouldThrow: e = !0 } = {}) {
|
|
72
72
|
const r = {
|
|
73
73
|
status: !0,
|
|
74
74
|
errors: []
|
|
@@ -91,7 +91,7 @@ function g(t, { shouldThrow: e = !0 } = {}) {
|
|
|
91
91
|
if (e && !r.status) throw r.errors[0];
|
|
92
92
|
return r;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function _(t, { shouldThrow: e = !0 } = {}) {
|
|
95
95
|
const r = {
|
|
96
96
|
status: !0,
|
|
97
97
|
errors: []
|
|
@@ -106,7 +106,7 @@ function c(t, { shouldThrow: e = !0 } = {}) {
|
|
|
106
106
|
else throw new TypeError(`${s} must be a string or an array of strings. "${i}" given.`);
|
|
107
107
|
else {
|
|
108
108
|
const o = {};
|
|
109
|
-
o[s] = t[s],
|
|
109
|
+
o[s] = t[s], v(o);
|
|
110
110
|
}
|
|
111
111
|
} catch (i) {
|
|
112
112
|
r.status = !1, r.errors.push(i);
|
|
@@ -164,13 +164,13 @@ function V(t, { shouldThrow: e = !0 } = {}) {
|
|
|
164
164
|
if (e && !r.status) throw r.errors[0];
|
|
165
165
|
return r;
|
|
166
166
|
}
|
|
167
|
-
function
|
|
167
|
+
function K(t, e, { shouldThrow: r = !0 } = {}) {
|
|
168
168
|
const s = {
|
|
169
169
|
status: !0,
|
|
170
170
|
errors: []
|
|
171
171
|
};
|
|
172
172
|
try {
|
|
173
|
-
if (a("string", { tagName: t }, { shouldThrow: !0 }).status &&
|
|
173
|
+
if (a("string", { tagName: t }, { shouldThrow: !0 }).status && l(HTMLElement, e, { shouldThrow: !0 }).status) {
|
|
174
174
|
const i = t.toLowerCase();
|
|
175
175
|
for (const o in e) try {
|
|
176
176
|
if (e[o].tagName.toLowerCase() !== i) throw new TypeError(`${o} must be a <${i}> element. <${e[o].tagName.toLowerCase()}> given.`);
|
|
@@ -184,7 +184,7 @@ function E(t, e, { shouldThrow: r = !0 } = {}) {
|
|
|
184
184
|
if (r && !s.status) throw s.errors[0];
|
|
185
185
|
return s;
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function F(t, e, { shouldThrow: r = !0 } = {}) {
|
|
188
188
|
const s = {
|
|
189
189
|
status: !0,
|
|
190
190
|
errors: []
|
|
@@ -197,7 +197,7 @@ function P(t, e, { shouldThrow: r = !0 } = {}) {
|
|
|
197
197
|
if (r && !s.status) throw s.errors[0];
|
|
198
198
|
return s;
|
|
199
199
|
}
|
|
200
|
-
function
|
|
200
|
+
function N(t, { shouldThrow: e = !0 } = {}) {
|
|
201
201
|
const r = {
|
|
202
202
|
status: !0,
|
|
203
203
|
errors: []
|
|
@@ -210,7 +210,7 @@ function K(t, { shouldThrow: e = !0 } = {}) {
|
|
|
210
210
|
if (e && !r.status) throw r.errors[0];
|
|
211
211
|
return r;
|
|
212
212
|
}
|
|
213
|
-
var
|
|
213
|
+
var f = class b {
|
|
214
214
|
_scope;
|
|
215
215
|
_type = "_default";
|
|
216
216
|
_storage = {};
|
|
@@ -220,7 +220,7 @@ var p = class v {
|
|
|
220
220
|
}
|
|
221
221
|
initialize() {
|
|
222
222
|
try {
|
|
223
|
-
!this._crush && typeof window[this.scope] < "u" && (
|
|
223
|
+
!this._crush && typeof window[this.scope] < "u" && (l(b, { storage: window[this.scope] }, { shouldThrow: !1 }).status || typeof window[this.scope].storage < "u" && typeof window[this.scope].scope < "u" && typeof window[this.scope].type < "u") && (this._storage = window[this.scope].storage);
|
|
224
224
|
} catch {} finally {
|
|
225
225
|
window[this.scope] = this;
|
|
226
226
|
}
|
|
@@ -270,7 +270,7 @@ var p = class v {
|
|
|
270
270
|
dispose() {
|
|
271
271
|
delete this._storage, delete this;
|
|
272
272
|
}
|
|
273
|
-
},
|
|
273
|
+
}, I = class {
|
|
274
274
|
_dom = {};
|
|
275
275
|
_rootDOMElement = "";
|
|
276
276
|
_protectedDOMElements = [];
|
|
@@ -315,7 +315,7 @@ var p = class v {
|
|
|
315
315
|
if (!this._validate()) throw new Error(`Graupl ${this.name}: Cannot initialize component. The following errors have been found:
|
|
316
316
|
- ${this.errors.map((t) => t.message).join(`
|
|
317
317
|
- `)}`);
|
|
318
|
-
|
|
318
|
+
m(this.initializeClass, this.rootDOMElement), this._dispatchEvent("preinitialize", this.rootDOMElement), this._generateKey(), this._setDOMElements(), this._setIds(), this._setAriaAttributes(), this._setCustomProps(), this._createChildElements(), this._handleMediaMatch(), this._handleFocus(), this._handleHover(), this._handleClick(), this._handleKeydown(), this._handleKeyup(), this._dispatchEvent("initialize", this.rootDOMElement), this._store(), d(this.initializeClass, this.rootDOMElement), this._initialized = !0, this._dispatchEvent("postinitialize", this.rootDOMElement);
|
|
319
319
|
} catch (t) {
|
|
320
320
|
console.error(t);
|
|
321
321
|
}
|
|
@@ -360,7 +360,7 @@ var p = class v {
|
|
|
360
360
|
return this._classes.initialize;
|
|
361
361
|
}
|
|
362
362
|
set initializeClass(t) {
|
|
363
|
-
|
|
363
|
+
_({ initializeClass: t }), this._classes.initialize !== t && (this._classes.initialize = t);
|
|
364
364
|
}
|
|
365
365
|
get focusState() {
|
|
366
366
|
return this._focusState;
|
|
@@ -413,25 +413,25 @@ var p = class v {
|
|
|
413
413
|
}
|
|
414
414
|
_validate() {
|
|
415
415
|
this._dispatchEvent("prevalidate", this.rootDOMElement);
|
|
416
|
-
const t =
|
|
416
|
+
const t = N(this, { shouldThrow: !1 });
|
|
417
417
|
if (t.status || (this._errors = [...this._errors, ...t.errors], this._valid = !1), Object.keys(this._dom).length > 0) {
|
|
418
418
|
const s = {};
|
|
419
|
-
for (const o of Object.keys(this._dom)) Array.isArray(this._dom[o]) ? this._dom[o].forEach((n,
|
|
420
|
-
s[`${o}Element[${
|
|
419
|
+
for (const o of Object.keys(this._dom)) Array.isArray(this._dom[o]) ? this._dom[o].forEach((n, c) => {
|
|
420
|
+
s[`${o}Element[${c}]`] = n;
|
|
421
421
|
}) : this._dom[o] !== null && (s[`${o}Element`] = this._dom[o]);
|
|
422
|
-
const i =
|
|
422
|
+
const i = l(HTMLElement, s, { shouldThrow: !1 });
|
|
423
423
|
i.status || (this._errors = [...this._errors, ...i.errors], this._valid = !1);
|
|
424
424
|
}
|
|
425
425
|
if (Object.keys(this._selectors).length > 0) {
|
|
426
426
|
const s = {};
|
|
427
427
|
for (const o of Object.keys(this._selectors)) s[`${o}Selector`] = this._selectors[o];
|
|
428
|
-
const i =
|
|
428
|
+
const i = v(s, { shouldThrow: !1 });
|
|
429
429
|
i.status || (this._errors = [...this._errors, ...i.errors], this._valid = !1);
|
|
430
430
|
}
|
|
431
431
|
if (Object.keys(this._classes).length > 0) {
|
|
432
432
|
const s = {};
|
|
433
433
|
for (const o of Object.keys(this._classes)) this._classes[o] !== "" && (s[`${o}Class`] = this._classes[o]);
|
|
434
|
-
const i =
|
|
434
|
+
const i = _(s, { shouldThrow: !1 });
|
|
435
435
|
i.status || (this._errors = [...this._errors, ...i.errors], this._valid = !1);
|
|
436
436
|
}
|
|
437
437
|
if (Object.keys(this._durations).length > 0) {
|
|
@@ -468,7 +468,7 @@ var p = class v {
|
|
|
468
468
|
_setDOMElementType(t, { context: e, overwrite: r = !0, strict: s = !1 } = {}) {
|
|
469
469
|
if (typeof this.selectors[t] != "string") throw new Error(`Graupl ${this.name}: "${t}" is not a valid element type.`);
|
|
470
470
|
if (this._rootDOMElement === t || this._protectedDOMElements.includes(t)) throw new Error(`Graupl ${this.name}: "${t}" element cannot be set through _setDOMElementType because it is a protected element.`);
|
|
471
|
-
|
|
471
|
+
l(HTMLElement, { context: e });
|
|
472
472
|
const i = Array.from(e.querySelectorAll(this.selectors[t])).filter((o) => s ? o.parentElement === e : !0);
|
|
473
473
|
Array.isArray(this._dom[t]) ? r ? this._dom[t] = i : this._dom[t] = [...this._dom[t], ...i] : this._dom[t] = i[0] || null;
|
|
474
474
|
}
|
|
@@ -488,14 +488,14 @@ var p = class v {
|
|
|
488
488
|
_handleKeydown() {}
|
|
489
489
|
_handleKeyup() {}
|
|
490
490
|
_store() {
|
|
491
|
-
this._shouldStore && (
|
|
491
|
+
this._shouldStore && (l(f, { storage: window.GrauplStorage }, { shouldThrow: !1 }).status || new f({ scope: "GrauplStorage" }), window.GrauplStorage.set({
|
|
492
492
|
key: this.id !== "" ? this.id : this.key,
|
|
493
493
|
type: this._storageKey,
|
|
494
494
|
data: this
|
|
495
495
|
}));
|
|
496
496
|
}
|
|
497
497
|
_unstore() {
|
|
498
|
-
this._shouldStore &&
|
|
498
|
+
this._shouldStore && l(f, { storage: window.GrauplStorage }, { shouldThrow: !1 }).status && window.GrauplStorage.clear({
|
|
499
499
|
key: this.id !== "" ? this.id : this.key,
|
|
500
500
|
type: this._storageKey
|
|
501
501
|
});
|
|
@@ -530,7 +530,7 @@ var p = class v {
|
|
|
530
530
|
});
|
|
531
531
|
}
|
|
532
532
|
_dispatchEvent(t, e) {
|
|
533
|
-
|
|
533
|
+
F(t, this), l(HTMLElement, { element: e }), e.dispatchEvent(this.events[t]);
|
|
534
534
|
}
|
|
535
535
|
_addEventListener(t, e, r, s = {}) {
|
|
536
536
|
e.addEventListener(t, r, s), this._listeners.push({
|
|
@@ -561,77 +561,96 @@ var p = class v {
|
|
|
561
561
|
dispose() {
|
|
562
562
|
this._clearIntervals(), this._clearTimeouts(), this._removeEventListeners(), this._unstore(), delete this;
|
|
563
563
|
}
|
|
564
|
-
},
|
|
564
|
+
}, p = class extends I {
|
|
565
|
+
_rootDOMElement = "carouselItem";
|
|
566
|
+
_shouldStore = !1;
|
|
567
|
+
_storageKey = "carouselItems";
|
|
568
|
+
_name = "CarouselItem";
|
|
569
|
+
_busy = !1;
|
|
570
|
+
constructor({ carouselItemElement: t, tabElement: e = null, clone: r = null, parent: s, prefix: i = "graupl-", key: o = null, initializeClass: n = "initializing", initialize: c = !1 }) {
|
|
571
|
+
super({
|
|
572
|
+
prefix: i,
|
|
573
|
+
key: o,
|
|
574
|
+
initializeClass: n
|
|
575
|
+
}), this._dom.carouselItem = t, this._dom.tab = e, this._elements.clone = r ?? null, this._elements.parent = s, c && this.initialize();
|
|
576
|
+
}
|
|
577
|
+
activate({ scroll: t = !0, scrollOptions: e = {} } = {}) {
|
|
578
|
+
requestAnimationFrame(() => {
|
|
579
|
+
m(this.elements.parent.activeClass, this.dom.carouselItem), this.dom.carouselItem.removeAttribute("inert"), t && this.elements.parent.dom.carouselItemContainer.scrollTo({
|
|
580
|
+
left: this.dom.carouselItem.offsetLeft,
|
|
581
|
+
top: this.dom.carouselItem.offsetTop,
|
|
582
|
+
behavior: "smooth",
|
|
583
|
+
...e
|
|
584
|
+
}), this.dom.tab && requestAnimationFrame(() => {
|
|
585
|
+
m(this.elements.parent.activeClass, this.dom.tab), this.dom.tab.setAttribute("aria-selected", !0);
|
|
586
|
+
});
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
deactivate() {
|
|
590
|
+
requestAnimationFrame(() => {
|
|
591
|
+
d(this.elements.parent.activeClass, this.dom.carouselItem), this.dom.carouselItem.setAttribute("inert", !0), requestAnimationFrame(() => {
|
|
592
|
+
this.dom.tab && (d(this.elements.parent.activeClass, this.dom.tab), this.dom.tab.setAttribute("aria-selected", !1));
|
|
593
|
+
});
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
}, q = class extends I {
|
|
565
597
|
_rootDOMElement = "carousel";
|
|
566
598
|
_currentItem = 0;
|
|
567
599
|
_autoplay = !0;
|
|
568
600
|
_playText = "Play";
|
|
569
601
|
_pauseText = "Pause";
|
|
570
|
-
_currentAction = "next";
|
|
571
602
|
_storageKey = "carousels";
|
|
572
603
|
_name = "Carousel";
|
|
573
|
-
|
|
604
|
+
_itemsPerPage = 1;
|
|
605
|
+
_loop = !0;
|
|
606
|
+
constructor({ carouselElement: t, carouselItemsSelector: e = ".carousel-item", carouselItemContainerSelector: r = ".carousel-item-container", carouselControlsSelector: s = ".carousel-control", carouselControlContainerSelector: i = ".carousel-control-container", carouselTabsSelector: o = ".carousel-tab", carouselTabContainerSelector: n = ".carousel-tab-container", autoplaySelector: c = ".autoplay", nextSelector: w = ".next", previousSelector: C = ".previous", activeClass: k = "active", playClass: T = "play", pauseClass: $ = "pause", autoplay: x = !0, transitionDelay: M = 1e4, playText: A = "Play", pauseText: O = "Pause", itemsPerPage: D = 1, loop: S = !0, prefix: L = "graupl-", key: z = null, initializeClass: P = "initializing", initialize: j = !1 }) {
|
|
574
607
|
super({
|
|
575
|
-
prefix:
|
|
576
|
-
key:
|
|
577
|
-
initializeClass:
|
|
578
|
-
}), this._dom.carousel = t, this._dom.carouselItems = [], this._dom.carouselItemContainer = null, this._dom.carouselControls = [], this._dom.carouselControlContainer = null, this._dom.carouselTabs = [], this._dom.carouselTabContainer = null, this._dom.autoplay = null, this._dom.next = null, this._dom.previous = null, this._selectors.carouselItems = e, this._selectors.carouselItemContainer = r, this._selectors.carouselControls = s, this._selectors.carouselControlContainer = i, this._selectors.carouselTabs = o, this._selectors.carouselTabContainer = n, this._selectors.autoplay =
|
|
579
|
-
this._handleAutoplay(), this.
|
|
580
|
-
m.setAttribute("inert", "true");
|
|
581
|
-
}), this.activateFirstItem();
|
|
608
|
+
prefix: L,
|
|
609
|
+
key: z,
|
|
610
|
+
initializeClass: P
|
|
611
|
+
}), this._dom.carousel = t, this._dom.carouselItems = [], this._dom.carouselItemContainer = null, this._dom.carouselControls = [], this._dom.carouselControlContainer = null, this._dom.carouselTabs = [], this._dom.carouselTabContainer = null, this._dom.autoplay = null, this._dom.next = null, this._dom.previous = null, this._selectors.carouselItems = e, this._selectors.carouselItemContainer = r, this._selectors.carouselControls = s, this._selectors.carouselControlContainer = i, this._selectors.carouselTabs = o, this._selectors.carouselTabContainer = n, this._selectors.autoplay = c, this._selectors.next = w, this._selectors.previous = C, this._elements.carouselItems = [], this._classes.active = k || "", this._classes.play = T || "", this._classes.pause = $ || "", this._autoplay = x, this._itemsPerPage = D, this._loop = S, this._delays.transition = M, this._playText = A || "", this._pauseText = O || "", this._addEventListener("grauplComponentInitialize", this.rootDOMElement, () => {
|
|
612
|
+
this._handleAutoplay(), this.loop && this._handleLoop(), this._handleIntersection(), this.activateFirstItem({ scrollOptions: { behavior: "instant" } });
|
|
582
613
|
}), this._addEventListener("grauplComponentValidate", this.rootDOMElement, () => {
|
|
583
|
-
const
|
|
584
|
-
|
|
585
|
-
|
|
614
|
+
const y = a("boolean", {
|
|
615
|
+
autoplay: this._autoplay,
|
|
616
|
+
loop: this._loop
|
|
617
|
+
}, { shouldThrow: !1 });
|
|
618
|
+
y.status || (this._errors = [...this._errors, ...y.errors], this._valid = !1);
|
|
619
|
+
const g = a("string", {
|
|
586
620
|
playText: this._playText,
|
|
587
621
|
pauseText: this._pauseText
|
|
588
622
|
}, { shouldThrow: !1 });
|
|
589
|
-
|
|
590
|
-
|
|
623
|
+
g.status || (this._errors = [...this._errors, ...g.errors], this._valid = !1);
|
|
624
|
+
const E = a("number", { itemsPerPage: this._itemsPerPage }, { shouldThrow: !1 });
|
|
625
|
+
E.status || (this._errors = [...this._errors, ...E.errors], this._valid = !1);
|
|
626
|
+
}), j && this.initialize();
|
|
591
627
|
}
|
|
592
628
|
get activeClass() {
|
|
593
629
|
return this._classes.active;
|
|
594
630
|
}
|
|
595
631
|
set activeClass(t) {
|
|
596
|
-
|
|
597
|
-
}
|
|
598
|
-
get previousClass() {
|
|
599
|
-
return this._classes.previous;
|
|
600
|
-
}
|
|
601
|
-
set previousClass(t) {
|
|
602
|
-
c({ previousClass: t }), this._classes.previous !== t && (this._classes.previous = t);
|
|
603
|
-
}
|
|
604
|
-
get nextClass() {
|
|
605
|
-
return this._classes.next;
|
|
606
|
-
}
|
|
607
|
-
set nextClass(t) {
|
|
608
|
-
c({ nextClass: t }), this._classes.next !== t && (this._classes.next = t);
|
|
632
|
+
_({ activeClass: t }), this._classes.active !== t && (this._classes.active = t);
|
|
609
633
|
}
|
|
610
634
|
get playClass() {
|
|
611
635
|
return this._classes.play;
|
|
612
636
|
}
|
|
613
637
|
set playClass(t) {
|
|
614
|
-
|
|
638
|
+
_({ playClass: t }), this._classes.play !== t && (this._classes.play = t);
|
|
615
639
|
}
|
|
616
640
|
get pauseClass() {
|
|
617
641
|
return this._classes.pause;
|
|
618
642
|
}
|
|
619
643
|
set pauseClass(t) {
|
|
620
|
-
|
|
644
|
+
_({ pauseClass: t }), this._classes.pause !== t && (this._classes.pause = t);
|
|
621
645
|
}
|
|
622
646
|
get currentItem() {
|
|
623
647
|
return this._currentItem;
|
|
624
648
|
}
|
|
625
649
|
set currentItem(t) {
|
|
626
|
-
a("number", { currentItem: t }), t !== this.currentItem && (t < 0 ? this._currentItem = 0 : t >= this.dom.carouselItems.length ? this._currentItem = this.dom.carouselItems.length - 1 : this._currentItem = t
|
|
627
|
-
e.setAttribute("aria-selected", r === this._currentItem);
|
|
628
|
-
}));
|
|
650
|
+
a("number", { currentItem: t }), t !== this.currentItem && (t < 0 ? this._currentItem = 0 : t >= this.dom.carouselItems.length ? this._currentItem = this.dom.carouselItems.length - 1 : this._currentItem = t);
|
|
629
651
|
}
|
|
630
652
|
get currentCarouselItem() {
|
|
631
|
-
return this.
|
|
632
|
-
}
|
|
633
|
-
get currentCarouselTab() {
|
|
634
|
-
return this.dom.carouselTabs[this.currentItem];
|
|
653
|
+
return this.elements.carouselItems[this.currentItem];
|
|
635
654
|
}
|
|
636
655
|
get autoplay() {
|
|
637
656
|
return this._autoplay;
|
|
@@ -639,18 +658,18 @@ var p = class v {
|
|
|
639
658
|
set autoplay(t) {
|
|
640
659
|
a("boolean", { autoplay: t }), this._autoplay !== t && (this._autoplay = t);
|
|
641
660
|
}
|
|
661
|
+
get itemsPerPage() {
|
|
662
|
+
return this._itemsPerPage;
|
|
663
|
+
}
|
|
664
|
+
get loop() {
|
|
665
|
+
return this._loop;
|
|
666
|
+
}
|
|
642
667
|
get transitionDelay() {
|
|
643
668
|
return this._delays.transition;
|
|
644
669
|
}
|
|
645
670
|
set transitionDelay(t) {
|
|
646
671
|
a("number", { transitionDelay: t }), t !== this.transitionDelay && t >= 0 && (this._delays.transition = t);
|
|
647
672
|
}
|
|
648
|
-
get transitionDuration() {
|
|
649
|
-
return this._durations.transition;
|
|
650
|
-
}
|
|
651
|
-
set transitionDuration(t) {
|
|
652
|
-
a("number", { transitionDuration: t }), this._durations.transition !== t && t >= 0 && (this._durations.transition = t, this._setTransitionDuration());
|
|
653
|
-
}
|
|
654
673
|
get playText() {
|
|
655
674
|
return this._playText;
|
|
656
675
|
}
|
|
@@ -663,12 +682,22 @@ var p = class v {
|
|
|
663
682
|
set pauseText(t) {
|
|
664
683
|
a("string", { pauseText: t }), this._pauseText !== t && (this._pauseText = t);
|
|
665
684
|
}
|
|
666
|
-
get currentAction() {
|
|
667
|
-
return this._currentAction;
|
|
668
|
-
}
|
|
669
685
|
_setDOMElements() {
|
|
670
686
|
this._setDOMElementType("carouselItemContainer", { context: this.dom.carousel }), this._setDOMElementType("carouselControlContainer", { context: this.dom.carousel }), this._setDOMElementType("carouselTabContainer", { context: this.dom.carousel }), this.dom.carouselItemContainer && this._setDOMElementType("carouselItems", { context: this.dom.carouselItemContainer }), this.dom.carouselControlContainer && (this._setDOMElementType("carouselControls", { context: this.dom.carouselControlContainer }), this._setDOMElementType("autoplay", { context: this.dom.carouselControlContainer }), this._setDOMElementType("next", { context: this.dom.carouselControlContainer }), this._setDOMElementType("previous", { context: this.dom.carouselControlContainer })), this._dom.carouselTabContainer && this._setDOMElementType("carouselTabs", { context: this.dom.carouselTabContainer });
|
|
671
687
|
}
|
|
688
|
+
_createChildElements() {
|
|
689
|
+
this.dom.carouselItems.forEach((t, e) => {
|
|
690
|
+
const r = new p({
|
|
691
|
+
carouselItemElement: t,
|
|
692
|
+
tabElement: this.dom.carouselTabs ? this.dom.carouselTabs[e] : null,
|
|
693
|
+
parent: this,
|
|
694
|
+
prefix: this.prefix,
|
|
695
|
+
initializeClass: this.classes.initialize,
|
|
696
|
+
initialize: !0
|
|
697
|
+
});
|
|
698
|
+
this._elements.carouselItems.push(r);
|
|
699
|
+
});
|
|
700
|
+
}
|
|
672
701
|
_setIds() {
|
|
673
702
|
this.dom.carousel.id = this.dom.carousel.id || `carousel-${this.key}`, this.dom.carouselItems.forEach((t, e) => {
|
|
674
703
|
t.id = t.id || `carousel-item-${this.key}-${e}`;
|
|
@@ -677,15 +706,36 @@ var p = class v {
|
|
|
677
706
|
}), this._id = this.dom.carousel.id;
|
|
678
707
|
}
|
|
679
708
|
_setAriaAttributes() {
|
|
680
|
-
!
|
|
681
|
-
|
|
709
|
+
!K("section", { carousel: this.dom.carousel }, { shouldThrow: !1 }).status && !this.dom.carousel.getAttribute("role") !== "region" && this.dom.carousel.setAttribute("role", "group"), this.dom.carouselItems.forEach((t) => {
|
|
710
|
+
t.setAttribute("inert", "true");
|
|
711
|
+
}), this.dom.carouselItemContainer && this.dom.carouselItemContainer.setAttribute("tabindex", "-1"), this._dom.carousel.setAttribute("aria-roledescription", "carousel"), this.dom.carouselTabContainer && this.dom.carouselTabContainer.setAttribute("role", "tablist"), this.dom.carouselTabs.forEach((t, e) => {
|
|
712
|
+
t.setAttribute("role", "tab"), t.setAttribute("aria-selected", e === 0), t.setAttribute("aria-controls", this.dom.carouselItems[e].id);
|
|
682
713
|
});
|
|
683
714
|
}
|
|
684
|
-
_setCustomProps() {
|
|
685
|
-
this.dom.carousel.style.setProperty(`--${this.prefix}carousel-transition-duration`, `${this.transitionDuration}ms`);
|
|
686
|
-
}
|
|
687
715
|
_handleAutoplay() {
|
|
688
|
-
this.autoplay ? (
|
|
716
|
+
this.autoplay ? (m(this.pauseClass, this.dom.autoplay), d(this.playClass, this.dom.autoplay), this.dom.autoplay.setAttribute("aria-label", this.pauseText), this.dom.carousel.setAttribute("aria-live", "off"), this._setInterval(() => this.activateNextItem(), this.transitionDelay)) : (m(this.playClass, this.dom.autoplay), d(this.pauseClass, this.dom.autoplay), this.dom.autoplay.setAttribute("aria-label", this.playText), this.dom.carousel.setAttribute("aria-live", "polite"), this._clearInterval());
|
|
717
|
+
}
|
|
718
|
+
_handleIntersection() {
|
|
719
|
+
const t = {
|
|
720
|
+
root: this.dom.carouselItemContainer,
|
|
721
|
+
rootMargin: "1px",
|
|
722
|
+
scrollMargin: "1px",
|
|
723
|
+
threshold: 1
|
|
724
|
+
}, e = new IntersectionObserver((r) => {
|
|
725
|
+
this.isInitialized && r.forEach((s) => {
|
|
726
|
+
if (!s.isIntersecting) return;
|
|
727
|
+
const i = this.dom.carouselItems.indexOf(s.target);
|
|
728
|
+
let o = i;
|
|
729
|
+
this.elements.carouselItems[i].elements.clone !== null && (o = this.dom.carouselItems.indexOf(this.elements.carouselItems[i].elements.clone.dom.carouselItem), (i === 0 || i === this.dom.carouselItems.length - 1) && this.dom.carouselItemContainer.scrollTo({
|
|
730
|
+
left: this.elements.carouselItems[i].elements.clone.dom.carouselItem.offsetLeft,
|
|
731
|
+
top: this.elements.carouselItems[i].elements.clone.dom.carouselItem.offsetTop,
|
|
732
|
+
behavior: "instant"
|
|
733
|
+
})), this.currentItem !== o && this.activateItem(o, { scroll: !1 });
|
|
734
|
+
});
|
|
735
|
+
}, t);
|
|
736
|
+
this.dom.carouselItems.forEach((r) => {
|
|
737
|
+
e.observe(r);
|
|
738
|
+
});
|
|
689
739
|
}
|
|
690
740
|
_handleFocus() {
|
|
691
741
|
this._addEventListener("focusin", this.dom.carousel, () => {
|
|
@@ -695,15 +745,15 @@ var p = class v {
|
|
|
695
745
|
});
|
|
696
746
|
}
|
|
697
747
|
_handleClick() {
|
|
698
|
-
this._addEventListener("click", this.dom.next, () => {
|
|
699
|
-
this.activateNextItem();
|
|
700
|
-
}), this._addEventListener("click", this.dom.previous, () => {
|
|
701
|
-
this.activatePreviousItem();
|
|
702
|
-
}), this._addEventListener("click", this.dom.autoplay, () => {
|
|
703
|
-
this.toggleAutoplay();
|
|
704
|
-
}), this.
|
|
705
|
-
this._addEventListener("click", t, () => {
|
|
706
|
-
|
|
748
|
+
this._addEventListener("click", this.dom.next, (t) => {
|
|
749
|
+
t.button === 0 && (h(t), this.currentEvent = "mouse", this.activateNextItem());
|
|
750
|
+
}), this._addEventListener("click", this.dom.previous, (t) => {
|
|
751
|
+
t.button === 0 && (h(t), this.currentEvent = "mouse", this.activatePreviousItem());
|
|
752
|
+
}), this._addEventListener("click", this.dom.autoplay, (t) => {
|
|
753
|
+
t.button === 0 && (h(t), this.currentEvent = "mouse", this.toggleAutoplay());
|
|
754
|
+
}), this.elements.carouselItems.forEach((t) => {
|
|
755
|
+
t.dom.tab && this._addEventListener("click", t.dom.tab, (e) => {
|
|
756
|
+
e.button === 0 && (h(e), this.currentEvent = "mouse", this.activateItem(this.dom.carouselItems.indexOf(t.dom.carouselItem)));
|
|
707
757
|
});
|
|
708
758
|
});
|
|
709
759
|
}
|
|
@@ -717,19 +767,19 @@ var p = class v {
|
|
|
717
767
|
_handleKeydown() {
|
|
718
768
|
this.dom.carouselControls.forEach((t) => {
|
|
719
769
|
this._addEventListener("keydown", t, (e) => {
|
|
720
|
-
switch (
|
|
770
|
+
switch (u(e)) {
|
|
721
771
|
case "Space":
|
|
722
772
|
case "Enter":
|
|
723
|
-
|
|
773
|
+
h(e);
|
|
724
774
|
break;
|
|
725
775
|
}
|
|
726
776
|
});
|
|
727
|
-
}), this.
|
|
728
|
-
this._addEventListener("keydown", t, (e) => {
|
|
729
|
-
switch (
|
|
777
|
+
}), this.elements.carouselItems.forEach((t) => {
|
|
778
|
+
t.dom.tab && this._addEventListener("keydown", t.dom.tab, (e) => {
|
|
779
|
+
switch (u(e)) {
|
|
730
780
|
case "Space":
|
|
731
781
|
case "Enter":
|
|
732
|
-
|
|
782
|
+
h(e);
|
|
733
783
|
break;
|
|
734
784
|
}
|
|
735
785
|
});
|
|
@@ -737,69 +787,140 @@ var p = class v {
|
|
|
737
787
|
}
|
|
738
788
|
_handleKeyup() {
|
|
739
789
|
this._addEventListener("keyup", this.dom.next, (t) => {
|
|
740
|
-
switch (
|
|
790
|
+
switch (u(t)) {
|
|
741
791
|
case "Space":
|
|
742
792
|
case "Enter":
|
|
743
|
-
this.activateNextItem(),
|
|
793
|
+
this.activateNextItem(), h(t);
|
|
744
794
|
break;
|
|
745
795
|
}
|
|
746
796
|
}), this._addEventListener("keyup", this.dom.previous, (t) => {
|
|
747
|
-
switch (
|
|
797
|
+
switch (u(t)) {
|
|
748
798
|
case "Space":
|
|
749
799
|
case "Enter":
|
|
750
|
-
this.activatePreviousItem(),
|
|
800
|
+
this.activatePreviousItem(), h(t);
|
|
751
801
|
break;
|
|
752
802
|
}
|
|
753
803
|
}), this._addEventListener("keyup", this.dom.autoplay, (t) => {
|
|
754
|
-
switch (
|
|
804
|
+
switch (u(t)) {
|
|
755
805
|
case "Space":
|
|
756
806
|
case "Enter":
|
|
757
|
-
this.toggleAutoplay(),
|
|
807
|
+
this.toggleAutoplay(), h(t);
|
|
758
808
|
break;
|
|
759
809
|
}
|
|
760
|
-
}), this.
|
|
761
|
-
this._addEventListener("keyup", t, (
|
|
762
|
-
switch (
|
|
810
|
+
}), this.elements.carouselItems.forEach((t) => {
|
|
811
|
+
t.dom.tab && this._addEventListener("keyup", t.dom.tab, (e) => {
|
|
812
|
+
switch (u(e)) {
|
|
763
813
|
case "Space":
|
|
764
814
|
case "Enter":
|
|
765
|
-
this.activateItem(
|
|
815
|
+
this.activateItem(this.dom.carouselItems.indexOf(t.dom.carouselItem)), h(e);
|
|
766
816
|
break;
|
|
767
817
|
}
|
|
768
818
|
});
|
|
769
819
|
});
|
|
770
820
|
}
|
|
771
|
-
|
|
772
|
-
|
|
821
|
+
_handleLoop() {
|
|
822
|
+
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), r = this.dom.carouselItemContainer;
|
|
823
|
+
for (let s = 0; s < this.itemsPerPage; s++) t.set(this.dom.carouselItems[s], this.dom.carouselItems.indexOf(this.dom.carouselItems[s]));
|
|
824
|
+
for (let s = this.dom.carouselItems.length - this.itemsPerPage; s < this.dom.carouselItems.length; s++) e.set(this.dom.carouselItems[s], this.dom.carouselItems.indexOf(this.dom.carouselItems[s]));
|
|
825
|
+
t.forEach((s, i) => {
|
|
826
|
+
const o = i.cloneNode(!0);
|
|
827
|
+
o.setAttribute("aria-hidden", "true"), o.setAttribute("inert", "true"), o.setAttribute("id", `${i.id}-clone`), r.appendChild(o);
|
|
828
|
+
const n = new p({
|
|
829
|
+
carouselItemElement: o,
|
|
830
|
+
clone: this._elements.carouselItems[s],
|
|
831
|
+
parent: this,
|
|
832
|
+
prefix: this.prefix,
|
|
833
|
+
initializeClass: this.classes.initialize,
|
|
834
|
+
initialize: !0
|
|
835
|
+
});
|
|
836
|
+
this.dom.carouselItems.push(o), this._elements.carouselItems.push(n);
|
|
837
|
+
}), e.forEach((s, i) => {
|
|
838
|
+
const o = i.cloneNode(!0);
|
|
839
|
+
o.setAttribute("aria-hidden", "true"), o.setAttribute("inert", "true"), o.setAttribute("id", `${i.id}-clone`), r.insertBefore(o, r.firstChild);
|
|
840
|
+
const n = new p({
|
|
841
|
+
carouselItemElement: o,
|
|
842
|
+
clone: this._elements.carouselItems[s],
|
|
843
|
+
parent: this,
|
|
844
|
+
prefix: this.prefix,
|
|
845
|
+
initializeClass: this.classes.initialize,
|
|
846
|
+
initialize: !0
|
|
847
|
+
});
|
|
848
|
+
this.dom.carouselItems.unshift(o), this._elements.carouselItems.unshift(n);
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
activateCurrentItem({ scroll: t = !0, scrollOptions: e = {} } = {}) {
|
|
852
|
+
this.currentCarouselItem.activate({
|
|
853
|
+
scroll: t,
|
|
854
|
+
scrollOptions: e
|
|
855
|
+
});
|
|
773
856
|
}
|
|
774
|
-
deactivateCurrentItem() {
|
|
775
|
-
|
|
857
|
+
deactivateCurrentItem({ scroll: t = !0, scrollOptions: e = {} } = {}) {
|
|
858
|
+
this.currentCarouselItem.deactivate({
|
|
859
|
+
scroll: t,
|
|
860
|
+
scrollOptions: e
|
|
861
|
+
});
|
|
776
862
|
}
|
|
777
|
-
activateItem(t) {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
});
|
|
863
|
+
activateItem(t, { scroll: e = !0, scrollOptions: r = {} } = {}) {
|
|
864
|
+
this.autoplay && this._clearInterval(), this.deactivateCurrentItem({
|
|
865
|
+
scroll: e,
|
|
866
|
+
scrollOptions: r
|
|
867
|
+
}), this.currentItem = t, this.activateCurrentItem({
|
|
868
|
+
scroll: e,
|
|
869
|
+
scrollOptions: r
|
|
785
870
|
}), this.autoplay && this._setInterval(() => this.activateNextItem(), this.transitionDelay);
|
|
786
871
|
}
|
|
787
|
-
activateFirstItem() {
|
|
788
|
-
this.
|
|
872
|
+
activateFirstItem({ scroll: t = !0, scrollOptions: e = {} } = {}) {
|
|
873
|
+
this.loop ? this.currentItem === this.dom.carouselItems.length - this.itemsPerPage - 1 ? this.activateNextItem({
|
|
874
|
+
scroll: t,
|
|
875
|
+
scrollOptions: e
|
|
876
|
+
}) : this.activateItem(this.itemsPerPage, {
|
|
877
|
+
scroll: t,
|
|
878
|
+
scrollOptions: e
|
|
879
|
+
}) : this.activateItem(0, {
|
|
880
|
+
scroll: t,
|
|
881
|
+
scrollOptions: e
|
|
882
|
+
});
|
|
789
883
|
}
|
|
790
|
-
activateLastItem() {
|
|
791
|
-
this.
|
|
884
|
+
activateLastItem({ scroll: t = !0, scrollOptions: e = {} } = {}) {
|
|
885
|
+
this.loop ? this.currentItem === this.itemsPerPage ? this.activatePreviousItem({
|
|
886
|
+
scroll: t,
|
|
887
|
+
scrollOptions: e
|
|
888
|
+
}) : this.activateItem(this.dom.carouselItems.length - this.itemsPerPage - 1, {
|
|
889
|
+
scroll: t,
|
|
890
|
+
scrollOptions: e
|
|
891
|
+
}) : this.activateItem(this.dom.carouselItems.length - 1, {
|
|
892
|
+
scroll: t,
|
|
893
|
+
scrollOptions: e
|
|
894
|
+
});
|
|
792
895
|
}
|
|
793
|
-
activateNextItem() {
|
|
794
|
-
this.
|
|
896
|
+
activateNextItem({ scroll: t = !0, scrollOptions: e = {} } = {}) {
|
|
897
|
+
this.loop ? this.activateItem(this.currentItem + 1, {
|
|
898
|
+
scroll: t,
|
|
899
|
+
scrollOptions: e
|
|
900
|
+
}) : this.currentItem + 1 >= this.dom.carouselItems.length ? this.activateFirstItem({
|
|
901
|
+
scroll: t,
|
|
902
|
+
scrollOptions: e
|
|
903
|
+
}) : this.activateItem(this.currentItem + 1, {
|
|
904
|
+
scroll: t,
|
|
905
|
+
scrollOptions: e
|
|
906
|
+
});
|
|
795
907
|
}
|
|
796
|
-
activatePreviousItem() {
|
|
797
|
-
this.
|
|
908
|
+
activatePreviousItem({ scroll: t = !0, scrollOptions: e = {} } = {}) {
|
|
909
|
+
this.loop ? this.activateItem(this.currentItem - 1, {
|
|
910
|
+
scroll: t,
|
|
911
|
+
scrollOptions: e
|
|
912
|
+
}) : this.currentItem - 1 < 0 || this.loop && this.currentItem - 1 < this.itemsPerPage ? this.activateLastItem({
|
|
913
|
+
scroll: t,
|
|
914
|
+
scrollOptions: e
|
|
915
|
+
}) : this.activateItem(this.currentItem - 1, {
|
|
916
|
+
scroll: t,
|
|
917
|
+
scrollOptions: e
|
|
918
|
+
});
|
|
798
919
|
}
|
|
799
920
|
toggleAutoplay() {
|
|
800
921
|
this.autoplay = !this.autoplay, this._handleAutoplay();
|
|
801
922
|
}
|
|
802
923
|
};
|
|
803
|
-
export {
|
|
924
|
+
export { q as default };
|
|
804
925
|
|
|
805
926
|
//# sourceMappingURL=carousel.es.js.map
|