@ledgerhq/native-ui 0.2.0 → 0.6.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.
Files changed (96) hide show
  1. package/README.md +16 -18
  2. package/assets/logos/LedgerLiveAltRegular.d.ts +0 -1
  3. package/assets/logos/LedgerLiveRegular.d.ts +0 -1
  4. package/components/Carousel/index.d.ts +45 -0
  5. package/components/Carousel/index.js +76 -0
  6. package/components/Form/Checkbox/index.d.ts +2 -2
  7. package/components/Form/Checkbox/index.js +5 -5
  8. package/components/Form/Input/BaseInput/index.d.ts +104 -7
  9. package/components/Form/Input/BaseInput/index.js +25 -17
  10. package/components/Form/Input/LegendInput/index.d.ts +14 -3
  11. package/components/Form/Input/LegendInput/index.js +4 -3
  12. package/components/Form/Input/NumberInput/index.d.ts +16 -5
  13. package/components/Form/Input/NumberInput/index.js +17 -9
  14. package/components/Form/Input/QrCodeInput/index.d.ts +15 -4
  15. package/components/Form/Input/QrCodeInput/index.js +5 -4
  16. package/components/Form/Input/SearchInput/index.d.ts +13 -2
  17. package/components/Form/Input/SearchInput/index.js +4 -3
  18. package/components/Form/SelectableList.d.ts +22 -0
  19. package/components/Form/SelectableList.js +31 -0
  20. package/components/Form/Slider/components.js +6 -6
  21. package/components/Form/Slider/index.d.ts +0 -1
  22. package/components/Form/Slider/index.native.d.ts +0 -1
  23. package/components/Form/Slider/index.native.js +2 -2
  24. package/components/Form/Switch/index.d.ts +0 -1
  25. package/components/Form/Switch/index.js +4 -4
  26. package/components/Form/Toggle/index.d.ts +0 -1
  27. package/components/Form/index.d.ts +2 -0
  28. package/components/Form/index.js +2 -0
  29. package/components/Icon/IconBox/index.js +2 -2
  30. package/components/Layout/Box/index.d.ts +11 -0
  31. package/components/Layout/Box/index.js +3 -0
  32. package/components/Layout/Flex/index.d.ts +11 -12
  33. package/components/Layout/Flex/index.js +2 -8
  34. package/components/Layout/Modals/BaseModal/index.js +4 -4
  35. package/components/Layout/ScrollContainerHeader/Header.d.ts +0 -1
  36. package/components/Layout/ScrollContainerHeader/Header.js +1 -1
  37. package/components/Layout/index.d.ts +3 -0
  38. package/components/Layout/index.js +3 -0
  39. package/components/Loader/index.js +2 -2
  40. package/components/Navigation/FlowStepper/index.d.ts +64 -0
  41. package/components/Navigation/FlowStepper/index.js +38 -0
  42. package/components/Navigation/SlideIndicator/index.js +15 -8
  43. package/components/Navigation/Stepper/index.js +12 -12
  44. package/components/Navigation/index.d.ts +1 -0
  45. package/components/Navigation/index.js +1 -0
  46. package/components/ProgressBar/index.d.ts +15 -0
  47. package/components/ProgressBar/index.js +33 -0
  48. package/components/Tabs/Chip/index.d.ts +5 -0
  49. package/components/Tabs/Chip/index.js +20 -0
  50. package/components/Tabs/Graph/index.d.ts +5 -0
  51. package/components/Tabs/Graph/index.js +21 -0
  52. package/components/Tabs/TemplateTabs/index.d.ts +29 -0
  53. package/components/Tabs/TemplateTabs/index.js +14 -0
  54. package/components/Tabs/index.d.ts +2 -0
  55. package/components/Tabs/index.js +2 -0
  56. package/components/Text/index.js +2 -2
  57. package/components/chart/index.d.ts +0 -1
  58. package/components/chart/index.js +6 -6
  59. package/components/cta/Button/getButtonStyle.js +12 -12
  60. package/components/cta/Button/index.d.ts +4 -15
  61. package/components/cta/Button/index.js +13 -14
  62. package/components/cta/Link/getLinkStyle.js +8 -8
  63. package/components/index.d.ts +4 -1
  64. package/components/index.js +5 -1
  65. package/components/message/Alert/index.d.ts +0 -1
  66. package/components/message/Alert/index.js +6 -6
  67. package/components/{drawer → message}/Notification/index.d.ts +5 -4
  68. package/components/message/Notification/index.js +35 -0
  69. package/components/message/index.d.ts +1 -0
  70. package/components/message/index.js +1 -0
  71. package/components/styled.d.ts +15 -0
  72. package/components/styled.js +12 -0
  73. package/components/tags/Badge/index.js +7 -7
  74. package/components/transitions/Fade.d.ts +5 -0
  75. package/components/transitions/Fade.js +32 -0
  76. package/components/transitions/Slide.d.ts +11 -0
  77. package/components/transitions/Slide.js +49 -0
  78. package/components/transitions/Transition.d.ts +49 -0
  79. package/components/transitions/Transition.js +42 -0
  80. package/components/transitions/index.d.ts +4 -0
  81. package/components/transitions/index.js +4 -0
  82. package/components/transitions/types.d.ts +21 -0
  83. package/components/transitions/types.js +1 -0
  84. package/icons/Close.js +1 -1
  85. package/package.json +8 -10
  86. package/styles/InvertTheme.d.ts +0 -1
  87. package/styles/StyleProvider.js +1 -1
  88. package/styles/theme.d.ts +4 -1
  89. package/styles/theme.js +3 -3
  90. package/assets/fonts/.DS_Store +0 -0
  91. package/assets/fonts/alpha/.DS_Store +0 -0
  92. package/components/Navigation/ToggleGroup/index.d.ts +0 -15
  93. package/components/Navigation/ToggleGroup/index.js +0 -25
  94. package/components/drawer/Notification/index.js +0 -37
  95. package/components/drawer/index.d.ts +0 -1
  96. package/components/drawer/index.js +0 -1
