@lookiero/checkout 3.10.0 → 4.0.0-beta.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.
Files changed (99) hide show
  1. package/dist/domain/checkoutBooking/event/createNotificationWhenCheckoutBookingExpired.d.ts +6 -0
  2. package/dist/domain/checkoutBooking/event/createNotificationWhenCheckoutBookingExpired.js +13 -0
  3. package/dist/infrastructure/domain/uiSetting/react/useIncrementIntroShownCount.d.ts +10 -0
  4. package/dist/infrastructure/domain/uiSetting/react/useIncrementIntroShownCount.js +11 -0
  5. package/dist/infrastructure/projection/uiSetting/react/useShouldIntroBeShown.d.ts +6 -0
  6. package/dist/infrastructure/projection/uiSetting/react/useShouldIntroBeShown.js +7 -0
  7. package/dist/infrastructure/projection/uiSetting/react/useViewIntroShownCount.d.ts +6 -0
  8. package/dist/infrastructure/projection/uiSetting/react/useViewIntroShownCount.js +9 -0
  9. package/dist/infrastructure/ui/Root.d.ts +2 -0
  10. package/dist/infrastructure/ui/Root.js +2 -2
  11. package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.d.ts +13 -0
  12. package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.js +19 -0
  13. package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.style.ts.d.ts +6 -0
  14. package/dist/infrastructure/ui/components/templates/SafeAreaScrollView.style.ts.js +7 -0
  15. package/dist/infrastructure/ui/components/templates/header/Header.style.d.ts +0 -1
  16. package/dist/infrastructure/ui/components/templates/header/Header.style.js +1 -3
  17. package/dist/infrastructure/ui/components/templates/header/header/Header.d.ts +3 -0
  18. package/dist/infrastructure/ui/components/templates/header/header/Header.js +10 -0
  19. package/dist/infrastructure/ui/components/templates/header/header/Header.style.d.ts +9 -0
  20. package/dist/infrastructure/ui/components/templates/header/header/Header.style.js +12 -0
  21. package/dist/infrastructure/ui/components/templates/safeAreaScrollView/SafeAreaScrollView.d.ts +13 -0
  22. package/dist/infrastructure/ui/components/templates/safeAreaScrollView/SafeAreaScrollView.js +19 -0
  23. package/dist/infrastructure/ui/components/templates/safeAreaScrollView/SafeAreaScrollView.style.ts.d.ts +6 -0
  24. package/dist/infrastructure/ui/components/templates/safeAreaScrollView/SafeAreaScrollView.style.ts.js +7 -0
  25. package/dist/infrastructure/ui/hooks/usePaymentInstrumentUpdateEvents.d.ts +2 -0
  26. package/dist/infrastructure/ui/hooks/usePaymentInstrumentUpdateEvents.js +28 -0
  27. package/dist/infrastructure/ui/hooks/useToast.d.ts +11 -0
  28. package/dist/infrastructure/ui/hooks/useToast.js +49 -0
  29. package/dist/infrastructure/ui/routing/Routing.d.ts +2 -0
  30. package/dist/infrastructure/ui/routing/Routing.js +2 -2
  31. package/dist/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.d.ts +4 -0
  32. package/dist/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +47 -3
  33. package/dist/infrastructure/ui/views/checkout/components/checkoutSuccessModal/CheckoutSuccessModal.d.ts +7 -0
  34. package/dist/infrastructure/ui/views/checkout/components/checkoutSuccessModal/CheckoutSuccessModal.js +25 -0
  35. package/dist/infrastructure/ui/views/checkout/components/checkoutSuccessModal/CheckoutSuccessModal.style.d.ts +16 -0
  36. package/dist/infrastructure/ui/views/checkout/components/checkoutSuccessModal/CheckoutSuccessModal.style.js +19 -0
  37. package/dist/infrastructure/ui/views/intro/Intro.d.ts +6 -0
  38. package/dist/infrastructure/ui/views/intro/Intro.js +52 -0
  39. package/dist/infrastructure/ui/views/intro/Intro.style.d.ts +52 -0
  40. package/dist/infrastructure/ui/views/intro/Intro.style.js +55 -0
  41. package/dist/infrastructure/ui/views/item/Item.style.d.ts +15 -0
  42. package/dist/infrastructure/ui/views/item/Item.style.js +18 -0
  43. package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.d.ts +26 -0
  44. package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.js +44 -0
  45. package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.style.d.ts +45 -0
  46. package/dist/infrastructure/ui/views/item/components/productVariant/ProductVariant.style.js +53 -0
  47. package/dist/infrastructure/ui/views/item/components/sizeChangeModal/SizeChangeModal.d.ts +7 -0
  48. package/dist/infrastructure/ui/views/item/components/sizeChangeModal/SizeChangeModal.js +25 -0
  49. package/dist/infrastructure/ui/views/item/components/sizeChangeModal/SizeChangeModal.style.d.ts +16 -0
  50. package/dist/infrastructure/ui/views/item/components/sizeChangeModal/SizeChangeModal.style.js +19 -0
  51. package/dist/infrastructure/ui/views/navigation/Navigation.d.ts +21 -0
  52. package/dist/infrastructure/ui/views/navigation/Navigation.js +45 -0
  53. package/dist/infrastructure/ui/views/navigation/Navigation.style.d.ts +5 -0
  54. package/dist/infrastructure/ui/views/navigation/Navigation.style.js +30 -0
  55. package/dist/infrastructure/ui/views/navigation/components/header/Header.d.ts +46 -0
  56. package/dist/infrastructure/ui/views/navigation/components/header/Header.js +120 -0
  57. package/dist/infrastructure/ui/views/navigation/components/header/Header.style.d.ts +31 -0
  58. package/dist/infrastructure/ui/views/navigation/components/header/Header.style.js +34 -0
  59. package/dist/infrastructure/ui/views/navigation/components/header/Logo.d.ts +7 -0
  60. package/dist/infrastructure/ui/views/navigation/components/header/Logo.js +11 -0
  61. package/dist/infrastructure/ui/views/navigation/components/header/Logo.style.d.ts +7 -0
  62. package/dist/infrastructure/ui/views/navigation/components/header/Logo.style.js +8 -0
  63. package/dist/infrastructure/ui/views/summary/components/checkoutItemsTabs/CheckoutItemsTabs.d.ts +12 -0
  64. package/dist/infrastructure/ui/views/summary/components/checkoutItemsTabs/CheckoutItemsTabs.js +24 -0
  65. package/dist/infrastructure/ui/views/summary/components/checkoutItemsTabs/CheckoutItemsTabs.style.d.ts +15 -0
  66. package/dist/infrastructure/ui/views/summary/components/checkoutItemsTabs/CheckoutItemsTabs.style.js +18 -0
  67. package/dist/projection/shared/order.d.ts +5 -0
  68. package/dist/projection/shared/order.js +1 -0
  69. package/dist/shared/notifications/domain/notification/command/createNotification.d.ts +17 -0
  70. package/dist/shared/notifications/domain/notification/command/createNotification.js +7 -0
  71. package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateNotification.d.ts +21 -0
  72. package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateNotification.js +22 -0
  73. package/dist/shared/notifications/infrastructure/ui/components/NotificationItem.d.ts +12 -0
  74. package/dist/shared/notifications/infrastructure/ui/components/NotificationItem.js +24 -0
  75. package/dist/shared/notifications/infrastructure/ui/components/Notifications.d.ts +9 -0
  76. package/dist/shared/notifications/infrastructure/ui/components/Notifications.js +20 -0
  77. package/dist/shared/notifications/infrastructure/ui/components/Notifications.style.d.ts +36 -0
  78. package/dist/shared/notifications/infrastructure/ui/components/Notifications.style.js +31 -0
  79. package/dist/shared/tracking/infrastructure/usePageView.d.ts +13 -0
  80. package/dist/shared/tracking/infrastructure/usePageView.js +27 -0
  81. package/dist/shared/tracking/infrastructure/useTrackCheckout.d.ts +25 -0
  82. package/dist/shared/tracking/infrastructure/useTrackCheckout.js +30 -0
  83. package/dist/shared/tracking/tracking.d.ts +15 -3
  84. package/dist/shared/tracking/tracking.js +2 -0
  85. package/dist/shared/ui/components/atoms/error/Error.style.d.ts +6 -0
  86. package/dist/shared/ui/components/atoms/error/Error.style.js +9 -0
  87. package/dist/shared/ui/components/layouts/slider/Bullets.d.ts +10 -0
  88. package/dist/shared/ui/components/layouts/slider/Bullets.js +29 -0
  89. package/dist/shared/ui/components/layouts/slider/Bullets.style.d.ts +12 -0
  90. package/dist/shared/ui/components/layouts/slider/Bullets.style.js +15 -0
  91. package/dist/shared/ui/components/layouts/slider/Pagination.d.ts +14 -0
  92. package/dist/shared/ui/components/layouts/slider/Pagination.js +11 -0
  93. package/dist/shared/ui/components/layouts/slider/Pagination.style.d.ts +23 -0
  94. package/dist/shared/ui/components/layouts/slider/Pagination.style.js +27 -0
  95. package/dist/shared/ui/components/layouts/slider/Slider.d.ts +15 -0
  96. package/dist/shared/ui/components/layouts/slider/Slider.js +132 -0
  97. package/dist/shared/ui/components/layouts/slider/Slider.style.d.ts +11 -0
  98. package/dist/shared/ui/components/layouts/slider/Slider.style.js +12 -0
  99. package/package.json +1 -1
