@thecb/components 9.3.0-beta.2 → 9.3.1-beta.0

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 (23) hide show
  1. package/dist/index.cjs.js +44 -103
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +44 -103
  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/checkbox/Checkbox.stories.js +2 -3
  8. package/src/components/atoms/country-dropdown/CountryDropdown.js +1 -3
  9. package/src/components/atoms/country-dropdown/CountryDropdown.stories.js +0 -1
  10. package/src/components/atoms/dropdown/Dropdown.js +3 -7
  11. package/src/components/atoms/form-layouts/FormInput.js +0 -4
  12. package/src/components/atoms/form-select/FormSelect.js +9 -22
  13. package/src/components/atoms/form-select/FormSelect.stories.js +2 -2
  14. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +1 -4
  15. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.stories.js +0 -1
  16. package/src/components/molecules/address-form/AddressForm.js +0 -6
  17. package/src/components/molecules/payment-form-ach/PaymentFormACH.js +0 -7
  18. package/src/components/molecules/payment-form-card/PaymentFormCard.js +0 -7
  19. package/src/components/molecules/radio-section/RadioSection.js +4 -4
  20. package/src/components/molecules/radio-section/RadioSection.stories.js +2 -3
  21. package/src/components/molecules/radio-section/radio-button/RadioButton.js +1 -4
  22. package/src/components/molecules/terms-and-conditions/TermsAndConditionsControlV1.js +0 -1
  23. package/src/components/molecules/terms-and-conditions/TermsAndConditionsControlV2.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "9.3.0-beta.2",
3
+ "version": "9.3.1-beta.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -95,8 +95,7 @@ const Checkbox = ({
95
95
  checkboxMargin = "0 16px 0 0",
96
96
  extraStyles,
97
97
  textExtraStyles,
