@treely/strapi-slices 6.1.1 → 6.2.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.
@@ -2526,6 +2526,17 @@ var ContextProvider = function ContextProvider(_ref) {
2526
2526
  }, children));
2527
2527
  };
2528
2528
 
2529
+ var shuffleElements = function shuffleElements(slides) {
2530
+ var slidesCopy = [].concat(slides); // Create a copy to avoid mutating the original array
2531
+ for (var i = slidesCopy.length - 1; i > 0; i--) {
2532
+ var j = Math.floor(Math.random() * (i + 1));
2533
+ var _ref = [slidesCopy[j], slidesCopy[i]];
2534
+ slidesCopy[i] = _ref[0];
2535
+ slidesCopy[j] = _ref[1];
2536
+ }
2537
+ return slidesCopy;
2538
+ };
2539
+
2529
2540
  var ITEM_GAP$1 = 24;
2530
2541
  var MAX_OFFSET_RIGHT$1 = 55;
2531
2542
  var TextCarousel = function TextCarousel(_ref) {
@@ -2564,6 +2575,13 @@ var TextCarousel = function TextCarousel(_ref) {
2564
2575
  var canMoveLeft = useMemo(function () {
2565
2576
  return sliderIndex !== 0;
2566
2577
  }, [sliderIndex]);
2578
+ var shuffleSlides = useMemo(function () {
2579
+ return shuffleElements(slice.slides);
2580
+ }, [slice.slides]);
2581
+ var slides = slice.slides,
2582
+ _slice$isShuffled = slice.isShuffled,
2583
+ isShuffled = _slice$isShuffled === void 0 ? false : _slice$isShuffled;
2584
+ var displaySlides = isShuffled ? shuffleSlides : slides;
2567
2585
  return React.createElement(DefaultSectionContainer, {
2568
2586
  backgroundColor: primary50,
2569
2587
  title: slice.title
@@ -2598,7 +2616,7 @@ var TextCarousel = function TextCarousel(_ref) {
2598
2616
  duration: 0.3,
2599
2617
  ease: 'easeInOut'
2600
2618
  }
2601
- }, slice.slides.map(function (_ref2) {
2619
+ }, displaySlides.map(function (_ref2) {
2602
2620
  var id = _ref2.id,
2603
2621
  title = _ref2.title,
2604
2622
  text = _ref2.text,