@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
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { TextProps } from "react-native";
|
|
3
|
-
import { FontSizeProps, TextAlignProps,
|
|
2
|
+
import { TextProps, TextStyle } from "react-native";
|
|
3
|
+
import { FontSizeProps, TextAlignProps, LineHeightProps } from "styled-system";
|
|
4
|
+
import { BaseStyledProps } from "../styled";
|
|
4
5
|
import { FontWeightTypes } from "./getTextStyle";
|
|
5
6
|
import { TextVariants } from "../../styles/theme";
|
|
6
|
-
export interface BaseTextProps extends TextProps, FontSizeProps, TextAlignProps,
|
|
7
|
+
export interface BaseTextProps extends TextProps, BaseStyledProps, FontSizeProps, TextAlignProps, LineHeightProps {
|
|
7
8
|
variant?: TextVariants;
|
|
8
9
|
fontWeight?: FontWeightTypes;
|
|
9
10
|
fontFamily?: string;
|
|
10
11
|
fontSize?: number | string | TextVariants;
|
|
11
12
|
color?: string;
|
|
12
|
-
|
|
13
|
-
mb?: number | string;
|
|
14
|
-
ml?: number | string;
|
|
15
|
-
mr?: number | string;
|
|
16
|
-
paddingTop?: number;
|
|
17
|
-
lineHeight?: number;
|
|
13
|
+
lineHeight?: number | string;
|
|
18
14
|
bracket?: boolean;
|
|
15
|
+
textTransform?: TextStyle["textTransform"];
|
|
16
|
+
uppercase?: boolean;
|
|
19
17
|
children: React.ReactNode;
|
|
20
18
|
}
|
|
21
19
|
declare const Text: ({ children, bracket, ...props }: BaseTextProps) => JSX.Element;
|
package/components/Text/index.js
CHANGED
|
@@ -11,12 +11,24 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import React from "react";
|
|
13
13
|
import styled, { useTheme } from "styled-components/native";
|
|
14
|
-
import { fontSize, textAlign,
|
|
14
|
+
import { compose, fontSize, textAlign, lineHeight, system, } from "styled-system";
|
|
15
|
+
import baseStyled from "../styled";
|
|
15
16
|
import BracketRight from "../../icons/BracketLeft";
|
|
16
17
|
import BracketLeft from "../../icons/BracketRight";
|
|
17
18
|
import { getColor } from "../../styles";
|
|
18
19
|
import { getTextStyle } from "./getTextStyle";
|
|
19
|
-
const
|
|
20
|
+
const uppercase = system({
|
|
21
|
+
uppercase: {
|
|
22
|
+
property: "textTransform",
|
|
23
|
+
transform: (value) => (value ? "uppercase" : "none"),
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const textTransform = system({
|
|
27
|
+
textTransform: {
|
|
28
|
+
property: "textTransform",
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const Base = baseStyled.Text.attrs((p) => {
|
|
20
32
|
var _a;
|
|
21
33
|
return ({
|
|
22
34
|
fontSize: p.fontSize ? p.fontSize : (_a = p.variant) !== null && _a !== void 0 ? _a : "paragraph",
|
|
@@ -24,12 +36,7 @@ const Base = styled.Text.attrs((p) => {
|
|
|
24
36
|
});
|
|
25
37
|
}) `
|
|
26
38
|
${(p) => getTextStyle(p)}
|
|
27
|
-
${lineHeight}
|
|
28
|
-
${fontSize};
|
|
29
|
-
${textAlign};
|
|
30
|
-
${color};
|
|
31
|
-
${space};
|
|
32
|
-
${border};
|
|
39
|
+
${compose(lineHeight, fontSize, textAlign, uppercase, textTransform)}
|
|
33
40
|
justify-content: center;
|
|
34
41
|
align-items: center;
|
|
35
42
|
`;
|
|
@@ -7,6 +7,7 @@ export declare type ButtonProps = TouchableOpacityProps & BaseStyledProps & {
|
|
|
7
7
|
size: number;
|
|
8
8
|
color: string;
|
|
9
9
|
}> | null;
|
|
10
|
+
iconName?: string;
|
|
10
11
|
type?: "main" | "shade" | "error" | "color" | "default";
|
|
11
12
|
size?: "small" | "medium" | "large";
|
|
12
13
|
iconPosition?: "right" | "left";
|
|
@@ -7,19 +7,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import React, { useCallback, useState } from "react";
|
|
10
|
+
import React, { useCallback, useState, useMemo } from "react";
|
|
11
11
|
import styled, { useTheme } from "styled-components/native";
|
|
12
|
-
import { ActivityIndicator, TouchableOpacity
|
|
13
|
-
import { buttonSizeStyle, getButtonColorStyle
|
|
12
|
+
import { ActivityIndicator, TouchableOpacity } from "react-native";
|
|
13
|
+
import { buttonSizeStyle, getButtonColorStyle } from "../../cta/Button/getButtonStyle";
|
|
14
14
|
import { ctaIconSize, ctaTextType } from "../../cta/getCtaStyle";
|
|
15
15
|
import Text from "../../Text";
|
|
16
|
+
import { Icon as IconComponent } from "../../Icon";
|
|
16
17
|
import baseStyled from "../../styled";
|
|
17
18
|
const IconContainer = styled.View `
|
|
18
|
-
${(p) => p.iconButton
|
|
19
|
-
? ""
|
|
20
|
-
: p.iconPosition === "left"
|
|
21
|
-
? `margin-right: 10px;`
|
|
22
|
-
: `margin-left: 10px;`}
|
|
19
|
+
${(p) => p.iconButton ? "" : p.iconPosition === "left" ? `margin-right: 10px;` : `margin-left: 10px;`}
|
|
23
20
|
`;
|
|
24
21
|
export const Base = baseStyled(TouchableOpacity).attrs((p) => (Object.assign(Object.assign({}, getButtonColorStyle(p.theme.colors, p).button), {
|
|
25
22
|
// Avoid conflict with styled-system's size property by nulling size and renaming it
|
|
@@ -58,13 +55,14 @@ const SpinnerContainer = styled.View `
|
|
|
58
55
|
justify-content: center;
|
|
59
56
|
`;
|
|
60
57
|
const ButtonContainer = (props) => {
|
|
61
|
-
const { Icon, iconPosition = "right", children, hide = false, size = "medium", } = props;
|
|
58
|
+
const { Icon, iconPosition = "right", children, hide = false, size = "medium", iconName } = props;
|
|
62
59
|
const theme = useTheme();
|
|
63
60
|
const { text } = getButtonColorStyle(theme.colors, props);
|
|
61
|
+
const IconNode = useMemo(() => (iconName && React.createElement(IconComponent, { name: iconName, size: ctaIconSize[size], color: text.color })) ||
|
|
62
|
+
(Icon && React.createElement(Icon, { size: ctaIconSize[size], color: text.color })), [iconName, size, Icon, text.color]);
|
|
64
63
|
return (React.createElement(Container, { hide: hide },
|
|
65
64
|
iconPosition === "right" && children ? (React.createElement(Text, { variant: ctaTextType[size], fontWeight: "semiBold", color: text.color }, children)) : null,
|
|
66
|
-
|
|
67
|
-
React.createElement(Icon, { size: ctaIconSize[size], color: text.color }))) : null,
|
|
65
|
+
IconNode && (React.createElement(IconContainer, { iconButton: !children, iconPosition: iconPosition }, IconNode)),
|
|
68
66
|
iconPosition === "left" && children ? (React.createElement(Text, { variant: ctaTextType[size], fontWeight: "semiBold", color: text.color }, children)) : null));
|
|
69
67
|
};
|
|
70
68
|
const Button = (props) => {
|
|
@@ -5,11 +5,7 @@ import Text from "../../Text";
|
|
|
5
5
|
import { getLinkColors } from "./getLinkStyle";
|
|
6
6
|
import { ctaIconSize, ctaTextType } from "../getCtaStyle";
|
|
7
7
|
const IconContainer = styled.View `
|
|
8
|
-
${(p) => p.iconLink
|
|
9
|
-
? ""
|
|
10
|
-
: p.iconPosition === "left"
|
|
11
|
-
? `margin-right: 6px;`
|
|
12
|
-
: `margin-left: 6px;`}
|
|
8
|
+
${(p) => p.iconLink ? "" : p.iconPosition === "left" ? `margin-right: 6px;` : `margin-left: 6px;`}
|
|
13
9
|
`;
|
|
14
10
|
export const Base = styled(TouchableOpacity) `
|
|
15
11
|
flex-direction: row;
|
package/components/index.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ export * from "./cta";
|
|
|
2
2
|
export * from "./Form";
|
|
3
3
|
export * from "./Icon";
|
|
4
4
|
export * from "./Layout";
|
|
5
|
-
export { default as Loader } from "./Loader";
|
|
6
5
|
export * from "./message";
|
|
7
6
|
export * from "./Navigation";
|
|
8
7
|
export * from "./tags";
|
|
9
8
|
export { default as Text } from "./Text";
|
|
10
9
|
export { default as Carousel } from "./Carousel";
|
|
11
10
|
export * from "./Tabs";
|
|
11
|
+
export * from "./Loader";
|
|
12
12
|
export { default as ProgressBar } from "./ProgressBar";
|
|
13
13
|
export * as Transitions from "./transitions";
|
package/components/index.js
CHANGED
|
@@ -2,13 +2,13 @@ export * from "./cta";
|
|
|
2
2
|
export * from "./Form";
|
|
3
3
|
export * from "./Icon";
|
|
4
4
|
export * from "./Layout";
|
|
5
|
-
export { default as Loader } from "./Loader";
|
|
6
5
|
export * from "./message";
|
|
7
6
|
export * from "./Navigation";
|
|
8
7
|
export * from "./tags";
|
|
9
8
|
export { default as Text } from "./Text";
|
|
10
9
|
export { default as Carousel } from "./Carousel";
|
|
11
10
|
export * from "./Tabs";
|
|
11
|
+
export * from "./Loader";
|
|
12
12
|
export { default as ProgressBar } from "./ProgressBar";
|
|
13
13
|
import * as Transitions_1 from "./transitions";
|
|
14
14
|
export { Transitions_1 as Transitions };
|
|
@@ -39,10 +39,10 @@ const StyledAlertContainer = styled(FlexBox).attrs((p) => ({
|
|
|
39
39
|
flex-direction: row;
|
|
40
40
|
align-items: center;
|
|
41
41
|
`;
|
|
42
|
-
export default function Alert({ type = "info", title, showIcon = true
|
|
42
|
+
export default function Alert({ type = "info", title, showIcon = true }) {
|
|
43
43
|
const theme = useTheme();
|
|
44
44
|
const textColor = getColor(theme, alertColors[type || "info"].color);
|
|
45
45
|
return (React.createElement(StyledAlertContainer, { type: type },
|
|
46
46
|
showIcon && !!icons[type] && (React.createElement(StyledIconContainer, null, icons[type || "info"]({ size: 20, color: textColor }))),
|
|
47
|
-
React.createElement(Text, { color: textColor }, title)));
|
|
47
|
+
React.createElement(Text, { color: textColor, flexShrink: 1 }, title)));
|
|
48
48
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import styled, { useTheme } from "styled-components/native";
|
|
3
3
|
import FlexBox from "../../Layout/Flex";
|
|
4
|
-
import { TouchableOpacity
|
|
4
|
+
import { TouchableOpacity } from "react-native";
|
|
5
5
|
import Text from "../../Text";
|
|
6
6
|
import CloseMedium from "@ledgerhq/icons-ui/native/CloseMedium";
|
|
7
7
|
import { Flex } from "../../Layout";
|
|
@@ -8,4 +8,4 @@ export interface SlideProps extends TransitionProps {
|
|
|
8
8
|
/**
|
|
9
9
|
* A slide left/right transition translating its children based on their status and a given direction.
|
|
10
10
|
*/
|
|
11
|
-
export declare function Slide({ status, duration, style, direction, children
|
|
11
|
+
export declare function Slide({ status, duration, style, direction, children }: SlideProps): JSX.Element;
|
|
@@ -4,7 +4,7 @@ const WEB = Platform.OS === "web";
|
|
|
4
4
|
/**
|
|
5
5
|
* A slide left/right transition translating its children based on their status and a given direction.
|
|
6
6
|
*/
|
|
7
|
-
export function Slide({ status, duration, style, direction = "left", children
|
|
7
|
+
export function Slide({ status, duration, style, direction = "left", children }) {
|
|
8
8
|
const [width, setWidth] = useState(Dimensions.get("window").width);
|
|
9
9
|
const styleRef = useRef(new Animated.Value(0)).current;
|
|
10
10
|
const previousStatus = useRef(null);
|
|
@@ -10,8 +10,7 @@ export function Transition({ in: inValue, timeout, mountOnEnter, unmountOnExit,
|
|
|
10
10
|
const canMount = useRef(!mountOnEnter);
|
|
11
11
|
canMount.current = canMount.current || inValue;
|
|
12
12
|
useEffect(() => {
|
|
13
|
-
if ((inValue && status === "entered") ||
|
|
14
|
-
(!inValue && status === "exited")) {
|
|
13
|
+
if ((inValue && status === "entered") || (!inValue && status === "exited")) {
|
|
15
14
|
return;
|
|
16
15
|
}
|
|
17
16
|
if (inValue && !enter) {
|
|
@@ -20,9 +19,7 @@ export function Transition({ in: inValue, timeout, mountOnEnter, unmountOnExit,
|
|
|
20
19
|
if (!inValue && !exit) {
|
|
21
20
|
return setStatus("exited");
|
|
22
21
|
}
|
|
23
|
-
const timeoutValue = typeof timeout === "number"
|
|
24
|
-
? timeout
|
|
25
|
-
: timeout[inValue ? "enter" : "exit"];
|
|
22
|
+
const timeoutValue = typeof timeout === "number" ? timeout : timeout[inValue ? "enter" : "exit"];
|
|
26
23
|
setStatus(inValue ? "entering" : "exiting");
|
|
27
24
|
const timeoutRef = setTimeout(() => {
|
|
28
25
|
setStatus(inValue ? "entered" : "exited");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/native-ui",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Ledger Live - Desktop UI",
|
|
5
5
|
"repository": "https://github.com/LedgerHQ/ui",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"index.js"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@ledgerhq/icons-ui": "^0.2.
|
|
19
|
-
"@ledgerhq/ui-shared": "^0.1.
|
|
18
|
+
"@ledgerhq/icons-ui": "^0.2.2",
|
|
19
|
+
"@ledgerhq/ui-shared": "^0.1.5",
|
|
20
20
|
"@types/color": "^3.0.2",
|
|
21
21
|
"@types/react": "^17.0.37",
|
|
22
22
|
"@types/react-native": "^0.65.9",
|
|
@@ -9,5 +9,5 @@ declare module "styled-components" {
|
|
|
9
9
|
interface DefaultTheme extends Theme {
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
export declare const StyleProvider: ({ children, selectedPalette
|
|
12
|
+
export declare const StyleProvider: ({ children, selectedPalette }: Props) => React.ReactElement;
|
|
13
13
|
export {};
|
package/styles/StyleProvider.js
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useMemo } from "react";
|
|
|
2
2
|
import { ThemeProvider } from "styled-components/native";
|
|
3
3
|
import defaultTheme from "./theme";
|
|
4
4
|
import { palettes } from "@ledgerhq/ui-shared";
|
|
5
|
-
export const StyleProvider = ({ children, selectedPalette
|
|
5
|
+
export const StyleProvider = ({ children, selectedPalette }) => {
|
|
6
6
|
const theme = useMemo(() => (Object.assign(Object.assign({}, defaultTheme), { colors: Object.assign(Object.assign(Object.assign({}, defaultTheme.colors), palettes[selectedPalette]), { palette: palettes[selectedPalette] }), theme: selectedPalette })), [selectedPalette]);
|
|
7
7
|
return React.createElement(ThemeProvider, { theme: theme }, children);
|
|
8
8
|
};
|
package/styles/helpers.js
CHANGED
|
@@ -5,9 +5,7 @@ export const darken = (c, a) => Color(c).darken(a).toString();
|
|
|
5
5
|
export const lighten = (c, a) => Color(c).lighten(a).toString();
|
|
6
6
|
export const mix = (c, b, a) => Color(c).mix(Color(b), a).toString();
|
|
7
7
|
const get = (object, path) => {
|
|
8
|
-
const p = typeof path === "string"
|
|
9
|
-
? path.split(".").filter((key) => key.length)
|
|
10
|
-
: path;
|
|
8
|
+
const p = typeof path === "string" ? path.split(".").filter((key) => key.length) : path;
|
|
11
9
|
return p.reduce((dive, key) => dive && dive[key], object);
|
|
12
10
|
};
|
|
13
11
|
export const getColor = (p, color) => {
|