98
- dataQa = null,
99
- isRequired = false
98
+ dataQa = null
100
99
  }) => {
101
100
  const [focused, setFocused] = useState(false);
102
101
 
@@ -143,7 +142,6 @@ const Checkbox = ({
143
142
  disabledStyles={themeValues.disabledStyles}
144
143
  disabledCheckedStyles={themeValues.disabledCheckedStyles}
145
144
  focusedStyles={themeValues.focusedStyles}
146
- aria-required={isRequired}
147
145
  >
148
146
  <CheckboxIcon
149
147
  viewBox="0 0 24 24"
@@ -13,13 +13,12 @@ const groupId = "props";
13
13
  export const checkbox = () => (
14
14
  <Checkbox
15
15
  variant={select(variantsLabel, variants, defaultValue, groupId)}
16
- title={text("title", "Checkbox Title", "props")}
17
- name={text("name", "Checkbox Name", "props")}
16
+ title={text("title", "Checkbox", "props")}
17
+ name={text("name", "Checkbox", "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")}
23
22
  />
24
23
  );
25
24
 
@@ -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
- isRequired={isRequired}
27
25
  />
28
26
  );
29
27
  export default CountryDropdown;
@@ -30,7 +30,6 @@ const CountryFormWrapper = ({ fields, actions }) => (
30
30
  options={options}
31
31
  field={fields.country}
32
32
  fieldActions={actions.fields.country}
33
- isRequired={true}
34
33
  />
35
34
  </Box>
36
35
  );
@@ -105,10 +105,8 @@ const Dropdown = ({
105
105
  ariaDescribedby,
106
106
  autocompleteValue, // browser autofill value, like country-name
107
107
  smoothScroll = true,
108
- ariaInvalid = false,
109
- isRequired = false
108
+ ariaInvalid = false
110
109
  }) => {
111
- const required = options.required || isRequired;
112
110
  const [inputValue, setInputValue] = useState("");
113
111
  const [optionsState, setOptionsState] = useState([]);
114
112
  const [filteredOptions, setFilteredOptions] = useState([]);
@@ -298,8 +296,7 @@ const Dropdown = ({
298
296
  aria-labelledby={ariaLabelledby}
299
297
  aria-describedby={ariaDescribedby}
300
298
  aria-expanded={isOpen}
301
- aria-required={required}
302
- required={required}
299
+ aria-required={options.required}
303
300
  aria-invalid={ariaInvalid}
304
301
  background={isOpen ? themeValues.hoverColor : WHITE}
305
302
  borderRadius="2px"
@@ -331,6 +328,7 @@ const Dropdown = ({
331
328
  }}
332
329
  padding="12px"
333
330
  placeholder={getSelection()}
331
+ required={options.required}
334
332
  role="combobox"
335
333
  themeValues={themeValues}
336
334
  title={hasTitles ? getSelection() : null}
@@ -338,7 +336,6 @@ const Dropdown = ({
338
336
  tabIndex={0}
339
337
  value={inputValue}
340
338
  width="100%"
341
- disabled={disabledValues.includes(inputValue)}
342
339
  />
343
340
  <IconWrapper open={isOpen} onClick={onClick}>
344
341
  <DropdownIcon />
@@ -353,7 +350,6 @@ const Dropdown = ({
353
350
  tabIndex={0}
354
351
  role="listbox"
355
352
  id={`${ariaLabelledby}_listbox`}
356
- required={required}
357
353
  >
358
354
  <Stack childGap="0" as="ul">
359
355
  {filteredOptions.map((choice, i) => {
@@ -116,10 +116,8 @@ const FormInput = ({
116
116
  extraStyles,
117
117
  removeFromValue, // regex of characters to remove before setting value
118
118
  dataQa = null,
119
- isRequired = false,
120
119
  ...props
121
120
  }) => {
122
- const required = isRequired || props?.required;
123
121
  const [showPassword, setShowPassword] = useState(false);
124
122
  const { isMobile } = useContext(ThemeContext);
125
123
  const setValue = value => {
@@ -223,7 +221,6 @@ const FormInput = ({
223
221
  $extraStyles={extraStyles}
224
222
  data-qa={dataQa || labelTextWhenNoError}
225
223
  autoComplete={autocompleteValue}
226
- required={required}
227
224
  {...props}
228
225
  />
229
226
  ) : (
@@ -250,7 +247,6 @@ const FormInput = ({
250
247
  $extraStyles={extraStyles}
251
248
  data-qa={dataQa || labelTextWhenNoError}
252
249
  autoComplete={autocompleteValue}
253
- required={required}
254
250
  {...props}
255
251
  />
256
252
  )}
@@ -1,4 +1,4 @@
1
- import React, { useState, useMemo, useRef, useEffect } from "react";
1
+ import React, { useState, useRef, useEffect } from "react";
2
2
  import Dropdown from "../dropdown";
3
3
  import Text from "../text";
4
4
  import { ERROR_COLOR } from "../../../constants/colors";
@@ -24,25 +24,10 @@ const FormSelect = ({
24
24
  autocompleteValue, // browser autofill value, like country-name
25
25
  smoothScroll = true, // whether the browser should animate scroll to selected item on first open
26
26
  dataQa = null,
27
- widthFitOptions = false,
28
- isRequired = false
27
+ widthFitOptions = false
29
28
  }) => {
30
29
  const [open, setOpen] = useState(false);
31
30
  const dropdownRef = useRef(null);
32
- const required = options?.required || isRequired;
33
-
34
- const labelId = useMemo(
35
- () => labelTextWhenNoError => createIdFromString(labelTextWhenNoError),
36
- [labelTextWhenNoError]
37
- );
38
-
39
- const descriptionId = useMemo(
40
- () => (field, labelTextWhenNoError) =>
41
- field.hasErrors && field.dirty
42
- ? labelId(labelTextWhenNoError) + "error-message"
43
- : "",
44
- [field, labelTextWhenNoError]
45
- );
46
31
 
47
32
  const handleClickAway = event => {
48
33
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
@@ -60,8 +45,8 @@ const FormSelect = ({
60
45
  return (
61
46
  <SelectContainer
62
47
  ref={dropdownRef}
63
- aria-role="group"
64
48
  disabled={disabled}
49
+ aria-disabled={disabled}
65
50
  data-qa={dataQa}
66
51
  >
67
52
  <Box padding="0" minWidth="100%">
@@ -76,15 +61,18 @@ const FormSelect = ({
76
61
  &::first-letter {
77
62
  text-transform: uppercase;
78
63
  }`}
79
- id={labelId(labelTextWhenNoError)}
64
+ id={createIdFromString(labelTextWhenNoError)}
80
65
  >
81
66
  {labelTextWhenNoError}
82
67
  </Text>
83
68
  </Cluster>
84
69
  </Box>
85
70
  <Dropdown
86
- ariaLabelledby={labelId(labelTextWhenNoError)}
87
- ariaDescribedby={descriptionId(field, labelTextWhenNoError)}
71
+ ariaLabelledby={createIdFromString(labelTextWhenNoError)}
72
+ ariaDescribedby={createIdFromString(
73
+ labelTextWhenNoError,
74
+ "error message"
75
+ )}
88
76
  maxHeight={dropdownMaxHeight}
89
77
  widthFitOptions={widthFitOptions}
90
78
  hasTitles={hasTitles}
@@ -106,7 +94,6 @@ const FormSelect = ({
106
94
  disabled={disabled}
107
95
  autocompleteValue={autocompleteValue}
108
96
  smoothScroll={smoothScroll}
109
- isRequired={required}
110
97
  />
111
98
  <Stack direction="row" justify="space-between">
112
99
  <Text
@@ -12,7 +12,7 @@ const { mapStateToProps, mapDispatchToProps, reducer } = createFormState({
12
12
  }
13
13
  });
14
14
  const errorMessages = {
15
- [required.error]: "This field is required."
15
+ [required.error]: "thing is required"
16
16
  };
17
17
  const options = [
18
18
  { value: "", text: "choose name" },
@@ -34,7 +34,7 @@ const story = page({
34
34
  const FormWrapper = props => (
35
35
  <FormSelect
36
36
  autocompleteValue={props.autocompleteValue}
37
- labelTextWhenNoError="Form Select Label"
37
+ labelTextWhenNoError="Form Select"
38
38
  errorMessages={errorMessages}
39
39
  options={options}
40
40
  field={props.fields.thing}
@@ -9,13 +9,11 @@ const FormStateDropdown = ({
9
9
  field,
10
10
  fieldActions,
11
11
  showErrors,
12
- countryCode,
13
- isRequired = false
12
+ countryCode
14
13
  }) => {
15
14
  const placeholder =
16
15
  countryCode === "US" ? placeHolderOptionUS : placeHolderOption;
17
16
  const options = [placeholder, ...getOptions(countryCode)];
18
-
19
17
  return (
20
18
  <FormSelect
21
19
  options={options}
@@ -25,7 +23,6 @@ const FormStateDropdown = ({
25
23
  errorMessages={errorMessages}
26
24
  showErrors={showErrors}
27
25
  autocompleteValue="address-level1"
28
- isRequired={isRequired}
29
26
  />
30
27
  );
31
28
  };
@@ -39,7 +39,6 @@ const FormWrapper = ({
39
39
  countryCode={countryCode}
40
40
  labelTextWhenNoError={labelTextWhenNoError}
41
41
  showErrors={showErrors}
42
- isRequired={true}
43
42
  />
44
43
  );
45
44
 
@@ -58,7 +58,6 @@ const AddressForm = ({
58
58
  labelTextWhenNoError="Country"
59
59
  errorMessages={countryErrorMessages}
60
60
  field={fields.country}
61
- isRequired={true}
62
61
  onChange={value => {
63
62
  actions.fields.country.set(value);
64
63
  // temporary measure to not dirty fields until
@@ -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
- isRequired={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
- isRequired={false}
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
- isRequired={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
- isRequired={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
- isRequired={true}
131
125
  />
132
126
  {showWalletCheckbox && (
133
127
  <Checkbox
@@ -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
@@ -136,7 +132,6 @@ const PaymentFormACH = ({
136
132
  <FormInput
137
133
  labelTextWhenNoError="Confirm account number"
138
134
  dataQa="Confirm account number"
139
- isRequired={true}
140
135
  errorMessages={confirmAccountNumberErrors}
141
136
  field={fields.confirmAccountNumber}
142
137
  fieldActions={actions.fields.confirmAccountNumber}
@@ -147,7 +142,6 @@ const PaymentFormACH = ({
147
142
  {allowBankAccountType && (
148
143
  <FormSelect
149
144
  labelTextWhenNoError="Account type"
150
- isRequired={true}
151
145
  dataQa="Account type"
152
146
  options={[
153
147
  { text: "Select account type", value: "" },
@@ -188,7 +182,6 @@ const PaymentFormACH = ({
188
182
  showCheckbox={false}
189
183
  description="View"
190
184
  terms={termsContent}
191
- isRequired={true}
192
185
  />
193
186
  </Cover>
194
187
  )}
@@ -98,7 +98,6 @@ const PaymentFormCard = ({
98
98
  {!hideZipCode && (
99
99
  <CountryDropdown
100
100
  labelTextWhenNoError="Country"
101
- isRequired={true}
102
101
  errorMessages={countryErrorMessages}
103
102
  field={fields.country}
104
103
  onChange={value => {
@@ -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
- isRequired={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
- isRequired={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
- isRequired={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
- isRequired={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
- isRequired={true}
193
187
  />
194
188
  </Box>
195
189
  )}
@@ -211,7 +205,6 @@ const PaymentFormCard = ({
211
205
  showCheckbox={false}
212
206
  description="View"
213
207
  terms={termsContent}
214
- isRequired={true}
215
208
  />
216
209
  </Cover>
217
210
  )}
@@ -47,7 +47,8 @@ const RadioSection = ({
47
47
  initiallyOpen = true,
48
48
  openHeight = "auto",
49
49
  containerStyles = "",
50
- ariaDescribedBy
50
+ ariaDescribedBy,
51
+ ariaLabel = "Please select an option."
51
52
  }) => {
52
53
  const handleKeyDown = (id, e) => {
53
54
  if (e?.keyCode === 13 || e?.keyCode === 32) {
@@ -105,7 +106,7 @@ const RadioSection = ({
105
106
  borderRadius="4px"
106
107
  extraStyles={containerStyles}
107
108
  >
108
- <Stack childGap="0" role="radiogroup">
109
+ <Stack childGap="0" role="radiogroup" aria-label={ariaLabel}>
109
110
  {sections
110
111
  .filter(section => !section.hidden)
111
112
  .map(section => (
@@ -177,7 +178,6 @@ const RadioSection = ({
177
178
  : () => toggleOpenSection(section.id)
178
179
  }
179
180
  tabIndex="-1"
180
- required={section?.required}
181
181
  />
182
182
  </Box>
183
183
  )}
@@ -198,7 +198,7 @@ const RadioSection = ({
198
198
  <Cluster
199
199
  childGap="0.5rem"
200
200
  aria-label={section?.rightIconsLabel || null}
201
- role={section?.rightIconsRole || "group"}
201
+ role={section?.rightIconsRole || null}
202
202
  >
203
203
  {section.rightIcons.map(icon => (
204
204
  <RightIcon
@@ -49,10 +49,9 @@ 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,
53
- required: true
52
+ rightIcons: cardIcons
54
53
  },
55
- { id: "bar", title: "Bar", content: <div>Content 1</div>, required: true },
54
+ { id: "bar", title: "Bar", content: <div>Content 1</div> },
56
55
  { id: "baz", title: "Baz", content: <div>Content 2</div> }
57
56
  ];
58
57
 
@@ -19,8 +19,7 @@ const RadioButton = ({
19
19
  ariaDescribedBy = "",
20
20
  themeValues,
21
21
  ariaLabelledBy = "",
22
- ariaLabel = null,
23
- required = false
22
+ ariaLabel = null
24
23
  }) => {
25
24
  const buttonBorder = {
26
25
  onFocused: {
@@ -91,8 +90,6 @@ const RadioButton = ({
91
90
  type="radio"
92
91
  id={`radio-${name}`}
93
92
  disabled={disabled}
94
- required={required}
95
- aria-required={required}
96
93
  onClick={toggleRadio}
97
94
  aria-describedby={ariaDescribedBy}
98
95
  tabIndex="-1"
@@ -22,7 +22,6 @@ const TermsAndConditionsControlV1 = ({
22
22
  error={error}
23
23
  checked={isChecked}
24
24
  onChange={onCheck}
25
- isRequired={true}
26
25
  />
27
26
  <Box padding="0 0 0 58px">
28
27
  <Stack>
@@ -57,7 +57,6 @@ const TermsAndConditionsControlV2 = ({
57
57
  onChange={onCheck}
58
58
  checkboxMargin={checkboxMargin}
59
59
  extraStyles={`align-self: flex-start;`}
60
- isRequired={true}
61
60
  />
62
61
  )}
63
62
  <Stack childGap="0.25rem" fullHeight>