neogestify-ui-components 1.2.17 → 1.2.19

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.
Files changed (41) hide show
  1. package/README.md +349 -342
  2. package/dist/components/alerts/index.js +1 -1
  3. package/dist/components/alerts/index.js.map +1 -1
  4. package/dist/components/alerts/index.mjs +1 -1
  5. package/dist/components/alerts/index.mjs.map +1 -1
  6. package/dist/components/html/index.js +7 -4
  7. package/dist/components/html/index.js.map +1 -1
  8. package/dist/components/html/index.mjs +7 -4
  9. package/dist/components/html/index.mjs.map +1 -1
  10. package/dist/components/icons/index.js.map +1 -1
  11. package/dist/components/icons/index.mjs.map +1 -1
  12. package/dist/context/theme/index.js +1 -1
  13. package/dist/context/theme/index.js.map +1 -1
  14. package/dist/context/theme/index.mjs +1 -1
  15. package/dist/context/theme/index.mjs.map +1 -1
  16. package/dist/index.js +7 -4
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +7 -4
  19. package/dist/index.mjs.map +1 -1
  20. package/package.json +1 -1
  21. package/src/components/alerts/InfoAlert.tsx +25 -25
  22. package/src/components/alerts/alerta.ts +93 -93
  23. package/src/components/alerts/index.ts +1 -1
  24. package/src/components/html/Button.tsx +71 -71
  25. package/src/components/html/Form.tsx +39 -39
  26. package/src/components/html/Input.tsx +136 -132
  27. package/src/components/html/Loading.tsx +104 -104
  28. package/src/components/html/Modal.tsx +79 -79
  29. package/src/components/html/Select.tsx +81 -81
  30. package/src/components/html/Table.tsx +61 -61
  31. package/src/components/html/TextArea.tsx +70 -70
  32. package/src/components/html/index.ts +7 -7
  33. package/src/components/icons/icons.tsx +550 -550
  34. package/src/components/icons/index.ts +1 -1
  35. package/src/context/theme/ThemeContext.tsx +37 -37
  36. package/src/context/theme/ThemeToggle.tsx +23 -23
  37. package/src/context/theme/index.ts +3 -3
  38. package/src/context/theme/theme.types.ts +11 -11
  39. package/src/context/theme/useTheme.ts +10 -10
  40. package/src/index.ts +5 -5
  41. package/src/types/types.ts +3 -3
