@thecb/components 11.11.0-beta.4 → 11.11.0-beta.7
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 +8 -4
- package/dist/index.cjs.js +95 -67
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +95 -67
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/card-type/CardType.js +10 -2
- package/src/components/atoms/dropdown/Dropdown.js +2 -3
- package/src/components/atoms/dropdown/DropdownIcon.js +1 -0
- package/src/components/atoms/dropdown/DropdownIconV2.js +1 -0
- package/src/components/atoms/form-layouts/FormInput.js +9 -16
- package/src/components/atoms/formatted-bank-account/FormattedBankAccount.js +2 -2
- package/src/components/atoms/formatted-bank-account/FormattedBankAccount.theme.js +2 -2
- package/src/components/atoms/formatted-credit-card/FormattedCreditCard.js +12 -9
- package/src/components/atoms/formatted-credit-card/FormattedCreditCard.theme.js +2 -2
- package/src/components/atoms/icons/AmExSmallIcon.js +2 -0
- package/src/components/atoms/icons/DiscoverSmallIcon.js +2 -0
- package/src/components/atoms/icons/GenericCardLarge.js +1 -1
- package/src/components/atoms/icons/GenericSmallIcon.js +2 -0
- package/src/components/atoms/icons/MasterCardSmallIcon.js +2 -0
- package/src/components/atoms/icons/VisaSmallIcon.js +2 -0
- package/src/components/molecules/email-form/EmailForm.js +2 -1
- package/src/components/molecules/email-form/EmailForm.stories.js +210 -0
- package/src/components/molecules/forgot-password-form/ForgotPasswordForm.js +2 -1
- package/src/components/molecules/login-form/LoginForm.js +2 -1
- package/src/components/molecules/radio-section/InnerRadioSection.js +3 -3
- package/src/components/molecules/radio-section/RadioSection.stories.js +142 -0
- package/src/components/molecules/registration-form/RegistrationForm.js +2 -1
- package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.js +1 -1
- package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.stories.js +110 -0
- package/src/components/molecules/tooltip/Tooltip.js +28 -15
- package/src/components/molecules/tooltip/Tooltip.stories.js +5 -5
- package/src/components/molecules/tooltip/Tooltip.theme.js +10 -11
- package/src/components/molecules/tooltip/index.d.ts +1 -1
- package/src/util/formats.js +6 -3
|
@@ -36,7 +36,8 @@ const RegistrationForm = ({
|
|
|
36
36
|
};
|
|
37
37
|
const emailErrorMessages = {
|
|
38
38
|
[required.error]: "Email is required",
|
|
39
|
-
[isProbablyEmail.error]:
|
|
39
|
+
[isProbablyEmail.error]:
|
|
40
|
+
"Please enter a valid email address in the format user@example.com"
|
|
40
41
|
};
|
|
41
42
|
const passwordErrorMessages = {
|
|
42
43
|
[required.error]: "Password is required",
|
|
@@ -54,7 +54,7 @@ const TermsAndConditionsModal = ({
|
|
|
54
54
|
weight={themeValues.fontWeight}
|
|
55
55
|
hoverStyles={themeValues.modalLinkHoverFocus}
|
|
56
56
|
textDecoration={themeValues.modalLinkTextDecoration}
|
|
57
|
-
extraStyles={`display: inline-block; width: fit-content; cursor: pointer
|
|
57
|
+
extraStyles={`display: inline-block; width: fit-content; cursor: pointer; min-height: 24px; line-height: 24px;`}
|
|
58
58
|
role="button" // This should always be a "button" since it opens a modal
|
|
59
59
|
className="modal-trigger"
|
|
60
60
|
>
|
package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.stories.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import TermsAndConditionsModal from "./TermsAndConditionsModal";
|
|
3
|
+
|
|
4
|
+
const TermsContent = () => (
|
|
5
|
+
<p>
|
|
6
|
+
By enrolling, you agree to the automatic payment terms. Payments will be
|
|
7
|
+
processed on the first of each month using your selected payment method. You
|
|
8
|
+
may cancel at any time by contacting support. See our{" "}
|
|
9
|
+
<a href="#">Privacy Policy</a> for more details.
|
|
10
|
+
</p>
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const meta = {
|
|
14
|
+
title: "Molecules/TermsAndConditionsModal",
|
|
15
|
+
component: TermsAndConditionsModal,
|
|
16
|
+
parameters: {
|
|
17
|
+
layout: "centered"
|
|
18
|
+
},
|
|
19
|
+
tags: ["!autodocs"],
|
|
20
|
+
args: {
|
|
21
|
+
link: "Terms and Conditions",
|
|
22
|
+
title: "Terms and Conditions",
|
|
23
|
+
terms: <TermsContent />,
|
|
24
|
+
isOpen: false,
|
|
25
|
+
linkVariant: "p",
|
|
26
|
+
initialFocusSelector: "[name='Cancel']"
|
|
27
|
+
},
|
|
28
|
+
argTypes: {
|
|
29
|
+
link: {
|
|
30
|
+
description: "Text displayed for the modal trigger link",
|
|
31
|
+
table: {
|
|
32
|
+
type: { summary: "string" },
|
|
33
|
+
defaultValue: { summary: "Terms and Conditions" }
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
title: {
|
|
37
|
+
description: "Title displayed in the modal header",
|
|
38
|
+
table: {
|
|
39
|
+
type: { summary: "string" },
|
|
40
|
+
defaultValue: { summary: "Terms & Conditions" }
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
isOpen: {
|
|
44
|
+
description: "Whether the modal is currently open",
|
|
45
|
+
table: {
|
|
46
|
+
type: { summary: "boolean" },
|
|
47
|
+
defaultValue: { summary: false }
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
acceptText: {
|
|
51
|
+
description:
|
|
52
|
+
"Text for the accept button. If omitted, only a close button is shown.",
|
|
53
|
+
table: {
|
|
54
|
+
type: { summary: "string" },
|
|
55
|
+
defaultValue: { summary: undefined }
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
linkVariant: {
|
|
59
|
+
description: "Text size variant for the trigger link",
|
|
60
|
+
control: "select",
|
|
61
|
+
options: ["p", "pL", "pS", "pXS", "pXXS", "pXL"],
|
|
62
|
+
table: {
|
|
63
|
+
type: { summary: "string" },
|
|
64
|
+
defaultValue: { summary: "p" }
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
initialFocusSelector: {
|
|
68
|
+
description: "CSS selector for the element that receives initial focus",
|
|
69
|
+
table: {
|
|
70
|
+
type: { summary: "string" },
|
|
71
|
+
defaultValue: { summary: "" }
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export default meta;
|
|
78
|
+
|
|
79
|
+
export const Default = {};
|
|
80
|
+
|
|
81
|
+
export const SmallVariant = {
|
|
82
|
+
args: {
|
|
83
|
+
linkVariant: "pS"
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const ExtraSmallVariant = {
|
|
88
|
+
args: {
|
|
89
|
+
linkVariant: "pXS"
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const LargeVariant = {
|
|
94
|
+
args: {
|
|
95
|
+
linkVariant: "pL"
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const WithAcceptButton = {
|
|
100
|
+
args: {
|
|
101
|
+
acceptText: "I Accept"
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const CustomLinkText = {
|
|
106
|
+
args: {
|
|
107
|
+
link: "Learn More",
|
|
108
|
+
linkVariant: "pS"
|
|
109
|
+
}
|
|
110
|
+
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
2
2
|
import { createThemeValues } from "../../../util/themeUtils";
|
|
3
|
+
import { WHITE } from "../../../constants/colors";
|
|
3
4
|
import { ThemeContext } from "styled-components";
|
|
4
5
|
import Text from "../../atoms/text";
|
|
5
6
|
import { Box } from "../../atoms/layouts";
|
|
6
7
|
import ButtonWithAction from "../../atoms/button-with-action";
|
|
7
8
|
import { noop, arrowBorder } from "../../../util/general";
|
|
8
|
-
import {
|
|
9
|
+
import { fallbackValues } from "./Tooltip.theme";
|
|
9
10
|
|
|
10
11
|
const Tooltip = ({
|
|
11
12
|
tooltipID,
|
|
@@ -32,7 +33,7 @@ const Tooltip = ({
|
|
|
32
33
|
arrowBottom: "-8px",
|
|
33
34
|
arrowLeft: "auto"
|
|
34
35
|
},
|
|
35
|
-
|
|
36
|
+
backgroundColor = WHITE
|
|
36
37
|
}) => {
|
|
37
38
|
const closeTimeoutRef = useRef(null);
|
|
38
39
|
const [tooltipOpen, setTooltipOpen] = useState(false);
|
|
@@ -40,7 +41,7 @@ const Tooltip = ({
|
|
|
40
41
|
const themeValues = createThemeValues(
|
|
41
42
|
themeContext,
|
|
42
43
|
fallbackValues,
|
|
43
|
-
|
|
44
|
+
"Tooltip"
|
|
44
45
|
);
|
|
45
46
|
|
|
46
47
|
const { top, right, bottom, left } = contentPosition;
|
|
@@ -82,13 +83,28 @@ const Tooltip = ({
|
|
|
82
83
|
|
|
83
84
|
const renderTrigger = () => {
|
|
84
85
|
if (hasCustomTrigger && children) {
|
|
85
|
-
|
|
86
|
+
const child = React.Children.only(children);
|
|
87
|
+
const {
|
|
88
|
+
onFocus: childOnFocus,
|
|
89
|
+
onBlur: childOnBlur,
|
|
90
|
+
onKeyDown: childOnKeyDown
|
|
91
|
+
} = child.props ?? {};
|
|
92
|
+
return React.cloneElement(child, {
|
|
86
93
|
"aria-describedby": tooltipID,
|
|
87
|
-
onFocus:
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
onFocus: e => {
|
|
95
|
+
childOnFocus?.(e);
|
|
96
|
+
handleToggleTooltip(true);
|
|
97
|
+
},
|
|
98
|
+
onBlur: e => {
|
|
99
|
+
childOnBlur?.(e);
|
|
100
|
+
handleToggleTooltip(false);
|
|
101
|
+
},
|
|
102
|
+
onKeyDown: e => {
|
|
103
|
+
childOnKeyDown?.(e);
|
|
104
|
+
handleKeyDown(e);
|
|
105
|
+
},
|
|
90
106
|
tabIndex: "0",
|
|
91
|
-
style: { cursor: "pointer" }
|
|
107
|
+
style: { ...child.props?.style, cursor: "pointer" }
|
|
92
108
|
});
|
|
93
109
|
}
|
|
94
110
|
|
|
@@ -127,7 +143,7 @@ const Tooltip = ({
|
|
|
127
143
|
role="tooltip"
|
|
128
144
|
id={tooltipID}
|
|
129
145
|
aria-hidden={!tooltipOpen}
|
|
130
|
-
background={
|
|
146
|
+
background={backgroundColor}
|
|
131
147
|
data-qa="tooltip-contents"
|
|
132
148
|
extraStyles={`
|
|
133
149
|
position: absolute;
|
|
@@ -137,6 +153,7 @@ const Tooltip = ({
|
|
|
137
153
|
bottom: ${bottom};
|
|
138
154
|
left: ${left};
|
|
139
155
|
height: ${height};
|
|
156
|
+
color: ${themeValues.textColor};
|
|
140
157
|
${contentExtraStyles}
|
|
141
158
|
`}
|
|
142
159
|
boxShadow="0px 2px 14px 0px rgb(246, 246, 249), 0px 3px 8px 0px rgb(202, 206, 216)"
|
|
@@ -146,7 +163,7 @@ const Tooltip = ({
|
|
|
146
163
|
maxWidth={maxWidth}
|
|
147
164
|
>
|
|
148
165
|
{typeof content === "string" ? (
|
|
149
|
-
<Text color={themeValues.
|
|
166
|
+
<Text color={themeValues.textColor}>{content}</Text>
|
|
150
167
|
) : (
|
|
151
168
|
content
|
|
152
169
|
)}
|
|
@@ -157,11 +174,7 @@ const Tooltip = ({
|
|
|
157
174
|
content: "";
|
|
158
175
|
width: 0;
|
|
159
176
|
height: 0;
|
|
160
|
-
${arrowBorder(
|
|
161
|
-
arrowColor || themeValues.borderColor,
|
|
162
|
-
arrowDirection,
|
|
163
|
-
"8px"
|
|
164
|
-
)};
|
|
177
|
+
${arrowBorder(backgroundColor, arrowDirection, "8px")};
|
|
165
178
|
filter: drop-shadow(2px 8px 14px black);
|
|
166
179
|
bottom: ${arrowBottom};
|
|
167
180
|
right: ${arrowRight};
|
|
@@ -3,7 +3,7 @@ import Tooltip from "./Tooltip";
|
|
|
3
3
|
import Text from "../../atoms/text/Text";
|
|
4
4
|
import AutopayOnIcon from "../../atoms/icons/AutopayOnIcon";
|
|
5
5
|
import Box from "../../atoms/layouts/Box";
|
|
6
|
-
import { SEA_GREEN } from "../../../constants/colors";
|
|
6
|
+
import { SEA_GREEN, WHITE } from "../../../constants/colors";
|
|
7
7
|
|
|
8
8
|
const meta = {
|
|
9
9
|
title: "Molecules/Tooltip",
|
|
@@ -161,12 +161,12 @@ const meta = {
|
|
|
161
161
|
defaultValue: { summary: '""' }
|
|
162
162
|
}
|
|
163
163
|
},
|
|
164
|
-
|
|
164
|
+
backgroundColor: {
|
|
165
165
|
description:
|
|
166
|
-
"Override
|
|
166
|
+
"Override backgroundColor for the tooltip arrow. Defaults to WHITE when not provided.",
|
|
167
167
|
table: {
|
|
168
168
|
type: { summary: "string" },
|
|
169
|
-
defaultValue: { summary:
|
|
169
|
+
defaultValue: { summary: WHITE }
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -215,7 +215,7 @@ export const RichTooltipContent = {
|
|
|
215
215
|
tooltipID: "tooltip-node-content",
|
|
216
216
|
contentExtraStyles: "background-color: #000000; color: #ffffff;",
|
|
217
217
|
triggerText: "Rich content",
|
|
218
|
-
|
|
218
|
+
backgroundColor: "black",
|
|
219
219
|
contentPosition: {
|
|
220
220
|
top: "-126px",
|
|
221
221
|
right: "auto",
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
ROYAL_BLUE_VIVID,
|
|
3
|
+
ROYAL_BLUE,
|
|
4
|
+
CONGRESS_BLUE,
|
|
5
|
+
CHARADE_GREY
|
|
5
6
|
} from "../../../constants/colors";
|
|
6
7
|
|
|
7
|
-
const hoverColor =
|
|
8
|
-
const activeColor =
|
|
9
|
-
const linkColor =
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
export const TOOLTIP_THEME_SOURCE = "Button";
|
|
8
|
+
const hoverColor = ROYAL_BLUE;
|
|
9
|
+
const activeColor = CONGRESS_BLUE;
|
|
10
|
+
const linkColor = ROYAL_BLUE_VIVID;
|
|
11
|
+
const textColor = CHARADE_GREY;
|
|
13
12
|
|
|
14
13
|
export const fallbackValues = {
|
|
15
|
-
borderColor,
|
|
16
14
|
linkColor,
|
|
17
15
|
hoverColor,
|
|
18
|
-
activeColor
|
|
16
|
+
activeColor,
|
|
17
|
+
textColor
|
|
19
18
|
};
|
package/src/util/formats.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { createFormat } from "formatted-input";
|
|
3
3
|
import Text from "../components/atoms/text";
|
|
4
|
-
import { ASH_GREY, FIRE_YELLOW } from "../constants/colors";
|
|
4
|
+
import { ASH_GREY, FIRE_YELLOW, STORM_GREY } from "../constants/colors";
|
|
5
5
|
export const formatDelimiter = "_";
|
|
6
6
|
|
|
7
7
|
export const phoneFormats = [
|
|
@@ -101,7 +101,8 @@ export const renderCardStatus = (
|
|
|
101
101
|
<Text
|
|
102
102
|
as={as}
|
|
103
103
|
variant="pXS"
|
|
104
|
-
|
|
104
|
+
fontSize=".75rem"
|
|
105
|
+
color={STORM_GREY}
|
|
105
106
|
extraStyles={`text-align: ${textAlign}; margin: ${textMargin};`}
|
|
106
107
|
>
|
|
107
108
|
Exp Date {expireDate}
|
|
@@ -112,6 +113,7 @@ export const renderCardStatus = (
|
|
|
112
113
|
<Text
|
|
113
114
|
as={as}
|
|
114
115
|
variant="pXS"
|
|
116
|
+
fontSize=".75rem"
|
|
115
117
|
color={FIRE_YELLOW}
|
|
116
118
|
extraStyles={`text-align: ${textAlign}; margin: ${textMargin};`}
|
|
117
119
|
>
|
|
@@ -123,7 +125,8 @@ export const renderCardStatus = (
|
|
|
123
125
|
<Text
|
|
124
126
|
as={as}
|
|
125
127
|
variant="pXS"
|
|
126
|
-
|
|
128
|
+
fontSize=".75rem"
|
|
129
|
+
color={STORM_GREY}
|
|
127
130
|
extraStyles={`text-align: ${textAlign}; margin: ${textMargin};`}
|
|
128
131
|
>
|
|
129
132
|
Expired
|