@ledgerhq/native-ui 0.5.0 → 0.6.3

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 (104) hide show
  1. package/README.md +1 -4
  2. package/components/Carousel/index.js +3 -5
  3. package/components/Form/Checkbox/index.d.ts +1 -1
  4. package/components/Form/Checkbox/index.js +1 -1
  5. package/components/Form/Input/BaseInput/index.d.ts +1 -1
  6. package/components/Form/Input/BaseInput/index.js +19 -5
  7. package/components/Form/Input/NumberInput/index.js +2 -2
  8. package/components/Form/SelectableList.d.ts +12 -3
  9. package/components/Form/SelectableList.js +9 -8
  10. package/components/Form/Slider/index.native.js +1 -1
  11. package/components/Form/Switch/index.d.ts +1 -1
  12. package/components/Form/Switch/index.js +2 -2
  13. package/components/Form/Toggle/index.d.ts +1 -1
  14. package/components/Form/Toggle/index.js +1 -1
  15. package/components/Form/index.d.ts +1 -0
  16. package/components/Form/index.js +1 -0
  17. package/components/Icon/BoxedIcon.d.ts +49 -0
  18. package/components/Icon/BoxedIcon.js +85 -0
  19. package/components/Icon/Icon.d.ts +9 -0
  20. package/components/Icon/Icon.js +20 -0
  21. package/components/Icon/IconBox/index.d.ts +2 -4
  22. package/components/Icon/IconBox/index.js +1 -2
  23. package/components/Icon/index.d.ts +2 -0
  24. package/components/Icon/index.js +2 -0
  25. package/components/Icon/type.d.ts +7 -0
  26. package/components/Icon/type.js +1 -0
  27. package/components/Layout/Collapse/Accordion/index.js +1 -1
  28. package/components/Layout/List/IconBoxList/index.d.ts +10 -0
  29. package/components/Layout/List/IconBoxList/index.js +19 -0
  30. package/components/Layout/List/List/index.d.ts +13 -0
  31. package/components/Layout/List/List/index.js +29 -0
  32. package/components/Layout/List/NumberedList/index.d.ts +9 -0
  33. package/components/Layout/List/NumberedList/index.js +23 -0
  34. package/components/Layout/List/TipList/index.d.ts +9 -0
  35. package/components/Layout/List/TipList/index.js +20 -0
  36. package/components/Layout/List/index.d.ts +4 -0
  37. package/components/Layout/List/index.js +4 -0
  38. package/components/Layout/ScrollContainer/index.d.ts +2 -1
  39. package/components/Layout/ScrollContainer/index.js +2 -2
  40. package/components/Layout/ScrollContainerHeader/Header.d.ts +1 -1
  41. package/components/Layout/ScrollContainerHeader/Header.js +23 -16
  42. package/components/Layout/ScrollContainerHeader/index.d.ts +3 -2
  43. package/components/Layout/ScrollContainerHeader/index.js +9 -4
  44. package/components/Layout/index.d.ts +1 -0
  45. package/components/Layout/index.js +1 -0
  46. package/components/Loader/InfiniteLoader/index.d.ts +9 -0
  47. package/components/Loader/InfiniteLoader/index.js +58 -0
  48. package/components/Loader/ProgressLoader/index.d.ts +11 -0
  49. package/components/Loader/ProgressLoader/index.js +24 -0
  50. package/components/Loader/index.d.ts +2 -11
  51. package/components/Loader/index.js +2 -24
  52. package/components/Navigation/FlowStepper/index.d.ts +70 -0
  53. package/components/Navigation/FlowStepper/index.js +36 -0
  54. package/components/Navigation/SlideIndicator/index.d.ts +1 -1
  55. package/components/Navigation/SlideIndicator/index.js +2 -3
  56. package/components/Navigation/Stepper/index.d.ts +1 -1
  57. package/components/Navigation/Stepper/index.js +4 -4
  58. package/components/Navigation/index.d.ts +1 -0
  59. package/components/Navigation/index.js +1 -0
  60. package/components/ProgressBar/index.d.ts +15 -0
  61. package/components/ProgressBar/index.js +33 -0
  62. package/components/Tabs/Chip/index.d.ts +5 -0
  63. package/components/Tabs/Chip/index.js +20 -0
  64. package/components/Tabs/Graph/index.d.ts +5 -0
  65. package/components/Tabs/Graph/index.js +21 -0
  66. package/components/Tabs/TemplateTabs/index.d.ts +29 -0
  67. package/components/Tabs/TemplateTabs/index.js +14 -0
  68. package/components/Tabs/index.d.ts +2 -0
  69. package/components/Tabs/index.js +2 -0
  70. package/components/Text/getTextStyle.d.ts +1 -0
  71. package/components/Text/getTextStyle.js +5 -0
  72. package/components/Text/index.d.ts +6 -8
  73. package/components/Text/index.js +15 -8
  74. package/components/cta/Button/index.d.ts +1 -0
  75. package/components/cta/Button/index.js +9 -11
  76. package/components/cta/Link/index.js +1 -5
  77. package/components/index.d.ts +4 -2
  78. package/components/index.js +5 -2
  79. package/components/message/Alert/index.d.ts +1 -1
  80. package/components/message/Alert/index.js +2 -2
  81. package/components/{drawer → message}/Notification/index.d.ts +5 -4
  82. package/components/{drawer → message}/Notification/index.js +16 -12
  83. package/components/message/index.d.ts +1 -0
  84. package/components/message/index.js +1 -0
  85. package/components/transitions/Fade.d.ts +5 -0
  86. package/components/transitions/Fade.js +32 -0
  87. package/components/transitions/Slide.d.ts +11 -0
  88. package/components/transitions/Slide.js +49 -0
  89. package/components/transitions/Transition.d.ts +49 -0
  90. package/components/transitions/Transition.js +39 -0
  91. package/components/transitions/index.d.ts +4 -0
  92. package/components/transitions/index.js +4 -0
  93. package/components/transitions/types.d.ts +21 -0
  94. package/components/transitions/types.js +1 -0
  95. package/package.json +3 -3
  96. package/styles/StyleProvider.d.ts +1 -1
  97. package/styles/StyleProvider.js +1 -1
  98. package/styles/helpers.js +1 -3
  99. package/assets/fonts/.DS_Store +0 -0
  100. package/assets/fonts/alpha/.DS_Store +0 -0
  101. package/components/Navigation/ToggleGroup/index.d.ts +0 -22
  102. package/components/Navigation/ToggleGroup/index.js +0 -25
  103. package/components/drawer/index.d.ts +0 -1
  104. package/components/drawer/index.js +0 -1