package/README.md CHANGED
@@ -1,342 +1,349 @@
1
- # UI Components
2
-
3
- Biblioteca de componentes UI reutilizables con React, Tailwind CSS y SweetAlert2.
4
-
5
- [Construyamos juntos esta libreria](https://github.com/NeoGestify/ui-components)
6
-
7
- ## Características
8
-
9
- - Componentes HTML preestilizados (Button, Input, Form, Select, Table, Modal)
10
- - Colección de iconos SVG
11
- - Alertas preconfiguradas con SweetAlert2
12
- - Soporte para modo claro/oscuro
13
- - TypeScript incluido
14
- - Compatible con Tailwind CSS 4.1
15
-
16
- ## Instalación
17
-
18
- Si estás usando workspaces con npm/bun:
19
-
20
- ### NPM
21
-
22
- ```bash
23
- # En tu proyecto
24
- npm i neogestify-ui-components
25
- ```
26
-
27
- ### BUN
28
- ```bash
29
- # En tu proyecto
30
- bun i neogestify-ui-components
31
- ```
32
-
33
-
34
- ## Configuración
35
-
36
- ### 1. Asegúrate de tener Tailwind CSS configurado en tu proyecto
37
-
38
- ```bash
39
- bun add -D tailwindcss@4.1.0
40
- ```
41
-
42
- Tu proyecto debe tener Tailwind configurado ya que los componentes solo usan clases de Tailwind (no incluyen CSS compilado).
43
-
44
- ### 2. Configura Tailwind para escanear los componentes de la biblioteca
45
-
46
- **⚠️ IMPORTANTE:** Esta librería requiere que configures Tailwind para escanear sus archivos fuente.
47
-
48
- **Para Tailwind CSS v4:**
49
-
50
- En tu archivo CSS principal (por ejemplo `src/index.css`):
51
-
52
- ```css
53
- @import "tailwindcss";
54
-
55
- @source "../node_modules/neogestify-ui-components/src";
56
-
57
- @variant dark (&:where(.dark, .dark *)) {}
58
- ```
59
-
60
- > 📖 **Para más detalles sobre la configuración de Tailwind v4, incluyendo monorepos y troubleshooting, consulta [TAILWIND_V4_SETUP.md](./TAILWIND_V4_SETUP.md)**
61
-
62
- ### 3. Instala las dependencias peer
63
-
64
- ```bash
65
- bun add react react-dom sweetalert2 sweetalert2-react-content
66
- ```
67
-
68
- ## Uso
69
-
70
- La biblioteca está organizada en módulos independientes:
71
-
72
- ### Componentes HTML
73
-
74
- ```tsx
75
- import { Button, Input, Form, Select, Table, Modal } from '@mi-empresa/ui-components/html';
76
-
77
- function MiComponente() {
78
- return (
79
- <Form onSubmit={handleSubmit}>
80
- <Input
81
- label="Nombre"
82
- placeholder="Tu nombre"
83
- value={nombre}
84
- onChange={(e) => setNombre(e.target.value)}
85
- />
86
-
87
- <Select
88
- label="País"
89
- options={[
90
- { value: 'mx', label: 'México' },
91
- { value: 'ar', label: 'Argentina' }
92
- ]}
93
- />
94
-
95
- <Button variant="primary" type="submit">
96
- Enviar
97
- </Button>
98
- </Form>
99
- );
100
- }
101
- ```
102
-
103
- ### Iconos
104
-
105
- ```tsx
106
- import {
107
- HomeIcon,
108
- SaveIcon,
109
- DeleteIcon,
110
- EditIcon
111
- } from '@mi-empresa/ui-components/icons';
112
-
113
- function MiComponente() {
114
- return (
115
- <div>
116
- <HomeIcon className="w-6 h-6 text-blue-500" />
117
- <SaveIcon className="w-5 h-5 text-green-600" />
118
- </div>
119
- );
120
- }
121
- ```
122
-
123
- ### Alertas
124
-
125
- ```tsx
126
- import {
127
- AlertaExito,
128
- AlertaError,
129
- AlertaAdvertencia,
130
- AlertaConfirmacion,
131
- AlertaToast
132
- } from '@mi-empresa/ui-components/alerts';
133
-
134
- function MiComponente() {
135
- const handleGuardar = async () => {
136
- try {
137
- await guardarDatos();
138
- AlertaExito('¡Guardado!', 'Los datos se guardaron correctamente');
139
- } catch (error) {
140
- AlertaError('Error', 'No se pudieron guardar los datos');
141
- }
142
- };
143
-
144
- const handleEliminar = () => {
145
- AlertaAdvertencia(
146
- '¿Estás seguro?',
147
- 'Esta acción no se puede deshacer',
148
- async () => {
149
- await eliminarDatos();
150
- AlertaToast('Eliminado', 'Registro eliminado', 'success');
151
- }
152
- );
153
- };
154
-
155
- return (
156
- <Button variant="danger" onClick={handleEliminar}>
157
- Eliminar
158
- </Button>
159
- );
160
- }
161
- ```
162
-
163
- ### Sistema de Tema
164
-
165
- El sistema de tema incluye un Context Provider y un componente toggle listo para usar.
166
-
167
- #### 1. Configurar el ThemeProvider
168
-
169
- Envuelve tu aplicación con el `ThemeProvider`:
170
-
171
- ```tsx
172
- // main.tsx o App.tsx
173
- import { ThemeProvider } from '@mi-empresa/ui-components/context/theme';
174
-
175
- function Main() {
176
- return (
177
- <ThemeProvider>
178
- <App />
179
- </ThemeProvider>
180
- );
181
- }
182
- ```
183
-
184
- #### 2. Usar el ThemeToggle
185
-
186
- ```tsx
187
- import { ThemeToggle } from '@mi-empresa/ui-components/theme';
188
-
189
- function Header() {
190
- return (
191
- <nav>
192
- <ThemeToggle />
193
- </nav>
194
- );
195
- }
196
- ```
197
-
198
- #### 3. Usar el hook useTheme
199
-
200
- ```tsx
201
- import { useTheme } from '@mi-empresa/ui-components/context/theme';
202
-
203
- function MiComponente() {
204
- const { theme, toggleTheme, setTheme } = useTheme();
205
-
206
- return (
207
- <div>
208
- <p>Tema actual: {theme}</p>
209
- <button onClick={toggleTheme}>Cambiar tema</button>
210
- <button onClick={() => setTheme('dark')}>Modo oscuro</button>
211
- <button onClick={() => setTheme('light')}>Modo claro</button>
212
- </div>
213
- );
214
- }
215
- ```
216
-
217
- El tema se guarda automáticamente en `localStorage` y se aplica al cargar la página.
218
-
219
- ## Componentes Disponibles
220
-
221
- ### Button
222
-
223
- Variantes: `primary`, `secondary`, `danger`, `success`, `warning`, `outline`, `icon`, `nav`, `link`, `toggle`
224
-
225
- ```tsx
226
- <Button variant="primary" isLoading loadingText="Guardando...">
227
- Guardar
228
- </Button>
229
- ```
230
-
231
- ### Input
232
-
233
- Soporta tipos: `text`, `email`, `password`, `number`, `checkbox`, etc.
234
-
235
- ```tsx
236
- <Input
237
- label="Email"
238
- type="email"
239
- error="Email inválido"
240
- helperText="Ingresa tu correo electrónico"
241
- />
242
- ```
243
-
244
- ### Select
245
-
246
- ```tsx
247
- <Select
248
- label="Categoría"
249
- placeholder="Selecciona..."
250
- options={categorias}
251
- variant="default"
252
- />
253
- ```
254
-
255
- ### Table
256
-
257
- ```tsx
258
- <Table
259
- headers={['ID', 'Nombre', 'Email']}
260
- rows={[
261
- ['1', 'Juan', 'juan@ejemplo.com'],
262
- ['2', 'María', 'maria@ejemplo.com']
263
- ]}
264
- />
265
- ```
266
-
267
- ### Modal
268
-
269
- ```tsx
270
- const modalRef = useRef<ModalRef>(null);
271
-
272
- <Modal
273
- ref={modalRef}
274
- title="Mi Modal"
275
- onClose={() => setShowModal(false)}
276
- footer={
277
- <Button onClick={() => modalRef.current?.handleClose()}>
278
- Cerrar
279
- </Button>
280
- }
281
- >
282
- <p>Contenido del modal</p>
283
- </Modal>
284
- ```
285
-
286
- ## Showcase / Demo
287
-
288
- Para ver todos los componentes en acción:
289
-
290
- ```bash
291
- cd showcase
292
- bun install
293
- bun dev
294
- ```
295
-
296
- Abre http://localhost:5173 en tu navegador.
297
-
298
- ## Desarrollo
299
-
300
- ### Build
301
-
302
- ```bash
303
- bun install
304
- bun run build
305
- ```
306
-
307
- ### Estructura del proyecto
308
-
309
- ```
310
- ui-components/
311
- ├── src/
312
- │ ├── components/
313
- │ │ ├── html/ # Componentes HTML
314
- │ │ ├── icons/ # Iconos SVG
315
- │ │ └── alerts/ # Alertas SweetAlert2
316
- │ └── types/ # Tipos TypeScript
317
- ├── showcase/ # Demo/Showcase
318
- └── dist/ # Build output
319
- ```
320
-
321
- ## Modo Oscuro
322
-
323
- Los componentes soportan modo oscuro automáticamente usando las clases `dark:` de Tailwind. Asegúrate de configurar el modo oscuro en tu proyecto:
324
-
325
- ```js
326
- // tailwind.config.js
327
- export default {
328
- darkMode: 'class', // o 'media'
329
- // ...
330
- }
331
- ```
332
-
333
- Para activar el modo oscuro:
334
-
335
- ```tsx
336
- // Agregar/quitar la clase 'dark' en el html
337
- document.documentElement.classList.add('dark');
338
- ```
339
-
340
- ## Licencia
341
-
342
- MIT
1
+ # UI Components
2
+
3
+ Biblioteca de componentes UI reutilizables con React, Tailwind CSS y SweetAlert2.
4
+
5
+ ## Características
6
+
7
+ - Componentes HTML preestilizados (Button, Input, Form, Select, Table, Modal)
8
+ - Colección de iconos SVG
9
+ - Alertas preconfiguradas con SweetAlert2
10
+ - Soporte para modo claro/oscuro
11
+ - TypeScript incluido
12
+ - Compatible con Tailwind CSS 4.1
13
+
14
+ ## Instalación
15
+
16
+ Si estás usando workspaces con npm/bun:
17
+
18
+ ### NPM
19
+
20
+ ```bash
21
+ # En tu proyecto
22
+ npm i neogestify-ui-components
23
+ ```
24
+
25
+ ### BUN
26
+ ```bash
27
+ # En tu proyecto
28
+ npm i neogestify-ui-components
29
+ ```
30
+
31
+
32
+ ## Configuración
33
+
34
+ ### 1. Asegúrate de tener Tailwind CSS configurado en tu proyecto
35
+
36
+ ```bash
37
+ bun add -D tailwindcss@4.1.0
38
+ ```
39
+
40
+ Tu proyecto debe tener Tailwind configurado ya que los componentes solo usan clases de Tailwind (no incluyen CSS compilado).
41
+
42
+ ### 2. Configura Tailwind para escanear los componentes de la biblioteca
43
+
44
+ **⚠️ IMPORTANTE:** Esta librería requiere que configures Tailwind para escanear sus archivos fuente.
45
+
46
+ **Para Tailwind CSS v4:**
47
+
48
+ En tu archivo CSS principal (por ejemplo `src/index.css`):
49
+
50
+ ```css
51
+ @import "tailwindcss";
52
+
53
+ @source "../node_modules/neogestify-ui-components/src";
54
+ ```
55
+
56
+ **Agrega este script a tu index.html**
57
+ ```html
58
+ <script>
59
+ // Prevenir flash de contenido sin estilo (FOUC)
60
+ const theme = localStorage.getItem('theme') || 'light';
61
+ if (theme === 'dark') {
62
+ document.documentElement.classList.add('dark');
63
+ } else {
64
+ document.documentElement.classList.remove('dark');
65
+ }
66
+ </script>
67
+ ```
68
+
69
+ ### 3. Instala las dependencias peer
70
+
71
+ ```bash
72
+ bun add react react-dom sweetalert2 sweetalert2-react-content
73
+ ```
74
+
75
+ ## Uso
76
+
77
+ La biblioteca está organizada en módulos independientes:
78
+
79
+ ### Componentes HTML
80
+
81
+ ```tsx
82
+ import { Button, Input, Form, Select, Table, Modal } from 'neogestify-ui-components/html';
83
+
84
+ function MiComponente() {
85
+ return (
86
+ <Form onSubmit={handleSubmit}>
87
+ <Input
88
+ label="Nombre"
89
+ placeholder="Tu nombre"
90
+ value={nombre}
91
+ onChange={(e) => setNombre(e.target.value)}
92
+ />
93
+
94
+ <Select
95
+ label="País"
96
+ options={[
97
+ { value: 'mx', label: 'México' },
98
+ { value: 'ar', label: 'Argentina' }
99
+ ]}
100
+ />
101
+
102
+ <Button variant="primary" type="submit">
103
+ Enviar
104
+ </Button>
105
+ </Form>
106
+ );
107
+ }
108
+ ```
109
+
110
+ ### Iconos
111
+
112
+ ```tsx
113
+ import {
114
+ HomeIcon,
115
+ SaveIcon,
116
+ DeleteIcon,
117
+ EditIcon
118
+ } from 'neogestify-ui-components/icons';
119
+
120
+ function MiComponente() {
121
+ return (
122
+ <div>
123
+ <HomeIcon className="w-6 h-6 text-blue-500" />
124
+ <SaveIcon className="w-5 h-5 text-green-600" />
125
+ </div>
126
+ );
127
+ }
128
+ ```
129
+
130
+ ### Alertas
131
+
132
+ ```tsx
133
+ import {
134
+ AlertaExito,
135
+ AlertaError,
136
+ AlertaAdvertencia,
137
+ AlertaConfirmacion,
138
+ AlertaToast
139
+ } from 'neogestify-ui-components/alerts';
140
+
141
+ function MiComponente() {
142
+ const handleGuardar = async () => {
143
+ try {
144
+ await guardarDatos();
145
+ AlertaExito('¡Guardado!', 'Los datos se guardaron correctamente');
146
+ } catch (error) {
147
+ AlertaError('Error', 'No se pudieron guardar los datos');
148
+ }
149
+ };
150
+
151
+ const handleEliminar = () => {
152
+ AlertaAdvertencia(
153
+ '¿Estás seguro?',
154
+ 'Esta acción no se puede deshacer',
155
+ async () => {
156
+ await eliminarDatos();
157
+ AlertaToast('Eliminado', 'Registro eliminado', 'success');
158
+ }
159
+ );
160
+ };
161
+
162
+ return (
163
+ <Button variant="danger" onClick={handleEliminar}>
164
+ Eliminar
165
+ </Button>
166
+ );
167
+ }
168
+ ```
169
+
170
+ ### Sistema de Tema
171
+
172
+ El sistema de tema incluye un Context Provider y un componente toggle listo para usar.
173
+
174
+ #### 1. Configurar el ThemeProvider
175
+
176
+ Envuelve tu aplicación con el `ThemeProvider`:
177
+
178
+ ```tsx
179
+ // main.tsx o App.tsx
180
+ import { ThemeProvider } from 'neogestify-ui-components/theme';
181
+
182
+ function Main() {
183
+ return (
184
+ <ThemeProvider>
185
+ <App />
186
+ </ThemeProvider>
187
+ );
188
+ }
189
+ ```
190
+
191
+ #### 2. Usar el ThemeToggle
192
+
193
+ ```tsx
194
+ import { ThemeToggle } from 'neogestify-ui-components/theme';
195
+
196
+ function Header() {
197
+ return (
198
+ <nav>
199
+ <ThemeToggle />
200
+ </nav>
201
+ );
202
+ }
203
+ ```
204
+
205
+ #### 3. Usar el hook useTheme
206
+
207
+ ```tsx
208
+ import { useTheme } from 'neogestify-ui-components/theme';
209
+
210
+ function MiComponente() {
211
+ const { theme, toggleTheme, setTheme } = useTheme();
212
+
213
+ return (
214
+ <div>
215
+ <p>Tema actual: {theme}</p>
216
+ <button onClick={toggleTheme}>Cambiar tema</button>
217
+ <button onClick={() => setTheme('dark')}>Modo oscuro</button>
218
+ <button onClick={() => setTheme('light')}>Modo claro</button>
219
+ </div>
220
+ );
221
+ }
222
+ ```
223
+
224
+ El tema se guarda automáticamente en `localStorage` y se aplica al cargar la página.
225
+
226
+ ## Componentes Disponibles
227
+
228
+ ### Button
229
+
230
+ Variantes: `primary`, `secondary`, `danger`, `success`, `warning`, `outline`, `icon`, `nav`, `link`, `toggle`
231
+
232
+ ```tsx
233
+ <Button variant="primary" isLoading loadingText="Guardando...">
234
+ Guardar
235
+ </Button>
236
+ ```
237
+
238
+ ### Input
239
+
240
+ Soporta tipos: `text`, `email`, `password`, `number`, `checkbox`, etc.
241
+
242
+ ```tsx
243
+ <Input
244
+ label="Email"
245
+ type="email"
246
+ error="Email inválido"
247
+ helperText="Ingresa tu correo electrónico"
248
+ />
249
+ ```
250
+
251
+ ### Select
252
+
253
+ ```tsx
254
+ <Select
255
+ label="Categoría"
256
+ placeholder="Selecciona..."
257
+ options={categorias}
258
+ variant="default"
259
+ />
260
+ ```
261
+
262
+ ### Table
263
+
264
+ ```tsx
265
+ <Table
266
+ headers={['ID', 'Nombre', 'Email']}
267
+ rows={[
268
+ ['1', 'Juan', 'juan@ejemplo.com'],
269
+ ['2', 'María', 'maria@ejemplo.com']
270
+ ]}
271
+ />
272
+ ```
273
+
274
+ ### Modal
275
+
276
+ ```tsx
277
+ const modalRef = useRef<ModalRef>(null);
278
+
279
+ <Modal
280
+ ref={modalRef}
281
+ title="Mi Modal"
282
+ onClose={() => setShowModal(false)}
283
+ footer={
284
+ <Button onClick={() => modalRef.current?.handleClose()}>
285
+ Cerrar
286
+ </Button>
287
+ }
288
+ >
289
+ <p>Contenido del modal</p>
290
+ </Modal>
291
+ ```
292
+
293
+ ## Showcase / Demo
294
+
295
+ Para ver todos los componentes en acción:
296
+
297
+ ```bash
298
+ cd showcase
299
+ bun install
300
+ bun dev
301
+ ```
302
+
303
+ Abre http://localhost:5173 en tu navegador.
304
+
305
+ ## Desarrollo
306
+
307
+ ### Build
308
+
309
+ ```bash
310
+ bun install
311
+ bun run build
312
+ ```
313
+
314
+ ### Estructura del proyecto
315
+
316
+ ```
317
+ ui-components/
318
+ ├── src/
319
+ │ ├── components/
320
+ │ │ ├── html/ # Componentes HTML
321
+ │ │ ├── icons/ # Iconos SVG
322
+ │ │ └── alerts/ # Alertas SweetAlert2
323
+ │ └── types/ # Tipos TypeScript
324
+ ├── showcase/ # Demo/Showcase
325
+ └── dist/ # Build output
326
+ ```
327
+
328
+ ## Modo Oscuro
329
+
330
+ Los componentes soportan modo oscuro automáticamente usando las clases `dark:` de Tailwind. Asegúrate de configurar el modo oscuro en tu proyecto:
331
+
332
+ ```js
333
+ // tailwind.config.js
334
+ export default {
335
+ darkMode: 'class', // o 'media'
336
+ // ...
337
+ }
338
+ ```
339
+
340
+ Para activar el modo oscuro:
341
+
342
+ ```tsx
343
+ // Agregar/quitar la clase 'dark' en el html
344
+ document.documentElement.classList.add('dark');
345
+ ```
346
+
347
+ ## Licencia
348
+
349
+ MIT