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

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