@lookiero/checkout 3.8.0 → 3.9.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 (72) hide show
  1. package/dist/infrastructure/projection/checkout/checkout.js +14 -0
  2. package/dist/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.js +7 -5
  3. package/dist/infrastructure/ui/components/layouts/layout/dummyLayout/useScrollViewRef.d.ts +15 -0
  4. package/dist/infrastructure/ui/components/layouts/layout/dummyLayout/useScrollViewRef.js +14 -0
  5. package/dist/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestion.js +1 -1
  6. package/dist/infrastructure/ui/components/organisms/checkoutQuestions/components/CheckoutQuestionItem.d.ts +0 -1
  7. package/dist/infrastructure/ui/components/organisms/checkoutQuestions/components/buttonCheckoutQuestionItem/ButtonCheckoutQuestionItem.js +2 -2
  8. package/dist/infrastructure/ui/components/organisms/checkoutQuestions/components/iconCheckoutQuestionItem/IconCheckoutQuestionItem.js +3 -3
  9. package/dist/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.js +2 -2
  10. package/dist/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.js +1 -1
  11. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/ReturnQuestionItem.d.ts +0 -1
  12. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.js +2 -2
  13. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.js +2 -2
  14. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +2 -2
  15. package/dist/infrastructure/ui/components/templates/header/Header.style.d.ts +1 -0
  16. package/dist/infrastructure/ui/components/templates/header/Header.style.js +3 -1
  17. package/dist/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.js +1 -1
  18. package/dist/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.js +4 -6
  19. package/dist/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.style.d.ts +3 -10
  20. package/dist/infrastructure/ui/views/item/components/getOutOfCheckoutModal/GetOutOfCheckoutModal.style.js +3 -10
  21. package/dist/infrastructure/ui/views/item/components/itemActions/ItemActions.js +3 -4
  22. package/dist/infrastructure/ui/views/item/components/itemActions/ItemActions.style.d.ts +0 -3
  23. package/dist/infrastructure/ui/views/item/components/itemActions/ItemActions.style.js +3 -6
  24. package/dist/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.style.d.ts +2 -1
  25. package/dist/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.style.js +4 -3
  26. package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.js +9 -15
  27. package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.style.d.ts +3 -0
  28. package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.style.js +3 -0
  29. package/dist/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.style.d.ts +0 -1
  30. package/dist/infrastructure/ui/views/item/components/returnQuestionsFeedback/ReturnQuestionsFeedback.style.js +0 -1
  31. package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +2 -3
  32. package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +0 -3
  33. package/dist/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.js +0 -3
  34. package/dist/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.js +3 -4
  35. package/dist/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.style.d.ts +3 -10
  36. package/dist/infrastructure/ui/views/item/components/sizeWithoutStockModal/SizeWithoutStockModal.style.js +3 -10
  37. package/dist/infrastructure/ui/views/item/views/productVariant/ProductVariant.js +2 -1
  38. package/dist/infrastructure/ui/views/item/views/productVariant/ProductVariant.style.d.ts +0 -4
  39. package/dist/infrastructure/ui/views/item/views/productVariant/ProductVariant.style.js +0 -4
  40. package/dist/infrastructure/ui/views/summary/components/pricing/Pricing.js +7 -8
  41. package/dist/infrastructure/ui/views/summary/components/pricing/Pricing.style.d.ts +0 -6
  42. package/dist/infrastructure/ui/views/summary/components/pricing/Pricing.style.js +0 -6
  43. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotificationItem.js +3 -4
  44. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotificationItem.style.d.ts +3 -10
  45. package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotificationItem.style.js +3 -10
  46. package/dist/shared/ui/components/atoms/input/Input.js +2 -2
  47. package/dist/shared/ui/components/layouts/carousel/Carousel.d.ts +11 -0
  48. package/dist/shared/ui/components/layouts/carousel/Carousel.js +31 -0
  49. package/dist/shared/ui/components/layouts/carousel/Carousel.style.d.ts +24 -0
  50. package/dist/shared/ui/components/layouts/carousel/Carousel.style.js +25 -0
  51. package/dist/shared/ui/components/layouts/carousel/Carousel2.d.ts +30 -0
  52. package/dist/shared/ui/components/layouts/carousel/Carousel2.js +79 -0
  53. package/dist/shared/ui/components/layouts/carousel/DragComponent.d.ts +3 -0
  54. package/dist/shared/ui/components/layouts/carousel/DragComponent.js +48 -0
  55. package/dist/shared/ui/components/layouts/modal/Modal.js +1 -1
  56. package/dist/shared/ui/components/layouts/slider/Bullets.d.ts +10 -0
  57. package/dist/shared/ui/components/layouts/slider/Bullets.js +28 -0
  58. package/dist/shared/ui/components/layouts/slider/Bullets.style.d.ts +12 -0
  59. package/dist/shared/ui/components/layouts/slider/Bullets.style.js +15 -0
  60. package/dist/shared/ui/components/layouts/slider/Bullets2.d.ts +10 -0
  61. package/dist/shared/ui/components/layouts/slider/Bullets2.js +30 -0
  62. package/dist/shared/ui/components/layouts/slider/Slider.d.ts +0 -5
  63. package/dist/shared/ui/components/layouts/slider/Slider.js +4 -4
  64. package/dist/shared/ui/components/layouts/slider/SliderDots.d.ts +8 -0
  65. package/dist/shared/ui/components/layouts/slider/SliderDots.js +16 -0
  66. package/dist/shared/ui/components/layouts/slider/SliderDots.style.d.ts +12 -0
  67. package/dist/shared/ui/components/layouts/slider/SliderDots.style.js +15 -0
  68. package/dist/shared/ui/components/layouts/sticky/Sticky.js +1 -3
  69. package/dist/shared/ui/components/layouts/sticky/Sticky.style.d.ts +3 -0
  70. package/dist/shared/ui/components/layouts/sticky/Sticky.style.js +3 -2
  71. package/dist/shared/ui/components/molecules/selectField/SelectField.js +3 -3
  72. package/package.json +8 -1