@@ -0,0 +1,49 @@
1
+ import React, { useState, useRef, useEffect, useMemo } from "react";
2
+ import { Animated, Platform, Dimensions } from "react-native";
3
+ const WEB = Platform.OS === "web";
4
+ /**
5
+ * A slide left/right transition translating its children based on their status and a given direction.
6
+ */
7
+ export function Slide({ status, duration, style, direction = "left", children, }) {
8
+ const [width, setWidth] = useState(Dimensions.get("window").width);
9
+ const styleRef = useRef(new Animated.Value(0)).current;
10
+ const previousStatus = useRef(null);
11
+ useEffect(() => () => {
12
+ previousStatus.current = status;
13
+ }, [status]);
14
+ const animateIn = useMemo(() => Animated.timing(styleRef, {
15
+ toValue: 0,
16
+ duration,
17
+ useNativeDriver: true,
18
+ }), [duration, styleRef]);
19
+ const animateOut = useMemo(() => Animated.timing(styleRef, {
20
+ toValue: direction === "left" ? -1 : 1,
21
+ duration,
22
+ useNativeDriver: true,
23
+ }), [direction, duration, styleRef]);
24
+ useEffect(() => {
25
+ if (status === "entering") {
26
+ if (previousStatus.current !== "exiting") {
27
+ styleRef.setValue(direction === "left" ? 1 : -1);
28
+ }
29
+ animateIn.start();
30
+ }
31
+ if (status === "exiting") {
32
+ animateOut.start();
33
+ }
34
+ // eslint-disable-next-line react-hooks/exhaustive-deps
35
+ }, [status]);
36
+ return (React.createElement(Animated.View, { style: [
37
+ {
38
+ transform: [
39
+ {
40
+ translateX: styleRef.interpolate({
41
+ inputRange: [-1, 1],
42
+ outputRange: WEB ? ["-100%", "100%"] : [-width, width],
43
+ }),
44
+ },
45
+ ],
46
+ },
47
+ style,
48
+ ], onLayout: ({ nativeEvent }) => setWidth(nativeEvent.layout.width) }, children));
49
+ }
@@ -0,0 +1,49 @@
1
+ import { TransitionStatus } from "./index";
2
+ export interface Props {
3
+ /**
4
+ * Show the component. Triggers the enter or exit states.
5
+ */
6
+ in: boolean;
7
+ /**
8
+ * By default the child component is mounted immediately along with the parent Transition component.
9
+ * If you want to "lazy mount" the component on the first in={true} you can set mountOnEnter.
10
+ * After the first enter transition the component will stay mounted, even on "exited",
11
+ * unless you also specify unmountOnExit.
12
+ */
13
+ mountOnEnter?: boolean;
14
+ /**
15
+ * By default the child component stays mounted after it reaches the 'exited' state.
16
+ * Set unmountOnExit if you'd prefer to unmount the component after it finishes exiting.
17
+ */
18
+ unmountOnExit?: boolean;
19
+ /**
20
+ * Enable or disable enter transitions.
21
+ */
22
+ enter?: boolean;
23
+ /**
24
+ * Enable or disable exit transitions.
25
+ */
26
+ exit?: boolean;
27
+ /**
28
+ * The duration of the transition, in milliseconds.
29
+ *
30
+ * You may specify a single timeout for all transitions using a string or or individually using an object.
31
+ */
32
+ timeout: number | {
33
+ enter?: number;
34
+ exit?: number;
35
+ };
36
+ /**
37
+ * A function child can be used instead of a React element.
38
+ * This function is called with the current transition status ('entering', 'entered', 'exiting', 'exited'),
39
+ * which can be used to apply context specific props to a component.
40
+ */
41
+ children: (status: TransitionStatus) => JSX.Element | null;
42
+ }
43
+ /**
44
+ * Mimics the [Transition](https://reactcommunity.org/react-transition-group/transition) component
45
+ * from [react-transition-group](https://reactcommunity.org/react-transition-group).
46
+ *
47
+ * Supports a minimal set of options but works with react-native.
48
+ */
49
+ export declare function Transition({ in: inValue, timeout, mountOnEnter, unmountOnExit, enter, exit, children, }: Props): JSX.Element | null;
@@ -0,0 +1,42 @@
1
+ import { useState, useEffect, useRef, useMemo } from "react";
2
+ /**
3
+ * Mimics the [Transition](https://reactcommunity.org/react-transition-group/transition) component
4
+ * from [react-transition-group](https://reactcommunity.org/react-transition-group).
5
+ *
6
+ * Supports a minimal set of options but works with react-native.
7
+ */
8
+ export function Transition({ in: inValue, timeout, mountOnEnter, unmountOnExit, enter = true, exit = true, children, }) {
9
+ const [status, setStatus] = useState(inValue ? "entered" : "exited");
10
+ const canMount = useRef(!mountOnEnter);
11
+ canMount.current = canMount.current || inValue;
12
+ useEffect(() => {
13
+ if ((inValue && status === "entered") ||
14
+ (!inValue && status === "exited")) {
15
+ return;
16
+ }
17
+ if (inValue && !enter) {
18
+ return setStatus("entered");
19
+ }
20
+ if (!inValue && !exit) {
21
+ return setStatus("exited");
22
+ }
23
+ const timeoutValue = typeof timeout === "number"
24
+ ? timeout
25
+ : timeout[inValue ? "enter" : "exit"];
26
+ setStatus(inValue ? "entering" : "exiting");
27
+ const timeoutRef = setTimeout(() => {
28
+ setStatus(inValue ? "entered" : "exited");
29
+ }, timeoutValue);
30
+ return () => {
31
+ clearTimeout(timeoutRef);
32
+ };
33
+ // eslint-disable-next-line react-hooks/exhaustive-deps
34
+ }, [inValue, timeout]);
35
+ const result = useMemo(() => {
36
+ if (!canMount.current || (unmountOnExit && status === "exited")) {
37
+ return null;
38
+ }
39
+ return children(status);
40
+ }, [children, status, unmountOnExit]);
41
+ return result;
42
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./Fade";
2
+ export * from "./Slide";
3
+ export * from "./types";
4
+ export * from "./Transition";
@@ -0,0 +1,4 @@
1
+ export * from "./Fade";
2
+ export * from "./Slide";
3
+ export * from "./types";
4
+ export * from "./Transition";
@@ -0,0 +1,21 @@
1
+ /// <reference types="react" />
2
+ import { StyleProp, ViewStyle } from "react-native";
3
+ export declare type TransitionStatus = "entering" | "entered" | "exiting" | "exited";
4
+ export interface TransitionProps {
5
+ /**
6
+ * The status of the transition, either "entered", "entering", "exiting" or "exited".
7
+ */
8
+ status: TransitionStatus;
9
+ /**
10
+ * Duration used to transition between statuses.
11
+ */
12
+ duration: number;
13
+ /**
14
+ * Additional styles to pass to the underlying View wrapper.
15
+ */
16
+ style?: StyleProp<ViewStyle>;
17
+ /**
18
+ * Children that will get controlled by the transition.
19
+ */
20
+ children: React.ReactNode;
21
+ }
@@ -0,0 +1 @@
1
+ export {};
package/icons/Close.js CHANGED
@@ -4,5 +4,5 @@ import { useTheme } from "styled-components/native";
4
4
  export default function Close({ size = 16, color }) {
5
5
  const { colors } = useTheme();
6
6
  return (React.createElement(Svg, { viewBox: "0 0 16 16", width: size, height: size },
7
- React.createElement(Path, { fill: color || colors.palette.neutral.c100, d: "M9.65 8.413l4.066-4.065a.375.375 0 0 0 0-.532l-.706-.706a.375.375 0 0 0-.531 0L8.413 7.176 4.348 3.11a.375.375 0 0 0-.532 0l-.706.706a.375.375 0 0 0 0 .532l4.066 4.065L3.11 12.48a.375.375 0 0 0 0 .531l.706.706a.375.375 0 0 0 .532 0l4.065-4.065 4.066 4.065a.375.375 0 0 0 .531 0l.706-.706a.375.375 0 0 0 0-.531L9.651 8.413z" })));
7
+ React.createElement(Path, { fill: color || colors.neutral.c100, d: "M9.65 8.413l4.066-4.065a.375.375 0 0 0 0-.532l-.706-.706a.375.375 0 0 0-.531 0L8.413 7.176 4.348 3.11a.375.375 0 0 0-.532 0l-.706.706a.375.375 0 0 0 0 .532l4.066 4.065L3.11 12.48a.375.375 0 0 0 0 .531l.706.706a.375.375 0 0 0 .532 0l4.065-4.065 4.066 4.065a.375.375 0 0 0 .531 0l.706-.706a.375.375 0 0 0 0-.531L9.651 8.413z" })));
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/native-ui",
3
- "version": "0.2.0",
3
+ "version": "0.6.0",
4
4
  "description": "Ledger Live - Desktop UI",
