@thecb/components 9.2.1-beta.0 → 9.2.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 +200 -212
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +200 -212
  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 -3
  12. package/src/components/atoms/form-select/FormSelect.js +25 -36
  13. package/src/components/atoms/form-select/FormSelect.stories.js +2 -2
  14. package/src/components/atoms/radio-button-with-label/RadioButtonWithLabel.js +6 -9
  15. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +1 -4
  16. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.stories.js +0 -1
  17. package/src/components/molecules/address-form/AddressForm.js +0 -6
  18. package/src/components/molecules/payment-form-ach/PaymentFormACH.js +0 -6
  19. package/src/components/molecules/payment-form-card/PaymentFormCard.js +0 -6
  20. package/src/components/molecules/radio-group/RadioGroup.js +1 -1
  21. package/src/components/molecules/radio-section/RadioSection.js +0 -1
  22. package/src/components/molecules/radio-section/RadioSection.stories.js +2 -3
  23. package/src/components/molecules/radio-section/radio-button/RadioButton.js +1 -4
  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.2.1-beta.0",
3
+ "version": "9.2.1",
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
  );
@@ -133,10 +133,8 @@ const Dropdown = ({
133
133
  ariaDescribedby,
134
134
  autocompleteValue, // browser autofill value, like country-name
135
135
  smoothScroll = true,
136
- ariaInvalid = false,
137
- isRequired = false
136
+ ariaInvalid = false
138
137
  }) => {
139
- const required = options.required || isRequired;
140
138
  const [inputValue, setInputValue] = useState("");
141
139
  const [optionsState, setOptionsState] = useState([]);
142
140
  const [filteredOptions, setFilteredOptions] = useState([]);
@@ -326,7 +324,7 @@ const Dropdown = ({
326
324
  aria-labelledby={ariaLabelledby}
327
325
  aria-describedby={ariaDescribedby}
328
326
  aria-expanded={isOpen}
329
- aria-required={required}
327
+ aria-required={options.required}
330
328
  aria-invalid={ariaInvalid}
331
329
  background={isOpen ? themeValues.hoverColor : WHITE}
332
330
  borderRadius="2px"
@@ -358,6 +356,7 @@ const Dropdown = ({
358
356
  }}
359
357
  padding="12px"
360
358
  placeholder={getSelection()}
359
+ required={options.required}
361
360
  role="combobox"
362
361
  themeValues={themeValues}
363
362
  title={hasTitles ? getSelection() : null}
@@ -365,8 +364,6 @@ const Dropdown = ({
365
364
  tabIndex={0}
366
365
  value={inputValue}
367
366
  width="100%"
368
- /* Non-semantic elements need the aria-* version of the attribute */
369
- aria-disabled={disabledValues.includes(inputValue)}
370
367
  />
371
368
  <IconWrapper open={isOpen} onClick={onClick}>
372
369
  <DropdownIcon />
@@ -381,7 +378,6 @@ const Dropdown = ({
381
378
  tabIndex={0}
382
379
  role="listbox"
383
380
  id={`${ariaLabelledby}_listbox`}
384
- required={required}
385
381
  >
386
382
  <Stack childGap="0" as="ul">
387
383
  {filteredOptions.map((choice, i) => {
@@ -116,7 +116,6 @@ 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
121
  const [showPassword, setShowPassword] = useState(false);
@@ -222,7 +221,6 @@ const FormInput = ({
222
221
  $extraStyles={extraStyles}
223
222
  data-qa={dataQa || labelTextWhenNoError}
224
223
  autoComplete={autocompleteValue}
225
- required={isRequired}
226
224
  {...props}
227
225
  />
228
226
  ) : (
@@ -249,7 +247,6 @@ const FormInput = ({
249
247
  $extraStyles={extraStyles}
250
248
  data-qa={dataQa || labelTextWhenNoError}
251
249
  autoComplete={autocompleteValue}
252
- required={isRequired}
253
250
  {...props}
254
251
  />
255
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,29 +94,30 @@ 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
- <Text
113
- color={ERROR_COLOR}
114
- variant="pXS"
115
- weight={themeValues.fontWeight}
116
- extraStyles={`
99
+ {(field.hasErrors && field.dirty) || (field.hasErrors && showErrors) ? (
100
+ <Text
101
+ color={ERROR_COLOR}
102
+ variant="pXS"
103
+ weight={themeValues.fontWeight}
104
+ extraStyles={`
117
105
  word-break: break-word;
118
106
  font-family: Public Sans;
119
107
  &::first-letter {
120
108
  text-transform: uppercase;
121
109
  }
122
110
  `}
123
- id={createIdFromString(labelTextWhenNoError, "error message")}
124
- aria-live="polite"
125
- aria-atomic={true}
126
- data-qa={createIdFromString(labelTextWhenNoError, "error message")}
127
- >
128
- {(field.hasErrors && field.dirty) || (field.hasErrors && showErrors)
129
- ? errorMessages[field.errors[0]]
130
- : ""}
131
- </Text>
111
+ id={createIdFromString(labelTextWhenNoError, "error message")}
112
+ aria-live="polite"
113
+ aria-atomic={true}
114
+ data-qa={createIdFromString(labelTextWhenNoError, "error message")}
115
+ >
116
+ {errorMessages[field.errors[0]]}
117
+ </Text>
118
+ ) : (
119
+ <Text extraStyles={`height: ${themeValues.lineHeight};`} />
120
+ )}
132
121
  </Stack>
133
122
  </SelectContainer>
134
123
  );
@@ -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}
@@ -18,7 +18,7 @@ const Circle = styled.div`
18
18
  flex-shrink: 0;
19
19
  margin-right: 8px;
20
20
  width: 1.5rem;
21
- height: 1.5rem;
21
+ height 1.5rem;
22
22
  border: ${({ inactiveBorderColor }) => `1px solid ${inactiveBorderColor}`};
23
23
  border-radius: 50%;
24
24
  box-sizing: border-box;
@@ -30,24 +30,21 @@ const Circle = styled.div`
30
30
  display: block;
31
31
  background: ${({ activeColor }) => activeColor};
32
32
  border-radius: 50%;
33
- transform: scale(0);
34
- }
33
+ transform: scale(0);
34
+ }
35
35
  `;
36
36
 
37
37
  const InputAndLabelContainer = styled(Cluster)`
38
38
  overflow: visible;
39
-
40
39
  ${HiddenRadioInput}:checked + label ${Circle}:after {
41
40
  transform: scale(0.85);
42
41
  transition: transform 0.15s;
43
42
  }
44
-
45
43
  ${HiddenRadioInput}:checked + label ${Circle} {
46
- border: ${({ activeColor }) => "1px solid " + activeColor};
44
+ border: ${({ activeColor }) => `1px solid ${activeColor};`}
47
45
  }
48
-
49
- ${HiddenRadioInput}:focus + label ${Circle} {
50
- box-shadow: ${({ activeColor }) => "0px 0px 2px 1px " + activeColor};
46
+ ${HiddenRadioInput}:focus + label ${Circle} { {
47
+ box-shadow: ${({ activeColor }) => `0px 0px 2px 1px ${activeColor};`}
51
48
  }
52
49
  `;
53
50
 
@@ -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: "" },
@@ -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,10 +121,8 @@ 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
- isRequired={true}
129
126
  labelTextWhenNoError="Credit card number"
130
127
  dataQa="Credit card number"
131
128
  errorMessages={creditCardNumberErrors}
@@ -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
  )}
@@ -7,7 +7,7 @@ import { noop } from "../../../util/general";
7
7
 
8
8
  const DefaultHeading = styled.div`
9
9
  font-size: 0.875rem;
10
- color: ${colors.CHARADE_GREY};
10
+ color: ${colors.CHARADE_GREY}
11
11
  margin: 0;
12
12
  padding: 8px 0px;
13
13
  `;
@@ -177,7 +177,6 @@ const RadioSection = ({
177
177
  : () => toggleOpenSection(section.id)
178
178
  }
179
179
  tabIndex="-1"
180
- required={section?.required}
181
180
  />
182
181
  </Box>
183
182
  )}
@@ -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"