@rubenpazch/confirmation-dialog 3.1.6 → 3.2.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 +13 -12
- package/dist/ConfirmationDialog.d.ts +7 -1
- package/dist/ConfirmationDialog.d.ts.map +1 -1
- package/dist/index.cjs.js +7 -2
- package/dist/index.d.ts +7 -1
- package/dist/index.esm.js +7 -2
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -20,18 +20,19 @@ npm install @rubenpazch/confirmation-dialog
|
|
|
20
20
|
Diálogo de confirmación (alertdialog) sobre Modal: foco retenido, Escape para cancelar y
|
|
21
21
|
el foco inicial en "Cancelar", la opción segura.
|
|
22
22
|
|
|
23
|
-
| Prop | Tipo
|
|
24
|
-
| ------------- |
|
|
25
|
-
| `isOpen` | `boolean`
|
|
26
|
-
| `message` | `ReactNode`
|
|
27
|
-
| `onCancel` | `() => void`
|
|
28
|
-
| `onConfirm` | `() => void`
|
|
29
|
-
| `title` | `string`
|
|
30
|
-
| `cancelText` | `string`
|
|
31
|
-
| `children` | `ReactNode`
|
|
32
|
-
| `confirmText` | `string`
|
|
33
|
-
| `isDangerous` | `boolean`
|
|
34
|
-
| `isLoading` | `boolean`
|
|
23
|
+
| Prop | Tipo | Req. | Por defecto | Descripción |
|
|
24
|
+
| ------------- | ----------------------------------------------- | ---- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
25
|
+
| `isOpen` | `boolean` | sí | | Si el diálogo está abierto. |
|
|
26
|
+
| `message` | `ReactNode` | sí | | Explicación de la consecuencia. |
|
|
27
|
+
| `onCancel` | `() => void` | sí | | Al cancelar, pulsar Escape o hacer clic fuera (si no está cargando). |
|
|
28
|
+
| `onConfirm` | `() => void` | sí | | Al confirmar. |
|
|
29
|
+
| `title` | `string` | sí | | Pregunta o título: "¿Eliminar la convocatoria?". |
|
|
30
|
+
| `cancelText` | `string` | | | Texto del botón de cancelar (por defecto "Cancelar"). |
|
|
31
|
+
| `children` | `ReactNode` | | | Contenido extra bajo el mensaje (p. ej. un campo "motivo"). |
|
|
32
|
+
| `confirmText` | `string` | | | Texto del botón de confirmar (por defecto "Confirmar"). |
|
|
33
|
+
| `isDangerous` | `boolean` | | `false` | Acción destructiva: botón rojo. |
|
|
34
|
+
| `isLoading` | `boolean` | | `false` | Muestra el botón de confirmar cargando y bloquea los botones. |
|
|
35
|
+
| `labels` | `Partial<{ confirm: string; cancel: string; }>` | | | Textos de la interfaz. Por defecto, los del idioma activo (`UiLocaleProvider`); también se cambian para toda la app con su prop `messages`. |
|
|
35
36
|
|
|
36
37
|
Tipos: `ConfirmationDialogProps`.
|
|
37
38
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { type UiMessages } from "@rubenpazch/shared";
|
|
2
3
|
export interface ConfirmationDialogProps {
|
|
3
4
|
/** Si el diálogo está abierto. */
|
|
4
5
|
isOpen: boolean;
|
|
@@ -20,10 +21,15 @@ export interface ConfirmationDialogProps {
|
|
|
20
21
|
onCancel: () => void;
|
|
21
22
|
/** Contenido extra bajo el mensaje (p. ej. un campo "motivo"). */
|
|
22
23
|
children?: React.ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Textos de la interfaz. Por defecto, los del idioma activo (`UiLocaleProvider`);
|
|
26
|
+
* también se cambian para toda la app con su prop `messages`.
|
|
27
|
+
*/
|
|
28
|
+
labels?: Partial<UiMessages["confirmationDialog"]>;
|
|
23
29
|
}
|
|
24
30
|
/**
|
|
25
31
|
* Diálogo de confirmación (alertdialog) sobre Modal: foco retenido, Escape para cancelar y
|
|
26
32
|
* el foco inicial en "Cancelar", la opción segura.
|
|
27
33
|
*/
|
|
28
|
-
export default function ConfirmationDialog({ isOpen, title, message, confirmText, cancelText, isDangerous, isLoading, onConfirm, onCancel, children, }: ConfirmationDialogProps): React.JSX.Element;
|
|
34
|
+
export default function ConfirmationDialog({ isOpen, title, message, confirmText, cancelText, isDangerous, isLoading, onConfirm, onCancel, children, labels, }: ConfirmationDialogProps): React.JSX.Element;
|
|
29
35
|
//# sourceMappingURL=ConfirmationDialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmationDialog.d.ts","sourceRoot":"","sources":["../src/ConfirmationDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfirmationDialog.d.ts","sourceRoot":"","sources":["../src/ConfirmationDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIpE,MAAM,WAAW,uBAAuB;IACtC,kCAAkC;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oEAAoE;IACpE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oBAAoB;IACpB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC;CACpD;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,MAAM,EACN,KAAK,EACL,OAAO,EACP,WAAW,EACX,UAAU,EACV,WAAmB,EACnB,SAAiB,EACjB,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,MAAM,GACP,EAAE,uBAAuB,qBA2CzB"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var shared = require('@rubenpazch/shared');
|
|
4
5
|
var Button = require('@rubenpazch/button');
|
|
5
6
|
var Modal = require('@rubenpazch/modal');
|
|
6
7
|
|
|
@@ -8,12 +9,16 @@ var Modal = require('@rubenpazch/modal');
|
|
|
8
9
|
* Diálogo de confirmación (alertdialog) sobre Modal: foco retenido, Escape para cancelar y
|
|
9
10
|
* el foco inicial en "Cancelar", la opción segura.
|
|
10
11
|
*/
|
|
11
|
-
function ConfirmationDialog({ isOpen, title, message, confirmText
|
|
12
|
+
function ConfirmationDialog({ isOpen, title, message, confirmText, cancelText, isDangerous = false, isLoading = false, onConfirm, onCancel, children, labels, }) {
|
|
13
|
+
const t = shared.useUiMessages("confirmationDialog", labels, {
|
|
14
|
+
confirm: confirmText,
|
|
15
|
+
cancel: cancelText,
|
|
16
|
+
});
|
|
12
17
|
const cancel = () => {
|
|
13
18
|
if (!isLoading)
|
|
14
19
|
onCancel();
|
|
15
20
|
};
|
|
16
|
-
return (jsxRuntime.jsx(Modal, { open: isOpen, onClose: cancel, role: "alertdialog", size: "sm", title: title, description: message, showCloseButton: false, closeOnOverlayClick: !isLoading, closeOnEscape: !isLoading, footer: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Button, { onClick: cancel, disabled: isLoading, variant: "outlined", color: "secondary", children:
|
|
21
|
+
return (jsxRuntime.jsx(Modal, { open: isOpen, onClose: cancel, role: "alertdialog", size: "sm", title: title, description: message, showCloseButton: false, closeOnOverlayClick: !isLoading, closeOnEscape: !isLoading, footer: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Button, { onClick: cancel, disabled: isLoading, variant: "outlined", color: "secondary", children: t.cancel }), jsxRuntime.jsx(Button, { onClick: onConfirm, loading: isLoading, variant: "contained", color: isDangerous ? "error" : "primary", children: t.confirm })] }), children: children }));
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
module.exports = ConfirmationDialog;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { UiMessages } from '@rubenpazch/shared';
|
|
2
3
|
|
|
3
4
|
interface ConfirmationDialogProps {
|
|
4
5
|
/** Si el diálogo está abierto. */
|
|
@@ -21,12 +22,17 @@ interface ConfirmationDialogProps {
|
|
|
21
22
|
onCancel: () => void;
|
|
22
23
|
/** Contenido extra bajo el mensaje (p. ej. un campo "motivo"). */
|
|
23
24
|
children?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Textos de la interfaz. Por defecto, los del idioma activo (`UiLocaleProvider`);
|
|
27
|
+
* también se cambian para toda la app con su prop `messages`.
|
|
28
|
+
*/
|
|
29
|
+
labels?: Partial<UiMessages["confirmationDialog"]>;
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
26
32
|
* Diálogo de confirmación (alertdialog) sobre Modal: foco retenido, Escape para cancelar y
|
|
27
33
|
* el foco inicial en "Cancelar", la opción segura.
|
|
28
34
|
*/
|
|
29
|
-
declare function ConfirmationDialog({ isOpen, title, message, confirmText, cancelText, isDangerous, isLoading, onConfirm, onCancel, children, }: ConfirmationDialogProps): React.JSX.Element;
|
|
35
|
+
declare function ConfirmationDialog({ isOpen, title, message, confirmText, cancelText, isDangerous, isLoading, onConfirm, onCancel, children, labels, }: ConfirmationDialogProps): React.JSX.Element;
|
|
30
36
|
|
|
31
37
|
export { ConfirmationDialog as default };
|
|
32
38
|
export type { ConfirmationDialogProps };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useUiMessages } from '@rubenpazch/shared';
|
|
2
3
|
import Button from '@rubenpazch/button';
|
|
3
4
|
import Modal from '@rubenpazch/modal';
|
|
4
5
|
|
|
@@ -6,12 +7,16 @@ import Modal from '@rubenpazch/modal';
|
|
|
6
7
|
* Diálogo de confirmación (alertdialog) sobre Modal: foco retenido, Escape para cancelar y
|
|
7
8
|
* el foco inicial en "Cancelar", la opción segura.
|
|
8
9
|
*/
|
|
9
|
-
function ConfirmationDialog({ isOpen, title, message, confirmText
|
|
10
|
+
function ConfirmationDialog({ isOpen, title, message, confirmText, cancelText, isDangerous = false, isLoading = false, onConfirm, onCancel, children, labels, }) {
|
|
11
|
+
const t = useUiMessages("confirmationDialog", labels, {
|
|
12
|
+
confirm: confirmText,
|
|
13
|
+
cancel: cancelText,
|
|
14
|
+
});
|
|
10
15
|
const cancel = () => {
|
|
11
16
|
if (!isLoading)
|
|
12
17
|
onCancel();
|
|
13
18
|
};
|
|
14
|
-
return (jsx(Modal, { open: isOpen, onClose: cancel, role: "alertdialog", size: "sm", title: title, description: message, showCloseButton: false, closeOnOverlayClick: !isLoading, closeOnEscape: !isLoading, footer: jsxs(Fragment, { children: [jsx(Button, { onClick: cancel, disabled: isLoading, variant: "outlined", color: "secondary", children:
|
|
19
|
+
return (jsx(Modal, { open: isOpen, onClose: cancel, role: "alertdialog", size: "sm", title: title, description: message, showCloseButton: false, closeOnOverlayClick: !isLoading, closeOnEscape: !isLoading, footer: jsxs(Fragment, { children: [jsx(Button, { onClick: cancel, disabled: isLoading, variant: "outlined", color: "secondary", children: t.cancel }), jsx(Button, { onClick: onConfirm, loading: isLoading, variant: "contained", color: isDangerous ? "error" : "primary", children: t.confirm })] }), children: children }));
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
export { ConfirmationDialog as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rubenpazch/confirmation-dialog",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "ConfirmationDialog component",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -32,8 +32,9 @@
|
|
|
32
32
|
"@rubenpazch/tokens": "0.5.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@rubenpazch/button": "6.2.
|
|
36
|
-
"@rubenpazch/modal": "0.
|
|
35
|
+
"@rubenpazch/button": "6.2.6",
|
|
36
|
+
"@rubenpazch/modal": "0.2.0",
|
|
37
|
+
"@rubenpazch/shared": "5.4.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@rubenpazch/typescript-config": "3.0.0"
|