@ledgerhq/native-ui 0.56.0 → 0.57.0-nightly.20260220030210
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.
|
@@ -3,7 +3,6 @@ import { ViewStyle, FlatListProps } from "react-native";
|
|
|
3
3
|
import { type ProgressIndicatorElement } from "./ProgressIndicator";
|
|
4
4
|
import { type ContentElement } from "./Content";
|
|
5
5
|
import { type FooterElement } from "./Footer";
|
|
6
|
-
declare const AnimatedFlatList: React.ComponentClass<import("react-native-reanimated").AnimatedProps<FlatListProps<unknown>>, any>;
|
|
7
6
|
type SlidesChild = ContentElement | FooterElement | ProgressIndicatorElement;
|
|
8
7
|
export type SlidesProps = {
|
|
9
8
|
children: SlidesChild | SlidesChild[];
|
|
@@ -11,11 +10,11 @@ export type SlidesProps = {
|
|
|
11
10
|
initialSlideIndex?: number;
|
|
12
11
|
style?: ViewStyle;
|
|
13
12
|
/**
|
|
14
|
-
* Custom component to use instead of the default AnimatedFlatList.
|
|
15
|
-
* For instance, inside gorhom/bottom-sheet, we need to pass FlatList from react-native-gesture-handler.
|
|
16
13
|
* Make sure it is wrapped in Animated.createAnimatedComponent
|
|
14
|
+
* Any custom FlatList component can be used here.
|
|
15
|
+
* For instance, inside gorhom/bottom-sheet, we need to pass FlatList from react-native-gesture-handler.
|
|
17
16
|
*/
|
|
18
|
-
as?:
|
|
17
|
+
as?: React.ComponentType<any>;
|
|
19
18
|
testID?: string;
|
|
20
19
|
} & Omit<FlatListProps<React.ReactElement>, "data" | "renderItem" | "keyExtractor" | "horizontal" | "pagingEnabled" | "showsHorizontalScrollIndicator" | "onScroll" | "scrollEventThrottle" | "onMomentumScrollEnd" | "getItemLayout" | "initialScrollIndex" | "ref">;
|
|
21
20
|
export declare function Slides({ children, onSlideChange, initialSlideIndex, style, testID, as, ...flatListProps }: SlidesProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slides.d.ts","sourceRoot":"","sources":["../../../../src/components/Layout/Slides/Slides.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"Slides.d.ts","sourceRoot":"","sources":["../../../../src/components/Layout/Slides/Slides.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,EAKL,SAAS,EACT,aAAa,EACd,MAAM,cAAc,CAAC;AAQtB,OAAO,EAAqB,KAAK,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAEvF,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAMtD,KAAK,WAAW,GAAG,cAAc,GAAG,aAAa,GAAG,wBAAwB,CAAC;AAE7E,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,WAAW,GAAG,WAAW,EAAE,CAAC;IACtC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;OAIG;IACH,EAAE,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,IAAI,CACN,aAAa,CAAC,KAAK,CAAC,YAAY,CAAC,EAC/B,MAAM,GACN,YAAY,GACZ,cAAc,GACd,YAAY,GACZ,eAAe,GACf,gCAAgC,GAChC,UAAU,GACV,qBAAqB,GACrB,qBAAqB,GACrB,eAAe,GACf,oBAAoB,GACpB,KAAK,CACR,CAAC;AAEF,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,aAAa,EACb,iBAAqB,EACrB,KAAK,EACL,MAAM,EACN,EAAqB,EACrB,GAAG,aAAa,EACjB,EAAE,WAAW,2CA0Jb"}
|
|
@@ -8,6 +8,7 @@ import { Slide } from "./Slide";
|
|
|
8
8
|
import { Content } from "./Content";
|
|
9
9
|
import { Footer } from "./Footer";
|
|
10
10
|
import { isElementOfType } from "./utils";
|
|
11
|
+
import { scheduleOnRN } from "react-native-worklets";
|
|
11
12
|
const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);
|
|
12
13
|
export function Slides({ children, onSlideChange, initialSlideIndex = 0, style, testID, as = AnimatedFlatList, ...flatListProps }) {
|
|
13
14
|
const ListComponent = as;
|
|
@@ -50,17 +51,19 @@ export function Slides({ children, onSlideChange, initialSlideIndex = 0, style,
|
|
|
50
51
|
scrollProgressSharedValue.value = event.contentOffset.x / width;
|
|
51
52
|
}
|
|
52
53
|
},
|
|
54
|
+
onMomentumEnd: (event) => {
|
|
55
|
+
if (width <= 0)
|
|
56
|
+
return;
|
|
57
|
+
const offsetX = event.contentOffset.x;
|
|
58
|
+
const newIndex = Math.round(offsetX / width);
|
|
59
|
+
if (newIndex !== currentIndex) {
|
|
60
|
+
scheduleOnRN(setCurrentIndex, newIndex);
|
|
61
|
+
if (onSlideChange) {
|
|
62
|
+
scheduleOnRN(onSlideChange, newIndex);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
53
66
|
});
|
|
54
|
-
const handleMomentumScrollEnd = useCallback((event) => {
|
|
55
|
-
if (width <= 0)
|
|
56
|
-
return;
|
|
57
|
-
const offsetX = event.nativeEvent.contentOffset.x;
|
|
58
|
-
const newIndex = Math.round(offsetX / width);
|
|
59
|
-
if (newIndex !== currentIndex) {
|
|
60
|
-
setCurrentIndex(newIndex);
|
|
61
|
-
onSlideChange?.(newIndex);
|
|
62
|
-
}
|
|
63
|
-
}, [width, currentIndex, onSlideChange]);
|
|
64
67
|
const getItemLayout = useCallback((_, index) => ({
|
|
65
68
|
length: width,
|
|
66
69
|
offset: width * index,
|
|
@@ -84,9 +87,7 @@ export function Slides({ children, onSlideChange, initialSlideIndex = 0, style,
|
|
|
84
87
|
if (width <= 0) {
|
|
85
88
|
return null;
|
|
86
89
|
}
|
|
87
|
-
return (_jsx(ListComponent, { ref: flatListRef, data: slideChildren, renderItem: renderItem, keyExtractor: (_, index) => `slide-${index}`, horizontal: true,
|
|
88
|
-
// @ts-expect-error - pagingEnabled exists but typescript does not seem to know about it
|
|
89
|
-
pagingEnabled: true, showsHorizontalScrollIndicator: false, onScroll: scrollHandler, scrollEventThrottle: 16, onMomentumScrollEnd: handleMomentumScrollEnd, getItemLayout: getItemLayout, initialScrollIndex: initialSlideIndex, ...flatListProps }, "slides-content"));
|
|
90
|
+
return (_jsx(ListComponent, { ref: flatListRef, data: slideChildren, renderItem: renderItem, keyExtractor: (_, index) => `slide-${index}`, horizontal: true, pagingEnabled: true, showsHorizontalScrollIndicator: false, onScroll: scrollHandler, scrollEventThrottle: 16, getItemLayout: getItemLayout, initialScrollIndex: initialSlideIndex, ...flatListProps }, "slides-content"));
|
|
90
91
|
}
|
|
91
92
|
if (isElementOfType(child, Footer) || isElementOfType(child, ProgressIndicator)) {
|
|
92
93
|
return child;
|
|
@@ -99,7 +100,6 @@ export function Slides({ children, onSlideChange, initialSlideIndex = 0, style,
|
|
|
99
100
|
slideChildren,
|
|
100
101
|
renderItem,
|
|
101
102
|
scrollHandler,
|
|
102
|
-
handleMomentumScrollEnd,
|
|
103
103
|
getItemLayout,
|
|
104
104
|
initialSlideIndex,
|
|
105
105
|
flatListProps,
|