vdb-ai-chat 1.0.7 → 1.0.9

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 (65) hide show
  1. package/dist/chat-widget.js +1 -1
  2. package/lib/commonjs/api.js +19 -1
  3. package/lib/commonjs/api.js.map +1 -1
  4. package/lib/commonjs/components/BetaNotice.js +13 -12
  5. package/lib/commonjs/components/BetaNotice.js.map +1 -1
  6. package/lib/commonjs/components/ChatInput.js +59 -49
  7. package/lib/commonjs/components/ChatInput.js.map +1 -1
  8. package/lib/commonjs/components/ChatWidget.js +95 -63
  9. package/lib/commonjs/components/ChatWidget.js.map +1 -1
  10. package/lib/commonjs/components/MessageBubble.js +67 -52
  11. package/lib/commonjs/components/MessageBubble.js.map +1 -1
  12. package/lib/commonjs/components/MessageMetaRow.js +50 -31
  13. package/lib/commonjs/components/MessageMetaRow.js.map +1 -1
  14. package/lib/commonjs/components/ProductsListView.js +232 -153
  15. package/lib/commonjs/components/ProductsListView.js.map +1 -1
  16. package/lib/commonjs/components/SuggestionsRow.js +27 -24
  17. package/lib/commonjs/components/SuggestionsRow.js.map +1 -1
  18. package/lib/commonjs/contexts/ThemeProvider.js +80 -0
  19. package/lib/commonjs/contexts/ThemeProvider.js.map +1 -0
  20. package/lib/commonjs/contexts/utils.js +142 -0
  21. package/lib/commonjs/contexts/utils.js.map +1 -0
  22. package/lib/module/api.js +19 -1
  23. package/lib/module/api.js.map +1 -1
  24. package/lib/module/components/BetaNotice.js +14 -13
  25. package/lib/module/components/BetaNotice.js.map +1 -1
  26. package/lib/module/components/ChatInput.js +61 -50
  27. package/lib/module/components/ChatInput.js.map +1 -1
  28. package/lib/module/components/ChatWidget.js +99 -65
  29. package/lib/module/components/ChatWidget.js.map +1 -1
  30. package/lib/module/components/MessageBubble.js +69 -52
  31. package/lib/module/components/MessageBubble.js.map +1 -1
  32. package/lib/module/components/MessageMetaRow.js +52 -32
  33. package/lib/module/components/MessageMetaRow.js.map +1 -1
  34. package/lib/module/components/ProductsListView.js +234 -154
  35. package/lib/module/components/ProductsListView.js.map +1 -1
  36. package/lib/module/components/SuggestionsRow.js +29 -25
  37. package/lib/module/components/SuggestionsRow.js.map +1 -1
  38. package/lib/module/contexts/ThemeProvider.js +75 -0
  39. package/lib/module/contexts/ThemeProvider.js.map +1 -0
  40. package/lib/module/contexts/utils.js +136 -0
  41. package/lib/module/contexts/utils.js.map +1 -0
  42. package/lib/typescript/api.d.ts.map +1 -1
  43. package/lib/typescript/components/BetaNotice.d.ts.map +1 -1
  44. package/lib/typescript/components/ChatInput.d.ts.map +1 -1
  45. package/lib/typescript/components/ChatWidget.d.ts.map +1 -1
  46. package/lib/typescript/components/MessageBubble.d.ts +1 -1
  47. package/lib/typescript/components/MessageBubble.d.ts.map +1 -1
  48. package/lib/typescript/components/MessageMetaRow.d.ts.map +1 -1
  49. package/lib/typescript/components/ProductsListView.d.ts.map +1 -1
  50. package/lib/typescript/components/SuggestionsRow.d.ts.map +1 -1
  51. package/lib/typescript/contexts/ThemeProvider.d.ts +7 -0
  52. package/lib/typescript/contexts/ThemeProvider.d.ts.map +1 -0
  53. package/lib/typescript/contexts/utils.d.ts +136 -0
  54. package/lib/typescript/contexts/utils.d.ts.map +1 -0
  55. package/package.json +6 -2
  56. package/src/api.ts +24 -0
  57. package/src/components/BetaNotice.tsx +15 -13
  58. package/src/components/ChatInput.tsx +63 -62
  59. package/src/components/ChatWidget.tsx +264 -216
  60. package/src/components/MessageBubble.tsx +113 -74
  61. package/src/components/MessageMetaRow.tsx +80 -50
  62. package/src/components/ProductsListView.tsx +242 -183
  63. package/src/components/SuggestionsRow.tsx +40 -25
  64. package/src/contexts/ThemeProvider.tsx +87 -0
  65. package/src/contexts/utils.ts +135 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/contexts/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsIzB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vdb-ai-chat",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Cross-platform AI chat widget for React Native and Web",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -61,8 +61,12 @@
