@thecb/components 9.2.10-beta.8 → 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.8",
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"
@@ -122,6 +127,8 @@ const Checkbox = ({
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,7 +148,6 @@ const Checkbox = ({
141
148
  disabledStyles={themeValues.disabledStyles}
142
149
  disabledCheckedStyles={themeValues.disabledCheckedStyles}
143
150
  focusedStyles={themeValues.focusedStyles}
144
- aria-labelledby={`${name}_title_id`}
145
151
  >
146
152
  <CheckboxIcon
147
153
  viewBox="0 0 24 24"
@@ -155,10 +161,10 @@ const Checkbox = ({
155
161
  </CheckboxContainer>
156
162
  {title && (
157
163
  <Text
164
+ id={titleId}
158
165
  variant="p"
159
166
  weight={themeValues.textFontWeight}
160
167
  color={themeValues.textColor}
161
- id={`${name}_title_id`}
162
168
  extraStyles={
163
169
  textExtraStyles
164
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,9 +10,7 @@ const TermsAndConditionsControlV1 = ({
10
10
  html,
11
11
  terms,
12
12
  error = false,
13
- linkVariant,
14
- initialFocusSelector = "",
15
- id = "terms-and-conditions"
13
+ linkVariant
16
14
  }) => {
17
15
  const [showTerms, toggleShowTerms] = useState(false);
18
16
  return (
@@ -24,13 +22,10 @@ const TermsAndConditionsControlV1 = ({
24
22
  error={error}
25
23
  checked={isChecked}
26
24
  onChange={onCheck}
27
- aria-labelledby={`${id}_label`}
28
25
  />
29
26
  <Box padding="0 0 0 58px">
30
27
  <Stack>
31
- <Box padding="0" id={`${id}_label`}>
32
- {html}
33
- </Box>
28
+ <Box padding="0">{html}</Box>
34
29
  {terms && (
35
30
  <TermsAndConditionsModal
36
31
  link="Learn More"
@@ -38,7 +33,6 @@ const TermsAndConditionsControlV1 = ({
38
33
  isOpen={showTerms}
39
34
  toggleOpen={toggleShowTerms}
40
35
  linkVariant={linkVariant}
41
- initialFocusSelector={initialFocusSelector}
42
36
  />
43
37
  )}
44
38
  </Stack>
@@ -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,8 +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
+ modalTitle = "Terms and Conditions"
31
32
  }) => {
32
33
  const [showTerms, toggleShowTerms] = useState(false);
33
34
  const standardBoxShadow = generateShadows().standard.base;
@@ -48,11 +49,7 @@ const TermsAndConditionsControlV2 = ({
48
49
  borderRadius={displayInline ? "0" : "4px"}
49
50
  >
50
51
  <Stack childGap="0">
51
- {html && (
52
- <Box padding="0" id={`${id}_label`}>
53
- {html}
54
- </Box>
55
- )}
52
+ {html && <Box padding="0">{html}</Box>}
56
53
  <Cluster justify="flex-start" align="center" nowrap>
57
54
  {showCheckbox && (
58
55
  <Checkbox
@@ -62,7 +59,7 @@ const TermsAndConditionsControlV2 = ({
62
59
  onChange={onCheck}
63
60
  checkboxMargin={checkboxMargin}
64
61
  extraStyles={`align-self: flex-start;`}
65
- aria-labelledby={`${id}_label`}
62
+ labelledById={TermsAndConditionsTitleDivId}
66
63
  />
67
64
  )}
68
65
  <Stack childGap="0.25rem" fullHeight>
@@ -71,6 +68,7 @@ const TermsAndConditionsControlV2 = ({
71
68
  align="center"
72
69
  nowrap
73
70
  extraStyles={`padding-right: 2px; > div > * { margin: 4px 2px; };`}
71
+ id={TermsAndConditionsTitleDivId}
74
72
  >
75
73
  {description && <Text color={CHARADE_GREY}>{description}</Text>}
76
74
  {terms && (
@@ -81,7 +79,6 @@ const TermsAndConditionsControlV2 = ({
81
79
  toggleOpen={toggleTerms}
82
80
  linkVariant={modalVariant}
83
81
  title={modalTitle}
84
- initialFocusSelector={initialFocusSelector}
85
82
  />
86
83
  )}
87
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