@thecb/components 12.1.0-beta.1 → 12.1.0-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": "12.1.0-beta.1",
3
+ "version": "12.1.0-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",
@@ -9,7 +9,9 @@
9
9
  "scripts": {
10
10
  "storybook": "storybook dev -p 6006",
11
11
  "build": "rollup -cm",
12
- "build-storybook": "storybook build"
12
+ "build-storybook": "storybook build",
13
+ "sync": "./scripts/sync-to-project.sh",
14
+ "publish-beta": "./scripts/publish-beta.sh"
13
15
  },
14
16
  "repository": {
15
17
  "type": "git",
@@ -110,6 +110,7 @@ const Checkbox = forwardRef(
110
110
  checkboxExtraStyles,
111
111
  hasIconOverride = false,
112
112
  icon: Icon,
113
+ customAriaLabel,
113
114
  ...rest
114
115
  },
115
116
  ref
@@ -122,9 +123,16 @@ const Checkbox = forwardRef(
122
123
  }
123
124
  };
124
125
 
125
- const titleId = title ? `checkboxlabel-${name}` : undefined;
126
- const ariaLabelledById = labelledById ?? titleId;
127
- const ariaLabel = ariaLabelledById ? undefined : name;
126
+ const normalizeName = name ? name.replace(/\s+/g, "-") : "";
127
+ const checkboxId = `checkbox-${normalizeName}`;
128
+ const titleId = title ? `checkboxlabel-${normalizeName}` : undefined;
129
+ const ariaLabelledById = customAriaLabel
130
+ ? undefined
131
+ : labelledById ?? titleId;
132
+ const ariaLabel = ariaLabelledById ? undefined : customAriaLabel ?? name;
133
+ const errorMessageNormalized = error
134
+ ? `${normalizeName}-error-message`
135
+ : undefined;
128
136
 