61
61
  }
62
62
  },
63
63
  "dependencies": {
64
+ "@types/styled-components": "^5.1.36",
65
+ "@types/styled-components-react-native": "^5.2.5",
66
+ "expo-device": "^8.0.10",
64
67
  "react-native-web": "^0.19.13",
65
- "react-responsive": "^10.0.1"
68
+ "react-responsive": "^10.0.1",
69
+ "styled-components": "^6.1.19"
66
70
  },
67
71
  "devDependencies": {
68
72
  "@babel/core": "^7.26.0",
package/src/api.ts CHANGED
@@ -251,6 +251,18 @@ export async function getProducts(
251
251
  });
252
252
  }
253
253
 
254
+ let depth_percent_from: number | undefined;
255
+ let depth_percent_to: number | undefined;
256
+ let table_percent_from: number | undefined;
257
+ let table_percent_to: number | undefined;
258
+
259
+ if (userInfo?.user?.max_search_key_values) {
260
+ depth_percent_from = userInfo.user.max_search_key_values.min_depth;
261
+ depth_percent_to = userInfo.user.max_search_key_values.max_depth;
262
+ table_percent_from = userInfo.user.max_search_key_values.min_table;
263
+ table_percent_to = userInfo.user.max_search_key_values.max_table;
264
+ }
265
+
254
266
  const res = await fetch(
255
267
  "https://pdpdemo1.demo.customvirtual.app/v3/vdb/search_diamonds",
256
268
  {
@@ -268,6 +280,18 @@ export async function getProducts(
268
280
  pair: sectionName === "Single Stones" ? "other" : "pair",
269
281
  with_available_items: false,
270
282
  page_number: 1,
283
+ ...(depth_percent_from !== undefined && depth_percent_to !== undefined
284
+ ? {
285
+ depth_percent_from: depth_percent_from,
286
+ depth_percent_to: depth_percent_to,
287
+ }
288
+ : {}),
289
+ ...(table_percent_from !== undefined && table_percent_to !== undefined
290
+ ? {
291
+ table_percent_from: table_percent_from,
292
+ table_percent_to: table_percent_to,
293
+ }
294
+ : {}),
271
295
  },
272
296
  }),
273
297
  }
@@ -1,17 +1,28 @@
1
1
  import React from "react";
2
- import { View, Text, StyleSheet } from "react-native";
2
+ import { View, StyleSheet } from "react-native";
3
+ import styled from "styled-components/native";
4
+ import { DefaultTheme } from "styled-components/native";
3
5
 
4
6
  export const BetaNotice = ({ active }: { active?: boolean }) => {
5
7
  if (!active) return null;
6
8
  return (
7
9
  <View style={styles.container}>
8
- <Text style={styles.text}>
9
- This AI feature is in beta and may make mistakes.
10
- </Text>
10
+ <TextView>This AI feature is in beta and may make mistakes.</TextView>
11
11
  </View>
12
12
  );
13
13
  };
14
14
 
