@bigbinary/neetoui-rn 0.0.269 → 0.0.271
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/lib/components/Accordion.js +1 -1
- package/lib/components/ActionIcon.js +1 -1
- package/lib/components/Alert.js +1 -1
- package/lib/components/AnimatedImage.js +1 -1
- package/lib/components/Avatar.js +1 -1
- package/lib/components/Badge.js +1 -1
- package/lib/components/BottomSheet.js +1 -1
- package/lib/components/BottomTabBar.js +1 -1
- package/lib/components/Button.js +1 -1
- package/lib/components/ButtonGroup.js +1 -1
- package/lib/components/Calendar.js +1 -1
- package/lib/components/Card.js +1 -1
- package/lib/components/Carousel.js +1 -1
- package/lib/components/ChatInput/AttachmentsView.js +1 -1
- package/lib/components/ChatInput/Badge.js +1 -1
- package/lib/components/ChatInput/ChatInput.js +1 -1
- package/lib/components/ChatInput/EmailFields.js +1 -1
- package/lib/components/ChatInput/IconButton.js +1 -1
- package/lib/components/ChatInput/MentionsInputWrapper.js +1 -1
- package/lib/components/CheckBox.js +1 -1
- package/lib/components/Chip.js +1 -1
- package/lib/components/Container.js +1 -1
- package/lib/components/Divider.js +1 -1
- package/lib/components/FAB.js +1 -1
- package/lib/components/FlashList.js +1 -1
- package/lib/components/FlatList.js +1 -1
- package/lib/components/Input.js +1 -1
- package/lib/components/InputEmailChip.js +1 -1
- package/lib/components/LineLoader.js +1 -1
- package/lib/components/ListItem.js +1 -1
- package/lib/components/Loader.js +1 -1
- package/lib/components/MultiSelect.js +1 -1
- package/lib/components/NotificationIcon.js +1 -1
- package/lib/components/NotificationPreferenceList.js +1 -1
- package/lib/components/OnBoarding.js +1 -1
- package/lib/components/OrganizationItem.js +1 -1
- package/lib/components/OtpInputs.js +1 -1
- package/lib/components/ParentView.js +1 -1
- package/lib/components/Popover.js +1 -1
- package/lib/components/RadioButton.js +1 -1
- package/lib/components/RichTextEditor.js +1 -1
- package/lib/components/Ripple.js +1 -1
- package/lib/components/ScrollView.js +1 -1
- package/lib/components/SearchBar.js +1 -1
- package/lib/components/SegmentedTopBar/Indicator.js +1 -1
- package/lib/components/SegmentedTopBar/Tab.js +1 -1
- package/lib/components/SegmentedTopBar/index.js +1 -1
- package/lib/components/SocialButton.js +1 -1
- package/lib/components/Toast.js +1 -1
- package/lib/components/ToggleSwitch.js +1 -1
- package/lib/components/TopBar.js +1 -1
- package/lib/components/Touchable.js +1 -1
- package/lib/components/TouchableWithoutFeedback.js +1 -1
- package/lib/components/Typography.js +1 -1
- package/lib/components/index.js +1 -1
- package/lib/config/toasterConfig.js +1 -1
- package/lib/contexts/index.js +1 -1
- package/lib/theme/index.js +1 -1
- package/lib/utils/utils.js +1 -1
- package/package.json +22 -15
- package/src/components/Accordion.jsx +0 -266
- package/src/components/ActionIcon.jsx +0 -76
- package/src/components/Alert.jsx +0 -262
- package/src/components/AnimatedImage.jsx +0 -140
- package/src/components/Avatar.jsx +0 -144
- package/src/components/Badge.jsx +0 -97
- package/src/components/BottomSheet.jsx +0 -487
- package/src/components/BottomTabBar.jsx +0 -232
- package/src/components/Button.jsx +0 -275
- package/src/components/ButtonGroup.jsx +0 -120
- package/src/components/Calendar.jsx +0 -128
- package/src/components/Card.jsx +0 -90
- package/src/components/Carousel.jsx +0 -116
- package/src/components/ChatInput/AttachmentsView.jsx +0 -51
- package/src/components/ChatInput/Badge.jsx +0 -24
- package/src/components/ChatInput/ChatInput.jsx +0 -564
- package/src/components/ChatInput/EmailFields.jsx +0 -122
- package/src/components/ChatInput/IconButton.jsx +0 -34
- package/src/components/ChatInput/MentionsInputWrapper.jsx +0 -155
- package/src/components/CheckBox.jsx +0 -150
- package/src/components/Chip.jsx +0 -180
- package/src/components/Container.jsx +0 -31
- package/src/components/Divider.jsx +0 -79
- package/src/components/FAB.jsx +0 -113
- package/src/components/FlashList.jsx +0 -189
- package/src/components/FlatList.js +0 -10
- package/src/components/Input.jsx +0 -357
- package/src/components/InputEmailChip.jsx +0 -246
- package/src/components/LineLoader.jsx +0 -46
- package/src/components/ListItem.jsx +0 -68
- package/src/components/Loader.jsx +0 -122
- package/src/components/MultiSelect.jsx +0 -631
- package/src/components/NotificationIcon.jsx +0 -38
- package/src/components/NotificationPreferenceList.jsx +0 -208
- package/src/components/OnBoarding.jsx +0 -134
- package/src/components/OrganizationItem.jsx +0 -110
- package/src/components/OtpInputs.jsx +0 -194
- package/src/components/ParentView.jsx +0 -139
- package/src/components/Popover.jsx +0 -221
- package/src/components/RadioButton.jsx +0 -155
- package/src/components/RichTextEditor.jsx +0 -163
- package/src/components/Ripple.jsx +0 -281
- package/src/components/ScrollView.js +0 -14
- package/src/components/SearchBar.jsx +0 -207
- package/src/components/SegmentedTopBar/Indicator.jsx +0 -77
- package/src/components/SegmentedTopBar/Tab.jsx +0 -37
- package/src/components/SegmentedTopBar/index.jsx +0 -128
- package/src/components/SocialButton.jsx +0 -106
- package/src/components/Toast.jsx +0 -195
- package/src/components/ToggleSwitch.jsx +0 -112
- package/src/components/TopBar.jsx +0 -147
- package/src/components/Touchable.jsx +0 -133
- package/src/components/TouchableWithoutFeedback.jsx +0 -51
- package/src/components/Typography.jsx +0 -93
- package/src/components/index.js +0 -45
- package/src/config/index.js +0 -1
- package/src/config/toasterConfig.jsx +0 -142
- package/src/contexts/index.js +0 -3
- package/src/hooks/index.js +0 -3
- package/src/hooks/useDebounce.js +0 -17
- package/src/hooks/useKeyboard.js +0 -33
- package/src/hooks/useRefreshByUser.js +0 -20
- package/src/index.js +0 -2
- package/src/theme/index.js +0 -181
- package/src/utils/utils.js +0 -56
|
@@ -1,564 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useEffect,
|
|
3
|
-
useRef,
|
|
4
|
-
useCallback,
|
|
5
|
-
useState,
|
|
6
|
-
forwardRef,
|
|
7
|
-
useImperativeHandle,
|
|
8
|
-
} from "react";
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
ChatBubble,
|
|
12
|
-
Notes,
|
|
13
|
-
Attachment,
|
|
14
|
-
Forward,
|
|
15
|
-
CannedResponses,
|
|
16
|
-
Down,
|
|
17
|
-
} from "@bigbinary/neeto-icons-rn";
|
|
18
|
-
import { parse } from "node-html-parser";
|
|
19
|
-
import PropTypes from "prop-types";
|
|
20
|
-
import { moderateScale } from "react-native-size-matters";
|
|
21
|
-
|
|
22
|
-
import ExpandSVG from "@assets/icons/expand.svg";
|
|
23
|
-
import MinimizeSVG from "@assets/icons/minimize.svg";
|
|
24
|
-
import { Container, LineLoader, Popover, Button } from "@components";
|
|
25
|
-
|
|
26
|
-
import { AttachmentsView } from "./AttachmentsView";
|
|
27
|
-
import { EmailFields } from "./EmailFields";
|
|
28
|
-
import { IconButton } from "./IconButton";
|
|
29
|
-
import { MentionsInputWrapper } from "./MentionsInputWrapper";
|
|
30
|
-
|
|
31
|
-
import { theme } from "../../theme";
|
|
32
|
-
|
|
33
|
-
// eslint-disable-next-line @bigbinary/neeto/no-dangling-constants
|
|
34
|
-
const OPTION_TYPES = {
|
|
35
|
-
REPLY: "REPLY",
|
|
36
|
-
NOTE: "NOTE",
|
|
37
|
-
FORWARD: "FORWARD",
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const placeholders = {
|
|
41
|
-
[OPTION_TYPES.REPLY]: "Type here to reply…",
|
|
42
|
-
[OPTION_TYPES.NOTE]: "Add note here…",
|
|
43
|
-
[OPTION_TYPES.FORWARD]: "Type here to forward…",
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const labels = {
|
|
47
|
-
[OPTION_TYPES.REPLY]: "Reply",
|
|
48
|
-
[OPTION_TYPES.NOTE]: "Add note",
|
|
49
|
-
[OPTION_TYPES.FORWARD]: "Forward",
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* ChatInput component supports various options like `REPLY`, `NOTE` and `FORWARD`.
|
|
54
|
-
* This component supports below props categories from [styled-system ](/styled-system).
|
|
55
|
-
* <ul>
|
|
56
|
-
* <li>flexbox</li>
|
|
57
|
-
* <li>space</li>
|
|
58
|
-
* <li>border</li>
|
|
59
|
-
* <li>buttonStyle</li>
|
|
60
|
-
* <li>brandLeft</li>
|
|
61
|
-
* <li>typography</li>
|
|
62
|
-
* </ul>
|
|
63
|
-
*
|
|
64
|
-
* <div class="screenshots">
|
|
65
|
-
* <img src="screenshots/chatInput/chatInput.png" />
|
|
66
|
-
* </div>
|
|
67
|
-
*
|
|
68
|
-
* ## Usage
|
|
69
|
-
* ```js
|
|
70
|
-
* import * as React from 'react';
|
|
71
|
-
* import { Typography, ChatInput, Container } from '@bigbinary/neetoui-rn';
|
|
72
|
-
*
|
|
73
|
-
* export default function Main() {
|
|
74
|
-
* const [value, setValue] = React.useState(
|
|
75
|
-
* "Hey Oliver, We are working on this issue. We will keep you update");
|
|
76
|
-
*
|
|
77
|
-
* return (
|
|
78
|
-
* <Container flex={1}>
|
|
79
|
-
* <Container alignItems="center" flex={1} justifyContent="center">
|
|
80
|
-
* <Typography> Desk Example</Typography>
|
|
81
|
-
* </Container>
|
|
82
|
-
* <Container align-self="end">
|
|
83
|
-
* <ChatInput
|
|
84
|
-
* shouldShowEmailFields
|
|
85
|
-
* attachmentsCount={2}
|
|
86
|
-
* toEmails="oliver@example.com"
|
|
87
|
-
* value={value}
|
|
88
|
-
* Attachments={
|
|
89
|
-
* <Container alignItems="flex-start">
|
|
90
|
-
* <AnimatedImage
|
|
91
|
-
* imageHeight={30}
|
|
92
|
-
* imageUrl="https://picsum.photos/255/139"
|
|
93
|
-
* imageWidth={30}
|
|
94
|
-
* resizeMode="cover"
|
|
95
|
-
* />
|
|
96
|
-
* </Container>
|
|
97
|
-
* }
|
|
98
|
-
* onChangeText={setValue}
|
|
99
|
-
* onCannedResponse={() => {
|
|
100
|
-
* alert("On Canned Response");
|
|
101
|
-
* }}
|
|
102
|
-
* onForward={() => {
|
|
103
|
-
* alert("On Forward");
|
|
104
|
-
* }}
|
|
105
|
-
* />
|
|
106
|
-
* </Container>
|
|
107
|
-
* </Container>
|
|
108
|
-
* );
|
|
109
|
-
* }
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
const convertMentionsToHTMLAndPlainText = ({ suggestions, value }) => {
|
|
114
|
-
const mentionsRegex = new RegExp(/@\[[^)]*\)/g);
|
|
115
|
-
let html = `<p>${value}</p>`;
|
|
116
|
-
let plainText = value;
|
|
117
|
-
const allMentions = html.matchAll(mentionsRegex);
|
|
118
|
-
|
|
119
|
-
for (const mentionObject of allMentions) {
|
|
120
|
-
const mention = mentionObject[0];
|
|
121
|
-
const id = /\((.*)\)/.exec(mention)[1];
|
|
122
|
-
|
|
123
|
-
const suggestion = suggestions.find(suggestion => suggestion.id === id);
|
|
124
|
-
|
|
125
|
-
const rootNode = parse("<span></span>");
|
|
126
|
-
const spanNode = rootNode.querySelector("span");
|
|
127
|
-
|
|
128
|
-
spanNode.setAttribute("data-type", "mention");
|
|
129
|
-
spanNode.setAttribute("data-id", id);
|
|
130
|
-
spanNode.setAttribute("data-label", suggestion.name);
|
|
131
|
-
spanNode.set_content(`@${suggestion.name}`);
|
|
132
|
-
const rootNodeString = rootNode.toString();
|
|
133
|
-
html = html.replace(mention, rootNodeString);
|
|
134
|
-
|
|
135
|
-
const plainTextMention = `@${suggestion.name}`;
|
|
136
|
-
plainText = plainText.replace(mention, plainTextMention);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return { html, plainText };
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
export const ChatInput = forwardRef(
|
|
143
|
-
(
|
|
144
|
-
{
|
|
145
|
-
shouldShowEmailFields,
|
|
146
|
-
showReplyMenuOptions,
|
|
147
|
-
value = "",
|
|
148
|
-
onChangeText = () => {},
|
|
149
|
-
onForward,
|
|
150
|
-
onCannedResponse,
|
|
151
|
-
toEmails: initialToEmails,
|
|
152
|
-
onReply = () => {},
|
|
153
|
-
onAddNote = () => {},
|
|
154
|
-
onAttachment = () => {},
|
|
155
|
-
attachmentsCount,
|
|
156
|
-
Attachments,
|
|
157
|
-
showCannedResponsesFor = [OPTION_TYPES.REPLY],
|
|
158
|
-
showSuggestionsFor = [OPTION_TYPES.NOTE],
|
|
159
|
-
disabled,
|
|
160
|
-
isLoading = true,
|
|
161
|
-
onOptionChange = () => {},
|
|
162
|
-
initialSelectedOption = OPTION_TYPES.REPLY,
|
|
163
|
-
suggestions,
|
|
164
|
-
...rest
|
|
165
|
-
},
|
|
166
|
-
ref
|
|
167
|
-
) => {
|
|
168
|
-
const inputRef = useRef();
|
|
169
|
-
|
|
170
|
-
const [selectedOption, setSelectedOption] = useState(initialSelectedOption);
|
|
171
|
-
const [isEmailFieldsVisible, setIsEmailFieldsVisible] = useState(false);
|
|
172
|
-
const [isAttachmentsVisible, setIsAttachmentsVisible] = useState(false);
|
|
173
|
-
|
|
174
|
-
const isReplyOptionSelected = selectedOption === OPTION_TYPES.REPLY;
|
|
175
|
-
const isNoteOptionSelected = selectedOption === OPTION_TYPES.NOTE;
|
|
176
|
-
const isForwardOptionSelected = selectedOption === OPTION_TYPES.FORWARD;
|
|
177
|
-
|
|
178
|
-
const [toEmails, setToEmails] = useState(initialToEmails ?? []);
|
|
179
|
-
const [toEmailsForForward, setToEmailsForForward] = useState([]);
|
|
180
|
-
const [ccEmails, setCcEmails] = useState([]);
|
|
181
|
-
const [bccEmails, setBccEmails] = useState([]);
|
|
182
|
-
|
|
183
|
-
const moreReplyOptions = [
|
|
184
|
-
{
|
|
185
|
-
label: "Send and set as closed",
|
|
186
|
-
Icon: () => null,
|
|
187
|
-
onPress: () => {
|
|
188
|
-
onReply({
|
|
189
|
-
toEmails,
|
|
190
|
-
ccEmails,
|
|
191
|
-
bccEmails,
|
|
192
|
-
status: "closed",
|
|
193
|
-
...convertMentionsToHTMLAndPlainText({ suggestions, value }),
|
|
194
|
-
});
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
];
|
|
198
|
-
|
|
199
|
-
useImperativeHandle(
|
|
200
|
-
ref,
|
|
201
|
-
() => ({
|
|
202
|
-
clearEmailFields: () => {
|
|
203
|
-
setToEmails(initialToEmails ?? []);
|
|
204
|
-
setToEmailsForForward([]);
|
|
205
|
-
setCcEmails([]);
|
|
206
|
-
setBccEmails([]);
|
|
207
|
-
inputRef.current.blur();
|
|
208
|
-
},
|
|
209
|
-
}),
|
|
210
|
-
[initialToEmails, isReplyOptionSelected]
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
useEffect(() => {
|
|
214
|
-
onOptionChange(selectedOption);
|
|
215
|
-
}, [selectedOption]);
|
|
216
|
-
|
|
217
|
-
useEffect(() => {
|
|
218
|
-
setSelectedOption(initialSelectedOption);
|
|
219
|
-
}, [initialSelectedOption]);
|
|
220
|
-
|
|
221
|
-
useEffect(() => {
|
|
222
|
-
setToEmails(initialToEmails ?? []);
|
|
223
|
-
}, [initialToEmails]);
|
|
224
|
-
|
|
225
|
-
const showEmailFieldsAndAttachments = () => {
|
|
226
|
-
setIsAttachmentsVisible(true);
|
|
227
|
-
setIsEmailFieldsVisible(true);
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
const hideEmailFieldsAndAttachments = () => {
|
|
231
|
-
setIsAttachmentsVisible(false);
|
|
232
|
-
setIsEmailFieldsVisible(false);
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
const onReplyClickHandler = () => {
|
|
236
|
-
hideEmailFieldsAndAttachments();
|
|
237
|
-
inputRef.current.focus();
|
|
238
|
-
setSelectedOption(OPTION_TYPES.REPLY);
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
const onAddNoteClickHandler = () => {
|
|
242
|
-
hideEmailFieldsAndAttachments();
|
|
243
|
-
inputRef.current.focus();
|
|
244
|
-
setIsEmailFieldsVisible(false);
|
|
245
|
-
setSelectedOption(OPTION_TYPES.NOTE);
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
const onAddForwardClickHandler = () => {
|
|
249
|
-
inputRef.current.focus();
|
|
250
|
-
setIsEmailFieldsVisible(true);
|
|
251
|
-
setIsAttachmentsVisible(false);
|
|
252
|
-
setSelectedOption(OPTION_TYPES.FORWARD);
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
const onAddAttachmentsClickHandler = () => {
|
|
256
|
-
if (!isAttachmentsVisible && attachmentsCount > 0) {
|
|
257
|
-
// When attachments are not visible but there are few attachments then we no need to show the upload modal.
|
|
258
|
-
} else {
|
|
259
|
-
onAttachment();
|
|
260
|
-
}
|
|
261
|
-
setIsEmailFieldsVisible(false);
|
|
262
|
-
setIsAttachmentsVisible(true);
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
const onActionHandler = useCallback(() => {
|
|
266
|
-
({
|
|
267
|
-
[OPTION_TYPES.REPLY]: () => {
|
|
268
|
-
onReply({
|
|
269
|
-
toEmails,
|
|
270
|
-
ccEmails,
|
|
271
|
-
bccEmails,
|
|
272
|
-
...convertMentionsToHTMLAndPlainText({ suggestions, value }),
|
|
273
|
-
});
|
|
274
|
-
},
|
|
275
|
-
[OPTION_TYPES.NOTE]: () => {
|
|
276
|
-
onAddNote({
|
|
277
|
-
toEmails,
|
|
278
|
-
ccEmails,
|
|
279
|
-
bccEmails,
|
|
280
|
-
...convertMentionsToHTMLAndPlainText({ suggestions, value }),
|
|
281
|
-
});
|
|
282
|
-
},
|
|
283
|
-
[OPTION_TYPES.FORWARD]: () => {
|
|
284
|
-
onForward({
|
|
285
|
-
toEmails: toEmailsForForward,
|
|
286
|
-
ccEmails,
|
|
287
|
-
bccEmails,
|
|
288
|
-
...convertMentionsToHTMLAndPlainText({ suggestions, value }),
|
|
289
|
-
});
|
|
290
|
-
},
|
|
291
|
-
}[selectedOption]());
|
|
292
|
-
}, [
|
|
293
|
-
bccEmails,
|
|
294
|
-
ccEmails,
|
|
295
|
-
onAddNote,
|
|
296
|
-
onForward,
|
|
297
|
-
onReply,
|
|
298
|
-
selectedOption,
|
|
299
|
-
suggestions,
|
|
300
|
-
toEmails,
|
|
301
|
-
value,
|
|
302
|
-
]);
|
|
303
|
-
|
|
304
|
-
const shouldShowExpandAndMinimizeButton =
|
|
305
|
-
attachmentsCount > 0 || toEmails.length > 0;
|
|
306
|
-
|
|
307
|
-
const shouldDisableWhenForwardAndToFieldMissing =
|
|
308
|
-
isForwardOptionSelected && toEmailsForForward.length === 0;
|
|
309
|
-
|
|
310
|
-
return (
|
|
311
|
-
<Container>
|
|
312
|
-
<LineLoader
|
|
313
|
-
backgroundColor={theme.colors.background.grey400}
|
|
314
|
-
isLoading={isLoading}
|
|
315
|
-
/>
|
|
316
|
-
<Container
|
|
317
|
-
bg={isNoteOptionSelected ? "background.oldLace" : "transparent"}
|
|
318
|
-
p={moderateScale(5)}
|
|
319
|
-
pt={0}
|
|
320
|
-
px={moderateScale(16)}
|
|
321
|
-
>
|
|
322
|
-
<Container pt={moderateScale(8)}>
|
|
323
|
-
<EmailFields
|
|
324
|
-
bccEmails={bccEmails}
|
|
325
|
-
ccEmails={ccEmails}
|
|
326
|
-
isEmailFieldsVisible={isEmailFieldsVisible}
|
|
327
|
-
isForwardOptionSelected={isForwardOptionSelected}
|
|
328
|
-
isNoteOptionSelected={isNoteOptionSelected}
|
|
329
|
-
isReplyOptionSelected={isReplyOptionSelected}
|
|
330
|
-
setBccEmails={setBccEmails}
|
|
331
|
-
setCcEmails={setCcEmails}
|
|
332
|
-
setIsEmailFieldsVisible={setIsEmailFieldsVisible}
|
|
333
|
-
setToEmails={setToEmails}
|
|
334
|
-
setToEmailsForForward={setToEmailsForForward}
|
|
335
|
-
shouldShowEmailFields={shouldShowEmailFields}
|
|
336
|
-
toEmails={toEmails}
|
|
337
|
-
toEmailsForForward={toEmailsForForward}
|
|
338
|
-
/>
|
|
339
|
-
<Container flexDirection="row" justifyContent="space-between">
|
|
340
|
-
<MentionsInputWrapper
|
|
341
|
-
placeholder={placeholders[selectedOption]}
|
|
342
|
-
ref={inputRef}
|
|
343
|
-
suggestions={suggestions}
|
|
344
|
-
value={value}
|
|
345
|
-
shouldShowSuggestions={showSuggestionsFor.includes(
|
|
346
|
-
selectedOption
|
|
347
|
-
)}
|
|
348
|
-
onChange={onChangeText}
|
|
349
|
-
onTouchStart={hideEmailFieldsAndAttachments}
|
|
350
|
-
{...rest}
|
|
351
|
-
/>
|
|
352
|
-
<Container alignSelf="center">
|
|
353
|
-
{shouldShowExpandAndMinimizeButton &&
|
|
354
|
-
(isEmailFieldsVisible || isAttachmentsVisible ? (
|
|
355
|
-
<IconButton
|
|
356
|
-
Icon={MinimizeSVG}
|
|
357
|
-
height={moderateScale(30)}
|
|
358
|
-
pt={moderateScale(8)}
|
|
359
|
-
width={moderateScale(30)}
|
|
360
|
-
onPress={hideEmailFieldsAndAttachments}
|
|
361
|
-
/>
|
|
362
|
-
) : (
|
|
363
|
-
<IconButton
|
|
364
|
-
Icon={ExpandSVG}
|
|
365
|
-
height={moderateScale(30)}
|
|
366
|
-
pt={moderateScale(8)}
|
|
367
|
-
width={moderateScale(30)}
|
|
368
|
-
onPress={showEmailFieldsAndAttachments}
|
|
369
|
-
/>
|
|
370
|
-
))}
|
|
371
|
-
</Container>
|
|
372
|
-
</Container>
|
|
373
|
-
<AttachmentsView
|
|
374
|
-
Attachments={Attachments}
|
|
375
|
-
attachmentsCount={attachmentsCount}
|
|
376
|
-
isAttachmentsVisible={isAttachmentsVisible}
|
|
377
|
-
isNoteOptionSelected={isNoteOptionSelected}
|
|
378
|
-
setIsAttachmentsVisible={setIsAttachmentsVisible}
|
|
379
|
-
/>
|
|
380
|
-
<Container
|
|
381
|
-
alignItems="center"
|
|
382
|
-
flexDirection="row"
|
|
383
|
-
justifyContent="space-between"
|
|
384
|
-
mt={moderateScale(10)}
|
|
385
|
-
>
|
|
386
|
-
<Container flexDirection="row" justifyContent="space-between">
|
|
387
|
-
<IconButton
|
|
388
|
-
Icon={ChatBubble}
|
|
389
|
-
opacity={isReplyOptionSelected ? 1 : 0.5}
|
|
390
|
-
pl={moderateScale(10)}
|
|
391
|
-
iconProps={{
|
|
392
|
-
viewBox: "0 0 37 37",
|
|
393
|
-
size: moderateScale(30),
|
|
394
|
-
color: theme.colors.font.grey500,
|
|
395
|
-
}}
|
|
396
|
-
onPress={onReplyClickHandler}
|
|
397
|
-
/>
|
|
398
|
-
<IconButton
|
|
399
|
-
Icon={Notes}
|
|
400
|
-
opacity={isNoteOptionSelected ? 1 : 0.5}
|
|
401
|
-
onPress={onAddNoteClickHandler}
|
|
402
|
-
/>
|
|
403
|
-
{onForward && (
|
|
404
|
-
<IconButton
|
|
405
|
-
Icon={Forward}
|
|
406
|
-
opacity={isForwardOptionSelected ? 1 : 0.5}
|
|
407
|
-
onPress={onAddForwardClickHandler}
|
|
408
|
-
/>
|
|
409
|
-
)}
|
|
410
|
-
<Container
|
|
411
|
-
bg="background.grey400"
|
|
412
|
-
mx={moderateScale(5)}
|
|
413
|
-
p={moderateScale(0.4)}
|
|
414
|
-
/>
|
|
415
|
-
{onCannedResponse &&
|
|
416
|
-
showCannedResponsesFor.includes(selectedOption) && (
|
|
417
|
-
<IconButton
|
|
418
|
-
Icon={CannedResponses}
|
|
419
|
-
opacity={0.5}
|
|
420
|
-
iconProps={{
|
|
421
|
-
viewBox: "0 0 38 38",
|
|
422
|
-
size: moderateScale(30),
|
|
423
|
-
}}
|
|
424
|
-
onPress={onCannedResponse}
|
|
425
|
-
/>
|
|
426
|
-
)}
|
|
427
|
-
<IconButton
|
|
428
|
-
Icon={Attachment}
|
|
429
|
-
opacity={0.5}
|
|
430
|
-
onPress={onAddAttachmentsClickHandler}
|
|
431
|
-
/>
|
|
432
|
-
</Container>
|
|
433
|
-
<Container alignItems="center" flexDirection="row">
|
|
434
|
-
<Button
|
|
435
|
-
height={moderateScale(30)}
|
|
436
|
-
label={labels[selectedOption]}
|
|
437
|
-
pr={0}
|
|
438
|
-
variant="text"
|
|
439
|
-
disabled={
|
|
440
|
-
shouldDisableWhenForwardAndToFieldMissing || disabled
|
|
441
|
-
}
|
|
442
|
-
labelStyle={{
|
|
443
|
-
mx: moderateScale(0),
|
|
444
|
-
}}
|
|
445
|
-
onPress={onActionHandler}
|
|
446
|
-
/>
|
|
447
|
-
{showReplyMenuOptions && isReplyOptionSelected && (
|
|
448
|
-
<Popover
|
|
449
|
-
data={moreReplyOptions}
|
|
450
|
-
from={
|
|
451
|
-
<Button
|
|
452
|
-
disabled={disabled}
|
|
453
|
-
height={moderateScale(30)}
|
|
454
|
-
label=""
|
|
455
|
-
p={0}
|
|
456
|
-
variant="text"
|
|
457
|
-
RightIcon={() => (
|
|
458
|
-
<Down
|
|
459
|
-
color={theme.colors.background.grey800}
|
|
460
|
-
size={moderateScale(22)}
|
|
461
|
-
/>
|
|
462
|
-
)}
|
|
463
|
-
/>
|
|
464
|
-
}
|
|
465
|
-
/>
|
|
466
|
-
)}
|
|
467
|
-
</Container>
|
|
468
|
-
</Container>
|
|
469
|
-
</Container>
|
|
470
|
-
</Container>
|
|
471
|
-
</Container>
|
|
472
|
-
);
|
|
473
|
-
}
|
|
474
|
-
);
|
|
475
|
-
|
|
476
|
-
ChatInput.displayName = "ChatInput";
|
|
477
|
-
ChatInput.propTypes = {
|
|
478
|
-
/**
|
|
479
|
-
* If true, Shows loader
|
|
480
|
-
*/
|
|
481
|
-
isLoading: PropTypes.bool,
|
|
482
|
-
/**
|
|
483
|
-
* If true, Shows to, cc and bcc email inputs.
|
|
484
|
-
*/
|
|
485
|
-
shouldShowEmailFields: PropTypes.bool,
|
|
486
|
-
/**
|
|
487
|
-
* If true, Shows reply menu options
|
|
488
|
-
*/
|
|
489
|
-
showReplyMenuOptions: PropTypes.bool,
|
|
490
|
-
/**
|
|
491
|
-
* Value to make input component controllable.
|
|
492
|
-
*/
|
|
493
|
-
value: PropTypes.string,
|
|
494
|
-
/**
|
|
495
|
-
* To set the initial selected option
|
|
496
|
-
*/
|
|
497
|
-
initialSelectedOption: PropTypes.oneOf(Object.values(OPTION_TYPES)),
|
|
498
|
-
/**
|
|
499
|
-
* Callback to be called when user selection option.
|
|
500
|
-
*/
|
|
501
|
-
onOptionChange: PropTypes.func,
|
|
502
|
-
/**
|
|
503
|
-
* Callback to be called when the input text changes.
|
|
504
|
-
*/
|
|
505
|
-
onChangeText: PropTypes.func,
|
|
506
|
-
/**
|
|
507
|
-
* Callback to be called on click of forward icon.
|
|
508
|
-
*/
|
|
509
|
-
onForward: PropTypes.func,
|
|
510
|
-
/**
|
|
511
|
-
* Callback to be called on click of canned responses icon.
|
|
512
|
-
*/
|
|
513
|
-
onCannedResponse: PropTypes.func,
|
|
514
|
-
/**
|
|
515
|
-
* Email list separated by comma.
|
|
516
|
-
*/
|
|
517
|
-
toEmails: PropTypes.arrayOf(PropTypes.string),
|
|
518
|
-
/**
|
|
519
|
-
* Callback to be called on click of reply icon.
|
|
520
|
-
*/
|
|
521
|
-
onReply: PropTypes.func,
|
|
522
|
-
/**
|
|
523
|
-
* Callback to be called on click of add note icon.
|
|
524
|
-
*/
|
|
525
|
-
onAddNote: PropTypes.func,
|
|
526
|
-
/**
|
|
527
|
-
* Callback to be called on click of attachment icon.
|
|
528
|
-
*/
|
|
529
|
-
onAttachment: PropTypes.func,
|
|
530
|
-
/**
|
|
531
|
-
* Count of attachments.
|
|
532
|
-
*/
|
|
533
|
-
attachmentsCount: PropTypes.number,
|
|
534
|
-
/**
|
|
535
|
-
* Component to render attachments.
|
|
536
|
-
*/
|
|
537
|
-
Attachments: PropTypes.any,
|
|
538
|
-
/**
|
|
539
|
-
* Array for options to show canned responses. Example: ["REPLY","NOTES","FORWARD"]
|
|
540
|
-
*/
|
|
541
|
-
showCannedResponsesFor: PropTypes.arrayOf(
|
|
542
|
-
PropTypes.oneOf(Object.values(OPTION_TYPES))
|
|
543
|
-
),
|
|
544
|
-
/**
|
|
545
|
-
* Array for options to show suggestions. Example: ["REPLY","NOTES","FORWARD"]
|
|
546
|
-
*/
|
|
547
|
-
showSuggestionsFor: PropTypes.arrayOf(
|
|
548
|
-
PropTypes.oneOf(Object.values(OPTION_TYPES))
|
|
549
|
-
),
|
|
550
|
-
/**
|
|
551
|
-
* If true, Disables the reply, forward and add note button.
|
|
552
|
-
*/
|
|
553
|
-
disabled: PropTypes.bool,
|
|
554
|
-
/**
|
|
555
|
-
* List of mentions
|
|
556
|
-
*/
|
|
557
|
-
suggestions: PropTypes.arrayOf(
|
|
558
|
-
PropTypes.shape({
|
|
559
|
-
name: PropTypes.string,
|
|
560
|
-
imageUrl: PropTypes.string,
|
|
561
|
-
id: PropTypes.string,
|
|
562
|
-
})
|
|
563
|
-
),
|
|
564
|
-
};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import Animated, { FadeInDown, FadeInUp } from "react-native-reanimated";
|
|
5
|
-
import { moderateScale } from "react-native-size-matters";
|
|
6
|
-
|
|
7
|
-
import { InputEmailChip } from "@components";
|
|
8
|
-
|
|
9
|
-
import { Badge } from "./Badge";
|
|
10
|
-
|
|
11
|
-
export const EmailFields = ({
|
|
12
|
-
shouldShowEmailFields,
|
|
13
|
-
setIsEmailFieldsVisible,
|
|
14
|
-
isEmailFieldsVisible,
|
|
15
|
-
toEmails,
|
|
16
|
-
toEmailsForForward,
|
|
17
|
-
ccEmails,
|
|
18
|
-
bccEmails,
|
|
19
|
-
setToEmails,
|
|
20
|
-
setToEmailsForForward,
|
|
21
|
-
setBccEmails,
|
|
22
|
-
setCcEmails,
|
|
23
|
-
isReplyOptionSelected,
|
|
24
|
-
isNoteOptionSelected,
|
|
25
|
-
isForwardOptionSelected,
|
|
26
|
-
}) => {
|
|
27
|
-
const firstToEmail = isReplyOptionSelected
|
|
28
|
-
? toEmails[0]
|
|
29
|
-
: toEmailsForForward[0];
|
|
30
|
-
|
|
31
|
-
let badge = "";
|
|
32
|
-
if (firstToEmail) {
|
|
33
|
-
badge = `To ${firstToEmail}`;
|
|
34
|
-
} else if (isForwardOptionSelected) {
|
|
35
|
-
badge = "Click here to enter email id.";
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const totalEmailsMinus1 =
|
|
39
|
-
toEmails.length +
|
|
40
|
-
toEmailsForForward.length +
|
|
41
|
-
ccEmails.length +
|
|
42
|
-
bccEmails.length -
|
|
43
|
-
1;
|
|
44
|
-
|
|
45
|
-
if (!shouldShowEmailFields) return null;
|
|
46
|
-
|
|
47
|
-
return isEmailFieldsVisible ? (
|
|
48
|
-
<Animated.View
|
|
49
|
-
entering={FadeInDown}
|
|
50
|
-
key={isEmailFieldsVisible}
|
|
51
|
-
pb={moderateScale(10)}
|
|
52
|
-
>
|
|
53
|
-
{isReplyOptionSelected && (
|
|
54
|
-
<InputEmailChip
|
|
55
|
-
disabled
|
|
56
|
-
emails={toEmails}
|
|
57
|
-
label="To:"
|
|
58
|
-
onUpdate={setToEmails}
|
|
59
|
-
/>
|
|
60
|
-
)}
|
|
61
|
-
{isForwardOptionSelected && (
|
|
62
|
-
<InputEmailChip
|
|
63
|
-
disabled={false}
|
|
64
|
-
emails={toEmailsForForward}
|
|
65
|
-
label="To:"
|
|
66
|
-
onUpdate={setToEmailsForForward}
|
|
67
|
-
/>
|
|
68
|
-
)}
|
|
69
|
-
<InputEmailChip
|
|
70
|
-
disabled={false}
|
|
71
|
-
emails={ccEmails}
|
|
72
|
-
label="Cc:"
|
|
73
|
-
onUpdate={setCcEmails}
|
|
74
|
-
/>
|
|
75
|
-
<InputEmailChip
|
|
76
|
-
disabled={false}
|
|
77
|
-
emails={bccEmails}
|
|
78
|
-
label="Bcc:"
|
|
79
|
-
onUpdate={setBccEmails}
|
|
80
|
-
/>
|
|
81
|
-
</Animated.View>
|
|
82
|
-
) : (
|
|
83
|
-
<Animated.View
|
|
84
|
-
alignItems="flex-start"
|
|
85
|
-
entering={FadeInUp}
|
|
86
|
-
flexDirection="row"
|
|
87
|
-
flexWrap="wrap"
|
|
88
|
-
key={isEmailFieldsVisible}
|
|
89
|
-
style={
|
|
90
|
-
isNoteOptionSelected && {
|
|
91
|
-
height: moderateScale(0),
|
|
92
|
-
width: moderateScale(0),
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
onTouchStart={() => setIsEmailFieldsVisible(true)}
|
|
96
|
-
>
|
|
97
|
-
{toEmails.length > 0 && (
|
|
98
|
-
<>
|
|
99
|
-
<Badge text={badge} />
|
|
100
|
-
{totalEmailsMinus1 > 1 && <Badge text={`+ ${totalEmailsMinus1}`} />}
|
|
101
|
-
</>
|
|
102
|
-
)}
|
|
103
|
-
</Animated.View>
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
EmailFields.propTypes = {
|
|
108
|
-
shouldShowEmailFields: PropTypes.bool,
|
|
109
|
-
isEmailFieldsVisible: PropTypes.bool,
|
|
110
|
-
setIsEmailFieldsVisible: PropTypes.func,
|
|
111
|
-
ccEmails: PropTypes.arrayOf(PropTypes.string),
|
|
112
|
-
toEmails: PropTypes.arrayOf(PropTypes.string),
|
|
113
|
-
toEmailsForForward: PropTypes.arrayOf(PropTypes.string),
|
|
114
|
-
bccEmails: PropTypes.arrayOf(PropTypes.string),
|
|
115
|
-
setBccEmails: PropTypes.func,
|
|
116
|
-
setCcEmails: PropTypes.func,
|
|
117
|
-
setToEmails: PropTypes.func,
|
|
118
|
-
setToEmailsForForward: PropTypes.func,
|
|
119
|
-
isReplyOptionSelected: PropTypes.bool,
|
|
120
|
-
isNoteOptionSelected: PropTypes.bool,
|
|
121
|
-
isForwardOptionSelected: PropTypes.bool,
|
|
122
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from "react";
|
|
2
|
-
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import { moderateScale } from "react-native-size-matters";
|
|
5
|
-
import { ThemeContext } from "styled-components/native";
|
|
6
|
-
|
|
7
|
-
import { Touchable } from "@components";
|
|
8
|
-
|
|
9
|
-
export const IconButton = ({ Icon, iconProps, ...rest }) => {
|
|
10
|
-
const theme = useContext(ThemeContext);
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<Touchable
|
|
14
|
-
alignItems="center"
|
|
15
|
-
height={moderateScale(22)}
|
|
16
|
-
px={moderateScale(18)}
|
|
17
|
-
width={moderateScale(22)}
|
|
18
|
-
{...rest}
|
|
19
|
-
>
|
|
20
|
-
{
|
|
21
|
-
<Icon
|
|
22
|
-
color={theme.colors.font.grey800}
|
|
23
|
-
size={moderateScale(22)}
|
|
24
|
-
{...iconProps}
|
|
25
|
-
/>
|
|
26
|
-
}
|
|
27
|
-
</Touchable>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
IconButton.propTypes = {
|
|
32
|
-
Icon: PropTypes.elementType,
|
|
33
|
-
iconProps: PropTypes.object,
|
|
34
|
-
};
|