@ledgerhq/native-ui 0.4.0 → 0.6.2

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 (124) hide show
  1. package/README.md +1 -4
  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 +74 -0
  6. package/components/Form/Checkbox/index.d.ts +3 -3
  7. package/components/Form/Checkbox/index.js +1 -1
  8. package/components/Form/Input/BaseInput/index.d.ts +83 -5
  9. package/components/Form/Input/BaseInput/index.js +6 -6
  10. package/components/Form/Input/LegendInput/index.d.ts +14 -3
  11. package/components/Form/Input/LegendInput/index.js +3 -2
  12. package/components/Form/Input/NumberInput/index.d.ts +16 -5
  13. package/components/Form/Input/NumberInput/index.js +5 -4
  14. package/components/Form/Input/QrCodeInput/index.d.ts +15 -4
  15. package/components/Form/Input/QrCodeInput/index.js +3 -2
  16. package/components/Form/Input/SearchInput/index.d.ts +13 -2
  17. package/components/Form/Input/SearchInput/index.js +3 -2
  18. package/components/Form/SelectableList.d.ts +12 -3
  19. package/components/Form/SelectableList.js +9 -8
  20. package/components/Form/Slider/index.d.ts +0 -1
  21. package/components/Form/Slider/index.native.d.ts +0 -1
  22. package/components/Form/Slider/index.native.js +1 -1
  23. package/components/Form/Switch/index.d.ts +1 -2
  24. package/components/Form/Switch/index.js +2 -2
  25. package/components/Form/Toggle/index.d.ts +1 -2
  26. package/components/Form/Toggle/index.js +1 -1
  27. package/components/Form/index.d.ts +1 -0
  28. package/components/Form/index.js +1 -0
  29. package/components/Icon/BoxedIcon.d.ts +49 -0
  30. package/components/Icon/BoxedIcon.js +85 -0
  31. package/components/Icon/Icon.d.ts +9 -0
  32. package/components/Icon/Icon.js +20 -0
  33. package/components/Icon/IconBox/index.d.ts +2 -4
  34. package/components/Icon/IconBox/index.js +1 -2
  35. package/components/Icon/index.d.ts +2 -0
  36. package/components/Icon/index.js +2 -0
  37. package/components/Icon/type.d.ts +7 -0
  38. package/components/Icon/type.js +1 -0
  39. package/components/Layout/Box/index.d.ts +11 -0
  40. package/components/Layout/Box/index.js +3 -0
  41. package/components/Layout/Collapse/Accordion/index.js +1 -1
  42. package/components/Layout/Flex/index.d.ts +11 -12
  43. package/components/Layout/Flex/index.js +2 -8
  44. package/components/Layout/List/IconBoxList/index.d.ts +10 -0
  45. package/components/Layout/List/IconBoxList/index.js +19 -0
  46. package/components/Layout/List/List/index.d.ts +13 -0
  47. package/components/Layout/List/List/index.js +29 -0
  48. package/components/Layout/List/NumberedList/index.d.ts +9 -0
  49. package/components/Layout/List/NumberedList/index.js +20 -0
  50. package/components/Layout/List/TipList/index.d.ts +9 -0
  51. package/components/Layout/List/TipList/index.js +20 -0
  52. package/components/Layout/List/index.d.ts +4 -0
  53. package/components/Layout/List/index.js +4 -0
  54. package/components/Layout/ScrollContainer/index.d.ts +2 -1
  55. package/components/Layout/ScrollContainer/index.js +2 -2
  56. package/components/Layout/ScrollContainerHeader/Header.d.ts +1 -2
  57. package/components/Layout/ScrollContainerHeader/Header.js +23 -16
  58. package/components/Layout/ScrollContainerHeader/index.d.ts +3 -2
  59. package/components/Layout/ScrollContainerHeader/index.js +9 -4
  60. package/components/Layout/index.d.ts +2 -0
  61. package/components/Layout/index.js +2 -0
  62. package/components/Loader/InfiniteLoader/index.d.ts +9 -0
  63. package/components/Loader/InfiniteLoader/index.js +58 -0
  64. package/components/Loader/ProgressLoader/index.d.ts +11 -0
  65. package/components/Loader/ProgressLoader/index.js +24 -0
  66. package/components/Loader/index.d.ts +2 -11
  67. package/components/Loader/index.js +2 -24
  68. package/components/Navigation/FlowStepper/index.d.ts +70 -0
  69. package/components/Navigation/FlowStepper/index.js +36 -0
  70. package/components/Navigation/SlideIndicator/index.d.ts +1 -1
  71. package/components/Navigation/SlideIndicator/index.js +13 -7
  72. package/components/Navigation/Stepper/index.d.ts +1 -1
  73. package/components/Navigation/Stepper/index.js +4 -4
  74. package/components/Navigation/index.d.ts +1 -0
  75. package/components/Navigation/index.js +1 -0
  76. package/components/ProgressBar/index.d.ts +15 -0
  77. package/components/ProgressBar/index.js +33 -0
  78. package/components/Tabs/Chip/index.d.ts +5 -0
  79. package/components/Tabs/Chip/index.js +20 -0
  80. package/components/Tabs/Graph/index.d.ts +5 -0
  81. package/components/Tabs/Graph/index.js +21 -0
  82. package/components/Tabs/TemplateTabs/index.d.ts +29 -0
  83. package/components/Tabs/TemplateTabs/index.js +14 -0
  84. package/components/Tabs/index.d.ts +2 -0
  85. package/components/Tabs/index.js +2 -0
  86. package/components/Text/getTextStyle.d.ts +1 -0
  87. package/components/Text/getTextStyle.js +5 -0
  88. package/components/Text/index.d.ts +6 -8
  89. package/components/Text/index.js +15 -8
  90. package/components/chart/index.d.ts +0 -1
  91. package/components/cta/Button/index.d.ts +5 -15
  92. package/components/cta/Button/index.js +21 -24
  93. package/components/cta/Link/index.js +1 -5
  94. package/components/index.d.ts +5 -2
  95. package/components/index.js +6 -2
  96. package/components/message/Alert/index.d.ts +1 -2
  97. package/components/message/Alert/index.js +2 -2
  98. package/components/{drawer → message}/Notification/index.d.ts +5 -4
  99. package/components/{drawer → message}/Notification/index.js +16 -12
  100. package/components/message/index.d.ts +1 -0
  101. package/components/message/index.js +1 -0
  102. package/components/styled.d.ts +15 -0
  103. package/components/styled.js +12 -0
  104. package/components/transitions/Fade.d.ts +5 -0
  105. package/components/transitions/Fade.js +32 -0
  106. package/components/transitions/Slide.d.ts +11 -0
  107. package/components/transitions/Slide.js +49 -0
  108. package/components/transitions/Transition.d.ts +49 -0
  109. package/components/transitions/Transition.js +39 -0
  110. package/components/transitions/index.d.ts +4 -0
  111. package/components/transitions/index.js +4 -0
  112. package/components/transitions/types.d.ts +21 -0
  113. package/components/transitions/types.js +1 -0
  114. package/package.json +4 -4
  115. package/styles/StyleProvider.d.ts +1 -1
  116. package/styles/StyleProvider.js +1 -1
  117. package/styles/helpers.js +1 -3
  118. package/styles/theme.js +2 -0
  119. package/assets/fonts/.DS_Store +0 -0
  120. package/assets/fonts/alpha/.DS_Store +0 -0
  121. package/components/Navigation/ToggleGroup/index.d.ts +0 -15
  122. package/components/Navigation/ToggleGroup/index.js +0 -25
  123. package/components/drawer/index.d.ts +0 -1
  124. package/components/drawer/index.js +0 -1
