srs-heritage-chatbot 1.0.0
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/LICENSE +20 -0
- package/README.md +194 -0
- package/lib/commonjs/assets/chat-icon-mobile.svg +1 -0
- package/lib/commonjs/assets/heritage.png +0 -0
- package/lib/commonjs/assets/posiden.svg +51 -0
- package/lib/commonjs/components/LoadingTips.js +104 -0
- package/lib/commonjs/components/LoadingTips.js.map +1 -0
- package/lib/commonjs/components/email.js +461 -0
- package/lib/commonjs/components/email.js.map +1 -0
- package/lib/commonjs/components/feedback.js +114 -0
- package/lib/commonjs/components/feedback.js.map +1 -0
- package/lib/commonjs/components/header.js +126 -0
- package/lib/commonjs/components/header.js.map +1 -0
- package/lib/commonjs/components/input.js +144 -0
- package/lib/commonjs/components/input.js.map +1 -0
- package/lib/commonjs/components/productCard.js +688 -0
- package/lib/commonjs/components/productCard.js.map +1 -0
- package/lib/commonjs/components/progressCircle.js +99 -0
- package/lib/commonjs/components/progressCircle.js.map +1 -0
- package/lib/commonjs/components/testing.js +74 -0
- package/lib/commonjs/components/testing.js.map +1 -0
- package/lib/commonjs/components/voice.js +184 -0
- package/lib/commonjs/components/voice.js.map +1 -0
- package/lib/commonjs/components/welcomeButton.js +149 -0
- package/lib/commonjs/components/welcomeButton.js.map +1 -0
- package/lib/commonjs/components/welcomeInput.js +137 -0
- package/lib/commonjs/components/welcomeInput.js.map +1 -0
- package/lib/commonjs/contexts/AppContext.js +552 -0
- package/lib/commonjs/contexts/AppContext.js.map +1 -0
- package/lib/commonjs/hooks/Stream.js +599 -0
- package/lib/commonjs/hooks/Stream.js.map +1 -0
- package/lib/commonjs/hooks/useAsyncStorage.js +36 -0
- package/lib/commonjs/hooks/useAsyncStorage.js.map +1 -0
- package/lib/commonjs/index.js +44 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/layout/disclaimer.js +208 -0
- package/lib/commonjs/layout/disclaimer.js.map +1 -0
- package/lib/commonjs/layout/ex.js +254 -0
- package/lib/commonjs/layout/ex.js.map +1 -0
- package/lib/commonjs/layout/icon.js +118 -0
- package/lib/commonjs/layout/icon.js.map +1 -0
- package/lib/commonjs/layout/layout.js +168 -0
- package/lib/commonjs/layout/layout.js.map +1 -0
- package/lib/commonjs/layout/welcome.js +160 -0
- package/lib/commonjs/layout/welcome.js.map +1 -0
- package/lib/commonjs/layout/window.js +396 -0
- package/lib/commonjs/layout/window.js.map +1 -0
- package/lib/commonjs/utils/audioRecorder.js +412 -0
- package/lib/commonjs/utils/audioRecorder.js.map +1 -0
- package/lib/commonjs/utils/cloudinary.js +69 -0
- package/lib/commonjs/utils/cloudinary.js.map +1 -0
- package/lib/commonjs/utils/storage.js +76 -0
- package/lib/commonjs/utils/storage.js.map +1 -0
- package/lib/commonjs/utils/textToSpeech.js +53 -0
- package/lib/commonjs/utils/textToSpeech.js.map +1 -0
- package/lib/module/assets/chat-icon-mobile.svg +1 -0
- package/lib/module/assets/heritage.png +0 -0
- package/lib/module/assets/posiden.svg +51 -0
- package/lib/module/components/LoadingTips.js +95 -0
- package/lib/module/components/LoadingTips.js.map +1 -0
- package/lib/module/components/email.js +452 -0
- package/lib/module/components/email.js.map +1 -0
- package/lib/module/components/feedback.js +105 -0
- package/lib/module/components/feedback.js.map +1 -0
- package/lib/module/components/header.js +117 -0
- package/lib/module/components/header.js.map +1 -0
- package/lib/module/components/input.js +135 -0
- package/lib/module/components/input.js.map +1 -0
- package/lib/module/components/productCard.js +679 -0
- package/lib/module/components/productCard.js.map +1 -0
- package/lib/module/components/progressCircle.js +91 -0
- package/lib/module/components/progressCircle.js.map +1 -0
- package/lib/module/components/testing.js +66 -0
- package/lib/module/components/testing.js.map +1 -0
- package/lib/module/components/voice.js +175 -0
- package/lib/module/components/voice.js.map +1 -0
- package/lib/module/components/welcomeButton.js +140 -0
- package/lib/module/components/welcomeButton.js.map +1 -0
- package/lib/module/components/welcomeInput.js +128 -0
- package/lib/module/components/welcomeInput.js.map +1 -0
- package/lib/module/contexts/AppContext.js +542 -0
- package/lib/module/contexts/AppContext.js.map +1 -0
- package/lib/module/hooks/Stream.js +592 -0
- package/lib/module/hooks/Stream.js.map +1 -0
- package/lib/module/hooks/useAsyncStorage.js +29 -0
- package/lib/module/hooks/useAsyncStorage.js.map +1 -0
- package/lib/module/index.js +36 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/layout/disclaimer.js +199 -0
- package/lib/module/layout/disclaimer.js.map +1 -0
- package/lib/module/layout/ex.js +253 -0
- package/lib/module/layout/ex.js.map +1 -0
- package/lib/module/layout/icon.js +108 -0
- package/lib/module/layout/icon.js.map +1 -0
- package/lib/module/layout/layout.js +160 -0
- package/lib/module/layout/layout.js.map +1 -0
- package/lib/module/layout/welcome.js +150 -0
- package/lib/module/layout/welcome.js.map +1 -0
- package/lib/module/layout/window.js +387 -0
- package/lib/module/layout/window.js.map +1 -0
- package/lib/module/utils/audioRecorder.js +398 -0
- package/lib/module/utils/audioRecorder.js.map +1 -0
- package/lib/module/utils/cloudinary.js +61 -0
- package/lib/module/utils/cloudinary.js.map +1 -0
- package/lib/module/utils/storage.js +67 -0
- package/lib/module/utils/storage.js.map +1 -0
- package/lib/module/utils/textToSpeech.js +43 -0
- package/lib/module/utils/textToSpeech.js.map +1 -0
- package/lib/typescript/components/LoadingTips.d.ts +3 -0
- package/lib/typescript/components/LoadingTips.d.ts.map +1 -0
- package/lib/typescript/components/email.d.ts +6 -0
- package/lib/typescript/components/email.d.ts.map +1 -0
- package/lib/typescript/components/feedback.d.ts +6 -0
- package/lib/typescript/components/feedback.d.ts.map +1 -0
- package/lib/typescript/components/header.d.ts +3 -0
- package/lib/typescript/components/header.d.ts.map +1 -0
- package/lib/typescript/components/input.d.ts +6 -0
- package/lib/typescript/components/input.d.ts.map +1 -0
- package/lib/typescript/components/productCard.d.ts +7 -0
- package/lib/typescript/components/productCard.d.ts.map +1 -0
- package/lib/typescript/components/progressCircle.d.ts +3 -0
- package/lib/typescript/components/progressCircle.d.ts.map +1 -0
- package/lib/typescript/components/testing.d.ts +6 -0
- package/lib/typescript/components/testing.d.ts.map +1 -0
- package/lib/typescript/components/voice.d.ts +5 -0
- package/lib/typescript/components/voice.d.ts.map +1 -0
- package/lib/typescript/components/welcomeButton.d.ts +4 -0
- package/lib/typescript/components/welcomeButton.d.ts.map +1 -0
- package/lib/typescript/components/welcomeInput.d.ts +6 -0
- package/lib/typescript/components/welcomeInput.d.ts.map +1 -0
- package/lib/typescript/contexts/AppContext.d.ts +10 -0
- package/lib/typescript/contexts/AppContext.d.ts.map +1 -0
- package/lib/typescript/hooks/Stream.d.ts +2 -0
- package/lib/typescript/hooks/Stream.d.ts.map +1 -0
- package/lib/typescript/hooks/useAsyncStorage.d.ts +2 -0
- package/lib/typescript/hooks/useAsyncStorage.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +8 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/layout/disclaimer.d.ts +5 -0
- package/lib/typescript/layout/disclaimer.d.ts.map +1 -0
- package/lib/typescript/layout/ex.d.ts +1 -0
- package/lib/typescript/layout/ex.d.ts.map +1 -0
- package/lib/typescript/layout/icon.d.ts +3 -0
- package/lib/typescript/layout/icon.d.ts.map +1 -0
- package/lib/typescript/layout/layout.d.ts +3 -0
- package/lib/typescript/layout/layout.d.ts.map +1 -0
- package/lib/typescript/layout/welcome.d.ts +6 -0
- package/lib/typescript/layout/welcome.d.ts.map +1 -0
- package/lib/typescript/layout/window.d.ts +5 -0
- package/lib/typescript/layout/window.d.ts.map +1 -0
- package/lib/typescript/utils/audioRecorder.d.ts +9 -0
- package/lib/typescript/utils/audioRecorder.d.ts.map +1 -0
- package/lib/typescript/utils/cloudinary.d.ts +17 -0
- package/lib/typescript/utils/cloudinary.d.ts.map +1 -0
- package/lib/typescript/utils/storage.d.ts +29 -0
- package/lib/typescript/utils/storage.d.ts.map +1 -0
- package/lib/typescript/utils/textToSpeech.d.ts +2 -0
- package/lib/typescript/utils/textToSpeech.d.ts.map +1 -0
- package/package.json +109 -0
- package/src/assets/chat-icon-mobile.svg +1 -0
- package/src/assets/heritage.png +0 -0
- package/src/assets/posiden.svg +51 -0
- package/src/components/LoadingTips.js +99 -0
- package/src/components/email.js +467 -0
- package/src/components/feedback.js +114 -0
- package/src/components/header.js +119 -0
- package/src/components/input.js +133 -0
- package/src/components/productCard.js +815 -0
- package/src/components/progressCircle.js +88 -0
- package/src/components/testing.js +60 -0
- package/src/components/voice.js +228 -0
- package/src/components/welcomeButton.js +161 -0
- package/src/components/welcomeInput.js +133 -0
- package/src/contexts/AppContext.js +678 -0
- package/src/hooks/Stream.js +655 -0
- package/src/hooks/useAsyncStorage.js +33 -0
- package/src/index.js +30 -0
- package/src/layout/disclaimer.js +231 -0
- package/src/layout/ex.js +252 -0
- package/src/layout/icon.js +105 -0
- package/src/layout/layout.js +160 -0
- package/src/layout/welcome.js +172 -0
- package/src/layout/window.js +476 -0
- package/src/utils/audioRecorder.js +445 -0
- package/src/utils/cloudinary.js +61 -0
- package/src/utils/storage.ts +89 -0
- package/src/utils/textToSpeech.js +49 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import React, { useState, useEffect, useContext, useRef } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Text,
|
|
4
|
+
StyleSheet,
|
|
5
|
+
View,
|
|
6
|
+
TextInput,
|
|
7
|
+
TouchableOpacity,
|
|
8
|
+
Platform,
|
|
9
|
+
KeyboardAvoidingView,
|
|
10
|
+
Keyboard
|
|
11
|
+
} from 'react-native';
|
|
12
|
+
import { Header } from '../components/header';
|
|
13
|
+
import { AppContext } from '../contexts/AppContext';
|
|
14
|
+
import Ionicons from 'react-native-vector-icons/Ionicons';
|
|
15
|
+
import { VoiceButton } from './voice';
|
|
16
|
+
|
|
17
|
+
export const ChatInput = ({ onProductCardClick, onAddToCartClick }) => {
|
|
18
|
+
const { handleSend, input, setInput, showModal, data, isListening } = useContext(AppContext);
|
|
19
|
+
const inputRef = useRef(null);
|
|
20
|
+
|
|
21
|
+
const handleKeyPress = ({ nativeEvent }) => {
|
|
22
|
+
if (nativeEvent.key === 'return' && !nativeEvent.shiftKey) {
|
|
23
|
+
nativeEvent.preventDefault && nativeEvent.preventDefault();
|
|
24
|
+
handleSend(input);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const onSubmitEditing = () => {
|
|
30
|
+
if (input.trim()) {
|
|
31
|
+
handleSend(input);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
<Text style={styles.textBeta} allowFontScaling={false}>Beta version. AI Assistant is still learning!</Text>
|
|
38
|
+
<View style={styles.inputWrapper}>
|
|
39
|
+
<View style={styles.inputContainer}>
|
|
40
|
+
<TextInput
|
|
41
|
+
ref={inputRef}
|
|
42
|
+
style={styles.input}
|
|
43
|
+
value={input}
|
|
44
|
+
onChangeText={setInput}
|
|
45
|
+
placeholder={isListening && !input ? "Listening..." : "Ask a question..."}
|
|
46
|
+
placeholderTextColor="#999"
|
|
47
|
+
editable={!isListening}
|
|
48
|
+
caretHidden={isListening}
|
|
49
|
+
showSoftInputOnFocus={!isListening}
|
|
50
|
+
multiline={false}
|
|
51
|
+
returnKeyType="send"
|
|
52
|
+
enablesReturnKeyAutomatically={true}
|
|
53
|
+
onKeyPress={handleKeyPress}
|
|
54
|
+
onSubmitEditing={onSubmitEditing}
|
|
55
|
+
selection={undefined}
|
|
56
|
+
blurOnSubmit={false}
|
|
57
|
+
/>
|
|
58
|
+
<VoiceButton setInput={(text) => {
|
|
59
|
+
setInput(text);
|
|
60
|
+
if (!isListening && inputRef.current) {
|
|
61
|
+
if (Platform.OS === 'android') {
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
if (inputRef.current) {
|
|
64
|
+
inputRef.current.setSelection(text.length, text.length);
|
|
65
|
+
}
|
|
66
|
+
}, 10);
|
|
67
|
+
} else {
|
|
68
|
+
inputRef.current.setSelection(text.length, text.length);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}}/>
|
|
72
|
+
<TouchableOpacity style={styles.sendButton} onPress={() => handleSend(input)} >
|
|
73
|
+
<Ionicons name="paper-plane-outline" size={24} color='#8E8E93' />
|
|
74
|
+
</TouchableOpacity>
|
|
75
|
+
</View>
|
|
76
|
+
</View>
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const styles = StyleSheet.create({
|
|
82
|
+
inputWrapper: {
|
|
83
|
+
backgroundColor: '#f6f6f6',
|
|
84
|
+
paddingHorizontal: 6,
|
|
85
|
+
paddingVertical: 6,
|
|
86
|
+
borderTopWidth: 1,
|
|
87
|
+
borderTopColor: 'rgba(0, 0, 0, 0.1)',
|
|
88
|
+
},
|
|
89
|
+
inputContainer: {
|
|
90
|
+
flexDirection: 'row',
|
|
91
|
+
alignItems: 'center',
|
|
92
|
+
paddingHorizontal: 8,
|
|
93
|
+
paddingVertical: 8,
|
|
94
|
+
backgroundColor: '#FFFFFF',
|
|
95
|
+
borderRadius: 16,
|
|
96
|
+
margin: 8,
|
|
97
|
+
shadowColor: '#000',
|
|
98
|
+
shadowOffset: {
|
|
99
|
+
width: 0,
|
|
100
|
+
height: 2,
|
|
101
|
+
},
|
|
102
|
+
shadowOpacity: 0.1,
|
|
103
|
+
shadowRadius: 4,
|
|
104
|
+
elevation: 3,
|
|
105
|
+
},
|
|
106
|
+
input: {
|
|
107
|
+
flex: 1,
|
|
108
|
+
fontSize: 16,
|
|
109
|
+
paddingVertical: 8,
|
|
110
|
+
paddingHorizontal: 12,
|
|
111
|
+
color: '#000000',
|
|
112
|
+
},
|
|
113
|
+
inputButton: {
|
|
114
|
+
padding: 6,
|
|
115
|
+
},
|
|
116
|
+
sendButton: {
|
|
117
|
+
padding: 6,
|
|
118
|
+
marginLeft: 'auto',
|
|
119
|
+
},
|
|
120
|
+
disabledButton: {
|
|
121
|
+
opacity: 0.7,
|
|
122
|
+
},
|
|
123
|
+
textBeta: {
|
|
124
|
+
textAlign: 'center',
|
|
125
|
+
fontSize: 11,
|
|
126
|
+
color: '#808080',
|
|
127
|
+
fontWeight: '400',
|
|
128
|
+
marginTop: 5,
|
|
129
|
+
marginBottom: 2,
|
|
130
|
+
textBreakStrategy: "simple",
|
|
131
|
+
lineHeight: 16,
|
|
132
|
+
},
|
|
133
|
+
});
|