@ledgerhq/react-ui 0.2.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.
- package/README.md +47 -4
- 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/Chart/index.js +1 -1
- package/components/Table/Columns.d.ts +62 -13
- package/components/Table/Columns.js +8 -18
- package/components/Table/index.d.ts +47 -14
- package/components/Table/index.js +37 -20
- package/components/Table/stories.helper.js +19 -18
- package/components/Tag/index.d.ts +18 -5
- package/components/Tag/index.js +54 -21
- package/components/animations/GlitchText/index.d.ts +6 -0
- package/components/animations/GlitchText/index.js +35 -0
- package/components/asorted/Divider/index.d.ts +0 -1
- package/components/asorted/Divider/index.js +2 -2
- package/components/asorted/Icon/BoxedIcon.d.ts +48 -0
- package/components/asorted/Icon/BoxedIcon.js +58 -0
- package/components/asorted/Icon/Icon.d.ts +0 -1
- package/components/asorted/Icon/index.d.ts +2 -0
- package/components/asorted/Icon/index.js +2 -0
- package/components/asorted/Text/index.d.ts +6 -22
- package/components/asorted/Text/index.js +7 -16
- package/components/asorted/Text/styles.d.ts +2 -1
- package/components/asorted/Text/styles.js +21 -9
- package/components/asorted/index.d.ts +1 -1
- package/components/asorted/index.js +1 -1
- package/components/cards/Carousel/Slide.js +3 -3
- package/components/cards/Carousel/index.js +8 -8
- package/components/cta/Button/index.d.ts +16 -8
- package/components/cta/Button/index.js +76 -65
- package/components/cta/Link/index.d.ts +59 -2
- package/components/cta/Link/index.js +17 -12
- package/components/cta/Toggle/index.d.ts +0 -1
- package/components/cta/Toggle/index.js +1 -1
- package/components/form/BaseInput/index.d.ts +81 -11
- package/components/form/BaseInput/index.js +42 -19
- package/components/form/Checkbox/Checkbox.js +12 -9
- package/components/form/Dropdown/index.d.ts +0 -1
- package/components/form/Dropdown/index.js +2 -2
- package/components/form/LegendInput/index.d.ts +26 -2
- package/components/form/LegendInput/index.js +5 -4
- package/components/form/NumberInput/index.d.ts +25 -3
- package/components/form/NumberInput/index.js +19 -7
- package/components/form/QrCodeInput/index.d.ts +25 -3
- package/components/form/QrCodeInput/index.js +7 -6
- package/components/form/QuantityInput/index.d.ts +26 -4
- package/components/form/QuantityInput/index.js +9 -8
- package/components/form/Radio/RadioElement.d.ts +5 -2
- package/components/form/Radio/RadioElement.js +15 -13
- package/components/form/Radio/RadioListElement.d.ts +22 -0
- package/components/form/Radio/RadioListElement.js +63 -0
- package/components/form/Radio/index.d.ts +8 -1
- package/components/form/Radio/index.js +2 -0
- package/components/form/SearchInput/index.d.ts +24 -2
- package/components/form/SearchInput/index.js +4 -3
- package/components/form/SelectInput/Control.d.ts +2 -2
- package/components/form/SelectInput/Control.js +3 -7
- package/components/form/SelectInput/DropdownIndicator.d.ts +0 -1
- package/components/form/SelectInput/DropdownIndicator.js +1 -1
- package/components/form/SelectInput/IndicatorsContainer.d.ts +0 -1
- package/components/form/SelectInput/MenuList.d.ts +0 -1
- package/components/form/SelectInput/MenuList.js +1 -1
- package/components/form/SelectInput/Option.js +11 -11
- package/components/form/SelectInput/ValueContainer.js +1 -1
- package/components/form/SelectInput/index.d.ts +3 -2
- package/components/form/SelectInput/index.js +5 -5
- package/components/form/SplitInput/index.js +5 -5
- package/components/form/Switch/Switch.js +8 -8
- package/components/helpers.d.ts +2 -2
- package/components/layout/Box/index.d.ts +8 -0
- package/components/layout/Box/index.js +3 -0
- package/components/layout/Drawer/index.d.ts +13 -0
- package/components/layout/{Side/Side.js → Drawer/index.js} +12 -12
- package/components/layout/Flex/index.d.ts +7 -7
- package/components/layout/Flex/index.js +2 -11
- package/components/layout/Grid/index.d.ts +3 -2
- package/components/layout/Grid/index.js +3 -6
- package/components/layout/Popin/index.d.ts +27 -6
- package/components/layout/Popin/index.js +65 -41
- package/components/layout/Side/index.d.ts +0 -1
- package/components/layout/Side/index.js +2 -2
- package/components/layout/index.d.ts +2 -0
- package/components/layout/index.js +2 -0
- package/components/loaders/ProgressLoader/index.d.ts +0 -1
- package/components/loaders/ProgressLoader/index.js +3 -3
- package/components/message/Alert/index.d.ts +22 -3
- package/components/message/Alert/index.js +31 -23
- package/components/message/Log/index.js +1 -1
- package/components/message/Notification/Badge.js +2 -2
- package/components/message/Notification/index.js +4 -6
- package/components/message/StatusNotification/index.d.ts +11 -0
- package/components/message/StatusNotification/index.js +33 -0
- package/components/message/Tip/index.d.ts +7 -0
- package/components/message/Tip/index.js +43 -0
- package/components/message/Tooltip/index.d.ts +3 -3
- package/components/message/Tooltip/index.js +1 -1
- package/components/message/Tooltip/styles.js +3 -3
- package/components/message/index.d.ts +3 -0
- package/components/message/index.js +3 -0
- package/components/navigation/Aside/index.d.ts +5 -1
- package/components/navigation/Breadcrumb/index.js +6 -6
- package/components/navigation/Header/index.d.ts +3 -3
- package/components/navigation/progress/ProgressBar/Onboarding.d.ts +0 -1
- package/components/navigation/progress/ProgressBar/Onboarding.js +6 -6
- package/components/navigation/progress/Stepper/index.js +9 -9
- package/components/navigation/sideBar/Item/Item.d.ts +4 -3
- package/components/navigation/sideBar/Item/Item.js +34 -16
- package/components/navigation/sideBar/Logo/Logo.d.ts +0 -1
- package/components/navigation/sideBar/SideBar/SideBar.d.ts +1 -2
- package/components/navigation/sideBar/SideBar/SideBar.js +14 -6
- package/components/navigation/sideBar/Toggle/Toggle.d.ts +0 -1
- package/components/navigation/sideBar/Toggle/Toggle.js +2 -2
- package/components/styled.d.ts +16 -0
- package/components/styled.js +13 -0
- package/components/tabs/Bar/index.js +4 -4
- package/components/tabs/Chip/index.d.ts +13 -0
- package/components/tabs/Chip/index.js +21 -0
- package/components/tabs/Pill/index.js +7 -7
- package/components/tabs/Tabs/index.js +8 -7
- package/components/tabs/index.d.ts +2 -0
- package/components/tabs/index.js +2 -0
- package/package.json +4 -4
- package/styles/InvertTheme.d.ts +1 -8
- package/styles/StyleProvider.d.ts +3 -3
- package/styles/StyleProvider.js +3 -3
- package/styles/global.d.ts +1 -0
- package/styles/global.js +15 -36
- package/styles/index.d.ts +0 -1
- package/styles/index.js +0 -1
- package/styles/theme.d.ts +5 -2
- package/styles/theme.js +7 -8
- package/components/layout/Side/Side.d.ts +0 -13
- package/styles/reset.d.ts +0 -2
- package/styles/reset.js +0 -62
|
@@ -11,145 +11,161 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import React, { useState } from "react";
|
|
13
13
|
import styled, { css } from "styled-components";
|
|
14
|
-
import
|
|
14
|
+
import baseStyled from "../../styled";
|
|
15
|
+
import { fontSize, border, compose } from "styled-system";
|
|
15
16
|
import fontFamily from "../../../styles/styled/fontFamily";
|
|
16
17
|
import { fontSizes } from "../../../styles/theme";
|
|
17
18
|
import ChevronBottom from "@ledgerhq/icons-ui/react/ChevronBottomRegular";
|
|
18
19
|
const IconContainer = styled.div `
|
|
19
20
|
display: inline-block;
|
|
20
|
-
|
|
21
|
+
${(p) => `${p.iconPosition === "left" ? "margin-right" : "margin-left"}: ${p.theme.space[4]}px;`}
|
|
21
22
|
padding-top: 0.2em;
|
|
22
23
|
`;
|
|
23
24
|
const getVariantColors = (p) => ({
|
|
24
25
|
main: {
|
|
25
26
|
outline: `
|
|
26
|
-
border-color: ${p.theme.colors.
|
|
27
|
-
color: ${p.theme.colors.
|
|
28
|
-
background-color: ${p.theme.colors.
|
|
29
|
-
&:hover {
|
|
30
|
-
background-color: ${p.theme.colors.
|
|
27
|
+
border-color: ${p.theme.colors.neutral.c100};
|
|
28
|
+
color: ${p.theme.colors.neutral.c100};
|
|
29
|
+
background-color: ${p.theme.colors.neutral.c00};
|
|
30
|
+
&:hover, &:focus {
|
|
31
|
+
background-color: ${p.theme.colors.neutral.c20};
|
|
31
32
|
}
|
|
32
33
|
&:active {
|
|
33
|
-
background-color: ${p.theme.colors.
|
|
34
|
+
background-color: ${p.theme.colors.neutral.c30};
|
|
34
35
|
}
|
|
35
36
|
`,
|
|
36
37
|
filled: `
|
|
37
|
-
color: ${p.theme.colors.
|
|
38
|
-
background-color: ${p.theme.colors.
|
|
39
|
-
&:hover {
|
|
40
|
-
background-color: ${p.theme.colors.
|
|
38
|
+
color: ${p.theme.colors.neutral.c00};
|
|
39
|
+
background-color: ${p.theme.colors.neutral.c100};
|
|
40
|
+
&:hover, &:focus {
|
|
41
|
+
background-color: ${p.theme.colors.neutral.c90};
|
|
41
42
|
}
|
|
42
43
|
`,
|
|
43
44
|
},
|
|
44
45
|
shade: `
|
|
45
|
-
border-color: ${p.theme.colors.
|
|
46
|
-
color: ${p.theme.colors.
|
|
47
|
-
background-color: ${p.theme.colors.
|
|
46
|
+
border-color: ${p.theme.colors.neutral.c40};
|
|
47
|
+
color: ${p.theme.colors.neutral.c100};
|
|
48
|
+
background-color: ${p.theme.colors.neutral.c00};
|
|
48
49
|
&:focus {
|
|
49
|
-
border-color: ${p.theme.colors.
|
|
50
|
+
border-color: ${p.theme.colors.primary.c80};
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
&:hover {
|
|
53
|
-
background-color: ${p.theme.colors.
|
|
53
|
+
&:hover, &:focus {
|
|
54
|
+
background-color: ${p.theme.colors.neutral.c20};
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
&:active {
|
|
57
|
-
background-color: ${p.theme.colors.
|
|
58
|
+
background-color: ${p.theme.colors.neutral.c30};
|
|
58
59
|
}
|
|
59
60
|
`,
|
|
60
61
|
error: {
|
|
61
62
|
outline: `
|
|
62
|
-
border-color: ${p.theme.colors.
|
|
63
|
-
color: ${p.theme.colors.
|
|
64
|
-
background-color: ${p.theme.colors.
|
|
63
|
+
border-color: ${p.theme.colors.error.c100};
|
|
64
|
+
color: ${p.theme.colors.error.c100};
|
|
65
|
+
background-color: ${p.theme.colors.neutral.c00};
|
|
65
66
|
&:hover {
|
|
66
|
-
background-color: ${p.theme.colors.
|
|
67
|
+
background-color: ${p.theme.colors.error.c10};
|
|
67
68
|
}
|
|
68
69
|
&:active {
|
|
69
|
-
background-color: ${p.theme.colors.
|
|
70
|
+
background-color: ${p.theme.colors.error.c30};
|
|
70
71
|
}
|
|
71
72
|
`,
|
|
72
73
|
filled: `
|
|
73
|
-
color: ${p.theme.colors.
|
|
74
|
-
background-color: ${p.theme.colors.
|
|
74
|
+
color: ${p.theme.colors.neutral.c00};
|
|
75
|
+
background-color: ${p.theme.colors.error.c100};
|
|
75
76
|
&:hover {
|
|
76
|
-
background-color: ${p.theme.colors.
|
|
77
|
+
background-color: ${p.theme.colors.error.c80};
|
|
77
78
|
}
|
|
78
79
|
`,
|
|
79
80
|
},
|
|
80
81
|
color: {
|
|
81
82
|
outline: `
|
|
82
|
-
border-color: ${p.theme.colors.
|
|
83
|
-
color: ${p.theme.colors.
|
|
84
|
-
background-color: ${p.theme.colors.
|
|
83
|
+
border-color: ${p.theme.colors.primary.c80};
|
|
84
|
+
color: ${p.theme.colors.primary.c80};
|
|
85
|
+
background-color: ${p.theme.colors.neutral.c00};
|
|
85
86
|
&:hover {
|
|
86
|
-
background-color: ${p.theme.colors.
|
|
87
|
+
background-color: ${p.theme.colors.primary.c10};
|
|
87
88
|
}
|
|
88
89
|
&:active {
|
|
89
|
-
background-color: ${p.theme.colors.
|
|
90
|
+
background-color: ${p.theme.colors.primary.c20};
|
|
90
91
|
}
|
|
91
92
|
`,
|
|
92
93
|
filled: `
|
|
93
|
-
color: ${p.theme.colors.
|
|
94
|
-
background-color: ${p.theme.colors.
|
|
94
|
+
color: ${p.theme.colors.neutral.c00};
|
|
95
|
+
background-color: ${p.theme.colors.primary.c80};
|
|
95
96
|
&:hover {
|
|
96
|
-
background-color: ${p.theme.colors.
|
|
97
|
+
background-color: ${p.theme.colors.primary.c70};
|
|
97
98
|
}
|
|
98
99
|
`,
|
|
99
100
|
},
|
|
100
101
|
disabled: {
|
|
101
102
|
outline: `
|
|
102
|
-
border-color: ${p.theme.colors.
|
|
103
|
-
color: ${p.theme.colors.
|
|
104
|
-
background-color: ${p.theme.colors.
|
|
103
|
+
border-color: ${p.theme.colors.neutral.c50};
|
|
104
|
+
color: ${p.theme.colors.neutral.c50};
|
|
105
|
+
background-color: ${p.theme.colors.neutral.c00};
|
|
105
106
|
`,
|
|
106
107
|
filled: `
|
|
107
|
-
color: ${p.theme.colors.
|
|
108
|
-
background-color: ${p.theme.colors.
|
|
108
|
+
color: ${p.theme.colors.neutral.c50};
|
|
109
|
+
background-color: ${p.theme.colors.neutral.c30};
|
|
109
110
|
`,
|
|
110
111
|
},
|
|
112
|
+
default: `
|
|
113
|
+
color: ${p.theme.colors.neutral.c100};
|
|
114
|
+
background-color: transparent;
|
|
115
|
+
&:hover {
|
|
116
|
+
text-decoration: underline;
|
|
117
|
+
}
|
|
118
|
+
`,
|
|
111
119
|
});
|
|
112
|
-
export const
|
|
113
|
-
|
|
120
|
+
export const ButtonUnstyled = styled.button `
|
|
121
|
+
all: unset;
|
|
122
|
+
cursor: pointer;
|
|
123
|
+
|
|
124
|
+
&:disabled {
|
|
125
|
+
cursor: default;
|
|
126
|
+
}
|
|
127
|
+
`;
|
|
128
|
+
export const Base = baseStyled.button.attrs((p) => {
|
|
129
|
+
var _a;
|
|
114
130
|
return ({
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
fontSize: (_b = p.fontSize) !== null && _b !== void 0 ? _b : 4,
|
|
131
|
+
fontFamily: "Inter",
|
|
132
|
+
fontSize: (_a = p.fontSize) !== null && _a !== void 0 ? _a : 4,
|
|
118
133
|
});
|
|
119
134
|
}) `
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
${color};
|
|
135
|
+
background-color: transparent;
|
|
136
|
+
border-color: transparent;
|
|
123
137
|
border-radius: ${(p) => p.theme.space[13]}px;
|
|
138
|
+
border-style: solid;
|
|
139
|
+
border-width: ${(p) => (p.outline || p.variant === "shade" ? 1 : 0)}px;
|
|
140
|
+
font-weight: 600;
|
|
141
|
+
${compose(fontFamily, fontSize, border)};
|
|
124
142
|
height: ${(p) => p.theme.space[13]}px;
|
|
125
143
|
line-height: ${(p) => p.theme.fontSizes[p.fontSize]}px;
|
|
126
|
-
border-style: solid;
|
|
127
|
-
border-width: ${(p) => (p.outline || p.type === "shade" ? 1 : 0)}px;
|
|
128
144
|
text-align: center;
|
|
129
145
|
display: inline-flex;
|
|
130
146
|
align-items: center;
|
|
131
147
|
justify-content: center;
|
|
132
148
|
padding: 0 2em;
|
|
133
|
-
background-color: transparent;
|
|
134
|
-
border-color: transparent;
|
|
135
149
|
overflow: hidden;
|
|
136
150
|
text-overflow: ellipsis;
|
|
137
151
|
white-space: nowrap;
|
|
138
152
|
max-width: 100%;
|
|
139
153
|
position: relative;
|
|
140
154
|
cursor: ${(p) => (p.disabled ? "default" : "pointer")};
|
|
141
|
-
&:
|
|
142
|
-
box-shadow: 0 0 0 4px ${(p) => p.theme.colors.
|
|
155
|
+
&:active {
|
|
156
|
+
box-shadow: 0 0 0 4px ${(p) => p.theme.colors.primary.c60};
|
|
143
157
|
}
|
|
144
158
|
|
|
145
159
|
${(p) => {
|
|
146
160
|
var _a;
|
|
147
161
|
const variants = getVariantColors(p);
|
|
148
162
|
if (p.disabled) {
|
|
149
|
-
return p.outline || p.
|
|
163
|
+
return p.outline || p.variant === "shade"
|
|
164
|
+
? variants.disabled.outline
|
|
165
|
+
: variants.disabled.filled;
|
|
150
166
|
}
|
|
151
|
-
const
|
|
152
|
-
switch (
|
|
167
|
+
const variant = (_a = p.variant) !== null && _a !== void 0 ? _a : "default";
|
|
168
|
+
switch (variant) {
|
|
153
169
|
case "main":
|
|
154
170
|
return p.outline ? variants.main.outline : variants.main.filled;
|
|
155
171
|
case "shade":
|
|
@@ -160,11 +176,7 @@ export const Base = styled.button.attrs((p) => {
|
|
|
160
176
|
return p.outline ? variants.color.outline : variants.color.filled;
|
|
161
177
|
case "default":
|
|
162
178
|
default:
|
|
163
|
-
return
|
|
164
|
-
&:hover {
|
|
165
|
-
text-decoration: underline;
|
|
166
|
-
}
|
|
167
|
-
`;
|
|
179
|
+
return variants.default;
|
|
168
180
|
}
|
|
169
181
|
}}
|
|
170
182
|
${(p) => p.iconButton
|
|
@@ -182,9 +194,7 @@ const ContentContainer = styled.div ``;
|
|
|
182
194
|
const Button = (_a) => {
|
|
183
195
|
var _b;
|
|
184
196
|
var { Icon, iconPosition = "right", iconSize = 16, children, onClick } = _a, props = __rest(_a, ["Icon", "iconPosition", "iconSize", "children", "onClick"]);
|
|
185
|
-
return (
|
|
186
|
-
// @ts-expect-error FIXME type button conflict
|
|
187
|
-
React.createElement(Base, Object.assign({}, props, { iconButton: !(Icon == null) && !children, onClick: onClick }),
|
|
197
|
+
return (React.createElement(Base, Object.assign({}, props, { iconButton: !(Icon == null) && !children, onClick: onClick }),
|
|
188
198
|
iconPosition === "right" ? React.createElement(ContentContainer, null, children) : null,
|
|
189
199
|
Icon != null ? (React.createElement(IconContainer, { iconPosition: iconPosition },
|
|
190
200
|
React.createElement(Icon, { size: iconSize || fontSizes[(_b = props.fontSize) !== null && _b !== void 0 ? _b : 4] }))) : null,
|
|
@@ -208,4 +218,5 @@ export const ExpandButton = function ExpandButton(_a) {
|
|
|
208
218
|
onClick != null && onClick(event);
|
|
209
219
|
} })));
|
|
210
220
|
};
|
|
221
|
+
Button.Unstyled = ButtonUnstyled;
|
|
211
222
|
export default Button;
|
|
@@ -1,22 +1,79 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
import { TextProps } from "../../asorted/Text";
|
|
3
|
+
import { BaseStyledProps } from "../../styled";
|
|
4
|
+
export declare type LinkProps = React.AnchorHTMLAttributes<HTMLAnchorElement> & BaseStyledProps & {
|
|
5
|
+
/**
|
|
6
|
+
* Component that takes `{size: number; color?: string}` as props
|
|
7
|
+
*/
|
|
3
8
|
Icon?: React.ComponentType<{
|
|
4
9
|
size: number;
|
|
5
10
|
color?: string;
|
|
6
11
|
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Affects the colors of the text, icon & underline, can be overriden by the `color` prop
|
|
14
|
+
*/
|
|
7
15
|
type?: "main" | "shade" | "color";
|
|
16
|
+
/**
|
|
17
|
+
* Affect the font variant & icon size
|
|
18
|
+
*/
|
|
8
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
|
+
*/
|
|
9
35
|
iconPosition?: "right" | "left";
|
|
10
36
|
disabled?: boolean;
|
|
11
37
|
children?: React.ReactNode;
|
|
12
38
|
};
|
|
13
|
-
export declare const
|
|
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>>> & {
|
|
43
|
+
columnGap?: string | number | undefined;
|
|
44
|
+
rowGap?: string | number | undefined;
|
|
45
|
+
color?: string | undefined;
|
|
46
|
+
} & {
|
|
47
|
+
/**
|
|
48
|
+
* Component that takes `{size: number; color?: string}` as props
|
|
49
|
+
*/
|
|
14
50
|
Icon?: React.ComponentType<{
|
|
15
51
|
size: number;
|
|
16
52
|
color?: string | undefined;
|
|
17
53
|
}> | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Affects the colors of the text, icon & underline, can be overriden by the `color` prop
|
|
56
|
+
*/
|
|
18
57
|
type?: "main" | "color" | "shade" | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Affect the font variant & icon size
|
|
60
|
+
*/
|
|
19
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
|
+
*/
|
|
20
77
|
iconPosition?: "left" | "right" | undefined;
|
|
21
78
|
disabled?: boolean | undefined;
|
|
22
79
|
children?: React.ReactNode;
|
|
@@ -3,14 +3,18 @@ import styled from "styled-components";
|
|
|
3
3
|
import { getLinkColors } from "./getLinkStyle";
|
|
4
4
|
import { ctaIconSize, ctaTextType } from "../getCtaStyle";
|
|
5
5
|
import { Text } from "../../asorted";
|
|
6
|
+
import baseStyled from "../../styled";
|
|
7
|
+
export const DEFAULT_ICON_POSITION = "right";
|
|
8
|
+
export const DEFAULT_SIZE = "medium";
|
|
9
|
+
export const DEFAULT_TYPE = "main";
|
|
6
10
|
const IconContainer = styled.div `
|
|
7
11
|
${(p) => p.iconLink ? "" : p.iconPosition === "left" ? `margin-right: 6px;` : `margin-left: 6px;`}
|
|
8
12
|
display: flex;
|
|
9
13
|
align-items: center;
|
|
10
14
|
justify-content: center;
|
|
11
15
|
`;
|
|
12
|
-
export const Base =
|
|
13
|
-
color: ${({ theme, disabled, type = "main" }) => getLinkColors(theme.colors)[disabled ? "disabled" : type]["default"]};
|
|
16
|
+
export const Base = baseStyled.a `
|
|
17
|
+
color: ${({ color, theme, disabled, type = "main" }) => color || getLinkColors(theme.colors)[disabled ? "disabled" : type]["default"]};
|
|
14
18
|
cursor: pointer;
|
|
15
19
|
display: inline-flex;
|
|
16
20
|
flex-direction: row;
|
|
@@ -18,27 +22,28 @@ export const Base = styled.a `
|
|
|
18
22
|
align-items: center;
|
|
19
23
|
justify-content: center;
|
|
20
24
|
|
|
21
|
-
text-decoration: none;
|
|
22
|
-
|
|
23
25
|
:hover {
|
|
24
26
|
text-decoration: underline;
|
|
25
27
|
}
|
|
26
28
|
:active {
|
|
27
|
-
color: ${({ theme, type = "main" }) => getLinkColors(theme.colors)[type]["pressed"]};
|
|
29
|
+
color: ${({ color, theme, type = "main" }) => color || getLinkColors(theme.colors)[type]["pressed"]};
|
|
28
30
|
text-decoration: underline;
|
|
29
31
|
}
|
|
32
|
+
|
|
33
|
+
text-decoration: ${(p) => (p.alwaysUnderline ? "underline" : "none")};
|
|
34
|
+
|
|
30
35
|
`;
|
|
31
|
-
const LinkContainer = (
|
|
32
|
-
const {
|
|
36
|
+
const LinkContainer = ({ Icon, iconPosition = DEFAULT_ICON_POSITION, children, color, size = DEFAULT_SIZE, textProps, }) => {
|
|
37
|
+
const text = (React.createElement(Text, Object.assign({ variant: ctaTextType[size], fontWeight: "semiBold", color: color || "inherit" }, textProps), children));
|
|
33
38
|
return (React.createElement(React.Fragment, null,
|
|
34
|
-
iconPosition === "right" && children ?
|
|
39
|
+
iconPosition === "right" && children ? text : null,
|
|
35
40
|
Icon ? (React.createElement(IconContainer, { iconLink: !children, iconPosition: iconPosition },
|
|
36
|
-
React.createElement(Icon, { size: ctaIconSize[size], color: "currentcolor" }))) : null,
|
|
37
|
-
iconPosition === "left" && children ?
|
|
41
|
+
React.createElement(Icon, { size: ctaIconSize[size], color: color || "currentcolor" }))) : null,
|
|
42
|
+
iconPosition === "left" && children ? text : null));
|
|
38
43
|
};
|
|
39
44
|
const Link = (props) => {
|
|
40
|
-
const { type =
|
|
41
|
-
return (React.createElement(Base, Object.assign({}, props),
|
|
45
|
+
const { type = DEFAULT_TYPE, size = DEFAULT_SIZE, color } = props;
|
|
46
|
+
return (React.createElement(Base, Object.assign({ color: color }, props),
|
|
42
47
|
React.createElement(LinkContainer, Object.assign({}, props, { type: type, size: size }))));
|
|
43
48
|
};
|
|
44
49
|
export default Link;
|
|
@@ -19,6 +19,6 @@ var TypeEnum;
|
|
|
19
19
|
const Toggle = (_a) => {
|
|
20
20
|
var { checked = true } = _a, buttonProps = __rest(_a, ["checked"]);
|
|
21
21
|
const type = useMemo(() => (checked ? TypeEnum.ENABLED : TypeEnum.DISABLED), [checked]);
|
|
22
|
-
return React.createElement(Button, Object.assign({
|
|
22
|
+
return React.createElement(Button, Object.assign({ variant: type, outline: type === TypeEnum.ENABLED }, buttonProps));
|
|
23
23
|
};
|
|
24
24
|
export default Toggle;
|
|
@@ -1,28 +1,98 @@
|
|
|
1
1
|
import { TypographyProps } from "styled-system";
|
|
2
2
|
import React, { InputHTMLAttributes } from "react";
|
|
3
|
-
|
|
3
|
+
declare type ValueType = HTMLInputElement["value"];
|
|
4
|
+
export declare type CommonProps = InputHTMLAttributes<HTMLInputElement> & TypographyProps & {
|
|
4
5
|
disabled?: boolean;
|
|
5
6
|
error?: string;
|
|
7
|
+
warning?: string;
|
|
6
8
|
};
|
|
7
|
-
export declare type InputProps = CommonProps & {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
export declare type InputProps<T = ValueType> = Omit<CommonProps, "value" | "onChange"> & {
|
|
10
|
+
value: T;
|
|
11
|
+
onChange?: (value: T) => void;
|
|
12
|
+
onChangeEvent?: InputHTMLAttributes<HTMLInputElement>["onChange"];
|
|
13
|
+
renderLeft?: ((props: InputProps<T>) => React.ReactNode) | React.ReactNode;
|
|
14
|
+
renderRight?: ((props: InputProps<T>) => React.ReactNode) | React.ReactNode;
|
|
11
15
|
unwrapped?: boolean;
|
|
16
|
+
containerProps?: InputContainerProps;
|
|
17
|
+
/**
|
|
18
|
+
* A function can be provided to serialize a value of any type to a string.
|
|
19
|
+
*
|
|
20
|
+
* This can be useful to wrap the `<BaseInput />` component (which expects a string)
|
|
21
|
+
* and create higher-level components that will automatically perform the input/output
|
|
22
|
+
* conversion to other types.
|
|
23
|
+
*
|
|
24
|
+
* *A serializer function should always be used in conjunction with a deserializer function.*
|
|
25
|
+
*/
|
|
26
|
+
serialize?: (value: T) => ValueType;
|
|
27
|
+
/**
|
|
28
|
+
* A deserializer can be provided to convert the html input value from a string to any other type.
|
|
29
|
+
*
|
|
30
|
+
* *A deserializer function should always be used in conjunction with a serializer function.*
|
|
31
|
+
*/
|
|
32
|
+
deserialize?: (value: ValueType) => T;
|
|
12
33
|
};
|
|
34
|
+
export declare type InputContainerProps = React.ComponentProps<typeof InputContainer>;
|
|
13
35
|
export declare const InputContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, Partial<CommonProps> & {
|
|
14
36
|
focus?: boolean | undefined;
|
|
15
37
|
}, never>;
|
|
16
38
|
export declare const BaseInput: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, Partial<CommonProps> & {
|
|
17
39
|
focus?: boolean | undefined;
|
|
18
40
|
} & TypographyProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>, never>;
|
|
19
|
-
export declare const InputErrorContainer: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, import("../../asorted/Text").
|
|
20
|
-
export declare const
|
|
41
|
+
export declare const InputErrorContainer: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, import("../../asorted/Text").TextProps, keyof import("../../asorted/Text").TextProps>;
|
|
42
|
+
export declare const InputWarningContainer: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, import("../../asorted/Text").TextProps, keyof import("../../asorted/Text").TextProps>;
|
|
43
|
+
export declare const InputRenderLeftContainer: 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>>> & 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>>> & {
|
|
44
|
+
columnGap?: string | number | undefined;
|
|
45
|
+
rowGap?: string | number | undefined;
|
|
46
|
+
color?: string | undefined;
|
|
47
|
+
} & {
|
|
21
48
|
alignItems: string;
|
|
22
49
|
pl: string;
|
|
23
|
-
}, "alignItems" | "pl">;
|
|
24
|
-
export declare const InputRenderRightContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("
|
|
50
|
+
}, "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">;
|
|
51
|
+
export declare const InputRenderRightContainer: 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>>> & 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>>> & {
|
|
52
|
+
columnGap?: string | number | undefined;
|
|
53
|
+
rowGap?: string | number | undefined;
|
|
54
|
+
color?: string | undefined;
|
|
55
|
+
} & {
|
|
25
56
|
alignItems: string;
|
|
26
57
|
pr: string;
|
|
27
|
-
}, "alignItems" | "pr">;
|
|
28
|
-
|
|
58
|
+
}, "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">;
|
|
59
|
+
declare function Input<T = ValueType>(props: InputProps<T>, ref?: React.ForwardedRef<HTMLInputElement>): JSX.Element;
|
|
60
|
+
declare const _default: <T>(props: Omit<CommonProps, "onChange" | "value"> & {
|
|
61
|
+
value: T;
|
|
62
|
+
onChange?: ((value: T) => void) | undefined;
|
|
63
|
+
onChangeEvent?: React.ChangeEventHandler<HTMLInputElement> | undefined;
|
|
64
|
+
renderLeft?: React.ReactNode | ((props: InputProps<T>) => React.ReactNode);
|
|
65
|
+
renderRight?: React.ReactNode | ((props: InputProps<T>) => React.ReactNode);
|
|
66
|
+
unwrapped?: boolean | undefined;
|
|
67
|
+
containerProps?: (({
|
|
68
|
+
[x: string]: any;
|
|
69
|
+
[x: number]: any;
|
|
70
|
+
[x: symbol]: any;
|
|
71
|
+
} & {
|
|
72
|
+
theme?: import("styled-components").DefaultTheme | undefined;
|
|
73
|
+
} & ({} | {
|
|
74
|
+
children?: import("react").ReactNode;
|
|
75
|
+
})) & {
|
|
76
|
+
as?: string | import("react").ComponentType<any> | undefined;
|
|
77
|
+
forwardedAs?: string | import("react").ComponentType<any> | undefined;
|
|
78
|
+
}) | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* A function can be provided to serialize a value of any type to a string.
|
|
81
|
+
*
|
|
82
|
+
* This can be useful to wrap the `<BaseInput />` component (which expects a string)
|
|
83
|
+
* and create higher-level components that will automatically perform the input/output
|
|
84
|
+
* conversion to other types.
|
|
85
|
+
*
|
|
86
|
+
* *A serializer function should always be used in conjunction with a deserializer function.*
|
|
87
|
+
*/
|
|
88
|
+
serialize?: ((value: T) => string) | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* A deserializer can be provided to convert the html input value from a string to any other type.
|
|
91
|
+
*
|
|
92
|
+
* *A deserializer function should always be used in conjunction with a serializer function.*
|
|
93
|
+
*/
|
|
94
|
+
deserialize?: ((value: string) => T) | undefined;
|
|
95
|
+
} & {
|
|
96
|
+
ref?: React.ForwardedRef<HTMLInputElement> | undefined;
|
|
97
|
+
}) => ReturnType<typeof Input>;
|
|
98
|
+
export default _default;
|