@@ -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,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,9 +1,7 @@
1
1
  import React from "react";
2
+ import { IconOrElementType } from "../type";
2
3
  declare type Props = {
3
- Icon: (props: {
4
- size?: number;
5
- color?: string;
6
- }) => React.ReactElement;
4
+ Icon: IconOrElementType;
7
5
  color?: string;
8
6
  boxSize?: number;
9
7
  iconSize?: number;
@@ -14,6 +14,5 @@ const IconContainer = styled.View `
14
14
  `;
15
15
  export default function IconBox({ Icon, color, boxSize = DEFAULT_BOX_SIZE, iconSize = DEFAULT_ICON_SIZE, }) {
16
16
  const { colors } = useTheme();
17
- return (React.createElement(IconContainer, { size: boxSize },
18
- React.createElement(Icon, { size: iconSize, color: color || colors.neutral.c100 })));
17
+ return (React.createElement(IconContainer, { size: boxSize }, React.isValidElement(Icon) ? (Icon) : (React.createElement(Icon, { size: iconSize, color: color || colors.neutral.c100 }))));
19
18
  }
@@ -1 +1,3 @@
1
1
  export { default as IconBox } from "./IconBox";
2
+ export { default as BoxedIcon } from "./BoxedIcon";
3
+ export { default as Icon } from "./Icon";
@@ -1 +1,3 @@
1
1
  export { default as IconBox } from "./IconBox";
2
+ export { default as BoxedIcon } from "./BoxedIcon";
3
+ export { default as Icon } from "./Icon";
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ export declare type IconProps = {
3
+ size?: number;
4
+ color?: string;
5
+ };
6
+ export declare type IconType = React.ComponentType<IconProps>;
7
+ export declare type IconOrElementType = IconType | React.ReactElement;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { BaseStyledProps } from "../../styled";
2
+ export declare type BoxProps = BaseStyledProps;
3
+ declare const Box: import("styled-components").StyledComponent<typeof import("react-native").View, import("styled-components").DefaultTheme, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & {
4
+ columnGap?: string | number | undefined;
5
+ rowGap?: string | number | undefined;
6
+ color?: string | undefined;
7
+ display?: string | undefined;
8
+ position?: string | undefined;
9
+ maxHeight?: number | undefined;
10
+ }, never>;
11
+ export default Box;
@@ -0,0 +1,3 @@
1
+ import baseStyled from "../../styled";
2
+ const Box = baseStyled.View ``;
3
+ export default Box;
@@ -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, } from "@ledgerhq/icons-ui/native";
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%");
@@ -1,13 +1,12 @@
1
- /// <reference types="styled-components-react-native" />
2
- import React from "react";
3
- import { BackgroundProps, ColorProps, FlexboxProps, LayoutProps, SpaceProps } from "styled-system";
4
- export interface Props extends ColorProps, BackgroundProps, LayoutProps, FlexboxProps, SpaceProps {
5
- alignItems?: "flex-start" | "flex-end" | "center" | "baseline" | "stretch";
6
- flexBasis?: string;
7
- flexDirection?: "row" | "row-reverse" | "column" | "column-reverse";
8
- justifyContent?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly";
9
- children?: React.ReactNode;
10
- style?: Record<string, unknown>;
11
- }
12
- declare const FlexBox: import("styled-components").StyledComponent<typeof import("react-native").View, import("styled-components").DefaultTheme, Props, never>;
1
+ import { BaseStyledProps } from "../../styled";
2
+ export declare type FlexBoxProps = BaseStyledProps;
3
+ export declare type Props = FlexBoxProps;
4
+ declare const FlexBox: import("styled-components").StyledComponent<typeof import("react-native").View, import("styled-components").DefaultTheme, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & {
5
+ columnGap?: string | number | undefined;
6
+ rowGap?: string | number | undefined;
7
+ color?: string | undefined;
8
+ display?: string | undefined;
9
+ position?: string | undefined;
10
+ maxHeight?: number | undefined;
11
+ }, never>;
13
12
  export default FlexBox;
