@cntrl-site/components 0.1.14-0 → 0.1.14-alpha.1
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/ControlSlider/ControlSlider.d.ts +2 -2
- package/dist/Components/ControlSlider/ControlSliderComponent.d.ts +4 -4
- package/dist/Components/Lightbox/Lightbox.d.ts +4 -2
- package/dist/components.css +1 -1
- package/dist/index.js +294 -192
- package/dist/index.mjs +251 -149
- 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] =
|
|
174
|
-
const { widthSettings, fontSettings, letterSpacing, textAlign, wordSpacing, fontSizeLineHeight, textAppearance, color } = sliderStyles.
|
|
175
|
-
const [sliderDimensions, setSliderDimensions] =
|
|
176
|
-
const [wrapperRef, setWrapperRef] =
|
|
177
|
-
const [currentSlideIndex, setCurrentSlideIndex] =
|
|
178
|
-
const [key, setKey] =
|
|
179
|
-
const { direction, transition, controls, pagination: pagination2,
|
|
180
|
-
const prevSliderTypeRef =
|
|
173
|
+
const [sliderRef, setSliderRef] = react.useState(null);
|
|
174
|
+
const { widthSettings, fontSettings, letterSpacing, textAlign, wordSpacing, fontSizeLineHeight, textAppearance, color } = sliderStyles.caption;
|
|
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
|
+
const { direction, transition, controls, pagination: pagination2, caption: caption2, triggers } = settings;
|
|
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;
|
|
@@ -212,7 +212,7 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
212
212
|
backgroundColor: transition.backgroundColor && transition.type === "fade in" ? transition.backgroundColor : "transparent"
|
|
213
213
|
},
|
|
214
214
|
children: [
|
|
215
|
-
settings.
|
|
215
|
+
settings.caption.isActive && /* @__PURE__ */ jsxRuntime.jsx(
|
|
216
216
|
"div",
|
|
217
217
|
{
|
|
218
218
|
className: cn(styles$3.captionBlock),
|
|
@@ -223,7 +223,7 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
223
223
|
children: content.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
224
224
|
"div",
|
|
225
225
|
{
|
|
226
|
-
className: cn(styles$3.captionText, alignmentClassName[
|
|
226
|
+
className: cn(styles$3.captionText, alignmentClassName[caption2.alignment], {
|
|
227
227
|
[styles$3.withPointerEvents]: index === currentSlideIndex && isEditor,
|
|
228
228
|
[styles$3.active]: index === currentSlideIndex
|
|
229
229
|
}),
|
|
@@ -246,13 +246,13 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
246
246
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
247
247
|
"div",
|
|
248
248
|
{
|
|
249
|
-
"data-styles": "
|
|
249
|
+
"data-styles": "caption",
|
|
250
250
|
className: styles$3.captionTextInner,
|
|
251
251
|
style: {
|
|
252
|
-
"--link-hover-color":
|
|
252
|
+
"--link-hover-color": caption2.hover,
|
|
253
253
|
position: "relative",
|
|
254
|
-
top: scalingValue(
|
|
255
|
-
left: scalingValue(
|
|
254
|
+
top: scalingValue(caption2.offset.y, isEditor),
|
|
255
|
+
left: scalingValue(caption2.offset.x, isEditor)
|
|
256
256
|
},
|
|
257
257
|
children: /* @__PURE__ */ jsxRuntime.jsx(RichTextRenderer, { content: item.imageCaption })
|
|
258
258
|
}
|
|
@@ -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 = {
|
|
@@ -705,7 +705,7 @@ const ControlSliderComponent = {
|
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
707
|
},
|
|
708
|
-
|
|
708
|
+
caption: {
|
|
709
709
|
title: "Caption",
|
|
710
710
|
icon: "text-icon",
|
|
711
711
|
tooltip: "Caption",
|
|
@@ -799,7 +799,7 @@ const ControlSliderComponent = {
|
|
|
799
799
|
hover: "#cccccc"
|
|
800
800
|
},
|
|
801
801
|
direction: "horiz",
|
|
802
|
-
|
|
802
|
+
caption: {
|
|
803
803
|
offset: {
|
|
804
804
|
x: 0,
|
|
805
805
|
y: 0
|
|
@@ -922,7 +922,7 @@ const ControlSliderComponent = {
|
|
|
922
922
|
layoutBased: true,
|
|
923
923
|
type: "object",
|
|
924
924
|
properties: {
|
|
925
|
-
|
|
925
|
+
caption: {
|
|
926
926
|
dataName: "caption",
|
|
927
927
|
type: "object",
|
|
928
928
|
properties: {
|
|
@@ -1020,7 +1020,7 @@ const ControlSliderComponent = {
|
|
|
1020
1020
|
}
|
|
1021
1021
|
},
|
|
1022
1022
|
default: {
|
|
1023
|
-
|
|
1023
|
+
caption: {
|
|
1024
1024
|
widthSettings: {
|
|
1025
1025
|
width: 0.13,
|
|
1026
1026
|
sizing: "auto"
|
|
@@ -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,22 @@ 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 =
|
|
1893
|
-
const { appear, triggers, slider, thumbnail, controls, area,
|
|
1894
|
-
const { widthSettings, fontSettings, letterSpacing, textAlign, wordSpacing, fontSizeLineHeight, textAppearance, color } = lightboxStyles.
|
|
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 { appear, triggers, slider, thumbnail, controls, area, caption: caption2, layout } = settings.lightboxBlock;
|
|
1907
|
+
const { widthSettings, fontSettings, letterSpacing, textAlign, wordSpacing, fontSizeLineHeight, textAppearance, color } = lightboxStyles.caption;
|
|
1895
1908
|
const { appearClass, backdropAppearClass, backdropDisappearClass, disappearClass } = getAnimationClasses(appear.type, appear.direction);
|
|
1896
|
-
|
|
1909
|
+
react.useEffect(() => {
|
|
1897
1910
|
const handleLayoutChange = () => {
|
|
1898
1911
|
setTimeout(() => {
|
|
1899
1912
|
var _a, _b;
|
|
@@ -1910,7 +1923,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
1910
1923
|
window.removeEventListener("ArticleEditor.ComponentContent:change", handleComponentContentChange);
|
|
1911
1924
|
};
|
|
1912
1925
|
}, []);
|
|
1913
|
-
const handleClose =
|
|
1926
|
+
const handleClose = react.useCallback(() => {
|
|
1914
1927
|
const isMobile = window.matchMedia("(max-width: 768px)").matches;
|
|
1915
1928
|
const colorAlpha = getColorAlpha(area.color);
|
|
1916
1929
|
if (isMobile && !isEditor && colorAlpha > 0.9) {
|
|
@@ -1957,6 +1970,19 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
1957
1970
|
(_b = lightboxRef.current) == null ? void 0 : _b.go(dir);
|
|
1958
1971
|
}
|
|
1959
1972
|
};
|
|
1973
|
+
const isClickInImagePadding = (img2, clientX, clientY) => {
|
|
1974
|
+
const rect = img2.getBoundingClientRect();
|
|
1975
|
+
const style = window.getComputedStyle(img2);
|
|
1976
|
+
const paddingTop = parseFloat(style.paddingTop) || 0;
|
|
1977
|
+
const paddingRight = parseFloat(style.paddingRight) || 0;
|
|
1978
|
+
const paddingBottom = parseFloat(style.paddingBottom) || 0;
|
|
1979
|
+
const paddingLeft = parseFloat(style.paddingLeft) || 0;
|
|
1980
|
+
const contentLeft = rect.left + paddingLeft;
|
|
1981
|
+
const contentRight = rect.right - paddingRight;
|
|
1982
|
+
const contentTop = rect.top + paddingTop;
|
|
1983
|
+
const contentBottom = rect.bottom - paddingBottom;
|
|
1984
|
+
return clientX < contentLeft || clientX > contentRight || clientY < contentTop || clientY > contentBottom;
|
|
1985
|
+
};
|
|
1960
1986
|
const handleImageWrapperClick = (e) => {
|
|
1961
1987
|
const currentImage = content[currentIndex];
|
|
1962
1988
|
const isCover = (currentImage == null ? void 0 : currentImage.image.objectFit) === "cover";
|
|
@@ -1974,7 +2000,16 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
1974
2000
|
let inside;
|
|
1975
2001
|
if (isCover && imageRef.current) {
|
|
1976
2002
|
const imgRect = imageRef.current.getBoundingClientRect();
|
|
1977
|
-
|
|
2003
|
+
const style = window.getComputedStyle(imageRef.current);
|
|
2004
|
+
const paddingTop = parseFloat(style.paddingTop) || 0;
|
|
2005
|
+
const paddingRight = parseFloat(style.paddingRight) || 0;
|
|
2006
|
+
const paddingBottom = parseFloat(style.paddingBottom) || 0;
|
|
2007
|
+
const paddingLeft = parseFloat(style.paddingLeft) || 0;
|
|
2008
|
+
const contentLeft = imgRect.left + paddingLeft;
|
|
2009
|
+
const contentRight = imgRect.right - paddingRight;
|
|
2010
|
+
const contentTop = imgRect.top + paddingTop;
|
|
2011
|
+
const contentBottom = imgRect.bottom - paddingBottom;
|
|
2012
|
+
inside = clientX >= contentLeft && clientX <= contentRight && clientY >= contentTop && clientY <= contentBottom;
|
|
1978
2013
|
} else {
|
|
1979
2014
|
const rect = imageRef.current ? getDisplayedImageRect(imageRef.current) : null;
|
|
1980
2015
|
if (!rect) {
|
|
@@ -1991,9 +2026,13 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
1991
2026
|
};
|
|
1992
2027
|
const onImageClick = (e) => {
|
|
1993
2028
|
e.stopPropagation();
|
|
2029
|
+
if (isClickInImagePadding(e.currentTarget, e.clientX, e.clientY)) {
|
|
2030
|
+
handleClose();
|
|
2031
|
+
return;
|
|
2032
|
+
}
|
|
1994
2033
|
handleTriggerClick(e.currentTarget, e.clientX, e.clientY);
|
|
1995
2034
|
};
|
|
1996
|
-
|
|
2035
|
+
react.useEffect(() => {
|
|
1997
2036
|
if (!isOpen) return;
|
|
1998
2037
|
const onKeyDown = (event) => {
|
|
1999
2038
|
var _a, _b;
|
|
@@ -2016,9 +2055,10 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2016
2055
|
window.removeEventListener("keydown", onKeyDown);
|
|
2017
2056
|
};
|
|
2018
2057
|
}, [isOpen, handleClose, content.length]);
|
|
2019
|
-
|
|
2058
|
+
react.useEffect(() => {
|
|
2020
2059
|
if (isOpen) {
|
|
2021
2060
|
setCurrentIndex(0);
|
|
2061
|
+
setSplideKey((prev) => prev + 1);
|
|
2022
2062
|
isClosingRef.current = false;
|
|
2023
2063
|
setIsClosing(false);
|
|
2024
2064
|
setAnimationFinished(false);
|
|
@@ -2032,13 +2072,13 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2032
2072
|
setAnimationFinished(false);
|
|
2033
2073
|
};
|
|
2034
2074
|
}, [isOpen]);
|
|
2035
|
-
|
|
2075
|
+
react.useEffect(() => {
|
|
2036
2076
|
if (prevSliderTypeRef.current !== null && prevSliderTypeRef.current !== slider.type) {
|
|
2037
2077
|
setSplideKey((prev) => prev + 1);
|
|
2038
2078
|
}
|
|
2039
2079
|
prevSliderTypeRef.current = slider.type;
|
|
2040
2080
|
}, [slider.type]);
|
|
2041
|
-
|
|
2081
|
+
react.useEffect(() => {
|
|
2042
2082
|
if (!isOpen) return;
|
|
2043
2083
|
const originalOverflow = document.body.style.overflow;
|
|
2044
2084
|
const isMobile = window.matchMedia("(max-width: 768px)").matches;
|
|
@@ -2073,7 +2113,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2073
2113
|
setAnimationFinished(false);
|
|
2074
2114
|
};
|
|
2075
2115
|
}, [isOpen, isEditor, area.color]);
|
|
2076
|
-
|
|
2116
|
+
react.useEffect(() => {
|
|
2077
2117
|
if (!isOpen) return;
|
|
2078
2118
|
const handleTouchEnd = (e) => {
|
|
2079
2119
|
if (isClosingRef.current) {
|
|
@@ -2122,14 +2162,14 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2122
2162
|
animationTimingFunction: "ease",
|
|
2123
2163
|
animationFillMode: "both"
|
|
2124
2164
|
};
|
|
2125
|
-
if (!
|
|
2165
|
+
if (!document.getElementById(portalId)) return null;
|
|
2126
2166
|
return reactDom.createPortal(
|
|
2127
2167
|
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2128
2168
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2129
2169
|
"div",
|
|
2130
2170
|
{
|
|
2131
2171
|
ref: !isEditor ? animationTargetRef : null,
|
|
2132
|
-
className: cn(classes.background, isClosing ? backdropDisappearClass : backdropAppearClass, { [classes.editor]: isEditor }),
|
|
2172
|
+
className: cn(classes.background, isClosing ? backdropDisappearClass : backdropAppearClass, { [classes.editor]: isEditor }, { [classes.hidden]: !isOpen }),
|
|
2133
2173
|
style: {
|
|
2134
2174
|
...backdropStyles,
|
|
2135
2175
|
...animationFinished && !isEditor && !isClosing ? { position: "absolute" } : {}
|
|
@@ -2140,7 +2180,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2140
2180
|
"div",
|
|
2141
2181
|
{
|
|
2142
2182
|
ref: isEditor ? animationTargetRef : null,
|
|
2143
|
-
className: cn(classes.contentStyle, !isClosing ? appearClass : disappearClass, { [classes.editor]: isEditor }),
|
|
2183
|
+
className: cn(classes.contentStyle, !isClosing ? appearClass : disappearClass, { [classes.editor]: isEditor }, { [classes.hidden]: !isOpen }),
|
|
2144
2184
|
style: {
|
|
2145
2185
|
animationDuration: `${parseInt(appear.duration)}ms`,
|
|
2146
2186
|
animationTimingFunction: "ease",
|
|
@@ -2164,7 +2204,8 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2164
2204
|
height: "100%",
|
|
2165
2205
|
type: slider.type === "fade" || slider.type === "scale" ? "fade" : "loop",
|
|
2166
2206
|
padding: 0,
|
|
2167
|
-
rewind: (slider.type === "scale" || slider.type === "fade") && triggers.repeat === "loop"
|
|
2207
|
+
rewind: (slider.type === "scale" || slider.type === "fade") && triggers.repeat === "loop",
|
|
2208
|
+
start: 0
|
|
2168
2209
|
},
|
|
2169
2210
|
style: { "--splide-speed": slider.duration },
|
|
2170
2211
|
children: content.map((item, index) => {
|
|
@@ -2199,13 +2240,13 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2199
2240
|
},
|
|
2200
2241
|
splideKey
|
|
2201
2242
|
),
|
|
2202
|
-
controls.isActive &&
|
|
2243
|
+
controls.isActive && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2203
2244
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2204
2245
|
"div",
|
|
2205
2246
|
{
|
|
2206
2247
|
className: cn(classes.arrow, { [classes.arrowVertical]: slider.direction === "vert" }),
|
|
2207
2248
|
style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
|
|
2208
|
-
children: /* @__PURE__ */ jsxRuntime.
|
|
2249
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2209
2250
|
"button",
|
|
2210
2251
|
{
|
|
2211
2252
|
className: classes.arrowInner,
|
|
@@ -2215,15 +2256,18 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2215
2256
|
return (_a = lightboxRef.current) == null ? void 0 : _a.go("-1");
|
|
2216
2257
|
},
|
|
2217
2258
|
"aria-label": "Previous",
|
|
2218
|
-
children:
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2259
|
+
children: [
|
|
2260
|
+
controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2261
|
+
SvgImage,
|
|
2262
|
+
{
|
|
2263
|
+
url: controls.arrowsImgUrl,
|
|
2264
|
+
fill: controls.color,
|
|
2265
|
+
hoverFill: controls.hover,
|
|
2266
|
+
className: cn(classes.arrowImg, classes.mirror)
|
|
2267
|
+
}
|
|
2268
|
+
),
|
|
2269
|
+
!controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(ArrowIcon, { color: controls.color, className: cn(classes.arrowIcon, classes.arrowImg, classes.mirror) })
|
|
2270
|
+
]
|
|
2227
2271
|
}
|
|
2228
2272
|
)
|
|
2229
2273
|
}
|
|
@@ -2233,7 +2277,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2233
2277
|
{
|
|
2234
2278
|
className: cn(classes.arrow, classes.nextArrow, { [classes.arrowVertical]: slider.direction === "vert" }),
|
|
2235
2279
|
style: { color: controls.color, ["--arrow-hover-color"]: controls.hover },
|
|
2236
|
-
children: /* @__PURE__ */ jsxRuntime.
|
|
2280
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2237
2281
|
"button",
|
|
2238
2282
|
{
|
|
2239
2283
|
className: classes.arrowInner,
|
|
@@ -2243,15 +2287,18 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2243
2287
|
return (_a = lightboxRef.current) == null ? void 0 : _a.go("+1");
|
|
2244
2288
|
},
|
|
2245
2289
|
"aria-label": "Next",
|
|
2246
|
-
children:
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2290
|
+
children: [
|
|
2291
|
+
controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2292
|
+
SvgImage,
|
|
2293
|
+
{
|
|
2294
|
+
url: controls.arrowsImgUrl,
|
|
2295
|
+
fill: controls.color,
|
|
2296
|
+
hoverFill: controls.hover,
|
|
2297
|
+
className: classes.arrowImg
|
|
2298
|
+
}
|
|
2299
|
+
),
|
|
2300
|
+
!controls.arrowsImgUrl && /* @__PURE__ */ jsxRuntime.jsx(ArrowIcon, { color: controls.color, className: cn(classes.arrowIcon, classes.arrowImg) })
|
|
2301
|
+
]
|
|
2255
2302
|
}
|
|
2256
2303
|
)
|
|
2257
2304
|
}
|
|
@@ -2261,14 +2308,14 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2261
2308
|
const positionStyles = getPositionStyles(area.closeIconAlign, area.closeIconOffset, isEditor);
|
|
2262
2309
|
const scaleTransform = `scale(${area.closeIconScale})`;
|
|
2263
2310
|
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 }) });
|
|
2311
|
+
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, hoverFill: area.closeIconHover }) });
|
|
2265
2312
|
})(),
|
|
2266
|
-
|
|
2313
|
+
caption2.isActive && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2267
2314
|
"div",
|
|
2268
2315
|
{
|
|
2269
2316
|
className: classes.caption,
|
|
2270
2317
|
style: {
|
|
2271
|
-
...getPositionStyles(
|
|
2318
|
+
...getPositionStyles(caption2.alignment, caption2.offset, isEditor),
|
|
2272
2319
|
fontFamily: fontSettings.fontFamily,
|
|
2273
2320
|
fontWeight: fontSettings.fontWeight,
|
|
2274
2321
|
fontStyle: fontSettings.fontStyle,
|
|
@@ -2287,104 +2334,134 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2287
2334
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2288
2335
|
"div",
|
|
2289
2336
|
{
|
|
2290
|
-
"data-styles": "
|
|
2337
|
+
"data-styles": "caption",
|
|
2291
2338
|
className: classes.captionTextInner,
|
|
2292
|
-
style: { ["--link-hover-color"]:
|
|
2339
|
+
style: { ["--link-hover-color"]: caption2.hover },
|
|
2293
2340
|
children: /* @__PURE__ */ jsxRuntime.jsx(RichTextRenderer, { content: content[currentIndex].imageCaption })
|
|
2294
2341
|
}
|
|
2295
2342
|
)
|
|
2296
2343
|
}
|
|
2297
2344
|
),
|
|
2298
|
-
thumbnail.isActive &&
|
|
2299
|
-
"
|
|
2300
|
-
{
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
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
|
-
};
|
|
2345
|
+
thumbnail.isActive && (() => {
|
|
2346
|
+
const [vertical] = thumbnail.position.split("-");
|
|
2347
|
+
const effectivePosition = slider.direction === "horiz" ? `${vertical}-left` : thumbnail.position;
|
|
2348
|
+
const thumbsPositionStyles = getPositionStyles(effectivePosition, thumbnail.offset, isEditor);
|
|
2349
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2350
|
+
"div",
|
|
2351
|
+
{
|
|
2352
|
+
className: classes.thumbsWrapper,
|
|
2353
|
+
style: {
|
|
2354
|
+
position: isEditor ? "absolute" : "fixed",
|
|
2355
|
+
...thumbsPositionStyles,
|
|
2356
|
+
...slider.direction === "horiz" ? {
|
|
2357
|
+
maxWidth: "100vw",
|
|
2358
|
+
width: "100vw",
|
|
2359
|
+
overflowX: "auto",
|
|
2360
|
+
overflowY: "hidden"
|
|
2361
|
+
} : {
|
|
2362
|
+
maxHeight: "100vh",
|
|
2363
|
+
overflowY: "auto",
|
|
2364
|
+
overflowX: "hidden"
|
|
2334
2365
|
}
|
|
2335
|
-
}
|
|
2336
|
-
|
|
2337
|
-
"
|
|
2366
|
+
},
|
|
2367
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2368
|
+
"div",
|
|
2338
2369
|
{
|
|
2339
|
-
className: classes.
|
|
2370
|
+
className: cn(classes.thumbsContainer, {
|
|
2371
|
+
[classes.thumbsContainerVertical]: slider.direction === "vert",
|
|
2372
|
+
[classes.thumbsAlignStart]: thumbnail.align === "start",
|
|
2373
|
+
[classes.thumbsAlignCenter]: thumbnail.align === "center",
|
|
2374
|
+
[classes.thumbsAlignEnd]: thumbnail.align === "end"
|
|
2375
|
+
}),
|
|
2340
2376
|
style: {
|
|
2341
|
-
|
|
2342
|
-
...slider.direction === "vert" && thumbnail.fit !== "fit" ? { width: scalingValue(activeSizeValue, isEditor) } : {},
|
|
2343
|
-
...thumbnail.fit === "cover" ? { width: scalingValue(activeSizeValue, isEditor), height: scalingValue(activeSizeValue, isEditor) } : {},
|
|
2344
|
-
...thumbnail.fit === "fit" ? getFitDimensions() : {},
|
|
2345
|
-
transition: isActive ? "all 0.2s ease" : "none",
|
|
2346
|
-
opacity: isActive ? thumbnail.activeState.opacity / 100 : thumbnail.opacity / 100,
|
|
2347
|
-
["--thumb-hover"]: thumbnail.activeState.opacity / 100
|
|
2348
|
-
},
|
|
2349
|
-
onClick: (e) => {
|
|
2350
|
-
var _a;
|
|
2351
|
-
e.stopPropagation();
|
|
2352
|
-
setCurrentIndex(index);
|
|
2353
|
-
(_a = lightboxRef.current) == null ? void 0 : _a.go(index);
|
|
2354
|
-
},
|
|
2355
|
-
onMouseEnter: () => {
|
|
2356
|
-
var _a;
|
|
2357
|
-
if (thumbnail.triggers === "hov") {
|
|
2358
|
-
(_a = lightboxRef.current) == null ? void 0 : _a.go(index);
|
|
2359
|
-
}
|
|
2377
|
+
gap: scalingValue(thumbnail.grid.gap, isEditor)
|
|
2360
2378
|
},
|
|
2361
|
-
children:
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
}
|
|
2379
|
+
children: content.map((item, index) => {
|
|
2380
|
+
const isActive = index === currentIndex;
|
|
2381
|
+
const thumbDims = thumbnailDimensions[index];
|
|
2382
|
+
const baseSizeValue = thumbnail.grid.size;
|
|
2383
|
+
const activeSizeValue = baseSizeValue * (isActive ? thumbnail.activeState.scale : 1);
|
|
2384
|
+
const getFitDimensions = () => {
|
|
2385
|
+
if (thumbnail.fit !== "fit") return {};
|
|
2386
|
+
if (!thumbDims) {
|
|
2387
|
+
if (slider.direction === "horiz") {
|
|
2388
|
+
return { height: scalingValue(activeSizeValue, isEditor) };
|
|
2389
|
+
} else {
|
|
2390
|
+
return { width: scalingValue(activeSizeValue, isEditor) };
|
|
2373
2391
|
}
|
|
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
2392
|
}
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2393
|
+
const aspectRatio = thumbDims.width / thumbDims.height;
|
|
2394
|
+
if (slider.direction === "horiz") {
|
|
2395
|
+
const heightValue = activeSizeValue;
|
|
2396
|
+
const widthValue = heightValue * aspectRatio;
|
|
2397
|
+
return {
|
|
2398
|
+
width: scalingValue(widthValue, isEditor),
|
|
2399
|
+
height: scalingValue(heightValue, isEditor)
|
|
2400
|
+
};
|
|
2401
|
+
} else {
|
|
2402
|
+
const widthValue = activeSizeValue;
|
|
2403
|
+
const heightValue = widthValue / aspectRatio;
|
|
2404
|
+
return {
|
|
2405
|
+
width: scalingValue(widthValue, isEditor),
|
|
2406
|
+
height: scalingValue(heightValue, isEditor)
|
|
2407
|
+
};
|
|
2408
|
+
}
|
|
2409
|
+
};
|
|
2410
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2411
|
+
"button",
|
|
2412
|
+
{
|
|
2413
|
+
className: classes.thumbItem,
|
|
2414
|
+
style: {
|
|
2415
|
+
...slider.direction === "horiz" && thumbnail.fit !== "fit" ? { height: scalingValue(activeSizeValue, isEditor) } : {},
|
|
2416
|
+
...slider.direction === "vert" && thumbnail.fit !== "fit" ? { width: scalingValue(activeSizeValue, isEditor) } : {},
|
|
2417
|
+
...thumbnail.fit === "cover" ? { width: scalingValue(activeSizeValue, isEditor), height: scalingValue(activeSizeValue, isEditor) } : {},
|
|
2418
|
+
...getFitDimensions(),
|
|
2419
|
+
transition: isActive ? "all 0.3s ease-out" : "none",
|
|
2420
|
+
opacity: isActive ? thumbnail.activeState.opacity / 100 : thumbnail.opacity / 100,
|
|
2421
|
+
["--thumb-hover"]: thumbnail.activeState.opacity / 100
|
|
2422
|
+
},
|
|
2423
|
+
onClick: (e) => {
|
|
2424
|
+
var _a;
|
|
2425
|
+
e.stopPropagation();
|
|
2426
|
+
setCurrentIndex(index);
|
|
2427
|
+
(_a = lightboxRef.current) == null ? void 0 : _a.go(index);
|
|
2428
|
+
},
|
|
2429
|
+
onMouseEnter: () => {
|
|
2430
|
+
var _a;
|
|
2431
|
+
if (thumbnail.triggers === "hov") {
|
|
2432
|
+
(_a = lightboxRef.current) == null ? void 0 : _a.go(index);
|
|
2433
|
+
}
|
|
2434
|
+
},
|
|
2435
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2436
|
+
"img",
|
|
2437
|
+
{
|
|
2438
|
+
src: item.image.url,
|
|
2439
|
+
alt: item.image.name ?? "",
|
|
2440
|
+
onLoad: (e) => {
|
|
2441
|
+
const img2 = e.currentTarget;
|
|
2442
|
+
if (img2.naturalWidth && img2.naturalHeight) {
|
|
2443
|
+
setThumbnailDimensions((prev) => ({
|
|
2444
|
+
...prev,
|
|
2445
|
+
[index]: { width: img2.naturalWidth, height: img2.naturalHeight }
|
|
2446
|
+
}));
|
|
2447
|
+
}
|
|
2448
|
+
},
|
|
2449
|
+
style: {
|
|
2450
|
+
objectFit: thumbnail.fit === "cover" ? "cover" : "contain",
|
|
2451
|
+
...thumbnail.fit === "fit" ? { maxWidth: "100%", maxHeight: "100%", objectFit: "contain" } : {},
|
|
2452
|
+
...thumbnail.fit === "cover" ? { width: "100%", height: "100%" } : {}
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
)
|
|
2456
|
+
},
|
|
2457
|
+
`${item.image.name}-${index}`
|
|
2458
|
+
);
|
|
2459
|
+
})
|
|
2460
|
+
}
|
|
2461
|
+
)
|
|
2462
|
+
}
|
|
2463
|
+
);
|
|
2464
|
+
})()
|
|
2388
2465
|
]
|
|
2389
2466
|
}
|
|
2390
2467
|
)
|
|
@@ -2392,6 +2469,9 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2392
2469
|
document.getElementById(portalId)
|
|
2393
2470
|
);
|
|
2394
2471
|
};
|
|
2472
|
+
function ArrowIcon({ color, className }) {
|
|
2473
|
+
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)" }) }) });
|
|
2474
|
+
}
|
|
2395
2475
|
const LightboxComponent = {
|
|
2396
2476
|
element: LightboxGallery,
|
|
2397
2477
|
id: "lightbox",
|
|
@@ -2889,10 +2969,26 @@ const LightboxComponent = {
|
|
|
2889
2969
|
}
|
|
2890
2970
|
}
|
|
2891
2971
|
}
|
|
2972
|
+
},
|
|
2973
|
+
closeIconColor: {
|
|
2974
|
+
title: "Color",
|
|
2975
|
+
type: "string",
|
|
2976
|
+
display: {
|
|
2977
|
+
type: "settings-color-picker",
|
|
2978
|
+
format: "single"
|
|
2979
|
+
}
|
|
2980
|
+
},
|
|
2981
|
+
closeIconHover: {
|
|
2982
|
+
title: "Hover",
|
|
2983
|
+
type: "string",
|
|
2984
|
+
display: {
|
|
2985
|
+
type: "settings-color-picker",
|
|
2986
|
+
format: "single"
|
|
2987
|
+
}
|
|
2892
2988
|
}
|
|
2893
2989
|
}
|
|
2894
2990
|
},
|
|
2895
|
-
|
|
2991
|
+
caption: {
|
|
2896
2992
|
title: "DESC",
|
|
2897
2993
|
icon: "text-icon",
|
|
2898
2994
|
tooltip: "Description",
|
|
@@ -2997,7 +3093,7 @@ const LightboxComponent = {
|
|
|
2997
3093
|
padding: { top: 0.06, right: 0, bottom: 0.06, left: 0 }
|
|
2998
3094
|
},
|
|
2999
3095
|
controls: {
|
|
3000
|
-
isActive:
|
|
3096
|
+
isActive: false,
|
|
3001
3097
|
arrowsImgUrl: null,
|
|
3002
3098
|
offset: { x: 0, y: 0 },
|
|
3003
3099
|
scale: 1,
|
|
@@ -3008,11 +3104,13 @@ const LightboxComponent = {
|
|
|
3008
3104
|
color: "rgba(28,31,34,0.9)",
|
|
3009
3105
|
blur: 0,
|
|
3010
3106
|
closeIconUrl: null,
|
|
3107
|
+
closeIconColor: "#000000",
|
|
3108
|
+
closeIconHover: "#cccccc",
|
|
3011
3109
|
closeIconAlign: "top-right",
|
|
3012
3110
|
closeIconOffset: { x: 0, y: 0 },
|
|
3013
3111
|
closeIconScale: 1
|
|
3014
3112
|
},
|
|
3015
|
-
|
|
3113
|
+
caption: {
|
|
3016
3114
|
isActive: true,
|
|
3017
3115
|
alignment: "middle-center",
|
|
3018
3116
|
offset: { x: 0, y: 0 },
|
|
@@ -3065,7 +3163,7 @@ const LightboxComponent = {
|
|
|
3065
3163
|
padding: { top: 0.06, right: 0.05, bottom: 0.06, left: 0.05 }
|
|
3066
3164
|
},
|
|
3067
3165
|
controls: {
|
|
3068
|
-
isActive:
|
|
3166
|
+
isActive: false,
|
|
3069
3167
|
arrowsImgUrl: null,
|
|
3070
3168
|
offset: { x: 0, y: 0 },
|
|
3071
3169
|
scale: 1,
|
|
@@ -3076,11 +3174,13 @@ const LightboxComponent = {
|
|
|
3076
3174
|
color: "rgba(28,31,34,0.9)",
|
|
3077
3175
|
blur: 0,
|
|
3078
3176
|
closeIconUrl: null,
|
|
3177
|
+
closeIconColor: "#000000",
|
|
3178
|
+
closeIconHover: "#cccccc",
|
|
3079
3179
|
closeIconAlign: "top-right",
|
|
3080
3180
|
closeIconOffset: { x: 0, y: 0 },
|
|
3081
3181
|
closeIconScale: 1
|
|
3082
3182
|
},
|
|
3083
|
-
|
|
3183
|
+
caption: {
|
|
3084
3184
|
isActive: true,
|
|
3085
3185
|
alignment: "middle-center",
|
|
3086
3186
|
offset: { x: 0, y: 0 },
|
|
@@ -3133,7 +3233,7 @@ const LightboxComponent = {
|
|
|
3133
3233
|
padding: { top: 0.06, right: 0.1, bottom: 0.06, left: 0.1 }
|
|
3134
3234
|
},
|
|
3135
3235
|
controls: {
|
|
3136
|
-
isActive:
|
|
3236
|
+
isActive: false,
|
|
3137
3237
|
arrowsImgUrl: null,
|
|
3138
3238
|
offset: { x: 0, y: 0 },
|
|
3139
3239
|
scale: 1,
|
|
@@ -3144,11 +3244,13 @@ const LightboxComponent = {
|
|
|
3144
3244
|
color: "rgba(28,31,34,0.9)",
|
|
3145
3245
|
blur: 0,
|
|
3146
3246
|
closeIconUrl: null,
|
|
3247
|
+
closeIconColor: "#000000",
|
|
3248
|
+
closeIconHover: "#cccccc",
|
|
3147
3249
|
closeIconAlign: "top-right",
|
|
3148
3250
|
closeIconOffset: { x: 0, y: 0 },
|
|
3149
3251
|
closeIconScale: 1
|
|
3150
3252
|
},
|
|
3151
|
-
|
|
3253
|
+
caption: {
|
|
3152
3254
|
isActive: true,
|
|
3153
3255
|
alignment: "middle-center",
|
|
3154
3256
|
offset: { x: 0, y: 0 },
|
|
@@ -3300,7 +3402,7 @@ const LightboxComponent = {
|
|
|
3300
3402
|
layoutBased: true,
|
|
3301
3403
|
type: "object",
|
|
3302
3404
|
properties: {
|
|
3303
|
-
|
|
3405
|
+
caption: {
|
|
3304
3406
|
dataName: "caption",
|
|
3305
3407
|
type: "object",
|
|
3306
3408
|
properties: {
|
|
@@ -3398,7 +3500,7 @@ const LightboxComponent = {
|
|
|
3398
3500
|
}
|
|
3399
3501
|
},
|
|
3400
3502
|
default: {
|
|
3401
|
-
|
|
3503
|
+
caption: {
|
|
3402
3504
|
widthSettings: {
|
|
3403
3505
|
width: 0.13,
|
|
3404
3506
|
sizing: "auto"
|