botech-library 1.0.76 → 1.0.78
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 +252 -69
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/types/components/ProfileSwitcher/ProfileSwitcher.d.ts +16 -0
- package/dist/types/components/ProfileSwitcher/ProfileSwitcher.d.ts.map +1 -0
- package/dist/types/components/ProfileSwitcher/index.d.ts +3 -0
- package/dist/types/components/ProfileSwitcher/index.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,125 +1,308 @@
|
|
|
1
|
-
#
|
|
1
|
+
# botech-library
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Librería de componentes React compartida entre los sistemas web de **BO-TECH** (PASS, Seguimiento y otros). Publicada en npm y consumida como dependencia estándar en cada proyecto.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Instalación
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install botech-library
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Peer dependencies requeridas
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install react react-dom axios sweetalert2
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Componentes disponibles
|
|
22
|
+
|
|
23
|
+
### Auth
|
|
24
|
+
|
|
25
|
+
#### `LoginPage`
|
|
26
|
+
|
|
27
|
+
Página de inicio de sesión con soporte para email/contraseña y Google SSO.
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { LoginPage } from 'botech-library';
|
|
31
|
+
|
|
32
|
+
<LoginPage
|
|
33
|
+
systemName="PASS"
|
|
34
|
+
leftPanelTitle={<>Simplicidad y<br />Seguridad Absoluta</>}
|
|
35
|
+
googleClientId={import.meta.env.VITE_GOOGLE_CLIENT_ID}
|
|
36
|
+
onLogin={async (email, password) => { /* lógica de login */ }}
|
|
37
|
+
onGoogleCredential={async (credential) => { /* lógica con JWT de Google */ }}
|
|
38
|
+
onForgotPassword={async (email) => ({ ok: true })}
|
|
39
|
+
onNavigateToRegister={() => navigate('/register-product-key')}
|
|
40
|
+
/>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Props:**
|
|
8
44
|
|
|
9
|
-
|
|
45
|
+
| Prop | Tipo | Descripción |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `systemName` | `string` | Nombre del sistema mostrado en el panel izquierdo |
|
|
48
|
+
| `leftPanelTitle` | `ReactNode` | Título decorativo del panel izquierdo |
|
|
49
|
+
| `quote` | `string?` | Cita inspiracional (opcional) |
|
|
50
|
+
| `quoteAuthor` | `string?` | Autor de la cita (opcional) |
|
|
51
|
+
| `googleClientId` | `string` | Client ID de Google OAuth 2.0 |
|
|
52
|
+
| `onLogin` | `(email, password) => Promise<void>` | Handler de login con credenciales |
|
|
53
|
+
| `onGoogleCredential` | `(credential) => Promise<void>` | Handler con el JWT de Google |
|
|
54
|
+
| `onForgotPassword` | `(email) => Promise<{ok, message?, error?}>` | Handler de recuperación de contraseña |
|
|
55
|
+
| `onNavigateToRegister` | `() => void` | Navegación al registro |
|
|
10
56
|
|
|
11
|
-
|
|
57
|
+
> El botón de Google usa un patrón de polling con `setInterval` para esperar que el SDK de Google Identity Services (cargado vía GTM) esté disponible antes de inicializarlo.
|
|
12
58
|
|
|
13
|
-
|
|
14
|
-
- `description`: Descripción de la página actual
|
|
15
|
-
- `systemName`: Nombre del sistema (por defecto: "PASS")
|
|
16
|
-
- `systemSubtitle`: Subtítulo del sistema (por defecto: "Sistema Escolar")
|
|
17
|
-
- `showPageInfo`: Controla si se muestra la información de la página en el lado derecho (por defecto: true)
|
|
18
|
-
- `onMenuToggle`: Función que se ejecuta al hacer clic en el botón de menú
|
|
59
|
+
---
|
|
19
60
|
|
|
20
|
-
####
|
|
61
|
+
#### `RegisterProductKeyPage`
|
|
62
|
+
|
|
63
|
+
Página de registro en dos pasos: validación de product key y creación de cuenta.
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import { RegisterProductKeyPage } from 'botech-library';
|
|
67
|
+
|
|
68
|
+
<RegisterProductKeyPage
|
|
69
|
+
googleClientId={import.meta.env.VITE_GOOGLE_CLIENT_ID}
|
|
70
|
+
onValidateKey={async (key) => ({ ok: true })}
|
|
71
|
+
onRegisterWithForm={async (email, password, fullName, phone, key) => ({ ok: true })}
|
|
72
|
+
onGoogleSignIn={async (credential) => ({ ok: true, localId: '...', idToken: '...' })}
|
|
73
|
+
onSuccess={() => navigate('/private/dashboard')}
|
|
74
|
+
onNavigateToLogin={() => navigate('/login')}
|
|
75
|
+
/>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### `Header`
|
|
81
|
+
|
|
82
|
+
Barra de navegación superior con logo del sistema, nombre de la página actual e información contextual.
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import { Header } from 'botech-library';
|
|
21
86
|
|
|
22
|
-
```jsx
|
|
23
87
|
<Header
|
|
24
88
|
title="Dashboard"
|
|
25
89
|
description="Panel principal del sistema"
|
|
90
|
+
logoUrl="/assets/logo-colegio.png"
|
|
91
|
+
logoAlt="Logo PASS"
|
|
26
92
|
systemName="PASS"
|
|
27
|
-
systemSubtitle="
|
|
28
|
-
onMenuToggle={() =>
|
|
93
|
+
systemSubtitle="Control de Asistencia"
|
|
94
|
+
onMenuToggle={() => setSidebarOpen(true)}
|
|
29
95
|
showPageInfo={true}
|
|
30
96
|
/>
|
|
31
97
|
```
|
|
32
98
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
- La descripción se muestra en **dos lugares**:
|
|
36
|
-
1. **Lado izquierdo**: `systemSubtitle` aparece debajo del nombre del sistema
|
|
37
|
-
2. **Lado derecho**: `description` aparece cuando `showPageInfo` es `true` (solo visible en pantallas medianas y grandes por la clase `hidden sm:block`)
|
|
99
|
+
**Props:**
|
|
38
100
|
|
|
39
|
-
|
|
101
|
+
| Prop | Tipo | Descripción |
|
|
102
|
+
|---|---|---|
|
|
103
|
+
| `title` | `string` | Título de la página actual |
|
|
104
|
+
| `description` | `string` | Descripción de la página actual |
|
|
105
|
+
| `logoUrl` | `string?` | URL del logo del colegio |
|
|
106
|
+
| `logoAlt` | `string?` | Texto alternativo del logo |
|
|
107
|
+
| `systemName` | `string` | Nombre del sistema |
|
|
108
|
+
| `systemSubtitle` | `string` | Subtítulo del sistema |
|
|
109
|
+
| `onMenuToggle` | `() => void` | Abre/cierra el sidebar |
|
|
110
|
+
| `showPageInfo` | `boolean` | Muestra el bloque de info de página (solo en `sm:+`) |
|
|
40
111
|
|
|
41
|
-
|
|
112
|
+
---
|
|
42
113
|
|
|
43
|
-
|
|
114
|
+
### `Sidebar`
|
|
44
115
|
|
|
45
|
-
|
|
46
|
-
- `onClose`: Función que se ejecuta al cerrar el sidebar
|
|
47
|
-
- `menuItems`: Array de elementos del menú
|
|
48
|
-
- `overlayClassName`: Clases CSS para el overlay (por defecto: "fixed inset-0 bg-black bg-opacity-25 z-40")
|
|
116
|
+
Navegación lateral con soporte para elementos simples, carpetas con submenús, menú inferior y overlay de cierre.
|
|
49
117
|
|
|
50
|
-
|
|
118
|
+
```tsx
|
|
119
|
+
import { Sidebar } from 'botech-library';
|
|
51
120
|
|
|
52
|
-
```jsx
|
|
53
121
|
<Sidebar
|
|
54
|
-
isOpen={
|
|
55
|
-
onClose={() =>
|
|
122
|
+
isOpen={sidebarOpen}
|
|
123
|
+
onClose={() => setSidebarOpen(false)}
|
|
124
|
+
onToggle={() => setSidebarOpen(!sidebarOpen)}
|
|
125
|
+
dashboardPath="/private/dashboard"
|
|
56
126
|
menuItems={menuItems}
|
|
127
|
+
logoUrl="/assets/logo-colegio.png"
|
|
128
|
+
logoAlt="Logo"
|
|
57
129
|
systemName="PASS"
|
|
58
|
-
activePath=
|
|
59
|
-
onNavigate={(path) =>
|
|
130
|
+
activePath={location.pathname}
|
|
131
|
+
onNavigate={(path) => navigate(path)}
|
|
132
|
+
showBottomMenu={true}
|
|
133
|
+
bottomMenuItems={bottomMenuItems}
|
|
134
|
+
overlayClassName="fixed inset-0 backdrop-blur-xs z-40"
|
|
60
135
|
/>
|
|
61
136
|
```
|
|
62
137
|
|
|
63
|
-
|
|
138
|
+
---
|
|
64
139
|
|
|
65
|
-
###
|
|
140
|
+
### `Table`
|
|
66
141
|
|
|
67
|
-
|
|
142
|
+
Tabla de datos genérica con soporte para columnas configurables, acciones por fila, paginación y modo responsive.
|
|
68
143
|
|
|
69
|
-
|
|
144
|
+
```tsx
|
|
145
|
+
import { Table } from 'botech-library';
|
|
70
146
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
147
|
+
<Table
|
|
148
|
+
columns={columns}
|
|
149
|
+
data={rows}
|
|
150
|
+
onEdit={(row) => handleEdit(row)}
|
|
151
|
+
onDelete={(row) => handleDelete(row)}
|
|
152
|
+
/>
|
|
77
153
|
```
|
|
78
154
|
|
|
79
|
-
|
|
155
|
+
---
|
|
80
156
|
|
|
81
|
-
|
|
157
|
+
### `ProfileSwitcher`
|
|
82
158
|
|
|
83
|
-
|
|
159
|
+
Componente para cambiar entre perfiles de usuario cuando el usuario tiene múltiples perfiles asignados.
|
|
84
160
|
|
|
85
|
-
|
|
86
|
-
|
|
161
|
+
```tsx
|
|
162
|
+
import { ProfileSwitcher } from 'botech-library';
|
|
87
163
|
|
|
88
|
-
|
|
164
|
+
<ProfileSwitcher />
|
|
165
|
+
```
|
|
89
166
|
|
|
90
|
-
|
|
167
|
+
---
|
|
91
168
|
|
|
92
|
-
|
|
93
|
-
|
|
169
|
+
### `Modal`
|
|
170
|
+
|
|
171
|
+
Modal genérico accesible con soporte para contenido personalizado.
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
import { Modal } from 'botech-library';
|
|
175
|
+
|
|
176
|
+
<Modal isOpen={open} onClose={() => setOpen(false)} title="Confirmar acción">
|
|
177
|
+
<p>¿Estás seguro?</p>
|
|
178
|
+
</Modal>
|
|
94
179
|
```
|
|
95
180
|
|
|
96
|
-
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
### `NotFound`
|
|
97
184
|
|
|
98
|
-
|
|
99
|
-
import { Header, Sidebar } from 'botech-library';
|
|
185
|
+
Página 404 estándar de BO-TECH.
|
|
100
186
|
|
|
101
|
-
|
|
187
|
+
```tsx
|
|
188
|
+
import { NotFound } from 'botech-library';
|
|
189
|
+
|
|
190
|
+
<Route path="*" element={<NotFound />} />
|
|
102
191
|
```
|
|
103
192
|
|
|
104
|
-
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
### `StudentSummary` y `StudentExcel`
|
|
196
|
+
|
|
197
|
+
Componentes para visualización resumida de estudiantes y exportación a Excel.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
### `Selector`
|
|
202
|
+
|
|
203
|
+
Selector con búsqueda integrada para formularios.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Desarrollo local
|
|
208
|
+
|
|
209
|
+
### Prerrequisitos
|
|
210
|
+
|
|
211
|
+
- Node.js >= 24
|
|
212
|
+
- yalc instalado globalmente (`npm i -g yalc`)
|
|
213
|
+
|
|
214
|
+
### Comandos
|
|
105
215
|
|
|
106
216
|
```bash
|
|
217
|
+
# Instalar dependencias
|
|
107
218
|
npm install
|
|
219
|
+
|
|
220
|
+
# Build de producción (ESM + CJS + tipos)
|
|
221
|
+
npm run build
|
|
222
|
+
|
|
223
|
+
# Storybook para desarrollo visual de componentes
|
|
224
|
+
npm run storybook
|
|
225
|
+
|
|
226
|
+
# Tests
|
|
227
|
+
npm test
|
|
228
|
+
|
|
229
|
+
# Tests en modo watch
|
|
230
|
+
npm run test:watch
|
|
231
|
+
|
|
232
|
+
# Publicar en yalc y enviar a proyectos locales enlazados
|
|
233
|
+
npm run yalc:push
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Publicar versión en npm
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
# El script yalc:push hace patch de versión automáticamente
|
|
240
|
+
# Para publicar en npm:
|
|
108
241
|
npm run build
|
|
242
|
+
npm publish
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## Desarrollo con yalc (integración local)
|
|
248
|
+
|
|
249
|
+
Para probar cambios en la librería desde un proyecto consumidor (ej. PASS) sin publicar en npm:
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
# 1. En este repositorio: compilar y publicar en yalc
|
|
253
|
+
npm run yalc:push
|
|
254
|
+
|
|
255
|
+
# 2. En el proyecto consumidor (ej. pass/)
|
|
256
|
+
yalc add botech-library
|
|
257
|
+
|
|
258
|
+
# 3. Al terminar el desarrollo, restaurar la versión de npm
|
|
259
|
+
yalc remove botech-library
|
|
260
|
+
npm install
|
|
109
261
|
```
|
|
110
262
|
|
|
111
|
-
|
|
263
|
+
> Los proyectos consumidores tienen un hook de pre-commit que bloquea commits con `file:.yalc/` en `package.json`.
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Estructura del proyecto
|
|
112
268
|
|
|
113
269
|
```
|
|
114
270
|
src/
|
|
115
271
|
├── components/
|
|
116
|
-
│ ├──
|
|
117
|
-
│
|
|
118
|
-
│
|
|
119
|
-
│
|
|
120
|
-
│ ├──
|
|
121
|
-
│
|
|
122
|
-
│
|
|
123
|
-
│
|
|
124
|
-
│
|
|
125
|
-
|
|
272
|
+
│ ├── Auth/ # LoginPage, RegisterProductKeyPage, AuthLayout, PasswordResetModal
|
|
273
|
+
│ ├── Button/ # Botón base reutilizable
|
|
274
|
+
│ ├── Header/ # Header con info de página
|
|
275
|
+
│ ├── Modal/ # Modal genérico
|
|
276
|
+
│ ├── NotFound/ # Página 404
|
|
277
|
+
│ ├── ProfileSwitcher/ # Selector de perfil de usuario
|
|
278
|
+
│ ├── Selector/ # Select con búsqueda
|
|
279
|
+
│ ├── Sidebar/ # Navegación lateral
|
|
280
|
+
│ ├── StudentExcel/ # Exportación de estudiantes a Excel
|
|
281
|
+
│ ├── StudentSummary/ # Resumen visual de estudiante
|
|
282
|
+
│ └── Table/ # Tabla de datos genérica
|
|
283
|
+
├── services/ # Servicios HTTP internos de la librería
|
|
284
|
+
├── types/ # Tipos TypeScript exportados
|
|
285
|
+
├── utils/ # Utilidades internas (generateTableColumns…)
|
|
286
|
+
└── index.ts # Punto de entrada y exportaciones públicas
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## Build
|
|
292
|
+
|
|
293
|
+
El build genera tres salidas mediante Rollup:
|
|
294
|
+
|
|
295
|
+
| Formato | Archivo | Uso |
|
|
296
|
+
|---|---|---|
|
|
297
|
+
| ESM | `dist/esm/index.js` | Bundlers modernos (Vite) |
|
|
298
|
+
| CJS | `dist/cjs/index.js` | Node.js / CommonJS |
|
|
299
|
+
| Tipos | `dist/types/index.d.ts` | TypeScript |
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Sistemas que consumen esta librería
|
|
304
|
+
|
|
305
|
+
| Sistema | URL de producción |
|
|
306
|
+
|---|---|
|
|
307
|
+
| PASS | `botech.com.co/pass/` |
|
|
308
|
+
| Seguimiento | `botech.com.co/seguimiento/` |
|