vdb-ai-chat 1.0.78 → 1.0.80
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 +189 -164
- package/dist/chat-widget.js.LICENSE.txt +2 -0
- package/lib/commonjs/api.js +84 -4
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/components/ChatInput.js +227 -65
- package/lib/commonjs/components/ChatInput.js.map +1 -1
- package/lib/commonjs/components/ChatWidget.js +6 -2
- package/lib/commonjs/components/ChatWidget.js.map +1 -1
- package/lib/commonjs/components/MessageBubble.js +22 -2
- package/lib/commonjs/components/MessageBubble.js.map +1 -1
- package/lib/commonjs/components/icons/VDBCustomIcon.js +54 -0
- package/lib/commonjs/components/icons/VDBCustomIcon.js.map +1 -0
- package/lib/commonjs/components/icons/VDBIcon.js +141 -0
- package/lib/commonjs/components/icons/VDBIcon.js.map +1 -0
- package/lib/commonjs/components/icons/VDBIcons.js +16 -0
- package/lib/commonjs/components/icons/VDBIcons.js.map +1 -0
- package/lib/commonjs/components/icons/index.js +34 -0
- package/lib/commonjs/components/icons/index.js.map +1 -0
- package/lib/commonjs/index.js +29 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.native.js +30 -1
- package/lib/commonjs/index.native.js.map +1 -1
- package/lib/commonjs/routes.js +1 -0
- package/lib/commonjs/routes.js.map +1 -1
- package/lib/module/api.js +81 -5
- package/lib/module/api.js.map +1 -1
- package/lib/module/components/ChatInput.js +228 -66
- package/lib/module/components/ChatInput.js.map +1 -1
- package/lib/module/components/ChatWidget.js +6 -2
- package/lib/module/components/ChatWidget.js.map +1 -1
- package/lib/module/components/MessageBubble.js +22 -2
- package/lib/module/components/MessageBubble.js.map +1 -1
- package/lib/module/components/icons/VDBCustomIcon.js +47 -0
- package/lib/module/components/icons/VDBCustomIcon.js.map +1 -0
- package/lib/module/components/icons/VDBIcon.js +134 -0
- package/lib/module/components/icons/VDBIcon.js.map +1 -0
- package/lib/module/components/icons/VDBIcons.js +10 -0
- package/lib/module/components/icons/VDBIcons.js.map +1 -0
- package/lib/module/components/icons/index.js +3 -0
- package/lib/module/components/icons/index.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.native.js +1 -0
- package/lib/module/index.native.js.map +1 -1
- package/lib/module/routes.js +1 -0
- package/lib/module/routes.js.map +1 -1
- package/lib/typescript/api.d.ts +22 -0
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/components/ChatInput.d.ts +4 -0
- 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 +2 -0
- package/lib/typescript/components/MessageBubble.d.ts.map +1 -1
- package/lib/typescript/components/icons/VDBCustomIcon.d.ts +11 -0
- package/lib/typescript/components/icons/VDBCustomIcon.d.ts.map +1 -0
- package/lib/typescript/components/icons/VDBIcon.d.ts +34 -0
- package/lib/typescript/components/icons/VDBIcon.d.ts.map +1 -0
- package/lib/typescript/components/icons/VDBIcons.d.ts +9 -0
- package/lib/typescript/components/icons/VDBIcons.d.ts.map +1 -0
- package/lib/typescript/components/icons/index.d.ts +5 -0
- package/lib/typescript/components/icons/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/index.native.d.ts +2 -0
- package/lib/typescript/index.native.d.ts.map +1 -1
- package/lib/typescript/routes.d.ts +1 -0
- package/lib/typescript/routes.d.ts.map +1 -1
- package/package.json +18 -2
- package/src/api.ts +147 -3
- package/src/components/ChatInput.tsx +360 -83
- package/src/components/ChatWidget.tsx +9 -0
- package/src/components/MessageBubble.tsx +27 -1
- package/src/components/icons/VDBCustomIcon.tsx +74 -0
- package/src/components/icons/VDBIcon.tsx +186 -0
- package/src/components/icons/VDBIcons.ts +9 -0
- package/src/components/icons/index.ts +4 -0
- package/src/index.native.tsx +12 -0
- package/src/index.ts +12 -0
- package/src/routes.ts +1 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Image, ImageResizeMode, Platform } from "react-native";
|
|
3
|
+
import VDBCustomIcon from "./VDBCustomIcon";
|
|
4
|
+
|
|
5
|
+
let AntDesign: any = null;
|
|
6
|
+
let FontAwesome: any = null;
|
|
7
|
+
let FontAwesome5: any = null;
|
|
8
|
+
try {
|
|
9
|
+
const antDesignMod = require("@expo/vector-icons/build/AntDesign");
|
|
10
|
+
const faMod = require("@expo/vector-icons/build/FontAwesome");
|
|
11
|
+
const fa5Mod = require("@expo/vector-icons/build/FontAwesome5");
|
|
12
|
+
AntDesign = antDesignMod?.default ?? antDesignMod;
|
|
13
|
+
FontAwesome = faMod?.default ?? faMod;
|
|
14
|
+
FontAwesome5 = fa5Mod?.default ?? fa5Mod;
|
|
15
|
+
} catch {
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let SvgUri: any = null;
|
|
19
|
+
try {
|
|
20
|
+
SvgUri = require("react-native-svg").SvgUri;
|
|
21
|
+
} catch {
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let ImageComponent: typeof Image = Image;
|
|
25
|
+
let ExpoImage: any = null;
|
|
26
|
+
if (Platform.OS !== "web") {
|
|
27
|
+
try {
|
|
28
|
+
ExpoImage = require("expo-image").Image;
|
|
29
|
+
if (ExpoImage) ImageComponent = ExpoImage;
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export enum IconsVariant {
|
|
35
|
+
AntDesign = "AntDesign",
|
|
36
|
+
FontAwesome = "FontAwesome",
|
|
37
|
+
FontAwesome5 = "FontAwesome5",
|
|
38
|
+
VDBCustom = "VDBCustom",
|
|
39
|
+
CustomUrl = "CustomUrl",
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export enum IconsType {
|
|
43
|
+
img = "img",
|
|
44
|
+
svg = "svg",
|
|
45
|
+
img_url = "img-url",
|
|
46
|
+
svg_url = "svg-url",
|
|
47
|
+
url = "url",
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface IconProps {
|
|
51
|
+
variant: IconsVariant;
|
|
52
|
+
name?: string;
|
|
53
|
+
color?: string;
|
|
54
|
+
size?: number;
|
|
55
|
+
uri?: string;
|
|
56
|
+
height?: number;
|
|
57
|
+
resizeMode?: ImageResizeMode;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface CustomIconProps extends IconProps {
|
|
61
|
+
others?: object;
|
|
62
|
+
avoidSVGCheck?: boolean;
|
|
63
|
+
thumbSize?: number;
|
|
64
|
+
style?: any;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const isSvgUri = (uri?: string) =>
|
|
68
|
+
!!uri && uri.split(/[?#]/)[0].toLowerCase().endsWith(".svg");
|
|
69
|
+
|
|
70
|
+
const isGifUri = (uri?: string) =>
|
|
71
|
+
!!uri && uri.split(/[?#]/)[0].toLowerCase().endsWith(".gif");
|
|
72
|
+
|
|
73
|
+
const VDBIcon: React.FC<CustomIconProps> = ({
|
|
74
|
+
variant,
|
|
75
|
+
name,
|
|
76
|
+
size = 16,
|
|
77
|
+
height,
|
|
78
|
+
color,
|
|
79
|
+
uri,
|
|
80
|
+
others = {},
|
|
81
|
+
resizeMode = "contain",
|
|
82
|
+
avoidSVGCheck = false,
|
|
83
|
+
thumbSize,
|
|
84
|
+
style,
|
|
85
|
+
}) => {
|
|
86
|
+
const normalizedName =
|
|
87
|
+
typeof name === "string" ? name.toLowerCase() : (name as any);
|
|
88
|
+
|
|
89
|
+
switch (variant) {
|
|
90
|
+
case IconsVariant.AntDesign:
|
|
91
|
+
if (!AntDesign) return null;
|
|
92
|
+
return (
|
|
93
|
+
<AntDesign
|
|
94
|
+
name={normalizedName}
|
|
95
|
+
color={color}
|
|
96
|
+
size={size}
|
|
97
|
+
style={style}
|
|
98
|
+
{...others}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
case IconsVariant.FontAwesome:
|
|
103
|
+
if (!FontAwesome) return null;
|
|
104
|
+
return (
|
|
105
|
+
<FontAwesome
|
|
106
|
+
name={normalizedName}
|
|
107
|
+
color={color}
|
|
108
|
+
size={size}
|
|
109
|
+
style={style}
|
|
110
|
+
{...others}
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
case IconsVariant.FontAwesome5:
|
|
115
|
+
if (!FontAwesome5) return null;
|
|
116
|
+
return (
|
|
117
|
+
<FontAwesome5
|
|
118
|
+
name={normalizedName}
|
|
119
|
+
color={color}
|
|
120
|
+
size={size}
|
|
121
|
+
style={style}
|
|
122
|
+
{...others}
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
case IconsVariant.VDBCustom:
|
|
127
|
+
return (
|
|
128
|
+
<VDBCustomIcon
|
|
129
|
+
name={normalizedName}
|
|
130
|
+
size={size}
|
|
131
|
+
color={color}
|
|
132
|
+
style={style}
|
|
133
|
+
{...others}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
case IconsVariant.CustomUrl: {
|
|
138
|
+
if (!uri) return null;
|
|
139
|
+
if (isSvgUri(uri) && !avoidSVGCheck && SvgUri) {
|
|
140
|
+
return (
|
|
141
|
+
<SvgUri
|
|
142
|
+
width={size}
|
|
143
|
+
height={height ?? size}
|
|
144
|
+
uri={uri}
|
|
145
|
+
fill={color}
|
|
146
|
+
style={style}
|
|
147
|
+
{...others}
|
|
148
|
+
/>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (isGifUri(uri) && ExpoImage) {
|
|
153
|
+
const dim = thumbSize ?? size;
|
|
154
|
+
return (
|
|
155
|
+
<ExpoImage
|
|
156
|
+
source={uri}
|
|
157
|
+
style={[{ width: dim, height: height ?? dim }, style]}
|
|
158
|
+
contentFit="contain"
|
|
159
|
+
{...others}
|
|
160
|
+
/>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<ImageComponent
|
|
166
|
+
style={[
|
|
167
|
+
{
|
|
168
|
+
width: size,
|
|
169
|
+
height: height ?? size,
|
|
170
|
+
...(color ? { tintColor: color } : {}),
|
|
171
|
+
},
|
|
172
|
+
style,
|
|
173
|
+
]}
|
|
174
|
+
source={{ uri }}
|
|
175
|
+
resizeMode={resizeMode}
|
|
176
|
+
{...others}
|
|
177
|
+
/>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
default:
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export default VDBIcon;
|
package/src/index.native.tsx
CHANGED
|
@@ -4,3 +4,15 @@ export * from "./types";
|
|
|
4
4
|
export * from "./theme";
|
|
5
5
|
export { normaliseMessages } from "./api";
|
|
6
6
|
export { initStorage, isStorageInitialized, Storage } from "./storage";
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
VDBIcon,
|
|
10
|
+
VDBCustomIcon,
|
|
11
|
+
IconsVariant,
|
|
12
|
+
IconsType,
|
|
13
|
+
} from "./components/icons";
|
|
14
|
+
export type {
|
|
15
|
+
IconProps,
|
|
16
|
+
CustomIconProps,
|
|
17
|
+
VDBCustomIconProps,
|
|
18
|
+
} from "./components/icons";
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,18 @@ export * from "./theme";
|
|
|
5
5
|
export { normaliseMessages } from "./api";
|
|
6
6
|
export { initStorage, isStorageInitialized, Storage } from "./storage";
|
|
7
7
|
|
|
8
|
+
export {
|
|
9
|
+
VDBIcon,
|
|
10
|
+
VDBCustomIcon,
|
|
11
|
+
IconsVariant,
|
|
12
|
+
IconsType,
|
|
13
|
+
} from "./components/icons";
|
|
14
|
+
export type {
|
|
15
|
+
IconProps,
|
|
16
|
+
CustomIconProps,
|
|
17
|
+
VDBCustomIconProps,
|
|
18
|
+
} from "./components/icons";
|
|
19
|
+
|
|
8
20
|
// i18n exports
|
|
9
21
|
export {
|
|
10
22
|
initI18n,
|
package/src/routes.ts
CHANGED
|
@@ -2,6 +2,7 @@ const API_VERSION = "v3";
|
|
|
2
2
|
|
|
3
3
|
const Routes = {
|
|
4
4
|
AGENCT_CONVERSATIONS: (apiUrl: string) => `${apiUrl}${API_VERSION}/agent_conversations`,
|
|
5
|
+
TRANSCRIBE: (apiUrl: string) => `${apiUrl}${API_VERSION}/agent_conversations/transcribe`,
|
|
5
6
|
SEARCH_DIAMONDS: (apiUrl: string) => `${apiUrl}${API_VERSION}/vdb/search_diamonds`,
|
|
6
7
|
REACTION: (apiUrl: string, conversation_id: string, message_id: string) => `${apiUrl}${API_VERSION}/agent_conversations/${conversation_id}/conversation_messages/${message_id}/reaction`,
|
|
7
8
|
}
|