@treely/strapi-slices 5.3.2 → 5.3.3
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/FullScreenImage/FullScreenImage.d.ts +3 -2
- package/dist/strapi-slices.cjs.development.js +31 -25
- package/dist/strapi-slices.cjs.development.js.map +1 -1
- package/dist/strapi-slices.cjs.production.min.js +1 -1
- package/dist/strapi-slices.cjs.production.min.js.map +1 -1
- package/dist/strapi-slices.esm.js +32 -26
- package/dist/strapi-slices.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FullScreenImage/FullScreenImage.tsx +29 -19
- package/src/slices/FullWidthImageSlider/FullWidthImageSlider.tsx +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect, Fragment, createRef, createContext, useContext
|
|
1
|
+
import React, { useState, useRef, useMemo, useCallback, useEffect, Fragment, createRef, createContext, useContext } from 'react';
|
|
2
2
|
import Head from 'next/head';
|
|
3
3
|
import { Box, BoemlyModal, Flex, IconButton, useMediaQuery, DefaultSectionContainer, Wrapper, DefaultSectionHeader, Button, Gradient, Spacer, SimpleGrid, Heading, Text, useToken, Grid, GridItem, BoemlyList, PortfolioCard, RichText, BoemlyAccordion, HeroCard, Shape, QuoteCard, Center, ShapesCard, TextCardWithIcon, ContactArea, ProjectCard, Tag, Link as Link$1, DatePersonPair, BoemlyThemeProvider, Badge, useDisclosure, Container, AvatarWithName, Divider, LabelNumberPair, BoemlyFormControl, InputRightAddon, LabelTextPair } from 'boemly';
|
|
4
4
|
import Image from 'next/image';
|
|
@@ -721,45 +721,50 @@ var FullScreenImage = function FullScreenImage(_ref) {
|
|
|
721
721
|
var images = _ref.images,
|
|
722
722
|
isOpen = _ref.isOpen,
|
|
723
723
|
onClose = _ref.onClose,
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
setImageIndex = _useState[1];
|
|
724
|
+
_ref$currentIndex = _ref.currentIndex,
|
|
725
|
+
currentIndex = _ref$currentIndex === void 0 ? 0 : _ref$currentIndex,
|
|
726
|
+
setCurrentIndex = _ref.setCurrentIndex;
|
|
728
727
|
var containerRef = useRef(null);
|
|
729
728
|
useLockBodyScroll(isOpen);
|
|
730
|
-
var canMoveRight =
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
729
|
+
var canMoveRight = useMemo(function () {
|
|
730
|
+
return currentIndex < images.length - 1;
|
|
731
|
+
}, [currentIndex, images.length]);
|
|
732
|
+
var canMoveLeft = useMemo(function () {
|
|
733
|
+
return currentIndex !== 0;
|
|
734
|
+
}, [currentIndex]);
|
|
735
|
+
var onRight = useCallback(function () {
|
|
736
|
+
return canMoveRight && setCurrentIndex && setCurrentIndex(function (c) {
|
|
737
|
+
return c + 1;
|
|
735
738
|
});
|
|
736
|
-
};
|
|
737
|
-
var onLeft = function
|
|
738
|
-
return
|
|
739
|
-
return
|
|
739
|
+
}, [canMoveRight]);
|
|
740
|
+
var onLeft = useCallback(function () {
|
|
741
|
+
return canMoveLeft && setCurrentIndex && setCurrentIndex(function (c) {
|
|
742
|
+
return c - 1;
|
|
740
743
|
});
|
|
741
|
-
};
|
|
744
|
+
}, [canMoveLeft]);
|
|
742
745
|
useKey('ArrowRight', onRight, {}, [onRight]);
|
|
743
746
|
useKey('ArrowLeft', onLeft, {}, [onLeft]);
|
|
744
747
|
useEffect(function () {
|
|
745
|
-
if (
|
|
746
|
-
|
|
748
|
+
if (!!isOpen) {
|
|
749
|
+
setTimeout(function () {
|
|
750
|
+
var _containerRef$current;
|
|
751
|
+
containerRef == null || (_containerRef$current = containerRef.current) == null || _containerRef$current.scrollTo({
|
|
752
|
+
left: currentIndex * containerRef.current.clientWidth,
|
|
753
|
+
behavior: 'instant'
|
|
754
|
+
});
|
|
755
|
+
}, 10);
|
|
747
756
|
}
|
|
748
|
-
}, [
|
|
757
|
+
}, [isOpen]);
|
|
749
758
|
useEffect(function () {
|
|
750
759
|
if (containerRef.current) {
|
|
751
760
|
containerRef.current.scrollTo({
|
|
752
|
-
left:
|
|
761
|
+
left: currentIndex * containerRef.current.clientWidth,
|
|
753
762
|
behavior: 'smooth'
|
|
754
763
|
});
|
|
755
764
|
}
|
|
756
|
-
}, [
|
|
757
|
-
var onCloseLocal = function onCloseLocal() {
|
|
758
|
-
setImageIndex(0);
|
|
759
|
-
onClose();
|
|
760
|
-
};
|
|
765
|
+
}, [currentIndex, containerRef]);
|
|
761
766
|
return React.createElement(BoemlyModal, {
|
|
762
|
-
onClose:
|
|
767
|
+
onClose: onClose,
|
|
763
768
|
isOpen: isOpen,
|
|
764
769
|
title: "",
|
|
765
770
|
trigger: "",
|
|
@@ -3326,7 +3331,8 @@ var FullWidthImageSlider = function FullWidthImageSlider(_ref) {
|
|
|
3326
3331
|
images: slice.images.map(function (image) {
|
|
3327
3332
|
return image.img;
|
|
3328
3333
|
}),
|
|
3329
|
-
|
|
3334
|
+
currentIndex: sliderIndex,
|
|
3335
|
+
setCurrentIndex: setSliderIndex,
|
|
3330
3336
|
isOpen: isOpen,
|
|
3331
3337
|
onClose: function onClose() {
|
|
3332
3338
|
return setIsOpen(false);
|