@wlloyalty/wll-react-sdk 1.0.101 → 1.0.102
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/index.d.ts +2 -1
- package/dist/native.js +26 -4
- package/dist/native.js.map +1 -1
- package/dist/types/components/molecules/Carousel/Carousel.stories.d.ts +3 -0
- package/dist/types/components/molecules/Carousel/index.d.ts +2 -1
- package/dist/web.js +35 -8
- package/dist/web.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,10 +3,13 @@ declare const _default: Meta;
|
|
|
3
3
|
export default _default;
|
|
4
4
|
export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, {
|
|
5
5
|
section?: import("../../../types/section").TSection;
|
|
6
|
+
autoRotateInterval?: number;
|
|
6
7
|
}>;
|
|
7
8
|
export declare const SingleItem: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, {
|
|
8
9
|
section?: import("../../../types/section").TSection;
|
|
10
|
+
autoRotateInterval?: number;
|
|
9
11
|
}>;
|
|
10
12
|
export declare const ManyItems: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, {
|
|
11
13
|
section?: import("../../../types/section").TSection;
|
|
14
|
+
autoRotateInterval?: number;
|
|
12
15
|
}>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TSection } from '../../../types/section';
|
|
2
2
|
type CarouselProps = {
|
|
3
3
|
section?: TSection;
|
|
4
|
+
autoRotateInterval?: number;
|
|
4
5
|
};
|
|
5
|
-
declare const Carousel: ({ section }: CarouselProps) => JSX.Element | null;
|
|
6
|
+
declare const Carousel: ({ section, autoRotateInterval, }: CarouselProps) => JSX.Element | null;
|
|
6
7
|
export default Carousel;
|
package/dist/web.js
CHANGED
|
@@ -20558,22 +20558,24 @@ var carouselReducer = function (state, action) {
|
|
|
20558
20558
|
}
|
|
20559
20559
|
};
|
|
20560
20560
|
var Carousel = function (_a) {
|
|
20561
|
-
var section = _a.section
|
|
20561
|
+
var section = _a.section,
|
|
20562
|
+
_b = _a.autoRotateInterval,
|
|
20563
|
+
autoRotateInterval = _b === void 0 ? 5000 : _b;
|
|
20562
20564
|
if (!section) return null;
|
|
20563
20565
|
var WINDOW_WIDTH = useWindowDimensions().width;
|
|
20564
20566
|
var containerRef = React.useRef(null);
|
|
20565
20567
|
var styles = useCarouselStyles(BUTTON_SIZE);
|
|
20566
20568
|
var animatedIndex = React.useRef(new Animated$1.Value(0)).current;
|
|
20567
20569
|
var theme = useWllSdk().theme;
|
|
20568
|
-
var
|
|
20569
|
-
isDesktop =
|
|
20570
|
-
isTablet =
|
|
20570
|
+
var _c = useResponsive(),
|
|
20571
|
+
isDesktop = _c.isDesktop,
|
|
20572
|
+
isTablet = _c.isTablet;
|
|
20571
20573
|
var scrollViewRef = React.useRef(null);
|
|
20572
|
-
var
|
|
20574
|
+
var _d = React.useReducer(carouselReducer, __assign(__assign({}, initialState), {
|
|
20573
20575
|
containerWidth: WINDOW_WIDTH
|
|
20574
20576
|
})),
|
|
20575
|
-
state =
|
|
20576
|
-
dispatch =
|
|
20577
|
+
state = _d[0],
|
|
20578
|
+
dispatch = _d[1];
|
|
20577
20579
|
var currentIndex = state.currentIndex,
|
|
20578
20580
|
containerWidth = state.containerWidth;
|
|
20579
20581
|
var sortedTiles = sortByPriority(section.tiles.filter(function (tile) {
|
|
@@ -20604,15 +20606,40 @@ var Carousel = function (_a) {
|
|
|
20604
20606
|
};
|
|
20605
20607
|
var handleNext = function () {
|
|
20606
20608
|
var _a;
|
|
20609
|
+
var nextIndex = Math.min(sortedTiles.length - 1, currentIndex + 1);
|
|
20607
20610
|
dispatch({
|
|
20608
20611
|
type: 'NEXT_SLIDE',
|
|
20609
20612
|
maxIndex: sortedTiles.length - 1
|
|
20610
20613
|
});
|
|
20611
20614
|
(_a = scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
|
|
20612
|
-
x:
|
|
20615
|
+
x: nextIndex * containerWidth,
|
|
20613
20616
|
animated: true
|
|
20614
20617
|
});
|
|
20615
20618
|
};
|
|
20619
|
+
var rotateToNextSlide = React.useCallback(function () {
|
|
20620
|
+
var _a;
|
|
20621
|
+
if (currentIndex >= sortedTiles.length - 1) {
|
|
20622
|
+
dispatch({
|
|
20623
|
+
type: 'SET_CURRENT_INDEX',
|
|
20624
|
+
payload: 0
|
|
20625
|
+
});
|
|
20626
|
+
(_a = scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
|
|
20627
|
+
x: 0,
|
|
20628
|
+
animated: true
|
|
20629
|
+
});
|
|
20630
|
+
} else {
|
|
20631
|
+
handleNext();
|
|
20632
|
+
}
|
|
20633
|
+
}, [currentIndex, containerWidth, sortedTiles.length]);
|
|
20634
|
+
React.useEffect(function () {
|
|
20635
|
+
if (sortedTiles.length <= 1) return;
|
|
20636
|
+
var rotationTimer = setInterval(function () {
|
|
20637
|
+
rotateToNextSlide();
|
|
20638
|
+
}, autoRotateInterval);
|
|
20639
|
+
return function () {
|
|
20640
|
+
return clearInterval(rotationTimer);
|
|
20641
|
+
};
|
|
20642
|
+
}, [rotateToNextSlide, autoRotateInterval, sortedTiles.length]);
|
|
20616
20643
|
var displayControls = sortedTiles.length > 1;
|
|
20617
20644
|
var showPrevButton = displayControls && currentIndex > 0;
|
|
20618
20645
|
var showNextButton = displayControls && currentIndex < sortedTiles.length - 1;
|