@treely/strapi-slices 5.3.1 → 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.
@@ -4,6 +4,7 @@ export interface FullScreenImageProps {
4
4
  images: StrapiImage[];
5
5
  isOpen: boolean;
6
6
  onClose: () => void;
7
- openIndex?: number;
7
+ currentIndex?: number;
8
+ setCurrentIndex?: (callback: (c: number) => number) => void;
8
9
  }
9
- export declare const FullScreenImage: ({ images, isOpen, onClose, openIndex, }: FullScreenImageProps) => React.JSX.Element;
10
+ export declare const FullScreenImage: ({ images, isOpen, onClose, currentIndex, setCurrentIndex, }: FullScreenImageProps) => React.JSX.Element;
@@ -3,12 +3,6 @@
3
3
  export declare const SliderContainer: import("@emotion/styled").StyledComponent<import("@chakra-ui/system/dist/system.types").MergeWithAs<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, any, Omit<import("@chakra-ui/system/dist/system.types").ChakraProps, never>, import("@chakra-ui/system/dist/system.types").As> & {
4
4
  theme?: import("@emotion/react").Theme | undefined;
5
5
  }, {}, {}>;
6
- interface ButtonsContainerProps {
7
- show: string;
8
- }
9
- export declare const ButtonsContainer: import("@emotion/styled").StyledComponent<(import("@chakra-ui/system/dist/system.types").MergeWithAs<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, any, Omit<import("@chakra-ui/system/dist/system.types").ChakraProps, never>, import("@chakra-ui/system/dist/system.types").As> & {
10
- theme?: import("@emotion/react").Theme | undefined;
11
- }) & ButtonsContainerProps, {}, {}>;
12
6
  interface SliderInnerContainerProps {
13
7
  imageCount: number;
14
8
  }
@@ -734,45 +734,50 @@ var FullScreenImage = function FullScreenImage(_ref) {
734
734
  var images = _ref.images,
735
735
  isOpen = _ref.isOpen,
736
736
  onClose = _ref.onClose,
737
- openIndex = _ref.openIndex;
738
- var _useState = React.useState(0),
739
- imageIndex = _useState[0],
740
- setImageIndex = _useState[1];
737
+ _ref$currentIndex = _ref.currentIndex,
738
+ currentIndex = _ref$currentIndex === void 0 ? 0 : _ref$currentIndex,
739
+ setCurrentIndex = _ref.setCurrentIndex;
741
740
  var containerRef = React.useRef(null);
742
741
  reactUse.useLockBodyScroll(isOpen);
743
- var canMoveRight = imageIndex < images.length - 1;
744
- var canMoveLeft = imageIndex !== 0;
745
- var onRight = function onRight() {
746
- return setImageIndex(function (p) {
747
- return canMoveRight ? p + 1 : p;
742
+ var canMoveRight = React.useMemo(function () {
743
+ return currentIndex < images.length - 1;
744
+ }, [currentIndex, images.length]);
745
+ var canMoveLeft = React.useMemo(function () {
746
+ return currentIndex !== 0;
747
+ }, [currentIndex]);
748
+ var onRight = React.useCallback(function () {
749
+ return canMoveRight && setCurrentIndex && setCurrentIndex(function (c) {
750
+ return c + 1;
748
751
  });
749
- };
750
- var onLeft = function onLeft() {
751
- return setImageIndex(function (p) {
752
- return canMoveLeft ? p - 1 : p;
752
+ }, [canMoveRight]);
753
+ var onLeft = React.useCallback(function () {
754
+ return canMoveLeft && setCurrentIndex && setCurrentIndex(function (c) {
755
+ return c - 1;
753
756
  });
754
- };
757
+ }, [canMoveLeft]);
755
758
  reactUse.useKey('ArrowRight', onRight, {}, [onRight]);
756
759
  reactUse.useKey('ArrowLeft', onLeft, {}, [onLeft]);
757
760
  React.useEffect(function () {
758
- if (openIndex !== undefined) {
759
- setImageIndex(openIndex);
761
+ if (!!isOpen) {
762
+ setTimeout(function () {
763
+ var _containerRef$current;
764
+ containerRef == null || (_containerRef$current = containerRef.current) == null || _containerRef$current.scrollTo({
765
+ left: currentIndex * containerRef.current.clientWidth,
766
+ behavior: 'instant'
767
+ });
768
+ }, 10);
760
769
  }
761
- }, [openIndex]);
770
+ }, [isOpen]);
762
771
  React.useEffect(function () {
763
772
  if (containerRef.current) {
764
773
  containerRef.current.scrollTo({
765
- left: imageIndex * containerRef.current.clientWidth,
774
+ left: currentIndex * containerRef.current.clientWidth,
766
775
  behavior: 'smooth'
767
776
  });
768
777
  }
769
- }, [imageIndex, containerRef]);
770
- var onCloseLocal = function onCloseLocal() {
771
- setImageIndex(0);
772
- onClose();
773
- };
778
+ }, [currentIndex, containerRef]);
774
779
  return React__default.default.createElement(boemly.BoemlyModal, {
775
- onClose: onCloseLocal,
780
+ onClose: onClose,
776
781
  isOpen: isOpen,
777
782
  title: "",
778
783
  trigger: "",
@@ -1418,12 +1423,12 @@ var LogoGridWithText = function LogoGridWithText(_ref) {
1418
1423
  })))));
