bibot 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.babelrc +7 -0
- package/.vscode/settings.json +5 -0
- package/README.md +46 -0
- package/dist/bibot.d.ts +5 -0
- package/dist/bibot.js +173 -0
- package/dist/bibot.js.map +1 -0
- package/dist/config/appStateEnums.d.ts +3 -0
- package/dist/config/appStateEnums.js +10 -0
- package/dist/config/appStateEnums.js.map +1 -0
- package/dist/config/endpointEnums.d.ts +18 -0
- package/dist/config/endpointEnums.js +31 -0
- package/dist/config/endpointEnums.js.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +38 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/statusCode.d.ts +42 -0
- package/dist/config/statusCode.js +49 -0
- package/dist/config/statusCode.js.map +1 -0
- package/dist/context/AppContext.d.ts +8 -0
- package/dist/context/AppContext.js +75 -0
- package/dist/context/AppContext.js.map +1 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.js +16 -0
- package/dist/context/index.js.map +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +38 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/mobileView.d.ts +1 -0
- package/dist/hooks/mobileView.js +33 -0
- package/dist/hooks/mobileView.js.map +1 -0
- package/dist/hooks/useBiBotChatBot.d.ts +29 -0
- package/dist/hooks/useBiBotChatBot.js +206 -0
- package/dist/hooks/useBiBotChatBot.js.map +1 -0
- package/dist/hooks/usePluginFactory.d.ts +1 -0
- package/dist/hooks/usePluginFactory.js +62 -0
- package/dist/hooks/usePluginFactory.js.map +1 -0
- package/dist/index.css +36 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/reducers/appReducer.d.ts +2 -0
- package/dist/reducers/appReducer.js +24 -0
- package/dist/reducers/appReducer.js.map +1 -0
- package/dist/reducers/index.d.ts +1 -0
- package/dist/reducers/index.js +16 -0
- package/dist/reducers/index.js.map +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +16 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/plugin-api.d.ts +26 -0
- package/dist/services/plugin-api.js +185 -0
- package/dist/services/plugin-api.js.map +1 -0
- package/dist/styles/RegisterPageStyle.css +63 -0
- package/dist/styles/adminPortal.css +26 -0
- package/dist/styles/appConfig.css +90 -0
- package/dist/styles/buttonStyle.css +27 -0
- package/dist/styles/chatStyle.css +140 -0
- package/dist/styles/index.css +82 -0
- package/dist/styles/predefinedStyle.css +35 -0
- package/dist/styles/themeStyle.css +42 -0
- package/dist/styles/training.css +86 -0
- package/dist/types/coreInterfaces.d.ts +51 -0
- package/dist/types/coreInterfaces.js +5 -0
- package/dist/types/coreInterfaces.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +16 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +27 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/sessionManager.d.ts +2 -0
- package/dist/utils/sessionManager.js +17 -0
- package/dist/utils/sessionManager.js.map +1 -0
- package/dist/utils/trimWhitespace.d.ts +2 -0
- package/dist/utils/trimWhitespace.js +15 -0
- package/dist/utils/trimWhitespace.js.map +1 -0
- package/example/README.md +46 -0
- package/example/package-lock.json +18164 -0
- package/example/package.json +46 -0
- package/example/public/favicon.ico +0 -0
- package/example/public/index.html +43 -0
- package/example/public/logo192.png +0 -0
- package/example/public/logo512.png +0 -0
- package/example/public/manifest.json +25 -0
- package/example/public/robots.txt +3 -0
- package/example/src/App.css +38 -0
- package/example/src/App.test.tsx +9 -0
- package/example/src/App.tsx +28 -0
- package/example/src/index.css +13 -0
- package/example/src/index.tsx +13 -0
- package/example/src/logo.svg +1 -0
- package/example/src/react-app-env.d.ts +1 -0
- package/example/tsconfig.json +26 -0
- package/package.json +28 -8
- package/src/bibot.tsx +111 -0
- package/src/config/appStateEnums.ts +3 -0
- package/src/config/endpointEnums.ts +28 -0
- package/src/config/index.ts +5 -0
- package/src/config/statusCode.ts +49 -0
- package/src/context/AppContext.tsx +66 -0
- package/src/context/index.ts +3 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/mobileView.tsx +17 -0
- package/src/hooks/useBiBotChatBot.tsx +107 -0
- package/src/hooks/usePluginFactory.tsx +38 -0
- package/src/index.css +36 -0
- package/src/index.tsx +3 -11
- package/src/reducers/appReducer.ts +16 -0
- package/src/reducers/index.ts +4 -0
- package/src/services/index.ts +2 -0
- package/src/services/plugin-api.tsx +120 -0
- package/src/styles/RegisterPageStyle.css +63 -0
- package/src/styles/adminPortal.css +26 -0
- package/src/styles/appConfig.css +90 -0
- package/src/styles/buttonStyle.css +27 -0
- package/src/styles/chatStyle.css +140 -0
- package/src/styles/index.css +82 -0
- package/src/styles/predefinedStyle.css +35 -0
- package/src/styles/themeStyle.css +42 -0
- package/src/styles/training.css +86 -0
- package/src/types/coreInterfaces.ts +69 -0
- package/src/types/index.ts +4 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/sessionManager.tsx +15 -0
- package/src/utils/trimWhitespace.ts +11 -0
- package/tsconfig.json +25 -0
- package/webpack.config.js +19 -0
- package/src/App.tsx +0 -11
@@ -0,0 +1,46 @@
|
|
1
|
+
{
|
2
|
+
"name": "example",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"private": true,
|
5
|
+
"dependencies": {
|
6
|
+
"@testing-library/jest-dom": "^5.17.0",
|
7
|
+
"@testing-library/react": "^13.4.0",
|
8
|
+
"@testing-library/user-event": "^13.5.0",
|
9
|
+
"@types/jest": "^27.5.2",
|
10
|
+
"@types/node": "^16.18.97",
|
11
|
+
"@types/react": "^18.3.1",
|
12
|
+
"@types/react-dom": "^18.3.0",
|
13
|
+
"react": "^18.3.1",
|
14
|
+
"react-dom": "^18.3.1",
|
15
|
+
"react-scripts": "5.0.1",
|
16
|
+
"typescript": "^4.9.5",
|
17
|
+
"web-vitals": "^2.1.4"
|
18
|
+
},
|
19
|
+
"scripts": {
|
20
|
+
"start": "react-scripts start",
|
21
|
+
"build": "react-scripts build",
|
22
|
+
"test": "react-scripts test",
|
23
|
+
"eject": "react-scripts eject"
|
24
|
+
},
|
25
|
+
"eslintConfig": {
|
26
|
+
"extends": [
|
27
|
+
"react-app",
|
28
|
+
"react-app/jest"
|
29
|
+
]
|
30
|
+
},
|
31
|
+
"browserslist": {
|
32
|
+
"production": [
|
33
|
+
">0.2%",
|
34
|
+
"not dead",
|
35
|
+
"not op_mini all"
|
36
|
+
],
|
37
|
+
"development": [
|
38
|
+
"last 1 chrome version",
|
39
|
+
"last 1 firefox version",
|
40
|
+
"last 1 safari version"
|
41
|
+
]
|
42
|
+
},
|
43
|
+
"devDependencies": {
|
44
|
+
"@babel/plugin-proposal-private-property-in-object": "^7.21.11"
|
45
|
+
}
|
46
|
+
}
|
Binary file
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
7
|
+
<meta name="theme-color" content="#000000" />
|
8
|
+
<meta
|
9
|
+
name="description"
|
10
|
+
content="Web site created using create-react-app"
|
11
|
+
/>
|
12
|
+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
13
|
+
<!--
|
14
|
+
manifest.json provides metadata used when your web app is installed on a
|
15
|
+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
16
|
+
-->
|
17
|
+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
18
|
+
<!--
|
19
|
+
Notice the use of %PUBLIC_URL% in the tags above.
|
20
|
+
It will be replaced with the URL of the `public` folder during the build.
|
21
|
+
Only files inside the `public` folder can be referenced from the HTML.
|
22
|
+
|
23
|
+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
24
|
+
work correctly both with client-side routing and a non-root public URL.
|
25
|
+
Learn how to configure a non-root public URL by running `npm run build`.
|
26
|
+
-->
|
27
|
+
<title>React App</title>
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<noscript>You need to enable JavaScript to run this app.</noscript>
|
31
|
+
<div id="root"></div>
|
32
|
+
<!--
|
33
|
+
This HTML file is a template.
|
34
|
+
If you open it directly in the browser, you will see an empty page.
|
35
|
+
|
36
|
+
You can add webfonts, meta tags, or analytics to this file.
|
37
|
+
The build step will place the bundled scripts into the <body> tag.
|
38
|
+
|
39
|
+
To begin the development, run `npm start` or `yarn start`.
|
40
|
+
To create a production bundle, use `npm run build` or `yarn build`.
|
41
|
+
-->
|
42
|
+
</body>
|
43
|
+
</html>
|
Binary file
|
Binary file
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"short_name": "React App",
|
3
|
+
"name": "Create React App Sample",
|
4
|
+
"icons": [
|
5
|
+
{
|
6
|
+
"src": "favicon.ico",
|
7
|
+
"sizes": "64x64 32x32 24x24 16x16",
|
8
|
+
"type": "image/x-icon"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"src": "logo192.png",
|
12
|
+
"type": "image/png",
|
13
|
+
"sizes": "192x192"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"src": "logo512.png",
|
17
|
+
"type": "image/png",
|
18
|
+
"sizes": "512x512"
|
19
|
+
}
|
20
|
+
],
|
21
|
+
"start_url": ".",
|
22
|
+
"display": "standalone",
|
23
|
+
"theme_color": "#000000",
|
24
|
+
"background_color": "#ffffff"
|
25
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
.App {
|
2
|
+
text-align: center;
|
3
|
+
}
|
4
|
+
|
5
|
+
.App-logo {
|
6
|
+
height: 40vmin;
|
7
|
+
pointer-events: none;
|
8
|
+
}
|
9
|
+
|
10
|
+
@media (prefers-reduced-motion: no-preference) {
|
11
|
+
.App-logo {
|
12
|
+
animation: App-logo-spin infinite 20s linear;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
.App-header {
|
17
|
+
background-color: #282c34;
|
18
|
+
min-height: 100vh;
|
19
|
+
display: flex;
|
20
|
+
flex-direction: column;
|
21
|
+
align-items: center;
|
22
|
+
justify-content: center;
|
23
|
+
font-size: calc(10px + 2vmin);
|
24
|
+
color: white;
|
25
|
+
}
|
26
|
+
|
27
|
+
.App-link {
|
28
|
+
color: #61dafb;
|
29
|
+
}
|
30
|
+
|
31
|
+
@keyframes App-logo-spin {
|
32
|
+
from {
|
33
|
+
transform: rotate(0deg);
|
34
|
+
}
|
35
|
+
to {
|
36
|
+
transform: rotate(360deg);
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render, screen } from '@testing-library/react';
|
3
|
+
import App from './App';
|
4
|
+
|
5
|
+
test('renders learn react link', () => {
|
6
|
+
render(<App />);
|
7
|
+
const linkElement = screen.getByText(/learn react/i);
|
8
|
+
expect(linkElement).toBeInTheDocument();
|
9
|
+
});
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import logo from './logo.svg';
|
3
|
+
import './App.css';
|
4
|
+
import BiBot from 'bibot'
|
5
|
+
|
6
|
+
function App() {
|
7
|
+
return (
|
8
|
+
<div className="App">
|
9
|
+
<header className="App-header">
|
10
|
+
<img src={logo} className="App-logo" alt="logo" />
|
11
|
+
<p>
|
12
|
+
Edit <code>src/App.tsx</code> and save to reload.
|
13
|
+
</p>
|
14
|
+
<a
|
15
|
+
className="App-link"
|
16
|
+
href="https://reactjs.org"
|
17
|
+
target="_blank"
|
18
|
+
rel="noopener noreferrer"
|
19
|
+
>
|
20
|
+
Learn React
|
21
|
+
</a>
|
22
|
+
</header>
|
23
|
+
<BiBot clientId='6c74b4bb-0395-4751-a55f-7d065d67c56b' />
|
24
|
+
</div>
|
25
|
+
);
|
26
|
+
}
|
27
|
+
|
28
|
+
export default App;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
body {
|
2
|
+
margin: 0;
|
3
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
4
|
+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
5
|
+
sans-serif;
|
6
|
+
-webkit-font-smoothing: antialiased;
|
7
|
+
-moz-osx-font-smoothing: grayscale;
|
8
|
+
}
|
9
|
+
|
10
|
+
code {
|
11
|
+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
12
|
+
monospace;
|
13
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import ReactDOM from 'react-dom/client';
|
3
|
+
import './index.css';
|
4
|
+
import App from './App';
|
5
|
+
|
6
|
+
const root = ReactDOM.createRoot(
|
7
|
+
document.getElementById('root') as HTMLElement
|
8
|
+
);
|
9
|
+
root.render(
|
10
|
+
<React.StrictMode>
|
11
|
+
<App />
|
12
|
+
</React.StrictMode>
|
13
|
+
);
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
/// <reference types="react-scripts" />
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "es5",
|
4
|
+
"lib": [
|
5
|
+
"dom",
|
6
|
+
"dom.iterable",
|
7
|
+
"esnext"
|
8
|
+
],
|
9
|
+
"allowJs": true,
|
10
|
+
"skipLibCheck": true,
|
11
|
+
"esModuleInterop": true,
|
12
|
+
"allowSyntheticDefaultImports": true,
|
13
|
+
"strict": true,
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
15
|
+
"noFallthroughCasesInSwitch": true,
|
16
|
+
"module": "esnext",
|
17
|
+
"moduleResolution": "node",
|
18
|
+
"resolveJsonModule": true,
|
19
|
+
"isolatedModules": true,
|
20
|
+
"noEmit": true,
|
21
|
+
"jsx": "react-jsx"
|
22
|
+
},
|
23
|
+
"include": [
|
24
|
+
"src"
|
25
|
+
]
|
26
|
+
}
|
package/package.json
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "bibot",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.1",
|
4
4
|
"description": "BiBot chat bubble integration point",
|
5
|
-
"main": "index.
|
5
|
+
"main": "dist/index.js",
|
6
|
+
"types": "dist/index.d.ts",
|
6
7
|
"scripts": {
|
7
|
-
"
|
8
|
+
"build": "tsc && npx babel src --out-dir dist --extensions '.tsx,.ts' --copy-files"
|
8
9
|
},
|
9
10
|
"keywords": [
|
10
11
|
"bibot"
|
@@ -19,12 +20,31 @@
|
|
19
20
|
"url": "https://github.com/chrisdjin/bibot_plugin/issues"
|
20
21
|
},
|
21
22
|
"homepage": "https://github.com/chrisdjin/bibot_plugin#readme",
|
22
|
-
"
|
23
|
-
"react": "^18.
|
24
|
-
"react-dom": "^18.2.0"
|
23
|
+
"peerDependencies":{
|
24
|
+
"react": "^18.3.1"
|
25
25
|
},
|
26
26
|
"devDependencies": {
|
27
|
-
"@
|
28
|
-
"@
|
27
|
+
"@emotion/react": "^11.11.4",
|
28
|
+
"@emotion/styled": "^11.11.5",
|
29
|
+
"@mantine/core": "^7.6.1",
|
30
|
+
"@mantine/hooks": "^7.6.1",
|
31
|
+
"@mantine/notifications": "^7.6.1",
|
32
|
+
"@mui/icons-material": "^5.14.13",
|
33
|
+
"@mui/material": "^5.15.9",
|
34
|
+
"antd": "^5.9.4",
|
35
|
+
"axios": "^1.6.7",
|
36
|
+
"uuid": "^9.0.1",
|
37
|
+
"react-dom": "^18.3.1",
|
38
|
+
"@babel/cli": "^7.24.5",
|
39
|
+
"@babel/core": "^7.24.5",
|
40
|
+
"@babel/preset-env": "^7.24.5",
|
41
|
+
"@babel/preset-react": "^7.24.1",
|
42
|
+
"@babel/preset-typescript": "^7.24.1",
|
43
|
+
"@types/react": "^18.3.1",
|
44
|
+
"@types/react-dom": "^18.2.25",
|
45
|
+
"@types/uuid": "^9.0.8",
|
46
|
+
"babel-cli": "^6.26.0",
|
47
|
+
"babel-loader": "^9.1.3",
|
48
|
+
"typescript": "^5.4.5"
|
29
49
|
}
|
30
50
|
}
|
package/src/bibot.tsx
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
import { Avatar, Indicator } from '@mantine/core'
|
2
|
+
import { useNetwork } from '@mantine/hooks'
|
3
|
+
import { Close, SendRounded } from '@mui/icons-material'
|
4
|
+
import ChatIcon from '@mui/icons-material/Chat'
|
5
|
+
import { Button } from 'antd'
|
6
|
+
import { useBiBotChatBot } from './hooks'
|
7
|
+
import { AppProvider } from './context/AppContext'
|
8
|
+
import React from 'react';
|
9
|
+
interface bubbleProps {
|
10
|
+
clientId: string
|
11
|
+
}
|
12
|
+
|
13
|
+
interface PredefinedQuestionsProps {
|
14
|
+
onSelect: (question: string) => void
|
15
|
+
questions: string[]
|
16
|
+
}
|
17
|
+
|
18
|
+
const PredefinedQuestions = ({ questions, onSelect }: PredefinedQuestionsProps) => {
|
19
|
+
return (
|
20
|
+
<div className="predefined-questions">
|
21
|
+
{questions.map((question, index) => (
|
22
|
+
<div key={index} className="predefined-question" onClick={() => onSelect(question)}>
|
23
|
+
{question}
|
24
|
+
</div>
|
25
|
+
))}
|
26
|
+
</div>
|
27
|
+
);
|
28
|
+
};
|
29
|
+
|
30
|
+
const BiBot = ({ clientId }: bubbleProps) => {
|
31
|
+
const {
|
32
|
+
chatIsOpen,
|
33
|
+
messages,
|
34
|
+
isLoading,
|
35
|
+
messageEndRef,
|
36
|
+
userInput,
|
37
|
+
handleUserInput,
|
38
|
+
handleKeyPress,
|
39
|
+
sendInputInquiry,
|
40
|
+
toggleChat,
|
41
|
+
chatBubbleConfig,
|
42
|
+
showPredefinedQuestions,
|
43
|
+
predefinedQuestions,
|
44
|
+
handlePredefinedQuestionSelect,
|
45
|
+
} = useBiBotChatBot({clientId})
|
46
|
+
const networkStatus = useNetwork()
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
return (
|
51
|
+
<AppProvider>
|
52
|
+
{/* <div>
|
53
|
+
Hello World
|
54
|
+
</div> */}
|
55
|
+
<div className={`chat-bubble ${chatIsOpen ? 'open' : ''}`}>
|
56
|
+
{chatIsOpen && (
|
57
|
+
<div className="chat-window" style={{ backgroundColor: chatBubbleConfig?.bgColor }}>
|
58
|
+
<div className="chat-header" style={{ backgroundColor: chatBubbleConfig?.color ?? '#dedede' }}>
|
59
|
+
<div style={{ alignItems: 'center', display: 'flex', color: '#fff', fontWeight: 'bold' }}>
|
60
|
+
<Indicator inline size={12} offset={7} position="bottom-end" color={ networkStatus.online ? 'green' : 'gray'}>
|
61
|
+
<Avatar color="white" src={chatBubbleConfig?.logo_url} alt="profile" />
|
62
|
+
</Indicator>
|
63
|
+
</div>
|
64
|
+
<div style={{ display: 'flex', flexDirection: 'column', textAlign: 'left', paddingLeft: '10px', justifyContent: 'flex-start', color: '#fff' }}>
|
65
|
+
<span style={{ fontWeight: 'bold' }}>{chatBubbleConfig?.title}</span>
|
66
|
+
{}
|
67
|
+
{isLoading ? <span style={{ fontSize: '12px', lineHeight: '0.5' }}>Typing...</span> : <span style={{ fontSize: '12px', lineHeight: '0.5' }}>{networkStatus.online ? 'Online' : 'Offline'}</span>}
|
68
|
+
</div>
|
69
|
+
</div>
|
70
|
+
<div className="message-list">
|
71
|
+
{messages.map((message: { sender: 'user' | 'bot', text: string }, index: number) => (
|
72
|
+
message.sender === 'user'
|
73
|
+
? <div key={index} className={`message ${message.sender}`}>
|
74
|
+
{message.text}
|
75
|
+
</div>
|
76
|
+
: <div key={index} style={{ display: 'flex' }}>
|
77
|
+
<Avatar color="white" src={chatBubbleConfig?.logo_url} size={25} alt="profile" />
|
78
|
+
<div className={`message ${message.sender}`}>
|
79
|
+
{message.text}
|
80
|
+
</div>
|
81
|
+
</div>
|
82
|
+
))}
|
83
|
+
{showPredefinedQuestions && predefinedQuestions && predefinedQuestions.length > 0 && (
|
84
|
+
<PredefinedQuestions questions={predefinedQuestions} onSelect={handlePredefinedQuestionSelect} />
|
85
|
+
)}
|
86
|
+
{isLoading && <div style={{marginLeft: '20px'}} className='message'> <div className="loader"></div> </div> }
|
87
|
+
<div ref={messageEndRef} />
|
88
|
+
</div>
|
89
|
+
<div className="input-area">
|
90
|
+
<input
|
91
|
+
autoFocus={true}
|
92
|
+
type="text"
|
93
|
+
value={userInput}
|
94
|
+
onChange={handleUserInput}
|
95
|
+
onKeyPress={handleKeyPress}
|
96
|
+
placeholder="Ask a question"
|
97
|
+
/>
|
98
|
+
<Button disabled={isLoading ?? true} style={{ backgroundColor: 'transparent', color: isLoading ? '#dedede' : chatBubbleConfig?.color }} size='middle' icon={<SendRounded />} onClick={sendInputInquiry}/>
|
99
|
+
</div>
|
100
|
+
</div>
|
101
|
+
)}
|
102
|
+
<Button type='link' onClick={toggleChat} className="chat-toggle" style={{ backgroundColor: chatBubbleConfig?.color ?? '#dedede' }}>
|
103
|
+
{chatIsOpen ? <Close style={{ width: 30, height: 30, color: '#fff' }} /> : <ChatIcon style={{ width: 30, height: 30, color: '#fff' }}/>}
|
104
|
+
</Button>
|
105
|
+
</div>
|
106
|
+
</AppProvider>
|
107
|
+
|
108
|
+
)
|
109
|
+
}
|
110
|
+
|
111
|
+
export default BiBot
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
export const APP_DATA = {
|
3
|
+
APP_NAME: 'Bibot'
|
4
|
+
}
|
5
|
+
|
6
|
+
const baseUrls = {
|
7
|
+
inference: 'https://inference.dev.bibot.thespuka.com/v0',
|
8
|
+
}
|
9
|
+
|
10
|
+
export const endpoints = {
|
11
|
+
get inference () {
|
12
|
+
return baseUrls.inference
|
13
|
+
},
|
14
|
+
} as const
|
15
|
+
|
16
|
+
export enum domain {
|
17
|
+
app = '/app',
|
18
|
+
bibot = '/bibot',
|
19
|
+
inference = '/inference',
|
20
|
+
}
|
21
|
+
|
22
|
+
export enum resources {
|
23
|
+
chatBubble = '/chat-bubble-config',
|
24
|
+
predefinedQ = '/predefined-q',
|
25
|
+
localQ = '/local-q',
|
26
|
+
timedOutLocalQ = '/t-local-q',
|
27
|
+
q = '/q'
|
28
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
export enum statusCode {
|
2
|
+
ok = 200
|
3
|
+
, created = 201
|
4
|
+
, accepted = 202
|
5
|
+
|
6
|
+
// 3xx codes
|
7
|
+
, unmodified = 304
|
8
|
+
|
9
|
+
// 4xx Client Error
|
10
|
+
, sucMsg = 'success'
|
11
|
+
, badReq = 400
|
12
|
+
, unauthorized = 401
|
13
|
+
, paymentReq = 402
|
14
|
+
, forbidden = 403
|
15
|
+
, notFound = 404
|
16
|
+
, methodNotAllowed = 405
|
17
|
+
, notAcceptable = 406
|
18
|
+
, pxyAuthReq = 407
|
19
|
+
, reqTimeOut = 408
|
20
|
+
, conflict = 409
|
21
|
+
, gone = 410
|
22
|
+
, lengthReq = 411
|
23
|
+
, preConFailed = 412
|
24
|
+
, payloadTooLarge = 413
|
25
|
+
, urlTooLong = 414
|
26
|
+
, unsupportedMediaType = 415
|
27
|
+
, rangeNotSatisfiable = 416
|
28
|
+
, expectationFailed = 417
|
29
|
+
|
30
|
+
, misdirectedReq = 421
|
31
|
+
, unprocessableEntity = 422
|
32
|
+
, locked = 423
|
33
|
+
, failedDependency = 424
|
34
|
+
, tooLarge = 425
|
35
|
+
, upgradeRequired = 426
|
36
|
+
, preconReq = 428
|
37
|
+
, tooManyReq = 429
|
38
|
+
, reqHeaderTooLarge = 431
|
39
|
+
, unavailableForLegalReasons = 451
|
40
|
+
|
41
|
+
// 5xx Server Error
|
42
|
+
, internalServerError = 500
|
43
|
+
, notImplemented = 501
|
44
|
+
, badGateway = 502
|
45
|
+
, svcUnavalable = 503
|
46
|
+
, gtwayTimeout = 504
|
47
|
+
, httpVNotSupported = 505
|
48
|
+
, networkAuthReq = 511
|
49
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import { appStateEnums } from '../config/appStateEnums'
|
2
|
+
import React, { type ReactNode, createContext, useReducer, useEffect } from 'react'
|
3
|
+
import { appReducer } from '../reducers/appReducer'
|
4
|
+
import type { AppContextProps, AppStates } from '../types/coreInterfaces'
|
5
|
+
import { getSessionId } from '../utils/sessionManager'
|
6
|
+
|
7
|
+
interface AppProps {
|
8
|
+
children: ReactNode
|
9
|
+
}
|
10
|
+
|
11
|
+
const dummyDispatch = () => {} // A no-op function.
|
12
|
+
|
13
|
+
const defaultContextValue: AppContextProps = {
|
14
|
+
state: {
|
15
|
+
chatIsOpen: false,
|
16
|
+
sessionId: getSessionId()
|
17
|
+
},
|
18
|
+
dispatch: dummyDispatch
|
19
|
+
}
|
20
|
+
|
21
|
+
const AppContext = createContext<AppContextProps>(defaultContextValue)
|
22
|
+
|
23
|
+
const AppProvider: React.FC<AppProps> = ({ children }) => {
|
24
|
+
const APP_STATE_KEY = 'app_states'
|
25
|
+
const initialState: AppStates = {
|
26
|
+
chatIsOpen: false,
|
27
|
+
sessionId: getSessionId()
|
28
|
+
}
|
29
|
+
|
30
|
+
const [state, dispatch] = useReducer(appReducer, initialState)
|
31
|
+
|
32
|
+
useEffect(() => {
|
33
|
+
// Pool the initial states from local storage
|
34
|
+
const storedStates = localStorage.getItem(APP_STATE_KEY)
|
35
|
+
|
36
|
+
if (storedStates) {
|
37
|
+
try {
|
38
|
+
const parsedStates = JSON.parse(storedStates)
|
39
|
+
|
40
|
+
// Merge stored states with initial states
|
41
|
+
const updatedStates = {
|
42
|
+
...initialState,
|
43
|
+
...parsedStates
|
44
|
+
}
|
45
|
+
console.log(initialState, parsedStates, updatedStates)
|
46
|
+
// Dispatch action to update the states
|
47
|
+
dispatch({ type: appStateEnums.BIBOT, ...updatedStates })
|
48
|
+
} catch (error) {
|
49
|
+
console.error('Failed to parse app states from local storage:', error)
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}, [])
|
53
|
+
|
54
|
+
useEffect(() => {
|
55
|
+
console.log('Changes in state: ', state)
|
56
|
+
localStorage.setItem(APP_STATE_KEY, JSON.stringify(state))
|
57
|
+
}, [state])
|
58
|
+
|
59
|
+
return (
|
60
|
+
<AppContext.Provider value={{ state, dispatch }}>
|
61
|
+
{children}
|
62
|
+
</AppContext.Provider>
|
63
|
+
)
|
64
|
+
}
|
65
|
+
|
66
|
+
export { AppContext, AppProvider }
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
2
|
+
export default function MobileView () {
|
3
|
+
const [isMobile, setIsMobile] = useState<boolean>(false)
|
4
|
+
useEffect(() => {
|
5
|
+
const isMobileDevice = () => {
|
6
|
+
const screenWidth = window.innerWidth
|
7
|
+
const mobileThreshold = 768
|
8
|
+
setIsMobile(screenWidth < mobileThreshold)
|
9
|
+
}
|
10
|
+
isMobileDevice()
|
11
|
+
window.addEventListener('resize', isMobileDevice)
|
12
|
+
return () => { // clean up event listner on when component unmount
|
13
|
+
window.removeEventListener('resize', isMobileDevice)
|
14
|
+
}
|
15
|
+
}, [])
|
16
|
+
return isMobile
|
17
|
+
}
|