@thecb/components 9.1.1-beta.3 → 9.1.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.
Files changed (28) hide show
  1. package/dist/index.cjs.js +279 -296
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +279 -296
  4. package/dist/index.esm.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/components/atoms/checkbox/Checkbox.js +1 -3
  7. package/src/components/atoms/country-dropdown/CountryDropdown.js +1 -3
  8. package/src/components/atoms/form-layouts/FormInput.js +3 -11
  9. package/src/components/atoms/radio-button-with-label/RadioButtonWithLabel.js +1 -3
  10. package/src/components/molecules/address-form/AddressForm.js +0 -6
  11. package/src/components/molecules/edit-name-form/EditNameForm.js +0 -2
  12. package/src/components/molecules/email-form/EmailForm.js +2 -5
  13. package/src/components/molecules/payment-form-ach/PaymentFormACH.js +0 -6
  14. package/src/components/molecules/payment-form-card/PaymentFormCard.js +0 -6
  15. package/src/components/molecules/phone-form/PhoneForm.js +1 -3
  16. package/src/components/molecules/radio-group/RadioGroup.js +7 -12
  17. package/src/components/molecules/radio-group/RadioGroup.stories.js +0 -2
  18. package/src/components/molecules/radio-section/RadioSection.js +2 -9
  19. package/src/components/molecules/radio-section/RadioSection.stories.js +4 -7
  20. package/src/components/molecules/radio-section/radio-button/RadioButton.js +1 -3
  21. package/src/components/templates/center-single/CenterSingle.js +2 -6
  22. package/src/components/templates/center-stack/CenterStack.js +4 -2
  23. package/src/components/templates/default-page-template/DefaultPageTemplate.js +1 -2
  24. package/dist/src/apps/checkout/pages/payment/sub-pages/payment-amount/PaymentAmount_old.js +0 -49322
  25. package/src/.DS_Store +0 -0
  26. package/src/components/.DS_Store +0 -0
  27. package/src/components/atoms/.DS_Store +0 -0
  28. package/src/components/atoms/icons/.DS_Store +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "9.1.1-beta.3",
3
+ "version": "9.1.1",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -64,8 +64,7 @@ const StyledCheckbox = styled.div`
64
64
  focusedStyles,
65
65
  errorStyles,
66
66
  disabledStyles,
67
- disabledCheckedStyles,
68
- required = false
67
+ disabledCheckedStyles
69
68
  }) =>
70
69
  error
71
70
  ? css`
