@thecb/components 12.0.0 → 12.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "12.0.0",
3
+ "version": "12.0.1",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -101,6 +101,7 @@ const Checkbox = forwardRef(
101
101
  themeValues,
102
102
  hidden = false,
103
103
  error = false,
104
+ isRequired = false,
104
105
  checkboxMargin = "0 16px 0 0",
105
106
  extraStyles,
106
107
  textExtraStyles,
@@ -130,6 +131,13 @@ const Checkbox = forwardRef(
130
131
  ref={ref}
131
132
  padding="0"
132
133
  tabIndex="0"
134
+ role="checkbox"
135
+ aria-checked={checked}
136
+ aria-required={isRequired || undefined}
137
+ aria-invalid={error}
138
+ aria-label={ariaLabel}
139
+ aria-labelledby={ariaLabelledById}
140
+ aria-describedby={error ? `${name}-error-message` : undefined}
133
141
  onFocus={() => setFocused(true)}
134
142
  onBlur={() => setFocused(false)}
135
143
  onKeyDown={e => handleClick(e, onChange)}
@@ -150,20 +158,17 @@ const Checkbox = forwardRef(
150
158
  id={`checkbox-${name}`}
151
159
  disabled={disabled}
152
160
  name={name}
153
- aria-label={ariaLabel}
154
- aria-labelledby={ariaLabelledById}
155
161
  checked={checked}
156
162
  onChange={onChange}
157
163
  tabIndex="-1"
158
- aria-invalid={error}
159
- aria-describedby={error ? `${name}-error-message` : ""}
164
+ required={isRequired}
165
+ aria-hidden="true"
160
166
  />
161
167
  <StyledCheckbox
162
- role="checkbox"
168
+ aria-hidden="true"
163
169
  error={error}
164
170
  disabled={disabled}
165
171
  checked={checked}
166
- aria-checked={checked}
167
172
  focused={focused}
168
173
  defaultStyles={themeValues.defaultStyles}
169
174
  checkedStyles={themeValues.checkedStyles}
@@ -224,6 +224,7 @@ const FormInput = ({
224
224
  (field.dirty && field.hasErrors) ||
225
225
  (field.hasErrors && showErrors)
226
226
  }
227
+ aria-required={isRequired}
227
228
  onChange={value => setValue(value)}
228
229
  onBlur={e => handleOnBlur(e.target.value)}
229
230
  type={type}
@@ -265,6 +266,7 @@ const FormInput = ({
265
266
  (field.dirty && field.hasErrors) ||
266
267
  (field.hasErrors && showErrors)
267
268
  }
269
+ aria-required={isRequired}
268
270
  onChange={e => setValue(e.target.value)}
269
271
  onBlur={e => handleOnBlur(e.target.value)}
270
272
  type={type === "password" && showPassword ? "text" : type}
@@ -65,6 +65,7 @@ const RegistrationForm = ({
65
65
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
66
66
  autocompleteValue="given-name"
67
67
  dataQa="First name"
68
+ isRequired
68
69
  />
69
70
  <FormInput
70
71
  labelTextWhenNoError="Last name"
@@ -75,6 +76,7 @@ const RegistrationForm = ({
75
76
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
76
77
  autocompleteValue="family-name"
77
78
  dataQa="Last name"
79
+ isRequired
78
80
  />
79
81
  <FormInput
80
82
  labelTextWhenNoError="Email address"
@@ -87,6 +89,7 @@ const RegistrationForm = ({
87
89
  isEmail
88
90
  autocompleteValue="email"
89
91
  dataQa="Email address"
92
+ isRequired
90
93
  />
91
94
  <FormInput
92
95
  labelTextWhenNoError="Password"
@@ -98,6 +101,7 @@ const RegistrationForm = ({
98
101
  type="password"
99
102
  autocompleteValue="new-password"
100
103
  dataQa="Password"
104
+ isRequired
101
105
  />
102
106
  <FormInput
103
107
  labelTextWhenNoError="Confirm password"
@@ -109,6 +113,7 @@ const RegistrationForm = ({
109
113
  type="password"
110
114
  autocompleteValue="new-password"
111
115
  dataQa="Confirm password"
116
+ isRequired
112
117
  />
113
118
  <Box padding={isMobile ? "0" : "0.5rem 0 0"}>
114
119
  <PasswordRequirements password={fields.password} isMobile={isMobile} />
@@ -29,7 +29,8 @@ const TermsAndConditionsControlV2 = ({
29
29
  containerBackground = ATHENS_GREY,
30
30
  checkboxMargin = "4px 8px 4px 4px",
31
31
  modalTitle = "Terms and Conditions",
32
- initialFocusSelector = ""
32
+ initialFocusSelector = "",
33
+ isRequired = false
33
34
  }) => {
34
35
  const [showTerms, toggleShowTerms] = useState(false);
35
36
  const standardBoxShadow = generateShadows().standard.base;
@@ -61,6 +62,7 @@ const TermsAndConditionsControlV2 = ({
61
62
  checkboxMargin={checkboxMargin}
62
63
  extraStyles={`align-self: flex-start;`}
63
64
  labelledById={TermsAndConditionsTitleDivId}
65
+ isRequired={isRequired}
64
66
  />
65
67
  )}
66
68
  <Stack childGap="0.25rem" fullHeight>