@cntrl-site/components 0.1.14 → 0.1.15

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
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
- const React = require("react");
4
+ const react = require("react");
5
5
  const reactSplide = require("@splidejs/react-splide");
6
6
  const cn = require("classnames");
7
7
  const reactDom = require("react-dom");
@@ -13,7 +13,7 @@ const arrow$1 = "ControlSlider-module__arrow___05ghY";
13
13
  const arrowVertical$1 = "ControlSlider-module__arrowVertical___tBfVN";
14
14
  const nextArrow$1 = "ControlSlider-module__nextArrow___-30Yc";
15
15
  const arrowInner$1 = "ControlSlider-module__arrowInner___aEra3";
16
- const arrowIcon = "ControlSlider-module__arrowIcon___S4ztF";
16
+ const arrowIcon$1 = "ControlSlider-module__arrowIcon___S4ztF";
17
17
  const arrowImg$1 = "ControlSlider-module__arrowImg___2dwJW";
18
18
  const mirror$1 = "ControlSlider-module__mirror___brd6U";
19
19
  const pagination = "ControlSlider-module__pagination___bicLF";
@@ -57,7 +57,7 @@ const styles$3 = {
57
57
  arrowVertical: arrowVertical$1,
58
58
  nextArrow: nextArrow$1,
59
59
  arrowInner: arrowInner$1,
60
- arrowIcon,
60
+ arrowIcon: arrowIcon$1,
61
61
  arrowImg: arrowImg$1,
62
62
  mirror: mirror$1,
63
63
  pagination,
@@ -135,8 +135,8 @@ const styles$1 = {
135
135
  img
136
136
  };
137
137
  const SvgImage = ({ url, fill = "#000000", hoverFill = "#CCCCCC", className = "" }) => {
138
- const [supportsMask, setSupportsMask] = React.useState(true);
139
- React.useEffect(() => {
138
+ const [supportsMask, setSupportsMask] = react.useState(true);
139
+ react.useEffect(() => {
140
140
  if (typeof window !== "undefined" && window.CSS) {
141
141
  const supported = CSS.supports("mask-image", 'url("")') || CSS.supports("-webkit-mask-image", 'url("")');
142
142
  setSupportsMask(supported);
@@ -170,21 +170,21 @@ const alignmentClassName = {
170
170
  "bottom-right": styles$3.bottomRightAlignment
171
171
  };
172
172
  function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
173
- const [sliderRef, setSliderRef] = React.useState(null);
173
+ const [sliderRef, setSliderRef] = react.useState(null);
174
174
  const { widthSettings, fontSettings, letterSpacing, textAlign, wordSpacing, fontSizeLineHeight, textAppearance, color } = sliderStyles.imageCaption;
175
- const [sliderDimensions, setSliderDimensions] = React.useState(void 0);
176
- const [wrapperRef, setWrapperRef] = React.useState(null);
177
- const [currentSlideIndex, setCurrentSlideIndex] = React.useState(0);
178
- const [key, setKey] = React.useState(0);
175
+ const [sliderDimensions, setSliderDimensions] = react.useState(void 0);
176
+ const [wrapperRef, setWrapperRef] = react.useState(null);
177
+ const [currentSlideIndex, setCurrentSlideIndex] = react.useState(0);
178
+ const [key, setKey] = react.useState(0);
179
179
  const { direction, transition, controls, pagination: pagination2, imageCaption, triggers } = settings;
180
- const prevSliderTypeRef = React.useRef(transition.type);
180
+ const prevSliderTypeRef = react.useRef(transition.type);
181
181
  const { x: controlsOffsetX, y: controlsOffsetY } = settings.controls.offset;
182
182
  const handleArrowClick = (dir) => {
183
183
  if (sliderRef) {
184
184
  sliderRef.go(dir);
185
185
  }
186
186
  };
187
- React.useEffect(() => {
187
+ react.useEffect(() => {
188
188
  if (!wrapperRef) return;
189
189
  const observer = new ResizeObserver((entries) => {
190
190
  if (!sliderRef) return;
@@ -197,7 +197,7 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
197
197
  observer.observe(wrapperRef);
198
198
  return () => observer.unobserve(wrapperRef);
199
199
  }, [wrapperRef]);
200
- React.useEffect(() => {
200
+ react.useEffect(() => {
201
201
  if (!sliderRef || prevSliderTypeRef.current === transition.type) return;
202
202
  setKey((prev) => prev + 1);
203
203
  prevSliderTypeRef.current = transition.type;
@@ -345,7 +345,7 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
345
345
  className: cn(styles$3.arrowImg, styles$3.mirror)
346
346
  }
347
347
  ),
348
- !controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(ArrowIcon, { color: controls.color, className: cn(styles$3.arrowIcon, styles$3.arrowImg, styles$3.mirror) })
348
+ !controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(ArrowIcon$1, { color: controls.color, className: cn(styles$3.arrowIcon, styles$3.arrowImg, styles$3.mirror) })
349
349
  ]
350
350
  }
351
351
  )
@@ -380,7 +380,7 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
380
380
  className: styles$3.arrowImg
381
381
  }
382
382
  ),
383
- !controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(ArrowIcon, { color: controls.color, className: cn(styles$3.arrowIcon, styles$3.arrowImg) })
383
+ !controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(ArrowIcon$1, { color: controls.color, className: cn(styles$3.arrowIcon, styles$3.arrowImg) })
384
384
  ]
385
385
  }
386
386
  )
@@ -452,7 +452,7 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
452
452
  }
453
453
  ) });
454
454
  }
455
- function ArrowIcon({ color, className }) {
455
+ function ArrowIcon$1({ color, className }) {
456
456
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 10 18", className, children: /* @__PURE__ */ jsxRuntime.jsx("g", { id: "Symbols", stroke: "none", strokeWidth: "1", fillRule: "evenodd", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M-3.70710678,4.29289322 C-3.34662282,3.93240926 -2.77939176,3.90467972 -2.38710056,4.20970461 L-2.29289322,4.29289322 L5,11.585 L12.2928932,4.29289322 C12.6533772,3.93240926 13.2206082,3.90467972 13.6128994,4.20970461 L13.7071068,4.29289322 C14.0675907,4.65337718 14.0953203,5.22060824 13.7902954,5.61289944 L13.7071068,5.70710678 L5.70710678,13.7071068 C5.34662282,14.0675907 4.77939176,14.0953203 4.38710056,13.7902954 L4.29289322,13.7071068 L-3.70710678,5.70710678 C-4.09763107,5.31658249 -4.09763107,4.68341751 -3.70710678,4.29289322 Z", id: "Shape-Copy", fill: color, transform: "translate(5, 9) rotate(-90) translate(-5, -9)" }) }) });
457
457
  }
