fernotify 1.2.1 → 1.2.5

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.
@@ -146,7 +146,7 @@ async function loadData() {
146
146
  }
147
147
  ```
148
148
 
149
- ### Confirmación de Eliminación
149
+ ### Confirmación de Eliminación (dos botones)
150
150
 
151
151
  ```javascript
152
152
  function deleteItem(id) {
@@ -154,12 +154,52 @@ function deleteItem(id) {
154
154
  type: 'warning',
155
155
  title: '¿Estás seguro?',
156
156
  message: 'Esta acción no se puede deshacer. El registro será eliminado permanentemente.',
157
- buttonText: 'Sí, eliminar',
158
- onClose: async () => {
159
- // Usuario confirmó, proceder con eliminación
157
+ buttons: [
158
+ {
159
+ text: 'Cancelar',
160
+ color: 'linear-gradient(135deg, #9ca3af 0%, #6b7280 100%)',
161
+ onClick: () => {
162
+ // El usuario decidió no continuar; simplemente cerramos
163
+ console.log('Eliminación cancelada');
164
+ }
165
+ },
166
+ {
167
+ text: 'Sí, eliminar',
168
+ color: 'linear-gradient(135deg, #ef4444 0%, #dc2626 100%)',
169
+ onClick: async () => {
170
+ await performDelete(id);
171
+ notify.success('Registro eliminado correctamente');
172
+ }
173
+ }
174
+ ],
175
+ allowOutsideClick: false,
176
+ allowEscapeKey: false
177
+ });
178
+ }
179
+ ```
180
+
181
+ ### Confirmación simplificada con `onConfirm` / `onCancel`
182
+
183
+ Si prefieres no definir un array de botones, puedes usar los atajos `onConfirm` y `onCancel`.
184
+ `onConfirm` puede devolver una promesa (se espera antes de cerrar la notificación).
185
+
186
+ ```javascript
187
+ function deleteItem(id) {
188
+ notify.show({
189
+ type: 'warning',
190
+ title: '¿Eliminar registro?',
191
+ message: 'Esta acción no se puede deshacer.',
192
+ confirmText: 'Sí, eliminar',
193
+ cancelText: 'Cancelar',
194
+ onConfirm: async () => {
160
195
  await performDelete(id);
161
196
  notify.success('Registro eliminado correctamente');
162
- }
197
+ },
198
+ onCancel: () => {
199
+ console.log('Eliminación cancelada por el usuario');
200
+ },
201
+ allowOutsideClick: false,
202
+ allowEscapeKey: false
163
203
  });
164
204
  }
165
205
  ```
@@ -653,8 +693,17 @@ Cada tipo tiene su propio estilo:
653
693
  type: 'success' | 'error' | 'warning' | 'info', // Requerido
654
694
  title: 'Título', // Opcional
655
695
  message: 'Mensaje detallado', // Requerido
656
- buttonText: 'OK', // Opcional (default: 'OK')
657
- timer: 5000, // Opcional (ms, null = sin timer)
696
+ buttonText: 'OK', // Opcional (default: 'OK') // Array de botones. Cada elemento puede contener:
697
+ // { text, color?, shadowColor?, onClick? }
698
+ // Si se proporciona, `buttonText` se ignora y se renderiza
699
+ // una botonera con el contenido del array.
700
+ buttons: [], timer: 5000, // Opcional (ms, null = sin timer)
701
+ // Atajos para confirmaciones: si prefieres no definir un array de botones,
702
+ // puedes usar `onConfirm` y `onCancel` junto con `confirmText` / `cancelText`:
703
+ // onConfirm: () => { /* acción confirmada */ },
704
+ // onCancel: () => { /* acción cancelada */ },
705
+ // confirmText: 'Sí, eliminar',
706
+ // cancelText: 'Cancelar',
658
707
  onClose: () => { } // Opcional (callback)
659
708
  }
660
709
  ```
package/README.md CHANGED
@@ -74,11 +74,11 @@ window.notify = new NotificationSystem();
74
74
 
75
75
  ```html
76
76
  <!-- UMD -->
77
- <script src="https://cdn.jsdelivr.net/gh/Fernandocabal/fernotify@1.0.0/dist/notification-system.js"></script>
77
+ <script src="https://cdn.jsdelivr.net/gh/Fernandocabal/fernotify@1.2.1/dist/notification-system.js"></script>
78
78
 
79
79
  <!-- ES Module -->
80
80
  <script type="module">
81
- import NotificationSystem from 'https://cdn.jsdelivr.net/gh/Fernandocabal/fernotify@1.0.0/dist/notification-system.esm.js';
81
+ import NotificationSystem from 'https://cdn.jsdelivr.net/gh/Fernandocabal/fernotify@1.2.1/dist/notification-system.esm.js';
82
82
  </script>
83
83
  ```
84
84
 
