@cntrl-site/components 0.1.14 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
- import React, { useState, useEffect, useRef, useCallback } from "react";
2
+ import { useState, useEffect, useRef, useCallback } from "react";
3
3
  import { Splide, SplideSlide } from "@splidejs/react-splide";
4
4
  import cn from "classnames";
5
5
  import { createPortal } from "react-dom";
@@ -11,7 +11,7 @@ const arrow$1 = "ControlSlider-module__arrow___05ghY";
11
11
  const arrowVertical$1 = "ControlSlider-module__arrowVertical___tBfVN";
12
12
  const nextArrow$1 = "ControlSlider-module__nextArrow___-30Yc";
13
13
  const arrowInner$1 = "ControlSlider-module__arrowInner___aEra3";
14
- const arrowIcon = "ControlSlider-module__arrowIcon___S4ztF";
14
+ const arrowIcon$1 = "ControlSlider-module__arrowIcon___S4ztF";
15
15
  const arrowImg$1 = "ControlSlider-module__arrowImg___2dwJW";
16
16
  const mirror$1 = "ControlSlider-module__mirror___brd6U";
17
17
  const pagination = "ControlSlider-module__pagination___bicLF";
@@ -55,7 +55,7 @@ const styles$3 = {
55
55
  arrowVertical: arrowVertical$1,
56
56
  nextArrow: nextArrow$1,
57
57
  arrowInner: arrowInner$1,
58
- arrowIcon,
58
+ arrowIcon: arrowIcon$1,
59
59
  arrowImg: arrowImg$1,
60
60
  mirror: mirror$1,
61
61
  pagination,
@@ -343,7 +343,7 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
343
343
  className: cn(styles$3.arrowImg, styles$3.mirror)
344
344
  }
345
345
  ),
346
- !controls.arrowsImgUrl && /* @__PURE__ */ jsx(ArrowIcon, { color: controls.color, className: cn(styles$3.arrowIcon, styles$3.arrowImg, styles$3.mirror) })
346
+ !controls.arrowsImgUrl && /* @__PURE__ */ jsx(ArrowIcon$1, { color: controls.color, className: cn(styles$3.arrowIcon, styles$3.arrowImg, styles$3.mirror) })
347
347
  ]
348
348
  }
349
349
  )
@@ -378,7 +378,7 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
378
378
  className: styles$3.arrowImg
379
379
  }
380
380
  ),
381
- !controls.arrowsImgUrl && /* @__PURE__ */ jsx(ArrowIcon, { color: controls.color, className: cn(styles$3.arrowIcon, styles$3.arrowImg) })
381
+ !controls.arrowsImgUrl && /* @__PURE__ */ jsx(ArrowIcon$1, { color: controls.color, className: cn(styles$3.arrowIcon, styles$3.arrowImg) })
382
382
  ]
383
383
  }
384
384
  )
@@ -450,7 +450,7 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
450
450
  }
451
451
  ) });
452
452
  }
453
- function ArrowIcon({ color, className }) {
453
+ function ArrowIcon$1({ color, className }) {
454
454
  return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 10 18", className, children: /* @__PURE__ */ jsx("g", { id: "Symbols", stroke: "none", strokeWidth: "1", fillRule: "evenodd", children: /* @__PURE__ */ 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)" }) }) });
455
455
  }
456
456
  const ControlSliderComponent = {
@@ -1615,6 +1615,7 @@ const ControlImageRevealSliderComponent = {
1615
1615
  }
1616
1616
  }
1617
1617
  };
1618
+ const hidden = "LightBox-module__hidden___9s-9x";
1618
1619
  const heroImage = "LightBox-module__heroImage___sTxNF";
1619
1620
  const background = "LightBox-module__background___rm9ml";
1620
1621
  const editor = "LightBox-module__editor___4ACaY";
@@ -1630,8 +1631,10 @@ const arrow = "LightBox-module__arrow___iz38X";
1630
1631
  const arrowVertical = "LightBox-module__arrowVertical___Zfz81";