458
458
  const ControlSliderComponent = {
@@ -1102,19 +1102,19 @@ async function calculateImageWidthHeight(imgUrl, sizeType, customWidth, randomRa
1102
1102
  return { width, height, finalWidth: `${width}px` };
1103
1103
  }
1104
1104
  function ImageRevealSlider({ settings, content, isEditor }) {
1105
- const [divRef, setDivRef] = React.useState(null);
1106
- const [placedImages, setPlacedImages] = React.useState([]);
1107
- const [counter, setCounter] = React.useState(0);
1108
- const imageIdCounter = React.useRef(0);
1109
- const [cursorCenter, setCursorCenter] = React.useState({ x: 0, y: 0 });
1110
- const [cursorScale, setCursorScale] = React.useState(1);
1111
- const [customCursorImg, setCustomCursorImg] = React.useState("none");
1112
- const lastMousePos = React.useRef({ x: 0, y: 0 });
1113
- const [isInside, setIsInside] = React.useState(false);
1105
+ const [divRef, setDivRef] = react.useState(null);
1106
+ const [placedImages, setPlacedImages] = react.useState([]);
1107
+ const [counter, setCounter] = react.useState(0);
1108
+ const imageIdCounter = react.useRef(0);
1109
+ const [cursorCenter, setCursorCenter] = react.useState({ x: 0, y: 0 });
1110
+ const [cursorScale, setCursorScale] = react.useState(1);
1111
+ const [customCursorImg, setCustomCursorImg] = react.useState("none");
1112
+ const lastMousePos = react.useRef({ x: 0, y: 0 });
1113
+ const [isInside, setIsInside] = react.useState(false);
1114
1114
  const { sizeType, imageWidth: customWidth, randomRangeImageWidth: randomRange } = settings.imageSize;
1115
1115
  const { revealPosition, visible } = settings.position;
1116
1116
  const { cursorType, target, defaultCursorScale, defaultCursor, hoverCursorScale, hoverCursor } = settings.cursor;
1117
- React.useEffect(() => {
1117
+ react.useEffect(() => {
1118
1118
  if (!divRef) return;
1119
1119
  const updateCursorPosition = (clientX, clientY) => {
1120
1120
  const rect = divRef.getBoundingClientRect();
@@ -1165,7 +1165,7 @@ function ImageRevealSlider({ settings, content, isEditor }) {
1165
1165
  defaultCursorScale,
1166
1166
  placedImages
1167
1167
  ]);
1168
- React.useEffect(() => {
1168
+ react.useEffect(() => {
1169
1169
  if (!isInside) {
1170
1170
  setCustomCursorImg("none");
1171
1171
  setCursorScale(0);
@@ -1198,7 +1198,7 @@ function ImageRevealSlider({ settings, content, isEditor }) {
1198
1198
  width: finalWidth
1199
1199
  };
1200
1200
  };
1201
- React.useEffect(() => {
1201
+ react.useEffect(() => {
1202
1202
  if (!divRef || content.length === 0) return;
1203
1203
  const rect = divRef.getBoundingClientRect();
1204
1204
  const containerWidth = rect.width;
@@ -1213,7 +1213,7 @@ function ImageRevealSlider({ settings, content, isEditor }) {
1213
1213
  };
1214
1214
  placeImages();
1215
1215
  }, [sizeType, customWidth, randomRange, revealPosition, divRef]);
1216
- React.useEffect(() => {
1216
+ react.useEffect(() => {
1217
1217
  if (visible === "last One") {
1218
1218
  setPlacedImages((prev) => prev.length > 0 ? [prev[prev.length - 1]] : []);
1219
1219
  }
@@ -1617,6 +1617,7 @@ const ControlImageRevealSliderComponent = {
1617
1617
  }
1618
1618
  }
1619
1619
  };
1620
+ const hidden = "LightBox-module__hidden___9s-9x";
1620
1621
  const heroImage = "LightBox-module__heroImage___sTxNF";
1621
1622
  const background = "LightBox-module__background___rm9ml";
1622
1623
  const editor = "LightBox-module__editor___4ACaY";
@@ -1632,8 +1633,10 @@ const arrow = "LightBox-module__arrow___iz38X";
1632
1633
  const arrowVertical = "LightBox-module__arrowVertical___Zfz81";
1633
1634
  const nextArrow = "LightBox-module__nextArrow___zkAQN";
1634
1635
  const arrowInner = "LightBox-module__arrowInner___p48sW";
1636
+ const arrowIcon = "LightBox-module__arrowIcon___3VaFf";
1635
1637
  const arrowImg = "LightBox-module__arrowImg___pNV88";
1636
1638
  const mirror = "LightBox-module__mirror___pjeXc";
1639
+ const thumbsWrapper = "LightBox-module__thumbsWrapper___GB-nU";
1637
1640
  const thumbsContainerVertical = "LightBox-module__thumbsContainerVertical___wttk5";
1638
1641
  const thumbsContainer = "LightBox-module__thumbsContainer___osSma";
1639
1642
  const thumbsAlignStart = "LightBox-module__thumbsAlignStart___MO6tY";
@@ -1653,6 +1656,7 @@ const slideOutTop = "LightBox-module__slideOutTop___Vgg0z";
1653
1656
  const slideOutBottom = "LightBox-module__slideOutBottom___nJ0Ef";
1654
1657
  const scaleSlide = "LightBox-module__scaleSlide___vZriG";
1655
1658
  const classes = {
1659
+ hidden,
1656
1660
  heroImage,
1657
1661
  background,
1658
1662
  editor,
@@ -1668,8 +1672,10 @@ const classes = {
1668
1672
  arrowVertical,
1669
1673
  nextArrow,
1670
1674
  arrowInner,
1675
+ arrowIcon,
1671
1676
  arrowImg,
1672
1677
  mirror,
1678
+ thumbsWrapper,
1673
1679
  thumbsContainerVertical,
1674
1680
  thumbsContainer,
1675
1681
  thumbsAlignStart,
@@ -1725,8 +1731,13 @@ const getPositionStyles = (position, offset, isEditor) => {
1725
1731
  };
1726
1732
  function getDisplayedImageRect(img2) {
1727
1733
  const container = img2.getBoundingClientRect();
1728
- const containerW = container.width;
1729
- const containerH = container.height;
1734
+ const style = window.getComputedStyle(img2);
1735
+ const paddingTop = parseFloat(style.paddingTop) || 0;
1736
+ const paddingRight = parseFloat(style.paddingRight) || 0;
1737
+ const paddingBottom = parseFloat(style.paddingBottom) || 0;
1738
+ const paddingLeft = parseFloat(style.paddingLeft) || 0;
1739
+ const containerW = Math.max(0, container.width - paddingLeft - paddingRight);
1740
+ const containerH = Math.max(0, container.height - paddingTop - paddingBottom);
1730
1741
  const imgW = img2.naturalWidth;
1731
1742
  const imgH = img2.naturalHeight;
1732
1743
  const containerRatio = containerW / containerH;
@@ -1739,8 +1750,10 @@ function getDisplayedImageRect(img2) {
1739
1750
  renderedH = containerH;
1740
1751
  renderedW = containerH * imgRatio;
1741
1752
  }
1742
- const offsetX = (containerW - renderedW) / 2 + container.left;
1743
- const offsetY = (containerH - renderedH) / 2 + container.top;
1753
+ const contentLeft = container.left + paddingLeft;
1754
+ const contentTop = container.top + paddingTop;
1755
+ const offsetX = (containerW - renderedW) / 2 + contentLeft;
1756
+ const offsetY = (containerH - renderedH) / 2 + contentTop;
1744
1757
  return {
1745
1758
  x: offsetX,
1746
1759
  y: offsetY,
@@ -1843,9 +1856,9 @@ function getAnimationClasses(type, direction) {
1843
1856
  return { appearClass, backdropAppearClass, backdropDisappearClass, disappearClass };
1844
1857
  }
1845
1858
  const LightboxGallery = ({ settings, content, styles: styles2, portalId, activeEvent, isEditor }) => {
1846
- const [open, setOpen] = React.useState(false);
1859
+ const [open, setOpen] = react.useState(false);
1847
1860
  const { url } = settings.thumbnailBlock.cover;
1848
- React.useEffect(() => {
1861
+ react.useEffect(() => {
1849
1862
  if (activeEvent === "close") {
1850
1863
  setOpen(false);
1851
1864
  }
@@ -1878,22 +1891,23 @@ const LightboxGallery = ({ settings, content, styles: styles2, portalId, activeE
1878
1891
  ] });
1879
1892
  };
1880
1893
  const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId, isEditor }) => {
1881
- const [currentIndex, setCurrentIndex] = React.useState(0);
1882
- const [splideKey, setSplideKey] = React.useState(0);
1883
- const [isClosing, setIsClosing] = React.useState(false);
1884
- const [animationFinished, setAnimationFinished] = React.useState(false);
1885
- const [thumbnailDimensions, setThumbnailDimensions] = React.useState({});
1886
- const lightboxRef = React.useRef(null);
1887
- const prevSliderTypeRef = React.useRef(null);
1888
- const imageRef = React.useRef(null);
1889
- const isClosingRef = React.useRef(false);
1890
- const animationTargetRef = React.useRef(null);
1891
- const animationEndHandlerRef = React.useRef(null);
1892
- const appearAnimationEndHandlerRef = React.useRef(null);
1894
+ const [currentIndex, setCurrentIndex] = react.useState(0);
1895
+ const [splideKey, setSplideKey] = react.useState(0);
1896
+ const [isClosing, setIsClosing] = react.useState(false);
1897
+ const [animationFinished, setAnimationFinished] = react.useState(false);
1898
+ const [thumbnailDimensions, setThumbnailDimensions] = react.useState({});
1899
+ const lightboxRef = react.useRef(null);
1900
+ const prevSliderTypeRef = react.useRef(null);
1901
+ const imageRef = react.useRef(null);
1902
+ const isClosingRef = react.useRef(false);
1903
+ const animationTargetRef = react.useRef(null);
1904
+ const animationEndHandlerRef = react.useRef(null);
1905
+ const appearAnimationEndHandlerRef = react.useRef(null);
1906
+ const dragStartRef = react.useRef(null);
1907
+ const hasDraggedRef = react.useRef(false);
1893
1908
  const { appear, triggers, slider, thumbnail, controls, area, imageCaption, layout } = settings.lightboxBlock;
1894
- const { widthSettings, fontSettings, letterSpacing, textAlign, wordSpacing, fontSizeLineHeight, textAppearance, color } = lightboxStyles.imageCaption;
1895
1909
  const { appearClass, backdropAppearClass, backdropDisappearClass, disappearClass } = getAnimationClasses(appear.type, appear.direction);
1896
- React.useEffect(() => {
1910
+ react.useEffect(() => {
1897
1911
  const handleLayoutChange = () => {
1898
1912
  setTimeout(() => {
1899
1913
  var _a, _b;
@@ -1910,7 +1924,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
1910
1924
  window.removeEventListener("ArticleEditor.ComponentContent:change", handleComponentContentChange);
1911
1925
  };
1912
1926
  }, []);
1913
- const handleClose = React.useCallback(() => {
1927
+ const handleClose = react.useCallback(() => {
1914
1928
  const isMobile = window.matchMedia("(max-width: 768px)").matches;
1915
1929
  const colorAlpha = getColorAlpha(area.color);
1916
1930
  if (isMobile && !isEditor && colorAlpha > 0.9) {
@@ -1957,7 +1971,24 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
1957
1971
  (_b = lightboxRef.current) == null ? void 0 : _b.go(dir);
1958
1972
  }
1959
1973
  };
1974
+ const isClickInImagePadding = (img2, clientX, clientY) => {
1975
+ const rect = img2.getBoundingClientRect();
1976
+ const style = window.getComputedStyle(img2);
1977
+ const paddingTop = parseFloat(style.paddingTop) || 0;
1978
+ const paddingRight = parseFloat(style.paddingRight) || 0;
1979
+ const paddingBottom = parseFloat(style.paddingBottom) || 0;
1980
+ const paddingLeft = parseFloat(style.paddingLeft) || 0;
1981
+ const contentLeft = rect.left + paddingLeft;
1982
+ const contentRight = rect.right - paddingRight;
1983
+ const contentTop = rect.top + paddingTop;
1984
+ const contentBottom = rect.bottom - paddingBottom;
1985
+ return clientX < contentLeft || clientX > contentRight || clientY < contentTop || clientY > contentBottom;
1986
+ };
1960
1987
  const handleImageWrapperClick = (e) => {
1988
+ if (hasDraggedRef.current) {
1989
+ hasDraggedRef.current = false;
1990
+ return;
1991
+ }
1961
1992
  const currentImage = content[currentIndex];
1962
1993
  const isCover = (currentImage == null ? void 0 : currentImage.image.objectFit) === "cover";
1963
1994
  let clientX;
@@ -1974,7 +2005,16 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
1974
2005
  let inside;
1975
2006
  if (isCover && imageRef.current) {
1976
2007
  const imgRect = imageRef.current.getBoundingClientRect();
1977
- inside = clientX >= imgRect.left && clientX <= imgRect.right && clientY >= imgRect.top && clientY <= imgRect.bottom;
2008
+ const style = window.getComputedStyle(imageRef.current);
2009
+ const paddingTop = parseFloat(style.paddingTop) || 0;
2010
+ const paddingRight = parseFloat(style.paddingRight) || 0;
2011
+ const paddingBottom = parseFloat(style.paddingBottom) || 0;
2012
+ const paddingLeft = parseFloat(style.paddingLeft) || 0;
2013
+ const contentLeft = imgRect.left + paddingLeft;
2014
+ const contentRight = imgRect.right - paddingRight;
2015
+ const contentTop = imgRect.top + paddingTop;
2016
+ const contentBottom = imgRect.bottom - paddingBottom;
2017
+ inside = clientX >= contentLeft && clientX <= contentRight && clientY >= contentTop && clientY <= contentBottom;
1978
2018
  } else {
1979
2019
  const rect = imageRef.current ? getDisplayedImageRect(imageRef.current) : null;
1980
2020
  if (!rect) {
@@ -1991,9 +2031,19 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
1991
2031
  };
1992
2032
  const onImageClick = (e) => {
1993
2033
  e.stopPropagation();
2034
+ if (isClickInImagePadding(e.currentTarget, e.clientX, e.clientY)) {
2035
+ handleClose();
2036
+ return;
2037
+ }
1994
2038
  handleTriggerClick(e.currentTarget, e.clientX, e.clientY);
1995
2039
  };
1996
- React.useEffect(() => {
2040
+ const handleThumbWrapperClick = (e) => {
2041
+ const target = e.target;
2042
+ if (target.classList.contains(classes.thumbsWrapper) || target.classList.contains(classes.thumbsContainer)) {
2043
+ handleImageWrapperClick(e);
2044
+ }
2045
+ };
2046
+ react.useEffect(() => {
1997
2047
  if (!isOpen) return;
1998
2048
  const onKeyDown = (event) => {
1999
2049
  var _a, _b;
@@ -2016,9 +2066,10 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2016
2066
  window.removeEventListener("keydown", onKeyDown);
2017
2067
  };
2018
2068
  }, [isOpen, handleClose, content.length]);
2019
- React.useEffect(() => {
2069
+ react.useEffect(() => {
2020
2070
  if (isOpen) {
2021
2071
  setCurrentIndex(0);
2072
+ setSplideKey((prev) => prev + 1);
2022
2073
  isClosingRef.current = false;
2023
2074
  setIsClosing(false);
2024
2075
  setAnimationFinished(false);
@@ -2032,13 +2083,13 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2032
2083
  setAnimationFinished(false);
2033
2084
  };
2034
2085
  }, [isOpen]);
2035
- React.useEffect(() => {
2086
+ react.useEffect(() => {
2036
2087
  if (prevSliderTypeRef.current !== null && prevSliderTypeRef.current !== slider.type) {
2037
2088
  setSplideKey((prev) => prev + 1);
2038
2089
  }
2039
2090
  prevSliderTypeRef.current = slider.type;
2040
2091
  }, [slider.type]);
2041
- React.useEffect(() => {
2092
+ react.useEffect(() => {
2042
2093
  if (!isOpen) return;
2043
2094
  const originalOverflow = document.body.style.overflow;
2044
2095
  const isMobile = window.matchMedia("(max-width: 768px)").matches;
@@ -2061,7 +2112,13 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2061
2112
  appearAnimationEndHandlerRef.current = handleAppearAnimationEnd;
2062
2113
  animationTargetRef.current.addEventListener("animationend", handleAppearAnimationEnd);
2063
2114
  }
2064
- const preventScroll = (e) => e.preventDefault();
2115
+ const preventScroll = (e) => {
2116
+ const target = e.target;
2117
+ if (target && (target.closest(`.${classes.thumbsWrapper}`) || target.closest(`.${classes.thumbsContainer}`))) {
2118
+ return;
2119
+ }
2120
+ e.preventDefault();
2121
+ };
2065
2122
  document.addEventListener("touchmove", preventScroll, { passive: false });
2066
2123
  return () => {
2067
2124
  document.body.style.overflow = originalOverflow;
@@ -2073,13 +2130,17 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2073
2130
  setAnimationFinished(false);
2074
2131
  };
2075
2132
  }, [isOpen, isEditor, area.color]);
2076
- React.useEffect(() => {
2133
+ react.useEffect(() => {
2077
2134
  if (!isOpen) return;
2078
2135
  const handleTouchEnd = (e) => {
2079
2136
  if (isClosingRef.current) {
2080
2137
  e.stopPropagation();
2081
2138
  return;
2082
2139
  }
2140
+ if (hasDraggedRef.current) {
2141
+ hasDraggedRef.current = false;
2142
+ return;
2143
+ }
2083
2144
  const target = e.target;
2084
2145
  if (target && (target.closest(`.${classes.thumbsContainer}`) || target.closest(`.${classes.thumbItem}`))) {
2085
2146
  return;
@@ -2115,6 +2176,103 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2115
2176
  document.removeEventListener("touchend", handleTouchEnd);
2116
2177
  };
2117
2178
  }, [isOpen, handleClose, currentIndex, content]);
2179
+ const needsCustomVerticalDrag = (slider.type === "scale" || slider.type === "fade") && slider.direction === "vert" && triggers.type === "drag";
2180
+ react.useEffect(() => {
2181
+ var _a, _b;
2182
+ if (!isOpen || !needsCustomVerticalDrag || !((_b = (_a = lightboxRef.current) == null ? void 0 : _a.splide) == null ? void 0 : _b.root)) return;
2183
+ const container = lightboxRef.current.splide.root;
2184
+ const DRAG_THRESHOLD = 30;
2185
+ const handleMove = (clientX, clientY) => {
2186
+ if (dragStartRef.current) {
2187
+ const deltaX = Math.abs(clientX - dragStartRef.current.x);
2188
+ const deltaY = Math.abs(clientY - dragStartRef.current.y);
2189
+ if (deltaX > 0 || deltaY > 0) {
2190
+ hasDraggedRef.current = true;
2191
+ }
2192
+ }
2193
+ };
2194
+ const handlePointerMove = (e) => {
2195
+ if (dragStartRef.current) {
2196
+ e.preventDefault();
2197
+ handleMove(e.clientX, e.clientY);
2198
+ }
2199
+ };
2200
+ const handleTouchMove = (e) => {
2201
+ if (dragStartRef.current && e.touches.length > 0) {
2202
+ e.preventDefault();
2203
+ handleMove(e.touches[0].clientX, e.touches[0].clientY);
2204
+ }
2205
+ };
2206
+ const handleUp = (clientX, clientY) => {
2207
+ if (!dragStartRef.current || !lightboxRef.current) {
2208
+ dragStartRef.current = null;
2209
+ return;
2210
+ }
2211
+ const deltaX = Math.abs(clientX - dragStartRef.current.x);
2212
+ const deltaY = Math.abs(clientY - dragStartRef.current.y);
2213
+ if (deltaY > DRAG_THRESHOLD && deltaY > deltaX) {
2214
+ lightboxRef.current.go(clientY < dragStartRef.current.y ? "+1" : "-1");
2215
+ }
2216
+ dragStartRef.current = null;
2217
+ };
2218
+ const handlePointerUp = (e) => {
2219
+ if (!dragStartRef.current) {
2220
+ document.removeEventListener("pointerup", handlePointerUp);
2221
+ document.removeEventListener("pointercancel", handlePointerUp);
2222
+ document.removeEventListener("pointermove", handlePointerMove);
2223
+ return;
2224
+ }
2225
+ handleUp(e.clientX, e.clientY);
2226
+ document.removeEventListener("pointerup", handlePointerUp);
2227
+ document.removeEventListener("pointercancel", handlePointerUp);
2228
+ document.removeEventListener("pointermove", handlePointerMove);
2229
+ };
2230
+ const handleTouchEnd = (e) => {
2231
+ if (!dragStartRef.current) {
2232
+ document.removeEventListener("touchend", handleTouchEnd);
2233
+ document.removeEventListener("touchcancel", handleTouchEnd);
2234
+ document.removeEventListener("touchmove", handleTouchMove);
2235
+ return;
2236
+ }
2237
+ if (e.changedTouches.length > 0) {
2238
+ const touch = e.changedTouches[0];
2239
+ handleUp(touch.clientX, touch.clientY);
2240
+ }
2241
+ document.removeEventListener("touchend", handleTouchEnd);
2242
+ document.removeEventListener("touchcancel", handleTouchEnd);
2243
+ document.removeEventListener("touchmove", handleTouchMove);
2244
+ };
2245
+ const handlePointerDown = (e) => {
2246
+ dragStartRef.current = { x: e.clientX, y: e.clientY };
2247
+ hasDraggedRef.current = false;
2248
+ document.addEventListener("pointermove", handlePointerMove, { passive: false });
2249
+ document.addEventListener("pointerup", handlePointerUp);
2250
+ document.addEventListener("pointercancel", handlePointerUp);
2251
+ };
2252
+ const handleTouchStart = (e) => {
2253
+ if (e.touches.length > 0) {
2254
+ dragStartRef.current = { x: e.touches[0].clientX, y: e.touches[0].clientY };
2255
+ hasDraggedRef.current = false;
2256
+ document.addEventListener("touchmove", handleTouchMove, { passive: false });
2257
+ document.addEventListener("touchend", handleTouchEnd);
2258
+ document.addEventListener("touchcancel", handleTouchEnd);
2259
+ }
2260
+ };
2261
+ container.addEventListener("pointerdown", handlePointerDown);
2262
+ container.addEventListener("touchstart", handleTouchStart);
2263
+ return () => {
2264
+ container.removeEventListener("pointerdown", handlePointerDown);
2265
+ container.removeEventListener("touchstart", handleTouchStart);
2266
+ document.removeEventListener("pointermove", handlePointerMove);
2267
+ document.removeEventListener("pointerup", handlePointerUp);
2268
+ document.removeEventListener("pointercancel", handlePointerUp);
2269
+ document.removeEventListener("touchmove", handleTouchMove);
2270
+ document.removeEventListener("touchend", handleTouchEnd);
2271
+ document.removeEventListener("touchcancel", handleTouchEnd);
2272
+ dragStartRef.current = null;
2273
+ hasDraggedRef.current = false;
2274
+ };
2275
+ }, [isOpen, needsCustomVerticalDrag, splideKey]);
2118
2276
  const backdropStyles = {
2119
2277
  backgroundColor: area.color,
2120
2278
  backdropFilter: `blur(${area.blur}px)`,
@@ -2122,14 +2280,14 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2122
2280
  animationTimingFunction: "ease",
2123
2281
  animationFillMode: "both"
2124
2282
  };
2125
- if (!isOpen && !isClosing) return null;
2283
+ if (!document.getElementById(portalId)) return null;
2126
2284
  return reactDom.createPortal(
2127
2285
  /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2128
2286
  /* @__PURE__ */ jsxRuntime.jsx(
2129
2287
  "div",
2130
2288
  {
2131
2289
  ref: !isEditor ? animationTargetRef : null,
2132
- className: cn(classes.background, isClosing ? backdropDisappearClass : backdropAppearClass, { [classes.editor]: isEditor }),
2290
+ className: cn(classes.background, isClosing ? backdropDisappearClass : backdropAppearClass, { [classes.editor]: isEditor }, { [classes.hidden]: !isOpen }),
2133
2291
  style: {
2134
2292
  ...backdropStyles,
2135
2293
  ...animationFinished && !isEditor && !isClosing ? { position: "absolute" } : {}
@@ -2140,7 +2298,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2140
2298
  "div",
2141
2299
  {
2142
2300
  ref: isEditor ? animationTargetRef : null,
2143
- className: cn(classes.contentStyle, !isClosing ? appearClass : disappearClass, { [classes.editor]: isEditor }),
2301
+ className: cn(classes.contentStyle, !isClosing ? appearClass : disappearClass, { [classes.editor]: isEditor }, { [classes.hidden]: !isOpen }),
2144
2302
  style: {
2145
2303
  animationDuration: `${parseInt(appear.duration)}ms`,
2146
2304
  animationTimingFunction: "ease",
@@ -2156,15 +2314,20 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2156
2314
  options: {
2157
2315
  arrows: false,
2158
2316
  speed: slider.duration ? parseInt(slider.duration) : 500,
2159
- direction: slider.direction === "horiz" || slider.type === "fade" || slider.type === "scale" ? "ltr" : "ttb",
2317
+ direction: (() => {
2318
+ const isHoriz = slider.direction === "horiz";
2319
+ return isHoriz || slider.type === "fade" || slider.type === "scale" ? "ltr" : "ttb";
2320
+ })(),
2160
2321
  pagination: false,
2161
- drag: triggers.type === "drag",
2322
+ // Disable Splide's drag when we need custom vertical drag handling
2323
+ drag: triggers.type === "drag" && !needsCustomVerticalDrag,
2162
2324
  perPage: 1,
2163
2325
  width: "100%",
2164
2326
  height: "100%",
2165
2327
  type: slider.type === "fade" || slider.type === "scale" ? "fade" : "loop",
2166
2328
  padding: 0,
2167
- rewind: (slider.type === "scale" || slider.type === "fade") && triggers.repeat === "loop"
2329
+ rewind: (slider.type === "scale" || slider.type === "fade") && triggers.repeat === "loop",
2330
+ start: 0
2168
2331
  },
2169
2332
  style: { "--splide-speed": slider.duration },
2170
2333
  children: content.map((item, index) => {
@@ -2199,13 +2362,13 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2199
2362
  },
2200
2363
  splideKey
2201
2364
  ),
2202
- controls.isActive && controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2365
+ controls.isActive && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2203
2366
  /* @__PURE__ */ jsxRuntime.jsx(
2204
2367
  "div",
2205
2368
  {
2206
2369
  className: cn(classes.arrow, { [classes.arrowVertical]: slider.direction === "vert" }),
2207
2370
  style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
2208
- children: /* @__PURE__ */ jsxRuntime.jsx(
2371
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
2209
2372
  "button",
2210
2373
  {
2211
2374
  className: classes.arrowInner,
@@ -2215,15 +2378,18 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2215
2378
  return (_a = lightboxRef.current) == null ? void 0 : _a.go("-1");
2216
2379
  },
2217
2380
  "aria-label": "Previous",
2218
- children: controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(
2219
- SvgImage,
2220
- {
2221
- url: controls.arrowsImgUrl,
2222
- fill: controls.color,
2223
- hoverFill: controls.hover,
2224
- className: cn(classes.arrowImg, classes.mirror)
2225
- }
2226
- )
2381
+ children: [
2382
+ controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(
2383
+ SvgImage,
2384
+ {
2385
+ url: controls.arrowsImgUrl,
2386
+ fill: controls.color,
2387
+ hoverFill: controls.hover,
2388
+ className: cn(classes.arrowImg, classes.mirror)
2389
+ }
2390
+ ),
2391
+ !controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(ArrowIcon, { color: controls.color, className: cn(classes.arrowIcon, classes.arrowImg, classes.mirror) })
2392
+ ]
2227
2393
  }
2228
2394
  )
2229
2395
  }
@@ -2233,7 +2399,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2233
2399
  {
2234
2400
  className: cn(classes.arrow, classes.nextArrow, { [classes.arrowVertical]: slider.direction === "vert" }),
2235
2401
  style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
2236
- children: /* @__PURE__ */ jsxRuntime.jsx(
2402
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
2237
2403
  "button",
2238
2404
  {
2239
2405
  className: classes.arrowInner,
@@ -2243,15 +2409,18 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2243
2409
  return (_a = lightboxRef.current) == null ? void 0 : _a.go("+1");
2244
2410
  },
2245
2411
  "aria-label": "Next",
2246
- children: controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(
2247
- SvgImage,
2248
- {
2249
- url: controls.arrowsImgUrl,
2250
- fill: controls.color,
2251
- hoverFill: controls.hover,
2252
- className: classes.arrowImg
2253
- }
2254
- )
2412
+ children: [
2413
+ controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(
2414
+ SvgImage,
2415
+ {
2416
+ url: controls.arrowsImgUrl,
2417
+ fill: controls.color,
2418
+ hoverFill: controls.hover,
2419
+ className: classes.arrowImg
2420
+ }
2421
+ ),
2422
+ !controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(ArrowIcon, { color: controls.color, className: cn(classes.arrowIcon, classes.arrowImg) })
2423
+ ]
2255
2424
  }
2256
2425
  )
2257
2426
  }
@@ -2261,130 +2430,177 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2261
2430
  const positionStyles = getPositionStyles(area.closeIconAlign, area.closeIconOffset, isEditor);
2262
2431
  const scaleTransform = `scale(${area.closeIconScale})`;
2263
2432
  const combinedTransform = positionStyles.transform ? `${positionStyles.transform} ${scaleTransform}` : scaleTransform;
2264
- return /* @__PURE__ */ jsxRuntime.jsx("button", { className: classes.closeButton, style: { ...positionStyles, transform: combinedTransform }, onClick: handleClose, "aria-label": "Close lightbox", children: /* @__PURE__ */ jsxRuntime.jsx(SvgImage, { url: area.closeIconUrl }) });
2433
+ return /* @__PURE__ */ jsxRuntime.jsx("button", { className: classes.closeButton, style: { ...positionStyles, transform: combinedTransform }, onClick: handleClose, "aria-label": "Close lightbox", children: /* @__PURE__ */ jsxRuntime.jsx(SvgImage, { url: area.closeIconUrl, fill: area.closeIconColor ?? "#000000", hoverFill: area.closeIconHover ?? "#cccccc" }) });
2265
2434
  })(),
2266
- imageCaption.isActive && /* @__PURE__ */ jsxRuntime.jsx(
2267
- "div",
2268
- {
2269
- className: classes.caption,
2270
- style: {
2271
- ...getPositionStyles(imageCaption.alignment, imageCaption.offset, isEditor),
2272
- fontFamily: fontSettings.fontFamily,
2273
- fontWeight: fontSettings.fontWeight,
2274
- fontStyle: fontSettings.fontStyle,
2275
- width: widthSettings.sizing === "auto" ? "max-content" : scalingValue(widthSettings.width, isEditor),
2276
- letterSpacing: scalingValue(letterSpacing, isEditor),
2277
- wordSpacing: scalingValue(wordSpacing, isEditor),
2278
- textAlign,
2279
- fontSize: scalingValue(fontSizeLineHeight.fontSize, isEditor),
2280
- lineHeight: scalingValue(fontSizeLineHeight.lineHeight, isEditor),
2281
- textTransform: textAppearance.textTransform ?? "none",
2282
- textDecoration: textAppearance.textDecoration ?? "none",
2283
- fontVariant: textAppearance.fontVariant ?? "normal",
2284
- color
2285
- },
2286
- onClick: (e) => e.stopPropagation(),
2287
- children: /* @__PURE__ */ jsxRuntime.jsx(
2288
- "div",
2289
- {
2290
- "data-styles": "imageCaption",
2291
- className: classes.captionTextInner,
2292
- style: { ["--link-hover-color"]: imageCaption.hover },
2293
- children: /* @__PURE__ */ jsxRuntime.jsx(RichTextRenderer, { content: content[currentIndex].imageCaption })
2294
- }
2295
- )
2296
- }
2297
- ),
2298
- thumbnail.isActive && /* @__PURE__ */ jsxRuntime.jsx(
2299
- "div",
2300
- {
2301
- className: cn(classes.thumbsContainer, {
2302
- [classes.thumbsContainerVertical]: slider.direction === "vert",
2303
- [classes.thumbsAlignStart]: thumbnail.align === "start",
2304
- [classes.thumbsAlignCenter]: thumbnail.align === "center",
2305
- [classes.thumbsAlignEnd]: thumbnail.align === "end"
2306
- }),
2307
- style: {
2308
- position: isEditor ? "absolute" : "fixed",
2309
- gap: scalingValue(thumbnail.grid.gap, isEditor),
2310
- ...getPositionStyles(thumbnail.position, thumbnail.offset, isEditor)
2311
- },
2312
- children: content.map((item, index) => {
2313
- const isActive = index === currentIndex;
2314
- const thumbDims = thumbnailDimensions[index];
2315
- const baseSizeValue = thumbnail.grid.size;
2316
- const activeSizeValue = baseSizeValue * (isActive ? thumbnail.activeState.scale : 1);
2317
- const getFitDimensions = () => {
2318
- if (thumbnail.fit !== "fit" || !thumbDims) return {};
2319
- const aspectRatio = thumbDims.width / thumbDims.height;
2320
- if (slider.direction === "horiz") {
2321
- const heightValue = activeSizeValue;
2322
- const widthValue = heightValue * aspectRatio;
2323
- return {
2324
- width: scalingValue(widthValue, isEditor),
2325
- height: scalingValue(heightValue, isEditor)
2326
- };
2327
- } else {
2328
- const widthValue = activeSizeValue;
2329
- const heightValue = widthValue / aspectRatio;
2330
- return {
2331
- width: scalingValue(widthValue, isEditor),
2332
- height: scalingValue(heightValue, isEditor)
2333
- };
2435
+ imageCaption.isActive && lightboxStyles.imageCaption && (() => {
2436
+ const { widthSettings, fontSettings, letterSpacing, textAlign, wordSpacing, fontSizeLineHeight, textAppearance, color } = lightboxStyles.imageCaption;
2437
+ return /* @__PURE__ */ jsxRuntime.jsx(
2438
+ "div",
2439
+ {
2440
+ className: classes.caption,
2441
+ style: {
2442
+ ...getPositionStyles(imageCaption.alignment, imageCaption.offset, isEditor),
2443
+ fontFamily: fontSettings.fontFamily,
2444
+ fontWeight: fontSettings.fontWeight,
2445
+ fontStyle: fontSettings.fontStyle,
2446
+ width: widthSettings.sizing === "auto" ? "max-content" : scalingValue(widthSettings.width, isEditor),
2447
+ letterSpacing: scalingValue(letterSpacing, isEditor),
2448
+ wordSpacing: scalingValue(wordSpacing, isEditor),
2449
+ textAlign,
2450
+ fontSize: scalingValue(fontSizeLineHeight.fontSize, isEditor),
2451
+ lineHeight: scalingValue(fontSizeLineHeight.lineHeight, isEditor),
2452
+ textTransform: textAppearance.textTransform ?? "none",
2453
+ textDecoration: textAppearance.textDecoration ?? "none",
2454
+ fontVariant: textAppearance.fontVariant ?? "normal",
2455
+ color
2456
+ },
2457
+ onClick: (e) => e.stopPropagation(),
2458
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2459
+ "div",
2460
+ {
2461
+ "data-styles": "caption",
2462
+ className: classes.captionTextInner,
2463
+ style: { ["--link-hover-color"]: imageCaption.hover },
2464
+ children: /* @__PURE__ */ jsxRuntime.jsx(RichTextRenderer, { content: content[currentIndex].imageCaption })
2334
2465
  }
2335
- };
2336
- return /* @__PURE__ */ jsxRuntime.jsx(
2337
- "button",
2466
+ )
2467
+ }
2468
+ );
2469
+ })(),
2470
+ thumbnail.isActive && (() => {
2471
+ const [vertical, horizontal] = thumbnail.position.split("-");
2472
+ const effectivePosition = slider.direction === "horiz" ? `${vertical}-left` : thumbnail.position;
2473
+ const thumbsPositionStyles = getPositionStyles(effectivePosition, thumbnail.offset, isEditor);
2474
+ const getJustifyContent = () => {
2475
+ if (slider.direction === "horiz") {
2476
+ if (horizontal === "left") return "flex-start";
2477
+ if (horizontal === "center") return "center";
2478
+ if (horizontal === "right") return "flex-end";
2479
+ } else {
2480
+ if (vertical === "top") return "flex-start";
2481
+ if (vertical === "middle") return "center";
2482
+ if (vertical === "bottom") return "flex-end";
2483
+ }
2484
+ return "flex-start";
2485
+ };
2486
+ return /* @__PURE__ */ jsxRuntime.jsx(
2487
+ "div",
2488
+ {
2489
+ className: classes.thumbsWrapper,
2490
+ onClick: (e) => handleThumbWrapperClick(e),
2491
+ style: {
2492
+ position: isEditor ? "absolute" : "fixed",
2493
+ ...thumbsPositionStyles,
2494
+ ...slider.direction === "horiz" ? {
2495
+ maxWidth: "100vw",
2496
+ width: "100vw",
2497
+ overflowX: "auto",
2498
+ overflowY: "hidden"
2499
+ } : {
2500
+ maxHeight: "100vh",
2501
+ overflowY: "auto",
2502
+ overflowX: "hidden"
2503
+ }
2504
+ },
2505
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2506
+ "div",
2338
2507
  {
2339
- className: classes.thumbItem,
2508
+ className: cn(classes.thumbsContainer, {
2509
+ [classes.thumbsContainerVertical]: slider.direction === "vert",
2510
+ [classes.thumbsAlignStart]: thumbnail.align === "start",
2511
+ [classes.thumbsAlignCenter]: thumbnail.align === "center",
2512
+ [classes.thumbsAlignEnd]: thumbnail.align === "end"
2513
+ }),
2340
2514
  style: {
2341
- ...slider.direction === "horiz" && thumbnail.fit !== "fit" ? { height: scalingValue(activeSizeValue, isEditor) } : {},
2342
- ...slider.direction === "vert" && thumbnail.fit !== "fit" ? { width: scalingValue(activeSizeValue, isEditor) } : {},
2343
- ...thumbnail.fit === "cover" ? { width: scalingValue(activeSizeValue, isEditor), height: scalingValue(activeSizeValue, isEditor) } : {},
2344
- ...thumbnail.fit === "fit" ? getFitDimensions() : {},
2345
- transition: isActive ? "all 0.2s ease" : "none",
2346
- opacity: isActive ? thumbnail.activeState.opacity / 100 : thumbnail.opacity / 100,
2347
- ["--thumb-hover"]: thumbnail.activeState.opacity / 100
2348
- },
2349
- onClick: (e) => {
2350
- var _a;
2351
- e.stopPropagation();
2352
- setCurrentIndex(index);
2353
- (_a = lightboxRef.current) == null ? void 0 : _a.go(index);
2515
+ gap: scalingValue(thumbnail.grid.gap, isEditor),
2516
+ justifyContent: getJustifyContent()
2354
2517
  },
2355
- onMouseEnter: () => {
2356
- var _a;
2357
- if (thumbnail.triggers === "hov") {
2358
- (_a = lightboxRef.current) == null ? void 0 : _a.go(index);
2359
- }
2360
- },
2361
- children: /* @__PURE__ */ jsxRuntime.jsx(
2362
- "img",
2363
- {
2364
- src: item.image.url,
2365
- alt: item.image.name ?? "",
2366
- onLoad: (e) => {
2367
- const img2 = e.currentTarget;
2368
- if (img2.naturalWidth && img2.naturalHeight) {
2369
- setThumbnailDimensions((prev) => ({
2370
- ...prev,
2371
- [index]: { width: img2.naturalWidth, height: img2.naturalHeight }
2372
- }));
2518
+ children: content.map((item, index) => {
2519
+ const isActive = index === currentIndex;
2520
+ const thumbDims = thumbnailDimensions[index];
2521
+ const baseSizeValue = thumbnail.grid.size;
2522
+ const activeSizeValue = baseSizeValue * (isActive ? thumbnail.activeState.scale : 1);
2523
+ const getFitDimensions = () => {
2524
+ if (thumbnail.fit !== "fit") return {};
2525
+ if (!thumbDims) {
2526
+ if (slider.direction === "horiz") {
2527
+ return { height: scalingValue(activeSizeValue, isEditor) };
2528
+ } else {
2529
+ return { width: scalingValue(activeSizeValue, isEditor) };
2373
2530
  }
2374
- },
2375
- style: {
2376
- objectFit: thumbnail.fit === "cover" ? "cover" : "contain",
2377
- ...thumbnail.fit === "fit" ? { maxWidth: "100%", maxHeight: "100%", objectFit: "contain" } : {},
2378
- ...thumbnail.fit === "cover" && slider.direction === "horiz" ? { width: "100%", height: "100%" } : {}
2379
2531
  }
2380
- }
2381
- )
2382
- },
2383
- `${item.image.name}-${index}`
2384
- );
2385
- })
2386
- }
2387
- )
2532
+ const aspectRatio = thumbDims.width / thumbDims.height;
2533
+ if (slider.direction === "horiz") {
2534
+ const heightValue = activeSizeValue;
2535
+ const widthValue = heightValue * aspectRatio;
2536
+ return {
2537
+ width: scalingValue(widthValue, isEditor),
2538
+ height: scalingValue(heightValue, isEditor)
2539
+ };
2540
+ } else {
2541
+ const widthValue = activeSizeValue;
2542
+ const heightValue = widthValue / aspectRatio;
2543
+ return {
2544
+ width: scalingValue(widthValue, isEditor),
2545
+ height: scalingValue(heightValue, isEditor)
2546
+ };
2547
+ }
2548
+ };
2549
+ return /* @__PURE__ */ jsxRuntime.jsx(
2550
+ "button",
2551
+ {
2552
+ className: classes.thumbItem,
2553
+ style: {
2554
+ ...slider.direction === "horiz" && thumbnail.fit !== "fit" ? { height: scalingValue(activeSizeValue, isEditor) } : {},
2555
+ ...slider.direction === "vert" && thumbnail.fit !== "fit" ? { width: scalingValue(activeSizeValue, isEditor) } : {},
2556
+ ...thumbnail.fit === "cover" ? { width: scalingValue(activeSizeValue, isEditor), height: scalingValue(activeSizeValue, isEditor) } : {},
2557
+ ...getFitDimensions(),
2558
+ transition: isActive ? "all 0.25s ease-out" : "none",
2559
+ opacity: isActive ? thumbnail.activeState.opacity / 100 : thumbnail.opacity / 100,
2560
+ ["--thumb-hover"]: thumbnail.activeState.opacity / 100
2561
+ },
2562
+ onClick: (e) => {
2563
+ var _a;
2564
+ e.stopPropagation();
2565
+ setCurrentIndex(index);
2566
+ (_a = lightboxRef.current) == null ? void 0 : _a.go(index);
2567
+ },
2568
+ onMouseEnter: () => {
2569
+ var _a;
2570
+ if (thumbnail.triggers === "hov") {
2571
+ (_a = lightboxRef.current) == null ? void 0 : _a.go(index);
2572
+ }
2573
+ },
2574
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2575
+ "img",
2576
+ {
2577
+ src: item.image.url,
2578
+ alt: item.image.name ?? "",
2579
+ onLoad: (e) => {
2580
+ const img2 = e.currentTarget;
2581
+ if (img2.naturalWidth && img2.naturalHeight) {
2582
+ setThumbnailDimensions((prev) => ({
2583
+ ...prev,
2584
+ [index]: { width: img2.naturalWidth, height: img2.naturalHeight }
2585
+ }));
2586
+ }
2587
+ },
2588
+ style: {
2589
+ objectFit: thumbnail.fit === "cover" ? "cover" : "contain",
2590
+ ...thumbnail.fit === "fit" ? { maxWidth: "100%", maxHeight: "100%", objectFit: "contain" } : {},
2591
+ ...thumbnail.fit === "cover" ? { width: "100%", height: "100%" } : {}
2592
+ }
2593
+ }
2594
+ )
2595
+ },
2596
+ `${item.image.name}-${index}`
2597
+ );
2598
+ })
2599
+ }
2600
+ )
2601
+ }
2602
+ );
2603
+ })()
2388
2604
  ]
2389
2605
  }
2390
2606
  )
@@ -2392,6 +2608,9 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2392
2608
  document.getElementById(portalId)
2393
2609
  );
2394
2610
  };
2611
+ function ArrowIcon({ color, className }) {
2612
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 10 18", className, children: /* @__PURE__ */ jsxRuntime.jsx("g", { id: "Symbols", stroke: "none", strokeWidth: "1", fillRule: "evenodd", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M-3.70710678,4.29289322 C-3.34662282,3.93240926 -2.77939176,3.90467972 -2.38710056,4.20970461 L-2.29289322,4.29289322 L5,11.585 L12.2928932,4.29289322 C12.6533772,3.93240926 13.2206082,3.90467972 13.6128994,4.20970461 L13.7071068,4.29289322 C14.0675907,4.65337718 14.0953203,5.22060824 13.7902954,5.61289944 L13.7071068,5.70710678 L5.70710678,13.7071068 C5.34662282,14.0675907 4.77939176,14.0953203 4.38710056,13.7902954 L4.29289322,13.7071068 L-3.70710678,5.70710678 C-4.09763107,5.31658249 -4.09763107,4.68341751 -3.70710678,4.29289322 Z", id: "Shape-Copy", fill: color, transform: "translate(5, 9) rotate(-90) translate(-5, -9)" }) }) });
2613
+ }
2395
2614
  const LightboxComponent = {
2396
2615
  element: LightboxGallery,
2397
2616
  id: "lightbox",
@@ -2889,6 +3108,22 @@ const LightboxComponent = {
2889
3108
  }
2890
3109
  }
2891
3110
  }
3111
+ },
3112
+ closeIconColor: {
3113
+ title: "Color",
3114
+ type: "string",
3115
+ display: {
3116
+ type: "settings-color-picker",
3117
+ format: "single"
3118
+ }
3119
+ },
3120
+ closeIconHover: {
3121
+ title: "Hover",
3122
+ type: "string",
3123
+ display: {
3124
+ type: "settings-color-picker",
3125
+ format: "single"
3126
+ }
2892
3127
  }
2893
3128
  }
2894
3129
  },
@@ -2997,7 +3232,7 @@ const LightboxComponent = {
2997
3232
  padding: { top: 0.06, right: 0, bottom: 0.06, left: 0 }
2998
3233
  },
2999
3234
  controls: {
3000
- isActive: true,
3235
+ isActive: false,
3001
3236
  arrowsImgUrl: null,
3002
3237
  offset: { x: 0, y: 0 },
3003
3238
  scale: 1,
@@ -3008,6 +3243,8 @@ const LightboxComponent = {
3008
3243
  color: "rgba(28,31,34,0.9)",
3009
3244
  blur: 0,
3010
3245
  closeIconUrl: null,
3246
+ closeIconColor: "#000000",
3247
+ closeIconHover: "#cccccc",
3011
3248
  closeIconAlign: "top-right",
3012
3249
  closeIconOffset: { x: 0, y: 0 },
3013
3250
  closeIconScale: 1
@@ -3065,7 +3302,7 @@ const LightboxComponent = {
3065
3302
  padding: { top: 0.06, right: 0.05, bottom: 0.06, left: 0.05 }
3066
3303
  },
3067
3304
  controls: {
3068
- isActive: true,
3305
+ isActive: false,
3069
3306
  arrowsImgUrl: null,
3070
3307
  offset: { x: 0, y: 0 },
3071
3308
  scale: 1,
@@ -3076,6 +3313,8 @@ const LightboxComponent = {
3076
3313
  color: "rgba(28,31,34,0.9)",
3077
3314
  blur: 0,
3078
3315
  closeIconUrl: null,
3316
+ closeIconColor: "#000000",
3317
+ closeIconHover: "#cccccc",
3079
3318
  closeIconAlign: "top-right",
3080
3319
  closeIconOffset: { x: 0, y: 0 },
3081
3320
  closeIconScale: 1
@@ -3133,7 +3372,7 @@ const LightboxComponent = {
3133
3372
  padding: { top: 0.06, right: 0.1, bottom: 0.06, left: 0.1 }
3134
3373
  },
3135
3374
  controls: {
3136
- isActive: true,
3375
+ isActive: false,
3137
3376
  arrowsImgUrl: null,
3138
3377
  offset: { x: 0, y: 0 },
3139
3378
  scale: 1,
@@ -3144,6 +3383,8 @@ const LightboxComponent = {
3144
3383
  color: "rgba(28,31,34,0.9)",
3145
3384
  blur: 0,
3146
3385
  closeIconUrl: null,
3386
+ closeIconColor: "#000000",
3387
+ closeIconHover: "#cccccc",
3147
3388
  closeIconAlign: "top-right",
3148
3389
  closeIconOffset: { x: 0, y: 0 },
3149
3390
  closeIconScale: 1