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

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.1",
3
+ "version": "9.2.10-beta.10",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -33,7 +33,7 @@ const CheckboxIcon = styled.svg`
33
33
  const HiddenCheckbox = styled.input.attrs({ type: "checkbox" })`
34
34
  border: 0;
35
35
  clip: rect(0 0 0 0);
36
- clippath: inset(50%);
36
+ clip-path: inset(50%);
37
37
  height: 1px;
38
38
  margin: -1px;
39
39
  overflow: hidden;
@@ -116,13 +116,12 @@ const Checkbox = ({
116
116
  background={themeValues.backgroundColor}
117
117
  extraStyles={`outline: none; ${extraStyles}; margin: ${checkboxMargin};`}
118
118
  >
119
- <CheckboxLabelContainer data-qa={dataQa}>
119
+ <CheckboxLabelContainer data-qa={dataQa} id={`${name}_label_container`}>
120
120
  <CheckboxContainer data-qa="Checkbox">
121
121
  <HiddenCheckbox
122
122
  id={`checkbox-${name}`}
123
123
  disabled={disabled}
124
124
  name={name}
125
- aria-label={name}
126
125
  checked={checked}
127
126
  onChange={onChange}
128
127
  tabIndex="-1"
@@ -142,6 +141,9 @@ const Checkbox = ({
142
141
  disabledStyles={themeValues.disabledStyles}
143
142
  disabledCheckedStyles={themeValues.disabledCheckedStyles}
144
143
  focusedStyles={themeValues.focusedStyles}
144
+ aria-labelledby={
145
+ title ? `${name}_title_id` : `${name}_label_container`
146
+ }
145
147
  >
146
148
  <CheckboxIcon
147
149
  viewBox="0 0 24 24"
@@ -158,6 +160,7 @@ const Checkbox = ({
158
160
  variant="p"
159
161
  weight={themeValues.textFontWeight}
160
162
  color={themeValues.textColor}
163
+ id={`${name}_title_id`}
161
164
  extraStyles={
162
165
  textExtraStyles
163
166
  ? `${textExtraStyles} ${disabled &&
@@ -50,6 +50,7 @@ const AccountAndRoutingModal = ({
50
50
  toggleAccepted(true);
51
51
  toggleOpen(false);
52
52
  }}
53
+ initialFocusSelector={"[name='Close']"}
53
54
  >
54
55
  <Text
55
56
  variant="pS"
@@ -46,8 +46,7 @@ const Modal = ({
46
46
  buttonExtraStyles,
47
47
  children,
48
48
  dataQa = null,
49
- initialFocusSelector = "",
50
- modalName = ""
49
+ initialFocusSelector = ""
51
50
  }) => {
52
51
  const { isMobile } = useContext(ThemeContext);
53
52
  const modalContainerRef = useRef(null);
@@ -75,8 +74,8 @@ const Modal = ({
75
74
  }}
76
75
  underlayClickExits={underlayClickExits}
77
76
  aria-modal={true}
78
- aria-name={!!modalName.length ? modalName : modalHeaderText}
79
77
  initialFocus={initialFocusSelector}
78
+ focusDialog={!initialFocusSelector} // Focus the dialogue box itself if no selector for initial focus was provided
80
79
  >
81
80
  <Box
82
81
  padding="0"
@@ -188,6 +188,7 @@ const PaymentFormACH = ({
188
188
  showCheckbox={false}
189
189
  description="View"
190
190
  terms={termsContent}
191
+ initialFocusSelector={".modal-close-button"}
191
192
  />
192
193
  </Cover>
193
194
  )}
@@ -210,6 +210,7 @@ const PaymentFormCard = ({
210
210
  showCheckbox={false}
211
211
  description="View"
212
212
  terms={termsContent}
213
+ initialFocusSelector={".modal-close-button"}
213
214
  />
214
215
  </Cover>
215
216
  )}
@@ -8,12 +8,7 @@ const TermsAndConditions = ({ version = "v1", ...rest }) => {
8
8
  ? TermsAndConditionsControlV1
9
9
  : TermsAndConditionsControlV2;
10
10
 
11
- return (
12
- <TermsAndConditionsControl
13
- initialFocusSelector="[role='button']:not(.modal-trigger)"
14
- {...rest}
15
- />
16
- );
11
+ return <TermsAndConditionsControl {...rest} />;
17
12
  };
18
13
 
19
14
  export default TermsAndConditions;
@@ -9,19 +9,29 @@ const groupId = "props";
9
9
 
10
10
  const Terms = () => (
11
11
  <p>
12
- Terms and <a href="#">conditions</a> modal content.
12
+ Modal Content: Elit voluptate cupidatat in pariatur anim in excepteur non.{" "}
13
+ <a href="#modal-bottom" id="focus-me">
14
+ Laboris elit laboris labore pariatur incididunt
15
+ </a>{" "}
16
+ proident occaecat laboris sit elit. Dolor irure enim adipisicing irure
17
+ consectetur dolor enim eiusmod elit eiusmod ut. Pariatur ut quis et pariatur
18
+ nulla nostrud sit esse. Veniam est occaecat cupidatat est nulla dolor minim
19
+ nostrud anim ea voluptate. modal content. Elit voluptate cupidatat in
20
+ pariatur anim in excepteur non. Laboris elit laboris labore pariatur
21
+ incididunt proident occaecat laboris sit elit. Dolor irure enim adipisicing
22
+ irure consectetur dolor enim eiusmod elit eiusmod ut. Pariatur ut quis et
23
+ pariatur nulla nostrud sit esse.
13
24
  </p>
14
25
  );
15
26
 
16
27
  export const termsAndConditions = () => (
17
28
  <TermsAndConditions
18
29
  onCheck={noop}
30
+ title="Agree to the terms and conditions"
19
31
  isChecked={boolean("isChecked", false, groupId)}
20
- html={text("html", "Terms and Conditions html", groupId)}
21
- modalName="Terms and Conditions Modal"
22
32
  terms={<Terms />}
23
33
  error={boolean("error", false, groupId)}
24
- initialFocusSelector="[role='button']:not(.modal-trigger)"
34
+ initialFocusSelector={text("initialFocusSelector", "#focus-me", groupId)}
25
35
  />
26
36
  );
27
37
 
@@ -11,7 +11,10 @@ const TermsAndConditionsControlV1 = ({
11
11
  terms,
12
12
  error = false,
13
13
  linkVariant,
14
- initialFocusSelector = ""
14
+ initialFocusSelector = "",
15
+ id = "terms-and-conditions",
16
+ screenReaderCheckboxLabel = "",
17
+ ariaLabelledBy = ""
15
18
  }) => {
16
19
  const [showTerms, toggleShowTerms] = useState(false);
17
20
  return (
@@ -23,10 +26,23 @@ const TermsAndConditionsControlV1 = ({
23
26
  error={error}
24
27
  checked={isChecked}
25
28
  onChange={onCheck}
29
+ aria-labelledby={
30
+ ariaLabelledBy ||
31
+ (screenReaderCheckboxLabel
32
+ ? `${id}_sr_only_label`
33
+ : `${id}_html_label`)
34
+ }
26
35
  />
27
36
  <Box padding="0 0 0 58px">
37
+ {screenReaderCheckboxLabel && (
38
+ <span className="sr-only-text" id={`${id}_sr_only_label`}>
39
+ {screenReaderCheckboxLabel}
40
+ </span>
41
+ )}
28
42
  <Stack>
29
- <Box padding="0">{html}</Box>
43
+ <Box padding="0" id={`${id}_html_label`}>
44
+ {html}
45
+ </Box>
30
46
  {terms && (
31
47
  <TermsAndConditionsModal
32
48
  link="Learn More"
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React, { Fragment, 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";
@@ -27,7 +27,9 @@ const TermsAndConditionsControlV2 = ({
27
27
  containerBackground = ATHENS_GREY,
28
28
  checkboxMargin = "4px 8px 4px 4px",
29
29
  modalTitle = "Terms and Conditions",
30
- initialFocusSelector = ""
30
+ initialFocusSelector = "",
31
+ screenReaderCheckboxLabel = "",
32
+ ariaLabelledBy = ""
31
33
  }) => {
32
34
  const [showTerms, toggleShowTerms] = useState(false);
33
35
  const standardBoxShadow = generateShadows().standard.base;
@@ -48,17 +50,34 @@ const TermsAndConditionsControlV2 = ({
48
50
  borderRadius={displayInline ? "0" : "4px"}
49
51
  >
50
52
  <Stack childGap="0">
51
- {html && <Box padding="0">{html}</Box>}
53
+ {html && (
54
+ <Box padding="0" id={`${id}_html_label`}>
55
+ {html}
56
+ </Box>
57
+ )}
52
58
  <Cluster justify="flex-start" align="center" nowrap>
53
59
  {showCheckbox && (
54
- <Checkbox
55
- name={id}
56
- error={hasError}
57
- checked={isChecked}
58
- onChange={onCheck}
59
- checkboxMargin={checkboxMargin}
60
- extraStyles={`align-self: flex-start;`}
61
- />
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>
62
81
  )}
63
82
  <Stack childGap="0.25rem" fullHeight>
64
83
  <Cluster