@thecb/components 9.2.10-beta.9 → 9.2.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.9",
3
+ "version": "9.2.10",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -95,6 +95,7 @@ const Checkbox = ({
95
95
  checkboxMargin = "0 16px 0 0",
96
96
  extraStyles,
97
97
  textExtraStyles,
98
+ labelledById,
98
99
  dataQa = null
99
100
  }) => {
100
101
  const [focused, setFocused] = useState(false);
@@ -105,6 +106,10 @@ const Checkbox = ({
105
106
  }
106
107
  };
107
108
 
109
+ const titleId = title ? `checkboxlabel-${name}` : undefined;
110
+ const ariaLabelledById = labelledById ?? titleId;
111
+ const ariaLabel = ariaLabelledById ? undefined : name;
112
+
108
113
  return (
109
114
  <Box
110
115
  padding="0"
@@ -116,12 +121,14 @@ const Checkbox = ({
116
121
  background={themeValues.backgroundColor}
117
122
  extraStyles={`outline: none; ${extraStyles}; margin: ${checkboxMargin};`}
118
123
  >
119
- <CheckboxLabelContainer data-qa={dataQa} id={`${id}_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={ariaLabel}
131
+ aria-labelledby={ariaLabelledById}
125
132
  checked={checked}
126
133
  onChange={onChange}
127
134
  tabIndex="-1"
@@ -141,9 +148,6 @@ const Checkbox = ({
141
148
  disabledStyles={themeValues.disabledStyles}
142
149
  disabledCheckedStyles={themeValues.disabledCheckedStyles}
143
150
  focusedStyles={themeValues.focusedStyles}
144
- aria-labelledby={
145
- title ? `${name}_title_id` : `${id}_label_container`
146
- }
147
151
  >
148
152
  <CheckboxIcon
149
153
  viewBox="0 0 24 24"
@@ -157,10 +161,10 @@ const Checkbox = ({
157
161
  </CheckboxContainer>
158
162
  {title && (
159
163
  <Text
164
+ id={titleId}
160
165
  variant="p"
161
166
  weight={themeValues.textFontWeight}
162
167
  color={themeValues.textColor}
163
- id={`${name}_title_id`}
164
168
  extraStyles={
165
169
  textExtraStyles
166
170
  ? `${textExtraStyles} ${disabled &&
@@ -19,6 +19,7 @@ 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
+ labelledById={text("labelledById", undefined, "props")}
22
23
  />
23
24
  );
24
25
 
@@ -50,7 +50,6 @@ const AccountAndRoutingModal = ({
50
50
  toggleAccepted(true);
51
51
  toggleOpen(false);
52
52
  }}
53
- initialFocusSelector={"[name='Close']"}
54
53
  >
55
54
  <Text
56
55
  variant="pS"
@@ -61,8 +60,6 @@ const AccountAndRoutingModal = ({
61
60
  weight={themeValues.fontWeight}
62
61
  hoverStyles={themeValues.modalLinkHoverFocus}
63
62
  extraStyles={`cursor: pointer;`}
64
- role="button"
65
- className="modal-trigger"
66
63
  >
67
64
  {link}
68
65
  </Text>
@@ -45,12 +45,10 @@ const Modal = ({
45
45
  isLoading,
46
46
  buttonExtraStyles,
47
47
  children,
48
- dataQa = null,
49
- initialFocusSelector = ""
48
+ dataQa = null
50
49
  }) => {
51
50
  const { isMobile } = useContext(ThemeContext);
52
51
  const modalContainerRef = useRef(null);
53
-
54
52
  return (
55
53
  <div ref={modalContainerRef} data-qa={dataQa}>
56
54
  {modalOpen && (
@@ -73,9 +71,6 @@ const Modal = ({
73
71
  overflow: "auto"
74
72
  }}
75
73
  underlayClickExits={underlayClickExits}
76
- aria-modal={true}
77
- initialFocus={initialFocusSelector}
78
- focusDialog={!initialFocusSelector} // Focus the dialogue box itself if no selector for initial focus was provided
79
74
  >
80
75
  <Box
81
76
  padding="0"
@@ -130,8 +125,6 @@ const Modal = ({
130
125
  dataQa={cancelButtonText}
131
126
  extraStyles={buttonExtraStyles}
132
127
  className="modal-cancel-button"
133
- role="button"
134
- name={cancelButtonText}
135
128
  />
136
129
  </Box>
137
130
  <Box width="100%" padding="0">
@@ -146,8 +139,6 @@ const Modal = ({
146
139
  disabled={isContinueActionDisabled}
147
140
  extraStyles={buttonExtraStyles}
148
141
  className="modal-continue-button"
149
- role="button"
150
- name={continueButtonText}
151
142
  />
152
143
  </Box>
153
144
  </Stack>
@@ -166,8 +157,6 @@ const Modal = ({
166
157
  dataQa={cancelButtonText}
167
158
  extraStyles={buttonExtraStyles}
168
159
  className="modal-cancel-button"
169
- role="button"
170
- name={cancelButtonText}
171
160
  />
172
161
  <ButtonWithAction
173
162
  variant={
@@ -180,8 +169,6 @@ const Modal = ({
180
169
  disabled={isContinueActionDisabled}
181
170
  extraStyles={buttonExtraStyles}
182
171
  className="modal-continue-button"
183
- role="button"
184
- name={continueButtonText}
185
172
  />
186
173
  </Stack>
187
174
  )}
@@ -195,8 +182,6 @@ const Modal = ({
195
182
  dataQa={closeButtonText}
196
183
  extraStyles={buttonExtraStyles}
197
184
  className="modal-close-button"
198
- role="button"
199
- name={closeButtonText}
200
185
  />
201
186
  </Box>
202
187
  )}
@@ -188,7 +188,6 @@ const PaymentFormACH = ({
188
188
  showCheckbox={false}
189
189
  description="View"
190
190
  terms={termsContent}
191
- initialFocusSelector={".modal-close-button"}
192
191
  />
193
192
  </Cover>
194
193
  )}
@@ -210,7 +210,6 @@ const PaymentFormCard = ({
210
210
  showCheckbox={false}
211
211
  description="View"
212
212
  terms={termsContent}
213
- initialFocusSelector={".modal-close-button"}
214
213
  />
215
214
  </Cover>
216
215
  )}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { text, boolean } from "@storybook/addon-knobs";
2
+ import { text, boolean, select } from "@storybook/addon-knobs";
3
3
 
4
4
  import TermsAndConditions from "./TermsAndConditions";
5
5
  import page from "../../../../.storybook/page";
@@ -7,31 +7,15 @@ import { noop } from "../../../util/general";
7
7
 
8
8
  const groupId = "props";
9
9
 
10
- const Terms = () => (
11
- <p>
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.
24
- </p>
25
- );
26
-
27
10
  export const termsAndConditions = () => (
28
11
  <TermsAndConditions
12
+ version={select("version", ["v1", "v2"], "v1", groupId)}
29
13
  onCheck={noop}
30
- title="Agree to the terms and conditions"
31
14
  isChecked={boolean("isChecked", false, groupId)}
32
- terms={<Terms />}
15
+ html={text("html", "terms and conditions summary", groupId)}
16
+ terms={text("terms", "terms and conditions modal text", groupId)}
33
17
  error={boolean("error", false, groupId)}
34
- initialFocusSelector={text("initialFocusSelector", "#focus-me", groupId)}
18
+ description={text("description", "I definitely agree to the", groupId)}
35
19
  />
36
20
  );
37
21
 
@@ -10,11 +10,7 @@ const TermsAndConditionsControlV1 = ({
10
10
  html,
11
11
  terms,
12
12
  error = false,
13
- linkVariant,
14
- initialFocusSelector = "",
15
- id = "terms-and-conditions",
16
- screenReaderCheckboxLabel = "",
17
- ariaLabelledBy = ""
13
+ linkVariant
18
14
  }) => {
19
15
  const [showTerms, toggleShowTerms] = useState(false);
20
16
  return (
@@ -26,23 +22,10 @@ const TermsAndConditionsControlV1 = ({
26
22
  error={error}
27
23
  checked={isChecked}
28
24
  onChange={onCheck}
29
- aria-labelledby={
30
- ariaLabelledBy ||
31
- (screenReaderCheckboxLabel
32
- ? `${id}_sr_only_label`
33
- : `${id}_html_label`)
34
- }
35
25
  />
36
26
  <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
27
  <Stack>
43
- <Box padding="0" id={`${id}_html_label`}>
44
- {html}
45
- </Box>
28
+ <Box padding="0">{html}</Box>
46
29
  {terms && (
47
30
  <TermsAndConditionsModal
48
31
  link="Learn More"
@@ -50,7 +33,6 @@ const TermsAndConditionsControlV1 = ({
50
33
  isOpen={showTerms}
51
34
  toggleOpen={toggleShowTerms}
52
35
  linkVariant={linkVariant}
53
- initialFocusSelector={initialFocusSelector}
54
36
  />
55
37
  )}
56
38
  </Stack>
@@ -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";
@@ -11,6 +11,8 @@ import {
11
11
  import { generateShadows } from "../../../util/generateShadows";
12
12
  import { useScrollTo } from "../../../hooks";
13
13
 
14
+ const TermsAndConditionsTitleDivId = "terms-and-conditions-title";
15
+
14
16
  const TermsAndConditionsControlV2 = ({
15
17
  showCheckbox = true,
16
18
  onCheck,
@@ -26,10 +28,7 @@ const TermsAndConditionsControlV2 = ({
26
28
  modalVariant = "default",
27
29
  containerBackground = ATHENS_GREY,
28
30
  checkboxMargin = "4px 8px 4px 4px",
29
- modalTitle = "Terms and Conditions",
30
- initialFocusSelector = "",
31
- screenReaderCheckboxLabel = "",
32
- ariaLabelledBy = ""
31
+ modalTitle = "Terms and Conditions"
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
+ labelledById={TermsAndConditionsTitleDivId}
63
+ />
81
64
  )}
82
65
  <Stack childGap="0.25rem" fullHeight>
83
66
  <Cluster
@@ -85,6 +68,7 @@ const TermsAndConditionsControlV2 = ({
85
68
  align="center"
86
69
  nowrap
87
70
  extraStyles={`padding-right: 2px; > div > * { margin: 4px 2px; };`}
71
+ id={TermsAndConditionsTitleDivId}
88
72
  >
89
73
  {description && <Text color={CHARADE_GREY}>{description}</Text>}
90
74
  {terms && (
@@ -95,7 +79,6 @@ const TermsAndConditionsControlV2 = ({
95
79
  toggleOpen={toggleTerms}
96
80
  linkVariant={modalVariant}
97
81
  title={modalTitle}
98
- initialFocusSelector={initialFocusSelector}
99
82
  />
100
83
  )}
101
84
  </Cluster>
@@ -15,8 +15,7 @@ const TermsAndConditionsModal = ({
15
15
  terms,
16
16
  variant,
17
17
  linkVariant = "p",
18
- themeValues,
19
- initialFocusSelector = ""
18
+ themeValues
20
19
  }) => (
21
20
  <Modal
22
21
  modalOpen={isOpen}
@@ -43,7 +42,6 @@ const TermsAndConditionsModal = ({
43
42
  toggleAccepted(true);
44
43
  toggleOpen(false);
45
44
  }}
46
- initialFocusSelector={initialFocusSelector}
47
45
  >
48
46
  <Text
49
47
  variant={linkVariant}
@@ -54,8 +52,6 @@ const TermsAndConditionsModal = ({
54
52
  weight={themeValues.fontWeight}
55
53
  hoverStyles={themeValues.modalLinkHoverFocus}
56
54
  extraStyles={`display: inline-block; width: fit-content; cursor: pointer`}
57
- role="button" // This should always be a "button" since it opens a modal
58
- className="modal-trigger"
59
55
  >
60
56
  {link}
61
57
  </Text>
@@ -20,22 +20,17 @@ const linkVariants = {
20
20
  pXL: "PXL"
21
21
  };
22
22
 
23
- const Terms = () => (
24
- <p>
25
- Terms content with a <a href="#">link</a> that should NOT get initial focus.
26
- Instead, the <code>Cancel</code> button below should.
27
- </p>
28
- );
29
23
  export const termsAndConditionsModal = () => (
30
24
  <TermsAndConditionsModal
31
25
  link={text("text", "Show modal", groupId)}
32
26
  title={text("title", "Title", groupId)}
33
27
  isOpen={boolean("isOpen", false, groupId)}
28
+ // toggleOpen={setShowTerms}
29
+ // toggleAccepted={toggleTermsAccepted}
34
30
  acceptText={text("acceptText", "Accept", groupId)}
35
- terms={<Terms />}
31
+ terms={text("terms", "terms and conditions", groupId)}
36
32
  variant={select("variants", variants, "default", groupId)}
37
33
  linkVariant={select("linkVariants", linkVariants, groupId)}
38
- initialFocusSelector="[name='Cancel']"
39
34
  />
40
35
  );
41
36