@ledgerhq/native-ui 0.6.0 → 0.6.4
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/README.md +1 -4
- package/components/Carousel/index.js +2 -4
- package/components/Form/Checkbox/index.d.ts +1 -1
- package/components/Form/Checkbox/index.js +1 -1
- package/components/Form/Input/BaseInput/index.d.ts +1 -1
- package/components/Form/Input/BaseInput/index.js +19 -5
- package/components/Form/Input/NumberInput/index.js +2 -2
- package/components/Form/SelectableList.d.ts +11 -7
- package/components/Form/SelectableList.js +5 -3
- package/components/Form/Slider/index.native.js +1 -1
- package/components/Form/Switch/index.d.ts +1 -1
- package/components/Form/Switch/index.js +2 -2
- package/components/Form/Toggle/index.d.ts +1 -1
- package/components/Form/Toggle/index.js +1 -1
- package/components/Icon/BoxedIcon.d.ts +49 -0
- package/components/Icon/BoxedIcon.js +85 -0
- package/components/Icon/Icon.d.ts +9 -0
- package/components/Icon/Icon.js +20 -0
- package/components/Icon/IconBox/index.d.ts +9 -5
- package/components/Icon/IconBox/index.js +11 -11
- package/components/Icon/index.d.ts +2 -0
- package/components/Icon/index.js +2 -0
- package/components/Icon/type.d.ts +7 -0
- package/components/Icon/type.js +1 -0
- package/components/Layout/Collapse/Accordion/index.js +1 -1
- package/components/Layout/List/IconBoxList/index.d.ts +10 -0
- package/components/Layout/List/IconBoxList/index.js +19 -0
- package/components/Layout/List/List/index.d.ts +13 -0
- package/components/Layout/List/List/index.js +29 -0
- package/components/Layout/List/NumberedList/index.d.ts +9 -0
- package/components/Layout/List/NumberedList/index.js +23 -0
- package/components/Layout/List/TipList/index.d.ts +9 -0
- package/components/Layout/List/TipList/index.js +20 -0
- package/components/Layout/List/index.d.ts +4 -0
- package/components/Layout/List/index.js +4 -0
- package/components/Layout/ScrollContainer/index.d.ts +2 -1
- package/components/Layout/ScrollContainer/index.js +2 -2
- package/components/Layout/ScrollContainerHeader/Header.d.ts +1 -1
- package/components/Layout/ScrollContainerHeader/Header.js +23 -16
- package/components/Layout/ScrollContainerHeader/index.d.ts +5 -3
- package/components/Layout/ScrollContainerHeader/index.js +9 -4
- package/components/Layout/index.d.ts +1 -0
- package/components/Layout/index.js +1 -0
- package/components/Loader/InfiniteLoader/index.d.ts +9 -0
- package/components/Loader/InfiniteLoader/index.js +58 -0
- package/components/Loader/ProgressLoader/index.d.ts +11 -0
- package/components/Loader/ProgressLoader/index.js +24 -0
- package/components/Loader/index.d.ts +2 -11
- package/components/Loader/index.js +2 -24
- package/components/Navigation/FlowStepper/index.d.ts +7 -1
- package/components/Navigation/FlowStepper/index.js +5 -7
- package/components/Navigation/SlideIndicator/index.d.ts +1 -1
- package/components/Navigation/SlideIndicator/index.js +2 -3
- package/components/Navigation/Stepper/index.d.ts +1 -1
- package/components/Navigation/Stepper/index.js +4 -4
- package/components/ProgressBar/index.js +1 -1
- package/components/Tabs/Chip/index.d.ts +1 -1
- package/components/Tabs/Chip/index.js +2 -2
- package/components/Tabs/Graph/index.d.ts +1 -1
- package/components/Tabs/Graph/index.js +9 -3
- package/components/Tabs/TemplateTabs/index.d.ts +6 -0
- package/components/Tabs/TemplateTabs/index.js +2 -2
- package/components/Text/getTextStyle.d.ts +1 -0
- package/components/Text/getTextStyle.js +5 -0
- package/components/Text/index.d.ts +7 -9
- package/components/Text/index.js +15 -8
- package/components/cta/Button/index.d.ts +1 -0
- package/components/cta/Button/index.js +9 -11
- package/components/cta/Link/index.js +1 -5
- package/components/index.d.ts +1 -1
- package/components/index.js +1 -1
- package/components/message/Alert/index.d.ts +1 -1
- package/components/message/Alert/index.js +2 -2
- package/components/message/Notification/index.js +1 -1
- package/components/transitions/Slide.d.ts +1 -1
- package/components/transitions/Slide.js +1 -1
- package/components/transitions/Transition.js +2 -5
- package/package.json +3 -3
- package/styles/StyleProvider.d.ts +1 -1
- package/styles/StyleProvider.js +1 -1
- package/styles/helpers.js +1 -3
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,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState, useRef, useCallback } from "react";
|
|
2
|
-
import { Platform
|
|
2
|
+
import { Platform } from "react-native";
|
|
3
3
|
import styled from "styled-components/native";
|
|
4
4
|
import { Flex, SlideIndicator } from "../index";
|
|
5
5
|
const HorizontalScrollView = styled.ScrollView.attrs({ horizontal: true }) `
|
|
@@ -14,9 +14,7 @@ function Carousel({ activeIndex, autoDelay, containerProps, slideIndicatorContai
|
|
|
14
14
|
const slidesLength = React.Children.count(children);
|
|
15
15
|
const scrollRef = useRef(null);
|
|
16
16
|
const fullWidth = 100 * slidesLength;
|
|
17
|
-
const itemWidth = !dimensions.current
|
|
18
|
-
? 0
|
|
19
|
-
: dimensions.current.contentWidth / slidesLength;
|
|
17
|
+
const itemWidth = !dimensions.current ? 0 : dimensions.current.contentWidth / slidesLength;
|
|
20
18
|
const scrollToIndex = useCallback((index, animated = true) => {
|
|
21
19
|
if (scrollRef.current && dimensions.current) {
|
|
22
20
|
scrollRef.current.scrollTo({
|
|
@@ -5,5 +5,5 @@ declare type CheckboxProps = {
|
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
label?: BaseTextProps["children"];
|
|
7
7
|
};
|
|
8
|
-
declare const Checkbox: ({ checked, onChange, disabled, label
|
|
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" },
|
|
@@ -71,7 +71,7 @@ export declare const InputRenderRightContainer: import("styled-components").Styl
|
|
|
71
71
|
flexDirection: string;
|
|
72
72
|
pr: string;
|
|
73
73
|
}, "pr" | "alignItems" | "flexDirection">;
|
|
74
|
-
declare function Input<T = string>(props: InputProps<T>, ref?:
|
|
74
|
+
declare function Input<T = string>(props: InputProps<T>, ref?: any): JSX.Element;
|
|
75
75
|
declare const _default: <T>(props: Omit<CommonProps, "onChange" | "value"> & {
|
|
76
76
|
/**
|
|
77
77
|
* The value of the input.
|
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React, { useMemo, useCallback } from "react";
|
|
12
|
+
import React, { useMemo, useCallback, useEffect, useImperativeHandle, useRef } from "react";
|
|
13
13
|
import styled, { css } from "styled-components/native";
|
|
14
14
|
import Text from "../../../Text";
|
|
15
15
|
import FlexBox from "../../../Layout/Flex";
|
|
@@ -17,7 +17,7 @@ const InputContainer = styled.View `
|
|
|
17
17
|
display: flex;
|
|
18
18
|
flex-direction: row;
|
|
19
19
|
width: 100%;
|
|
20
|
-
background: ${(p) => p.theme.colors.
|
|
20
|
+
background: ${(p) => p.theme.colors.background.main};
|
|
21
21
|
height: 48px;
|
|
22
22
|
border: ${(p) => `1px solid ${p.theme.colors.neutral.c40}`};
|
|
23
23
|
border-radius: 24px;
|
|
@@ -49,6 +49,8 @@ const InputContainer = styled.View `
|
|
|
49
49
|
`;
|
|
50
50
|
const BaseInput = styled.TextInput.attrs((p) => ({
|
|
51
51
|
selectionColor: p.theme.colors.primary.c80,
|
|
52
|
+
color: p.theme.colors.neutral.c100,
|
|
53
|
+
placeholderTextColor: p.theme.colors.neutral.c80,
|
|
52
54
|
})) `
|
|
53
55
|
height: 100%;
|
|
54
56
|
width: 100%;
|
|
@@ -77,18 +79,30 @@ export const InputRenderRightContainer = styled(FlexBox).attrs(() => ({
|
|
|
77
79
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
80
|
const IDENTITY = (_) => _;
|
|
79
81
|
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
|
+
const { value, onChange, onChangeText, onChangeEvent, disabled, error, renderLeft, renderRight, serialize = IDENTITY, deserialize = IDENTITY, containerStyle, autoFocus, onFocus, onBlur } = props, textInputProps = __rest(props, ["value", "onChange", "onChangeText", "onChangeEvent", "disabled", "error", "renderLeft", "renderRight", "serialize", "deserialize", "containerStyle", "autoFocus", "onFocus", "onBlur"]);
|
|
83
|
+
const inputRef = useRef();
|
|
84
|
+
useImperativeHandle(ref, () => inputRef.current, [inputRef]);
|
|
81
85
|
const inputValue = useMemo(() => serialize(value), [serialize, value]);
|
|
82
86
|
const handleChange = useCallback((value) => {
|
|
83
87
|
onChange && onChange(deserialize(value));
|
|
84
88
|
onChangeText && onChangeText(value);
|
|
85
89
|
}, [onChange, onChangeText, deserialize]);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (autoFocus && inputRef && inputRef.current && inputRef.current.focus)
|
|
92
|
+
inputRef.current.focus();
|
|
93
|
+
}, [inputRef, autoFocus]);
|
|
86
94
|
const [focus, setFocus] = React.useState(false);
|
|
87
95
|
return (React.createElement(FlexBox, { width: "100%", style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
|
|
88
96
|
React.createElement(InputContainer, { disabled: disabled, focus: focus, error: error },
|
|
89
97
|
typeof renderLeft === "function" ? renderLeft(props) : renderLeft,
|
|
90
|
-
React.createElement(BaseInput, Object.assign({ ref:
|
|
98
|
+
React.createElement(BaseInput, Object.assign({ ref: inputRef }, textInputProps, { value: inputValue, onChange: onChangeEvent, onChangeText: handleChange, editable: !disabled, disabled: disabled, error: error, onFocus: (e) => {
|
|
99
|
+
setFocus(true);
|
|
100
|
+
typeof onFocus === "function" && onFocus(e);
|
|
101
|
+
}, onBlur: (e) => {
|
|
102
|
+
setFocus(false);
|
|
103
|
+
typeof onBlur === "function" && onBlur(e);
|
|
104
|
+
} })),
|
|
91
105
|
typeof renderRight === "function" ? renderRight(props) : renderRight),
|
|
92
|
-
!!error && !disabled &&
|
|
106
|
+
!!error && !disabled && React.createElement(InputErrorContainer, null, error)));
|
|
93
107
|
}
|
|
94
108
|
export default React.forwardRef(Input);
|
|
@@ -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;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { ComponentType } from "react";
|
|
2
2
|
import { GestureResponderEvent } from "react-native";
|
|
3
|
-
|
|
3
|
+
import { IconType } from "../Icon/type";
|
|
4
|
+
declare type BaseElementProps<V> = {
|
|
4
5
|
first?: boolean;
|
|
5
6
|
selected?: boolean;
|
|
6
7
|
disabled?: boolean;
|
|
7
8
|
value?: V;
|
|
8
9
|
onPress?: ((event: GestureResponderEvent) => void) | undefined;
|
|
9
|
-
Icon?:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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;
|
|
13
17
|
}>;
|
|
14
18
|
export declare type Props<V> = React.PropsWithChildren<{
|
|
15
19
|
currentValue?: V;
|
|
@@ -17,6 +21,6 @@ export declare type Props<V> = React.PropsWithChildren<{
|
|
|
17
21
|
}>;
|
|
18
22
|
declare function SelectableList<V>({ currentValue, onChange, children }: Props<V>): JSX.Element;
|
|
19
23
|
declare namespace SelectableList {
|
|
20
|
-
var Element: <V>(
|
|
24
|
+
var Element: <V>(props: ElementProps<V>) => JSX.Element;
|
|
21
25
|
}
|
|
22
26
|
export default SelectableList;
|
|
@@ -7,12 +7,14 @@ const ElementContainer = styled(Flex).attrs({
|
|
|
7
7
|
accessible: true,
|
|
8
8
|
accessibilityRole: "radio",
|
|
9
9
|
}) ``;
|
|
10
|
-
function Element(
|
|
10
|
+
function Element(props) {
|
|
11
|
+
const { first, value, selected, disabled, onPress, children, Icon, renderRight: RenderRight, } = props;
|
|
11
12
|
return (React.createElement(TouchableOpacity, { onPress: onPress, disabled: disabled },
|
|
12
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" },
|
|
13
|
-
Icon && (React.createElement(Flex, { mr: 6 },
|
|
14
|
+
Icon && (React.createElement(Flex, { mr: 6, flexShrink: 0 },
|
|
14
15
|
React.createElement(Icon, { size: 24, color: disabled ? "neutral.c50" : "neutral.c100" }))),
|
|
15
|
-
React.createElement(Text, { variant: "large", color: disabled ? "neutral.c50" : "neutral.c100" }, children || value)
|
|
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)))))));
|
|
16
18
|
}
|
|
17
19
|
function SelectableList({ currentValue, onChange, children }) {
|
|
18
20
|
return (React.createElement(Flex, { accessible: true, accessibilityRole: "radiogroup" }, React.Children.map(children, (child, index) => {
|
|
@@ -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
|
|
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;
|
|
@@ -4,5 +4,5 @@ declare type SwitchProps = {
|
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
label?: string;
|
|
6
6
|
};
|
|
7
|
-
declare const Switch: ({ checked, onChange, disabled, label
|
|
7
|
+
declare const Switch: ({ checked, onChange, disabled, label }: SwitchProps) => JSX.Element;
|
|
8
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;
|
|
@@ -4,5 +4,5 @@ declare type ToggleProps = {
|
|
|
4
4
|
onPress: () => void;
|
|
5
5
|
children: ButtonProps["children"];
|
|
6
6
|
};
|
|
7
|
-
export default function Toggle({ active, children, onPress
|
|
7
|
+
export default function Toggle({ active, children, onPress }: ToggleProps): JSX.Element;
|
|
8
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
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { IconOrElementType, IconType } from "./type";
|
|
2
|
+
export declare const DEFAULT_BOX_SIZE = 40;
|
|
3
|
+
export declare const DEFAULT_ICON_SIZE = 16;
|
|
4
|
+
export declare const DEFAULT_BADGE_SIZE = 20;
|
|
5
|
+
export declare type Variant = "square" | "circle";
|
|
6
|
+
export declare type IconBoxProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Component that takes `{size?: number; color?: string}` as props. Will be rendered at the top right with the size provided in `badgeSize` or a default size.
|
|
9
|
+
*/
|
|
10
|
+
Badge?: IconType;
|
|
11
|
+
/**
|
|
12
|
+
* Color of the border
|
|
13
|
+
*/
|
|
14
|
+
borderColor?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Badge color, will be applied to the component provided in the `Badge` prop
|
|
17
|
+
*/
|
|
18
|
+
badgeColor?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Badge size, will be applied to the component provided in the `Badge` prop
|
|
21
|
+
*/
|
|
22
|
+
badgeSize?: number;
|
|
23
|
+
children?: JSX.Element;
|
|
24
|
+
/**
|
|
25
|
+
* Box size for preview
|
|
26
|
+
*/
|
|
27
|
+
size?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Box variant (box or circled)
|
|
30
|
+
*/
|
|
31
|
+
variant?: Variant;
|
|
32
|
+
};
|
|
33
|
+
export declare type BoxedIconProps = IconBoxProps & {
|
|
34
|
+
/**
|
|
35
|
+
* Component that takes `{size?: number; color?: string}` as props. Will be rendered at the top right with the size provided in `iconSize` or a default size.
|
|
36
|
+
*/
|
|
37
|
+
Icon: IconOrElementType;
|
|
38
|
+
/**
|
|
39
|
+
* Icon size, will be applied to the component provided in the `Icon` prop
|
|
40
|
+
*/
|
|
41
|
+
iconSize?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Icon color, will be applied to the component provided in the `Icon` prop
|
|
44
|
+
*/
|
|
45
|
+
iconColor?: string;
|
|
46
|
+
};
|
|
47
|
+
export declare const IconBox: ({ Badge, size, children, borderColor, badgeColor, badgeSize, variant, }: IconBoxProps) => JSX.Element;
|
|
48
|
+
declare const BoxedIcon: ({ Icon, iconSize, iconColor, ...iconBoxProps }: BoxedIconProps) => JSX.Element;
|
|
49
|
+
export default BoxedIcon;
|
|
@@ -0,0 +1,85 @@
|
|
|
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, { useTheme } from "styled-components/native";
|
|
14
|
+
import { PixelRatio } from "react-native";
|
|
15
|
+
import { Rect, ClipPath, Svg, Defs } from "react-native-svg";
|
|
16
|
+
import Flex from "../Layout/Flex";
|
|
17
|
+
import Box from "../Layout/Box";
|
|
18
|
+
export const DEFAULT_BOX_SIZE = 40;
|
|
19
|
+
export const DEFAULT_ICON_SIZE = 16;
|
|
20
|
+
export const DEFAULT_BADGE_SIZE = 20;
|
|
21
|
+
const BORDER_RADIUS = 2;
|
|
22
|
+
function getClipRectangleSize(badgeSize) {
|
|
23
|
+
return (3 / 4) * badgeSize;
|
|
24
|
+
}
|
|
25
|
+
const Container = styled(Flex).attrs((p) => ({
|
|
26
|
+
heigth: p.size,
|
|
27
|
+
width: p.size,
|
|
28
|
+
alignItems: "center",
|
|
29
|
+
justifyContent: "center",
|
|
30
|
+
position: "relative",
|
|
31
|
+
overflow: "visible",
|
|
32
|
+
})) ``;
|
|
33
|
+
const IconBoxBackground = styled(Flex) `
|
|
34
|
+
position: absolute;
|
|
35
|
+
height: ${(p) => p.size}px;
|
|
36
|
+
width: ${(p) => p.size}px;
|
|
37
|
+
border-radius: ${(p) => (p.variant === "circle" ? p.size : p.theme.radii[BORDER_RADIUS])}px;
|
|
38
|
+
`;
|
|
39
|
+
const BadgeContainer = styled.View `
|
|
40
|
+
position: absolute;
|
|
41
|
+
overflow: visible;
|
|
42
|
+
${(p) => `
|
|
43
|
+
top: -${p.badgeSize / 2 - 2}px;
|
|
44
|
+
right: -${p.badgeSize / 2 - 2}px;
|
|
45
|
+
height: ${p.badgeSize}px;
|
|
46
|
+
width: ${p.badgeSize}px;`}
|
|
47
|
+
`;
|
|
48
|
+
/** This component is needed to draw a border that is clipped behind the badge icon */
|
|
49
|
+
const IconBoxBackgroundSVG = ({ size, borderColor, badgeSize, variant = "square", }) => {
|
|
50
|
+
const { colors, radii } = useTheme();
|
|
51
|
+
const borderRadius = radii[BORDER_RADIUS];
|
|
52
|
+
const borderWidth = 1;
|
|
53
|
+
const paletteStr = borderColor.split(".")[0];
|
|
54
|
+
// @ts-expect-error idk how to handle this properly pls help
|
|
55
|
+
const palette = colors[paletteStr];
|
|
56
|
+
const strokeColor = (palette ? palette[borderColor.split(".")[1]] : borderColor) || colors.neutral.c40;
|
|
57
|
+
const squareSize = getClipRectangleSize(badgeSize);
|
|
58
|
+
/**
|
|
59
|
+
* The following adjustments are necessary to have visual consistency
|
|
60
|
+
* between RN (native) Views with border and this component
|
|
61
|
+
*/
|
|
62
|
+
const svgSize = size + borderWidth;
|
|
63
|
+
const rectSize = size - borderWidth;
|
|
64
|
+
const rectRadius = variant === "circle" ? size : borderRadius - borderWidth / 2;
|
|
65
|
+
return (React.createElement(Box, { position: "absolute", overflow: "hidden" },
|
|
66
|
+
React.createElement(Svg, { height: svgSize, width: svgSize },
|
|
67
|
+
React.createElement(Defs, null,
|
|
68
|
+
React.createElement(ClipPath, { id: "clip" },
|
|
69
|
+
React.createElement(Rect, { x: "0", y: "0", width: svgSize - squareSize, height: squareSize }),
|
|
70
|
+
React.createElement(Rect, { x: "0", y: squareSize, width: "100%", height: svgSize - squareSize }))),
|
|
71
|
+
React.createElement(Rect, { strokeWidth: PixelRatio.roundToNearestPixel(borderWidth), stroke: strokeColor, x: borderWidth, y: borderWidth, rx: rectRadius, ry: rectRadius, width: rectSize, height: rectSize, fill: "transparent", clipPath: "url(#clip)" }))));
|
|
72
|
+
};
|
|
73
|
+
export const IconBox = ({ Badge, size = DEFAULT_BOX_SIZE, children, borderColor = "neutral.c40", badgeColor, badgeSize = DEFAULT_BADGE_SIZE, variant = "square", }) => {
|
|
74
|
+
const hasBadge = !!Badge;
|
|
75
|
+
return (React.createElement(Container, { size: size },
|
|
76
|
+
hasBadge ? (React.createElement(IconBoxBackgroundSVG, { size: size, badgeSize: badgeSize, borderColor: borderColor, variant: variant })) : (React.createElement(IconBoxBackground, { border: "1px solid", size: size, borderColor: borderColor, variant: variant })),
|
|
77
|
+
children,
|
|
78
|
+
hasBadge && (React.createElement(BadgeContainer, { badgeSize: badgeSize },
|
|
79
|
+
React.createElement(Badge, { size: badgeSize, color: badgeColor })))));
|
|
80
|
+
};
|
|
81
|
+
const BoxedIcon = (_a) => {
|
|
82
|
+
var { Icon, iconSize = DEFAULT_ICON_SIZE, iconColor } = _a, iconBoxProps = __rest(_a, ["Icon", "iconSize", "iconColor"]);
|
|
83
|
+
return (React.createElement(IconBox, Object.assign({}, iconBoxProps), React.isValidElement(Icon) ? (Icon) : (React.createElement(Icon, { size: iconSize || DEFAULT_ICON_SIZE, color: iconColor }))));
|
|
84
|
+
};
|
|
85
|
+
export default BoxedIcon;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare type Props = {
|
|
2
|
+
name: string;
|
|
3
|
+
size?: number;
|
|
4
|
+
weight?: "Regular" | "Thin" | "Light" | "Medium" | "UltraLight";
|
|
5
|
+
color?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const iconNames: string[];
|
|
8
|
+
declare const Icon: ({ name, size, color, weight, }: Props) => JSX.Element | null;
|
|
9
|
+
export default Icon;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as icons from "@ledgerhq/icons-ui/native";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export const iconNames = Array.from(Object.keys(icons).reduce((set, rawKey) => {
|
|
4
|
+
const key = rawKey
|
|
5
|
+
.replace(/(.+)(Regular|Light|UltraLight|Thin|Medium)+$/g, "$1")
|
|
6
|
+
.replace(/(.+)(Ultra)+$/g, "$1");
|
|
7
|
+
if (!set.has(key))
|
|
8
|
+
set.add(key);
|
|
9
|
+
return set;
|
|
10
|
+
}, new Set()));
|
|
11
|
+
const Icon = ({ name, size = 16, color = "currentColor", weight = "Medium", }) => {
|
|
12
|
+
const maybeIconName = `${name}${weight}`;
|
|
13
|
+
if (maybeIconName in icons) {
|
|
14
|
+
// @ts-expect-error FIXME I don't know how to make you happy ts
|
|
15
|
+
const Component = icons[maybeIconName];
|
|
16
|
+
return React.createElement(Component, { size: size, color: color });
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
20
|
+
export default Icon;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { IconOrElementType } from "../type";
|
|
3
|
+
import { FlexBoxProps } from "../../Layout/Flex";
|
|
2
4
|
declare type Props = {
|
|
3
|
-
Icon:
|
|
4
|
-
size?: number;
|
|
5
|
-
color?: string;
|
|
6
|
-
}) => React.ReactElement;
|
|
5
|
+
Icon: IconOrElementType;
|
|
7
6
|
color?: string;
|
|
8
7
|
boxSize?: number;
|
|
9
8
|
iconSize?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Additional props to pass to the container component.
|
|
11
|
+
* This component is a Flex element.
|
|
12
|
+
*/
|
|
13
|
+
iconContainerProps?: FlexBoxProps;
|
|
10
14
|
};
|
|
11
|
-
export default function IconBox({ Icon, color, boxSize, iconSize, }: Props): React.ReactElement;
|
|
15
|
+
export default function IconBox({ Icon, color, boxSize, iconSize, iconContainerProps, }: Props): React.ReactElement;
|
|
12
16
|
export {};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import styled, { useTheme } from "styled-components/native";
|
|
3
|
+
import Flex from "../../Layout/Flex";
|
|
3
4
|
const DEFAULT_BOX_SIZE = 56;
|
|
4
5
|
const DEFAULT_ICON_SIZE = 24;
|
|
5
|
-
const IconContainer = styled.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
const IconContainer = styled(Flex).attrs(({ size = DEFAULT_BOX_SIZE }) => ({
|
|
7
|
+
justifyContent: "center",
|
|
8
|
+
alignItems: "center",
|
|
9
|
+
borderWidth: "1px",
|
|
10
|
+
borderColor: "neutral.c40",
|
|
11
|
+
width: `${size}px`,
|
|
12
|
+
height: `${size}px`,
|
|
13
|
+
})) `
|
|
13
14
|
border-radius: ${(p) => `${p.theme.radii[1]}px`};
|
|
14
15
|
`;
|
|
15
|
-
export default function IconBox({ Icon, color, boxSize = DEFAULT_BOX_SIZE, iconSize = DEFAULT_ICON_SIZE, }) {
|
|
16
|
+
export default function IconBox({ Icon, color, boxSize = DEFAULT_BOX_SIZE, iconSize = DEFAULT_ICON_SIZE, iconContainerProps, }) {
|
|
16
17
|
const { colors } = useTheme();
|
|
17
|
-
return (React.createElement(IconContainer, { size: boxSize },
|
|
18
|
-
React.createElement(Icon, { size: iconSize, color: color || colors.neutral.c100 })));
|
|
18
|
+
return (React.createElement(IconContainer, Object.assign({ size: boxSize }, iconContainerProps), React.isValidElement(Icon) ? (Icon) : (React.createElement(Icon, { size: iconSize, color: color || colors.neutral.c100 }))));
|
|
19
19
|
}
|
package/components/Icon/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
2
|
import Animated, { useSharedValue, withTiming, useAnimatedStyle, Easing, } from "react-native-reanimated";
|
|
3
3
|
import Link from "../../../cta/Link";
|
|
4
|
-
import { ChevronBottomMedium, ChevronTopMedium
|
|
4
|
+
import { ChevronBottomMedium, ChevronTopMedium } from "@ledgerhq/icons-ui/native";
|
|
5
5
|
import { View } from "react-native";
|
|
6
6
|
const Accordion = ({ collapsed = false, children, title, onPress, }) => {
|
|
7
7
|
const animationHeight = useSharedValue(collapsed ? "0%" : "100%");
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseListItemProps, BaseListProps } from "../List";
|
|
3
|
+
import { IconType } from "../../../Icon/type";
|
|
4
|
+
export declare type IconBoxListItemProps = Omit<BaseListItemProps, "bullet"> & {
|
|
5
|
+
Icon: IconType;
|
|
6
|
+
};
|
|
7
|
+
export declare type IconBoxListProps = Omit<BaseListProps, "items"> & {
|
|
8
|
+
items: IconBoxListItemProps[];
|
|
9
|
+
};
|
|
10
|
+
export default function IconBoxList({ items, ...props }: IconBoxListProps): React.ReactElement;
|
|
@@ -0,0 +1,19 @@
|
|
|
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 { IconBox } from "../../../Icon";
|
|
15
|
+
export default function IconBoxList(_a) {
|
|
16
|
+
var { items } = _a, props = __rest(_a, ["items"]);
|
|
17
|
+
const iconBoxItems = useMemo(() => items.map((item) => (Object.assign(Object.assign({}, item), { bullet: React.createElement(IconBox, { Icon: item.Icon, boxSize: 48, iconSize: 20 }) }))), [items]);
|
|
18
|
+
return React.createElement(List, Object.assign({ items: iconBoxItems }, props));
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseStyledProps } from "../../../styled";
|
|
3
|
+
export declare type BaseListItemProps = {
|
|
4
|
+
title?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
bullet?: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export declare type BaseListProps = {
|
|
9
|
+
items: BaseListItemProps[];
|
|
10
|
+
itemContainerProps?: BaseStyledProps;
|
|
11
|
+
};
|
|
12
|
+
export declare const ListItem: ({ title, description, bullet, ...props }: BaseStyledProps & BaseListItemProps) => React.ReactElement;
|
|
13
|
+
export default function List({ items, itemContainerProps, ...props }: BaseListProps): React.ReactElement;
|
|
@@ -0,0 +1,29 @@
|
|
|
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, { useCallback } from "react";
|
|
13
|
+
import Text from "../../../Text";
|
|
14
|
+
import { Box, Flex } from "../../index";
|
|
15
|
+
import { FlatList } from "react-native";
|
|
16
|
+
export const ListItem = (_a) => {
|
|
17
|
+
var { title, description, bullet = null } = _a, props = __rest(_a, ["title", "description", "bullet"]);
|
|
18
|
+
return (React.createElement(Flex, Object.assign({ flexDirection: "row", alignItems: "center" }, props),
|
|
19
|
+
bullet && (React.createElement(Box, { mr: 7, flexShrink: 0 }, bullet)),
|
|
20
|
+
React.createElement(Flex, { flexDirection: "column", flexShrink: 1, flexWrap: "nowrap" },
|
|
21
|
+
title && (React.createElement(Text, { variant: "body", fontWeight: "semiBold", color: "neutral.c100", flexShrink: 1, mb: description ? 2 : null }, title)),
|
|
22
|
+
description && (React.createElement(Text, { variant: "body", fontWeight: "medium", color: "neutral.c80", flexShrink: 1 }, description)))));
|
|
23
|
+
};
|
|
24
|
+
export default function List(_a) {
|
|
25
|
+
var { items, itemContainerProps } = _a, props = __rest(_a, ["items", "itemContainerProps"]);
|
|
26
|
+
const renderItem = useCallback(({ item }) => (React.createElement(ListItem, Object.assign({}, item, { mb: 6, pb: 2 }, itemContainerProps))), [itemContainerProps]);
|
|
27
|
+
return (React.createElement(Flex, Object.assign({ flexDirection: "column" }, props),
|
|
28
|
+
React.createElement(FlatList, { data: items, renderItem: renderItem })));
|
|
29
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseListItemProps, BaseListProps } from "../List";
|
|
3
|
+
export declare type NumberedListItemProps = Omit<BaseListItemProps, "bullet"> & {
|
|
4
|
+
number?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare type NumberedListProps = Omit<BaseListProps, "items"> & {
|
|
7
|
+
items: NumberedListItemProps[];
|
|
8
|
+
};
|
|
9
|
+
export default function NumberedList({ items, ...props }: NumberedListProps): React.ReactElement;
|
|
@@ -0,0 +1,23 @@
|
|
|
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 { IconBox } from "../../../Icon";
|
|
15
|
+
import Text from "../../../Text";
|
|
16
|
+
export default function NumberedList(_a) {
|
|
17
|
+
var { items } = _a, props = __rest(_a, ["items"]);
|
|
18
|
+
const numberedItems = useMemo(() => items.map((item, index) => {
|
|
19
|
+
var _a;
|
|
20
|
+
return (Object.assign(Object.assign({}, item), { bullet: (React.createElement(IconBox, { Icon: React.createElement(Text, { variant: "body", fontWeight: "medium", color: "neutral.c100" }, (_a = item.number) !== null && _a !== void 0 ? _a : index + 1), boxSize: 36 })) }));
|
|
21
|
+
}), [items]);
|
|
22
|
+
return React.createElement(List, Object.assign({ items: numberedItems }, props));
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseListItemProps, BaseListProps } from "../List";
|
|
3
|
+
export declare type TipListItemProps = Omit<BaseListItemProps, "bullet"> & {
|
|
4
|
+
isPositive: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare type TipListProps = Omit<BaseListProps, "items"> & {
|
|
7
|
+
items: TipListItemProps[];
|
|
8
|
+
};
|
|
9
|
+
export default function TipList({ items, ...props }: TipListProps): React.ReactElement;
|