@cntrl-site/components 0.1.0-alpha.3 → 0.1.0-alpha.31

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.js CHANGED
@@ -565,15 +565,28 @@ const ControlSliderComponent = {
565
565
  },
566
566
  offset: {
567
567
  type: "object",
568
+ title: "Offset",
568
569
  display: {
569
- type: "offset-controls"
570
+ type: "group"
570
571
  },
571
572
  properties: {
572
573
  x: {
573
- type: "number"
574
+ type: "number",
575
+ label: "X",
576
+ scalingEnabled: true,
577
+ display: {
578
+ type: "numeric-input",
579
+ visible: true
580
+ }
574
581
  },
575
582
  y: {
576
- type: "number"
583
+ type: "number",
584
+ label: "Y",
585
+ scalingEnabled: true,
586
+ display: {
587
+ type: "numeric-input",
588
+ visible: true
589
+ }
577
590
  }
578
591
  }
579
592
  },
@@ -626,15 +639,28 @@ const ControlSliderComponent = {
626
639
  },
627
640
  offset: {
628
641
  type: "object",
642
+ title: "Offset",
629
643
  display: {
630
- type: "offset-controls"
644
+ type: "group"
631
645
  },
632
646
  properties: {
633
647
  x: {
634
- type: "number"
648
+ type: "number",
649
+ label: "X",
650
+ scalingEnabled: true,
651
+ display: {
652
+ type: "numeric-input",
653
+ visible: true
654
+ }
635
655
  },
636
656
  y: {
637
- type: "number"
657
+ type: "number",
658
+ label: "Y",
659
+ scalingEnabled: true,
660
+ display: {
661
+ type: "numeric-input",
662
+ visible: true
663
+ }
638
664
  }
639
665
  }
640
666
  },
@@ -690,14 +716,26 @@ const ControlSliderComponent = {
690
716
  offset: {
691
717
  type: "object",
692
718
  display: {
693
- type: "offset-controls"
719
+ type: "group"
694
720
  },
695
721
  properties: {
696
722
  x: {
697
- type: "number"
723
+ type: "number",
724
+ label: "X",
725
+ scalingEnabled: true,
726
+ display: {
727
+ type: "numeric-input",
728
+ visible: true
729
+ }
698
730
  },
699
731
  y: {
700
- type: "number"
732
+ type: "number",
733
+ label: "Y",
734
+ scalingEnabled: true,
735
+ display: {
736
+ type: "numeric-input",
737
+ visible: true
738
+ }
701
739
  }
702
740
  }
703
741
  },
@@ -1443,6 +1481,7 @@ const ControlImageRevealSliderComponent = {
1443
1481
  }
1444
1482
  }
1445
1483
  };
1484
+ const background = "Lightbox-module__background___wf1Ii";
1446
1485
  const backdropStyle = "Lightbox-module__backdropStyle___y7avj";
1447
1486
  const editor = "Lightbox-module__editor___Vh82D";
1448
1487
  const contentStyle = "Lightbox-module__contentStyle___FzFaW";
@@ -1464,15 +1503,20 @@ const thumbsAlignStart = "Lightbox-module__thumbsAlignStart___uiFIV";
1464
1503
  const thumbsAlignCenter = "Lightbox-module__thumbsAlignCenter___sbUPA";
1465
1504
  const thumbsAlignEnd = "Lightbox-module__thumbsAlignEnd___OA9N4";
1466
1505
  const thumbItem = "Lightbox-module__thumbItem___zROyu";
1467
- const thumbImage = "Lightbox-module__thumbImage___xGakV";
1468
1506
  const closeButton = "Lightbox-module__closeButton___r3Dur";
1469
1507
  const fadeIn = "Lightbox-module__fadeIn___sHwRK";
1470
1508
  const slideInLeft = "Lightbox-module__slideInLeft___P-XRo";
1471
1509
  const slideInRight = "Lightbox-module__slideInRight___ZQqFi";
1472
1510
  const slideInTop = "Lightbox-module__slideInTop___XRKCs";
1473
1511
  const slideInBottom = "Lightbox-module__slideInBottom___TYOBS";
1512
+ const fadeOut = "Lightbox-module__fadeOut___h2fpQ";
1513
+ const slideOutLeft = "Lightbox-module__slideOutLeft___J-eMU";
1514
+ const slideOutRight = "Lightbox-module__slideOutRight___iZUQz";
1515
+ const slideOutTop = "Lightbox-module__slideOutTop___3TXF9";
1516
+ const slideOutBottom = "Lightbox-module__slideOutBottom___SB5ws";
1474
1517
  const scaleSlide = "Lightbox-module__scaleSlide___wS7d4";
1475
1518
  const styles = {
1519
+ background,
1476
1520
  backdropStyle,
1477
1521
  editor,
1478
1522
  contentStyle,
@@ -1494,16 +1538,20 @@ const styles = {
1494
1538
  thumbsAlignCenter,
1495
1539
  thumbsAlignEnd,
1496
1540
  thumbItem,
1497
- thumbImage,
1498
1541
  closeButton,
1499
1542
  fadeIn,
1500
1543
  slideInLeft,
1501
1544
  slideInRight,
1502
1545
  slideInTop,
1503
1546
  slideInBottom,
1547
+ fadeOut,
1548
+ slideOutLeft,
1549
+ slideOutRight,
1550
+ slideOutTop,
1551
+ slideOutBottom,
1504
1552
  scaleSlide
1505
1553
  };
1506
- const getPositionStyles = (position, offset) => {
1554
+ const getPositionStyles = (position, offset, isEditor) => {
1507
1555
  const styles2 = {};
1508
1556
  const [vertical, horizontal] = position.split("-");
1509
1557
  if (vertical === "top") {
@@ -1527,16 +1575,41 @@ const getPositionStyles = (position, offset) => {
1527
1575
  styles2.right = "0";
1528
1576
  }
1529
1577
  if (vertical === "middle" && horizontal === "center") {
1530
- styles2.transform = `translate(calc(-50% + ${offset.x}px), calc(-50% + ${offset.y}px))`;
1578
+ styles2.transform = `translate(calc(-50% + ${scalingValue(offset.x, isEditor)}), calc(-50% + ${scalingValue(offset.y, isEditor)}))`;
1531
1579
  } else if (vertical === "middle") {
1532
- styles2.transform = `translate(${offset.x}px, calc(-50% + ${offset.y}px))`;
1580
+ styles2.transform = `translate(${scalingValue(offset.x, isEditor)}, calc(-50% + ${scalingValue(offset.y, isEditor)}))`;
1533
1581
  } else if (horizontal === "center") {
1534
- styles2.transform = `translate(calc(-50% + ${offset.x}px), ${offset.y}px)`;
1582
+ styles2.transform = `translate(calc(-50% + ${scalingValue(offset.x, isEditor)}), ${scalingValue(offset.y, isEditor)})`;
1535
1583
  } else {
1536
- styles2.transform = `translate(${offset.x}px, ${offset.y}px)`;
1584
+ styles2.transform = `translate(${scalingValue(offset.x, isEditor)}, ${scalingValue(offset.y, isEditor)})`;
1537
1585
  }
1538
1586
  return styles2;
1539
1587
  };
1588
+ function getDisplayedImageRect(img2) {
1589
+ const container = img2.getBoundingClientRect();
1590
+ const containerW = container.width;
1591
+ const containerH = container.height;
1592
+ const imgW = img2.naturalWidth;
1593
+ const imgH = img2.naturalHeight;
1594
+ const containerRatio = containerW / containerH;
1595
+ const imgRatio = imgW / imgH;
1596
+ let renderedW, renderedH;
1597
+ if (imgRatio > containerRatio) {
1598
+ renderedW = containerW;
1599
+ renderedH = containerW / imgRatio;
1600
+ } else {
1601
+ renderedH = containerH;
1602
+ renderedW = containerH * imgRatio;
1603
+ }
1604
+ const offsetX = (containerW - renderedW) / 2 + container.left;
1605
+ const offsetY = (containerH - renderedH) / 2 + container.top;
1606
+ return {
1607
+ x: offsetX,
1608
+ y: offsetY,
1609
+ width: renderedW,
1610
+ height: renderedH
1611
+ };
1612
+ }
1540
1613
  function LightboxGallery({ settings, content, styles: styles2, portalId, activeEvent, isEditor }) {
1541
1614
  const [open, setOpen] = React.useState(false);
1542
1615
  const { url } = settings.thumbnailBlock.cover;
@@ -1558,34 +1631,147 @@ function LightboxGallery({ settings, content, styles: styles2, portalId, activeE
1558
1631
  onClick: () => setOpen(true)
1559
1632
  }
1560
1633
  ),
1561
- /* @__PURE__ */ jsxRuntime.jsx(Lightbox, { isOpen: open, onClose: () => setOpen(false), content, settings, portalId, isEditor })
1634
+ /* @__PURE__ */ jsxRuntime.jsx(Lightbox, { isOpen: open, onClose: () => setOpen(false), content, settings, styles: styles2, portalId, isEditor, activeEvent })
1562
1635
  ] });
1563
1636
  }