@@ -5,9 +5,5 @@ const style = StyleSheet.create({
5
5
  content: {
6
6
  paddingHorizontal: spaceXL,
7
7
  },
8
- sliderContainer: {
9
- marginBottom: spaceXL,
10
- minHeight: 500,
11
- },
12
8
  });
13
9
  export { style };
@@ -1,4 +1,4 @@
1
- import { ALIGN, Button, Text } from "@lookiero/aurora";
1
+ import { Button, Text } from "@lookiero/aurora";
2
2
  import { useI18nMessage } from "@lookiero/i18n-react";
3
3
  import { animated, useSpring } from "@react-spring/native";
4
4
  import React from "react";
@@ -30,18 +30,17 @@ const Pricing = ({ pendingToPay, subtotal, balanceDiscount, discount, discountPe
30
30
  const feeText = useI18nMessage({ id: I18nMessages.SUMMARY_FEE });
31
31
  const collapsedStyle = useSpring({ opacitiy: collapsed ? 1 : 0 });
32
32
  const notCollapsedStyle = useSpring({ opacitiy: collapsed ? 0 : 1 });
33
- return (React.createElement(React.Fragment, null,
34
- collapsible && (React.createElement(Pressable, { style: style.iconContainer, testID: "pricing-collapsed", onPress: onPress }, collapsed ? (React.createElement(ArrowUp, { stroke: colorGrayscaleS, style: style.icon, testID: "arrow-up" })) : (React.createElement(ArrowDown, { stroke: colorGrayscaleS, style: style.icon, testID: "arrow-down" })))),
33
+ return (React.createElement(Pressable, { testID: "pricing", onPress: collapsible ? onPress : null },
34
+ collapsible && (React.createElement(View, { style: style.iconContainer }, collapsed ? (React.createElement(ArrowUp, { stroke: colorGrayscaleS, style: style.icon, testID: "arrow-up" })) : (React.createElement(ArrowDown, { stroke: colorGrayscaleS, style: style.icon, testID: "arrow-down" })))),
35
35
  collapsed && collapsible ? (React.createElement(animated.View, { style: [style.collapsed, { opacity: collapsedStyle.opacitiy }] },
36
- React.createElement(View, { style: style.collapsedContent },
36
+ React.createElement(View, null,
37
37
  React.createElement(Text, { level: 1, style: style.totalCollapsed, detail: true },
38
38
  totalText,
39
39
  " ",
40
40
  totalCheckoutItemsKeptText),
41
41
  React.createElement(Price, { price: pendingToPay, variant: "detail" })),
42
- React.createElement(View, { style: style.collapsedContent },
43
- React.createElement(Button, { busy: busy, testID: "confirm-checkout-collpased-button", small: true, onPress: onSubmit },
44
- React.createElement(Text, { align: ALIGN.CENTER, level: 3, selectable: false, style: style.buttonText, action: true, upperCase: true }, submitButtonText))))) : (React.createElement(animated.View, { style: { opacity: notCollapsedStyle.opacitiy } },
42
+ React.createElement(View, null,
43
+ React.createElement(Button, { busy: busy, small: true, onPress: onSubmit }, submitButtonText)))) : (React.createElement(animated.View, { style: { opacity: notCollapsedStyle.opacitiy } },
45
44
  React.createElement(Row, { text: `${subtotalText} ${totalCheckoutItemsKeptText}` },
46
45
  React.createElement(Price, { price: subtotal, variant: "subtotal" })),
47
46
  discount && discount.amount !== 0 && (React.createElement(Row, { text: discountText },
@@ -52,6 +51,6 @@ const Pricing = ({ pendingToPay, subtotal, balanceDiscount, discount, discountPe
52
51
  React.createElement(View, { style: style.divider }),
53
52
  React.createElement(Row, { level: 2, text: totalText },
54
53
  React.createElement(Price, { price: pendingToPay, variant: "total" })),
55
- React.createElement(Button, { busy: busy, testID: "confirm-checkout-button", onPress: onSubmit }, submitButtonText)))));
54
+ React.createElement(Button, { busy: busy, onPress: onSubmit }, submitButtonText)))));
56
55
  };
57
56
  export { Pricing };
@@ -1,14 +1,8 @@
1
1
  declare const style: {
2
- buttonText: {
3
- width: string;
4
- };
5
2
  collapsed: {
6
3
  flexDirection: "row";
7
4
  justifyContent: "space-between";
8
5
  };
9
- collapsedContent: {
10
- flex: number;
11
- };
12
6
  divider: {
13
7
  backgroundColor: string;
14
8
  height: number;
@@ -2,16 +2,10 @@ import { StyleSheet } from "react-native";
2
2
  import { theme } from "../../../../theme/theme";
3
3
  const { colorContent, spaceXS, spaceL } = theme();
4
4
  const style = StyleSheet.create({
5
- buttonText: {
6
- width: "100%",
7
- },
8
5
  collapsed: {
9
6
  flexDirection: "row",
10
7
  justifyContent: "space-between",
11
8
  },
12
- collapsedContent: {
13
- flex: 1,
14
- },
15
9
  divider: {
16
10
  backgroundColor: colorContent,
17
11
  height: 1,
@@ -24,9 +24,8 @@ const ModalNotificationItem = ({ visible, notification, onRemove, testID = "moda
24
24
  }, [notification.id, onRemove]);
25
25
  return (React.createElement(Modal, { testID: testID, visible: visible, onClose: handleOnClose },
26
26
  React.createElement(View, { style: style.modal },
27
- React.createElement(Text, { align: ALIGN.CENTER, level: 1, style: style.title }, titleText),
28
- React.createElement(Text, { level: 3, style: style.description }, bodyText),
29
- React.createElement(Button, { style: style.button, testID: "modal-notification-button", onPress: handleOnClose },
30
- React.createElement(Text, { align: ALIGN.CENTER, level: 3, selectable: false, style: style.buttonText, action: true, upperCase: true }, acceptText)))));
27
+ React.createElement(Text, { align: ALIGN.CENTER, level: 1 }, titleText),
28
+ React.createElement(Text, { level: 3, style: style.modalDescription }, bodyText),
29
+ React.createElement(Button, { style: style.button, onPress: handleOnClose }, acceptText))));
31
30
  };
32
31
  export { ModalNotificationItem };
@@ -2,19 +2,12 @@ declare const style: {
2
2
  button: {
3
3
  flex: number;
4
4
  };
5
- buttonText: {
6
- width: string;
7
- };
8
- description: {
9
- marginVertical: number;
10
- textAlign: "center";
11
- width: string;
12
- };
13
5
  modal: {
14
6
  padding: number;
15
7
  };
16
- title: {
17
- width: string;
8
+ modalDescription: {
9
+ marginVertical: number;
10
+ textAlign: "center";
18
11
  };
19
12
  };
20
13
  export { style };
@@ -5,19 +5,12 @@ const style = StyleSheet.create({
5
5
  button: {
6
6
  flex: 0,
7
7
  },
8
- buttonText: {
9
- width: "100%",
10
- },
11
- description: {
12
- marginVertical: spaceXL,
13
- textAlign: "center",
14
- width: "100%",
15
- },
16
8
  modal: {
17
9
  padding: spaceXL,
18
10
  },
19
- title: {
20
- width: "100%",
11
+ modalDescription: {
12
+ marginVertical: spaceXL,
13
+ textAlign: "center",
21
14
  },
22
15
  });
23
16
  export { style };
@@ -6,7 +6,7 @@ const MIN_HEIGHT = 56;
6
6
  const MAX_HEIGHT = 242; // 10 lines
7
7
  const { colorGrayscaleL } = theme();
8
8
  const clamp = (min, max, value) => Math.min(Math.max(min, value), max);
9
- const Input = ({ minHeight = MIN_HEIGHT, maxHeight = MAX_HEIGHT, style: customStyle, placeholderTextColor = colorGrayscaleL, onChange, onContentSizeChange, value, multiline, testID = "input", ...restOfProps }) => {
9
+ const Input = ({ minHeight = MIN_HEIGHT, maxHeight = MAX_HEIGHT, style: customStyle, placeholderTextColor = colorGrayscaleL, onChange, onContentSizeChange, value, multiline, ...restOfProps }) => {
10
10
  const [height, setHeight] = useState(minHeight);
11
11
  // When content height has became smaller the onContentSizeChange does in fact triggered but the internal height is incorrect.
12
12
  const handleOnContentSizeChange = useCallback((event) => {
@@ -32,6 +32,6 @@ const Input = ({ minHeight = MIN_HEIGHT, maxHeight = MAX_HEIGHT, style: customSt
32
32
  }, [maxHeight, minHeight, multiline]);
33
33
  useLayoutEffect(handleOnContentSizeChangeWeb, [handleOnContentSizeChangeWeb, value]);
34
34
  const textInputRef = useRef(null);
35
- return (React.createElement(TextInput, { ref: textInputRef, accessibilityLabel: testID, multiline: multiline, numberOfLines: !!multiline ? undefined : 1, placeholderTextColor: placeholderTextColor, style: [style.input, customStyle, { height }], testID: testID, textAlignVertical: "top", value: value, accessible: true, onChange: onChange, onContentSizeChange: handleOnContentSizeChange, ...restOfProps }));
35
+ return (React.createElement(TextInput, { ...restOfProps, ref: textInputRef, multiline: multiline, numberOfLines: !!multiline ? undefined : 1, placeholderTextColor: placeholderTextColor, style: [style.input, customStyle, { height }], testID: "input", textAlignVertical: "top", value: value, onChange: onChange, onContentSizeChange: handleOnContentSizeChange }));
36
36
  };
37
37
  export { Input };
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { TCarouselProps } from "react-native-reanimated-carousel";
3
+ type CarouselRenderItem<T> = TCarouselProps<T>["renderItem"];
4
+ interface CarouselProps<T> {
5
+ readonly data: T[];
6
+ readonly children: CarouselRenderItem<T>;
7
+ readonly onActiveIndexChanged?: (index: number) => void;
8
+ }
9
+ declare const Carousel: <T>({ data, children, onActiveIndexChanged }: CarouselProps<T>) => JSX.Element;
10
+ export type { CarouselRenderItem };
11
+ export { Carousel };
@@ -0,0 +1,31 @@
1
+ import React, { useCallback, useRef, useState } from "react";
2
+ import { View } from "react-native";
3
+ import { GestureHandlerRootView } from "react-native-gesture-handler";
4
+ import RNRCarousel from "react-native-reanimated-carousel";
5
+ import { Bullets } from "../slider/Bullets";
6
+ const Carousel = ({ data, children, onActiveIndexChanged }) => {
7
+ const [carouselDimensions, setCarouselDimensions] = useState();
8
+ const handleOnLayout = useCallback(({ nativeEvent: { layout: { width, height }, }, }) => setCarouselDimensions({ width, height }), []);
9
+ const ref = React.useRef(null);
10
+ const [activeIndex, setActiveIndex] = useState(0);
11
+ const activeIndexRef = useRef(activeIndex);
12
+ activeIndexRef.current = activeIndex;
13
+ const handleOnActiveChanged = useCallback((index) => ref.current?.scrollTo({ index, animated: true }), []);
14
+ const handleOnProgressChanged = useCallback(
15
+ // eslint-disable-next-line @typescript-eslint/naming-convention
16
+ (_offsetProgress, absoluteProgress) => {
17
+ const index = Math.round(absoluteProgress);
18
+ if (activeIndexRef.current === index) {
19
+ return;
20
+ }
21
+ setActiveIndex(index);
22
+ onActiveIndexChanged?.(index);
23
+ }, [onActiveIndexChanged]);
24
+ return (React.createElement(React.Fragment, null,
25
+ React.createElement(View, { style: { flex: 1 }, onLayout: handleOnLayout }, carouselDimensions && (React.createElement(GestureHandlerRootView, { style: { flex: 1 } },
26
+ React.createElement(RNRCarousel, { ref: ref, data: data, height: carouselDimensions.height, loop: false, renderItem: children, width: carouselDimensions.width, panGestureHandlerProps: {
27
+ activeOffsetX: [-10, 10],
28
+ }, onProgressChange: handleOnProgressChanged })))),
29
+ React.createElement(Bullets, { activeIndex: activeIndex, count: data.length, onChange: handleOnActiveChanged })));
30
+ };
31
+ export { Carousel };
@@ -0,0 +1,24 @@
1
+ declare const style: {
2
+ bullets: {
3
+ bottom: number;
4
+ justifyContent: "center";
5
+ position: "absolute";
6
+ width: string;
7
+ };
8
+ carousel: {
9
+ flex: number;
10
+ };
11
+ carouselItem: {
12
+ flex: number;
13
+ };
14
+ carouselTrack: {
15
+ flex: number;
16
+ flexDirection: "row";
17
+ height: string;
18
+ };
19
+ container: {
20
+ flex: number;
21
+ overflow: "hidden";
22
+ };
23
+ };
24
+ export { style };
@@ -0,0 +1,25 @@
1
+ import { StyleSheet } from "react-native";
2
+ const style = StyleSheet.create({
3
+ bullets: {
4
+ bottom: 0,
5
+ justifyContent: "center",
6
+ position: "absolute",
7
+ width: "100%",
8
+ },
9
+ carousel: {
10
+ flex: 1,
11
+ },
12
+ carouselItem: {
13
+ flex: 1,
14
+ },
15
+ carouselTrack: {
16
+ flex: 1,
17
+ flexDirection: "row",
18
+ height: "100%",
19
+ },
20
+ container: {
21
+ flex: 1,
22
+ overflow: "hidden",
23
+ },
24
+ });
25
+ export { style };
@@ -0,0 +1,30 @@
1
+ /// <reference types="react" />
2
+ import { StyleProp, ViewStyle } from "react-native";
3
+ interface RenderItemFunctionArgs<T> {
4
+ readonly item: T;
5
+ readonly index: number;
6
+ }
7
+ interface RenderItemFunction<T> {
8
+ (args: RenderItemFunctionArgs<T>): JSX.Element;
9
+ }
10
+ interface RenderBulletsFunctionArgs {
11
+ readonly activeIndex: number;
12
+ readonly count: number;
13
+ readonly onChange: (index: number) => void;
14
+ }
15
+ interface RenderBulletsFunction {
16
+ (args: RenderBulletsFunctionArgs): JSX.Element;
17
+ }
18
+ interface CarouselStyle {
19
+ readonly container?: StyleProp<ViewStyle>;
20
+ }
21
+ interface CarouselProps<T> {
22
+ readonly data: T[];
23
+ readonly children: RenderItemFunction<T>;
24
+ readonly bullets: RenderBulletsFunction;
25
+ readonly onActiveIndexChanged?: (index: number) => void;
26
+ readonly style?: CarouselStyle;
27
+ }
28
+ declare const Carousel2: <T>({ data, children, bullets, onActiveIndexChanged, style: customStyle }: CarouselProps<T>) => JSX.Element;
29
+ export type { RenderItemFunction, RenderBulletsFunction };
30
+ export { Carousel2 };
@@ -0,0 +1,79 @@
1
+ import React, { useCallback, useMemo, useRef, useState } from "react";
2
+ import { View } from "react-native";
3
+ import { Gesture, GestureDetector, GestureHandlerRootView } from "react-native-gesture-handler";
4
+ import Animated, { useSharedValue, withSpring, useAnimatedStyle, runOnJS } from "react-native-reanimated";
5
+ import { style } from "./Carousel.style";
6
+ const SPRING_CONFIG = {
7
+ damping: 25,
8
+ mass: 1,
9
+ stiffness: 300,
10
+ };
11
+ const clamp = (min, max, value) => {
12
+ "worklet";
13
+ return Math.min(max, Math.max(min, value));
14
+ };
15
+ const Carousel2 = ({ data, children, bullets, onActiveIndexChanged, style: customStyle }) => {
16
+ const [carouselDimensions, setCarouselDimensions] = useState({
17
+ width: 0,
18
+ height: 0,
19
+ });
20
+ const handleOnLayout = useCallback(({ nativeEvent: { layout: { width, height }, }, }) => setCarouselDimensions({ width, height }), []);
21
+ const [activeIndex, setActiveIndex] = useState(0);
22
+ const activeIndexRef = useRef(activeIndex);
23
+ activeIndexRef.current = activeIndex;
24
+ const updateActiveIndex = useCallback((index) => {
25
+ if (activeIndexRef.current === index) {
26
+ return;
27
+ }
28
+ setActiveIndex(index);
29
+ onActiveIndexChanged?.(index);
30
+ }, [onActiveIndexChanged]);
31
+ const panTranslationX = useSharedValue(0);
32
+ const panInitialTranslationX = useSharedValue(undefined);
33
+ const handleOnActiveIndexChanged = useCallback((index) => {
34
+ updateActiveIndex(index);
35
+ panTranslationX.value = withSpring(-index * carouselDimensions.width, SPRING_CONFIG);
36
+ }, [carouselDimensions.width, panTranslationX, updateActiveIndex]);
37
+ const panGesture = useMemo(() => Gesture.Pan()
38
+ .maxPointers(1)
39
+ .activeOffsetX([-20, 20])
40
+ // .failOffsetY([-20, 20])
41
+ // This method does not work if legacy implementation is enabled
42
+ // Expo.tsx => enableLegacyWebImplementation(true)
43
+ // .onStart(() => {
44
+ // panInitialTranslationX.value = panTranslationX.value;
45
+ // })
46
+ // This method is defined as legacy implementation is enabled
47
+ .onBegin(() => {
48
+ panInitialTranslationX.value = panTranslationX.value;
49
+ })
50
+ .onUpdate(({ translationX }) => {
51
+ if (panInitialTranslationX.value === undefined) {
52
+ return;
53
+ }
54
+ const tX = panInitialTranslationX.value + translationX;
55
+ const index = clamp(0, data.length - 1, Math.round(-tX / carouselDimensions.width));
56
+ panTranslationX.value = tX;
57
+ runOnJS(updateActiveIndex)(index);
58
+ })
59
+ .onEnd(({ translationX, velocityX }) => {
60
+ if (panInitialTranslationX.value === undefined) {
61
+ return;
62
+ }
63
+ const tX = panInitialTranslationX.value + translationX;
64
+ const indexDelta = Math.round(translationX / carouselDimensions.width);
65
+ const velocityIndex = Math.abs(indexDelta) > 0 ? 0 : clamp(-1, 1, Math.abs(velocityX) > 2 ? -velocityX : 0);
66
+ const index = clamp(0, data.length - 1, Math.round(-tX / carouselDimensions.width) + velocityIndex);
67
+ panTranslationX.value = withSpring(-index * carouselDimensions.width, SPRING_CONFIG);
68
+ panInitialTranslationX.value = undefined;
69
+ runOnJS(updateActiveIndex)(index);
70
+ }), [carouselDimensions.width, data.length, panInitialTranslationX, panTranslationX, updateActiveIndex]);
71
+ const animatedStyle = useAnimatedStyle(() => ({ transform: [{ translateX: panTranslationX.value }] }), [panTranslationX]);
72
+ return (React.createElement(View, { style: [style.container, customStyle?.container] },
73
+ React.createElement(View, { style: style.carousel, onLayout: handleOnLayout },
74
+ React.createElement(GestureHandlerRootView, { style: { flex: 1 } },
75
+ React.createElement(GestureDetector, { gesture: panGesture },
76
+ React.createElement(Animated.View, { style: [style.carouselTrack, { width: carouselDimensions.width * data.length }, animatedStyle] }, data.map((item, index) => (React.createElement(View, { key: index, style: [style.carouselItem, { width: carouselDimensions.width }] }, children({ index, item })))))))),
77
+ React.createElement(View, { style: style.bullets }, bullets({ activeIndex, count: data.length, onChange: handleOnActiveIndexChanged }))));
78
+ };
79
+ export { Carousel2 };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const DragComponent: (props: any) => JSX.Element;
3
+ export { DragComponent };
@@ -0,0 +1,48 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
2
+ import React from "react";
3
+ import { View } from "react-native";
4
+ import { Gesture, GestureDetector } from "react-native-gesture-handler";
5
+ import { useSharedValue } from "react-native-reanimated";
6
+ import { useScrollViewRef } from "../../../../../infrastructure/ui/components/layouts/layout/dummyLayout/useScrollViewRef";
7
+ const TOUCH_SLOP = 5;
8
+ const TIME_TO_ACTIVATE_PAN = 400;
9
+ // @ts-ignore
10
+ const DragComponent = (props) => {
11
+ const { scrollViewRef, panGestureRef } = useScrollViewRef();
12
+ const touchStart = useSharedValue({ x: 0, y: 0, time: 0 });
13
+ const gesture = Gesture.Pan()
14
+ .manualActivation(true)
15
+ .onTouchesDown((e) => {
16
+ touchStart.value = {
17
+ // @ts-ignore
18
+ x: e.changedTouches[0].x,
19
+ // @ts-ignore
20
+ y: e.changedTouches[0].y,
21
+ time: Date.now(),
22
+ };
23
+ })
24
+ .onTouchesMove((e, state) => {
25
+ if (Date.now() - touchStart.value.time > TIME_TO_ACTIVATE_PAN) {
26
+ state.activate();
27
+ console.log("activate");
28
+ }
29
+ else if (
30
+ // @ts-ignore
31
+ Math.abs(touchStart.value.x - e.changedTouches[0].x) > TOUCH_SLOP ||
32
+ // @ts-ignore
33
+ Math.abs(touchStart.value.y - e.changedTouches[0].y) > TOUCH_SLOP) {
34
+ state.fail();
35
+ console.log("fail");
36
+ }
37
+ })
38
+ .onUpdate(() => {
39
+ console.log("pan update");
40
+ })
41
+ // @ts-ignore
42
+ .simultaneousWithExternalGesture(scrollViewRef)
43
+ // @ts-ignore
44
+ .withRef(panGestureRef);
45
+ return (React.createElement(GestureDetector, { gesture: gesture },
46
+ React.createElement(View, null, props.children)));
47
+ };
48
+ export { DragComponent };
@@ -75,7 +75,7 @@ const Modal = ({ children, visible, header, footer, portalHostName, onClose, sho
75
75
  (header || showCloseButton) && (React.createElement(View, { style: [style.header, customStyle?.header] },
76
76
  React.createElement(View, null, header),
77
77
  showCloseButton && (React.createElement(ButtonIcon, { name: "close", style: { button: customStyle?.closeButton }, onPress: onClose })))),
78
- React.createElement(ModalContentView, { keyboardShouldPersistTaps: "handled" },
78
+ React.createElement(ModalContentView, null,
79
79
  React.createElement(View, { style: {
80
80
  paddingBottom: safeAreaInsetBottom +
81
81
  (Platform.OS !== "ios" ? spaceXL : 0) +
@@ -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,28 @@
1
+ import { animated, useSpring } from "@react-spring/native";
2
+ import React from "react";
3
+ import { View, Pressable } from "react-native";
4
+ import { theme } from "../../../../../infrastructure/ui/theme/theme";
5
+ import { style } from "./Bullets.style";
6
+ const { colorContent, colorGrayscaleM } = theme();
7
+ const MAX = 5;
8
+ const DIAMETER_MAX = 8;
9
+ const DIAMETER_MIN = 2;
10
+ const Bullet = ({ index, activeIndex, maxBullets, onChange }) => {
11
+ const pivot = Math.floor(maxBullets / 2) + 1;
12
+ const delta = Math.abs(index - activeIndex);
13
+ const diameter = delta > 1 ? DIAMETER_MAX - delta * DIAMETER_MIN : DIAMETER_MAX;
14
+ const color = delta === 0 ? colorContent : colorGrayscaleM;
15
+ const springs = useSpring({ diameter, color });
16
+ return delta >= pivot ? null : (React.createElement(Pressable, { onPress: () => onChange(index) },
17
+ React.createElement(animated.View, { accessibilityState: { selected: delta === 0 }, testID: "bullet", style: [
18
+ style.bullet,
19
+ {
20
+ width: springs.diameter,
21
+ height: springs.diameter,
22
+ backgroundColor: springs.color,
23
+ borderRadius: springs.diameter,
24
+ },
25
+ ] })));
26
+ };
27
+ 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 })))));
28
+ 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,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,30 @@
1
+ import React, { useEffect } from "react";
2
+ import { View, Pressable } from "react-native";
3
+ import Animated, { useAnimatedStyle, useDerivedValue, useSharedValue } from "react-native-reanimated";
4
+ import { withSpring } from "react-native-reanimated";
5
+ import { theme } from "../../../../../infrastructure/ui/theme/theme";
6
+ import { style } from "./Bullets.style";
7
+ const { colorContent, colorGrayscaleM } = theme();
8
+ const MAX = 5;
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 delta = useSharedValue(0);
15
+ useEffect(() => {
16
+ delta.value = Math.abs(index - activeIndex);
17
+ }, [activeIndex, delta, index]);
18
+ const diameter = useDerivedValue(() => withSpring(delta.value > 1 ? DIAMETER_MAX - delta.value * DIAMETER_MIN : DIAMETER_MAX), [delta]);
19
+ const color = useDerivedValue(() => withSpring(delta.value === 0 ? colorContent : colorGrayscaleM), [delta]);
20
+ const animatedStyle = useAnimatedStyle(() => ({
21
+ width: diameter.value,
22
+ height: diameter.value,
23
+ backgroundColor: color.value,
24
+ borderRadius: diameter.value,
25
+ }), [diameter, color]);
26
+ return delta.value >= pivot ? null : (React.createElement(Pressable, { onPress: () => onChange(index) },
27
+ React.createElement(Animated.View, { accessibilityState: { selected: delta.value === 0 }, style: [style.bullet, animatedStyle], testID: "bullet" })));
28
+ };
29
+ 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 })))));
30
+ export { Bullets };
@@ -1,5 +1,4 @@
1
1
  import { FC, ReactNode } from "react";
2
- import { StyleProp, ViewStyle } from "react-native";
3
2
  interface SliderProps {
4
3
  readonly children: ReactNode[];
5
4
  readonly active?: number;
@@ -8,13 +7,9 @@ interface SliderProps {
8
7
  readonly minDistanceForAction?: number;
9
8
  readonly gesturesEnabled?: boolean;
10
9
  readonly paginationEnabled?: boolean;
11
- readonly paginationStyle?: StyleProp<ViewStyle>;
12
- readonly paginationItemStyle?: StyleProp<ViewStyle>;
13
- readonly paginationActiveItemStyle?: StyleProp<ViewStyle>;
14
10
  readonly onSliderStart?: () => void;
15
11
  readonly onSliderEnd?: () => void;
16
12
  readonly onChanged?: (index: number) => void;
17
- readonly paginationRenderItem?: (index: number) => ReactNode;
18
13
  }
19
14
  declare const Slider: FC<SliderProps>;
20
15
  export { Slider };
@@ -1,9 +1,9 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from "react";
2
- import { Animated, I18nManager, PanResponder, StyleSheet, View, } from "react-native";
3
- import { Pagination } from "./Pagination";
2
+ import { Animated, I18nManager, PanResponder, StyleSheet, View } from "react-native";
3
+ import { Bullets } from "./Bullets";
4
4
  import { style } from "./Slider.style";
5
5
  const DEFAULT_WIDTH = 200;
6
- const Slider = ({ children, active = 0, loop = false, minDistanceToCapture = 5, minDistanceForAction = 0.2, gesturesEnabled = true, paginationEnabled = true, paginationStyle, paginationItemStyle, paginationActiveItemStyle, onSliderStart, onSliderEnd, onChanged, paginationRenderItem, }) => {
6
+ const Slider = ({ children, active = 0, loop = false, minDistanceToCapture = 5, minDistanceForAction = 0.2, gesturesEnabled = true, paginationEnabled = true, onSliderStart, onSliderEnd, onChanged, }) => {
7
7
  const flatennedChildren = children.flat();
8
8
  const count = flatennedChildren.length;
9
9
  const [width, setWidth] = useState(0);
@@ -127,6 +127,6 @@ const Slider = ({ children, active = 0, loop = false, minDistanceToCapture = 5,
127
127
  },
128
128
  style.sliderAreaStyle,
129
129
  ]), ...panResponder.panHandlers }, flatennedChildren.map((child, index) => (React.createElement(View, { key: index, style: { width }, testID: "slider-child" }, child)))),
130
- paginationEnabled && (React.createElement(Pagination, { activeIndex: getActiveIndex(), count: count, paginationActiveItemStyle: paginationActiveItemStyle, paginationItemStyle: paginationItemStyle, paginationStyle: paginationStyle, renderItem: paginationRenderItem, onChange: (index) => goTo(index) }))));
130
+ paginationEnabled && (React.createElement(Bullets, { activeIndex: getActiveIndex(), count: count, testID: "slider-bullets", onChange: (index) => goTo(index) }))));
131
131
  };