@@ -0,0 +1,30 @@
1
+ import { useCallback } from "react";
2
+ import { PROJECT } from "../../../infrastructure/tracking/tracking";
3
+ import { TrackingEvent, TrackingEventCategory } from "../tracking";
4
+ import { useEmitUserEvent } from "./useEmitUserEvent";
5
+ const useTrackCheckout = ({ page, country, checkoutId }) => {
6
+ const emitUserEvent = useEmitUserEvent();
7
+ const trackCheckout = useCallback(({ checkoutItems, checkoutItemId, checkoutValue, isFirstOrder, orderNumber, productVariantId, sizeChange, userId, }) => {
8
+ if (!checkoutId) {
9
+ return;
10
+ }
11
+ const checkoutTrackingEvent = {
12
+ event: TrackingEvent.CHECKOUT,
13
+ eventCategory: TrackingEventCategory.ECOMMERCE,
14
+ section: `${PROJECT}_${page}`,
15
+ store: country,
16
+ checkoutId,
17
+ checkoutItems,
18
+ checkoutItemId,
19
+ checkoutValue,
20
+ isFirstOrder,
21
+ orderNumber,
22
+ productVariantId,
23
+ sizeChange,
24
+ userId,
25
+ };
26
+ emitUserEvent(checkoutTrackingEvent);
27
+ }, [checkoutId, country, emitUserEvent, page]);
28
+ return trackCheckout;
29
+ };
30
+ export { useTrackCheckout };
@@ -16,10 +16,12 @@ declare enum TrackingEvent {
16
16
  PRESS_MENU = "press_menu",
17
17
  PRESS_BACK = "press_back",
18
18
  PRESS_NEXT = "press_next",
19
- PRESS_PREVIOUS = "press_previous"
19
+ PRESS_PREVIOUS = "press_previous",
20
+ CHECKOUT = "checkout"
20
21
  }
