@thecb/components 9.3.0-beta.2 → 9.3.2-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 +753 -631
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +169 -60
- package/dist/index.esm.js +751 -631
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/checkbox/Checkbox.js +1 -3
- package/src/components/atoms/checkbox/Checkbox.stories.js +2 -3
- package/src/components/atoms/country-dropdown/CountryDropdown.js +1 -3
- package/src/components/atoms/country-dropdown/CountryDropdown.stories.js +0 -1
- package/src/components/atoms/dropdown/Dropdown.js +73 -43
- package/src/components/atoms/dropdown/Dropdown.theme.js +8 -2
- package/src/components/atoms/form-layouts/FormInput.js +0 -4
- package/src/components/atoms/form-select/FormSelect.js +25 -36
- package/src/components/atoms/form-select/FormSelect.stories.js +2 -2
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +1 -4
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.stories.js +0 -1
- package/src/components/molecules/address-form/AddressForm.js +0 -6
- package/src/components/molecules/index.d.ts +1 -0
- package/src/components/molecules/index.js +1 -0
- package/src/components/molecules/payment-form-ach/PaymentFormACH.js +0 -7
- package/src/components/molecules/payment-form-card/PaymentFormCard.js +0 -7
- package/src/components/molecules/popover/Popover.js +1 -1
- package/src/components/molecules/radio-section/RadioSection.js +1 -2
- package/src/components/molecules/radio-section/RadioSection.stories.js +2 -3
- package/src/components/molecules/radio-section/radio-button/RadioButton.js +1 -4
- package/src/components/molecules/terms-and-conditions/TermsAndConditionsControlV1.js +0 -1
- package/src/components/molecules/terms-and-conditions/TermsAndConditionsControlV2.js +1 -2
- package/src/components/molecules/toast-notification/ToastNotification.js +75 -0
- package/src/components/molecules/toast-notification/ToastNotification.stories.js +67 -0
- package/src/components/molecules/toast-notification/index.d.ts +18 -0
- package/src/components/molecules/toast-notification/index.js +3 -0
- package/src/constants/colors.d.ts +1 -0
- package/src/constants/colors.js +5 -1
- package/src/hooks/index.js +3 -0
- package/src/hooks/use-toast-notification/index.d.ts +23 -0
- package/src/hooks/use-toast-notification/index.js +38 -0
- package/src/index.d.ts +2 -1
- package/src/index.js +2 -1
- package/src/types/common/ToastVariants.ts +6 -0
- package/src/types/common/index.ts +1 -0
- package/src/util/index.js +10 -2
- package/dist/src/apps/checkout/pages/payment/sub-pages/payment-amount/PaymentAmount_old.js +0 -49322
- 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/icons/.DS_Store +0 -0
- /package/src/{util/useOutsideClick.js → hooks/use-outside-click/index.js} +0 -0
- /package/src/{util/useScrollTo.js → hooks/use-scroll-to/index.js} +0 -0
|
@@ -49,10 +49,9 @@ const sections = [
|
|
|
49
49
|
title: "New Card",
|
|
50
50
|
content: <p>The form to add a credit card would go here.</p>,
|
|
51
51
|
rightIconsLabel: cardIconsLabel,
|
|
52
|
-
rightIcons: cardIcons
|
|
53
|
-
required: true
|
|
52
|
+
rightIcons: cardIcons
|
|
54
53
|
},
|
|
55
|
-
{ id: "bar", title: "Bar", content: <div>Content 1</div
|
|
54
|
+
{ id: "bar", title: "Bar", content: <div>Content 1</div> },
|
|
56
55
|
{ id: "baz", title: "Baz", content: <div>Content 2</div> }
|
|
57
56
|
];
|
|
58
57
|
|
|
@@ -19,8 +19,7 @@ const RadioButton = ({
|
|
|
19
19
|
ariaDescribedBy = "",
|
|
20
20
|
themeValues,
|
|
21
21
|
ariaLabelledBy = "",
|
|
22
|
-
ariaLabel = null
|
|
23
|
-
required = false
|
|
22
|
+
ariaLabel = null
|
|
24
23
|
}) => {
|
|
25
24
|
const buttonBorder = {
|
|
26
25
|
onFocused: {
|
|
@@ -91,8 +90,6 @@ const RadioButton = ({
|
|
|
91
90
|
type="radio"
|
|
92
91
|
id={`radio-${name}`}
|
|
93
92
|
disabled={disabled}
|
|
94
|
-
required={required}
|
|
95
|
-
aria-required={required}
|
|
96
93
|
onClick={toggleRadio}
|
|
97
94
|
aria-describedby={ariaDescribedBy}
|
|
98
95
|
tabIndex="-1"
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ERROR_COLOR
|
|
10
10
|
} from "../../../constants/colors";
|
|
11
11
|
import { generateShadows } from "../../../util/generateShadows";
|
|
12
|
-
import useScrollTo from "../../../
|
|
12
|
+
import { useScrollTo } from "../../../hooks";
|
|
13
13
|
|
|
14
14
|
const TermsAndConditionsControlV2 = ({
|
|
15
15
|
showCheckbox = true,
|
|
@@ -57,7 +57,6 @@ const TermsAndConditionsControlV2 = ({
|
|
|
57
57
|
onChange={onCheck}
|
|
58
58
|
checkboxMargin={checkboxMargin}
|
|
59
59
|
extraStyles={`align-self: flex-start;`}
|
|
60
|
-
isRequired={true}
|
|
61
60
|
/>
|
|
62
61
|
)}
|
|
63
62
|
<Stack childGap="0.25rem" fullHeight>
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
import { generateShadows } from "../../../util/generateShadows";
|
|
16
|
+
|
|
17
|
+
const VARIANTS = {
|
|
18
|
+
SUCCESS: "success",
|
|
19
|
+
ERROR: "error"
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const ToastNotification = ({
|
|
23
|
+
variant = VARIANTS.SUCCESS,
|
|
24
|
+
message = "",
|
|
25
|
+
toastOpen,
|
|
26
|
+
closeToastNotification,
|
|
27
|
+
extraStyles,
|
|
28
|
+
minWidth = "112px",
|
|
29
|
+
maxWidth = "350px",
|
|
30
|
+
height = "56px",
|
|
31
|
+
childGap = "1rem",
|
|
32
|
+
backgroundColor
|
|
33
|
+
}) => (
|
|
34
|
+
<Box
|
|
35
|
+
onClick={closeToastNotification}
|
|
36
|
+
background={
|
|
37
|
+
backgroundColor
|
|
38
|
+
? backgroundColor
|
|
39
|
+
: variant === VARIANTS.SUCCESS
|
|
40
|
+
? HINT_GREEN
|
|
41
|
+
: variant === VARIANTS.ERROR
|
|
42
|
+
? ERROR_BACKGROUND_COLOR
|
|
43
|
+
: WHITE
|
|
44
|
+
}
|
|
45
|
+
minWidth={minWidth}
|
|
46
|
+
minHeight={height && parseInt(height) < 100 ? height : "100px"}
|
|
47
|
+
height={height ? height : "auto"}
|
|
48
|
+
tabIndex={toastOpen ? "-1" : "0"}
|
|
49
|
+
padding="0rem 1rem"
|
|
50
|
+
borderRadius="4px"
|
|
51
|
+
boxShadow={generateShadows().standard.base}
|
|
52
|
+
extraStyles={`
|
|
53
|
+
display: ${toastOpen ? "block" : "none"};
|
|
54
|
+
position: fixed; bottom: 4rem; left: 4rem;
|
|
55
|
+
${extraStyles};
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
`}
|
|
58
|
+
>
|
|
59
|
+
<Cluster align="center" childGap={childGap}>
|
|
60
|
+
{variant === VARIANTS.SUCCESS && <SuccessfulIconMedium />}
|
|
61
|
+
{variant === VARIANTS.ERROR && <ErroredIcon />}
|
|
62
|
+
<Box padding="1rem 0" maxWidth={maxWidth}>
|
|
63
|
+
<Paragraph
|
|
64
|
+
weight={FONT_WEIGHT_SEMIBOLD}
|
|
65
|
+
extraStyles={"word-break: break-word;"}
|
|
66
|
+
>
|
|
67
|
+
{message}
|
|
68
|
+
</Paragraph>
|
|
69
|
+
</Box>
|
|
70
|
+
<IconQuitLarge />
|
|
71
|
+
</Cluster>
|
|
72
|
+
</Box>
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
export default ToastNotification;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import ToastNotification from "./ToastNotification";
|
|
3
|
+
import page from "../../../../.storybook/page";
|
|
4
|
+
import { useToastNotification } from "../../../hooks";
|
|
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;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Expand from "../../../util/expand";
|
|
3
|
+
|
|
4
|
+
export interface ToastNotificationProps {
|
|
5
|
+
variant?: string;
|
|
6
|
+
message: string;
|
|
7
|
+
toastOpen: boolean;
|
|
8
|
+
closeToastNotification: (event?: React.MouseEvent<HTMLElement>) => void;
|
|
9
|
+
extraStyles?: string;
|
|
10
|
+
minWidth?: string;
|
|
11
|
+
maxWidth?: string;
|
|
12
|
+
height?: string;
|
|
13
|
+
childGap?: string;
|
|
14
|
+
backgroundColor?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const ToastNotification: React.FC<Expand<ToastNotificationProps> &
|
|
18
|
+
React.HTMLAttributes<HTMLElement>>;
|
package/src/constants/colors.js
CHANGED
|
@@ -56,6 +56,7 @@ const INFO_BLUE = "#E4F4FD";
|
|
|
56
56
|
const CORNFLOWER_BLUE = "#EBEFFB";
|
|
57
57
|
const HOVER_LIGHT_BLUE = "#EFFAFF";
|
|
58
58
|
const MATISSE_BLUE = "#15749D";
|
|
59
|
+
const MATISSE_BLUE_DARK = "#105C7D";
|
|
59
60
|
const ROYAL_BLUE = "#3181E3";
|
|
60
61
|
const ROYAL_BLUE_VIVID = "#3B5BDB";
|
|
61
62
|
const ASTRAL_BLUE = "#3176AA";
|
|
@@ -90,6 +91,7 @@ const BLUSH_RED = "#FFF0F5";
|
|
|
90
91
|
|
|
91
92
|
// Second level color constants
|
|
92
93
|
const ERROR_COLOR = RAZZMATAZZ_RED;
|
|
94
|
+
const ERROR_BACKGROUND_COLOR = "#FFF4F8";
|
|
93
95
|
|
|
94
96
|
// These colors are sequestered so that the alert component can reference them // by type of alert
|
|
95
97
|
const ALERT_COLORS = {
|
|
@@ -192,6 +194,7 @@ export {
|
|
|
192
194
|
BOSTON_BLUE,
|
|
193
195
|
HOVER_LIGHT_BLUE,
|
|
194
196
|
MATISSE_BLUE,
|
|
197
|
+
MATISSE_BLUE_DARK,
|
|
195
198
|
ROYAL_BLUE,
|
|
196
199
|
ROYAL_BLUE_VIVID,
|
|
197
200
|
ASTRAL_BLUE,
|
|
@@ -221,5 +224,6 @@ export {
|
|
|
221
224
|
RASPBERRY,
|
|
222
225
|
ALERT_COLORS,
|
|
223
226
|
PILL_COLORS,
|
|
224
|
-
ERROR_COLOR
|
|
227
|
+
ERROR_COLOR,
|
|
228
|
+
ERROR_BACKGROUND_COLOR
|
|
225
229
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ToastVariants } from "../../types/common";
|
|
2
|
+
|
|
3
|
+
export interface UseToastOptions {
|
|
4
|
+
timeout?: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface UseToastResult {
|
|
8
|
+
isToastOpen: boolean;
|
|
9
|
+
toastVariant: string | ToastVariants;
|
|
10
|
+
toastMessage: string;
|
|
11
|
+
showToast: ({
|
|
12
|
+
message,
|
|
13
|
+
variant
|
|
14
|
+
}: {
|
|
15
|
+
message: string;
|
|
16
|
+
variant: string | ToastVariants;
|
|
17
|
+
}) => void;
|
|
18
|
+
hideToast: () => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function useToastNotification(
|
|
22
|
+
options?: UseToastOptions
|
|
23
|
+
): UseToastResult;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
const initialToastState = {
|
|
4
|
+
isOpen: false,
|
|
5
|
+
variant: "",
|
|
6
|
+
message: ""
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const useToastNotification = ({ timeout = 5000 } = {}) => {
|
|
10
|
+
const [toastState, setToastState] = useState(initialToastState);
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (toastState.isOpen) {
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
setToastState(initialToastState);
|
|
16
|
+
}, timeout);
|
|
17
|
+
}
|
|
18
|
+
}, [timeout, toastState.isOpen]);
|
|
19
|
+
|
|
20
|
+
const showToast = ({ message, variant }) =>
|
|
21
|
+
setToastState({
|
|
22
|
+
isOpen: true,
|
|
23
|
+
variant,
|
|
24
|
+
message
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const hideToast = () => setToastState(initialToastState);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
isToastOpen: toastState.isOpen,
|
|
31
|
+
toastVariant: toastState.variant,
|
|
32
|
+
toastMessage: toastState.message,
|
|
33
|
+
showToast,
|
|
34
|
+
hideToast
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default useToastNotification;
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -4,4 +4,5 @@ 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";
|
|
7
8
|
export * from "./FieldActions";
|
package/src/util/index.js
CHANGED
|
@@ -2,6 +2,14 @@ import * as formats from "./formats";
|
|
|
2
2
|
import * as general from "./general";
|
|
3
3
|
import * as theme from "./themeUtils";
|
|
4
4
|
import useFocusInvalidInput from "./focusFirstInvalidInputHook";
|
|
5
|
-
import useOutsideClick from "
|
|
5
|
+
import useOutsideClick from "../hooks/use-outside-click";
|
|
6
|
+
import useToastNotification from "../hooks/use-toast-notification";
|
|
6
7
|
|
|
7
|
-
export {
|
|
8
|
+
export {
|
|
9
|
+
formats,
|
|
10
|
+
general,
|
|
11
|
+
theme,
|
|
12
|
+
useFocusInvalidInput,
|
|
13
|
+
useOutsideClick,
|
|
14
|
+
useToastNotification
|
|
15
|
+
};
|