beem-component 1.4.5 → 1.4.8
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/components/ChatComponents/ChatBody/chatBody.js +47 -39
- package/dist/components/ChatComponents/ChatBody/chatBody.stories.js +5 -1
- package/dist/components/ChatComponents/ChatBody/sessionDetails.js +39 -0
- package/dist/components/Modals/modal.js +2 -4
- package/dist/components/Tags/tags.js +67 -13
- package/dist/components/Tags/tags.stories.js +29 -8
- package/package.json +2 -2
- package/src/App.js +69 -0
- package/src/index.js +1 -1
- package/src/lib/components/ChatComponents/ChatBody/chatBody.js +98 -77
- package/src/lib/components/ChatComponents/ChatBody/chatBody.stories.js +1 -0
- package/src/lib/components/ChatComponents/ChatBody/sessionDetails.js +22 -0
- package/src/lib/components/Modals/modal.js +1 -1
- package/src/lib/components/Tags/tags.js +31 -8
- package/src/lib/components/Tags/tags.stories.js +24 -7
- package/dist/components/Modals/modal copy.js +0 -160
- package/src/lib/components/Modals/modal copy.js +0 -159
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Done, DoneAll } from
|
|
3
|
-
import FilePresentIcon from
|
|
4
|
-
import DownloadIcon from
|
|
5
|
-
import styled from
|
|
6
|
-
import BmAvatar from
|
|
7
|
-
import { BmIcons } from
|
|
8
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Done, DoneAll } from "@material-ui/icons";
|
|
3
|
+
import FilePresentIcon from "@mui/icons-material/FilePresent";
|
|
4
|
+
import DownloadIcon from "@mui/icons-material/Download";
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
import BmAvatar from "../../Avatars/avatars";
|
|
7
|
+
import { BmIcons } from "../../iconStyles";
|
|
8
|
+
import { SessionDetails } from "./sessionDetails";
|
|
9
9
|
import {
|
|
10
10
|
BmPrimaryWhite,
|
|
11
11
|
BmPrimaryBlue,
|
|
12
12
|
BmPrimaryBlack,
|
|
13
13
|
BmSecondaryDarkGreen,
|
|
14
14
|
BmGrey200,
|
|
15
|
-
} from
|
|
15
|
+
} from "../../colors";
|
|
16
16
|
|
|
17
17
|
const BmChat = styled.div`
|
|
18
18
|
display: flex;
|
|
19
19
|
flex-direction: column;
|
|
20
20
|
height: 100%;
|
|
21
|
-
${
|
|
21
|
+
${"" /* border: 0.071rem solid ${BmGrey400}; */}
|
|
22
22
|
`;
|
|
23
23
|
|
|
24
24
|
BmChat.Body = styled.div`
|
|
@@ -28,18 +28,19 @@ BmChat.Body = styled.div`
|
|
|
28
28
|
flex-grow: 1;
|
|
29
29
|
overflow: auto;
|
|
30
30
|
height: 100%;
|
|
31
|
+
border: 10px solid green;
|
|
31
32
|
`;
|
|
32
33
|
|
|
33
34
|
const Details = styled.div`
|
|
34
35
|
display: flex;
|
|
35
36
|
justify-content: ${({ state }) => {
|
|
36
|
-
if (state ===
|
|
37
|
-
return
|
|
37
|
+
if (state === "inbound") {
|
|
38
|
+
return "flex-start";
|
|
38
39
|
}
|
|
39
|
-
if (state ===
|
|
40
|
-
return
|
|
40
|
+
if (state === "outbound") {
|
|
41
|
+
return "flex-end";
|
|
41
42
|
}
|
|
42
|
-
return
|
|
43
|
+
return "row";
|
|
43
44
|
}};
|
|
44
45
|
> *:not(:last-child) {
|
|
45
46
|
margin-right: 1rem;
|
|
@@ -49,6 +50,7 @@ const Details = styled.div`
|
|
|
49
50
|
word-wrap: break-word !important;
|
|
50
51
|
margin: 0rem;
|
|
51
52
|
flex-grow: 1;
|
|
53
|
+
${"" /* border: 1px solid red; */}
|
|
52
54
|
`;
|
|
53
55
|
|
|
54
56
|
const MessageDetails = styled.div`
|
|
@@ -68,22 +70,22 @@ const Messages = styled.div`
|
|
|
68
70
|
padding: 0.5rem;
|
|
69
71
|
background: ${({ state }) => {
|
|
70
72
|
if (state) {
|
|
71
|
-
if (state ===
|
|
72
|
-
if (state ===
|
|
73
|
+
if (state === "inbound") return `${BmPrimaryWhite}`;
|
|
74
|
+
if (state === "outbound") return `${BmPrimaryBlue}`;
|
|
73
75
|
}
|
|
74
76
|
return `${BmPrimaryWhite}`;
|
|
75
77
|
}};
|
|
76
78
|
color: ${({ state }) => {
|
|
77
79
|
if (state) {
|
|
78
|
-
if (state ===
|
|
79
|
-
if (state ===
|
|
80
|
+
if (state === "inbound") return `${BmPrimaryBlack}`;
|
|
81
|
+
if (state === "outbound") return `${BmPrimaryWhite}`;
|
|
80
82
|
}
|
|
81
83
|
return `${BmPrimaryWhite}`;
|
|
82
84
|
}};
|
|
83
85
|
border-radius: ${({ state }) => {
|
|
84
86
|
if (state) {
|
|
85
|
-
if (state ===
|
|
86
|
-
if (state ===
|
|
87
|
+
if (state === "inbound") return "0.21875rem 0.21875rem 0.21875rem 0rem";
|
|
88
|
+
if (state === "outbound") return "0.21875rem 0.21875rem 0rem 0.21875rem";
|
|
87
89
|
}
|
|
88
90
|
return `${BmPrimaryWhite}`;
|
|
89
91
|
}};
|
|
@@ -103,11 +105,11 @@ const MessagesSubDetails = styled.div`
|
|
|
103
105
|
`;
|
|
104
106
|
|
|
105
107
|
const handleState = ({ session }) => {
|
|
106
|
-
if (session ===
|
|
107
|
-
return <BmAvatar size=
|
|
108
|
+
if (session === "bot") {
|
|
109
|
+
return <BmAvatar size="small" user="chatbot" />;
|
|
108
110
|
}
|
|
109
|
-
if (session ===
|
|
110
|
-
return <BmAvatar size=
|
|
111
|
+
if (session === "live") {
|
|
112
|
+
return <BmAvatar size="small" user="employee" />;
|
|
111
113
|
}
|
|
112
114
|
};
|
|
113
115
|
|
|
@@ -119,22 +121,22 @@ const FileAttachmentWrapper = styled.div`
|
|
|
119
121
|
padding: 1rem;
|
|
120
122
|
background: ${({ state }) => {
|
|
121
123
|
if (state) {
|
|
122
|
-
if (state ===
|
|
123
|
-
if (state ===
|
|
124
|
+
if (state === "inbound") return `${BmPrimaryWhite}`;
|
|
125
|
+
if (state === "outbound") return `${BmPrimaryBlue}`;
|
|
124
126
|
}
|
|
125
127
|
return `${BmPrimaryWhite}`;
|
|
126
128
|
}};
|
|
127
129
|
color: ${({ state }) => {
|
|
128
130
|
if (state) {
|
|
129
|
-
if (state ===
|
|
130
|
-
if (state ===
|
|
131
|
+
if (state === "inbound") return `${BmPrimaryBlack}`;
|
|
132
|
+
if (state === "outbound") return `${BmPrimaryWhite}`;
|
|
131
133
|
}
|
|
132
134
|
return `${BmPrimaryWhite}`;
|
|
133
135
|
}};
|
|
134
136
|
border-radius: ${({ state }) => {
|
|
135
137
|
if (state) {
|
|
136
|
-
if (state ===
|
|
137
|
-
if (state ===
|
|
138
|
+
if (state === "inbound") return "0.21875rem 0.21875rem 0.21875rem 0rem";
|
|
139
|
+
if (state === "outbound") return "0.21875rem 0.21875rem 0rem 0.21875rem";
|
|
138
140
|
}
|
|
139
141
|
return `${BmPrimaryWhite}`;
|
|
140
142
|
}};
|
|
@@ -151,14 +153,14 @@ const FileAttachmentWrapper = styled.div`
|
|
|
151
153
|
align-items: center;
|
|
152
154
|
color: ${({ state }) => {
|
|
153
155
|
if (state) {
|
|
154
|
-
if (state ===
|
|
155
|
-
if (state ===
|
|
156
|
+
if (state === "inbound") return `${BmPrimaryBlue}`;
|
|
157
|
+
if (state === "outbound") return `${BmPrimaryWhite}`;
|
|
156
158
|
}
|
|
157
159
|
return `${BmPrimaryWhite}`;
|
|
158
160
|
}};
|
|
159
161
|
}
|
|
160
|
-
${
|
|
161
|
-
${
|
|
162
|
+
${"" /* max-width: 100%; */}
|
|
163
|
+
${"" /* max-height: 100%; */}
|
|
162
164
|
`;
|
|
163
165
|
|
|
164
166
|
const BmFileAttachment = ({
|
|
@@ -183,15 +185,15 @@ export const BmImageWrapper = styled.div`
|
|
|
183
185
|
flex-direction: column;
|
|
184
186
|
color: ${({ state }) => {
|
|
185
187
|
if (state) {
|
|
186
|
-
if (state ===
|
|
187
|
-
if (state ===
|
|
188
|
+
if (state === "inbound") return `${BmPrimaryBlack}`;
|
|
189
|
+
if (state === "outbound") return `${BmPrimaryWhite}`;
|
|
188
190
|
}
|
|
189
191
|
return `${BmPrimaryWhite}`;
|
|
190
192
|
}};
|
|
191
193
|
border-radius: ${({ state }) => {
|
|
192
194
|
if (state) {
|
|
193
|
-
if (state ===
|
|
194
|
-
if (state ===
|
|
195
|
+
if (state === "inbound") return "0.21875rem 0.21875rem 0.21875rem 0rem";
|
|
196
|
+
if (state === "outbound") return "0.21875rem 0.21875rem 0rem 0.21875rem";
|
|
195
197
|
}
|
|
196
198
|
return `${BmPrimaryWhite}`;
|
|
197
199
|
}};
|
|
@@ -199,7 +201,7 @@ export const BmImageWrapper = styled.div`
|
|
|
199
201
|
`;
|
|
200
202
|
|
|
201
203
|
export const BmImage = styled.img`
|
|
202
|
-
${
|
|
204
|
+
${"" /* Fix width */}
|
|
203
205
|
width: 100%;
|
|
204
206
|
object-fit: cover;
|
|
205
207
|
flex-grow: 1;
|
|
@@ -209,7 +211,7 @@ export const BmImageChat = ({ state, src, fileName, ...rest }) => {
|
|
|
209
211
|
return (
|
|
210
212
|
<>
|
|
211
213
|
<BmImageWrapper state={state} {...rest}>
|
|
212
|
-
<BmImage src={src} alt=
|
|
214
|
+
<BmImage src={src} alt="src" />
|
|
213
215
|
{fileName && (
|
|
214
216
|
<BmFileAttachment
|
|
215
217
|
state={state}
|
|
@@ -240,48 +242,67 @@ BmChat.Details = ({
|
|
|
240
242
|
src,
|
|
241
243
|
file,
|
|
242
244
|
fileName,
|
|
245
|
+
sessionDetails,
|
|
243
246
|
...rest
|
|
244
247
|
}) => {
|
|
245
248
|
return (
|
|
246
|
-
|
|
247
|
-
{
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
<MessagesSubDetails>
|
|
268
|
-
{displayTime && displayTime}
|
|
269
|
-
{status === 'sent' && (
|
|
270
|
-
<BmIcons
|
|
271
|
-
icon={<DoneAll />}
|
|
272
|
-
color={`${BmSecondaryDarkGreen}`}
|
|
273
|
-
size='small'
|
|
249
|
+
<>
|
|
250
|
+
{sessionDetails && (
|
|
251
|
+
<SessionDetails
|
|
252
|
+
time={sessionDetails.time}
|
|
253
|
+
message={sessionDetails.message}
|
|
254
|
+
{...rest}
|
|
255
|
+
/>
|
|
256
|
+
)}
|
|
257
|
+
<Details state={state} {...rest}>
|
|
258
|
+
{/* Adding for mobile */}
|
|
259
|
+
<MessageState>
|
|
260
|
+
{state === "inbound" && session && handleState({ state, session })}
|
|
261
|
+
</MessageState>
|
|
262
|
+
<MessageDetails>
|
|
263
|
+
{/* For Images */}
|
|
264
|
+
{src && (
|
|
265
|
+
<BmImageChat
|
|
266
|
+
state={state}
|
|
267
|
+
src={src}
|
|
268
|
+
fileName={fileName}
|
|
269
|
+
{...rest}
|
|
274
270
|
/>
|
|
275
271
|
)}
|
|
276
|
-
{
|
|
277
|
-
|
|
272
|
+
{/* For Messages */}
|
|
273
|
+
{children && <Messages state={state}>{children}</Messages>}
|
|
274
|
+
{/* For files */}
|
|
275
|
+
{file && (
|
|
276
|
+
<BmFileAttachment
|
|
277
|
+
file={file}
|
|
278
|
+
fileName={fileName}
|
|
279
|
+
state={state}
|
|
280
|
+
{...rest}
|
|
281
|
+
/>
|
|
278
282
|
)}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
283
|
+
<MessagesSubDetails>
|
|
284
|
+
{displayTime && displayTime}
|
|
285
|
+
{status === "sent" && (
|
|
286
|
+
<BmIcons
|
|
287
|
+
icon={<DoneAll />}
|
|
288
|
+
color={`${BmSecondaryDarkGreen}`}
|
|
289
|
+
size="small"
|
|
290
|
+
/>
|
|
291
|
+
)}
|
|
292
|
+
{status === "failed" && (
|
|
293
|
+
<BmIcons
|
|
294
|
+
icon={<Done />}
|
|
295
|
+
color={`${BmPrimaryBlack}`}
|
|
296
|
+
size="small"
|
|
297
|
+
/>
|
|
298
|
+
)}
|
|
299
|
+
</MessagesSubDetails>
|
|
300
|
+
</MessageDetails>
|
|
301
|
+
<MessageState>
|
|
302
|
+
{state === "outbound" && session && handleState({ state, session })}
|
|
303
|
+
</MessageState>
|
|
304
|
+
</Details>
|
|
305
|
+
</>
|
|
285
306
|
);
|
|
286
307
|
};
|
|
287
308
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { BmGrey200 } from "../../colors";
|
|
3
|
+
|
|
4
|
+
const SessionDetailsWrapper = styled.div`
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: row;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
align-items: center;
|
|
9
|
+
text-align: center;
|
|
10
|
+
border-bottom: 0.071rem solid ${BmGrey200};
|
|
11
|
+
margin: 0.5rem;
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export const SessionDetails = ({ message, time, ...rest }) => {
|
|
15
|
+
return (
|
|
16
|
+
<SessionDetailsWrapper time={time} message={message} {...rest}>
|
|
17
|
+
<p> </p>
|
|
18
|
+
{message || <p> </p>}
|
|
19
|
+
{time || <p> </p>}
|
|
20
|
+
</SessionDetailsWrapper>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useState } from "react";
|
|
2
2
|
import styled from "styled-components";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { BmIcons } from "../iconStyles";
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
BmGrey400,
|
|
12
12
|
BmPrimaryGold,
|
|
13
13
|
} from "../../components/colors";
|
|
14
|
+
import { Clear } from "@material-ui/icons";
|
|
14
15
|
|
|
15
16
|
const Color = ({ variant, color }) => {
|
|
16
17
|
if (variant === "success" || variant === "warning" || variant === "danger") {
|
|
@@ -23,11 +24,17 @@ const Color = ({ variant, color }) => {
|
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
const BeemTag = styled.button`
|
|
26
|
-
display: flex;
|
|
27
|
+
${"" /* display: flex; */}
|
|
28
|
+
display: ${({ closeButton, show }) => {
|
|
29
|
+
if (!closeButton) {
|
|
30
|
+
return "flex";
|
|
31
|
+
}
|
|
32
|
+
return show ? "flex" : "none";
|
|
33
|
+
}};
|
|
27
34
|
flex-direction: row;
|
|
28
35
|
justify-content: center;
|
|
29
36
|
align-items: center;
|
|
30
|
-
padding: 0.
|
|
37
|
+
padding: 0.25rem 0.5rem;
|
|
31
38
|
border-radius: 0.25rem;
|
|
32
39
|
background: ${({ variant }) => {
|
|
33
40
|
if (variant === "neutral") return `${BmGrey100}`;
|
|
@@ -57,6 +64,8 @@ const BeemTag = styled.button`
|
|
|
57
64
|
`;
|
|
58
65
|
|
|
59
66
|
export const BmTag = (props) => {
|
|
67
|
+
const [toggle, setToggle] = useState(true);
|
|
68
|
+
|
|
60
69
|
const {
|
|
61
70
|
variant,
|
|
62
71
|
size,
|
|
@@ -65,6 +74,8 @@ export const BmTag = (props) => {
|
|
|
65
74
|
leadingIcon,
|
|
66
75
|
trailingIcon,
|
|
67
76
|
color,
|
|
77
|
+
closeButton,
|
|
78
|
+
onHide,
|
|
68
79
|
...rest
|
|
69
80
|
} = props;
|
|
70
81
|
|
|
@@ -75,6 +86,8 @@ export const BmTag = (props) => {
|
|
|
75
86
|
disabled={disabled}
|
|
76
87
|
children={children}
|
|
77
88
|
color={color}
|
|
89
|
+
closeButton={closeButton}
|
|
90
|
+
show={toggle}
|
|
78
91
|
{...rest}
|
|
79
92
|
>
|
|
80
93
|
{leadingIcon && (
|
|
@@ -82,8 +95,8 @@ export const BmTag = (props) => {
|
|
|
82
95
|
disabled={disabled}
|
|
83
96
|
icon={leadingIcon}
|
|
84
97
|
variant={variant}
|
|
85
|
-
color={Color({color, variant})}
|
|
86
|
-
size={size ||
|
|
98
|
+
color={Color({ color, variant })}
|
|
99
|
+
size={size || "small"}
|
|
87
100
|
/>
|
|
88
101
|
)}
|
|
89
102
|
{children}
|
|
@@ -91,8 +104,17 @@ export const BmTag = (props) => {
|
|
|
91
104
|
<BmIcons
|
|
92
105
|
icon={trailingIcon}
|
|
93
106
|
disabled={disabled}
|
|
94
|
-
color={Color({color, variant})}
|
|
95
|
-
size={size ||
|
|
107
|
+
color={Color({ color, variant })}
|
|
108
|
+
size={size || "small"}
|
|
109
|
+
/>
|
|
110
|
+
)}
|
|
111
|
+
{closeButton && (
|
|
112
|
+
<BmIcons
|
|
113
|
+
icon={<Clear />}
|
|
114
|
+
color={Color({ color, variant })}
|
|
115
|
+
size={size ? size : "small"}
|
|
116
|
+
style={{ marginLeft: "auto" }}
|
|
117
|
+
onClick={() => onHide && onHide(setToggle(!toggle))}
|
|
96
118
|
/>
|
|
97
119
|
)}
|
|
98
120
|
</BeemTag>
|
|
@@ -106,4 +128,5 @@ BmTag.propTypes = {
|
|
|
106
128
|
color: PropTypes.string,
|
|
107
129
|
size: PropTypes.string,
|
|
108
130
|
variant: PropTypes.string,
|
|
109
|
-
|
|
131
|
+
closeButton: PropTypes.bool,
|
|
132
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable import/no-anonymous-default-export */
|
|
2
|
-
import { Favorite
|
|
2
|
+
import { Favorite } from "@material-ui/icons";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { BmTag } from "./tags";
|
|
5
5
|
|
|
@@ -9,7 +9,16 @@ export default {
|
|
|
9
9
|
argTypes: {
|
|
10
10
|
color: {
|
|
11
11
|
control: { type: "text" },
|
|
12
|
-
description:
|
|
12
|
+
description:
|
|
13
|
+
"Color of the Icons and Text, will work only if variant is not present",
|
|
14
|
+
},
|
|
15
|
+
closeButton: {
|
|
16
|
+
control: { type: "boolean" },
|
|
17
|
+
description: "Will display (x) - Optional",
|
|
18
|
+
},
|
|
19
|
+
onHide: {
|
|
20
|
+
description:
|
|
21
|
+
"Handles closing of tags, will only work if closeButton is present (Optional)",
|
|
13
22
|
},
|
|
14
23
|
size: {
|
|
15
24
|
options: ["xsmall", "small", "medium", "large", "xlarge"],
|
|
@@ -26,12 +35,20 @@ export default {
|
|
|
26
35
|
},
|
|
27
36
|
};
|
|
28
37
|
|
|
29
|
-
const
|
|
38
|
+
const MainTag = (args) => <BmTag {...args} />;
|
|
30
39
|
|
|
31
|
-
export const
|
|
32
|
-
|
|
33
|
-
children: <p>
|
|
40
|
+
export const Tags = MainTag.bind({});
|
|
41
|
+
Tags.args = {
|
|
42
|
+
children: <p>Tags</p>,
|
|
34
43
|
leadingIcon: <Favorite />,
|
|
35
44
|
trailingIcon: <Favorite />,
|
|
36
|
-
variant:
|
|
45
|
+
variant: "success",
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const TagsWithCloseButton = () => {
|
|
49
|
+
return (
|
|
50
|
+
<BmTag variant="light" closeButton onHide={() => console.log("Hide Tag")}>
|
|
51
|
+
<p>TAG</p>
|
|
52
|
+
</BmTag>
|
|
53
|
+
);
|
|
37
54
|
};
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = exports.Overlay = exports.ModalWrapper = exports.ModalContent = exports.HeaderWrapper = exports.HeaderText = exports.Close = exports.BmModal = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
|
-
var _icons = require("@material-ui/icons");
|
|
13
|
-
|
|
14
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
-
|
|
16
|
-
var _colors = require("../colors");
|
|
17
|
-
|
|
18
|
-
var _iconStyles = require("../iconStyles");
|
|
19
|
-
|
|
20
|
-
var _excluded = ["children", "show", "size", "centered", "setShowModals"],
|
|
21
|
-
_excluded2 = ["children", "leadingIcon", "trailingIcon", "size", "closeButton", "show"];
|
|
22
|
-
|
|
23
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
|
24
|
-
|
|
25
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
-
|
|
27
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
28
|
-
|
|
29
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
30
|
-
|
|
31
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
32
|
-
|
|
33
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
34
|
-
|
|
35
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
36
|
-
|
|
37
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
38
|
-
|
|
39
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
40
|
-
|
|
41
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
42
|
-
|
|
43
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
44
|
-
|
|
45
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
46
|
-
|
|
47
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
48
|
-
|
|
49
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
50
|
-
|
|
51
|
-
var _React$createContext = /*#__PURE__*/_react.default.createContext(),
|
|
52
|
-
Provider = _React$createContext.Provider,
|
|
53
|
-
Consumer = _React$createContext.Consumer;
|
|
54
|
-
|
|
55
|
-
var Overlay = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n \tposition: fixed;\n top: 0;\n left: 0;\n z-index: 9999;\n width: 100%;\n height: 100%;\n background-color: ", ";\n}\n"])), _colors.BmBgGrey45);
|
|
56
|
-
|
|
57
|
-
exports.Overlay = Overlay;
|
|
58
|
-
|
|
59
|
-
var ModalContent = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n border-radius: 0.25rem;\n padding: 1rem;\n margin: auto;\n background: ", ";\n width: ", ";\n > *:not(:last-child) {\n margin-bottom: 1rem;\n }\n"])), _colors.BmPrimaryWhite, function (_ref) {
|
|
60
|
-
var size = _ref.size;
|
|
61
|
-
|
|
62
|
-
if (size) {
|
|
63
|
-
console.log({
|
|
64
|
-
size: size
|
|
65
|
-
});
|
|
66
|
-
if (size === "small") return "21.429rem";
|
|
67
|
-
if (size === "default") return "35.714rem";
|
|
68
|
-
if (size === "large") return "57.143rem";
|
|
69
|
-
if (size === "xlarge") return "81.429rem";
|
|
70
|
-
return size;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return "35.714rem";
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
exports.ModalContent = ModalContent;
|
|
77
|
-
|
|
78
|
-
var ModalWrapper = _styledComponents.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n z-index: 9999;\n overflow-x: auto;\n overflow-y: auto;\n outline: 0;\n position: fixed;\n height: auto;\n top: ", ";\n left: 50%;\n transform: translate(-50%, -50%);\n"])), function (_ref2) {
|
|
79
|
-
var centered = _ref2.centered;
|
|
80
|
-
|
|
81
|
-
if (centered) {
|
|
82
|
-
return "50%";
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return "10%";
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
exports.ModalWrapper = ModalWrapper;
|
|
89
|
-
|
|
90
|
-
var HeaderWrapper = _styledComponents.default.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n padding: 1.143rem 0rem;\n"])));
|
|
91
|
-
|
|
92
|
-
exports.HeaderWrapper = HeaderWrapper;
|
|
93
|
-
|
|
94
|
-
var HeaderText = _styledComponents.default.h2(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n text-align: center;\n display: flex;\n color: ", ";\n margin-left: auto;\n"])), _colors.BmPrimaryBlack);
|
|
95
|
-
|
|
96
|
-
exports.HeaderText = HeaderText;
|
|
97
|
-
|
|
98
|
-
var Close = _styledComponents.default.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: flex;\n justify-content: flex-end;\n margin-left: auto;\n"])));
|
|
99
|
-
|
|
100
|
-
exports.Close = Close;
|
|
101
|
-
|
|
102
|
-
var BmModal = function BmModal(_ref3) {
|
|
103
|
-
var children = _ref3.children,
|
|
104
|
-
show = _ref3.show,
|
|
105
|
-
size = _ref3.size,
|
|
106
|
-
centered = _ref3.centered,
|
|
107
|
-
setShowModals = _ref3.setShowModals,
|
|
108
|
-
rest = _objectWithoutProperties(_ref3, _excluded);
|
|
109
|
-
|
|
110
|
-
var _useState = (0, _react.useState)(show),
|
|
111
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
112
|
-
toggle = _useState2[0],
|
|
113
|
-
setToggle = _useState2[1];
|
|
114
|
-
|
|
115
|
-
(0, _react.useEffect)(function () {
|
|
116
|
-
setToggle(show);
|
|
117
|
-
}, [show]);
|
|
118
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, toggle && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Overlay, null), /*#__PURE__*/_react.default.createElement(ModalWrapper, {
|
|
119
|
-
showModal: show,
|
|
120
|
-
centered: centered
|
|
121
|
-
}, /*#__PURE__*/_react.default.createElement(Provider, {
|
|
122
|
-
value: {
|
|
123
|
-
toggle: toggle,
|
|
124
|
-
setToggle: setToggle,
|
|
125
|
-
size: size,
|
|
126
|
-
show: show
|
|
127
|
-
}
|
|
128
|
-
}, /*#__PURE__*/_react.default.createElement(ModalContent, _extends({
|
|
129
|
-
size: size
|
|
130
|
-
}, rest), children)))));
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
exports.BmModal = BmModal;
|
|
134
|
-
|
|
135
|
-
var ModalHeader = _styledComponents.default.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n"])));
|
|
136
|
-
|
|
137
|
-
BmModal.Header = function (_ref4) {
|
|
138
|
-
var children = _ref4.children,
|
|
139
|
-
leadingIcon = _ref4.leadingIcon,
|
|
140
|
-
trailingIcon = _ref4.trailingIcon,
|
|
141
|
-
size = _ref4.size,
|
|
142
|
-
closeButton = _ref4.closeButton,
|
|
143
|
-
show = _ref4.show,
|
|
144
|
-
rest = _objectWithoutProperties(_ref4, _excluded2);
|
|
145
|
-
|
|
146
|
-
return /*#__PURE__*/_react.default.createElement(Consumer, null, function (value) {
|
|
147
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(ModalHeader, rest, JSON.stringify(value), children, closeButton && /*#__PURE__*/_react.default.createElement(_iconStyles.BmIcons, _extends({
|
|
148
|
-
size: "xlarge",
|
|
149
|
-
icon: /*#__PURE__*/_react.default.createElement(_icons.Clear, null),
|
|
150
|
-
onClick: function onClick() {
|
|
151
|
-
return value.setToggle(!value.toggle);
|
|
152
|
-
}
|
|
153
|
-
}, rest))));
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
BmModal.Body = _styledComponents.default.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n"])));
|
|
158
|
-
BmModal.Footer = _styledComponents.default.div(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n display: flex;\n justify-content: space-between;\n"])));
|
|
159
|
-
var _default = BmModal;
|
|
160
|
-
exports.default = _default;
|