@ledgerhq/native-ui 0.4.0 → 0.6.2

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 (124) hide show
  1. package/README.md +1 -4
  2. package/assets/logos/LedgerLiveAltRegular.d.ts +0 -1
  3. package/assets/logos/LedgerLiveRegular.d.ts +0 -1
  4. package/components/Carousel/index.d.ts +45 -0
  5. package/components/Carousel/index.js +74 -0
  6. package/components/Form/Checkbox/index.d.ts +3 -3
  7. package/components/Form/Checkbox/index.js +1 -1
  8. package/components/Form/Input/BaseInput/index.d.ts +83 -5
  9. package/components/Form/Input/BaseInput/index.js +6 -6
  10. package/components/Form/Input/LegendInput/index.d.ts +14 -3
  11. package/components/Form/Input/LegendInput/index.js +3 -2
  12. package/components/Form/Input/NumberInput/index.d.ts +16 -5
  13. package/components/Form/Input/NumberInput/index.js +5 -4
  14. package/components/Form/Input/QrCodeInput/index.d.ts +15 -4
  15. package/components/Form/Input/QrCodeInput/index.js +3 -2
  16. package/components/Form/Input/SearchInput/index.d.ts +13 -2
  17. package/components/Form/Input/SearchInput/index.js +3 -2
  18. package/components/Form/SelectableList.d.ts +12 -3
  19. package/components/Form/SelectableList.js +9 -8
  20. package/components/Form/Slider/index.d.ts +0 -1
  21. package/components/Form/Slider/index.native.d.ts +0 -1
  22. package/components/Form/Slider/index.native.js +1 -1
  23. package/components/Form/Switch/index.d.ts +1 -2
  24. package/components/Form/Switch/index.js +2 -2
  25. package/components/Form/Toggle/index.d.ts +1 -2
  26. package/components/Form/Toggle/index.js +1 -1
  27. package/components/Form/index.d.ts +1 -0
  28. package/components/Form/index.js +1 -0
  29. package/components/Icon/BoxedIcon.d.ts +49 -0
  30. package/components/Icon/BoxedIcon.js +85 -0
  31. package/components/Icon/Icon.d.ts +9 -0
  32. package/components/Icon/Icon.js +20 -0
  33. package/components/Icon/IconBox/index.d.ts +2 -4
  34. package/components/Icon/IconBox/index.js +1 -2
  35. package/components/Icon/index.d.ts +2 -0
  36. package/components/Icon/index.js +2 -0
  37. package/components/Icon/type.d.ts +7 -0
  38. package/components/Icon/type.js +1 -0
  39. package/components/Layout/Box/index.d.ts +11 -0
  40. package/components/Layout/Box/index.js +3 -0
  41. package/components/Layout/Collapse/Accordion/index.js +1 -1
  42. package/components/Layout/Flex/index.d.ts +11 -12
  43. package/components/Layout/Flex/index.js +2 -8
  44. package/components/Layout/List/IconBoxList/index.d.ts +10 -0
  45. package/components/Layout/List/IconBoxList/index.js +19 -0
  46. package/components/Layout/List/List/index.d.ts +13 -0
  47. package/components/Layout/List/List/index.js +29 -0
  48. package/components/Layout/List/NumberedList/index.d.ts +9 -0
  49. package/components/Layout/List/NumberedList/index.js +20 -0
  50. package/components/Layout/List/TipList/index.d.ts +9 -0
  51. package/components/Layout/List/TipList/index.js +20 -0
  52. package/components/Layout/List/index.d.ts +4 -0
  53. package/components/Layout/List/index.js +4 -0
  54. package/components/Layout/ScrollContainer/index.d.ts +2 -1
  55. package/components/Layout/ScrollContainer/index.js +2 -2
  56. package/components/Layout/ScrollContainerHeader/Header.d.ts +1 -2
  57. package/components/Layout/ScrollContainerHeader/Header.js +23 -16
  58. package/components/Layout/ScrollContainerHeader/index.d.ts +3 -2
  59. package/components/Layout/ScrollContainerHeader/index.js +9 -4
  60. package/components/Layout/index.d.ts +2 -0
  61. package/components/Layout/index.js +2 -0
  62. package/components/Loader/InfiniteLoader/index.d.ts +9 -0
  63. package/components/Loader/InfiniteLoader/index.js +58 -0
  64. package/components/Loader/ProgressLoader/index.d.ts +11 -0
  65. package/components/Loader/ProgressLoader/index.js +24 -0
  66. package/components/Loader/index.d.ts +2 -11
  67. package/components/Loader/index.js +2 -24
  68. package/components/Navigation/FlowStepper/index.d.ts +70 -0
  69. package/components/Navigation/FlowStepper/index.js +36 -0
  70. package/components/Navigation/SlideIndicator/index.d.ts +1 -1
  71. package/components/Navigation/SlideIndicator/index.js +13 -7
  72. package/components/Navigation/Stepper/index.d.ts +1 -1
  73. package/components/Navigation/Stepper/index.js +4 -4
  74. package/components/Navigation/index.d.ts +1 -0
  75. package/components/Navigation/index.js +1 -0
  76. package/components/ProgressBar/index.d.ts +15 -0
  77. package/components/ProgressBar/index.js +33 -0
  78. package/components/Tabs/Chip/index.d.ts +5 -0
  79. package/components/Tabs/Chip/index.js +20 -0
  80. package/components/Tabs/Graph/index.d.ts +5 -0
  81. package/components/Tabs/Graph/index.js +21 -0
  82. package/components/Tabs/TemplateTabs/index.d.ts +29 -0
  83. package/components/Tabs/TemplateTabs/index.js +14 -0
  84. package/components/Tabs/index.d.ts +2 -0
  85. package/components/Tabs/index.js +2 -0
  86. package/components/Text/getTextStyle.d.ts +1 -0
  87. package/components/Text/getTextStyle.js +5 -0
  88. package/components/Text/index.d.ts +6 -8
  89. package/components/Text/index.js +15 -8
  90. package/components/chart/index.d.ts +0 -1
  91. package/components/cta/Button/index.d.ts +5 -15
  92. package/components/cta/Button/index.js +21 -24
  93. package/components/cta/Link/index.js +1 -5
  94. package/components/index.d.ts +5 -2
  95. package/components/index.js +6 -2
  96. package/components/message/Alert/index.d.ts +1 -2
  97. package/components/message/Alert/index.js +2 -2
  98. package/components/{drawer → message}/Notification/index.d.ts +5 -4
  99. package/components/{drawer → message}/Notification/index.js +16 -12
  100. package/components/message/index.d.ts +1 -0
  101. package/components/message/index.js +1 -0
  102. package/components/styled.d.ts +15 -0
  103. package/components/styled.js +12 -0
  104. package/components/transitions/Fade.d.ts +5 -0
  105. package/components/transitions/Fade.js +32 -0
  106. package/components/transitions/Slide.d.ts +11 -0
  107. package/components/transitions/Slide.js +49 -0
  108. package/components/transitions/Transition.d.ts +49 -0
  109. package/components/transitions/Transition.js +39 -0
  110. package/components/transitions/index.d.ts +4 -0
  111. package/components/transitions/index.js +4 -0
  112. package/components/transitions/types.d.ts +21 -0
  113. package/components/transitions/types.js +1 -0
  114. package/package.json +4 -4
  115. package/styles/StyleProvider.d.ts +1 -1
  116. package/styles/StyleProvider.js +1 -1
  117. package/styles/helpers.js +1 -3
  118. package/styles/theme.js +2 -0
  119. package/assets/fonts/.DS_Store +0 -0
  120. package/assets/fonts/alpha/.DS_Store +0 -0
  121. package/components/Navigation/ToggleGroup/index.d.ts +0 -15
  122. package/components/Navigation/ToggleGroup/index.js +0 -25
  123. package/components/drawer/index.d.ts +0 -1
  124. package/components/drawer/index.js +0 -1
package/README.md CHANGED
@@ -211,10 +211,7 @@ export default function App() {
211
211
  <Text variant="h2" color="neutral.c100" my={10}>
212
212
  Hello, world!
213
213
  </Text>
214
- <Switch
215
- checked={isLight}
216
- onChange={() => setPalette(() => (isLight ? "dark" : "light"))}
217
- />
214
+ <Switch checked={isLight} onChange={() => setPalette(() => (isLight ? "dark" : "light"))} />
218
215
  </Flex>
219
216
  </StyleProvider>
220
217
  );
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare type Props = {
3
2
  width?: number | string;
4
3
  height?: number | string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare type Props = {
3
2
  width?: number | string;
4
3
  height?: number | string;
@@ -0,0 +1,45 @@
1
+ /// <reference types="styled-components-react-native" />
2
+ import React from "react";
3
+ import { ScrollView, ViewProps } from "react-native";
4
+ import type { Props as FlexboxProps } from "../Layout/Flex";
5
+ declare const HorizontalScrollView: import("styled-components").StyledComponent<typeof ScrollView, import("styled-components").DefaultTheme, {
6
+ horizontal: true;
7
+ }, "horizontal">;
8
+ export declare type Props = React.PropsWithChildren<{
9
+ /**
10
+ * Forces the selection of a specific item of the carousel.
11
+ */
12
+ activeIndex?: number;
13
+ /**
14
+ * Called when the active carousel index is updated.
15
+ */
16
+ onChange?: (index: number) => void;
17
+ /**
18
+ * This number in milliseconds will enable automatic scrolling when defined.
19
+ *
20
+ * The Carousel will scroll to the next item after this delay is elapsed,
21
+ * unless the user is currently dragging the content.
22
+ *
23
+ * This delay will also reset whenever the user taps on an indicator bullet to
24
+ * manually change the carousel item displayed.
25
+ */
26
+ autoDelay?: number;
27
+ /**
28
+ * Additional props to pass to the outer container.
29
+ * This container is a Flex element.
30
+ */
31
+ containerProps?: FlexboxProps;
32
+ /**
33
+ * Additional props to pass to the ScrollView element.
34
+ * See: https://reactnative.dev/docs/scrollview
35
+ */
36
+ scrollViewProps?: React.ComponentProps<typeof HorizontalScrollView>;
37
+ /**
38
+ * Additional props to pass to the indicators container.
39
+ * This container is a Flex element.
40
+ */
41
+ slideIndicatorContainerProps?: FlexboxProps & ViewProps;
42
+ }>;
43
+ declare function Carousel({ activeIndex, autoDelay, containerProps, slideIndicatorContainerProps, scrollViewProps, onChange, children, }: Props): JSX.Element;
44
+ declare const _default: React.MemoExoticComponent<typeof Carousel>;
45
+ export default _default;
@@ -0,0 +1,74 @@
1
+ import React, { useEffect, useState, useRef, useCallback } from "react";
2
+ import { Platform } from "react-native";
3
+ import styled from "styled-components/native";
4
+ import { Flex, SlideIndicator } from "../index";
5
+ const HorizontalScrollView = styled.ScrollView.attrs({ horizontal: true }) `
6
+ flex: 1;
7
+ `;
8
+ function Carousel({ activeIndex, autoDelay, containerProps, slideIndicatorContainerProps, scrollViewProps, onChange, children, }) {
9
+ const [init, setInit] = useState(false);
10
+ const [activeIndexState, setActiveIndexState] = useState(activeIndex);
11
+ const disableTimer = useRef(false);
12
+ const [resetTimer, setResetTimer] = useState({});
13
+ const dimensions = useRef(null);
14
+ const slidesLength = React.Children.count(children);
15
+ const scrollRef = useRef(null);
16
+ const fullWidth = 100 * slidesLength;
17
+ const itemWidth = !dimensions.current ? 0 : dimensions.current.contentWidth / slidesLength;
18
+ const scrollToIndex = useCallback((index, animated = true) => {
19
+ if (scrollRef.current && dimensions.current) {
20
+ scrollRef.current.scrollTo({
21
+ x: itemWidth * index,
22
+ animated,
23
+ });
24
+ }
25
+ }, [itemWidth]);
26
+ useEffect(() => {
27
+ // On init scroll to the active index prop location - if specified.
28
+ if (init && activeIndex)
29
+ scrollToIndex(activeIndex, false);
30
+ // eslint-disable-next-line react-hooks/exhaustive-deps
31
+ }, [init]);
32
+ useEffect(() => {
33
+ if (scrollToIndex && typeof activeIndex === "number") {
34
+ scrollToIndex(activeIndex);
35
+ }
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ }, [activeIndex]);
38
+ const onContentSizeChange = (contentWidth, contentHeight) => {
39
+ dimensions.current = { contentWidth, contentHeight };
40
+ setInit(true);
41
+ };
42
+ const onScroll = ({ nativeEvent: { contentOffset, contentSize }, }) => {
43
+ const newIndex = Math.abs(Math.round((contentOffset.x / contentSize.width) * slidesLength));
44
+ setActiveIndexState(newIndex);
45
+ onChange && onChange(newIndex);
46
+ };
47
+ useEffect(() => {
48
+ if (!autoDelay)
49
+ return;
50
+ const interval = setInterval(() => {
51
+ if (!disableTimer.current) {
52
+ setActiveIndexState((index) => {
53
+ const newIndex = typeof index !== "undefined" ? (index + 1) % slidesLength : 0;
54
+ scrollToIndex(newIndex);
55
+ onChange && onChange(newIndex);
56
+ return newIndex;
57
+ });
58
+ }
59
+ }, autoDelay);
60
+ return () => clearInterval(interval);
61
+ }, [resetTimer, slidesLength, scrollToIndex, onChange, autoDelay]);
62
+ return (React.createElement(Flex, Object.assign({ flex: 1, width: "100%", alignItems: "center", justifyContent: "center" }, containerProps),
63
+ React.createElement(HorizontalScrollView, Object.assign({ ref: scrollRef, onScroll: onScroll, onContentSizeChange: onContentSizeChange, onScrollBeginDrag: () => {
64
+ disableTimer.current = true;
65
+ }, onScrollEndDrag: () => {
66
+ disableTimer.current = false;
67
+ }, pagingEnabled: Platform.OS !== "web", showsHorizontalScrollIndicator: false, scrollEventThrottle: 200, contentContainerStyle: { width: `${fullWidth}%` }, decelerationRate: "fast" }, scrollViewProps), React.Children.map(children, (child, index) => (React.createElement(Flex, { key: index, flex: 1 }, child)))),
68
+ React.createElement(Flex, Object.assign({ my: 8 }, slideIndicatorContainerProps),
69
+ React.createElement(SlideIndicator, { activeIndex: activeIndexState || 0, onChange: (index) => {
70
+ scrollToIndex(index);
71
+ setResetTimer({});
72
+ }, slidesLength: slidesLength }))));
73
+ }
74
+ export default React.memo(Carousel);
@@ -1,9 +1,9 @@
1
- /// <reference types="react" />
1
+ import type { BaseTextProps } from "../../Text";
2
2
  declare type CheckboxProps = {
3
3
  checked: boolean;
4
4
  onChange?: () => void;
5
5
  disabled?: boolean;
6
- label?: string;
6
+ label?: BaseTextProps["children"];
7
7
  };
8
- declare const Checkbox: ({ checked, onChange, disabled, label, }: CheckboxProps) => JSX.Element;
8
+ declare const Checkbox: ({ checked, onChange, disabled, label }: CheckboxProps) => JSX.Element;
9
9
  export default Checkbox;
@@ -16,7 +16,7 @@ const Square = styled(Flex).attrs({
16
16
  ? `background-color: ${theme.colors.primary.c90};`
17
17
  : `border: 1px solid ${theme.colors.neutral.c50};`}
18
18
  `;
19
- const Checkbox = ({ checked, onChange, disabled, label, }) => {
19
+ const Checkbox = ({ checked, onChange, disabled, label }) => {
20
20
  const { colors, space } = useTheme();
21
21
  return (React.createElement(Pressable, { onPress: onChange, disabled: disabled },
22
22
  React.createElement(Flex, { flexDirection: "row", alignItems: "center" },
@@ -1,15 +1,30 @@
1
1
  /// <reference types="styled-components-react-native" />
2
2
  import React from "react";
3
- import { View, TextInputProps } from "react-native";
3
+ import { TextInput, TextInputProps, StyleProp, ViewStyle } from "react-native";
4
4
  export declare type CommonProps = TextInputProps & {
5
5
  disabled?: boolean;
6
6
  error?: string;
7
7
  };
8
8
  export declare type InputProps<T = string> = Omit<CommonProps, "value" | "onChange"> & {
9
+ /**
10
+ * The value of the input.
11
+ */
12
+ value: T;
13
+ /**
14
+ * A function that will render some content on the left side of the input.
15
+ */
9
16
  renderLeft?: ((props: InputProps<T>) => React.ReactNode) | React.ReactNode;
17
+ /**
18
+ * A function that will render some content on the right side of the input.
19
+ */
10
20
  renderRight?: ((props: InputProps<T>) => React.ReactNode) | React.ReactNode;
11
- value: T;
21
+ /**
22
+ * Triggered when the input value is updated.
23
+ */
12
24
  onChange?: (value: T) => void;
25
+ /**
26
+ * Same as onChange but preserves the native event passed as the callback argument.
27
+ */
13
28
  onChangeEvent?: TextInputProps["onChange"];
14
29
  /**
15
30
  * A function can be provided to serialize a value of any type to a string.
@@ -27,15 +42,78 @@ export declare type InputProps<T = string> = Omit<CommonProps, "value" | "onChan
27
42
  * *A deserializer function should always be used in conjunction with a serializer function.*
28
43
  */
29
44
  deserialize?: (value: string) => T;
45
+ /**
46
+ * Additional style for the container element.
47
+ */
48
+ containerStyle?: StyleProp<ViewStyle>;
30
49
  };
31
- export declare const InputRenderLeftContainer: import("styled-components").StyledComponent<typeof View, import("styled-components").DefaultTheme, import("../../../Layout/Flex").Props & {
50
+ export declare const InputRenderLeftContainer: import("styled-components").StyledComponent<typeof import("react-native").View, import("styled-components").DefaultTheme, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & {
51
+ columnGap?: string | number | undefined;
52
+ rowGap?: string | number | undefined;
53
+ color?: string | undefined;
54
+ display?: string | undefined;
55
+ position?: string | undefined;
56
+ maxHeight?: number | undefined;
57
+ } & {
32
58
  alignItems: string;
33
59
  flexDirection: string;
34
60
  pl: string;
35
61
  }, "pl" | "alignItems" | "flexDirection">;
36
- export declare const InputRenderRightContainer: import("styled-components").StyledComponent<typeof View, import("styled-components").DefaultTheme, import("../../../Layout/Flex").Props & {
62
+ export declare const InputRenderRightContainer: import("styled-components").StyledComponent<typeof import("react-native").View, import("styled-components").DefaultTheme, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & {
63
+ columnGap?: string | number | undefined;
64
+ rowGap?: string | number | undefined;
65
+ color?: string | undefined;
66
+ display?: string | undefined;
67
+ position?: string | undefined;
68
+ maxHeight?: number | undefined;
69
+ } & {
37
70
  alignItems: string;
38
71
  flexDirection: string;
39
72
  pr: string;
40
73
  }, "pr" | "alignItems" | "flexDirection">;
41
- export default function Input<T = string>(props: InputProps<T>): JSX.Element;
74
+ declare function Input<T = string>(props: InputProps<T>, ref?: React.ForwardedRef<TextInput>): JSX.Element;
75
+ declare const _default: <T>(props: Omit<CommonProps, "onChange" | "value"> & {
76
+ /**
77
+ * The value of the input.
78
+ */
79
+ value: T;
80
+ /**
81
+ * A function that will render some content on the left side of the input.
82
+ */
83
+ renderLeft?: React.ReactNode | ((props: InputProps<T>) => React.ReactNode);
84
+ /**
85
+ * A function that will render some content on the right side of the input.
86
+ */
87
+ renderRight?: React.ReactNode | ((props: InputProps<T>) => React.ReactNode);
88
+ /**
89
+ * Triggered when the input value is updated.
90
+ */
91
+ onChange?: ((value: T) => void) | undefined;
92
+ /**
93
+ * Same as onChange but preserves the native event passed as the callback argument.
94
+ */
95
+ onChangeEvent?: ((e: import("react-native").NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
96
+ /**
97
+ * A function can be provided to serialize a value of any type to a string.
98
+ *
99
+ * This can be useful to wrap the `<BaseInput />` component (which expects a string)
100
+ * and create higher-level components that will automatically perform the input/output
101
+ * conversion to other types.
102
+ *
103
+ * *A serializer function should always be used in conjunction with a deserializer function.*
104
+ */
105
+ serialize?: ((value: T) => string) | undefined;
106
+ /**
107
+ * A deserializer can be provided to convert the html input value from a string to any other type.
108
+ *
109
+ * *A deserializer function should always be used in conjunction with a serializer function.*
110
+ */
111
+ deserialize?: ((value: string) => T) | undefined;
112
+ /**
113
+ * Additional style for the container element.
114
+ */
115
+ containerStyle?: StyleProp<ViewStyle>;
116
+ } & {
117
+ ref?: React.ForwardedRef<TextInput> | undefined;
118
+ }) => ReturnType<typeof Input>;
119
+ export default _default;
@@ -10,7 +10,6 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import React, { useMemo, useCallback } from "react";
13
- import { View } from "react-native";
14
13
  import styled, { css } from "styled-components/native";
15
14
  import Text from "../../../Text";
16
15
  import FlexBox from "../../../Layout/Flex";
@@ -77,18 +76,19 @@ export const InputRenderRightContainer = styled(FlexBox).attrs(() => ({
77
76
  // Yes, this is dirty. If you can figure out a better way please change the code :).
78
77
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
78
  const IDENTITY = (_) => _;
80
- export default function Input(props) {
81
- const { value, onChange, onChangeText, onChangeEvent, disabled, error, renderLeft, renderRight, serialize = IDENTITY, deserialize = IDENTITY } = props, textInputProps = __rest(props, ["value", "onChange", "onChangeText", "onChangeEvent", "disabled", "error", "renderLeft", "renderRight", "serialize", "deserialize"]);
79
+ function Input(props, ref) {
80
+ const { value, onChange, onChangeText, onChangeEvent, disabled, error, renderLeft, renderRight, serialize = IDENTITY, deserialize = IDENTITY, containerStyle } = props, textInputProps = __rest(props, ["value", "onChange", "onChangeText", "onChangeEvent", "disabled", "error", "renderLeft", "renderRight", "serialize", "deserialize", "containerStyle"]);
82
81
  const inputValue = useMemo(() => serialize(value), [serialize, value]);
83
82
  const handleChange = useCallback((value) => {
84
83
  onChange && onChange(deserialize(value));
85
84
  onChangeText && onChangeText(value);
86
85
  }, [onChange, onChangeText, deserialize]);
87
86
  const [focus, setFocus] = React.useState(false);
88
- return (React.createElement(View, { style: { display: "flex", width: "100%" } },
87
+ return (React.createElement(FlexBox, { width: "100%", style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
89
88
  React.createElement(InputContainer, { disabled: disabled, focus: focus, error: error },
90
89
  typeof renderLeft === "function" ? renderLeft(props) : renderLeft,
91
- React.createElement(BaseInput, Object.assign({}, textInputProps, { value: inputValue, onChange: onChangeEvent, onChangeText: handleChange, editable: !disabled, disabled: disabled, error: error, onFocus: () => setFocus(true), onBlur: () => setFocus(false) })),
90
+ React.createElement(BaseInput, Object.assign({ ref: ref }, textInputProps, { value: inputValue, onChange: onChangeEvent, onChangeText: handleChange, editable: !disabled, disabled: disabled, error: error, onFocus: () => setFocus(true), onBlur: () => setFocus(false) })),
92
91
  typeof renderRight === "function" ? renderRight(props) : renderRight),
93
- !!error && !disabled && (React.createElement(InputErrorContainer, null, error))));
92
+ !!error && !disabled && React.createElement(InputErrorContainer, null, error)));
94
93
  }
94
+ export default React.forwardRef(Input);
@@ -1,5 +1,16 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
+ import { TextInput } from "react-native";
2
3
  import { InputProps } from "../BaseInput";
3
- export default function LegendInput({ legend, ...inputProps }: InputProps & {
4
+ declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInput").CommonProps, "onChange" | "value"> & {
5
+ value: string;
6
+ renderLeft?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
7
+ renderRight?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
8
+ onChange?: ((value: string) => void) | undefined;
9
+ onChangeEvent?: ((e: import("react-native").NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
10
+ serialize?: ((value: string) => string) | undefined;
11
+ deserialize?: ((value: string) => string) | undefined;
12
+ containerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
13
+ } & {
4
14
  legend: string;
5
- }): JSX.Element;
15
+ } & React.RefAttributes<TextInput>>;
16
+ export default _default;
@@ -12,8 +12,9 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import React from "react";
13
13
  import Input, { InputRenderRightContainer } from "../BaseInput";
14
14
  import Text from "../../../Text";
15
- export default function LegendInput(_a) {
15
+ function LegendInput(_a, ref) {
16
16
  var { legend } = _a, inputProps = __rest(_a, ["legend"]);
17
- return (React.createElement(Input, Object.assign({}, inputProps, { renderRight: React.createElement(InputRenderRightContainer, null,
17
+ return (React.createElement(Input, Object.assign({ ref: ref }, inputProps, { renderRight: React.createElement(InputRenderRightContainer, null,
18
18
  React.createElement(Text, { color: "neutral.c70", variant: "body" }, legend)) })));
19
19
  }
20
+ export default React.forwardRef(LegendInput);
@@ -1,7 +1,18 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
+ import { TextInput } from "react-native";
2
3
  import { InputProps } from "../BaseInput";
3
- export default function NumberInput({ onPercentClick, max, value, disabled, ...inputProps }: InputProps<number | undefined> & {
4
+ declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInput").CommonProps, "onChange" | "value"> & {
5
+ value: number | undefined;
6
+ renderLeft?: React.ReactNode | ((props: InputProps<number | undefined>) => React.ReactNode);
7
+ renderRight?: React.ReactNode | ((props: InputProps<number | undefined>) => React.ReactNode);
8
+ onChange?: ((value: number | undefined) => void) | undefined;
9
+ onChangeEvent?: ((e: import("react-native").NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
10
+ serialize?: ((value: number | undefined) => string) | undefined;
11
+ deserialize?: ((value: string) => number | undefined) | undefined;
12
+ containerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
13
+ } & {
4
14
  onPercentClick: (percent: number) => void;
5
- min?: number;
6
- max?: number;
7
- }): JSX.Element;
15
+ min?: number | undefined;
16
+ max?: number | undefined;
17
+ } & React.RefAttributes<TextInput>>;
18
+ export default _default;
@@ -16,8 +16,8 @@ import Input from "../BaseInput";
16
16
  import FlexBox from "../../../Layout/Flex";
17
17
  import Text from "../../../Text";
18
18
  const PercentButton = styled(TouchableOpacity) `
19
- color: ${(p) => p.active ? p.theme.colors.neutral.c00 : p.theme.colors.neutral.c70};
20
- background-color: ${(p) => p.active ? p.theme.colors.neutral.c100 : p.theme.colors.neutral.c00};
19
+ color: ${(p) => (p.active ? p.theme.colors.neutral.c00 : p.theme.colors.neutral.c70)};
20
+ background-color: ${(p) => (p.active ? p.theme.colors.neutral.c100 : p.theme.colors.neutral.c00)};
21
21
  border-radius: 100px;
22
22
  border-width: 0;
23
23
  height: 31px;
@@ -38,9 +38,9 @@ function deserialize(value) {
38
38
  return undefined;
39
39
  }
40
40
  }
41
- export default function NumberInput(_a) {
41
+ function NumberInput(_a, ref) {
42
42
  var { onPercentClick, max, value, disabled } = _a, inputProps = __rest(_a, ["onPercentClick", "max", "value", "disabled"]);
43
- return (React.createElement(Input, Object.assign({ serialize: serialize, deserialize: deserialize }, inputProps, { value: value, disabled: disabled, keyboardType: "numeric", renderRight: React.createElement(FlexBox, { alignItems: "center", justifyContent: "center", py: "3px", mr: "8px", flexDirection: "row" }, [0.25, 0.5, 0.75, 1].map((percent) => {
43
+ return (React.createElement(Input, Object.assign({ ref: ref, serialize: serialize, deserialize: deserialize }, inputProps, { value: value, disabled: disabled, keyboardType: "numeric", renderRight: React.createElement(FlexBox, { alignItems: "center", justifyContent: "center", py: "3px", mr: "8px", flexDirection: "row" }, [0.25, 0.5, 0.75, 1].map((percent) => {
44
44
  const active = !!value && !!max && Number(value) === percent * Number(max);
45
45
  return (React.createElement(PercentButton, { key: percent, onPress: () => onPercentClick(percent), active: active, disabled: disabled },
46
46
  React.createElement(Text, { variant: "small", color: active ? "neutral.c00" : "neutral.c70" },
@@ -48,3 +48,4 @@ export default function NumberInput(_a) {
48
48
  "%")));
49
49
  })) })));
50
50
  }
51
+ export default React.forwardRef(NumberInput);
@@ -1,6 +1,17 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
+ import { TextInput } from "react-native";
2
3
  import { GestureResponderEvent } from "react-native";
3
4
  import { InputProps } from "../BaseInput";
4
- export default function QrCodeInput({ onQrCodeClick, ...inputProps }: InputProps & {
5
- onQrCodeClick?: (event: GestureResponderEvent) => void;
6
- }): JSX.Element;
5
+ declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInput").CommonProps, "onChange" | "value"> & {
6
+ value: string;
7
+ renderLeft?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
8
+ renderRight?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
9
+ onChange?: ((value: string) => void) | undefined;
10
+ onChangeEvent?: ((e: import("react-native").NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
11
+ serialize?: ((value: string) => string) | undefined;
12
+ deserialize?: ((value: string) => string) | undefined;
13
+ containerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
14
+ } & {
15
+ onQrCodeClick?: ((event: GestureResponderEvent) => void) | undefined;
16
+ } & React.RefAttributes<TextInput>>;
17
+ export default _default;
@@ -28,9 +28,10 @@ const QrCodeButton = styled(TouchableOpacity) `
28
28
  const Icon = styled(QrCodeMedium).attrs((p) => ({
29
29
  color: p.theme.colors.neutral.c00,
30
30
  })) ``;
31
- export default function QrCodeInput(_a) {
31
+ function QrCodeInput(_a, ref) {
32
32
  var { onQrCodeClick } = _a, inputProps = __rest(_a, ["onQrCodeClick"]);
33
- return (React.createElement(Input, Object.assign({}, inputProps, { renderRight: React.createElement(FlexBox, { alignItems: "center", justifyContent: "center", pr: "8px" },
33
+ return (React.createElement(Input, Object.assign({ ref: ref }, inputProps, { renderRight: React.createElement(FlexBox, { alignItems: "center", justifyContent: "center", pr: "8px" },
34
34
  React.createElement(QrCodeButton, { onPress: onQrCodeClick },
35
35
  React.createElement(Icon, { size: "20px" }))) })));
36
36
  }
37
+ export default React.forwardRef(QrCodeInput);
@@ -1,3 +1,14 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
+ import { TextInput } from "react-native";
2
3
  import { InputProps } from "../BaseInput";
3
- export default function SearchInput(props: InputProps): JSX.Element;
4
+ declare const _default: React.ForwardRefExoticComponent<Omit<import("../BaseInput").CommonProps, "onChange" | "value"> & {
5
+ value: string;
6
+ renderLeft?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
7
+ renderRight?: React.ReactNode | ((props: InputProps<string>) => React.ReactNode);
8
+ onChange?: ((value: string) => void) | undefined;
9
+ onChangeEvent?: ((e: import("react-native").NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
10
+ serialize?: ((value: string) => string) | undefined;
11
+ deserialize?: ((value: string) => string) | undefined;
12
+ containerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
13
+ } & React.RefAttributes<TextInput>>;
14
+ export default _default;
@@ -5,7 +5,8 @@ import SearchMedium from "@ledgerhq/icons-ui/native/SearchMedium";
5
5
  const Icon = styled(SearchMedium).attrs((p) => ({
6
6
  color: p.theme.colors.neutral.c70,
7
7
  })) ``;
8
- export default function SearchInput(props) {
9
- return (React.createElement(Input, Object.assign({}, props, { renderLeft: React.createElement(InputRenderLeftContainer, null,
8
+ function SearchInput(props, ref) {
9
+ return (React.createElement(Input, Object.assign({ ref: ref }, props, { renderLeft: React.createElement(InputRenderLeftContainer, null,
10
10
  React.createElement(Icon, null)) })));
11
11
  }
12
+ export default React.forwardRef(SearchInput);
@@ -1,10 +1,19 @@
1
- import React from "react";
1
+ import React, { ComponentType } from "react";
2
2
  import { GestureResponderEvent } from "react-native";
3
- export declare type ElementProps<V> = React.PropsWithChildren<{
3
+ import { IconType } from "../Icon/type";
4
+ declare type BaseElementProps<V> = {
4
5
  first?: boolean;
5
6
  selected?: boolean;
7
+ disabled?: boolean;
6
8
  value?: V;
7
9
  onPress?: ((event: GestureResponderEvent) => void) | undefined;
10
+ Icon?: IconType;
11
+ };
12
+ export declare type ElementProps<V> = React.PropsWithChildren<BaseElementProps<V> & {
13
+ /**
14
+ * A function that will render some content on the right side of the input.
15
+ */
16
+ renderRight?: ComponentType<BaseElementProps<V>> | React.ReactElement;
8
17
  }>;
9
18
  export declare type Props<V> = React.PropsWithChildren<{
10
19
  currentValue?: V;
@@ -12,6 +21,6 @@ export declare type Props<V> = React.PropsWithChildren<{
12
21
  }>;
13
22
  declare function SelectableList<V>({ currentValue, onChange, children }: Props<V>): JSX.Element;
14
23
  declare namespace SelectableList {
15
- var Element: <V>({ first, value, selected, onPress, children, }: ElementProps<V>) => JSX.Element;
24
+ var Element: <V>(props: ElementProps<V>) => JSX.Element;
16
25
  }
17
26
  export default SelectableList;
@@ -1,19 +1,20 @@
1
1
  import React from "react";
2
2
  import { TouchableOpacity } from "react-native";
3
3
  import styled from "styled-components/native";
4
- import { border } from "styled-system";
5
4
  import Flex from "../Layout/Flex";
6
5
  import { Text } from "../index";
7
6
  const ElementContainer = styled(Flex).attrs({
8
7
  accessible: true,
9
8
  accessibilityRole: "radio",
10
- }) `
11
- ${border}
12
- `;
13
- function Element({ first, value, selected, onPress, children, }) {
14
- return (React.createElement(TouchableOpacity, { onPress: onPress },
15
- React.createElement(ElementContainer, { p: 6, mt: first ? 0 : 4, backgroundColor: selected ? "primary.c20" : "neutral.c00", border: "1px solid", borderColor: selected ? "primary.c100" : "neutral.c40", borderRadius: 1 },
16
- React.createElement(Text, { variant: "large" }, children || value))));
9
+ }) ``;
10
+ function Element(props) {
11
+ const { first, value, selected, disabled, onPress, children, Icon, renderRight: RenderRight, } = props;
12
+ return (React.createElement(TouchableOpacity, { onPress: onPress, disabled: disabled },
13
+ React.createElement(ElementContainer, { p: 6, mt: first ? 0 : 4, backgroundColor: selected ? "primary.c20" : "neutral.c00", border: "1px solid", borderColor: selected ? "primary.c100" : "neutral.c40", borderRadius: 1, flexDirection: "row", alignItems: "center" },
14
+ Icon && (React.createElement(Flex, { mr: 6, flexShrink: 0 },
15
+ React.createElement(Icon, { size: 24, color: disabled ? "neutral.c50" : "neutral.c100" }))),
16
+ React.createElement(Text, { variant: "large", flex: 1, color: disabled ? "neutral.c50" : "neutral.c100" }, children || value),
17
+ RenderRight && (React.createElement(Flex, { pl: 6, flexShrink: 0 }, React.isValidElement(RenderRight) ? RenderRight : React.createElement(RenderRight, Object.assign({}, props)))))));
17
18
  }
18
19
  function SelectableList({ currentValue, onChange, children }) {
19
20
  return (React.createElement(Flex, { accessible: true, accessibilityRole: "radiogroup" }, React.Children.map(children, (child, index) => {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { SliderProps } from "./index.native";
3
2
  declare const SliderScreen: (_props: SliderProps) => JSX.Element;
4
3
  export default SliderScreen;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare type SliderProps = {
3
2
  step: number;
4
3
  min: number;
@@ -2,7 +2,7 @@ import React, { useCallback } from "react";
2
2
  import styled from "styled-components/native";
3
3
  import RnRangeSlider from "rn-range-slider";
4
4
  import Text from "../../Text";
5
- import { Label, MinMaxTextContainer, Notch, Rail, RailSelected, Thumb, } from "./components";
5
+ import { Label, MinMaxTextContainer, Notch, Rail, RailSelected, Thumb } from "./components";
6
6
  const SliderContainer = styled.View `
7
7
  display: flex;
8
8
  flex-direction: column;
@@ -1,9 +1,8 @@
1
- /// <reference types="react" />
2
1
  declare type SwitchProps = {
3
2
  checked: boolean;
4
3
  onChange?: (value: boolean) => void;
5
4
  disabled?: boolean;
6
5
  label?: string;
7
6
  };
8
- declare const Switch: ({ checked, onChange, disabled, label, }: SwitchProps) => JSX.Element;
7
+ declare const Switch: ({ checked, onChange, disabled, label }: SwitchProps) => JSX.Element;
9
8
  export default Switch;
@@ -3,13 +3,13 @@ import { Switch as NativeSwitch } from "react-native";
3
3
  import { useTheme } from "styled-components/native";
4
4
  import Text from "../../Text";
5
5
  import Flex from "../../Layout/Flex";
6
- const Switch = ({ checked, onChange, disabled, label, }) => {
6
+ const Switch = ({ checked, onChange, disabled, label }) => {
7
7
  const { colors, space } = useTheme();
8
8
  return (React.createElement(Flex, { flexDirection: "row", alignItems: "center" },
9
9
  React.createElement(NativeSwitch, { trackColor: {
10
10
  false: colors.neutral.c50,
11
11
  true: colors.primary.c80,
12
12
  }, thumbColor: colors.neutral.c00, onValueChange: onChange, value: checked, disabled: disabled, ios_backgroundColor: colors.neutral.c50 }),
13
- label ? (React.createElement(Text, { variant: "body", color: checked ? colors.primary.c90 : colors.neutral.c100, style: { marginLeft: space[3] } }, label)) : null));
13
+ label ? (React.createElement(Text, { variant: "body", color: checked ? colors.primary.c90 : colors.neutral.c100, style: { marginLeft: space[3], flexShrink: 1 } }, label)) : null));
14
14
  };
15
15
  export default Switch;
@@ -1,9 +1,8 @@
1
- /// <reference types="react" />
2
1
  import type { ButtonProps } from "../../cta/Button";
3
2
  declare type ToggleProps = {
4
3
  active?: boolean;
5
4
  onPress: () => void;
6
5
  children: ButtonProps["children"];
7
6
  };
8
- export default function Toggle({ active, children, onPress, }: ToggleProps): JSX.Element;
7
+ export default function Toggle({ active, children, onPress }: ToggleProps): JSX.Element;
9
8
  export {};
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { TouchableOpacity } from "react-native";
3
3
  import Button from "../../cta/Button";
4
- export default function Toggle({ active = false, children, onPress, }) {
4
+ export default function Toggle({ active = false, children, onPress }) {
5
5
  return (React.createElement(TouchableOpacity, { onPress: onPress },
6
6
  React.createElement(Button, { disabled: !active, type: "main" }, children)));
7
7
  }
@@ -2,4 +2,5 @@ export { default as Checkbox } from "./Checkbox";
2
2
  export * from "./Input";
3
3
  export { default as Slider } from "./Slider";
4
4
  export { default as Switch } from "./Switch";
5
+ export { default as Toggle } from "./Toggle";
5
6
  export { default as SelectableList } from "./SelectableList";