@cntrl-site/components 0.1.25 → 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.
|
@@ -5,7 +5,7 @@ type SliderProps = {
|
|
|
5
5
|
styles: SliderStyles;
|
|
6
6
|
isEditor?: boolean;
|
|
7
7
|
} & CommonComponentProps;
|
|
8
|
-
export declare function ControlSlider({ settings, content, styles: sliderStyles, isEditor }: SliderProps): JSX.Element;
|
|
8
|
+
export declare function ControlSlider({ settings, content, styles: sliderStyles, isEditor }: SliderProps): import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
type SliderItem = {
|
|
10
10
|
image: {
|
|
11
11
|
url: string;
|
|
@@ -36,5 +36,5 @@ type ImageRevealSliderItem = {
|
|
|
36
36
|
};
|
|
37
37
|
link: string;
|
|
38
38
|
};
|
|
39
|
-
export declare function ImageRevealSlider({ settings, content, isEditor }: ImageRevealSliderProps): JSX.Element;
|
|
39
|
+
export declare function ImageRevealSlider({ settings, content, isEditor }: ImageRevealSliderProps): import("react/jsx-runtime").JSX.Element;
|
|
40
40
|
export {};
|
|
@@ -7,7 +7,7 @@ type LightboxGalleryProps = {
|
|
|
7
7
|
activeEvent: 'close' | 'open';
|
|
8
8
|
isEditor?: boolean;
|
|
9
9
|
};
|
|
10
|
-
export declare const LightboxGallery: ({ settings, content, styles, portalId, activeEvent, isEditor }: LightboxGalleryProps) => JSX.Element;
|
|
10
|
+
export declare const LightboxGallery: ({ settings, content, styles, portalId, activeEvent, isEditor }: LightboxGalleryProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
type LightboxImage = {
|
|
12
12
|
image: {
|
|
13
13
|
url: string;
|
package/dist/index.js
CHANGED
|
@@ -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
|
@@ -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;
|