@thecb/components 9.2.10-beta.10 → 9.2.10-beta.11

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.2.10-beta.10",
3
+ "version": "9.2.10-beta.11",
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
+ checkboxAriaLabel = ""
99
100
  }) => {
100
101
  const [focused, setFocused] = useState(false);
101
102
 
@@ -105,6 +106,10 @@ const Checkbox = ({
105
106
  }
106
107
  };
107
108
 
109
+ const checkboxProps = {
110
+ ...(checkboxAriaLabel ? { "aria-label": checkboxAriaLabel } : {})
111
+ };
112
+
108
113
  return (
109
114
  <Box
110
115
  padding="0"
@@ -116,12 +121,13 @@ const Checkbox = ({
116
121
  background={themeValues.backgroundColor}
117
122
  extraStyles={`outline: none; ${extraStyles}; margin: ${checkboxMargin};`}
118
123
  >
119
- <CheckboxLabelContainer data-qa={dataQa} id={`${name}_label_container`}>
124
+ <CheckboxLabelContainer data-qa={dataQa}>
120
125
  <CheckboxContainer data-qa="Checkbox">
121
126
  <HiddenCheckbox
122
127
  id={`checkbox-${name}`}
123
128
  disabled={disabled}
124
129
  name={name}
130
+ aria-label={checkboxAriaLabel || `${title} checkbox`}
125
131
  checked={checked}
126
132
  onChange={onChange}
127
133
  tabIndex="-1"
@@ -130,8 +136,11 @@ const Checkbox = ({
130
136
  />
131
137
  <StyledCheckbox
132
138
  role="checkbox"
139
+ name={name}
133
140
  error={error}
141
+ aria-invalid={error}
134
142
  disabled={disabled}
143
+ aria-disabled={disabled}
135
144
  checked={checked}
136
145
  aria-checked={checked}
137
146
  focused={focused}
@@ -141,9 +150,7 @@ const Checkbox = ({
141
150
  disabledStyles={themeValues.disabledStyles}
142
151
  disabledCheckedStyles={themeValues.disabledCheckedStyles}
143
152
  focusedStyles={themeValues.focusedStyles}
144
- aria-labelledby={
145
- title ? `${name}_title_id` : `${name}_label_container`
146
- }
153
+ {...checkboxProps}
147
154
  >
148
155
  <CheckboxIcon
149
156
  viewBox="0 0 24 24"
@@ -160,7 +167,6 @@ const Checkbox = ({
160
167
  variant="p"
161
168
  weight={themeValues.textFontWeight}
162
169
  color={themeValues.textColor}
163
- id={`${name}_title_id`}
164
170
  extraStyles={
165
171
  textExtraStyles
166
172
  ? `${textExtraStyles} ${disabled &&
@@ -19,6 +19,11 @@ export const checkbox = () => (
19
19
  error={boolean("error", false, "props")}
20
20
  disabled={boolean("disabled", false, "props")}
21
21
  focused={boolean("focused", false, "props")}
22
+ checkboxAriaLabel={text(
23
+ "checkboxAriaLabel",
24
+ "Checkbox Label Prop",
25
+ groupId
26
+ )}
22
27
  />
23
28
  );
24
29
 
@@ -27,11 +27,11 @@ const Terms = () => (
27
27
  export const termsAndConditions = () => (
28
28
  <TermsAndConditions
29
29
  onCheck={noop}
30
- title="Agree to the terms and conditions"
31
30
  isChecked={boolean("isChecked", false, groupId)}
32
31
  terms={<Terms />}
33
32
  error={boolean("error", false, groupId)}
34
33
  initialFocusSelector={text("initialFocusSelector", "#focus-me", groupId)}
34
+ checkboxAriaLabel="I agree to the Terms and Conditions"
35
35
  />
36
36
  );
37
37
 
@@ -12,9 +12,7 @@ const TermsAndConditionsControlV1 = ({
12
12
  error = false,
13
13
  linkVariant,
14
14
  initialFocusSelector = "",
15
- id = "terms-and-conditions",
16
- screenReaderCheckboxLabel = "",
17
- ariaLabelledBy = ""
15
+ checkboxAriaLabel = ""
18
16
  }) => {
19
17
  const [showTerms, toggleShowTerms] = useState(false);
20
18
  return (
@@ -26,23 +24,11 @@ const TermsAndConditionsControlV1 = ({
26
24
  error={error}
27
25
  checked={isChecked}
28
26
  onChange={onCheck}
29
- aria-labelledby={
30
- ariaLabelledBy ||
31
- (screenReaderCheckboxLabel
32
- ? `${id}_sr_only_label`
33
- : `${id}_html_label`)
34
- }
27
+ aria-label={checkboxAriaLabel}
35
28
  />
36
29
  <Box padding="0 0 0 58px">
37
- {screenReaderCheckboxLabel && (
38
- <span className="sr-only-text" id={`${id}_sr_only_label`}>
39
- {screenReaderCheckboxLabel}
40
- </span>
41
- )}
42
30
  <Stack>
43
- <Box padding="0" id={`${id}_html_label`}>
44
- {html}
45
- </Box>
31
+ <Box padding="0">{html}</Box>
46
32
  {terms && (
47
33
  <TermsAndConditionsModal
48
34
  link="Learn More"
@@ -1,4 +1,4 @@
1
- import React, { Fragment, useState } from "react";
1
+ import React, { useState } from "react";
2
2
  import Checkbox from "../../atoms/checkbox";
3
3
  import { Box, Stack, Cluster } from "../../atoms/layouts";
4
4
  import Text from "../../atoms/text";
@@ -28,8 +28,7 @@ const TermsAndConditionsControlV2 = ({
28
28
  checkboxMargin = "4px 8px 4px 4px",
29
29
  modalTitle = "Terms and Conditions",
30
30
  initialFocusSelector = "",
31
- screenReaderCheckboxLabel = "",
32
- ariaLabelledBy = ""
31
+ checkboxAriaLabel = ""
33
32
  }) => {
34
33
  const [showTerms, toggleShowTerms] = useState(false);
35
34
  const standardBoxShadow = generateShadows().standard.base;
@@ -50,34 +49,18 @@ const TermsAndConditionsControlV2 = ({
50
49
  borderRadius={displayInline ? "0" : "4px"}
51
50
  >
52
51
  <Stack childGap="0">
53
- {html && (
54
- <Box padding="0" id={`${id}_html_label`}>
55
- {html}
56
- </Box>
57
- )}
52
+ {html && <Box padding="0">{html}</Box>}
58
53
  <Cluster justify="flex-start" align="center" nowrap>
59
54
  {showCheckbox && (
60
- <Fragment>
61
- <Checkbox
62
- name={id}
63
- error={hasError}
64
- checked={isChecked}
65
- onChange={onCheck}
66
- checkboxMargin={checkboxMargin}
67
- extraStyles={`align-self: flex-start;`}
68
- aria-labelledby={
69
- ariaLabelledBy ||
70
- (screenReaderCheckboxLabel
71
- ? `${id}_sr_only_label`
72
- : `${id}_html_label`)
73
- }
74
- />
75
- {screenReaderCheckboxLabel && (
76
- <span className="sr-only-text" id={`${id}_sr_only_label`}>
77
- {screenReaderCheckboxLabel}
78
- </span>
79
- )}
80
- </Fragment>
55
+ <Checkbox
56
+ name={id}
57
+ error={hasError}
58
+ checked={isChecked}
59
+ onChange={onCheck}
60
+ checkboxMargin={checkboxMargin}
61
+ extraStyles={`align-self: flex-start;`}
62
+ aria-label={checkboxAriaLabel}
63
+ />
81
64
  )}
82
65
  <Stack childGap="0.25rem" fullHeight>
83
66
  <Cluster