@ledgerhq/react-ui 0.4.0 → 0.5.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 (57) hide show
  1. package/assets/logos/LedgerLiveAltRegular.d.ts +0 -1
  2. package/assets/logos/LedgerLiveRegular.d.ts +0 -1
  3. package/components/Chart/index.d.ts +0 -1
  4. package/components/Table/Columns.d.ts +60 -11
  5. package/components/Table/Columns.js +6 -16
  6. package/components/Table/index.d.ts +44 -12
  7. package/components/Table/index.js +36 -16
  8. package/components/Table/stories.helper.js +13 -12
  9. package/components/animations/GlitchText/index.d.ts +0 -1
  10. package/components/asorted/Divider/index.d.ts +0 -1
  11. package/components/asorted/Icon/BoxedIcon.d.ts +48 -0
  12. package/components/asorted/Icon/BoxedIcon.js +58 -0
  13. package/components/asorted/Icon/Icon.d.ts +0 -2
  14. package/components/asorted/Icon/Icon.js +0 -7
  15. package/components/asorted/Icon/index.d.ts +3 -1
  16. package/components/asorted/Icon/index.js +3 -1
  17. package/components/cta/Link/index.d.ts +53 -4
  18. package/components/cta/Link/index.js +15 -11
  19. package/components/cta/Toggle/index.d.ts +0 -1
  20. package/components/form/BaseInput/index.d.ts +8 -14
  21. package/components/form/Dropdown/index.d.ts +0 -1
  22. package/components/form/LegendInput/index.d.ts +26 -2
  23. package/components/form/LegendInput/index.js +3 -2
  24. package/components/form/NumberInput/index.d.ts +25 -3
  25. package/components/form/NumberInput/index.js +3 -2
  26. package/components/form/QrCodeInput/index.d.ts +25 -3
  27. package/components/form/QrCodeInput/index.js +3 -2
  28. package/components/form/QuantityInput/index.d.ts +26 -4
  29. package/components/form/QuantityInput/index.js +3 -2
  30. package/components/form/SearchInput/index.d.ts +24 -2
  31. package/components/form/SearchInput/index.js +3 -2
  32. package/components/form/SelectInput/Control.d.ts +2 -2
  33. package/components/form/SelectInput/Control.js +3 -7
  34. package/components/form/SelectInput/DropdownIndicator.d.ts +0 -1
  35. package/components/form/SelectInput/IndicatorsContainer.d.ts +0 -1
  36. package/components/form/SelectInput/MenuList.d.ts +0 -1
  37. package/components/form/SelectInput/index.js +1 -1
  38. package/components/layout/Box/index.d.ts +1 -4
  39. package/components/layout/Flex/index.d.ts +2 -5
  40. package/components/layout/Popin/index.d.ts +4 -10
  41. package/components/layout/Side/index.d.ts +0 -1
  42. package/components/loaders/ProgressLoader/index.d.ts +0 -1
  43. package/components/message/Alert/index.d.ts +22 -3
  44. package/components/message/Alert/index.js +31 -23
  45. package/components/message/Tip/index.d.ts +0 -1
  46. package/components/message/Tooltip/index.d.ts +0 -1
  47. package/components/navigation/Aside/index.d.ts +2 -5
  48. package/components/navigation/Breadcrumb/index.js +1 -1
  49. package/components/navigation/progress/ProgressBar/Onboarding.d.ts +0 -1
  50. package/components/navigation/sideBar/Item/Item.d.ts +0 -1
  51. package/components/navigation/sideBar/Logo/Logo.d.ts +0 -1
  52. package/components/navigation/sideBar/SideBar/SideBar.d.ts +0 -1
  53. package/components/navigation/sideBar/Toggle/Toggle.d.ts +0 -1
  54. package/components/styled.d.ts +8 -5
  55. package/components/styled.js +2 -2
  56. package/package.json +2 -2
  57. package/styles/theme.js +1 -1
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare type Props = {
3
2
  width?: number | string;
4
3
  height?: number | string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare type Props = {
3
2
  width?: number | string;
4
3
  height?: number | string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ChartProps } from "react-chartjs-2";
3
2
  import "chartjs-adapter-moment";
4
3
  import type { Item, timeOptions } from "./types";
@@ -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
- export declare function IconColumn<T>({ props, header, layout, }: {
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
- header?: HeaderFn;
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
- export declare function TextColumn<T>({ title, subtitle, header, layout, titleProps, subtitleProps, }: {
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
- header?: HeaderFn;
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
- export function IconColumn({ props, header, layout, }) {
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
- export function TextColumn({
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 Container: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, GridProps & ContainerExtraProps, never>;
12
- export declare const ExtraRowContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, GridColumnProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>, never>;
13
- export interface Props<T> extends Omit<ContainerProps, "columns" | "color"> {
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
- withHeaders?: boolean;
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 RowProps<T> {
20
- data: T[];
21
- columns: Column<T>[];
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, render }: RowProps<T>): JSX.Element;
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 const _default: typeof Table;
34
- export default _default;
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
- export const Container = styled(Grid) `
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
- function RowsComponent({ data, columns, extraRender, render }) {
23
- return (React.createElement(React.Fragment, { key: "row-component" }, data.map((elt, rowIndex) => (React.createElement(React.Fragment, { key: `row-component-row-${rowIndex}` },
24
- columns.map((column, columnIndex) => (React.createElement(React.Fragment, { key: `row-component-column-${rowIndex}${columnIndex}` }, render
25
- ? render({
26
- column,
27
- rowIndex,
28
- columnIndex,
29
- children: column.render({ elt, rowIndex, columnIndex }),
30
- })
31
- : column.render({ elt, rowIndex, columnIndex })))),
32
- (extraRender && extraRender(elt, rowIndex)) || null)))));
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
- export default memo(Table);
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 { IconColumn, TextColumn } from "./Columns";
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
- TextColumn({
46
+ Columns.text({
46
47
  header: () => React.createElement(Header, null, "Currency"),
47
48
  title: (elt) => elt.currency,
48
49
  }),
49
- TextColumn({
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
- TextColumn({
55
+ Columns.text({
55
56
  header: () => React.createElement(Header, null, "Address"),
56
57
  subtitle: (elt) => elt.address,
57
58
  }),
58
- TextColumn({
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
- IconColumn({
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
- TextColumn({
141
+ Columns.text({
141
142
  layout: "2fr",
142
143
  title: (elt) => elt.name,
143
144
  subtitle: (elt) => elt.currency.name,
144
145
  }),
145
- IconColumn({
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
- TextColumn({
152
+ Columns.text({
152
153
  layout: "1fr",
153
154
  subtitle: (elt) => elt.currency.abbrev,
154
155
  }),
155
- TextColumn({
156
+ Columns.text({
156
157
  layout: "1fr",
157
158
  title: (elt) => elt.amount,
158
159
  }),
159
- TextColumn({
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
- IconColumn({
167
+ Columns.icon({
167
168
  props: (elt) => ({
168
169
  name: "StarSolid",
169
170
  color: elt.starred ? "neutral.c100" : "neutral.c70",
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export interface GlitchTextProps {
3
2
  text: string;
4
3
  duration?: number;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare type Props = {
3
2
  variant: "default" | "light";
4
3
  };
@@ -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,58 @@
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
+ const getTopRightSquareClippedPolygon = (boxSize, rectangleSize) => {
19
+ // clipping path that hides top right square of size `${rectangleSize}px`
20
+ const diff = boxSize - rectangleSize;
21
+ 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%)`;
22
+ };
23
+ const Container = styled(Flex).attrs((p) => ({
24
+ heigth: p.size,
25
+ width: p.size,
26
+ alignItems: "center",
27
+ justifyContent: "center",
28
+ position: "relative",
29
+ })) ``;
30
+ const IconBoxBackground = styled(Flex) `
31
+ position: absolute;
32
+ height: ${(p) => p.size}px;
33
+ width: ${(p) => p.size}px;
34
+ ${(p) => {
35
+ return p.hasBadge && `clip-path: ${getTopRightSquareClippedPolygon(p.size, 15)};`;
36
+ }};
37
+ border-radius: ${(p) => p.theme.radii[2]}px;
38
+ `;
39
+ const BadgeContainer = styled.div `
40
+ position: absolute;
41
+ ${(p) => `
42
+ top: -${p.badgeSize / 2 - 2}px;
43
+ right: -${p.badgeSize / 2 - 2}px;`}
44
+ `;
45
+ export const IconBox = ({ Badge, size = DEFAULT_BOX_SIZE, children, borderColor = "neutral.c40", badgeColor, badgeSize = DEFAULT_BADGE_SIZE, }) => {
46
+ const hasBadge = !!Badge;
47
+ return (React.createElement(Container, { size: size },
48
+ React.createElement(IconBoxBackground, { size: size, hasBadge: hasBadge, border: "1px solid", borderColor: borderColor }),
49
+ children,
50
+ hasBadge && (React.createElement(BadgeContainer, { badgeSize: badgeSize },
51
+ React.createElement(Badge, { size: badgeSize, color: badgeColor })))));
52
+ };
53
+ const BoxedIcon = (_a) => {
54
+ var { Icon, iconSize = DEFAULT_ICON_SIZE, iconColor } = _a, iconBoxProps = __rest(_a, ["Icon", "iconSize", "iconColor"]);
55
+ return (React.createElement(IconBox, Object.assign({}, iconBoxProps),
56
+ React.createElement(Icon, { size: iconSize || DEFAULT_ICON_SIZE, color: iconColor })));
57
+ };
58
+ 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;
@@ -1,2 +1,4 @@
1
- export { default, iconNames, IconBox } from "./Icon";
1
+ export { default, iconNames } from "./Icon";
2
+ import BoxedIcon, { IconBox } from "./BoxedIcon";
3
+ export { BoxedIcon, IconBox };
2
4
  export type { Props } from "./Icon";
@@ -1 +1,3 @@
1
- export { default, iconNames, IconBox } from "./Icon";
1
+ export { default, iconNames } from "./Icon";
2
+ import BoxedIcon, { IconBox } from "./BoxedIcon";
3
+ export { BoxedIcon, IconBox };
@@ -1,30 +1,79 @@
1
1
  import React from "react";
2
+ import { TextProps } from "../../asorted/Text";
2
3
  import { BaseStyledProps } from "../../styled";
3
4
  export declare type LinkProps = React.AnchorHTMLAttributes<HTMLAnchorElement> & BaseStyledProps & {
5
+ /**
6
+ * Component that takes `{size: number; color?: string}` as props
7
+ */
4
8
  Icon?: React.ComponentType<{
5
9
  size: number;
6
10
  color?: string;
7
11
  }>;
12
+ /**
13
+ * Affects the colors of the text, icon & underline, can be overriden by the `color` prop
14
+ */
8
15
  type?: "main" | "shade" | "color";
16
+ /**
17
+ * Affect the font variant & icon size
18
+ */
9
19
  size?: "small" | "medium" | "large";
20
+ /**
21
+ * Color of the link, overrides colors defined by the `type` prop
22
+ */
23
+ color?: string;
24
+ /**
25
+ * Props passed to the rendered text
26
+ */
27
+ textProps?: TextProps;
28
+ /**
29
+ * If true text will always be underlined, else it will be underlined only on hover
30
+ */
31
+ alwaysUnderline?: boolean;
32
+ /**
33
+ * Position of the icon relative to the text
34
+ */
10
35
  iconPosition?: "right" | "left";
11
36
  disabled?: boolean;
12
37
  children?: React.ReactNode;
13
38
  };
14
- export declare const Base: import("styled-components").StyledComponent<"a", import("styled-components").DefaultTheme, React.AnchorHTMLAttributes<HTMLAnchorElement> & 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>>> & {
39
+ export declare const DEFAULT_ICON_POSITION = "right";
40
+ export declare const DEFAULT_SIZE = "medium";
41
+ export declare const DEFAULT_TYPE = "main";
42
+ export declare const Base: import("styled-components").StyledComponent<"a", import("styled-components").DefaultTheme, React.AnchorHTMLAttributes<HTMLAnchorElement> & 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").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>>> & {
15
43
  columnGap?: string | number | undefined;
16
44
  rowGap?: string | number | undefined;
17
45
  color?: string | undefined;
18
- display?: string | undefined;
19
- position?: string | undefined;
20
- maxHeight?: number | undefined;
21
46
  } & {
47
+ /**
48
+ * Component that takes `{size: number; color?: string}` as props
49
+ */
22
50
  Icon?: React.ComponentType<{
23
51
  size: number;
24
52
  color?: string | undefined;
25
53
  }> | undefined;
54
+ /**
55
+ * Affects the colors of the text, icon & underline, can be overriden by the `color` prop
56
+ */
26
57
  type?: "main" | "color" | "shade" | undefined;
58
+ /**
59
+ * Affect the font variant & icon size
60
+ */
27
61
  size?: "small" | "medium" | "large" | undefined;
62
+ /**
63
+ * Color of the link, overrides colors defined by the `type` prop
64
+ */
65
+ color?: string | undefined;
66
+ /**
67
+ * Props passed to the rendered text
68
+ */
69
+ textProps?: TextProps | undefined;
70
+ /**
71
+ * If true text will always be underlined, else it will be underlined only on hover
72
+ */
73
+ alwaysUnderline?: boolean | undefined;
74
+ /**
75
+ * Position of the icon relative to the text
76
+ */
28
77
  iconPosition?: "left" | "right" | undefined;
29
78
  disabled?: boolean | undefined;
30
79
  children?: React.ReactNode;