@treely/strapi-slices 5.3.2 → 5.4.0

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.
@@ -1,4 +1,4 @@
1
- import React, { useState, useRef, useEffect, Fragment, createRef, createContext, useContext, useMemo, useCallback } from 'react';
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
- openIndex = _ref.openIndex;
725
- var _useState = useState(0),
726
- imageIndex = _useState[0],
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 = imageIndex < images.length - 1;
731
- var canMoveLeft = imageIndex !== 0;
732
- var onRight = function onRight() {
733
- return setImageIndex(function (p) {
734
- return canMoveRight ? p + 1 : p;
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 onLeft() {
738
- return setImageIndex(function (p) {
739
- return canMoveLeft ? p - 1 : p;
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 (openIndex !== undefined) {
746
- setImageIndex(openIndex);
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
- }, [openIndex]);
757
+ }, [isOpen]);
749
758
  useEffect(function () {
750
759
  if (containerRef.current) {
751
760
  containerRef.current.scrollTo({
752
- left: imageIndex * containerRef.current.clientWidth,
761
+ left: currentIndex * containerRef.current.clientWidth,
753
762
  behavior: 'smooth'
754
763
  });
755
764
  }
756
- }, [imageIndex, containerRef]);
757
- var onCloseLocal = function onCloseLocal() {
758
- setImageIndex(0);
759
- onClose();
760
- };
765
+ }, [currentIndex, containerRef]);
761
766
  return React.createElement(BoemlyModal, {
762
- onClose: onCloseLocal,
767
+ onClose: onClose,
763
768
  isOpen: isOpen,
764
769
  title: "",
765
770
  trigger: "",
@@ -2038,6 +2043,7 @@ var messagesDe$6 = {
2038
2043
  'features.projectInfo.properties.projectDeveloper': 'Projekt Entwickler',
2039
2044
  'features.projectInfo.properties.verificationStandard.label': 'Verifizierungsstandard',
2040
2045
  'features.projectInfo.properties.verificationStandard.value.SilvaconsultFCSISO14': 'SILVACONSULT® Forest Carbon Standard, ISO 14064-2',
2046
+ 'features.projectInfo.properties.verificationStandard.value.MfKWCH': 'Methodik für Klimaschutzprojekte im Wald für die Schweiz',
2041
2047
  'features.projectInfo.properties.forecastedAmountYear.label': 'Projektvolumen',
2042
2048
  'features.projectInfo.properties.riskBuffer': 'Anteil Risikopuffer',
2043
2049
  'features.projectInfo.properties.year': '{years} {years, plural, one {Jahr} other {Jahre} }'
@@ -2152,6 +2158,7 @@ var messagesEn$4 = {
2152
2158
  'features.projectInfo.properties.projectDeveloper': 'Project Developer',
2153
2159
  'features.projectInfo.properties.verificationStandard.label': 'Verification Standard',
2154
2160
  'features.projectInfo.properties.verificationStandard.value.SilvaconsultFCSISO14': 'SILVACONSULT® Forest Carbon Standard, ISO 14064-2',
2161
+ 'features.projectInfo.properties.verificationStandard.value.MfKWCH': 'Methodik für Klimaschutzprojekte im Wald für die Schweiz',
2155
2162
  'features.projectInfo.properties.forecastedAmountYear.label': 'Project Volume',
2156
2163
  'features.projectInfo.properties.riskBuffer': 'Risk Buffer Share',
2157
2164
  'features.projectInfo.properties.year': '{years} {years, plural, one {year} other {years} }'
@@ -3326,7 +3333,8 @@ var FullWidthImageSlider = function FullWidthImageSlider(_ref) {
3326
3333
  images: slice.images.map(function (image) {
3327
3334
  return image.img;
3328
3335
  }),
3329
- openIndex: sliderIndex,
3336
+ currentIndex: sliderIndex,
3337
+ setCurrentIndex: setSliderIndex,
3330
3338
  isOpen: isOpen,
3331
3339
  onClose: function onClose() {
3332
3340
  return setIsOpen(false);