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