@@ -1,11 +1,5 @@
1
- import styled from "styled-components/native";
2
- import { background, color, flexbox, layout, space, } from "styled-system";
3
- const FlexBox = styled.View `
1
+ import baseStyled from "../../styled";
2
+ const FlexBox = baseStyled.View `
4
3
  display: flex;
5
- ${flexbox};
6
- ${space};
7
- ${background};
8
- ${color};
9
- ${layout};
10
4
  `;
11
5
  export default FlexBox;
@@ -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,20 @@
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) => (Object.assign(Object.assign({}, item), { bullet: (React.createElement(IconBox, { Icon: React.createElement(Text, { variant: "body", fontWeight: "medium", color: "neutral.c100" }, item.number ? item.number : index), boxSize: 36 })) }))), [items]);
19
+ return React.createElement(List, Object.assign({ items: numberedItems }, props));
20
+ }
@@ -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;
@@ -0,0 +1,20 @@
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 Check from "@ledgerhq/icons-ui/native/CheckAloneMedium";
15
+ import Close from "@ledgerhq/icons-ui/native/CloseMedium";
16
+ export default function TipList(_a) {
17
+ var { items } = _a, props = __rest(_a, ["items"]);
18
+ const tipItems = useMemo(() => items.map((item) => (Object.assign(Object.assign({}, item), { bullet: item.isPositive ? (React.createElement(Check, { size: 20, color: "success.c100" })) : (React.createElement(Close, { size: 20, color: "error.c100" })) }))), [items]);
19
+ return React.createElement(List, Object.assign({ items: tipItems }, props));
20
+ }
@@ -0,0 +1,4 @@
1
+ export { default as List } from "./List";
2
+ export { default as IconBoxList } from "./IconBoxList";
3
+ export { default as TipList } from "./TipList";
4
+ export { default as NumberedList } from "./NumberedList";
@@ -0,0 +1,4 @@
1
+ export { default as List } from "./List";
2
+ export { default as IconBoxList } from "./IconBoxList";
3
+ export { default as TipList } from "./TipList";
4
+ export { default as NumberedList } from "./NumberedList";
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
2
  import { SpaceProps } from "styled-system";
3
+ import { BaseStyledProps } from "../../styled";
3
4
  import type { NativeSyntheticEvent, NativeScrollEvent, ScrollViewProps } from "react-native";
4
- declare type ScrollContainerProps = ScrollViewProps & SpaceProps & {
5
+ declare type ScrollContainerProps = BaseStyledProps & ScrollViewProps & SpaceProps & {
5
6
  children: React.ReactNode;
6
7
  onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
7
8
  horizontal?: boolean;
@@ -11,9 +11,9 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import React from "react";
13
13
  import { space } from "styled-system";
14
- import styled from "styled-components/native";
14
+ import baseStyled from "../../styled";
15
15
  import Animated from "react-native-reanimated";
16
- const ScrollView = styled(Animated.ScrollView) `
16
+ const ScrollView = baseStyled(Animated.ScrollView) `
17
17
  ${space};
18
18
  `;
