@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.
Files changed (51) hide show
  1. package/dist/css/component/carousel.css +1 -1
  2. package/dist/css/component/carousel.css.map +1 -1
  3. package/dist/css/component.css +1 -1
  4. package/dist/css/component.css.map +1 -1
  5. package/dist/css/graupl.css +1 -1
  6. package/dist/css/graupl.css.map +1 -1
  7. package/dist/js/breadcrumb.js +30 -30
  8. package/dist/js/breadcrumb.js.map +1 -1
  9. package/dist/js/carousel.js +266 -145
  10. package/dist/js/carousel.js.map +1 -1
  11. package/dist/js/component/breadcrumb.cjs.js +22 -22
  12. package/dist/js/component/breadcrumb.cjs.js.map +1 -1
  13. package/dist/js/component/breadcrumb.es.js +22 -22
  14. package/dist/js/component/breadcrumb.es.js.map +1 -1
  15. package/dist/js/component/breadcrumb.iife.js +24 -24
  16. package/dist/js/component/breadcrumb.iife.js.map +1 -1
  17. package/dist/js/component/carousel.cjs.js +246 -125
  18. package/dist/js/component/carousel.cjs.js.map +1 -1
  19. package/dist/js/component/carousel.es.js +246 -125
  20. package/dist/js/component/carousel.es.js.map +1 -1
  21. package/dist/js/component/carousel.iife.js +243 -122
  22. package/dist/js/component/carousel.iife.js.map +1 -1
  23. package/dist/js/component/disclosure.cjs.js +1 -1
  24. package/dist/js/component/disclosure.cjs.js.map +1 -1
  25. package/dist/js/component/disclosure.es.js +1 -1
  26. package/dist/js/component/disclosure.es.js.map +1 -1
  27. package/dist/js/component/disclosure.iife.js +1 -1
  28. package/dist/js/component/disclosure.iife.js.map +1 -1
  29. package/dist/js/disclosure.js +12 -12
  30. package/dist/js/disclosure.js.map +1 -1
  31. package/dist/js/generator/breadcrumb.cjs.js +24 -24
  32. package/dist/js/generator/breadcrumb.cjs.js.map +1 -1
  33. package/dist/js/generator/breadcrumb.es.js +40 -40
  34. package/dist/js/generator/breadcrumb.es.js.map +1 -1
  35. package/dist/js/generator/breadcrumb.iife.js +46 -46
  36. package/dist/js/generator/breadcrumb.iife.js.map +1 -1
  37. package/dist/js/generator/carousel.cjs.js +262 -141
  38. package/dist/js/generator/carousel.cjs.js.map +1 -1
  39. package/dist/js/generator/carousel.es.js +262 -141
  40. package/dist/js/generator/carousel.es.js.map +1 -1
  41. package/dist/js/generator/carousel.iife.js +263 -142
  42. package/dist/js/generator/carousel.iife.js.map +1 -1
  43. package/dist/js/generator/disclosure.cjs.js +13 -13
  44. package/dist/js/generator/disclosure.cjs.js.map +1 -1
  45. package/dist/js/generator/disclosure.es.js +13 -13
  46. package/dist/js/generator/disclosure.es.js.map +1 -1
  47. package/dist/js/generator/disclosure.iife.js +12 -12
  48. package/dist/js/generator/disclosure.iife.js.map +1 -1
  49. package/dist/js/graupl.js +565 -444
  50. package/dist/js/graupl.js.map +1 -1
  51. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
