@ledgerhq/react-ui 0.4.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/logos/LedgerLiveAltRegular.d.ts +0 -1
- package/assets/logos/LedgerLiveRegular.d.ts +0 -1
- package/components/Chart/index.d.ts +0 -1
- package/components/Table/Columns.d.ts +60 -11
- package/components/Table/Columns.js +6 -16
- package/components/Table/index.d.ts +44 -12
- package/components/Table/index.js +36 -16
- package/components/Table/stories.helper.js +13 -12
- package/components/animations/GlitchText/index.d.ts +0 -1
- package/components/asorted/Divider/index.d.ts +1 -2
- package/components/asorted/Icon/BoxedIcon.d.ts +48 -0
- package/components/asorted/Icon/BoxedIcon.js +62 -0
- package/components/asorted/Icon/Icon.d.ts +0 -2
- package/components/asorted/Icon/Icon.js +0 -7
- package/components/asorted/Icon/index.d.ts +3 -1
- package/components/asorted/Icon/index.js +3 -1
- package/components/asorted/index.d.ts +1 -1
- package/components/asorted/index.js +1 -1
- package/components/cta/Button/index.d.ts +11 -8
- package/components/cta/Button/index.js +34 -23
- package/components/cta/Link/index.d.ts +53 -4
- package/components/cta/Link/index.js +15 -11
- package/components/cta/Toggle/index.d.ts +0 -1
- package/components/form/BaseInput/index.d.ts +8 -14
- package/components/form/BaseInput/index.js +1 -1
- package/components/form/Dropdown/index.d.ts +3 -3
- package/components/form/Dropdown/index.js +9 -8
- package/components/form/DropdownGeneric/index.d.ts +36 -0
- package/components/form/DropdownGeneric/index.js +95 -0
- package/components/form/LegendInput/index.d.ts +26 -2
- package/components/form/LegendInput/index.js +3 -2
- package/components/form/NumberInput/index.d.ts +25 -3
- package/components/form/NumberInput/index.js +3 -2
- package/components/form/QrCodeInput/index.d.ts +25 -3
- package/components/form/QrCodeInput/index.js +3 -2
- package/components/form/QuantityInput/index.d.ts +26 -4
- package/components/form/QuantityInput/index.js +3 -2
- package/components/form/Radio/RadioElement.d.ts +3 -2
- package/components/form/Radio/RadioElement.js +72 -3
- package/components/form/Radio/index.d.ts +1 -1
- package/components/form/SearchInput/index.d.ts +24 -2
- package/components/form/SearchInput/index.js +3 -2
- package/components/form/SelectInput/Control.d.ts +4 -10
- package/components/form/SelectInput/Control.js +5 -8
- package/components/form/SelectInput/DropdownIndicator.d.ts +3 -10
- package/components/form/SelectInput/IndicatorsContainer.d.ts +2 -6
- package/components/form/SelectInput/IndicatorsContainer.js +1 -1
- package/components/form/SelectInput/MenuList.d.ts +3 -10
- package/components/form/SelectInput/MenuList.js +2 -1
- package/components/form/SelectInput/Option.d.ts +6 -18
- package/components/form/SelectInput/ValueContainer.d.ts +5 -14
- package/components/form/SelectInput/ValueContainer.js +1 -1
- package/components/form/SelectInput/VirtualMenuList.d.ts +2 -5
- package/components/form/SelectInput/VirtualMenuList.js +2 -1
- package/components/form/SelectInput/index.d.ts +7 -16
- package/components/form/SelectInput/index.js +10 -2
- package/components/form/index.d.ts +1 -0
- package/components/form/index.js +1 -0
- package/components/layout/Box/index.d.ts +1 -4
- package/components/layout/Drawer/index.d.ts +17 -2
- package/components/layout/Drawer/index.js +45 -36
- package/components/layout/Flex/index.d.ts +2 -5
- package/components/layout/Popin/index.d.ts +6 -11
- package/components/layout/Popin/index.js +10 -5
- package/components/layout/Side/index.d.ts +0 -1
- package/components/loaders/InfiniteLoader/index.d.ts +8 -7
- package/components/loaders/InfiniteLoader/index.js +35 -9
- package/components/loaders/ProgressLoader/index.d.ts +22 -2
- package/components/loaders/ProgressLoader/index.js +10 -12
- package/components/message/Alert/index.d.ts +31 -3
- package/components/message/Alert/index.js +30 -23
- package/components/message/Log/index.d.ts +5 -2
- package/components/message/Log/index.js +3 -4
- package/components/message/Tip/index.d.ts +0 -1
- package/components/message/Tooltip/index.d.ts +0 -1
- package/components/navigation/Aside/index.d.ts +2 -5
- package/components/navigation/Breadcrumb/index.js +1 -1
- package/components/navigation/FlowStepper/index.d.ts +77 -0
- package/components/navigation/FlowStepper/index.js +35 -0
- package/components/navigation/index.d.ts +1 -0
- package/components/navigation/index.js +1 -0
- package/components/navigation/progress/ProgressBar/Onboarding.d.ts +0 -1
- package/components/navigation/progress/Stepper/index.d.ts +27 -10
- package/components/navigation/progress/Stepper/index.js +37 -18
- package/components/navigation/sideBar/Item/Item.d.ts +0 -1
- package/components/navigation/sideBar/Logo/Logo.d.ts +0 -1
- package/components/navigation/sideBar/SideBar/SideBar.d.ts +0 -1
- package/components/navigation/sideBar/SideBar/SideBar.js +9 -7
- package/components/navigation/sideBar/Toggle/Toggle.d.ts +0 -1
- package/components/styled.d.ts +8 -5
- package/components/styled.js +2 -2
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +6 -6
- package/styles/InvertTheme.d.ts +4 -1
- package/styles/InvertTheme.js +5 -5
- package/styles/index.d.ts +1 -0
- package/styles/index.js +1 -0
- package/styles/theme.d.ts +1 -1
- package/styles/theme.js +8 -8
- package/components/loaders/InfiniteLoader/image.d.ts +0 -2
- package/components/loaders/InfiniteLoader/image.js +0 -1
|
@@ -1,34 +1,83 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Props as IconProps } from "../asorted/Icon";
|
|
3
3
|
import Text, { TextProps } from "../asorted/Text";
|
|
4
|
+
export interface Column<T> {
|
|
5
|
+
/**
|
|
6
|
+
* A function called to render each cell of the column.
|
|
7
|
+
*/
|
|
8
|
+
render: (props: CellProps<T>) => React.ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* A valid grid template [value](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns#values).
|
|
11
|
+
* This layout is applied to every cell of the column.
|
|
12
|
+
* Default to "min-content" - the largest minimal content contribution of the grid item.
|
|
13
|
+
*/
|
|
14
|
+
layout?: string;
|
|
15
|
+
/**
|
|
16
|
+
* A function called to render the header cell.
|
|
17
|
+
* If omitted the rendered header element will be an empty div.
|
|
18
|
+
*/
|
|
19
|
+
header?: () => React.ReactNode;
|
|
20
|
+
}
|
|
4
21
|
export interface CellProps<T> {
|
|
22
|
+
/**
|
|
23
|
+
* The cell element.
|
|
24
|
+
*/
|
|
5
25
|
elt: T;
|
|
26
|
+
/**
|
|
27
|
+
* The row index.
|
|
28
|
+
*/
|
|
6
29
|
rowIndex: number;
|
|
30
|
+
/**
|
|
31
|
+
* The column index.
|
|
32
|
+
*/
|
|
7
33
|
columnIndex: number;
|
|
8
34
|
}
|
|
9
|
-
declare type HeaderFn = () => React.ReactNode;
|
|
10
|
-
export interface Column<T> {
|
|
11
|
-
layout?: string;
|
|
12
|
-
render: (props: CellProps<T>) => React.ReactNode;
|
|
13
|
-
header?: HeaderFn;
|
|
14
|
-
}
|
|
15
35
|
/**
|
|
16
36
|
* A column which contains a single icon and that has a fixed width.
|
|
17
37
|
*/
|
|
18
|
-
|
|
38
|
+
declare function iconColumn<T>({ props, header, layout, }: {
|
|
39
|
+
/**
|
|
40
|
+
* An object containing the unerlying <Text /> wrapper props as well as
|
|
41
|
+
* the "name" and "weight" props of the unerlying <Icon />.
|
|
42
|
+
*/
|
|
19
43
|
props: (elt: T) => Pick<IconProps, "name" | "weight"> & TextProps;
|
|
20
|
-
|
|
44
|
+
/**
|
|
45
|
+
* An optional render function to display the column header.
|
|
46
|
+
*/
|
|
47
|
+
header?: () => React.ReactNode;
|
|
48
|
+
/**
|
|
49
|
+
* The grid column layout, by default "min-content".
|
|
50
|
+
*/
|
|
21
51
|
layout?: string;
|
|
22
52
|
}): Column<T>;
|
|
53
|
+
export { iconColumn as icon };
|
|
23
54
|
/**
|
|
24
55
|
* A column that contains a title and a subtitle.
|
|
25
56
|
*/
|
|
26
|
-
|
|
57
|
+
declare function textColumn<T>({ title, subtitle, header, layout, titleProps, subtitleProps, }: {
|
|
58
|
+
/**
|
|
59
|
+
* An optional title.
|
|
60
|
+
*/
|
|
27
61
|
title?: (elt: T) => React.ReactNode;
|
|
62
|
+
/**
|
|
63
|
+
* An optional subtitle.
|
|
64
|
+
*/
|
|
28
65
|
subtitle?: (elt: T) => React.ReactNode;
|
|
29
|
-
|
|
66
|
+
/**
|
|
67
|
+
* An optional render function to display the column header.
|
|
68
|
+
*/
|
|
69
|
+
header?: () => React.ReactNode;
|
|
70
|
+
/**
|
|
71
|
+
* The grid column layout, by default "auto".
|
|
72
|
+
*/
|
|
30
73
|
layout?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Optional extra props passed to the title <Text /> wrapper.
|
|
76
|
+
*/
|
|
31
77
|
titleProps?: (elt: T) => Partial<React.ComponentProps<typeof Text>>;
|
|
78
|
+
/**
|
|
79
|
+
* Optional extra props passed to the subtitle <Text /> wrapper.
|
|
80
|
+
*/
|
|
32
81
|
subtitleProps?: (elt: T) => Partial<React.ComponentProps<typeof Text>>;
|
|
33
82
|
}): Column<T>;
|
|
34
|
-
export {};
|
|
83
|
+
export { textColumn as text };
|
|
@@ -16,38 +16,28 @@ import Text from "../asorted/Text";
|
|
|
16
16
|
/**
|
|
17
17
|
* A column which contains a single icon and that has a fixed width.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
function iconColumn({ props, header, layout, }) {
|
|
20
20
|
return {
|
|
21
21
|
layout: layout || "min-content",
|
|
22
22
|
render: ({ elt }) => {
|
|
23
23
|
const _a = props(elt), { name, weight } = _a, textProps = __rest(_a, ["name", "weight"]);
|
|
24
|
-
return (React.createElement(Text, Object.assign({}, textProps, { style: { display: "flex" } }),
|
|
24
|
+
return (React.createElement(Text, Object.assign({}, textProps, { style: { display: "flex", alignItems: "center" } }),
|
|
25
25
|
React.createElement(Icon, { name: name, weight: weight })));
|
|
26
26
|
},
|
|
27
27
|
header,
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
+
export { iconColumn as icon };
|
|
30
31
|
/**
|
|
31
32
|
* A column that contains a title and a subtitle.
|
|
32
33
|
*/
|
|
33
|
-
|
|
34
|
-
// An optional title.
|
|
35
|
-
title,
|
|
36
|
-
// An optional subtitle.
|
|
37
|
-
subtitle,
|
|
38
|
-
// An optional render function to display the column header.
|
|
39
|
-
header,
|
|
40
|
-
// The grid column layout, by default "auto".
|
|
41
|
-
layout,
|
|
42
|
-
// Optional extra props passed to the title <Text /> wrapper.
|
|
43
|
-
titleProps,
|
|
44
|
-
// Optional extra props passed to the subtitle <Text /> wrapper.
|
|
45
|
-
subtitleProps, }) {
|
|
34
|
+
function textColumn({ title, subtitle, header, layout, titleProps, subtitleProps, }) {
|
|
46
35
|
return {
|
|
47
36
|
layout: layout || "auto",
|
|
48
|
-
render: ({ elt }) => (React.createElement(FlexBox, { flexDirection: "column" },
|
|
37
|
+
render: ({ elt }) => (React.createElement(FlexBox, { flexDirection: "column", justifyContent: "center" },
|
|
49
38
|
title && (React.createElement(Text, Object.assign({ fontWeight: "medium", variant: "body", textOverflow: "ellipsis", overflow: "hidden", color: "neutral.c100" }, ((titleProps && titleProps(elt)) || {})), title(elt))),
|
|
50
39
|
subtitle && (React.createElement(Text, Object.assign({ fontWeight: "medium", variant: "paragraph", textOverflow: "ellipsis", overflow: "hidden", color: "neutral.c80" }, ((subtitleProps && subtitleProps(elt)) || {})), subtitle(elt))))),
|
|
51
40
|
header,
|
|
52
41
|
};
|
|
53
42
|
}
|
|
43
|
+
export { textColumn as text };
|
|
@@ -8,27 +8,59 @@ export interface ContainerExtraProps extends BorderProps, BaseStyledProps {
|
|
|
8
8
|
}
|
|
9
9
|
export interface ContainerProps extends ContainerExtraProps, GridProps {
|
|
10
10
|
}
|
|
11
|
-
export declare const
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
export declare const ExtraRowContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
12
|
+
gridColumn: string;
|
|
13
|
+
} & GridColumnProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>, "gridColumn">;
|
|
14
|
+
export declare type RowContainerProps = {
|
|
15
|
+
rowIndex: number;
|
|
16
|
+
};
|
|
17
|
+
export declare const RowContainer: import("styled-components").StyledComponent<"div", 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>>> & BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
|
|
18
|
+
columnGap?: string | number | undefined;
|
|
19
|
+
rowGap?: string | number | undefined;
|
|
20
|
+
color?: string | undefined;
|
|
21
|
+
} & RowContainerProps, "overflow" | "p" | "color" | "size" | "rowGap" | "alignContent" | "alignItems" | "alignSelf" | "backgroundColor" | "borderBottomColor" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "borderBottomStyle" | "borderBottomWidth" | "borderLeftColor" | "borderLeftStyle" | "borderLeftWidth" | "borderRightColor" | "borderRightStyle" | "borderRightWidth" | "borderTopColor" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStyle" | "borderTopWidth" | "bottom" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "order" | "overflowX" | "overflowY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "top" | "verticalAlign" | "width" | "zIndex" | "border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderStyle" | "borderTop" | "borderWidth" | "flex" | "margin" | "padding" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "bg" | "borderX" | "borderY">;
|
|
22
|
+
interface CommonProps<T> {
|
|
23
|
+
/** Table data */
|
|
14
24
|
data: T[];
|
|
25
|
+
/** Columns used to render table cells and headers. */
|
|
15
26
|
columns: Column<T>[];
|
|
16
|
-
|
|
27
|
+
/**
|
|
28
|
+
* An optional rendering function that will get called after each row render.
|
|
29
|
+
* Can be used to display additional rows and columns dynamically.
|
|
30
|
+
*/
|
|
17
31
|
extraRender?: (elt: T, index: number) => React.ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* A render function that can be used to wrap each row of the table inside an custom element.
|
|
34
|
+
*/
|
|
35
|
+
renderRow?: (rowIndex: number, children: React.ReactNode) => React.ReactNode;
|
|
18
36
|
}
|
|
19
|
-
export interface
|
|
20
|
-
|
|
21
|
-
|
|
37
|
+
export interface Props<T> extends CommonProps<T>, Omit<ContainerProps, "columns" | "color"> {
|
|
38
|
+
/**
|
|
39
|
+
* Renders headers if set to true.
|
|
40
|
+
*/
|
|
41
|
+
withHeaders?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface RowProps<T> extends CommonProps<T> {
|
|
22
44
|
render?: (args: {
|
|
23
45
|
column: Column<T>;
|
|
24
46
|
rowIndex: number;
|
|
25
47
|
columnIndex: number;
|
|
26
48
|
children: React.ReactNode;
|
|
27
49
|
}) => React.ReactNode;
|
|
28
|
-
extraRender?: (elt: T, index: number) => React.ReactNode;
|
|
29
50
|
}
|
|
30
|
-
declare function RowsComponent<T>({ data, columns, extraRender,
|
|
51
|
+
declare function RowsComponent<T>({ data, columns, render, extraRender, renderRow, }: RowProps<T>): JSX.Element;
|
|
31
52
|
export declare const Rows: typeof RowsComponent;
|
|
32
|
-
declare function Table<T>({ data, columns, withHeaders, extraRender, ...containerProps }: Props<T>): JSX.Element;
|
|
33
|
-
declare
|
|
34
|
-
|
|
53
|
+
declare function Table<T>({ data, columns, withHeaders, extraRender, renderRow, ...containerProps }: Props<T>): JSX.Element;
|
|
54
|
+
declare namespace Table {
|
|
55
|
+
var Columns: typeof import("./Columns");
|
|
56
|
+
var ExtraRowContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
57
|
+
gridColumn: string;
|
|
58
|
+
} & GridColumnProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>, "gridColumn">;
|
|
59
|
+
var RowContainer: import("styled-components").StyledComponent<"div", 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>>> & BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
|
|
60
|
+
columnGap?: string | number | undefined;
|
|
61
|
+
rowGap?: string | number | undefined;
|
|
62
|
+
color?: string | undefined;
|
|
63
|
+
} & RowContainerProps, "overflow" | "p" | "color" | "size" | "rowGap" | "alignContent" | "alignItems" | "alignSelf" | "backgroundColor" | "borderBottomColor" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "borderBottomStyle" | "borderBottomWidth" | "borderLeftColor" | "borderLeftStyle" | "borderLeftWidth" | "borderRightColor" | "borderRightStyle" | "borderRightWidth" | "borderTopColor" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStyle" | "borderTopWidth" | "bottom" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "order" | "overflowX" | "overflowY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "top" | "verticalAlign" | "width" | "zIndex" | "border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderStyle" | "borderTop" | "borderWidth" | "flex" | "margin" | "padding" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "bg" | "borderX" | "borderY">;
|
|
64
|
+
}
|
|
65
|
+
declare const memoTable: typeof Table;
|
|
66
|
+
export default memoTable;
|
|
@@ -13,27 +13,40 @@ import React, { memo, useMemo } from "react";
|
|
|
13
13
|
import styled from "styled-components";
|
|
14
14
|
import { border, gridColumn } from "styled-system";
|
|
15
15
|
import Grid from "../layout/Grid";
|
|
16
|
-
|
|
16
|
+
import Flex from "../layout/Flex";
|
|
17
|
+
import * as Columns from "./Columns";
|
|
18
|
+
const Container = styled(Grid) `
|
|
17
19
|
${border}
|
|
18
20
|
`;
|
|
19
|
-
export const ExtraRowContainer = styled.div `
|
|
21
|
+
export const ExtraRowContainer = styled.div.attrs({ gridColumn: "1 / -1" }) `
|
|
20
22
|
${gridColumn}
|
|
21
23
|
`;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
export const RowContainer = styled(Flex) `
|
|
25
|
+
display: contents;
|
|
26
|
+
`;
|
|
27
|
+
function RowsComponent({ data, columns, render, extraRender, renderRow, }) {
|
|
28
|
+
return (React.createElement(React.Fragment, { key: "row-component" }, data.map((elt, rowIndex) => {
|
|
29
|
+
const row = (React.createElement(React.Fragment, null,
|
|
30
|
+
columns.map((column, columnIndex) => (React.createElement(React.Fragment, { key: `row-component-column-${rowIndex}${columnIndex}` }, render
|
|
31
|
+
? render({
|
|
32
|
+
column,
|
|
33
|
+
rowIndex,
|
|
34
|
+
columnIndex,
|
|
35
|
+
children: column.render({ elt, rowIndex, columnIndex }),
|
|
36
|
+
})
|
|
37
|
+
: column.render({ elt, rowIndex, columnIndex })))),
|
|
38
|
+
(extraRender && extraRender(elt, rowIndex)) || null));
|
|
39
|
+
if (renderRow) {
|
|
40
|
+
return renderRow(rowIndex, row);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return React.createElement(React.Fragment, { key: `row-component-row-${rowIndex}` }, row);
|
|
44
|
+
}
|
|
45
|
+
})));
|
|
33
46
|
}
|
|
34
47
|
export const Rows = memo(RowsComponent);
|
|
35
48
|
function Table(_a) {
|
|
36
|
-
var { data, columns, withHeaders, extraRender } = _a, containerProps = __rest(_a, ["data", "columns", "withHeaders", "extraRender"]);
|
|
49
|
+
var { data, columns, withHeaders, extraRender, renderRow } = _a, containerProps = __rest(_a, ["data", "columns", "withHeaders", "extraRender", "renderRow"]);
|
|
37
50
|
const gridTemplateColumns = useMemo(() => columns.reduce((acc, col) => `${acc} ${col.layout || "auto"}`, ""), [columns]);
|
|
38
51
|
const headers = useMemo(() => withHeaders
|
|
39
52
|
? columns.reduce((acc, col, index) => [
|
|
@@ -43,6 +56,13 @@ function Table(_a) {
|
|
|
43
56
|
: null, [withHeaders, columns]);
|
|
44
57
|
return (React.createElement(Container, Object.assign({ gridTemplateColumns: gridTemplateColumns, gridAutoRows: "auto", columns: "none", alignItems: "center" }, containerProps),
|
|
45
58
|
headers,
|
|
46
|
-
React.createElement(Rows, { data: data, columns: columns, extraRender: extraRender })));
|
|
59
|
+
React.createElement(Rows, { data: data, columns: columns, extraRender: extraRender, renderRow: renderRow })));
|
|
47
60
|
}
|
|
48
|
-
|
|
61
|
+
Table.Columns = Columns;
|
|
62
|
+
Table.ExtraRowContainer = ExtraRowContainer;
|
|
63
|
+
Table.RowContainer = RowContainer;
|
|
64
|
+
const memoTable = memo(Table);
|
|
65
|
+
memoTable.Columns = Columns;
|
|
66
|
+
memoTable.RowContainer = RowContainer;
|
|
67
|
+
memoTable.ExtraRowContainer = ExtraRowContainer;
|
|
68
|
+
export default memoTable;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { useTheme } from "styled-components";
|
|
3
3
|
import Text from "../asorted/Text";
|
|
4
|
-
import
|
|
4
|
+
import Table from "./index";
|
|
5
|
+
const { Columns } = Table;
|
|
5
6
|
function Header({ children }) {
|
|
6
7
|
const theme = useTheme();
|
|
7
8
|
return (React.createElement(Text, { fontWeight: "semiBold", variant: "paragraph", style: { borderBottom: `1px solid ${theme.colors.neutral.c40}` }, mx: -4, px: 4, pb: 8 }, children));
|
|
@@ -42,27 +43,27 @@ export const balance = {
|
|
|
42
43
|
},
|
|
43
44
|
],
|
|
44
45
|
columns: [
|
|
45
|
-
|
|
46
|
+
Columns.text({
|
|
46
47
|
header: () => React.createElement(Header, null, "Currency"),
|
|
47
48
|
title: (elt) => elt.currency,
|
|
48
49
|
}),
|
|
49
|
-
|
|
50
|
+
Columns.text({
|
|
50
51
|
header: () => React.createElement(Header, null, "Amount"),
|
|
51
52
|
title: (elt) => elt.amount,
|
|
52
53
|
subtitle: (elt) => elt.counterValue,
|
|
53
54
|
}),
|
|
54
|
-
|
|
55
|
+
Columns.text({
|
|
55
56
|
header: () => React.createElement(Header, null, "Address"),
|
|
56
57
|
subtitle: (elt) => elt.address,
|
|
57
58
|
}),
|
|
58
|
-
|
|
59
|
+
Columns.text({
|
|
59
60
|
header: () => React.createElement(Header, null, "Evolution"),
|
|
60
61
|
subtitle: (elt) => (elt.evolution > 0 ? "+" : "") + elt.evolution,
|
|
61
62
|
subtitleProps: (elt) => ({
|
|
62
63
|
color: elt.evolution < 0 ? "error.c100" : "success.c100",
|
|
63
64
|
}),
|
|
64
65
|
}),
|
|
65
|
-
|
|
66
|
+
Columns.icon({
|
|
66
67
|
header: () => React.createElement(Header, null, "\u00A0"),
|
|
67
68
|
props: (elt) => ({
|
|
68
69
|
name: "StarSolid",
|
|
@@ -137,33 +138,33 @@ export const accounts = {
|
|
|
137
138
|
layout: "64px",
|
|
138
139
|
render: ({ elt }) => elt.currency.abbrev === "BTC" ? svgBtc : elt.currency.abbrev === "ETH" ? svgEth : svgUsdt,
|
|
139
140
|
},
|
|
140
|
-
|
|
141
|
+
Columns.text({
|
|
141
142
|
layout: "2fr",
|
|
142
143
|
title: (elt) => elt.name,
|
|
143
144
|
subtitle: (elt) => elt.currency.name,
|
|
144
145
|
}),
|
|
145
|
-
|
|
146
|
+
Columns.icon({
|
|
146
147
|
props: (elt) => ({
|
|
147
148
|
name: elt.synchronized ? "CircledCheck" : "Clock",
|
|
148
149
|
color: elt.synchronized ? "success.c100" : "neutral.c80",
|
|
149
150
|
}),
|
|
150
151
|
}),
|
|
151
|
-
|
|
152
|
+
Columns.text({
|
|
152
153
|
layout: "1fr",
|
|
153
154
|
subtitle: (elt) => elt.currency.abbrev,
|
|
154
155
|
}),
|
|
155
|
-
|
|
156
|
+
Columns.text({
|
|
156
157
|
layout: "1fr",
|
|
157
158
|
title: (elt) => elt.amount,
|
|
158
159
|
}),
|
|
159
|
-
|
|
160
|
+
Columns.text({
|
|
160
161
|
layout: "1fr",
|
|
161
162
|
subtitle: (elt) => (elt.evolution > 0 ? "+" : "") + elt.evolution,
|
|
162
163
|
subtitleProps: (elt) => ({
|
|
163
164
|
color: elt.evolution < 0 ? "error.c100" : "success.c100",
|
|
164
165
|
}),
|
|
165
166
|
}),
|
|
166
|
-
|
|
167
|
+
Columns.icon({
|
|
167
168
|
props: (elt) => ({
|
|
168
169
|
name: "StarSolid",
|
|
169
170
|
color: elt.starred ? "neutral.c100" : "neutral.c70",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from "react";
|
|
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 IconProps = {
|
|
6
|
+
size?: number;
|
|
7
|
+
color?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare type IconBoxProps = {
|
|
10
|
+
/**
|
|
11
|
+
* 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.
|
|
12
|
+
*/
|
|
13
|
+
Badge?: React.ComponentType<IconProps> | ((props: IconProps) => JSX.Element);
|
|
14
|
+
/**
|
|
15
|
+
* Color of the border
|
|
16
|
+
*/
|
|
17
|
+
borderColor?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Badge color, will be applied to the component provided in the `Badge` prop
|
|
20
|
+
*/
|
|
21
|
+
badgeColor?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Badge size, will be applied to the component provided in the `Badge` prop
|
|
24
|
+
*/
|
|
25
|
+
badgeSize?: number;
|
|
26
|
+
children?: JSX.Element;
|
|
27
|
+
/**
|
|
28
|
+
* Box size for preview
|
|
29
|
+
*/
|
|
30
|
+
size?: number;
|
|
31
|
+
};
|
|
32
|
+
export declare type BoxedIconProps = IconBoxProps & {
|
|
33
|
+
/**
|
|
34
|
+
* 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.
|
|
35
|
+
*/
|
|
36
|
+
Icon: React.ComponentType<IconProps> | ((props: IconProps) => JSX.Element);
|
|
37
|
+
/**
|
|
38
|
+
* Icon size, will be applied to the component provided in the `Icon` prop
|
|
39
|
+
*/
|
|
40
|
+
iconSize?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Icon color, will be applied to the component provided in the `Icon` prop
|
|
43
|
+
*/
|
|
44
|
+
iconColor?: string;
|
|
45
|
+
};
|
|
46
|
+
export declare const IconBox: ({ Badge, size, children, borderColor, badgeColor, badgeSize, }: IconBoxProps) => JSX.Element;
|
|
47
|
+
declare const BoxedIcon: ({ Icon, iconSize, iconColor, ...iconBoxProps }: BoxedIconProps) => JSX.Element;
|
|
48
|
+
export default BoxedIcon;
|
|
@@ -0,0 +1,62 @@
|
|
|
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";
|
|
14
|
+
import Flex from "../../layout/Flex";
|
|
15
|
+
export const DEFAULT_BOX_SIZE = 40;
|
|
16
|
+
export const DEFAULT_ICON_SIZE = 16;
|
|
17
|
+
export const DEFAULT_BADGE_SIZE = 20;
|
|
18
|
+
function getClipRectangleSize(badgeSize) {
|
|
19
|
+
return (3 / 4) * badgeSize;
|
|
20
|
+
}
|
|
21
|
+
const getTopRightSquareClippedPolygon = (boxSize, rectangleSize) => {
|
|
22
|
+
// clipping path that hides top right square of size `${rectangleSize}px`
|
|
23
|
+
const diff = boxSize - rectangleSize;
|
|
24
|
+
return `polygon(0 0, 0 0, 0 0, ${diff}px 0, ${diff}px ${rectangleSize}px, 100% ${rectangleSize}px, 100% 100%, 100% 100%, 100% 100%, 0 100%, 0 100%, 0 100%)`;
|
|
25
|
+
};
|
|
26
|
+
const Container = styled(Flex).attrs((p) => ({
|
|
27
|
+
heigth: p.size,
|
|
28
|
+
width: p.size,
|
|
29
|
+
alignItems: "center",
|
|
30
|
+
justifyContent: "center",
|
|
31
|
+
position: "relative",
|
|
32
|
+
})) ``;
|
|
33
|
+
const IconBoxBackground = styled(Flex) `
|
|
34
|
+
position: absolute;
|
|
35
|
+
height: ${(p) => p.size}px;
|
|
36
|
+
width: ${(p) => p.size}px;
|
|
37
|
+
${(p) => {
|
|
38
|
+
return (p.hasBadge &&
|
|
39
|
+
`clip-path: ${getTopRightSquareClippedPolygon(p.size, getClipRectangleSize(p.badgeSize))};`);
|
|
40
|
+
}};
|
|
41
|
+
border-radius: ${(p) => p.theme.radii[2]}px;
|
|
42
|
+
`;
|
|
43
|
+
const BadgeContainer = styled.div `
|
|
44
|
+
position: absolute;
|
|
45
|
+
${(p) => `
|
|
46
|
+
top: -${p.badgeSize / 2 - 2}px;
|
|
47
|
+
right: -${p.badgeSize / 2 - 2}px;`}
|
|
48
|
+
`;
|
|
49
|
+
export const IconBox = ({ Badge, size = DEFAULT_BOX_SIZE, children, borderColor = "neutral.c40", badgeColor, badgeSize = DEFAULT_BADGE_SIZE, }) => {
|
|
50
|
+
const hasBadge = !!Badge;
|
|
51
|
+
return (React.createElement(Container, { size: size },
|
|
52
|
+
React.createElement(IconBoxBackground, { size: size, badgeSize: badgeSize, hasBadge: hasBadge, border: "1px solid", borderColor: borderColor }),
|
|
53
|
+
children,
|
|
54
|
+
hasBadge && (React.createElement(BadgeContainer, { badgeSize: badgeSize },
|
|
55
|
+
React.createElement(Badge, { size: badgeSize, color: badgeColor })))));
|
|
56
|
+
};
|
|
57
|
+
const BoxedIcon = (_a) => {
|
|
58
|
+
var { Icon, iconSize = DEFAULT_ICON_SIZE, iconColor } = _a, iconBoxProps = __rest(_a, ["Icon", "iconSize", "iconColor"]);
|
|
59
|
+
return (React.createElement(IconBox, Object.assign({}, iconBoxProps),
|
|
60
|
+
React.createElement(Icon, { size: iconSize || DEFAULT_ICON_SIZE, color: iconColor })));
|
|
61
|
+
};
|
|
62
|
+
export default BoxedIcon;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
export declare type Props = {
|
|
3
2
|
name: string;
|
|
4
3
|
size?: number;
|
|
@@ -7,5 +6,4 @@ export declare type Props = {
|
|
|
7
6
|
};
|
|
8
7
|
export declare const iconNames: string[];
|
|
9
8
|
declare const Icon: ({ name, size, color, weight, }: Props) => JSX.Element | null;
|
|
10
|
-
export declare const IconBox: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
11
9
|
export default Icon;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as icons from "@ledgerhq/icons-ui/react";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import styled from "styled-components";
|
|
4
3
|
export const iconNames = Array.from(Object.keys(icons).reduce((set, rawKey) => {
|
|
5
4
|
const key = rawKey
|
|
6
5
|
.replace(/(.+)(Regular|Light|UltraLight|Thin|Medium)+$/g, "$1")
|
|
@@ -18,10 +17,4 @@ const Icon = ({ name, size = 16, color = "currentColor", weight = "Medium", }) =
|
|
|
18
17
|
}
|
|
19
18
|
return null;
|
|
20
19
|
};
|
|
21
|
-
export const IconBox = styled.div `
|
|
22
|
-
padding: ${(p) => p.theme.space[6]}px;
|
|
23
|
-
border: 1px solid ${(p) => p.theme.colors.neutral.c40};
|
|
24
|
-
border-radius: ${(p) => p.theme.radii[2]}px;
|
|
25
|
-
display: inline-flex;
|
|
26
|
-
`;
|
|
27
20
|
export default Icon;
|
|
@@ -14,13 +14,14 @@ interface BaseProps extends BaseStyledProps, BordersProps {
|
|
|
14
14
|
iconButton?: boolean;
|
|
15
15
|
disabled?: boolean;
|
|
16
16
|
}
|
|
17
|
-
export interface ButtonProps extends BaseProps {
|
|
17
|
+
export interface ButtonProps extends BaseProps, React.RefAttributes<HTMLButtonElement> {
|
|
18
|
+
iconName?: string;
|
|
18
19
|
Icon?: React.ComponentType<{
|
|
19
20
|
size: number;
|
|
20
21
|
color?: string;
|
|
21
22
|
}>;
|
|
22
23
|
children?: React.ReactNode;
|
|
23
|
-
onClick
|
|
24
|
+
onClick?: (event: React.SyntheticEvent<HTMLButtonElement>) => void;
|
|
24
25
|
iconSize?: number;
|
|
25
26
|
style?: React.CSSProperties;
|
|
26
27
|
}
|
|
@@ -29,13 +30,15 @@ export declare const Base: import("styled-components").StyledComponent<"button",
|
|
|
29
30
|
fontFamily: string;
|
|
30
31
|
fontSize: number;
|
|
31
32
|
} & BaseProps, "fontFamily" | "fontSize">;
|
|
32
|
-
declare const
|
|
33
|
-
({ Icon, iconPosition, iconSize, children, onClick, ...props }: ButtonProps): React.ReactElement;
|
|
33
|
+
declare const ButtonWithRef: {
|
|
34
|
+
({ Icon, iconPosition, iconSize, children, onClick, iconName, ...props }: ButtonProps, ref?: React.ForwardedRef<HTMLButtonElement> | undefined): React.ReactElement;
|
|
34
35
|
Unstyled: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
|
|
36
|
+
Expand: React.ForwardRefExoticComponent<Pick<ButtonProps & {
|
|
37
|
+
onToggle?: ((arg0: boolean) => void) | undefined;
|
|
38
|
+
}, "overflow" | "p" | "style" | "key" | "color" | "children" | "onClick" | "variant" | "size" | "rowGap" | "alignContent" | "alignItems" | "alignSelf" | "backgroundColor" | "borderBottomColor" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "borderBottomStyle" | "borderBottomWidth" | "borderLeftColor" | "borderLeftStyle" | "borderLeftWidth" | "borderRightColor" | "borderRightStyle" | "borderRightWidth" | "borderTopColor" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStyle" | "borderTopWidth" | "bottom" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontSize" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "order" | "overflowX" | "overflowY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "top" | "verticalAlign" | "width" | "zIndex" | "border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderStyle" | "borderTop" | "borderWidth" | "flex" | "margin" | "outline" | "padding" | "disabled" | "onToggle" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "bg" | "borderX" | "borderY" | "Icon" | "iconSize" | "ff" | "iconPosition" | "iconButton" | "iconName"> & React.RefAttributes<HTMLButtonElement>>;
|
|
35
39
|
};
|
|
36
|
-
export declare type
|
|
40
|
+
export declare type ButtonExpandProps = React.PropsWithChildren<ButtonProps & {
|
|
37
41
|
onToggle?: (arg0: boolean) => void;
|
|
38
|
-
onClick?: (arg0: React.SyntheticEvent<HTMLButtonElement>) => void;
|
|
39
42
|
}>;
|
|
40
|
-
export declare
|
|
41
|
-
export default
|
|
43
|
+
export declare function ButtonExpand({ onToggle, onClick, ...props }: ButtonExpandProps, ref?: React.ForwardedRef<HTMLButtonElement>): React.ReactElement;
|
|
44
|
+
export default ButtonWithRef;
|