neogestify-ui-components 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 ADDED
@@ -0,0 +1,350 @@
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
+ ### Opción 1: Workspace local (Monorepo)
17
+
18
+ Si estás usando workspaces con npm/bun:
19
+
20
+ ```bash
21
+ # En tu proyecto principal
22
+ bun add @mi-empresa/ui-components@workspace:*
23
+ ```
24
+
25
+ ### Opción 2: Link local
26
+
27
+ ```bash
28
+ # En la carpeta ui-components
29
+ bun link
30
+
31
+ # En tu proyecto
32
+ bun link @mi-empresa/ui-components
33
+ ```
34
+
35
+ ### Opción 3: Repositorio Git
36
+
37
+ ```json
38
+ {
39
+ "dependencies": {
40
+ "@mi-empresa/ui-components": "git+https://github.com/tu-usuario/ui-components.git"
41
+ }
42
+ }
43
+ ```
44
+
45
+ ## Configuración
46
+
47
+ ### 1. Asegúrate de tener Tailwind CSS configurado en tu proyecto
48
+
49
+ ```bash
50
+ bun add -D tailwindcss@4.1.0
51
+ ```
52
+
53
+ Tu proyecto debe tener Tailwind configurado ya que los componentes solo usan clases de Tailwind (no incluyen CSS compilado).
54
+
55
+ ### 2. Configura Tailwind para escanear los componentes de la biblioteca
56
+
57
+ En tu archivo de configuración de Tailwind:
58
+
59
+ ```js
60
+ // tailwind.config.js
61
+ export default {
62
+ content: [
63
+ "./src/**/*.{js,jsx,ts,tsx}",
64
+ "./node_modules/@mi-empresa/ui-components/dist/**/*.{js,mjs}"
65
+ ],
66
+ // ... resto de configuración
67
+ }
68
+ ```
69
+
70
+ ### 3. Instala las dependencias peer
71
+
72
+ ```bash
73
+ bun add react react-dom sweetalert2 sweetalert2-react-content
74
+ ```
75
+
76
+ ## Uso
77
+
78
+ La biblioteca está organizada en módulos independientes:
79
+
80
+ ### Componentes HTML
81
+
82
+ ```tsx
83
+ import { Button, Input, Form, Select, Table, Modal } from '@mi-empresa/ui-components/html';
84
+
85
+ function MiComponente() {
86
+ return (
87
+ <Form onSubmit={handleSubmit}>
88
+ <Input
89
+ label="Nombre"
90
+ placeholder="Tu nombre"
91
+ value={nombre}
92
+ onChange={(e) => setNombre(e.target.value)}
93
+ />
94
+
95
+ <Select
96
+ label="País"
97
+ options={[
98
+ { value: 'mx', label: 'México' },
99
+ { value: 'ar', label: 'Argentina' }
100
+ ]}
101
+ />
102
+
103
+ <Button variant="primary" type="submit">
104
+ Enviar
105
+ </Button>
106
+ </Form>
107
+ );
108
+ }
109
+ ```
110
+
111
+ ### Iconos
112
+
113
+ ```tsx
114
+ import {
115
+ HomeIcon,
116
+ SaveIcon,
117
+ DeleteIcon,
118
+ EditIcon
119
+ } from '@mi-empresa/ui-components/icons';
120
+
121
+ function MiComponente() {
122
+ return (
123
+ <div>
124
+ <HomeIcon className="w-6 h-6 text-blue-500" />
125
+ <SaveIcon className="w-5 h-5 text-green-600" />
126
+ </div>
127
+ );
128
+ }
129
+ ```
130
+
131
+ ### Alertas
132
+
133
+ ```tsx
134
+ import {
135
+ AlertaExito,
136
+ AlertaError,
137
+ AlertaAdvertencia,
138
+ AlertaConfirmacion,
139
+ AlertaToast
140
+ } from '@mi-empresa/ui-components/alerts';
141
+
142
+ function MiComponente() {
143
+ const handleGuardar = async () => {
144
+ try {
145
+ await guardarDatos();
146
+ AlertaExito('¡Guardado!', 'Los datos se guardaron correctamente');
147
+ } catch (error) {
148
+ AlertaError('Error', 'No se pudieron guardar los datos');
149
+ }
150
+ };
151
+
152
+ const handleEliminar = () => {
153
+ AlertaAdvertencia(
154
+ '¿Estás seguro?',
155
+ 'Esta acción no se puede deshacer',
156
+ async () => {
157
+ await eliminarDatos();
158
+ AlertaToast('Eliminado', 'Registro eliminado', 'success');
159
+ }
160
+ );
161
+ };
162
+
163
+ return (
164
+ <Button variant="danger" onClick={handleEliminar}>
165
+ Eliminar
166
+ </Button>
167
+ );
168
+ }
169
+ ```
170
+
171
+ ### Sistema de Tema
172
+
173
+ El sistema de tema incluye un Context Provider y un componente toggle listo para usar.
174
+
175
+ #### 1. Configurar el ThemeProvider
176
+
177
+ Envuelve tu aplicación con el `ThemeProvider`:
178
+
179
+ ```tsx
180
+ // main.tsx o App.tsx
181
+ import { ThemeProvider } from '@mi-empresa/ui-components/context/theme';
182
+
183
+ function Main() {
184
+ return (
185
+ <ThemeProvider>
186
+ <App />
187
+ </ThemeProvider>
188
+ );
189
+ }
190
+ ```
191
+
192
+ #### 2. Usar el ThemeToggle
193
+
194
+ ```tsx
195
+ import { ThemeToggle } from '@mi-empresa/ui-components/theme';
196
+
197
+ function Header() {
198
+ return (
199
+ <nav>
200
+ <ThemeToggle />
201
+ </nav>
202
+ );
203
+ }
204
+ ```
205
+
206
+ #### 3. Usar el hook useTheme
207
+
208
+ ```tsx
209
+ import { useTheme } from '@mi-empresa/ui-components/context/theme';
210
+
211
+ function MiComponente() {
212
+ const { theme, toggleTheme, setTheme } = useTheme();
213
+
214
+ return (
215
+ <div>
216
+ <p>Tema actual: {theme}</p>
217
+ <button onClick={toggleTheme}>Cambiar tema</button>
218
+ <button onClick={() => setTheme('dark')}>Modo oscuro</button>
219
+ <button onClick={() => setTheme('light')}>Modo claro</button>
220
+ </div>
221
+ );
222
+ }
223
+ ```
224
+
225
+ El tema se guarda automáticamente en `localStorage` y se aplica al cargar la página.
226
+
227
+ ## Componentes Disponibles
228
+
229
+ ### Button
230
+
231
+ Variantes: `primary`, `secondary`, `danger`, `success`, `warning`, `outline`, `icon`, `nav`, `link`, `toggle`
232
+
233
+ ```tsx
234
+ <Button variant="primary" isLoading loadingText="Guardando...">
235
+ Guardar
236
+ </Button>
237
+ ```
238
+
239
+ ### Input
240
+
241
+ Soporta tipos: `text`, `email`, `password`, `number`, `checkbox`, etc.
242
+
243
+ ```tsx
244
+ <Input
245
+ label="Email"
246
+ type="email"
247
+ error="Email inválido"
248
+ helperText="Ingresa tu correo electrónico"
249
+ />
250
+ ```
251
+
252
+ ### Select
253
+
254
+ ```tsx
255
+ <Select
256
+ label="Categoría"
257
+ placeholder="Selecciona..."
258
+ options={categorias}
259
+ variant="default"
260
+ />
261
+ ```
262
+
263
+ ### Table
264
+
265
+ ```tsx
266
+ <Table
267
+ headers={['ID', 'Nombre', 'Email']}
268
+ rows={[
269
+ ['1', 'Juan', 'juan@ejemplo.com'],
270
+ ['2', 'María', 'maria@ejemplo.com']
271
+ ]}
272
+ />
273
+ ```
274
+
275
+ ### Modal
276
+
277
+ ```tsx
278
+ const modalRef = useRef<ModalRef>(null);
279
+
280
+ <Modal
281
+ ref={modalRef}
282
+ title="Mi Modal"
283
+ onClose={() => setShowModal(false)}
284
+ footer={
285
+ <Button onClick={() => modalRef.current?.handleClose()}>
286
+ Cerrar
287
+ </Button>
288
+ }
289
+ >
290
+ <p>Contenido del modal</p>
291
+ </Modal>
292
+ ```
293
+
294
+ ## Showcase / Demo
295
+
296
+ Para ver todos los componentes en acción:
297
+
298
+ ```bash
299
+ cd showcase
300
+ bun install
301
+ bun dev
302
+ ```
303
+
304
+ Abre http://localhost:5173 en tu navegador.
305
+
306
+ ## Desarrollo
307
+
308
+ ### Build
309
+
310
+ ```bash
311
+ bun install
312
+ bun run build
313
+ ```
314
+
315
+ ### Estructura del proyecto
316
+
317
+ ```
318
+ ui-components/
319
+ ├── src/
320
+ │ ├── components/
321
+ │ │ ├── html/ # Componentes HTML
322
+ │ │ ├── icons/ # Iconos SVG
323
+ │ │ └── alerts/ # Alertas SweetAlert2
324
+ │ └── types/ # Tipos TypeScript
325
+ ├── showcase/ # Demo/Showcase
326
+ └── dist/ # Build output
327
+ ```
328
+
329
+ ## Modo Oscuro
330
+
331
+ Los componentes soportan modo oscuro automáticamente usando las clases `dark:` de Tailwind. Asegúrate de configurar el modo oscuro en tu proyecto:
332
+
333
+ ```js
334
+ // tailwind.config.js
335
+ export default {
336
+ darkMode: 'class', // o 'media'
337
+ // ...
338
+ }
339
+ ```
340
+
341
+ Para activar el modo oscuro:
342
+
343
+ ```tsx
344
+ // Agregar/quitar la clase 'dark' en el html
345
+ document.documentElement.classList.add('dark');
346
+ ```
347
+
348
+ ## Licencia
349
+
350
+ MIT
@@ -0,0 +1,46 @@
1
+ import * as sweetalert2 from 'sweetalert2';
2
+
3
+ interface AlertaOptions {
4
+ title: string;
5
+ text: string;
6
+ icon: 'success' | 'error' | 'warning' | 'info' | 'question';
7
+ confirmButtonText?: string;
8
+ showCancelButton?: boolean;
9
+ cancelButtonText?: string;
10
+ showDenyButton?: boolean;
11
+ denyButtonText?: string;
12
+ onConfirm?: () => void;
13
+ onCancel?: () => void;
14
+ onDeny?: () => void;
15
+ toast?: boolean;
16
+ timer?: number;
17
+ position?: 'top' | 'top-start' | 'top-end' | 'center' | 'center-start' | 'center-end' | 'bottom' | 'bottom-start' | 'bottom-end';
18
+ allowOutsideClick?: boolean;
19
+ allowEscapeKey?: boolean;
20
+ input?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'range' | 'textarea' | 'select' | 'radio' | 'checkbox' | 'file' | 'url';
21
+ inputLabel?: string;
22
+ inputPlaceholder?: string;
23
+ inputValue?: string;
24
+ inputValidator?: (value: unknown) => string | null | Promise<string | null>;
25
+ inputAttributes?: Record<string, string>;
26
+ }
27
+ declare function Alerta(options: AlertaOptions): Promise<sweetalert2.SweetAlertResult<any>>;
28
+ declare const AlertaExito: (title: string, text: string, onConfirm?: () => void, options?: {
29
+ allowOutsideClick?: boolean;
30
+ allowEscapeKey?: boolean;
31
+ }) => Promise<sweetalert2.SweetAlertResult<any>>;
32
+ declare const AlertaError: (title: string, text: string, onConfirm?: () => void, options?: {
33
+ allowOutsideClick?: boolean;
34
+ allowEscapeKey?: boolean;
35
+ }) => Promise<sweetalert2.SweetAlertResult<any>>;
36
+ declare const AlertaAdvertencia: (title: string, text: string, onConfirm?: () => void, onCancel?: () => void, options?: {
37
+ allowOutsideClick?: boolean;
38
+ allowEscapeKey?: boolean;
39
+ }) => Promise<sweetalert2.SweetAlertResult<any>>;
40
+ declare const AlertaConfirmacion: (title: string, text: string, onConfirm?: () => void, onCancel?: () => void, options?: {
41
+ allowOutsideClick?: boolean;
42
+ allowEscapeKey?: boolean;
43
+ }) => Promise<sweetalert2.SweetAlertResult<any>>;
44
+ declare const AlertaToast: (title: string, text: string, icon?: "success" | "error" | "warning" | "info", timer?: number, position?: "top" | "top-start" | "top-end" | "center" | "center-start" | "center-end" | "bottom" | "bottom-start" | "bottom-end") => Promise<sweetalert2.SweetAlertResult<any>>;
45
+
46
+ export { Alerta, AlertaAdvertencia, AlertaConfirmacion, AlertaError, AlertaExito, AlertaToast };
@@ -0,0 +1,46 @@
1
+ import * as sweetalert2 from 'sweetalert2';
2
+
3
+ interface AlertaOptions {
4
+ title: string;
5
+ text: string;
6
+ icon: 'success' | 'error' | 'warning' | 'info' | 'question';
7
+ confirmButtonText?: string;
8
+ showCancelButton?: boolean;
9
+ cancelButtonText?: string;
10
+ showDenyButton?: boolean;
11
+ denyButtonText?: string;
12
+ onConfirm?: () => void;
13
+ onCancel?: () => void;
14
+ onDeny?: () => void;
15
+ toast?: boolean;
16
+ timer?: number;
17
+ position?: 'top' | 'top-start' | 'top-end' | 'center' | 'center-start' | 'center-end' | 'bottom' | 'bottom-start' | 'bottom-end';
18
+ allowOutsideClick?: boolean;
19
+ allowEscapeKey?: boolean;
20
+ input?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'range' | 'textarea' | 'select' | 'radio' | 'checkbox' | 'file' | 'url';
21
+ inputLabel?: string;
22
+ inputPlaceholder?: string;
23
+ inputValue?: string;
24
+ inputValidator?: (value: unknown) => string | null | Promise<string | null>;
25
+ inputAttributes?: Record<string, string>;
26
+ }
27
+ declare function Alerta(options: AlertaOptions): Promise<sweetalert2.SweetAlertResult<any>>;
28
+ declare const AlertaExito: (title: string, text: string, onConfirm?: () => void, options?: {
29
+ allowOutsideClick?: boolean;
30
+ allowEscapeKey?: boolean;
31
+ }) => Promise<sweetalert2.SweetAlertResult<any>>;
32
+ declare const AlertaError: (title: string, text: string, onConfirm?: () => void, options?: {
33
+ allowOutsideClick?: boolean;
34
+ allowEscapeKey?: boolean;
35
+ }) => Promise<sweetalert2.SweetAlertResult<any>>;
36
+ declare const AlertaAdvertencia: (title: string, text: string, onConfirm?: () => void, onCancel?: () => void, options?: {
37
+ allowOutsideClick?: boolean;
38
+ allowEscapeKey?: boolean;
39
+ }) => Promise<sweetalert2.SweetAlertResult<any>>;
40
+ declare const AlertaConfirmacion: (title: string, text: string, onConfirm?: () => void, onCancel?: () => void, options?: {
41
+ allowOutsideClick?: boolean;
42
+ allowEscapeKey?: boolean;
43
+ }) => Promise<sweetalert2.SweetAlertResult<any>>;
44
+ declare const AlertaToast: (title: string, text: string, icon?: "success" | "error" | "warning" | "info", timer?: number, position?: "top" | "top-start" | "top-end" | "center" | "center-start" | "center-end" | "bottom" | "bottom-start" | "bottom-end") => Promise<sweetalert2.SweetAlertResult<any>>;
45
+
46
+ export { Alerta, AlertaAdvertencia, AlertaConfirmacion, AlertaError, AlertaExito, AlertaToast };
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+
3
+ var Swal = require('sweetalert2');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var Swal__default = /*#__PURE__*/_interopDefault(Swal);
8
+
9
+ // src/components/alerts/alerta.ts
10
+ async function Alerta(options) {
11
+ const theme = localStorage.getItem("theme");
12
+ const isDark = theme === "dark";
13
+ const result = await Swal__default.default.fire({
14
+ title: options.title,
15
+ text: options.text,
16
+ icon: options.icon,
17
+ confirmButtonText: options.confirmButtonText || "Aceptar",
18
+ showCancelButton: options.showCancelButton || false,
19
+ cancelButtonText: options.cancelButtonText || "Cancelar",
20
+ showDenyButton: options.showDenyButton || false,
21
+ denyButtonText: options.denyButtonText || "No",
22
+ background: isDark ? "#1f2937" : "#f9fafb",
23
+ color: isDark ? "#f9fafb" : "#1f2937",
24
+ customClass: {
25
+ popup: isDark ? "swal-dark-popup" : "swal-light-popup",
26
+ title: isDark ? "swal-dark-title" : "swal-light-title",
27
+ confirmButton: isDark ? "swal-dark-confirm" : "swal-light-confirm",
28
+ cancelButton: isDark ? "swal-dark-cancel" : "swal-light-cancel",
29
+ denyButton: isDark ? "swal-dark-deny" : "swal-light-deny"
30
+ },
31
+ toast: options.toast || false,
32
+ timer: options.timer,
33
+ position: options.position || "center",
34
+ showConfirmButton: !options.toast && !options.timer,
35
+ timerProgressBar: options.toast || !!options.timer,
36
+ allowOutsideClick: options.allowOutsideClick !== false,
37
+ // Por defecto true
38
+ allowEscapeKey: options.allowEscapeKey !== false,
39
+ // Por defecto true
40
+ input: options.input,
41
+ inputLabel: options.inputLabel,
42
+ inputPlaceholder: options.inputPlaceholder,
43
+ inputValue: options.inputValue,
44
+ inputValidator: options.inputValidator,
45
+ inputAttributes: options.inputAttributes
46
+ });
47
+ if (result.isConfirmed && options.onConfirm) {
48
+ options.onConfirm();
49
+ } else if (result.isDenied && options.onDeny) {
50
+ options.onDeny();
51
+ } else if (result.isDismissed && options.onCancel) {
52
+ options.onCancel();
53
+ }
54
+ return result;
55
+ }
56
+ var AlertaExito = (title, text, onConfirm, options) => Alerta({ title, text, icon: "success", confirmButtonText: "Aceptar", onConfirm, ...options });
57
+ var AlertaError = (title, text, onConfirm, options) => Alerta({ title, text, icon: "error", confirmButtonText: "Aceptar", onConfirm, ...options });
58
+ var AlertaAdvertencia = (title, text, onConfirm, onCancel, options) => Alerta({ title, text, icon: "warning", confirmButtonText: "S\xED, continuar", cancelButtonText: "Cancelar", showCancelButton: true, onConfirm, onCancel, ...options });
59
+ var AlertaConfirmacion = (title, text, onConfirm, onCancel, options) => Alerta({ title, text, icon: "question", confirmButtonText: "S\xED", cancelButtonText: "No", showCancelButton: true, onConfirm, onCancel, ...options });
60
+ var AlertaToast = (title, text, icon = "info", timer = 3e3, position = "top-end") => Alerta({ title, text, icon, toast: true, timer, position });
61
+
62
+ exports.Alerta = Alerta;
63
+ exports.AlertaAdvertencia = AlertaAdvertencia;
64
+ exports.AlertaConfirmacion = AlertaConfirmacion;
65
+ exports.AlertaError = AlertaError;
66
+ exports.AlertaExito = AlertaExito;
67
+ exports.AlertaToast = AlertaToast;
68
+ //# sourceMappingURL=index.js.map
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/alerts/alerta.ts"],"names":["Swal"],"mappings":";;;;;;;;;AA2BA,eAAsB,OAAO,OAAA,EAAwB;AACjD,EAAA,MAAM,KAAA,GAAQ,YAAA,CAAa,OAAA,CAAQ,OAAO,CAAA;AAE1C,EAAA,MAAM,SAAS,KAAA,KAAU,MAAA;AAEzB,EAAA,MAAM,MAAA,GAAS,MAAMA,qBAAA,CAAK,IAAA,CAAK;AAAA,IAC3B,OAAO,OAAA,CAAQ,KAAA;AAAA,IACf,MAAM,OAAA,CAAQ,IAAA;AAAA,IACd,MAAM,OAAA,CAAQ,IAAA;AAAA,IACd,iBAAA,EAAmB,QAAQ,iBAAA,IAAqB,SAAA;AAAA,IAChD,gBAAA,EAAkB,QAAQ,gBAAA,IAAoB,KAAA;AAAA,IAC9C,gBAAA,EAAkB,QAAQ,gBAAA,IAAoB,UAAA;AAAA,IAC9C,cAAA,EAAgB,QAAQ,cAAA,IAAkB,KAAA;AAAA,IAC1C,cAAA,EAAgB,QAAQ,cAAA,IAAkB,IAAA;AAAA,IAC1C,UAAA,EAAY,SAAS,SAAA,GAAY,SAAA;AAAA,IACjC,KAAA,EAAO,SAAS,SAAA,GAAY,SAAA;AAAA,IAC5B,WAAA,EAAa;AAAA,MACT,KAAA,EAAO,SAAS,iBAAA,GAAoB,kBAAA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ACrB;AAEA,EAAA,OAAO,MAAA;AACX;AAGO,IAAM,cAAc,CAAC,KAAA,EAAe,IAAA,EAAc,SAAA,EAAwB,YAC7E,MAAA,CAAO,EAAE,KAAA,EAAO,IAAA,EAAM,MAAM,SAAA,EAAW,iBAAA,EAAmB,WAAW,SAAA,EAAW,GAAG,SAAS;AAEzF,IAAM,cAAc,CAAC,KAAA,EAAe,IAAA,EAAc,SAAA,EAAwB,YAC7E,MAAA,CAAO,EAAE,KAAA,EAAO,IAAA,EAAM,MAAM,OAAA,EAAS,iBAAA,EAAmB,WAAW,SAAA,EAAW,GAAG,SAAS;AAEvF,IAAM,iBAAA,GAAoB,CAAC,KAAA,EAAe,IAAA,EAAc,WAAwB,QAAA,EAAuB,OAAA,KAC1G,MAAA,CAAO,EAAE,KAAA,EAAO,IAAA,EAAM,MAAM,SAAA,EAAW,iBAAA,EAAmB,kBAAA,EAAiB,gBAAA,EAAkB,UAAA,EAAY,gBAAA,EAAkB,MAAM,SAAA,EAAW,QAAA,EAAU,GAAG,OAAA,EAAS;AAE/J,IAAM,kBAAA,GAAqB,CAAC,KAAA,EAAe,IAAA,EAAc,WAAwB,QAAA,EAAuB,OAAA,KAC3G,MAAA,CAAO,EAAE,KAAA,EAAO,IAAA,EAAM,MAAM,UAAA,EAAY,iBAAA,EAAmB,OAAA,EAAM,gBAAA,EAAkB,IAAA,EAAM,gBAAA,EAAkB,MAAM,SAAA,EAAW,QAAA,EAAU,GAAG,OAAA,EAAS;AAE/I,IAAM,cAAc,CAAC,KAAA,EAAe,MAAc,IAAA,GAAiD,MAAA,EAAQ,QAAgB,GAAA,EAAM,QAAA,GAAkI,cACtQ,MAAA,CAAO,EAAE,OAAO,IAAA,EAAM,IAAA,EAAM,OAAO,IAAA,EAAM,KAAA,EAAO,UAAU","file":"index.js","sourcesContent":["import Swal from \"sweetalert2\";\n\ninterface AlertaOptions {\n title: string;\n text: string;\n icon: 'success' | 'error' | 'warning' | 'info' | 'question';\n confirmButtonText?: string;\n showCancelButton?: boolean;\n cancelButtonText?: string;\n showDenyButton?: boolean;\n denyButtonText?: string;\n onConfirm?: () => void;\n onCancel?: () => void;\n onDeny?: () => void;\n toast?: boolean;\n timer?: number;\n position?: 'top' | 'top-start' | 'top-end' | 'center' | 'center-start' | 'center-end' | 'bottom' | 'bottom-start' | 'bottom-end';\n allowOutsideClick?: boolean;\n allowEscapeKey?: boolean;\n input?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'range' | 'textarea' | 'select' | 'radio' | 'checkbox' | 'file' | 'url';\n inputLabel?: string;\n inputPlaceholder?: string;\n inputValue?: string;\n inputValidator?: (value: unknown) => string | null | Promise<string | null>;\n inputAttributes?: Record<string, string>;\n}\n\nexport async function Alerta(options: AlertaOptions) {\n const theme = localStorage.getItem('theme');\n\n const isDark = theme === 'dark';\n\n const result = await Swal.fire({\n title: options.title,\n text: options.text,\n icon: options.icon,\n confirmButtonText: options.confirmButtonText || 'Aceptar',\n showCancelButton: options.showCancelButton || false,\n cancelButtonText: options.cancelButtonText || 'Cancelar',\n showDenyButton: options.showDenyButton || false,\n denyButtonText: options.denyButtonText || 'No',\n background: isDark ? '#1f2937' : '#f9fafb',\n color: isDark ? '#f9fafb' : '#1f2937',\n customClass: {\n popup: isDark ? 'swal-dark-popup' : 'swal-light-popup',\n title: isDark ? 'swal-dark-title' : 'swal-light-title',\n confirmButton: isDark ? 'swal-dark-confirm' : 'swal-light-confirm',\n cancelButton: isDark ? 'swal-dark-cancel' : 'swal-light-cancel',\n denyButton: isDark ? 'swal-dark-deny' : 'swal-light-deny'\n },\n toast: options.toast || false,\n timer: options.timer,\n position: options.position || 'center',\n showConfirmButton: !options.toast && !options.timer,\n timerProgressBar: options.toast || !!options.timer,\n allowOutsideClick: options.allowOutsideClick !== false, // Por defecto true\n allowEscapeKey: options.allowEscapeKey !== false, // Por defecto true\n input: options.input,\n inputLabel: options.inputLabel,\n inputPlaceholder: options.inputPlaceholder,\n inputValue: options.inputValue,\n inputValidator: options.inputValidator,\n inputAttributes: options.inputAttributes\n });\n\n if (result.isConfirmed && options.onConfirm) {\n options.onConfirm();\n } else if (result.isDenied && options.onDeny) {\n options.onDeny();\n } else if (result.isDismissed && options.onCancel) {\n options.onCancel();\n }\n\n return result;\n}\n\n// Funciones de conveniencia para casos comunes\nexport const AlertaExito = (title: string, text: string, onConfirm?: () => void, options?: { allowOutsideClick?: boolean; allowEscapeKey?: boolean }) =>\n Alerta({ title, text, icon: 'success', confirmButtonText: 'Aceptar', onConfirm, ...options });\n\nexport const AlertaError = (title: string, text: string, onConfirm?: () => void, options?: { allowOutsideClick?: boolean; allowEscapeKey?: boolean }) =>\n Alerta({ title, text, icon: 'error', confirmButtonText: 'Aceptar', onConfirm, ...options });\n\nexport const AlertaAdvertencia = (title: string, text: string, onConfirm?: () => void, onCancel?: () => void, options?: { allowOutsideClick?: boolean; allowEscapeKey?: boolean }) =>\n Alerta({ title, text, icon: 'warning', confirmButtonText: 'Sí, continuar', cancelButtonText: 'Cancelar', showCancelButton: true, onConfirm, onCancel, ...options });\n\nexport const AlertaConfirmacion = (title: string, text: string, onConfirm?: () => void, onCancel?: () => void, options?: { allowOutsideClick?: boolean; allowEscapeKey?: boolean }) =>\n Alerta({ title, text, icon: 'question', confirmButtonText: 'Sí', cancelButtonText: 'No', showCancelButton: true, onConfirm, onCancel, ...options });\n\nexport const AlertaToast = (title: string, text: string, icon: 'success' | 'error' | 'warning' | 'info' = 'info', timer: number = 3000, position: 'top' | 'top-start' | 'top-end' | 'center' | 'center-start' | 'center-end' | 'bottom' | 'bottom-start' | 'bottom-end' = 'top-end') =>\n Alerta({ title, text, icon, toast: true, timer, position });"]}
@@ -0,0 +1,58 @@
1
+ import Swal from 'sweetalert2';
2
+
3
+ // src/components/alerts/alerta.ts
4
+ async function Alerta(options) {
5
+ const theme = localStorage.getItem("theme");
6
+ const isDark = theme === "dark";
7
+ const result = await Swal.fire({
8
+ title: options.title,
9
+ text: options.text,
10
+ icon: options.icon,
11
+ confirmButtonText: options.confirmButtonText || "Aceptar",
12
+ showCancelButton: options.showCancelButton || false,
13
+ cancelButtonText: options.cancelButtonText || "Cancelar",
14
+ showDenyButton: options.showDenyButton || false,
15
+ denyButtonText: options.denyButtonText || "No",
16
+ background: isDark ? "#1f2937" : "#f9fafb",
17
+ color: isDark ? "#f9fafb" : "#1f2937",
18
+ customClass: {
19
+ popup: isDark ? "swal-dark-popup" : "swal-light-popup",
20
+ title: isDark ? "swal-dark-title" : "swal-light-title",
21
+ confirmButton: isDark ? "swal-dark-confirm" : "swal-light-confirm",
22
+ cancelButton: isDark ? "swal-dark-cancel" : "swal-light-cancel",
23
+ denyButton: isDark ? "swal-dark-deny" : "swal-light-deny"
24
+ },
25
+ toast: options.toast || false,
26
+ timer: options.timer,
27
+ position: options.position || "center",
28
+ showConfirmButton: !options.toast && !options.timer,
29
+ timerProgressBar: options.toast || !!options.timer,
30
+ allowOutsideClick: options.allowOutsideClick !== false,
31
+ // Por defecto true
32
+ allowEscapeKey: options.allowEscapeKey !== false,
33
+ // Por defecto true
34
+ input: options.input,
35
+ inputLabel: options.inputLabel,
36
+ inputPlaceholder: options.inputPlaceholder,
37
+ inputValue: options.inputValue,
38
+ inputValidator: options.inputValidator,
39
+ inputAttributes: options.inputAttributes
40
+ });
41
+ if (result.isConfirmed && options.onConfirm) {
42
+ options.onConfirm();
43
+ } else if (result.isDenied && options.onDeny) {
44
+ options.onDeny();
45
+ } else if (result.isDismissed && options.onCancel) {
46
+ options.onCancel();
47
+ }
48
+ return result;
49
+ }
50
+ var AlertaExito = (title, text, onConfirm, options) => Alerta({ title, text, icon: "success", confirmButtonText: "Aceptar", onConfirm, ...options });
51
+ var AlertaError = (title, text, onConfirm, options) => Alerta({ title, text, icon: "error", confirmButtonText: "Aceptar", onConfirm, ...options });
52
+ var AlertaAdvertencia = (title, text, onConfirm, onCancel, options) => Alerta({ title, text, icon: "warning", confirmButtonText: "S\xED, continuar", cancelButtonText: "Cancelar", showCancelButton: true, onConfirm, onCancel, ...options });
53
+ var AlertaConfirmacion = (title, text, onConfirm, onCancel, options) => Alerta({ title, text, icon: "question", confirmButtonText: "S\xED", cancelButtonText: "No", showCancelButton: true, onConfirm, onCancel, ...options });
54
+ var AlertaToast = (title, text, icon = "info", timer = 3e3, position = "top-end") => Alerta({ title, text, icon, toast: true, timer, position });
55
+
56
+ export { Alerta, AlertaAdvertencia, AlertaConfirmacion, AlertaError, AlertaExito, AlertaToast };
57
+ //# sourceMappingURL=index.mjs.map
58
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/alerts/alerta.ts"],"names":[],"mappings":";;;AA2BA,eAAsB,OAAO,OAAA,EAAwB;AACjD,EAAA,MAAM,KAAA,GAAQ,YAAA,CAAa,OAAA,CAAQ,OAAO,CAAA;AAE1C,EAAA,MAAM,SAAS,KAAA,KAAU,MAAA;AAEzB,EAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,IAAA,CAAK;AAAA,IAC3B,OAAO,OAAA,CAAQ,KAAA;AAAA,IACf,MAAM,OAAA,CAAQ,IAAA;AAAA,IACd,MAAM,OAAA,CAAQ,IAAA;AAAA,IACd,iBAAA,EAAmB,QAAQ,iBAAA,IAAqB,SAAA;AAAA,IAChD,gBAAA,EAAkB,QAAQ,gBAAA,IAAoB,KAAA;AAAA,IAC9C,gBAAA,EAAkB,QAAQ,gBAAA,IAAoB,UAAA;AAAA,IAC9C,cAAA,EAAgB,QAAQ,cAAA,IAAkB,KAAA;AAAA,IAC1C,cAAA,EAAgB,QAAQ,cAAA,IAAkB,IAAA;AAAA,IAC1C,UAAA,EAAY,SAAS,SAAA,GAAY,SAAA;AAAA,IACjC,KAAA,EAAO,SAAS,SAAA,GAAY,SAAA;AAAA,IAC5B,WAAA,EAAa;AAAA,MACT,KAAA,EAAO,SAAS,iBAAA,GAAoB,kBAAA;AAAA,MACpC,KAAA,EAAO,SAAS,iBAAA,GAAoB,kBAAA;AAAA,MACpC,a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Ae,IAAA,EAAc,SAAA,EAAwB,YAC7E,MAAA,CAAO,EAAE,KAAA,EAAO,IAAA,EAAM,MAAM,SAAA,EAAW,iBAAA,EAAmB,WAAW,SAAA,EAAW,GAAG,SAAS;AAEzF,IAAM,cAAc,CAAC,KAAA,EAAe,IAAA,EAAc,SAAA,EAAwB,YAC7E,MAAA,CAAO,EAAE,KAAA,EAAO,IAAA,EAAM,MAAM,OAAA,EAAS,iBAAA,EAAmB,WAAW,SAAA,EAAW,GAAG,SAAS;AAEvF,IAAM,iBAAA,GAAoB,CAAC,KAAA,EAAe,IAAA,EAAc,WAAwB,QAAA,EAAuB,OAAA,KAC1G,MAAA,CAAO,EAAE,KAAA,EAAO,IAAA,EAAM,MAAM,SAAA,EAAW,iBAAA,EAAmB,kBAAA,EAAiB,gBAAA,EAAkB,UAAA,EAAY,gBAAA,EAAkB,MAAM,SAAA,EAAW,QAAA,EAAU,GAAG,OAAA,EAAS;AAE/J,IAAM,kBAAA,GAAqB,CAAC,KAAA,EAAe,IAAA,EAAc,WAAwB,QAAA,EAAuB,OAAA,KAC3G,MAAA,CAAO,EAAE,KAAA,EAAO,IAAA,EAAM,MAAM,UAAA,EAAY,iBAAA,EAAmB,OAAA,EAAM,gBAAA,EAAkB,IAAA,EAAM,gBAAA,EAAkB,MAAM,SAAA,EAAW,QAAA,EAAU,GAAG,OAAA,EAAS;AAE/I,IAAM,cAAc,CAAC,KAAA,EAAe,MAAc,IAAA,GAAiD,MAAA,EAAQ,QAAgB,GAAA,EAAM,QAAA,GAAkI,cACtQ,MAAA,CAAO,EAAE,OAAO,IAAA,EAAM,IAAA,EAAM,OAAO,IAAA,EAAM,KAAA,EAAO,UAAU","file":"index.mjs","sourcesContent":["import Swal from \"sweetalert2\";\n\ninterface AlertaOptions {\n title: string;\n text: string;\n icon: 'success' | 'error' | 'warning' | 'info' | 'question';\n confirmButtonText?: string;\n showCancelButton?: boolean;\n cancelButtonText?: string;\n showDenyButton?: boolean;\n denyButtonText?: string;\n onConfirm?: () => void;\n onCancel?: () => void;\n onDeny?: () => void;\n toast?: boolean;\n timer?: number;\n position?: 'top' | 'top-start' | 'top-end' | 'center' | 'center-start' | 'center-end' | 'bottom' | 'bottom-start' | 'bottom-end';\n allowOutsideClick?: boolean;\n allowEscapeKey?: boolean;\n input?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'range' | 'textarea' | 'select' | 'radio' | 'checkbox' | 'file' | 'url';\n inputLabel?: string;\n inputPlaceholder?: string;\n inputValue?: string;\n inputValidator?: (value: unknown) => string | null | Promise<string | null>;\n inputAttributes?: Record<string, string>;\n}\n\nexport async function Alerta(options: AlertaOptions) {\n const theme = localStorage.getItem('theme');\n\n const isDark = theme === 'dark';\n\n const result = await Swal.fire({\n title: options.title,\n text: options.text,\n icon: options.icon,\n confirmButtonText: options.confirmButtonText || 'Aceptar',\n showCancelButton: options.showCancelButton || false,\n cancelButtonText: options.cancelButtonText || 'Cancelar',\n showDenyButton: options.showDenyButton || false,\n denyButtonText: options.denyButtonText || 'No',\n background: isDark ? '#1f2937' : '#f9fafb',\n color: isDark ? '#f9fafb' : '#1f2937',\n customClass: {\n popup: isDark ? 'swal-dark-popup' : 'swal-light-popup',\n title: isDark ? 'swal-dark-title' : 'swal-light-title',\n confirmButton: isDark ? 'swal-dark-confirm' : 'swal-light-confirm',\n cancelButton: isDark ? 'swal-dark-cancel' : 'swal-light-cancel',\n denyButton: isDark ? 'swal-dark-deny' : 'swal-light-deny'\n },\n toast: options.toast || false,\n timer: options.timer,\n position: options.position || 'center',\n showConfirmButton: !options.toast && !options.timer,\n timerProgressBar: options.toast || !!options.timer,\n allowOutsideClick: options.allowOutsideClick !== false, // Por defecto true\n allowEscapeKey: options.allowEscapeKey !== false, // Por defecto true\n input: options.input,\n inputLabel: options.inputLabel,\n inputPlaceholder: options.inputPlaceholder,\n inputValue: options.inputValue,\n inputValidator: options.inputValidator,\n inputAttributes: options.inputAttributes\n });\n\n if (result.isConfirmed && options.onConfirm) {\n options.onConfirm();\n } else if (result.isDenied && options.onDeny) {\n options.onDeny();\n } else if (result.isDismissed && options.onCancel) {\n options.onCancel();\n }\n\n return result;\n}\n\n// Funciones de conveniencia para casos comunes\nexport const AlertaExito = (title: string, text: string, onConfirm?: () => void, options?: { allowOutsideClick?: boolean; allowEscapeKey?: boolean }) =>\n Alerta({ title, text, icon: 'success', confirmButtonText: 'Aceptar', onConfirm, ...options });\n\nexport const AlertaError = (title: string, text: string, onConfirm?: () => void, options?: { allowOutsideClick?: boolean; allowEscapeKey?: boolean }) =>\n Alerta({ title, text, icon: 'error', confirmButtonText: 'Aceptar', onConfirm, ...options });\n\nexport const AlertaAdvertencia = (title: string, text: string, onConfirm?: () => void, onCancel?: () => void, options?: { allowOutsideClick?: boolean; allowEscapeKey?: boolean }) =>\n Alerta({ title, text, icon: 'warning', confirmButtonText: 'Sí, continuar', cancelButtonText: 'Cancelar', showCancelButton: true, onConfirm, onCancel, ...options });\n\nexport const AlertaConfirmacion = (title: string, text: string, onConfirm?: () => void, onCancel?: () => void, options?: { allowOutsideClick?: boolean; allowEscapeKey?: boolean }) =>\n Alerta({ title, text, icon: 'question', confirmButtonText: 'Sí', cancelButtonText: 'No', showCancelButton: true, onConfirm, onCancel, ...options });\n\nexport const AlertaToast = (title: string, text: string, icon: 'success' | 'error' | 'warning' | 'info' = 'info', timer: number = 3000, position: 'top' | 'top-start' | 'top-end' | 'center' | 'center-start' | 'center-end' | 'bottom' | 'bottom-start' | 'bottom-end' = 'top-end') =>\n Alerta({ title, text, icon, toast: true, timer, position });"]}
@@ -0,0 +1,67 @@
1
+ import React, { FC, ButtonHTMLAttributes, ReactNode, InputHTMLAttributes, FormHTMLAttributes, FormEvent, SelectHTMLAttributes } from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+
4
+ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
5
+ variant?: 'primary' | 'secondary' | 'icon' | 'danger' | 'success' | 'outline' | 'nav' | 'custom' | 'link' | 'warning' | 'toggle';
6
+ children: ReactNode;
7
+ isLoading?: boolean;
8
+ loadingText?: string;
9
+ isActive?: boolean;
10
+ }
11
+ declare const Button: FC<ButtonProps>;
12
+
13
+ interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
14
+ label?: string | ReactNode;
15
+ error?: string;
16
+ helperText?: string;
17
+ }
18
+ declare const Input: FC<InputProps>;
19
+
20
+ interface FormProps extends FormHTMLAttributes<HTMLFormElement> {
21
+ children: ReactNode;
22
+ onSubmit?: (e: FormEvent<HTMLFormElement>) => void;
23
+ variant?: 'default' | 'modal' | 'card' | 'inline' | 'compact';
24
+ }
25
+ declare const Form: FC<FormProps>;
26
+
27
+ interface Option {
28
+ value: string | number;
29
+ label: string;
30
+ disabled?: boolean;
31
+ selected?: boolean;
32
+ }
33
+ interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, 'size'> {
34
+ options: Option[];
35
+ placeholder?: string;
36
+ variant?: 'default' | 'small';
37
+ error?: boolean;
38
+ helperText?: string;
39
+ label?: string | ReactNode;
40
+ }
41
+ declare const Select: FC<SelectProps>;
42
+
43
+ interface TableProps {
44
+ headers: ReactNode[];
45
+ rows: ReactNode[][];
46
+ variant?: 'default' | 'custom';
47
+ className?: string;
48
+ thClassName?: string;
49
+ tdClassName?: string;
50
+ }
51
+ declare function Table({ headers, rows, variant, className, thClassName, tdClassName }: TableProps): react_jsx_runtime.JSX.Element;
52
+
53
+ interface ModalProps {
54
+ onClose: () => void;
55
+ title: string;
56
+ children: React.ReactNode;
57
+ footer?: React.ReactNode;
58
+ maxWidth?: string;
59
+ showCloseButton?: boolean;
60
+ zIndex?: number;
61
+ }
62
+ interface ModalRef {
63
+ handleClose: () => void;
64
+ }
65
+ declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<ModalRef>>;
66
+
67
+ export { Button, Form, Input, Modal, type ModalRef, Select, Table };