@@ -0,0 +1,20 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React, { useMemo } from "react";
13
+ import List from "../List";
14
+ import Check from "@ledgerhq/icons-ui/native/CheckAloneMedium";
15
+ import Close from "@ledgerhq/icons-ui/native/CloseMedium";
16
+ export default function TipList(_a) {
17
+ var { items } = _a, props = __rest(_a, ["items"]);
18
+ const tipItems = useMemo(() => items.map((item) => (Object.assign(Object.assign({}, item), { bullet: item.isPositive ? (React.createElement(Check, { size: 20, color: "success.c100" })) : (React.createElement(Close, { size: 20, color: "error.c100" })) }))), [items]);
19
+ return React.createElement(List, Object.assign({ items: tipItems }, props));
20
+ }
@@ -0,0 +1,4 @@
1
+ export { default as List } from "./List";
2
+ export { default as IconBoxList } from "./IconBoxList";
3
+ export { default as TipList } from "./TipList";
4
+ export { default as NumberedList } from "./NumberedList";
@@ -0,0 +1,4 @@
1
+ export { default as List } from "./List";
2
+ export { default as IconBoxList } from "./IconBoxList";
3
+ export { default as TipList } from "./TipList";
4
+ export { default as NumberedList } from "./NumberedList";
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
2
  import { SpaceProps } from "styled-system";
3
+ import { BaseStyledProps } from "../../styled";
3
4
  import type { NativeSyntheticEvent, NativeScrollEvent, ScrollViewProps } from "react-native";
