@cntrl-site/components 0.1.0-alpha.2 → 0.1.0-alpha.20

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.mjs CHANGED
@@ -563,15 +563,28 @@ const ControlSliderComponent = {
563
563
  },
564
564
  offset: {
565
565
  type: "object",
566
+ title: "Offset",
566
567
  display: {
567
- type: "offset-controls"
568
+ type: "group"
568
569
  },
569
570
  properties: {
570
571
  x: {
571
- type: "number"
572
+ type: "number",
573
+ label: "X",
574
+ scalingEnabled: true,
575
+ display: {
576
+ type: "numeric-input",
577
+ visible: true
578
+ }
572
579
  },
573
580
  y: {
574
- type: "number"
581
+ type: "number",
582
+ label: "Y",
583
+ scalingEnabled: true,
584
+ display: {
585
+ type: "numeric-input",
586
+ visible: true
587
+ }
575
588
  }
576
589
  }
577
590
  },
@@ -624,15 +637,28 @@ const ControlSliderComponent = {
624
637
  },
625
638
  offset: {
626
639
  type: "object",
640
+ title: "Offset",
627
641
  display: {
628
- type: "offset-controls"
642
+ type: "group"
629
643
  },
630
644
  properties: {
631
645
  x: {
632
- type: "number"
646
+ type: "number",
647
+ label: "X",
648
+ scalingEnabled: true,
649
+ display: {
650
+ type: "numeric-input",
651
+ visible: true
652
+ }
633
653
  },
634
654
  y: {
635
- type: "number"
655
+ type: "number",
656
+ label: "Y",
657
+ scalingEnabled: true,
658
+ display: {
659
+ type: "numeric-input",
660
+ visible: true
661
+ }
636
662
  }
637
663
  }
638
664
  },
@@ -688,14 +714,26 @@ const ControlSliderComponent = {
688
714
  offset: {
689
715
  type: "object",
690
716
  display: {
691
- type: "offset-controls"
717
+ type: "group"
692
718
  },
693
719
  properties: {
694
720
  x: {
695
- type: "number"
721
+ type: "number",
722
+ label: "X",
723
+ scalingEnabled: true,
724
+ display: {
725
+ type: "numeric-input",
726
+ visible: true
727
+ }
696
728
  },
697
729
  y: {
698
- type: "number"
730
+ type: "number",
731
+ label: "Y",
732
+ scalingEnabled: true,
733
+ display: {
734
+ type: "numeric-input",
735
+ visible: true
736
+ }
699
737
  }
700
738
  }
701
739
  },
@@ -1441,7 +1479,9 @@ const ControlImageRevealSliderComponent = {
1441
1479
  }
1442
1480
  }
1443
1481
  };
1482
+ const background = "Lightbox-module__background___wf1Ii";
1444
1483
  const backdropStyle = "Lightbox-module__backdropStyle___y7avj";
1484
+ const editor = "Lightbox-module__editor___Vh82D";
1445
1485
  const contentStyle = "Lightbox-module__contentStyle___FzFaW";
1446
1486
  const imageStyle = "Lightbox-module__imageStyle___Qb7f5";
1447
1487
  const imgWrapper = "Lightbox-module__imgWrapper___cdytV";
@@ -1461,7 +1501,6 @@ const thumbsAlignStart = "Lightbox-module__thumbsAlignStart___uiFIV";
1461
1501
  const thumbsAlignCenter = "Lightbox-module__thumbsAlignCenter___sbUPA";
1462
1502
  const thumbsAlignEnd = "Lightbox-module__thumbsAlignEnd___OA9N4";
1463
1503
  const thumbItem = "Lightbox-module__thumbItem___zROyu";
1464
- const thumbImage = "Lightbox-module__thumbImage___xGakV";
1465
1504
  const closeButton = "Lightbox-module__closeButton___r3Dur";
1466
1505
  const fadeIn = "Lightbox-module__fadeIn___sHwRK";
1467
1506
  const slideInLeft = "Lightbox-module__slideInLeft___P-XRo";
@@ -1470,7 +1509,9 @@ const slideInTop = "Lightbox-module__slideInTop___XRKCs";
1470
1509
  const slideInBottom = "Lightbox-module__slideInBottom___TYOBS";
1471
1510
  const scaleSlide = "Lightbox-module__scaleSlide___wS7d4";
