@asante-org/atlascopco-vt-litesitegenerator 3.8.15 → 3.8.16

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/index.esm.js CHANGED
@@ -2493,6 +2493,16 @@ var SLIDE_NEXT = "lsg-carousel__slide--next";
2493
2493
  var MEDIA_ITEM_SELECTOR = "[data-lsg-carousel-item]";
2494
2494
  /** Text track slides, one per media slide. */
2495
2495
  var CONTENT_ITEM_SELECTOR = "[data-lsg-carousel-content-item]";
2496
+ /**
2497
+ * A text slide's "head" is its leading run of titles: the pre-title and heading
2498
+ * in Storybook, or the leading LSG Title components in AEM (the same
2499
+ * positional mapping LsgCarousel.scss uses).
2500
+ */
2501
+ var HEAD_SELECTOR = ".lsg-carousel__pre-title, .lsg-carousel__heading, .cmp-lsg-title";
2502
+ /** Marks the last element of each slide's head. */
2503
+ var HEAD_END_ATTR = "data-lsg-carousel-head-end";
2504
+ /** Set on the root once the head/media measurements below are in place. */
2505
+ var MEASURED_ATTR = "data-lsg-carousel-measured";
2496
2506
  var directChildren = function (container, selector) {
2497
2507
  return container ? Array.from(container.children).filter(function (el) {
2498
2508
  return el instanceof HTMLElement && el.matches(selector);
@@ -2512,6 +2522,7 @@ var LsgCarouselController = /** @class */function () {
2512
2522
  this.media = null;
2513
2523
  this.content = null;
2514
2524
  this.syncing = false;
2525
+ this.headObserver = null;
2515
2526
  /**
2516
2527
  * Embla automatically falls back to non-looping mode when there is not enough
2517
2528
  * slide content to create a safe loop (most noticeable with two-up layouts and
@@ -2603,6 +2614,34 @@ var LsgCarouselController = /** @class */function () {
2603
2614
  if (active) slide.removeAttribute("aria-hidden");else slide.setAttribute("aria-hidden", "true");
2604
2615
  });
2605
2616
  };
2617
+ /**
2618
+ * Publishes the geometry a theme needs to place the media column between each
2619
+ * slide's head (pre-title + heading) and its body:
2620
+ *
2621
+ * root --lsg-carousel-head-max tallest head across all slides
2622
+ * --lsg-carousel-media-block media column height (cards + dots)
2623
+ * slide --lsg-carousel-head-height this slide's own head height
2624
+ *
2625
+ * Every slide pads its head up to the tallest one, so the media never moves
2626
+ * as the text crossfades between headings of different lengths. Themes that
2627
+ * do not opt in ignore these. MEASURED_ATTR is only set when at least one
2628
+ * slide has a head, so a carousel without titles keeps the plain stack.
2629
+ */
2630
+ this.measureSplit = function () {
2631
+ if (!_this.root || !_this.mediaColumn) return;
2632
+ var max = 0;
2633
+ _this.contentSlides.forEach(function (slide, index) {
2634
+ var end = _this.headEnds[index];
2635
+ // Rect deltas, not offsetTop: the slide is not an offset parent. The fade
2636
+ // plugin only translates on X, so the vertical delta is unaffected.
2637
+ var height = end ? Math.ceil(end.getBoundingClientRect().bottom - slide.getBoundingClientRect().top) : 0;
2638
+ slide.style.setProperty("--lsg-carousel-head-height", "".concat(height, "px"));
2639
+ max = Math.max(max, height);
2640
+ });
2641
+ _this.root.style.setProperty("--lsg-carousel-head-max", "".concat(max, "px"));
2642
+ _this.root.style.setProperty("--lsg-carousel-media-block", "".concat(Math.ceil(_this.mediaColumn.getBoundingClientRect().height), "px"));
2643
+ _this.root.toggleAttribute(MEASURED_ATTR, max > 0);
2644
+ };
2606
2645
  this.els = elements;
2607
2646
  this.mediaViewport = viewport;
2608
2647
  this.paginationBtns = elements.paginationBtns ? Array.from(elements.paginationBtns) : [];
@@ -2673,6 +2712,35 @@ var LsgCarouselController = /** @class */function () {
2673
2712
  slides: this.contentSlides
2674
2713
  }, [Fade()]);
2675
2714
  }
