vdb-ai-chat 1.0.1 → 1.0.2
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/dist/10.chat-widget.js +2 -0
- package/dist/10.chat-widget.js.LICENSE.txt +1 -0
- package/dist/104.chat-widget.js +1 -0
- package/dist/50.chat-widget.js +1 -0
- package/dist/521.chat-widget.js +1 -0
- package/dist/538.chat-widget.js +1 -1
- package/dist/572.chat-widget.js +1 -0
- package/dist/694.chat-widget.js +1 -0
- package/dist/chat-widget.js +1 -1
- package/lib/commonjs/api.js +4 -3
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/components/BetaNotice.js +38 -0
- package/lib/commonjs/components/BetaNotice.js.map +1 -0
- package/lib/commonjs/components/ChatHeader.js +27 -20
- package/lib/commonjs/components/ChatHeader.js.map +1 -1
- package/lib/commonjs/components/ChatInput.js +21 -21
- package/lib/commonjs/components/ChatInput.js.map +1 -1
- package/lib/commonjs/components/ChatWidget.js +119 -72
- package/lib/commonjs/components/ChatWidget.js.map +1 -1
- package/lib/commonjs/components/MessageBubble.js +26 -90
- package/lib/commonjs/components/MessageBubble.js.map +1 -1
- package/lib/commonjs/components/MessageMetaRow.js +135 -0
- package/lib/commonjs/components/MessageMetaRow.js.map +1 -0
- package/lib/commonjs/components/ProductsGrid.js +139 -0
- package/lib/commonjs/components/ProductsGrid.js.map +1 -0
- package/lib/commonjs/components/ProductsList.js +22 -126
- package/lib/commonjs/components/ProductsList.js.map +1 -1
- package/lib/commonjs/components/ProductsListView.js +139 -0
- package/lib/commonjs/components/ProductsListView.js.map +1 -0
- package/lib/commonjs/components/SuggestionsRow.js +41 -23
- package/lib/commonjs/components/SuggestionsRow.js.map +1 -1
- package/lib/commonjs/components/utils.js +4 -3
- package/lib/commonjs/components/utils.js.map +1 -1
- package/lib/commonjs/index.web.js +86 -29
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/theme.js +4 -4
- package/lib/commonjs/theme.js.map +1 -1
- package/lib/module/api.js +4 -3
- package/lib/module/api.js.map +1 -1
- package/lib/module/components/BetaNotice.js +30 -0
- package/lib/module/components/BetaNotice.js.map +1 -0
- package/lib/module/components/ChatHeader.js +27 -20
- package/lib/module/components/ChatHeader.js.map +1 -1
- package/lib/module/components/ChatInput.js +21 -21
- package/lib/module/components/ChatInput.js.map +1 -1
- package/lib/module/components/ChatWidget.js +120 -73
- package/lib/module/components/ChatWidget.js.map +1 -1
- package/lib/module/components/MessageBubble.js +26 -92
- package/lib/module/components/MessageBubble.js.map +1 -1
- package/lib/module/components/MessageMetaRow.js +127 -0
- package/lib/module/components/MessageMetaRow.js.map +1 -0
- package/lib/module/components/ProductsGrid.js +133 -0
- package/lib/module/components/ProductsGrid.js.map +1 -0
- package/lib/module/components/ProductsList.js +21 -126
- package/lib/module/components/ProductsList.js.map +1 -1
- package/lib/module/components/ProductsListView.js +132 -0
- package/lib/module/components/ProductsListView.js.map +1 -0
- package/lib/module/components/SuggestionsRow.js +41 -23
- package/lib/module/components/SuggestionsRow.js.map +1 -1
- package/lib/module/components/utils.js +4 -3
- package/lib/module/components/utils.js.map +1 -1
- package/lib/module/index.web.js +86 -29
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/theme.js +4 -4
- package/lib/module/theme.js.map +1 -1
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/components/BetaNotice.d.ts +5 -0
- package/lib/typescript/components/BetaNotice.d.ts.map +1 -0
- package/lib/typescript/components/ChatHeader.d.ts +5 -2
- package/lib/typescript/components/ChatHeader.d.ts.map +1 -1
- package/lib/typescript/components/ChatInput.d.ts.map +1 -1
- package/lib/typescript/components/ChatWidget.d.ts.map +1 -1
- package/lib/typescript/components/MessageBubble.d.ts +7 -3
- package/lib/typescript/components/MessageBubble.d.ts.map +1 -1
- package/lib/typescript/components/MessageMetaRow.d.ts +14 -0
- package/lib/typescript/components/MessageMetaRow.d.ts.map +1 -0
- package/lib/typescript/components/ProductsGrid.d.ts +10 -0
- package/lib/typescript/components/ProductsGrid.d.ts.map +1 -0
- package/lib/typescript/components/ProductsList.d.ts +4 -2
- package/lib/typescript/components/ProductsList.d.ts.map +1 -1
- package/lib/typescript/components/ProductsListView.d.ts +10 -0
- package/lib/typescript/components/ProductsListView.d.ts.map +1 -0
- package/lib/typescript/components/SuggestionsRow.d.ts +2 -0
- package/lib/typescript/components/SuggestionsRow.d.ts.map +1 -1
- package/lib/typescript/components/utils.d.ts +1 -0
- package/lib/typescript/components/utils.d.ts.map +1 -1
- package/lib/typescript/index.web.d.ts +1 -1
- package/lib/typescript/index.web.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +3 -1
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +4 -3
- package/src/components/BetaNotice.tsx +32 -0
- package/src/components/ChatHeader.tsx +32 -18
- package/src/components/ChatInput.tsx +20 -21
- package/src/components/ChatWidget.tsx +258 -220
- package/src/components/MessageBubble.tsx +44 -149
- package/src/components/MessageMetaRow.tsx +199 -0
- package/src/components/ProductsGrid.tsx +163 -0
- package/src/components/ProductsList.tsx +20 -146
- package/src/components/ProductsListView.tsx +149 -0
- package/src/components/SuggestionsRow.tsx +45 -21
- package/src/components/utils.ts +6 -4
- package/src/index.web.tsx +87 -32
- package/src/theme.ts +4 -4
- package/src/types.ts +3 -2
- package/dist/751.chat-widget.js +0 -1
- package/lib/commonjs/contexts/SegmentClientContext.js +0 -19
- package/lib/commonjs/contexts/SegmentClientContext.js.map +0 -1
- package/lib/module/contexts/SegmentClientContext.js +0 -10
- package/lib/module/contexts/SegmentClientContext.js.map +0 -1
- package/lib/typescript/contexts/SegmentClientContext.d.ts +0 -9
- package/lib/typescript/contexts/SegmentClientContext.d.ts.map +0 -1
- package/src/contexts/SegmentClientContext.tsx +0 -20
|
@@ -16,18 +16,33 @@ if (Platform.OS !== "web") {
|
|
|
16
16
|
const CloseIcon = () => {
|
|
17
17
|
return /*#__PURE__*/React.createElement(ImageComponent, {
|
|
18
18
|
source: {
|
|
19
|
-
uri: "
|
|
19
|
+
uri: "http://cdn.vdbapp.com/ai/chat-widget/assets/img/minus-cirlce.svg"
|
|
20
20
|
},
|
|
21
21
|
resizeMode: "contain",
|
|
22
22
|
style: {
|
|
23
23
|
width: 20,
|
|
24
|
-
height: 20
|
|
24
|
+
height: 20,
|
|
25
|
+
tintColor: "#ACACB3"
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
const VDBLogo = () => {
|
|
30
|
+
return /*#__PURE__*/React.createElement(ImageComponent, {
|
|
31
|
+
source: {
|
|
32
|
+
uri: "http://cdn.vdbapp.com/ai/chat-widget/assets/img/vdb.svg"
|
|
33
|
+
},
|
|
34
|
+
resizeMode: "contain",
|
|
35
|
+
style: {
|
|
36
|
+
width: 30,
|
|
37
|
+
height: 30,
|
|
38
|
+
marginRight: 10
|
|
25
39
|
}
|
|
26
40
|
});
|
|
27
41
|
};
|
|
28
42
|
const ChatHeader = ({
|
|
29
43
|
onClose,
|
|
30
|
-
onClearChat
|
|
44
|
+
onClearChat,
|
|
45
|
+
isBetaMode
|
|
31
46
|
}) => {
|
|
32
47
|
const {
|
|
33
48
|
trackEvent
|
|
@@ -36,19 +51,9 @@ const ChatHeader = ({
|
|
|
36
51
|
style: styles.container
|
|
37
52
|
}, /*#__PURE__*/React.createElement(View, {
|
|
38
53
|
style: styles.logoContainer
|
|
39
|
-
}, /*#__PURE__*/React.createElement(
|
|
40
|
-
source: {
|
|
41
|
-
uri: "https://getvdb.com/mail_images/web_app_favicon.ico"
|
|
42
|
-
},
|
|
43
|
-
resizeMode: "contain",
|
|
44
|
-
style: {
|
|
45
|
-
width: 30,
|
|
46
|
-
height: 30,
|
|
47
|
-
marginRight: 10
|
|
48
|
-
}
|
|
49
|
-
}), /*#__PURE__*/React.createElement(Text, {
|
|
54
|
+
}, /*#__PURE__*/React.createElement(VDBLogo, null), /*#__PURE__*/React.createElement(Text, {
|
|
50
55
|
style: styles.title
|
|
51
|
-
}, "AI Search")), /*#__PURE__*/React.createElement(View, {
|
|
56
|
+
}, isBetaMode ? "AI Search Beta" : "AI Search")), /*#__PURE__*/React.createElement(View, {
|
|
52
57
|
style: styles.buttonContainer
|
|
53
58
|
}, /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
54
59
|
onPress: () => {
|
|
@@ -70,19 +75,21 @@ const ChatHeader = ({
|
|
|
70
75
|
const styles = StyleSheet.create({
|
|
71
76
|
container: {
|
|
72
77
|
padding: 16,
|
|
73
|
-
backgroundColor: "#
|
|
78
|
+
backgroundColor: "#FFFFFF",
|
|
74
79
|
justifyContent: "space-between",
|
|
75
80
|
flexDirection: "row",
|
|
76
|
-
alignItems: "center"
|
|
81
|
+
alignItems: "center",
|
|
82
|
+
borderBottomWidth: 1,
|
|
83
|
+
borderBottomColor: "#E0E0E0"
|
|
77
84
|
},
|
|
78
85
|
logoContainer: {
|
|
79
86
|
flexDirection: "row",
|
|
80
87
|
alignItems: "center"
|
|
81
88
|
},
|
|
82
89
|
title: {
|
|
83
|
-
fontSize:
|
|
90
|
+
fontSize: 16,
|
|
84
91
|
fontWeight: "500",
|
|
85
|
-
color: "#
|
|
92
|
+
color: "#020001"
|
|
86
93
|
},
|
|
87
94
|
closeButton: {
|
|
88
95
|
backgroundColor: "#FFF",
|
|
@@ -103,7 +110,7 @@ const styles = StyleSheet.create({
|
|
|
103
110
|
color: "#FFF"
|
|
104
111
|
},
|
|
105
112
|
clearChatText: {
|
|
106
|
-
color: "#
|
|
113
|
+
color: "#4F4E57",
|
|
107
114
|
fontSize: 14,
|
|
108
115
|
fontWeight: "500",
|
|
109
116
|
textDecorationLine: "none"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["View","Text","StyleSheet","TouchableOpacity","Platform","Image","React","useUserAnalytics","AnalyticsEventNames","ImageComponent","OS","ExpoImage","require","CloseIcon","createElement","source","uri","resizeMode","style","width","height","ChatHeader","onClose","onClearChat","trackEvent","styles","container","logoContainer","
|
|
1
|
+
{"version":3,"names":["View","Text","StyleSheet","TouchableOpacity","Platform","Image","React","useUserAnalytics","AnalyticsEventNames","ImageComponent","OS","ExpoImage","require","CloseIcon","createElement","source","uri","resizeMode","style","width","height","tintColor","VDBLogo","marginRight","ChatHeader","onClose","onClearChat","isBetaMode","trackEvent","styles","container","logoContainer","title","buttonContainer","onPress","CHAT_CLEARED","console","log","clearChatText","closeButton","WIDGET_CLOSED","create","padding","backgroundColor","justifyContent","flexDirection","alignItems","borderBottomWidth","borderBottomColor","fontSize","fontWeight","color","borderRadius","closeIconText","textAlign","lineHeight","closeButtonText","textDecorationLine","gap"],"sourceRoot":"../../../src","sources":["components/ChatHeader.tsx"],"mappings":"AAAA,SACEA,IAAI,EACJC,IAAI,EACJC,UAAU,EACVC,gBAAgB,EAChBC,QAAQ,EACRC,KAAK,QACA,cAAc;AACrB,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,mBAAmB,QAAQ,SAAS;;AAE7C;AACA,IAAIC,cAA4B,GAAGJ,KAAK;AACxC,IAAID,QAAQ,CAACM,EAAE,KAAK,KAAK,EAAE;EACzB,IAAI;IACF,MAAMC,SAAS,GAAGC,OAAO,CAAC,YAAY,CAAC,CAACP,KAAK;IAC7C,IAAIM,SAAS,EAAEF,cAAc,GAAGE,SAAS;EAC3C,CAAC,CAAC,MAAM;IACN;EAAA;AAEJ;AAEA,MAAME,SAAS,GAAGA,CAAA,KAAM;EACtB,oBACEP,KAAA,CAAAQ,aAAA,CAACL,cAAc;IACbM,MAAM,EAAE;MACNC,GAAG,EAAE;IACP,CAAE;IACFC,UAAU,EAAC,SAAS;IACpBC,KAAK,EAAE;MAAEC,KAAK,EAAE,EAAE;MAAEC,MAAM,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAU;EAAE,CACxD,CAAC;AAEN,CAAC;AAED,MAAMC,OAAO,GAAGA,CAAA,KAAM;EACpB,oBACEhB,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pBC,UAAU,EAAE,QAAQ;IACpBY,GAAG,EAAE;EACP;AACF,CAAC,CAAC;AAEF,eAAelC,UAAU","ignoreList":[]}
|
|
@@ -17,12 +17,13 @@ const SendIcon = ({
|
|
|
17
17
|
const isInactive = disabled || isEmpty;
|
|
18
18
|
return /*#__PURE__*/React.createElement(ImageComponent, {
|
|
19
19
|
source: {
|
|
20
|
-
uri: "https://cdn.vdbapp.com/ai/chat-widget/assets/img/
|
|
20
|
+
uri: "https://cdn.vdbapp.com/ai/chat-widget/assets/img/send.svg"
|
|
21
21
|
},
|
|
22
22
|
resizeMode: "contain",
|
|
23
23
|
style: {
|
|
24
24
|
...styles.buttonIcon,
|
|
25
|
-
tintColor: isInactive ? "#
|
|
25
|
+
tintColor: isInactive ? "#ACACB3" : "#020001",
|
|
26
|
+
cursor: isInactive ? "auto" : "pointer"
|
|
26
27
|
}
|
|
27
28
|
});
|
|
28
29
|
};
|
|
@@ -37,7 +38,7 @@ export const ChatInput = ({
|
|
|
37
38
|
}) => {
|
|
38
39
|
const isInactive = disabled || value.trim() === "";
|
|
39
40
|
return /*#__PURE__*/React.createElement(View, {
|
|
40
|
-
style: [styles.
|
|
41
|
+
style: [styles.inputContainer, Platform.OS === "web" ? styles.webShadow : styles.nativeShadow]
|
|
41
42
|
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
42
43
|
ref: inputRef
|
|
43
44
|
// @ts-ignore - supported on web via react-native-web
|
|
@@ -52,10 +53,7 @@ export const ChatInput = ({
|
|
|
52
53
|
editable: !disabled,
|
|
53
54
|
autoFocus: true
|
|
54
55
|
}), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
55
|
-
style:
|
|
56
|
-
...styles.button,
|
|
57
|
-
backgroundColor: isInactive ? "#EDEDF2" : "#C000FF"
|
|
58
|
-
},
|
|
56
|
+
style: styles.button,
|
|
59
57
|
onPress: onSend,
|
|
60
58
|
disabled: disabled
|
|
61
59
|
}, /*#__PURE__*/React.createElement(SendIcon, {
|
|
@@ -64,17 +62,19 @@ export const ChatInput = ({
|
|
|
64
62
|
})));
|
|
65
63
|
};
|
|
66
64
|
const styles = StyleSheet.create({
|
|
67
|
-
|
|
65
|
+
inputContainer: {
|
|
68
66
|
flexDirection: "row",
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
paddingVertical: 0,
|
|
67
|
+
paddingHorizontal: 12,
|
|
68
|
+
paddingVertical: 16,
|
|
72
69
|
justifyContent: "space-between",
|
|
73
70
|
alignItems: "center",
|
|
74
71
|
alignSelf: "stretch",
|
|
75
|
-
|
|
72
|
+
flex: 1,
|
|
73
|
+
borderRadius: 8,
|
|
76
74
|
backgroundColor: "#FFF",
|
|
77
|
-
|
|
75
|
+
borderColor: "#ACACB3",
|
|
76
|
+
borderWidth: 1,
|
|
77
|
+
height: 56
|
|
78
78
|
},
|
|
79
79
|
webShadow: {
|
|
80
80
|
...(Platform.OS === "web" ? {
|
|
@@ -101,7 +101,7 @@ const styles = StyleSheet.create({
|
|
|
101
101
|
lineHeight: 20,
|
|
102
102
|
minHeight: 20,
|
|
103
103
|
maxHeight: 120,
|
|
104
|
-
paddingHorizontal:
|
|
104
|
+
paddingHorizontal: 0,
|
|
105
105
|
paddingVertical: 0,
|
|
106
106
|
backgroundColor: "transparent",
|
|
107
107
|
borderWidth: 0
|
|
@@ -114,18 +114,18 @@ const styles = StyleSheet.create({
|
|
|
114
114
|
} : {})
|
|
115
115
|
},
|
|
116
116
|
button: {
|
|
117
|
-
marginLeft:
|
|
118
|
-
padding:
|
|
117
|
+
marginLeft: 0,
|
|
118
|
+
padding: 0,
|
|
119
119
|
justifyContent: "center",
|
|
120
120
|
alignItems: "center",
|
|
121
|
-
height:
|
|
121
|
+
height: 24,
|
|
122
122
|
aspectRatio: 1,
|
|
123
|
-
borderRadius:
|
|
124
|
-
backgroundColor: "#
|
|
123
|
+
borderRadius: 0,
|
|
124
|
+
backgroundColor: "#FFFFFF"
|
|
125
125
|
},
|
|
126
126
|
buttonIcon: {
|
|
127
|
-
height:
|
|
128
|
-
width:
|
|
127
|
+
height: 24,
|
|
128
|
+
width: 24
|
|
129
129
|
},
|
|
130
130
|
sendIconText: {
|
|
131
131
|
fontSize: 18,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","View","TextInput","TouchableOpacity","StyleSheet","Platform","Image","ImageComponent","OS","ExpoImage","require","SendIcon","disabled","isEmpty","isInactive","createElement","source","uri","resizeMode","style","styles","buttonIcon","tintColor","ChatInput","value","onChangeText","onSend","placeholder","theme","inputRef","trim","
|
|
1
|
+
{"version":3,"names":["React","View","TextInput","TouchableOpacity","StyleSheet","Platform","Image","ImageComponent","OS","ExpoImage","require","SendIcon","disabled","isEmpty","isInactive","createElement","source","uri","resizeMode","style","styles","buttonIcon","tintColor","cursor","ChatInput","value","onChangeText","onSend","placeholder","theme","inputRef","trim","inputContainer","webShadow","nativeShadow","ref","id","input","inputWeb","placeholderTextColor","onSubmitEditing","editable","autoFocus","button","onPress","create","flexDirection","paddingHorizontal","paddingVertical","justifyContent","alignItems","alignSelf","flex","borderRadius","backgroundColor","borderColor","borderWidth","height","boxShadow","shadowColor","shadowOffset","width","shadowOpacity","shadowRadius","elevation","color","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","minHeight","maxHeight","outlineStyle","outlineWidth","marginLeft","padding","aspectRatio","sendIconText","textAlign"],"sourceRoot":"../../../src","sources":["components/ChatInput.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SACEC,IAAI,EACJC,SAAS,EACTC,gBAAgB,EAEhBC,UAAU,EACVC,QAAQ,EACRC,KAAK,QACA,cAAc;AAGrB;AACA,IAAIC,cAA4B,GAAGD,KAAK;AACxC,IAAID,QAAQ,CAACG,EAAE,KAAK,KAAK,EAAE;EACzB,IAAI;IACF,MAAMC,SAAS,GAAGC,OAAO,CAAC,YAAY,CAAC,CAACJ,KAAK;IAC7C,IAAIG,SAAS,EAAEF,cAAc,GAAGE,SAAS;EAC3C,CAA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E;IACdC,SAAS,EAAE,EAAE;IACbC,SAAS,EAAE,GAAG;IACdzB,iBAAiB,EAAE,CAAC;IACpBC,eAAe,EAAE,CAAC;IAClBM,eAAe,EAAE,aAAa;IAC9BE,WAAW,EAAE;EACf,CAAC;EACDlB,QAAQ,EAAE;IACR,IAAIjC,QAAQ,CAACG,EAAE,KAAK,KAAK,GACpB;MAAEiE,YAAY,EAAE,MAAM;MAAEC,YAAY,EAAE,CAAC;MAAEhB,SAAS,EAAE;IAAO,CAAC,GAC7D,CAAC,CAAC;EACR,CAAC;EACDf,MAAM,EAAE;IACNgC,UAAU,EAAE,CAAC;IACbC,OAAO,EAAE,CAAC;IACV3B,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE,QAAQ;IACpBO,MAAM,EAAE,EAAE;IACVoB,WAAW,EAAE,CAAC;IACdxB,YAAY,EAAE,CAAC;IACfC,eAAe,EAAE;EACnB,CAAC;EACDjC,UAAU,EAAE;IACVoC,MAAM,EAAE,EAAE;IACVI,KAAK,EAAE;EACT,CAAC;EACDiB,YAAY,EAAE;IACZX,QAAQ,EAAE,EAAE;IACZE,UAAU,EAAE,KAAK;IACjBU,SAAS,EAAE;EACb;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
2
|
-
import { View, StyleSheet, ScrollView, Text, DeviceEventEmitter, Platform } from "react-native";
|
|
2
|
+
import { View, StyleSheet, ScrollView, Text, KeyboardAvoidingView, DeviceEventEmitter, Platform } from "react-native";
|
|
3
3
|
import { ChatInput } from "./ChatInput";
|
|
4
4
|
import { MessageBubble } from "./MessageBubble";
|
|
5
|
+
import MessageMetaRow from "./MessageMetaRow";
|
|
5
6
|
import { mergeTheme } from "../theme";
|
|
6
7
|
import { fetchInitialMessages, getProducts, handleFeedbackActionApi, normaliseMessages, sendUserMessage } from "../api";
|
|
7
8
|
import ChatHeader from "./ChatHeader";
|
|
8
|
-
import
|
|
9
|
+
import BetaNotice from "./BetaNotice";
|
|
9
10
|
import ProductsList from "./ProductsList";
|
|
10
11
|
import { FeedbackAction, formatToTime, getUserDetails } from "./utils";
|
|
11
12
|
import { useUserAnalytics } from "../hooks/useAnalytics";
|
|
12
13
|
import { Storage } from "../storage";
|
|
13
14
|
export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
14
15
|
apiUrl,
|
|
15
|
-
userId: userIdProp,
|
|
16
16
|
userToken: userTokenProp,
|
|
17
17
|
priceMode: priceModeProp,
|
|
18
18
|
modalHeight,
|
|
@@ -22,7 +22,8 @@ export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
|
22
22
|
onClose,
|
|
23
23
|
onClearChat,
|
|
24
24
|
onViewAllPress,
|
|
25
|
-
onItemPress: onItemPressProp
|
|
25
|
+
onItemPress: onItemPressProp,
|
|
26
|
+
isBetaMode: isBetaModeProp
|
|
26
27
|
}, ref) => {
|
|
27
28
|
const [messages, setMessages] = useState(initialMessages);
|
|
28
29
|
const [input, setInput] = useState("");
|
|
@@ -34,8 +35,6 @@ export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
|
34
35
|
const [productsByMsg, setProductsByMsg] = useState({});
|
|
35
36
|
const [reloadLoadingIds, setReloadLoadingIds] = useState(new Set());
|
|
36
37
|
const [priceMode, setPriceMode] = useState(priceModeProp || null);
|
|
37
|
-
const [conversationId, setConversationId] = useState(null);
|
|
38
|
-
const [userId, setUserId] = useState(userIdProp || "");
|
|
39
38
|
const [userToken, setUserToken] = useState(userTokenProp || "");
|
|
40
39
|
const scrollRef = useRef(null);
|
|
41
40
|
const inputRef = useRef(null);
|
|
@@ -43,16 +42,11 @@ export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
|
43
42
|
const {
|
|
44
43
|
_identify
|
|
45
44
|
} = useUserAnalytics();
|
|
45
|
+
const betaActive = Boolean(isBetaModeProp);
|
|
46
46
|
// Load user auth data from storage on mount
|
|
47
47
|
useEffect(() => {
|
|
48
48
|
const loadAuthData = async () => {
|
|
49
49
|
try {
|
|
50
|
-
if (!userIdProp) {
|
|
51
|
-
const userData = await Storage.getJSON("userData", {});
|
|
52
|
-
if (userData?.id) {
|
|
53
|
-
setUserId(userData.id);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
50
|
if (!userTokenProp) {
|
|
57
51
|
const token = await Storage.getItem("token");
|
|
58
52
|
if (token) {
|
|
@@ -64,7 +58,7 @@ export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
|
64
58
|
}
|
|
65
59
|
};
|
|
66
60
|
loadAuthData();
|
|
67
|
-
}, [
|
|
61
|
+
}, [userTokenProp]);
|
|
68
62
|
const onViewAll = useCallback(() => {
|
|
69
63
|
const searchPayload = JSON.stringify(assistantResponse?.search_payload);
|
|
70
64
|
const payload = assistantResponse?.search_payload;
|
|
@@ -92,10 +86,10 @@ export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
|
92
86
|
window.open(deepLinkUrl, "_parent");
|
|
93
87
|
}
|
|
94
88
|
}, [apiUrl, priceMode, onItemPressProp]);
|
|
95
|
-
const hasAuth = useMemo(() => Boolean(
|
|
89
|
+
const hasAuth = useMemo(() => Boolean(userToken), [userToken]);
|
|
96
90
|
const apiParams = useMemo(() => ({
|
|
97
|
-
conversationId: userToken
|
|
98
|
-
}), [
|
|
91
|
+
conversationId: userToken
|
|
92
|
+
}), [userToken]);
|
|
99
93
|
const handleFeedbackAction = useCallback(async (action, conversation_id, message_id) => {
|
|
100
94
|
try {
|
|
101
95
|
// Use functional update to get current messages without dependency
|
|
@@ -128,7 +122,21 @@ export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
|
128
122
|
try {
|
|
129
123
|
const initial = await fetchInitialMessages(apiUrl, apiParams, priceMode);
|
|
130
124
|
if (!cancelled) {
|
|
131
|
-
|
|
125
|
+
const normalised = normaliseMessages(initial).reverse();
|
|
126
|
+
if (normalised.length === 0) {
|
|
127
|
+
const initialAssistant = {
|
|
128
|
+
id: "",
|
|
129
|
+
role: "assistant",
|
|
130
|
+
text: "Hello! How can I help you today?",
|
|
131
|
+
createdAt: Date.now(),
|
|
132
|
+
isLoading: false,
|
|
133
|
+
suggestions: ["Search Natural Diamonds", "Search Lab-Grown Diamonds"],
|
|
134
|
+
reaction: "0"
|
|
135
|
+
};
|
|
136
|
+
setMessages([initialAssistant]);
|
|
137
|
+
} else {
|
|
138
|
+
setMessages(normalised);
|
|
139
|
+
}
|
|
132
140
|
}
|
|
133
141
|
} catch (error) {
|
|
134
142
|
console.error("Failed to fetch initial messages", error);
|
|
@@ -156,6 +164,7 @@ export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
|
156
164
|
role: "assistant",
|
|
157
165
|
text: "Thinking",
|
|
158
166
|
createdAt: Date.now(),
|
|
167
|
+
reaction: "0",
|
|
159
168
|
isLoading: true
|
|
160
169
|
};
|
|
161
170
|
setMessages(prev => [...prev, userMessage, loadingMessage]);
|
|
@@ -195,10 +204,10 @@ export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
|
195
204
|
inputRef.current?.focus();
|
|
196
205
|
return;
|
|
197
206
|
}
|
|
198
|
-
setProductsByMsg({
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
});
|
|
207
|
+
setProductsByMsg(prev => ({
|
|
208
|
+
...prev,
|
|
209
|
+
[latestAssistant.id]: productsResult
|
|
210
|
+
}));
|
|
202
211
|
}
|
|
203
212
|
setLoadingMessageId(null);
|
|
204
213
|
setMessages(prev => prev.map(msg => msg.id === loadingId ? {
|
|
@@ -276,7 +285,7 @@ export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
|
276
285
|
useEffect(() => {
|
|
277
286
|
DeviceEventEmitter.addListener("clearChat", handleClearChat);
|
|
278
287
|
DeviceEventEmitter.addListener("changePriceMode", data => changePriceMode(data.priceMode));
|
|
279
|
-
changePriceMode(
|
|
288
|
+
changePriceMode();
|
|
280
289
|
identifySegmentUser();
|
|
281
290
|
return () => {
|
|
282
291
|
DeviceEventEmitter.removeAllListeners("clearChat");
|
|
@@ -284,37 +293,24 @@ export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
|
284
293
|
};
|
|
285
294
|
}, []);
|
|
286
295
|
const changePriceMode = async _priceMode => {
|
|
287
|
-
// Priority: passed argument > prop > storage
|
|
288
296
|
if (!_priceMode && priceModeProp) {
|
|
289
297
|
_priceMode = priceModeProp;
|
|
290
298
|
}
|
|
291
299
|
if (!_priceMode) {
|
|
292
|
-
|
|
300
|
+
let userData = await Storage.getJSON("persist:userInfo", {
|
|
301
|
+
user: undefined
|
|
302
|
+
});
|
|
303
|
+
userData = userData && userData.user ? JSON.parse(userData.user) : {};
|
|
293
304
|
_priceMode = userData?.price_mode;
|
|
294
305
|
}
|
|
295
|
-
setPriceMode(_priceMode
|
|
306
|
+
setPriceMode(_priceMode === undefined ? null : String(_priceMode));
|
|
296
307
|
};
|
|
297
|
-
|
|
298
|
-
// Update conversationId when priceMode changes
|
|
299
|
-
useEffect(() => {
|
|
300
|
-
const loadConversationId = async () => {
|
|
301
|
-
if (!priceMode) {
|
|
302
|
-
setConversationId(null);
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
const conversations = await Storage.getJSON("vdbchat_conversations", {});
|
|
306
|
-
const storedId = conversations?.[priceMode]?.conversation_id ?? null;
|
|
307
|
-
setConversationId(storedId ? String(storedId) : null);
|
|
308
|
-
};
|
|
309
|
-
loadConversationId();
|
|
310
|
-
}, [priceMode, messages]); // Re-fetch when messages change (new conversation might be created)
|
|
311
|
-
|
|
312
308
|
const handleClearChat = useCallback(async () => {
|
|
313
309
|
try {
|
|
314
310
|
const conversations = await Storage.getJSON("vdbchat_conversations", {});
|
|
315
|
-
const storedId = conversations
|
|
311
|
+
const storedId = conversations ? conversations[priceMode]?.conversation_id : null;
|
|
316
312
|
if (storedId && priceMode) {
|
|
317
|
-
const updatedConversations = conversations
|
|
313
|
+
const updatedConversations = conversations ?? {};
|
|
318
314
|
delete updatedConversations[priceMode];
|
|
319
315
|
await Storage.setJSON("vdbchat_conversations", updatedConversations);
|
|
320
316
|
}
|
|
@@ -327,30 +323,39 @@ export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
|
327
323
|
setTypingMessageId(null);
|
|
328
324
|
setTypingFullText("");
|
|
329
325
|
const fresh = await fetchInitialMessages(apiUrl, undefined, priceMode);
|
|
330
|
-
|
|
326
|
+
{
|
|
327
|
+
const normalised = normaliseMessages(fresh).reverse();
|
|
328
|
+
if (normalised.length === 0) {
|
|
329
|
+
const initialAssistant = {
|
|
330
|
+
id: "",
|
|
331
|
+
role: "assistant",
|
|
332
|
+
text: "Hello! How can I help you today?",
|
|
333
|
+
createdAt: Date.now(),
|
|
334
|
+
isLoading: false,
|
|
335
|
+
suggestions: ["Search Natural Diamonds", "Search Lab-Grown Diamonds"],
|
|
336
|
+
reaction: "0"
|
|
337
|
+
};
|
|
338
|
+
setMessages([initialAssistant]);
|
|
339
|
+
} else {
|
|
340
|
+
setMessages(normalised);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
331
343
|
onClearChat?.();
|
|
332
344
|
} catch (err) {
|
|
345
|
+
// eslint-disable-next-line no-console
|
|
333
346
|
console.error("Failed to clear chat", err);
|
|
334
347
|
}
|
|
335
|
-
}, [apiUrl,
|
|
336
|
-
|
|
337
|
-
// Expose clearChat method via ref for external use (React Native)
|
|
338
|
-
useImperativeHandle(ref, () => ({
|
|
339
|
-
clearChat: handleClearChat
|
|
340
|
-
}), [handleClearChat]);
|
|
348
|
+
}, [apiUrl, priceMode]);
|
|
341
349
|
|
|
342
350
|
// "Thinking..." dot animation while waiting for the API
|
|
343
351
|
useEffect(() => {
|
|
344
|
-
if (!loadingMessageId || typingMessageId)
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
352
|
+
if (!loadingMessageId || typingMessageId) return;
|
|
347
353
|
let step = 0;
|
|
348
354
|
const base = "Thinking";
|
|
349
|
-
const msgId = loadingMessageId;
|
|
350
355
|
const interval = setInterval(() => {
|
|
351
356
|
step = (step + 1) % 3;
|
|
352
357
|
const dots = ".".repeat(step + 1);
|
|
353
|
-
setMessages(prev => prev.map(msg => msg.id ===
|
|
358
|
+
setMessages(prev => prev.map(msg => msg.id === loadingMessageId && msg.isLoading ? {
|
|
354
359
|
...msg,
|
|
355
360
|
text: `${base}${dots}`
|
|
356
361
|
} : msg));
|
|
@@ -360,6 +365,11 @@ export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
|
360
365
|
};
|
|
361
366
|
}, [loadingMessageId, typingMessageId]);
|
|
362
367
|
|
|
368
|
+
// Expose clearChat method via ref for external use (React Native)
|
|
369
|
+
useImperativeHandle(ref, () => ({
|
|
370
|
+
clearChat: handleClearChat
|
|
371
|
+
}), [handleClearChat]);
|
|
372
|
+
|
|
363
373
|
// Typewriter-style animation for assistant reply once it arrives
|
|
364
374
|
const typingIndexRef = useRef(0);
|
|
365
375
|
useEffect(() => {
|
|
@@ -399,17 +409,25 @@ export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
|
399
409
|
}]
|
|
400
410
|
}, Platform.OS === "web" && /*#__PURE__*/React.createElement(ChatHeader, {
|
|
401
411
|
onClose: onClose,
|
|
402
|
-
onClearChat: handleClearChat
|
|
403
|
-
|
|
412
|
+
onClearChat: handleClearChat,
|
|
413
|
+
isBetaMode: betaActive
|
|
414
|
+
}), /*#__PURE__*/React.createElement(KeyboardAvoidingView, {
|
|
415
|
+
style: {
|
|
416
|
+
flex: 1
|
|
417
|
+
},
|
|
418
|
+
behavior: Platform.OS === "ios" ? "padding" : "height",
|
|
419
|
+
keyboardVerticalOffset: -16
|
|
420
|
+
}, /*#__PURE__*/React.createElement(ScrollView, {
|
|
404
421
|
ref: scrollRef,
|
|
422
|
+
keyboardShouldPersistTaps: "handled",
|
|
405
423
|
style: modalHeight ? {
|
|
406
424
|
height: modalHeight,
|
|
407
|
-
backgroundColor: "#
|
|
425
|
+
backgroundColor: "#FFFFFF"
|
|
408
426
|
} : {
|
|
409
|
-
backgroundColor: "#
|
|
427
|
+
backgroundColor: "#FFFFFF"
|
|
410
428
|
},
|
|
411
429
|
contentContainerStyle: {
|
|
412
|
-
backgroundColor: theme?.listContentBackgroundColor || "#
|
|
430
|
+
backgroundColor: theme?.listContentBackgroundColor || "#FFFFFF",
|
|
413
431
|
...styles.listContent,
|
|
414
432
|
justifyContent: messages.length === 0 ? "center" : "flex-end",
|
|
415
433
|
minHeight: modalHeight ? modalHeight : undefined
|
|
@@ -427,26 +445,42 @@ export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
|
427
445
|
const ordered = [...messages];
|
|
428
446
|
return ordered.map((item, index) => {
|
|
429
447
|
const isLatest = index === ordered.length - 1;
|
|
448
|
+
const hasDiamonds = Boolean(productsByMsg[item.id]?.response?.body?.diamonds && productsByMsg[item.id]?.response?.body?.diamonds.length > 0);
|
|
430
449
|
return /*#__PURE__*/React.createElement(View, {
|
|
431
|
-
key: item.id + index
|
|
450
|
+
key: item.id + index,
|
|
451
|
+
style: {
|
|
452
|
+
gap: 12
|
|
453
|
+
}
|
|
432
454
|
}, /*#__PURE__*/React.createElement(MessageBubble, {
|
|
433
455
|
message: item,
|
|
434
456
|
theme: theme,
|
|
435
|
-
|
|
457
|
+
priceMode: priceMode,
|
|
436
458
|
handleFeedbackAction: handleFeedbackAction,
|
|
437
459
|
onReloadResults: handleReloadResults,
|
|
438
460
|
reloading: reloadLoadingIds.has(item.id),
|
|
439
|
-
hasResults:
|
|
440
|
-
|
|
441
|
-
|
|
461
|
+
hasResults: hasDiamonds,
|
|
462
|
+
totalResults: productsByMsg[item.id]?.response?.header?.total_diamonds_found || 0,
|
|
463
|
+
shownResults: productsByMsg[item.id]?.response?.body?.diamonds.length || 0,
|
|
464
|
+
onSuggestionSelect: handleSuggestionSelect,
|
|
465
|
+
isLatest: isLatest,
|
|
466
|
+
isTyping: typingMessageId === item.id
|
|
467
|
+
}), item.role === "assistant" && hasDiamonds && /*#__PURE__*/React.createElement(ProductsList, {
|
|
468
|
+
data: productsByMsg[item.id]?.response?.body?.diamonds || [],
|
|
469
|
+
totalResults: productsByMsg[item.id]?.response?.header?.total_diamonds_found || 0,
|
|
442
470
|
onViewAll: onViewAll,
|
|
443
471
|
onItemPress: onItemPress
|
|
444
|
-
}),
|
|
445
|
-
|
|
446
|
-
|
|
472
|
+
}), /*#__PURE__*/React.createElement(MessageMetaRow, {
|
|
473
|
+
message: item,
|
|
474
|
+
priceMode: priceMode || "",
|
|
475
|
+
handleFeedbackAction: handleFeedbackAction,
|
|
476
|
+
onReloadResults: handleReloadResults,
|
|
477
|
+
reloading: reloadLoadingIds.has(item.id),
|
|
478
|
+
hasResults: hasDiamonds
|
|
447
479
|
}));
|
|
448
480
|
});
|
|
449
|
-
})()), /*#__PURE__*/React.createElement(
|
|
481
|
+
})()), /*#__PURE__*/React.createElement(View, {
|
|
482
|
+
style: styles.bottomContainer
|
|
483
|
+
}, /*#__PURE__*/React.createElement(ChatInput, {
|
|
450
484
|
value: input,
|
|
451
485
|
onChangeText: setInput,
|
|
452
486
|
onSend: handleSend,
|
|
@@ -454,7 +488,9 @@ export const ChatWidget = /*#__PURE__*/forwardRef(({
|
|
|
454
488
|
placeholder: placeholder,
|
|
455
489
|
theme: theme,
|
|
456
490
|
inputRef: inputRef
|
|
457
|
-
})
|
|
491
|
+
}), /*#__PURE__*/React.createElement(BetaNotice, {
|
|
492
|
+
active: betaActive
|
|
493
|
+
}))));
|
|
458
494
|
});
|
|
459
495
|
ChatWidget.displayName = "ChatWidget";
|
|
460
496
|
const styles = StyleSheet.create({
|
|
@@ -475,12 +511,23 @@ const styles = StyleSheet.create({
|
|
|
475
511
|
padding: 16,
|
|
476
512
|
alignItems: "center",
|
|
477
513
|
justifyContent: "center",
|
|
478
|
-
backgroundColor: "#
|
|
514
|
+
backgroundColor: "#FFFFFF"
|
|
479
515
|
},
|
|
480
516
|
emptyText: {
|
|
481
|
-
fontSize:
|
|
482
|
-
fontWeight: "
|
|
483
|
-
color: "#
|
|
517
|
+
fontSize: 13,
|
|
518
|
+
fontWeight: "400",
|
|
519
|
+
color: "#4F4E57"
|
|
520
|
+
},
|
|
521
|
+
bottomContainer: {
|
|
522
|
+
paddingVertical: 12,
|
|
523
|
+
paddingHorizontal: 16,
|
|
524
|
+
borderTopColor: "#E0E0E0",
|
|
525
|
+
borderTopWidth: 1,
|
|
526
|
+
flexDirection: "column",
|
|
527
|
+
justifyContent: "space-between",
|
|
528
|
+
alignItems: "center",
|
|
529
|
+
alignSelf: "stretch",
|
|
530
|
+
gap: 12
|
|
484
531
|
}
|
|
485
532
|
});
|
|
486
533
|
//# sourceMappingURL=ChatWidget.js.map
|