@ledgerhq/native-ui 0.5.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 (42) hide show
  1. package/components/Carousel/index.js +1 -1
  2. package/components/Form/SelectableList.d.ts +6 -1
  3. package/components/Form/SelectableList.js +7 -8
  4. package/components/Form/index.d.ts +1 -0
  5. package/components/Form/index.js +1 -0
  6. package/components/Navigation/FlowStepper/index.d.ts +64 -0
  7. package/components/Navigation/FlowStepper/index.js +38 -0
  8. package/components/Navigation/index.d.ts +1 -0
  9. package/components/Navigation/index.js +1 -0
  10. package/components/ProgressBar/index.d.ts +15 -0
  11. package/components/ProgressBar/index.js +33 -0
  12. package/components/Tabs/Chip/index.d.ts +5 -0
  13. package/components/Tabs/Chip/index.js +20 -0
  14. package/components/Tabs/Graph/index.d.ts +5 -0
  15. package/components/Tabs/Graph/index.js +21 -0
  16. package/components/Tabs/TemplateTabs/index.d.ts +29 -0
  17. package/components/Tabs/TemplateTabs/index.js +14 -0
  18. package/components/Tabs/index.d.ts +2 -0
  19. package/components/Tabs/index.js +2 -0
  20. package/components/index.d.ts +3 -1
  21. package/components/index.js +4 -1
  22. package/components/{drawer → message}/Notification/index.d.ts +5 -4
  23. package/components/{drawer → message}/Notification/index.js +15 -11
  24. package/components/message/index.d.ts +1 -0
  25. package/components/message/index.js +1 -0
  26. package/components/transitions/Fade.d.ts +5 -0
  27. package/components/transitions/Fade.js +32 -0
  28. package/components/transitions/Slide.d.ts +11 -0
  29. package/components/transitions/Slide.js +49 -0
  30. package/components/transitions/Transition.d.ts +49 -0
  31. package/components/transitions/Transition.js +42 -0
  32. package/components/transitions/index.d.ts +4 -0
  33. package/components/transitions/index.js +4 -0
  34. package/components/transitions/types.d.ts +21 -0
  35. package/components/transitions/types.js +1 -0
  36. package/package.json +3 -3
  37. package/assets/fonts/.DS_Store +0 -0
  38. package/assets/fonts/alpha/.DS_Store +0 -0
  39. package/components/Navigation/ToggleGroup/index.d.ts +0 -22
  40. package/components/Navigation/ToggleGroup/index.js +0 -25
  41. package/components/drawer/index.d.ts +0 -1
  42. package/components/drawer/index.js +0 -1
