@thecb/components 9.2.0-beta.9 → 9.3.0-beta.1
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/dist/index.cjs.js +321 -1462
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +60 -115
- package/dist/index.esm.js +322 -1462
- package/dist/index.esm.js.map +1 -1
- package/dist/src/apps/checkout/pages/payment/sub-pages/payment-amount/PaymentAmount_old.js +49322 -0
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/atoms/.DS_Store +0 -0
- package/src/components/atoms/checkbox/Checkbox.js +3 -1
- package/src/components/atoms/checkbox/Checkbox.stories.js +3 -2
- package/src/components/atoms/country-dropdown/CountryDropdown.js +3 -1
- package/src/components/atoms/country-dropdown/CountryDropdown.stories.js +1 -0
- package/src/components/atoms/dropdown/Dropdown.js +7 -3
- package/src/components/atoms/form-layouts/FormInput.js +4 -0
- package/src/components/atoms/form-select/FormSelect.js +22 -9
- package/src/components/atoms/form-select/FormSelect.stories.js +2 -2
- package/src/components/atoms/icons/.DS_Store +0 -0
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +4 -1
- package/src/components/molecules/address-form/AddressForm.js +6 -0
- package/src/components/molecules/index.d.ts +0 -1
- package/src/components/molecules/index.js +0 -1
- package/src/components/molecules/payment-form-ach/PaymentFormACH.js +7 -0
- package/src/components/molecules/payment-form-card/PaymentFormCard.js +1 -0
- package/src/components/molecules/radio-section/radio-button/RadioButton.js +7 -5
- package/src/components/molecules/radio-section/radio-button/RadioButton.theme.js +2 -2
- package/src/components/molecules/terms-and-conditions/TermsAndConditionsControlV1.js +1 -0
- package/src/components/molecules/terms-and-conditions/TermsAndConditionsControlV2.js +1 -0
- package/src/constants/colors.d.ts +0 -1
- package/src/constants/colors.js +1 -3
- package/src/index.d.ts +1 -2
- package/src/types/common/index.ts +0 -1
- package/src/util/index.js +1 -9
- package/src/components/molecules/toast-notification/ToastNotification.js +0 -76
- package/src/components/molecules/toast-notification/ToastNotification.stories.js +0 -67
- package/src/components/molecules/toast-notification/index.d.ts +0 -18
- package/src/components/molecules/toast-notification/index.js +0 -3
- package/src/types/common/ToastVariants.ts +0 -6
- package/src/util/hooks/index.js +0 -1
- package/src/util/hooks/use-toast-notification/index.d.ts +0 -23
- package/src/util/hooks/use-toast-notification/index.js +0 -38
package/package.json
CHANGED
package/src/.DS_Store
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -95,7 +95,8 @@ const Checkbox = ({
|
|
|
95
95
|
checkboxMargin = "0 16px 0 0",
|
|
96
96
|
extraStyles,
|
|
97
97
|
textExtraStyles,
|
|
98
|
-
dataQa = null
|
|
98
|
+
dataQa = null,
|
|
99
|
+
isRequired = false
|
|
99
100
|
}) => {
|
|
100
101
|
const [focused, setFocused] = useState(false);
|
|
101
102
|
|
|
@@ -142,6 +143,7 @@ const Checkbox = ({
|
|
|
142
143
|
disabledStyles={themeValues.disabledStyles}
|
|
143
144
|
disabledCheckedStyles={themeValues.disabledCheckedStyles}
|
|
144
145
|
focusedStyles={themeValues.focusedStyles}
|
|
146
|
+
aria-required={isRequired}
|
|
145
147
|
>
|
|
146
148
|
<CheckboxIcon
|
|
147
149
|
viewBox="0 0 24 24"
|
|
@@ -13,12 +13,13 @@ const groupId = "props";
|
|
|
13
13
|
export const checkbox = () => (
|
|
14
14
|
<Checkbox
|
|
15
15
|
variant={select(variantsLabel, variants, defaultValue, groupId)}
|
|
16
|
-
title={text("title", "Checkbox", "props")}
|
|
17
|
-
name={text("name", "Checkbox", "props")}
|
|
16
|
+
title={text("title", "Checkbox Title", "props")}
|
|
17
|
+
name={text("name", "Checkbox Name", "props")}
|
|
18
18
|
checked={boolean("checked", false, "props")}
|
|
19
19
|
error={boolean("error", false, "props")}
|
|
20
20
|
disabled={boolean("disabled", false, "props")}
|
|
21
21
|
focused={boolean("focused", false, "props")}
|
|
22
|
+
isRequired={boolean("isRequired", true, "props")}
|
|
22
23
|
/>
|
|
23
24
|
);
|
|
24
25
|
|
|
@@ -10,7 +10,8 @@ const CountryDropdown = ({
|
|
|
10
10
|
fieldActions,
|
|
11
11
|
showErrors,
|
|
12
12
|
onChange,
|
|
13
|
-
dataQa = null
|
|
13
|
+
dataQa = null,
|
|
14
|
+
isRequired = false
|
|
14
15
|
}) => (
|
|
15
16
|
<FormSelect
|
|
16
17
|
options={options}
|
|
@@ -22,6 +23,7 @@ const CountryDropdown = ({
|
|
|
22
23
|
showErrors={showErrors}
|
|
23
24
|
onChange={onChange}
|
|
24
25
|
autocompleteValue="country-name"
|
|
26
|
+
isRequired={isRequired}
|
|
25
27
|
/>
|
|
26
28
|
);
|
|
27
29
|
export default CountryDropdown;
|
|
@@ -105,8 +105,10 @@ const Dropdown = ({
|
|
|
105
105
|
ariaDescribedby,
|
|
106
106
|
autocompleteValue, // browser autofill value, like country-name
|
|
107
107
|
smoothScroll = true,
|
|
108
|
-
ariaInvalid = false
|
|
108
|
+
ariaInvalid = false,
|
|
109
|
+
isRequired = false
|
|
109
110
|
}) => {
|
|
111
|
+
const required = options.required || isRequired;
|
|
110
112
|
const [inputValue, setInputValue] = useState("");
|
|
111
113
|
const [optionsState, setOptionsState] = useState([]);
|
|
112
114
|
const [filteredOptions, setFilteredOptions] = useState([]);
|
|
@@ -296,7 +298,8 @@ const Dropdown = ({
|
|
|
296
298
|
aria-labelledby={ariaLabelledby}
|
|
297
299
|
aria-describedby={ariaDescribedby}
|
|
298
300
|
aria-expanded={isOpen}
|
|
299
|
-
aria-required={
|
|
301
|
+
aria-required={required}
|
|
302
|
+
required={required}
|
|
300
303
|
aria-invalid={ariaInvalid}
|
|
301
304
|
background={isOpen ? themeValues.hoverColor : WHITE}
|
|
302
305
|
borderRadius="2px"
|
|
@@ -328,7 +331,6 @@ const Dropdown = ({
|
|
|
328
331
|
}}
|
|
329
332
|
padding="12px"
|
|
330
333
|
placeholder={getSelection()}
|
|
331
|
-
required={options.required}
|
|
332
334
|
role="combobox"
|
|
333
335
|
themeValues={themeValues}
|
|
334
336
|
title={hasTitles ? getSelection() : null}
|
|
@@ -336,6 +338,7 @@ const Dropdown = ({
|
|
|
336
338
|
tabIndex={0}
|
|
337
339
|
value={inputValue}
|
|
338
340
|
width="100%"
|
|
341
|
+
disabled={disabledValues.includes(inputValue)}
|
|
339
342
|
/>
|
|
340
343
|
<IconWrapper open={isOpen} onClick={onClick}>
|
|
341
344
|
<DropdownIcon />
|
|
@@ -350,6 +353,7 @@ const Dropdown = ({
|
|
|
350
353
|
tabIndex={0}
|
|
351
354
|
role="listbox"
|
|
352
355
|
id={`${ariaLabelledby}_listbox`}
|
|
356
|
+
required={required}
|
|
353
357
|
>
|
|
354
358
|
<Stack childGap="0" as="ul">
|
|
355
359
|
{filteredOptions.map((choice, i) => {
|
|
@@ -116,8 +116,10 @@ const FormInput = ({
|
|
|
116
116
|
extraStyles,
|
|
117
117
|
removeFromValue, // regex of characters to remove before setting value
|
|
118
118
|
dataQa = null,
|
|
119
|
+
isRequired = false,
|
|
119
120
|
...props
|
|
120
121
|
}) => {
|
|
122
|
+
const required = isRequired || props?.required;
|
|
121
123
|
const [showPassword, setShowPassword] = useState(false);
|
|
122
124
|
const { isMobile } = useContext(ThemeContext);
|
|
123
125
|
const setValue = value => {
|
|
@@ -221,6 +223,7 @@ const FormInput = ({
|
|
|
221
223
|
$extraStyles={extraStyles}
|
|
222
224
|
data-qa={dataQa || labelTextWhenNoError}
|
|
223
225
|
autoComplete={autocompleteValue}
|
|
226
|
+
required={required}
|
|
224
227
|
{...props}
|
|
225
228
|
/>
|
|
226
229
|
) : (
|
|
@@ -247,6 +250,7 @@ const FormInput = ({
|
|
|
247
250
|
$extraStyles={extraStyles}
|
|
248
251
|
data-qa={dataQa || labelTextWhenNoError}
|
|
249
252
|
autoComplete={autocompleteValue}
|
|
253
|
+
required={required}
|
|
250
254
|
{...props}
|
|
251
255
|
/>
|
|
252
256
|
)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect } from "react";
|
|
1
|
+
import React, { useState, useMemo, useRef, useEffect } from "react";
|
|
2
2
|
import Dropdown from "../dropdown";
|
|
3
3
|
import Text from "../text";
|
|
4
4
|
import { ERROR_COLOR } from "../../../constants/colors";
|
|
@@ -24,10 +24,25 @@ const FormSelect = ({
|
|
|
24
24
|
autocompleteValue, // browser autofill value, like country-name
|
|
25
25
|
smoothScroll = true, // whether the browser should animate scroll to selected item on first open
|
|
26
26
|
dataQa = null,
|
|
27
|
-
widthFitOptions = false
|
|
27
|
+
widthFitOptions = false,
|
|
28
|
+
isRequired = false
|
|
28
29
|
}) => {
|
|
29
30
|
const [open, setOpen] = useState(false);
|
|
30
31
|
const dropdownRef = useRef(null);
|
|
32
|
+
const required = options?.required || isRequired;
|
|
33
|
+
|
|
34
|
+
const labelId = useMemo(
|
|
35
|
+
() => labelTextWhenNoError => createIdFromString(labelTextWhenNoError),
|
|
36
|
+
[labelTextWhenNoError]
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const descriptionId = useMemo(
|
|
40
|
+
() => (field, labelTextWhenNoError) =>
|
|
41
|
+
field.hasErrors && field.dirty
|
|
42
|
+
? labelId(labelTextWhenNoError) + "error-message"
|
|
43
|
+
: "",
|
|
44
|
+
[field, labelTextWhenNoError]
|
|
45
|
+
);
|
|
31
46
|
|
|
32
47
|
const handleClickAway = event => {
|
|
33
48
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
@@ -45,8 +60,8 @@ const FormSelect = ({
|
|
|
45
60
|
return (
|
|
46
61
|
<SelectContainer
|
|
47
62
|
ref={dropdownRef}
|
|
63
|
+
aria-role="group"
|
|
48
64
|
disabled={disabled}
|
|
49
|
-
aria-disabled={disabled}
|
|
50
65
|
data-qa={dataQa}
|
|
51
66
|
>
|
|
52
67
|
<Box padding="0" minWidth="100%">
|
|
@@ -61,18 +76,15 @@ const FormSelect = ({
|
|
|
61
76
|
&::first-letter {
|
|
62
77
|
text-transform: uppercase;
|
|
63
78
|
}`}
|
|
64
|
-
id={
|
|
79
|
+
id={labelId(labelTextWhenNoError)}
|
|
65
80
|
>
|
|
66
81
|
{labelTextWhenNoError}
|
|
67
82
|
</Text>
|
|
68
83
|
</Cluster>
|
|
69
84
|
</Box>
|
|
70
85
|
<Dropdown
|
|
71
|
-
ariaLabelledby={
|
|
72
|
-
ariaDescribedby={
|
|
73
|
-
labelTextWhenNoError,
|
|
74
|
-
"error message"
|
|
75
|
-
)}
|
|
86
|
+
ariaLabelledby={labelId(labelTextWhenNoError)}
|
|
87
|
+
ariaDescribedby={descriptionId(field, labelTextWhenNoError)}
|
|
76
88
|
maxHeight={dropdownMaxHeight}
|
|
77
89
|
widthFitOptions={widthFitOptions}
|
|
78
90
|
hasTitles={hasTitles}
|
|
@@ -94,6 +106,7 @@ const FormSelect = ({
|
|
|
94
106
|
disabled={disabled}
|
|
95
107
|
autocompleteValue={autocompleteValue}
|
|
96
108
|
smoothScroll={smoothScroll}
|
|
109
|
+
isRequired={required}
|
|
97
110
|
/>
|
|
98
111
|
<Stack direction="row" justify="space-between">
|
|
99
112
|
<Text
|
|
@@ -12,7 +12,7 @@ const { mapStateToProps, mapDispatchToProps, reducer } = createFormState({
|
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
const errorMessages = {
|
|
15
|
-
[required.error]: "
|
|
15
|
+
[required.error]: "This field is required."
|
|
16
16
|
};
|
|
17
17
|
const options = [
|
|
18
18
|
{ value: "", text: "choose name" },
|
|
@@ -34,7 +34,7 @@ const story = page({
|
|
|
34
34
|
const FormWrapper = props => (
|
|
35
35
|
<FormSelect
|
|
36
36
|
autocompleteValue={props.autocompleteValue}
|
|
37
|
-
labelTextWhenNoError="Form Select"
|
|
37
|
+
labelTextWhenNoError="Form Select Label"
|
|
38
38
|
errorMessages={errorMessages}
|
|
39
39
|
options={options}
|
|
40
40
|
field={props.fields.thing}
|
|
Binary file
|
|
@@ -9,11 +9,13 @@ const FormStateDropdown = ({
|
|
|
9
9
|
field,
|
|
10
10
|
fieldActions,
|
|
11
11
|
showErrors,
|
|
12
|
-
countryCode
|
|
12
|
+
countryCode,
|
|
13
|
+
isRequired = false
|
|
13
14
|
}) => {
|
|
14
15
|
const placeholder =
|
|
15
16
|
countryCode === "US" ? placeHolderOptionUS : placeHolderOption;
|
|
16
17
|
const options = [placeholder, ...getOptions(countryCode)];
|
|
18
|
+
|
|
17
19
|
return (
|
|
18
20
|
<FormSelect
|
|
19
21
|
options={options}
|
|
@@ -23,6 +25,7 @@ const FormStateDropdown = ({
|
|
|
23
25
|
errorMessages={errorMessages}
|
|
24
26
|
showErrors={showErrors}
|
|
25
27
|
autocompleteValue="address-level1"
|
|
28
|
+
isRequired={isRequired}
|
|
26
29
|
/>
|
|
27
30
|
);
|
|
28
31
|
};
|
|
@@ -58,6 +58,7 @@ const AddressForm = ({
|
|
|
58
58
|
labelTextWhenNoError="Country"
|
|
59
59
|
errorMessages={countryErrorMessages}
|
|
60
60
|
field={fields.country}
|
|
61
|
+
isRequired={true}
|
|
61
62
|
onChange={value => {
|
|
62
63
|
actions.fields.country.set(value);
|
|
63
64
|
// temporary measure to not dirty fields until
|
|
@@ -81,6 +82,7 @@ const AddressForm = ({
|
|
|
81
82
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
82
83
|
autocompleteValue="address-line1"
|
|
83
84
|
dataQa="Address"
|
|
85
|
+
isRequired={true}
|
|
84
86
|
/>
|
|
85
87
|
<FormInput
|
|
86
88
|
labelTextWhenNoError="Apt, Suite, Unit, Floor, etc. (Optional)"
|
|
@@ -90,6 +92,7 @@ const AddressForm = ({
|
|
|
90
92
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
91
93
|
autocompleteValue="address-line2"
|
|
92
94
|
dataQa="Address Line 2"
|
|
95
|
+
isRequired={false}
|
|
93
96
|
/>
|
|
94
97
|
<FormInput
|
|
95
98
|
labelTextWhenNoError="City"
|
|
@@ -100,6 +103,7 @@ const AddressForm = ({
|
|
|
100
103
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
101
104
|
autocompleteValue="address-level2"
|
|
102
105
|
dataQa="City"
|
|
106
|
+
isRequired={true}
|
|
103
107
|
/>
|
|
104
108
|
<StateProvinceDropdown
|
|
105
109
|
labelTextWhenNoError={isUS ? "State" : "State or Province"}
|
|
@@ -110,6 +114,7 @@ const AddressForm = ({
|
|
|
110
114
|
showErrors={showErrors}
|
|
111
115
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
112
116
|
dataQa="State or Province"
|
|
117
|
+
isRequired={true}
|
|
113
118
|
/>
|
|
114
119
|
<FormInput
|
|
115
120
|
isNum={isUS}
|
|
@@ -122,6 +127,7 @@ const AddressForm = ({
|
|
|
122
127
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
123
128
|
autocompleteValue="postal-code"
|
|
124
129
|
dataQa="Zip code"
|
|
130
|
+
isRequired={true}
|
|
125
131
|
/>
|
|
126
132
|
{showWalletCheckbox && (
|
|
127
133
|
<Checkbox
|
|
@@ -37,6 +37,5 @@ export { default as TabSidebar } from "./tab-sidebar";
|
|
|
37
37
|
export { default as TermsAndConditions } from "./terms-and-conditions";
|
|
38
38
|
export { default as TermsAndConditionsModal } from "./terms-and-conditions-modal";
|
|
39
39
|
export { default as Timeout } from "./timeout";
|
|
40
|
-
export { default as ToastNotification } from "./toast-notification";
|
|
41
40
|
export { default as WelcomeModule } from "./welcome-module";
|
|
42
41
|
export { default as WorkflowTile } from "./workflow-tile";
|
|
@@ -76,6 +76,7 @@ const PaymentFormACH = ({
|
|
|
76
76
|
showErrors={showErrors}
|
|
77
77
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
78
78
|
autocompleteValue="name"
|
|
79
|
+
isRequired={true}
|
|
79
80
|
/>
|
|
80
81
|
<FormInput
|
|
81
82
|
labelTextWhenNoError="Routing number"
|
|
@@ -97,6 +98,7 @@ const PaymentFormACH = ({
|
|
|
97
98
|
/>
|
|
98
99
|
)}
|
|
99
100
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
101
|
+
isRequired={true}
|
|
100
102
|
/>
|
|
101
103
|
<FormInput
|
|
102
104
|
labelTextWhenNoError="Confirm routing number"
|
|
@@ -106,6 +108,7 @@ const PaymentFormACH = ({
|
|
|
106
108
|
fieldActions={actions.fields.confirmRoutingNumber}
|
|
107
109
|
showErrors={showErrors}
|
|
108
110
|
onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
|
|
111
|
+
isRequired={true}
|
|
109
112
|
isNum
|
|
110
113
|
/>
|
|
111
114
|
<FormInput
|
|
@@ -115,6 +118,7 @@ const PaymentFormACH = ({
|
|
|
115
118
|
field={fields.accountNumber}
|
|
116
119
|
fieldActions={actions.fields.accountNumber}
|
|
117
120
|
showErrors={showErrors}
|
|
121
|
+
isRequired={true}
|
|
118
122
|
isNum
|
|
119
123
|
helperModal={() => (
|
|
120
124
|
<AccountAndRoutingModal
|
|
@@ -132,6 +136,7 @@ const PaymentFormACH = ({
|
|
|
132
136
|
<FormInput
|
|
133
137
|
labelTextWhenNoError="Confirm account number"
|
|
134
138
|
dataQa="Confirm account number"
|
|
139
|
+
isRequired={true}
|
|
135
140
|
errorMessages={confirmAccountNumberErrors}
|
|
136
141
|
field={fields.confirmAccountNumber}
|
|
137
142
|
fieldActions={actions.fields.confirmAccountNumber}
|
|
@@ -142,6 +147,7 @@ const PaymentFormACH = ({
|
|
|
142
147
|
{allowBankAccountType && (
|
|
143
148
|
<FormSelect
|
|
144
149
|
labelTextWhenNoError="Account type"
|
|
150
|
+
isRequired={true}
|
|
145
151
|
dataQa="Account type"
|
|
146
152
|
options={[
|
|
147
153
|
{ text: "Select account type", value: "" },
|
|
@@ -182,6 +188,7 @@ const PaymentFormACH = ({
|
|
|
182
188
|
showCheckbox={false}
|
|
183
189
|
description="View"
|
|
184
190
|
terms={termsContent}
|
|
191
|
+
isRequired={true}
|
|
185
192
|
/>
|
|
186
193
|
</Cover>
|
|
187
194
|
)}
|
|
@@ -24,19 +24,21 @@ const RadioButton = ({
|
|
|
24
24
|
const buttonBorder = {
|
|
25
25
|
onFocused: {
|
|
26
26
|
borderColor: themeValues.activeColor,
|
|
27
|
-
|
|
27
|
+
outline: `3px solid ${themeValues.activeColor}`,
|
|
28
|
+
outlineOffset: "2px"
|
|
28
29
|
},
|
|
29
30
|
offFocused: {
|
|
30
31
|
borderColor: themeValues.activeColor,
|
|
31
|
-
|
|
32
|
+
outline: `3px solid ${themeValues.activeColor}`,
|
|
33
|
+
outlineOffset: "2px"
|
|
32
34
|
},
|
|
33
35
|
on: {
|
|
34
36
|
borderColor: themeValues.activeColor,
|
|
35
|
-
|
|
37
|
+
outline: "0"
|
|
36
38
|
},
|
|
37
39
|
off: {
|
|
38
40
|
borderColor: themeValues.inactiveColor,
|
|
39
|
-
|
|
41
|
+
outline: "0"
|
|
40
42
|
}
|
|
41
43
|
};
|
|
42
44
|
|
|
@@ -97,7 +99,7 @@ const RadioButton = ({
|
|
|
97
99
|
borderWidth="1px"
|
|
98
100
|
borderStyle="solid"
|
|
99
101
|
borderRadius="12px"
|
|
100
|
-
margin="
|
|
102
|
+
margin="6px 14px 6px 6px"
|
|
101
103
|
height="24px"
|
|
102
104
|
width="24px"
|
|
103
105
|
variants={buttonBorder}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { MATISSE_BLUE,
|
|
1
|
+
import { MATISSE_BLUE, STORM_GREY } from "../../../../constants/colors";
|
|
2
2
|
|
|
3
3
|
const activeColor = `${MATISSE_BLUE}`;
|
|
4
|
-
const inactiveColor = `${
|
|
4
|
+
const inactiveColor = `${STORM_GREY}`;
|
|
5
5
|
|
|
6
6
|
export const fallbackValues = {
|
|
7
7
|
activeColor,
|
package/src/constants/colors.js
CHANGED
|
@@ -90,7 +90,6 @@ const BLUSH_RED = "#FFF0F5";
|
|
|
90
90
|
|
|
91
91
|
// Second level color constants
|
|
92
92
|
const ERROR_COLOR = RAZZMATAZZ_RED;
|
|
93
|
-
const ERROR_BACKGROUND_COLOR = "#FFF4F8";
|
|
94
93
|
|
|
95
94
|
// These colors are sequestered so that the alert component can reference them // by type of alert
|
|
96
95
|
const ALERT_COLORS = {
|
|
@@ -222,6 +221,5 @@ export {
|
|
|
222
221
|
RASPBERRY,
|
|
223
222
|
ALERT_COLORS,
|
|
224
223
|
PILL_COLORS,
|
|
225
|
-
ERROR_COLOR
|
|
226
|
-
ERROR_BACKGROUND_COLOR
|
|
224
|
+
ERROR_COLOR
|
|
227
225
|
};
|
package/src/index.d.ts
CHANGED
|
@@ -4,5 +4,4 @@ export { default as FieldActions } from "./FieldActions";
|
|
|
4
4
|
export { default as FormSelectOption } from "./FormSelectOption";
|
|
5
5
|
export { default as SearchableSelectOption } from "./SearchableSelectOption";
|
|
6
6
|
export { default as ErrorMessageDictionary } from "./ErrorMessageDictionary";
|
|
7
|
-
export { default as ToastVariants } from "./ToastVariants";
|
|
8
7
|
export * from "./FieldActions";
|
package/src/util/index.js
CHANGED
|
@@ -3,13 +3,5 @@ import * as general from "./general";
|
|
|
3
3
|
import * as theme from "./themeUtils";
|
|
4
4
|
import useFocusInvalidInput from "./focusFirstInvalidInputHook";
|
|
5
5
|
import useOutsideClick from "./useOutsideClick";
|
|
6
|
-
import useToastNotification from "./hooks/use-toast-notification";
|
|
7
6
|
|
|
8
|
-
export {
|
|
9
|
-
formats,
|
|
10
|
-
general,
|
|
11
|
-
theme,
|
|
12
|
-
useFocusInvalidInput,
|
|
13
|
-
useOutsideClick,
|
|
14
|
-
useToastNotification
|
|
15
|
-
};
|
|
7
|
+
export { formats, general, theme, useFocusInvalidInput, useOutsideClick };
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Box, Cluster } from "../../atoms/layouts";
|
|
3
|
-
import { Paragraph } from "../../atoms";
|
|
4
|
-
import {
|
|
5
|
-
SuccessfulIconMedium,
|
|
6
|
-
ErroredIcon,
|
|
7
|
-
IconQuitLarge
|
|
8
|
-
} from "../../atoms/icons";
|
|
9
|
-
import {
|
|
10
|
-
ERROR_BACKGROUND_COLOR,
|
|
11
|
-
HINT_GREEN,
|
|
12
|
-
WHITE
|
|
13
|
-
} from "../../../constants/colors";
|
|
14
|
-
import { FONT_WEIGHT_SEMIBOLD } from "../../../constants/style_constants";
|
|
15
|
-
|
|
16
|
-
const VARIANTS = {
|
|
17
|
-
SUCCESS: "success",
|
|
18
|
-
ERROR: "error"
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const ToastNotification = ({
|
|
22
|
-
variant = VARIANTS.SUCCESS,
|
|
23
|
-
message = "",
|
|
24
|
-
toastOpen,
|
|
25
|
-
closeToastNotification,
|
|
26
|
-
extraStyles,
|
|
27
|
-
minWidth = "112px",
|
|
28
|
-
maxWidth = "350px",
|
|
29
|
-
height = "56px",
|
|
30
|
-
childGap = "1rem",
|
|
31
|
-
backgroundColor
|
|
32
|
-
}) => (
|
|
33
|
-
<Box
|
|
34
|
-
onClick={closeToastNotification}
|
|
35
|
-
background={
|
|
36
|
-
backgroundColor
|
|
37
|
-
? backgroundColor
|
|
38
|
-
: variant === VARIANTS.SUCCESS
|
|
39
|
-
? HINT_GREEN
|
|
40
|
-
: variant === "error"
|
|
41
|
-
? ERROR_BACKGROUND_COLOR
|
|
42
|
-
: WHITE
|
|
43
|
-
}
|
|
44
|
-
minWidth={minWidth}
|
|
45
|
-
minHeight={height && parseInt(height) < 100 ? height : "100px"}
|
|
46
|
-
height={height ? height : "auto"}
|
|
47
|
-
tabIndex={toastOpen ? "-1" : "0"}
|
|
48
|
-
padding="0rem 1rem"
|
|
49
|
-
borderRadius="4px"
|
|
50
|
-
boxShadow="0px 4px 4px rgba(41, 42, 51, 0.15),
|
|
51
|
-
0px 1px 7px rgba(41, 42, 51, 0.2),
|
|
52
|
-
0px 7px 12px rgba(41, 42, 51, 0.15)"
|
|
53
|
-
extraStyles={`
|
|
54
|
-
display: ${toastOpen ? "block" : "none"};
|
|
55
|
-
position: fixed; bottom: 4rem; left: 4rem;
|
|
56
|
-
${extraStyles};
|
|
57
|
-
cursor: pointer;
|
|
58
|
-
`}
|
|
59
|
-
>
|
|
60
|
-
<Cluster align="center" childGap={childGap}>
|
|
61
|
-
{variant === "success" && <SuccessfulIconMedium />}
|
|
62
|
-
{variant === "error" && <ErroredIcon />}
|
|
63
|
-
<Box padding="1rem 0" maxWidth={maxWidth}>
|
|
64
|
-
<Paragraph
|
|
65
|
-
weight={FONT_WEIGHT_SEMIBOLD}
|
|
66
|
-
extraStyles={"word-break: break-word;"}
|
|
67
|
-
>
|
|
68
|
-
{message}
|
|
69
|
-
</Paragraph>
|
|
70
|
-
</Box>
|
|
71
|
-
<IconQuitLarge />
|
|
72
|
-
</Cluster>
|
|
73
|
-
</Box>
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
export default ToastNotification;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from "react";
|
|
2
|
-
import ToastNotification from "./ToastNotification";
|
|
3
|
-
import page from "../../../../.storybook/page";
|
|
4
|
-
import { useToastNotification } from "../../../util";
|
|
5
|
-
import { ToastVariants } from "../../../types/common";
|
|
6
|
-
|
|
7
|
-
export const toastNotificationSuccess = () => {
|
|
8
|
-
const {
|
|
9
|
-
isToastOpen,
|
|
10
|
-
toastVariant,
|
|
11
|
-
toastMessage,
|
|
12
|
-
showToast,
|
|
13
|
-
hideToast
|
|
14
|
-
} = useToastNotification();
|
|
15
|
-
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
showToast({
|
|
18
|
-
message: "Success!",
|
|
19
|
-
variant: ToastVariants.SUCCESS
|
|
20
|
-
});
|
|
21
|
-
}, []);
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<ToastNotification
|
|
25
|
-
variant={toastVariant}
|
|
26
|
-
message={toastMessage}
|
|
27
|
-
toastOpen={isToastOpen}
|
|
28
|
-
closeToastNotification={() => hideToast()}
|
|
29
|
-
/>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
toastNotificationSuccess.storyName = "Success Toast";
|
|
34
|
-
|
|
35
|
-
export const toastNotificationError = () => {
|
|
36
|
-
const {
|
|
37
|
-
isToastOpen,
|
|
38
|
-
toastVariant,
|
|
39
|
-
toastMessage,
|
|
40
|
-
showToast,
|
|
41
|
-
hideToast,
|
|
42
|
-
} = useToastNotification();
|
|
43
|
-
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
showToast({
|
|
46
|
-
message: "An error occurred",
|
|
47
|
-
variant: ToastVariants.ERROR,
|
|
48
|
-
});
|
|
49
|
-
}, []);
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<ToastNotification
|
|
53
|
-
variant={toastVariant}
|
|
54
|
-
message={toastMessage}
|
|
55
|
-
toastOpen={isToastOpen}
|
|
56
|
-
closeToastNotification={() => hideToast()}
|
|
57
|
-
/>
|
|
58
|
-
);
|
|
59
|
-
};
|
|
60
|
-
toastNotificationError.storyName = "Error Toast";
|
|
61
|
-
|
|
62
|
-
const story = page({
|
|
63
|
-
title: "Components|Molecules/ToastNotification",
|
|
64
|
-
Component: ToastNotification,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
export default story;
|