1631
1632
  const nextArrow = "LightBox-module__nextArrow___zkAQN";
1632
1633
  const arrowInner = "LightBox-module__arrowInner___p48sW";
1634
+ const arrowIcon = "LightBox-module__arrowIcon___3VaFf";
1633
1635
  const arrowImg = "LightBox-module__arrowImg___pNV88";
1634
1636
  const mirror = "LightBox-module__mirror___pjeXc";
1637
+ const thumbsWrapper = "LightBox-module__thumbsWrapper___GB-nU";
1635
1638
  const thumbsContainerVertical = "LightBox-module__thumbsContainerVertical___wttk5";
1636
1639
  const thumbsContainer = "LightBox-module__thumbsContainer___osSma";
1637
1640
  const thumbsAlignStart = "LightBox-module__thumbsAlignStart___MO6tY";
@@ -1651,6 +1654,7 @@ const slideOutTop = "LightBox-module__slideOutTop___Vgg0z";
1651
1654
  const slideOutBottom = "LightBox-module__slideOutBottom___nJ0Ef";
1652
1655
  const scaleSlide = "LightBox-module__scaleSlide___vZriG";
1653
1656
  const classes = {
1657
+ hidden,
1654
1658
  heroImage,
1655
1659
  background,
1656
1660
  editor,
@@ -1666,8 +1670,10 @@ const classes = {
1666
1670
  arrowVertical,
1667
1671
  nextArrow,
1668
1672
  arrowInner,
1673
+ arrowIcon,
1669
1674
  arrowImg,
1670
1675
  mirror,
1676
+ thumbsWrapper,
1671
1677
  thumbsContainerVertical,
1672
1678
  thumbsContainer,
1673
1679
  thumbsAlignStart,
@@ -1723,8 +1729,13 @@ const getPositionStyles = (position, offset, isEditor) => {
1723
1729
  };
1724
1730
  function getDisplayedImageRect(img2) {
1725
1731
  const container = img2.getBoundingClientRect();
1726
- const containerW = container.width;
1727
- const containerH = container.height;
1732
+ const style = window.getComputedStyle(img2);
1733
+ const paddingTop = parseFloat(style.paddingTop) || 0;
1734
+ const paddingRight = parseFloat(style.paddingRight) || 0;
1735
+ const paddingBottom = parseFloat(style.paddingBottom) || 0;
1736
+ const paddingLeft = parseFloat(style.paddingLeft) || 0;
1737
+ const containerW = Math.max(0, container.width - paddingLeft - paddingRight);
1738
+ const containerH = Math.max(0, container.height - paddingTop - paddingBottom);
1728
1739
  const imgW = img2.naturalWidth;
1729
1740
  const imgH = img2.naturalHeight;
1730
1741
  const containerRatio = containerW / containerH;
@@ -1737,8 +1748,10 @@ function getDisplayedImageRect(img2) {
1737
1748
  renderedH = containerH;
1738
1749
  renderedW = containerH * imgRatio;
1739
1750
  }
1740
- const offsetX = (containerW - renderedW) / 2 + container.left;
1741
- const offsetY = (containerH - renderedH) / 2 + container.top;
1751
+ const contentLeft = container.left + paddingLeft;
1752
+ const contentTop = container.top + paddingTop;
1753
+ const offsetX = (containerW - renderedW) / 2 + contentLeft;
1754
+ const offsetY = (containerH - renderedH) / 2 + contentTop;
1742
1755
  return {
1743
1756
  x: offsetX,
1744
1757
  y: offsetY,
@@ -1841,7 +1854,7 @@ function getAnimationClasses(type, direction) {
1841
1854
  return { appearClass, backdropAppearClass, backdropDisappearClass, disappearClass };
1842
1855
  }
1843
1856
  const LightboxGallery = ({ settings, content, styles: styles2, portalId, activeEvent, isEditor }) => {
1844
- const [open, setOpen] = React.useState(false);
1857
+ const [open, setOpen] = useState(false);
1845
1858
  const { url } = settings.thumbnailBlock.cover;
1846
1859
  useEffect(() => {
1847
1860
  if (activeEvent === "close") {
@@ -1888,8 +1901,9 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
1888
1901
  const animationTargetRef = useRef(null);
1889
1902
  const animationEndHandlerRef = useRef(null);
1890
1903
  const appearAnimationEndHandlerRef = useRef(null);
1904
+ const dragStartRef = useRef(null);
1905
+ const hasDraggedRef = useRef(false);
1891
1906
  const { appear, triggers, slider, thumbnail, controls, area, imageCaption, layout } = settings.lightboxBlock;
1892
- const { widthSettings, fontSettings, letterSpacing, textAlign, wordSpacing, fontSizeLineHeight, textAppearance, color } = lightboxStyles.imageCaption;
1893
1907
  const { appearClass, backdropAppearClass, backdropDisappearClass, disappearClass } = getAnimationClasses(appear.type, appear.direction);
1894
1908
  useEffect(() => {
1895
1909
  const handleLayoutChange = () => {
@@ -1955,7 +1969,24 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
1955
1969
  (_b = lightboxRef.current) == null ? void 0 : _b.go(dir);
1956
1970
  }
1957
1971
  };
1972
+ const isClickInImagePadding = (img2, clientX, clientY) => {
1973
+ const rect = img2.getBoundingClientRect();
1974
+ const style = window.getComputedStyle(img2);
1975
+ const paddingTop = parseFloat(style.paddingTop) || 0;
1976
+ const paddingRight = parseFloat(style.paddingRight) || 0;
1977
+ const paddingBottom = parseFloat(style.paddingBottom) || 0;
1978
+ const paddingLeft = parseFloat(style.paddingLeft) || 0;
1979
+ const contentLeft = rect.left + paddingLeft;
1980
+ const contentRight = rect.right - paddingRight;
1981
+ const contentTop = rect.top + paddingTop;
1982
+ const contentBottom = rect.bottom - paddingBottom;
1983
+ return clientX < contentLeft || clientX > contentRight || clientY < contentTop || clientY > contentBottom;
1984
+ };
1958
1985
  const handleImageWrapperClick = (e) => {
1986
+ if (hasDraggedRef.current) {
1987
+ hasDraggedRef.current = false;
1988
+ return;
1989
+ }
1959
1990
  const currentImage = content[currentIndex];
1960
1991
  const isCover = (currentImage == null ? void 0 : currentImage.image.objectFit) === "cover";
1961
1992
  let clientX;
@@ -1972,7 +2003,16 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
1972
2003
  let inside;
1973
2004
  if (isCover && imageRef.current) {
1974
2005
  const imgRect = imageRef.current.getBoundingClientRect();
1975
- inside = clientX >= imgRect.left && clientX <= imgRect.right && clientY >= imgRect.top && clientY <= imgRect.bottom;
2006
+ const style = window.getComputedStyle(imageRef.current);
2007
+ const paddingTop = parseFloat(style.paddingTop) || 0;
2008
+ const paddingRight = parseFloat(style.paddingRight) || 0;
2009
+ const paddingBottom = parseFloat(style.paddingBottom) || 0;
2010
+ const paddingLeft = parseFloat(style.paddingLeft) || 0;
2011
+ const contentLeft = imgRect.left + paddingLeft;
2012
+ const contentRight = imgRect.right - paddingRight;
2013
+ const contentTop = imgRect.top + paddingTop;
2014
+ const contentBottom = imgRect.bottom - paddingBottom;
2015
+ inside = clientX >= contentLeft && clientX <= contentRight && clientY >= contentTop && clientY <= contentBottom;
1976
2016
  } else {
1977
2017
  const rect = imageRef.current ? getDisplayedImageRect(imageRef.current) : null;
1978
2018
  if (!rect) {
@@ -1989,8 +2029,18 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
1989
2029
  };
1990
2030
  const onImageClick = (e) => {
1991
2031
  e.stopPropagation();
2032
+ if (isClickInImagePadding(e.currentTarget, e.clientX, e.clientY)) {
2033
+ handleClose();
2034
+ return;
2035
+ }
1992
2036
  handleTriggerClick(e.currentTarget, e.clientX, e.clientY);
1993
2037
  };
2038
+ const handleThumbWrapperClick = (e) => {
2039
+ const target = e.target;
2040
+ if (target.classList.contains(classes.thumbsWrapper) || target.classList.contains(classes.thumbsContainer)) {
2041
+ handleImageWrapperClick(e);
2042
+ }
2043
+ };
1994
2044
  useEffect(() => {
1995
2045
  if (!isOpen) return;
1996
2046
  const onKeyDown = (event) => {
@@ -2017,10 +2067,13 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2017
2067
  useEffect(() => {
2018
2068
  if (isOpen) {
2019
2069
  setCurrentIndex(0);
2070
+ setSplideKey((prev) => prev + 1);
2020
2071
  isClosingRef.current = false;
2021
2072
  setIsClosing(false);
2022
2073
  setAnimationFinished(false);
2023
2074
  setThumbnailDimensions({});
2075
+ const event = new CustomEvent("page-overlay");
2076
+ window.dispatchEvent(event);
2024
2077
  }
2025
2078
  return () => {
2026
2079
  if (animationTargetRef.current && animationEndHandlerRef.current) {
@@ -2059,7 +2112,13 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2059
2112
  appearAnimationEndHandlerRef.current = handleAppearAnimationEnd;
2060
2113
  animationTargetRef.current.addEventListener("animationend", handleAppearAnimationEnd);
2061
2114
  }
2062
- 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
+ };
2063
2122
  document.addEventListener("touchmove", preventScroll, { passive: false });
2064
2123
  return () => {
2065
2124
  document.body.style.overflow = originalOverflow;
@@ -2078,6 +2137,10 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2078
2137
  e.stopPropagation();
2079
2138
  return;
2080
2139
  }
2140
+ if (hasDraggedRef.current) {
2141
+ hasDraggedRef.current = false;
2142
+ return;
2143
+ }
2081
2144
  const target = e.target;
2082
2145
  if (target && (target.closest(`.${classes.thumbsContainer}`) || target.closest(`.${classes.thumbItem}`))) {
2083
2146
  return;
@@ -2113,6 +2176,103 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2113
2176
  document.removeEventListener("touchend", handleTouchEnd);
2114
2177
  };
2115
2178
  }, [isOpen, handleClose, currentIndex, content]);
2179
+ const needsCustomVerticalDrag = (slider.type === "scale" || slider.type === "fade") && slider.direction === "vert" && triggers.type === "drag";
2180
+ 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]);
2116
2276
  const backdropStyles = {
2117
2277
  backgroundColor: area.color,
2118
2278
  backdropFilter: `blur(${area.blur}px)`,
@@ -2120,14 +2280,14 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2120
2280
  animationTimingFunction: "ease",
2121
2281
  animationFillMode: "both"
2122
2282
  };
2123
- if (!isOpen && !isClosing) return null;
2283
+ if (!document.getElementById(portalId)) return null;
2124
2284
  return createPortal(
2125
2285
  /* @__PURE__ */ jsxs(Fragment, { children: [
2126
2286
  /* @__PURE__ */ jsx(
2127
2287
  "div",
2128
2288
  {
2129
2289
  ref: !isEditor ? animationTargetRef : null,
2130
- className: cn(classes.background, isClosing ? backdropDisappearClass : backdropAppearClass, { [classes.editor]: isEditor }),
2290
+ className: cn(classes.background, isClosing ? backdropDisappearClass : backdropAppearClass, { [classes.editor]: isEditor }, { [classes.hidden]: !isOpen }),
2131
2291
  style: {
2132
2292
  ...backdropStyles,
2133
2293
  ...animationFinished && !isEditor && !isClosing ? { position: "absolute" } : {}
@@ -2138,7 +2298,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2138
2298
  "div",
2139
2299
  {
2140
2300
  ref: isEditor ? animationTargetRef : null,
2141
- className: cn(classes.contentStyle, !isClosing ? appearClass : disappearClass, { [classes.editor]: isEditor }),
2301
+ className: cn(classes.contentStyle, !isClosing ? appearClass : disappearClass, { [classes.editor]: isEditor }, { [classes.hidden]: !isOpen }),
2142
2302
  style: {
2143
2303
  animationDuration: `${parseInt(appear.duration)}ms`,
2144
2304
  animationTimingFunction: "ease",
@@ -2154,15 +2314,20 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2154
2314
  options: {
2155
2315
  arrows: false,
2156
2316
  speed: slider.duration ? parseInt(slider.duration) : 500,
2157
- 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
+ })(),
2158
2321
  pagination: false,
2159
- drag: triggers.type === "drag",
2322
+ // Disable Splide's drag when we need custom vertical drag handling
2323
+ drag: triggers.type === "drag" && !needsCustomVerticalDrag,
2160
2324
  perPage: 1,
2161
2325
  width: "100%",
2162
2326
  height: "100%",
2163
2327
  type: slider.type === "fade" || slider.type === "scale" ? "fade" : "loop",
2164
2328
  padding: 0,
2165
- rewind: (slider.type === "scale" || slider.type === "fade") && triggers.repeat === "loop"
2329
+ rewind: (slider.type === "scale" || slider.type === "fade") && triggers.repeat === "loop",
2330
+ start: 0
2166
2331
  },
2167
2332
  style: { "--splide-speed": slider.duration },
2168
2333
  children: content.map((item, index) => {
@@ -2197,13 +2362,13 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2197
2362
  },
2198
2363
  splideKey
2199
2364
  ),
2200
- controls.isActive && controls.arrowsImgUrl && /* @__PURE__ */ jsxs(Fragment, { children: [
2365
+ controls.isActive && /* @__PURE__ */ jsxs(Fragment, { children: [
2201
2366
  /* @__PURE__ */ jsx(
2202
2367
  "div",
2203
2368
  {
2204
2369
  className: cn(classes.arrow, { [classes.arrowVertical]: slider.direction === "vert" }),
2205
2370
  style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
2206
- children: /* @__PURE__ */ jsx(
2371
+ children: /* @__PURE__ */ jsxs(
2207
2372
  "button",
2208
2373
  {
2209
2374
  className: classes.arrowInner,
@@ -2213,15 +2378,18 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2213
2378
  return (_a = lightboxRef.current) == null ? void 0 : _a.go("-1");
2214
2379
  },
2215
2380
  "aria-label": "Previous",
2216
- children: controls.arrowsImgUrl && /* @__PURE__ */ jsx(
2217
- SvgImage,
2218
- {
2219
- url: controls.arrowsImgUrl,
2220
- fill: controls.color,
2221
- hoverFill: controls.hover,
2222
- className: cn(classes.arrowImg, classes.mirror)
2223
- }
2224
- )
2381
+ children: [
2382
+ controls.arrowsImgUrl && /* @__PURE__ */ 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__ */ jsx(ArrowIcon, { color: controls.color, className: cn(classes.arrowIcon, classes.arrowImg, classes.mirror) })
2392
+ ]
2225
2393
  }
2226
2394
  )
2227
2395
  }
@@ -2231,7 +2399,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2231
2399
  {
2232
2400
  className: cn(classes.arrow, classes.nextArrow, { [classes.arrowVertical]: slider.direction === "vert" }),
2233
2401
  style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
2234
- children: /* @__PURE__ */ jsx(
2402
+ children: /* @__PURE__ */ jsxs(
2235
2403
  "button",
2236
2404
  {
2237
2405
  className: classes.arrowInner,
@@ -2241,15 +2409,18 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2241
2409
  return (_a = lightboxRef.current) == null ? void 0 : _a.go("+1");
2242
2410
  },
2243
2411
  "aria-label": "Next",
2244
- children: controls.arrowsImgUrl && /* @__PURE__ */ jsx(
2245
- SvgImage,
2246
- {
2247
- url: controls.arrowsImgUrl,
2248
- fill: controls.color,
2249
- hoverFill: controls.hover,
2250
- className: classes.arrowImg
2251
- }
2252
- )
2412
+ children: [
2413
+ controls.arrowsImgUrl && /* @__PURE__ */ 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__ */ jsx(ArrowIcon, { color: controls.color, className: cn(classes.arrowIcon, classes.arrowImg) })
2423
+ ]
2253
2424
  }
2254
2425
  )
2255
2426
  }
@@ -2259,130 +2430,177 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2259
2430
  const positionStyles = getPositionStyles(area.closeIconAlign, area.closeIconOffset, isEditor);
2260
2431
  const scaleTransform = `scale(${area.closeIconScale})`;
2261
2432
  const combinedTransform = positionStyles.transform ? `${positionStyles.transform} ${scaleTransform}` : scaleTransform;
2262
- return /* @__PURE__ */ jsx("button", { className: classes.closeButton, style: { ...positionStyles, transform: combinedTransform }, onClick: handleClose, "aria-label": "Close lightbox", children: /* @__PURE__ */ jsx(SvgImage, { url: area.closeIconUrl }) });
2433
+ return /* @__PURE__ */ jsx("button", { className: classes.closeButton, style: { ...positionStyles, transform: combinedTransform }, onClick: handleClose, "aria-label": "Close lightbox", children: /* @__PURE__ */ jsx(SvgImage, { url: area.closeIconUrl, fill: area.closeIconColor ?? "#000000", hoverFill: area.closeIconHover ?? "#cccccc" }) });
2263
2434
  })(),
2264
- imageCaption.isActive && /* @__PURE__ */ jsx(
2265
- "div",
2266
- {
2267
- className: classes.caption,
2268
- style: {
2269
- ...getPositionStyles(imageCaption.alignment, imageCaption.offset, isEditor),
2270
- fontFamily: fontSettings.fontFamily,
2271
- fontWeight: fontSettings.fontWeight,
2272
- fontStyle: fontSettings.fontStyle,
2273
- width: widthSettings.sizing === "auto" ? "max-content" : scalingValue(widthSettings.width, isEditor),
2274
- letterSpacing: scalingValue(letterSpacing, isEditor),
2275
- wordSpacing: scalingValue(wordSpacing, isEditor),
2276
- textAlign,
2277
- fontSize: scalingValue(fontSizeLineHeight.fontSize, isEditor),
2278
- lineHeight: scalingValue(fontSizeLineHeight.lineHeight, isEditor),
2279
- textTransform: textAppearance.textTransform ?? "none",
2280
- textDecoration: textAppearance.textDecoration ?? "none",
2281
- fontVariant: textAppearance.fontVariant ?? "normal",
2282
- color
2283
- },
2284
- onClick: (e) => e.stopPropagation(),
2285
- children: /* @__PURE__ */ jsx(
2286
- "div",
2287
- {
2288
- "data-styles": "imageCaption",
2289
- className: classes.captionTextInner,
2290
- style: { ["--link-hover-color"]: imageCaption.hover },
2291
- children: /* @__PURE__ */ jsx(RichTextRenderer, { content: content[currentIndex].imageCaption })
2292
- }
2293
- )
2294
- }
2295
- ),
2296
- thumbnail.isActive && /* @__PURE__ */ jsx(
2297
- "div",
2298
- {
2299
- className: cn(classes.thumbsContainer, {
2300
- [classes.thumbsContainerVertical]: slider.direction === "vert",
2301
- [classes.thumbsAlignStart]: thumbnail.align === "start",
2302
- [classes.thumbsAlignCenter]: thumbnail.align === "center",
2303
- [classes.thumbsAlignEnd]: thumbnail.align === "end"
2304
- }),
2305
- style: {
2306
- position: isEditor ? "absolute" : "fixed",
2307
- gap: scalingValue(thumbnail.grid.gap, isEditor),
2308
- ...getPositionStyles(thumbnail.position, thumbnail.offset, isEditor)
2309
- },
2310
- children: content.map((item, index) => {
2311
- const isActive = index === currentIndex;
2312
- const thumbDims = thumbnailDimensions[index];
2313
- const baseSizeValue = thumbnail.grid.size;
2314
- const activeSizeValue = baseSizeValue * (isActive ? thumbnail.activeState.scale : 1);
2315
- const getFitDimensions = () => {
2316
- if (thumbnail.fit !== "fit" || !thumbDims) return {};
2317
- const aspectRatio = thumbDims.width / thumbDims.height;
2318
- if (slider.direction === "horiz") {
2319
- const heightValue = activeSizeValue;
2320
- const widthValue = heightValue * aspectRatio;
2321
- return {
2322
- width: scalingValue(widthValue, isEditor),
2323
- height: scalingValue(heightValue, isEditor)
2324
- };
2325
- } else {
2326
- const widthValue = activeSizeValue;
2327
- const heightValue = widthValue / aspectRatio;
2328
- return {
2329
- width: scalingValue(widthValue, isEditor),
2330
- height: scalingValue(heightValue, isEditor)
2331
- };
2435
+ imageCaption.isActive && lightboxStyles.imageCaption && (() => {
2436
+ const { widthSettings, fontSettings, letterSpacing, textAlign, wordSpacing, fontSizeLineHeight, textAppearance, color } = lightboxStyles.imageCaption;
2437
+ return /* @__PURE__ */ 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__ */ jsx(
2459
+ "div",
2460
+ {
2461
+ "data-styles": "caption",
2462
+ className: classes.captionTextInner,
2463
+ style: { ["--link-hover-color"]: imageCaption.hover },
2464
+ children: /* @__PURE__ */ jsx(RichTextRenderer, { content: content[currentIndex].imageCaption })
2332
2465
  }
2333
- };
2334
- return /* @__PURE__ */ jsx(
2335
- "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__ */ 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__ */ jsx(
2506
+ "div",
2336
2507
  {
2337
- 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
+ }),
2338
2514
  style: {
2339
- ...slider.direction === "horiz" && thumbnail.fit !== "fit" ? { height: scalingValue(activeSizeValue, isEditor) } : {},
2340
- ...slider.direction === "vert" && thumbnail.fit !== "fit" ? { width: scalingValue(activeSizeValue, isEditor) } : {},
2341
- ...thumbnail.fit === "cover" ? { width: scalingValue(activeSizeValue, isEditor), height: scalingValue(activeSizeValue, isEditor) } : {},
2342
- ...thumbnail.fit === "fit" ? getFitDimensions() : {},
2343
- transition: isActive ? "all 0.2s ease" : "none",
2344
- opacity: isActive ? thumbnail.activeState.opacity / 100 : thumbnail.opacity / 100,
2345
- ["--thumb-hover"]: thumbnail.activeState.opacity / 100
2346
- },
2347
- onClick: (e) => {
2348
- var _a;
2349
- e.stopPropagation();
2350
- setCurrentIndex(index);
2351
- (_a = lightboxRef.current) == null ? void 0 : _a.go(index);
2515
+ gap: scalingValue(thumbnail.grid.gap, isEditor),
2516
+ justifyContent: getJustifyContent()
2352
2517
  },
2353
- onMouseEnter: () => {
2354
- var _a;
2355
- if (thumbnail.triggers === "hov") {
2356
- (_a = lightboxRef.current) == null ? void 0 : _a.go(index);
2357
- }
2358
- },
2359
- children: /* @__PURE__ */ jsx(
2360
- "img",
2361
- {
2362
- src: item.image.url,
2363
- alt: item.image.name ?? "",
2364
- onLoad: (e) => {
2365
- const img2 = e.currentTarget;
2366
- if (img2.naturalWidth && img2.naturalHeight) {
2367
- setThumbnailDimensions((prev) => ({
2368
- ...prev,
2369
- [index]: { width: img2.naturalWidth, height: img2.naturalHeight }
2370
- }));
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) };
2371
2530
  }
2372
- },
2373
- style: {
2374
- objectFit: thumbnail.fit === "cover" ? "cover" : "contain",
2375
- ...thumbnail.fit === "fit" ? { maxWidth: "100%", maxHeight: "100%", objectFit: "contain" } : {},
2376
- ...thumbnail.fit === "cover" && slider.direction === "horiz" ? { width: "100%", height: "100%" } : {}
2377
2531
  }
2378
- }
2379
- )
2380
- },
2381
- `${item.image.name}-${index}`
2382
- );
2383
- })
2384
- }
2385
- )
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__ */ 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__ */ 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
+ })()
2386
2604
  ]
2387
2605
  }
2388
2606
  )
@@ -2390,6 +2608,9 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2390
2608
  document.getElementById(portalId)
2391
2609
  );
2392
2610
  };
2611
+ function ArrowIcon({ color, className }) {
2612
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 10 18", className, children: /* @__PURE__ */ jsx("g", { id: "Symbols", stroke: "none", strokeWidth: "1", fillRule: "evenodd", children: /* @__PURE__ */ 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
+ }
2393
2614
  const LightboxComponent = {
2394
2615
  element: LightboxGallery,
2395
2616
  id: "lightbox",
@@ -2887,6 +3108,22 @@ const LightboxComponent = {
2887
3108
  }
2888
3109
  }
2889
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
+ }
2890
3127
  }
2891
3128
  }
2892
3129
  },
@@ -2995,7 +3232,7 @@ const LightboxComponent = {
2995
3232
  padding: { top: 0.06, right: 0, bottom: 0.06, left: 0 }
2996
3233
  },
2997
3234
  controls: {
2998
- isActive: true,
3235
+ isActive: false,
2999
3236
  arrowsImgUrl: null,
3000
3237
  offset: { x: 0, y: 0 },
3001
3238
  scale: 1,
@@ -3006,6 +3243,8 @@ const LightboxComponent = {
3006
3243
  color: "rgba(28,31,34,0.9)",
3007
3244
  blur: 0,
3008
3245
  closeIconUrl: null,
3246
+ closeIconColor: "#000000",
3247
+ closeIconHover: "#cccccc",
3009
3248
  closeIconAlign: "top-right",
3010
3249
  closeIconOffset: { x: 0, y: 0 },
3011
3250
  closeIconScale: 1
@@ -3063,7 +3302,7 @@ const LightboxComponent = {
3063
3302
  padding: { top: 0.06, right: 0.05, bottom: 0.06, left: 0.05 }
3064
3303
  },
3065
3304
  controls: {
3066
- isActive: true,
3305
+ isActive: false,
3067
3306
  arrowsImgUrl: null,
3068
3307
  offset: { x: 0, y: 0 },
3069
3308
  scale: 1,
@@ -3074,6 +3313,8 @@ const LightboxComponent = {
3074
3313
  color: "rgba(28,31,34,0.9)",
3075
3314
  blur: 0,
3076
3315
  closeIconUrl: null,
3316
+ closeIconColor: "#000000",
3317
+ closeIconHover: "#cccccc",
3077
3318
  closeIconAlign: "top-right",
3078
3319
  closeIconOffset: { x: 0, y: 0 },
3079
3320
  closeIconScale: 1
@@ -3131,7 +3372,7 @@ const LightboxComponent = {
3131
3372
  padding: { top: 0.06, right: 0.1, bottom: 0.06, left: 0.1 }
3132
3373
  },
3133
3374
  controls: {
3134
- isActive: true,
3375
+ isActive: false,
3135
3376
  arrowsImgUrl: null,
3136
3377
  offset: { x: 0, y: 0 },
3137
3378
  scale: 1,
@@ -3142,6 +3383,8 @@ const LightboxComponent = {
3142
3383
  color: "rgba(28,31,34,0.9)",
3143
3384
  blur: 0,
3144
3385
  closeIconUrl: null,
3386
+ closeIconColor: "#000000",
3387
+ closeIconHover: "#cccccc",
3145
3388
  closeIconAlign: "top-right",
3146
3389
  closeIconOffset: { x: 0, y: 0 },
3147
3390
  closeIconScale: 1