@@ -52,7 +52,7 @@ function Carousel({ activeIndex, autoDelay, containerProps, slideIndicatorContai
52
52
  const interval = setInterval(() => {
53
53
  if (!disableTimer.current) {
54
54
  setActiveIndexState((index) => {
55
- const newIndex = index ? (index + 1) % slidesLength : 0;
55
+ const newIndex = typeof index !== "undefined" ? (index + 1) % slidesLength : 0;
56
56
  scrollToIndex(newIndex);
57
57
  onChange && onChange(newIndex);
58
58
  return newIndex;
@@ -3,8 +3,13 @@ import { GestureResponderEvent } from "react-native";
3
3
  export declare type ElementProps<V> = React.PropsWithChildren<{
4
4
  first?: boolean;
5
5
  selected?: boolean;
6
+ disabled?: boolean;
6
7
  value?: V;
7
8
  onPress?: ((event: GestureResponderEvent) => void) | undefined;
9
+ Icon?: (props: {
10
+ size?: number;
11
+ color?: string;
12
+ }) => React.ReactElement;
8
13
  }>;
9
14
  export declare type Props<V> = React.PropsWithChildren<{
10
15
  currentValue?: V;
@@ -12,6 +17,6 @@ export declare type Props<V> = React.PropsWithChildren<{
12
17
  }>;
13
18
  declare function SelectableList<V>({ currentValue, onChange, children }: Props<V>): JSX.Element;
14
19
  declare namespace SelectableList {
15
- var Element: <V>({ first, value, selected, onPress, children, }: ElementProps<V>) => JSX.Element;
20
+ var Element: <V>({ first, value, selected, disabled, onPress, children, Icon, }: ElementProps<V>) => JSX.Element;
16
21
  }
17
22
  export default SelectableList;
@@ -1,19 +1,18 @@
1
1
  import React from "react";
2
2
  import { TouchableOpacity } from "react-native";
3
3
  import styled from "styled-components/native";
4
- import { border } from "styled-system";
5
4
  import Flex from "../Layout/Flex";
6
5
  import { Text } from "../index";
7
6
  const ElementContainer = styled(Flex).attrs({
8
7
  accessible: true,
9
8
  accessibilityRole: "radio",
10
- }) `
11
- ${border}
12
- `;
13
- function Element({ first, value, selected, onPress, children, }) {
14
- return (React.createElement(TouchableOpacity, { onPress: onPress },
15
- React.createElement(ElementContainer, { p: 6, mt: first ? 0 : 4, backgroundColor: selected ? "primary.c20" : "neutral.c00", border: "1px solid", borderColor: selected ? "primary.c100" : "neutral.c40", borderRadius: 1 },
16
- React.createElement(Text, { variant: "large" }, children || value))));
9
+ }) ``;
10
+ function Element({ first, value, selected, disabled, onPress, children, Icon, }) {
11
+ return (React.createElement(TouchableOpacity, { onPress: onPress, disabled: disabled },
12
+ 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
+ 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))));
17
16
  }
18
17
  function SelectableList({ currentValue, onChange, children }) {
19
18
  return (React.createElement(Flex, { accessible: true, accessibilityRole: "radiogroup" }, React.Children.map(children, (child, index) => {
@@ -2,4 +2,5 @@ export { default as Checkbox } from "./Checkbox";
2
2
  export * from "./Input";
3
3
  export { default as Slider } from "./Slider";
4
4
  export { default as Switch } from "./Switch";
5
+ export { default as Toggle } from "./Toggle";
5
6
  export { default as SelectableList } from "./SelectableList";
@@ -2,4 +2,5 @@ export { default as Checkbox } from "./Checkbox";
2
2
  export * from "./Input";
3
3
  export { default as Slider } from "./Slider";
4
4
  export { default as Switch } from "./Switch";
5
+ export { default as Toggle } from "./Toggle";
5
6
  export { default as SelectableList } from "./SelectableList";
@@ -0,0 +1,64 @@
1
+ import React from "react";
2
+ import { TransitionProps } from "../../transitions";
3
+ interface InnerProps {
4
+ /**
5
+ * The active index.
6
+ */
7
+ activeIndex: number;
8
+ /**
9
+ * The total number of steps.
10
+ */
11
+ stepsLength: number;
12
+ }
13
+ export interface RenderTransitionProps extends InnerProps, TransitionProps {
14
+ /**
15
+ * The index of the child.
16
+ */
17
+ index: number;
18
+ /**
19
+ * The previously active index.
20
+ */
21
+ previousActiveIndex: number | null;
22
+ }
23
+ export interface Props<ExtraProps> {
24
+ /**
25
+ * The index of the active step.
26
+ */
27
+ activeIndex: number;
28
+ /**
29
+ * An optional header displayed above the progress bar.
30
+ */
31
+ header?: (props: InnerProps & ExtraProps) => React.ReactNode;
32
+ /**
33
+ * An optional footer displayed below the body.
34
+ */
35
+ footer?: (props: InnerProps & ExtraProps) => React.ReactNode;
36
+ /**
37
+ * Extra props that are passed to the header and footer render functions.
38
+ */
39
+ extraProps?: ExtraProps;
40
+ /**
41
+ * **Use this prop in combination with `transitionDuration`.**
42
+ *
43
+ * A render function wrapping every children which allows using transitions.
44
+ * This function is called with various useful arguments, most notably:
45
+ * - the child index
46
+ * - the current active index
47
+ * - the previous active index
48
+ * - the transition status ("entered", "entering", "exiting" or "exited")
49
+ */
50
+ renderTransition?: (props: RenderTransitionProps) => JSX.Element | null;
51
+ /**
52
+ * **Use this prop in combination with `renderTransition`.**
53
+ *
54
+ * If this prop is true and if `renderTransition` is used
55
+ * then specifies the duration of the transition in milliseconds.
56
+ */
57
+ transitionDuration?: number;
58
+ /**
59
+ * A list of children representing each step of the flow.
60
+ */
61
+ children: React.ReactNode;
62
+ }
63
+ declare function FlowStepper<ExtraProps>({ activeIndex, header, footer, extraProps, renderTransition, transitionDuration, children, }: Props<ExtraProps>): JSX.Element;
64
+ export default FlowStepper;
@@ -0,0 +1,38 @@
1
+ import React, { useRef, useEffect } from "react";
2
+ import { SafeAreaView } from "react-native";
3
+ import Flex from "../../Layout/Flex";
4
+ import ProgressBar from "../../ProgressBar";
5
+ import { Transition, } from "../../transitions";
6
+ function FlowStepper({ activeIndex, header, footer, extraProps, renderTransition, transitionDuration = 0, children, }) {
7
+ const previousActiveIndex = useRef(null);
8
+ const stepsLength = React.Children.count(children);
9
+ useEffect(() => () => {
10
+ previousActiveIndex.current = activeIndex;
11
+ }, [activeIndex]);
12
+ return (React.createElement(Flex, { flex: 1 },
13
+ header &&
14
+ header(Object.assign(Object.assign({}, extraProps), { activeIndex, stepsLength })),
15
+ React.createElement(SafeAreaView, { style: { flex: 1 } },
16
+ React.createElement(ProgressBar, { index: activeIndex, length: stepsLength }),
17
+ React.createElement(Flex, { flex: 1 }, React.Children.map(children, (child, index) => {
18
+ if (renderTransition && transitionDuration) {
19
+ return (React.createElement(Transition, { in: index === activeIndex, timeout: transitionDuration, mountOnEnter: true, unmountOnExit: true }, (status) => {
20
+ return renderTransition({
21
+ index,
22
+ activeIndex,
23
+ previousActiveIndex: previousActiveIndex.current,
24
+ stepsLength,
25
+ status,
26
+ duration: transitionDuration,
27
+ children: child,
28
+ });
29
+ }));
30
+ }
31
+ else {
32
+ return index === activeIndex ? child : null;
33
+ }
34
+ })),
35
+ footer &&
36
+ footer(Object.assign(Object.assign({}, extraProps), { activeIndex, stepsLength })))));
37
+ }
38
+ export default FlowStepper;
@@ -1,2 +1,3 @@
1
1
  export { default as SlideIndicator } from "./SlideIndicator";
2
2
  export { default as Stepper } from "./Stepper";
3
+ export { default as FlowStepper } from "./FlowStepper";
@@ -1,2 +1,3 @@
1
1
  export { default as SlideIndicator } from "./SlideIndicator";
2
2
  export { default as Stepper } from "./Stepper";
3
+ export { default as FlowStepper } from "./FlowStepper";
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import { FlexBoxProps } from "../Layout/Flex";
3
+ export interface Props extends FlexBoxProps {
4
+ /**
5
+ * The index of the active step.
6
+ */
7
+ index: number;
8
+ /**
9
+ * The total number of steps.
10
+ */
11
+ length: number;
12
+ }
13
+ declare function ProgressBar({ index, length, ...props }: Props): JSX.Element;
14
+ declare const _default: React.MemoExoticComponent<typeof ProgressBar>;
15
+ export default _default;
@@ -0,0 +1,33 @@
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 from "styled-components/native";
14
+ import Flex from "../Layout/Flex";
15
+ import Animated, { useDerivedValue, useAnimatedStyle, withTiming, } from "react-native-reanimated";
16
+ const ActiveBar = styled.View `
17
+ background-color: ${(p) => p.theme.colors.neutral.c100};
18
+ position: absolute;
19
+ height: 100%;
20
+ top: 0;
21
+ left: 0;
22
+ `;
23
+ const AnimatedBar = Animated.createAnimatedComponent(ActiveBar);
24
+ function ProgressBar(_a) {
25
+ var { index, length } = _a, props = __rest(_a, ["index", "length"]);
26
+ const width = useDerivedValue(() => Math.round((index / (length - 1)) * 100), [index, length]);
27
+ const animatedStyles = useAnimatedStyle(() => ({
28
+ width: withTiming(`${width.value}%`),
29
+ }));
30
+ return (React.createElement(Flex, Object.assign({ height: 4, width: "100%", backgroundColor: "neutral.c20", position: "relative" }, props),
31
+ React.createElement(AnimatedBar, { style: [animatedStyles] })));
32
+ }
33
+ export default React.memo(ProgressBar);
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import { BaseTabsProps, TabItemProps } from "../TemplateTabs";
3
+ export declare const ChipTab: ({ onPress, isActive, label, }: TabItemProps) => React.ReactElement;
4
+ declare const ChipTabs: (props: BaseTabsProps) => React.ReactElement;
5
+ export default ChipTabs;
@@ -0,0 +1,20 @@
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 TemplateTabs from "../TemplateTabs";
6
+ const TabBox = styled(TouchableOpacity) `
7
+ text-align: center;
8
+ margin: auto;
9
+ flex: 1;
10
+ padding: ${(p) => p.theme.space[5]}px 0;
11
+ border-radius: 8px;
12
+ background-color: ${(p) => p.isActive ? p.theme.colors.palette.primary.c20 : "transparent"};
13
+ `;
14
+ const StyledTabs = styled(TemplateTabs) ``;
15
+ export const ChipTab = ({ onPress, isActive, label, }) => {
16
+ return (React.createElement(TabBox, { isActive: isActive, onPress: onPress },
17
+ React.createElement(Text, { variant: "small", fontWeight: "semiBold", color: isActive ? "palette.neutral.c100" : "palette.neutral.c80", textAlign: "center" }, label)));
18
+ };
19
+ const ChipTabs = (props) => (React.createElement(StyledTabs, Object.assign({}, props, { Item: ChipTab })));
20
+ export default ChipTabs;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import { BaseTabsProps, TabItemProps } from "../TemplateTabs";
3
+ export declare const GraphTab: ({ onPress, isActive, label, }: TabItemProps) => React.ReactElement;
4
+ declare const GraphTabs: (props: BaseTabsProps) => React.ReactElement;
5
+ export default GraphTabs;
@@ -0,0 +1,21 @@
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 TemplateTabs from "../TemplateTabs";
7
+ const TabBbx = styled(TouchableOpacity) `
8
+ text-align: center;
9
+ margin: auto;
10
+ flex: 1;
11
+ `;
12
+ const StyledTabs = styled(TemplateTabs) `
13
+ border: ${(p) => `1px solid ${p.theme.colors.palette.neutral.c40}`};
14
+ border-radius: 35px;
15
+ padding: 4px;
16
+ `;
17
+ export const GraphTab = ({ onPress, isActive, label, }) => {
18
+ return (React.createElement(TabBbx, { onPress: onPress }, isActive ? (React.createElement(Button, { type: "main" }, label)) : (React.createElement(Text, { lineHeight: 36, textAlign: "center" }, label))));
19
+ };
20
+ const GraphTabs = (props) => (React.createElement(StyledTabs, Object.assign({}, props, { Item: GraphTab })));
21
+ export default GraphTabs;
@@ -0,0 +1,29 @@
1
+ /// <reference types="styled-components-react-native" />
2
+ import React from "react";
3
+ export declare type BaseTabsProps = {
4
+ labels: string[];
5
+ activeIndex: number;
6
+ onChange: (newIndex: number) => void;
7
+ };
8
+ export declare type TabItemProps = Partial<BaseTabsProps> & {
9
+ label: string;
10
+ isActive: boolean;
11
+ index: number;
12
+ onPress: () => void;
13
+ };
14
+ export declare type TabsProps = BaseTabsProps & {
15
+ Item: (props: TabItemProps) => React.ReactElement;
16
+ };
17
+ export declare const TabsContainer: 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>> & {
18
+ columnGap?: string | number | undefined;
19
+ rowGap?: string | number | undefined;
20
+ color?: string | undefined;
21
+ display?: string | undefined;
22
+ position?: string | undefined;
23
+ maxHeight?: number | undefined;
24
+ } & {
25
+ flexDirection: string;
26
+ alignItems: string;
27
+ }, "alignItems" | "flexDirection">;
28
+ declare const TemplateTabsGroup: (props: TabsProps) => React.ReactElement;
29
+ export default TemplateTabsGroup;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import styled from "styled-components/native";
3
+ import FlexBox from "../../Layout/Flex";
4
+ export const TabsContainer = styled(FlexBox).attrs({
5
+ flexDirection: "row",
6
+ alignItems: "stretch",
7
+ }) `
8
+ width: 100%;
9
+ `;
10
+ const TemplateTabsGroup = (props) => {
11
+ const { labels, activeIndex, onChange, Item } = props;
12
+ return (React.createElement(TabsContainer, Object.assign({}, props), labels.map((label, index) => (React.createElement(Item, Object.assign({ key: index }, props, { label: label, index: index, isActive: index === activeIndex, onPress: () => onChange(index) }))))));
13
+ };
14
+ export default TemplateTabsGroup;
@@ -0,0 +1,2 @@
1
+ export { default as ChipTabs } from "./Chip";
2
+ export { default as GraphTabs } from "./Graph";
@@ -0,0 +1,2 @@
1
+ export { default as ChipTabs } from "./Chip";
2
+ export { default as GraphTabs } from "./Graph";
@@ -1,5 +1,4 @@
1
1
  export * from "./cta";
2
- export * from "./drawer";
3
2
  export * from "./Form";
4
3
  export * from "./Icon";
5
4
  export * from "./Layout";
@@ -9,3 +8,6 @@ export * from "./Navigation";
9
8
  export * from "./tags";
10
9
  export { default as Text } from "./Text";
11
10
  export { default as Carousel } from "./Carousel";
11
+ export * from "./Tabs";
12
+ export { default as ProgressBar } from "./ProgressBar";
13
+ export * as Transitions from "./transitions";
@@ -1,5 +1,4 @@
1
1
  export * from "./cta";
2
- export * from "./drawer";
3
2
  export * from "./Form";
4
3
  export * from "./Icon";
5
4
  export * from "./Layout";
@@ -9,3 +8,7 @@ export * from "./Navigation";
9
8
  export * from "./tags";
10
9
  export { default as Text } from "./Text";
11
10
  export { default as Carousel } from "./Carousel";
11
+ export * from "./Tabs";
12
+ export { default as ProgressBar } from "./ProgressBar";
13
+ import * as Transitions_1 from "./transitions";
14
+ export { Transitions_1 as Transitions };
@@ -1,17 +1,18 @@
1
1
  import React from "react";
2
2
  import { TextProps, TouchableOpacityProps } from "react-native";
3
3
  declare type Props = {
4
- Icon: React.ComponentType<{
4
+ Icon?: React.ComponentType<{
5
5
  size: number;
6
6
  color?: string;
7
7
  }>;
8
- color?: string;
8
+ iconColor?: string;
9
9
  variant?: "primary" | "secondary";
10
10
  title: string;
11
11
  subtitle?: string;
12
12
  numberOfLines?: TextProps["numberOfLines"];
13
13
  onClose?: TouchableOpacityProps["onPress"];
14
- onLearnMore?: TouchableOpacityProps["onPress"];
14
+ linkText?: string;
15
+ onLinkPress?: TouchableOpacityProps["onPress"];
15
16
  };
16
- export default function Notification({ Icon, color, variant, numberOfLines, title, subtitle, onClose, onLearnMore, }: Props): React.ReactElement;
17
+ export default function Notification({ Icon, iconColor, variant, numberOfLines, title, subtitle, onClose, linkText, onLinkPress, }: Props): React.ReactElement;
17
18
  export {};
@@ -4,28 +4,32 @@ import FlexBox from "../../Layout/Flex";
4
4
  import { TouchableOpacity, } from "react-native";
5
5
  import Text from "../../Text";
6
6
  import CloseMedium from "@ledgerhq/icons-ui/native/CloseMedium";
7
+ import { Flex } from "../../Layout";
7
8
  const NotificationContainer = styled.View `
8
9
  display: flex;
9
10
  width: 100%;
10
11
  flex-direction: row;
11
12
  align-items: center;
12
- padding: 16px;
13
+ ${(p) => p.variant === "primary" &&
14
+ `
15
+ padding: 16px;
16
+ `}
13
17
  background-color: ${(p) => p.variant === "primary" ? p.theme.colors.primary.c90 : "transparent"};
14
18
  border-radius: ${(p) => `${p.theme.radii[1]}px`};
15
19
  `;
16
- export default function Notification({ Icon, color, variant = "primary", numberOfLines, title, subtitle, onClose, onLearnMore, }) {
20
+ export default function Notification({ Icon, iconColor, variant = "primary", numberOfLines, title, subtitle, onClose, linkText, onLinkPress, }) {
17
21
  const { colors } = useTheme();
18
22
  const textColor = variant === "primary" ? colors.neutral.c00 : colors.neutral.c100;
19
23
  return (React.createElement(NotificationContainer, { variant: variant },
20
- React.createElement(FlexBox, null,
21
- React.createElement(Icon, { size: 18, color: color || textColor })),
22
- React.createElement(FlexBox, { ml: 16, flexShrink: 1 },
23
- React.createElement(Text, { variant: "body", fontWeight: "medium", color: color || textColor, numberOfLines: numberOfLines }, title),
24
- !!subtitle && (React.createElement(Text, { variant: "body", fontWeight: "medium", color: color ||
25
- (variant === "primary" ? colors.neutral.c00 : colors.neutral.c80), mt: "2px", mb: "2px" }, subtitle)),
26
- onLearnMore && (React.createElement(TouchableOpacity, { onPress: onLearnMore },
27
- React.createElement(Text, { variant: "body", fontWeight: "semiBold", color: color || textColor }, "Learn more")))),
24
+ Icon && (React.createElement(FlexBox, { mr: 16 },
25
+ React.createElement(Icon, { size: 20, color: iconColor || textColor }))),
26
+ React.createElement(FlexBox, { flexShrink: 1 },
27
+ React.createElement(Text, { variant: "body", fontWeight: "medium", color: textColor, numberOfLines: numberOfLines }, title),
28
+ !!subtitle && (React.createElement(Text, { variant: "body", fontWeight: "medium", color: variant === "primary" ? colors.neutral.c00 : colors.neutral.c80, mt: 2 }, subtitle)),
29
+ linkText && onLinkPress && (React.createElement(Flex, { mt: 3 },
30
+ React.createElement(TouchableOpacity, { onPress: onLinkPress },
31
+ React.createElement(Text, { variant: "body", fontWeight: "semiBold", color: textColor }, linkText))))),
28
32
  onClose && (React.createElement(FlexBox, { marginLeft: "auto", pl: 16 },
29
33
  React.createElement(TouchableOpacity, { onPress: onClose },
30
- React.createElement(CloseMedium, { size: 14, color: color || textColor }))))));
34
+ React.createElement(CloseMedium, { size: 14, color: textColor }))))));
31
35
  }
@@ -1 +1,2 @@
1
1
  export { default as Alert } from "./Alert";
2
+ export { default as Notification } from "./Notification";
@@ -1 +1,2 @@
1
1
  export { default as Alert } from "./Alert";
2
+ export { default as Notification } from "./Notification";
@@ -0,0 +1,5 @@
1
+ import { TransitionProps } from "./types";
2
+ /**
3
+ * A fade-in / fade-out transition changing the opacity of its children based on their status.
4
+ */
5
+ export declare function Fade({ status, duration, style, children }: TransitionProps): JSX.Element;
@@ -0,0 +1,32 @@
1
+ import React, { useRef, useMemo, useEffect } from "react";
2
+ import { Animated } from "react-native";
3
+ /**
4
+ * A fade-in / fade-out transition changing the opacity of its children based on their status.
5
+ */
6
+ export function Fade({ status, duration, style, children }) {
7
+ const fadeAnim = useRef(new Animated.Value(status === "entered" ? 1 : 0)).current;
8
+ const fadeIn = useMemo(() => Animated.timing(fadeAnim, {
9
+ toValue: 1,
10
+ duration,
11
+ useNativeDriver: true,
12
+ }), [duration, fadeAnim]);
13
+ const fadeOut = useMemo(() => Animated.timing(fadeAnim, {
14
+ toValue: 0,
15
+ duration,
16
+ useNativeDriver: true,
17
+ }), [duration, fadeAnim]);
18
+ useEffect(() => {
19
+ if (status === "entering") {
20
+ fadeIn.start();
21
+ }
22
+ if (status === "exiting") {
23
+ fadeOut.start();
24
+ }
25
+ }, [fadeIn, fadeOut, status]);
26
+ return (React.createElement(Animated.View, { style: [
27
+ {
28
+ opacity: fadeAnim,
29
+ },
30
+ style,
31
+ ] }, children));
32
+ }
@@ -0,0 +1,11 @@
1
+ import { TransitionProps } from "./types";
2
+ export interface SlideProps extends TransitionProps {
3
+ /**
4
+ * The direction of the slide animation.
5
+ */
6
+ direction?: "left" | "right";
7
+ }
8
+ /**
9
+ * A slide left/right transition translating its children based on their status and a given direction.
10
+ */
11
+ export declare function Slide({ status, duration, style, direction, children, }: SlideProps): JSX.Element;
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/native-ui",
3
- "version": "0.5.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,8 +15,8 @@
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
21
  "@types/react": "^17.0.37",
22
22
  "@types/react-native": "^0.65.9",
Binary file
Binary file
@@ -1,22 +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("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
- } & {
17
- flexDirection: string;
18
- alignItems: string;
19
- }, "alignItems" | "flexDirection">;
20
- export declare const ToggleBox: import("styled-components").StyledComponent<typeof TouchableOpacity, import("styled-components").DefaultTheme, {}, never>;
21
- declare const ToggleGroup: (props: ToggleGroupProps) => React.ReactElement;
22
- 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.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 +0,0 @@
1
- export { default as Notification } from "./Notification";
@@ -1 +0,0 @@
1
- export { default as Notification } from "./Notification";