@windstream/react-shared-components 0.0.9 → 0.0.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/README.md +623 -623
- package/dist/contentful/index.d.ts +10 -6
- package/dist/contentful/index.esm.js +1 -1
- package/dist/contentful/index.esm.js.map +1 -1
- package/dist/contentful/index.js +1 -1
- package/dist/contentful/index.js.map +1 -1
- package/dist/core.d.ts +3 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +159 -159
- package/src/components/accordion/Accordion.stories.tsx +225 -225
- package/src/components/accordion/index.tsx +36 -36
- package/src/components/accordion/types.ts +9 -9
- package/src/components/alert-card/types.ts +9 -9
- package/src/components/brand-button/BrandButton.stories.tsx +221 -221
- package/src/components/brand-button/helpers.ts +35 -35
- package/src/components/brand-button/index.tsx +90 -90
- package/src/components/brand-button/types.ts +26 -26
- package/src/components/button/Button.stories.tsx +108 -108
- package/src/components/button/index.tsx +23 -23
- package/src/components/button/types.ts +14 -14
- package/src/components/call-button/CallButton.stories.tsx +324 -324
- package/src/components/call-button/index.tsx +80 -80
- package/src/components/call-button/types.ts +9 -9
- package/src/components/checkbox/Checkbox.stories.tsx +248 -248
- package/src/components/checkbox/types.ts +23 -23
- package/src/components/checklist/Checklist.stories.tsx +151 -151
- package/src/components/checklist/index.tsx +33 -33
- package/src/components/checklist/types.ts +5 -5
- package/src/components/collapse/Collapse.stories.tsx +256 -256
- package/src/components/collapse/index.tsx +44 -44
- package/src/components/collapse/types.ts +5 -5
- package/src/components/divider/Divider.stories.tsx +206 -206
- package/src/components/divider/index.tsx +23 -23
- package/src/components/divider/type.ts +2 -2
- package/src/components/input/Input.stories.tsx +358 -358
- package/src/components/input/index.tsx +174 -174
- package/src/components/input/types.ts +36 -36
- package/src/components/link/Link.stories.tsx +163 -163
- package/src/components/link/index.tsx +96 -96
- package/src/components/link/types.ts +25 -25
- package/src/components/list/List.stories.tsx +272 -272
- package/src/components/list/index.tsx +86 -86
- package/src/components/list/list-item/index.tsx +36 -36
- package/src/components/list/list-item/types.ts +13 -13
- package/src/components/list/types.ts +29 -29
- package/src/components/material-icon/MaterialIcon.stories.tsx +330 -330
- package/src/components/material-icon/constants.ts +95 -95
- package/src/components/material-icon/index.tsx +44 -44
- package/src/components/material-icon/types.ts +31 -31
- package/src/components/modal/Modal.stories.tsx +171 -171
- package/src/components/modal/index.tsx +168 -168
- package/src/components/modal/types.ts +23 -23
- package/src/components/radio-button/index.tsx +73 -73
- package/src/components/radio-button/types.ts +21 -21
- package/src/components/see-more/SeeMore.stories.tsx +182 -182
- package/src/components/see-more/index.tsx +38 -38
- package/src/components/see-more/types.ts +3 -3
- package/src/components/select/Select.stories.tsx +410 -410
- package/src/components/select/index.tsx +150 -150
- package/src/components/select/types.ts +34 -34
- package/src/components/select-plan-button/SelectPlanButton.stories.tsx +160 -160
- package/src/components/select-plan-button/index.tsx +20 -20
- package/src/components/select-plan-button/types.ts +3 -3
- package/src/components/skeleton/Skeleton.stories.tsx +180 -180
- package/src/components/skeleton/index.tsx +61 -61
- package/src/components/skeleton/types.ts +3 -3
- package/src/components/spinner/Spinner.stories.tsx +335 -335
- package/src/components/spinner/index.tsx +44 -44
- package/src/components/spinner/types.ts +4 -4
- package/src/components/text/Text.stories.tsx +302 -302
- package/src/components/text/index.tsx +26 -26
- package/src/components/text/types.ts +45 -45
- package/src/components/tooltip/Tooltip.stories.tsx +220 -220
- package/src/components/tooltip/index.tsx +78 -78
- package/src/components/tooltip/types.ts +6 -6
- package/src/components/view-cart-button/ViewCartButton.stories.tsx +241 -241
- package/src/components/view-cart-button/index.tsx +38 -38
- package/src/components/view-cart-button/types.ts +4 -4
- package/src/contentful/blocks/accordion/index.tsx +7 -7
- package/src/contentful/blocks/button/index.tsx +5 -5
- package/src/contentful/blocks/callout/index.tsx +7 -7
- package/src/contentful/blocks/cards/index.tsx +7 -7
- package/src/contentful/blocks/carousel/index.tsx +7 -7
- package/src/contentful/blocks/cta-callout/index.tsx +6 -0
- package/src/contentful/blocks/cta-callout/types.ts +1 -0
- package/src/contentful/blocks/floating-banner/index.tsx +7 -7
- package/src/contentful/blocks/footer/index.tsx +7 -7
- package/src/contentful/blocks/image-promo-bar/index.tsx +7 -7
- package/src/contentful/blocks/modal/index.tsx +5 -5
- package/src/contentful/blocks/navigation/index.tsx +7 -7
- package/src/contentful/blocks/primary-hero/index.tsx +7 -7
- package/src/contentful/blocks/shape-background-wrapper/index.tsx +123 -101
- package/src/contentful/blocks/shape-background-wrapper/types.ts +35 -29
- package/src/contentful/blocks/text/index.tsx +6 -6
- package/src/contentful/index.ts +4 -1
- package/src/hooks/use-body-scroll-lock.ts +31 -31
- package/src/index.ts +81 -81
- package/src/setupTests.ts +46 -46
- package/src/styles/globals.css +275 -269
- package/src/types/global.d.ts +9 -9
- package/src/utils/index.ts +49 -49
|
@@ -1,168 +1,168 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState } from "react";
|
|
2
|
-
import ReactModal from "react-modal";
|
|
3
|
-
import { Transition } from "react-transition-group";
|
|
4
|
-
|
|
5
|
-
import { MaterialIcon } from "../material-icon";
|
|
6
|
-
import { cx } from "../../utils";
|
|
7
|
-
import useBodyScrollLock from "../../hooks/use-body-scroll-lock";
|
|
8
|
-
|
|
9
|
-
import { ModalProps, Size, Shape, Animation } from "./types";
|
|
10
|
-
import { Button } from "../button";
|
|
11
|
-
|
|
12
|
-
const Modal: React.FC<ModalProps> = ({
|
|
13
|
-
size = "md",
|
|
14
|
-
shape = "default",
|
|
15
|
-
animation = "popper",
|
|
16
|
-
centered,
|
|
17
|
-
title,
|
|
18
|
-
isOpen,
|
|
19
|
-
children,
|
|
20
|
-
bodyStyle,
|
|
21
|
-
className,
|
|
22
|
-
bodyClassName,
|
|
23
|
-
portalClassName,
|
|
24
|
-
overlayClassName,
|
|
25
|
-
closeButtonClassName,
|
|
26
|
-
closeWrapperClassName,
|
|
27
|
-
onRequestClose,
|
|
28
|
-
parentSelector,
|
|
29
|
-
hideScrollOnIsOpenFalse = true,
|
|
30
|
-
hideCloseButton = false,
|
|
31
|
-
...modalProps
|
|
32
|
-
}: ModalProps) => {
|
|
33
|
-
// Use the custom hook to lock/unlock the body scroll when the modal is open/closed.
|
|
34
|
-
useBodyScrollLock(isOpen, hideScrollOnIsOpenFalse);
|
|
35
|
-
|
|
36
|
-
// Animation cannot run at the same time as the modal opening
|
|
37
|
-
const [isTransitioning, setIsTransitioning] = useState(false);
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
// Run animation one frame after rendering the modal
|
|
41
|
-
setIsTransitioning(isOpen);
|
|
42
|
-
}, [isOpen]);
|
|
43
|
-
|
|
44
|
-
const parent = useMemo(() => {
|
|
45
|
-
/* istanbul ignore next */ if (typeof document === "undefined") return null;
|
|
46
|
-
let parent = document.querySelector("main") || document.body;
|
|
47
|
-
if (parentSelector)
|
|
48
|
-
parent = document.querySelector(parentSelector) || document.body;
|
|
49
|
-
|
|
50
|
-
return parent;
|
|
51
|
-
}, [parentSelector]);
|
|
52
|
-
|
|
53
|
-
if (!parent) return null;
|
|
54
|
-
|
|
55
|
-
// Don't render anything when modal is closed
|
|
56
|
-
if (!isOpen) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const getSizeClasses = (size: Size) => {
|
|
61
|
-
const sizeMap = {
|
|
62
|
-
xl: "inset-[5%] min-h-fit",
|
|
63
|
-
lg: "inset-[10%] min-h-fit",
|
|
64
|
-
md: "inset-[15%] min-h-fit",
|
|
65
|
-
sm: "top-[18%] w-[640px]",
|
|
66
|
-
xs: "w-[calc(100%-30px)]",
|
|
67
|
-
};
|
|
68
|
-
return sizeMap[size];
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const getAnimationClasses = (animation: Animation, state: string) => {
|
|
72
|
-
if (animation === "popper") {
|
|
73
|
-
const baseClasses = "transition-transform duration-300";
|
|
74
|
-
if (state === "entering" || state === "entered") {
|
|
75
|
-
return `${baseClasses} opacity-100 ${state === "entered" ? "translate-y-0 pointer-events-auto" : ""}`;
|
|
76
|
-
}
|
|
77
|
-
if (state === "exiting" || state === "exited") {
|
|
78
|
-
return `${baseClasses} opacity-0 translate-y-[-18px] duration-[180ms]`;
|
|
79
|
-
}
|
|
80
|
-
return `${baseClasses} opacity-0 translate-y-[-18px]`;
|
|
81
|
-
}
|
|
82
|
-
if (animation === "bottomSheet") {
|
|
83
|
-
const baseClasses = "transition-transform duration-200 ease-in-out";
|
|
84
|
-
if (state === "entering" || state === "entered") {
|
|
85
|
-
return `${baseClasses} opacity-100 ${state === "entered" ? "translate-y-0 pointer-events-auto" : ""}`;
|
|
86
|
-
}
|
|
87
|
-
if (state === "exiting" || state === "exited") {
|
|
88
|
-
return `${baseClasses} opacity-0 translate-y-full duration-[180ms]`;
|
|
89
|
-
}
|
|
90
|
-
return `${baseClasses} opacity-0 translate-y-full`;
|
|
91
|
-
}
|
|
92
|
-
return "";
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<Transition enter exit in={isTransitioning} timeout={0}>
|
|
97
|
-
{(state: string) => (
|
|
98
|
-
<ReactModal
|
|
99
|
-
ariaHideApp={false}
|
|
100
|
-
isOpen={isOpen}
|
|
101
|
-
onRequestClose={onRequestClose}
|
|
102
|
-
closeTimeoutMS={0}
|
|
103
|
-
parentSelector={() => parent}
|
|
104
|
-
className={cx(
|
|
105
|
-
"absolute bg-white overflow-auto outline-none min-w-[150px] rounded-lg max-w-[calc(100vw-30px)]",
|
|
106
|
-
getSizeClasses(size),
|
|
107
|
-
shape === "rounded" && "rounded-3xl",
|
|
108
|
-
centered && "top-0 translate-y-[calc(50vh-50%)]",
|
|
109
|
-
getAnimationClasses(animation, state),
|
|
110
|
-
className
|
|
111
|
-
)}
|
|
112
|
-
portalClassName={cx("z-80", portalClassName)}
|
|
113
|
-
overlayClassName={cx(
|
|
114
|
-
"z-80 fixed inset-0 bg-black/50 flex items-center justify-center pb-[300px]",
|
|
115
|
-
overlayClassName
|
|
116
|
-
)}
|
|
117
|
-
{...modalProps}
|
|
118
|
-
>
|
|
119
|
-
{!hideCloseButton && (
|
|
120
|
-
<div className={cx(closeWrapperClassName)}>
|
|
121
|
-
<Button
|
|
122
|
-
className={cx(
|
|
123
|
-
"absolute right-0 top-0 float-right h-6 cursor-pointer p-5 text-text",
|
|
124
|
-
closeButtonClassName
|
|
125
|
-
)}
|
|
126
|
-
onClick={onRequestClose as () => void}
|
|
127
|
-
data-testid="close-button"
|
|
128
|
-
data-track-element-name="modal_close_button"
|
|
129
|
-
data-track-click-text="Close Modal"
|
|
130
|
-
data-track-element-clicked="modal"
|
|
131
|
-
>
|
|
132
|
-
<MaterialIcon
|
|
133
|
-
name="close"
|
|
134
|
-
size={24}
|
|
135
|
-
/>
|
|
136
|
-
</Button>
|
|
137
|
-
</div>
|
|
138
|
-
)}
|
|
139
|
-
|
|
140
|
-
{title ? (
|
|
141
|
-
<div
|
|
142
|
-
className={cx(
|
|
143
|
-
"px-[7px] py-[7px] border-b border-border-secondary-on-bg-fill text-text",
|
|
144
|
-
)}
|
|
145
|
-
>
|
|
146
|
-
{title}
|
|
147
|
-
</div>
|
|
148
|
-
) : null}
|
|
149
|
-
<div
|
|
150
|
-
className={cx("p-5", bodyClassName)}
|
|
151
|
-
style={bodyStyle}
|
|
152
|
-
data-testid={modalProps["data-testid"]}
|
|
153
|
-
data-cy={modalProps["data-cy"]}
|
|
154
|
-
>
|
|
155
|
-
{children}
|
|
156
|
-
</div>
|
|
157
|
-
</ReactModal>
|
|
158
|
-
)}
|
|
159
|
-
</Transition>
|
|
160
|
-
);
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
export { Modal };
|
|
164
|
-
|
|
165
|
-
Modal.displayName = "Modal";
|
|
166
|
-
|
|
167
|
-
export type { ModalProps, Size, Shape, Animation };
|
|
168
|
-
|
|
1
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import ReactModal from "react-modal";
|
|
3
|
+
import { Transition } from "react-transition-group";
|
|
4
|
+
|
|
5
|
+
import { MaterialIcon } from "../material-icon";
|
|
6
|
+
import { cx } from "../../utils";
|
|
7
|
+
import useBodyScrollLock from "../../hooks/use-body-scroll-lock";
|
|
8
|
+
|
|
9
|
+
import { ModalProps, Size, Shape, Animation } from "./types";
|
|
10
|
+
import { Button } from "../button";
|
|
11
|
+
|
|
12
|
+
const Modal: React.FC<ModalProps> = ({
|
|
13
|
+
size = "md",
|
|
14
|
+
shape = "default",
|
|
15
|
+
animation = "popper",
|
|
16
|
+
centered,
|
|
17
|
+
title,
|
|
18
|
+
isOpen,
|
|
19
|
+
children,
|
|
20
|
+
bodyStyle,
|
|
21
|
+
className,
|
|
22
|
+
bodyClassName,
|
|
23
|
+
portalClassName,
|
|
24
|
+
overlayClassName,
|
|
25
|
+
closeButtonClassName,
|
|
26
|
+
closeWrapperClassName,
|
|
27
|
+
onRequestClose,
|
|
28
|
+
parentSelector,
|
|
29
|
+
hideScrollOnIsOpenFalse = true,
|
|
30
|
+
hideCloseButton = false,
|
|
31
|
+
...modalProps
|
|
32
|
+
}: ModalProps) => {
|
|
33
|
+
// Use the custom hook to lock/unlock the body scroll when the modal is open/closed.
|
|
34
|
+
useBodyScrollLock(isOpen, hideScrollOnIsOpenFalse);
|
|
35
|
+
|
|
36
|
+
// Animation cannot run at the same time as the modal opening
|
|
37
|
+
const [isTransitioning, setIsTransitioning] = useState(false);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
// Run animation one frame after rendering the modal
|
|
41
|
+
setIsTransitioning(isOpen);
|
|
42
|
+
}, [isOpen]);
|
|
43
|
+
|
|
44
|
+
const parent = useMemo(() => {
|
|
45
|
+
/* istanbul ignore next */ if (typeof document === "undefined") return null;
|
|
46
|
+
let parent = document.querySelector("main") || document.body;
|
|
47
|
+
if (parentSelector)
|
|
48
|
+
parent = document.querySelector(parentSelector) || document.body;
|
|
49
|
+
|
|
50
|
+
return parent;
|
|
51
|
+
}, [parentSelector]);
|
|
52
|
+
|
|
53
|
+
if (!parent) return null;
|
|
54
|
+
|
|
55
|
+
// Don't render anything when modal is closed
|
|
56
|
+
if (!isOpen) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const getSizeClasses = (size: Size) => {
|
|
61
|
+
const sizeMap = {
|
|
62
|
+
xl: "inset-[5%] min-h-fit",
|
|
63
|
+
lg: "inset-[10%] min-h-fit",
|
|
64
|
+
md: "inset-[15%] min-h-fit",
|
|
65
|
+
sm: "top-[18%] w-[640px]",
|
|
66
|
+
xs: "w-[calc(100%-30px)]",
|
|
67
|
+
};
|
|
68
|
+
return sizeMap[size];
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const getAnimationClasses = (animation: Animation, state: string) => {
|
|
72
|
+
if (animation === "popper") {
|
|
73
|
+
const baseClasses = "transition-transform duration-300";
|
|
74
|
+
if (state === "entering" || state === "entered") {
|
|
75
|
+
return `${baseClasses} opacity-100 ${state === "entered" ? "translate-y-0 pointer-events-auto" : ""}`;
|
|
76
|
+
}
|
|
77
|
+
if (state === "exiting" || state === "exited") {
|
|
78
|
+
return `${baseClasses} opacity-0 translate-y-[-18px] duration-[180ms]`;
|
|
79
|
+
}
|
|
80
|
+
return `${baseClasses} opacity-0 translate-y-[-18px]`;
|
|
81
|
+
}
|
|
82
|
+
if (animation === "bottomSheet") {
|
|
83
|
+
const baseClasses = "transition-transform duration-200 ease-in-out";
|
|
84
|
+
if (state === "entering" || state === "entered") {
|
|
85
|
+
return `${baseClasses} opacity-100 ${state === "entered" ? "translate-y-0 pointer-events-auto" : ""}`;
|
|
86
|
+
}
|
|
87
|
+
if (state === "exiting" || state === "exited") {
|
|
88
|
+
return `${baseClasses} opacity-0 translate-y-full duration-[180ms]`;
|
|
89
|
+
}
|
|
90
|
+
return `${baseClasses} opacity-0 translate-y-full`;
|
|
91
|
+
}
|
|
92
|
+
return "";
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<Transition enter exit in={isTransitioning} timeout={0}>
|
|
97
|
+
{(state: string) => (
|
|
98
|
+
<ReactModal
|
|
99
|
+
ariaHideApp={false}
|
|
100
|
+
isOpen={isOpen}
|
|
101
|
+
onRequestClose={onRequestClose}
|
|
102
|
+
closeTimeoutMS={0}
|
|
103
|
+
parentSelector={() => parent}
|
|
104
|
+
className={cx(
|
|
105
|
+
"absolute bg-white overflow-auto outline-none min-w-[150px] rounded-lg max-w-[calc(100vw-30px)]",
|
|
106
|
+
getSizeClasses(size),
|
|
107
|
+
shape === "rounded" && "rounded-3xl",
|
|
108
|
+
centered && "top-0 translate-y-[calc(50vh-50%)]",
|
|
109
|
+
getAnimationClasses(animation, state),
|
|
110
|
+
className
|
|
111
|
+
)}
|
|
112
|
+
portalClassName={cx("z-80", portalClassName)}
|
|
113
|
+
overlayClassName={cx(
|
|
114
|
+
"z-80 fixed inset-0 bg-black/50 flex items-center justify-center pb-[300px]",
|
|
115
|
+
overlayClassName
|
|
116
|
+
)}
|
|
117
|
+
{...modalProps}
|
|
118
|
+
>
|
|
119
|
+
{!hideCloseButton && (
|
|
120
|
+
<div className={cx(closeWrapperClassName)}>
|
|
121
|
+
<Button
|
|
122
|
+
className={cx(
|
|
123
|
+
"absolute right-0 top-0 float-right h-6 cursor-pointer p-5 text-text",
|
|
124
|
+
closeButtonClassName
|
|
125
|
+
)}
|
|
126
|
+
onClick={onRequestClose as () => void}
|
|
127
|
+
data-testid="close-button"
|
|
128
|
+
data-track-element-name="modal_close_button"
|
|
129
|
+
data-track-click-text="Close Modal"
|
|
130
|
+
data-track-element-clicked="modal"
|
|
131
|
+
>
|
|
132
|
+
<MaterialIcon
|
|
133
|
+
name="close"
|
|
134
|
+
size={24}
|
|
135
|
+
/>
|
|
136
|
+
</Button>
|
|
137
|
+
</div>
|
|
138
|
+
)}
|
|
139
|
+
|
|
140
|
+
{title ? (
|
|
141
|
+
<div
|
|
142
|
+
className={cx(
|
|
143
|
+
"px-[7px] py-[7px] border-b border-border-secondary-on-bg-fill text-text",
|
|
144
|
+
)}
|
|
145
|
+
>
|
|
146
|
+
{title}
|
|
147
|
+
</div>
|
|
148
|
+
) : null}
|
|
149
|
+
<div
|
|
150
|
+
className={cx("p-5", bodyClassName)}
|
|
151
|
+
style={bodyStyle}
|
|
152
|
+
data-testid={modalProps["data-testid"]}
|
|
153
|
+
data-cy={modalProps["data-cy"]}
|
|
154
|
+
>
|
|
155
|
+
{children}
|
|
156
|
+
</div>
|
|
157
|
+
</ReactModal>
|
|
158
|
+
)}
|
|
159
|
+
</Transition>
|
|
160
|
+
);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export { Modal };
|
|
164
|
+
|
|
165
|
+
Modal.displayName = "Modal";
|
|
166
|
+
|
|
167
|
+
export type { ModalProps, Size, Shape, Animation };
|
|
168
|
+
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { Props as RModalProps } from "react-modal";
|
|
2
|
-
|
|
3
|
-
export type Size = "xl" | "lg" | "md" | "sm" | "xs";
|
|
4
|
-
export type Shape = "rounded" | "default";
|
|
5
|
-
export type Animation = "popper" | "bottomSheet";
|
|
6
|
-
|
|
7
|
-
type OwnProps = {
|
|
8
|
-
size?: Size;
|
|
9
|
-
shape?: Shape;
|
|
10
|
-
title?: string;
|
|
11
|
-
bodyClassName?: string | null | undefined;
|
|
12
|
-
closeWrapperClassName?: string | null | undefined;
|
|
13
|
-
closeButtonClassName?: string | null | undefined;
|
|
14
|
-
bodyStyle?: React.CSSProperties;
|
|
15
|
-
centered?: boolean;
|
|
16
|
-
hideScrollOnIsOpenFalse?: boolean;
|
|
17
|
-
parentSelector?: string;
|
|
18
|
-
animation?: Animation;
|
|
19
|
-
hideCloseButton?: boolean;
|
|
20
|
-
["data-testid"]?: string;
|
|
21
|
-
["data-cy"]?: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
1
|
+
import { Props as RModalProps } from "react-modal";
|
|
2
|
+
|
|
3
|
+
export type Size = "xl" | "lg" | "md" | "sm" | "xs";
|
|
4
|
+
export type Shape = "rounded" | "default";
|
|
5
|
+
export type Animation = "popper" | "bottomSheet";
|
|
6
|
+
|
|
7
|
+
type OwnProps = {
|
|
8
|
+
size?: Size;
|
|
9
|
+
shape?: Shape;
|
|
10
|
+
title?: string;
|
|
11
|
+
bodyClassName?: string | null | undefined;
|
|
12
|
+
closeWrapperClassName?: string | null | undefined;
|
|
13
|
+
closeButtonClassName?: string | null | undefined;
|
|
14
|
+
bodyStyle?: React.CSSProperties;
|
|
15
|
+
centered?: boolean;
|
|
16
|
+
hideScrollOnIsOpenFalse?: boolean;
|
|
17
|
+
parentSelector?: string;
|
|
18
|
+
animation?: Animation;
|
|
19
|
+
hideCloseButton?: boolean;
|
|
20
|
+
["data-testid"]?: string;
|
|
21
|
+
["data-cy"]?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
24
|
export type ModalProps = OwnProps & RModalProps;
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { cx } from "@shared/utils";
|
|
4
|
-
|
|
5
|
-
import { RadioButtonProps } from "./types";
|
|
6
|
-
import { Button } from "@shared/components/button";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export const RadioButton: React.FC<RadioButtonProps> = props => {
|
|
10
|
-
const {
|
|
11
|
-
name,
|
|
12
|
-
value,
|
|
13
|
-
label,
|
|
14
|
-
subText,
|
|
15
|
-
checked,
|
|
16
|
-
onChange,
|
|
17
|
-
className,
|
|
18
|
-
variant = "circle",
|
|
19
|
-
hasError = false,
|
|
20
|
-
labelProps = {},
|
|
21
|
-
"data-cy": dataCy,
|
|
22
|
-
labelClassName = "",
|
|
23
|
-
disabled,
|
|
24
|
-
...rest
|
|
25
|
-
} = props;
|
|
26
|
-
|
|
27
|
-
const handleChange = () => onChange?.(value || name);
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<label
|
|
31
|
-
htmlFor={name}
|
|
32
|
-
className={cx("flex items-center", className)}
|
|
33
|
-
data-cy={dataCy}
|
|
34
|
-
{...labelProps}
|
|
35
|
-
>
|
|
36
|
-
<input
|
|
37
|
-
className="hidden"
|
|
38
|
-
type="radio"
|
|
39
|
-
name={name}
|
|
40
|
-
value={value}
|
|
41
|
-
checked={checked}
|
|
42
|
-
readOnly
|
|
43
|
-
disabled={disabled}
|
|
44
|
-
{...rest}
|
|
45
|
-
/>
|
|
46
|
-
<Button
|
|
47
|
-
type="button"
|
|
48
|
-
onClick={handleChange}
|
|
49
|
-
disabled={disabled}
|
|
50
|
-
className={cx(
|
|
51
|
-
"border-border-secondary-on-bg-fill bg-bg mr-3 flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full border-[1px] border-solid outline-offset-4",
|
|
52
|
-
checked && "border-border-brand border-[1px] border-solid",
|
|
53
|
-
disabled && "opacity-50"
|
|
54
|
-
)}
|
|
55
|
-
>
|
|
56
|
-
{checked && <div className="bg-bg-fill-brand h-[0.875rem] w-[0.875rem] rounded-full" />}
|
|
57
|
-
</Button>
|
|
58
|
-
<Button
|
|
59
|
-
type="button"
|
|
60
|
-
onClick={handleChange}
|
|
61
|
-
disabled={disabled}
|
|
62
|
-
tabIndex={label ? 0 : -1}
|
|
63
|
-
>
|
|
64
|
-
<div className={cx("text-body2 font-normal", labelClassName)}>{label}</div>
|
|
65
|
-
<div className="text-text-info text-body1">{subText}</div>
|
|
66
|
-
</Button>
|
|
67
|
-
</label>
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
RadioButton.displayName = "RadioButton";
|
|
72
|
-
|
|
73
|
-
export type { RadioButtonProps };
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { cx } from "@shared/utils";
|
|
4
|
+
|
|
5
|
+
import { RadioButtonProps } from "./types";
|
|
6
|
+
import { Button } from "@shared/components/button";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export const RadioButton: React.FC<RadioButtonProps> = props => {
|
|
10
|
+
const {
|
|
11
|
+
name,
|
|
12
|
+
value,
|
|
13
|
+
label,
|
|
14
|
+
subText,
|
|
15
|
+
checked,
|
|
16
|
+
onChange,
|
|
17
|
+
className,
|
|
18
|
+
variant = "circle",
|
|
19
|
+
hasError = false,
|
|
20
|
+
labelProps = {},
|
|
21
|
+
"data-cy": dataCy,
|
|
22
|
+
labelClassName = "",
|
|
23
|
+
disabled,
|
|
24
|
+
...rest
|
|
25
|
+
} = props;
|
|
26
|
+
|
|
27
|
+
const handleChange = () => onChange?.(value || name);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<label
|
|
31
|
+
htmlFor={name}
|
|
32
|
+
className={cx("flex items-center", className)}
|
|
33
|
+
data-cy={dataCy}
|
|
34
|
+
{...labelProps}
|
|
35
|
+
>
|
|
36
|
+
<input
|
|
37
|
+
className="hidden"
|
|
38
|
+
type="radio"
|
|
39
|
+
name={name}
|
|
40
|
+
value={value}
|
|
41
|
+
checked={checked}
|
|
42
|
+
readOnly
|
|
43
|
+
disabled={disabled}
|
|
44
|
+
{...rest}
|
|
45
|
+
/>
|
|
46
|
+
<Button
|
|
47
|
+
type="button"
|
|
48
|
+
onClick={handleChange}
|
|
49
|
+
disabled={disabled}
|
|
50
|
+
className={cx(
|
|
51
|
+
"border-border-secondary-on-bg-fill bg-bg mr-3 flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full border-[1px] border-solid outline-offset-4",
|
|
52
|
+
checked && "border-border-brand border-[1px] border-solid",
|
|
53
|
+
disabled && "opacity-50"
|
|
54
|
+
)}
|
|
55
|
+
>
|
|
56
|
+
{checked && <div className="bg-bg-fill-brand h-[0.875rem] w-[0.875rem] rounded-full" />}
|
|
57
|
+
</Button>
|
|
58
|
+
<Button
|
|
59
|
+
type="button"
|
|
60
|
+
onClick={handleChange}
|
|
61
|
+
disabled={disabled}
|
|
62
|
+
tabIndex={label ? 0 : -1}
|
|
63
|
+
>
|
|
64
|
+
<div className={cx("text-body2 font-normal", labelClassName)}>{label}</div>
|
|
65
|
+
<div className="text-text-info text-body1">{subText}</div>
|
|
66
|
+
</Button>
|
|
67
|
+
</label>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
RadioButton.displayName = "RadioButton";
|
|
72
|
+
|
|
73
|
+
export type { RadioButtonProps };
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { InputHTMLAttributes, LabelHTMLAttributes, ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
type OwnProps = {
|
|
4
|
-
name: string;
|
|
5
|
-
value?: string | number;
|
|
6
|
-
checked?: boolean;
|
|
7
|
-
onChange?: (newVal?: string | number) => void;
|
|
8
|
-
label?: string | ReactNode;
|
|
9
|
-
subText?: string;
|
|
10
|
-
className?: string;
|
|
11
|
-
labelProps?: LabelHTMLAttributes<HTMLLabelElement>;
|
|
12
|
-
variant?: "circle";
|
|
13
|
-
hasError?: boolean;
|
|
14
|
-
"data-cy"?: string;
|
|
15
|
-
labelClassName?: string;
|
|
16
|
-
};
|
|
17
|
-
export type RadioButtonProps = OwnProps &
|
|
18
|
-
Omit<
|
|
19
|
-
InputHTMLAttributes<HTMLInputElement>,
|
|
20
|
-
"onChange" | "value" | "name" | "checked"
|
|
21
|
-
>;
|
|
1
|
+
import { InputHTMLAttributes, LabelHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
type OwnProps = {
|
|
4
|
+
name: string;
|
|
5
|
+
value?: string | number;
|
|
6
|
+
checked?: boolean;
|
|
7
|
+
onChange?: (newVal?: string | number) => void;
|
|
8
|
+
label?: string | ReactNode;
|
|
9
|
+
subText?: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
labelProps?: LabelHTMLAttributes<HTMLLabelElement>;
|
|
12
|
+
variant?: "circle";
|
|
13
|
+
hasError?: boolean;
|
|
14
|
+
"data-cy"?: string;
|
|
15
|
+
labelClassName?: string;
|
|
16
|
+
};
|
|
17
|
+
export type RadioButtonProps = OwnProps &
|
|
18
|
+
Omit<
|
|
19
|
+
InputHTMLAttributes<HTMLInputElement>,
|
|
20
|
+
"onChange" | "value" | "name" | "checked"
|
|
21
|
+
>;
|
|
22
22
|
|