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

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
@@ -1,5 +1,5 @@
1
1
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
- import React, { useState, useEffect, useRef, useMemo } from "react";
2
+ import React, { useState, useEffect, useRef, useMemo, useCallback } from "react";
3
3
  import { Splide, SplideSlide } from "@splidejs/react-splide";
4
4
  import cn from "classnames";
5
5
  import { createPortal } from "react-dom";
@@ -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,6 +1479,7 @@ const ControlImageRevealSliderComponent = {
1441
1479
  }
1442
1480
  }
1443
1481
  };
1482
+ const background = "Lightbox-module__background___wf1Ii";
1444
1483
  const backdropStyle = "Lightbox-module__backdropStyle___y7avj";
1445
1484
  const editor = "Lightbox-module__editor___Vh82D";
1446
1485
  const contentStyle = "Lightbox-module__contentStyle___FzFaW";
@@ -1462,15 +1501,20 @@ const thumbsAlignStart = "Lightbox-module__thumbsAlignStart___uiFIV";
1462
1501
  const thumbsAlignCenter = "Lightbox-module__thumbsAlignCenter___sbUPA";
1463
1502
  const thumbsAlignEnd = "Lightbox-module__thumbsAlignEnd___OA9N4";
1464
1503
  const thumbItem = "Lightbox-module__thumbItem___zROyu";
1465
- const thumbImage = "Lightbox-module__thumbImage___xGakV";
1466
1504
  const closeButton = "Lightbox-module__closeButton___r3Dur";
1467
1505
  const fadeIn = "Lightbox-module__fadeIn___sHwRK";
1468
1506
  const slideInLeft = "Lightbox-module__slideInLeft___P-XRo";
1469
1507
  const slideInRight = "Lightbox-module__slideInRight___ZQqFi";
1470
1508
  const slideInTop = "Lightbox-module__slideInTop___XRKCs";
1471
1509
  const slideInBottom = "Lightbox-module__slideInBottom___TYOBS";
1510
+ const fadeOut = "Lightbox-module__fadeOut___h2fpQ";
1511
+ const slideOutLeft = "Lightbox-module__slideOutLeft___J-eMU";
1512
+ const slideOutRight = "Lightbox-module__slideOutRight___iZUQz";
1513
+ const slideOutTop = "Lightbox-module__slideOutTop___3TXF9";
1514
+ const slideOutBottom = "Lightbox-module__slideOutBottom___SB5ws";
1472
1515
  const scaleSlide = "Lightbox-module__scaleSlide___wS7d4";
1473
1516
  const styles = {
1517
+ background,
1474
1518
  backdropStyle,
1475
1519
  editor,
1476
1520
  contentStyle,
@@ -1492,16 +1536,20 @@ const styles = {
1492
1536
  thumbsAlignCenter,
1493
1537
  thumbsAlignEnd,
1494
1538
  thumbItem,
1495
- thumbImage,
1496
1539
  closeButton,
1497
1540
  fadeIn,
1498
1541
  slideInLeft,
1499
1542
  slideInRight,
1500
1543
  slideInTop,
1501
1544
  slideInBottom,
1545
+ fadeOut,
1546
+ slideOutLeft,
1547
+ slideOutRight,
1548
+ slideOutTop,
1549
+ slideOutBottom,
1502
1550
  scaleSlide
1503
1551
  };
1504
- const getPositionStyles = (position, offset) => {
1552
+ const getPositionStyles = (position, offset, isEditor) => {
1505
1553
  const styles2 = {};
1506
1554
  const [vertical, horizontal] = position.split("-");
1507
1555
  if (vertical === "top") {
@@ -1525,16 +1573,41 @@ const getPositionStyles = (position, offset) => {
1525
1573
  styles2.right = "0";
1526
1574
  }
1527
1575
  if (vertical === "middle" && horizontal === "center") {
1528
- styles2.transform = `translate(calc(-50% + ${offset.x}px), calc(-50% + ${offset.y}px))`;
1576
+ styles2.transform = `translate(calc(-50% + ${scalingValue(offset.x, isEditor)}), calc(-50% + ${scalingValue(offset.y, isEditor)}))`;
1529
1577
  } else if (vertical === "middle") {
1530
- styles2.transform = `translate(${offset.x}px, calc(-50% + ${offset.y}px))`;
1578
+ styles2.transform = `translate(${scalingValue(offset.x, isEditor)}, calc(-50% + ${scalingValue(offset.y, isEditor)}))`;
1531
1579
  } else if (horizontal === "center") {
1532
- styles2.transform = `translate(calc(-50% + ${offset.x}px), ${offset.y}px)`;
1580
+ styles2.transform = `translate(calc(-50% + ${scalingValue(offset.x, isEditor)}), ${scalingValue(offset.y, isEditor)})`;
1533
1581
  } else {
1534
- styles2.transform = `translate(${offset.x}px, ${offset.y}px)`;
1582
+ styles2.transform = `translate(${scalingValue(offset.x, isEditor)}, ${scalingValue(offset.y, isEditor)})`;
1535
1583
  }
1536
1584
  return styles2;
1537
1585
  };
1586
+ function getDisplayedImageRect(img2) {
1587
+ const container = img2.getBoundingClientRect();
1588
+ const containerW = container.width;
1589
+ const containerH = container.height;
1590
+ const imgW = img2.naturalWidth;
1591
+ const imgH = img2.naturalHeight;
1592
+ const containerRatio = containerW / containerH;
1593
+ const imgRatio = imgW / imgH;
1594
+ let renderedW, renderedH;
1595
+ if (imgRatio > containerRatio) {
1596
+ renderedW = containerW;
1597
+ renderedH = containerW / imgRatio;
1598
+ } else {
1599
+ renderedH = containerH;
1600
+ renderedW = containerH * imgRatio;
1601
+ }
1602
+ const offsetX = (containerW - renderedW) / 2 + container.left;
1603
+ const offsetY = (containerH - renderedH) / 2 + container.top;
1604
+ return {
1605
+ x: offsetX,
1606
+ y: offsetY,
1607
+ width: renderedW,
1608
+ height: renderedH
1609
+ };
1610
+ }
1538
1611
  function LightboxGallery({ settings, content, styles: styles2, portalId, activeEvent, isEditor }) {
1539
1612
  const [open, setOpen] = React.useState(false);
1540
1613
  const { url } = settings.thumbnailBlock.cover;
@@ -1556,54 +1629,133 @@ function LightboxGallery({ settings, content, styles: styles2, portalId, activeE
1556
1629
  onClick: () => setOpen(true)
1557
1630
  }
1558
1631
  ),
1559
- /* @__PURE__ */ jsx(Lightbox, { isOpen: open, onClose: () => setOpen(false), content, settings, portalId, isEditor })
1632
+ /* @__PURE__ */ jsx(Lightbox, { isOpen: open, onClose: () => setOpen(false), content, settings, styles: styles2, portalId, isEditor, activeEvent })
1560
1633
  ] });
1561
1634
  }
