@thecb/components 9.3.0-beta.0 → 9.3.0-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "9.3.0-beta.0",
3
+ "version": "9.3.0-beta.2",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -95,7 +95,8 @@ const Checkbox = ({
95
95
  checkboxMargin = "0 16px 0 0",
96
96
  extraStyles,
97
97
  textExtraStyles,
98
- dataQa = null
98
+ dataQa = null,
99
+ isRequired = false
99
100
  }) => {
100
101
  const [focused, setFocused] = useState(false);
101
102
 
@@ -142,6 +143,7 @@ const Checkbox = ({
142
143
  disabledStyles={themeValues.disabledStyles}
143
144
  disabledCheckedStyles={themeValues.disabledCheckedStyles}
144
145
  focusedStyles={themeValues.focusedStyles}
146
+ aria-required={isRequired}
145
147
  >
146
148
  <CheckboxIcon
147
149
  viewBox="0 0 24 24"
@@ -13,12 +13,13 @@ const groupId = "props";
13
13
  export const checkbox = () => (
14
14
  <Checkbox
15
15
  variant={select(variantsLabel, variants, defaultValue, groupId)}
16
- title={text("title", "Checkbox", "props")}
17
- name={text("name", "Checkbox", "props")}
16
+ title={text("title", "Checkbox Title", "props")}
17
+ name={text("name", "Checkbox Name", "props")}
18
18
  checked={boolean("checked", false, "props")}
19
19
  error={boolean("error", false, "props")}
20
20
  disabled={boolean("disabled", false, "props")}
21
21
  focused={boolean("focused", false, "props")}
22
+ isRequired={boolean("isRequired", true, "props")}
22
23
  />
23
24
  );
24
25
 
@@ -29,6 +29,7 @@ const FormSelect = ({
29
29
  }) => {
30
30
  const [open, setOpen] = useState(false);
31
31
  const dropdownRef = useRef(null);
32
+ const required = options?.required || isRequired;
32
33
 
33
34
  const labelId = useMemo(
34
35
  () => labelTextWhenNoError => createIdFromString(labelTextWhenNoError),
@@ -105,7 +106,7 @@ const FormSelect = ({
105
106
  disabled={disabled}
106
107
  autocompleteValue={autocompleteValue}
107
108
  smoothScroll={smoothScroll}
108
- required={options?.required}
109
+ isRequired={required}
109
110
  />
110
111
  <Stack direction="row" justify="space-between">
111
112
  <Text
@@ -25,7 +25,7 @@ const FormStateDropdown = ({
25
25
  errorMessages={errorMessages}
26
26
  showErrors={showErrors}
27
27
  autocompleteValue="address-level1"
28
- isRequired={options?.required || isRequired}
28
+ isRequired={isRequired}
29
29
  />
30
30
  );
31
31
  };
@@ -39,6 +39,7 @@ const FormWrapper = ({
39
39
  countryCode={countryCode}
40
40
  labelTextWhenNoError={labelTextWhenNoError}
41
41
  showErrors={showErrors}
42
+ isRequired={true}
42
43
  />
43
44
  );
44
45
 
@@ -82,6 +82,7 @@ const AddressForm = ({
82
82
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
83
83
  autocompleteValue="address-line1"
84
84
  dataQa="Address"
85
+ isRequired={true}
85
86
  />
86
87
  <FormInput
87
88
  labelTextWhenNoError="Apt, Suite, Unit, Floor, etc. (Optional)"
@@ -91,6 +92,7 @@ const AddressForm = ({
91
92
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
92
93
  autocompleteValue="address-line2"
93
94
  dataQa="Address Line 2"
95
+ isRequired={false}
94
96
  />
95
97
  <FormInput
96
98
  labelTextWhenNoError="City"
@@ -101,6 +103,7 @@ const AddressForm = ({
101
103
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
102
104
  autocompleteValue="address-level2"
103
105
  dataQa="City"
106
+ isRequired={true}
104
107
  />
105
108
  <StateProvinceDropdown
106
109
  labelTextWhenNoError={isUS ? "State" : "State or Province"}
@@ -111,6 +114,7 @@ const AddressForm = ({
111
114
  showErrors={showErrors}
112
115
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
113
116
  dataQa="State or Province"
117
+ isRequired={true}
114
118
  />
115
119
  <FormInput
116
120
  isNum={isUS}
@@ -123,6 +127,7 @@ const AddressForm = ({
123
127
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
124
128
  autocompleteValue="postal-code"
125
129
  dataQa="Zip code"
130
+ isRequired={true}
126
131
  />
127
132
  {showWalletCheckbox && (
128
133
  <Checkbox
@@ -76,6 +76,7 @@ const PaymentFormACH = ({
76
76
  showErrors={showErrors}
77
77
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
78
78
  autocompleteValue="name"
79
+ isRequired={true}
79
80
  />
80
81
  <FormInput
81
82
  labelTextWhenNoError="Routing number"
@@ -97,6 +98,7 @@ const PaymentFormACH = ({
97
98
  />
98
99
  )}
99
100
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
101
+ isRequired={true}
100
102
  />
101
103
  <FormInput
102
104
  labelTextWhenNoError="Confirm routing number"
@@ -106,6 +108,7 @@ const PaymentFormACH = ({
106
108
  fieldActions={actions.fields.confirmRoutingNumber}
107
109
  showErrors={showErrors}
108
110
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
111
+ isRequired={true}
109
112
  isNum
110
113
  />
111
114
  <FormInput
@@ -115,6 +118,7 @@ const PaymentFormACH = ({
115
118
  field={fields.accountNumber}
116
119
  fieldActions={actions.fields.accountNumber}
117
120
  showErrors={showErrors}
121
+ isRequired={true}
118
122
  isNum
119
123
  helperModal={() => (
120
124
  <AccountAndRoutingModal
@@ -132,6 +136,7 @@ const PaymentFormACH = ({
132
136
  <FormInput
133
137
  labelTextWhenNoError="Confirm account number"
134
138
  dataQa="Confirm account number"
139
+ isRequired={true}
135
140
  errorMessages={confirmAccountNumberErrors}
136
141
  field={fields.confirmAccountNumber}
137
142
  fieldActions={actions.fields.confirmAccountNumber}
@@ -142,6 +147,7 @@ const PaymentFormACH = ({
142
147
  {allowBankAccountType && (
143
148
  <FormSelect
144
149
  labelTextWhenNoError="Account type"
150
+ isRequired={true}
145
151
  dataQa="Account type"
146
152
  options={[
147
153
  { text: "Select account type", value: "" },
@@ -182,6 +188,7 @@ const PaymentFormACH = ({
182
188
  showCheckbox={false}
183
189
  description="View"
184
190
  terms={termsContent}
191
+ isRequired={true}
185
192
  />
186
193
  </Cover>
187
194
  )}
@@ -122,6 +122,7 @@ const PaymentFormCard = ({
122
122
  showErrors={showErrors}
123
123
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
124
124
  autocompleteValue="cc-name"
125
+ isRequired={true}
125
126
  />
126
127
  <FormInput
127
128
  labelTextWhenNoError="Credit card number"
@@ -134,6 +135,7 @@ const PaymentFormCard = ({
134
135
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
135
136
  isNum
136
137
  autocompleteValue="cc-number"
138
+ isRequired={true}
137
139
  />
138
140
  <FormInputRow
139
141
  breakpoint={isMobile ? "1000rem" : "21rem"}
@@ -151,6 +153,7 @@ const PaymentFormCard = ({
151
153
  isNum
152
154
  removeFromValue={/\//} // removes "/" from browser autofill
153
155
  autocompleteValue="cc-exp"
156
+ isRequired={true}
154
157
  />
155
158
  <FormInput
156
159
  labelTextWhenNoError="CVV"
@@ -167,6 +170,7 @@ const PaymentFormCard = ({
167
170
  }
168
171
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
169
172
  autocompleteValue="cc-csc"
173
+ isRequired={true}
170
174
  />
171
175
  </FormInputRow>
172
176
  {!hideZipCode && (
@@ -185,6 +189,7 @@ const PaymentFormCard = ({
185
189
  showErrors={showErrors}
186
190
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
187
191
  autocompleteValue="billing postal-code"
192
+ isRequired={true}
188
193
  />
189
194
  </Box>
190
195
  )}
@@ -206,6 +211,7 @@ const PaymentFormCard = ({
206
211
  showCheckbox={false}
207
212
  description="View"
208
213
  terms={termsContent}
214
+ isRequired={true}
209
215
  />
210
216
  </Cover>
211
217
  )}
@@ -177,6 +177,7 @@ const RadioSection = ({
177
177
  : () => toggleOpenSection(section.id)
178
178
  }
179
179
  tabIndex="-1"
180
+ required={section?.required}
180
181
  />
181
182
  </Box>
182
183
  )}
@@ -197,7 +198,7 @@ const RadioSection = ({
197
198
  <Cluster
198
199
  childGap="0.5rem"
199
200
  aria-label={section?.rightIconsLabel || null}
200
- role={section?.rightIconsRole || null}
201
+ role={section?.rightIconsRole || "group"}
201
202
  >
202
203
  {section.rightIcons.map(icon => (
203
204
  <RightIcon
@@ -49,9 +49,10 @@ const sections = [
49
49
  title: "New Card",
50
50
  content: <p>The form to add a credit card would go here.</p>,
51
51
  rightIconsLabel: cardIconsLabel,
52
- rightIcons: cardIcons
52
+ rightIcons: cardIcons,
53
+ required: true
53
54
  },
54
- { id: "bar", title: "Bar", content: <div>Content 1</div> },
55
+ { id: "bar", title: "Bar", content: <div>Content 1</div>, required: true },
55
56
  { id: "baz", title: "Baz", content: <div>Content 2</div> }
56
57
  ];
57
58
 
@@ -19,7 +19,8 @@ const RadioButton = ({
19
19
  ariaDescribedBy = "",
20
20
  themeValues,
21
21
  ariaLabelledBy = "",
22
- ariaLabel = null
22
+ ariaLabel = null,
23
+ required = false
23
24
  }) => {
24
25
  const buttonBorder = {
25
26
  onFocused: {
@@ -90,6 +91,8 @@ const RadioButton = ({
90
91
  type="radio"
91
92
  id={`radio-${name}`}
92
93
  disabled={disabled}
94
+ required={required}
95
+ aria-required={required}
93
96
  onClick={toggleRadio}
94
97
  aria-describedby={ariaDescribedBy}
95
98
  tabIndex="-1"
@@ -22,6 +22,7 @@ const TermsAndConditionsControlV1 = ({
22
22
  error={error}
23
23
  checked={isChecked}
24
24
  onChange={onCheck}
25
+ isRequired={true}
25
26
  />
26
27
  <Box padding="0 0 0 58px">
27
28
  <Stack>
@@ -57,6 +57,7 @@ const TermsAndConditionsControlV2 = ({
57
57
  onChange={onCheck}
58
58
  checkboxMargin={checkboxMargin}
59
59
  extraStyles={`align-self: flex-start;`}
60
+ isRequired={true}
60
61
  />
61
62
  )}
62
63
  <Stack childGap="0.25rem" fullHeight>