@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/LICENSE +21 -21
- package/README.md +2 -2
- package/dist/Components/Lightbox/Lightbox.d.ts +2 -0
- package/dist/components.css +1 -1
- package/dist/index.js +447 -204
- package/dist/index.mjs +404 -161
- package/package.json +68 -68
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
|
|
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] =
|
|
139
|
-
|
|
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] =
|
|
173
|
+
const [sliderRef, setSliderRef] = react.useState(null);
|
|
174
174
|
const { widthSettings, fontSettings, letterSpacing, textAlign, wordSpacing, fontSizeLineHeight, textAppearance, color } = sliderStyles.imageCaption;
|
|
175
|
-
const [sliderDimensions, setSliderDimensions] =
|
|
176
|
-
const [wrapperRef, setWrapperRef] =
|
|
177
|
-
const [currentSlideIndex, setCurrentSlideIndex] =
|
|
178
|
-
const [key, setKey] =
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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] =
|
|
1106
|
-
const [placedImages, setPlacedImages] =
|
|
1107
|
-
const [counter, setCounter] =
|
|
1108
|
-
const imageIdCounter =
|
|
1109
|
-
const [cursorCenter, setCursorCenter] =
|
|
1110
|
-
const [cursorScale, setCursorScale] =
|
|
1111
|
-
const [customCursorImg, setCustomCursorImg] =
|
|
1112
|
-
const lastMousePos =
|
|
1113
|
-
const [isInside, setIsInside] =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
1729
|
-
const
|
|
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
|
|
1743
|
-
const
|
|
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] =
|
|
1859
|
+
const [open, setOpen] = react.useState(false);
|
|
1847
1860
|
const { url } = settings.thumbnailBlock.cover;
|
|
1848
|
-
|
|
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] =
|
|
1882
|
-
const [splideKey, setSplideKey] =
|
|
1883
|
-
const [isClosing, setIsClosing] =
|
|
1884
|
-
const [animationFinished, setAnimationFinished] =
|
|
1885
|
-
const [thumbnailDimensions, setThumbnailDimensions] =
|
|
1886
|
-
const lightboxRef =
|
|
1887
|
-
const prevSliderTypeRef =
|
|
1888
|
-
const imageRef =
|
|
1889
|
-
const isClosingRef =
|
|
1890
|
-
const animationTargetRef =
|
|
1891
|
-
const animationEndHandlerRef =
|
|
1892
|
-
const appearAnimationEndHandlerRef =
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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,13 +2066,16 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2016
2066
|
window.removeEventListener("keydown", onKeyDown);
|
|
2017
2067
|
};
|
|
2018
2068
|
}, [isOpen, handleClose, content.length]);
|
|
2019
|
-
|
|
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);
|
|
2025
2076
|
setThumbnailDimensions({});
|
|
2077
|
+
const event = new CustomEvent("page-overlay");
|
|
2078
|
+
window.dispatchEvent(event);
|
|
2026
2079
|
}
|
|
2027
2080
|
return () => {
|
|
2028
2081
|
if (animationTargetRef.current && animationEndHandlerRef.current) {
|
|
@@ -2032,13 +2085,13 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2032
2085
|
setAnimationFinished(false);
|
|
2033
2086
|
};
|
|
2034
2087
|
}, [isOpen]);
|
|
2035
|
-
|
|
2088
|
+
react.useEffect(() => {
|
|
2036
2089
|
if (prevSliderTypeRef.current !== null && prevSliderTypeRef.current !== slider.type) {
|
|
2037
2090
|
setSplideKey((prev) => prev + 1);
|
|
2038
2091
|
}
|
|
2039
2092
|
prevSliderTypeRef.current = slider.type;
|
|
2040
2093
|
}, [slider.type]);
|
|
2041
|
-
|
|
2094
|
+
react.useEffect(() => {
|
|
2042
2095
|
if (!isOpen) return;
|
|
2043
2096
|
const originalOverflow = document.body.style.overflow;
|
|
2044
2097
|
const isMobile = window.matchMedia("(max-width: 768px)").matches;
|
|
@@ -2061,7 +2114,13 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2061
2114
|
appearAnimationEndHandlerRef.current = handleAppearAnimationEnd;
|
|
2062
2115
|
animationTargetRef.current.addEventListener("animationend", handleAppearAnimationEnd);
|
|
2063
2116
|
}
|
|
2064
|
-
const preventScroll = (e) =>
|
|
2117
|
+
const preventScroll = (e) => {
|
|
2118
|
+
const target = e.target;
|
|
2119
|
+
if (target && (target.closest(`.${classes.thumbsWrapper}`) || target.closest(`.${classes.thumbsContainer}`))) {
|
|
2120
|
+
return;
|
|
2121
|
+
}
|
|
2122
|
+
e.preventDefault();
|
|
2123
|
+
};
|
|
2065
2124
|
document.addEventListener("touchmove", preventScroll, { passive: false });
|
|
2066
2125
|
return () => {
|
|
2067
2126
|
document.body.style.overflow = originalOverflow;
|
|
@@ -2073,13 +2132,17 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2073
2132
|
setAnimationFinished(false);
|
|
2074
2133
|
};
|
|
2075
2134
|
}, [isOpen, isEditor, area.color]);
|
|
2076
|
-
|
|
2135
|
+
react.useEffect(() => {
|
|
2077
2136
|
if (!isOpen) return;
|
|
2078
2137
|
const handleTouchEnd = (e) => {
|
|
2079
2138
|
if (isClosingRef.current) {
|
|
2080
2139
|
e.stopPropagation();
|
|
2081
2140
|
return;
|
|
2082
2141
|
}
|
|
2142
|
+
if (hasDraggedRef.current) {
|
|
2143
|
+
hasDraggedRef.current = false;
|
|
2144
|
+
return;
|
|
2145
|
+
}
|
|
2083
2146
|
const target = e.target;
|
|
2084
2147
|
if (target && (target.closest(`.${classes.thumbsContainer}`) || target.closest(`.${classes.thumbItem}`))) {
|
|
2085
2148
|
return;
|
|
@@ -2115,6 +2178,103 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2115
2178
|
document.removeEventListener("touchend", handleTouchEnd);
|
|
2116
2179
|
};
|
|
2117
2180
|
}, [isOpen, handleClose, currentIndex, content]);
|
|
2181
|
+
const needsCustomVerticalDrag = (slider.type === "scale" || slider.type === "fade") && slider.direction === "vert" && triggers.type === "drag";
|
|
2182
|
+
react.useEffect(() => {
|
|
2183
|
+
var _a, _b;
|
|
2184
|
+
if (!isOpen || !needsCustomVerticalDrag || !((_b = (_a = lightboxRef.current) == null ? void 0 : _a.splide) == null ? void 0 : _b.root)) return;
|
|
2185
|
+
const container = lightboxRef.current.splide.root;
|
|
2186
|
+
const DRAG_THRESHOLD = 30;
|
|
2187
|
+
const handleMove = (clientX, clientY) => {
|
|
2188
|
+
if (dragStartRef.current) {
|
|
2189
|
+
const deltaX = Math.abs(clientX - dragStartRef.current.x);
|
|
2190
|
+
const deltaY = Math.abs(clientY - dragStartRef.current.y);
|
|
2191
|
+
if (deltaX > 0 || deltaY > 0) {
|
|
2192
|
+
hasDraggedRef.current = true;
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
};
|
|
2196
|
+
const handlePointerMove = (e) => {
|
|
2197
|
+
if (dragStartRef.current) {
|
|
2198
|
+
e.preventDefault();
|
|
2199
|
+
handleMove(e.clientX, e.clientY);
|
|
2200
|
+
}
|
|
2201
|
+
};
|
|
2202
|
+
const handleTouchMove = (e) => {
|
|
2203
|
+
if (dragStartRef.current && e.touches.length > 0) {
|
|
2204
|
+
e.preventDefault();
|
|
2205
|
+
handleMove(e.touches[0].clientX, e.touches[0].clientY);
|
|
2206
|
+
}
|
|
2207
|
+
};
|
|
2208
|
+
const handleUp = (clientX, clientY) => {
|
|
2209
|
+
if (!dragStartRef.current || !lightboxRef.current) {
|
|
2210
|
+
dragStartRef.current = null;
|
|
2211
|
+
return;
|
|
2212
|
+
}
|
|
2213
|
+
const deltaX = Math.abs(clientX - dragStartRef.current.x);
|
|
2214
|
+
const deltaY = Math.abs(clientY - dragStartRef.current.y);
|
|
2215
|
+
if (deltaY > DRAG_THRESHOLD && deltaY > deltaX) {
|
|
2216
|
+
lightboxRef.current.go(clientY < dragStartRef.current.y ? "+1" : "-1");
|
|
2217
|
+
}
|
|
2218
|
+
dragStartRef.current = null;
|
|
2219
|
+
};
|
|
2220
|
+
const handlePointerUp = (e) => {
|
|
2221
|
+
if (!dragStartRef.current) {
|
|
2222
|
+
document.removeEventListener("pointerup", handlePointerUp);
|
|
2223
|
+
document.removeEventListener("pointercancel", handlePointerUp);
|
|
2224
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
2225
|
+
return;
|
|
2226
|
+
}
|
|
2227
|
+
handleUp(e.clientX, e.clientY);
|
|
2228
|
+
document.removeEventListener("pointerup", handlePointerUp);
|
|
2229
|
+
document.removeEventListener("pointercancel", handlePointerUp);
|
|
2230
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
2231
|
+
};
|
|
2232
|
+
const handleTouchEnd = (e) => {
|
|
2233
|
+
if (!dragStartRef.current) {
|
|
2234
|
+
document.removeEventListener("touchend", handleTouchEnd);
|
|
2235
|
+
document.removeEventListener("touchcancel", handleTouchEnd);
|
|
2236
|
+
document.removeEventListener("touchmove", handleTouchMove);
|
|
2237
|
+
return;
|
|
2238
|
+
}
|
|
2239
|
+
if (e.changedTouches.length > 0) {
|
|
2240
|
+
const touch = e.changedTouches[0];
|
|
2241
|
+
handleUp(touch.clientX, touch.clientY);
|
|
2242
|
+
}
|
|
2243
|
+
document.removeEventListener("touchend", handleTouchEnd);
|
|
2244
|
+
document.removeEventListener("touchcancel", handleTouchEnd);
|
|
2245
|
+
document.removeEventListener("touchmove", handleTouchMove);
|
|
2246
|
+
};
|
|
2247
|
+
const handlePointerDown = (e) => {
|
|
2248
|
+
dragStartRef.current = { x: e.clientX, y: e.clientY };
|
|
2249
|
+
hasDraggedRef.current = false;
|
|
2250
|
+
document.addEventListener("pointermove", handlePointerMove, { passive: false });
|
|
2251
|
+
document.addEventListener("pointerup", handlePointerUp);
|
|
2252
|
+
document.addEventListener("pointercancel", handlePointerUp);
|
|
2253
|
+
};
|
|
2254
|
+
const handleTouchStart = (e) => {
|
|
2255
|
+
if (e.touches.length > 0) {
|
|
2256
|
+
dragStartRef.current = { x: e.touches[0].clientX, y: e.touches[0].clientY };
|
|
2257
|
+
hasDraggedRef.current = false;
|
|
2258
|
+
document.addEventListener("touchmove", handleTouchMove, { passive: false });
|
|
2259
|
+
document.addEventListener("touchend", handleTouchEnd);
|
|
2260
|
+
document.addEventListener("touchcancel", handleTouchEnd);
|
|
2261
|
+
}
|
|
2262
|
+
};
|
|
2263
|
+
container.addEventListener("pointerdown", handlePointerDown);
|
|
2264
|
+
container.addEventListener("touchstart", handleTouchStart);
|
|
2265
|
+
return () => {
|
|
2266
|
+
container.removeEventListener("pointerdown", handlePointerDown);
|
|
2267
|
+
container.removeEventListener("touchstart", handleTouchStart);
|
|
2268
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
2269
|
+
document.removeEventListener("pointerup", handlePointerUp);
|
|
2270
|
+
document.removeEventListener("pointercancel", handlePointerUp);
|
|
2271
|
+
document.removeEventListener("touchmove", handleTouchMove);
|
|
2272
|
+
document.removeEventListener("touchend", handleTouchEnd);
|
|
2273
|
+
document.removeEventListener("touchcancel", handleTouchEnd);
|
|
2274
|
+
dragStartRef.current = null;
|
|
2275
|
+
hasDraggedRef.current = false;
|
|
2276
|
+
};
|
|
2277
|
+
}, [isOpen, needsCustomVerticalDrag, splideKey]);
|
|
2118
2278
|
const backdropStyles = {
|
|
2119
2279
|
backgroundColor: area.color,
|
|
2120
2280
|
backdropFilter: `blur(${area.blur}px)`,
|
|
@@ -2122,14 +2282,14 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2122
2282
|
animationTimingFunction: "ease",
|
|
2123
2283
|
animationFillMode: "both"
|
|
2124
2284
|
};
|
|
2125
|
-
if (!
|
|
2285
|
+
if (!document.getElementById(portalId)) return null;
|
|
2126
2286
|
return reactDom.createPortal(
|
|
2127
2287
|
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2128
2288
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2129
2289
|
"div",
|
|
2130
2290
|
{
|
|
2131
2291
|
ref: !isEditor ? animationTargetRef : null,
|
|
2132
|
-
className: cn(classes.background, isClosing ? backdropDisappearClass : backdropAppearClass, { [classes.editor]: isEditor }),
|
|
2292
|
+
className: cn(classes.background, isClosing ? backdropDisappearClass : backdropAppearClass, { [classes.editor]: isEditor }, { [classes.hidden]: !isOpen }),
|
|
2133
2293
|
style: {
|
|
2134
2294
|
...backdropStyles,
|
|
2135
2295
|
...animationFinished && !isEditor && !isClosing ? { position: "absolute" } : {}
|
|
@@ -2140,7 +2300,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2140
2300
|
"div",
|
|
2141
2301
|
{
|
|
2142
2302
|
ref: isEditor ? animationTargetRef : null,
|
|
2143
|
-
className: cn(classes.contentStyle, !isClosing ? appearClass : disappearClass, { [classes.editor]: isEditor }),
|
|
2303
|
+
className: cn(classes.contentStyle, !isClosing ? appearClass : disappearClass, { [classes.editor]: isEditor }, { [classes.hidden]: !isOpen }),
|
|
2144
2304
|
style: {
|
|
2145
2305
|
animationDuration: `${parseInt(appear.duration)}ms`,
|
|
2146
2306
|
animationTimingFunction: "ease",
|
|
@@ -2156,15 +2316,20 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2156
2316
|
options: {
|
|
2157
2317
|
arrows: false,
|
|
2158
2318
|
speed: slider.duration ? parseInt(slider.duration) : 500,
|
|
2159
|
-
direction:
|
|
2319
|
+
direction: (() => {
|
|
2320
|
+
const isHoriz = slider.direction === "horiz";
|
|
2321
|
+
return isHoriz || slider.type === "fade" || slider.type === "scale" ? "ltr" : "ttb";
|
|
2322
|
+
})(),
|
|
2160
2323
|
pagination: false,
|
|
2161
|
-
drag
|
|
2324
|
+
// Disable Splide's drag when we need custom vertical drag handling
|
|
2325
|
+
drag: triggers.type === "drag" && !needsCustomVerticalDrag,
|
|
2162
2326
|
perPage: 1,
|
|
2163
2327
|
width: "100%",
|
|
2164
2328
|
height: "100%",
|
|
2165
2329
|
type: slider.type === "fade" || slider.type === "scale" ? "fade" : "loop",
|
|
2166
2330
|
padding: 0,
|
|
2167
|
-
rewind: (slider.type === "scale" || slider.type === "fade") && triggers.repeat === "loop"
|
|
2331
|
+
rewind: (slider.type === "scale" || slider.type === "fade") && triggers.repeat === "loop",
|
|
2332
|
+
start: 0
|
|
2168
2333
|
},
|
|
2169
2334
|
style: { "--splide-speed": slider.duration },
|
|
2170
2335
|
children: content.map((item, index) => {
|
|
@@ -2199,13 +2364,13 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2199
2364
|
},
|
|
2200
2365
|
splideKey
|
|
2201
2366
|
),
|
|
2202
|
-
controls.isActive &&
|
|
2367
|
+
controls.isActive && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2203
2368
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2204
2369
|
"div",
|
|
2205
2370
|
{
|
|
2206
2371
|
className: cn(classes.arrow, { [classes.arrowVertical]: slider.direction === "vert" }),
|
|
2207
2372
|
style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
|
|
2208
|
-
children: /* @__PURE__ */ jsxRuntime.
|
|
2373
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2209
2374
|
"button",
|
|
2210
2375
|
{
|
|
2211
2376
|
className: classes.arrowInner,
|
|
@@ -2215,15 +2380,18 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2215
2380
|
return (_a = lightboxRef.current) == null ? void 0 : _a.go("-1");
|
|
2216
2381
|
},
|
|
2217
2382
|
"aria-label": "Previous",
|
|
2218
|
-
children:
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2383
|
+
children: [
|
|
2384
|
+
controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2385
|
+
SvgImage,
|
|
2386
|
+
{
|
|
2387
|
+
url: controls.arrowsImgUrl,
|
|
2388
|
+
fill: controls.color,
|
|
2389
|
+
hoverFill: controls.hover,
|
|
2390
|
+
className: cn(classes.arrowImg, classes.mirror)
|
|
2391
|
+
}
|
|
2392
|
+
),
|
|
2393
|
+
!controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(ArrowIcon, { color: controls.color, className: cn(classes.arrowIcon, classes.arrowImg, classes.mirror) })
|
|
2394
|
+
]
|
|
2227
2395
|
}
|
|
2228
2396
|
)
|
|
2229
2397
|
}
|
|
@@ -2233,7 +2401,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2233
2401
|
{
|
|
2234
2402
|
className: cn(classes.arrow, classes.nextArrow, { [classes.arrowVertical]: slider.direction === "vert" }),
|
|
2235
2403
|
style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
|
|
2236
|
-
children: /* @__PURE__ */ jsxRuntime.
|
|
2404
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2237
2405
|
"button",
|
|
2238
2406
|
{
|
|
2239
2407
|
className: classes.arrowInner,
|
|
@@ -2243,15 +2411,18 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2243
2411
|
return (_a = lightboxRef.current) == null ? void 0 : _a.go("+1");
|
|
2244
2412
|
},
|
|
2245
2413
|
"aria-label": "Next",
|
|
2246
|
-
children:
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2414
|
+
children: [
|
|
2415
|
+
controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2416
|
+
SvgImage,
|
|
2417
|
+
{
|
|
2418
|
+
url: controls.arrowsImgUrl,
|
|
2419
|
+
fill: controls.color,
|
|
2420
|
+
hoverFill: controls.hover,
|
|
2421
|
+
className: classes.arrowImg
|
|
2422
|
+
}
|
|
2423
|
+
),
|
|
2424
|
+
!controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(ArrowIcon, { color: controls.color, className: cn(classes.arrowIcon, classes.arrowImg) })
|
|
2425
|
+
]
|
|
2255
2426
|
}
|
|
2256
2427
|
)
|
|
2257
2428
|
}
|
|
@@ -2261,130 +2432,177 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2261
2432
|
const positionStyles = getPositionStyles(area.closeIconAlign, area.closeIconOffset, isEditor);
|
|
2262
2433
|
const scaleTransform = `scale(${area.closeIconScale})`;
|
|
2263
2434
|
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 }) });
|
|
2435
|
+
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
2436
|
})(),
|
|
2266
|
-
imageCaption.isActive &&
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
"
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
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
|
-
};
|
|
2437
|
+
imageCaption.isActive && lightboxStyles.imageCaption && (() => {
|
|
2438
|
+
const { widthSettings, fontSettings, letterSpacing, textAlign, wordSpacing, fontSizeLineHeight, textAppearance, color } = lightboxStyles.imageCaption;
|
|
2439
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2440
|
+
"div",
|
|
2441
|
+
{
|
|
2442
|
+
className: classes.caption,
|
|
2443
|
+
style: {
|
|
2444
|
+
...getPositionStyles(imageCaption.alignment, imageCaption.offset, isEditor),
|
|
2445
|
+
fontFamily: fontSettings.fontFamily,
|
|
2446
|
+
fontWeight: fontSettings.fontWeight,
|
|
2447
|
+
fontStyle: fontSettings.fontStyle,
|
|
2448
|
+
width: widthSettings.sizing === "auto" ? "max-content" : scalingValue(widthSettings.width, isEditor),
|
|
2449
|
+
letterSpacing: scalingValue(letterSpacing, isEditor),
|
|
2450
|
+
wordSpacing: scalingValue(wordSpacing, isEditor),
|
|
2451
|
+
textAlign,
|
|
2452
|
+
fontSize: scalingValue(fontSizeLineHeight.fontSize, isEditor),
|
|
2453
|
+
lineHeight: scalingValue(fontSizeLineHeight.lineHeight, isEditor),
|
|
2454
|
+
textTransform: textAppearance.textTransform ?? "none",
|
|
2455
|
+
textDecoration: textAppearance.textDecoration ?? "none",
|
|
2456
|
+
fontVariant: textAppearance.fontVariant ?? "normal",
|
|
2457
|
+
color
|
|
2458
|
+
},
|
|
2459
|
+
onClick: (e) => e.stopPropagation(),
|
|
2460
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2461
|
+
"div",
|
|
2462
|
+
{
|
|
2463
|
+
"data-styles": "caption",
|
|
2464
|
+
className: classes.captionTextInner,
|
|
2465
|
+
style: { ["--link-hover-color"]: imageCaption.hover },
|
|
2466
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(RichTextRenderer, { content: content[currentIndex].imageCaption })
|
|
2334
2467
|
}
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2468
|
+
)
|
|
2469
|
+
}
|
|
2470
|
+
);
|
|
2471
|
+
})(),
|
|
2472
|
+
thumbnail.isActive && (() => {
|
|
2473
|
+
const [vertical, horizontal] = thumbnail.position.split("-");
|
|
2474
|
+
const effectivePosition = slider.direction === "horiz" ? `${vertical}-left` : thumbnail.position;
|
|
2475
|
+
const thumbsPositionStyles = getPositionStyles(effectivePosition, thumbnail.offset, isEditor);
|
|
2476
|
+
const getJustifyContent = () => {
|
|
2477
|
+
if (slider.direction === "horiz") {
|
|
2478
|
+
if (horizontal === "left") return "flex-start";
|
|
2479
|
+
if (horizontal === "center") return "center";
|
|
2480
|
+
if (horizontal === "right") return "flex-end";
|
|
2481
|
+
} else {
|
|
2482
|
+
if (vertical === "top") return "flex-start";
|
|
2483
|
+
if (vertical === "middle") return "center";
|
|
2484
|
+
if (vertical === "bottom") return "flex-end";
|
|
2485
|
+
}
|
|
2486
|
+
return "flex-start";
|
|
2487
|
+
};
|
|
2488
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2489
|
+
"div",
|
|
2490
|
+
{
|
|
2491
|
+
className: classes.thumbsWrapper,
|
|
2492
|
+
onClick: (e) => handleThumbWrapperClick(e),
|
|
2493
|
+
style: {
|
|
2494
|
+
position: isEditor ? "absolute" : "fixed",
|
|
2495
|
+
...thumbsPositionStyles,
|
|
2496
|
+
...slider.direction === "horiz" ? {
|
|
2497
|
+
maxWidth: "100vw",
|
|
2498
|
+
width: "100vw",
|
|
2499
|
+
overflowX: "auto",
|
|
2500
|
+
overflowY: "hidden"
|
|
2501
|
+
} : {
|
|
2502
|
+
maxHeight: "100vh",
|
|
2503
|
+
overflowY: "auto",
|
|
2504
|
+
overflowX: "hidden"
|
|
2505
|
+
}
|
|
2506
|
+
},
|
|
2507
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2508
|
+
"div",
|
|
2338
2509
|
{
|
|
2339
|
-
className: classes.
|
|
2510
|
+
className: cn(classes.thumbsContainer, {
|
|
2511
|
+
[classes.thumbsContainerVertical]: slider.direction === "vert",
|
|
2512
|
+
[classes.thumbsAlignStart]: thumbnail.align === "start",
|
|
2513
|
+
[classes.thumbsAlignCenter]: thumbnail.align === "center",
|
|
2514
|
+
[classes.thumbsAlignEnd]: thumbnail.align === "end"
|
|
2515
|
+
}),
|
|
2340
2516
|
style: {
|
|
2341
|
-
|
|
2342
|
-
|
|
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);
|
|
2517
|
+
gap: scalingValue(thumbnail.grid.gap, isEditor),
|
|
2518
|
+
justifyContent: getJustifyContent()
|
|
2354
2519
|
},
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
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
|
-
}));
|
|
2520
|
+
children: content.map((item, index) => {
|
|
2521
|
+
const isActive = index === currentIndex;
|
|
2522
|
+
const thumbDims = thumbnailDimensions[index];
|
|
2523
|
+
const baseSizeValue = thumbnail.grid.size;
|
|
2524
|
+
const activeSizeValue = baseSizeValue * (isActive ? thumbnail.activeState.scale : 1);
|
|
2525
|
+
const getFitDimensions = () => {
|
|
2526
|
+
if (thumbnail.fit !== "fit") return {};
|
|
2527
|
+
if (!thumbDims) {
|
|
2528
|
+
if (slider.direction === "horiz") {
|
|
2529
|
+
return { height: scalingValue(activeSizeValue, isEditor) };
|
|
2530
|
+
} else {
|
|
2531
|
+
return { width: scalingValue(activeSizeValue, isEditor) };
|
|
2373
2532
|
}
|
|
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
2533
|
}
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2534
|
+
const aspectRatio = thumbDims.width / thumbDims.height;
|
|
2535
|
+
if (slider.direction === "horiz") {
|
|
2536
|
+
const heightValue = activeSizeValue;
|
|
2537
|
+
const widthValue = heightValue * aspectRatio;
|
|
2538
|
+
return {
|
|
2539
|
+
width: scalingValue(widthValue, isEditor),
|
|
2540
|
+
height: scalingValue(heightValue, isEditor)
|
|
2541
|
+
};
|
|
2542
|
+
} else {
|
|
2543
|
+
const widthValue = activeSizeValue;
|
|
2544
|
+
const heightValue = widthValue / aspectRatio;
|
|
2545
|
+
return {
|
|
2546
|
+
width: scalingValue(widthValue, isEditor),
|
|
2547
|
+
height: scalingValue(heightValue, isEditor)
|
|
2548
|
+
};
|
|
2549
|
+
}
|
|
2550
|
+
};
|
|
2551
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2552
|
+
"button",
|
|
2553
|
+
{
|
|
2554
|
+
className: classes.thumbItem,
|
|
2555
|
+
style: {
|
|
2556
|
+
...slider.direction === "horiz" && thumbnail.fit !== "fit" ? { height: scalingValue(activeSizeValue, isEditor) } : {},
|
|
2557
|
+
...slider.direction === "vert" && thumbnail.fit !== "fit" ? { width: scalingValue(activeSizeValue, isEditor) } : {},
|
|
2558
|
+
...thumbnail.fit === "cover" ? { width: scalingValue(activeSizeValue, isEditor), height: scalingValue(activeSizeValue, isEditor) } : {},
|
|
2559
|
+
...getFitDimensions(),
|
|
2560
|
+
transition: isActive ? "all 0.25s ease-out" : "none",
|
|
2561
|
+
opacity: isActive ? thumbnail.activeState.opacity / 100 : thumbnail.opacity / 100,
|
|
2562
|
+
["--thumb-hover"]: thumbnail.activeState.opacity / 100
|
|
2563
|
+
},
|
|
2564
|
+
onClick: (e) => {
|
|
2565
|
+
var _a;
|
|
2566
|
+
e.stopPropagation();
|
|
2567
|
+
setCurrentIndex(index);
|
|
2568
|
+
(_a = lightboxRef.current) == null ? void 0 : _a.go(index);
|
|
2569
|
+
},
|
|
2570
|
+
onMouseEnter: () => {
|
|
2571
|
+
var _a;
|
|
2572
|
+
if (thumbnail.triggers === "hov") {
|
|
2573
|
+
(_a = lightboxRef.current) == null ? void 0 : _a.go(index);
|
|
2574
|
+
}
|
|
2575
|
+
},
|
|
2576
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2577
|
+
"img",
|
|
2578
|
+
{
|
|
2579
|
+
src: item.image.url,
|
|
2580
|
+
alt: item.image.name ?? "",
|
|
2581
|
+
onLoad: (e) => {
|
|
2582
|
+
const img2 = e.currentTarget;
|
|
2583
|
+
if (img2.naturalWidth && img2.naturalHeight) {
|
|
2584
|
+
setThumbnailDimensions((prev) => ({
|
|
2585
|
+
...prev,
|
|
2586
|
+
[index]: { width: img2.naturalWidth, height: img2.naturalHeight }
|
|
2587
|
+
}));
|
|
2588
|
+
}
|
|
2589
|
+
},
|
|
2590
|
+
style: {
|
|
2591
|
+
objectFit: thumbnail.fit === "cover" ? "cover" : "contain",
|
|
2592
|
+
...thumbnail.fit === "fit" ? { maxWidth: "100%", maxHeight: "100%", objectFit: "contain" } : {},
|
|
2593
|
+
...thumbnail.fit === "cover" ? { width: "100%", height: "100%" } : {}
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
)
|
|
2597
|
+
},
|
|
2598
|
+
`${item.image.name}-${index}`
|
|
2599
|
+
);
|
|
2600
|
+
})
|
|
2601
|
+
}
|
|
2602
|
+
)
|
|
2603
|
+
}
|
|
2604
|
+
);
|
|
2605
|
+
})()
|
|
2388
2606
|
]
|
|
2389
2607
|
}
|
|
2390
2608
|
)
|
|
@@ -2392,6 +2610,9 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2392
2610
|
document.getElementById(portalId)
|
|
2393
2611
|
);
|
|
2394
2612
|
};
|
|
2613
|
+
function ArrowIcon({ color, className }) {
|
|
2614
|
+
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)" }) }) });
|
|
2615
|
+
}
|
|
2395
2616
|
const LightboxComponent = {
|
|
2396
2617
|
element: LightboxGallery,
|
|
2397
2618
|
id: "lightbox",
|
|
@@ -2889,6 +3110,22 @@ const LightboxComponent = {
|
|
|
2889
3110
|
}
|
|
2890
3111
|
}
|
|
2891
3112
|
}
|
|
3113
|
+
},
|
|
3114
|
+
closeIconColor: {
|
|
3115
|
+
title: "Color",
|
|
3116
|
+
type: "string",
|
|
3117
|
+
display: {
|
|
3118
|
+
type: "settings-color-picker",
|
|
3119
|
+
format: "single"
|
|
3120
|
+
}
|
|
3121
|
+
},
|
|
3122
|
+
closeIconHover: {
|
|
3123
|
+
title: "Hover",
|
|
3124
|
+
type: "string",
|
|
3125
|
+
display: {
|
|
3126
|
+
type: "settings-color-picker",
|
|
3127
|
+
format: "single"
|
|
3128
|
+
}
|
|
2892
3129
|
}
|
|
2893
3130
|
}
|
|
2894
3131
|
},
|
|
@@ -2997,7 +3234,7 @@ const LightboxComponent = {
|
|
|
2997
3234
|
padding: { top: 0.06, right: 0, bottom: 0.06, left: 0 }
|
|
2998
3235
|
},
|
|
2999
3236
|
controls: {
|
|
3000
|
-
isActive:
|
|
3237
|
+
isActive: false,
|
|
3001
3238
|
arrowsImgUrl: null,
|
|
3002
3239
|
offset: { x: 0, y: 0 },
|
|
3003
3240
|
scale: 1,
|
|
@@ -3008,6 +3245,8 @@ const LightboxComponent = {
|
|
|
3008
3245
|
color: "rgba(28,31,34,0.9)",
|
|
3009
3246
|
blur: 0,
|
|
3010
3247
|
closeIconUrl: null,
|
|
3248
|
+
closeIconColor: "#000000",
|
|
3249
|
+
closeIconHover: "#cccccc",
|
|
3011
3250
|
closeIconAlign: "top-right",
|
|
3012
3251
|
closeIconOffset: { x: 0, y: 0 },
|
|
3013
3252
|
closeIconScale: 1
|
|
@@ -3065,7 +3304,7 @@ const LightboxComponent = {
|
|
|
3065
3304
|
padding: { top: 0.06, right: 0.05, bottom: 0.06, left: 0.05 }
|
|
3066
3305
|
},
|
|
3067
3306
|
controls: {
|
|
3068
|
-
isActive:
|
|
3307
|
+
isActive: false,
|
|
3069
3308
|
arrowsImgUrl: null,
|
|
3070
3309
|
offset: { x: 0, y: 0 },
|
|
3071
3310
|
scale: 1,
|
|
@@ -3076,6 +3315,8 @@ const LightboxComponent = {
|
|
|
3076
3315
|
color: "rgba(28,31,34,0.9)",
|
|
3077
3316
|
blur: 0,
|
|
3078
3317
|
closeIconUrl: null,
|
|
3318
|
+
closeIconColor: "#000000",
|
|
3319
|
+
closeIconHover: "#cccccc",
|
|
3079
3320
|
closeIconAlign: "top-right",
|
|
3080
3321
|
closeIconOffset: { x: 0, y: 0 },
|
|
3081
3322
|
closeIconScale: 1
|
|
@@ -3133,7 +3374,7 @@ const LightboxComponent = {
|
|
|
3133
3374
|
padding: { top: 0.06, right: 0.1, bottom: 0.06, left: 0.1 }
|
|
3134
3375
|
},
|
|
3135
3376
|
controls: {
|
|
3136
|
-
isActive:
|
|
3377
|
+
isActive: false,
|
|
3137
3378
|
arrowsImgUrl: null,
|
|
3138
3379
|
offset: { x: 0, y: 0 },
|
|
3139
3380
|
scale: 1,
|
|
@@ -3144,6 +3385,8 @@ const LightboxComponent = {
|
|
|
3144
3385
|
color: "rgba(28,31,34,0.9)",
|
|
3145
3386
|
blur: 0,
|
|
3146
3387
|
closeIconUrl: null,
|
|
3388
|
+
closeIconColor: "#000000",
|
|
3389
|
+
closeIconHover: "#cccccc",
|
|
3147
3390
|
closeIconAlign: "top-right",
|
|
3148
3391
|
closeIconOffset: { x: 0, y: 0 },
|
|
3149
3392
|
closeIconScale: 1
|