@thecb/components 12.1.0-beta.0 → 12.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +28 -25
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +28 -25
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/checkbox/Checkbox.js +21 -15
- package/src/components/atoms/checkbox/Checkbox.stories.js +1 -7
- package/src/components/molecules/partial-amount-form/PartialAmountField.js +2 -1
- package/src/components/molecules/payment-form-ach/PaymentFormACH.js +1 -1
- package/src/components/molecules/payment-form-card/PaymentFormCard.js +1 -1
- package/src/components/molecules/payment-form-ach/PaymentFormACH.stories.js +0 -121
- package/src/components/molecules/payment-form-card/PaymentFormCard.stories.js +0 -120
package/package.json
CHANGED
|
@@ -122,41 +122,47 @@ const Checkbox = forwardRef(
|
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
// aria-label fallback when no visible title or external labelledById is provided
|
|
129
|
-
const ariaLabel = !labelledById && !title ? name : undefined;
|
|
125
|
+
const titleId = title ? `checkboxlabel-${name}` : undefined;
|
|
126
|
+
const ariaLabelledById = labelledById ?? titleId;
|
|
127
|
+
const ariaLabel = ariaLabelledById ? undefined : name;
|
|
130
128
|
|
|
131
129
|
return (
|
|
132
130
|
<Box
|
|
133
131
|
ref={ref}
|
|
134
132
|
padding="0"
|
|
133
|
+
tabIndex="0"
|
|
134
|
+
role="checkbox"
|
|
135
|
+
aria-checked={checked}
|
|
136
|
+
aria-required={isRequired || undefined}
|
|
137
|
+
aria-invalid={error}
|
|
138
|
+
aria-label={ariaLabel}
|
|
139
|
+
aria-labelledby={ariaLabelledById}
|
|
140
|
+
aria-describedby={error ? `${name}-error-message` : undefined}
|
|
141
|
+
onFocus={() => setFocused(true)}
|
|
142
|
+
onBlur={() => setFocused(false)}
|
|
143
|
+
onKeyDown={e => handleClick(e, onChange)}
|
|
135
144
|
hiddenStyles={hidden}
|
|
136
145
|
background={themeValues.backgroundColor}
|
|
137
146
|
extraStyles={`
|
|
147
|
+
:focus {
|
|
148
|
+
outline: 0;
|
|
149
|
+
}
|
|
138
150
|
${extraStyles};
|
|
139
151
|
margin: ${checkboxMargin};
|
|
140
152
|
`}
|
|
141
153
|
{...rest}
|
|
142
154
|
>
|
|
143
|
-
<CheckboxLabelContainer
|
|
155
|
+
<CheckboxLabelContainer data-qa={dataQa}>
|
|
144
156
|
<CheckboxContainer data-qa="Checkbox">
|
|
145
157
|
<HiddenCheckbox
|
|
146
|
-
id={
|
|
158
|
+
id={`checkbox-${name}`}
|
|
147
159
|
disabled={disabled}
|
|
148
160
|
name={name}
|
|
149
161
|
checked={checked}
|
|
150
162
|
onChange={onChange}
|
|
151
|
-
tabIndex="
|
|
163
|
+
tabIndex="-1"
|
|
152
164
|
required={isRequired}
|
|
153
|
-
aria-
|
|
154
|
-
aria-label={ariaLabel}
|
|
155
|
-
aria-labelledby={labelledById}
|
|
156
|
-
aria-describedby={error ? `${name}-error-message` : undefined}
|
|
157
|
-
onKeyDown={e => handleClick(e, onChange)}
|
|
158
|
-
onFocus={() => setFocused(true)}
|
|
159
|
-
onBlur={() => setFocused(false)}
|
|
165
|
+
aria-hidden="true"
|
|
160
166
|
/>
|
|
161
167
|
<StyledCheckbox
|
|
162
168
|
aria-hidden="true"
|
|
@@ -95,15 +95,9 @@ const RequiredCheckbox = props => {
|
|
|
95
95
|
onChange={onChange}
|
|
96
96
|
checked={checked}
|
|
97
97
|
error={!checked}
|
|
98
|
-
extraStyles="display: inline-block;"
|
|
99
98
|
/>
|
|
100
99
|
{!checked && (
|
|
101
|
-
<div
|
|
102
|
-
id={`${props.name}-error-message`}
|
|
103
|
-
style={{ display: "inline-block" }}
|
|
104
|
-
>
|
|
105
|
-
This box is required.
|
|
106
|
-
</div>
|
|
100
|
+
<div id={`${props.name}-error-message`}>You must check this!</div>
|
|
107
101
|
)}
|
|
108
102
|
</div>
|
|
109
103
|
);
|
|
@@ -39,7 +39,7 @@ const PartialAmountField = ({
|
|
|
39
39
|
variant={themeValues.detailVariant}
|
|
40
40
|
weight="400"
|
|
41
41
|
>
|
|
42
|
-
{lineItem.subDescription}
|
|
42
|
+
{lineItem.subDescription} payment amount
|
|
43
43
|
</Detail>
|
|
44
44
|
</Box>
|
|
45
45
|
</Stack>
|
|
@@ -53,6 +53,7 @@ const PartialAmountField = ({
|
|
|
53
53
|
placeholder="$0.00"
|
|
54
54
|
formatter={moneyFormat}
|
|
55
55
|
isNum
|
|
56
|
+
isRequired
|
|
56
57
|
decorator={
|
|
57
58
|
<Text variant="p">
|
|
58
59
|
Amount owed:{" "}
|
|
@@ -178,7 +178,7 @@ const PaymentFormACH = ({
|
|
|
178
178
|
<Checkbox
|
|
179
179
|
name="bank checkbox"
|
|
180
180
|
dataQa="Save checking account to wallet"
|
|
181
|
-
title="Save checking account to wallet
|
|
181
|
+
title="Save checking account to wallet."
|
|
182
182
|
checked={walletCheckboxMarked}
|
|
183
183
|
onChange={saveToWallet}
|
|
184
184
|
/>
|
|
@@ -202,7 +202,7 @@ const PaymentFormCard = ({
|
|
|
202
202
|
<Checkbox
|
|
203
203
|
name="credit card checkbox"
|
|
204
204
|
dataQa="Save credit card to wallet"
|
|
205
|
-
title="Save credit card to wallet
|
|
205
|
+
title="Save credit card to wallet."
|
|
206
206
|
checked={walletCheckboxMarked}
|
|
207
207
|
onChange={saveToWallet}
|
|
208
208
|
/>
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { connect, Provider } from "react-redux";
|
|
3
|
-
import { createStore } from "redux";
|
|
4
|
-
import PaymentFormACH from "./PaymentFormACH";
|
|
5
|
-
import * as PaymentFormACHState from "./PaymentFormACH.state";
|
|
6
|
-
import { noop } from "../../../util/general";
|
|
7
|
-
import { fn } from "@storybook/test";
|
|
8
|
-
|
|
9
|
-
const store = createStore(
|
|
10
|
-
PaymentFormACHState.reducer,
|
|
11
|
-
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
const FormWrapper = props => {
|
|
15
|
-
const [walletChecked, setWalletChecked] = useState(
|
|
16
|
-
props.walletCheckboxMarked ?? false
|
|
17
|
-
);
|
|
18
|
-
return (
|
|
19
|
-
<PaymentFormACH
|
|
20
|
-
{...props}
|
|
21
|
-
walletCheckboxMarked={walletChecked}
|
|
22
|
-
saveToWallet={() => setWalletChecked(!walletChecked)}
|
|
23
|
-
/>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const ConnectedForm = connect(
|
|
28
|
-
PaymentFormACHState.mapStateToProps,
|
|
29
|
-
PaymentFormACHState.mapDispatchToProps
|
|
30
|
-
)(FormWrapper);
|
|
31
|
-
|
|
32
|
-
export default {
|
|
33
|
-
title: "Molecules/PaymentFormACH",
|
|
34
|
-
component: ConnectedForm,
|
|
35
|
-
tags: ["!autodocs"],
|
|
36
|
-
parameters: {
|
|
37
|
-
layout: "centered",
|
|
38
|
-
controls: { expanded: true }
|
|
39
|
-
},
|
|
40
|
-
args: {
|
|
41
|
-
showErrors: false,
|
|
42
|
-
hideDefaultPayment: true,
|
|
43
|
-
allowBankAccountType: false,
|
|
44
|
-
showWalletCheckbox: false,
|
|
45
|
-
handleSubmit: noop
|
|
46
|
-
},
|
|
47
|
-
argTypes: {
|
|
48
|
-
showErrors: {
|
|
49
|
-
description: "Displays validation error messages on each field.",
|
|
50
|
-
control: { type: "boolean" },
|
|
51
|
-
table: {
|
|
52
|
-
type: { summary: "boolean" },
|
|
53
|
-
defaultValue: { summary: false }
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
hideDefaultPayment: {
|
|
57
|
-
description:
|
|
58
|
-
"Hides the 'Save as Default Payment Method' checkbox. Defaults to `true`.",
|
|
59
|
-
control: { type: "boolean" },
|
|
60
|
-
table: {
|
|
61
|
-
type: { summary: "boolean" },
|
|
62
|
-
defaultValue: { summary: true }
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
allowBankAccountType: {
|
|
66
|
-
description: "Shows the account type dropdown (Checking / Savings).",
|
|
67
|
-
control: { type: "boolean" },
|
|
68
|
-
table: {
|
|
69
|
-
type: { summary: "boolean" },
|
|
70
|
-
defaultValue: { summary: false }
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
showWalletCheckbox: {
|
|
74
|
-
description:
|
|
75
|
-
'Shows the "Save checking account to wallet (optional)." checkbox.',
|
|
76
|
-
control: { type: "boolean" },
|
|
77
|
-
table: {
|
|
78
|
-
type: { summary: "boolean" },
|
|
79
|
-
defaultValue: { summary: false }
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
handleSubmit: {
|
|
83
|
-
description: "Function called when Enter is pressed on any text input.",
|
|
84
|
-
control: { type: "object" },
|
|
85
|
-
table: {
|
|
86
|
-
type: { summary: "function" },
|
|
87
|
-
defaultValue: { summary: undefined }
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
decorators: [
|
|
92
|
-
Story => (
|
|
93
|
-
<Provider store={store}>
|
|
94
|
-
<Story />
|
|
95
|
-
</Provider>
|
|
96
|
-
)
|
|
97
|
-
]
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export const Basic = args => <ConnectedForm {...args} />;
|
|
101
|
-
|
|
102
|
-
export const WithWalletCheckbox = {
|
|
103
|
-
args: {
|
|
104
|
-
showWalletCheckbox: true
|
|
105
|
-
},
|
|
106
|
-
render: args => <ConnectedForm {...args} />
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export const ShowErrors = {
|
|
110
|
-
args: {
|
|
111
|
-
showErrors: true
|
|
112
|
-
},
|
|
113
|
-
render: args => <ConnectedForm {...args} />
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export const WithAccountType = {
|
|
117
|
-
args: {
|
|
118
|
-
allowBankAccountType: true
|
|
119
|
-
},
|
|
120
|
-
render: args => <ConnectedForm {...args} />
|
|
121
|
-
};
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { connect, Provider } from "react-redux";
|
|
3
|
-
import { createStore } from "redux";
|
|
4
|
-
import PaymentFormCard from "./PaymentFormCard";
|
|
5
|
-
import * as PaymentFormCardState from "./PaymentFormCard.state";
|
|
6
|
-
import { noop } from "../../../util/general";
|
|
7
|
-
import { fn } from "@storybook/test";
|
|
8
|
-
|
|
9
|
-
const store = createStore(
|
|
10
|
-
PaymentFormCardState.reducer,
|
|
11
|
-
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
const FormWrapper = props => {
|
|
15
|
-
const [walletChecked, setWalletChecked] = useState(
|
|
16
|
-
props.walletCheckboxMarked ?? false
|
|
17
|
-
);
|
|
18
|
-
return (
|
|
19
|
-
<PaymentFormCard
|
|
20
|
-
{...props}
|
|
21
|
-
walletCheckboxMarked={walletChecked}
|
|
22
|
-
saveToWallet={() => setWalletChecked(!walletChecked)}
|
|
23
|
-
/>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const ConnectedForm = connect(
|
|
28
|
-
PaymentFormCardState.mapStateToProps,
|
|
29
|
-
PaymentFormCardState.mapDispatchToProps
|
|
30
|
-
)(FormWrapper);
|
|
31
|
-
|
|
32
|
-
export default {
|
|
33
|
-
title: "Molecules/PaymentFormCard",
|
|
34
|
-
component: ConnectedForm,
|
|
35
|
-
tags: ["!autodocs"],
|
|
36
|
-
parameters: {
|
|
37
|
-
layout: "centered",
|
|
38
|
-
controls: { expanded: true }
|
|
39
|
-
},
|
|
40
|
-
args: {
|
|
41
|
-
showErrors: false,
|
|
42
|
-
hideZipCode: false,
|
|
43
|
-
showWalletCheckbox: false,
|
|
44
|
-
deniedCards: undefined,
|
|
45
|
-
handleSubmit: noop
|
|
46
|
-
},
|
|
47
|
-
argTypes: {
|
|
48
|
-
showErrors: {
|
|
49
|
-
description: "Displays validation error messages on each field.",
|
|
50
|
-
control: { type: "boolean" },
|
|
51
|
-
table: {
|
|
52
|
-
type: { summary: "boolean" },
|
|
53
|
-
defaultValue: { summary: false }
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
hideZipCode: {
|
|
57
|
-
description: "Hides the country dropdown and zip code field.",
|
|
58
|
-
control: { type: "boolean" },
|
|
59
|
-
table: {
|
|
60
|
-
type: { summary: "boolean" },
|
|
61
|
-
defaultValue: { summary: false }
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
showWalletCheckbox: {
|
|
65
|
-
description:
|
|
66
|
-
'Shows the "Save credit card to wallet (optional)." checkbox.',
|
|
67
|
-
control: { type: "boolean" },
|
|
68
|
-
table: {
|
|
69
|
-
type: { summary: "boolean" },
|
|
70
|
-
defaultValue: { summary: false }
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
deniedCards: {
|
|
74
|
-
description: 'Array of card brand strings to deny (e.g. `["AMEX"]`).',
|
|
75
|
-
control: { type: "object" },
|
|
76
|
-
table: {
|
|
77
|
-
type: { summary: "string[]" },
|
|
78
|
-
defaultValue: { summary: undefined }
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
handleSubmit: {
|
|
82
|
-
description: "Function called when Enter is pressed on any text input.",
|
|
83
|
-
control: { type: "object" },
|
|
84
|
-
table: {
|
|
85
|
-
type: { summary: "function" },
|
|
86
|
-
defaultValue: { summary: undefined }
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
decorators: [
|
|
91
|
-
Story => (
|
|
92
|
-
<Provider store={store}>
|
|
93
|
-
<Story />
|
|
94
|
-
</Provider>
|
|
95
|
-
)
|
|
96
|
-
]
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export const Basic = args => <ConnectedForm {...args} />;
|
|
100
|
-
|
|
101
|
-
export const WithWalletCheckbox = {
|
|
102
|
-
args: {
|
|
103
|
-
showWalletCheckbox: true
|
|
104
|
-
},
|
|
105
|
-
render: args => <ConnectedForm {...args} />
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export const ShowErrors = {
|
|
109
|
-
args: {
|
|
110
|
-
showErrors: true
|
|
111
|
-
},
|
|
112
|
-
render: args => <ConnectedForm {...args} />
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export const WithDeniedCards = {
|
|
116
|
-
args: {
|
|
117
|
-
deniedCards: ["AMEX"]
|
|
118
|
-
},
|
|
119
|
-
render: args => <ConnectedForm {...args} />
|
|
120
|
-
};
|