132
132
  export { Slider };
@@ -0,0 +1,8 @@
1
+ import { FC } from "react";
2
+ interface SliderDotsProps {
3
+ readonly count: number;
4
+ readonly index: number;
5
+ readonly onChange: (index: number) => void;
6
+ }
7
+ declare const SliderDots: FC<SliderDotsProps>;
8
+ export { SliderDots };
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import { TouchableWithoutFeedback, View } from "react-native";
3
+ import { theme } from "../../../../../infrastructure/ui/theme/theme";
4
+ import { style } from "./SliderDots.style";
5
+ const { colorContent } = theme();
6
+ const SliderDot = ({ diameter, color }) => (React.createElement(View, { style: [style.sliderDot, { width: diameter, height: diameter, backgroundColor: color, borderRadius: diameter }] }));
7
+ const SliderDots = () => {
8
+ return (React.createElement(View, { style: style.sliderDots },
9
+ React.createElement(TouchableWithoutFeedback, null,
10
+ React.createElement(SliderDot, { color: colorContent, diameter: 8 })),
11
+ React.createElement(TouchableWithoutFeedback, null,
12
+ React.createElement(SliderDot, { color: colorContent, diameter: 8 })),
13
+ React.createElement(TouchableWithoutFeedback, null,
14
+ React.createElement(SliderDot, { color: colorContent, diameter: 8 }))));
15
+ };
16
+ export { SliderDots };
@@ -0,0 +1,12 @@
1
+ declare const style: {
2
+ sliderDot: {
3
+ marginHorizontal: number;
4
+ };
5
+ sliderDots: {
6
+ alignItems: "center";
7
+ flexDirection: "row";
8
+ justifyContent: "center";
9
+ paddingVertical: number;
10
+ };
11
+ };
12
+ export { style };