- function h(t, e) {
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 l(t, e) {
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 d(t) {
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 _(t) {
28
+ function l(t) {
29
29
  t.preventDefault(), t.stopPropagation();
30
30
  }
31
- function u(t, e, { shouldThrow: r = !0 } = {}) {
31
+ function h(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 T(t, { shouldThrow: e = !0 } = {}) {
71
+ function k(t, { shouldThrow: e = !0 } = {}) {
72
72
  const r = {
73
73
  status: !0,
74
74
  errors: []
@@ -91,7 +91,7 @@ function T(t, { shouldThrow: e = !0 } = {}) {
91
91
  if (e && !r.status) throw r.errors[0];
92
92
  return r;
93
93
  }
94
- function c(t, { shouldThrow: e = !0 } = {}) {
94
+ function f(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], T(o);
109
+ o[s] = t[s], k(o);
110
110
  }
111
111
  } catch (i) {
112
112
  r.status = !1, r.errors.push(i);
@@ -117,7 +117,7 @@ function c(t, { shouldThrow: e = !0 } = {}) {
117
117
  if (e && !r.status) throw r.errors[0];
118
118
  return r;
119
119
  }
120
- function H(t, { shouldThrow: e = !0 } = {}) {
120
+ function R(t, { shouldThrow: e = !0 } = {}) {
121
121
  const r = {
122
122
  status: !0,
123
123
  errors: []
@@ -140,7 +140,7 @@ function H(t, { shouldThrow: e = !0 } = {}) {
140
140
  if (e && !r.status) throw r.errors[0];
141
141
  return r;
142
142
  }
143
- function R(t, { shouldThrow: e = !0 } = {}) {
143
+ function U(t, { shouldThrow: e = !0 } = {}) {
144
144
  const r = {
145
145
  status: !0,
146
146
  errors: []
@@ -164,13 +164,13 @@ function R(t, { shouldThrow: e = !0 } = {}) {
164
164
  if (e && !r.status) throw r.errors[0];
165
165
  return r;
166
166
  }
167
- function I(t, e, { shouldThrow: r = !0 } = {}) {
167
+ function J(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 && u(HTMLElement, e, { shouldThrow: !0 }).status) {
173
+ if (a("string", { tagName: t }, { shouldThrow: !0 }).status && h(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 I(t, e, { shouldThrow: r = !0 } = {}) {
184
184
  if (r && !s.status) throw s.errors[0];
185
185
  return s;
186
186
  }
187
- function U(t, e, { shouldThrow: r = !0 } = {}) {
187
+ function B(t, e, { shouldThrow: r = !0 } = {}) {
188
188
  const s = {
189
189
  status: !0,
190
190
  errors: []
@@ -197,7 +197,7 @@ function U(t, e, { shouldThrow: r = !0 } = {}) {
197
197
  if (r && !s.status) throw s.errors[0];
198
198
  return s;
199
199
  }
200
- function J(t, { shouldThrow: e = !0 } = {}) {
200
+ function Z(t, { shouldThrow: e = !0 } = {}) {
201
201
  const r = {
202
202
  status: !0,
203
203
  errors: []
@@ -210,7 +210,7 @@ function J(t, { shouldThrow: e = !0 } = {}) {
210
210
  if (e && !r.status) throw r.errors[0];
211
211
  return r;
212
212
  }
213
- var E = class A {
213
+ var g = class O {
214
214
  _scope;
215
215
  _type = "_default";
216
216
  _storage = {};
@@ -220,7 +220,7 @@ var E = class A {
220
220
  }
221
221
  initialize() {
222
222
  try {
223
- !this._crush && typeof window[this.scope] < "u" && (u(A, { 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);
223
+ !this._crush && typeof window[this.scope] < "u" && (h(O, { 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 E = class A {
270
270
  dispose() {
271
271
  delete this._storage, delete this;
272
272
  }
273
- }, Z = class {
273
+ }, $ = class {
274
274
  _dom = {};
275
275
  _rootDOMElement = "";
276
276
  _protectedDOMElements = [];
@@ -315,7 +315,7 @@ var E = class A {
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
- h(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(), l(this.initializeClass, this.rootDOMElement), this._initialized = !0, this._dispatchEvent("postinitialize", this.rootDOMElement);
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,19 +360,19 @@ var E = class A {
360
360
  return this._classes.initialize;
361
361
  }
362
362
  set initializeClass(t) {
363
- c({ initializeClass: t }), this._classes.initialize !== t && (this._classes.initialize = t);
363
+ f({ initializeClass: t }), this._classes.initialize !== t && (this._classes.initialize = t);
364
364
  }
365
365
  get focusState() {
366
366
  return this._focusState;
367
367
  }
368
368
  set focusState(t) {
369
- H({ focusState: t }), this._focusState !== t && (this._focusState = t);
369
+ R({ focusState: t }), this._focusState !== t && (this._focusState = t);
370
370
  }
371
371
  get currentEvent() {
372
372
  return this._currentEvent;
373
373
  }
374
374
  set currentEvent(t) {
375
- R({ currentEvent: t }), this._currentEvent !== t && (this._currentEvent = t);
375
+ U({ currentEvent: t }), this._currentEvent !== t && (this._currentEvent = t);
376
376
  }
377
377
  get shouldFocus() {
378
378
  let t = !1;
@@ -413,25 +413,25 @@ var E = class A {
413
413
  }
414
414
  _validate() {
415
415
  this._dispatchEvent("prevalidate", this.rootDOMElement);
416
- const t = J(this, { shouldThrow: !1 });
416
+ const t = Z(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, g) => {
420
- s[`${o}Element[${g}]`] = n;
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 = u(HTMLElement, s, { shouldThrow: !1 });
422
+ const i = h(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 = T(s, { shouldThrow: !1 });
428
+ const i = k(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 = c(s, { shouldThrow: !1 });
434
+ const i = f(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 E = class A {
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
- u(HTMLElement, { context: e });
471
+ h(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 E = class A {
488
488
  _handleKeydown() {}
489
489
  _handleKeyup() {}
490
490
  _store() {
491
- this._shouldStore && (u(E, { storage: window.GrauplStorage }, { shouldThrow: !1 }).status || new E({ scope: "GrauplStorage" }), window.GrauplStorage.set({
491
+ this._shouldStore && (h(g, { storage: window.GrauplStorage }, { shouldThrow: !1 }).status || new g({ 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 && u(E, { storage: window.GrauplStorage }, { shouldThrow: !1 }).status && window.GrauplStorage.clear({
498
+ this._shouldStore && h(g, { 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 E = class A {
530
530
  });
531
531
  }
532
532
  _dispatchEvent(t, e) {
533
- U(t, this), u(HTMLElement, { element: e }), e.dispatchEvent(this.events[t]);
533
+ B(t, this), h(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 E = class A {
561
561
  dispose() {
562
562
  this._clearIntervals(), this._clearTimeouts(), this._removeEventListeners(), this._unstore(), delete this;
563
563
  }
564
- }, B = class extends Z {
564
+ }, E = class extends $ {
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
+ }, W = class extends $ {
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
- 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: g = ".autoplay", nextSelector: D = ".next", previousSelector: O = ".previous", activeClass: M = "active", previousClass: x = "previous", nextClass: S = "next", playClass: L = "play", pauseClass: j = "pause", autoplay: z = !0, transitionDelay: Q = 1e4, transitionDuration: V = 500, playText: P = "Play", pauseText: K = "Pause", prefix: F = "graupl-", key: q = null, initializeClass: G = "initializing", initialize: N = !1 }) {
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: x = ".next", previousSelector: D = ".previous", activeClass: S = "active", playClass: L = "play", pauseClass: z = "pause", autoplay: P = !0, transitionDelay: j = 1e4, playText: Q = "Play", pauseText: V = "Pause", itemsPerPage: K = 1, loop: F = !0, prefix: N = "graupl-", key: q = null, initializeClass: G = "initializing", initialize: H = !1 }) {
574
607
  super({
575
- prefix: F,
608
+ prefix: N,
576
609
  key: q,
577
610
  initializeClass: G
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 = g, this._selectors.next = D, this._selectors.previous = O, this._classes.active = M || "", this._classes.previous = x || "", this._classes.next = S || "", this._classes.play = L || "", this._classes.pause = j || "", this._autoplay = z, this._delays.transition = Q, this._durations.transition = V, this._playText = P || "", this._pauseText = K || "", this._addEventListener("grauplComponentInitialize", this.rootDOMElement, () => {
579
- this._handleAutoplay(), this.dom.carouselItems.forEach((m) => {
580
- m.setAttribute("inert", "true");
581
- }), this.activateFirstItem();
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 = x, this._selectors.previous = D, this._elements.carouselItems = [], this._classes.active = S || "", this._classes.play = L || "", this._classes.pause = z || "", this._autoplay = P, this._itemsPerPage = K, this._loop = F, this._delays.transition = j, this._playText = Q || "", this._pauseText = V || "", 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 m = a("boolean", { autoplay: this._autoplay }, { shouldThrow: !1 });
584
- m.status || (this._errors = [...this._errors, ...m.errors], this._valid = !1);
614
+ const I = a("boolean", {
615
+ autoplay: this._autoplay,
616
+ loop: this._loop
617
+ }, { shouldThrow: !1 });
618
+ I.status || (this._errors = [...this._errors, ...I.errors], this._valid = !1);
585
619
  const C = a("string", {
586
620
  playText: this._playText,
587
621
  pauseText: this._pauseText
588
622
  }, { shouldThrow: !1 });
589
623
  C.status || (this._errors = [...this._errors, ...C.errors], this._valid = !1);
590
- }), N && this.initialize();
624
+ const T = a("number", { itemsPerPage: this._itemsPerPage }, { shouldThrow: !1 });
625
+ T.status || (this._errors = [...this._errors, ...T.errors], this._valid = !1);
626
+ }), H && this.initialize();
591
627
  }
592
628
  get activeClass() {
593
629
  return this._classes.active;
594
630
  }
595
631
  set activeClass(t) {
596
- c({ activeClass: t }), this._classes.active !== t && (this._classes.active = t);
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
+ f({ 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
- c({ playClass: t }), this._classes.play !== t && (this._classes.play = t);
638
+ f({ 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
- c({ pauseClass: t }), this._classes.pause !== t && (this._classes.pause = t);
644
+ f({ 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, this._dom.carousel.querySelectorAll(this.selectors.carouselTab) && this.dom.carouselItems.forEach((e, r) => {
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.dom.carouselItems[this.currentItem];
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 E = class A {
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 E = class A {
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 E({
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 E = class A {
677
706
  }), this._id = this.dom.carousel.id;
678
707
  }
679
708
  _setAriaAttributes() {
680
- !I("section", { carousel: this.dom.carousel }, { shouldThrow: !1 }).status && !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, e) => {
681
- I("button", { tab: t }, { shouldThrow: !1 }).status || t.setAttribute("role", "button"), t.setAttribute("aria-selected", e === 0), t.setAttribute("aria-controls", this.dom.carouselItems[e].id);
709
+ !J("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 ? (h(this.pauseClass, this.dom.autoplay), l(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)) : (h(this.playClass, this.dom.autoplay), l(this.pauseClass, this.dom.autoplay), this.dom.autoplay.setAttribute("aria-label", this.playText), this.dom.carousel.setAttribute("aria-live", "polite"), this._clearInterval());
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 E = class A {
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.dom.carouselTabs.forEach((t, e) => {
705
- this._addEventListener("click", t, () => {
706
- this.currentItem > e ? this._currentAction = "previous" : this._currentAction = "next", this.activateItem(e);
748
+ this._addEventListener("click", this.dom.next, (t) => {
749
+ t.button === 0 && (l(t), this.currentEvent = "mouse", this.activateNextItem());
750
+ }), this._addEventListener("click", this.dom.previous, (t) => {
751
+ t.button === 0 && (l(t), this.currentEvent = "mouse", this.activatePreviousItem());
752
+ }), this._addEventListener("click", this.dom.autoplay, (t) => {
753
+ t.button === 0 && (l(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 && (l(e), this.currentEvent = "mouse", this.activateItem(this.dom.carouselItems.indexOf(t.dom.carouselItem)));
707
757
  });
708
758
  });
709
759
  }
@@ -717,19 +767,19 @@ var E = class A {
717
767
  _handleKeydown() {
718
768
  this.dom.carouselControls.forEach((t) => {
719
769
  this._addEventListener("keydown", t, (e) => {
720
- switch (d(e)) {
770
+ switch (u(e)) {
721
771
  case "Space":
722
772
  case "Enter":
723
- _(e);
773
+ l(e);
724
774
  break;
725
775
  }
726
776
  });
727
- }), this.dom.carouselTabs.forEach((t) => {
728
- this._addEventListener("keydown", t, (e) => {
729
- switch (d(e)) {
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
- _(e);
782
+ l(e);
733
783
  break;
734
784
  }
735
785
  });
@@ -737,83 +787,154 @@ var E = class A {
737
787
  }
738
788
  _handleKeyup() {
739
789
  this._addEventListener("keyup", this.dom.next, (t) => {
740
- switch (d(t)) {
790
+ switch (u(t)) {
741
791
  case "Space":
742
792
  case "Enter":
743
- this.activateNextItem(), _(t);
793
+ this.activateNextItem(), l(t);
744
794
  break;
745
795
  }
746
796
  }), this._addEventListener("keyup", this.dom.previous, (t) => {
747
- switch (d(t)) {
797
+ switch (u(t)) {
748
798
  case "Space":
749
799
  case "Enter":
750
- this.activatePreviousItem(), _(t);
800
+ this.activatePreviousItem(), l(t);
751
801
  break;
752
802
  }
753
803
  }), this._addEventListener("keyup", this.dom.autoplay, (t) => {
754
- switch (d(t)) {
804
+ switch (u(t)) {
755
805
  case "Space":
756
806
  case "Enter":
757
- this.toggleAutoplay(), _(t);
807
+ this.toggleAutoplay(), l(t);
758
808
  break;
759
809
  }
760
- }), this.dom.carouselTabs.forEach((t, e) => {
761
- this._addEventListener("keyup", t, (r) => {
762
- switch (d(r)) {
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(e), _(r);
815
+ this.activateItem(this.dom.carouselItems.indexOf(t.dom.carouselItem)), l(e);
766
816
  break;
767
817
  }
768
818
  });
769
819
  });
770
820
  }
771
- activateCurrentItem() {
772
- h(this.activeClass, this.currentCarouselItem), this.currentCarouselItem.removeAttribute("inert"), this.currentCarouselTab && (this.currentCarouselTab.setAttribute("aria-selected", !0), h(this.activeClass, this.currentCarouselTab));
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 E({
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 E({
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
+ });
773
850
  }
774
- deactivateCurrentItem() {
775
- l(this.activeClass, this.currentCarouselItem), this.currentCarouselItem.setAttribute("inert", !0), this.currentCarouselTab && (this.currentCarouselTab.setAttribute("aria-selected", !1), l(this.activeClass, this.currentCarouselTab));
851
+ activateCurrentItem({ scroll: t = !0, scrollOptions: e = {} } = {}) {
852
+ this.currentCarouselItem.activate({
853
+ scroll: t,
854
+ scrollOptions: e
855
+ });
776
856
  }
777
- activateItem(t) {
778
- const e = this.currentItem;
779
- this.dom.carousel.dataset.grauplAction = this._currentAction, this.autoplay && this._clearInterval(), h(this.previousClass, this.currentCarouselItem), h(this.nextClass, this.dom.carouselItems[t]), requestAnimationFrame(() => {
780
- this.deactivateCurrentItem(), this.currentItem = t, this.activateCurrentItem(), requestAnimationFrame(() => {
781
- setTimeout(() => {
782
- l(this.previousClass, this.dom.carouselItems[e]), l(this.nextClass, this.currentCarouselItem);
783
- }, this.transitionDuration);
784
- });
857
+ deactivateCurrentItem({ scroll: t = !0, scrollOptions: e = {} } = {}) {
858
+ this.currentCarouselItem.deactivate({
859
+ scroll: t,
860
+ scrollOptions: e
861
+ });
862
+ }
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.activateItem(0);
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.activateItem(this.dom.carouselItems.length - 1);
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._currentAction = "next", this.currentItem + 1 >= this.dom.carouselItems.length ? this.activateFirstItem() : this.activateItem(this.currentItem + 1);
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._currentAction = "previous", this.currentItem - 1 < 0 ? this.activateLastItem() : this.activateItem(this.currentItem - 1);
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
- const k = /[\11\12\14\15\40]+/, w = "data-once", W = document;
804
- function v(t, e, r) {
805
- return t[`${e}Attribute`](w, r);
924
+ const A = /[\11\12\14\15\40]+/, v = "data-once", X = document;
925
+ function w(t, e, r) {
926
+ return t[`${e}Attribute`](v, r);
806
927
  }
807
- function f(t) {
928
+ function _(t) {
808
929
  if (typeof t != "string") throw new TypeError("once ID must be a string");
809
- if (t === "" || k.test(t)) throw new RangeError("once ID must not be empty or contain spaces");
810
- return `[${w}~="${t}"]`;
930
+ if (t === "" || A.test(t)) throw new RangeError("once ID must not be empty or contain spaces");
931
+ return `[${v}~="${t}"]`;
811
932
  }
812
- function X(t) {
933
+ function Y(t) {
813
934
  if (!(t instanceof Element)) throw new TypeError("The element must be an instance of Element");
814
935
  return !0;
815
936
  }
816
- function p(t, e = W) {
937
+ function p(t, e = X) {
817
938
  let r = t;
818
939
  if (t === null) r = [];
819
940
  else if (t) if (e instanceof Document || e instanceof DocumentFragment || e instanceof Element) typeof t == "string" ? r = e.querySelectorAll(t) : t instanceof Element && (r = [t]);
@@ -823,26 +944,26 @@ function p(t, e = W) {
823
944
  }
824
945
  function b(t, e, r) {
825
946
  return e.filter((s) => {
826
- const i = X(s) && s.matches(t);
947
+ const i = Y(s) && s.matches(t);
827
948
  return i && r && r(s), i;
828
949
  });
829
950
  }
830
- function $(t, { add: e, remove: r }) {
951
+ function M(t, { add: e, remove: r }) {
831
952
  const s = [];
832
- v(t, "has") && v(t, "get").trim().split(k).forEach((o) => {
953
+ w(t, "has") && w(t, "get").trim().split(A).forEach((o) => {
833
954
  s.indexOf(o) < 0 && o !== r && s.push(o);
834
955
  }), e && s.push(e);
835
956
  const i = s.join(" ");
836
- v(t, i === "" ? "remove" : "set", i);
957
+ w(t, i === "" ? "remove" : "set", i);
837
958
  }
838
959
  function y(t, e, r) {
839
- return b(`:not(${f(t)})`, p(e, r), (s) => $(s, { add: t }));
960
+ return b(`:not(${_(t)})`, p(e, r), (s) => M(s, { add: t }));
840
961
  }
841
- y.remove = (t, e, r) => b(f(t), p(e, r), (s) => $(s, { remove: t })), y.filter = (t, e, r) => b(f(t), p(e, r)), y.find = (t, e) => p(t ? f(t) : `[${w}]`, e);
842
- const Y = (t = {}, e = document, r = ".carousel") => {
962
+ y.remove = (t, e, r) => b(_(t), p(e, r), (s) => M(s, { remove: t })), y.filter = (t, e, r) => b(_(t), p(e, r)), y.find = (t, e) => p(t ? _(t) : `[${v}]`, e);
963
+ const tt = (t = {}, e = document, r = ".carousel") => {
843
964
  y("graupl-carousel-generator", r, e).forEach((s) => {
844
965
  const i = s.dataset.grauplCarouselOptions ? JSON.parse(s.dataset.grauplCarouselOptions.replace(/'/g, "\"")) || {} : {};
845
- new B({
966
+ new W({
846
967
  carouselElement: s,
847
968
  initialize: !0,
848
969
  ...t,
@@ -850,6 +971,6 @@ const Y = (t = {}, e = document, r = ".carousel") => {
850
971
  });
851
972
  });
852
973
  };
853
- export { Y as default };
974
+ export { tt as default };
854
975
 
855
976
  //# sourceMappingURL=carousel.es.js.map