4
- declare type ScrollContainerProps = ScrollViewProps & SpaceProps & {
5
+ declare type ScrollContainerProps = BaseStyledProps & ScrollViewProps & SpaceProps & {
5
6
  children: React.ReactNode;
6
7
  onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
7
8
  horizontal?: boolean;
@@ -11,9 +11,9 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import React from "react";
13
13
  import { space } from "styled-system";
14
- import styled from "styled-components/native";
14
+ import baseStyled from "../../styled";
15
15
  import Animated from "react-native-reanimated";
16
- const ScrollView = styled(Animated.ScrollView) `
16
+ const ScrollView = baseStyled(Animated.ScrollView) `
17
17
  ${space};
18
18
  `;
19
19
  const ScrollContainer = (_a) => {
@@ -7,5 +7,5 @@ export declare type HeaderProps = {
7
7
  BottomSection?: JSX.Element;
8
8
  currentPositionY: Animated.SharedValue<number>;
9
9
  };
10
- declare const Header: ({ TopLeftSection, TopRightSection, MiddleSection, BottomSection, currentPositionY, }: HeaderProps) => JSX.Element;
10
+ declare const Header: ({ TopLeftSection, TopRightSection, TopMiddleSection, MiddleSection, BottomSection, currentPositionY, }: HeaderProps) => JSX.Element;
11
11
  export default Header;
@@ -1,7 +1,6 @@
1
1
  import React, { useCallback, useState } from "react";
2
- import { View } from "react-native";
3
2
  import styled from "styled-components/native";
4
- import Animated, { useAnimatedStyle, interpolate, Extrapolate, } from "react-native-reanimated";
3
+ import Animated, { useAnimatedStyle, interpolate, Extrapolate } from "react-native-reanimated";
5
4
  import Flex from "../Flex";
6
5
  const Container = styled(Flex).attrs({
7
6
  paddingHorizontal: 16,
@@ -10,7 +9,7 @@ const Container = styled(Flex).attrs({
10
9
  width: 100%;
11
10
  `;
12
11
  const SCROLL_BREAKPOINT = 80;
13
- const Header = ({ TopLeftSection, TopRightSection, MiddleSection, BottomSection, currentPositionY, }) => {
12
+ const Header = ({ TopLeftSection, TopRightSection, TopMiddleSection, MiddleSection, BottomSection, currentPositionY, }) => {
14
13
  const [topSectionHeight, setTopSectionHeight] = useState(0);
15
14
  const [topSectionWidth, setTopSectionWidth] = useState(0);
16
15
  const [topMiddleWidth, setTopMiddleWidth] = useState(0);
@@ -29,34 +28,42 @@ const Header = ({ TopLeftSection, TopRightSection, MiddleSection, BottomSection,
29
28
  const onLayoutMiddle = useCallback(({ nativeEvent: { layout } }) => {
30
29
  setMiddleWidth(layout.width);
31
30
  }, []);
31
+ const TopMiddleStyle = useAnimatedStyle(() => {
32
+ const scaleRatio = middleWidth ? Math.min(topMiddleWidth / middleWidth, 0.9) : 0.7;
33
+ /** scale the animated content to fit in the available space on the top header section */
34
+ const scale = interpolate(currentPositionY.value, [0, SCROLL_BREAKPOINT], [1, scaleRatio], Extrapolate.CLAMP);
35
+ /** offset horizontaly given the scale transformation and potential top left header section */
36
+ const translateX = interpolate(currentPositionY.value, [0, SCROLL_BREAKPOINT], [0, -(topMiddleWidth - topMiddleWidth * scaleRatio) / 2], Extrapolate.CLAMP);
37
+ const opacity = interpolate(currentPositionY.value, [SCROLL_BREAKPOINT - 1, SCROLL_BREAKPOINT + 40], [0, 1], Extrapolate.CLAMP);
38
+ return {
39
+ transform: [{ translateX }, { scale }],
40
+ flex: 1,
41
+ opacity,
42
+ justifyContent: "center", // needed to ensure vertical centering of animated content
43
+ };
44
+ }, [topLeftWidth, topSectionHeight, middleWidth, topMiddleWidth, topSectionWidth]);
32
45
  const MiddleStyle = useAnimatedStyle(() => {
33
- const scaleRatio = middleWidth
34
- ? Math.min(topMiddleWidth / middleWidth, 0.9)
35
- : 0.7;
46
+ const scaleRatio = middleWidth ? Math.min(topMiddleWidth / middleWidth, 0.9) : 0.7;
36
47
  /** scale the animated content to fit in the available space on the top header section */
37
48
  const scale = interpolate(currentPositionY.value, [0, SCROLL_BREAKPOINT], [1, scaleRatio], Extrapolate.CLAMP);
38
49
  /** translate verticaly to the middle of the top header section */
39
50
  const translateY = interpolate(currentPositionY.value, [0, SCROLL_BREAKPOINT], [0, -topSectionHeight + topSectionHeight / 2], Extrapolate.CLAMP);
40
51
  /** offset horizontaly given the scale transformation and potential top left header section */
41
- const translateX = interpolate(currentPositionY.value, [0, SCROLL_BREAKPOINT], [0, -(topSectionWidth - topMiddleWidth) / 2 + topLeftWidth], Extrapolate.CLAMP);
52
+ const translateX = interpolate(currentPositionY.value, [0, SCROLL_BREAKPOINT], [0, -(topSectionWidth - topSectionWidth * scaleRatio) / 2 + topLeftWidth], Extrapolate.CLAMP);
42
53
  /** allow for content to move upward as animation is taking place */
43
54
  const maxHeight = interpolate(currentPositionY.value, [0, SCROLL_BREAKPOINT], [70, 0], Extrapolate.CLAMP);
55
+ const opacity = interpolate(currentPositionY.value, [SCROLL_BREAKPOINT - 1, SCROLL_BREAKPOINT + 40], [1, 0], Extrapolate.CLAMP);
44
56
  return {
45
57
  maxHeight,
46
58
  transform: [{ translateY }, { translateX }, { scale }],
59
+ opacity,
47
60
  justifyContent: "center", // needed to ensure vertical centering of animated content
48
61
  };
49
- }, [
50
- topLeftWidth,
51
- topSectionHeight,
52
- middleWidth,
53
- topMiddleWidth,
54
- topSectionWidth,
55
- ]);
62
+ }, [topLeftWidth, topSectionHeight, middleWidth, topMiddleWidth, topSectionWidth]);
56
63
  return (React.createElement(Container, null,
57
64
  React.createElement(Flex, { flexDirection: "row", justifyContent: "space-between", alignItems: "center", onLayout: onLayout },
58
- React.createElement(View, { onLayout: onLayoutTopLeft }, TopLeftSection),
59
- React.createElement(Flex, { flex: 1, onLayout: onLayoutTopMiddle }),
65
+ React.createElement(Flex, { onLayout: onLayoutTopLeft }, TopLeftSection),
66
+ React.createElement(Animated.View, { style: [TopMiddleStyle], onLayout: topMiddleWidth ? () => { } : onLayoutTopMiddle }, TopMiddleSection || MiddleSection),
60
67
  TopRightSection),
61
68
  React.createElement(Animated.View, { onLayout: middleWidth ? () => { } : onLayoutMiddle, style: MiddleStyle }, MiddleSection),
62
69
  BottomSection ? React.createElement(Flex, null, BottomSection) : null));
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
- import type { ScrollViewProps } from "react-native";
2
+ import { FlatListProps } from "react-native";
3
3
  import type { HeaderProps } from "./Header";
4
- declare type ScrollContainerHeaderProps = Omit<HeaderProps, "currentPositionY"> & Omit<ScrollViewProps, "onScroll"> & {
4
+ import { BaseStyledProps } from "../../styled";
5
+ declare type ScrollContainerHeaderProps = BaseStyledProps & Omit<HeaderProps, "currentPositionY"> & Omit<FlatListProps<any>, "onScroll" | "data" | "renderItem" | "stickyHeaderIndices"> & {
5
6
  children?: React.ReactNode;
6
7
  onScroll?: (y: number) => void;
7
8
  };
@@ -10,8 +10,12 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import React from "react";
13
- import Animated, { useAnimatedScrollHandler, useSharedValue, } from "react-native-reanimated";
13
+ import { View } from "react-native";
14
+ import Animated, { useAnimatedScrollHandler, useSharedValue } from "react-native-reanimated";
14
15
  import Header from "./Header";
16
+ import baseStyled from "../../styled";
17
+ const StyledFlatList = baseStyled.FlatList ``;
18
+ const AnimatedFlatList = Animated.createAnimatedComponent(StyledFlatList);
15
19
  const ScrollContainerHeader = (_a) => {
16
20
  var { TopLeftSection, TopRightSection, TopMiddleSection, MiddleSection, BottomSection, children, onScroll } = _a, props = __rest(_a, ["TopLeftSection", "TopRightSection", "TopMiddleSection", "MiddleSection", "BottomSection", "children", "onScroll"]);
17
21
  const currentPositionY = useSharedValue(0);
@@ -20,8 +24,9 @@ const ScrollContainerHeader = (_a) => {
20
24
  if (onScroll)
21
25
  onScroll(event.contentOffset.y);
22
26
  });
23
- return (React.createElement(Animated.ScrollView, Object.assign({}, props, { onScroll: handleScroll, scrollEventThrottle: 16, stickyHeaderIndices: [0] }),
24
- React.createElement(Header, { TopLeftSection: TopLeftSection, TopRightSection: TopRightSection, TopMiddleSection: TopMiddleSection, MiddleSection: MiddleSection, BottomSection: BottomSection, currentPositionY: currentPositionY }),
25
- children));
27
+ return (React.createElement(AnimatedFlatList, Object.assign({}, props, { onScroll: handleScroll, scrollEventThrottle: 16, stickyHeaderIndices: [0], data: [
28
+ React.createElement(Header, { TopLeftSection: TopLeftSection, TopRightSection: TopRightSection, TopMiddleSection: TopMiddleSection, MiddleSection: MiddleSection, BottomSection: BottomSection, currentPositionY: currentPositionY }),
29
+ children,
30
+ ], renderItem: ({ item, index }) => (React.createElement(View, { key: index }, item)) })));
26
31
  };
27
32
  export default ScrollContainerHeader;
@@ -5,3 +5,4 @@ export * from "./Modals";
5
5
  export { default as ScrollContainer } from "./ScrollContainer";
6
6
  export { default as ScrollContainerHeader } from "./ScrollContainerHeader";
7
7
  export { default as Row } from "./Table/Row";
8
+ export * from "./List";
@@ -5,3 +5,4 @@ export * from "./Modals";
5
5
  export { default as ScrollContainer } from "./ScrollContainer";
6
6
  export { default as ScrollContainerHeader } from "./ScrollContainerHeader";
7
7
  export { default as Row } from "./Table/Row";
8
+ export * from "./List";
@@ -0,0 +1,9 @@
1
+ /// <reference types="styled-components-react-native" />
2
+ import React from "react";
3
+ import { SizeProps } from "styled-system";
4
+ declare const Loader: import("styled-components").StyledComponent<import("react").ComponentClass<import("react-native-svg").SvgProps, any>, import("styled-components").DefaultTheme, SizeProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Height<import("styled-system").TLengthStyledSystem>>, never>;
5
+ export declare type Props = React.ComponentProps<typeof Loader> & {
6
+ color?: string;
7
+ };
8
+ export default function InfiniteLoader({ size, color, ...extraProps }: Props): JSX.Element;
9
+ export {};
@@ -0,0 +1,58 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React, { useEffect } from "react";
13
+ import Svg, { LinearGradient, Stop, Mask, Path, Rect } from "react-native-svg";
14
+ import styled from "styled-components/native";
15
+ import { system, size } from "styled-system";
16
+ import Animated, { useAnimatedStyle, useSharedValue, withRepeat, withTiming, cancelAnimation, Easing, } from "react-native-reanimated";
17
+ const strokeSystem = system({
18
+ stroke: {
19
+ property: "stroke",
20
+ scale: "colors",
21
+ },
22
+ });
23
+ const Loader = styled(Svg).attrs((props) => (Object.assign({}, strokeSystem(props)))) `
24
+ ${size}
25
+ `;
26
+ export default function InfiniteLoader(_a) {
27
+ var { size = 38, color = "primary.c50" } = _a, extraProps = __rest(_a, ["size", "color"]);
28
+ const rotation = useSharedValue(0);
29
+ const animatedStyles = useAnimatedStyle(() => {
30
+ return {
31
+ transform: [
32
+ {
33
+ rotateZ: `${rotation.value}deg`,
34
+ },
35
+ ],
36
+ };
37
+ }, [rotation.value]);
38
+ useEffect(() => {
39
+ rotation.value = withRepeat(withTiming(360, {
40
+ duration: 1000,
41
+ easing: Easing.linear,
42
+ }), -1);
43
+ return () => cancelAnimation(rotation);
44
+ // eslint-disable-next-line react-hooks/exhaustive-deps
45
+ }, []);
46
+ return (React.createElement(Animated.View, { style: [{ display: "flex", justifyContent: "center", alignItems: "center" }, animatedStyles] },
47
+ React.createElement(Loader, Object.assign({ size: size, stroke: color, viewBox: "0 0 38 38", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, extraProps),
48
+ React.createElement(LinearGradient, { id: "gradient-start", gradientUnits: "userSpaceOnUse", gradientTransform: "rotate(-20)" },
49
+ React.createElement(Stop, { offset: 0, stopColor: "white", stopOpacity: 0.5 }),
50
+ React.createElement(Stop, { offset: 1, stopColor: "white", stopOpacity: 1 })),
51
+ React.createElement(LinearGradient, { id: "gradient-end", gradientUnits: "userSpaceOnUse", gradientTransform: "rotate(-20)" },
52
+ React.createElement(Stop, { offset: 0, stopColor: "white", stopOpacity: 0.5 }),
53
+ React.createElement(Stop, { offset: 1, stopColor: "white", stopOpacity: 0 })),
54
+ React.createElement(Mask, { id: "gradient-mask" },
55
+ React.createElement(Rect, { x: 0, y: -4, width: 44, height: 22, strokeWidth: 0, fill: "url(#gradient-start)", transform: "rotate(10)" }),
56
+ React.createElement(Rect, { x: 0, y: 18, width: 44, height: 21, strokeWidth: 0, fill: "url(#gradient-end)", transform: "rotate(10)" })),
57
+ React.createElement(Path, { d: "M34.8807 20.9499C35.3608 17.0398 34.3815 13.09 32.1304 9.85712C29.8793 6.6242 26.5146 4.33541 22.6808 3.42914C18.847 2.52287 14.8136 3.06283 11.3532 4.94559C7.89277 6.82836 5.24858 9.92158 3.92708 13.6328C2.60558 17.344 2.69968 21.4123 4.19135 25.0584C5.68302 28.7045 8.4674 31.6722 12.0112 33.3929C15.5549 35.1137 19.609 35.4666 23.3968 34.384C27.1846 33.3015 30.4398 30.8596 32.5391 27.526", strokeWidth: 6, strokeLinecap: "round", strokeLinejoin: "round", mask: "url(#gradient-mask)" }))));
58
+ }
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ declare type Props = {
3
+ progress?: number;
4
+ onPress?: () => void;
5
+ Icon?: React.ComponentType<{
6
+ color: string;
7
+ size: number;
8
+ }>;
9
+ };
10
+ declare const ProgressLoader: ({ progress, onPress, Icon }: Props) => React.ReactElement;
11
+ export default ProgressLoader;
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ import { Svg, Circle, G } from "react-native-svg";
3
+ import { useTheme } from "styled-components/native";
4
+ import { TouchableOpacity } from "react-native";
5
+ const radius = 25;
6
+ const strokeWidth = 2;
7
+ const normalizedRadius = radius - strokeWidth / 2;
8
+ const circumference = normalizedRadius * 2 * Math.PI;
9
+ const iconSize = radius * 0.88;
10
+ const iconOffset = radius - iconSize / 2;
11
+ const ProgressLoader = ({ progress = 0, onPress, Icon }) => {
12
+ const { colors } = useTheme();
13
+ const backgroundColor = colors.primary.c20;
14
+ const progressColor = colors.primary.c90;
15
+ const strokeDashoffset = circumference - progress * circumference;
16
+ return (React.createElement(TouchableOpacity, { disabled: !onPress, onPress: onPress },
17
+ React.createElement(Svg, { width: radius * 2, height: radius * 2 },
18
+ React.createElement(Circle, { cx: radius, cy: radius, r: radius * 0.92, fill: "transparent", stroke: backgroundColor, strokeDashoffset: 0, strokeWidth: strokeWidth }),
19
+ React.createElement(G, { transform: `rotate(-90) translate(-${radius * 2}, 0)` },
20
+ React.createElement(Circle, { cx: radius, cy: radius, r: radius * 0.92, fill: "transparent", stroke: progressColor, strokeWidth: strokeWidth, strokeDasharray: `${circumference} ${circumference}`, strokeDashoffset: strokeDashoffset })),
21
+ Icon ? (React.createElement(G, { transform: `translate(${iconOffset}, ${iconOffset})` },
22
+ React.createElement(Icon, { color: progressColor, size: iconSize }))) : null)));
23
+ };
24
+ export default ProgressLoader;
@@ -1,11 +1,2 @@
1
- import React from "react";
2
- declare type Props = {
3
- progress?: number;
4
- onPress?: () => void;
5
- Icon?: React.ComponentType<{
6
- color: string;
7
- size: number;
8
- }>;
9
- };
10
- declare const ProgressLoader: ({ progress, onPress, Icon, }: Props) => React.ReactElement;
11
- export default ProgressLoader;
1
+ export { default as Loader } from "./ProgressLoader";
2
+ export { default as InfiniteLoader } from "./InfiniteLoader";
@@ -1,24 +1,2 @@
1
- import React from "react";
2
- import { Svg, Circle, G } from "react-native-svg";
3
- import { useTheme } from "styled-components/native";
4
- import { TouchableOpacity } from "react-native";
5
- const radius = 25;
6
- const strokeWidth = 2;
7
- const normalizedRadius = radius - strokeWidth / 2;
8
- const circumference = normalizedRadius * 2 * Math.PI;
9
- const iconSize = radius * 0.88;
10
- const iconOffset = radius - iconSize / 2;
11
- const ProgressLoader = ({ progress = 0, onPress, Icon, }) => {
12
- const { colors } = useTheme();
13
- const backgroundColor = colors.primary.c20;
14
- const progressColor = colors.primary.c90;
15
- const strokeDashoffset = circumference - progress * circumference;
16
- return (React.createElement(TouchableOpacity, { disabled: !onPress, onPress: onPress },
17
- React.createElement(Svg, { width: radius * 2, height: radius * 2 },
18
- React.createElement(Circle, { cx: radius, cy: radius, r: radius * 0.92, fill: "transparent", stroke: backgroundColor, strokeDashoffset: 0, strokeWidth: strokeWidth }),
19
- React.createElement(G, { transform: `rotate(-90) translate(-${radius * 2}, 0)` },
20
- React.createElement(Circle, { cx: radius, cy: radius, r: radius * 0.92, fill: "transparent", stroke: progressColor, strokeWidth: strokeWidth, strokeDasharray: `${circumference} ${circumference}`, strokeDashoffset: strokeDashoffset })),
21
- Icon ? (React.createElement(G, { transform: `translate(${iconOffset}, ${iconOffset})` },
22
- React.createElement(Icon, { color: progressColor, size: iconSize }))) : null)));
23
- };
24
- export default ProgressLoader;
1
+ export { default as Loader } from "./ProgressLoader";
2
+ export { default as InfiniteLoader } from "./InfiniteLoader";
@@ -0,0 +1,70 @@
1
+ import React from "react";
2
+ import { FlexBoxProps } from "../../Layout/Flex";
3
+ import { TransitionProps } from "../../transitions";
4
+ interface InnerProps {
5
+ /**
6
+ * The active index.
7
+ */
8
+ activeIndex: number;
9
+ /**
10
+ * The total number of steps.
11
+ */
12
+ stepsLength: number;
13
+ }
14
+ export interface RenderTransitionProps extends InnerProps, TransitionProps {
15
+ /**
16
+ * The index of the child.
17
+ */
18
+ index: number;
19
+ /**
20
+ * The previously active index.
21
+ */
22
+ previousActiveIndex: number | null;
23
+ }
24
+ export interface Props<ExtraProps> {
25
+ /**
26
+ * The index of the active step.
27
+ */
28
+ activeIndex: number;
29
+ /**
30
+ * An optional header displayed above the progress bar.
31
+ */
32
+ header?: (props: InnerProps & ExtraProps) => React.ReactNode;
33
+ /**
34
+ * An optional footer displayed below the body.
35
+ */
36
+ footer?: (props: InnerProps & ExtraProps) => React.ReactNode;
37
+ /**
38
+ * Extra props that are passed to the header and footer render functions.
39
+ */
40
+ extraProps?: ExtraProps;
41
+ /**
42
+ * Additional props to pass to the progressbar component.
43
+ * This component is a Flex element.
44
+ */
45
+ progressBarProps?: FlexBoxProps;
46
+ /**
47
+ * **Use this prop in combination with `transitionDuration`.**
48
+ *
49
+ * A render function wrapping every children which allows using transitions.
50
+ * This function is called with various useful arguments, most notably:
51
+ * - the child index
52
+ * - the current active index
53
+ * - the previous active index
54
+ * - the transition status ("entered", "entering", "exiting" or "exited")
55
+ */
56
+ renderTransition?: (props: RenderTransitionProps) => JSX.Element | null;
57
+ /**
58
+ * **Use this prop in combination with `renderTransition`.**
59
+ *
60
+ * If this prop is true and if `renderTransition` is used
61
+ * then specifies the duration of the transition in milliseconds.
62
+ */
63
+ transitionDuration?: number;
64
+ /**
65
+ * A list of children representing each step of the flow.
66
+ */
67
+ children: React.ReactNode;
68
+ }
69
+ declare function FlowStepper<ExtraProps>({ activeIndex, header, footer, extraProps, progressBarProps, renderTransition, transitionDuration, children, }: Props<ExtraProps>): JSX.Element;
70
+ export default FlowStepper;
@@ -0,0 +1,36 @@
1
+ import React, { useRef, useEffect } from "react";
2
+ import { SafeAreaView } from "react-native";
3
+ import Flex from "../../Layout/Flex";
4
+ import ProgressBar from "../../ProgressBar";
5
+ import { Transition } from "../../transitions";
6
+ function FlowStepper({ activeIndex, header, footer, extraProps, progressBarProps, renderTransition, transitionDuration = 0, children, }) {
7
+ const previousActiveIndex = useRef(null);
8
+ const stepsLength = React.Children.count(children);
9
+ useEffect(() => () => {
10
+ previousActiveIndex.current = activeIndex;
11
+ }, [activeIndex]);
12
+ return (React.createElement(Flex, { flex: 1 },
13
+ header && header(Object.assign(Object.assign({}, extraProps), { activeIndex, stepsLength })),
14
+ React.createElement(SafeAreaView, { style: { flex: 1 } },
15
+ React.createElement(ProgressBar, Object.assign({ index: activeIndex, length: stepsLength }, progressBarProps)),
16
+ React.createElement(Flex, { flex: 1 }, React.Children.map(children, (child, index) => {
17
+ if (renderTransition && transitionDuration) {
18
+ return (React.createElement(Transition, { in: index === activeIndex, timeout: transitionDuration, mountOnEnter: true, unmountOnExit: true }, (status) => {
19
+ return renderTransition({
20
+ index,
21
+ activeIndex,
22
+ previousActiveIndex: previousActiveIndex.current,
23
+ stepsLength,
24
+ status,
25
+ duration: transitionDuration,
26
+ children: child,
27
+ });
28
+ }));
29
+ }
30
+ else {
31
+ return index === activeIndex ? child : null;
32
+ }
33
+ })),
34
+ footer && footer(Object.assign(Object.assign({}, extraProps), { activeIndex, stepsLength })))));
35
+ }
36
+ export default FlowStepper;
@@ -4,5 +4,5 @@ declare type Props = {
4
4
  activeIndex: number;
5
5
  onChange: (index: number) => void;
6
6
  };
7
- declare function SlideIndicator({ slidesLength, activeIndex, onChange, }: Props): React.ReactElement;
7
+ declare function SlideIndicator({ slidesLength, activeIndex, onChange }: Props): React.ReactElement;
8
8
  export default SlideIndicator;
@@ -30,11 +30,10 @@ const config = {
30
30
  duration: 200,
31
31
  easing: Easing.bezier(0.5, 0.01, 0, 1),
32
32
  };
33
- function SlideIndicator({ slidesLength, activeIndex = 0, onChange, }) {
33
+ function SlideIndicator({ slidesLength, activeIndex = 0, onChange }) {
34
34
  const slidesArray = useMemo(() => new Array(slidesLength).fill(0), [slidesLength]);
35
35
  const activeSize = useDerivedValue(() => {
36
- const size = (Math.max(0, Math.min(slidesLength - 1, activeIndex)) + 1) * (6 + 12) -
37
- 12;
36
+ const size = (Math.max(0, Math.min(slidesLength - 1, activeIndex)) + 1) * (6 + 12) - 12;
38
37
  return size;
39
38
  }, [activeIndex, slidesLength]);
40
39
  const animatedStyles = useAnimatedStyle(() => ({
@@ -13,5 +13,5 @@ export declare type StepperProps = {
13
13
  */
14
14
  errored?: boolean;
15
15
  };
16
- declare function Stepper({ steps, activeIndex, errored, }: StepperProps): React.ReactElement;
16
+ declare function Stepper({ steps, activeIndex, errored }: StepperProps): React.ReactElement;
17
17
  export default Stepper;
@@ -15,7 +15,7 @@ import { space, color } from "styled-system";
15
15
  import Text from "../../Text";
16
16
  import CheckAlone from "@ledgerhq/icons-ui/native/CheckAloneMedium";
17
17
  import CloseMedium from "@ledgerhq/icons-ui/native/CloseMedium";
18
- import Animated, { useAnimatedStyle, withTiming, withDelay, Easing, } from "react-native-reanimated";
18
+ import Animated, { useAnimatedStyle, withTiming, withDelay, Easing } from "react-native-reanimated";
19
19
  const Separator = styled.View `
20
20
  flex: 1;
21
21
  height: 1px;
@@ -75,8 +75,8 @@ const StepIcon = {
75
75
  border-radius: ${(p) => p.theme.space[1]}px;
76
76
  background-color: ${(p) => p.theme.colors.neutral.c70};
77
77
  `,
78
- Completed: ({ color }) => (React.createElement(CheckAlone, { size: 16, color: color })),
79
- Errored: ({ color }) => (React.createElement(CloseMedium, { size: 16, color: color })),
78
+ Completed: ({ color }) => React.createElement(CheckAlone, { size: 16, color: color }),
79
+ Errored: ({ color }) => React.createElement(CloseMedium, { size: 16, color: color }),
80
80
  };
81
81
  // #endregion
82
82
  // #region Step
@@ -133,7 +133,7 @@ const Container = styled.View `
133
133
  flex-direction: row;
134
134
  width: 100%;
135
135
  `;
136
- function Stepper({ steps, activeIndex, errored, }) {
136
+ function Stepper({ steps, activeIndex, errored }) {
137
137
  const { space } = useTheme();
138
138
  const separatorMarginTop = useMemo(() => Math.floor(space[5] / 2), [space]);
139
139
  return (React.createElement(Container, null, steps.map((label, i) => (React.createElement(React.Fragment, { key: i },
@@ -1,2 +1,3 @@
1
1
  export { default as SlideIndicator } from "./SlideIndicator";
2
2
  export { default as Stepper } from "./Stepper";
3
+ export { default as FlowStepper } from "./FlowStepper";
@@ -1,2 +1,3 @@
1
1
  export { default as SlideIndicator } from "./SlideIndicator";
2
2
  export { default as Stepper } from "./Stepper";
3
+ export { default as FlowStepper } from "./FlowStepper";
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import { FlexBoxProps } from "../Layout/Flex";
3
+ export interface Props extends FlexBoxProps {
4
+ /**
5
+ * The index of the active step.
6
+ */
7
+ index: number;
8
+ /**
9
+ * The total number of steps.
10
+ */
11
+ length: number;
12
+ }
13
+ declare function ProgressBar({ index, length, ...props }: Props): JSX.Element;
14
+ declare const _default: React.MemoExoticComponent<typeof ProgressBar>;
15
+ export default _default;
@@ -0,0 +1,33 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React from "react";
13
+ import styled from "styled-components/native";
14
+ import Flex from "../Layout/Flex";
15
+ import Animated, { useDerivedValue, useAnimatedStyle, withTiming } from "react-native-reanimated";
16
+ const ActiveBar = styled.View `
17
+ background-color: ${(p) => p.theme.colors.neutral.c100};
18
+ position: absolute;
19
+ height: 100%;
20
+ top: 0;
21
+ left: 0;
22
+ `;
23
+ const AnimatedBar = Animated.createAnimatedComponent(ActiveBar);
24
+ function ProgressBar(_a) {
25
+ var { index, length } = _a, props = __rest(_a, ["index", "length"]);
26
+ const width = useDerivedValue(() => Math.round((index / (length - 1)) * 100), [index, length]);
27
+ const animatedStyles = useAnimatedStyle(() => ({
28
+ width: withTiming(`${width.value}%`),
29
+ }));
30
+ return (React.createElement(Flex, Object.assign({ height: 4, width: "100%", backgroundColor: "neutral.c20", position: "relative" }, props),
31
+ React.createElement(AnimatedBar, { style: [animatedStyles] })));
32
+ }
33
+ export default React.memo(ProgressBar);
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import { BaseTabsProps, TabItemProps } from "../TemplateTabs";
3
+ export declare const ChipTab: ({ onPress, isActive, label }: TabItemProps) => React.ReactElement;
4
+ declare const ChipTabs: (props: BaseTabsProps) => React.ReactElement;
5
+ export default ChipTabs;
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import styled from "styled-components/native";
3
+ import Text from "../../Text";
4
+ import { TouchableOpacity } from "react-native";
5
+ import TemplateTabs from "../TemplateTabs";
6
+ const TabBox = styled(TouchableOpacity) `
7
+ text-align: center;
8
+ margin: auto;
9
+ flex: 1;
10
+ padding: ${(p) => p.theme.space[5]}px 0;
11
+ border-radius: 8px;
12
+ background-color: ${(p) => (p.isActive ? p.theme.colors.palette.primary.c20 : "transparent")};
13
+ `;
14
+ const StyledTabs = styled(TemplateTabs) ``;
15
+ export const ChipTab = ({ onPress, isActive, label }) => {
16
+ return (React.createElement(TabBox, { isActive: isActive, onPress: onPress },
17
+ React.createElement(Text, { variant: "small", fontWeight: "semiBold", color: isActive ? "palette.neutral.c100" : "palette.neutral.c80", textAlign: "center" }, label)));
18
+ };
19
+ const ChipTabs = (props) => (React.createElement(StyledTabs, Object.assign({}, props, { Item: ChipTab })));
20
+ export default ChipTabs;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import { BaseTabsProps, TabItemProps } from "../TemplateTabs";
3
+ export declare const GraphTab: ({ onPress, isActive, label }: TabItemProps) => React.ReactElement;
4
+ declare const GraphTabs: (props: BaseTabsProps) => React.ReactElement;
5
+ export default GraphTabs;
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import styled from "styled-components/native";
3
+ import Text from "../../Text";
4
+ import { TouchableOpacity } from "react-native";
5
+ import Button from "../../cta/Button";
6
+ import TemplateTabs from "../TemplateTabs";
7
+ const TabBbx = styled(TouchableOpacity) `
8
+ text-align: center;
9
+ margin: auto;
10
+ flex: 1;
11
+ `;
12
+ const StyledTabs = styled(TemplateTabs) `
13
+ border: ${(p) => `1px solid ${p.theme.colors.palette.neutral.c40}`};
14
+ border-radius: 35px;
15
+ padding: 4px;
16
+ `;
17
+ export const GraphTab = ({ onPress, isActive, label }) => {
18
+ return (React.createElement(TabBbx, { onPress: onPress }, isActive ? (React.createElement(Button, { type: "main" }, label)) : (React.createElement(Text, { lineHeight: 36, textAlign: "center" }, label))));
19
+ };
20
+ const GraphTabs = (props) => (React.createElement(StyledTabs, Object.assign({}, props, { Item: GraphTab })));
21
+ export default GraphTabs;