react-native-srschat 0.1.46 → 0.1.48
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 +14 -3
- package/lib/commonjs/components/LoadingTips.js +2 -2
- package/lib/commonjs/components/LoadingTips.js.map +1 -1
- package/lib/commonjs/components/email.js +6 -3
- package/lib/commonjs/components/email.js.map +1 -1
- package/lib/commonjs/components/input.js +2 -3
- package/lib/commonjs/components/input.js.map +1 -1
- package/lib/commonjs/components/productCard.js +125 -32
- package/lib/commonjs/components/productCard.js.map +1 -1
- package/lib/commonjs/components/progressCircle.js +1 -1
- package/lib/commonjs/components/progressCircle.js.map +1 -1
- package/lib/commonjs/contexts/AppContext.js +12 -6
- package/lib/commonjs/contexts/AppContext.js.map +1 -1
- package/lib/commonjs/hooks/Stream.js +2 -1
- package/lib/commonjs/hooks/Stream.js.map +1 -1
- package/lib/commonjs/layout/ex.js +252 -270
- package/lib/commonjs/layout/ex.js.map +1 -1
- package/lib/commonjs/layout/icon.js +2 -1
- package/lib/commonjs/layout/icon.js.map +1 -1
- package/lib/commonjs/layout/welcome.js +6 -5
- package/lib/commonjs/layout/welcome.js.map +1 -1
- package/lib/commonjs/layout/window.js +38 -10
- package/lib/commonjs/layout/window.js.map +1 -1
- package/lib/commonjs/utils/storage.js +1 -1
- package/lib/module/components/LoadingTips.js +2 -2
- package/lib/module/components/LoadingTips.js.map +1 -1
- package/lib/module/components/email.js +7 -4
- package/lib/module/components/email.js.map +1 -1
- package/lib/module/components/input.js +2 -3
- package/lib/module/components/input.js.map +1 -1
- package/lib/module/components/productCard.js +125 -32
- package/lib/module/components/productCard.js.map +1 -1
- package/lib/module/components/progressCircle.js +1 -1
- package/lib/module/components/progressCircle.js.map +1 -1
- package/lib/module/contexts/AppContext.js +12 -6
- package/lib/module/contexts/AppContext.js.map +1 -1
- package/lib/module/hooks/Stream.js +2 -1
- package/lib/module/hooks/Stream.js.map +1 -1
- package/lib/module/layout/ex.js +252 -261
- package/lib/module/layout/ex.js.map +1 -1
- package/lib/module/layout/icon.js +2 -1
- package/lib/module/layout/icon.js.map +1 -1
- package/lib/module/layout/welcome.js +6 -5
- package/lib/module/layout/welcome.js.map +1 -1
- package/lib/module/layout/window.js +38 -10
- package/lib/module/layout/window.js.map +1 -1
- package/lib/module/utils/storage.js +1 -1
- package/lib/typescript/components/email.d.ts.map +1 -1
- package/lib/typescript/components/productCard.d.ts +2 -1
- package/lib/typescript/components/productCard.d.ts.map +1 -1
- package/lib/typescript/contexts/AppContext.d.ts.map +1 -1
- package/lib/typescript/hooks/Stream.d.ts.map +1 -1
- package/lib/typescript/layout/ex.d.ts +0 -2
- package/lib/typescript/layout/ex.d.ts.map +1 -1
- package/lib/typescript/layout/icon.d.ts.map +1 -1
- package/lib/typescript/layout/window.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/LoadingTips.js +2 -2
- package/src/components/email.js +7 -4
- package/src/components/input.js +1 -2
- package/src/components/productCard.js +132 -33
- package/src/components/progressCircle.js +1 -1
- package/src/contexts/AppContext.js +13 -6
- package/src/hooks/Stream.js +1 -0
- package/src/layout/ex.js +250 -249
- package/src/layout/icon.js +2 -1
- package/src/layout/welcome.js +5 -5
- package/src/layout/window.js +33 -6
- package/src/utils/storage.ts +1 -1
package/src/layout/window.js
CHANGED
|
@@ -15,11 +15,13 @@ import { ProgressCircle } from '../components/progressCircle';
|
|
|
15
15
|
|
|
16
16
|
export const ChatWindow = ({ panHandlers }) => {
|
|
17
17
|
const { handleSend, messages, input, setInput, ghostMessage, handleButtonClick,
|
|
18
|
-
onProductCardClick, onAddToCartClick, uiConfig, ghostCard, typingIndicator
|
|
18
|
+
onProductCardClick, onAddToCartClick, uiConfig, ghostCard, typingIndicator, feedbackOpen, setFeedbackOpen
|
|
19
19
|
} = useContext(AppContext);
|
|
20
20
|
|
|
21
21
|
const scrollViewRef = useRef(null);
|
|
22
22
|
const fadeAnim = useRef(new Animated.Value(0.6)).current;
|
|
23
|
+
const [messageCount, setMessageCount] = useState(messages.length);
|
|
24
|
+
|
|
23
25
|
|
|
24
26
|
useEffect(() => {
|
|
25
27
|
if (scrollViewRef.current) {
|
|
@@ -61,19 +63,43 @@ export const ChatWindow = ({ panHandlers }) => {
|
|
|
61
63
|
ref={scrollViewRef}
|
|
62
64
|
contentContainerStyle={styles.messagesContent}
|
|
63
65
|
enableOnAndroid
|
|
66
|
+
enableOnIOS
|
|
64
67
|
contentInsetAdjustmentBehavior="never"
|
|
65
68
|
automaticallyAdjustContentInsets={false}
|
|
66
69
|
contentInset={{ bottom: 0 }}
|
|
67
70
|
keyboardShouldPersistTaps="handled"
|
|
68
71
|
showsVerticalScrollIndicator={false}
|
|
69
|
-
extraScrollHeight={
|
|
70
|
-
onContentSizeChange={() => {
|
|
71
|
-
|
|
72
|
+
extraScrollHeight={200}
|
|
73
|
+
onContentSizeChange={(contentWidth, contentHeight) => {
|
|
74
|
+
const currentLength = messages.length;
|
|
75
|
+
|
|
76
|
+
if (currentLength > messageCount) {
|
|
77
|
+
scrollViewRef.current?.scrollToEnd({ animated: true });
|
|
78
|
+
|
|
79
|
+
setMessageCount(currentLength);
|
|
80
|
+
} else if (currentLength == messageCount) {
|
|
81
|
+
// Check if *any* value in the feedbackOpen object is true
|
|
82
|
+
const isAnyFeedbackOpen = Object.values(feedbackOpen).some(isOpen => isOpen === true);
|
|
83
|
+
|
|
84
|
+
if (isAnyFeedbackOpen) {
|
|
85
|
+
// console.log("A feedback input is open, not scrolling to end.");
|
|
86
|
+
// Do nothing, prevent scrolling
|
|
87
|
+
} else {
|
|
88
|
+
// console.log("No feedback open, scrolling to end.");
|
|
89
|
+
if (typingIndicator) {
|
|
90
|
+
scrollViewRef.current?.scrollToEnd({ animated: true });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// You might still want to update messageCount regardless
|
|
94
|
+
setMessageCount(currentLength); // Decide if this should be inside the else or outside the if/else
|
|
95
|
+
|
|
96
|
+
} else if (currentLength < messageCount) {
|
|
97
|
+
setMessageCount(currentLength);
|
|
98
|
+
}
|
|
72
99
|
}}
|
|
73
100
|
keyboardDismissMode="none"
|
|
74
101
|
bounces={false}
|
|
75
102
|
enableResetScrollToCoords={false}
|
|
76
|
-
extraHeight={0}
|
|
77
103
|
keyboardOpeningTime={0}
|
|
78
104
|
>
|
|
79
105
|
{messages.map((msg, i) => (
|
|
@@ -102,7 +128,7 @@ export const ChatWindow = ({ panHandlers }) => {
|
|
|
102
128
|
{msg.products && msg.products.length > 0 &&
|
|
103
129
|
msg.products.map((prod, index) => (
|
|
104
130
|
<View key={index} style={styles.productCardWrapper}>
|
|
105
|
-
<ProductCard prod={prod} />
|
|
131
|
+
<ProductCard prod={prod} messageId={msg.message_id} />
|
|
106
132
|
</View>
|
|
107
133
|
))}
|
|
108
134
|
|
|
@@ -171,6 +197,7 @@ const styles = StyleSheet.create({
|
|
|
171
197
|
messagesContent: {
|
|
172
198
|
padding: 16,
|
|
173
199
|
justifyContent: 'flex-end',
|
|
200
|
+
paddingBottom: 300,
|
|
174
201
|
},
|
|
175
202
|
messageWrapper: {
|
|
176
203
|
marginBottom: 0,
|
package/src/utils/storage.ts
CHANGED
|
@@ -33,7 +33,7 @@ export const defaultState: ChatState = {
|
|
|
33
33
|
startStreaming: false,
|
|
34
34
|
messages: [{
|
|
35
35
|
type: "ai",
|
|
36
|
-
text: "Hi there 👋 I'm
|
|
36
|
+
text: "Hi there 👋 Hi there 👋 I'm your Heritage Pool+ AI Assistant. I'm here to help you with Product and Account information during your online visit. I'm still learning and growing - the more we interact and the more feedback you share, the better I can assist you. How can I help you today?"
|
|
37
37
|
}],
|
|
38
38
|
showIcon: true,
|
|
39
39
|
toggleChat: false,
|