21
22
  declare enum TrackingEventCategory {
22
- NAVIGATION = "navigation"
23
+ NAVIGATION = "navigation",
24
+ ECOMMERCE = "ecommerce"
23
25
  }
24
26
  interface BaseTrackingEvent {
25
27
  readonly event: TrackingEvent;
@@ -82,5 +84,15 @@ interface PressPreviousTrackingEvent extends BaseTrackingEvent {
82
84
  readonly from: string;
83
85
  readonly to: string;
84
86
  }
85
- export type { BaseTrackingEvent, ChangeFeedbackTrackingEvent, ImageViewTrackingEvent, ItemPageViewTrackingEvent, KeepItemTrackingEvent, PageViewTrackingEvent, PressContinueTrackingEvent, PressItemTrackingEvent, PressPricingTrackingEvent, ReplaceItemTrackingEvent, ResetItemTrackingEvent, ReturnItemTrackingEvent, TabViewTrackingEvent, PressMenuTrackingEvent, PressBackTrackingEvent, PressNextTrackingEvent, PressPreviousTrackingEvent, };
87
+ interface CheckoutTrackingEvent extends BaseTrackingEvent {
88
+ readonly userId: string;
89
+ readonly orderNumber: number;
90
+ readonly checkoutItems: number;
91
+ readonly productVariantId: string[];
92
+ readonly checkoutItemId: string[];
93
+ readonly checkoutValue: number;
94
+ readonly sizeChange: string[];
95
+ readonly isFirstOrder: boolean;
96
+ }
97
+ export type { BaseTrackingEvent, ChangeFeedbackTrackingEvent, CheckoutTrackingEvent, ImageViewTrackingEvent, ItemPageViewTrackingEvent, KeepItemTrackingEvent, PageViewTrackingEvent, PressContinueTrackingEvent, PressItemTrackingEvent, PressPricingTrackingEvent, ReplaceItemTrackingEvent, ResetItemTrackingEvent, ReturnItemTrackingEvent, TabViewTrackingEvent, PressMenuTrackingEvent, PressBackTrackingEvent, PressNextTrackingEvent, PressPreviousTrackingEvent, };
86
98
  export { TrackingEvent, TrackingEventCategory };
@@ -15,9 +15,11 @@ var TrackingEvent;
15
15
  TrackingEvent["PRESS_BACK"] = "press_back";
16
16
  TrackingEvent["PRESS_NEXT"] = "press_next";
17
17
  TrackingEvent["PRESS_PREVIOUS"] = "press_previous";
18
+ TrackingEvent["CHECKOUT"] = "checkout";
18
19
  })(TrackingEvent || (TrackingEvent = {}));
