@thecb/components 9.0.4-beta.1 → 9.0.4-beta.2

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.0.4-beta.1",
3
+ "version": "9.0.4-beta.2",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -24,7 +24,10 @@ const Alert = ({
24
24
  enableSmallText = false,
25
25
  innerContentPadding = "1rem",
26
26
  iconPadding = "0 0 0 1rem",
27
- contentFullHeight = false
27
+ contentFullHeight = false,
28
+ ariaRole = "group",
29
+ ariaAtomic = true,
30
+ ariaLive = "polite"
28
31
  }) => {
29
32
  const Icon = AlertIcons[variant];
30
33
  let contentPadding = maxContentWidth
@@ -92,8 +95,9 @@ const Alert = ({
92
95
  borderSize={noBorder ? "0px" : "1px"}
93
96
  boxShadow={enableBoxShadow ? generateShadows()?.inset?.base : ""}
94
97
  extraStyles={extraStyles}
95
- role="alert"
96
- aria-atomic={true}
98
+ role={ariaRole}
99
+ aria-atomic={ariaAtomic}
100
+ aria-live={ariaLive}
97
101
  >
98
102
  {maxContentWidth ? (
99
103
  <Center maxWidth={maxContentWidth}>{content}</Center>
@@ -221,6 +221,7 @@ const FormInput = ({
221
221
  $extraStyles={extraStyles}
222
222
  data-qa={dataQa || labelTextWhenNoError}
223
223
  autoComplete={autocompleteValue}
224
+ aria-busy={true}
224
225
  {...props}
225
226
  />
226
227
  ) : (
@@ -247,35 +248,36 @@ const FormInput = ({
247
248
  $extraStyles={extraStyles}
248
249
  data-qa={dataQa || labelTextWhenNoError}
249
250
  autoComplete={autocompleteValue}
251
+ aria-busy={true}
250
252
  {...props}
251
253
  />
252
254
  )}
253
255
  </Box>
254
- <Stack
255
- direction="row"
256
- justify="space-between"
257
- aria-live="polite"
258
- aria-atomic={true}
259
- >
260
- {(field.hasErrors && field.dirty) || (field.hasErrors && showErrors) ? (
261
- <Text
262
- color={ERROR_COLOR}
263
- variant="pXS"
264
- weight={themeValues.fontWeight}
265
- extraStyles={`word-break: break-word;
266
- font-family: Public Sans;
267
- &::first-letter {
268
- text-transform: uppercase;
269
- }`}
270
- id={createIdFromString(labelTextWhenNoError, "error message")}
271
- >
272
- {errorMessages[field.errors[0]]}
273
- </Text>
274
- ) : (
275
- <Text extraStyles={`height: ${themeValues.lineHeight};`} />
276
- )}
277
- {!isMobile && decorator && <Box padding="0 0 0 auto">{decorator}</Box>}
278
- </Stack>
256
+ <div role="status" aria-atomic={true}>
257
+ <Stack direction="row" justify="space-between">
258
+ {(field.hasErrors && field.dirty) ||
259
+ (field.hasErrors && showErrors) ? (
260
+ <Text
261
+ color={ERROR_COLOR}
262
+ variant="pXS"
263
+ weight={themeValues.fontWeight}
264
+ extraStyles={`word-break: break-word;
265
+ font-family: Public Sans;
266
+ &::first-letter {
267
+ text-transform: uppercase;
268
+ }`}
269
+ id={createIdFromString(labelTextWhenNoError, "error message")}
270
+ >
271
+ {errorMessages[field.errors[0]]}
272
+ </Text>
273
+ ) : (
274
+ <Text extraStyles={`height: ${themeValues.lineHeight};`} />
275
+ )}
276
+ {!isMobile && decorator && (
277
+ <Box padding="0 0 0 auto">{decorator}</Box>
278
+ )}
279
+ </Stack>
280
+ </div>
279
281
  </Stack>
280
282
  );
281
283
  };
@@ -83,6 +83,7 @@ const PartialAmountForm = ({
83
83
  }
84
84
  </Text>
85
85
  }
86
+ aria-busy={true}
86
87
  />
87
88
  ))}
88
89
  </FormInputColumn>
@@ -0,0 +1,146 @@
1
+ import React from "react";
2
+ import { connect } from "react-redux";
3
+ import { boolean } from "@storybook/addon-knobs";
4
+ import { createFormState, required } from "redux-freeform";
5
+ import PartialAmountForm from "./PartialAmountForm";
6
+ import page from "../../../../.storybook/page";
7
+ import * as PartialAmountFormState from "./PartialAmountForm.state";
8
+
9
+ const { mapStateToProps, mapDispatchToProps, reducer } = createFormState({
10
+ thing: {
11
+ validators: [required()]
12
+ }
13
+ });
14
+ const errorMessages = {
15
+ [required.error]: "thing is required"
16
+ };
17
+ const partialAmountFormFields = {
18
+ "3cd98097-1c95-43c6-848a-d44f95d312ec": {
19
+ dirty: false,
20
+ rawValue: "5000",
21
+ validators: [
22
+ {
23
+ type: "validator/REQUIRED",
24
+ args: [],
25
+ error: "error/REQUIRED"
26
+ },
27
+ {
28
+ type: "validator/VALIDATE_SUM",
29
+ args: [
30
+ {
31
+ type: "validator/NUMBER_GREATER_THAN_OR_EQUAL_TO",
32
+ args: [1],
33
+ error: "error/NUMBER_GREATER_THAN_OR_EQUAL_TO"
34
+ },
35
+ [
36
+ "ff4b6d84-7f6a-4692-8d50-05eab56a6351",
37
+ "4396e95d-e0eb-44e6-8691-f94d72c2f7e7"
38
+ ]
39
+ ],
40
+ error: "error/NUMBER_GREATER_THAN_OR_EQUAL_TO"
41
+ },
42
+ {
43
+ type: "validator/VALIDATE_SUM",
44
+ args: [
45
+ {
46
+ type: "validator/NUMBER_LESS_THAN_OR_EQUAL_TO",
47
+ args: [50000],
48
+ error: "error/NUMBER_LESS_THAN_OR_EQUAL_TO"
49
+ },
50
+ [
51
+ "ff4b6d84-7f6a-4692-8d50-05eab56a6351",
52
+ "4396e95d-e0eb-44e6-8691-f94d72c2f7e7"
53
+ ]
54
+ ],
55
+ error: "error/NUMBER_LESS_THAN_OR_EQUAL_TO"
56
+ }
57
+ ],
58
+ constraints: [
59
+ {
60
+ type: "validator/ONLY_NATURALS",
61
+ args: [],
62
+ error: "error/ONLY_NATURALS"
63
+ }
64
+ ],
65
+ errors: ["error/NUMBER_LESS_THAN_OR_EQUAL_TO"],
66
+ hasErrors: true,
67
+ id: "3cd98097-1c95-43c6-848a-d44f95d312ec"
68
+ },
69
+ "ff4b6d84-7f6a-4692-8d50-05eab56a6351": {
70
+ dirty: false,
71
+ rawValue: "25000",
72
+ id: "ff4b6d84-7f6a-4692-8d50-05eab56a6351",
73
+ validators: [
74
+ {
75
+ type: "validator/REQUIRED",
76
+ args: [],
77
+ error: "error/REQUIRED"
78
+ },
79
+ {
80
+ type: "validator/VALIDATE_SUM",
81
+ args: [
82
+ {
83
+ type: "validator/NUMBER_GREATER_THAN_OR_EQUAL_TO",
84
+ args: [1],
85
+ error: "error/NUMBER_GREATER_THAN_OR_EQUAL_TO"
86
+ },
87
+ [
88
+ "3cd98097-1c95-43c6-848a-d44f95d312ec",
89
+ "4396e95d-e0eb-44e6-8691-f94d72c2f7e7"
90
+ ]
91
+ ],
92
+ error: "error/NUMBER_GREATER_THAN_OR_EQUAL_TO"
93
+ },
94
+ {
95
+ type: "validator/VALIDATE_SUM",
96
+ args: [
97
+ {
98
+ type: "validator/NUMBER_LESS_THAN_OR_EQUAL_TO",
99
+ args: [50000],
100
+ error: "error/NUMBER_LESS_THAN_OR_EQUAL_TO"
101
+ },
102
+ [
103
+ "3cd98097-1c95-43c6-848a-d44f95d312ec",
104
+ "4396e95d-e0eb-44e6-8691-f94d72c2f7e7"
105
+ ]
106
+ ],
107
+ error: "error/NUMBER_LESS_THAN_OR_EQUAL_TO"
108
+ }
109
+ ],
110
+ constraints: [
111
+ {
112
+ type: "validator/ONLY_NATURALS",
113
+ args: [],
114
+ error: "error/ONLY_NATURALS"
115
+ }
116
+ ],
117
+ errors: ["error/NUMBER_LESS_THAN_OR_EQUAL_TO"],
118
+ hasErrors: true
119
+ }
120
+ };
121
+ const options = [
122
+ { value: "", text: "choose name" },
123
+ { value: "foo", text: "foo" },
124
+ { value: "bar", text: "bar" },
125
+ { value: "baz", text: "baz" },
126
+ { value: "disabled", text: "disabled" }
127
+ ];
128
+ const story = page({
129
+ title: "Components|Molecules/PartialAmountForm",
130
+ Component: PartialAmountForm,
131
+ reducer: PartialAmountFormState.reducer,
132
+ mapStateToProps: PartialAmountFormState.mapStateToProps,
133
+ mapDispatchToProps: PartialAmountFormState.mapDispatchToProps
134
+ });
135
+ export default story;
136
+
137
+ const ConnectedPartialAmountForm = connect(
138
+ PartialAmountFormState.mapStateToProps,
139
+ PartialAmountFormState.mapDispatchToProps
140
+ )(PartialAmountForm);
141
+ export const partialAmountForm = () => (
142
+ <ConnectedPartialAmountForm
143
+ showErrors={boolean("showErrors", false, "props")}
144
+ lineItems={options}
145
+ />
146
+ );
@@ -64,15 +64,6 @@ const PaymentFormACH = ({
64
64
  [required.error]: "Account type is required"
65
65
  };
66
66
 
67
- useEffect(() => {
68
- const firstFocusableField = document.getElementById(
69
- `first-focusable-ach-input`
70
- );
71
- if (firstFocusableField) {
72
- firstFocusableField.focus();
73
- }
74
- }, []);
75
-
76
67
  return (
77
68
  <FormContainer variant={variant} role="form" aria-label="ACH Payment">
78
69
  <FormInputColumn>
@@ -85,7 +76,6 @@ const PaymentFormACH = ({
85
76
  showErrors={showErrors}
86
77
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
87
78
  autocompleteValue="name"
88
- id="first-focusable-ach-input"
89
79
  />
90
80
  <FormInput
91
81
  labelTextWhenNoError="Routing number"
@@ -71,7 +71,7 @@ const PaymentFormCard = ({
71
71
  [hasLength.error]: "Credit card number is invalid",
72
72
  [matchesRegex.error]: `${displayCardBrand(
73
73
  fields.creditCardNumber.rawValue
74
- )} is not accepted.`
74
+ )} is not accepted`
75
75
  };
76
76
  const expirationDateErrors = {
77
77
  [required.error]: "Expiration date is required",
@@ -91,15 +91,6 @@ const PaymentFormCard = ({
91
91
  [required.error]: "Country is required"
92
92
  };
93
93
 
94
- useEffect(() => {
95
- const firstFocusableField = document.getElementById(
96
- `first-focusable-card-input`
97
- );
98
- if (firstFocusableField) {
99
- firstFocusableField.focus();
100
- }
101
- }, []);
102
-
103
94
  const isUS = fields.country.rawValue === "US";
104
95
  return (
105
96
  <FormContainer variant={variant} role="form" aria-label="Card payment">
@@ -130,7 +121,6 @@ const PaymentFormCard = ({
130
121
  showErrors={showErrors}
131
122
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
132
123
  autocompleteValue="cc-name"
133
- id="first-focusable-card-input"
134
124
  />
135
125
  <FormInput
136
126
  labelTextWhenNoError="Credit card number"
@@ -1,4 +1,4 @@
1
- import React, { Fragment, useEffect, useRef, useState } from "react";
1
+ import React, { Fragment, useState } from "react";
2
2
  import styled from "styled-components";
3
3
  import { themeComponent } from "../../../util/themeUtils";
4
4
  import { fallbackValues } from "./RadioSection.theme";
@@ -98,19 +98,6 @@ const RadioSection = ({
98
98
 
99
99
  const [focused, setFocused] = useState(null);
100
100
 
101
- // useEffect(() => {
102
- // if (toggledContentRef && toggledContentRef?.current) {
103
- // const inputEl = toggledContentRef.current?.querySelector(
104
- // `[tabindex="0"]`
105
- // );
106
- // if (inputEl) {
107
- // inputEl?.focus();
108
- // } else {
109
- // toggledContentRef.current.focus();
110
- // }
111
- // }
112
- // }, [toggledContentRef.current]);
113
-
114
101
  return (
115
102
  <Box
116
103
  padding="1px"
@@ -201,11 +188,6 @@ const RadioSection = ({
201
188
  as="label"
202
189
  htmlFor={`radio-input-${idString(section)}`}
203
190
  color={CHARADE_GREY}
204
- {...{
205
- ...(section?.titleLabel
206
- ? { "aria-label": section.titleLabel }
207
- : {})
208
- }}
209
191
  >
210
192
  {section.title}
211
193
  </Text>