1564
- const Lightbox = ({ isOpen, onClose, content, settings, closeOnBackdropClick = true, closeOnEsc = true, portalId, isEditor }) => {
1637
+ const Lightbox = ({ isOpen, onClose, content, styles: lightboxStyles, settings, portalId, isEditor }) => {
1638
+ const { widthSettings, fontSettings, letterSpacing, textAlign, wordSpacing, fontSizeLineHeight, textAppearance, color } = lightboxStyles.caption;
1565
1639
  const [currentIndex, setCurrentIndex] = React.useState(0);
1640
+ const [splideKey, setSplideKey] = React.useState(0);
1641
+ const [isClosing, setIsClosing] = React.useState(false);
1566
1642
  const lightboxRef = React.useRef(null);
1567
- const resizeObserverRef = React.useRef(null);
1643
+ const prevSliderTypeRef = React.useRef(null);
1644
+ const imageRef = React.useRef(null);
1645
+ const isClosingRef = React.useRef(false);
1646
+ const contentRef = React.useRef(null);
1647
+ const animationEndHandlerRef = React.useRef(null);
1648
+ const appearAnimationEndHandlerRef = React.useRef(null);
1568
1649
  const { appear, triggers, slider, thumbnail, controls, area, caption: caption2, layout } = settings.lightboxBlock;
1650
+ const appearDurationMs = appear.duration ? parseInt(appear.duration) : 300;
1651
+ React.useEffect(() => {
1652
+ window.addEventListener("ArticleEditor.Layout:change", () => {
1653
+ var _a, _b;
1654
+ (_b = (_a = lightboxRef.current) == null ? void 0 : _a.splide) == null ? void 0 : _b.refresh();
1655
+ });
1656
+ return () => {
1657
+ window.removeEventListener("ArticleEditor.Layout:change", () => {
1658
+ var _a, _b;
1659
+ (_b = (_a = lightboxRef.current) == null ? void 0 : _a.splide) == null ? void 0 : _b.refresh();
1660
+ });
1661
+ };
1662
+ }, []);
1663
+ const handleClose = React.useCallback(() => {
1664
+ const isMobile = window.matchMedia("(max-width: 768px)").matches;
1665
+ const colorAlpha = getColorAlpha(area.color);
1666
+ if (isMobile && !isEditor && colorAlpha > 0.9) {
1667
+ document.body.style.backgroundColor = "";
1668
+ }
1669
+ setIsClosing(true);
1670
+ isClosingRef.current = true;
1671
+ const handleAnimationEnd = (e) => {
1672
+ if (e.target === contentRef.current && e.animationName) {
1673
+ if (contentRef.current && animationEndHandlerRef.current) {
1674
+ contentRef.current.removeEventListener("animationend", animationEndHandlerRef.current);
1675
+ }
1676
+ animationEndHandlerRef.current = null;
1677
+ onClose();
1678
+ setIsClosing(false);
1679
+ }
1680
+ };
1681
+ if (contentRef.current) {
1682
+ animationEndHandlerRef.current = handleAnimationEnd;
1683
+ contentRef.current.addEventListener("animationend", handleAnimationEnd);
1684
+ }
1685
+ }, [onClose, appearDurationMs, area.color, isEditor]);
1569
1686
  const handleBackdropClick = (e) => {
1570
- if (!closeOnBackdropClick) return;
1571
1687
  if (e.target === e.currentTarget) {
1572
- onClose();
1688
+ handleClose();
1573
1689
  }
1574
1690
  };
1575
1691
  const handleImageWrapperClick = (e) => {
1576
- if (!closeOnBackdropClick) return;
1577
- if (e.target === e.currentTarget) {
1578
- onClose();
1692
+ var _a, _b;
1693
+ const currentImage = content[currentIndex];
1694
+ const isCover = (currentImage == null ? void 0 : currentImage.image.objectFit) === "cover";
1695
+ let clientX;
1696
+ let clientY;
1697
+ if ("changedTouches" in e && e.changedTouches.length > 0) {
1698
+ clientX = e.changedTouches[0].clientX;
1699
+ clientY = e.changedTouches[0].clientY;
1700
+ } else if ("clientX" in e) {
1701
+ clientX = e.clientX;
1702
+ clientY = e.clientY;
1703
+ } else {
1704
+ return;
1705
+ }
1706
+ let inside;
1707
+ if (isCover && imageRef.current) {
1708
+ const imgRect = imageRef.current.getBoundingClientRect();
1709
+ inside = clientX >= imgRect.left && clientX <= imgRect.right && clientY >= imgRect.top && clientY <= imgRect.bottom;
1710
+ } else {
1711
+ const rect = imageRef.current ? getDisplayedImageRect(imageRef.current) : null;
1712
+ if (!rect) {
1713
+ if (e.target === e.currentTarget) {
1714
+ handleClose();
1715
+ }
1716
+ return;
1717
+ }
1718
+ inside = clientX >= rect.x && clientX <= rect.x + rect.width && clientY >= rect.y && clientY <= rect.y + rect.height;
1719
+ }
1720
+ if (inside) {
1721
+ if (triggers.type === "click" && triggers.switch === "image") {
1722
+ if (triggers.repeat === "close" && currentIndex === content.length - 1) {
1723
+ handleClose();
1724
+ } else {
1725
+ (_a = lightboxRef.current) == null ? void 0 : _a.go("+1");
1726
+ }
1727
+ } else if (triggers.type === "click" && triggers.switch === "50/50") {
1728
+ const img2 = imageRef.current;
1729
+ if (img2) {
1730
+ const imgRect = img2.getBoundingClientRect();
1731
+ const clickX = clientX - imgRect.left;
1732
+ const clickY = clientY - imgRect.top;
1733
+ const imgWidth = imgRect.width;
1734
+ const imgHeight = imgRect.height;
1735
+ let dir;
1736
+ if (slider.direction === "horiz") {
1737
+ dir = clickX < imgWidth / 2 ? "-1" : "+1";
1738
+ } else {
1739
+ dir = clickY < imgHeight / 2 ? "-1" : "+1";
1740
+ }
1741
+ (_b = lightboxRef.current) == null ? void 0 : _b.go(dir);
1742
+ }
1743
+ }
1744
+ } else {
1745
+ handleClose();
1746
+ }
1747
+ };
1748
+ const handleContentClick = (e) => {
1749
+ const target = e.target;
1750
+ const currentTarget = e.currentTarget;
1751
+ if (target === currentTarget) {
1752
+ handleClose();
1753
+ return;
1754
+ }
1755
+ const isImg = target.tagName === "IMG" || target.closest("img");
1756
+ const isButton = target.tagName === "BUTTON" || target.closest("button");
1757
+ const isSplide = target.closest(".splide") || target.closest('[class*="splide"]');
1758
+ const isCaption = target.closest(`.${styles.caption}`);
1759
+ const isThumbnail = target.closest(`.${styles.thumbsContainer}`);
1760
+ if (!isImg && !isButton && !isSplide && !isCaption && !isThumbnail) {
1761
+ handleClose();
1579
1762
  }
1580
1763
  };
1581
1764
  const onImageClick = (e) => {
1582
1765
  var _a, _b;
1766
+ e.stopPropagation();
1583
1767
  if (triggers.type === "click" && triggers.switch === "image") {
1584
- e.stopPropagation();
1585
- (_a = lightboxRef.current) == null ? void 0 : _a.go("+1");
1768
+ if (triggers.repeat === "close" && currentIndex === content.length - 1) {
1769
+ handleClose();
1770
+ } else {
1771
+ (_a = lightboxRef.current) == null ? void 0 : _a.go("+1");
1772
+ }
1586
1773
  }
1587
1774
  if (triggers.type === "click" && triggers.switch === "50/50") {
1588
- e.stopPropagation();
1589
1775
  const img2 = e.currentTarget;
1590
1776
  const rect = img2.getBoundingClientRect();
1591
1777
  const clickX = e.clientX - rect.left;
@@ -1602,10 +1788,10 @@ const Lightbox = ({ isOpen, onClose, content, settings, closeOnBackdropClick = t
1602
1788
  }
1603
1789
  };
1604
1790
  React.useEffect(() => {
1605
- if (!isOpen || !closeOnEsc) return;
1791
+ if (!isOpen) return;
1606
1792
  const onKeyDown = (event) => {
1607
1793
  if (event.key === "Escape") {
1608
- onClose();
1794
+ handleClose();
1609
1795
  return;
1610
1796
  }
1611
1797
  if (event.key === "ArrowRight") {
@@ -1620,58 +1806,62 @@ const Lightbox = ({ isOpen, onClose, content, settings, closeOnBackdropClick = t
1620
1806
  return () => {
1621
1807
  window.removeEventListener("keydown", onKeyDown);
1622
1808
  };
1623
- }, [isOpen, closeOnEsc, onClose, content.length]);
1809
+ }, [isOpen, handleClose, content.length]);
1624
1810
  React.useEffect(() => {
1625
- if (isOpen) setCurrentIndex(0);
1811
+ if (isOpen) {
1812
+ setCurrentIndex(0);
1813
+ isClosingRef.current = false;
1814
+ setIsClosing(false);
1815
+ }
1816
+ return () => {
1817
+ if (contentRef.current && animationEndHandlerRef.current) {
1818
+ contentRef.current.removeEventListener("animationend", animationEndHandlerRef.current);
1819
+ animationEndHandlerRef.current = null;
1820
+ }
1821
+ };
1626
1822
  }, [isOpen]);
1627
1823
  React.useEffect(() => {
1628
- if (!isOpen) return;
1629
- if (resizeObserverRef.current) {
1630
- resizeObserverRef.current.disconnect();
1631
- resizeObserverRef.current = null;
1824
+ if (prevSliderTypeRef.current !== null && prevSliderTypeRef.current !== slider.type) {
1825
+ setSplideKey((prev) => prev + 1);
1632
1826
  }
1633
- const timeoutId = setTimeout(() => {
1634
- const activeSlide = document.querySelector(".splide__slide.is-active");
1635
- if (!activeSlide) return;
1636
- const img2 = activeSlide.querySelector("img");
1637
- const container = activeSlide.querySelector(`.${styles.imgWrapper}`);
1638
- if (!img2 || !container) return;
1639
- const updateImageSize = () => {
1640
- if (!img2.naturalWidth || !img2.naturalHeight) return;
1641
- const imageAspectRatio = img2.naturalWidth / img2.naturalHeight;
1642
- const containerWidth = container.clientWidth;
1643
- const containerHeight = container.clientHeight;
1644
- const containerAspectRatio = containerWidth / containerHeight;
1645
- if (imageAspectRatio > containerAspectRatio) {
1646
- img2.style.width = "100%";
1647
- } else {
1648
- img2.style.height = "100%";
1827
+ prevSliderTypeRef.current = slider.type;
1828
+ }, [slider.type]);
1829
+ React.useEffect(() => {
1830
+ if (!isOpen) return;
1831
+ const originalOverflow = document.body.style.overflow;
1832
+ document.body.style.overflow = "hidden";
1833
+ const isMobile = window.matchMedia("(max-width: 768px)").matches;
1834
+ const colorAlpha = getColorAlpha(area.color);
1835
+ const handleAppearAnimationEnd = (e) => {
1836
+ if (e.target === contentRef.current && !isClosingRef.current && e.animationName) {
1837
+ if (isMobile && !isEditor && colorAlpha > 0.9) {
1838
+ document.body.style.backgroundColor = area.color;
1649
1839
  }
1650
- };
1651
- if (img2.complete) {
1652
- updateImageSize();
1653
- } else {
1654
- img2.onload = updateImageSize;
1840
+ if (contentRef.current && appearAnimationEndHandlerRef.current) {
1841
+ contentRef.current.removeEventListener("animationend", appearAnimationEndHandlerRef.current);
1842
+ }
1843
+ appearAnimationEndHandlerRef.current = null;
1655
1844
  }
1656
- resizeObserverRef.current = new ResizeObserver(() => {
1657
- updateImageSize();
1658
- });
1659
- resizeObserverRef.current.observe(container);
1660
- resizeObserverRef.current.observe(img2);
1661
- }, 0);
1845
+ };
1846
+ if (contentRef.current && isMobile && !isEditor && colorAlpha > 0.9) {
1847
+ appearAnimationEndHandlerRef.current = handleAppearAnimationEnd;
1848
+ contentRef.current.addEventListener("animationend", handleAppearAnimationEnd);
1849
+ }
1850
+ const preventScroll = (e) => e.preventDefault();
1851
+ document.addEventListener("touchmove", preventScroll, { passive: false });
1662
1852
  return () => {
1663
- clearTimeout(timeoutId);
1664
- if (resizeObserverRef.current) {
1665
- resizeObserverRef.current.disconnect();
1666
- resizeObserverRef.current = null;
1853
+ document.body.style.overflow = originalOverflow;
1854
+ document.removeEventListener("touchmove", preventScroll);
1855
+ if (contentRef.current && appearAnimationEndHandlerRef.current) {
1856
+ contentRef.current.removeEventListener("animationend", appearAnimationEndHandlerRef.current);
1857
+ appearAnimationEndHandlerRef.current = null;
1667
1858
  }
1668
1859
  };
1669
- }, [isOpen, currentIndex, content]);
1860
+ }, [isOpen, area.color, isEditor]);
1670
1861
  const handleArrowClick = (dir) => {
1671
1862
  var _a;
1672
1863
  (_a = lightboxRef.current) == null ? void 0 : _a.go(dir);
1673
1864
  };
1674
- const appearDurationMs = appear.duration ? parseInt(appear.duration) : 300;
1675
1865
  const backdropDurationMs = appear.type === "fade in" || appear.type === "mix" ? Math.floor(appearDurationMs * 0.7) : appearDurationMs;
1676
1866
  const appearClass = (() => {
1677
1867
  if (appear.type === "fade in") return styles.fadeIn;
@@ -1709,247 +1899,400 @@ const Lightbox = ({ isOpen, onClose, content, settings, closeOnBackdropClick = t
1709
1899
  }
1710
1900
  return styles.fadeIn;
1711
1901
  })();
1712
- if (!isOpen) return null;
1902
+ const backdropDisappearClass = (() => {
1903
+ if (appear.type === "fade in" || appear.type === "mix") return styles.fadeOut;
1904
+ if (appear.type === "slide in") {
1905
+ switch (appear.direction) {
1906
+ case "left":
1907
+ return styles.slideOutLeft;
1908
+ case "right":
1909
+ return styles.slideOutRight;
1910
+ case "top":
1911
+ return styles.slideOutTop;
1912
+ case "bottom":
1913
+ return styles.slideOutBottom;
1914
+ default:
1915
+ return styles.slideOutRight;
1916
+ }
1917
+ }
1918
+ return styles.fadeOut;
1919
+ })();
1920
+ const disappearClass = (() => {
1921
+ if (appear.type === "fade in") return styles.fadeOut;
1922
+ if (appear.type === "slide in" || appear.type === "mix") {
1923
+ switch (appear.direction) {
1924
+ case "left":
1925
+ return styles.slideOutLeft;
1926
+ case "right":
1927
+ return styles.slideOutRight;
1928
+ case "top":
1929
+ return styles.slideOutTop;
1930
+ case "bottom":
1931
+ return styles.slideOutBottom;
1932
+ default:
1933
+ return styles.slideOutRight;
1934
+ }
1935
+ }
1936
+ return styles.fadeOut;
1937
+ })();
1938
+ React.useEffect(() => {
1939
+ if (!isOpen) return;
1940
+ const handleTouchEnd = (e) => {
1941
+ if (isClosingRef.current) {
1942
+ e.stopPropagation();
1943
+ return;
1944
+ }
1945
+ if (e.touches.length === 0 && e.changedTouches.length > 0) {
1946
+ const currentImage = content[currentIndex];
1947
+ const isCover = (currentImage == null ? void 0 : currentImage.image.objectFit) === "cover";
1948
+ const touch = e.changedTouches[0];
1949
+ let inside;
1950
+ if (isCover && imageRef.current) {
1951
+ const imgRect = imageRef.current.getBoundingClientRect();
1952
+ inside = touch.clientX >= imgRect.left && touch.clientX <= imgRect.right && touch.clientY >= imgRect.top && touch.clientY <= imgRect.bottom;
1953
+ } else {
1954
+ const rect = imageRef.current ? getDisplayedImageRect(imageRef.current) : null;
1955
+ if (!rect) return;
1956
+ inside = touch.clientX >= rect.x && touch.clientX <= rect.x + rect.width && touch.clientY >= rect.y && touch.clientY <= rect.y + rect.height;
1957
+ }
1958
+ if (!inside) {
1959
+ e.stopPropagation();
1960
+ isClosingRef.current = true;
1961
+ const blockNextClick = (clickEvent) => {
1962
+ clickEvent.stopPropagation();
1963
+ clickEvent.preventDefault();
1964
+ document.removeEventListener("click", blockNextClick, true);
1965
+ };
1966
+ document.addEventListener("click", blockNextClick, true);
1967
+ handleClose();
1968
+ }
1969
+ }
1970
+ };
1971
+ document.addEventListener("touchend", handleTouchEnd, { passive: true });
1972
+ return () => {
1973
+ document.removeEventListener("touchend", handleTouchEnd);
1974
+ };
1975
+ }, [isOpen, handleClose, currentIndex, content]);
1976
+ if (!isOpen && !isClosing) return null;
1713
1977
  return reactDom.createPortal(
1714
- /* @__PURE__ */ jsxRuntime.jsx(
1715
- "div",
1716
- {
1717
- className: cn(styles.backdropStyle, backdropAppearClass, { [styles.editor]: isEditor }),
1718
- style: { backgroundColor: area.color, backdropFilter: `blur(${area.blur}px)`, animationDuration: `${backdropDurationMs}ms`, animationTimingFunction: "ease", animationFillMode: "both" },
1719
- onClick: handleBackdropClick,
1720
- children: /* @__PURE__ */ jsxRuntime.jsxs(
1721
- "div",
1722
- {
1723
- className: cn(styles.contentStyle, appearClass),
1724
- style: {
1725
- padding: `${layout.padding.top}px ${layout.padding.right}px ${layout.padding.bottom}px ${layout.padding.left}px`,
1726
- animationDuration: `${appearDurationMs}ms`,
1727
- animationTimingFunction: "ease",
1728
- animationFillMode: "both",
1729
- ...appear.type === "mix" && { animationDelay: `${backdropDurationMs}ms` },
1730
- "--splide-speed": triggers.duration || "500ms"
1731
- },
1732
- children: [
1733
- /* @__PURE__ */ jsxRuntime.jsx(
1734
- reactSplide.Splide,
1735
- {
1736
- onMove: (splide) => {
1737
- setCurrentIndex(splide.index);
1738
- },
1739
- ref: lightboxRef,
1740
- className: styles.lightboxSplide,
1741
- options: {
1742
- arrows: false,
1743
- speed: triggers.duration ? parseInt(triggers.duration) : 500,
1744
- direction: slider.direction === "horiz" || slider.type === "fade" || slider.type === "scale" ? "ltr" : "ttb",
1745
- pagination: false,
1746
- drag: triggers.type === "drag",
1747
- perPage: 1,
1748
- width: "100%",
1749
- height: "100%",
1750
- type: slider.type === "fade" || slider.type === "scale" ? "fade" : "loop",
1751
- padding: 0,
1752
- rewind: (slider.type === "scale" || slider.type === "fade") && appear.repeat !== "close"
1753
- },
1754
- style: { "--splide-speed": triggers.duration || "500ms" },
1755
- children: content.map((item, index) => {
1756
- const positionStyles = getPositionStyles(layout.position, layout.offset);
1757
- const imageStyle2 = slider.type === "scale" ? (() => {
1758
- const { transform, ...restStyles } = positionStyles;
1759
- return {
1760
- ...restStyles,
1761
- "--position-transform": transform || "none"
1762
- };
1763
- })() : positionStyles;
1764
- return /* @__PURE__ */ jsxRuntime.jsx(reactSplide.SplideSlide, { children: /* @__PURE__ */ jsxRuntime.jsx(
1765
- "div",
1766
- {
1767
- className: styles.imgWrapper,
1768
- onClick: handleImageWrapperClick,
1769
- style: {
1770
- padding: `${layout.padding.top}px ${layout.padding.right}px ${layout.padding.bottom}px ${layout.padding.left}px`
1771
- },
1772
- children: /* @__PURE__ */ jsxRuntime.jsx(
1773
- "img",
1774
- {
1775
- className: cn(styles.imageStyle, {
1776
- [styles.contain]: item.image.objectFit === "contain",
1777
- [styles.cover]: item.image.objectFit === "cover",
1778
- [styles.scaleSlide]: slider.type === "scale"
1779
- }),
1780
- src: item.image.url,
1781
- alt: item.image.name ?? "",
1782
- onClick: onImageClick,
1783
- style: imageStyle2
1784
- }
1785
- )
1786
- }
1787
- ) }, index);
1788
- })
1789
- }
1790
- ),
1791
- controls.isActive && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1978
+ /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1979
+ /* @__PURE__ */ jsxRuntime.jsx(
1980
+ "div",
1981
+ {
1982
+ className: cn(styles.background, isClosing ? backdropDisappearClass : backdropAppearClass),
1983
+ style: {
1984
+ ...isEditor && { display: "none" },
1985
+ backgroundColor: area.color,
1986
+ backdropFilter: `blur(${area.blur}px)`,
1987
+ animationDuration: `${appearDurationMs}ms`,
1988
+ animationTimingFunction: "ease",
1989
+ animationFillMode: "both"
1990
+ }
1991
+ }
1992
+ ),
1993
+ /* @__PURE__ */ jsxRuntime.jsx(
1994
+ "div",
1995
+ {
1996
+ className: cn(styles.backdropStyle, { [styles.editor]: isEditor, [isClosing ? backdropDisappearClass : backdropAppearClass]: isEditor }),
1997
+ style: { ...isEditor && {
1998
+ backgroundColor: area.color,
1999
+ backdropFilter: `blur(${area.blur}px)`,
2000
+ animationDuration: `${appearDurationMs}ms`,
2001
+ animationTimingFunction: "ease",
2002
+ animationFillMode: "both"
2003
+ } },
2004
+ onClick: handleBackdropClick,
2005
+ onTouchEnd: handleBackdropClick,
2006
+ onTouchStart: handleBackdropClick,
2007
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
2008
+ "div",
2009
+ {
2010
+ ref: contentRef,
2011
+ className: cn(styles.contentStyle, isClosing ? disappearClass : appearClass),
2012
+ onClick: handleContentClick,
2013
+ style: {
2014
+ animationDuration: `${appearDurationMs}ms`,
2015
+ animationTimingFunction: "ease",
2016
+ animationFillMode: "both",
2017
+ ...appear.type === "mix" && !isClosing && { animationDelay: `${backdropDurationMs / 2}ms` },
2018
+ ...appear.type === "mix" && isClosing && { animationDelay: "0ms" }
2019
+ },
2020
+ children: [
1792
2021
  /* @__PURE__ */ jsxRuntime.jsx(
2022
+ reactSplide.Splide,
2023
+ {
2024
+ onMove: (splide) => {
2025
+ setCurrentIndex(splide.index);
2026
+ },
2027
+ ref: lightboxRef,
2028
+ className: styles.lightboxSplide,
2029
+ options: {
2030
+ arrows: false,
2031
+ speed: slider.duration ? parseInt(slider.duration) : 500,
2032
+ direction: slider.direction === "horiz" || slider.type === "fade" || slider.type === "scale" ? "ltr" : "ttb",
2033
+ pagination: false,
2034
+ drag: triggers.type === "drag",
2035
+ perPage: 1,
2036
+ width: "100%",
2037
+ height: "100%",
2038
+ type: slider.type === "fade" || slider.type === "scale" ? "fade" : "loop",
2039
+ padding: 0,
2040
+ rewind: (slider.type === "scale" || slider.type === "fade") && triggers.repeat === "loop"
2041
+ },
2042
+ style: { "--splide-speed": slider.duration || "500ms" },
2043
+ children: content.map((item, index) => {
2044
+ const positionStyles = getPositionStyles(layout.position, layout.offset, isEditor);
2045
+ const imageStyle2 = slider.type === "scale" ? (() => {
2046
+ const { transform, ...restStyles } = positionStyles;
2047
+ return {
2048
+ ...restStyles,
2049
+ "--position-transform": transform || "none"
2050
+ };
2051
+ })() : positionStyles;
2052
+ return /* @__PURE__ */ jsxRuntime.jsx(reactSplide.SplideSlide, { children: /* @__PURE__ */ jsxRuntime.jsx(
2053
+ "div",
2054
+ {
2055
+ className: styles.imgWrapper,
2056
+ onClick: handleImageWrapperClick,
2057
+ style: { padding: scalingValue(layout.padding.top, isEditor) + " " + scalingValue(layout.padding.right, isEditor) + " " + scalingValue(layout.padding.bottom, isEditor) + " " + scalingValue(layout.padding.left, isEditor) },
2058
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2059
+ "img",
2060
+ {
2061
+ ref: index === currentIndex ? imageRef : null,
2062
+ className: cn(styles.imageStyle, {
2063
+ [styles.contain]: item.image.objectFit === "contain",
2064
+ [styles.cover]: item.image.objectFit === "cover",
2065
+ [styles.scaleSlide]: slider.type === "scale"
2066
+ }),
2067
+ onClick: item.image.objectFit !== "contain" ? onImageClick : void 0,
2068
+ src: item.image.url,
2069
+ alt: item.image.name ?? "",
2070
+ style: {
2071
+ ...imageStyle2,
2072
+ ...item.image.objectFit === "contain" ? {
2073
+ pointerEvents: "none"
2074
+ } : {}
2075
+ }
2076
+ }
2077
+ )
2078
+ }
2079
+ ) }, index);
2080
+ })
2081
+ },
2082
+ splideKey
2083
+ ),
2084
+ controls.isActive && controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2085
+ /* @__PURE__ */ jsxRuntime.jsx(
2086
+ "div",
2087
+ {
2088
+ className: cn(styles.arrow, { [styles.arrowVertical]: slider.direction === "vert" }),
2089
+ style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
2090
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2091
+ "button",
2092
+ {
2093
+ className: styles.arrowInner,
2094
+ style: {
2095
+ 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"})`
2096
+ },
2097
+ onClick: (e) => {
2098
+ handleArrowClick("-1");
2099
+ },
2100
+ children: controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(
2101
+ SvgImage,
2102
+ {
2103
+ url: controls.arrowsImgUrl,
2104
+ fill: controls.color,
2105
+ hoverFill: controls.hover,
2106
+ className: cn(styles.arrowImg, styles.mirror)
2107
+ }
2108
+ )
2109
+ }
2110
+ )
2111
+ }
2112
+ ),
2113
+ /* @__PURE__ */ jsxRuntime.jsx(
2114
+ "div",
2115
+ {
2116
+ className: cn(styles.arrow, styles.nextArrow, { [styles.arrowVertical]: slider.direction === "vert" }),
2117
+ style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
2118
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2119
+ "button",
2120
+ {
2121
+ className: styles.arrowInner,
2122
+ style: {
2123
+ 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"})`
2124
+ },
2125
+ onClick: (e) => {
2126
+ handleArrowClick("+1");
2127
+ },
2128
+ "aria-label": "Next",
2129
+ children: controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(
2130
+ SvgImage,
2131
+ {
2132
+ url: controls.arrowsImgUrl,
2133
+ fill: controls.color,
2134
+ hoverFill: controls.hover,
2135
+ className: styles.arrowImg
2136
+ }
2137
+ )
2138
+ }
2139
+ )
2140
+ }
2141
+ )
2142
+ ] }),
2143
+ area.closeIconUrl && (() => {
2144
+ const positionStyles = getPositionStyles(area.closeIconAlign, area.closeIconOffset, isEditor);
2145
+ const scaleTransform = `scale(${area.closeIconScale})`;
2146
+ const combinedTransform = positionStyles.transform ? `${positionStyles.transform} ${scaleTransform}` : scaleTransform;
2147
+ return /* @__PURE__ */ jsxRuntime.jsx(
2148
+ "button",
2149
+ {
2150
+ className: styles.closeButton,
2151
+ style: {
2152
+ ...positionStyles,
2153
+ transform: combinedTransform
2154
+ },
2155
+ onClick: handleClose,
2156
+ children: /* @__PURE__ */ jsxRuntime.jsx(SvgImage, { url: area.closeIconUrl })
2157
+ }
2158
+ );
2159
+ })(),
2160
+ caption2.isActive && /* @__PURE__ */ jsxRuntime.jsx(
1793
2161
  "div",
1794
2162
  {
1795
- className: cn(styles.arrow, { [styles.arrowVertical]: slider.direction === "vert" }),
1796
- style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
2163
+ className: styles.caption,
2164
+ style: {
2165
+ ...getPositionStyles(caption2.alignment, caption2.offset, isEditor),
2166
+ fontFamily: fontSettings.fontFamily,
2167
+ fontWeight: fontSettings.fontWeight,
2168
+ fontStyle: fontSettings.fontStyle,
2169
+ width: widthSettings.sizing === "auto" ? "max-content" : scalingValue(widthSettings.width, isEditor),
2170
+ letterSpacing: scalingValue(letterSpacing, isEditor),
2171
+ wordSpacing: scalingValue(wordSpacing, isEditor),
2172
+ textAlign,
2173
+ fontSize: scalingValue(fontSizeLineHeight.fontSize, isEditor),
2174
+ lineHeight: scalingValue(fontSizeLineHeight.lineHeight, isEditor),
2175
+ textTransform: textAppearance.textTransform ?? "none",
2176
+ textDecoration: textAppearance.textDecoration ?? "none",
2177
+ fontVariant: textAppearance.fontVariant ?? "normal",
2178
+ color,
2179
+ transitionDuration: slider.duration ? `${Math.round(parseInt(slider.duration) / 2)}ms` : "500ms"
2180
+ },
2181
+ onClick: (e) => e.stopPropagation(),
1797
2182
  children: /* @__PURE__ */ jsxRuntime.jsx(
1798
- "button",
2183
+ "div",
1799
2184
  {
1800
- className: styles.arrowInner,
2185
+ "data-styles": "caption",
2186
+ className: styles.captionTextInner,
1801
2187
  style: {
1802
- transform: `translate(${scalingValue(controls.offset.x)}, ${scalingValue(controls.offset.y * (slider.direction === "horiz" ? 1 : -1))}) scale(${controls.scale}) rotate(${slider.direction === "horiz" ? "0deg" : "90deg"})`
1803
- },
1804
- onClick: (e) => {
1805
- handleArrowClick("-1");
2188
+ "--link-hover-color": caption2.hover,
2189
+ position: "relative"
1806
2190
  },
1807
- children: controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(
1808
- SvgImage,
1809
- {
1810
- url: controls.arrowsImgUrl,
1811
- fill: controls.color,
1812
- hoverFill: controls.hover,
1813
- className: cn(styles.arrowImg, styles.mirror)
1814
- }
1815
- )
2191
+ children: /* @__PURE__ */ jsxRuntime.jsx(RichTextRenderer, { content: content[currentIndex].imageCaption })
1816
2192
  }
1817
2193
  )
1818
2194
  }
1819
2195
  ),
1820
- /* @__PURE__ */ jsxRuntime.jsx(
2196
+ thumbnail.isActive && /* @__PURE__ */ jsxRuntime.jsx(
1821
2197
  "div",
1822
2198
  {
1823
- className: cn(styles.arrow, styles.nextArrow, { [styles.arrowVertical]: slider.direction === "vert" }),
1824
- style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
1825
- children: /* @__PURE__ */ jsxRuntime.jsx(
1826
- "button",
2199
+ className: cn(
2200
+ styles.thumbsContainer,
1827
2201
  {
1828
- className: styles.arrowInner,
1829
- style: {
1830
- transform: `translate(${scalingValue(controls.offset.x * (slider.direction === "horiz" ? -1 : 1))}, ${scalingValue(controls.offset.y)}) scale(${controls.scale}) rotate(${slider.direction === "horiz" ? "0deg" : "90deg"})`
1831
- },
1832
- onClick: (e) => {
1833
- handleArrowClick("+1");
1834
- },
1835
- "aria-label": "Next",
1836
- children: controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(
1837
- SvgImage,
1838
- {
1839
- url: controls.arrowsImgUrl,
1840
- fill: controls.color,
1841
- hoverFill: controls.hover,
1842
- className: styles.arrowImg
1843
- }
1844
- )
2202
+ [styles.thumbsContainerVertical]: slider.direction === "vert",
2203
+ [styles.thumbsAlignStart]: thumbnail.align === "start",
2204
+ [styles.thumbsAlignCenter]: thumbnail.align === "center",
2205
+ [styles.thumbsAlignEnd]: thumbnail.align === "end"
1845
2206
  }
1846
- )
1847
- }
1848
- )
1849
- ] }),
1850
- area.closeIconUrl && (() => {
1851
- const positionStyles = getPositionStyles(area.closeIconAlign, area.closeIconOffset);
1852
- const scaleTransform = `scale(${area.closeIconScale})`;
1853
- const combinedTransform = positionStyles.transform ? `${positionStyles.transform} ${scaleTransform}` : scaleTransform;
1854
- return /* @__PURE__ */ jsxRuntime.jsx(
1855
- "button",
1856
- {
1857
- className: styles.closeButton,
2207
+ ),
1858
2208
  style: {
1859
- ...positionStyles,
1860
- transform: combinedTransform
2209
+ gap: `${scalingValue(thumbnail.grid.gap, isEditor)}`,
2210
+ ...getPositionStyles(thumbnail.position, thumbnail.offset, isEditor)
1861
2211
  },
1862
- onClick: onClose,
1863
- children: /* @__PURE__ */ jsxRuntime.jsx(SvgImage, { url: area.closeIconUrl })
1864
- }
1865
- );
1866
- })(),
1867
- caption2.isActive && /* @__PURE__ */ jsxRuntime.jsx(
1868
- "div",
1869
- {
1870
- className: styles.caption,
1871
- style: {
1872
- ...getPositionStyles(caption2.alignment, caption2.offset),
1873
- ["--link-hover-color"]: caption2.hover
1874
- },
1875
- children: /* @__PURE__ */ jsxRuntime.jsx(RichTextRenderer, { content: content[currentIndex].imageCaption })
1876
- }
1877
- ),
1878
- thumbnail.isActive && /* @__PURE__ */ jsxRuntime.jsx(
1879
- "div",
1880
- {
1881
- className: cn(
1882
- styles.thumbsContainer,
1883
- {
1884
- [styles.thumbsContainerVertical]: slider.direction === "vert",
1885
- [styles.thumbsAlignStart]: thumbnail.align === "start",
1886
- [styles.thumbsAlignCenter]: thumbnail.align === "center",
1887
- [styles.thumbsAlignEnd]: thumbnail.align === "end"
1888
- }
1889
- ),
1890
- style: {
1891
- gap: `${thumbnail.grid.gap}px`,
1892
- ...slider.direction === "horiz" ? { height: `${thumbnail.grid.height}px` } : {},
1893
- ...slider.direction === "vert" ? { width: `${thumbnail.grid.width}px` } : {},
1894
- ...getPositionStyles(thumbnail.position, thumbnail.offset)
1895
- },
1896
- children: content.map((item, index) => {
1897
- const isActive = index === currentIndex;
1898
- return /* @__PURE__ */ jsxRuntime.jsx(
1899
- "button",
1900
- {
1901
- className: styles.thumbItem,
1902
- style: {
1903
- transform: `scale(${isActive ? thumbnail.activeState.scale : 1})`,
1904
- ...slider.direction === "horiz" ? { height: "100%" } : {},
1905
- ...slider.direction === "vert" ? { width: "100%" } : {},
1906
- opacity: isActive ? thumbnail.activeState.opacity : thumbnail.opacity,
1907
- ["--thumb-hover"]: thumbnail.activeState.opacity
1908
- },
1909
- onClick: (e) => {
1910
- var _a;
1911
- e.stopPropagation();
1912
- setCurrentIndex(index);
1913
- (_a = lightboxRef.current) == null ? void 0 : _a.go(index);
1914
- },
1915
- children: /* @__PURE__ */ jsxRuntime.jsx(
1916
- "img",
1917
- {
1918
- src: item.image.url,
1919
- alt: item.image.name ?? "",
1920
- className: styles.thumbImage,
1921
- style: {
1922
- objectFit: thumbnail.fit === "cover" ? "cover" : "contain",
1923
- ...slider.direction === "horiz" ? { height: "100%" } : {},
1924
- ...slider.direction === "vert" ? { width: "100%" } : {}
2212
+ children: content.map((item, index) => {
2213
+ const isActive = index === currentIndex;
2214
+ return /* @__PURE__ */ jsxRuntime.jsx(
2215
+ "button",
2216
+ {
2217
+ className: styles.thumbItem,
2218
+ style: {
2219
+ ...slider.direction === "horiz" ? { height: isActive ? `${scalingValue(thumbnail.grid.height * (isActive ? thumbnail.activeState.scale : 1), isEditor)}` : `${scalingValue(thumbnail.grid.height, isEditor)}` } : {},
2220
+ ...slider.direction === "vert" ? { width: isActive ? `${scalingValue(thumbnail.grid.width * (isActive ? thumbnail.activeState.scale : 1), isEditor)}` : `${scalingValue(thumbnail.grid.width, isEditor)}` } : {},
2221
+ ...thumbnail.fit === "cover" && slider.direction === "horiz" ? { width: isActive ? `${scalingValue(thumbnail.grid.width * (isActive ? thumbnail.activeState.scale : 1), isEditor)}` : `${scalingValue(thumbnail.grid.width, isEditor)}` } : {},
2222
+ ...thumbnail.fit === "cover" && slider.direction === "vert" ? { height: isActive ? `${scalingValue(thumbnail.grid.height * (isActive ? thumbnail.activeState.scale : 1), isEditor)}` : `${scalingValue(thumbnail.grid.height, isEditor)}` } : {},
2223
+ transition: isActive ? "all 0.2s ease" : "none",
2224
+ opacity: isActive ? thumbnail.activeState.opacity / 100 : thumbnail.opacity / 100,
2225
+ ["--thumb-hover"]: thumbnail.activeState.opacity / 100
2226
+ },
2227
+ onClick: (e) => {
2228
+ var _a;
2229
+ e.stopPropagation();
2230
+ setCurrentIndex(index);
2231
+ (_a = lightboxRef.current) == null ? void 0 : _a.go(index);
2232
+ },
2233
+ onMouseEnter: () => {
2234
+ var _a;
2235
+ if (thumbnail.triggers === "hov") {
2236
+ (_a = lightboxRef.current) == null ? void 0 : _a.go(index);
1925
2237
  }
1926
- }
1927
- )
1928
- },
1929
- `${item.image.url}-${index}`
1930
- );
1931
- })
1932
- }
1933
- )
1934
- ]
1935
- }
1936
- )
1937
- }
1938
- ),
2238
+ },
2239
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2240
+ "img",
2241
+ {
2242
+ src: item.image.url,
2243
+ alt: item.image.name ?? "",
2244
+ style: {
2245
+ objectFit: thumbnail.fit === "cover" ? "cover" : "contain",
2246
+ ...thumbnail.fit === "fit" ? { maxWidth: "100%", maxHeight: "100%", objectFit: "contain" } : {},
2247
+ ...thumbnail.fit === "cover" && slider.direction === "horiz" ? { width: "100%", height: "100%" } : {}
2248
+ }
2249
+ }
2250
+ )
2251
+ },
2252
+ `${item.image.url}-${index}`
2253
+ );
2254
+ })
2255
+ }
2256
+ )
2257
+ ]
2258
+ }
2259
+ )
2260
+ }
2261
+ )
2262
+ ] }),
1939
2263
  document.getElementById(portalId)
