@thecb/components 9.0.0-beta.4 → 9.0.0-beta.6

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.0.0-beta.4",
3
+ "version": "9.0.0-beta.6",
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,7 @@ const Checkbox = ({
95
95
  checkboxMargin = "0 16px 0 0",
96
96
  extraStyles,
97
97
  textExtraStyles,
98
- dataQa = "Checkbox Label"
98
+ dataQa = null
99
99
  }) => {
100
100
  const [focused, setFocused] = useState(false);
101
101
 
@@ -130,6 +130,7 @@ const Checkbox = ({
130
130
  aria-describedby={error ? `${name}-error-message` : ""}
131
131
  />
132
132
  <StyledCheckbox
133
+ role="checkbox"
133
134
  error={error}
134
135
  disabled={disabled}
135
136
  checked={checked}
@@ -10,14 +10,14 @@ const CountryDropdown = ({
10
10
  fieldActions,
11
11
  showErrors,
12
12
  onChange,
13
- dataQa = "Country Dropdown"
13
+ dataQa = null
14
14
  }) => (
15
15
  <FormSelect
16
16
  options={options}
17
17
  field={field}
18
18
  fieldActions={fieldActions}
19
19
  labelTextWhenNoError={labelTextWhenNoError}
20
- dataQa={dataQa}
20
+ dataQa={dataQa || "CountryDropdown"}
21
21
  errorMessages={errorMessages}
22
22
  showErrors={showErrors}
23
23
  onChange={onChange}
@@ -4,12 +4,7 @@ import { fallbackValues } from "./DisplayBox.theme";
4
4
  import { themeComponent } from "../../../util/themeUtils";
5
5
  import { RED } from "../../../constants/colors";
6
6
 
7
- const DisplayBox = ({
8
- children,
9
- themeValues,
10
- showError,
11
- dataQa = "DisplayBox"
12
- }) => (
7
+ const DisplayBox = ({ children, themeValues, showError, dataQa = null }) => (
13
8
  <Box padding="0.5rem 0 1.5rem 0">
14
9
  <Box
15
10
  padding="1.5rem"
@@ -290,13 +290,15 @@ const Dropdown = ({
290
290
  as="input"
291
291
  aria-multiline="false"
292
292
  autoComplete={autocompleteValue}
293
- aria-controls={`${createIdFromString(ariaLabelledby)}_listbox`}
293
+ aria-controls={`${ariaLabelledby}_listbox`}
294
294
  aria-activedescendant="focused_option"
295
295
  aria-owns={`${ariaLabelledby}_listbox`}
296
296
  aria-haspopup="listbox"
297
297
  aria-labelledby={ariaLabelledby}
298
298
  aria-describedby={ariaDescribedby}
299
299
  aria-expanded={isOpen}
300
+ aria-required={options.required}
301
+ aria-invalid={ariaInvalid}
300
302
  background={isOpen ? themeValues.hoverColor : WHITE}
301
303
  borderRadius="2px"
302
304
  borderSize="1px"
@@ -307,6 +309,7 @@ const Dropdown = ({
307
309
  ? themeValues.selectedColor
308
310
  : GREY_CHATEAU
309
311
  }
312
+ dataQa={placeholder}
310
313
  extraStyles={
311
314
  disabled
312
315
  ? `${inputPlaceholderTextStyle}${inputDisabledStyle}`
@@ -326,6 +329,7 @@ const Dropdown = ({
326
329
  }}
327
330
  padding="12px"
328
331
  placeholder={getSelection()}
332
+ required={options.required}
329
333
  role="combobox"
330
334
  themeValues={themeValues}
331
335
  title={hasTitles ? getSelection() : null}
@@ -333,10 +337,6 @@ const Dropdown = ({
333
337
  tabIndex={0}
334
338
  value={inputValue}
335
339
  width="100%"
336
- dataQa={placeholder}
337
- required={options.required}
338
- aria-required={options.required}
339
- aria-invalid={ariaInvalid}
340
340
  />
341
341
  <IconWrapper open={isOpen} onClick={onClick}>
342
342
  <DropdownIcon />
@@ -384,7 +384,6 @@ const Dropdown = ({
384
384
  themeValues={themeValues}
385
385
  title={hasTitles ? choice.text : null}
386
386
  onFocus={() => setFocusedRef(optionRefs.current[i])}
387
- role="option"
388
387
  >
389
388
  <Text
390
389
  variant="p"
@@ -219,7 +219,7 @@ const FormInput = ({
219
219
  themeValues={themeValues}
220
220
  $customHeight={customHeight}
221
221
  $extraStyles={extraStyles}
222
- data-qa={dataQa || labelTextWhenNoError}
222
+ data-qa={dataQa}
223
223
  autoComplete={autocompleteValue}
224
224
  {...props}
225
225
  />
@@ -245,7 +245,7 @@ const FormInput = ({
245
245
  background={background}
246
246
  $customHeight={customHeight}
247
247
  $extraStyles={extraStyles}
248
- data-qa={dataQa || labelTextWhenNoError}
248
+ data-qa={dataQa}
249
249
  autoComplete={autocompleteValue}
250
250
  {...props}
251
251
  />
@@ -25,7 +25,7 @@ export interface FormInputProps {
25
25
  customHeight?: string;
26
26
  autocompleteValue?: string;
27
27
  removeFromValue?: RegExp;
28
- dataQa?: string;
28
+ dataQa?: string | null;
29
29
  }
30
30
 
31
31
  export const FormInput: React.FC<Expand<FormInputProps> &
@@ -21,9 +21,9 @@ const FormSelect = ({
21
21
  disabled,
22
22
  themeValues,
23
23
  hasTitles = false,
24
- autocompleteValue = "", // browser autofill value, like country-name or address-level1 for state
24
+ autocompleteValue = null, // browser autofill value, like country-name
25
25
  smoothScroll = true, // whether the browser should animate scroll to selected item on first open
26
- dataQa = "FormSelect"
26
+ dataQa = null
27
27
  }) => {
28
28
  const [open, setOpen] = useState(false);
29
29
  const dropdownRef = useRef(null);
@@ -42,7 +42,12 @@ const FormSelect = ({
42
42
  });
43
43
 
44
44
  return (
45
- <SelectContainer ref={dropdownRef} disabled={disabled} data-qa={dataQa}>
45
+ <SelectContainer
46
+ ref={dropdownRef}
47
+ disabled={disabled}
48
+ aria-disabled={disabled}
49
+ data-qa={dataQa}
50
+ >
46
51
  <Box padding="0" minWidth="100%">
47
52
  <Cluster justify="space-between" align="center">
48
53
  <Text
@@ -62,7 +67,7 @@ const FormSelect = ({
62
67
  </Cluster>
63
68
  </Box>
64
69
  <Dropdown
65
- ariaLabelledby={labelTextWhenNoError}
70
+ ariaLabelledby={createIdFromString(labelTextWhenNoError)}
66
71
  ariaDescribedBy={createIdFromString(
67
72
  labelTextWhenNoError,
68
73
  "error message"
@@ -22,7 +22,7 @@ export interface FormSelectProps {
22
22
  hasTitles?: boolean;
23
23
  autocompleteValue?: string;
24
24
  smoothScroll?: boolean;
25
- dataQa?: string;
25
+ dataQa?: string | null;
26
26
  }
27
27
 
28
28
  export const FormSelect: React.FC<Expand<FormSelectProps> &
@@ -10,8 +10,7 @@ const FormStateDropdown = ({
10
10
  fieldActions,
11
11
  showErrors,
12
12
  countryCode,
13
- autocompleteValue = "administrative-area",
14
- dataQa = "StateProvinceDropdown"
13
+ autocompleteValue = null
15
14
  }) => {
16
15
  const placeholder =
17
16
  countryCode === "US" ? placeHolderOptionUS : placeHolderOption;
@@ -24,9 +23,7 @@ const FormStateDropdown = ({
24
23
  labelTextWhenNoError={labelTextWhenNoError}
25
24
  errorMessages={errorMessages}
26
25
  showErrors={showErrors}
27
- aria-invalid={!!errorMessages?.length}
28
26
  autocompleteValue={autocompleteValue}
29
- dataQa={dataQa}
30
27
  />
31
28
  );
32
29
  };
@@ -17,7 +17,7 @@ const AccountAndRoutingModal = ({
17
17
  content,
18
18
  imageType,
19
19
  themeValues,
20
- dataQa = "AccountAndRoutingModal"
20
+ dataQa = null
21
21
  }) => (
22
22
  <Modal
23
23
  modalOpen={isOpen}
@@ -20,7 +20,8 @@ const AddressForm = ({
20
20
  handleSubmit = noop,
21
21
  showWalletCheckbox,
22
22
  saveToWallet,
23
- walletCheckboxMarked
23
+ walletCheckboxMarked,
24
+ dataQa = null
24
25
  }) => {
25
26
  if (clearOnDismount) {
26
27
  useEffect(() => () => actions.form.clear(), []);
@@ -46,7 +47,12 @@ const AddressForm = ({
46
47
  const isUS = fields.country.rawValue === "US";
47
48
 
48
49
  return (
49
- <FormContainer variant={variant} role="form" aria-label="Address">
50
+ <FormContainer
51
+ variant={variant}
52
+ role="form"
53
+ aria-label="Address"
54
+ dataQa={dataQa}
55
+ >
50
56
  <FormInputColumn>
51
57
  <CountryDropdown
52
58
  labelTextWhenNoError="Country"
@@ -5,7 +5,7 @@ export interface LinkCardProps {
5
5
  variant?: string; // "default" is only one
6
6
  title?: string; // title
7
7
  subtitle?: string; // beneath title
8
- themeValues?: any;
8
+ themeValues?: object;
9
9
  showLeft?: boolean;
10
10
  leftContent?: JSX.Element;
11
11
  showRight?: boolean;
@@ -10,12 +10,11 @@ const TermsAndConditionsControlV1 = ({
10
10
  html,
11
11
  terms,
12
12
  error = false,
13
- linkVariant,
14
- dataQa = "TermsAndConditionsControlV1"
13
+ linkVariant
15
14
  }) => {
16
15
  const [showTerms, toggleShowTerms] = useState(false);
17
16
  return (
18
- <DisplayBox dataQ={dataQa}>
17
+ <DisplayBox dataQa="TermsAndConditionsControlV1">
19
18
  <Stack>
20
19
  <Checkbox
21
20
  name="terms"
@@ -26,8 +26,7 @@ const TermsAndConditionsControlV2 = ({
26
26
  modalVariant = "default",
27
27
  containerBackground = ATHENS_GREY,
28
28
  checkboxMargin = "4px 8px 4px 4px",
29
- modalTitle = "Terms and Conditions",
30
- dataQa = "TermsAndConditionsControlV2"
29
+ modalTitle = "Terms and Conditions"
31
30
  }) => {
32
31
  const [showTerms, toggleShowTerms] = useState(false);
33
32
  const standardBoxShadow = generateShadows().standard.base;
@@ -46,7 +45,7 @@ const TermsAndConditionsControlV2 = ({
46
45
  background={displayInline ? "transparent" : containerBackground}
47
46
  boxShadow={displayInline ? "none" : standardBoxShadow}
48
47
  borderRadius={displayInline ? "0" : "4px"}
49
- dataQa={dataQa}
48
+ dataQa="TermsAndConditionsControlV2"
50
49
  >
51
50
  <Stack childGap="0">
52
51
  {html && <Box padding="0">{html}</Box>}