2715
+ // Head/media measurements for themes that split the text around the media
2716
+ // on mobile (theme 3). Only paired tracks qualify: the split lays one track
2717
+ // inside the other, which only makes sense when they show the same item.
2718
+ this.root = viewport.closest(".lsg-carousel");
2719
+ this.mediaColumn = viewport.closest(".lsg-carousel__media-column");
2720
+ var heads = [];
2721
+ this.headEnds = this.contentSlides.map(function (slide) {
2722
+ var end = null;
2723
+ for (var _i = 0, _a = Array.from(slide.children); _i < _a.length; _i++) {
2724
+ var child = _a[_i];
2725
+ if (!(child instanceof HTMLElement) || !child.matches(HEAD_SELECTOR)) break;
2726
+ heads.push(child);
2727
+ end = child;
2728
+ }
2729
+ end === null || end === void 0 ? void 0 : end.setAttribute(HEAD_END_ATTR, "");
2730
+ return end;
2731
+ });
2732
+ if (this.content && this.root && this.mediaColumn && typeof ResizeObserver !== "undefined") {
2733
+ // Heads re-wrap with the viewport width and again when web fonts land; the
2734
+ // media column follows the breakpoint's card height. Neither box's size
2735
+ // depends on the variables written below, so this cannot feed back.
2736
+ this.headObserver = new ResizeObserver(this.measureSplit);
2737
+ this.headObserver.observe(this.mediaColumn);
2738
+ heads.forEach(function (head) {
2739
+ var _a;
2740
+ return (_a = _this.headObserver) === null || _a === void 0 ? void 0 : _a.observe(head);
2741
+ });
2742
+ this.measureSplit();
2743
+ }
2676
2744
  this.paginationHandlers = this.paginationBtns.map(function (_, index) {
2677
2745
  return function () {
2678
2746
  var _a;
@@ -2744,7 +2812,7 @@ var LsgCarouselController = /** @class */function () {
2744
2812
  });
2745
2813
  LsgCarouselController.prototype.destroy = function () {
2746
2814
  var _this = this;
2747
- var _a, _b, _c, _d;
2815
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2748
2816
  (_a = this.els.prevBtn) === null || _a === void 0 ? void 0 : _a.removeEventListener("click", this.scrollPrev);
2749
2817
  (_b = this.els.nextBtn) === null || _b === void 0 ? void 0 : _b.removeEventListener("click", this.scrollNext);
2750
2818
  this.paginationBtns.forEach(function (button, index) {
@@ -2783,7 +2851,16 @@ var LsgCarouselController = /** @class */function () {
2783
2851
  this.contentSlides.forEach(function (slide) {
2784
2852
  slide.removeAttribute("inert");
2785
2853
  slide.removeAttribute("aria-hidden");
2854
+ slide.style.removeProperty("--lsg-carousel-head-height");
2855
+ });
2856
+ (_e = this.headObserver) === null || _e === void 0 ? void 0 : _e.disconnect();
2857
+ this.headObserver = null;
2858
+ this.headEnds.forEach(function (end) {
2859
+ return end === null || end === void 0 ? void 0 : end.removeAttribute(HEAD_END_ATTR);
2786
2860
  });
2861
+ (_f = this.root) === null || _f === void 0 ? void 0 : _f.style.removeProperty("--lsg-carousel-head-max");
2862
+ (_g = this.root) === null || _g === void 0 ? void 0 : _g.style.removeProperty("--lsg-carousel-media-block");
2863
+ (_h = this.root) === null || _h === void 0 ? void 0 : _h.removeAttribute(MEASURED_ATTR);
2787
2864
  };
2788
2865
  return LsgCarouselController;
2789
2866
  }();