@@ -129,7 +128,6 @@ const Checkbox = ({
129
128
  tabIndex="-1"
130
129
  aria-invalid={error}
131
130
  aria-describedby={error ? `${name}-error-message` : ""}
132
- required={required}
133
131
  />
134
132
  <StyledCheckbox
135
133
  role="checkbox"
@@ -10,8 +10,7 @@ const CountryDropdown = ({
10
10
  fieldActions,
11
11
  showErrors,
12
12
  onChange,
13
- dataQa = null,
14
- isRequired = false
13
+ dataQa = null
15
14
  }) => (
16
15
  <FormSelect
17
16
  options={options}
@@ -23,7 +22,6 @@ const CountryDropdown = ({
23
22
  showErrors={showErrors}
24
23
  onChange={onChange}
25
24
  autocompleteValue="country-name"
26
- required={isRequired}
27
25
  />
28
26
  );
29
27
  export default CountryDropdown;
@@ -55,14 +55,9 @@ const InputField = styled.input`
55
55
  `;
56
56
 
57
57
  // eslint-disable-next-line no-unused-vars
58
- const FormattedInputField = styled(({ showErrors, themeValues, ...props }) => {
59
- const { isRequired } = props;
60
- return (
61
- <FormattedInput
62
- {...(isRequired ? { ...props, required: true } : { ...props })}
63
- />
64
- );
65
- })`
58
+ const FormattedInputField = styled(({ showErrors, themeValues, ...props }) => (
59
+ <FormattedInput {...props} />
60
+ ))`
66
61
  border: 1px solid
67
62
  ${({ field, showErrors, themeValues }) =>
68
63
  (field.dirty && field.hasErrors) || (field.hasErrors && showErrors)
@@ -121,7 +116,6 @@ const FormInput = ({
121
116
  extraStyles,
122
117
  removeFromValue, // regex of characters to remove before setting value
123
118
  dataQa = null,
124
- isRequired = false,
125
119
  ...props
126
120
  }) => {
127
121
  const [showPassword, setShowPassword] = useState(false);
@@ -227,7 +221,6 @@ const FormInput = ({
227
221
  $extraStyles={extraStyles}
228
222
  data-qa={dataQa || labelTextWhenNoError}
229
223
  autoComplete={autocompleteValue}
230
- required={isRequired}
231
224
  {...props}
232
225
  />
233
226
  ) : (
@@ -254,7 +247,6 @@ const FormInput = ({
254
247
  $extraStyles={extraStyles}
255
248
  data-qa={dataQa || labelTextWhenNoError}
256
249
  autoComplete={autocompleteValue}
257
- required={isRequired}
258
250
  {...props}
259
251
  />
260
252
  )}
@@ -59,8 +59,7 @@ const RadioButtonWithLabel = ({
59
59
  index,
60
60
  handleChange = noop, // optional, for custom event handling in ingesting app
61
61
  field,
62
- config,
63
- required = false
62
+ config
64
63
  }) => {
65
64
  const getDefaultChecked = (value, idx) => {
66
65
  const selectionExistsInConfig = config
@@ -92,7 +91,6 @@ const RadioButtonWithLabel = ({
92
91
  handleChange(e);
93
92
  }}
94
93
  defaultChecked={getDefaultChecked(value, index)}
95
- required={required}
96
94
  />
97
95
  <Text
98
96
  as="label"
@@ -71,7 +71,6 @@ const AddressForm = ({
71
71
  }}
72
72
  showErrors={showErrors}
73
73
  dataQa="Country"
74
- isRequired={true}
75
74
  />
76
75
  <FormInput
77
76
  labelTextWhenNoError="Address"
@@ -82,7 +81,6 @@ const AddressForm = ({
82
81
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
83
82
  autocompleteValue="address-line1"
84
83
  dataQa="Address"
85
- required={true}
86
84
  />
87
85
  <FormInput
88
86
  labelTextWhenNoError="Apt, Suite, Unit, Floor, etc. (Optional)"
@@ -92,7 +90,6 @@ const AddressForm = ({
92
90
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
93
91
  autocompleteValue="address-line2"
94
92
  dataQa="Address Line 2"
95
- required={true}
96
93
  />
97
94
  <FormInput
98
95
  labelTextWhenNoError="City"
@@ -103,7 +100,6 @@ const AddressForm = ({
103
100
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
104
101
  autocompleteValue="address-level2"
105
102
  dataQa="City"
106
- required={true}
107
103
  />
108
104
  <StateProvinceDropdown
109
105
  labelTextWhenNoError={isUS ? "State" : "State or Province"}
@@ -114,7 +110,6 @@ const AddressForm = ({
114
110
  showErrors={showErrors}
115
111
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
116
112
  dataQa="State or Province"
117
- required={true}
118
113
  />
119
114
  <FormInput
120
115
  isNum={isUS}
@@ -127,7 +122,6 @@ const AddressForm = ({
127
122
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
128
123
  autocompleteValue="postal-code"
129
124
  dataQa="Zip code"
130
- required={true}
131
125
  />
132
126
  {showWalletCheckbox && (
133
127
  <Checkbox
@@ -37,7 +37,6 @@ const EditNameForm = ({
37
37
  showErrors={showErrors}
38
38
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
39
39
  autocompleteValue="given-name"
40
- isRequired={true}
41
40
  />
42
41
  <FormInput
43
42
  labelTextWhenNoError="Last Name"
@@ -48,7 +47,6 @@ const EditNameForm = ({
48
47
  showErrors={showErrors}
49
48
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
50
49
  autocompleteValue="family-name"
51
- isRequired={true}
52
50
  />
53
51
  </FormInputColumn>
54
52
  </FormContainer>
@@ -19,8 +19,7 @@ const EmailForm = ({
19
19
  handleSubmit = noop,
20
20
  showWalletCheckbox,
21
21
  saveToWallet,
22
- walletCheckboxMarked,
23
- isRequired = false
22
+ walletCheckboxMarked
24
23
  }) => {
25
24
  if (clearOnDismount) {
26
25
  useEffect(() => () => actions.form.clear(), []);
@@ -33,7 +32,7 @@ const EmailForm = ({
33
32
  return (
34
33
  <FormContainer variant={variant} role="form" aria-label="Email address">
35
34
  {guestCheckout && (
36
- <Paragraph margin="0 0 1.125rem 0" id="explanation">
35
+ <Paragraph margin="0 0 1.125rem 0">
37
36
  If desired, you can create a wallet later for faster checkout
38
37
  </Paragraph>
39
38
  )}
@@ -49,7 +48,6 @@ const EmailForm = ({
49
48
  isEmail
50
49
  autocompleteValue="email"
51
50
  dataQa="Email address"
52
- required={isRequired}
53
51
  />
54
52
  {showWalletCheckbox && (
55
53
  <Checkbox
@@ -57,7 +55,6 @@ const EmailForm = ({
57
55
  title="Save email address to wallet"
58
56
  checked={walletCheckboxMarked}
59
57
  onChange={saveToWallet}
60
- aria-describedby="explanation"
61
58
  />
62
59
  )}
63
60
  </FormInputColumn>
@@ -76,7 +76,6 @@ const PaymentFormACH = ({
76
76
  showErrors={showErrors}
77
77
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
78
78
  autocompleteValue="name"
79
- isRequired={true}
80
79
  />
81
80
  <FormInput
82
81
  labelTextWhenNoError="Routing number"
@@ -98,7 +97,6 @@ const PaymentFormACH = ({
98
97
  />
99
98
  )}
100
99
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
101
- isRequired={true}
102
100
  />
103
101
  <FormInput
104
102
  labelTextWhenNoError="Confirm routing number"
@@ -108,7 +106,6 @@ const PaymentFormACH = ({
108
106
  fieldActions={actions.fields.confirmRoutingNumber}
109
107
  showErrors={showErrors}
110
108
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
111
- isRequired={true}
112
109
  isNum
113
110
  />
114
111
  <FormInput
@@ -118,7 +115,6 @@ const PaymentFormACH = ({
118
115
  field={fields.accountNumber}
119
116
  fieldActions={actions.fields.accountNumber}
120
117
  showErrors={showErrors}
121
- isRequired={true}
122
118
  isNum
123
119
  helperModal={() => (
124
120
  <AccountAndRoutingModal
@@ -135,7 +131,6 @@ const PaymentFormACH = ({
135
131
  />
136
132
  <FormInput
137
133
  labelTextWhenNoError="Confirm account number"
138
- isRequired={true}
139
134
  dataQa="Confirm account number"
140
135
  errorMessages={confirmAccountNumberErrors}
141
136
  field={fields.confirmAccountNumber}
@@ -162,7 +157,6 @@ const PaymentFormACH = ({
162
157
  {!hideDefaultPayment && (
163
158
  <Checkbox
164
159
  title="Save as Default Payment Method"
165
- required={true}
166
160
  dataQa="default-payment-ach"
167
161
  name="default-payment-ach"
168
162
  onChange={toggleCheckbox}
@@ -110,7 +110,6 @@ const PaymentFormCard = ({
110
110
  }}
111
111
  showErrors={showErrors}
112
112
  dataQa="Country"
113
- isRequired={true}
114
113
  />
115
114
  )}
116
115
  <FormInput
@@ -122,7 +121,6 @@ const PaymentFormCard = ({
122
121
  showErrors={showErrors}
123
122
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
124
123
  autocompleteValue="cc-name"
125
- required={true}
126
124
  />
127
125
  <FormInput
128
126
  labelTextWhenNoError="Credit card number"
@@ -135,7 +133,6 @@ const PaymentFormCard = ({
135
133
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
136
134
  isNum
137
135
  autocompleteValue="cc-number"
138
- required={true}
139
136
  />
140
137
  <FormInputRow
141
138
  breakpoint={isMobile ? "1000rem" : "21rem"}
@@ -153,7 +150,6 @@ const PaymentFormCard = ({
153
150
  isNum
154
151
  removeFromValue={/\//} // removes "/" from browser autofill
155
152
  autocompleteValue="cc-exp"
156
- required={true}
157
153
  />
158
154
  <FormInput
159
155
  labelTextWhenNoError="CVV"
@@ -170,7 +166,6 @@ const PaymentFormCard = ({
170
166
  }
171
167
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
172
168
  autocompleteValue="cc-csc"
173
- required={true}
174
169
  />
175
170
  </FormInputRow>
176
171
  {!hideZipCode && (
@@ -189,7 +184,6 @@ const PaymentFormCard = ({
189
184
  showErrors={showErrors}
190
185
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
191
186
  autocompleteValue="billing postal-code"
192
- required={true}
193
187
  />
194
188
  </Box>
195
189
  )}
@@ -19,8 +19,7 @@ const PhoneForm = ({
19
19
  handleSubmit = noop,
20
20
  showWalletCheckbox,
21
21
  saveToWallet,
22
- walletCheckboxMarked,
23
- isRequired = false
22
+ walletCheckboxMarked
24
23
  }) => {
25
24
  if (clearOnDismount) {
26
25
  useEffect(() => () => actions.form.clear(), []);
@@ -44,7 +43,6 @@ const PhoneForm = ({
44
43
  autocompleteValue="tel-national"
45
44
  dataQa="Phone number"
46
45
  isNum={true}
47
- required={isRequired}
48
46
  />
49
47
  {showWalletCheckbox && (
50
48
  <Checkbox
@@ -29,24 +29,19 @@ const RadioGroup = ({
29
29
  handleChange = noop, // optional, for custom event handling in ingesting app
30
30
  // redux-freeform props - this is similar to how FormInput works, duplicated because the radio input is hidden for styling overrides
31
31
  field,
32
- fieldActions,
33
- role = "radiogroup",
34
- isRequired = false
32
+ fieldActions
35
33
  }) => {
36
34
  const setValue = value => fieldActions.set(value);
37
35
  return (
38
- <StyledFieldset $extraStyles={extraStyles}>
36
+ <StyledFieldset
37
+ role="radiogroup"
38
+ aria-labelledby={`radio-group-${groupName}-heading`}
39
+ $extraStyles={extraStyles}
40
+ >
39
41
  {Heading !== null && Heading}
40
- <Stack
41
- childGap="4px"
42
- role={role}
43
- required={isRequired}
44
- aria-labelledby={`radio-group-${groupName}-heading`}
45
- >
42
+ <Stack childGap="4px">
46
43
  {config.map((c, idx) => (
47
44
  <RadioButtonWithLabel
48
- required={isRequired}
49
- role="radio"
50
45
  index={idx}
51
46
  key={c.id}
52
47
  {...c}
@@ -33,8 +33,6 @@ export const radioGroup = () => (
33
33
  fieldActions={{
34
34
  set: () => noop()
35
35
  }}
36
- isRequired={true}
37
- role="radiogroup"
38
36
  />
39
37
  );
40
38
 
@@ -47,10 +47,7 @@ const RadioSection = ({
47
47
  initiallyOpen = true,
48
48
  openHeight = "auto",
49
49
  containerStyles = "",
50
- ariaDescribedBy,
51
- role = "radiogroup",
52
- required = false,
53
- label = ""
50
+ ariaDescribedBy
54
51
  }) => {
55
52
  const handleKeyDown = (id, e) => {
56
53
  if (e?.keyCode === 13 || e?.keyCode === 32) {
@@ -107,10 +104,8 @@ const RadioSection = ({
107
104
  border={`1px solid ${themeValues.borderColor}`}
108
105
  borderRadius="4px"
109
106
  extraStyles={containerStyles}
110
- role={role}
111
- required={required}
112
107
  >
113
- <Stack childGap="0">
108
+ <Stack childGap="0" role="radiogroup">
114
109
  {sections
115
110
  .filter(section => !section.hidden)
116
111
  .map(section => (
@@ -129,7 +124,6 @@ const RadioSection = ({
129
124
  role="radio"
130
125
  aria-checked={openSection === section.id}
131
126
  aria-disabled={section.disabled}
132
- aria-label={label || section.title}
133
127
  >
134
128
  <Stack childGap="0">
135
129
  <Box
@@ -183,7 +177,6 @@ const RadioSection = ({
183
177
  : () => toggleOpenSection(section.id)
184
178
  }
185
179
  tabIndex="-1"
186
- isRequired={required}
187
180
  />
188
181
  </Box>
189
182
  )}
@@ -1,5 +1,6 @@
1
1
  import React, { useState } from "react";
2
- import { text, boolean, object } from "@storybook/addon-knobs";
2
+ import { text, boolean } from "@storybook/addon-knobs";
3
+
3
4
  import RadioSection from "./RadioSection";
4
5
  import page from "../../../../.storybook/page";
5
6
 
@@ -58,16 +59,12 @@ export const radioSection = () => {
58
59
  const [openSection, setOpenSection] = useState("");
59
60
  return (
60
61
  <RadioSection
61
- required={true}
62
- role="radiogroup"
63
62
  isMobile={boolean("isMobile", false, "props")}
64
63
  supportsTouch={boolean("isMobile", false, "props")}
65
64
  toggleOpenSection={setOpenSection}
66
- openSection={text("openSection", "bar", "props")}
65
+ openSection={openSection}
67
66
  staggeredAnimation={boolean("staggeredAnimation", false, "props")}
68
- sections={object("sections", sections, "props")}
69
- title={text("title", "Example Radio Section", "props")}
70
- initiallyOpen={boolean("initiallyOpen", true, "props")}
67
+ sections={sections}
71
68
  />
72
69
  );
73
70
  };
@@ -19,8 +19,7 @@ const RadioButton = ({
19
19
  ariaDescribedBy = "",
20
20
  themeValues,
21
21
  ariaLabelledBy = "",
22
- ariaLabel = null,
23
- isRequired = false
22
+ ariaLabel = null
24
23
  }) => {
25
24
  const buttonBorder = {
26
25
  onFocused: {
@@ -92,7 +91,6 @@ const RadioButton = ({
92
91
  onClick={toggleRadio}
93
92
  aria-describedby={ariaDescribedBy}
94
93
  tabIndex="-1"
95
- required={isRequired}
96
94
  {...extraProps}
97
95
  />
98
96
  <Motion
@@ -30,12 +30,7 @@ const CenterSingle = ({
30
30
  >
31
31
  <Cover centerOverride={isMobile && !centeredMobileContent}>
32
32
  {header ? header : <Box padding="0" />}
33
- <Box
34
- padding="0"
35
- minWidth="100%"
36
- extraStyles={`z-index: 1;`}
37
- role="main"
38
- >
33
+ <Box padding="0" minWidth="100%" extraStyles={`z-index: 1;`}>
39
34
  {subHeader && !(isMobile && hideMobileSubHeader) ? (
40
35
  subHeader
41
36
  ) : (
@@ -44,6 +39,7 @@ const CenterSingle = ({
44
39
  <Center
45
40
  maxWidth={isMobile && fullWidthMobile ? "100%" : maxContentWidth}
46
41
  intrinsic={!isMobile}
42
+ role="main"
47
43
  >
48
44
  {centeredMobileContent ? (
49
45
  <Cover minHeight="100%" singleChild>
@@ -15,7 +15,8 @@ const CenterStack = ({
15
15
  maxContentWidth = "36.75rem",
16
16
  fullWidthMobile = true,
17
17
  content,
18
- themeValues
18
+ themeValues,
19
+ role = "main"
19
20
  }) => {
20
21
  const themeContext = useContext(ThemeContext);
21
22
  const { isMobile } = themeContext;
@@ -29,7 +30,7 @@ const CenterStack = ({
29
30
  >
30
31
  <Cover>
31
32
  {header ? header : <Box padding="0" />}
32
- <Box padding="0" minWidth="100%" role="main">
33
+ <Box padding="0" minWidth="100%">
33
34
  {subHeader && !(isMobile && hideMobileSubHeader) ? (
34
35
  subHeader
35
36
  ) : (
@@ -38,6 +39,7 @@ const CenterStack = ({
38
39
  <Center
39
40
  maxWidth={isMobile && fullWidthMobile ? "100%" : maxContentWidth}
40
41
  intrinsic={!isMobile}
42
+ role={role}
41
43
  >
42
44
  <Cover minHeight="100%" singleChild>
43
45
  <Stack childGap={contentSpacing}>{content}</Stack>
@@ -38,14 +38,13 @@ const CenterSingle = ({
38
38
  minWidth="100%"
39
39
  minHeight="100%"
40
40
  extraStyles={`z-index: 1;`}
41
- role="main"
42
41
  >
43
42
  {subHeader && !(isMobile && hideMobileSubHeader) ? (
44
43
  subHeader
45
44
  ) : (
46
45
  <Fragment />
47
46
  )}
48
- <Center maxWidth={maxWidth} gutters={gutters}>
47
+ <Center maxWidth={maxWidth} gutters={gutters} role="main">
49
48
  {content}
50
49
  </Center>
51
50
  </Box>