129
137
  return (
130
138
  <Box
@@ -137,7 +145,7 @@ const Checkbox = forwardRef(
137
145
  aria-invalid={error}
138
146
  aria-label={ariaLabel}
139
147
  aria-labelledby={ariaLabelledById}
140
- aria-describedby={error ? `${name}-error-message` : undefined}
148
+ aria-describedby={errorMessageNormalized}
141
149
  onFocus={() => setFocused(true)}
142
150
  onBlur={() => setFocused(false)}
143
151
  onKeyDown={e => handleClick(e, onChange)}
@@ -155,7 +163,7 @@ const Checkbox = forwardRef(
155
163
  <CheckboxLabelContainer data-qa={dataQa}>
156
164
  <CheckboxContainer data-qa="Checkbox">
157
165
  <HiddenCheckbox
158
- id={`checkbox-${name}`}
166
+ id={checkboxId}
159
167
  disabled={disabled}
160
168
  name={name}
161
169
  checked={checked}
@@ -20,8 +20,8 @@ const NavFooter = ({
20
20
  minWidth="100%"
21
21
  extraStyles={
22
22
  isMobile
23
- ? `overflow: hidden;`
24
- : `height: ${footerMinHeight}; > * { height: 100%; };`
23
+ ? ``
24
+ : `min-height: ${footerMinHeight}; > * { min-height: 100%; };`
25
25
  }
26
26
  {...rest}
27
27
  >
@@ -39,7 +39,7 @@ const PartialAmountField = ({
39
39
  variant={themeValues.detailVariant}
40
40
  weight="400"
41
41
  >
42
- {lineItem.subDescription} payment amount
42
+ {lineItem.subDescription}
43
43
  </Detail>
44
44
  </Box>
45
45
  </Stack>
@@ -53,7 +53,6 @@ const PartialAmountField = ({
53
53
  placeholder="$0.00"
54
54
  formatter={moneyFormat}
55
55
  isNum
56
- isRequired
57
56
  decorator={
58
57
  <Text variant="p">
59
58
  Amount owed:{" "}
@@ -14,7 +14,6 @@ import {
14
14
  } from "../../atoms/form-layouts";
15
15
  import AccountAndRoutingModal from "../account-and-routing-modal";
16
16
  import { noop } from "../../../util/general";
17
- import { Cluster, Cover } from "../../atoms/layouts";
18
17
  import TermsAndConditions from "../terms-and-conditions";
19
18
 
20
19
  const PaymentFormACH = ({
@@ -172,29 +171,42 @@ const PaymentFormACH = ({
172
171
  hidden={hideDefaultPayment}
173
172
  />
174
173
  )}
175
- {(showWalletCheckbox || showTerms) && (
176
- <Cluster childGap={"4px"} align="center">
177
- {showWalletCheckbox && (
178
- <Checkbox
179
- name="bank checkbox"
180
- dataQa="Save checking account to wallet"
181
- title="Save checking account to wallet."
182
- checked={walletCheckboxMarked}
183
- onChange={saveToWallet}
184
- />
185
- )}
186
- {showTerms && (
187
- <Cover singleChild>
188
- <TermsAndConditions
189
- version="v2"
190
- showCheckbox={false}
191
- description="View"
192
- terms={termsContent}
193
- initialFocusSelector={".modal-close-button"}
194
- />
195
- </Cover>
196
- )}
197
- </Cluster>
174
+ {showWalletCheckbox && (
175
+ <Checkbox
176
+ name="bank checkbox"
177
+ dataQa="Save checking account to wallet"
178
+ customAriaLabel="Save checking account to wallet (optional)."
179
+ title={
180
+ <>
181
+ Save checking account to wallet (optional).{" "}
182
+ {showTerms && (
183
+ <span
184
+ onClick={e => e.stopPropagation()}
185
+ style={{ display: "inline" }}
186
+ >
187
+ <TermsAndConditions
188
+ version="v2"
189
+ showCheckbox={false}
190
+ description="View "
191
+ terms={termsContent}
192
+ initialFocusSelector={".modal-close-button"}
193
+ />
194
+ </span>
195
+ )}
196
+ </>
197
+ }
198
+ checked={walletCheckboxMarked}
199
+ onChange={saveToWallet}
200
+ />
201
+ )}
202
+ {!showWalletCheckbox && showTerms && (
203
+ <TermsAndConditions
204
+ version="v2"
205
+ showCheckbox={false}
206
+ description="View "
207
+ terms={termsContent}
208
+ initialFocusSelector=".modal-close-button"
209
+ />
198
210
  )}
199
211
  </FormInputColumn>
200
212
  </FormContainer>
@@ -196,29 +196,42 @@ const PaymentFormCard = ({
196
196
  />
197
197
  </Box>
198
198
  )}
199
- {(showWalletCheckbox || showTerms) && (
200
- <Cluster childGap={"4px"} align="center">
201
- {showWalletCheckbox && (
202
- <Checkbox
203
- name="credit card checkbox"
204
- dataQa="Save credit card to wallet"
205
- title="Save credit card to wallet."
206
- checked={walletCheckboxMarked}
207
- onChange={saveToWallet}
208
- />
209
- )}
210
- {showTerms && (
211
- <Cover singleChild>
212
- <TermsAndConditions
213
- version="v2"
214
- showCheckbox={false}
215
- description="View"
216
- terms={termsContent}
217
- initialFocusSelector={".modal-close-button"}
218
- />
219
- </Cover>
220
- )}
221
- </Cluster>
199
+ {showWalletCheckbox && (
200
+ <Checkbox
201
+ name="bank checkbox"
202
+ dataQa="Save credit card to wallet"
203
+ customAriaLabel="Save credit card to wallet (optional)."
204
+ title={
205
+ <>
206
+ Save credit card to wallet (optional).{" "}
207
+ {showTerms && (
208
+ <span
209
+ onClick={e => e.stopPropagation()}
210
+ style={{ display: "inline" }}
211
+ >
212
+ <TermsAndConditions
213
+ version="v2"
214
+ showCheckbox={false}
215
+ description="View "
216
+ terms={termsContent}
217
+ initialFocusSelector={".modal-close-button"}
218
+ />
219
+ </span>
220
+ )}
221
+ </>
222
+ }
223
+ checked={walletCheckboxMarked}
224
+ onChange={saveToWallet}
225
+ />
226
+ )}
227
+ {!showWalletCheckbox && showTerms && (
228
+ <TermsAndConditions
229
+ version="v2"
230
+ showCheckbox={false}
231
+ description="View "
232
+ terms={termsContent}
233
+ initialFocusSelector=".modal-close-button"
234
+ />
222
235
  )}
223
236
  </FormInputColumn>
224
237
  </FormContainer>
@@ -1,4 +1,5 @@
1
1
  import React, { useState } from "react";
2
+ import styled from "styled-components";
2
3
  import Checkbox from "../../atoms/checkbox";
3
4
  import { Box, Stack, Cluster } from "../../atoms/layouts";
4
5
  import Text from "../../atoms/text";
@@ -12,6 +13,15 @@ import { generateShadows } from "../../../util/generateShadows";
12
13
  import { useScrollTo } from "../../../hooks";
13
14
 
14
15
  const TermsAndConditionsTitleDivId = "terms-and-conditions-title";
16
+ const InlineTermsWrapper = styled.span`
17
+ display: inline;
18
+ > div {
19
+ display: inline;
20
+ }
21
+ .modal-trigger {
22
+ display: inline !important;
23
+ }
24
+ `;
15
25
 
16
26
  const TermsAndConditionsControlV2 = ({
17
27
  showCheckbox = true,
@@ -42,6 +52,25 @@ const TermsAndConditionsControlV2 = ({
42
52
  }
43
53
  };
44
54
 
55
+ if (!showCheckbox && displayInline) {
56
+ return (
57
+ <InlineTermsWrapper id={TermsAndConditionsTitleDivId}>
58
+ {description && <Text color={CHARADE_GREY}>{description}</Text>}
59
+ {terms && (
60
+ <TermsAndConditionsModal
61
+ link={linkText}
62
+ terms={terms}
63
+ isOpen={showTerms}
64
+ toggleOpen={toggleTerms}
65
+ linkVariant={modalVariant}
66
+ title={modalTitle}
67
+ initialFocusSelector={initialFocusSelector}
68
+ />
69
+ )}
70
+ </InlineTermsWrapper>
71
+ );
72
+ }
73
+
45
74
  return (
46
75
  <Box
47
76
  padding={displayInline ? "0" : "1.5rem"}