@aslaluroba/help-center-react 2.0.0 → 2.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/index.esm.js +6 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/postcss.config.js +6 -0
- package/rollup.config.js +58 -0
- package/src/core/api.ts +0 -1
- package/src/ui/help-center.tsx +6 -2
- package/src/ui/help-popup.tsx +1 -1
- package/tailwind.config.js +174 -0
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"main": "dist/index.js",
|
|
4
4
|
"module": "dist/index.esm.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
-
"version": "2.0.
|
|
6
|
+
"version": "2.0.2",
|
|
7
7
|
"description": "BabylAI Help Center Widget for React and Next.js",
|
|
8
8
|
"private": false,
|
|
9
9
|
"exports": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dev": "rollup -c -w",
|
|
25
25
|
"test": "jest",
|
|
26
26
|
"clean": "rimraf dist",
|
|
27
|
-
"publish": "npm run build && npm publish --access public"
|
|
27
|
+
"publish:lib": "npm run build && npm publish --access public"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"dist",
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import json from '@rollup/plugin-json';
|
|
2
|
+
import resolve from '@rollup/plugin-node-resolve'
|
|
3
|
+
import commonjs from '@rollup/plugin-commonjs'
|
|
4
|
+
import typescript from '@rollup/plugin-typescript'
|
|
5
|
+
import postcss from 'rollup-plugin-postcss'
|
|
6
|
+
import svgr from '@svgr/rollup'
|
|
7
|
+
import image from '@rollup/plugin-image'
|
|
8
|
+
|
|
9
|
+
const createConfig = (format) => ({
|
|
10
|
+
input: 'src/index.ts',
|
|
11
|
+
output: {
|
|
12
|
+
file: `dist/index${format === 'esm' ? '.esm' : ''}.js`,
|
|
13
|
+
format: format === 'esm' ? 'es' : 'cjs',
|
|
14
|
+
sourcemap: true
|
|
15
|
+
},
|
|
16
|
+
external: ['react', 'react-dom', '@microsoft/signalr', 'axios', 'i18next', 'react-i18next'],
|
|
17
|
+
plugins: [
|
|
18
|
+
svgr({
|
|
19
|
+
svgoConfig: {
|
|
20
|
+
plugins: [
|
|
21
|
+
{
|
|
22
|
+
name: 'preset-default',
|
|
23
|
+
params: {
|
|
24
|
+
overrides: {
|
|
25
|
+
removeViewBox: false
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
image({
|
|
33
|
+
include: ['**/*.gif', '**/*.png', '**/*.jpg', '**/*.jpeg'],
|
|
34
|
+
limit: 0,
|
|
35
|
+
fileName: '[dirname][name][extname]'
|
|
36
|
+
}),
|
|
37
|
+
resolve(),
|
|
38
|
+
json(),
|
|
39
|
+
commonjs(),
|
|
40
|
+
postcss({
|
|
41
|
+
config: {
|
|
42
|
+
path: './postcss.config.js'
|
|
43
|
+
},
|
|
44
|
+
extensions: ['.css'],
|
|
45
|
+
minimize: true,
|
|
46
|
+
inject: {
|
|
47
|
+
insertAt: 'top'
|
|
48
|
+
}
|
|
49
|
+
}),
|
|
50
|
+
typescript({
|
|
51
|
+
tsconfig: './tsconfig.json',
|
|
52
|
+
declaration: true,
|
|
53
|
+
declarationDir: './dist'
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
export default [createConfig('cjs'), createConfig('esm')]
|
package/src/core/api.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { TokenResponse } from '../lib/types'
|
|
|
2
2
|
|
|
3
3
|
let getTokenFunction: (() => Promise<TokenResponse>) | undefined = undefined
|
|
4
4
|
|
|
5
|
-
console.log('🚀 ~ getTokenFunction:', getTokenFunction)
|
|
6
5
|
let baseUrl: string | null = null
|
|
7
6
|
|
|
8
7
|
export function initializeAPI(url: string, getToken: () => Promise<TokenResponse>) {
|
package/src/ui/help-center.tsx
CHANGED
|
@@ -102,6 +102,8 @@ export function HelpCenter({
|
|
|
102
102
|
} catch (error) {
|
|
103
103
|
console.error('Error ending chat:', error)
|
|
104
104
|
setError('Failed to end chat session')
|
|
105
|
+
// If ending chat fails, the chat is not considered closed.
|
|
106
|
+
setIsChatClosed(false)
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
|
|
@@ -127,7 +129,6 @@ export function HelpCenter({
|
|
|
127
129
|
}
|
|
128
130
|
})
|
|
129
131
|
}
|
|
130
|
-
|
|
131
132
|
const response = await apiRequest('Client/ClientChatSession/create-session', 'POST', chatSessionCreateDto)
|
|
132
133
|
|
|
133
134
|
if (!response.ok) {
|
|
@@ -163,7 +164,7 @@ export function HelpCenter({
|
|
|
163
164
|
}
|
|
164
165
|
|
|
165
166
|
// Connect to SignalR
|
|
166
|
-
|
|
167
|
+
ClientSignalRService.startConnection(createdSession.id, tokenResponse, handleReceiveMessage)
|
|
167
168
|
|
|
168
169
|
setIsSignalRConnected(true)
|
|
169
170
|
setIsChatClosed(false)
|
|
@@ -172,6 +173,8 @@ export function HelpCenter({
|
|
|
172
173
|
console.error('Chat start error:', error)
|
|
173
174
|
setError(error instanceof Error ? error.message : 'Failed to start chat session')
|
|
174
175
|
setStatus('failed')
|
|
176
|
+
// If starting chat fails, SignalR is not connected.
|
|
177
|
+
setIsSignalRConnected(false)
|
|
175
178
|
}
|
|
176
179
|
}
|
|
177
180
|
|
|
@@ -220,6 +223,7 @@ export function HelpCenter({
|
|
|
220
223
|
// Connect to SignalR with the new session
|
|
221
224
|
const tokenResponse = await configService.getToken()
|
|
222
225
|
await ClientSignalRService.startConnection(createdSession.id, tokenResponse, handleReceiveMessage)
|
|
226
|
+
|
|
223
227
|
setIsSignalRConnected(true)
|
|
224
228
|
}
|
|
225
229
|
|
package/src/ui/help-popup.tsx
CHANGED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/** @type {import('tailwindcss').Config} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
prefix: 'babylai-',
|
|
4
|
+
content: ['./src/**/*.{js,jsx,ts,tsx}', './components/**/*.{js,jsx,ts,tsx}'],
|
|
5
|
+
theme: {
|
|
6
|
+
extend: {
|
|
7
|
+
fontFamily: {
|
|
8
|
+
sans: ['Cairo']
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
rotate: {
|
|
12
|
+
270: '270deg'
|
|
13
|
+
},
|
|
14
|
+
borderRadius: {
|
|
15
|
+
lg: 'var(--radius)',
|
|
16
|
+
md: 'calc(var(--radius) - 2px)',
|
|
17
|
+
sm: 'calc(var(--radius) - 4px)'
|
|
18
|
+
},
|
|
19
|
+
colors: {
|
|
20
|
+
background: 'hsl(var(--background))',
|
|
21
|
+
foreground: 'hsl(var(--foreground))',
|
|
22
|
+
borderColor: '#606060',
|
|
23
|
+
textDark: '#333333',
|
|
24
|
+
black: '#171717',
|
|
25
|
+
pureWhite: '#FFFFFF',
|
|
26
|
+
primary: {
|
|
27
|
+
100: '#F6ECFC',
|
|
28
|
+
200: '#DEB6F3',
|
|
29
|
+
300: '#D49CEE',
|
|
30
|
+
400: '#C57FEA',
|
|
31
|
+
500: '#AD49E1',
|
|
32
|
+
600: '#672B87',
|
|
33
|
+
700: '#451D5A',
|
|
34
|
+
800: '#220E2D',
|
|
35
|
+
900: '#110716',
|
|
36
|
+
950: '#0A0310',
|
|
37
|
+
DEFAULT: '#AD49E1',
|
|
38
|
+
foreground: '#FFFFFF'
|
|
39
|
+
},
|
|
40
|
+
'black-white': {
|
|
41
|
+
50: '#FFFFFF',
|
|
42
|
+
100: '#F3F3F3',
|
|
43
|
+
200: '#E2E2E2',
|
|
44
|
+
300: '#919191',
|
|
45
|
+
400: '#606060',
|
|
46
|
+
500: '#333333',
|
|
47
|
+
600: '#1F1F1F',
|
|
48
|
+
700: '#171717',
|
|
49
|
+
800: '#0A0A0A',
|
|
50
|
+
900: '#050505',
|
|
51
|
+
950: '#000000',
|
|
52
|
+
DEFAULT: '#333333'
|
|
53
|
+
},
|
|
54
|
+
'wild-sand': {
|
|
55
|
+
50: '#f8f8f8',
|
|
56
|
+
100: '#f3f3f3',
|
|
57
|
+
200: '#dcdcdc',
|
|
58
|
+
300: '#bdbdbd',
|
|
59
|
+
400: '#989898',
|
|
60
|
+
500: '#7c7c7c',
|
|
61
|
+
600: '#656565',
|
|
62
|
+
700: '#525252',
|
|
63
|
+
800: '#464646',
|
|
64
|
+
900: '#3d3d3d',
|
|
65
|
+
950: '#292929'
|
|
66
|
+
},
|
|
67
|
+
'storm-dust': {
|
|
68
|
+
50: '#f6f6f6',
|
|
69
|
+
100: '#e7e7e7',
|
|
70
|
+
200: '#d1d1d1',
|
|
71
|
+
300: '#b0b0b0',
|
|
72
|
+
400: '#888888',
|
|
73
|
+
500: '#6d6d6d',
|
|
74
|
+
600: '#606060',
|
|
75
|
+
700: '#4f4f4f',
|
|
76
|
+
800: '#454545',
|
|
77
|
+
900: '#3d3d3d',
|
|
78
|
+
950: '#262626'
|
|
79
|
+
},
|
|
80
|
+
card: {
|
|
81
|
+
DEFAULT: 'hsl(var(--card))',
|
|
82
|
+
foreground: 'hsl(var(--card-foreground))'
|
|
83
|
+
},
|
|
84
|
+
popover: {
|
|
85
|
+
DEFAULT: 'hsl(var(--popover))',
|
|
86
|
+
foreground: 'hsl(var(--popover-foreground))'
|
|
87
|
+
},
|
|
88
|
+
secondary: {
|
|
89
|
+
DEFAULT: 'hsl(var(--secondary))',
|
|
90
|
+
foreground: 'hsl(var(--secondary-foreground))'
|
|
91
|
+
},
|
|
92
|
+
muted: {
|
|
93
|
+
DEFAULT: 'hsl(var(--muted))',
|
|
94
|
+
foreground: 'hsl(var(--muted-foreground))'
|
|
95
|
+
},
|
|
96
|
+
accent: {
|
|
97
|
+
DEFAULT: 'hsl(var(--accent))',
|
|
98
|
+
foreground: 'hsl(var(--accent-foreground))'
|
|
99
|
+
},
|
|
100
|
+
destructive: {
|
|
101
|
+
DEFAULT: 'hsl(var(--destructive))',
|
|
102
|
+
foreground: 'hsl(var(--destructive-foreground))'
|
|
103
|
+
},
|
|
104
|
+
border: 'hsl(var(--border))',
|
|
105
|
+
input: 'hsl(var(--input))',
|
|
106
|
+
ring: 'hsl(var(--ring))',
|
|
107
|
+
chart: {
|
|
108
|
+
1: 'hsl(var(--chart-1))',
|
|
109
|
+
2: 'hsl(var(--chart-2))',
|
|
110
|
+
3: 'hsl(var(--chart-3))',
|
|
111
|
+
4: 'hsl(var(--chart-4))',
|
|
112
|
+
5: 'hsl(var(--chart-5))'
|
|
113
|
+
},
|
|
114
|
+
sidebar: {
|
|
115
|
+
DEFAULT: 'hsl(var(--sidebar-background))',
|
|
116
|
+
foreground: 'hsl(var(--sidebar-foreground))',
|
|
117
|
+
primary: 'hsl(var(--sidebar-primary))',
|
|
118
|
+
'primary-foreground': 'hsl(var(--sidebar-primary-foreground))',
|
|
119
|
+
accent: 'hsl(var(--sidebar-accent))',
|
|
120
|
+
'accent-foreground': 'hsl(var(--sidebar-accent-foreground))',
|
|
121
|
+
border: 'hsl(var(--sidebar-border))',
|
|
122
|
+
ring: 'hsl(var(--sidebar-ring))'
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
keyframes: {
|
|
126
|
+
'accordion-down': {
|
|
127
|
+
from: { height: 0 },
|
|
128
|
+
to: { height: 'var(--radix-accordion-content-height)' }
|
|
129
|
+
},
|
|
130
|
+
'accordion-up': {
|
|
131
|
+
from: { height: 'var(--radix-accordion-content-height)' },
|
|
132
|
+
to: { height: 0 }
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
animation: {
|
|
136
|
+
'accordion-down': 'accordion-down 0.2s ease-out',
|
|
137
|
+
'accordion-up': 'accordion-up 0.2s ease-out',
|
|
138
|
+
float: 'float 3s infinite ease-in-out'
|
|
139
|
+
},
|
|
140
|
+
screens: {
|
|
141
|
+
sm: '640px',
|
|
142
|
+
md: '768px',
|
|
143
|
+
lg: '1024px',
|
|
144
|
+
xl: '1400px',
|
|
145
|
+
'2xl': '1600px',
|
|
146
|
+
'3xl': '1820px'
|
|
147
|
+
},
|
|
148
|
+
fontSize: {
|
|
149
|
+
'4.5xl': ['2.875rem', { lineHeight: '2.875rem' }],
|
|
150
|
+
'3.4xl': ['2.25rem', { lineHeight: '2.25rem' }]
|
|
151
|
+
},
|
|
152
|
+
boxShadow: {
|
|
153
|
+
'minimal-shadow': 'rgba(100, 100, 111, 0.2) 0px 7px 29px 0px'
|
|
154
|
+
},
|
|
155
|
+
opacity: {
|
|
156
|
+
15: '0.15'
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
plugins: [
|
|
161
|
+
require('tailwindcss-animate'),
|
|
162
|
+
require('tailwindcss-rtl'),
|
|
163
|
+
({ addBase }) => {
|
|
164
|
+
addBase({
|
|
165
|
+
html: {
|
|
166
|
+
fontFamily: '"Cairo", sans-serif'
|
|
167
|
+
},
|
|
168
|
+
body: {
|
|
169
|
+
fontFamily: '"Cairo", sans-serif'
|
|
170
|
+
}
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
}
|