19
19
  const ScrollContainer = (_a) => {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import Animated from "react-native-reanimated";
3
2
  export declare type HeaderProps = {
4
3
  TopLeftSection?: JSX.Element;
@@ -8,5 +7,5 @@ export declare type HeaderProps = {
8
7
  BottomSection?: JSX.Element;
9
8
  currentPositionY: Animated.SharedValue<number>;
10
9
  };
11
- declare const Header: ({ TopLeftSection, TopRightSection, MiddleSection, BottomSection, currentPositionY, }: HeaderProps) => JSX.Element;
10
+ declare const Header: ({ TopLeftSection, TopRightSection, TopMiddleSection, MiddleSection, BottomSection, currentPositionY, }: HeaderProps) => JSX.Element;
12
11
  export default Header;
@@ -1,7 +1,6 @@
1
1
  import React, { useCallback, useState } from "react";
2
- import { View } from "react-native";
3
2
  import styled from "styled-components/native";
4
- import Animated, { useAnimatedStyle, interpolate, Extrapolate, } from "react-native-reanimated";
3
+ import Animated, { useAnimatedStyle, interpolate, Extrapolate } from "react-native-reanimated";
5
4
  import Flex from "../Flex";
6
5
  const Container = styled(Flex).attrs({
7
6
  paddingHorizontal: 16,
@@ -10,7 +9,7 @@ const Container = styled(Flex).attrs({
10
9
  width: 100%;
11
10
  `;
12
11
  const SCROLL_BREAKPOINT = 80;
13
- const Header = ({ TopLeftSection, TopRightSection, MiddleSection, BottomSection, currentPositionY, }) => {
12
+ const Header = ({ TopLeftSection, TopRightSection, TopMiddleSection, MiddleSection, BottomSection, currentPositionY, }) => {
14
13
  const [topSectionHeight, setTopSectionHeight] = useState(0);
15
14
  const [topSectionWidth, setTopSectionWidth] = useState(0);
16
15
  const [topMiddleWidth, setTopMiddleWidth] = useState(0);
@@ -29,34 +28,42 @@ const Header = ({ TopLeftSection, TopRightSection, MiddleSection, BottomSection,
29
28
  const onLayoutMiddle = useCallback(({ nativeEvent: { layout } }) => {
30
29
  setMiddleWidth(layout.width);
31
30
  }, []);
31
+ const TopMiddleStyle = useAnimatedStyle(() => {
32
+ const scaleRatio = middleWidth ? Math.min(topMiddleWidth / middleWidth, 0.9) : 0.7;
33
+ /** scale the animated content to fit in the available space on the top header section */
34
+ const scale = interpolate(currentPositionY.value, [0, SCROLL_BREAKPOINT], [1, scaleRatio], Extrapolate.CLAMP);
35
+ /** offset horizontaly given the scale transformation and potential top left header section */
36
+ const translateX = interpolate(currentPositionY.value, [0, SCROLL_BREAKPOINT], [0, -(topMiddleWidth - topMiddleWidth * scaleRatio) / 2], Extrapolate.CLAMP);
37
+ const opacity = interpolate(currentPositionY.value, [SCROLL_BREAKPOINT - 1, SCROLL_BREAKPOINT + 40], [0, 1], Extrapolate.CLAMP);
38
+ return {
39
+ transform: [{ translateX }, { scale }],
40
+ flex: 1,
41
+ opacity,
42
+ justifyContent: "center", // needed to ensure vertical centering of animated content
43
+ };
44
+ }, [topLeftWidth, topSectionHeight, middleWidth, topMiddleWidth, topSectionWidth]);
32
45
  const MiddleStyle = useAnimatedStyle(() => {
33
- const scaleRatio = middleWidth
34
- ? Math.min(topMiddleWidth / middleWidth, 0.9)
35
- : 0.7;
46
+ const scaleRatio = middleWidth ? Math.min(topMiddleWidth / middleWidth, 0.9) : 0.7;
36
47
  /** scale the animated content to fit in the available space on the top header section */
37
48
  const scale = interpolate(currentPositionY.value, [0, SCROLL_BREAKPOINT], [1, scaleRatio], Extrapolate.CLAMP);
38
49
  /** translate verticaly to the middle of the top header section */
39
50
  const translateY = interpolate(currentPositionY.value, [0, SCROLL_BREAKPOINT], [0, -topSectionHeight + topSectionHeight / 2], Extrapolate.CLAMP);
40
51
  /** offset horizontaly given the scale transformation and potential top left header section */
41
- const translateX = interpolate(currentPositionY.value, [0, SCROLL_BREAKPOINT], [0, -(topSectionWidth - topMiddleWidth) / 2 + topLeftWidth], Extrapolate.CLAMP);
52
+ const translateX = interpolate(currentPositionY.value, [0, SCROLL_BREAKPOINT], [0, -(topSectionWidth - topSectionWidth * scaleRatio) / 2 + topLeftWidth], Extrapolate.CLAMP);
42
53
  /** allow for content to move upward as animation is taking place */
43
54
  const maxHeight = interpolate(currentPositionY.value, [0, SCROLL_BREAKPOINT], [70, 0], Extrapolate.CLAMP);
55
+ const opacity = interpolate(currentPositionY.value, [SCROLL_BREAKPOINT - 1, SCROLL_BREAKPOINT + 40], [1, 0], Extrapolate.CLAMP);
44
56
  return {
45
57
  maxHeight,
46
58
  transform: [{ translateY }, { translateX }, { scale }],
59
+ opacity,
47
60
  justifyContent: "center", // needed to ensure vertical centering of animated content
48
61
  };
49
- }, [
50
- topLeftWidth,
51
- topSectionHeight,
52
- middleWidth,
53
- topMiddleWidth,
54
- topSectionWidth,
55
- ]);
62
+ }, [topLeftWidth, topSectionHeight, middleWidth, topMiddleWidth, topSectionWidth]);
56
63
  return (React.createElement(Container, null,
57
64
  React.createElement(Flex, { flexDirection: "row", justifyContent: "space-between", alignItems: "center", onLayout: onLayout },
58
- React.createElement(View, { onLayout: onLayoutTopLeft }, TopLeftSection),
59
- React.createElement(Flex, { flex: 1, onLayout: onLayoutTopMiddle }),
65
+ React.createElement(Flex, { onLayout: onLayoutTopLeft }, TopLeftSection),
66
+ React.createElement(Animated.View, { style: [TopMiddleStyle], onLayout: topMiddleWidth ? () => { } : onLayoutTopMiddle }, TopMiddleSection || MiddleSection),
60
67
  TopRightSection),
61
68
  React.createElement(Animated.View, { onLayout: middleWidth ? () => { } : onLayoutMiddle, style: MiddleStyle }, MiddleSection),
62
69
  BottomSection ? React.createElement(Flex, null, BottomSection) : null));
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
- import type { ScrollViewProps } from "react-native";
2
+ import { FlatListProps } from "react-native";
3
3
  import type { HeaderProps } from "./Header";
4
- declare type ScrollContainerHeaderProps = Omit<HeaderProps, "currentPositionY"> & Omit<ScrollViewProps, "onScroll"> & {
4
+ import { BaseStyledProps } from "../../styled";
5
+ declare type ScrollContainerHeaderProps = BaseStyledProps & Omit<HeaderProps, "currentPositionY"> & Omit<FlatListProps<any>, "onScroll" | "data" | "renderItem" | "stickyHeaderIndices"> & {
5
6
  children?: React.ReactNode;
6
7
  onScroll?: (y: number) => void;
7
8
  };
@@ -10,8 +10,12 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import React from "react";
13
- import Animated, { useAnimatedScrollHandler, useSharedValue, } from "react-native-reanimated";
13
+ import { View } from "react-native";
14
+ import Animated, { useAnimatedScrollHandler, useSharedValue } from "react-native-reanimated";
14
15
  import Header from "./Header";
16
+ import baseStyled from "../../styled";
17
+ const StyledFlatList = baseStyled.FlatList ``;
18
+ const AnimatedFlatList = Animated.createAnimatedComponent(StyledFlatList);
15
19
  const ScrollContainerHeader = (_a) => {
16
20
  var { TopLeftSection, TopRightSection, TopMiddleSection, MiddleSection, BottomSection, children, onScroll } = _a, props = __rest(_a, ["TopLeftSection", "TopRightSection", "TopMiddleSection", "MiddleSection", "BottomSection", "children", "onScroll"]);
17
21
  const currentPositionY = useSharedValue(0);
@@ -20,8 +24,9 @@ const ScrollContainerHeader = (_a) => {
20
24
  if (onScroll)
21
25
  onScroll(event.contentOffset.y);
22
26
  });
23
- return (React.createElement(Animated.ScrollView, Object.assign({}, props, { onScroll: handleScroll, scrollEventThrottle: 16, stickyHeaderIndices: [0] }),
24
- React.createElement(Header, { TopLeftSection: TopLeftSection, TopRightSection: TopRightSection, TopMiddleSection: TopMiddleSection, MiddleSection: MiddleSection, BottomSection: BottomSection, currentPositionY: currentPositionY }),
25
- children));
27
+ return (React.createElement(AnimatedFlatList, Object.assign({}, props, { onScroll: handleScroll, scrollEventThrottle: 16, stickyHeaderIndices: [0], data: [
28
+ React.createElement(Header, { TopLeftSection: TopLeftSection, TopRightSection: TopRightSection, TopMiddleSection: TopMiddleSection, MiddleSection: MiddleSection, BottomSection: BottomSection, currentPositionY: currentPositionY }),
29
+ children,
30
+ ], renderItem: ({ item, index }) => (React.createElement(View, { key: index }, item)) })));
26
31
  };
27
32
  export default ScrollContainerHeader;
@@ -1,6 +1,8 @@
1
1
  export { default as Accordion } from "./Collapse/Accordion";
2
2
  export { default as Flex } from "./Flex";
3
+ export { default as Box } from "./Box";
3
4
  export * from "./Modals";
4
5
  export { default as ScrollContainer } from "./ScrollContainer";
5
6
  export { default as ScrollContainerHeader } from "./ScrollContainerHeader";
6
7
  export { default as Row } from "./Table/Row";
8
+ export * from "./List";
@@ -1,6 +1,8 @@
1
1
  export { default as Accordion } from "./Collapse/Accordion";
2
2
  export { default as Flex } from "./Flex";
3
+ export { default as Box } from "./Box";
3
4
  export * from "./Modals";
4
5
  export { default as ScrollContainer } from "./ScrollContainer";
5
6
  export { default as ScrollContainerHeader } from "./ScrollContainerHeader";
6
7
  export { default as Row } from "./Table/Row";
8
+ export * from "./List";