bmi-next-brokers 1.1.4 → 1.1.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.
@@ -1 +1 @@
1
- ._modalOverlay_dvid0_1{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#0009;display:flex;justify-content:center;align-items:center;animation:_overlayFadeIn_dvid0_1 .25s ease-in-out forwards;overflow:hidden;-webkit-backdrop-filter:blur(0px);backdrop-filter:blur(0px)}._modalOverlay_dvid0_1._closing_dvid0_16{animation:_overlayFadeOut_dvid0_1 .25s ease-in-out forwards}@keyframes _overlayFadeIn_dvid0_1{0%{opacity:0;-webkit-backdrop-filter:blur(0px);backdrop-filter:blur(0px)}to{opacity:1;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}}@keyframes _overlayFadeOut_dvid0_1{0%{opacity:1;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}to{opacity:0;-webkit-backdrop-filter:blur(0px);backdrop-filter:blur(0px)}}._modal_dvid0_1{display:flex;flex-direction:column;border-radius:24px;background-color:#fff;box-shadow:0 4px 6px #0000001a;max-height:calc(100dvh - 15px)}._modalHeader_dvid0_52{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;gap:8px}._modalTitle_dvid0_60{color:var(--Blacks-Black, #000);font-size:20px;font-style:normal;font-weight:600;line-height:24px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}._closeIcon_dvid0_71{display:flex;flex-direction:column;border-radius:50%;background-color:#d9d9d9;align-items:center;justify-content:center;aspect-ratio:1/1;padding:6.2px;cursor:pointer}._modalBody_dvid0_83{flex:1;overflow-y:auto;padding:0 16px 16px}._modalBody_dvid0_83::-webkit-scrollbar{display:none}._modalFooter_dvid0_93{display:grid;grid-template-columns:1fr 1fr;margin-left:auto;width:fit-content;gap:19px;padding-inline:16px;margin-block:16px}._modalFooter_dvid0_93 :only-child{grid-column:2}
1
+ ._modalOverlay_1x735_1{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#0009;display:flex;justify-content:center;align-items:center;animation:_overlayFadeIn_1x735_1 .25s ease-in-out forwards;overflow:hidden}._modalOverlay_1x735_1._closing_1x735_15{animation:_overlayFadeOut_1x735_1 .25s ease-in-out forwards}@keyframes _overlayFadeIn_1x735_1{0%{opacity:0}to{opacity:1}}@keyframes _overlayFadeOut_1x735_1{0%{opacity:1}to{opacity:0}}._modal_1x735_1{display:flex;flex-direction:column;border-radius:24px;background-color:#fff;box-shadow:0 4px 6px #0000001a;max-height:calc(100dvh - 15px)}._modalHeader_1x735_47{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;gap:8px}._modalTitle_1x735_55{color:var(--Blacks-Black, #000);font-size:20px;font-style:normal;font-weight:600;line-height:24px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}._closeIcon_1x735_66{display:flex;flex-direction:column;border-radius:50%;background-color:#d9d9d9;align-items:center;justify-content:center;aspect-ratio:1/1;padding:6.2px;cursor:pointer;margin-left:auto}._modalBody_1x735_79{flex:1;overflow-y:auto;padding:0 16px 16px}._modalBody_1x735_79::-webkit-scrollbar{display:none}._modalFooter_1x735_89{display:grid;grid-template-columns:1fr 1fr;margin-left:auto;width:fit-content;gap:19px;padding-inline:16px;margin-block:16px}._modalFooter_1x735_89 :only-child{grid-column:2}
@@ -1,4 +1,14 @@
1
1
  import { default as React } from 'react';
2
+ import { ButtonSize, ButtonVariant } from '../Button';
3
+ type ModalButtonProps = {
4
+ show?: boolean;
5
+ text?: string;
6
+ disabled?: boolean;
7
+ action?: () => Promise<void> | void;
8
+ size?: ButtonSize;
9
+ variant?: ButtonVariant;
10
+ loading?: boolean;
11
+ };
2
12
  /**
3
13
  * Props del Modal
4
14
  */
@@ -7,10 +17,8 @@ export interface ModalProps extends React.HTMLAttributes<HTMLSpanElement> {
7
17
  title?: string;
8
18
  children?: React.ReactNode;
9
19
  width?: number;
10
- confirmButton?: string | boolean;
11
- cancelButton?: string | boolean;
12
- onConfirm?: () => Promise<void> | void;
13
- onCancel?: () => Promise<void> | void;
20
+ confirmButton: ModalButtonProps;
21
+ cancelButton: ModalButtonProps;
14
22
  zIndex?: number;
15
23
  className?: string;
16
24
  onClickOverlay?: (() => Promise<void> | void) | false;
@@ -18,32 +26,34 @@ export interface ModalProps extends React.HTMLAttributes<HTMLSpanElement> {
18
26
  closeModal: () => void;
19
27
  }
20
28
  /**
21
- * Componente Modal para mostrar un modal con overlay.
22
- * Permite pasar título, contenido personalizado, botones de confirmación y cancelación,
23
- * y manejar el cierre del modal mediante callbacks.
29
+ * Modal con overlay, header, body y footer configurable.
30
+ *
31
+ * Puedes pasar un objeto a `confirmButton` y `cancelButton` para controlar:
32
+ * - `show`: si se renderiza el botón (por defecto true)
33
+ * - `text`: texto del botón
34
+ * - `action`: función a ejecutar al hacer click
35
+ * - `variant`: variante visual del botón ("brand", "outline", etc.)
36
+ * - `size`: tamaño del botón ("small", "medium", "large")
37
+ * - `disabled`: deshabilita el botón
38
+ * - `loading`: muestra estado de carga en el botón
24
39
  *
25
40
  * @param isOpen - Controla la visibilidad del modal.
26
41
  * @param title - Título que se muestra en el header del modal.
27
42
  * @param children - Contenido del modal; puede ser cualquier componente React.
28
43
  * @param width - Ancho del modal en píxeles. Por defecto 752.
29
- * @param confirmButton - Texto del botón de confirmación. Si es `true`, muestra "Confirmar". Si es `false`, no se renderiza. Se puede pasar texto personalizado.
30
- * @param cancelButton - Texto del botón de cancelación. Si es `true`, muestra "Cancelar". Si es `false`, no se renderiza. Se puede pasar texto personalizado
31
- * @param onConfirm - Callback opcional al pulsar el botón de confirmación.
32
- * @param onCancel - Callback opcional al pulsar el botón de cancelación.
44
+ * @param confirmButton - Configuración del botón de confirmación.
45
+ * @param cancelButton - Configuración del botón de cancelación.
33
46
  * @param zIndex - Número para controlar la superposición del modal.
34
47
  * @param className - Clases CSS adicionales para el modal.
35
48
  * @param style - Estilos inline adicionales para el contenedor del modal.
36
- * @param onClickOverlay - Callback opcional al hacer click fuera del modal.
37
- * Si se pasa `false`, el overlay no cerrará el modal ni ejecutará acción alguna.
38
- * @param onClose - Callback opcional al hacer click en el icono de cierre.
39
- * Si se pasa `false`, no se renderiza el icono.
49
+ * @param onClickOverlay - Callback opcional al hacer click fuera del modal. Si se pasa `false`, el overlay no cierra el modal ni ejecuta acción.
50
+ * @param onClose - Callback opcional al pulsar el icono de cierre. Si se pasa `false`, no se renderiza el icono de cierre.
40
51
  * @param closeModal - Función obligatoria que cierra el modal desde el exterior.
41
52
  *
42
- *
43
53
  * @example
44
54
  * ```tsx
45
55
  * import { useState } from "react";
46
- * import { Modal, Button } from "tu-libreria";
56
+ * import { Modal, Button } from "bmi-next-brokers";
47
57
  *
48
58
  * export default function Example() {
49
59
  * const [isOpen, setIsOpen] = useState(false);
@@ -60,21 +70,25 @@ export interface ModalProps extends React.HTMLAttributes<HTMLSpanElement> {
60
70
  * closeModal={() => setIsOpen(false)}
61
71
  * title="Ejemplo de Modal"
62
72
  * width={500}
63
- * confirmButton={false}
64
- * cancelButton="Cancelar"
65
- * onConfirm={handleConfirm}
66
- * onCancel={handleCancel}
73
+ * confirmButton={{
74
+ * text: "Guardar",
75
+ * action: handleConfirm,
76
+ * variant: "brand",
77
+ * size: "small",
78
+ * loading: false
79
+ * }}
80
+ * cancelButton={{
81
+ * show: false, // no se renderiza
82
+ * text: "Cerrar",
83
+ * action: handleCancel,
84
+ * variant: "outline",
85
+ * size: "small",
86
+ * loading: false
87
+ * }}
67
88
  * onClose={() => console.log("Click en el botón de cierre")}
68
89
  * >
69
90
  * <div style={{ padding: "16px 0" }}>
70
- * <p>
71
- * Este es un contenido de ejemplo dentro del modal. Puedes poner
72
- * cualquier componente aquí: formularios, listas, tablas, etc.
73
- * </p>
74
- * <p>
75
- * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nisi vel
76
- * consectetur interdum, aliquet nunc vitae convallis sapien.
77
- * </p>
91
+ * <p>Contenido del modal...</p>
78
92
  * </div>
79
93
  * </Modal>
80
94
  * </>
@@ -83,3 +97,4 @@ export interface ModalProps extends React.HTMLAttributes<HTMLSpanElement> {
83
97
  * ```
84
98
  */
85
99
  export declare const Modal: React.FC<ModalProps>;
100
+ export {};
@@ -1,72 +1,68 @@
1
- import { jsx as e, jsxs as n } from "react/jsx-runtime";
2
- import { useRef as O, useState as R } from "react";
3
- import { Icon as S } from "../../icons/Icon.js";
4
- import { useScrollLock as $ } from "../../hooks/useScrollLock.js";
1
+ import { jsx as e, jsxs as r } from "react/jsx-runtime";
2
+ import { useRef as z, useState as A } from "react";
3
+ import { Icon as F } from "../../icons/Icon.js";
4
+ import { useScrollLock as H } from "../../hooks/useScrollLock.js";
5
5
  import { Button as y } from "../Button/Button.js";
6
- import { r as b } from "../../index-CGDUIzcq.js";
7
- import '../../assets/index7.css';const D = "_modalOverlay_dvid0_1", L = "_closing_dvid0_16", j = "_modal_dvid0_1", V = "_modalHeader_dvid0_52", W = "_modalTitle_dvid0_60", X = "_closeIcon_dvid0_71", Y = "_modalBody_dvid0_83", Z = "_modalFooter_dvid0_93", o = {
8
- modalOverlay: D,
9
- closing: L,
10
- modal: j,
11
- modalHeader: V,
12
- modalTitle: W,
13
- closeIcon: X,
14
- modalBody: Y,
15
- modalFooter: Z
16
- }, Q = ({
17
- isOpen: r,
18
- title: c,
19
- children: g,
20
- width: p = 752,
21
- confirmButton: d = !0,
22
- cancelButton: t = !0,
23
- onConfirm: i,
24
- onCancel: m,
25
- zIndex: I,
26
- className: C,
27
- style: N,
28
- onClickOverlay: s,
29
- onClose: a,
30
- closeModal: E,
31
- ...T
6
+ import { r as O } from "../../index-CGDUIzcq.js";
7
+ import '../../assets/index7.css';const R = "_modalOverlay_1x735_1", $ = "_closing_1x735_15", D = "_modal_1x735_1", L = "_modalHeader_1x735_47", j = "_modalTitle_1x735_55", V = "_closeIcon_1x735_66", W = "_modalBody_1x735_79", X = "_modalFooter_1x735_89", o = {
8
+ modalOverlay: R,
9
+ closing: $,
10
+ modal: D,
11
+ modalHeader: L,
12
+ modalTitle: j,
13
+ closeIcon: V,
14
+ modalBody: W,
15
+ modalFooter: X
16
+ }, K = ({
17
+ isOpen: t,
18
+ title: n,
19
+ children: x,
20
+ width: g = 752,
21
+ confirmButton: a,
22
+ cancelButton: l,
23
+ zIndex: v,
24
+ className: p,
25
+ style: u,
26
+ onClickOverlay: i,
27
+ onClose: s,
28
+ closeModal: C,
29
+ ...I
32
30
  }) => {
33
- const f = O(null), [k, _] = R(!1);
34
- $(r);
35
- const l = () => {
36
- _(!0), setTimeout(() => {
37
- E(), _(!1);
31
+ const c = z(null), [w, m] = A(!1);
32
+ H(t);
33
+ const d = () => {
34
+ m(!0), setTimeout(() => {
35
+ C(), m(!1);
38
36
  }, 250);
39
- }, x = async (H) => {
37
+ }, N = async (T) => {
40
38
  var h;
41
- (h = f.current) != null && h.contains(H.target) || s !== !1 && (typeof s == "function" && await s(), l());
42
- }, B = async () => {
43
- a !== !1 && (typeof a == "function" && await a(), l());
44
- }, w = async () => {
45
- i && await i(), l();
46
- }, A = async () => {
47
- m && await m(), l();
48
- }, u = t === !0 ? "Cancelar" : t || void 0, v = d === !0 ? "Confirmar" : d || void 0;
49
- if (!r) return null;
50
- const F = `${o.modal} ${C || ""}`;
51
- return b.createPortal(
39
+ (h = c.current) != null && h.contains(T.target) || i !== !1 && (typeof i == "function" && await i(), d());
40
+ }, E = async () => {
41
+ s !== !1 && (typeof s == "function" && await s(), d());
42
+ }, b = async () => {
43
+ a.action && await a.action(), d();
44
+ }, k = async () => {
45
+ l.action && await l.action(), d();
46
+ }, _ = l.show ?? !0, f = a.show ?? !0, S = `${o.modal} ${p || ""}`;
47
+ return t ? O.createPortal(
52
48
  /* @__PURE__ */ e(
53
49
  "div",
54
50
  {
55
- className: `${o.modalOverlay} ${k ? o.closing : ""}`,
56
- style: { zIndex: 3e3 + (I || 0) },
57
- onClick: x,
58
- children: /* @__PURE__ */ n(
51
+ className: `${o.modalOverlay} ${w ? o.closing : ""}`,
52
+ style: { zIndex: 3e3 + (v || 0) },
53
+ onClick: N,
54
+ children: /* @__PURE__ */ r(
59
55
  "div",
60
56
  {
61
- className: F,
62
- style: { width: p, ...N },
63
- ref: f,
64
- ...T,
57
+ className: S,
58
+ style: { width: g, ...u },
59
+ ref: c,
60
+ ...I,
65
61
  children: [
66
- /* @__PURE__ */ n("div", { className: o.modalHeader, children: [
67
- c && /* @__PURE__ */ e("h2", { className: o.modalTitle, children: c }),
68
- a !== !1 && /* @__PURE__ */ e("div", { className: o.closeIcon, onClick: B, children: /* @__PURE__ */ e(
69
- S,
62
+ /* @__PURE__ */ r("div", { className: o.modalHeader, children: [
63
+ n && /* @__PURE__ */ e("span", { className: o.modalTitle, children: n }),
64
+ s !== !1 && /* @__PURE__ */ e("div", { className: o.closeIcon, onClick: E, children: /* @__PURE__ */ e(
65
+ F,
70
66
  {
71
67
  name: "Close",
72
68
  width: 12,
@@ -75,10 +71,32 @@ import '../../assets/index7.css';const D = "_modalOverlay_dvid0_1", L = "_closin
75
71
  }
76
72
  ) })
77
73
  ] }),
78
- /* @__PURE__ */ e("div", { className: o.modalBody, children: g }),
79
- (d || t) && /* @__PURE__ */ n("div", { className: o.modalFooter, children: [
80
- u && /* @__PURE__ */ e(y, { variant: "outline", onClick: A, fullWidth: !0, children: u }),
81
- v && /* @__PURE__ */ e(y, { variant: "brand", onClick: w, fullWidth: !0, children: v })
74
+ /* @__PURE__ */ e("div", { className: o.modalBody, children: x }),
75
+ (_ || f) && /* @__PURE__ */ r("div", { className: o.modalFooter, children: [
76
+ _ && /* @__PURE__ */ e(
77
+ y,
78
+ {
79
+ variant: l.variant || "outline",
80
+ onClick: k,
81
+ disabled: l.disabled || !1,
82
+ size: l.size || "small",
83
+ loading: l.loading,
84
+ fullWidth: !0,
85
+ children: l.text || "Cancelar"
86
+ }
87
+ ),
88
+ f && /* @__PURE__ */ e(
89
+ y,
90
+ {
91
+ variant: a.variant || "brand",
92
+ onClick: b,
93
+ disabled: a.disabled || !1,
94
+ size: a.size || "small",
95
+ loading: a.loading,
96
+ fullWidth: !0,
97
+ children: a.text || "Confirmar"
98
+ }
99
+ )
82
100
  ] })
83
101
  ]
84
102
  }
@@ -86,8 +104,8 @@ import '../../assets/index7.css';const D = "_modalOverlay_dvid0_1", L = "_closin
86
104
  }
87
105
  ),
88
106
  document.getElementById("root") || document.body
89
- );
107
+ ) : null;
90
108
  };
91
109
  export {
92
- Q as Modal
110
+ K as Modal
93
111
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bmi-next-brokers",
3
3
  "description": "Componentes de UI para proyecto BMI Next Brokers",
4
- "version": "1.1.4",
4
+ "version": "1.1.5",
5
5
  "author": "BMI Ahorro España",
6
6
  "contributors": [
7
7
  "José Ramón Jiménez <jrjimenez@bmicos.com>",