@cntrl-site/components 0.1.24 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +31 -6
- package/dist/index.mjs +31 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -461,7 +461,7 @@ const ControlSliderComponent = {
|
|
|
461
461
|
name: "Slider",
|
|
462
462
|
preview: {
|
|
463
463
|
type: "video",
|
|
464
|
-
url: "https://cdn.cntrl.site/
|
|
464
|
+
url: "https://cdn.cntrl.site/component-assets/Control-slider-preview.mp4"
|
|
465
465
|
},
|
|
466
466
|
defaultSize: {
|
|
467
467
|
width: 400,
|
|
@@ -880,7 +880,7 @@ const ControlSliderComponent = {
|
|
|
880
880
|
{
|
|
881
881
|
image: {
|
|
882
882
|
objectFit: "cover",
|
|
883
|
-
url: "https://cdn.cntrl.site/
|
|
883
|
+
url: "https://cdn.cntrl.site/component-assets/Control-slider-default-picture-1.png",
|
|
884
884
|
name: "Slider-1.png"
|
|
885
885
|
},
|
|
886
886
|
imageCaption: [
|
|
@@ -893,7 +893,7 @@ const ControlSliderComponent = {
|
|
|
893
893
|
{
|
|
894
894
|
image: {
|
|
895
895
|
objectFit: "cover",
|
|
896
|
-
url: "https://cdn.cntrl.site/
|
|
896
|
+
url: "https://cdn.cntrl.site/component-assets/Control-slider-default-picture-2.png",
|
|
897
897
|
name: "Slider-2.png"
|
|
898
898
|
},
|
|
899
899
|
imageCaption: [
|
|
@@ -906,7 +906,7 @@ const ControlSliderComponent = {
|
|
|
906
906
|
{
|
|
907
907
|
image: {
|
|
908
908
|
objectFit: "cover",
|
|
909
|
-
url: "https://cdn.cntrl.site/
|
|
909
|
+
url: "https://cdn.cntrl.site/component-assets/Control-slider-default-picture-3.png",
|
|
910
910
|
name: "Slider-3.png"
|
|
911
911
|
},
|
|
912
912
|
imageCaption: [
|
|
@@ -1921,6 +1921,8 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
1921
1921
|
const appearAnimationEndHandlerRef = react.useRef(null);
|
|
1922
1922
|
const dragStartRef = react.useRef(null);
|
|
1923
1923
|
const hasDraggedRef = react.useRef(false);
|
|
1924
|
+
const thumbsWrapperRef = react.useRef(null);
|
|
1925
|
+
const [hasThumbsOverflow, setHasThumbsOverflow] = react.useState(false);
|
|
1924
1926
|
const { appear, triggers, slider, thumbnail, controls, area, caption: caption2, layout } = settings.lightboxBlock;
|
|
1925
1927
|
const { appearClass, backdropAppearClass, backdropDisappearClass, disappearClass } = getAnimationClasses(appear.type, appear.direction);
|
|
1926
1928
|
const itemId = (metadata == null ? void 0 : metadata.itemId) ?? null;
|
|
@@ -1941,6 +1943,25 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
1941
1943
|
window.removeEventListener("ArticleEditor.ComponentContent:change", handleComponentContentChange);
|
|
1942
1944
|
};
|
|
1943
1945
|
}, []);
|
|
1946
|
+
react.useEffect(() => {
|
|
1947
|
+
if (!isOpen || !thumbnail.isActive) {
|
|
1948
|
+
setHasThumbsOverflow(false);
|
|
1949
|
+
return;
|
|
1950
|
+
}
|
|
1951
|
+
const ref = thumbsWrapperRef.current;
|
|
1952
|
+
if (!ref) return;
|
|
1953
|
+
const checkOverflow = () => {
|
|
1954
|
+
if (slider.direction === "horiz") {
|
|
1955
|
+
setHasThumbsOverflow(ref.scrollWidth > ref.clientWidth);
|
|
1956
|
+
} else {
|
|
1957
|
+
setHasThumbsOverflow(ref.scrollHeight > ref.clientHeight);
|
|
1958
|
+
}
|
|
1959
|
+
};
|
|
1960
|
+
checkOverflow();
|
|
1961
|
+
const observer = new ResizeObserver(checkOverflow);
|
|
1962
|
+
observer.observe(ref);
|
|
1963
|
+
return () => observer.disconnect();
|
|
1964
|
+
}, [isOpen, thumbnail.isActive, content.length, thumbnailDimensions, slider.direction]);
|
|
1944
1965
|
const handleClose = react.useCallback(() => {
|
|
1945
1966
|
const isMobile = window.matchMedia("(max-width: 768px)").matches;
|
|
1946
1967
|
const colorAlpha = getColorAlpha(area.color);
|
|
@@ -1955,7 +1976,10 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
1955
1976
|
animationTargetRef.current.removeEventListener("animationend", animationEndHandlerRef.current);
|
|
1956
1977
|
}
|
|
1957
1978
|
animationEndHandlerRef.current = null;
|
|
1958
|
-
|
|
1979
|
+
if (isClosingRef.current) {
|
|
1980
|
+
isClosingRef.current = false;
|
|
1981
|
+
onClose();
|
|
1982
|
+
}
|
|
1959
1983
|
setIsClosing(false);
|
|
1960
1984
|
}
|
|
1961
1985
|
};
|
|
@@ -2478,6 +2502,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2478
2502
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2479
2503
|
"div",
|
|
2480
2504
|
{
|
|
2505
|
+
ref: thumbsWrapperRef,
|
|
2481
2506
|
className: classes.thumbsWrapper,
|
|
2482
2507
|
onClick: (e) => handleThumbWrapperClick(e),
|
|
2483
2508
|
style: {
|
|
@@ -2505,7 +2530,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2505
2530
|
}),
|
|
2506
2531
|
style: {
|
|
2507
2532
|
gap: scalingValue(thumbnail.grid.gap, isEditor),
|
|
2508
|
-
justifyContent: getJustifyContent()
|
|
2533
|
+
justifyContent: hasThumbsOverflow ? "flex-start" : getJustifyContent()
|
|
2509
2534
|
},
|
|
2510
2535
|
children: content.map((item, index) => {
|
|
2511
2536
|
const isActive = index === currentIndex;
|
package/dist/index.mjs
CHANGED
|
@@ -459,7 +459,7 @@ const ControlSliderComponent = {
|
|
|
459
459
|
name: "Slider",
|
|
460
460
|
preview: {
|
|
461
461
|
type: "video",
|
|
462
|
-
url: "https://cdn.cntrl.site/
|
|
462
|
+
url: "https://cdn.cntrl.site/component-assets/Control-slider-preview.mp4"
|
|
463
463
|
},
|
|
464
464
|
defaultSize: {
|
|
465
465
|
width: 400,
|
|
@@ -878,7 +878,7 @@ const ControlSliderComponent = {
|
|
|
878
878
|
{
|
|
879
879
|
image: {
|
|
880
880
|
objectFit: "cover",
|
|
881
|
-
url: "https://cdn.cntrl.site/
|
|
881
|
+
url: "https://cdn.cntrl.site/component-assets/Control-slider-default-picture-1.png",
|
|
882
882
|
name: "Slider-1.png"
|
|
883
883
|
},
|
|
884
884
|
imageCaption: [
|
|
@@ -891,7 +891,7 @@ const ControlSliderComponent = {
|
|
|
891
891
|
{
|
|
892
892
|
image: {
|
|
893
893
|
objectFit: "cover",
|
|
894
|
-
url: "https://cdn.cntrl.site/
|
|
894
|
+
url: "https://cdn.cntrl.site/component-assets/Control-slider-default-picture-2.png",
|
|
895
895
|
name: "Slider-2.png"
|
|
896
896
|
},
|
|
897
897
|
imageCaption: [
|
|
@@ -904,7 +904,7 @@ const ControlSliderComponent = {
|
|
|
904
904
|
{
|
|
905
905
|
image: {
|
|
906
906
|
objectFit: "cover",
|
|
907
|
-
url: "https://cdn.cntrl.site/
|
|
907
|
+
url: "https://cdn.cntrl.site/component-assets/Control-slider-default-picture-3.png",
|
|
908
908
|
name: "Slider-3.png"
|
|
909
909
|
},
|
|
910
910
|
imageCaption: [
|
|
@@ -1919,6 +1919,8 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
1919
1919
|
const appearAnimationEndHandlerRef = useRef(null);
|
|
1920
1920
|
const dragStartRef = useRef(null);
|
|
1921
1921
|
const hasDraggedRef = useRef(false);
|
|
1922
|
+
const thumbsWrapperRef = useRef(null);
|
|
1923
|
+
const [hasThumbsOverflow, setHasThumbsOverflow] = useState(false);
|
|
1922
1924
|
const { appear, triggers, slider, thumbnail, controls, area, caption: caption2, layout } = settings.lightboxBlock;
|
|
1923
1925
|
const { appearClass, backdropAppearClass, backdropDisappearClass, disappearClass } = getAnimationClasses(appear.type, appear.direction);
|
|
1924
1926
|
const itemId = (metadata == null ? void 0 : metadata.itemId) ?? null;
|
|
@@ -1939,6 +1941,25 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
1939
1941
|
window.removeEventListener("ArticleEditor.ComponentContent:change", handleComponentContentChange);
|
|
1940
1942
|
};
|
|
1941
1943
|
}, []);
|
|
1944
|
+
useEffect(() => {
|
|
1945
|
+
if (!isOpen || !thumbnail.isActive) {
|
|
1946
|
+
setHasThumbsOverflow(false);
|
|
1947
|
+
return;
|
|
1948
|
+
}
|
|
1949
|
+
const ref = thumbsWrapperRef.current;
|
|
1950
|
+
if (!ref) return;
|
|
1951
|
+
const checkOverflow = () => {
|
|
1952
|
+
if (slider.direction === "horiz") {
|
|
1953
|
+
setHasThumbsOverflow(ref.scrollWidth > ref.clientWidth);
|
|
1954
|
+
} else {
|
|
1955
|
+
setHasThumbsOverflow(ref.scrollHeight > ref.clientHeight);
|
|
1956
|
+
}
|
|
1957
|
+
};
|
|
1958
|
+
checkOverflow();
|
|
1959
|
+
const observer = new ResizeObserver(checkOverflow);
|
|
1960
|
+
observer.observe(ref);
|
|
1961
|
+
return () => observer.disconnect();
|
|
1962
|
+
}, [isOpen, thumbnail.isActive, content.length, thumbnailDimensions, slider.direction]);
|
|
1942
1963
|
const handleClose = useCallback(() => {
|
|
1943
1964
|
const isMobile = window.matchMedia("(max-width: 768px)").matches;
|
|
1944
1965
|
const colorAlpha = getColorAlpha(area.color);
|
|
@@ -1953,7 +1974,10 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
1953
1974
|
animationTargetRef.current.removeEventListener("animationend", animationEndHandlerRef.current);
|
|
1954
1975
|
}
|
|
1955
1976
|
animationEndHandlerRef.current = null;
|
|
1956
|
-
|
|
1977
|
+
if (isClosingRef.current) {
|
|
1978
|
+
isClosingRef.current = false;
|
|
1979
|
+
onClose();
|
|
1980
|
+
}
|
|
1957
1981
|
setIsClosing(false);
|
|
1958
1982
|
}
|
|
1959
1983
|
};
|
|
@@ -2476,6 +2500,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2476
2500
|
return /* @__PURE__ */ jsx(
|
|
2477
2501
|
"div",
|
|
2478
2502
|
{
|
|
2503
|
+
ref: thumbsWrapperRef,
|
|
2479
2504
|
className: classes.thumbsWrapper,
|
|
2480
2505
|
onClick: (e) => handleThumbWrapperClick(e),
|
|
2481
2506
|
style: {
|
|
@@ -2503,7 +2528,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
|
|
|
2503
2528
|
}),
|
|
2504
2529
|
style: {
|
|
2505
2530
|
gap: scalingValue(thumbnail.grid.gap, isEditor),
|
|
2506
|
-
justifyContent: getJustifyContent()
|
|
2531
|
+
justifyContent: hasThumbsOverflow ? "flex-start" : getJustifyContent()
|
|
2507
2532
|
},
|
|
2508
2533
|
children: content.map((item, index) => {
|
|
2509
2534
|
const isActive = index === currentIndex;
|