1419
1424
  };
1420
1425
 
1421
- var _templateObject$7, _templateObject2$4, _templateObject3$2, _templateObject4$1, _templateObject5$1;
1426
+ var _templateObject$7, _templateObject2$4, _templateObject3$2, _templateObject4$1, _templateObject5;
1422
1427
  var MapHeroContainer = /*#__PURE__*/styled__default.default(boemly.Box)(_templateObject$7 || (_templateObject$7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n width: 100vw;\n height: var(--default-hero-height);\n min-height: var(--boemly-sizes-3xl);\n background-color: var(--boemly-colors-primary-50);\n overflow: hidden;\n z-index: var(--boemly-zIndices-base);\n\n @media screen and (max-width: ", ") {\n height: auto;\n }\n"])), BREAKPOINT_LG);
1423
1428
  var MapHeroTextContainer = /*#__PURE__*/styled__default.default(boemly.Box)(_templateObject2$4 || (_templateObject2$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n width: 100vw;\n top: 56%;\n left: 0;\n transform: translateY(-50%);\n z-index: var(--boemly-zIndices-aboveBase);\n\n @media screen and (max-width: ", ") {\n position: relative;\n transform: unset;\n\n padding-top: var(--boemly-space-32);\n }\n"])), BREAKPOINT_LG);
1424
1429
  var ShapeContainer = /*#__PURE__*/styled__default.default(boemly.Box)(_templateObject3$2 || (_templateObject3$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n bottom: calc(var(--boemly-space-8) * -1);\n left: 0;\n\n width: var(--boemly-sizes-sm);\n height: var(--boemly-sizes-sm);\n\n border-top-right-radius: var(--boemly-radii-full);\n\n & span,\n div {\n border-top-right-radius: var(--boemly-radii-full);\n }\n\n @media screen and (max-width: ", ") {\n display: none;\n }\n"])), BREAKPOINT_LG);
1425
1430
  var MapContainer = /*#__PURE__*/styled__default.default(boemly.Box)(_templateObject4$1 || (_templateObject4$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n\n width: 50%;\n height: 100%;\n\n right: 0;\n top: 0;\n\n & img {\n object-fit: cover !important;\n }\n\n @media screen and (max-width: ", ") {\n width: 100%;\n height: var(--boemly-sizes-4xl);\n position: relative;\n margin-top: calc(var(--boemly-space-72) * -1);\n background-color: var(--boemly-colors-white);\n\n & img {\n object-fit: contain !important;\n }\n }\n"])), BREAKPOINT_LG);
1426
- var MapGradient = /*#__PURE__*/styled__default.default(boemly.Box)(_templateObject5$1 || (_templateObject5$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n top: 0;\n right: 0;\n width: 100%;\n height: 100%;\n\n background: linear-gradient(\n 90deg,\n var(--boemly-colors-primary-50) 0%,\n var(--boemly-colors-primary-50) 10%,\n rgba(243, 246, 245, 0.6) 28%,\n rgba(243, 246, 245, 0) 40%,\n rgba(243, 246, 245, 0) 100%\n );\n\n @media screen and (max-width: ", ") {\n background: linear-gradient(\n 180deg,\n var(--boemly-colors-primary-50) 0%,\n var(--boemly-colors-primary-50) 36%,\n rgba(243, 246, 245, 0.12) 46%,\n rgba(243, 246, 245, 0) 100%\n );\n }\n"])), BREAKPOINT_LG);
1431
+ var MapGradient = /*#__PURE__*/styled__default.default(boemly.Box)(_templateObject5 || (_templateObject5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n top: 0;\n right: 0;\n width: 100%;\n height: 100%;\n\n background: linear-gradient(\n 90deg,\n var(--boemly-colors-primary-50) 0%,\n var(--boemly-colors-primary-50) 10%,\n rgba(243, 246, 245, 0.6) 28%,\n rgba(243, 246, 245, 0) 40%,\n rgba(243, 246, 245, 0) 100%\n );\n\n @media screen and (max-width: ", ") {\n background: linear-gradient(\n 180deg,\n var(--boemly-colors-primary-50) 0%,\n var(--boemly-colors-primary-50) 36%,\n rgba(243, 246, 245, 0.12) 46%,\n rgba(243, 246, 245, 0) 100%\n );\n }\n"])), BREAKPOINT_LG);
1427
1432
 
1428
1433
  var MapHero = function MapHero(_ref) {
1429
1434
  var slice = _ref.slice;
@@ -2251,8 +2256,8 @@ var ContextProvider = function ContextProvider(_ref) {
2251
2256
  }, children));
2252
2257
  };
2253
2258
 
2254
- var ITEM_GAP = 24;
2255
- var MAX_OFFSET_RIGHT = 55;
2259
+ var ITEM_GAP$1 = 24;
2260
+ var MAX_OFFSET_RIGHT$1 = 55;
2256
2261
  var TextCarousel = function TextCarousel(_ref) {
2257
2262
  var slice = _ref.slice;
2258
2263
  var containerRef = React.useRef(null);
@@ -2272,17 +2277,17 @@ var TextCarousel = function TextCarousel(_ref) {
2272
2277
  return slice.slides.length;
2273
2278
  }, [slice.slides.length]);
2274
2279
  var sliderItemsWidth = React.useMemo(function () {
2275
- return numberOfItems * (itemWidth + ITEM_GAP) - ITEM_GAP;
2280
+ return numberOfItems * (itemWidth + ITEM_GAP$1) - ITEM_GAP$1;
2276
2281
  }, [itemWidth, numberOfItems]);
2277
2282
  var offsetLeft = React.useMemo(function () {
2278
- return sliderIndex * (itemWidth + ITEM_GAP) * -1;
2283
+ return sliderIndex * (itemWidth + ITEM_GAP$1) * -1;
2279
2284
  }, [sliderIndex, itemWidth]);
2280
2285
  var allowScroll = React.useMemo(function () {
2281
- return sliderItemsWidth + ITEM_GAP * 2 > windowWidth;
2286
+ return sliderItemsWidth + ITEM_GAP$1 * 2 > windowWidth;
2282
2287
  }, [sliderItemsWidth, windowWidth]);
2283
2288
  var canMoveRight = React.useMemo(function () {
2284
2289
  var offsetRight = windowWidth - (sliderItemsWidth + offsetLeft);
2285
- return offsetRight < MAX_OFFSET_RIGHT;
2290
+ return offsetRight < MAX_OFFSET_RIGHT$1;
2286
2291
  }, [itemWidth, sliderIndex, sliderItemsWidth, windowWidth]);
2287
2292
  var canMoveLeft = React.useMemo(function () {
2288
2293
  return sliderIndex !== 0;
@@ -3180,19 +3185,15 @@ var FullWidthHighlightQuote = function FullWidthHighlightQuote(_ref) {
3180
3185
  })));
3181
3186
  };
3182
3187
 
3183
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
3188
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
3184
3189
  var SliderContainer = /*#__PURE__*/styled__default.default(boemly.Box)(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n --mobile-image-width: calc(100vw - var(--boemly-space-24));\n --desktop-image-width: var(--boemly-sizes-md);\n\n width: var(--boemly-size-full);\n\n overflow-x: hidden;\n\n padding-left: max(\n var(--boemly-space-8),\n calc(50vw - var(--boemly-sizes-7xl) / 2 + var(--boemly-space-6))\n );\n\n @media screen and (max-width: ", ") {\n overflow-x: scroll;\n padding-left: max(\n var(--boemly-space-8),\n calc(50vw - var(--boemly-sizes-7xl) / 2 + var(--boemly-space-8))\n );\n }\n"])), BREAKPOINT_MD);
3185
- var ButtonsContainer = /*#__PURE__*/styled__default.default(boemly.Box)(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: ", ";\n pointer-events: none;\n\n // Place at 50% of height of tallest image minus size of button\n position: absolute;\n top: calc(50% - var(--boemly-sizes-12));\n left: 0;\n width: var(--boemly-sizes-full);\n\n padding: 0 var(--boemly-sizes-32);\n justify-content: space-between;\n\n @media screen and (max-width: ", ") {\n display: none;\n }\n"])), function (_ref) {
3186
- var show = _ref.show;
3187
- return show ? 'flex' : 'none';
3188
- }, BREAKPOINT_MD);
3189
- var SliderInnerContainer = /*#__PURE__*/styled__default.default(framerMotion.motion.div)(_templateObject3 || (_templateObject3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n gap: var(--boemly-space-6);\n\n width: fit-content;\n"])));
3190
- var ItemContainer = /*#__PURE__*/styled__default.default(boemly.Box)(_templateObject4 || (_templateObject4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: var(--desktop-image-width);\n\n :last-of-type {\n margin-right: var(--boemly-space-8);\n }\n\n @media screen and (max-width: ", ") {\n width: var(--mobile-image-width);\n }\n"])), BREAKPOINT_MD);
3191
- var ImageContainer = /*#__PURE__*/styled__default.default(boemly.Box)(_templateObject5 || (_templateObject5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n\n max-height: var(--boemly-sizes-xl);\n height: calc(\n var(--desktop-image-width) /\n ", "\n );\n width: var(--desktop-image-width);\n\n border-radius: var(--boemly-radii-xl);\n\n & img {\n border-radius: var(--boemly-radii-xl);\n }\n\n @media screen and (max-width: ", ") {\n height: calc(\n var(--mobile-image-width) /\n ", "\n );\n width: var(--mobile-image-width);\n }\n"])), function (_ref2) {
3192
- var aspectRatio = _ref2.aspectRatio;
3190
+ var SliderInnerContainer = /*#__PURE__*/styled__default.default(framerMotion.motion.div)(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n gap: var(--boemly-space-6);\n\n width: fit-content;\n"])));
3191
+ var ItemContainer = /*#__PURE__*/styled__default.default(boemly.Box)(_templateObject3 || (_templateObject3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: var(--desktop-image-width);\n\n :last-of-type {\n margin-right: var(--boemly-space-8);\n }\n\n @media screen and (max-width: ", ") {\n width: var(--mobile-image-width);\n }\n"])), BREAKPOINT_MD);
3192
+ var ImageContainer = /*#__PURE__*/styled__default.default(boemly.Box)(_templateObject4 || (_templateObject4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n\n max-height: var(--boemly-sizes-xl);\n height: calc(\n var(--desktop-image-width) /\n ", "\n );\n width: var(--desktop-image-width);\n\n border-radius: var(--boemly-radii-xl);\n\n & img {\n border-radius: var(--boemly-radii-xl);\n }\n\n @media screen and (max-width: ", ") {\n height: calc(\n var(--mobile-image-width) /\n ", "\n );\n width: var(--mobile-image-width);\n }\n"])), function (_ref) {
3193
+ var aspectRatio = _ref.aspectRatio;
3193
3194
  return aspectRatio;
3194
- }, BREAKPOINT_MD, function (_ref3) {
3195
- var aspectRatio = _ref3.aspectRatio;
3195
+ }, BREAKPOINT_MD, function (_ref2) {
3196
+ var aspectRatio = _ref2.aspectRatio;
3196
3197
  return aspectRatio;
3197
3198
  });
3198
3199
 
@@ -3210,6 +3211,8 @@ var getClosestRatio = function getClosestRatio(width, height) {
3210
3211
  return ALLOWED_RATIOS[posMinDiff];
3211
3212
  };
3212
3213
 
3214
+ var ITEM_GAP = 24;
3215
+ var MAX_OFFSET_RIGHT = 162;
3213
3216
  var FullWidthImageSlider = function FullWidthImageSlider(_ref) {
3214
3217
  var slice = _ref.slice;
3215
3218
  var containerRef = React.useRef(null);
@@ -3226,9 +3229,25 @@ var FullWidthImageSlider = function FullWidthImageSlider(_ref) {
3226
3229
  var _useState2 = React.useState(false),
3227
3230
  isOpen = _useState2[0],
3228
3231
  setIsOpen = _useState2[1];
3229
- var allowScroll = windowWidth / 2 / imageWidth < slice.images.length;
3230
- var canMoveRight = sliderIndex < slice.images.length - 1;
3231
- var canMoveLeft = sliderIndex !== 0;
3232
+ var numberOfItems = React.useMemo(function () {
3233
+ return slice.images.length;
3234
+ }, [slice.images.length]);
3235
+ var sliderItemsWidth = React.useMemo(function () {
3236
+ return numberOfItems * (imageWidth + ITEM_GAP) - ITEM_GAP;
3237
+ }, [imageWidth, numberOfItems]);
3238
+ var offsetLeft = React.useMemo(function () {
3239
+ return sliderIndex * (imageWidth + ITEM_GAP) * -1;
3240
+ }, [sliderIndex, imageWidth]);
3241
+ var allowScroll = React.useMemo(function () {
3242
+ return sliderItemsWidth + ITEM_GAP * 3 > windowWidth;
3243
+ }, [sliderItemsWidth, windowWidth]);
3244
+ var canMoveRight = React.useMemo(function () {
3245
+ var offsetRight = windowWidth - (sliderItemsWidth + offsetLeft);
3246
+ return offsetRight < MAX_OFFSET_RIGHT;
3247
+ }, [imageWidth, sliderIndex, sliderItemsWidth, windowWidth]);
3248
+ var canMoveLeft = React.useMemo(function () {
3249
+ return sliderIndex !== 0;
3250
+ }, [sliderIndex]);
3232
3251
  return React__default.default.createElement(boemly.DefaultSectionContainer, null, React__default.default.createElement(SliderContainer, {
3233
3252
  ref: containerRef
3234
3253
  }, React__default.default.createElement(SliderInnerContainer, {
@@ -3267,8 +3286,16 @@ var FullWidthImageSlider = function FullWidthImageSlider(_ref) {
3267
3286
  })), React__default.default.createElement(boemly.Text, {
3268
3287
  height: "6"
3269
3288
  }, image.caption)));
3270
- }))), React__default.default.createElement(ButtonsContainer, {
3271
- show: (allowScroll && !isOpen).toString()
3289
+ }))), React__default.default.createElement(boemly.Box, {
3290
+ display: ['none', null, null, !!allowScroll ? 'flex' : 'none'],
3291
+ pointerEvents: "none",
3292
+ position: "absolute",
3293
+ top: "calc(50% - var(--boemly-sizes-12))",
3294
+ left: "0",
3295
+ width: "full",
3296
+ py: "0",
3297
+ px: "32",
3298
+ justifyContent: "space-between"
3272
3299
  }, React__default.default.createElement(boemly.Box, null, React__default.default.createElement(framerMotion.AnimatePresence, null, canMoveLeft && React__default.default.createElement(boemly.IconButton, {
3273
3300
  key: "leftButton",
3274
3301
  as: framerMotion.motion.button,
@@ -3317,7 +3344,8 @@ var FullWidthImageSlider = function FullWidthImageSlider(_ref) {
3317
3344
  images: slice.images.map(function (image) {
3318
3345
  return image.img;
3319
3346
  }),
3320
- openIndex: sliderIndex,
3347
+ currentIndex: sliderIndex,
3348
+ setCurrentIndex: setSliderIndex,
3321
3349
  isOpen: isOpen,
3322
3350
  onClose: function onClose() {
3323
3351
  return setIsOpen(false);