19
20
  var TrackingEventCategory;
20
21
  (function (TrackingEventCategory) {
21
22
  TrackingEventCategory["NAVIGATION"] = "navigation";
23
+ TrackingEventCategory["ECOMMERCE"] = "ecommerce";
22
24
  })(TrackingEventCategory || (TrackingEventCategory = {}));
23
25
  export { TrackingEvent, TrackingEventCategory };
@@ -0,0 +1,6 @@
1
+ declare const style: {
2
+ error: {
3
+ color: string;
4
+ };
5
+ };
6
+ export { style };
@@ -0,0 +1,9 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../../../../infrastructure/ui/theme/theme";
3
+ const { colorPrimary } = theme();
4
+ const style = StyleSheet.create({
5
+ error: {
6
+ color: colorPrimary,
7
+ },
8
+ });
9
+ export { style };
@@ -0,0 +1,10 @@
1
+ import { FC } from "react";
2
+ interface BulletsProps {
3
+ readonly activeIndex: number;
4
+ readonly onChange: (index: number) => void;
5
+ readonly count: number;
6
+ readonly maxBullets?: number;
7
+ readonly testID?: string;
8
+ }
9
+ declare const Bullets: FC<BulletsProps>;
10
+ export { Bullets };
@@ -0,0 +1,29 @@
1
+ import { animated, useSpring } from "@react-spring/native";
2
+ import React from "react";
3
+ import { TouchableHighlight, View } from "react-native";
4
+ import { theme } from "../../../../../infrastructure/ui/theme/theme";
5
+ import { style } from "./Bullets.style";
6
+ const { colorContent, colorGrayscaleM } = theme();
7
+ const colorTransparent = "rgba(0,0,0,0)";
8
+ const MAX = 7;
9
+ const DIAMETER_MAX = 8;
10
+ const DIAMETER_MIN = 2;
11
+ const Bullet = ({ index, activeIndex, maxBullets, onChange }) => {
12
+ const pivot = Math.floor(maxBullets / 2) + 1;
13
+ const delta = Math.abs(index - activeIndex);
14
+ const diameter = delta > 1 ? DIAMETER_MAX - delta * DIAMETER_MIN : DIAMETER_MAX;
15
+ const color = delta === 0 ? colorContent : colorGrayscaleM;
16
+ const springs = useSpring({ diameter, color });
17
+ return delta >= pivot ? null : (React.createElement(TouchableHighlight, { underlayColor: colorTransparent, onPress: () => onChange(index) },
18
+ React.createElement(animated.View, { accessibilityState: { selected: delta === 0 }, testID: "bullet", style: [
19
+ style.bullet,
20
+ {
21
+ width: springs.diameter,
22
+ height: springs.diameter,
23
+ backgroundColor: springs.color,
24
+ borderRadius: springs.diameter,
25
+ },
26
+ ] })));
27
+ };
28
+ const Bullets = ({ activeIndex, count, maxBullets = MAX, onChange, testID = "bullets" }) => (React.createElement(View, { style: style.bullets, testID: testID }, [...Array(count).keys()].map((index) => (React.createElement(Bullet, { key: index, activeIndex: activeIndex, index: index, maxBullets: maxBullets, onChange: onChange })))));
29
+ export { Bullets };
@@ -0,0 +1,12 @@
1
+ declare const style: {
2
+ bullet: {
3
+ marginHorizontal: number;
4
+ };
5
+ bullets: {
6
+ alignItems: "center";
7
+ flexDirection: "row";
8
+ justifyContent: "center";
9
+ paddingVertical: number;
10
+ };
11
+ };
12
+ export { style };
@@ -0,0 +1,15 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../../../../infrastructure/ui/theme/theme";
3
+ const { spaceM } = theme();
4
+ const style = StyleSheet.create({
5
+ bullet: {
6
+ marginHorizontal: 3,
7
+ },
8
+ bullets: {
9
+ alignItems: "center",
10
+ flexDirection: "row",
11
+ justifyContent: "center",
12
+ paddingVertical: spaceM,
13
+ },
14
+ });
15
+ export { style };
@@ -0,0 +1,14 @@
1
+ import { FC, ReactNode } from "react";
2
+ import { StyleProp, ViewStyle } from "react-native";
3
+ interface PaginationProps {
4
+ readonly touchable?: boolean;
5
+ readonly paginationStyle?: StyleProp<ViewStyle>;
6
+ readonly paginationItemStyle?: StyleProp<ViewStyle>;
7
+ readonly paginationActiveItemStyle?: StyleProp<ViewStyle>;
8
+ readonly count?: number;
9
+ readonly activeIndex?: number;
10
+ readonly onChange: (index: number) => void;
11
+ readonly renderItem?: (index: number) => ReactNode;
12
+ }
13
+ declare const Pagination: FC<PaginationProps>;
14
+ export { Pagination };
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { Pressable, View } from "react-native";
3
+ import { style } from "./Pagination.style";
4
+ const Pagination = ({ touchable = true, paginationStyle, paginationItemStyle, paginationActiveItemStyle, count = 0, activeIndex = 0, renderItem, onChange, }) => (React.createElement(View, { style: [style.paginationWrapper, paginationStyle], testID: "slider-pagination" }, Array.from(Array(count).keys()).map((index) => (React.createElement(View, { key: index, style: style.paginationContainer },
5
+ React.createElement(Pressable, { testID: "slider-pagination-item", style: [
6
+ style.paginationItem,
7
+ activeIndex === index && style.active,
8
+ paginationItemStyle,
9
+ activeIndex === index && paginationActiveItemStyle,
10
+ ], onPress: !touchable ? undefined : () => onChange(index) }, renderItem?.(index)))))));
11
+ export { Pagination };
@@ -0,0 +1,23 @@
1
+ declare const style: {
2
+ active: {
3
+ backgroundColor: string;
4
+ };
5
+ paginationContainer: {
6
+ margin: number;
7
+ };
8
+ paginationItem: {
9
+ backgroundColor: string;
10
+ borderRadius: number;
11
+ height: number;
12
+ width: number;
13
+ };
14
+ paginationWrapper: {
15
+ alignItems: "center";
16
+ bottom: number;
17
+ flexDirection: "row";
18
+ justifyContent: "center";
19
+ position: "absolute";
20
+ width: string;
21
+ };
22
+ };
23
+ export { style };
@@ -0,0 +1,27 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../../../../infrastructure/ui/theme/theme";
3
+ const { colorGrayscaleS, colorGrayscaleXL } = theme();
4
+ const DOT_SIZE = 8;
5
+ const style = StyleSheet.create({
6
+ active: {
7
+ backgroundColor: colorGrayscaleXL,
8
+ },
9
+ paginationContainer: {
10
+ margin: 3,
11
+ },
12
+ paginationItem: {
13
+ backgroundColor: colorGrayscaleS,
14
+ borderRadius: DOT_SIZE / 2,
15
+ height: DOT_SIZE,
16
+ width: DOT_SIZE,
17
+ },
18
+ paginationWrapper: {
19
+ alignItems: "center",
20
+ bottom: 10,
21
+ flexDirection: "row",
22
+ justifyContent: "center",
23
+ position: "absolute",
24
+ width: "100%",
25
+ },
26
+ });
27
+ export { style };
@@ -0,0 +1,15 @@
1
+ import { FC, ReactNode } from "react";
2
+ interface SliderProps {
3
+ readonly children: ReactNode[];
4
+ readonly active?: number;
5
+ readonly loop?: boolean;
6
+ readonly minDistanceToCapture?: number;
7
+ readonly minDistanceForAction?: number;
8
+ readonly gesturesEnabled?: boolean;
9
+ readonly paginationEnabled?: boolean;
10
+ readonly onSliderStart?: () => void;
11
+ readonly onSliderEnd?: () => void;
12
+ readonly onChanged?: (index: number) => void;
13
+ }
14
+ declare const Slider: FC<SliderProps>;
15
+ export { Slider };
@@ -0,0 +1,132 @@
1
+ import React, { useCallback, useEffect, useRef, useState } from "react";
2
+ import { Animated, I18nManager, PanResponder, StyleSheet, View } from "react-native";
3
+ import { Bullets } from "./Bullets";
4
+ import { style } from "./Slider.style";
5
+ const DEFAULT_WIDTH = 200;
6
+ const Slider = ({ children, active = 0, loop = false, minDistanceToCapture = 5, minDistanceForAction = 0.2, gesturesEnabled = true, paginationEnabled = true, onSliderStart, onSliderEnd, onChanged, }) => {
7
+ const flatennedChildren = children.flat();
8
+ const count = flatennedChildren.length;
9
+ const [width, setWidth] = useState(0);
10
+ const widthRef = useRef(width);
11
+ const activeIndex = useRef(active);
12
+ const animatedValueX = useRef(0);
13
+ const animatedValueY = useRef(0);
14
+ const pan = useRef(new Animated.ValueXY()).current;
15
+ const started = useRef(false);
16
+ const panResponder = useRef(PanResponder.create({
17
+ onPanResponderTerminationRequest: () => false,
18
+ onMoveShouldSetPanResponder: () => gesturesEnabled,
19
+ // eslint-disable-next-line @typescript-eslint/naming-convention
20
+ onMoveShouldSetPanResponderCapture: (_e, gestureState) => {
21
+ if (!gesturesEnabled) {
22
+ return false;
23
+ }
24
+ startAnimation();
25
+ const allow = Math.abs(gestureState.dx) > minDistanceToCapture;
26
+ return allow;
27
+ },
28
+ onPanResponderGrant: () => fixState(),
29
+ onPanResponderMove: Animated.event([null, { dx: pan.x }], {
30
+ useNativeDriver: false,
31
+ }),
32
+ // eslint-disable-next-line @typescript-eslint/naming-convention
33
+ onPanResponderRelease: (_e, gesture) => {
34
+ const correction = gesture.moveX - gesture.x0;
35
+ if (Math.abs(correction) < widthRef.current * minDistanceForAction) {
36
+ spring({ x: 0, y: 0 });
37
+ }
38
+ else {
39
+ changeIndex(correction > 0 ? (I18nManager.isRTL ? 1 : -1) : I18nManager.isRTL ? -1 : 1);
40
+ }
41
+ },
42
+ onPanResponderEnd: () => endAnimation(),
43
+ })).current;
44
+ const startAnimation = useCallback(() => {
45
+ if (!started.current) {
46
+ onSliderStart?.();
47
+ started.current = true;
48
+ }
49
+ }, [onSliderStart]);
50
+ const endAnimation = useCallback(() => {
51
+ if (started.current) {
52
+ onSliderEnd?.();
53
+ started.current = false;
54
+ }
55
+ }, [onSliderEnd]);
56
+ const fixState = useCallback(() => {
57
+ animatedValueX.current = widthRef.current * activeIndex.current * (I18nManager.isRTL ? 1 : -1);
58
+ animatedValueY.current = 0;
59
+ pan.setOffset({
60
+ x: animatedValueX.current,
61
+ y: animatedValueY.current,
62
+ });
63
+ pan.setValue({ x: 0, y: 0 });
64
+ }, [pan]);
65
+ const spring = useCallback((toValue) => {
66
+ Animated.spring(pan, {
67
+ toValue,
68
+ useNativeDriver: false,
69
+ }).start();
70
+ }, [pan]);
71
+ const changeIndex = useCallback((delta = 1) => {
72
+ const toValue = { x: 0, y: 0 };
73
+ let skipChanges = !delta;
74
+ let calcDelta = delta;
75
+ if (activeIndex.current <= 0 && delta < 0) {
76
+ skipChanges = !loop;
77
+ calcDelta = count + delta;
78
+ }
79
+ else if (activeIndex.current + 1 >= count && delta > 0) {
80
+ skipChanges = !loop;
81
+ calcDelta = -1 * activeIndex.current + delta - 1;
82
+ }
83
+ if (skipChanges) {
84
+ return spring(toValue);
85
+ }
86
+ const index = activeIndex.current + calcDelta;
87
+ activeIndex.current = index;
88
+ toValue.x = widthRef.current * (I18nManager.isRTL ? 1 : -1) * calcDelta;
89
+ spring(toValue);
90
+ onChanged?.(index);
91
+ }, [count, loop, onChanged, spring]);
92
+ const fixAndGo = useCallback((delta) => {
93
+ fixState();
94
+ startAnimation();
95
+ changeIndex(delta);
96
+ }, [changeIndex, fixState, startAnimation]);
97
+ const goTo = useCallback((index = 0) => {
98
+ const delta = index - activeIndex.current;
99
+ if (delta) {
100
+ fixAndGo(delta);
101
+ }
102
+ }, [fixAndGo]);
103
+ const getActiveIndex = useCallback(() => activeIndex.current, []);
104
+ useEffect(() => {
105
+ pan.x.addListener(({ value }) => (animatedValueX.current = value));
106
+ pan.y.addListener(({ value }) => (animatedValueY.current = value));
107
+ return () => {
108
+ pan.x.removeAllListeners();
109
+ pan.y.removeAllListeners();
110
+ };
111
+ }, [pan.x, pan.y]);
112
+ useEffect(() => {
113
+ if (activeIndex.current !== active) {
114
+ goTo(active);
115
+ }
116
+ }, [active, goTo]);
117
+ const onLayoutWrapper = useCallback(({ nativeEvent: { layout: { width: wrapperWidth }, }, }) => {
118
+ const width = wrapperWidth || DEFAULT_WIDTH;
119
+ setWidth(width);
120
+ widthRef.current = width;
121
+ fixState();
122
+ }, [fixState]);
123
+ return (React.createElement(View, { style: style.container, testID: "slider", onLayout: onLayoutWrapper },
124
+ React.createElement(Animated.View, { style: StyleSheet.flatten([
125
+ {
126
+ left: pan.x,
127
+ },
128
+ style.sliderAreaStyle,
129
+ ]), ...panResponder.panHandlers }, flatennedChildren.map((child, index) => (React.createElement(View, { key: index, style: { width }, testID: "slider-child" }, child)))),
130
+ paginationEnabled && (React.createElement(Bullets, { activeIndex: getActiveIndex(), count: count, testID: "slider-bullets", onChange: (index) => goTo(index) }))));
131
+ };
132
+ export { Slider };
@@ -0,0 +1,11 @@
1
+ declare const style: {
2
+ container: {
3
+ flex: number;
4
+ overflow: "hidden";
5
+ };
6
+ sliderAreaStyle: {
7
+ flex: number;
8
+ flexDirection: "row";
9
+ };
10
+ };
11
+ export { style };
@@ -0,0 +1,12 @@
1
+ import { StyleSheet } from "react-native";
2
+ const style = StyleSheet.create({
3
+ container: {
4
+ flex: 1,
5
+ overflow: "hidden",
6
+ },
7
+ sliderAreaStyle: {
8
+ flex: 1,
9
+ flexDirection: "row",
10
+ },
11
+ });
12
+ export { style };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "3.10.0",
3
+ "version": "4.0.0-beta.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [