@ledgerhq/native-ui 0.4.0 → 0.5.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.
- package/assets/logos/LedgerLiveAltRegular.d.ts +0 -1
- package/assets/logos/LedgerLiveRegular.d.ts +0 -1
- package/components/Carousel/index.d.ts +45 -0
- package/components/Carousel/index.js +76 -0
- package/components/Form/Checkbox/index.d.ts +2 -2
- package/components/Form/Input/BaseInput/index.d.ts +83 -5
- package/components/Form/Input/BaseInput/index.js +5 -5
- package/components/Form/Input/LegendInput/index.d.ts +14 -3
- package/components/Form/Input/LegendInput/index.js +3 -2
- package/components/Form/Input/NumberInput/index.d.ts +16 -5
- package/components/Form/Input/NumberInput/index.js +3 -2
- package/components/Form/Input/QrCodeInput/index.d.ts +15 -4
- package/components/Form/Input/QrCodeInput/index.js +3 -2
- package/components/Form/Input/SearchInput/index.d.ts +13 -2
- package/components/Form/Input/SearchInput/index.js +3 -2
- package/components/Form/Slider/index.d.ts +0 -1
- package/components/Form/Slider/index.native.d.ts +0 -1
- package/components/Form/Switch/index.d.ts +0 -1
- package/components/Form/Toggle/index.d.ts +0 -1
- package/components/Layout/Box/index.d.ts +11 -0
- package/components/Layout/Box/index.js +3 -0
- package/components/Layout/Flex/index.d.ts +11 -12
- package/components/Layout/Flex/index.js +2 -8
- package/components/Layout/ScrollContainerHeader/Header.d.ts +0 -1
- package/components/Layout/index.d.ts +1 -0
- package/components/Layout/index.js +1 -0
- package/components/Navigation/SlideIndicator/index.js +13 -6
- package/components/Navigation/ToggleGroup/index.d.ts +8 -1
- package/components/chart/index.d.ts +0 -1
- package/components/cta/Button/index.d.ts +4 -15
- package/components/cta/Button/index.js +12 -13
- package/components/index.d.ts +1 -0
- package/components/index.js +1 -0
- package/components/message/Alert/index.d.ts +0 -1
- package/components/styled.d.ts +15 -0
- package/components/styled.js +12 -0
- package/package.json +2 -2
- package/styles/theme.js +2 -0
|
@@ -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,76 @@
|
|
|
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
|
|
18
|
+
? 0
|
|
19
|
+
: dimensions.current.contentWidth / slidesLength;
|
|
20
|
+
const scrollToIndex = useCallback((index, animated = true) => {
|
|
21
|
+
if (scrollRef.current && dimensions.current) {
|
|
22
|
+
scrollRef.current.scrollTo({
|
|
23
|
+
x: itemWidth * index,
|
|
24
|
+
animated,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}, [itemWidth]);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
// On init scroll to the active index prop location - if specified.
|
|
30
|
+
if (init && activeIndex)
|
|
31
|
+
scrollToIndex(activeIndex, false);
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
}, [init]);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (scrollToIndex && typeof activeIndex === "number") {
|
|
36
|
+
scrollToIndex(activeIndex);
|
|
37
|
+
}
|
|
38
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
|
+
}, [activeIndex]);
|
|
40
|
+
const onContentSizeChange = (contentWidth, contentHeight) => {
|
|
41
|
+
dimensions.current = { contentWidth, contentHeight };
|
|
42
|
+
setInit(true);
|
|
43
|
+
};
|
|
44
|
+
const onScroll = ({ nativeEvent: { contentOffset, contentSize }, }) => {
|
|
45
|
+
const newIndex = Math.abs(Math.round((contentOffset.x / contentSize.width) * slidesLength));
|
|
46
|
+
setActiveIndexState(newIndex);
|
|
47
|
+
onChange && onChange(newIndex);
|
|
48
|
+
};
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!autoDelay)
|
|
51
|
+
return;
|
|
52
|
+
const interval = setInterval(() => {
|
|
53
|
+
if (!disableTimer.current) {
|
|
54
|
+
setActiveIndexState((index) => {
|
|
55
|
+
const newIndex = index ? (index + 1) % slidesLength : 0;
|
|
56
|
+
scrollToIndex(newIndex);
|
|
57
|
+
onChange && onChange(newIndex);
|
|
58
|
+
return newIndex;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, autoDelay);
|
|
62
|
+
return () => clearInterval(interval);
|
|
63
|
+
}, [resetTimer, slidesLength, scrollToIndex, onChange, autoDelay]);
|
|
64
|
+
return (React.createElement(Flex, Object.assign({ flex: 1, width: "100%", alignItems: "center", justifyContent: "center" }, containerProps),
|
|
65
|
+
React.createElement(HorizontalScrollView, Object.assign({ ref: scrollRef, onScroll: onScroll, onContentSizeChange: onContentSizeChange, onScrollBeginDrag: () => {
|
|
66
|
+
disableTimer.current = true;
|
|
67
|
+
}, onScrollEndDrag: () => {
|
|
68
|
+
disableTimer.current = false;
|
|
69
|
+
}, 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)))),
|
|
70
|
+
React.createElement(Flex, Object.assign({ my: 8 }, slideIndicatorContainerProps),
|
|
71
|
+
React.createElement(SlideIndicator, { activeIndex: activeIndexState || 0, onChange: (index) => {
|
|
72
|
+
scrollToIndex(index);
|
|
73
|
+
setResetTimer({});
|
|
74
|
+
}, slidesLength: slidesLength }))));
|
|
75
|
+
}
|
|
76
|
+
export default React.memo(Carousel);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
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?:
|
|
6
|
+
label?: BaseTextProps["children"];
|
|
7
7
|
};
|
|
8
8
|
declare const Checkbox: ({ checked, onChange, disabled, label, }: CheckboxProps) => JSX.Element;
|
|
9
9
|
export default Checkbox;
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
/// <reference types="styled-components-react-native" />
|
|
2
2
|
import React from "react";
|
|
3
|
-
import {
|
|
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
|
-
|
|
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("
|
|
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("
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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
92
|
!!error && !disabled && (React.createElement(InputErrorContainer, null, error))));
|
|
94
93
|
}
|
|
94
|
+
export default React.forwardRef(Input);
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TextInput } from "react-native";
|
|
2
3
|
import { InputProps } from "../BaseInput";
|
|
3
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TextInput } from "react-native";
|
|
2
3
|
import { InputProps } from "../BaseInput";
|
|
3
|
-
|
|
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
|
-
}
|
|
15
|
+
min?: number | undefined;
|
|
16
|
+
max?: number | undefined;
|
|
17
|
+
} & React.RefAttributes<TextInput>>;
|
|
18
|
+
export default _default;
|
|
@@ -38,9 +38,9 @@ function deserialize(value) {
|
|
|
38
38
|
return undefined;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
|
|
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
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TextInput } from "react-native";
|
|
2
3
|
import { InputProps } from "../BaseInput";
|
|
3
|
-
|
|
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
|
-
|
|
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);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseStyledProps } from "../../styled";
|
|
2
|
+
export declare type BoxProps = BaseStyledProps;
|
|
3
|
+
declare const Box: 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>> & {
|
|
4
|
+
columnGap?: string | number | undefined;
|
|
5
|
+
rowGap?: string | number | undefined;
|
|
6
|
+
color?: string | undefined;
|
|
7
|
+
display?: string | undefined;
|
|
8
|
+
position?: string | undefined;
|
|
9
|
+
maxHeight?: number | undefined;
|
|
10
|
+
}, never>;
|
|
11
|
+
export default Box;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
declare const FlexBox: import("styled-components").StyledComponent<typeof import("react-native").View, import("styled-components").DefaultTheme, Props, never>;
|
|
1
|
+
import { BaseStyledProps } from "../../styled";
|
|
2
|
+
export declare type FlexBoxProps = BaseStyledProps;
|
|
3
|
+
export declare type Props = FlexBoxProps;
|
|
4
|
+
declare const FlexBox: 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>> & {
|
|
5
|
+
columnGap?: string | number | undefined;
|
|
6
|
+
rowGap?: string | number | undefined;
|
|
7
|
+
color?: string | undefined;
|
|
8
|
+
display?: string | undefined;
|
|
9
|
+
position?: string | undefined;
|
|
10
|
+
maxHeight?: number | undefined;
|
|
11
|
+
}, never>;
|
|
13
12
|
export default FlexBox;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const FlexBox = styled.View `
|
|
1
|
+
import baseStyled from "../../styled";
|
|
2
|
+
const FlexBox = baseStyled.View `
|
|
4
3
|
display: flex;
|
|
5
|
-
${flexbox};
|
|
6
|
-
${space};
|
|
7
|
-
${background};
|
|
8
|
-
${color};
|
|
9
|
-
${layout};
|
|
10
4
|
`;
|
|
11
5
|
export default FlexBox;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as Accordion } from "./Collapse/Accordion";
|
|
2
2
|
export { default as Flex } from "./Flex";
|
|
3
|
+
export { default as Box } from "./Box";
|
|
3
4
|
export * from "./Modals";
|
|
4
5
|
export { default as ScrollContainer } from "./ScrollContainer";
|
|
5
6
|
export { default as ScrollContainerHeader } from "./ScrollContainerHeader";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as Accordion } from "./Collapse/Accordion";
|
|
2
2
|
export { default as Flex } from "./Flex";
|
|
3
|
+
export { default as Box } from "./Box";
|
|
3
4
|
export * from "./Modals";
|
|
4
5
|
export { default as ScrollContainer } from "./ScrollContainer";
|
|
5
6
|
export { default as ScrollContainerHeader } from "./ScrollContainerHeader";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useMemo } from "react";
|
|
2
2
|
import styled from "styled-components/native";
|
|
3
|
-
import Animated, { useAnimatedStyle, Easing, withTiming, } from "react-native-reanimated";
|
|
3
|
+
import Animated, { useDerivedValue, useAnimatedStyle, Easing, withTiming, } from "react-native-reanimated";
|
|
4
4
|
const Container = styled.View `
|
|
5
5
|
flex-direction: row;
|
|
6
6
|
align-items: center;
|
|
@@ -8,14 +8,18 @@ const Container = styled.View `
|
|
|
8
8
|
height: 6px;
|
|
9
9
|
position: relative;
|
|
10
10
|
`;
|
|
11
|
-
const
|
|
11
|
+
const bulletStyle = `
|
|
12
12
|
width: 6px;
|
|
13
13
|
height: 6px;
|
|
14
14
|
border-radius: 6px;
|
|
15
15
|
margin: 0 6px;
|
|
16
|
+
`;
|
|
17
|
+
const Bullet = styled.TouchableOpacity `
|
|
18
|
+
${bulletStyle}
|
|
16
19
|
background-color: ${(p) => p.theme.colors.neutral.c40};
|
|
17
20
|
`;
|
|
18
|
-
const ActiveBullet = styled(
|
|
21
|
+
const ActiveBullet = styled.View.attrs({ pointerEvents: "none" }) `
|
|
22
|
+
${bulletStyle}
|
|
19
23
|
background-color: ${(p) => p.theme.colors.neutral.c100};
|
|
20
24
|
position: absolute;
|
|
21
25
|
top: 0;
|
|
@@ -28,10 +32,13 @@ const config = {
|
|
|
28
32
|
};
|
|
29
33
|
function SlideIndicator({ slidesLength, activeIndex = 0, onChange, }) {
|
|
30
34
|
const slidesArray = useMemo(() => new Array(slidesLength).fill(0), [slidesLength]);
|
|
31
|
-
const activeSize =
|
|
32
|
-
|
|
35
|
+
const activeSize = useDerivedValue(() => {
|
|
36
|
+
const size = (Math.max(0, Math.min(slidesLength - 1, activeIndex)) + 1) * (6 + 12) -
|
|
37
|
+
12;
|
|
38
|
+
return size;
|
|
39
|
+
}, [activeIndex, slidesLength]);
|
|
33
40
|
const animatedStyles = useAnimatedStyle(() => ({
|
|
34
|
-
width: withTiming(activeSize, config),
|
|
41
|
+
width: withTiming(activeSize.value, config),
|
|
35
42
|
}));
|
|
36
43
|
return (React.createElement(Container, null,
|
|
37
44
|
slidesArray.map((_, index) => (React.createElement(Bullet, { key: index, onPress: () => onChange(index) }))),
|
|
@@ -6,7 +6,14 @@ export declare type ToggleGroupProps = {
|
|
|
6
6
|
activeIndex: number;
|
|
7
7
|
onChange: (newIndex: number) => void;
|
|
8
8
|
};
|
|
9
|
-
export declare const ToggleGroupContainer: import("styled-components").StyledComponent<typeof import("react-native").View, import("styled-components").DefaultTheme, import("
|
|
9
|
+
export declare const ToggleGroupContainer: 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>> & {
|
|
10
|
+
columnGap?: string | number | undefined;
|
|
11
|
+
rowGap?: string | number | undefined;
|
|
12
|
+
color?: string | undefined;
|
|
13
|
+
display?: string | undefined;
|
|
14
|
+
position?: string | undefined;
|
|
15
|
+
maxHeight?: number | undefined;
|
|
16
|
+
} & {
|
|
10
17
|
flexDirection: string;
|
|
11
18
|
alignItems: string;
|
|
12
19
|
}, "alignItems" | "flexDirection">;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="styled-components-react-native" />
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { SpaceProps } from "styled-system";
|
|
4
3
|
import { TouchableOpacity, TouchableOpacityProps } from "react-native";
|
|
5
|
-
|
|
4
|
+
import { BaseStyledProps } from "../../styled";
|
|
5
|
+
export declare type ButtonProps = TouchableOpacityProps & BaseStyledProps & {
|
|
6
6
|
Icon?: React.ComponentType<{
|
|
7
7
|
size: number;
|
|
8
8
|
color: string;
|
|
@@ -17,19 +17,8 @@ export declare type ButtonProps = TouchableOpacityProps & SpaceProps & {
|
|
|
17
17
|
};
|
|
18
18
|
export declare const Base: import("styled-components").StyledComponent<typeof TouchableOpacity, import("styled-components").DefaultTheme, {
|
|
19
19
|
iconButton?: boolean | undefined;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
size: number;
|
|
23
|
-
color: string;
|
|
24
|
-
}> | null | undefined;
|
|
25
|
-
type?: "default" | "main" | "shade" | "error" | "color" | undefined;
|
|
26
|
-
size?: "large" | "small" | "medium" | undefined;
|
|
27
|
-
iconPosition?: "left" | "right" | undefined;
|
|
28
|
-
outline?: boolean | undefined;
|
|
29
|
-
disabled?: boolean | undefined;
|
|
30
|
-
pressed?: boolean | undefined;
|
|
31
|
-
children?: React.ReactNode;
|
|
32
|
-
}, never>;
|
|
20
|
+
sizeVariant?: ButtonProps["size"];
|
|
21
|
+
} & Omit<ButtonProps, "size">, never>;
|
|
33
22
|
declare const Button: (props: ButtonProps) => React.ReactElement;
|
|
34
23
|
export declare const PromisableButton: (props: ButtonProps) => React.ReactElement;
|
|
35
24
|
export default Button;
|
|
@@ -9,11 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import React, { useCallback, useState } from "react";
|
|
11
11
|
import styled, { useTheme } from "styled-components/native";
|
|
12
|
-
import { color, border, space } from "styled-system";
|
|
13
12
|
import { ActivityIndicator, TouchableOpacity, } from "react-native";
|
|
14
13
|
import { buttonSizeStyle, getButtonColorStyle, } from "../../cta/Button/getButtonStyle";
|
|
15
14
|
import { ctaIconSize, ctaTextType } from "../../cta/getCtaStyle";
|
|
16
15
|
import Text from "../../Text";
|
|
16
|
+
import baseStyled from "../../styled";
|
|
17
17
|
const IconContainer = styled.View `
|
|
18
18
|
${(p) => p.iconButton
|
|
19
19
|
? ""
|
|
@@ -21,12 +21,11 @@ const IconContainer = styled.View `
|
|
|
21
21
|
? `margin-right: 10px;`
|
|
22
22
|
: `margin-left: 10px;`}
|
|
23
23
|
`;
|
|
24
|
-
export const Base =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
export const Base = baseStyled(TouchableOpacity).attrs((p) => (Object.assign(Object.assign({}, getButtonColorStyle(p.theme.colors, p).button), {
|
|
25
|
+
// Avoid conflict with styled-system's size property by nulling size and renaming it
|
|
26
|
+
size: undefined, sizeVariant: p.size }))) `
|
|
27
|
+
|
|
28
28
|
border-radius: ${(p) => p.theme.space[10]}px;
|
|
29
|
-
height: ${(p) => p.theme.space[10]}px;
|
|
30
29
|
padding: 0 ${(p) => p.theme.space[7]}px;
|
|
31
30
|
flex-direction: row;
|
|
32
31
|
border-style: solid;
|
|
@@ -36,7 +35,7 @@ export const Base = styled(TouchableOpacity).attrs((p) => (Object.assign({}, get
|
|
|
36
35
|
align-content: center;
|
|
37
36
|
overflow: hidden;
|
|
38
37
|
position: relative;
|
|
39
|
-
${(p) => buttonSizeStyle[p.
|
|
38
|
+
${(p) => buttonSizeStyle[p.sizeVariant || "medium"]}
|
|
40
39
|
|
|
41
40
|
${(p) => (p.iconButton ? `padding: 0; width: ${p.theme.space[10]}px;` : "")}
|
|
42
41
|
`;
|
|
@@ -69,12 +68,12 @@ const ButtonContainer = (props) => {
|
|
|
69
68
|
iconPosition === "left" && children ? (React.createElement(Text, { variant: ctaTextType[size], fontWeight: "semiBold", color: text.color }, children)) : null));
|
|
70
69
|
};
|
|
71
70
|
const Button = (props) => {
|
|
72
|
-
const { Icon, children, type = "default"
|
|
73
|
-
return (React.createElement(Base, Object.assign({}, props, { type: type,
|
|
74
|
-
React.createElement(ButtonContainer, Object.assign({}, props, { type: type
|
|
71
|
+
const { Icon, children, type = "default" } = props;
|
|
72
|
+
return (React.createElement(Base, Object.assign({}, props, { type: type, iconButton: !!Icon && !children, activeOpacity: 0.5 }),
|
|
73
|
+
React.createElement(ButtonContainer, Object.assign({}, props, { type: type }))));
|
|
75
74
|
};
|
|
76
75
|
export const PromisableButton = (props) => {
|
|
77
|
-
const { Icon, children, onPress, type = "main",
|
|
76
|
+
const { Icon, children, onPress, type = "main", disabled = false } = props;
|
|
78
77
|
const [spinnerOn, setSpinnerOn] = useState(false);
|
|
79
78
|
const theme = useTheme();
|
|
80
79
|
const onPressHandler = useCallback((event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -88,8 +87,8 @@ export const PromisableButton = (props) => {
|
|
|
88
87
|
setSpinnerOn(false);
|
|
89
88
|
}
|
|
90
89
|
}), [onPress]);
|
|
91
|
-
return (React.createElement(Base, Object.assign({}, props, { type: type,
|
|
92
|
-
React.createElement(ButtonContainer, Object.assign({}, props, { type: type,
|
|
90
|
+
return (React.createElement(Base, Object.assign({}, props, { type: type, iconButton: !!Icon && !children, disabled: disabled || spinnerOn, onPress: onPressHandler }),
|
|
91
|
+
React.createElement(ButtonContainer, Object.assign({}, props, { type: type, hide: spinnerOn })),
|
|
93
92
|
React.createElement(SpinnerContainer, null,
|
|
94
93
|
React.createElement(ActivityIndicator, { color: theme.colors.neutral.c50, animating: spinnerOn }))));
|
|
95
94
|
};
|
package/components/index.d.ts
CHANGED
package/components/index.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="styled-components-react-native" />
|
|
2
|
+
import { ReactNativeStyledInterface, DefaultTheme } from "styled-components/native";
|
|
3
|
+
import { FlexboxProps, SpaceProps, PositionProps, ColorProps, LayoutProps, OverflowProps, BorderProps, BackgroundProps } from "styled-system";
|
|
4
|
+
import { InterpolationFunction } from "styled-components";
|
|
5
|
+
export declare type BaseStyledProps = SpaceProps & FlexboxProps & PositionProps & ColorProps & LayoutProps & OverflowProps & BorderProps & BackgroundProps & {
|
|
6
|
+
columnGap?: string | number;
|
|
7
|
+
rowGap?: string | number;
|
|
8
|
+
color?: string;
|
|
9
|
+
display?: string;
|
|
10
|
+
position?: string;
|
|
11
|
+
maxHeight?: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const baseStyles: InterpolationFunction<unknown>;
|
|
14
|
+
declare const _default: ReactNativeStyledInterface<DefaultTheme>;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import styled from "styled-components/native";
|
|
2
|
+
import { compose, flexbox, space, position, color, layout, overflow, border, background, } from "styled-system";
|
|
3
|
+
export const baseStyles = compose(flexbox, space, position, color, layout, overflow, border, background);
|
|
4
|
+
const proxyStyled = new Proxy(styled, {
|
|
5
|
+
apply(target, thisArg, argumentsList) {
|
|
6
|
+
return styled(target.apply(thisArg, argumentsList)(baseStyles));
|
|
7
|
+
},
|
|
8
|
+
get(target, property) {
|
|
9
|
+
return styled(target[property].apply(styled, [baseStyles]));
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
export default proxyStyled;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/native-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Ledger Live - Desktop UI",
|
|
5
5
|
"repository": "https://github.com/LedgerHQ/ui",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@ledgerhq/icons-ui": "^0.2.0",
|
|
19
19
|
"@ledgerhq/ui-shared": "^0.1.3",
|
|
20
20
|
"@types/color": "^3.0.2",
|
|
21
|
-
"@types/react": "^17.0.
|
|
21
|
+
"@types/react": "^17.0.37",
|
|
22
22
|
"@types/react-native": "^0.65.9",
|
|
23
23
|
"@types/styled-components-react-native": "^5.1.3",
|
|
24
24
|
"@types/styled-system": "^5.1.13",
|
package/styles/theme.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { palettes } from "@ledgerhq/ui-shared";
|
|
2
|
+
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
|
2
3
|
export const space = [0, 2, 4, 8, 12, 14, 16, 24, 32, 40, 48, 64, 80, 96, 120];
|
|
4
|
+
// 0 1 2 3 4 5 6 7 8
|
|
3
5
|
export const fontSizes = [10, 11, 12, 13, 14, 16, 18, 24, 28];
|
|
4
6
|
[
|
|
5
7
|
fontSizes.tiny,
|