5
5
  "repository": "https://github.com/LedgerHQ/ui",
6
6
  "license": "MIT",
@@ -15,27 +15,25 @@
15
15
  "index.js"
16
16
  ],
17
17
  "dependencies": {
18
- "@ledgerhq/icons-ui": "^0.2.0",
19
- "@ledgerhq/ui-shared": "^0.1.3",
18
+ "@ledgerhq/icons-ui": "^0.2.1",
19
+ "@ledgerhq/ui-shared": "^0.1.4",
20
20
  "@types/color": "^3.0.2",
21
- "@types/react": "^17.0.34",
21
+ "@types/react": "^17.0.37",
22
22
  "@types/react-native": "^0.65.9",
23
- "@types/styled-components-react-native": "^5.1.1",
23
+ "@types/styled-components-react-native": "^5.1.3",
24
24
  "@types/styled-system": "^5.1.13",
25
25
  "color": "^3.1.3",
26
26
  "moment": "^2.29.1",
27
27
  "react-native-modal": "^12.0.3",
28
- "react-native-reanimated": "~2.2.3",
29
- "react-native-svg": "12.1.1",
30
28
  "rn-range-slider": "^2.1.1",
31
- "styled-components": "^5.3.3",
32
29
  "styled-system": "^5.1.5",
33
30
  "victory-native": "^35.5.5"
34
31
  },
