@cntrl-site/sdk 1.24.0 → 1.24.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Components/ControlSlider/ControlSlider.d.ts +1 -2
- package/dist/Components/ImageRevealSlider/ControlImageRevealSliderComponent.d.ts +210 -0
- package/dist/Components/ImageRevealSlider/ImageRevealSlider.d.ts +38 -0
- package/dist/index.js +518 -56
- package/dist/index.mjs +519 -57
- package/dist/sdk.css +1 -1
- package/dist/types/component/Component.d.ts +1 -2
- package/package.json +7 -3
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { z } from "zod";
|
|
|
4
4
|
import UAParser from "ua-parser-js";
|
|
5
5
|
import * as MP4Box from "mp4box";
|
|
6
6
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { useState, useEffect, useRef } from "react";
|
|
7
|
+
import { useState, useEffect, useRef, useMemo } from "react";
|
|
8
8
|
import { Splide, SplideSlide } from "@splidejs/react-splide";
|
|
9
9
|
import cn from "classnames";
|
|
10
10
|
var SectionHeightMode = /* @__PURE__ */ ((SectionHeightMode2) => {
|
|
@@ -1303,7 +1303,7 @@ const bottomRightAlignment = "ControlSlider-module__bottomRightAlignment___kEwrz
|
|
|
1303
1303
|
const clickOverlay = "ControlSlider-module__clickOverlay___DZA28";
|
|
1304
1304
|
const contain = "ControlSlider-module__contain___pLyq7";
|
|
1305
1305
|
const cover = "ControlSlider-module__cover___KdDat";
|
|
1306
|
-
const styles$
|
|
1306
|
+
const styles$3 = {
|
|
1307
1307
|
wrapper,
|
|
1308
1308
|
sliderItem,
|
|
1309
1309
|
sliderImage,
|
|
@@ -1347,15 +1347,15 @@ const styles$2 = {
|
|
|
1347
1347
|
contain,
|
|
1348
1348
|
cover
|
|
1349
1349
|
};
|
|
1350
|
-
const link = "RichTextRenderer-module__link___BWeZ2";
|
|
1351
|
-
const styles$
|
|
1352
|
-
link
|
|
1350
|
+
const link$1 = "RichTextRenderer-module__link___BWeZ2";
|
|
1351
|
+
const styles$2 = {
|
|
1352
|
+
link: link$1
|
|
1353
1353
|
};
|
|
1354
1354
|
const RichTextRenderer = ({ content }) => {
|
|
1355
1355
|
const getChildren = (children) => {
|
|
1356
1356
|
return children.map((child, i) => {
|
|
1357
1357
|
if (child.type === "link") {
|
|
1358
|
-
return /* @__PURE__ */ jsx("a", { className: styles$
|
|
1358
|
+
return /* @__PURE__ */ jsx("a", { className: styles$2.link, href: child.value, target: child.target, children: getChildren(child.children) }, i);
|
|
1359
1359
|
}
|
|
1360
1360
|
return /* @__PURE__ */ jsx("span", { style: getLeafCss(child), children: child.text }, i);
|
|
1361
1361
|
});
|
|
@@ -1383,7 +1383,7 @@ function scalingValue(value, isEditor = false) {
|
|
|
1383
1383
|
}
|
|
1384
1384
|
const svg = "SvgImage-module__svg___q3xE-";
|
|
1385
1385
|
const img = "SvgImage-module__img___VsTm-";
|
|
1386
|
-
const styles = {
|
|
1386
|
+
const styles$1 = {
|
|
1387
1387
|
svg,
|
|
1388
1388
|
img
|
|
1389
1389
|
};
|
|
@@ -1396,13 +1396,13 @@ const SvgImage = ({ url, fill = "#000000", hoverFill = "#CCCCCC", className = ""
|
|
|
1396
1396
|
}
|
|
1397
1397
|
}, []);
|
|
1398
1398
|
if (!url.endsWith(".svg") || !supportsMask) {
|
|
1399
|
-
return /* @__PURE__ */ jsx("img", { src: url, alt: "", className: cn(styles.img, className) });
|
|
1399
|
+
return /* @__PURE__ */ jsx("img", { src: url, alt: "", className: cn(styles$1.img, className) });
|
|
1400
1400
|
}
|
|
1401
1401
|
return /* @__PURE__ */ jsx(
|
|
1402
1402
|
"span",
|
|
1403
1403
|
{
|
|
1404
1404
|
"data-supports-mask": supportsMask,
|
|
1405
|
-
className: cn(styles.svg, className),
|
|
1405
|
+
className: cn(styles$1.svg, className),
|
|
1406
1406
|
style: {
|
|
1407
1407
|
"--svg": `url(${url})`,
|
|
1408
1408
|
"--fill": fill,
|
|
@@ -1412,15 +1412,15 @@ const SvgImage = ({ url, fill = "#000000", hoverFill = "#CCCCCC", className = ""
|
|
|
1412
1412
|
);
|
|
1413
1413
|
};
|
|
1414
1414
|
const alignmentClassName = {
|
|
1415
|
-
"top-left": styles$
|
|
1416
|
-
"top-center": styles$
|
|
1417
|
-
"top-right": styles$
|
|
1418
|
-
"middle-left": styles$
|
|
1419
|
-
"middle-center": styles$
|
|
1420
|
-
"middle-right": styles$
|
|
1421
|
-
"bottom-left": styles$
|
|
1422
|
-
"bottom-center": styles$
|
|
1423
|
-
"bottom-right": styles$
|
|
1415
|
+
"top-left": styles$3.topLeftAlignment,
|
|
1416
|
+
"top-center": styles$3.topCenterAlignment,
|
|
1417
|
+
"top-right": styles$3.topRightAlignment,
|
|
1418
|
+
"middle-left": styles$3.middleLeftAlignment,
|
|
1419
|
+
"middle-center": styles$3.middleCenterAlignment,
|
|
1420
|
+
"middle-right": styles$3.middleRightAlignment,
|
|
1421
|
+
"bottom-left": styles$3.bottomLeftAlignment,
|
|
1422
|
+
"bottom-center": styles$3.bottomCenterAlignment,
|
|
1423
|
+
"bottom-right": styles$3.bottomRightAlignment
|
|
1424
1424
|
};
|
|
1425
1425
|
function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
1426
1426
|
const [sliderRef, setSliderRef] = useState(null);
|
|
@@ -1455,10 +1455,10 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
1455
1455
|
setKey((prev) => prev + 1);
|
|
1456
1456
|
prevSliderTypeRef.current = transition.type;
|
|
1457
1457
|
}, [transition.type]);
|
|
1458
|
-
return /* @__PURE__ */ jsx("div", { className: cn(styles$
|
|
1458
|
+
return /* @__PURE__ */ jsx("div", { className: cn(styles$3.wrapper, { [styles$3.editor]: isEditor }), ref: setWrapperRef, children: /* @__PURE__ */ jsxs(
|
|
1459
1459
|
"div",
|
|
1460
1460
|
{
|
|
1461
|
-
className: styles$
|
|
1461
|
+
className: styles$3.sliderInner,
|
|
1462
1462
|
style: {
|
|
1463
1463
|
width: sliderDimensions ? sliderDimensions.width : "100%",
|
|
1464
1464
|
height: sliderDimensions ? sliderDimensions.height : "100%",
|
|
@@ -1468,17 +1468,17 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
1468
1468
|
settings.caption.isActive && /* @__PURE__ */ jsx(
|
|
1469
1469
|
"div",
|
|
1470
1470
|
{
|
|
1471
|
-
className: cn(styles$
|
|
1471
|
+
className: cn(styles$3.captionBlock),
|
|
1472
1472
|
children: /* @__PURE__ */ jsx(
|
|
1473
1473
|
"div",
|
|
1474
1474
|
{
|
|
1475
|
-
className: styles$
|
|
1475
|
+
className: styles$3.captionTextWrapper,
|
|
1476
1476
|
children: content.map((item, index) => /* @__PURE__ */ jsx(
|
|
1477
1477
|
"div",
|
|
1478
1478
|
{
|
|
1479
|
-
className: cn(styles$
|
|
1480
|
-
[styles$
|
|
1481
|
-
[styles$
|
|
1479
|
+
className: cn(styles$3.captionText, alignmentClassName[caption.alignment], {
|
|
1480
|
+
[styles$3.withPointerEvents]: index === currentSlideIndex && isEditor,
|
|
1481
|
+
[styles$3.active]: index === currentSlideIndex
|
|
1482
1482
|
}),
|
|
1483
1483
|
style: {
|
|
1484
1484
|
fontFamily: fontSettings.fontFamily,
|
|
@@ -1500,7 +1500,7 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
1500
1500
|
"div",
|
|
1501
1501
|
{
|
|
1502
1502
|
"data-styles": "caption",
|
|
1503
|
-
className: styles$
|
|
1503
|
+
className: styles$3.captionTextInner,
|
|
1504
1504
|
style: {
|
|
1505
1505
|
"--link-hover-color": caption.hover,
|
|
1506
1506
|
position: "relative",
|
|
@@ -1543,17 +1543,17 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
1543
1543
|
children: content.map((item, index) => /* @__PURE__ */ jsx(SplideSlide, { children: /* @__PURE__ */ jsx(
|
|
1544
1544
|
"div",
|
|
1545
1545
|
{
|
|
1546
|
-
className: styles$
|
|
1546
|
+
className: styles$3.sliderItem,
|
|
1547
1547
|
children: /* @__PURE__ */ jsx(
|
|
1548
1548
|
"div",
|
|
1549
1549
|
{
|
|
1550
|
-
className: styles$
|
|
1550
|
+
className: styles$3.imgWrapper,
|
|
1551
1551
|
children: /* @__PURE__ */ jsx(
|
|
1552
1552
|
"img",
|
|
1553
1553
|
{
|
|
1554
|
-
className: cn(styles$
|
|
1555
|
-
[styles$
|
|
1556
|
-
[styles$
|
|
1554
|
+
className: cn(styles$3.sliderImage, {
|
|
1555
|
+
[styles$3.contain]: item.image.objectFit === "contain",
|
|
1556
|
+
[styles$3.cover]: item.image.objectFit === "cover"
|
|
1557
1557
|
}),
|
|
1558
1558
|
src: item.image.url,
|
|
1559
1559
|
alt: item.image.name ?? ""
|
|
@@ -1570,8 +1570,8 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
1570
1570
|
/* @__PURE__ */ jsx(
|
|
1571
1571
|
"div",
|
|
1572
1572
|
{
|
|
1573
|
-
className: cn(styles$
|
|
1574
|
-
[styles$
|
|
1573
|
+
className: cn(styles$3.arrow, {
|
|
1574
|
+
[styles$3.arrowVertical]: direction === "vert"
|
|
1575
1575
|
}),
|
|
1576
1576
|
style: {
|
|
1577
1577
|
color: controls.color,
|
|
@@ -1583,7 +1583,7 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
1583
1583
|
onClick: () => {
|
|
1584
1584
|
handleArrowClick("-1");
|
|
1585
1585
|
},
|
|
1586
|
-
className: styles$
|
|
1586
|
+
className: styles$3.arrowInner,
|
|
1587
1587
|
style: {
|
|
1588
1588
|
transform: `translate(${scalingValue(controlsOffsetX, isEditor)}, ${scalingValue(controlsOffsetY * (direction === "horiz" ? 1 : -1), isEditor)}) scale(${settings.controls.scale / 100}) rotate(${direction === "horiz" ? "0deg" : "90deg"})`
|
|
1589
1589
|
},
|
|
@@ -1594,10 +1594,10 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
1594
1594
|
url: controls.arrowsImgUrl,
|
|
1595
1595
|
fill: controls.color,
|
|
1596
1596
|
hoverFill: controls.hover,
|
|
1597
|
-
className: cn(styles$
|
|
1597
|
+
className: cn(styles$3.arrowImg, styles$3.mirror)
|
|
1598
1598
|
}
|
|
1599
1599
|
),
|
|
1600
|
-
!controls.arrowsImgUrl && /* @__PURE__ */ jsx(ArrowIcon, { color: controls.color, className: cn(styles$
|
|
1600
|
+
!controls.arrowsImgUrl && /* @__PURE__ */ jsx(ArrowIcon, { color: controls.color, className: cn(styles$3.arrowIcon, styles$3.arrowImg, styles$3.mirror) })
|
|
1601
1601
|
]
|
|
1602
1602
|
}
|
|
1603
1603
|
)
|
|
@@ -1606,8 +1606,8 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
1606
1606
|
/* @__PURE__ */ jsx(
|
|
1607
1607
|
"div",
|
|
1608
1608
|
{
|
|
1609
|
-
className: cn(styles$
|
|
1610
|
-
[styles$
|
|
1609
|
+
className: cn(styles$3.arrow, styles$3.nextArrow, {
|
|
1610
|
+
[styles$3.arrowVertical]: direction === "vert"
|
|
1611
1611
|
}),
|
|
1612
1612
|
style: {
|
|
1613
1613
|
color: controls.color,
|
|
@@ -1616,7 +1616,7 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
1616
1616
|
children: /* @__PURE__ */ jsxs(
|
|
1617
1617
|
"button",
|
|
1618
1618
|
{
|
|
1619
|
-
className: styles$
|
|
1619
|
+
className: styles$3.arrowInner,
|
|
1620
1620
|
onClick: () => handleArrowClick("+1"),
|
|
1621
1621
|
style: {
|
|
1622
1622
|
transform: `translate(${scalingValue(controlsOffsetX * (direction === "horiz" ? -1 : 1), isEditor)}, ${scalingValue(controlsOffsetY, isEditor)}) scale(${settings.controls.scale / 100}) rotate(${direction === "horiz" ? "0deg" : "90deg"})`
|
|
@@ -1628,10 +1628,10 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
1628
1628
|
url: controls.arrowsImgUrl,
|
|
1629
1629
|
fill: controls.color,
|
|
1630
1630
|
hoverFill: controls.hover,
|
|
1631
|
-
className: styles$
|
|
1631
|
+
className: styles$3.arrowImg
|
|
1632
1632
|
}
|
|
1633
1633
|
),
|
|
1634
|
-
!controls.arrowsImgUrl && /* @__PURE__ */ jsx(ArrowIcon, { color: controls.color, className: cn(styles$
|
|
1634
|
+
!controls.arrowsImgUrl && /* @__PURE__ */ jsx(ArrowIcon, { color: controls.color, className: cn(styles$3.arrowIcon, styles$3.arrowImg) })
|
|
1635
1635
|
]
|
|
1636
1636
|
}
|
|
1637
1637
|
)
|
|
@@ -1641,7 +1641,7 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
1641
1641
|
triggers.triggersList.click && /* @__PURE__ */ jsx(
|
|
1642
1642
|
"div",
|
|
1643
1643
|
{
|
|
1644
|
-
className: styles$
|
|
1644
|
+
className: styles$3.clickOverlay,
|
|
1645
1645
|
onClick: () => {
|
|
1646
1646
|
if (sliderRef) {
|
|
1647
1647
|
sliderRef.go("+1");
|
|
@@ -1652,21 +1652,21 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
1652
1652
|
pagination2.isActive && /* @__PURE__ */ jsx(
|
|
1653
1653
|
"div",
|
|
1654
1654
|
{
|
|
1655
|
-
className: cn(styles$
|
|
1656
|
-
[styles$
|
|
1657
|
-
[styles$
|
|
1658
|
-
[styles$
|
|
1659
|
-
[styles$
|
|
1660
|
-
[styles$
|
|
1661
|
-
[styles$
|
|
1662
|
-
[styles$
|
|
1663
|
-
[styles$
|
|
1664
|
-
[styles$
|
|
1655
|
+
className: cn(styles$3.pagination, {
|
|
1656
|
+
[styles$3.paginationInsideBottom]: pagination2.position === "inside-1" && direction === "horiz",
|
|
1657
|
+
[styles$3.paginationInsideTop]: pagination2.position === "inside-2" && direction === "horiz",
|
|
1658
|
+
[styles$3.paginationOutsideBottom]: pagination2.position === "outside-1" && direction === "horiz",
|
|
1659
|
+
[styles$3.paginationOutsideTop]: pagination2.position === "outside-2" && direction === "horiz",
|
|
1660
|
+
[styles$3.paginationInsideLeft]: pagination2.position === "inside-1" && direction === "vert",
|
|
1661
|
+
[styles$3.paginationInsideRight]: pagination2.position === "inside-2" && direction === "vert",
|
|
1662
|
+
[styles$3.paginationOutsideLeft]: pagination2.position === "outside-1" && direction === "vert",
|
|
1663
|
+
[styles$3.paginationOutsideRight]: pagination2.position === "outside-2" && direction === "vert",
|
|
1664
|
+
[styles$3.paginationVertical]: direction === "vert"
|
|
1665
1665
|
}),
|
|
1666
1666
|
children: /* @__PURE__ */ jsx(
|
|
1667
1667
|
"div",
|
|
1668
1668
|
{
|
|
1669
|
-
className: styles$
|
|
1669
|
+
className: styles$3.paginationInner,
|
|
1670
1670
|
style: {
|
|
1671
1671
|
backgroundColor: pagination2.colors[2],
|
|
1672
1672
|
transform: `scale(${pagination2.scale / 100}) translate(${scalingValue(pagination2.offset.x, isEditor)}, ${scalingValue(pagination2.offset.y, isEditor)}) rotate(${direction === "horiz" ? "0deg" : "90deg"})`
|
|
@@ -1679,12 +1679,12 @@ function ControlSlider({ settings, content, styles: sliderStyles, isEditor }) {
|
|
|
1679
1679
|
sliderRef.go(index);
|
|
1680
1680
|
}
|
|
1681
1681
|
},
|
|
1682
|
-
className: cn(styles$
|
|
1682
|
+
className: cn(styles$3.paginationItem),
|
|
1683
1683
|
children: /* @__PURE__ */ jsx(
|
|
1684
1684
|
"div",
|
|
1685
1685
|
{
|
|
1686
|
-
className: cn(styles$
|
|
1687
|
-
[styles$
|
|
1686
|
+
className: cn(styles$3.dot, {
|
|
1687
|
+
[styles$3.activeDot]: index === currentSlideIndex
|
|
1688
1688
|
}),
|
|
1689
1689
|
style: {
|
|
1690
1690
|
backgroundColor: index === currentSlideIndex ? pagination2.colors[0] : pagination2.colors[1],
|
|
@@ -2255,8 +2255,470 @@ const ControlSliderComponent = {
|
|
|
2255
2255
|
required: ["settings", "content", "styles"]
|
|
2256
2256
|
}
|
|
2257
2257
|
};
|
|
2258
|
+
const imageRevealSlider = "ImageRevealSlider-module__imageRevealSlider___UE5Ob";
|
|
2259
|
+
const image = "ImageRevealSlider-module__image___Qjt-e";
|
|
2260
|
+
const link = "ImageRevealSlider-module__link___N-iLG";
|
|
2261
|
+
const styles = {
|
|
2262
|
+
imageRevealSlider,
|
|
2263
|
+
image,
|
|
2264
|
+
link
|
|
2265
|
+
};
|
|
2266
|
+
function isMouseOverImage(mouseX, mouseY, placedImages) {
|
|
2267
|
+
for (const img2 of placedImages) {
|
|
2268
|
+
const imgEl = new Image();
|
|
2269
|
+
imgEl.src = img2.url;
|
|
2270
|
+
const imgWidth = img2.width ? Number.parseFloat(img2.width) : imgEl.naturalWidth;
|
|
2271
|
+
const imgHeight = imgEl.naturalHeight / imgEl.naturalWidth * imgWidth;
|
|
2272
|
+
const halfW = imgWidth / 2;
|
|
2273
|
+
const halfH = imgHeight / 2;
|
|
2274
|
+
if (mouseX >= img2.x - halfW && mouseX <= img2.x + halfW && mouseY >= img2.y - halfH && mouseY <= img2.y + halfH) {
|
|
2275
|
+
return true;
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
return false;
|
|
2279
|
+
}
|
|
2280
|
+
function getImageSize(url) {
|
|
2281
|
+
return new Promise((resolve) => {
|
|
2282
|
+
const img2 = new Image();
|
|
2283
|
+
img2.src = url;
|
|
2284
|
+
img2.onload = () => {
|
|
2285
|
+
resolve({ width: img2.naturalWidth, height: img2.naturalHeight });
|
|
2286
|
+
};
|
|
2287
|
+
});
|
|
2288
|
+
}
|
|
2289
|
+
async function calculateImageWidthHeight(imgUrl, sizeType, customWidth, randomRange) {
|
|
2290
|
+
let width;
|
|
2291
|
+
let height;
|
|
2292
|
+
if (sizeType === "custom") {
|
|
2293
|
+
width = customWidth;
|
|
2294
|
+
const size = await getImageSize(imgUrl);
|
|
2295
|
+
height = size.height / size.width * width;
|
|
2296
|
+
} else if (sizeType === "random") {
|
|
2297
|
+
width = Math.random() * (randomRange.max - randomRange.min) + randomRange.min;
|
|
2298
|
+
const size = await getImageSize(imgUrl);
|
|
2299
|
+
height = size.height / size.width * width;
|
|
2300
|
+
} else {
|
|
2301
|
+
const size = await getImageSize(imgUrl);
|
|
2302
|
+
width = size.width;
|
|
2303
|
+
height = size.height;
|
|
2304
|
+
}
|
|
2305
|
+
return { width, height, finalWidth: `${width}px` };
|
|
2306
|
+
}
|
|
2307
|
+
function ImageRevealSlider({ settings, content, isEditor }) {
|
|
2308
|
+
const divRef = useRef(null);
|
|
2309
|
+
const [placedImages, setPlacedImages] = useState([]);
|
|
2310
|
+
const [counter, setCounter] = useState(0);
|
|
2311
|
+
const imageIdCounter = useRef(0);
|
|
2312
|
+
const defaultImageCount = 1;
|
|
2313
|
+
const { sizeType, imageWidth: customWidth, randomRangeImageWidth: randomRange } = settings.imageSize;
|
|
2314
|
+
const { revealPosition, visible, target } = settings.position;
|
|
2315
|
+
const { cursorType, defaultCursor, hoverCursor } = settings.cursor;
|
|
2316
|
+
const createNewImage = async (imgData, containerWidth, containerHeight, position = {}) => {
|
|
2317
|
+
const { width, height, finalWidth } = await calculateImageWidthHeight(
|
|
2318
|
+
imgData.image.url,
|
|
2319
|
+
sizeType,
|
|
2320
|
+
customWidth,
|
|
2321
|
+
randomRange
|
|
2322
|
+
);
|
|
2323
|
+
let x = position.x ?? Math.random() * containerWidth;
|
|
2324
|
+
let y = position.y ?? Math.random() * containerHeight;
|
|
2325
|
+
const adjustedX = Math.min(Math.max(x, width / 2), containerWidth - width / 2);
|
|
2326
|
+
const adjustedY = Math.min(Math.max(y, height / 2), containerHeight - height / 2);
|
|
2327
|
+
return {
|
|
2328
|
+
id: imageIdCounter.current++,
|
|
2329
|
+
url: imgData.image.url,
|
|
2330
|
+
link: imgData.link,
|
|
2331
|
+
name: imgData.image.name,
|
|
2332
|
+
x: adjustedX,
|
|
2333
|
+
y: adjustedY,
|
|
2334
|
+
width: finalWidth
|
|
2335
|
+
};
|
|
2336
|
+
};
|
|
2337
|
+
const defaultContentUrls = useMemo(() => {
|
|
2338
|
+
const defaultContentLength = Math.min(content.length, defaultImageCount);
|
|
2339
|
+
return content.filter((_, i) => i < defaultContentLength).map((c) => c.image.url).join("-");
|
|
2340
|
+
}, [content]);
|
|
2341
|
+
useEffect(() => {
|
|
2342
|
+
if (!divRef.current || content.length === 0) return;
|
|
2343
|
+
const rect = divRef.current.getBoundingClientRect();
|
|
2344
|
+
const containerWidth = rect.width;
|
|
2345
|
+
const containerHeight = rect.height;
|
|
2346
|
+
const defaultPlaced = [];
|
|
2347
|
+
const placeImages = async () => {
|
|
2348
|
+
for (let i = 0; i < defaultImageCount && i < content.length; i++) {
|
|
2349
|
+
const imgData = content[i];
|
|
2350
|
+
const newImg = await createNewImage(imgData, containerWidth, containerHeight);
|
|
2351
|
+
defaultPlaced.push(newImg);
|
|
2352
|
+
}
|
|
2353
|
+
setPlacedImages(defaultPlaced);
|
|
2354
|
+
setCounter(defaultImageCount % content.length);
|
|
2355
|
+
};
|
|
2356
|
+
placeImages();
|
|
2357
|
+
}, [defaultContentUrls, sizeType, customWidth, randomRange]);
|
|
2358
|
+
useEffect(() => {
|
|
2359
|
+
if (visible === "lastOne") {
|
|
2360
|
+
setPlacedImages((prev) => prev.length > 0 ? [prev[prev.length - 1]] : []);
|
|
2361
|
+
}
|
|
2362
|
+
}, [visible]);
|
|
2363
|
+
const handleClick = async (e) => {
|
|
2364
|
+
if (!divRef.current) return;
|
|
2365
|
+
const rect = divRef.current.getBoundingClientRect();
|
|
2366
|
+
const clickX = e.clientX - rect.left;
|
|
2367
|
+
const clickY = e.clientY - rect.top;
|
|
2368
|
+
if (target === "image" && !isMouseOverImage(clickX, clickY, placedImages)) return;
|
|
2369
|
+
let x = 0, y = 0;
|
|
2370
|
+
if (revealPosition === "onClick") {
|
|
2371
|
+
x = clickX;
|
|
2372
|
+
y = clickY;
|
|
2373
|
+
} else if (revealPosition === "same") {
|
|
2374
|
+
x = rect.width / 2;
|
|
2375
|
+
y = rect.height / 2;
|
|
2376
|
+
} else {
|
|
2377
|
+
x = Math.random() * rect.width;
|
|
2378
|
+
y = Math.random() * rect.height;
|
|
2379
|
+
}
|
|
2380
|
+
const imgData = content[counter];
|
|
2381
|
+
const newImage = await createNewImage(imgData, rect.width, rect.height, { x, y });
|
|
2382
|
+
setPlacedImages((prev) => visible === "all" ? [...prev, newImage] : [newImage]);
|
|
2383
|
+
setCounter((prev) => prev >= content.length - 1 ? 0 : prev + 1);
|
|
2384
|
+
};
|
|
2385
|
+
const handleMouseMove = (e) => {
|
|
2386
|
+
if (!divRef.current) return;
|
|
2387
|
+
if (cursorType === "system") {
|
|
2388
|
+
divRef.current.style.cursor = "";
|
|
2389
|
+
return;
|
|
2390
|
+
}
|
|
2391
|
+
const rect = divRef.current.getBoundingClientRect();
|
|
2392
|
+
const mouseX = e.clientX - rect.left;
|
|
2393
|
+
const mouseY = e.clientY - rect.top;
|
|
2394
|
+
const isHover = target === "area" || isMouseOverImage(mouseX, mouseY, placedImages);
|
|
2395
|
+
divRef.current.style.cursor = isHover ? `url(${hoverCursor}), auto` : `url(${defaultCursor}), auto`;
|
|
2396
|
+
};
|
|
2397
|
+
return /* @__PURE__ */ jsx(
|
|
2398
|
+
"div",
|
|
2399
|
+
{
|
|
2400
|
+
ref: divRef,
|
|
2401
|
+
onClick: handleClick,
|
|
2402
|
+
onMouseEnter: handleMouseMove,
|
|
2403
|
+
onMouseMove: handleMouseMove,
|
|
2404
|
+
className: styles.imageRevealSlider,
|
|
2405
|
+
children: placedImages.map((img2) => /* @__PURE__ */ jsx(
|
|
2406
|
+
"div",
|
|
2407
|
+
{
|
|
2408
|
+
className: styles.wrapper,
|
|
2409
|
+
style: {
|
|
2410
|
+
top: `${img2.y}px`,
|
|
2411
|
+
left: `${img2.x}px`,
|
|
2412
|
+
position: "absolute",
|
|
2413
|
+
transform: "translate(-50%, -50%)",
|
|
2414
|
+
width: img2.width ?? "auto",
|
|
2415
|
+
height: "auto"
|
|
2416
|
+
},
|
|
2417
|
+
children: target === "area" && img2.link ? /* @__PURE__ */ jsx("a", { href: img2.link, target: "_blank", className: styles.link, children: /* @__PURE__ */ jsx(
|
|
2418
|
+
"img",
|
|
2419
|
+
{
|
|
2420
|
+
src: img2.url,
|
|
2421
|
+
alt: img2.name,
|
|
2422
|
+
className: styles.image
|
|
2423
|
+
},
|
|
2424
|
+
img2.id
|
|
2425
|
+
) }) : /* @__PURE__ */ jsx(
|
|
2426
|
+
"img",
|
|
2427
|
+
{
|
|
2428
|
+
src: img2.url,
|
|
2429
|
+
alt: img2.name,
|
|
2430
|
+
className: styles.image
|
|
2431
|
+
},
|
|
2432
|
+
img2.id
|
|
2433
|
+
)
|
|
2434
|
+
}
|
|
2435
|
+
))
|
|
2436
|
+
}
|
|
2437
|
+
);
|
|
2438
|
+
}
|
|
2439
|
+
const ControlImageRevealSliderComponent = {
|
|
2440
|
+
element: ImageRevealSlider,
|
|
2441
|
+
id: "control-image-reveal",
|
|
2442
|
+
name: "Image reveal",
|
|
2443
|
+
preview: {
|
|
2444
|
+
type: "video",
|
|
2445
|
+
url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K723EY5AH8SKQFK4R31D8FPV.mp4"
|
|
2446
|
+
},
|
|
2447
|
+
defaultSize: {
|
|
2448
|
+
width: 700,
|
|
2449
|
+
height: 400
|
|
2450
|
+
},
|
|
2451
|
+
schema: {
|
|
2452
|
+
type: "object",
|
|
2453
|
+
properties: {
|
|
2454
|
+
settings: {
|
|
2455
|
+
layoutBased: true,
|
|
2456
|
+
type: "object",
|
|
2457
|
+
properties: {
|
|
2458
|
+
imageSize: {
|
|
2459
|
+
name: "IMG SIZE",
|
|
2460
|
+
icon: "size",
|
|
2461
|
+
tooltip: "IMG SIZE",
|
|
2462
|
+
type: "object",
|
|
2463
|
+
properties: {
|
|
2464
|
+
sizeType: {
|
|
2465
|
+
name: "sizeType",
|
|
2466
|
+
type: "string",
|
|
2467
|
+
display: {
|
|
2468
|
+
type: "ratio-group"
|
|
2469
|
+
},
|
|
2470
|
+
enum: ["as Is", "custom", "random"]
|
|
2471
|
+
},
|
|
2472
|
+
imageWidth: {
|
|
2473
|
+
type: "number",
|
|
2474
|
+
label: "W",
|
|
2475
|
+
display: {
|
|
2476
|
+
type: "numeric-input",
|
|
2477
|
+
visible: false
|
|
2478
|
+
}
|
|
2479
|
+
},
|
|
2480
|
+
randomRangeImageWidth: {
|
|
2481
|
+
type: "object",
|
|
2482
|
+
display: {
|
|
2483
|
+
type: "random-range-controls",
|
|
2484
|
+
visible: false
|
|
2485
|
+
},
|
|
2486
|
+
properties: {
|
|
2487
|
+
min: {
|
|
2488
|
+
type: "number"
|
|
2489
|
+
},
|
|
2490
|
+
max: {
|
|
2491
|
+
type: "number"
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
},
|
|
2497
|
+
cursor: {
|
|
2498
|
+
name: "cursor",
|
|
2499
|
+
icon: "cursor",
|
|
2500
|
+
tooltip: "cursor",
|
|
2501
|
+
type: "object",
|
|
2502
|
+
properties: {
|
|
2503
|
+
cursorType: {
|
|
2504
|
+
name: "cursorType",
|
|
2505
|
+
type: "string",
|
|
2506
|
+
display: {
|
|
2507
|
+
type: "ratio-group"
|
|
2508
|
+
},
|
|
2509
|
+
enum: ["system", "custom"]
|
|
2510
|
+
},
|
|
2511
|
+
defaultCursor: {
|
|
2512
|
+
type: ["string", "null"],
|
|
2513
|
+
display: {
|
|
2514
|
+
type: "settings-image-input",
|
|
2515
|
+
title: "Default",
|
|
2516
|
+
visible: false
|
|
2517
|
+
}
|
|
2518
|
+
},
|
|
2519
|
+
hoverCursor: {
|
|
2520
|
+
type: ["string", "null"],
|
|
2521
|
+
display: {
|
|
2522
|
+
type: "settings-image-input",
|
|
2523
|
+
title: "Hover",
|
|
2524
|
+
visible: false
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
},
|
|
2529
|
+
position: {
|
|
2530
|
+
name: "position",
|
|
2531
|
+
icon: "transition",
|
|
2532
|
+
tooltip: "Position",
|
|
2533
|
+
type: "object",
|
|
2534
|
+
properties: {
|
|
2535
|
+
revealPosition: {
|
|
2536
|
+
type: "string",
|
|
2537
|
+
display: {
|
|
2538
|
+
type: "ratio-group"
|
|
2539
|
+
},
|
|
2540
|
+
enum: ["random", "same", "onClick"]
|
|
2541
|
+
},
|
|
2542
|
+
visible: {
|
|
2543
|
+
type: "string",
|
|
2544
|
+
display: {
|
|
2545
|
+
type: "ratio-group"
|
|
2546
|
+
},
|
|
2547
|
+
enum: ["all", "lastOne"]
|
|
2548
|
+
},
|
|
2549
|
+
target: {
|
|
2550
|
+
type: "string",
|
|
2551
|
+
display: {
|
|
2552
|
+
type: "ratio-group"
|
|
2553
|
+
},
|
|
2554
|
+
enum: ["area", "image"]
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
},
|
|
2559
|
+
default: {
|
|
2560
|
+
imageSize: {
|
|
2561
|
+
sizeType: "custom",
|
|
2562
|
+
imageWidth: 500,
|
|
2563
|
+
randomRangeImageWidth: {
|
|
2564
|
+
min: 100,
|
|
2565
|
+
max: 1e3
|
|
2566
|
+
}
|
|
2567
|
+
},
|
|
2568
|
+
cursor: {
|
|
2569
|
+
cursorType: "system",
|
|
2570
|
+
defaultCursor: null,
|
|
2571
|
+
hoverCursor: null
|
|
2572
|
+
},
|
|
2573
|
+
position: {
|
|
2574
|
+
revealPosition: "random",
|
|
2575
|
+
visible: "all",
|
|
2576
|
+
target: "area"
|
|
2577
|
+
}
|
|
2578
|
+
},
|
|
2579
|
+
displayRules: [
|
|
2580
|
+
{
|
|
2581
|
+
if: {
|
|
2582
|
+
name: "imageSize.sizeType",
|
|
2583
|
+
value: "custom"
|
|
2584
|
+
},
|
|
2585
|
+
then: {
|
|
2586
|
+
name: "properties.imageSize.properties.imageWidth.display.visible",
|
|
2587
|
+
value: true
|
|
2588
|
+
}
|
|
2589
|
+
},
|
|
2590
|
+
{
|
|
2591
|
+
if: {
|
|
2592
|
+
name: "imageSize.sizeType",
|
|
2593
|
+
value: "random"
|
|
2594
|
+
},
|
|
2595
|
+
then: {
|
|
2596
|
+
name: "properties.imageSize.properties.randomRangeImageWidth.display.visible",
|
|
2597
|
+
value: true
|
|
2598
|
+
}
|
|
2599
|
+
},
|
|
2600
|
+
{
|
|
2601
|
+
if: [
|
|
2602
|
+
{ name: "position.target", value: "image" },
|
|
2603
|
+
{ name: "cursor.cursorType", value: "custom" }
|
|
2604
|
+
],
|
|
2605
|
+
then: {
|
|
2606
|
+
name: "properties.cursor.properties.defaultCursor.display.visible",
|
|
2607
|
+
value: true
|
|
2608
|
+
}
|
|
2609
|
+
},
|
|
2610
|
+
{
|
|
2611
|
+
if: {
|
|
2612
|
+
name: "cursor.cursorType",
|
|
2613
|
+
value: "custom"
|
|
2614
|
+
},
|
|
2615
|
+
then: {
|
|
2616
|
+
name: "properties.cursor.properties.hoverCursor.display.visible",
|
|
2617
|
+
value: true
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
]
|
|
2621
|
+
},
|
|
2622
|
+
content: {
|
|
2623
|
+
layoutBased: false,
|
|
2624
|
+
type: "array",
|
|
2625
|
+
items: {
|
|
2626
|
+
type: "object",
|
|
2627
|
+
properties: {
|
|
2628
|
+
image: {
|
|
2629
|
+
type: "object",
|
|
2630
|
+
display: {
|
|
2631
|
+
type: "media-input"
|
|
2632
|
+
},
|
|
2633
|
+
properties: {
|
|
2634
|
+
url: {
|
|
2635
|
+
type: "string"
|
|
2636
|
+
},
|
|
2637
|
+
name: {
|
|
2638
|
+
type: "string"
|
|
2639
|
+
},
|
|
2640
|
+
objectFit: {
|
|
2641
|
+
type: "string",
|
|
2642
|
+
enum: ["cover", "contain"]
|
|
2643
|
+
}
|
|
2644
|
+
},
|
|
2645
|
+
required: ["url", "name"]
|
|
2646
|
+
},
|
|
2647
|
+
link: {
|
|
2648
|
+
type: "string",
|
|
2649
|
+
display: {
|
|
2650
|
+
type: "text-input",
|
|
2651
|
+
placeholder: "Enter link..."
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
},
|
|
2655
|
+
required: ["image"]
|
|
2656
|
+
},
|
|
2657
|
+
default: [
|
|
2658
|
+
{
|
|
2659
|
+
image: {
|
|
2660
|
+
objectFit: "cover",
|
|
2661
|
+
url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K740QZCY7R9HD9KTMB6XGPJ4.jpeg",
|
|
2662
|
+
name: "Slider-1.jpeg"
|
|
2663
|
+
},
|
|
2664
|
+
link: ""
|
|
2665
|
+
},
|
|
2666
|
+
{
|
|
2667
|
+
image: {
|
|
2668
|
+
objectFit: "cover",
|
|
2669
|
+
url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K740S36970GH347RCZ8GW6QF.jpeg",
|
|
2670
|
+
name: "Slider-2.jpeg"
|
|
2671
|
+
},
|
|
2672
|
+
link: ""
|
|
2673
|
+
},
|
|
2674
|
+
{
|
|
2675
|
+
image: {
|
|
2676
|
+
objectFit: "cover",
|
|
2677
|
+
url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K740RZ7VG1PWA7CRMR6TW0QS.jpeg",
|
|
2678
|
+
name: "Slider-3.jpeg"
|
|
2679
|
+
},
|
|
2680
|
+
link: ""
|
|
2681
|
+
},
|
|
2682
|
+
{
|
|
2683
|
+
image: {
|
|
2684
|
+
objectFit: "cover",
|
|
2685
|
+
url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K740RV2XQMBWM2RZABY6AP9N.jpeg",
|
|
2686
|
+
name: "Slider-4.jpeg"
|
|
2687
|
+
},
|
|
2688
|
+
link: ""
|
|
2689
|
+
},
|
|
2690
|
+
{
|
|
2691
|
+
image: {
|
|
2692
|
+
objectFit: "cover",
|
|
2693
|
+
url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K740RQ4E62FG7Y92J4AP8T0A.jpeg",
|
|
2694
|
+
name: "Slider-5.jpeg"
|
|
2695
|
+
},
|
|
2696
|
+
link: ""
|
|
2697
|
+
},
|
|
2698
|
+
{
|
|
2699
|
+
image: {
|
|
2700
|
+
objectFit: "cover",
|
|
2701
|
+
url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K740RE073FS2HZX8AVP3MCR7.jpeg",
|
|
2702
|
+
name: "Slider-6.jpeg"
|
|
2703
|
+
},
|
|
2704
|
+
link: ""
|
|
2705
|
+
},
|
|
2706
|
+
{
|
|
2707
|
+
image: {
|
|
2708
|
+
objectFit: "cover",
|
|
2709
|
+
url: "https://cdn.cntrl.site/projects/01JJKT02AWY2FGN2QJ7A173RNZ/articles-assets/01K740R841W216BPQR07XZN8G4.jpeg",
|
|
2710
|
+
name: "Slider-7.jpeg"
|
|
2711
|
+
},
|
|
2712
|
+
link: ""
|
|
2713
|
+
}
|
|
2714
|
+
]
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
};
|
|
2258
2719
|
const components = [
|
|
2259
|
-
ControlSliderComponent
|
|
2720
|
+
ControlSliderComponent,
|
|
2721
|
+
ControlImageRevealSliderComponent
|
|
2260
2722
|
];
|
|
2261
2723
|
export {
|
|
2262
2724
|
AnchorSide,
|