@lookiero/checkout 3.10.0-beta.0 → 3.10.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 (27) hide show
  1. package/dist/infrastructure/ui/components/templates/header/Header.style.d.ts +1 -0
  2. package/dist/infrastructure/ui/components/templates/header/Header.style.js +3 -1
  3. package/package.json +1 -1
  4. package/dist/infrastructure/ui/components/layouts/layout/dummyLayout/useScrollViewRef.d.ts +0 -15
  5. package/dist/infrastructure/ui/components/layouts/layout/dummyLayout/useScrollViewRef.js +0 -14
  6. package/dist/shared/ui/components/layouts/carousel/Carousel2.d.ts +0 -30
  7. package/dist/shared/ui/components/layouts/carousel/Carousel2.js +0 -79
  8. package/dist/shared/ui/components/layouts/carousel/DragComponent.d.ts +0 -3
  9. package/dist/shared/ui/components/layouts/carousel/DragComponent.js +0 -48
  10. package/dist/shared/ui/components/layouts/slider/Bullets.d.ts +0 -10
  11. package/dist/shared/ui/components/layouts/slider/Bullets.js +0 -28
  12. package/dist/shared/ui/components/layouts/slider/Bullets.style.d.ts +0 -12
  13. package/dist/shared/ui/components/layouts/slider/Bullets.style.js +0 -15
  14. package/dist/shared/ui/components/layouts/slider/Bullets2.d.ts +0 -10
  15. package/dist/shared/ui/components/layouts/slider/Bullets2.js +0 -30
  16. package/dist/shared/ui/components/layouts/slider/Pagination.d.ts +0 -14
  17. package/dist/shared/ui/components/layouts/slider/Pagination.js +0 -11
  18. package/dist/shared/ui/components/layouts/slider/Pagination.style.d.ts +0 -23
  19. package/dist/shared/ui/components/layouts/slider/Pagination.style.js +0 -27
  20. package/dist/shared/ui/components/layouts/slider/Slider.d.ts +0 -15
  21. package/dist/shared/ui/components/layouts/slider/Slider.js +0 -132
  22. package/dist/shared/ui/components/layouts/slider/Slider.style.d.ts +0 -11
  23. package/dist/shared/ui/components/layouts/slider/Slider.style.js +0 -12
  24. package/dist/shared/ui/components/layouts/slider/SliderDots.d.ts +0 -8
  25. package/dist/shared/ui/components/layouts/slider/SliderDots.js +0 -16
  26. package/dist/shared/ui/components/layouts/slider/SliderDots.style.d.ts +0 -12
  27. package/dist/shared/ui/components/layouts/slider/SliderDots.style.js +0 -15
@@ -5,6 +5,7 @@ declare const style: {
5
5
  flexDirection: "row";
6
6
  flexGrow: number;
7
7
  flexWrap: "nowrap";
8
+ height: number;
8
9
  justifyContent: "space-between";
9
10
  overflow: "visible";
10
11
  paddingHorizontal: number;
@@ -1,6 +1,7 @@
1
1
  import { StyleSheet } from "react-native";
2
2
  import { theme } from "../../../theme/theme";
3
- const { colorBase, spaceS } = theme();
3
+ const { colorBase, spaceS, spaceXXXL } = theme();
4
+ const HEADER_HEIGHT = spaceXXXL;
4
5
  const style = StyleSheet.create({
5
6
  header: {
6
7
  alignItems: "center",
@@ -8,6 +9,7 @@ const style = StyleSheet.create({
8
9
  flexDirection: "row",
9
10
  flexGrow: 0,
10
11
  flexWrap: "nowrap",
12
+ height: HEADER_HEIGHT,
11
13
  justifyContent: "space-between",
12
14
  overflow: "visible",
13
15
  paddingHorizontal: spaceS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "3.10.0-beta.0",
3
+ "version": "3.10.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -1,15 +0,0 @@
1
- import { FC, ReactNode, Ref } from "react";
2
- import { GestureType, ScrollView } from "react-native-gesture-handler";
3
- interface ContextShape {
4
- readonly scrollViewRef: Ref<ScrollView>;
5
- readonly panGestureRef: Ref<GestureType>;
6
- }
7
- interface ScrollViewRefContextProviderProps {
8
- readonly children: ReactNode;
9
- }
10
- declare const ScrollViewRefContextProvider: FC<ScrollViewRefContextProviderProps>;
11
- interface UseScrollViewRefFunction {
12
- (): ContextShape;
13
- }
14
- declare const useScrollViewRef: UseScrollViewRefFunction;
15
- export { useScrollViewRef, ScrollViewRefContextProvider };
@@ -1,14 +0,0 @@
1
- import React, { createContext, useContext, useRef } from "react";
2
- import invariant from "tiny-invariant";
3
- const ScrollViewRefContext = createContext(null);
4
- const ScrollViewRefContextProvider = ({ children }) => {
5
- const scrollViewRef = useRef(null);
6
- const panGestureRef = useRef(null);
7
- return (React.createElement(ScrollViewRefContext.Provider, { value: { scrollViewRef, panGestureRef } }, children));
8
- };
9
- const useScrollViewRef = () => {
10
- const ref = useContext(ScrollViewRefContext);
11
- invariant(ref, "Your are trying to use the useScrollViewRef hook without wrapping your app with the <ScrollViewRefContextProvider>.");
12
- return ref;
13
- };
14
- export { useScrollViewRef, ScrollViewRefContextProvider };
@@ -1,30 +0,0 @@
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 };
@@ -1,79 +0,0 @@
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 };
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- declare const DragComponent: (props: any) => JSX.Element;
3
- export { DragComponent };
@@ -1,48 +0,0 @@
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 };
@@ -1,10 +0,0 @@
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 };
@@ -1,28 +0,0 @@
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 };
@@ -1,12 +0,0 @@
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 };
@@ -1,15 +0,0 @@
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 };
@@ -1,10 +0,0 @@
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 };
@@ -1,30 +0,0 @@
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,14 +0,0 @@
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 };
@@ -1,11 +0,0 @@
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 };
@@ -1,23 +0,0 @@
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 };
@@ -1,27 +0,0 @@
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 };
@@ -1,15 +0,0 @@
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 };
@@ -1,132 +0,0 @@
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 };
@@ -1,11 +0,0 @@
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 };
@@ -1,12 +0,0 @@
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 };
@@ -1,8 +0,0 @@
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 };
@@ -1,16 +0,0 @@
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 };
@@ -1,12 +0,0 @@
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 };
@@ -1,15 +0,0 @@
1
- import { StyleSheet } from "react-native";
2
- import { theme } from "../../../../../infrastructure/ui/theme/theme";
3
- const { spaceM } = theme();
4
- const style = StyleSheet.create({
5
- sliderDot: {
6
- marginHorizontal: 3,
7
- },
8
- sliderDots: {
9
- alignItems: "center",
10
- flexDirection: "row",
11
- justifyContent: "center",
12
- paddingVertical: spaceM,
13
- },
14
- });
15
- export { style };