@@ -167,6 +167,11 @@ notify.show({
167
167
  title: 'Título', // Opcional
168
168
  message: 'Mensaje', // Requerido
169
169
  buttonText: 'OK', // Opcional (default: 'OK')
170
+ // Para confirmaciones rápidas hay atajos:
171
+ // `onConfirm` (función) se ejecuta al pulsar el botón de confirmar.
172
+ // `onCancel` (función) se ejecuta al pulsar el botón de cancelar.
173
+ // Puedes personalizar textos con `confirmText` / `cancelText` y colores con
174
+ // `confirmColor` / `cancelColor`.
170
175
  timer: 3000, // Opcional (ms, null = sin timer)
171
176
  allowOutsideClick: true, // Opcional (default: true)
172
177
  allowEscapeKey: true, // Opcional (default: true)
@@ -269,25 +274,76 @@ async function fetchData() {
269
274
  fetchData();
270
275
  ```
271
276
 
272
- ### Confirmación de Operación
277
+ ### Confirmación de Operación (dos botones)
273
278
 
274
279
  ```javascript
275
280
  notify.show({
276
281
  type: 'warning',
277
282
  title: '¿Estás seguro?',
278
283
  message: 'Esta acción no se puede deshacer',
279
- buttonText: 'Sí, continuar',
284
+ buttons: [
285
+ {
286
+ text: 'Cancelar',
287
+ color: 'linear-gradient(135deg, #9ca3af 0%, #6b7280 100%)',
288
+ onClick: () => {
289
+ console.log('Operación cancelada');
290
+ }
291
+ },
292
+ {
293
+ text: 'Sí, continuar',
294
+ color: 'linear-gradient(135deg, #f59e0b 0%, #d97706 100%)',
295
+ onClick: () => {
296
+ deleteUser();
297
+ }
298
+ }
299
+ ],
280
300
  allowOutsideClick: false,
281
- allowEscapeKey: false,
282
- onClose: () => {
283
- // Ejecutar acción después de confirmar
284
- deleteUser();
285
- }
301
+ allowEscapeKey: false
286
302
  });
287
303
  ```
288
304
 
289
305
  ### Notificación con Contenido HTML
290
306
 
307
+ ### Confirmación (atajo `onConfirm` / `onCancel`)
308
+
309
+ ```javascript
310
+ notify.show({
311
+ type: 'warning',
312
+ title: '¿Eliminar registro?',
313
+ message: 'Esta acción no se puede deshacer.',
314
+ confirmText: 'Sí, eliminar',
315
+ cancelText: 'Cancelar',
316
+ onConfirm: async () => {
317
+ await performDelete(id);
318
+ notify.success('Registro eliminado correctamente');
319
+ },
320
+ onCancel: () => {
321
+ console.log('El usuario canceló la operación');
322
+ },
323
+ allowOutsideClick: false,
324
+ allowEscapeKey: false
325
+ });
326
+ ```
327
+
328
+ ### Personalizar colores y sombras (ejemplo)
329
+
330
+ ```javascript
331
+ notify.show({
332
+ type: 'warning',
333
+ title: 'Eliminar elemento',
334
+ message: '¿Estás seguro?',
335
+ confirmText: 'Sí, borrar',
336
+ cancelText: 'No, cancelar',
337
+ onConfirm: () => fetch('/api/delete', { method: 'POST' }),
338
+ onCancel: () => console.log('Cancelado'),
339
+ // Colores y sombras pueden ser cualquier string CSS (gradiente o color simple)
340
+ confirmColor: 'linear-gradient(135deg, #10b981 0%, #059669 100%)',
341
+ confirmShadow: 'rgba(5,150,105,0.22)',
342
+ cancelColor: 'linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%)',
343
+ cancelShadow: 'rgba(0,0,0,0.08)'
344
+ });
345
+ ```
346
+
291
347
  ```javascript
292
348
  const form = document.createElement('form');
293
349
  form.innerHTML = `
@@ -347,10 +403,10 @@ Para usar una versión específica, usa tags en la URL del CDN:
347
403
 
348
404
  ```html
349
405
  <!-- Última versión (auto-actualiza) -->
350
- <script src="https://cdn.jsdelivr.net/gh/Fernandocabal/notification-system@latest/dist/notification-system.js"></script>
406
+ <script src="https://cdn.jsdelivr.net/gh/Fernandocabal/fernotify@latest/dist/notification-system.js"></script>
351
407
 
352
408
  <!-- Versión fija (recomendado en producción) -->
353
- <script src="https://cdn.jsdelivr.net/gh/Fernandocabal/notification-system@1.0.0/dist/notification-system.js"></script>
409
+ <script src="https://cdn.jsdelivr.net/gh/Fernandocabal/fernotify@1.2.1/dist/notification-system.js"></script>
354
410
  ```
355
411
 
356
412
  ### Crear una nueva versión