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.
Files changed (69) hide show
  1. package/README.md +14 -3
  2. package/lib/commonjs/components/LoadingTips.js +2 -2
  3. package/lib/commonjs/components/LoadingTips.js.map +1 -1
  4. package/lib/commonjs/components/email.js +6 -3
  5. package/lib/commonjs/components/email.js.map +1 -1
  6. package/lib/commonjs/components/input.js +2 -3
  7. package/lib/commonjs/components/input.js.map +1 -1
  8. package/lib/commonjs/components/productCard.js +125 -32
  9. package/lib/commonjs/components/productCard.js.map +1 -1
  10. package/lib/commonjs/components/progressCircle.js +1 -1
  11. package/lib/commonjs/components/progressCircle.js.map +1 -1
  12. package/lib/commonjs/contexts/AppContext.js +12 -6
  13. package/lib/commonjs/contexts/AppContext.js.map +1 -1
  14. package/lib/commonjs/hooks/Stream.js +2 -1
  15. package/lib/commonjs/hooks/Stream.js.map +1 -1
  16. package/lib/commonjs/layout/ex.js +252 -270
  17. package/lib/commonjs/layout/ex.js.map +1 -1
  18. package/lib/commonjs/layout/icon.js +2 -1
  19. package/lib/commonjs/layout/icon.js.map +1 -1
  20. package/lib/commonjs/layout/welcome.js +6 -5
  21. package/lib/commonjs/layout/welcome.js.map +1 -1
  22. package/lib/commonjs/layout/window.js +38 -10
  23. package/lib/commonjs/layout/window.js.map +1 -1
  24. package/lib/commonjs/utils/storage.js +1 -1
  25. package/lib/module/components/LoadingTips.js +2 -2
  26. package/lib/module/components/LoadingTips.js.map +1 -1
  27. package/lib/module/components/email.js +7 -4
  28. package/lib/module/components/email.js.map +1 -1
  29. package/lib/module/components/input.js +2 -3
  30. package/lib/module/components/input.js.map +1 -1
  31. package/lib/module/components/productCard.js +125 -32
  32. package/lib/module/components/productCard.js.map +1 -1
  33. package/lib/module/components/progressCircle.js +1 -1
  34. package/lib/module/components/progressCircle.js.map +1 -1
  35. package/lib/module/contexts/AppContext.js +12 -6
  36. package/lib/module/contexts/AppContext.js.map +1 -1
  37. package/lib/module/hooks/Stream.js +2 -1
  38. package/lib/module/hooks/Stream.js.map +1 -1
  39. package/lib/module/layout/ex.js +252 -261
  40. package/lib/module/layout/ex.js.map +1 -1
  41. package/lib/module/layout/icon.js +2 -1
  42. package/lib/module/layout/icon.js.map +1 -1
  43. package/lib/module/layout/welcome.js +6 -5
  44. package/lib/module/layout/welcome.js.map +1 -1
  45. package/lib/module/layout/window.js +38 -10
  46. package/lib/module/layout/window.js.map +1 -1
  47. package/lib/module/utils/storage.js +1 -1
  48. package/lib/typescript/components/email.d.ts.map +1 -1
  49. package/lib/typescript/components/productCard.d.ts +2 -1
  50. package/lib/typescript/components/productCard.d.ts.map +1 -1
  51. package/lib/typescript/contexts/AppContext.d.ts.map +1 -1
  52. package/lib/typescript/hooks/Stream.d.ts.map +1 -1
  53. package/lib/typescript/layout/ex.d.ts +0 -2
  54. package/lib/typescript/layout/ex.d.ts.map +1 -1
  55. package/lib/typescript/layout/icon.d.ts.map +1 -1
  56. package/lib/typescript/layout/window.d.ts.map +1 -1
  57. package/package.json +1 -1
  58. package/src/components/LoadingTips.js +2 -2
  59. package/src/components/email.js +7 -4
  60. package/src/components/input.js +1 -2
  61. package/src/components/productCard.js +132 -33
  62. package/src/components/progressCircle.js +1 -1
  63. package/src/contexts/AppContext.js +13 -6
  64. package/src/hooks/Stream.js +1 -0
  65. package/src/layout/ex.js +250 -249
  66. package/src/layout/icon.js +2 -1
  67. package/src/layout/welcome.js +5 -5
  68. package/src/layout/window.js +33 -6
  69. package/src/utils/storage.ts +1 -1
@@ -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={0}
70
- onContentSizeChange={() => {
71
- scrollViewRef.current?.scrollToEnd({ animated: true });
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,
@@ -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 Poseidon, your Heritage Pool+ AI Agent. I can help you during your online visit with Product and Account information. How can I help you today?"
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,