1940
2264
  );
1941
2265
  };
2266
+ const getColorAlpha = (color) => {
2267
+ const rgbaMatch = color.match(/rgba?\(([^)]+)\)/);
2268
+ if (rgbaMatch) {
2269
+ const values = rgbaMatch[1].split(",").map((v) => parseFloat(v.trim()));
2270
+ if (values.length === 4) {
2271
+ return values[3];
2272
+ }
2273
+ return 1;
2274
+ }
2275
+ const hexMatch = color.match(/^#([0-9a-fA-F]{8})$/);
2276
+ if (hexMatch) {
2277
+ const alphaHex = hexMatch[1].substring(6, 8);
2278
+ return parseInt(alphaHex, 16) / 255;
2279
+ }
2280
+ if (color.match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/)) {
2281
+ return 1;
2282
+ }
2283
+ return 1;
2284
+ };
1942
2285
  const LightboxComponent = {
1943
2286
  element: LightboxGallery,
1944
2287
  id: "lightbox",
1945
2288
  name: "Lightbox",
1946
2289
  preview: {
1947
2290
  type: "video",
1948
- url: "https://cdn.cntrl.site/projects/01GJ2SPDSH73MC92WW7ZA2CWBY/articles-assets/01KA24CHYZXJBZ0Q714B05A7VD.mp4"
2291
+ url: "https://cdn.cntrl.site/component-assets/lightbox.mp4"
1949
2292
  },
1950
2293
  defaultSize: {
1951
- width: 400,
1952
- height: 400
2294
+ width: 440,
2295
+ height: 550
1953
2296
  },
1954
2297
  schema: {
1955
2298
  type: "object",
@@ -1974,7 +2317,7 @@ const LightboxComponent = {
1974
2317
  url: {
1975
2318
  type: "string",
1976
2319
  display: {
1977
- type: "settings-image-input"
2320
+ type: "cover-image-input"
1978
2321
  }
1979
2322
  }
1980
2323
  }
@@ -2016,14 +2359,6 @@ const LightboxComponent = {
2016
2359
  type: "direction-control"
2017
2360
  },
2018
2361
  enum: ["top", "left", "right", "bottom"]
2019
- },
2020
- repeat: {
2021
- type: "string",
2022
- title: "Repeat",
2023
- display: {
2024
- type: "ratio-group"
2025
- },
2026
- enum: ["close", "loop"]
2027
2362
  }
2028
2363
  }