1472
1511
  const styles = {
1512
+ background,
1473
1513
  backdropStyle,
1514
+ editor,
1474
1515
  contentStyle,
1475
1516
  imageStyle,
1476
1517
  imgWrapper,
@@ -1490,7 +1531,6 @@ const styles = {
1490
1531
  thumbsAlignCenter,
1491
1532
  thumbsAlignEnd,
1492
1533
  thumbItem,
1493
- thumbImage,
1494
1534
  closeButton,
1495
1535
  fadeIn,
1496
1536
  slideInLeft,
@@ -1499,7 +1539,7 @@ const styles = {
1499
1539
  slideInBottom,
1500
1540
  scaleSlide
1501
1541
  };
1502
- const getPositionStyles = (position, offset) => {
1542
+ const getPositionStyles = (position, offset, isEditor) => {
1503
1543
  const styles2 = {};
1504
1544
  const [vertical, horizontal] = position.split("-");
1505
1545
  if (vertical === "top") {
@@ -1523,17 +1563,42 @@ const getPositionStyles = (position, offset) => {
1523
1563
  styles2.right = "0";
1524
1564
  }
1525
1565
  if (vertical === "middle" && horizontal === "center") {
1526
- styles2.transform = `translate(calc(-50% + ${offset.x}px), calc(-50% + ${offset.y}px))`;
1566
+ styles2.transform = `translate(calc(-50% + ${scalingValue(offset.x, isEditor)}), calc(-50% + ${scalingValue(offset.y, isEditor)}))`;
1527
1567
  } else if (vertical === "middle") {
1528
- styles2.transform = `translate(${offset.x}px, calc(-50% + ${offset.y}px))`;
1568
+ styles2.transform = `translate(${scalingValue(offset.x, isEditor)}, calc(-50% + ${scalingValue(offset.y, isEditor)}))`;
1529
1569
  } else if (horizontal === "center") {
1530
- styles2.transform = `translate(calc(-50% + ${offset.x}px), ${offset.y}px)`;
1570
+ styles2.transform = `translate(calc(-50% + ${scalingValue(offset.x, isEditor)}), ${scalingValue(offset.y, isEditor)})`;
1531
1571
  } else {
1532
- styles2.transform = `translate(${offset.x}px, ${offset.y}px)`;
1572
+ styles2.transform = `translate(${scalingValue(offset.x, isEditor)}, ${scalingValue(offset.y, isEditor)})`;
1533
1573
  }
1534
1574
  return styles2;
1535
1575
  };
1536
- function LightboxGallery({ settings, content, styles: styles2, portalId, activeEvent, isEditor = true }) {
1576
+ function getDisplayedImageRect(img2) {
1577
+ const container = img2.getBoundingClientRect();
1578
+ const containerW = container.width;
1579
+ const containerH = container.height;
1580
+ const imgW = img2.naturalWidth;
1581
+ const imgH = img2.naturalHeight;
1582
+ const containerRatio = containerW / containerH;
1583
+ const imgRatio = imgW / imgH;
1584
+ let renderedW, renderedH;
1585
+ if (imgRatio > containerRatio) {
1586
+ renderedW = containerW;
1587
+ renderedH = containerW / imgRatio;
1588
+ } else {
1589
+ renderedH = containerH;
1590
+ renderedW = containerH * imgRatio;
1591
+ }
1592
+ const offsetX = (containerW - renderedW) / 2 + container.left;
1593
+ const offsetY = (containerH - renderedH) / 2 + container.top;
1594
+ return {
1595
+ x: offsetX,
1596
+ y: offsetY,
1597
+ width: renderedW,
1598
+ height: renderedH
1599
+ };
1600
+ }
1601
+ function LightboxGallery({ settings, content, styles: styles2, portalId, activeEvent, isEditor }) {
1537
1602
  const [open, setOpen] = React.useState(false);
1538
1603
  const { url } = settings.thumbnailBlock.cover;
1539
1604
  useEffect(() => {
@@ -1554,13 +1619,16 @@ function LightboxGallery({ settings, content, styles: styles2, portalId, activeE
1554
1619
  onClick: () => setOpen(true)
1555
1620
  }
1556
1621
  ),
1557
- /* @__PURE__ */ jsx(Lightbox, { isOpen: open, onClose: () => setOpen(false), content, settings, portalId, isEditor })
1622
+ /* @__PURE__ */ jsx(Lightbox, { isOpen: open, onClose: () => setOpen(false), content, settings, styles: styles2, portalId, isEditor })
1558
1623
  ] });
1559
1624
  }
1560
- const Lightbox = ({ isOpen, onClose, content, settings, closeOnBackdropClick = true, closeOnEsc = true, portalId, isEditor }) => {
1625
+ const Lightbox = ({ isOpen, onClose, content, styles: lightboxStyles, settings, closeOnBackdropClick = true, closeOnEsc = true, portalId, isEditor }) => {
1626
+ const { widthSettings, fontSettings, letterSpacing, textAlign, wordSpacing, fontSizeLineHeight, textAppearance, color } = lightboxStyles.caption;
1561
1627
  const [currentIndex, setCurrentIndex] = React.useState(0);
1628
+ const [splideKey, setSplideKey] = React.useState(0);
1562
1629
  const lightboxRef = useRef(null);
1563
- const resizeObserverRef = useRef(null);
1630
+ const prevSliderTypeRef = useRef(null);
1631
+ const imageRef = useRef(null);
1564
1632
  const { appear, triggers, slider, thumbnail, controls, area, caption: caption2, layout } = settings.lightboxBlock;
1565
1633
  const handleBackdropClick = (e) => {
1566
1634
  if (!closeOnBackdropClick) return;
@@ -1574,6 +1642,23 @@ const Lightbox = ({ isOpen, onClose, content, settings, closeOnBackdropClick = t
1574
1642
  onClose();
1575
1643
  }
1576
1644
  };
1645
+ const handleContentClick = (e) => {
1646
+ if (!closeOnBackdropClick) return;
1647
+ const target = e.target;
1648
+ const currentTarget = e.currentTarget;
1649
+ if (target === currentTarget) {
1650
+ onClose();
1651
+ return;
1652
+ }
1653
+ const isImg = target.tagName === "IMG" || target.closest("img");
1654
+ const isButton = target.tagName === "BUTTON" || target.closest("button");
1655
+ const isSplide = target.closest(".splide") || target.closest('[class*="splide"]');
1656
+ const isCaption = target.closest(`.${styles.caption}`);
1657
+ const isThumbnail = target.closest(`.${styles.thumbsContainer}`);
1658
+ if (!isImg && !isButton && !isSplide && !isCaption && !isThumbnail) {
1659
+ onClose();
1660
+ }
1661
+ };
1577
1662
  const onImageClick = (e) => {
1578
1663
  var _a, _b;
1579
1664
  if (triggers.type === "click" && triggers.switch === "image") {
@@ -1621,48 +1706,24 @@ const Lightbox = ({ isOpen, onClose, content, settings, closeOnBackdropClick = t
1621
1706
  if (isOpen) setCurrentIndex(0);
1622
1707
  }, [isOpen]);
1623
1708
  useEffect(() => {
1624
- if (!isOpen) return;
1625
- if (resizeObserverRef.current) {
1626
- resizeObserverRef.current.disconnect();
1627
- resizeObserverRef.current = null;
1709
+ if (prevSliderTypeRef.current !== null && prevSliderTypeRef.current !== slider.type) {
1710
+ setSplideKey((prev) => prev + 1);
1628
1711
  }
1629
- const timeoutId = setTimeout(() => {
1630
- const activeSlide = document.querySelector(".splide__slide.is-active");
1631
- if (!activeSlide) return;
1632
- const img2 = activeSlide.querySelector("img");
1633
- const container = activeSlide.querySelector(`.${styles.imgWrapper}`);
1634
- if (!img2 || !container) return;
1635
- const updateImageSize = () => {
1636
- if (!img2.naturalWidth || !img2.naturalHeight) return;
1637
- const imageAspectRatio = img2.naturalWidth / img2.naturalHeight;
1638
- const containerWidth = container.clientWidth;
1639
- const containerHeight = container.clientHeight;
1640
- const containerAspectRatio = containerWidth / containerHeight;
1641
- if (imageAspectRatio > containerAspectRatio) {
1642
- img2.style.width = "100%";
1643
- } else {
1644
- img2.style.height = "100%";
1645
- }
1646
- };
1647
- if (img2.complete) {
1648
- updateImageSize();
1649
- } else {
1650
- img2.onload = updateImageSize;
1651
- }
1652
- resizeObserverRef.current = new ResizeObserver(() => {
1653
- updateImageSize();
1654
- });
1655
- resizeObserverRef.current.observe(container);
1656
- resizeObserverRef.current.observe(img2);
1657
- }, 0);
1712
+ prevSliderTypeRef.current = slider.type;
1713
+ }, [slider.type]);
1714
+ useEffect(() => {
1715
+ if (!isOpen) return;
1716
+ const originalOverflow = document.body.style.overflow;
1717
+ document.body.style.overflow = "hidden";
1718
+ document.body.style.backgroundColor = area.color;
1719
+ const preventScroll = (e) => e.preventDefault();
1720
+ document.addEventListener("touchmove", preventScroll, { passive: false });
1658
1721
  return () => {
1659
- clearTimeout(timeoutId);
1660
- if (resizeObserverRef.current) {
1661
- resizeObserverRef.current.disconnect();
1662
- resizeObserverRef.current = null;
1663
- }
1722
+ document.body.style.overflow = originalOverflow;
1723
+ document.removeEventListener("touchmove", preventScroll);
1724
+ document.body.style.backgroundColor = "";
1664
1725
  };
1665
- }, [isOpen, currentIndex, content]);
1726
+ }, [isOpen]);
1666
1727
  const handleArrowClick = (dir) => {
1667
1728
  var _a;
1668
1729
  (_a = lightboxRef.current) == null ? void 0 : _a.go(dir);
@@ -1705,233 +1766,295 @@ const Lightbox = ({ isOpen, onClose, content, settings, closeOnBackdropClick = t
1705
1766
  }
1706
1767
  return styles.fadeIn;
1707
1768
  })();
1769
+ useEffect(() => {
1770
+ if (!isOpen || !closeOnBackdropClick) return;
1771
+ const handleTouchEnd = (e) => {
1772
+ if (e.touches.length === 0 && e.changedTouches.length > 0) {
1773
+ const rect = imageRef.current ? getDisplayedImageRect(imageRef.current) : null;
1774
+ if (!rect) return;
1775
+ const touch = e.changedTouches[0];
1776
+ const inside = touch.clientX >= rect.x && touch.clientX <= rect.x + rect.width && touch.clientY >= rect.y && touch.clientY <= rect.y + rect.height;
1777
+ if (!inside) {
1778
+ onClose();
1779
+ }
1780
+ }
1781
+ };
1782
+ const timeoutId = setTimeout(() => {
1783
+ document.addEventListener("touchend", handleTouchEnd, { passive: true });
1784
+ }, 100);
1785
+ return () => {
1786
+ clearTimeout(timeoutId);
1787
+ document.removeEventListener("touchend", handleTouchEnd);
1788
+ };
1789
+ }, [isOpen, closeOnBackdropClick, onClose, currentIndex]);
1708
1790
  if (!isOpen) return null;
1709
1791
  return createPortal(
1710
- /* @__PURE__ */ jsx(
1711
- "div",
1712
- {
1713
- className: cn(styles.backdropStyle, backdropAppearClass, { [styles.editor]: isEditor }),
1714
- style: { backgroundColor: area.color, backdropFilter: `blur(${area.blur}px)`, animationDuration: `${backdropDurationMs}ms`, animationTimingFunction: "ease", animationFillMode: "both" },
1715
- onClick: handleBackdropClick,
1716
- children: /* @__PURE__ */ jsxs(
1717
- "div",
1718
- {
1719
- className: cn(styles.contentStyle, appearClass),
1720
- style: {
1721
- padding: `${layout.padding.top}px ${layout.padding.right}px ${layout.padding.bottom}px ${layout.padding.left}px`,
1722
- animationDuration: `${appearDurationMs}ms`,
1723
- animationTimingFunction: "ease",
1724
- animationFillMode: "both",
1725
- ...appear.type === "mix" && { animationDelay: `${backdropDurationMs}ms` },
1726
- "--splide-speed": triggers.duration || "500ms"
1727
- },
1728
- children: [
1729
- /* @__PURE__ */ jsx(
1730
- Splide,
1731
- {
1732
- onMove: (splide) => {
1733
- setCurrentIndex(splide.index);
1734
- },
1735
- ref: lightboxRef,
1736
- className: styles.lightboxSplide,
1737
- options: {
1738
- arrows: false,
1739
- speed: triggers.duration ? parseInt(triggers.duration) : 500,
1740
- direction: slider.direction === "horiz" || slider.type === "fade" || slider.type === "scale" ? "ltr" : "ttb",
1741
- pagination: false,
1742
- drag: triggers.type === "drag",
1743
- perPage: 1,
1744
- width: "100%",
1745
- height: "100%",
1746
- type: slider.type === "fade" || slider.type === "scale" ? "fade" : "loop",
1747
- padding: 0,
1748
- rewind: (slider.type === "scale" || slider.type === "fade") && appear.repeat !== "close"
1749
- },
1750
- style: { "--splide-speed": triggers.duration || "500ms" },
1751
- children: content.map((item, index) => {
1752
- const positionStyles = getPositionStyles(layout.position, layout.offset);
1753
- const imageStyle2 = slider.type === "scale" ? (() => {
1754
- const { transform, ...restStyles } = positionStyles;
1755
- return {
1756
- ...restStyles,
1757
- "--position-transform": transform || "none"
1758
- };
1759
- })() : positionStyles;
1760
- return /* @__PURE__ */ jsx(SplideSlide, { children: /* @__PURE__ */ jsx(
1761
- "div",
1762
- {
1763
- className: styles.imgWrapper,
1764
- onClick: handleImageWrapperClick,
1765
- style: {
1766
- padding: `${layout.padding.top}px ${layout.padding.right}px ${layout.padding.bottom}px ${layout.padding.left}px`
1767
- },
1768
- children: /* @__PURE__ */ jsx(
1769
- "img",
1770
- {
1771
- className: cn(styles.imageStyle, {
1772
- [styles.contain]: item.image.objectFit === "contain",
1773
- [styles.cover]: item.image.objectFit === "cover",
1774
- [styles.scaleSlide]: slider.type === "scale"
1775
- }),
1776
- src: item.image.url,
1777
- alt: item.image.name ?? "",
1778
- onClick: onImageClick,
1779
- style: imageStyle2
1780
- }
1781
- )
1782
- }
1783
- ) }, index);
1784
- })
1785
- }
1786
- ),
1787
- controls.isActive && /* @__PURE__ */ jsxs(Fragment, { children: [
1792
+ /* @__PURE__ */ jsxs(Fragment, { children: [
1793
+ /* @__PURE__ */ jsx(
1794
+ "div",
1795
+ {
1796
+ className: cn(styles.background, backdropAppearClass),
1797
+ style: {
1798
+ ...isEditor && { display: "none" },
1799
+ backgroundColor: area.color,
1800
+ backdropFilter: `blur(${area.blur}px)`,
1801
+ animationDuration: `${backdropDurationMs}ms`,
1802
+ animationTimingFunction: "ease",
1803
+ animationFillMode: "both"
1804
+ }
1805
+ }
1806
+ ),
1807
+ /* @__PURE__ */ jsx(
1808
+ "div",
1809
+ {
1810
+ className: cn(styles.backdropStyle, { [styles.editor]: isEditor }),
1811
+ style: { ...isEditor && { backgroundColor: area.color, backdropFilter: `blur(${area.blur}px)` } },
1812
+ onClick: handleBackdropClick,
1813
+ onTouchEnd: handleBackdropClick,
1814
+ onTouchStart: handleBackdropClick,
1815
+ children: /* @__PURE__ */ jsxs(
1816
+ "div",
1817
+ {
1818
+ className: cn(styles.contentStyle, appearClass),
1819
+ onClick: handleContentClick,
1820
+ style: {
1821
+ animationDuration: `${appearDurationMs}ms`,
1822
+ animationTimingFunction: "ease",
1823
+ animationFillMode: "both",
1824
+ ...appear.type === "mix" && { animationDelay: `${backdropDurationMs / 2}ms` },
1825
+ "--splide-speed": slider.duration || "500ms"
1826
+ },
1827
+ children: [
1788
1828
  /* @__PURE__ */ jsx(
1829
+ Splide,
1830
+ {
1831
+ onMove: (splide) => {
1832
+ setCurrentIndex(splide.index);
1833
+ },
1834
+ ref: lightboxRef,
1835
+ className: styles.lightboxSplide,
1836
+ options: {
1837
+ arrows: false,
1838
+ speed: slider.duration ? parseInt(slider.duration) : 500,
1839
+ direction: slider.direction === "horiz" || slider.type === "fade" || slider.type === "scale" ? "ltr" : "ttb",
1840
+ pagination: false,
1841
+ drag: triggers.type === "drag",
1842
+ perPage: 1,
1843
+ width: "100%",
1844
+ height: "100%",
1845
+ type: slider.type === "fade" || slider.type === "scale" ? "fade" : "loop",
1846
+ padding: 0,
1847
+ rewind: (slider.type === "scale" || slider.type === "fade") && appear.repeat !== "close"
1848
+ },
1849
+ style: { "--splide-speed": slider.duration || "500ms" },
1850
+ children: content.map((item, index) => {
1851
+ const positionStyles = getPositionStyles(layout.position, layout.offset, isEditor);
1852
+ const imageStyle2 = slider.type === "scale" ? (() => {
1853
+ const { transform, ...restStyles } = positionStyles;
1854
+ return {
1855
+ ...restStyles,
1856
+ "--position-transform": transform || "none"
1857
+ };
1858
+ })() : positionStyles;
1859
+ return /* @__PURE__ */ jsx(SplideSlide, { children: /* @__PURE__ */ jsx(
1860
+ "div",
1861
+ {
1862
+ className: styles.imgWrapper,
1863
+ onClick: handleImageWrapperClick,
1864
+ style: { padding: scalingValue(layout.padding.top, isEditor) + " " + scalingValue(layout.padding.right, isEditor) + " " + scalingValue(layout.padding.bottom, isEditor) + " " + scalingValue(layout.padding.left, isEditor) },
1865
+ children: /* @__PURE__ */ jsx(
1866
+ "img",
1867
+ {
1868
+ ref: imageRef,
1869
+ className: cn(styles.imageStyle, {
1870
+ [styles.contain]: item.image.objectFit === "contain",
1871
+ [styles.cover]: item.image.objectFit === "cover",
1872
+ [styles.scaleSlide]: slider.type === "scale"
1873
+ }),
1874
+ src: item.image.url,
1875
+ alt: item.image.name ?? "",
1876
+ onClick: onImageClick,
1877
+ style: imageStyle2
1878
+ }
1879
+ )
1880
+ }
1881
+ ) }, index);
1882
+ })
1883
+ },
1884
+ splideKey
1885
+ ),
1886
+ controls.isActive && controls.arrowsImgUrl && /* @__PURE__ */ jsxs(Fragment, { children: [
1887
+ /* @__PURE__ */ jsx(
1888
+ "div",
1889
+ {
1890
+ className: cn(styles.arrow, { [styles.arrowVertical]: slider.direction === "vert" }),
1891
+ style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
1892
+ children: /* @__PURE__ */ jsx(
1893
+ "button",
1894
+ {
1895
+ className: styles.arrowInner,
1896
+ style: {
1897
+ transform: `translate(${scalingValue(controls.offset.x, isEditor)}, ${scalingValue(controls.offset.y * (slider.direction === "horiz" ? 1 : -1), isEditor)}) scale(${controls.scale}) rotate(${slider.direction === "horiz" ? "0deg" : "90deg"})`
1898
+ },
1899
+ onClick: (e) => {
1900
+ handleArrowClick("-1");
1901
+ },
1902
+ children: controls.arrowsImgUrl && /* @__PURE__ */ jsx(
1903
+ SvgImage,
1904
+ {
1905
+ url: controls.arrowsImgUrl,
1906
+ fill: controls.color,
1907
+ hoverFill: controls.hover,
1908
+ className: cn(styles.arrowImg, styles.mirror)
1909
+ }
1910
+ )
1911
+ }
1912
+ )
1913
+ }
1914
+ ),
1915
+ /* @__PURE__ */ jsx(
1916
+ "div",
1917
+ {
1918
+ className: cn(styles.arrow, styles.nextArrow, { [styles.arrowVertical]: slider.direction === "vert" }),
1919
+ style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
1920
+ children: /* @__PURE__ */ jsx(
1921
+ "button",
1922
+ {
1923
+ className: styles.arrowInner,
1924
+ style: {
1925
+ transform: `translate(${scalingValue(controls.offset.x * (slider.direction === "horiz" ? -1 : 1), isEditor)}, ${scalingValue(controls.offset.y, isEditor)}) scale(${controls.scale}) rotate(${slider.direction === "horiz" ? "0deg" : "90deg"})`
1926
+ },
1927
+ onClick: (e) => {
1928
+ handleArrowClick("+1");
1929
+ },
1930
+ "aria-label": "Next",
1931
+ children: controls.arrowsImgUrl && /* @__PURE__ */ jsx(
1932
+ SvgImage,
1933
+ {
1934
+ url: controls.arrowsImgUrl,
1935
+ fill: controls.color,
1936
+ hoverFill: controls.hover,
1937
+ className: styles.arrowImg
1938
+ }
1939
+ )
1940
+ }
1941
+ )
1942
+ }
1943
+ )
1944
+ ] }),
1945
+ area.closeIconUrl && (() => {
1946
+ const positionStyles = getPositionStyles(area.closeIconAlign, area.closeIconOffset, isEditor);
1947
+ const scaleTransform = `scale(${area.closeIconScale})`;
1948
+ const combinedTransform = positionStyles.transform ? `${positionStyles.transform} ${scaleTransform}` : scaleTransform;
1949
+ return /* @__PURE__ */ jsx(
1950
+ "button",
1951
+ {
1952
+ className: styles.closeButton,
1953
+ style: {
1954
+ ...positionStyles,
1955
+ transform: combinedTransform
1956
+ },
1957
+ onClick: onClose,
1958
+ children: /* @__PURE__ */ jsx(SvgImage, { url: area.closeIconUrl })
1959
+ }
1960
+ );
1961
+ })(),
1962
+ caption2.isActive && /* @__PURE__ */ jsx(
1789
1963
  "div",
1790
1964
  {
1791
- className: cn(styles.arrow, { [styles.arrowVertical]: slider.direction === "vert" }),
1792
- style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
1965
+ className: styles.caption,
1966
+ style: {
1967
+ ...getPositionStyles(caption2.alignment, caption2.offset, isEditor),
1968
+ fontFamily: fontSettings.fontFamily,
1969
+ fontWeight: fontSettings.fontWeight,
1970
+ fontStyle: fontSettings.fontStyle,
1971
+ width: widthSettings.sizing === "auto" ? "max-content" : scalingValue(widthSettings.width, isEditor),
1972
+ letterSpacing: scalingValue(letterSpacing, isEditor),
1973
+ wordSpacing: scalingValue(wordSpacing, isEditor),
1974
+ textAlign,
1975
+ fontSize: scalingValue(fontSizeLineHeight.fontSize, isEditor),
1976
+ lineHeight: scalingValue(fontSizeLineHeight.lineHeight, isEditor),
1977
+ textTransform: textAppearance.textTransform ?? "none",
1978
+ textDecoration: textAppearance.textDecoration ?? "none",
1979
+ fontVariant: textAppearance.fontVariant ?? "normal",
1980
+ color,
1981
+ transitionDuration: slider.duration ? `${Math.round(parseInt(slider.duration) / 2)}ms` : "500ms"
1982
+ },
1983
+ onClick: (e) => e.stopPropagation(),
1793
1984
  children: /* @__PURE__ */ jsx(
1794
- "button",
1985
+ "div",
1795
1986
  {
1796
- className: styles.arrowInner,
1987
+ "data-styles": "caption",
1988
+ className: styles.captionTextInner,
1797
1989
  style: {
1798
- transform: `translate(${scalingValue(controls.offset.x)}, ${scalingValue(controls.offset.y * (slider.direction === "horiz" ? 1 : -1))}) scale(${controls.scale}) rotate(${slider.direction === "horiz" ? "0deg" : "90deg"})`
1799
- },
1800
- onClick: (e) => {
1801
- handleArrowClick("-1");
1990
+ position: "relative"
1802
1991
  },
1803
- children: controls.arrowsImgUrl && /* @__PURE__ */ jsx(
1804
- SvgImage,
1805
- {
1806
- url: controls.arrowsImgUrl,
1807
- fill: controls.color,
1808
- hoverFill: controls.hover,
1809
- className: cn(styles.arrowImg, styles.mirror)
1810
- }
1811
- )
1992
+ children: /* @__PURE__ */ jsx(RichTextRenderer, { content: content[currentIndex].imageCaption })
1812
1993
  }
1813
1994
  )
1814
1995
  }
1815
1996
  ),
1816
- /* @__PURE__ */ jsx(
1997
+ thumbnail.isActive && /* @__PURE__ */ jsx(
1817
1998
  "div",
1818
1999
  {
1819
- className: cn(styles.arrow, styles.nextArrow, { [styles.arrowVertical]: slider.direction === "vert" }),
1820
- style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
1821
- children: /* @__PURE__ */ jsx(
1822
- "button",
2000
+ className: cn(
2001
+ styles.thumbsContainer,
1823
2002
  {
1824
- className: styles.arrowInner,
1825
- style: {
1826
- transform: `translate(${scalingValue(controls.offset.x * (slider.direction === "horiz" ? -1 : 1))}, ${scalingValue(controls.offset.y)}) scale(${controls.scale}) rotate(${slider.direction === "horiz" ? "0deg" : "90deg"})`
1827
- },
1828
- onClick: (e) => {
1829
- handleArrowClick("+1");
1830
- },
1831
- "aria-label": "Next",
1832
- children: controls.arrowsImgUrl && /* @__PURE__ */ jsx(
1833
- SvgImage,
1834
- {
1835
- url: controls.arrowsImgUrl,
1836
- fill: controls.color,
1837
- hoverFill: controls.hover,
1838
- className: styles.arrowImg
1839
- }
1840
- )
2003
+ [styles.thumbsContainerVertical]: slider.direction === "vert",
2004
+ [styles.thumbsAlignStart]: thumbnail.align === "start",
2005
+ [styles.thumbsAlignCenter]: thumbnail.align === "center",
2006
+ [styles.thumbsAlignEnd]: thumbnail.align === "end"
1841
2007
  }
1842
- )
1843
- }
1844
- )
1845
- ] }),
1846
- area.closeIconUrl && (() => {
1847
- const positionStyles = getPositionStyles(area.closeIconAlign, area.closeIconOffset);
1848
- const scaleTransform = `scale(${area.closeIconScale})`;
1849
- const combinedTransform = positionStyles.transform ? `${positionStyles.transform} ${scaleTransform}` : scaleTransform;
1850
- return /* @__PURE__ */ jsx(
1851
- "button",
1852
- {
1853
- className: styles.closeButton,
2008
+ ),
1854
2009
  style: {
1855
- ...positionStyles,
1856
- transform: combinedTransform
2010
+ gap: `${scalingValue(thumbnail.grid.gap, isEditor)}`,
2011
+ ...getPositionStyles(thumbnail.position, thumbnail.offset, isEditor)
1857
2012
  },
1858
- onClick: onClose,
1859
- children: /* @__PURE__ */ jsx(SvgImage, { url: area.closeIconUrl })
1860
- }
1861
- );
1862
- })(),
1863
- caption2.isActive && /* @__PURE__ */ jsx(
1864
- "div",
1865
- {
1866
- className: styles.caption,
1867
- style: {
1868
- ...getPositionStyles(caption2.alignment, caption2.offset),
1869
- ["--link-hover-color"]: caption2.hover
1870
- },
1871
- children: /* @__PURE__ */ jsx(RichTextRenderer, { content: content[currentIndex].imageCaption })
1872
- }
1873
- ),
1874
- thumbnail.isActive && /* @__PURE__ */ jsx(
1875
- "div",
1876
- {
1877
- className: cn(
1878
- styles.thumbsContainer,
1879
- {
1880
- [styles.thumbsContainerVertical]: slider.direction === "vert",
1881
- [styles.thumbsAlignStart]: thumbnail.align === "start",
1882
- [styles.thumbsAlignCenter]: thumbnail.align === "center",
1883
- [styles.thumbsAlignEnd]: thumbnail.align === "end"
1884
- }
1885
- ),
1886
- style: {
1887
- gap: `${thumbnail.grid.gap}px`,
1888
- ...slider.direction === "horiz" ? { height: `${thumbnail.grid.height}px` } : {},
1889
- ...slider.direction === "vert" ? { width: `${thumbnail.grid.width}px` } : {},
1890
- ...getPositionStyles(thumbnail.position, thumbnail.offset)
1891
- },
1892
- children: content.map((item, index) => {
1893
- const isActive = index === currentIndex;
1894
- return /* @__PURE__ */ jsx(
1895
- "button",
1896
- {
1897
- className: styles.thumbItem,
1898
- style: {
1899
- transform: `scale(${isActive ? thumbnail.activeState.scale : 1})`,
1900
- ...slider.direction === "horiz" ? { height: "100%" } : {},
1901
- ...slider.direction === "vert" ? { width: "100%" } : {},
1902
- opacity: isActive ? thumbnail.activeState.opacity : thumbnail.opacity,
1903
- ["--thumb-hover"]: thumbnail.activeState.opacity
1904
- },
1905
- onClick: (e) => {
1906
- var _a;
1907
- e.stopPropagation();
1908
- setCurrentIndex(index);
1909
- (_a = lightboxRef.current) == null ? void 0 : _a.go(index);
1910
- },
1911
- children: /* @__PURE__ */ jsx(
1912
- "img",
1913
- {
1914
- src: item.image.url,
1915
- alt: item.image.name ?? "",
1916
- className: styles.thumbImage,
1917
- style: {
1918
- objectFit: thumbnail.fit === "cover" ? "cover" : "contain",
1919
- ...slider.direction === "horiz" ? { height: "100%" } : {},
1920
- ...slider.direction === "vert" ? { width: "100%" } : {}
2013
+ children: content.map((item, index) => {
2014
+ const isActive = index === currentIndex;
2015
+ return /* @__PURE__ */ jsx(
2016
+ "button",
2017
+ {
2018
+ className: styles.thumbItem,
2019
+ style: {
2020
+ ...slider.direction === "horiz" ? { height: isActive ? `${scalingValue(thumbnail.grid.height * (isActive ? thumbnail.activeState.scale : 1), isEditor)}` : `${scalingValue(thumbnail.grid.height, isEditor)}` } : {},
2021
+ ...slider.direction === "vert" ? { width: isActive ? `${scalingValue(thumbnail.grid.width * (isActive ? thumbnail.activeState.scale : 1), isEditor)}` : `${scalingValue(thumbnail.grid.width, isEditor)}` } : {},
2022
+ ...thumbnail.fit === "cover" && slider.direction === "horiz" ? { width: isActive ? `${scalingValue(thumbnail.grid.width * (isActive ? thumbnail.activeState.scale : 1), isEditor)}` : `${scalingValue(thumbnail.grid.width, isEditor)}` } : {},
2023
+ ...thumbnail.fit === "cover" && slider.direction === "vert" ? { height: isActive ? `${scalingValue(thumbnail.grid.height * (isActive ? thumbnail.activeState.scale : 1), isEditor)}` : `${scalingValue(thumbnail.grid.height, isEditor)}` } : {},
2024
+ transition: isActive ? "all 0.2s ease" : "none",
2025
+ opacity: isActive ? thumbnail.activeState.opacity / 100 : thumbnail.opacity / 100,
2026
+ ["--thumb-hover"]: thumbnail.activeState.opacity / 100
2027
+ },
2028
+ onClick: (e) => {
2029
+ var _a;
2030
+ e.stopPropagation();
2031
+ setCurrentIndex(index);
2032
+ (_a = lightboxRef.current) == null ? void 0 : _a.go(index);
2033
+ },
2034
+ children: /* @__PURE__ */ jsx(
2035
+ "img",
2036
+ {
2037
+ src: item.image.url,
2038
+ alt: item.image.name ?? "",
2039
+ style: {
2040
+ objectFit: thumbnail.fit === "cover" ? "cover" : "contain",
2041
+ ...thumbnail.fit === "fit" ? { maxWidth: "100%", maxHeight: "100%", objectFit: "contain" } : {},
2042
+ ...thumbnail.fit === "cover" && slider.direction === "horiz" ? { width: "100%", height: "100%" } : {}
2043
+ }
1921
2044
  }
1922
- }
1923
- )
1924
- },
1925
- `${item.image.url}-${index}`
1926
- );
1927
- })
1928
- }
1929
- )
1930
- ]
1931
- }
1932
- )
1933
- }
1934
- ),
2045
+ )
2046
+ },
2047
+ `${item.image.url}-${index}`
2048
+ );
2049
+ })
2050
+ }
2051
+ )
2052
+ ]
2053
+ }
2054
+ )
2055
+ }
2056
+ )
2057
+ ] }),
1935
2058
  document.getElementById(portalId)
1936
2059
  );
1937
2060
  };
@@ -1944,8 +2067,8 @@ const LightboxComponent = {
1944
2067
  url: "https://cdn.cntrl.site/projects/01GJ2SPDSH73MC92WW7ZA2CWBY/articles-assets/01KA24CHYZXJBZ0Q714B05A7VD.mp4"
1945
2068
  },
1946
2069
  defaultSize: {
1947
- width: 400,
1948
- height: 400
2070
+ width: 440,
2071
+ height: 550
1949
2072
  },
1950
2073
  schema: {
1951
2074
  type: "object",
@@ -1970,6 +2093,7 @@ const LightboxComponent = {
1970
2093
  url: {
1971
2094
  type: "string",
1972
2095
  display: {
2096
+ mode: "cover",
1973
2097
  type: "settings-image-input"
1974
2098
  }
1975
2099
  }
@@ -2042,14 +2166,6 @@ const LightboxComponent = {
2042
2166
  type: "ratio-group"
2043
2167
  },
2044
2168
  enum: ["image", "50/50"]
2045
- },
2046
- duration: {
2047
- type: "string",
2048
- label: "T",
2049
- display: {
2050
- type: "step-selector"
2051
- },
2052
- enum: ["100ms", "250ms", "500ms", "1000ms", "1500ms", "2000ms"]
2053
2169
  }
2054
2170
  }
2055
2171
  },
@@ -2072,6 +2188,14 @@ const LightboxComponent = {
2072
2188
  type: "ratio-group"
2073
2189
  },
2074
2190
  enum: ["horiz", "vert"]
2191
+ },
2192
+ duration: {
2193
+ type: "string",
2194
+ label: "T",
2195
+ display: {
2196
+ type: "step-selector"
2197
+ },
2198
+ enum: ["100ms", "250ms", "500ms", "1000ms", "1500ms", "2000ms"]
2075
2199
  }
2076
2200
  }
2077
2201
  },
@@ -2130,7 +2254,8 @@ const LightboxComponent = {
2130
2254
  type: "number",
2131
2255
  label: "H",
2132
2256
  display: {
2133
- type: "numeric-input"
2257
+ type: "numeric-input",
2258
+ visible: true
2134
2259
  }
2135
2260
  },
2136
2261
  width: {
@@ -2152,15 +2277,28 @@ const LightboxComponent = {
2152
2277
  },
2153
2278
  offset: {
2154
2279
  type: "object",
2280
+ title: "Offset",
2155
2281
  display: {
2156
- type: "offset-controls"
2282
+ type: "group"
2157
2283
  },
2158
2284
  properties: {
2159
2285
  x: {
2160
- type: "number"
2286
+ type: "number",
2287
+ label: "X",
2288
+ scalingEnabled: true,
2289
+ display: {
2290
+ type: "numeric-input",
2291
+ visible: true
2292
+ }
2161
2293
  },
2162
2294
  y: {
2163
- type: "number"
2295
+ type: "number",
2296
+ label: "Y",
2297
+ scalingEnabled: true,
2298
+ display: {
2299
+ type: "numeric-input",
2300
+ visible: true
2301
+ }
2164
2302
  }
2165
2303
  }
2166
2304
  },
@@ -2185,7 +2323,7 @@ const LightboxComponent = {
2185
2323
  scale: {
2186
2324
  type: "number",
2187
2325
  title: "Scale",
2188
- min: 0.5,
2326
+ min: 1,
2189
2327
  max: 5,
2190
2328
  step: 0.1,
2191
2329
  display: {
@@ -2222,15 +2360,28 @@ const LightboxComponent = {
2222
2360
  },
2223
2361
  offset: {
2224
2362
  type: "object",
2363
+ title: "Offset",
2225
2364
  display: {
2226
- type: "offset-controls"
2365
+ type: "group"
2227
2366
  },
2228
2367
  properties: {
2229
2368
  x: {
2230
- type: "number"
2369
+ type: "number",
2370
+ label: "X",
2371
+ scalingEnabled: true,
2372
+ display: {
2373
+ type: "numeric-input",
2374
+ visible: true
2375
+ }
2231
2376
  },
2232
2377
  y: {
2233
- type: "number"
2378
+ type: "number",
2379
+ label: "Y",
2380
+ scalingEnabled: true,
2381
+ display: {
2382
+ type: "numeric-input",
2383
+ visible: true
2384
+ }
2234
2385
  }
2235
2386
  }
2236
2387
  },
@@ -2276,16 +2427,29 @@ const LightboxComponent = {
2276
2427
  }
2277
2428
  },
2278
2429
  offset: {
2430
+ title: "Offset",
2279
2431
  type: "object",
2280
2432
  display: {
2281
- type: "offset-controls"
2433
+ type: "group"
2282
2434
  },
2283
2435
  properties: {
2284
2436
  x: {
2285
- type: "number"
2437
+ type: "number",
2438
+ label: "X",
2439
+ scalingEnabled: true,
2440
+ display: {
2441
+ type: "numeric-input",
2442
+ visible: true
2443
+ }
2286
2444
  },
2287
2445
  y: {
2288
- type: "number"
2446
+ type: "number",
2447
+ label: "Y",
2448
+ scalingEnabled: true,
2449
+ display: {
2450
+ type: "numeric-input",
2451
+ visible: true
2452
+ }
2289
2453
  }
2290
2454
  }
2291
2455
  },
@@ -2364,15 +2528,28 @@ const LightboxComponent = {
2364
2528
  },
2365
2529
  closeIconOffset: {
2366
2530
  type: "object",
2531
+ title: "Offset",
2367
2532
  display: {
2368
- type: "offset-controls"
2533
+ type: "group"
2369
2534
  },
2370
2535
  properties: {
2371
2536
  x: {
2372
- type: "number"
2537
+ type: "number",
2538
+ label: "X",
2539
+ scalingEnabled: true,
2540
+ display: {
2541
+ type: "numeric-input",
2542
+ visible: true
2543
+ }
2373
2544
  },
2374
2545
  y: {
2375
- type: "number"
2546
+ type: "number",
2547
+ label: "Y",
2548
+ scalingEnabled: true,
2549
+ display: {
2550
+ type: "numeric-input",
2551
+ visible: true
2552
+ }
2376
2553
  }
2377
2554
  }
2378
2555
  }
@@ -2398,16 +2575,29 @@ const LightboxComponent = {
2398
2575
  enum: ["top-left", "top-center", "top-right", "middle-left", "middle-center", "middle-right", "bottom-left", "bottom-center", "bottom-right"]
2399
2576
  },
2400
2577
  offset: {
2578
+ title: "Offset",
2401
2579
  type: "object",
2402
2580
  display: {
2403
- type: "offset-controls"
2581
+ type: "group"
2404
2582
  },
2405
2583
  properties: {
2406
2584
  x: {
2407
- type: "number"
2585
+ type: "number",
2586
+ label: "X",
2587
+ scalingEnabled: true,
2588
+ display: {
2589
+ type: "numeric-input",
2590
+ visible: true
2591
+ }
2408
2592
  },
2409
2593
  y: {
2410
- type: "number"
2594
+ type: "number",
2595
+ label: "Y",
2596
+ scalingEnabled: true,
2597
+ display: {
2598
+ type: "numeric-input",
2599
+ visible: true
2600
+ }
2411
2601
  }
2412
2602
  }
2413
2603
  },
@@ -2433,18 +2623,18 @@ const LightboxComponent = {
2433
2623
  lightboxBlock: {
2434
2624
  appear: {
2435
2625
  type: "slide in",
2436
- duration: "1000ms",
2626
+ duration: "500ms",
2437
2627
  direction: "right",
2438
- repeat: "close"
2628
+ repeat: "loop"
2439
2629
  },
2440
2630
  triggers: {
2441
2631
  type: "click",
2442
- switch: "image",
2443
- duration: "2000ms"
2632
+ switch: "image"
2444
2633
  },
2445
2634
  slider: {
2446
2635
  type: "fade",
2447
- direction: "horiz"
2636
+ direction: "horiz",
2637
+ duration: "1000ms"
2448
2638
  },
2449
2639
  thumbnail: {
2450
2640
  isActive: true,
@@ -2453,12 +2643,12 @@ const LightboxComponent = {
2453
2643
  align: "center",
2454
2644
  triggers: "clk",
2455
2645
  grid: {
2456
- height: 60,
2457
- width: 60,
2458
- gap: 8
2646
+ height: 0.03,
2647
+ width: 0.03,
2648
+ gap: 8e-3
2459
2649
  },
2460
2650
  offset: { x: 0, y: 0 },
2461
- opacity: 100,
2651
+ opacity: 80,
2462
2652
  activeState: {
2463
2653
  scale: 1,
2464
2654
  opacity: 100
@@ -2510,7 +2700,7 @@ const LightboxComponent = {
2510
2700
  value: "vert"
2511
2701
  },
2512
2702
  then: {
2513
- name: "properties.lightboxBlock.properties.thumbnail.properties.position.display.direction",
2703
+ name: "properties.lightboxBlock.properties.thumbnail.properties.align.display.direction",
2514
2704
  value: "vertical"
2515
2705
  }
2516
2706
  },
@@ -2573,47 +2763,27 @@ const LightboxComponent = {
2573
2763
  name: "properties.lightboxBlock.properties.appear.properties.direction.display.visible",
2574
2764
  value: false
2575
2765
  }
2576
- },
2577
- {
2578
- if: {
2579
- name: "lightboxBlock.triggers.type",
2580
- value: "click"
2581
- },
2582
- then: {
2583
- name: "properties.lightboxBlock.properties.triggers.properties.duration.display.visible",
2584
- value: true
2585
- }
2586
- },
2587
- {
2588
- if: {
2589
- name: "lightboxBlock.triggers.type",
2590
- value: "click"
2591
- },
2592
- then: {
2593
- name: "properties.lightboxBlock.properties.triggers.properties.switch.display.visible",
2594
- value: true
2595
- }
2596
- },
2597
- {
2598
- if: {
2599
- name: "lightboxBlock.triggers.type",
2600
- value: "drag"
2601
- },
2602
- then: {
2603
- name: "properties.lightboxBlock.properties.triggers.properties.duration.display.visible",
2604
- value: false
2605
- }
2606
- },
2607
- {
2608
- if: {
2609
- name: "lightboxBlock.triggers.type",
2610
- value: "drag"
2611
- },
2612
- then: {
2613
- name: "properties.lightboxBlock.properties.triggers.properties.switch.display.visible",
2614
- value: false
2615
- }
2616
2766
  }
2767
+ // {
2768
+ // if: {
2769
+ // name: 'lightboxBlock.triggers.type',
2770
+ // value: 'click'
2771
+ // },
2772
+ // then: {
2773
+ // name: 'properties.lightboxBlock.properties.slider.properties.switch.display.visible',
2774
+ // value: true
2775
+ // }
2776
+ // },
2777
+ // {
2778
+ // if: {
2779
+ // name: 'lightboxBlock.triggers.type',
2780
+ // value: 'drag'
2781
+ // },
2782
+ // then: {
2783
+ // name: 'properties.lightboxBlock.properties.slider.properties.switch.display.visible',
2784
+ // value: false
2785
+ // }
2786
+ // }
2617
2787
  ]
2618
2788
  },
2619
2789
  content: {