@cntrl-site/components 0.1.0-alpha.22 → 0.1.0-alpha.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1631,6 +1631,7 @@ const Lightbox = ({ isOpen, onClose, content, styles: lightboxStyles, settings,
1631
1631
  const lightboxRef = React.useRef(null);
1632
1632
  const prevSliderTypeRef = React.useRef(null);
1633
1633
  const imageRef = React.useRef(null);
1634
+ const isClosingRef = React.useRef(false);
1634
1635
  const { appear, triggers, slider, thumbnail, controls, area, caption: caption2, layout } = settings.lightboxBlock;
1635
1636
  const handleBackdropClick = (e) => {
1636
1637
  if (!closeOnBackdropClick) return;
@@ -1705,7 +1706,10 @@ const Lightbox = ({ isOpen, onClose, content, styles: lightboxStyles, settings,
1705
1706
  };
1706
1707
  }, [isOpen, closeOnEsc, onClose, content.length]);
1707
1708
  React.useEffect(() => {
1708
- if (isOpen) setCurrentIndex(0);
1709
+ if (isOpen) {
1710
+ setCurrentIndex(0);
1711
+ isClosingRef.current = false;
1712
+ }
1709
1713
  }, [isOpen]);
1710
1714
  React.useEffect(() => {
1711
1715
  if (prevSliderTypeRef.current !== null && prevSliderTypeRef.current !== slider.type) {
@@ -1717,13 +1721,18 @@ const Lightbox = ({ isOpen, onClose, content, styles: lightboxStyles, settings,
1717
1721
  if (!isOpen) return;
1718
1722
  const originalOverflow = document.body.style.overflow;
1719
1723
  document.body.style.overflow = "hidden";
1720
- document.body.style.backgroundColor = area.color;
1724
+ const isMobile = window.matchMedia("(max-width: 768px)").matches;
1725
+ if (isMobile && !isEditor) {
1726
+ document.body.style.backgroundColor = area.color;
1727
+ }
1721
1728
  const preventScroll = (e) => e.preventDefault();
1722
1729
  document.addEventListener("touchmove", preventScroll, { passive: false });
1723
1730
  return () => {
1724
1731
  document.body.style.overflow = originalOverflow;
1725
1732
  document.removeEventListener("touchmove", preventScroll);
1726
- document.body.style.backgroundColor = "";
1733
+ if (isMobile && !isEditor) {
1734
+ document.body.style.backgroundColor = "";
1735
+ }
1727
1736
  };
1728
1737
  }, [isOpen]);
1729
1738
  const handleArrowClick = (dir) => {
@@ -1771,12 +1780,18 @@ const Lightbox = ({ isOpen, onClose, content, styles: lightboxStyles, settings,
1771
1780
  React.useEffect(() => {
1772
1781
  if (!isOpen || !closeOnBackdropClick) return;
1773
1782
  const handleTouchEnd = (e) => {
1783
+ if (isClosingRef.current) {
1784
+ e.stopPropagation();
1785
+ return;
1786
+ }
1774
1787
  if (e.touches.length === 0 && e.changedTouches.length > 0) {
1775
1788
  const rect = imageRef.current ? getDisplayedImageRect(imageRef.current) : null;
1776
1789
  if (!rect) return;
1777
1790
  const touch = e.changedTouches[0];
1778
1791
  const inside = touch.clientX >= rect.x && touch.clientX <= rect.x + rect.width && touch.clientY >= rect.y && touch.clientY <= rect.y + rect.height;
1779
1792
  if (!inside) {
1793
+ e.stopPropagation();
1794
+ isClosingRef.current = true;
1780
1795
  onClose();
1781
1796
  }
1782
1797
  }
@@ -1809,8 +1824,14 @@ const Lightbox = ({ isOpen, onClose, content, styles: lightboxStyles, settings,
1809
1824
  /* @__PURE__ */ jsxRuntime.jsx(
1810
1825
  "div",
1811
1826
  {
1812
- className: cn(styles.backdropStyle, { [styles.editor]: isEditor }),
1813
- style: { ...isEditor && { backgroundColor: area.color, backdropFilter: `blur(${area.blur}px)` } },
1827
+ className: cn(styles.backdropStyle, { [styles.editor]: isEditor, [backdropAppearClass]: isEditor }),
1828
+ style: { ...isEditor && {
1829
+ backgroundColor: area.color,
1830
+ backdropFilter: `blur(${area.blur}px)`,
1831
+ animationDuration: `${backdropDurationMs}ms`,
1832
+ animationTimingFunction: "ease",
1833
+ animationFillMode: "both"
1834
+ } },
1814
1835
  onClick: handleBackdropClick,
1815
1836
  onTouchEnd: handleBackdropClick,
1816
1837
  onTouchStart: handleBackdropClick,
@@ -2095,8 +2116,7 @@ const LightboxComponent = {
2095
2116
  url: {
2096
2117
  type: "string",
2097
2118
  display: {
2098
- mode: "cover",
2099
- type: "settings-image-input"
2119
+ type: "cover-image-input"
2100
2120
  }
2101
2121
  }
2102
2122
  }
package/dist/index.mjs CHANGED
@@ -1629,6 +1629,7 @@ const Lightbox = ({ isOpen, onClose, content, styles: lightboxStyles, settings,
1629
1629
  const lightboxRef = useRef(null);
1630
1630
  const prevSliderTypeRef = useRef(null);
1631
1631
  const imageRef = useRef(null);
1632
+ const isClosingRef = useRef(false);
1632
1633
  const { appear, triggers, slider, thumbnail, controls, area, caption: caption2, layout } = settings.lightboxBlock;
1633
1634
  const handleBackdropClick = (e) => {
1634
1635
  if (!closeOnBackdropClick) return;
@@ -1703,7 +1704,10 @@ const Lightbox = ({ isOpen, onClose, content, styles: lightboxStyles, settings,
1703
1704
  };
1704
1705
  }, [isOpen, closeOnEsc, onClose, content.length]);
1705
1706
  useEffect(() => {
1706
- if (isOpen) setCurrentIndex(0);
1707
+ if (isOpen) {
1708
+ setCurrentIndex(0);
1709
+ isClosingRef.current = false;
1710
+ }
1707
1711
  }, [isOpen]);
1708
1712
  useEffect(() => {
1709
1713
  if (prevSliderTypeRef.current !== null && prevSliderTypeRef.current !== slider.type) {
@@ -1715,13 +1719,18 @@ const Lightbox = ({ isOpen, onClose, content, styles: lightboxStyles, settings,
1715
1719
  if (!isOpen) return;
1716
1720
  const originalOverflow = document.body.style.overflow;
1717
1721
  document.body.style.overflow = "hidden";
1718
- document.body.style.backgroundColor = area.color;
1722
+ const isMobile = window.matchMedia("(max-width: 768px)").matches;
1723
+ if (isMobile && !isEditor) {
1724
+ document.body.style.backgroundColor = area.color;
1725
+ }
1719
1726
  const preventScroll = (e) => e.preventDefault();
1720
1727
  document.addEventListener("touchmove", preventScroll, { passive: false });
1721
1728
  return () => {
1722
1729
  document.body.style.overflow = originalOverflow;
1723
1730
  document.removeEventListener("touchmove", preventScroll);
1724
- document.body.style.backgroundColor = "";
1731
+ if (isMobile && !isEditor) {
1732
+ document.body.style.backgroundColor = "";
1733
+ }
1725
1734
  };
1726
1735
  }, [isOpen]);
1727
1736
  const handleArrowClick = (dir) => {
@@ -1769,12 +1778,18 @@ const Lightbox = ({ isOpen, onClose, content, styles: lightboxStyles, settings,
1769
1778
  useEffect(() => {
1770
1779
  if (!isOpen || !closeOnBackdropClick) return;
1771
1780
  const handleTouchEnd = (e) => {
1781
+ if (isClosingRef.current) {
1782
+ e.stopPropagation();
1783
+ return;
1784
+ }
1772
1785
  if (e.touches.length === 0 && e.changedTouches.length > 0) {
1773
1786
  const rect = imageRef.current ? getDisplayedImageRect(imageRef.current) : null;
1774
1787
  if (!rect) return;
1775
1788
  const touch = e.changedTouches[0];
1776
1789
  const inside = touch.clientX >= rect.x && touch.clientX <= rect.x + rect.width && touch.clientY >= rect.y && touch.clientY <= rect.y + rect.height;
1777
1790
  if (!inside) {
1791
+ e.stopPropagation();
1792
+ isClosingRef.current = true;
1778
1793
  onClose();
1779
1794
  }
1780
1795
  }
@@ -1807,8 +1822,14 @@ const Lightbox = ({ isOpen, onClose, content, styles: lightboxStyles, settings,
1807
1822
  /* @__PURE__ */ jsx(
1808
1823
  "div",
1809
1824
  {
1810
- className: cn(styles.backdropStyle, { [styles.editor]: isEditor }),
1811
- style: { ...isEditor && { backgroundColor: area.color, backdropFilter: `blur(${area.blur}px)` } },
1825
+ className: cn(styles.backdropStyle, { [styles.editor]: isEditor, [backdropAppearClass]: isEditor }),
1826
+ style: { ...isEditor && {
1827
+ backgroundColor: area.color,
1828
+ backdropFilter: `blur(${area.blur}px)`,
1829
+ animationDuration: `${backdropDurationMs}ms`,
1830
+ animationTimingFunction: "ease",
1831
+ animationFillMode: "both"
1832
+ } },
1812
1833
  onClick: handleBackdropClick,
1813
1834
  onTouchEnd: handleBackdropClick,
1814
1835
  onTouchStart: handleBackdropClick,
@@ -2093,8 +2114,7 @@ const LightboxComponent = {
2093
2114
  url: {
2094
2115
  type: "string",
2095
2116
  display: {
2096
- mode: "cover",
2097
- type: "settings-image-input"
2117
+ type: "cover-image-input"
2098
2118
  }
2099
2119
  }
2100
2120
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/components",
3
- "version": "0.1.0-alpha.22",
3
+ "version": "0.1.0-alpha.23",
4
4
  "description": "Custom components for control editor and public websites.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",