2029
2364
  },
@@ -2047,13 +2382,14 @@ const LightboxComponent = {
2047
2382
  },
2048
2383
  enum: ["image", "50/50"]
2049
2384
  },
2050
- duration: {
2385
+ repeat: {
2051
2386
  type: "string",
2052
- label: "T",
2387
+ title: "Repeat",
2053
2388
  display: {
2054
- type: "step-selector"
2389
+ visible: false,
2390
+ type: "ratio-group"
2055
2391
  },
2056
- enum: ["100ms", "250ms", "500ms", "1000ms", "1500ms", "2000ms"]
2392
+ enum: ["close", "loop"]
2057
2393
  }
2058
2394
  }
2059
2395
  },
@@ -2076,6 +2412,14 @@ const LightboxComponent = {
2076
2412
  type: "ratio-group"
2077
2413
  },
2078
2414
  enum: ["horiz", "vert"]
2415
+ },
2416
+ duration: {
2417
+ type: "string",
2418
+ label: "T",
2419
+ display: {
2420
+ type: "step-selector"
2421
+ },
2422
+ enum: ["100ms", "250ms", "500ms", "1000ms", "1500ms", "2000ms"]
2079
2423
  }
2080
2424
  }
2081
2425
  },
@@ -2133,13 +2477,16 @@ const LightboxComponent = {
2133
2477
  height: {
2134
2478
  type: "number",
2135
2479
  label: "H",
2480
+ scalingEnabled: true,
2136
2481
  display: {
2137
- type: "numeric-input"
2482
+ type: "numeric-input",
2483
+ visible: true
2138
2484
  }
2139
2485
  },
2140
2486
  width: {
2141
2487
  type: "number",
2142
2488
  label: "W",
2489
+ scalingEnabled: true,
2143
2490
  display: {
2144
2491
  type: "numeric-input",
2145
2492
  visible: false
@@ -2148,6 +2495,7 @@ const LightboxComponent = {
2148
2495
  gap: {
2149
2496
  type: "number",
2150
2497
  label: "Gap",
2498
+ scalingEnabled: true,
2151
2499
  display: {
2152
2500
  type: "numeric-input"
2153
2501
  }
@@ -2156,15 +2504,28 @@ const LightboxComponent = {
2156
2504
  },
2157
2505
  offset: {
2158
2506
  type: "object",
2507
+ title: "Offset",
2159
2508
  display: {
2160
- type: "offset-controls"
2509
+ type: "group"
2161
2510
  },
2162
2511
  properties: {
2163
2512
  x: {
2164
- type: "number"
2513
+ type: "number",
2514
+ label: "X",
2515
+ scalingEnabled: true,
2516
+ display: {
2517
+ type: "numeric-input",
2518
+ visible: true
2519
+ }
2165
2520
  },
2166
2521
  y: {
2167
- type: "number"
2522
+ type: "number",
2523
+ label: "Y",
2524
+ scalingEnabled: true,
2525
+ display: {
2526
+ type: "numeric-input",
2527
+ visible: true
2528
+ }
2168
2529
  }
2169
2530
  }
2170
2531
  },
@@ -2189,7 +2550,7 @@ const LightboxComponent = {
2189
2550
  scale: {
2190
2551
  type: "number",
2191
2552
  title: "Scale",
2192
- min: 0.5,
2553
+ min: 1,
2193
2554
  max: 5,
2194
2555
  step: 0.1,
2195
2556
  display: {
@@ -2226,15 +2587,28 @@ const LightboxComponent = {
2226
2587
  },
2227
2588
  offset: {
2228
2589
  type: "object",
2590
+ title: "Offset",
2229
2591
  display: {
2230
- type: "offset-controls"
2592
+ type: "group"
2231
2593
  },
2232
2594
  properties: {
2233
2595
  x: {
2234
- type: "number"
2596
+ type: "number",
2597
+ label: "X",
2598
+ scalingEnabled: true,
2599
+ display: {
2600
+ type: "numeric-input",
2601
+ visible: true
2602
+ }
2235
2603
  },
2236
2604
  y: {
2237
- type: "number"
2605
+ type: "number",
2606
+ label: "Y",
2607
+ scalingEnabled: true,
2608
+ display: {
2609
+ type: "numeric-input",
2610
+ visible: true
2611
+ }
2238
2612
  }
2239
2613
  }
2240
2614
  },
@@ -2246,15 +2620,23 @@ const LightboxComponent = {
2246
2620
  },
2247
2621
  properties: {
2248
2622
  top: {
2623
+ min: 0,
2624
+ step: 1,
2249
2625
  type: "number"
2250
2626
  },
2251
2627
  left: {
2628
+ min: 0,
2629
+ step: 1,
2252
2630
  type: "number"
2253
2631
  },
2254
2632
  right: {
2633
+ min: 0,
2634
+ step: 1,
2255
2635
  type: "number"
2256
2636
  },
2257
2637
  bottom: {
2638
+ min: 0,
2639
+ step: 1,
2258
2640
  type: "number"
2259
2641
  }
2260
2642
  }
@@ -2280,16 +2662,29 @@ const LightboxComponent = {
2280
2662
  }
2281
2663
  },
2282
2664
  offset: {
2665
+ title: "Offset",
2283
2666
  type: "object",
2284
2667
  display: {
2285
- type: "offset-controls"
2668
+ type: "group"
2286
2669
  },
2287
2670
  properties: {
2288
2671
  x: {
2289
- type: "number"
2672
+ type: "number",
2673
+ label: "X",
2674
+ scalingEnabled: true,
2675
+ display: {
2676
+ type: "numeric-input",
2677
+ visible: true
2678
+ }
2290
2679
  },
2291
2680
  y: {
2292
- type: "number"
2681
+ type: "number",
2682
+ label: "Y",
2683
+ scalingEnabled: true,
2684
+ display: {
2685
+ type: "numeric-input",
2686
+ visible: true
2687
+ }
2293
2688
  }
2294
2689
  }
2295
2690
  },
@@ -2368,15 +2763,28 @@ const LightboxComponent = {
2368
2763
  },
2369
2764
  closeIconOffset: {
2370
2765
  type: "object",
2766
+ title: "Offset",
2371
2767
  display: {
2372
- type: "offset-controls"
2768
+ type: "group"
2373
2769
  },
2374
2770
  properties: {
2375
2771
  x: {
2376
- type: "number"
2772
+ type: "number",
2773
+ label: "X",
2774
+ scalingEnabled: true,
2775
+ display: {
2776
+ type: "numeric-input",
2777
+ visible: true
2778
+ }
2377
2779
  },
2378
2780
  y: {
2379
- type: "number"
2781
+ type: "number",
2782
+ label: "Y",
2783
+ scalingEnabled: true,
2784
+ display: {
2785
+ type: "numeric-input",
2786
+ visible: true
2787
+ }
2380
2788
  }
2381
2789
  }
2382
2790
  }
@@ -2402,16 +2810,29 @@ const LightboxComponent = {
2402
2810
  enum: ["top-left", "top-center", "top-right", "middle-left", "middle-center", "middle-right", "bottom-left", "bottom-center", "bottom-right"]
2403
2811
  },
2404
2812
  offset: {
2813
+ title: "Offset",
2405
2814
  type: "object",
2406
2815
  display: {
2407
- type: "offset-controls"
2816
+ type: "group"
2408
2817
  },
2409
2818
  properties: {
2410
2819
  x: {
2411
- type: "number"
2820
+ type: "number",
2821
+ label: "X",
2822
+ scalingEnabled: true,
2823
+ display: {
2824
+ type: "numeric-input",
2825
+ visible: true
2826
+ }
2412
2827
  },
2413
2828
  y: {
2414
- type: "number"
2829
+ type: "number",
2830
+ label: "Y",
2831
+ scalingEnabled: true,
2832
+ display: {
2833
+ type: "numeric-input",
2834
+ visible: true
2835
+ }
2415
2836
  }
2416
2837
  }
2417
2838
  },
@@ -2431,38 +2852,38 @@ const LightboxComponent = {
2431
2852
  default: {
2432
2853
  thumbnailBlock: {
2433
2854
  cover: {
2434
- url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K7ERMHNP08T27H1649S67NZV.png"
2855
+ url: "https://cdn.cntrl.site/component-assets/Cover.jpg"
2435
2856
  }
2436
2857
  },
2437
2858
  lightboxBlock: {
2438
2859
  appear: {
2439
- type: "slide in",
2860
+ type: "fade in",
2440
2861
  duration: "1000ms",
2441
- direction: "right",
2442
- repeat: "close"
2862
+ direction: "right"
2443
2863
  },
2444
2864
  triggers: {
2445
2865
  type: "click",
2446
- switch: "image",
2447
- duration: "2000ms"
2866
+ switch: "50/50",
2867
+ repeat: "loop"
2448
2868
  },
2449
2869
  slider: {
2450
- type: "fade",
2451
- direction: "horiz"
2870
+ type: "slide",
2871
+ direction: "horiz",
2872
+ duration: "1000ms"
2452
2873
  },
2453
2874
  thumbnail: {
2454
2875
  isActive: true,
2455
2876
  position: "bottom-center",
2456
- fit: "cover",
2877
+ fit: "fit",
2457
2878
  align: "center",
2458
2879
  triggers: "clk",
2459
2880
  grid: {
2460
- height: 60,
2461
- width: 60,
2462
- gap: 8
2881
+ height: 0.03,
2882
+ width: 0.03,
2883
+ gap: 8e-3
2463
2884
  },
2464
2885
  offset: { x: 0, y: 0 },
2465
- opacity: 100,
2886
+ opacity: 80,
2466
2887
  activeState: {
2467
2888
  scale: 1,
2468
2889
  opacity: 100
@@ -2471,7 +2892,7 @@ const LightboxComponent = {
2471
2892
  layout: {
2472
2893
  position: "middle-center",
2473
2894
  offset: { x: 0, y: 0 },
2474
- padding: { top: 0, right: 0, bottom: 0, left: 0 }
2895
+ padding: { top: 0.04, right: 0, bottom: 0.04, left: 0 }
2475
2896
  },
2476
2897
  controls: {
2477
2898
  isActive: true,
@@ -2482,7 +2903,7 @@ const LightboxComponent = {
2482
2903
  hover: "#cccccc"
2483
2904
  },
2484
2905
  area: {
2485
- color: "rgba(0,0,0,0.9)",
2906
+ color: "rgba(64,67,71,0.9)",
2486
2907
  blur: 0,
2487
2908
  closeIconUrl: null,
2488
2909
  closeIconAlign: "top-right",
@@ -2514,7 +2935,7 @@ const LightboxComponent = {
2514
2935
  value: "vert"
2515
2936
  },
2516
2937
  then: {
2517
- name: "properties.lightboxBlock.properties.thumbnail.properties.position.display.direction",
2938
+ name: "properties.lightboxBlock.properties.thumbnail.properties.align.display.direction",
2518
2939
  value: "vertical"
2519
2940
  }
2520
2941
  },
@@ -2579,44 +3000,14 @@ const LightboxComponent = {
2579
3000
  }
2580
3001
  },
2581
3002
  {
2582
- if: {
2583
- name: "lightboxBlock.triggers.type",
2584
- value: "click"
2585
- },
2586
- then: {
2587
- name: "properties.lightboxBlock.properties.triggers.properties.duration.display.visible",
2588
- value: true
2589
- }
2590
- },
2591
- {
2592
- if: {
2593
- name: "lightboxBlock.triggers.type",
2594
- value: "click"
2595
- },
3003
+ if: [
3004
+ { name: "lightboxBlock.triggers.type", value: "click" },
3005
+ { name: "lightboxBlock.triggers.switch", value: "image" }
3006
+ ],
2596
3007
  then: {
2597
- name: "properties.lightboxBlock.properties.triggers.properties.switch.display.visible",
3008
+ name: "properties.lightboxBlock.properties.triggers.properties.repeat.display.visible",
2598
3009
  value: true
2599
3010
  }
2600
- },
2601
- {
2602
- if: {
2603
- name: "lightboxBlock.triggers.type",
2604
- value: "drag"
2605
- },
2606
- then: {
2607
- name: "properties.lightboxBlock.properties.triggers.properties.duration.display.visible",
2608
- value: false
2609
- }
2610
- },
2611
- {
2612
- if: {
2613
- name: "lightboxBlock.triggers.type",
2614
- value: "drag"
2615
- },
2616
- then: {
2617
- name: "properties.lightboxBlock.properties.triggers.properties.switch.display.visible",
2618
- value: false
2619
- }
2620
3011
  }
2621
3012
  ]
2622
3013
  },
@@ -2668,7 +3059,7 @@ const LightboxComponent = {
2668
3059
  {
2669
3060
  image: {
2670
3061
  objectFit: "contain",
2671
- url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K7ERMHNP08T27H1649S67NZV.png",
3062
+ url: "https://cdn.cntrl.site/component-assets/2.jpg",
2672
3063
  name: "Slider-1.png"
2673
3064
  },
2674
3065
  imageCaption: [
@@ -2681,7 +3072,7 @@ const LightboxComponent = {
2681
3072
  {
2682
3073
  image: {
2683
3074
  objectFit: "contain",
2684
- url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K7ERMTZA3RYMXKF0M095D6JD.png",
3075
+ url: "https://cdn.cntrl.site/component-assets/3.jpg",
2685
3076
  name: "Slider-2.png"
2686
3077
  },
2687
3078
  imageCaption: [
@@ -2694,7 +3085,7 @@ const LightboxComponent = {
2694
3085
  {
2695
3086
  image: {
2696
3087
  objectFit: "contain",
2697
- url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K7ERMVSCMPVJBG2WF5KJZYHZ.png",
3088
+ url: "https://cdn.cntrl.site/component-assets/4.jpg",
2698
3089
  name: "Slider-3.png"
2699
3090
  },
2700
3091
  imageCaption: [