15
+ const TextView = styled.Text<{ theme: DefaultTheme }>`
16
+ color: ${({ theme }: { theme: DefaultTheme }) =>
17
+ theme["core-06"] || "#4F4E57"};
18
+ font-family: "Roboto";
19
+ font-size: 13px;
20
+ font-style: normal;
21
+ font-weight: 400;
22
+ line-height: 18px;
23
+ text-align: center;
24
+ `;
25
+
15
26
  const styles = StyleSheet.create({
16
27
  container: {
17
28
  alignSelf: "stretch",
@@ -21,15 +32,6 @@ const styles = StyleSheet.create({
21
32
  alignItems: "center",
22
33
  justifyContent: "center",
23
34
  },
24
- text: {
25
- color: "#4F4E57",
26
- fontFamily: "Roboto",
27
- fontSize: 13,
28
- fontStyle: "normal",
29
- fontWeight: "400",
30
- lineHeight: 18,
31
- textAlign: "center",
32
- },
33
35
  });
34
36
 
35
37
  export default BetaNotice;
@@ -1,14 +1,14 @@
1
1
  import React from "react";
2
2
  import {
3
- View,
4
3
  TextInput,
5
- TouchableOpacity,
6
- Text,
7
4
  StyleSheet,
8
5
  Platform,
9
6
  Image,
10
7
  } from "react-native";
11
8
  import type { ChatTheme } from "../types";
9
+ import { useTheme } from "styled-components/native";
10
+ import { DefaultTheme } from "styled-components/native";
11
+ import styled from "styled-components/native";
12
12
 
13
13
  // Use expo-image on native if available, fallback to RN Image
14
14
  let ImageComponent: typeof Image = Image;
@@ -17,7 +17,7 @@ if (Platform.OS !== "web") {
17
17
  const ExpoImage = require("expo-image").Image;
18
18
  if (ExpoImage) ImageComponent = ExpoImage;
19
19
  } catch {
20
- // expo-image not installed, use React Native Image
20
+ ImageComponent = Image;
21
21
  }
22
22
  }
23
23
 
@@ -39,7 +39,7 @@ const SendIcon = ({
39
39
  isEmpty: boolean;
40
40
  }) => {
41
41
  const isInactive = disabled || isEmpty;
42
-
42
+ const theme = useTheme();
43
43
  return (
44
44
  <ImageComponent
45
45
  source={{
@@ -48,7 +48,9 @@ const SendIcon = ({
48
48
  resizeMode="contain"
49
49
  style={{
50
50
  ...styles.buttonIcon,
51
- tintColor: isInactive ? "#ACACB3" : "#020001",
51
+ tintColor: isInactive
52
+ ? theme["core-04"] || "#ACACB3"
53
+ : theme["core-05"] || "#020001",
52
54
  cursor: isInactive ? "auto" : "pointer",
53
55
  }}
54
56
  />
@@ -61,56 +63,80 @@ export const ChatInput: React.FC<Props> = ({
61
63
  onSend,
62
64
  disabled,
63
65
  placeholder,
64
- theme,
65
66
  inputRef,
66
67
  }) => {
67
- const isInactive = disabled || value.trim() === "";
68
-
68
+ const theme = useTheme();
69
69
  return (
70
- <View
71
- style={[
72
- styles.inputContainer,
73
- Platform.OS === "web" ? styles.webShadow : styles.nativeShadow,
74
- ]}
70
+ <InputContainer
71
+ theme={theme}
72
+ style={[Platform.OS === "web" ? styles.webShadow : styles.nativeShadow]}
75
73
  >
76
- <TextInput
74
+ <Input
77
75
  ref={inputRef}
78
76
  // @ts-ignore - supported on web via react-native-web
79
77
  id="chat-input"
80
- style={[styles.input, styles.inputWeb]}
78
+ style={[styles.inputWeb]}
81
79
  placeholder={placeholder || "What are you looking for?"}
82
- placeholderTextColor="#999"
80
+ placeholderTextColor={theme["core-06"] || "#999"}
83
81
  value={value}
84
82
  onChangeText={onChangeText}
85
83
  onSubmitEditing={onSend}
86
84
  editable={!disabled}
87
85
  autoFocus
88
86
  />
89
- <TouchableOpacity
90
- style={styles.button}
91
- onPress={onSend}
92
- disabled={disabled}
93
- >
87
+ <SendButton onPress={onSend} disabled={disabled}>
94
88
  <SendIcon disabled={disabled} isEmpty={value.trim() === ""} />
95
- </TouchableOpacity>
96
- </View>
89
+ </SendButton>
90
+ </InputContainer>
97
91
  );
98
92
  };
99
93
 
94
+ const InputContainer = styled.View<{ theme: DefaultTheme }>`
95
+ flex-direction: row;
96
+ padding-horizontal: 12px;
97
+ padding-vertical: 16px;
98
+ justify-content: space-between;
99
+ align-items: center;
100
+ align-self: stretch;
101
+ border-radius: 8px;
102
+ background-color: ${({ theme }: { theme: DefaultTheme }) =>
103
+ theme["core-01"] || "#FFFFFF"};
104
+ border-color: ${({ theme }: { theme: DefaultTheme }) =>
105
+ theme["core-04"] || "#ACACB3"};
106
+ border-width: 1;
107
+ height: 56px;
108
+ `;
109
+
110
+ const Input = styled.TextInput<{ theme: DefaultTheme }>`
111
+ flex: 1;
112
+ color: ${({ theme }: { theme: DefaultTheme }) =>
113
+ theme["core-06"] || "#4F4E57"};
114
+ font-family: "Roboto";
115
+ font-size: 14px;
116
+ font-style: normal;
117
+ font-weight: 400;
118
+ line-height: 20px;
119
+ min-height: 20px;
120
+ max-height: 120px;
121
+ padding-horizontal: 0;
122
+ padding-vertical: 0;
123
+ background-color: transparent;
124
+ border-width: 0;
125
+ `;
126
+
127
+ const SendButton = styled.TouchableOpacity<{ theme: DefaultTheme }>`
128
+ margin-left: 0;
129
+ padding: 0;
130
+ justify-content: center;
131
+ align-items: center;
132
+ height: 24;
133
+ aspect-ratio: 1;
134
+ border-radius: 0px;
135
+ background-color: ${({ theme }: { theme: DefaultTheme }) =>
136
+ theme["core-01"] || "#FFFFFF"};
137
+ `;
138
+
100
139
  const styles = StyleSheet.create({
101
- inputContainer: {
102
- flexDirection: "row",
103
- paddingHorizontal: 12,
104
- paddingVertical: 16,
105
- justifyContent: "space-between",
106
- alignItems: "center",
107
- alignSelf: "stretch",
108
- borderRadius: 8,
109
- backgroundColor: "#FFF",
110
- borderColor: "#ACACB3",
111
- borderWidth: 1,
112
- height: 56,
113
- },
114
140
  webShadow: {
115
141
  ...(Platform.OS === "web"
116
142
  ? ({ boxShadow: "2px 8px 24px -6px rgba(55, 54, 64, 0.26)" } as any)
@@ -123,36 +149,11 @@ const styles = StyleSheet.create({
123
149
  shadowRadius: 12,
124
150
  elevation: 3,
125
151
  },
126
- input: {
127
- flex: 1,
128
- color: "#4F4E57",
129
- fontFamily: "Roboto",
130
- fontSize: 14,
131
- fontStyle: "normal",
132
- fontWeight: "400",
133
- lineHeight: 20,
134
- minHeight: 20,
135
- maxHeight: 120,
136
- paddingHorizontal: 0,
137
- paddingVertical: 0,
138
- backgroundColor: "transparent",
139
- borderWidth: 0,
140
- },
141
152
  inputWeb: {
142
153
  ...(Platform.OS === "web"
143
154
  ? ({ outlineStyle: "none", outlineWidth: 0, boxShadow: "none" } as any)
144
155
  : {}),
145
156
  },
146
- button: {
147
- marginLeft: 0,
148
- padding: 0,
149
- justifyContent: "center",
150
- alignItems: "center",
151
- height: 24,
152
- aspectRatio: 1,
153
- borderRadius: 0,
154
- backgroundColor: "#FFFFFF",
155
- },
156
157
  buttonIcon: {
157
158
  height: 24,
158
159
  width: 24,