35
32
  "peerDependencies": {
36
33
  "react": "^17.0.2",
37
34
  "react-native": "^0.64.0",
38
- "react-native-reanimated": "~2.2.3",
39
- "react-native-svg": "12.1.1"
35
+ "react-native-reanimated": "^2.2.4",
36
+ "react-native-svg": "^12.1.1",
37
+ "styled-components": "^5.3.3"
40
38
  }
41
39
  }
@@ -3,7 +3,6 @@ import { ThemeNames } from "@ledgerhq/ui-shared";
3
3
  interface Props {
4
4
  children: React.ReactNode;
5
5
  selectedPalette?: ThemeNames;
6
- fontsPath?: string;
7
6
  }
8
7
  export declare const InvertTheme: ({ children }: Props) => React.ReactElement;
9
8
  export {};
@@ -3,6 +3,6 @@ import { ThemeProvider } from "styled-components/native";
3
3
  import defaultTheme from "./theme";
4
4
  import { palettes } from "@ledgerhq/ui-shared";
5
5
  export const StyleProvider = ({ children, selectedPalette, }) => {
6
- const theme = useMemo(() => (Object.assign(Object.assign({}, defaultTheme), { colors: Object.assign(Object.assign({}, defaultTheme.colors), { palette: palettes[selectedPalette] }), theme: selectedPalette })), [selectedPalette]);
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/theme.d.ts CHANGED
@@ -14,7 +14,10 @@ export declare type Theme = {
14
14
  radii: number[];
15
15
  fontSizes: number[];
16
16
  space: number[];
17
- colors: {
17
+ colors: ColorPalette & {
18
+ /**
19
+ * @deprecated Do not use the .palette prefix anymore!
20
+ */
18
21
  palette: ColorPalette;
19
22
  };
20
23
  zIndexes: number[];
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,
@@ -26,9 +28,7 @@ const theme = {
26
28
  radii,
27
29
  fontSizes,
28
30
  space,
29
- colors: {
30
- palette: palettes.light,
31
- },
31
+ colors: Object.assign(Object.assign({}, palettes.light), { palette: palettes.light }),
32
32
  zIndexes,
33
33
  };
34
34
  export default theme;
Binary file
Binary file
@@ -1,15 +0,0 @@
1
- /// <reference types="styled-components-react-native" />
2
- import React from "react";
3
- import { TouchableOpacity } from "react-native";
4
- export declare type ToggleGroupProps = {
5
- labels: string[];
6
- activeIndex: number;
7
- onChange: (newIndex: number) => void;
8
- };
9
- export declare const ToggleGroupContainer: import("styled-components").StyledComponent<typeof import("react-native").View, import("styled-components").DefaultTheme, import("../../Layout/Flex").Props & {
10
- flexDirection: string;
11
- alignItems: string;
12
- }, "alignItems" | "flexDirection">;
13
- export declare const ToggleBox: import("styled-components").StyledComponent<typeof TouchableOpacity, import("styled-components").DefaultTheme, {}, never>;
14
- declare const ToggleGroup: (props: ToggleGroupProps) => React.ReactElement;
15
- export default ToggleGroup;
@@ -1,25 +0,0 @@
1
- import React from "react";
2
- import styled from "styled-components/native";
3
- import Text from "../../Text";
4
- import { TouchableOpacity } from "react-native";
5
- import Button from "../../cta/Button";
6
- import FlexBox from "../../Layout/Flex";
7
- export const ToggleGroupContainer = styled(FlexBox).attrs({
8
- flexDirection: "row",
9
- alignItems: "stretch",
10
- }) `
11
- width: 100%;
12
- border: ${(p) => `1px solid ${p.theme.colors.palette.neutral.c40}`};
13
- border-radius: 35px;
14
- padding: 4px;
15
- `;
16
- export const ToggleBox = styled(TouchableOpacity) `
17
- text-align: center;
18
- margin: auto;
19
- flex: 1;
20
- `;
21
- const ToggleGroup = (props) => {
22
- const { labels, activeIndex, onChange } = props;
23
- return (React.createElement(ToggleGroupContainer, null, labels.map((label, key) => (React.createElement(ToggleBox, { key: key, onPress: () => onChange(key) }, key === activeIndex ? (React.createElement(Button, { type: "main" }, label)) : (React.createElement(Text, { lineHeight: 36 }, label)))))));
24
- };
25
- export default ToggleGroup;
@@ -1,37 +0,0 @@
1
- import React from "react";
2
- import styled, { useTheme } from "styled-components/native";
3
- import FlexBox from "../../Layout/Flex";
4
- import { TouchableOpacity, } from "react-native";
5
- import Text from "../../Text";
6
- import CloseMedium from "@ledgerhq/icons-ui/native/CloseMedium";
7
- const NotificationContainer = styled.View `
8
- display: flex;
9
- width: 100%;
10
- flex-direction: row;
11
- align-items: center;
12
- padding: 16px;
13
- background-color: ${(p) => p.variant === "primary"
14
- ? p.theme.colors.palette.primary.c90
15
- : "transparent"};
16
- border-radius: ${(p) => `${p.theme.radii[1]}px`};
17
- `;
18
- export default function Notification({ Icon, color, variant = "primary", numberOfLines, title, subtitle, onClose, onLearnMore, }) {
19
- const { colors } = useTheme();
20
- const textColor = variant === "primary"
21
- ? colors.palette.neutral.c00
22
- : colors.palette.neutral.c100;
23
- return (React.createElement(NotificationContainer, { variant: variant },
24
- React.createElement(FlexBox, null,
25
- React.createElement(Icon, { size: 18, color: color || textColor })),
26
- React.createElement(FlexBox, { ml: 16, flexShrink: 1 },
27
- React.createElement(Text, { variant: "body", fontWeight: "medium", color: color || textColor, numberOfLines: numberOfLines }, title),
28
- !!subtitle && (React.createElement(Text, { variant: "body", fontWeight: "medium", color: color ||
29
- (variant === "primary"
30
- ? colors.palette.neutral.c00
31
- : colors.palette.neutral.c80), mt: "2px", mb: "2px" }, subtitle)),
32
- onLearnMore && (React.createElement(TouchableOpacity, { onPress: onLearnMore },
33
- React.createElement(Text, { variant: "body", fontWeight: "semiBold", color: color || textColor }, "Learn more")))),
34
- onClose && (React.createElement(FlexBox, { marginLeft: "auto", pl: 16 },
35
- React.createElement(TouchableOpacity, { onPress: onClose },
36
- React.createElement(CloseMedium, { size: 14, color: color || textColor }))))));
37
- }
@@ -1 +0,0 @@
1
- export { default as Notification } from "./Notification";
@@ -1 +0,0 @@
1
- export { default as Notification } from "./Notification";