@controleonline/ui-crm 1.0.80 → 1.0.82
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.81",
|
|
3
3
|
"rc": 1,
|
|
4
|
-
"branch": "rc/1.0.
|
|
5
|
-
"baseMaster": "
|
|
4
|
+
"branch": "rc/1.0.81-rc.1",
|
|
5
|
+
"baseMaster": "b96041bba3797409d02e6f95437aca568547dfaf",
|
|
6
6
|
"tasks": [
|
|
7
|
-
|
|
7
|
+
89
|
|
8
8
|
],
|
|
9
9
|
"frozen": true,
|
|
10
10
|
"repositories": {
|
|
11
|
-
"ControleOnline/ui-crm": "
|
|
11
|
+
"ControleOnline/ui-crm": "92c56c7f73ab065f470877d7838d2a3a9ee7236b"
|
|
12
12
|
}
|
|
13
13
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @agents WhatsApp-like attachment preview: opens right after a file is picked, shows the image (or the
|
|
3
|
+
* file name), takes an optional caption and sends with ➤ (Enter on web) or discards with ✕.
|
|
4
|
+
*/
|
|
5
|
+
import React, {useEffect, useMemo, useState} from 'react';
|
|
6
|
+
import {Image, Modal, Platform, Text, TextInput, TouchableOpacity, View} from 'react-native';
|
|
7
|
+
|
|
8
|
+
const mimeOf = file => String(file?.type || file?.mimeType || '').toLowerCase();
|
|
9
|
+
|
|
10
|
+
export default function AttachmentPreview({file, palette, onCancel, onSend}) {
|
|
11
|
+
const [caption, setCaption] = useState('');
|
|
12
|
+
const isImage = mimeOf(file).startsWith('image/') || /\.(png|jpe?g|gif|webp)$/i.test(String(file?.name || ''));
|
|
13
|
+
|
|
14
|
+
// Web files need an object URL for the preview; native pickers already give a uri.
|
|
15
|
+
const uri = useMemo(() => {
|
|
16
|
+
if (!file || !isImage) return null;
|
|
17
|
+
if (file.uri) return file.uri;
|
|
18
|
+
if (Platform.OS === 'web' && typeof URL !== 'undefined' && file instanceof Blob) return URL.createObjectURL(file);
|
|
19
|
+
return null;
|
|
20
|
+
}, [file, isImage]);
|
|
21
|
+
useEffect(() => () => {
|
|
22
|
+
if (uri && Platform.OS === 'web' && uri.startsWith('blob:')) URL.revokeObjectURL(uri);
|
|
23
|
+
}, [uri]);
|
|
24
|
+
useEffect(() => setCaption(''), [file]);
|
|
25
|
+
|
|
26
|
+
if (!file) return null;
|
|
27
|
+
const send = () => onSend({text: caption.trim(), file});
|
|
28
|
+
const onKeyPress = event => {
|
|
29
|
+
const e = event?.nativeEvent || {};
|
|
30
|
+
if (Platform.OS === 'web' && e.key === 'Enter' && !e.shiftKey) {
|
|
31
|
+
event.preventDefault?.();
|
|
32
|
+
send();
|
|
33
|
+
}
|
|
34
|
+
if (Platform.OS === 'web' && e.key === 'Escape') onCancel();
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Modal transparent animationType="fade" visible onRequestClose={onCancel}>
|
|
39
|
+
<View style={{flex: 1, backgroundColor: 'rgba(0,0,0,0.6)', alignItems: 'center', justifyContent: 'center', padding: 16}}>
|
|
40
|
+
<View style={{width: '100%', maxWidth: 520, borderRadius: 14, overflow: 'hidden', backgroundColor: palette.panel}}>
|
|
41
|
+
<View style={{flexDirection: 'row', alignItems: 'center', paddingHorizontal: 12, paddingVertical: 10, borderBottomWidth: 1, borderBottomColor: palette.border}}>
|
|
42
|
+
<TouchableOpacity onPress={onCancel} accessibilityLabel="Descartar anexo" style={{padding: 4, marginRight: 8}}>
|
|
43
|
+
<Text style={{color: palette.muted, fontSize: 18, fontWeight: '700'}}>✕</Text>
|
|
44
|
+
</TouchableOpacity>
|
|
45
|
+
<Text style={{color: palette.text, fontWeight: '700', flex: 1}} numberOfLines={1}>
|
|
46
|
+
{file.name || 'Anexo'}
|
|
47
|
+
</Text>
|
|
48
|
+
</View>
|
|
49
|
+
<View style={{alignItems: 'center', justifyContent: 'center', padding: 16, backgroundColor: palette.background, minHeight: 160}}>
|
|
50
|
+
{uri ? (
|
|
51
|
+
<Image source={{uri}} style={{width: '100%', height: 300}} resizeMode="contain" />
|
|
52
|
+
) : (
|
|
53
|
+
<View style={{alignItems: 'center'}}>
|
|
54
|
+
<Text style={{fontSize: 48}}>📄</Text>
|
|
55
|
+
<Text style={{color: palette.text, marginTop: 8, textAlign: 'center'}} numberOfLines={2}>
|
|
56
|
+
{file.name || 'Arquivo'}
|
|
57
|
+
</Text>
|
|
58
|
+
</View>
|
|
59
|
+
)}
|
|
60
|
+
</View>
|
|
61
|
+
<View style={{flexDirection: 'row', alignItems: 'flex-end', gap: 8, padding: 10}}>
|
|
62
|
+
<TextInput
|
|
63
|
+
style={{
|
|
64
|
+
flex: 1,
|
|
65
|
+
minHeight: 40,
|
|
66
|
+
maxHeight: 120,
|
|
67
|
+
borderRadius: 20,
|
|
68
|
+
borderWidth: 1,
|
|
69
|
+
borderColor: palette.inputBorder,
|
|
70
|
+
backgroundColor: palette.input,
|
|
71
|
+
color: palette.inputText,
|
|
72
|
+
paddingHorizontal: 14,
|
|
73
|
+
paddingVertical: 9,
|
|
74
|
+
fontSize: 15,
|
|
75
|
+
}}
|
|
76
|
+
value={caption}
|
|
77
|
+
onChangeText={setCaption}
|
|
78
|
+
onKeyPress={onKeyPress}
|
|
79
|
+
placeholder="Adicione uma legenda (opcional)"
|
|
80
|
+
placeholderTextColor={palette.placeholder}
|
|
81
|
+
multiline
|
|
82
|
+
autoFocus
|
|
83
|
+
/>
|
|
84
|
+
<TouchableOpacity
|
|
85
|
+
onPress={send}
|
|
86
|
+
accessibilityLabel="Enviar anexo"
|
|
87
|
+
style={{width: 44, height: 44, borderRadius: 22, alignItems: 'center', justifyContent: 'center', backgroundColor: palette.chipActive}}>
|
|
88
|
+
<Text style={{color: palette.chipActiveText, fontSize: 18}}>➤</Text>
|
|
89
|
+
</TouchableOpacity>
|
|
90
|
+
</View>
|
|
91
|
+
</View>
|
|
92
|
+
</View>
|
|
93
|
+
</Modal>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* @agents Message input, WhatsApp-like: Enter sends (Shift+Enter breaks the line), 📎
|
|
2
|
+
* @agents Message input, WhatsApp-like: Enter sends (Shift+Enter breaks the line), 📎 picks a file and opens
|
|
3
|
+
* a preview with caption (AttachmentPreview),
|
|
3
4
|
* 🎤 records a voice note (sent when recording stops). Sending never blocks typing: the input is cleared
|
|
4
5
|
* at once and `onSend({text, file})` queues the message (ConversationView shows it as pending).
|
|
5
6
|
*/
|
|
6
7
|
import React, {useState} from 'react';
|
|
7
8
|
import {ActivityIndicator, Platform, Text, TextInput, TouchableOpacity, View} from 'react-native';
|
|
9
|
+
import AttachmentPreview from './AttachmentPreview';
|
|
8
10
|
import useAudioRecording from './useAudioRecording';
|
|
9
11
|
import {selectFile} from './fileApi';
|
|
10
12
|
|
|
@@ -14,11 +16,11 @@ export default function Composer({palette, placeholder, disabled, disabledText,
|
|
|
14
16
|
const sending = false;
|
|
15
17
|
const audio = useAudioRecording();
|
|
16
18
|
|
|
17
|
-
const send = (payload = {text, file}) => {
|
|
19
|
+
const send = (payload = {text, file: null}) => {
|
|
18
20
|
const message = {text: String(payload.text || '').trim(), file: payload.file || null};
|
|
19
21
|
if (!message.text && !message.file) return;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
if (message.file) setFile(null);
|
|
23
|
+
else setText('');
|
|
22
24
|
Promise.resolve()
|
|
23
25
|
.then(() => onSend(message))
|
|
24
26
|
.catch(e => onError?.(e?.message || 'Não foi possível enviar'));
|
|
@@ -63,18 +65,11 @@ export default function Composer({palette, placeholder, disabled, disabledText,
|
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
const iconBtn = {width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center'};
|
|
66
|
-
const hasContent = Boolean(text.trim()
|
|
68
|
+
const hasContent = Boolean(text.trim());
|
|
67
69
|
return (
|
|
68
70
|
<View style={{borderTopWidth: 1, borderTopColor: palette.border, backgroundColor: palette.panel, paddingHorizontal: 8, paddingVertical: 6}}>
|
|
69
71
|
{top}
|
|
70
|
-
{file
|
|
71
|
-
<View style={{flexDirection: 'row', alignItems: 'center', gap: 8, padding: 6, marginBottom: 4, borderRadius: 8, backgroundColor: palette.chip}}>
|
|
72
|
-
<Text style={{color: palette.chipText, flex: 1}} numberOfLines={1}>{`📎 ${file.name || 'arquivo'}`}</Text>
|
|
73
|
-
<TouchableOpacity onPress={() => setFile(null)}>
|
|
74
|
-
<Text style={{color: palette.danger, fontWeight: '700'}}>✕</Text>
|
|
75
|
-
</TouchableOpacity>
|
|
76
|
-
</View>
|
|
77
|
-
) : null}
|
|
72
|
+
<AttachmentPreview file={file} palette={palette} onCancel={() => setFile(null)} onSend={send} />
|
|
78
73
|
<View style={{flexDirection: 'row', alignItems: 'flex-end', gap: 6}}>
|
|
79
74
|
<TouchableOpacity style={iconBtn} onPress={attach} disabled={sending || audio.recording} accessibilityLabel="Anexar arquivo">
|
|
80
75
|
<Text style={{fontSize: 20, color: palette.muted}}>📎</Text>
|