1562
- const Lightbox = ({ isOpen, onClose, content, settings, closeOnBackdropClick = true, closeOnEsc = true, portalId, isEditor }) => {
1635
+ const Lightbox = ({ isOpen, onClose, content, styles: lightboxStyles, settings, portalId, isEditor }) => {
1636
+ const { widthSettings, fontSettings, letterSpacing, textAlign, wordSpacing, fontSizeLineHeight, textAppearance, color } = lightboxStyles.caption;
1563
1637
  const [currentIndex, setCurrentIndex] = React.useState(0);
1638
+ const [splideKey, setSplideKey] = React.useState(0);
1639
+ const [isClosing, setIsClosing] = React.useState(false);
1564
1640
  const lightboxRef = useRef(null);
1565
- const resizeObserverRef = useRef(null);
1641
+ const prevSliderTypeRef = useRef(null);
1642
+ const imageRef = useRef(null);
1643
+ const isClosingRef = useRef(false);
1644
+ const contentRef = useRef(null);
1645
+ const animationEndHandlerRef = useRef(null);
1646
+ const appearAnimationEndHandlerRef = useRef(null);
1566
1647
  const { appear, triggers, slider, thumbnail, controls, area, caption: caption2, layout } = settings.lightboxBlock;
1648
+ const appearDurationMs = appear.duration ? parseInt(appear.duration) : 300;
1649
+ useEffect(() => {
1650
+ window.addEventListener("ArticleEditor.Layout:change", () => {
1651
+ var _a, _b;
1652
+ (_b = (_a = lightboxRef.current) == null ? void 0 : _a.splide) == null ? void 0 : _b.refresh();
1653
+ });
1654
+ return () => {
1655
+ window.removeEventListener("ArticleEditor.Layout:change", () => {
1656
+ var _a, _b;
1657
+ (_b = (_a = lightboxRef.current) == null ? void 0 : _a.splide) == null ? void 0 : _b.refresh();
1658
+ });
1659
+ };
1660
+ }, []);
1661
+ const handleClose = useCallback(() => {
1662
+ const isMobile = window.matchMedia("(max-width: 768px)").matches;
1663
+ const colorAlpha = getColorAlpha(area.color);
1664
+ if (isMobile && !isEditor && colorAlpha > 0.9) {
1665
+ document.body.style.backgroundColor = "";
1666
+ }
1667
+ setIsClosing(true);
1668
+ isClosingRef.current = true;
1669
+ const handleAnimationEnd = (e) => {
1670
+ if (e.target === contentRef.current && e.animationName) {
1671
+ if (contentRef.current && animationEndHandlerRef.current) {
1672
+ contentRef.current.removeEventListener("animationend", animationEndHandlerRef.current);
1673
+ }
1674
+ animationEndHandlerRef.current = null;
1675
+ onClose();
1676
+ setIsClosing(false);
1677
+ }
1678
+ };
1679
+ if (contentRef.current) {
1680
+ animationEndHandlerRef.current = handleAnimationEnd;
1681
+ contentRef.current.addEventListener("animationend", handleAnimationEnd);
1682
+ }
1683
+ }, [onClose, appearDurationMs, area.color, isEditor]);
1567
1684
  const handleBackdropClick = (e) => {
1568
- if (!closeOnBackdropClick) return;
1569
1685
  if (e.target === e.currentTarget) {
1570
- onClose();
1686
+ handleClose();
1571
1687
  }
1572
1688
  };
1573
1689
  const handleImageWrapperClick = (e) => {
1574
- if (!closeOnBackdropClick) return;
1575
- if (e.target === e.currentTarget) {
1576
- onClose();
1577
- }
1578
- };
1579
- const onImageClick = (e) => {
1580
1690
  var _a, _b;
1581
- if (triggers.type === "click" && triggers.switch === "image") {
1582
- e.stopPropagation();
1583
- (_a = lightboxRef.current) == null ? void 0 : _a.go("+1");
1691
+ const rect = imageRef.current ? getDisplayedImageRect(imageRef.current) : null;
1692
+ if (!rect) {
1693
+ if (e.target === e.currentTarget) {
1694
+ handleClose();
1695
+ }
1696
+ return;
1697
+ }
1698
+ let clientX;
1699
+ let clientY;
1700
+ if ("changedTouches" in e && e.changedTouches.length > 0) {
1701
+ clientX = e.changedTouches[0].clientX;
1702
+ clientY = e.changedTouches[0].clientY;
1703
+ } else if ("clientX" in e) {
1704
+ clientX = e.clientX;
1705
+ clientY = e.clientY;
1706
+ } else {
1707
+ return;
1584
1708
  }
1585
- if (triggers.type === "click" && triggers.switch === "50/50") {
1586
- e.stopPropagation();
1587
- const img2 = e.currentTarget;
1588
- const rect = img2.getBoundingClientRect();
1589
- const clickX = e.clientX - rect.left;
1590
- const clickY = e.clientY - rect.top;
1591
- const imgWidth = rect.width;
1592
- const imgHeight = rect.height;
1593
- let dir;
1594
- if (slider.direction === "horiz") {
1595
- dir = clickX < imgWidth / 2 ? "-1" : "+1";
1596
- } else {
1597
- dir = clickY < imgHeight / 2 ? "-1" : "+1";
1709
+ const inside = clientX >= rect.x && clientX <= rect.x + rect.width && clientY >= rect.y && clientY <= rect.y + rect.height;
1710
+ if (inside) {
1711
+ if (triggers.type === "click" && triggers.switch === "image") {
1712
+ if (triggers.repeat === "close" && currentIndex === content.length - 1) {
1713
+ handleClose();
1714
+ } else {
1715
+ (_a = lightboxRef.current) == null ? void 0 : _a.go("+1");
1716
+ }
1717
+ } else if (triggers.type === "click" && triggers.switch === "50/50") {
1718
+ const img2 = imageRef.current;
1719
+ if (img2) {
1720
+ const imgRect = img2.getBoundingClientRect();
1721
+ const clickX = clientX - imgRect.left;
1722
+ const clickY = clientY - imgRect.top;
1723
+ const imgWidth = imgRect.width;
1724
+ const imgHeight = imgRect.height;
1725
+ let dir;
1726
+ if (slider.direction === "horiz") {
1727
+ dir = clickX < imgWidth / 2 ? "-1" : "+1";
1728
+ } else {
1729
+ dir = clickY < imgHeight / 2 ? "-1" : "+1";
1730
+ }
1731
+ (_b = lightboxRef.current) == null ? void 0 : _b.go(dir);
1732
+ }
1598
1733
  }
1599
- (_b = lightboxRef.current) == null ? void 0 : _b.go(dir);
1734
+ } else {
1735
+ handleClose();
1736
+ }
1737
+ };
1738
+ const handleContentClick = (e) => {
1739
+ const target = e.target;
1740
+ const currentTarget = e.currentTarget;
1741
+ if (target === currentTarget) {
1742
+ handleClose();
1743
+ return;
1744
+ }
1745
+ const isImg = target.tagName === "IMG" || target.closest("img");
1746
+ const isButton = target.tagName === "BUTTON" || target.closest("button");
1747
+ const isSplide = target.closest(".splide") || target.closest('[class*="splide"]');
1748
+ const isCaption = target.closest(`.${styles.caption}`);
1749
+ const isThumbnail = target.closest(`.${styles.thumbsContainer}`);
1750
+ if (!isImg && !isButton && !isSplide && !isCaption && !isThumbnail) {
1751
+ handleClose();
1600
1752
  }
1601
1753
  };
1602
1754
  useEffect(() => {
1603
- if (!isOpen || !closeOnEsc) return;
1755
+ if (!isOpen) return;
1604
1756
  const onKeyDown = (event) => {
1605
1757
  if (event.key === "Escape") {
1606
- onClose();
1758
+ handleClose();
1607
1759
  return;
1608
1760
  }
1609
1761
  if (event.key === "ArrowRight") {
@@ -1618,58 +1770,62 @@ const Lightbox = ({ isOpen, onClose, content, settings, closeOnBackdropClick = t
1618
1770
  return () => {
1619
1771
  window.removeEventListener("keydown", onKeyDown);
1620
1772
  };
1621
- }, [isOpen, closeOnEsc, onClose, content.length]);
1773
+ }, [isOpen, handleClose, content.length]);
1622
1774
  useEffect(() => {
1623
- if (isOpen) setCurrentIndex(0);
1775
+ if (isOpen) {
1776
+ setCurrentIndex(0);
1777
+ isClosingRef.current = false;
1778
+ setIsClosing(false);
1779
+ }
1780
+ return () => {
1781
+ if (contentRef.current && animationEndHandlerRef.current) {
1782
+ contentRef.current.removeEventListener("animationend", animationEndHandlerRef.current);
1783
+ animationEndHandlerRef.current = null;
1784
+ }
1785
+ };
1624
1786
  }, [isOpen]);
1625
1787
  useEffect(() => {
1626
- if (!isOpen) return;
1627
- if (resizeObserverRef.current) {
1628
- resizeObserverRef.current.disconnect();
1629
- resizeObserverRef.current = null;
1788
+ if (prevSliderTypeRef.current !== null && prevSliderTypeRef.current !== slider.type) {
1789
+ setSplideKey((prev) => prev + 1);
1630
1790
  }
1631
- const timeoutId = setTimeout(() => {
1632
- const activeSlide = document.querySelector(".splide__slide.is-active");
1633
- if (!activeSlide) return;
1634
- const img2 = activeSlide.querySelector("img");
1635
- const container = activeSlide.querySelector(`.${styles.imgWrapper}`);
1636
- if (!img2 || !container) return;
1637
- const updateImageSize = () => {
1638
- if (!img2.naturalWidth || !img2.naturalHeight) return;
1639
- const imageAspectRatio = img2.naturalWidth / img2.naturalHeight;
1640
- const containerWidth = container.clientWidth;
1641
- const containerHeight = container.clientHeight;
1642
- const containerAspectRatio = containerWidth / containerHeight;
1643
- if (imageAspectRatio > containerAspectRatio) {
1644
- img2.style.width = "100%";
1645
- } else {
1646
- img2.style.height = "100%";
1791
+ prevSliderTypeRef.current = slider.type;
1792
+ }, [slider.type]);
1793
+ useEffect(() => {
1794
+ if (!isOpen) return;
1795
+ const originalOverflow = document.body.style.overflow;
1796
+ document.body.style.overflow = "hidden";
1797
+ const isMobile = window.matchMedia("(max-width: 768px)").matches;
1798
+ const colorAlpha = getColorAlpha(area.color);
1799
+ const handleAppearAnimationEnd = (e) => {
1800
+ if (e.target === contentRef.current && !isClosingRef.current && e.animationName) {
1801
+ if (isMobile && !isEditor && colorAlpha > 0.9) {
1802
+ document.body.style.backgroundColor = area.color;
1647
1803
  }
1648
- };
1649
- if (img2.complete) {
1650
- updateImageSize();
1651
- } else {
1652
- img2.onload = updateImageSize;
1804
+ if (contentRef.current && appearAnimationEndHandlerRef.current) {
1805
+ contentRef.current.removeEventListener("animationend", appearAnimationEndHandlerRef.current);
1806
+ }
1807
+ appearAnimationEndHandlerRef.current = null;
1653
1808
  }
1654
- resizeObserverRef.current = new ResizeObserver(() => {
1655
- updateImageSize();
1656
- });
1657
- resizeObserverRef.current.observe(container);
1658
- resizeObserverRef.current.observe(img2);
1659
- }, 0);
1809
+ };
1810
+ if (contentRef.current && isMobile && !isEditor && colorAlpha > 0.9) {
1811
+ appearAnimationEndHandlerRef.current = handleAppearAnimationEnd;
1812
+ contentRef.current.addEventListener("animationend", handleAppearAnimationEnd);
1813
+ }
1814
+ const preventScroll = (e) => e.preventDefault();
1815
+ document.addEventListener("touchmove", preventScroll, { passive: false });
1660
1816
  return () => {
1661
- clearTimeout(timeoutId);
1662
- if (resizeObserverRef.current) {
1663
- resizeObserverRef.current.disconnect();
1664
- resizeObserverRef.current = null;
1817
+ document.body.style.overflow = originalOverflow;
1818
+ document.removeEventListener("touchmove", preventScroll);
1819
+ if (contentRef.current && appearAnimationEndHandlerRef.current) {
1820
+ contentRef.current.removeEventListener("animationend", appearAnimationEndHandlerRef.current);
1821
+ appearAnimationEndHandlerRef.current = null;
1665
1822
  }
1666
1823
  };
1667
- }, [isOpen, currentIndex, content]);
1824
+ }, [isOpen, area.color, isEditor]);
1668
1825
  const handleArrowClick = (dir) => {
1669
1826
  var _a;
1670
1827
  (_a = lightboxRef.current) == null ? void 0 : _a.go(dir);
1671
1828
  };
1672
- const appearDurationMs = appear.duration ? parseInt(appear.duration) : 300;
1673
1829
  const backdropDurationMs = appear.type === "fade in" || appear.type === "mix" ? Math.floor(appearDurationMs * 0.7) : appearDurationMs;
1674
1830
  const appearClass = (() => {
1675
1831
  if (appear.type === "fade in") return styles.fadeIn;
@@ -1707,247 +1863,392 @@ const Lightbox = ({ isOpen, onClose, content, settings, closeOnBackdropClick = t
1707
1863
  }
1708
1864
  return styles.fadeIn;
1709
1865
  })();
1710
- if (!isOpen) return null;
1866
+ const backdropDisappearClass = (() => {
1867
+ if (appear.type === "fade in" || appear.type === "mix") return styles.fadeOut;
1868
+ if (appear.type === "slide in") {
1869
+ switch (appear.direction) {
1870
+ case "left":
1871
+ return styles.slideOutLeft;
1872
+ case "right":
1873
+ return styles.slideOutRight;
1874
+ case "top":
1875
+ return styles.slideOutTop;
1876
+ case "bottom":
1877
+ return styles.slideOutBottom;
1878
+ default:
1879
+ return styles.slideOutRight;
1880
+ }
1881
+ }
1882
+ return styles.fadeOut;
1883
+ })();
1884
+ const disappearClass = (() => {
1885
+ if (appear.type === "fade in") return styles.fadeOut;
1886
+ if (appear.type === "slide in" || appear.type === "mix") {
1887
+ switch (appear.direction) {
1888
+ case "left":
1889
+ return styles.slideOutLeft;
1890
+ case "right":
1891
+ return styles.slideOutRight;
1892
+ case "top":
1893
+ return styles.slideOutTop;
1894
+ case "bottom":
1895
+ return styles.slideOutBottom;
1896
+ default:
1897
+ return styles.slideOutRight;
1898
+ }
1899
+ }
1900
+ return styles.fadeOut;
1901
+ })();
1902
+ useEffect(() => {
1903
+ if (!isOpen) return;
1904
+ const handleTouchEnd = (e) => {
1905
+ if (isClosingRef.current) {
1906
+ e.stopPropagation();
1907
+ return;
1908
+ }
1909
+ if (e.touches.length === 0 && e.changedTouches.length > 0) {
1910
+ const rect = imageRef.current ? getDisplayedImageRect(imageRef.current) : null;
1911
+ console.log("rect", rect);
1912
+ if (!rect) return;
1913
+ const touch = e.changedTouches[0];
1914
+ const inside = touch.clientX >= rect.x && touch.clientX <= rect.x + rect.width && touch.clientY >= rect.y && touch.clientY <= rect.y + rect.height;
1915
+ if (!inside) {
1916
+ e.stopPropagation();
1917
+ isClosingRef.current = true;
1918
+ const blockNextClick = (clickEvent) => {
1919
+ clickEvent.stopPropagation();
1920
+ clickEvent.preventDefault();
1921
+ document.removeEventListener("click", blockNextClick, true);
1922
+ };
1923
+ document.addEventListener("click", blockNextClick, true);
1924
+ handleClose();
1925
+ }
1926
+ }
1927
+ };
1928
+ document.addEventListener("touchend", handleTouchEnd, { passive: true });
1929
+ return () => {
1930
+ document.removeEventListener("touchend", handleTouchEnd);
1931
+ };
1932
+ }, [isOpen, handleClose, currentIndex]);
1933
+ if (!isOpen && !isClosing) return null;
1711
1934
  return createPortal(
1712
- /* @__PURE__ */ jsx(
1713
- "div",
1714
- {
1715
- className: cn(styles.backdropStyle, backdropAppearClass, { [styles.editor]: isEditor }),
1716
- style: { backgroundColor: area.color, backdropFilter: `blur(${area.blur}px)`, animationDuration: `${backdropDurationMs}ms`, animationTimingFunction: "ease", animationFillMode: "both" },
1717
- onClick: handleBackdropClick,
1718
- children: /* @__PURE__ */ jsxs(
1719
- "div",
1720
- {
1721
- className: cn(styles.contentStyle, appearClass),
1722
- style: {
1723
- padding: `${layout.padding.top}px ${layout.padding.right}px ${layout.padding.bottom}px ${layout.padding.left}px`,
1724
- animationDuration: `${appearDurationMs}ms`,
1725
- animationTimingFunction: "ease",
1726
- animationFillMode: "both",
1727
- ...appear.type === "mix" && { animationDelay: `${backdropDurationMs}ms` },
1728
- "--splide-speed": triggers.duration || "500ms"
1729
- },
1730
- children: [
1731
- /* @__PURE__ */ jsx(
1732
- Splide,
1733
- {
1734
- onMove: (splide) => {
1735
- setCurrentIndex(splide.index);
1736
- },
1737
- ref: lightboxRef,
1738
- className: styles.lightboxSplide,
1739
- options: {
1740
- arrows: false,
1741
- speed: triggers.duration ? parseInt(triggers.duration) : 500,
1742
- direction: slider.direction === "horiz" || slider.type === "fade" || slider.type === "scale" ? "ltr" : "ttb",
1743
- pagination: false,
1744
- drag: triggers.type === "drag",
1745
- perPage: 1,
1746
- width: "100%",
1747
- height: "100%",
1748
- type: slider.type === "fade" || slider.type === "scale" ? "fade" : "loop",
1749
- padding: 0,
1750
- rewind: (slider.type === "scale" || slider.type === "fade") && appear.repeat !== "close"
1751
- },
1752
- style: { "--splide-speed": triggers.duration || "500ms" },
1753
- children: content.map((item, index) => {
1754
- const positionStyles = getPositionStyles(layout.position, layout.offset);
1755
- const imageStyle2 = slider.type === "scale" ? (() => {
1756
- const { transform, ...restStyles } = positionStyles;
1757
- return {
1758
- ...restStyles,
1759
- "--position-transform": transform || "none"
1760
- };
1761
- })() : positionStyles;
1762
- return /* @__PURE__ */ jsx(SplideSlide, { children: /* @__PURE__ */ jsx(
1763
- "div",
1764
- {
1765
- className: styles.imgWrapper,
1766
- onClick: handleImageWrapperClick,
1767
- style: {
1768
- padding: `${layout.padding.top}px ${layout.padding.right}px ${layout.padding.bottom}px ${layout.padding.left}px`
1769
- },
1770
- children: /* @__PURE__ */ jsx(
1771
- "img",
1772
- {
1773
- className: cn(styles.imageStyle, {
1774
- [styles.contain]: item.image.objectFit === "contain",
1775
- [styles.cover]: item.image.objectFit === "cover",
1776
- [styles.scaleSlide]: slider.type === "scale"
1777
- }),
1778
- src: item.image.url,
1779
- alt: item.image.name ?? "",
1780
- onClick: onImageClick,
1781
- style: imageStyle2
1782
- }
1783
- )
1784
- }
1785
- ) }, index);
1786
- })
1787
- }
1788
- ),
1789
- controls.isActive && /* @__PURE__ */ jsxs(Fragment, { children: [
1935
+ /* @__PURE__ */ jsxs(Fragment, { children: [
1936
+ /* @__PURE__ */ jsx(
1937
+ "div",
1938
+ {
1939
+ className: cn(styles.background, isClosing ? backdropDisappearClass : backdropAppearClass),
1940
+ style: {
1941
+ ...isEditor && { display: "none" },
1942
+ backgroundColor: area.color,
1943
+ backdropFilter: `blur(${area.blur}px)`,
1944
+ animationDuration: `${appearDurationMs}ms`,
1945
+ animationTimingFunction: "ease",
1946
+ animationFillMode: "both"
1947
+ }
1948
+ }
1949
+ ),
1950
+ /* @__PURE__ */ jsx(
1951
+ "div",
1952
+ {
1953
+ className: cn(styles.backdropStyle, { [styles.editor]: isEditor, [isClosing ? backdropDisappearClass : backdropAppearClass]: isEditor }),
1954
+ style: { ...isEditor && {
1955
+ backgroundColor: area.color,
1956
+ backdropFilter: `blur(${area.blur}px)`,
1957
+ animationDuration: `${appearDurationMs}ms`,
1958
+ animationTimingFunction: "ease",
1959
+ animationFillMode: "both"
1960
+ } },
1961
+ onClick: handleBackdropClick,
1962
+ onTouchEnd: handleBackdropClick,
1963
+ onTouchStart: handleBackdropClick,
1964
+ children: /* @__PURE__ */ jsxs(
1965
+ "div",
1966
+ {
1967
+ ref: contentRef,
1968
+ className: cn(styles.contentStyle, isClosing ? disappearClass : appearClass),
1969
+ onClick: handleContentClick,
1970
+ style: {
1971
+ animationDuration: `${appearDurationMs}ms`,
1972
+ animationTimingFunction: "ease",
1973
+ animationFillMode: "both",
1974
+ ...appear.type === "mix" && !isClosing && { animationDelay: `${backdropDurationMs / 2}ms` },
1975
+ ...appear.type === "mix" && isClosing && { animationDelay: "0ms" }
1976
+ },
1977
+ children: [
1790
1978
  /* @__PURE__ */ jsx(
1979
+ Splide,
1980
+ {
1981
+ onMove: (splide) => {
1982
+ setCurrentIndex(splide.index);
1983
+ },
1984
+ ref: lightboxRef,
1985
+ className: styles.lightboxSplide,
1986
+ options: {
1987
+ arrows: false,
1988
+ speed: slider.duration ? parseInt(slider.duration) : 500,
1989
+ direction: slider.direction === "horiz" || slider.type === "fade" || slider.type === "scale" ? "ltr" : "ttb",
1990
+ pagination: false,
1991
+ drag: triggers.type === "drag",
1992
+ perPage: 1,
1993
+ width: "100%",
1994
+ height: "100%",
1995
+ type: slider.type === "fade" || slider.type === "scale" ? "fade" : "loop",
1996
+ padding: 0,
1997
+ rewind: (slider.type === "scale" || slider.type === "fade") && triggers.repeat === "loop"
1998
+ },
1999
+ style: { "--splide-speed": slider.duration || "500ms" },
2000
+ children: content.map((item, index) => {
2001
+ const positionStyles = getPositionStyles(layout.position, layout.offset, isEditor);
2002
+ const imageStyle2 = slider.type === "scale" ? (() => {
2003
+ const { transform, ...restStyles } = positionStyles;
2004
+ return {
2005
+ ...restStyles,
2006
+ "--position-transform": transform || "none"
2007
+ };
2008
+ })() : positionStyles;
2009
+ return /* @__PURE__ */ jsx(SplideSlide, { children: /* @__PURE__ */ jsx(
2010
+ "div",
2011
+ {
2012
+ className: styles.imgWrapper,
2013
+ onClick: handleImageWrapperClick,
2014
+ style: { padding: scalingValue(layout.padding.top, isEditor) + " " + scalingValue(layout.padding.right, isEditor) + " " + scalingValue(layout.padding.bottom, isEditor) + " " + scalingValue(layout.padding.left, isEditor) },
2015
+ children: /* @__PURE__ */ jsx(
2016
+ "img",
2017
+ {
2018
+ ref: index === currentIndex ? imageRef : null,
2019
+ className: cn(styles.imageStyle, {
2020
+ [styles.contain]: item.image.objectFit === "contain",
2021
+ [styles.cover]: item.image.objectFit === "cover",
2022
+ [styles.scaleSlide]: slider.type === "scale"
2023
+ }),
2024
+ src: item.image.url,
2025
+ alt: item.image.name ?? "",
2026
+ style: {
2027
+ ...imageStyle2,
2028
+ ...item.image.objectFit === "contain" ? {
2029
+ pointerEvents: "none"
2030
+ } : {}
2031
+ }
2032
+ }
2033
+ )
2034
+ }
2035
+ ) }, index);
2036
+ })
2037
+ },
2038
+ splideKey
2039
+ ),
2040
+ controls.isActive && controls.arrowsImgUrl && /* @__PURE__ */ jsxs(Fragment, { children: [
2041
+ /* @__PURE__ */ jsx(
2042
+ "div",
2043
+ {
2044
+ className: cn(styles.arrow, { [styles.arrowVertical]: slider.direction === "vert" }),
2045
+ style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
2046
+ children: /* @__PURE__ */ jsx(
2047
+ "button",
2048
+ {
2049
+ className: styles.arrowInner,
2050
+ style: {
2051
+ 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"})`
2052
+ },
2053
+ onClick: (e) => {
2054
+ handleArrowClick("-1");
2055
+ },
2056
+ children: controls.arrowsImgUrl && /* @__PURE__ */ jsx(
2057
+ SvgImage,
2058
+ {
2059
+ url: controls.arrowsImgUrl,
2060
+ fill: controls.color,
2061
+ hoverFill: controls.hover,
2062
+ className: cn(styles.arrowImg, styles.mirror)
2063
+ }
2064
+ )
2065
+ }
2066
+ )
2067
+ }
2068
+ ),
2069
+ /* @__PURE__ */ jsx(
2070
+ "div",
2071
+ {
2072
+ className: cn(styles.arrow, styles.nextArrow, { [styles.arrowVertical]: slider.direction === "vert" }),
2073
+ style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
2074
+ children: /* @__PURE__ */ jsx(
2075
+ "button",
2076
+ {
2077
+ className: styles.arrowInner,
2078
+ style: {
2079
+ 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"})`
2080
+ },
2081
+ onClick: (e) => {
2082
+ handleArrowClick("+1");
2083
+ },
2084
+ "aria-label": "Next",
2085
+ children: controls.arrowsImgUrl && /* @__PURE__ */ jsx(
2086
+ SvgImage,
2087
+ {
2088
+ url: controls.arrowsImgUrl,
2089
+ fill: controls.color,
2090
+ hoverFill: controls.hover,
2091
+ className: styles.arrowImg
2092
+ }
2093
+ )
2094
+ }
2095
+ )
2096
+ }
2097
+ )
2098
+ ] }),
2099
+ area.closeIconUrl && (() => {
2100
+ const positionStyles = getPositionStyles(area.closeIconAlign, area.closeIconOffset, isEditor);
2101
+ const scaleTransform = `scale(${area.closeIconScale})`;
2102
+ const combinedTransform = positionStyles.transform ? `${positionStyles.transform} ${scaleTransform}` : scaleTransform;
2103
+ return /* @__PURE__ */ jsx(
2104
+ "button",
2105
+ {
2106
+ className: styles.closeButton,
2107
+ style: {
2108
+ ...positionStyles,
2109
+ transform: combinedTransform
2110
+ },
2111
+ onClick: handleClose,
2112
+ children: /* @__PURE__ */ jsx(SvgImage, { url: area.closeIconUrl })
2113
+ }
2114
+ );
2115
+ })(),
2116
+ caption2.isActive && /* @__PURE__ */ jsx(
1791
2117
  "div",
1792
2118
  {
1793
- className: cn(styles.arrow, { [styles.arrowVertical]: slider.direction === "vert" }),
1794
- style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
2119
+ className: styles.caption,
2120
+ style: {
2121
+ ...getPositionStyles(caption2.alignment, caption2.offset, isEditor),
2122
+ fontFamily: fontSettings.fontFamily,
2123
+ fontWeight: fontSettings.fontWeight,
2124
+ fontStyle: fontSettings.fontStyle,
2125
+ width: widthSettings.sizing === "auto" ? "max-content" : scalingValue(widthSettings.width, isEditor),
2126
+ letterSpacing: scalingValue(letterSpacing, isEditor),
2127
+ wordSpacing: scalingValue(wordSpacing, isEditor),
2128
+ textAlign,
2129
+ fontSize: scalingValue(fontSizeLineHeight.fontSize, isEditor),
2130
+ lineHeight: scalingValue(fontSizeLineHeight.lineHeight, isEditor),
2131
+ textTransform: textAppearance.textTransform ?? "none",
2132
+ textDecoration: textAppearance.textDecoration ?? "none",
2133
+ fontVariant: textAppearance.fontVariant ?? "normal",
2134
+ color,
2135
+ transitionDuration: slider.duration ? `${Math.round(parseInt(slider.duration) / 2)}ms` : "500ms"
2136
+ },
2137
+ onClick: (e) => e.stopPropagation(),
1795
2138
  children: /* @__PURE__ */ jsx(
1796
- "button",
2139
+ "div",
1797
2140
  {
1798
- className: styles.arrowInner,
2141
+ "data-styles": "caption",
2142
+ className: styles.captionTextInner,
1799
2143
  style: {
1800
- transform: `translate(${scalingValue(controls.offset.x)}, ${scalingValue(controls.offset.y * (slider.direction === "horiz" ? 1 : -1))}) scale(${controls.scale}) rotate(${slider.direction === "horiz" ? "0deg" : "90deg"})`
1801
- },
1802
- onClick: (e) => {
1803
- handleArrowClick("-1");
2144
+ "--link-hover-color": caption2.hover,
2145
+ position: "relative"
1804
2146
  },
1805
- children: controls.arrowsImgUrl && /* @__PURE__ */ jsx(
1806
- SvgImage,
1807
- {
1808
- url: controls.arrowsImgUrl,
1809
- fill: controls.color,
1810
- hoverFill: controls.hover,
1811
- className: cn(styles.arrowImg, styles.mirror)
1812
- }
1813
- )
2147
+ children: /* @__PURE__ */ jsx(RichTextRenderer, { content: content[currentIndex].imageCaption })
1814
2148
  }
1815
2149
  )
1816
2150
  }
1817
2151
  ),
1818
- /* @__PURE__ */ jsx(
2152
+ thumbnail.isActive && /* @__PURE__ */ jsx(
1819
2153
  "div",
1820
2154
  {
1821
- className: cn(styles.arrow, styles.nextArrow, { [styles.arrowVertical]: slider.direction === "vert" }),
1822
- style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
1823
- children: /* @__PURE__ */ jsx(
1824
- "button",
2155
+ className: cn(
2156
+ styles.thumbsContainer,
1825
2157
  {
1826
- className: styles.arrowInner,
1827
- style: {
1828
- transform: `translate(${scalingValue(controls.offset.x * (slider.direction === "horiz" ? -1 : 1))}, ${scalingValue(controls.offset.y)}) scale(${controls.scale}) rotate(${slider.direction === "horiz" ? "0deg" : "90deg"})`
1829
- },
1830
- onClick: (e) => {
1831
- handleArrowClick("+1");
1832
- },
1833
- "aria-label": "Next",
1834
- children: controls.arrowsImgUrl && /* @__PURE__ */ jsx(
1835
- SvgImage,
1836
- {
1837
- url: controls.arrowsImgUrl,
1838
- fill: controls.color,
1839
- hoverFill: controls.hover,
1840
- className: styles.arrowImg
1841
- }
1842
- )
2158
+ [styles.thumbsContainerVertical]: slider.direction === "vert",
2159
+ [styles.thumbsAlignStart]: thumbnail.align === "start",
2160
+ [styles.thumbsAlignCenter]: thumbnail.align === "center",
2161
+ [styles.thumbsAlignEnd]: thumbnail.align === "end"
1843
2162
  }
1844
- )
1845
- }
1846
- )
1847
- ] }),
1848
- area.closeIconUrl && (() => {
1849
- const positionStyles = getPositionStyles(area.closeIconAlign, area.closeIconOffset);
1850
- const scaleTransform = `scale(${area.closeIconScale})`;
1851
- const combinedTransform = positionStyles.transform ? `${positionStyles.transform} ${scaleTransform}` : scaleTransform;
1852
- return /* @__PURE__ */ jsx(
1853
- "button",
1854
- {
1855
- className: styles.closeButton,
2163
+ ),
1856
2164
  style: {
1857
- ...positionStyles,
1858
- transform: combinedTransform
2165
+ gap: `${scalingValue(thumbnail.grid.gap, isEditor)}`,
2166
+ ...getPositionStyles(thumbnail.position, thumbnail.offset, isEditor)
1859
2167
  },
1860
- onClick: onClose,
1861
- children: /* @__PURE__ */ jsx(SvgImage, { url: area.closeIconUrl })
1862
- }
1863
- );
1864
- })(),
1865
- caption2.isActive && /* @__PURE__ */ jsx(
1866
- "div",
1867
- {
1868
- className: styles.caption,
1869
- style: {
1870
- ...getPositionStyles(caption2.alignment, caption2.offset),
1871
- ["--link-hover-color"]: caption2.hover
1872
- },
1873
- children: /* @__PURE__ */ jsx(RichTextRenderer, { content: content[currentIndex].imageCaption })
1874
- }
1875
- ),
1876
- thumbnail.isActive && /* @__PURE__ */ jsx(
1877
- "div",
1878
- {
1879
- className: cn(
1880
- styles.thumbsContainer,
1881
- {
1882
- [styles.thumbsContainerVertical]: slider.direction === "vert",
1883
- [styles.thumbsAlignStart]: thumbnail.align === "start",
1884
- [styles.thumbsAlignCenter]: thumbnail.align === "center",
1885
- [styles.thumbsAlignEnd]: thumbnail.align === "end"
1886
- }
1887
- ),
1888
- style: {
1889
- gap: `${thumbnail.grid.gap}px`,
1890
- ...slider.direction === "horiz" ? { height: `${thumbnail.grid.height}px` } : {},
1891
- ...slider.direction === "vert" ? { width: `${thumbnail.grid.width}px` } : {},
1892
- ...getPositionStyles(thumbnail.position, thumbnail.offset)
1893
- },
1894
- children: content.map((item, index) => {
1895
- const isActive = index === currentIndex;
1896
- return /* @__PURE__ */ jsx(
1897
- "button",
1898
- {
1899
- className: styles.thumbItem,
1900
- style: {
1901
- transform: `scale(${isActive ? thumbnail.activeState.scale : 1})`,
1902
- ...slider.direction === "horiz" ? { height: "100%" } : {},
1903
- ...slider.direction === "vert" ? { width: "100%" } : {},
1904
- opacity: isActive ? thumbnail.activeState.opacity : thumbnail.opacity,
1905
- ["--thumb-hover"]: thumbnail.activeState.opacity
1906
- },
1907
- onClick: (e) => {
1908
- var _a;
1909
- e.stopPropagation();
1910
- setCurrentIndex(index);
1911
- (_a = lightboxRef.current) == null ? void 0 : _a.go(index);
1912
- },
1913
- children: /* @__PURE__ */ jsx(
1914
- "img",
1915
- {
1916
- src: item.image.url,
1917
- alt: item.image.name ?? "",
1918
- className: styles.thumbImage,
1919
- style: {
1920
- objectFit: thumbnail.fit === "cover" ? "cover" : "contain",
1921
- ...slider.direction === "horiz" ? { height: "100%" } : {},
1922
- ...slider.direction === "vert" ? { width: "100%" } : {}
2168
+ children: content.map((item, index) => {
2169
+ const isActive = index === currentIndex;
2170
+ return /* @__PURE__ */ jsx(
2171
+ "button",
2172
+ {
2173
+ className: styles.thumbItem,
2174
+ style: {
2175
+ ...slider.direction === "horiz" ? { height: isActive ? `${scalingValue(thumbnail.grid.height * (isActive ? thumbnail.activeState.scale : 1), isEditor)}` : `${scalingValue(thumbnail.grid.height, isEditor)}` } : {},
2176
+ ...slider.direction === "vert" ? { width: isActive ? `${scalingValue(thumbnail.grid.width * (isActive ? thumbnail.activeState.scale : 1), isEditor)}` : `${scalingValue(thumbnail.grid.width, isEditor)}` } : {},
2177
+ ...thumbnail.fit === "cover" && slider.direction === "horiz" ? { width: isActive ? `${scalingValue(thumbnail.grid.width * (isActive ? thumbnail.activeState.scale : 1), isEditor)}` : `${scalingValue(thumbnail.grid.width, isEditor)}` } : {},
2178
+ ...thumbnail.fit === "cover" && slider.direction === "vert" ? { height: isActive ? `${scalingValue(thumbnail.grid.height * (isActive ? thumbnail.activeState.scale : 1), isEditor)}` : `${scalingValue(thumbnail.grid.height, isEditor)}` } : {},
2179
+ transition: isActive ? "all 0.2s ease" : "none",
2180
+ opacity: isActive ? thumbnail.activeState.opacity / 100 : thumbnail.opacity / 100,
2181
+ ["--thumb-hover"]: thumbnail.activeState.opacity / 100
2182
+ },
2183
+ onClick: (e) => {
2184
+ var _a;
2185
+ e.stopPropagation();
2186
+ setCurrentIndex(index);
2187
+ (_a = lightboxRef.current) == null ? void 0 : _a.go(index);
2188
+ },
2189
+ onMouseEnter: () => {
2190
+ var _a;
2191
+ if (thumbnail.triggers === "hov") {
2192
+ (_a = lightboxRef.current) == null ? void 0 : _a.go(index);
1923
2193
  }
1924
- }
1925
- )
1926
- },
1927
- `${item.image.url}-${index}`
1928
- );
1929
- })
1930
- }
1931
- )
1932
- ]
1933
- }
1934
- )
1935
- }
1936
- ),
2194
+ },
2195
+ children: /* @__PURE__ */ jsx(
2196
+ "img",
2197
+ {
2198
+ src: item.image.url,
2199
+ alt: item.image.name ?? "",
2200
+ style: {
2201
+ objectFit: thumbnail.fit === "cover" ? "cover" : "contain",
2202
+ ...thumbnail.fit === "fit" ? { maxWidth: "100%", maxHeight: "100%", objectFit: "contain" } : {},
2203
+ ...thumbnail.fit === "cover" && slider.direction === "horiz" ? { width: "100%", height: "100%" } : {}
2204
+ }
2205
+ }
2206
+ )
2207
+ },
2208
+ `${item.image.url}-${index}`
2209
+ );
2210
+ })
2211
+ }
2212
+ )
2213
+ ]
2214
+ }
2215
+ )
2216
+ }
2217
+ )
2218
+ ] }),
1937
2219
  document.getElementById(portalId)
1938
2220
  );
1939
2221
  };
2222
+ const getColorAlpha = (color) => {
2223
+ const rgbaMatch = color.match(/rgba?\(([^)]+)\)/);
2224
+ if (rgbaMatch) {
2225
+ const values = rgbaMatch[1].split(",").map((v) => parseFloat(v.trim()));
2226
+ if (values.length === 4) {
2227
+ return values[3];
2228
+ }
2229
+ return 1;
2230
+ }
2231
+ const hexMatch = color.match(/^#([0-9a-fA-F]{8})$/);
2232
+ if (hexMatch) {
2233
+ const alphaHex = hexMatch[1].substring(6, 8);
2234
+ return parseInt(alphaHex, 16) / 255;
2235
+ }
2236
+ if (color.match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/)) {
2237
+ return 1;
2238
+ }
2239
+ return 1;
2240
+ };
1940
2241
  const LightboxComponent = {
1941
2242
  element: LightboxGallery,
1942
2243
  id: "lightbox",
1943
2244
  name: "Lightbox",
1944
2245
  preview: {
1945
2246
  type: "video",
1946
- url: "https://cdn.cntrl.site/projects/01GJ2SPDSH73MC92WW7ZA2CWBY/articles-assets/01KA24CHYZXJBZ0Q714B05A7VD.mp4"
2247
+ url: "https://cdn.cntrl.site/component-assets/lightbox.mp4"
1947
2248
  },
1948
2249
  defaultSize: {
1949
- width: 400,
1950
- height: 400
2250
+ width: 440,
2251
+ height: 550
1951
2252
  },
1952
2253
  schema: {
1953
2254
  type: "object",
@@ -1972,7 +2273,7 @@ const LightboxComponent = {
1972
2273
  url: {
1973
2274
  type: "string",
1974
2275
  display: {
1975
- type: "settings-image-input"
2276
+ type: "cover-image-input"
1976
2277
  }
1977
2278
  }
1978
2279
  }
@@ -2014,14 +2315,6 @@ const LightboxComponent = {
2014
2315
  type: "direction-control"
2015
2316
  },
2016
2317
  enum: ["top", "left", "right", "bottom"]
2017
- },
2018
- repeat: {
2019
- type: "string",
2020
- title: "Repeat",
2021
- display: {
2022
- type: "ratio-group"
2023
- },
2024
- enum: ["close", "loop"]
2025
2318
  }
2026
2319
  }
2027
2320
  },
@@ -2045,13 +2338,14 @@ const LightboxComponent = {
2045
2338
  },
2046
2339
  enum: ["image", "50/50"]
2047
2340
  },
2048
- duration: {
2341
+ repeat: {
2049
2342
  type: "string",
2050
- label: "T",
2343
+ title: "Repeat",
2051
2344
  display: {
2052
- type: "step-selector"
2345
+ visible: false,
2346
+ type: "ratio-group"
2053
2347
  },
2054
- enum: ["100ms", "250ms", "500ms", "1000ms", "1500ms", "2000ms"]
2348
+ enum: ["close", "loop"]
2055
2349
  }
2056
2350
  }
2057
2351
  },
@@ -2074,6 +2368,14 @@ const LightboxComponent = {
2074
2368
  type: "ratio-group"
2075
2369
  },
2076
2370
  enum: ["horiz", "vert"]
2371
+ },
2372
+ duration: {
2373
+ type: "string",
2374
+ label: "T",
2375
+ display: {
2376
+ type: "step-selector"
2377
+ },
2378
+ enum: ["100ms", "250ms", "500ms", "1000ms", "1500ms", "2000ms"]
2077
2379
  }
2078
2380
  }
2079
2381
  },
@@ -2131,13 +2433,16 @@ const LightboxComponent = {
2131
2433
  height: {
2132
2434
  type: "number",
2133
2435
  label: "H",
2436
+ scalingEnabled: true,
2134
2437
  display: {
2135
- type: "numeric-input"
2438
+ type: "numeric-input",
2439
+ visible: true
2136
2440
  }
2137
2441
  },
2138
2442
  width: {
2139
2443
  type: "number",
2140
2444
  label: "W",
2445
+ scalingEnabled: true,
2141
2446
  display: {
2142
2447
  type: "numeric-input",
2143
2448
  visible: false
@@ -2146,6 +2451,7 @@ const LightboxComponent = {
2146
2451
  gap: {
2147
2452
  type: "number",
2148
2453
  label: "Gap",
2454
+ scalingEnabled: true,
2149
2455
  display: {
2150
2456
  type: "numeric-input"
2151
2457
  }
@@ -2154,15 +2460,28 @@ const LightboxComponent = {
2154
2460
  },
2155
2461
  offset: {
2156
2462
  type: "object",
2463
+ title: "Offset",
2157
2464
  display: {
2158
- type: "offset-controls"
2465
+ type: "group"
2159
2466
  },
2160
2467
  properties: {
2161
2468
  x: {
2162
- type: "number"
2469
+ type: "number",
2470
+ label: "X",
2471
+ scalingEnabled: true,
2472
+ display: {
2473
+ type: "numeric-input",
2474
+ visible: true
2475
+ }
2163
2476
  },
2164
2477
  y: {
2165
- type: "number"
2478
+ type: "number",
2479
+ label: "Y",
2480
+ scalingEnabled: true,
2481
+ display: {
2482
+ type: "numeric-input",
2483
+ visible: true
2484
+ }
2166
2485
  }
2167
2486
  }
2168
2487
  },
@@ -2187,7 +2506,7 @@ const LightboxComponent = {
2187
2506
  scale: {
2188
2507
  type: "number",
2189
2508
  title: "Scale",
2190
- min: 0.5,
2509
+ min: 1,
2191
2510
  max: 5,
2192
2511
  step: 0.1,
2193
2512
  display: {
@@ -2224,15 +2543,28 @@ const LightboxComponent = {
2224
2543
  },
2225
2544
  offset: {
2226
2545
  type: "object",
2546
+ title: "Offset",
2227
2547
  display: {
2228
- type: "offset-controls"
2548
+ type: "group"
2229
2549
  },
2230
2550
  properties: {
2231
2551
  x: {
2232
- type: "number"
2552
+ type: "number",
2553
+ label: "X",
2554
+ scalingEnabled: true,
2555
+ display: {
2556
+ type: "numeric-input",
2557
+ visible: true
2558
+ }
2233
2559
  },
2234
2560
  y: {
2235
- type: "number"
2561
+ type: "number",
2562
+ label: "Y",
2563
+ scalingEnabled: true,
2564
+ display: {
2565
+ type: "numeric-input",
2566
+ visible: true
2567
+ }
2236
2568
  }
2237
2569
  }
2238
2570
  },
@@ -2244,15 +2576,23 @@ const LightboxComponent = {
2244
2576
  },
2245
2577
  properties: {
2246
2578
  top: {
2579
+ min: 0,
2580
+ step: 1,
2247
2581
  type: "number"
2248
2582
  },
2249
2583
  left: {
2584
+ min: 0,
2585
+ step: 1,
2250
2586
  type: "number"
2251
2587
  },
2252
2588
  right: {
2589
+ min: 0,
2590
+ step: 1,
2253
2591
  type: "number"
2254
2592
  },
2255
2593
  bottom: {
2594
+ min: 0,
2595
+ step: 1,
2256
2596
  type: "number"
2257
2597
  }
2258
2598
  }
@@ -2278,16 +2618,29 @@ const LightboxComponent = {
2278
2618
  }
2279
2619
  },
2280
2620
  offset: {
2621
+ title: "Offset",
2281
2622
  type: "object",
2282
2623
  display: {
2283
- type: "offset-controls"
2624
+ type: "group"
2284
2625
  },
2285
2626
  properties: {
2286
2627
  x: {
2287
- type: "number"
2628
+ type: "number",
2629
+ label: "X",
2630
+ scalingEnabled: true,
2631
+ display: {
2632
+ type: "numeric-input",
2633
+ visible: true
2634
+ }
2288
2635
  },
2289
2636
  y: {
2290
- type: "number"
2637
+ type: "number",
2638
+ label: "Y",
2639
+ scalingEnabled: true,
2640
+ display: {
2641
+ type: "numeric-input",
2642
+ visible: true
2643
+ }
2291
2644
  }
2292
2645
  }
2293
2646
  },
@@ -2366,15 +2719,28 @@ const LightboxComponent = {
2366
2719
  },
2367
2720
  closeIconOffset: {
2368
2721
  type: "object",
2722
+ title: "Offset",
2369
2723
  display: {
2370
- type: "offset-controls"
2724
+ type: "group"
2371
2725
  },
2372
2726
  properties: {
2373
2727
  x: {
2374
- type: "number"
2728
+ type: "number",
2729
+ label: "X",
2730
+ scalingEnabled: true,
2731
+ display: {
2732
+ type: "numeric-input",
2733
+ visible: true
2734
+ }
2375
2735
  },
2376
2736
  y: {
2377
- type: "number"
2737
+ type: "number",
2738
+ label: "Y",
2739
+ scalingEnabled: true,
2740
+ display: {
2741
+ type: "numeric-input",
2742
+ visible: true
2743
+ }
2378
2744
  }
2379
2745
  }
2380
2746
  }
@@ -2400,16 +2766,29 @@ const LightboxComponent = {
2400
2766
  enum: ["top-left", "top-center", "top-right", "middle-left", "middle-center", "middle-right", "bottom-left", "bottom-center", "bottom-right"]
2401
2767
  },
2402
2768
  offset: {
2769
+ title: "Offset",
2403
2770
  type: "object",
2404
2771
  display: {
2405
- type: "offset-controls"
2772
+ type: "group"
2406
2773
  },
2407
2774
  properties: {
2408
2775
  x: {
2409
- type: "number"
2776
+ type: "number",
2777
+ label: "X",
2778
+ scalingEnabled: true,
2779
+ display: {
2780
+ type: "numeric-input",
2781
+ visible: true
2782
+ }
2410
2783
  },
2411
2784
  y: {
2412
- type: "number"
2785
+ type: "number",
2786
+ label: "Y",
2787
+ scalingEnabled: true,
2788
+ display: {
2789
+ type: "numeric-input",
2790
+ visible: true
2791
+ }
2413
2792
  }
2414
2793
  }
2415
2794
  },
@@ -2429,38 +2808,38 @@ const LightboxComponent = {
2429
2808
  default: {
2430
2809
  thumbnailBlock: {
2431
2810
  cover: {
2432
- url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K7ERMHNP08T27H1649S67NZV.png"
2811
+ url: "https://cdn.cntrl.site/component-assets/Cover.jpg"
2433
2812
  }
2434
2813
  },
2435
2814
  lightboxBlock: {
2436
2815
  appear: {
2437
- type: "slide in",
2816
+ type: "fade in",
2438
2817
  duration: "1000ms",
2439
- direction: "right",
2440
- repeat: "close"
2818
+ direction: "right"
2441
2819
  },
2442
2820
  triggers: {
2443
2821
  type: "click",
2444
- switch: "image",
2445
- duration: "2000ms"
2822
+ switch: "50/50",
2823
+ repeat: "loop"
2446
2824
  },
2447
2825
  slider: {
2448
- type: "fade",
2449
- direction: "horiz"
2826
+ type: "slide",
2827
+ direction: "horiz",
2828
+ duration: "1000ms"
2450
2829
  },
2451
2830
  thumbnail: {
2452
2831
  isActive: true,
2453
2832
  position: "bottom-center",
2454
- fit: "cover",
2833
+ fit: "fit",
2455
2834
  align: "center",
2456
2835
  triggers: "clk",
2457
2836
  grid: {
2458
- height: 60,
2459
- width: 60,
2460
- gap: 8
2837
+ height: 0.03,
2838
+ width: 0.03,
2839
+ gap: 8e-3
2461
2840
  },
2462
2841
  offset: { x: 0, y: 0 },
2463
- opacity: 100,
2842
+ opacity: 80,
2464
2843
  activeState: {
2465
2844
  scale: 1,
2466
2845
  opacity: 100
@@ -2469,7 +2848,7 @@ const LightboxComponent = {
2469
2848
  layout: {
2470
2849
  position: "middle-center",
2471
2850
  offset: { x: 0, y: 0 },
2472
- padding: { top: 0, right: 0, bottom: 0, left: 0 }
2851
+ padding: { top: 0.04, right: 0, bottom: 0.04, left: 0 }
2473
2852
  },
2474
2853
  controls: {
2475
2854
  isActive: true,
@@ -2480,7 +2859,7 @@ const LightboxComponent = {
2480
2859
  hover: "#cccccc"
2481
2860
  },
2482
2861
  area: {
2483
- color: "rgba(0,0,0,0.9)",
2862
+ color: "rgba(64,67,71,0.9)",
2484
2863
  blur: 0,
2485
2864
  closeIconUrl: null,
2486
2865
  closeIconAlign: "top-right",
@@ -2512,7 +2891,7 @@ const LightboxComponent = {
2512
2891
  value: "vert"
2513
2892
  },
2514
2893
  then: {
2515
- name: "properties.lightboxBlock.properties.thumbnail.properties.position.display.direction",
2894
+ name: "properties.lightboxBlock.properties.thumbnail.properties.align.display.direction",
2516
2895
  value: "vertical"
2517
2896
  }
2518
2897
  },
@@ -2577,44 +2956,14 @@ const LightboxComponent = {
2577
2956
  }
2578
2957
  },
2579
2958
  {
2580
- if: {
2581
- name: "lightboxBlock.triggers.type",
2582
- value: "click"
2583
- },
2584
- then: {
2585
- name: "properties.lightboxBlock.properties.triggers.properties.duration.display.visible",
2586
- value: true
2587
- }
2588
- },
2589
- {
2590
- if: {
2591
- name: "lightboxBlock.triggers.type",
2592
- value: "click"
2593
- },
2959
+ if: [
2960
+ { name: "lightboxBlock.triggers.type", value: "click" },
2961
+ { name: "lightboxBlock.triggers.switch", value: "image" }
2962
+ ],
2594
2963
  then: {
2595
- name: "properties.lightboxBlock.properties.triggers.properties.switch.display.visible",
2964
+ name: "properties.lightboxBlock.properties.triggers.properties.repeat.display.visible",
2596
2965
  value: true
2597
2966
  }
2598
- },
2599
- {
2600
- if: {
2601
- name: "lightboxBlock.triggers.type",
2602
- value: "drag"
2603
- },
2604
- then: {
2605
- name: "properties.lightboxBlock.properties.triggers.properties.duration.display.visible",
2606
- value: false
2607
- }
2608
- },
2609
- {
2610
- if: {
2611
- name: "lightboxBlock.triggers.type",
2612
- value: "drag"
2613
- },
2614
- then: {
2615
- name: "properties.lightboxBlock.properties.triggers.properties.switch.display.visible",
2616
- value: false
2617
- }
2618
2967
  }
2619
2968
  ]
2620
2969
  },
@@ -2666,7 +3015,7 @@ const LightboxComponent = {
2666
3015
  {
2667
3016
  image: {
2668
3017
  objectFit: "contain",
2669
- url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K7ERMHNP08T27H1649S67NZV.png",
3018
+ url: "https://cdn.cntrl.site/component-assets/2.jpg",
2670
3019
  name: "Slider-1.png"
2671
3020
  },
2672
3021
  imageCaption: [
@@ -2679,7 +3028,7 @@ const LightboxComponent = {
2679
3028
  {
2680
3029
  image: {
2681
3030
  objectFit: "contain",
2682
- url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K7ERMTZA3RYMXKF0M095D6JD.png",
3031
+ url: "https://cdn.cntrl.site/component-assets/3.jpg",
2683
3032
  name: "Slider-2.png"
2684
3033
  },
2685
3034
  imageCaption: [
@@ -2692,7 +3041,7 @@ const LightboxComponent = {
2692
3041
  {
2693
3042
  image: {
2694
3043
  objectFit: "contain",
2695
- url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K7ERMVSCMPVJBG2WF5KJZYHZ.png",
3044
+ url: "https://cdn.cntrl.site/component-assets/4.jpg",
2696
3045
  name: "Slider-3.png"
2697
3046
  },
2698
3047
  imageCaption: [