neogestify-ui-components 1.2.12 → 1.2.14

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