vdb-ai-chat 1.0.7 → 1.0.8
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/chat-widget.js +1 -1
- package/lib/commonjs/components/BetaNotice.js +13 -12
- package/lib/commonjs/components/BetaNotice.js.map +1 -1
- package/lib/commonjs/components/ChatInput.js +59 -49
- package/lib/commonjs/components/ChatInput.js.map +1 -1
- package/lib/commonjs/components/ChatWidget.js +72 -59
- package/lib/commonjs/components/ChatWidget.js.map +1 -1
- package/lib/commonjs/components/MessageBubble.js +67 -52
- package/lib/commonjs/components/MessageBubble.js.map +1 -1
- package/lib/commonjs/components/MessageMetaRow.js +50 -31
- package/lib/commonjs/components/MessageMetaRow.js.map +1 -1
- package/lib/commonjs/components/ProductsListView.js +232 -153
- package/lib/commonjs/components/ProductsListView.js.map +1 -1
- package/lib/commonjs/components/SuggestionsRow.js +27 -24
- package/lib/commonjs/components/SuggestionsRow.js.map +1 -1
- package/lib/commonjs/contexts/ThemeProvider.js +80 -0
- package/lib/commonjs/contexts/ThemeProvider.js.map +1 -0
- package/lib/commonjs/contexts/utils.js +142 -0
- package/lib/commonjs/contexts/utils.js.map +1 -0
- package/lib/module/components/BetaNotice.js +14 -13
- package/lib/module/components/BetaNotice.js.map +1 -1
- package/lib/module/components/ChatInput.js +61 -50
- package/lib/module/components/ChatInput.js.map +1 -1
- package/lib/module/components/ChatWidget.js +76 -61
- package/lib/module/components/ChatWidget.js.map +1 -1
- package/lib/module/components/MessageBubble.js +69 -52
- package/lib/module/components/MessageBubble.js.map +1 -1
- package/lib/module/components/MessageMetaRow.js +52 -32
- package/lib/module/components/MessageMetaRow.js.map +1 -1
- package/lib/module/components/ProductsListView.js +234 -154
- package/lib/module/components/ProductsListView.js.map +1 -1
- package/lib/module/components/SuggestionsRow.js +29 -25
- package/lib/module/components/SuggestionsRow.js.map +1 -1
- package/lib/module/contexts/ThemeProvider.js +75 -0
- package/lib/module/contexts/ThemeProvider.js.map +1 -0
- package/lib/module/contexts/utils.js +136 -0
- package/lib/module/contexts/utils.js.map +1 -0
- package/lib/typescript/components/BetaNotice.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 +1 -1
- package/lib/typescript/components/MessageBubble.d.ts.map +1 -1
- package/lib/typescript/components/MessageMetaRow.d.ts.map +1 -1
- package/lib/typescript/components/ProductsListView.d.ts.map +1 -1
- package/lib/typescript/components/SuggestionsRow.d.ts.map +1 -1
- package/lib/typescript/contexts/ThemeProvider.d.ts +7 -0
- package/lib/typescript/contexts/ThemeProvider.d.ts.map +1 -0
- package/lib/typescript/contexts/utils.d.ts +136 -0
- package/lib/typescript/contexts/utils.d.ts.map +1 -0
- package/package.json +6 -2
- package/src/components/BetaNotice.tsx +15 -13
- package/src/components/ChatInput.tsx +63 -62
- package/src/components/ChatWidget.tsx +238 -206
- package/src/components/MessageBubble.tsx +113 -74
- package/src/components/MessageMetaRow.tsx +80 -50
- package/src/components/ProductsListView.tsx +242 -183
- package/src/components/SuggestionsRow.tsx +40 -25
- package/src/contexts/ThemeProvider.tsx +87 -0
- package/src/contexts/utils.ts +135 -0
|
@@ -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
|
-
|
|
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
|
|
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
|
|
68
|
-
|
|
68
|
+
const theme = useTheme();
|
|
69
69
|
return (
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
<
|
|
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.
|
|
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
|
-
<
|
|
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
|
-
</
|
|
96
|
-
</
|
|
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,
|