tia-gpc-widget 1.0.0
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/README.md +387 -0
- package/dist/tia-gpc.cjs.js +15 -0
- package/dist/tia-gpc.cjs.js.map +1 -0
- package/dist/tia-gpc.css +1 -0
- package/dist/tia-gpc.es.js +7434 -0
- package/dist/tia-gpc.es.js.map +1 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
# TIA GPC Widget
|
|
2
|
+
|
|
3
|
+
Librería React para integrar TIA GPC - Sistema de atención al cliente con IA.
|
|
4
|
+
|
|
5
|
+
## 📦 Instalación
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @tia/gpc-widget
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
o con yarn:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn add @tia/gpc-widget
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 🚀 Uso Básico
|
|
18
|
+
|
|
19
|
+
### React / Vite
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
import { TiaGPCWidget } from '@tia/gpc-widget';
|
|
23
|
+
import '@tia/gpc-widget/styles';
|
|
24
|
+
|
|
25
|
+
function App() {
|
|
26
|
+
return (
|
|
27
|
+
<div>
|
|
28
|
+
<TiaGPCWidget token="tu-token-de-licencia" />
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default App;
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Next.js App Router
|
|
37
|
+
|
|
38
|
+
```jsx
|
|
39
|
+
// app/layout.js
|
|
40
|
+
import { TiaGPCWidget } from '@tia/gpc-widget';
|
|
41
|
+
import '@tia/gpc-widget/styles';
|
|
42
|
+
|
|
43
|
+
export default function RootLayout({ children }) {
|
|
44
|
+
return (
|
|
45
|
+
<html lang="en">
|
|
46
|
+
<body>
|
|
47
|
+
{children}
|
|
48
|
+
<TiaGPCWidget token={process.env.NEXT_PUBLIC_TIA_GPC_TOKEN} />
|
|
49
|
+
</body>
|
|
50
|
+
</html>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Next.js Pages Router
|
|
56
|
+
|
|
57
|
+
```jsx
|
|
58
|
+
// pages/_app.js
|
|
59
|
+
import { TiaGPCWidget } from '@tia/gpc-widget';
|
|
60
|
+
import '@tia/gpc-widget/styles';
|
|
61
|
+
|
|
62
|
+
function MyApp({ Component, pageProps }) {
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
<Component {...pageProps} />
|
|
66
|
+
<TiaGPCWidget token={process.env.NEXT_PUBLIC_TIA_GPC_TOKEN} />
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default MyApp;
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## ⚙️ Props
|
|
75
|
+
|
|
76
|
+
### Requeridas
|
|
77
|
+
|
|
78
|
+
| Prop | Tipo | Descripción |
|
|
79
|
+
|------|------|-------------|
|
|
80
|
+
| `token` | `string` | Token de licencia de TIA GPC |
|
|
81
|
+
|
|
82
|
+
### Opcionales
|
|
83
|
+
|
|
84
|
+
| Prop | Tipo | Default | Descripción |
|
|
85
|
+
|------|------|---------|-------------|
|
|
86
|
+
| `theme` | `"auto" \| "light" \| "dark"` | `"auto"` | Tema visual del widget |
|
|
87
|
+
| `language` | `"auto" \| "es" \| "en" \| "fr"` | `"auto"` | Idioma de la interfaz |
|
|
88
|
+
| `position` | `"bottom-right" \| "bottom-left" \| "top-right" \| "top-left"` | `"bottom-right"` | Posición del widget flotante |
|
|
89
|
+
| `autoOpen` | `boolean` | `false` | Abrir automáticamente al cargar |
|
|
90
|
+
| `showBranding` | `boolean` | `true` | Mostrar marca "Powered by TIA" |
|
|
91
|
+
| `showMetadata` | `boolean` | `false` | Mostrar metadatos de tokens y tiempos de respuesta |
|
|
92
|
+
| `mobileFullscreen` | `boolean` | `true` | Mostrar en pantalla completa en móviles |
|
|
93
|
+
| `onReady` | `() => void` | - | Callback cuando el widget está listo |
|
|
94
|
+
| `onError` | `(error: Error) => void` | - | Callback cuando hay un error |
|
|
95
|
+
| `onClose` | `() => void` | - | Callback cuando se cierra el widget |
|
|
96
|
+
|
|
97
|
+
## 📝 Ejemplos
|
|
98
|
+
|
|
99
|
+
### Configuración Completa
|
|
100
|
+
|
|
101
|
+
```jsx
|
|
102
|
+
import { TiaGPCWidget } from '@tia/gpc-widget';
|
|
103
|
+
import '@tia/gpc-widget/styles';
|
|
104
|
+
|
|
105
|
+
function App() {
|
|
106
|
+
const handleReady = () => {
|
|
107
|
+
console.log('TIA GPC Widget ready!');
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const handleError = (error) => {
|
|
111
|
+
console.error('TIA GPC Error:', error);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const handleClose = () => {
|
|
115
|
+
console.log('Widget closed');
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<TiaGPCWidget
|
|
120
|
+
token="tu-token-de-licencia"
|
|
121
|
+
theme="light"
|
|
122
|
+
language="en"
|
|
123
|
+
position="bottom-right"
|
|
124
|
+
autoOpen={false}
|
|
125
|
+
showBranding={true}
|
|
126
|
+
showMetadata={false}
|
|
127
|
+
mobileFullscreen={true}
|
|
128
|
+
onReady={handleReady}
|
|
129
|
+
onError={handleError}
|
|
130
|
+
onClose={handleClose}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Variables de Entorno (Recomendado)
|
|
137
|
+
|
|
138
|
+
Crea un archivo `.env` o `.env.local`:
|
|
139
|
+
|
|
140
|
+
```env
|
|
141
|
+
# Para Vite/React
|
|
142
|
+
VITE_TIA_GPC_TOKEN=tu-token-de-licencia
|
|
143
|
+
|
|
144
|
+
# Para Next.js
|
|
145
|
+
NEXT_PUBLIC_TIA_GPC_TOKEN=tu-token-de-licencia
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Luego úsala:
|
|
149
|
+
|
|
150
|
+
```jsx
|
|
151
|
+
// Vite/React
|
|
152
|
+
<TiaGPCWidget token={process.env.VITE_TIA_GPC_TOKEN} />
|
|
153
|
+
|
|
154
|
+
// Next.js
|
|
155
|
+
<TiaGPCWidget token={process.env.NEXT_PUBLIC_TIA_GPC_TOKEN} />
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Uso Condicional
|
|
159
|
+
|
|
160
|
+
```jsx
|
|
161
|
+
import { useState } from 'react';
|
|
162
|
+
import { TiaGPCWidget } from '@tia/gpc-widget';
|
|
163
|
+
import '@tia/gpc-widget/styles';
|
|
164
|
+
|
|
165
|
+
function App() {
|
|
166
|
+
const [showChat, setShowChat] = useState(true);
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<div>
|
|
170
|
+
<button onClick={() => setShowChat(!showChat)}>
|
|
171
|
+
Toggle Chat
|
|
172
|
+
</button>
|
|
173
|
+
|
|
174
|
+
{showChat && <TiaGPCWidget token="tu-token" />}
|
|
175
|
+
</div>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## 🌍 Idiomas Soportados
|
|
181
|
+
|
|
182
|
+
- 🇪🇸 Español (`es`)
|
|
183
|
+
- 🇬🇧 English (`en`)
|
|
184
|
+
- 🇫🇷 Français (`fr`)
|
|
185
|
+
|
|
186
|
+
El widget detecta automáticamente el idioma del navegador cuando `language="auto"`.
|
|
187
|
+
|
|
188
|
+
## 🎨 Temas
|
|
189
|
+
|
|
190
|
+
- **`auto`**: Detecta el tema del sistema operativo del usuario
|
|
191
|
+
- **`light`**: Tema claro
|
|
192
|
+
- **`dark`**: Tema oscuro
|
|
193
|
+
|
|
194
|
+
## 🛡️ Seguridad (Turnstile)
|
|
195
|
+
|
|
196
|
+
TIA GPC utiliza [Cloudflare Turnstile](https://www.cloudflare.com/products/turnstile/) para protección anti-bot.
|
|
197
|
+
|
|
198
|
+
✅ **Ya configurado** - La librería viene con Turnstile preconfigurado. No necesitas hacer nada adicional.
|
|
199
|
+
|
|
200
|
+
## 📦 Dependencias
|
|
201
|
+
|
|
202
|
+
### Peer Dependencies (debes instalarlas en tu proyecto)
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
npm install react react-dom
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Versiones soportadas:
|
|
209
|
+
- `react`: ^18.0.0
|
|
210
|
+
- `react-dom`: ^18.0.0
|
|
211
|
+
|
|
212
|
+
### Dependencies Incluidas
|
|
213
|
+
|
|
214
|
+
El paquete incluye automáticamente:
|
|
215
|
+
- `@marsidev/react-turnstile` - Integración de Cloudflare Turnstile
|
|
216
|
+
- `axios` - Cliente HTTP
|
|
217
|
+
- `i18next` - Internacionalización
|
|
218
|
+
- `react-i18next` - i18n para React
|
|
219
|
+
- `i18next-browser-languagedetector` - Detección automática de idioma
|
|
220
|
+
- `lucide-react` - Iconos
|
|
221
|
+
- `react-hot-toast` - Notificaciones toast
|
|
222
|
+
|
|
223
|
+
## 🎯 Exports Disponibles
|
|
224
|
+
|
|
225
|
+
```jsx
|
|
226
|
+
// Componente principal
|
|
227
|
+
import { TiaGPCWidget } from '@tia/gpc-widget';
|
|
228
|
+
|
|
229
|
+
// Constantes útiles
|
|
230
|
+
import { WIDGET_POSITIONS, THEMES, LANGUAGES } from '@tia/gpc-widget';
|
|
231
|
+
|
|
232
|
+
// Servicio para uso avanzado (opcional)
|
|
233
|
+
import { GPCService, getGPCService } from '@tia/gpc-widget';
|
|
234
|
+
|
|
235
|
+
// Estilos
|
|
236
|
+
import '@tia/gpc-widget/styles';
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Uso de Constantes
|
|
240
|
+
|
|
241
|
+
```jsx
|
|
242
|
+
import { TiaGPCWidget, WIDGET_POSITIONS, THEMES, LANGUAGES } from '@tia/gpc-widget';
|
|
243
|
+
|
|
244
|
+
<TiaGPCWidget
|
|
245
|
+
token="tu-token"
|
|
246
|
+
position={WIDGET_POSITIONS.BOTTOM_LEFT}
|
|
247
|
+
theme={THEMES.DARK}
|
|
248
|
+
language={LANGUAGES.ENGLISH,}
|
|
249
|
+
/>
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## 🔧 Troubleshooting
|
|
253
|
+
|
|
254
|
+
### El widget no se muestra
|
|
255
|
+
|
|
256
|
+
1. Verifica que importaste los estilos:
|
|
257
|
+
```jsx
|
|
258
|
+
import '@tia/gpc-widget/styles';
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
2. Asegúrate que React y ReactDOM estén instalados:
|
|
262
|
+
```bash
|
|
263
|
+
npm install react react-dom
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Errores de Conexión
|
|
267
|
+
|
|
268
|
+
Si ves errores de conexión al backend:
|
|
269
|
+
- Verifica que tu `token` de licencia sea válido
|
|
270
|
+
- Asegúrate de tener conexión a internet
|
|
271
|
+
- Contacta a soporte si el problema persiste
|
|
272
|
+
|
|
273
|
+
## 🏗️ Desarrollo Local
|
|
274
|
+
|
|
275
|
+
### Clonar el repositorio
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
git clone https://gitlab.com/softia/tiagpc-frontend.git
|
|
279
|
+
cd tiagpc-frontend
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Instalar dependencias
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
npm install
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Configurar variables de entorno
|
|
289
|
+
|
|
290
|
+
Crea un archivo `.env` (valores de desarrollo):
|
|
291
|
+
|
|
292
|
+
```env
|
|
293
|
+
VITE_API_URL=http://localhost:8002
|
|
294
|
+
VITE_TURNSTILE_SITE_KEY=0x4AAAAAAB9XB2TsB-P7vbJM
|
|
295
|
+
VITE_ENV=development
|
|
296
|
+
VITE_DEBUG=true
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
> **Nota:** En producción, la librería usa automáticamente los valores correctos de API y Turnstile configurados internamente.
|
|
300
|
+
|
|
301
|
+
### Comandos disponibles
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
# Servidor de desarrollo
|
|
305
|
+
npm run dev
|
|
306
|
+
|
|
307
|
+
# Build de producción
|
|
308
|
+
npm run build
|
|
309
|
+
|
|
310
|
+
# Preview del build
|
|
311
|
+
npm run preview
|
|
312
|
+
|
|
313
|
+
# Linting
|
|
314
|
+
npm run lint
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Build para publicación
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
# Crear build de producción
|
|
321
|
+
npm run build
|
|
322
|
+
|
|
323
|
+
# El build genera:
|
|
324
|
+
# - dist/tia-gpc.es.js (ESM)
|
|
325
|
+
# - dist/tia-gpc.cjs.js (CommonJS)
|
|
326
|
+
# - dist/tia-gpc.css (Estilos)
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## 📤 Publicación en NPM
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
# 1. Autenticarse en npm
|
|
333
|
+
npm login
|
|
334
|
+
|
|
335
|
+
# 2. Publicar (automáticamente ejecuta build)
|
|
336
|
+
npm publish --access public
|
|
337
|
+
|
|
338
|
+
# O para scoped packages
|
|
339
|
+
npm publish --access public
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
El script `prepublishOnly` ejecuta automáticamente el build antes de publicar.
|
|
343
|
+
|
|
344
|
+
## 🌐 Compatibilidad
|
|
345
|
+
|
|
346
|
+
### Frameworks Soportados
|
|
347
|
+
|
|
348
|
+
- ✅ React 18+
|
|
349
|
+
- ✅ Next.js 13+ (App Router y Pages Router)
|
|
350
|
+
- ✅ Vite
|
|
351
|
+
- ✅ Create React App
|
|
352
|
+
- ✅ Remix
|
|
353
|
+
- ✅ Gatsby
|
|
354
|
+
|
|
355
|
+
### Navegadores Soportados
|
|
356
|
+
|
|
357
|
+
- ✅ Chrome/Edge (últimas 2 versiones)
|
|
358
|
+
- ✅ Firefox (últimas 2 versiones)
|
|
359
|
+
- ✅ Safari 14+
|
|
360
|
+
- ✅ Mobile (iOS Safari, Chrome Mobile)
|
|
361
|
+
|
|
362
|
+
## 📱 Características
|
|
363
|
+
|
|
364
|
+
- 💬 Chat con IA contextualizada por documentos
|
|
365
|
+
- 🛡️ Protección anti-bot con Cloudflare Turnstile
|
|
366
|
+
- 🌍 Multiidioma (Español, Inglés, Francés) con detección automática
|
|
367
|
+
- 📱 Totalmente responsive y optimizado para móviles
|
|
368
|
+
- 🎨 Temas claro/oscuro con detección automática del sistema
|
|
369
|
+
- ⚡ Tree-shaking y optimización de bundle
|
|
370
|
+
- 🔒 Validación de sesiones con cacheo
|
|
371
|
+
- ♿ Accesible (a11y)
|
|
372
|
+
- 📊 Metadatos opcionales (tokens, tiempos de respuesta)
|
|
373
|
+
|
|
374
|
+
## 📄 Licencia
|
|
375
|
+
|
|
376
|
+
UNLICENSED - Uso restringido solo para clientes autorizados de TIA GPC.
|
|
377
|
+
|
|
378
|
+
## 🆘 Soporte
|
|
379
|
+
|
|
380
|
+
Para soporte técnico, contacta a:
|
|
381
|
+
- 📧 Email: soporte@tiagpc.com
|
|
382
|
+
- 🌐 Documentación: https://docs.tiagpc.com
|
|
383
|
+
- 🔗 Repository: https://gitlab.com/softia/tiagpc-frontend
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
**TIA GPC** - Sistema de atención al cliente con IA para negocios
|