@thecb/components 11.9.2-beta.1 → 11.9.2-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +11 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +11 -13
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/form-layouts/FormInput.js +1 -1
- 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 +2 -2
- package/src/components/atoms/formatted-credit-card/FormattedCreditCard.theme.js +2 -2
- package/src/components/molecules/email-form/EmailForm.js +2 -1
- package/src/components/molecules/email-form/EmailForm.stories.js +210 -0
- package/src/util/formats.js +3 -6
package/package.json
CHANGED
|
@@ -148,7 +148,7 @@ const FormInput = ({
|
|
|
148
148
|
<Stack childGap="0.25rem">
|
|
149
149
|
<Box padding="0">
|
|
150
150
|
{helperModal ? (
|
|
151
|
-
<Cluster justify="space-between" align="center">
|
|
151
|
+
<Cluster justify="space-between" align="center" overflow>
|
|
152
152
|
{labelDisplayOverride ? (
|
|
153
153
|
labelDisplayOverride
|
|
154
154
|
) : (
|
|
@@ -50,8 +50,8 @@ const FormattedBankAccount = ({
|
|
|
50
50
|
<Text
|
|
51
51
|
variant="p"
|
|
52
52
|
color={themeValues.autopayTextColor}
|
|
53
|
-
extraStyles={`font-style: italic
|
|
54
|
-
>{`Autopay
|
|
53
|
+
extraStyles={`font-style: italic;`}
|
|
54
|
+
>{`Autopay Enabled`}</Text>
|
|
55
55
|
)}
|
|
56
56
|
</Stack>
|
|
57
57
|
</BankItemWrapper>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CHARADE_GREY,
|
|
1
|
+
import { CHARADE_GREY, REGENT_GREY } from "../../../constants/colors";
|
|
2
2
|
|
|
3
3
|
const textColor = `${CHARADE_GREY}`;
|
|
4
|
-
const autopayTextColor = `${
|
|
4
|
+
const autopayTextColor = `${REGENT_GREY}`;
|
|
5
5
|
|
|
6
6
|
export const fallbackValues = {
|
|
7
7
|
textColor,
|
|
@@ -53,8 +53,8 @@ const FormattedCreditCard = ({
|
|
|
53
53
|
<Text
|
|
54
54
|
variant="p"
|
|
55
55
|
color={themeValues.autopayTextColor}
|
|
56
|
-
extraStyles={`font-style: italic
|
|
57
|
-
>{`Autopay
|
|
56
|
+
extraStyles={`font-style: italic;`}
|
|
57
|
+
>{`Autopay Enabled`}</Text>
|
|
58
58
|
)}
|
|
59
59
|
</Stack>
|
|
60
60
|
</CreditCardWrapper>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CHARADE_GREY,
|
|
1
|
+
import { CHARADE_GREY, REGENT_GREY } from "../../../constants/colors";
|
|
2
2
|
|
|
3
3
|
const textColor = `${CHARADE_GREY}`;
|
|
4
|
-
const autopayTextColor = `${
|
|
4
|
+
const autopayTextColor = `${REGENT_GREY}`;
|
|
5
5
|
|
|
6
6
|
export const fallbackValues = {
|
|
7
7
|
textColor,
|
|
@@ -34,7 +34,8 @@ const EmailForm = ({
|
|
|
34
34
|
);
|
|
35
35
|
const emailFieldErrorMessages = {
|
|
36
36
|
[required.error]: "Email address is required",
|
|
37
|
-
[isProbablyEmail.error]:
|
|
37
|
+
[isProbablyEmail.error]:
|
|
38
|
+
"Please enter a valid email address in the format user@example.com"
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
return (
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import EmailForm from "./EmailForm";
|
|
3
|
+
import { connect, Provider } from "react-redux";
|
|
4
|
+
import { createStore } from "redux";
|
|
5
|
+
import { createFormState, isProbablyEmail } from "redux-freeform";
|
|
6
|
+
import { noop } from "../../../util/general";
|
|
7
|
+
import { fn } from "@storybook/test";
|
|
8
|
+
|
|
9
|
+
const formConfig = {
|
|
10
|
+
email: {
|
|
11
|
+
validators: [isProbablyEmail()]
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const { mapStateToProps, mapDispatchToProps, reducer } = createFormState(
|
|
16
|
+
formConfig
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const store = createStore(
|
|
20
|
+
reducer,
|
|
21
|
+
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const FormWrapper = props => <EmailForm {...props} />;
|
|
25
|
+
|
|
26
|
+
const ConnectedEmailForm = connect(
|
|
27
|
+
mapStateToProps,
|
|
28
|
+
mapDispatchToProps
|
|
29
|
+
)(FormWrapper);
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
title: "Molecules/EmailForm",
|
|
33
|
+
component: ConnectedEmailForm,
|
|
34
|
+
tags: ["!autodocs"],
|
|
35
|
+
parameters: {
|
|
36
|
+
layout: "centered"
|
|
37
|
+
},
|
|
38
|
+
args: {
|
|
39
|
+
variant: "default",
|
|
40
|
+
clearOnDismount: undefined,
|
|
41
|
+
fields: undefined,
|
|
42
|
+
actions: undefined,
|
|
43
|
+
showErrors: false,
|
|
44
|
+
guestCheckout: false,
|
|
45
|
+
handleSubmit: noop,
|
|
46
|
+
showWalletCheckbox: false,
|
|
47
|
+
saveToWallet: noop,
|
|
48
|
+
walletCheckboxMarked: false,
|
|
49
|
+
isRequired: false
|
|
50
|
+
},
|
|
51
|
+
argTypes: {
|
|
52
|
+
variant: {
|
|
53
|
+
description: "Form container variant.",
|
|
54
|
+
control: { type: "text" },
|
|
55
|
+
table: {
|
|
56
|
+
type: { summary: "string" },
|
|
57
|
+
defaultValue: { summary: "default" }
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
fields: {
|
|
61
|
+
description:
|
|
62
|
+
"Field data, usually generated with [redux-freeform](https://github.com/CityBaseInc/redux-freeform).",
|
|
63
|
+
control: { type: "object" },
|
|
64
|
+
table: {
|
|
65
|
+
type: { summary: "object" },
|
|
66
|
+
defaultValue: { summary: undefined }
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
actions: {
|
|
70
|
+
description:
|
|
71
|
+
"Field actions, usually generated with [redux-freeform](https://github.com/CityBaseInc/redux-freeform).",
|
|
72
|
+
control: { type: "object" },
|
|
73
|
+
table: {
|
|
74
|
+
type: { summary: "object" },
|
|
75
|
+
defaultValue: { summary: undefined }
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
clearOnDismount: {
|
|
79
|
+
description:
|
|
80
|
+
"If `true`, `actions.form.clear()` will be called when the component unmounts.",
|
|
81
|
+
control: { type: "boolean" },
|
|
82
|
+
table: {
|
|
83
|
+
type: { summary: "boolean" },
|
|
84
|
+
defaultValue: { summary: undefined }
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
showErrors: {
|
|
88
|
+
description: "Show form field errors.",
|
|
89
|
+
control: { type: "boolean" },
|
|
90
|
+
table: {
|
|
91
|
+
type: { summary: "boolean" },
|
|
92
|
+
defaultValue: { summary: false }
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
guestCheckout: {
|
|
96
|
+
description:
|
|
97
|
+
"If `true`, displays a message about creating a wallet later for faster checkout.",
|
|
98
|
+
control: { type: "boolean" },
|
|
99
|
+
table: {
|
|
100
|
+
type: { summary: "boolean" },
|
|
101
|
+
defaultValue: { summary: false }
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
handleSubmit: {
|
|
105
|
+
description:
|
|
106
|
+
"Function called when the `Enter` key is pressed on the email input (via `onKeyDown` prop passed to `FormInput` component).",
|
|
107
|
+
control: { type: "object" },
|
|
108
|
+
table: {
|
|
109
|
+
type: { summary: "function" },
|
|
110
|
+
defaultValue: { summary: undefined }
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
showWalletCheckbox: {
|
|
114
|
+
description:
|
|
115
|
+
"If `true`, displays a checkbox to save the email address to wallet.",
|
|
116
|
+
control: { type: "boolean" },
|
|
117
|
+
table: {
|
|
118
|
+
type: { summary: "boolean" },
|
|
119
|
+
defaultValue: { summary: false }
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
saveToWallet: {
|
|
123
|
+
description: "Function called when the wallet checkbox is toggled.",
|
|
124
|
+
control: { type: "object" },
|
|
125
|
+
table: {
|
|
126
|
+
type: { summary: "function" },
|
|
127
|
+
defaultValue: { summary: undefined }
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
walletCheckboxMarked: {
|
|
131
|
+
description: "Whether the wallet checkbox is checked.",
|
|
132
|
+
control: { type: "boolean" },
|
|
133
|
+
table: {
|
|
134
|
+
type: { summary: "boolean" },
|
|
135
|
+
defaultValue: { summary: false }
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
isRequired: {
|
|
139
|
+
description: "If `true`, the email field becomes required.",
|
|
140
|
+
control: { type: "boolean" },
|
|
141
|
+
table: {
|
|
142
|
+
type: { summary: "boolean" },
|
|
143
|
+
defaultValue: { summary: false }
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
decorators: [
|
|
148
|
+
Story => (
|
|
149
|
+
<Provider store={store}>
|
|
150
|
+
<Story />
|
|
151
|
+
</Provider>
|
|
152
|
+
)
|
|
153
|
+
]
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export const Basic = args => <ConnectedEmailForm {...args} />;
|
|
157
|
+
|
|
158
|
+
export const ShowErrors = {
|
|
159
|
+
args: {
|
|
160
|
+
showErrors: true
|
|
161
|
+
},
|
|
162
|
+
render: args => <ConnectedEmailForm {...args} />
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export const GuestCheckout = {
|
|
166
|
+
args: {
|
|
167
|
+
guestCheckout: true
|
|
168
|
+
},
|
|
169
|
+
render: args => <ConnectedEmailForm {...args} />
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export const WithWalletCheckbox = {
|
|
173
|
+
args: {
|
|
174
|
+
showWalletCheckbox: true,
|
|
175
|
+
saveToWallet: fn()
|
|
176
|
+
},
|
|
177
|
+
render: args => <ConnectedEmailForm {...args} />
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export const Required = {
|
|
181
|
+
args: {
|
|
182
|
+
isRequired: true
|
|
183
|
+
},
|
|
184
|
+
render: args => <ConnectedEmailForm {...args} />
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export const RequiredWithErrors = {
|
|
188
|
+
args: {
|
|
189
|
+
isRequired: true,
|
|
190
|
+
showErrors: true
|
|
191
|
+
},
|
|
192
|
+
render: args => <ConnectedEmailForm {...args} />
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export const GuestCheckoutWithWallet = {
|
|
196
|
+
args: {
|
|
197
|
+
guestCheckout: true,
|
|
198
|
+
showWalletCheckbox: true,
|
|
199
|
+
saveToWallet: fn(),
|
|
200
|
+
walletCheckboxMarked: true
|
|
201
|
+
},
|
|
202
|
+
render: args => <ConnectedEmailForm {...args} />
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
export const HandleSubmit = {
|
|
206
|
+
args: {
|
|
207
|
+
handleSubmit: fn()
|
|
208
|
+
},
|
|
209
|
+
render: args => <ConnectedEmailForm {...args} />
|
|
210
|
+
};
|
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
|
|
4
|
+
import { ASH_GREY, FIRE_YELLOW } from "../constants/colors";
|
|
5
5
|
export const formatDelimiter = "_";
|
|
6
6
|
|
|
7
7
|
export const phoneFormats = [
|
|
@@ -101,8 +101,7 @@ export const renderCardStatus = (
|
|
|
101
101
|
<Text
|
|
102
102
|
as={as}
|
|
103
103
|
variant="pXS"
|
|
104
|
-
|
|
105
|
-
color={STORM_GREY}
|
|
104
|
+
color={ASH_GREY}
|
|
106
105
|
extraStyles={`text-align: ${textAlign}; margin: ${textMargin};`}
|
|
107
106
|
>
|
|
108
107
|
Exp Date {expireDate}
|
|
@@ -113,7 +112,6 @@ export const renderCardStatus = (
|
|
|
113
112
|
<Text
|
|
114
113
|
as={as}
|
|
115
114
|
variant="pXS"
|
|
116
|
-
fontSize=".75rem"
|
|
117
115
|
color={FIRE_YELLOW}
|
|
118
116
|
extraStyles={`text-align: ${textAlign}; margin: ${textMargin};`}
|
|
119
117
|
>
|
|
@@ -125,8 +123,7 @@ export const renderCardStatus = (
|
|
|
125
123
|
<Text
|
|
126
124
|
as={as}
|
|
127
125
|
variant="pXS"
|
|
128
|
-
|
|
129
|
-
color={STORM_GREY}
|
|
126
|
+
color={ASH_GREY}
|
|
130
127
|
extraStyles={`text-align: ${textAlign}; margin: ${textMargin};`}
|
|
131
128
|
>
|
|
132
129
|
Expired
|