bmi-next-brokers 1.4.4 → 1.4.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.
- package/dist/assets/index7.css +1 -1
- package/dist/components/modal/index.d.ts +10 -1
- package/dist/components/modal/index.js +141 -128
- package/package.json +1 -1
package/dist/assets/index7.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._modalOverlay_1yekd_1{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#0009;display:flex;justify-content:center;align-items:center;animation:_overlayFadeIn_1yekd_1 .25s ease-in-out forwards;overflow:hidden}._modalOverlay_1yekd_1._closing_1yekd_15{animation:_overlayFadeOut_1yekd_1 .25s ease-in-out forwards}@keyframes _overlayFadeIn_1yekd_1{0%{opacity:0}to{opacity:1}}@keyframes _overlayFadeOut_1yekd_1{0%{opacity:1}to{opacity:0}}._modalLayout_1yekd_37{display:flex;gap:20px;justify-content:center;align-items:flex-start}._modal_1yekd_1{display:flex;flex-direction:column;border-radius:24px;background-color:#fff;box-shadow:0 4px 6px #0000001a;max-height:calc(100dvh - 15px);margin-inline:15px}._modalHeader_1yekd_55{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;gap:8px}._modalHeader_1yekd_55._withBorder_1yekd_63{border-bottom:1px solid var(--Blacks-Transparencias-Black-20, rgba(0, 0, 0, .2))}._modalTitle_1yekd_68{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;width:100%}._closeIcon_1yekd_80{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_1yekd_93{display:flex;flex-direction:column;flex:1;padding:0 16px 16px}._modalBody_1yekd_93::-webkit-scrollbar{display:none}._modalFooter_1yekd_104._withBorder_1yekd_63{border-top:1px solid var(--Blacks-Transparencias-Black-20, rgba(0, 0, 0, .2))}._buttonsDiv_1yekd_109{display:grid;grid-template-columns:1fr 1fr;margin-left:auto;width:fit-content;gap:19px;padding-inline:16px;margin-block:16px}._buttonsDiv_1yekd_109._fullWidthFooter_1yekd_119{width:100%}._buttonsDiv_1yekd_109 :only-child{grid-column:2}
|
|
@@ -26,6 +26,8 @@ export interface ModalProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
|
26
26
|
onClose?: (() => Promise<void> | void) | false;
|
|
27
27
|
closeModal: () => void;
|
|
28
28
|
withScroll?: boolean;
|
|
29
|
+
fullWidthFooter?: boolean;
|
|
30
|
+
helperElement?: React.ReactNode;
|
|
29
31
|
}
|
|
30
32
|
/**
|
|
31
33
|
* Modal con overlay, header, body y footer configurable.
|
|
@@ -51,11 +53,15 @@ export interface ModalProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
|
51
53
|
* @param onClickOverlay - Callback opcional al hacer click fuera del modal. Si se pasa `false`, el overlay no cierra el modal ni ejecuta acción.
|
|
52
54
|
* @param onClose - Callback opcional al pulsar el icono de cierre. Si se pasa `false`, no se renderiza el icono de cierre.
|
|
53
55
|
* @param closeModal - Función obligatoria que cierra el modal desde el exterior.
|
|
56
|
+
* @param withScroll - Scroll automático en modalBody. Aparece línea de separación en el header y en el footer.
|
|
57
|
+
* @param fullWidthFooter - Footer ocupa el 100% del ancho en lugar de fit-content.
|
|
58
|
+
* @param helperElement - Componente a renderizar como helper a la derecha del modal, dentro del mismo layout de overlay.
|
|
54
59
|
*
|
|
55
60
|
* @example
|
|
56
61
|
* ```tsx
|
|
57
62
|
* import { useState } from "react";
|
|
58
63
|
* import { Modal, Button } from "bmi-next-brokers";
|
|
64
|
+
* import MiComponente from "@componentes";
|
|
59
65
|
*
|
|
60
66
|
* export default function Example() {
|
|
61
67
|
* const [isOpen, setIsOpen] = useState(false);
|
|
@@ -72,12 +78,15 @@ export interface ModalProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
|
72
78
|
* closeModal={() => setIsOpen(false)}
|
|
73
79
|
* title="Ejemplo de Modal"
|
|
74
80
|
* width={500}
|
|
81
|
+
* fullWidthFooter
|
|
82
|
+
* withScroll={false}
|
|
83
|
+
* helperElement={< MiComponente />}
|
|
75
84
|
* confirmButton={{
|
|
76
85
|
* text: "Guardar",
|
|
77
86
|
* action: handleConfirm,
|
|
78
87
|
* variant: "brand",
|
|
79
88
|
* size: "small",
|
|
80
|
-
* loading: false
|
|
89
|
+
* loading: false,
|
|
81
90
|
* id: "form"
|
|
82
91
|
* }}
|
|
83
92
|
* cancelButton={{
|
|
@@ -1,148 +1,161 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { Icon as
|
|
4
|
-
import { useScrollLock as
|
|
5
|
-
import { Button as
|
|
6
|
-
import { r as
|
|
7
|
-
import '../../assets/index7.css';const
|
|
8
|
-
modalOverlay:
|
|
9
|
-
closing:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import { jsx as a, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as C, useState as v, useEffect as M } from "react";
|
|
3
|
+
import { Icon as P } from "../../icons/Icon.js";
|
|
4
|
+
import { useScrollLock as q } from "../../hooks/useScrollLock.js";
|
|
5
|
+
import { Button as E } from "../Button/Button.js";
|
|
6
|
+
import { r as G } from "../../index-CGDUIzcq.js";
|
|
7
|
+
import '../../assets/index7.css';const J = "_modalOverlay_1yekd_1", K = "_closing_1yekd_15", Q = "_modalLayout_1yekd_37", U = "_modal_1yekd_1", n = "_modalHeader_1yekd_55", u = "_withBorder_1yekd_63", B = "_modalTitle_1yekd_68", ee = "_closeIcon_1yekd_80", se = "_modalBody_1yekd_93", le = "_modalFooter_1yekd_104", de = "_buttonsDiv_1yekd_109", ae = "_fullWidthFooter_1yekd_119", l = {
|
|
8
|
+
modalOverlay: J,
|
|
9
|
+
closing: K,
|
|
10
|
+
modalLayout: Q,
|
|
11
|
+
modal: U,
|
|
12
|
+
modalHeader: n,
|
|
13
|
+
withBorder: u,
|
|
14
|
+
modalTitle: B,
|
|
15
|
+
closeIcon: ee,
|
|
16
|
+
modalBody: se,
|
|
17
|
+
modalFooter: le,
|
|
18
|
+
buttonsDiv: de,
|
|
19
|
+
fullWidthFooter: ae
|
|
20
|
+
}, me = ({
|
|
21
|
+
isOpen: m,
|
|
22
|
+
title: k,
|
|
23
|
+
children: b,
|
|
24
|
+
width: N = 752,
|
|
25
|
+
confirmButton: e,
|
|
26
|
+
cancelButton: s,
|
|
27
|
+
zIndex: I,
|
|
28
|
+
className: S,
|
|
29
|
+
style: $,
|
|
30
|
+
onClickOverlay: _,
|
|
31
|
+
onClose: o,
|
|
32
|
+
closeModal: L,
|
|
33
|
+
withScroll: O = !0,
|
|
34
|
+
fullWidthFooter: F = !1,
|
|
35
|
+
helperElement: H,
|
|
32
36
|
...x
|
|
33
37
|
}) => {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
const g = C(null), [D, t] = v(!1), y = C(null), [T, c] = v(!1), [z, R] = v(!1);
|
|
39
|
+
q(m);
|
|
40
|
+
const i = () => {
|
|
41
|
+
t(!0), setTimeout(() => {
|
|
42
|
+
L(), t(!1);
|
|
39
43
|
}, 250);
|
|
40
|
-
},
|
|
44
|
+
}, W = async (d) => {
|
|
41
45
|
var r;
|
|
42
|
-
(r =
|
|
43
|
-
},
|
|
44
|
-
|
|
46
|
+
(r = g.current) != null && r.contains(d.target) || _ !== !1 && (typeof _ == "function" && await _(), i());
|
|
47
|
+
}, j = async () => {
|
|
48
|
+
o !== !1 && (typeof o == "function" && await o(), i());
|
|
45
49
|
}, A = async () => {
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
return
|
|
51
|
-
if (!
|
|
52
|
-
const
|
|
53
|
-
|
|
50
|
+
e != null && e.action && await e.action(), i();
|
|
51
|
+
}, Y = async () => {
|
|
52
|
+
s != null && s.action && await s.action(), i();
|
|
53
|
+
}, V = s && Object.keys(s).length > 0, X = e && Object.keys(e).length > 0, w = V && (s.show ?? !0), p = X && (e.show ?? !0), Z = `${l.modal} ${S || ""}`;
|
|
54
|
+
return M(() => {
|
|
55
|
+
if (!y.current) return;
|
|
56
|
+
const d = y.current, r = () => {
|
|
57
|
+
R(d.scrollTop > 0), c(d.scrollHeight > d.clientHeight);
|
|
54
58
|
};
|
|
55
|
-
r(),
|
|
56
|
-
const
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
+
r(), d.addEventListener("scroll", r);
|
|
60
|
+
const f = new ResizeObserver(r);
|
|
61
|
+
return f.observe(d), () => {
|
|
62
|
+
d.removeEventListener("scroll", r), f.disconnect();
|
|
59
63
|
};
|
|
60
|
-
}, [
|
|
61
|
-
/* @__PURE__ */
|
|
64
|
+
}, [b]), m ? G.createPortal(
|
|
65
|
+
/* @__PURE__ */ a(
|
|
62
66
|
"div",
|
|
63
67
|
{
|
|
64
68
|
className: `${l.modalOverlay} ${D ? l.closing : ""}`,
|
|
65
|
-
style: { zIndex: 3e3 + (
|
|
66
|
-
onClick:
|
|
67
|
-
children: /* @__PURE__ */
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
69
|
+
style: { zIndex: 3e3 + (I || 0) },
|
|
70
|
+
onClick: W,
|
|
71
|
+
children: /* @__PURE__ */ h("div", { className: l.modalLayout, children: [
|
|
72
|
+
/* @__PURE__ */ h(
|
|
73
|
+
"div",
|
|
74
|
+
{
|
|
75
|
+
className: Z,
|
|
76
|
+
style: { width: N, ...$ },
|
|
77
|
+
ref: g,
|
|
78
|
+
...x,
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ h(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
className: `${l.modalHeader} ${z ? l.withBorder : ""}`,
|
|
84
|
+
children: [
|
|
85
|
+
k && /* @__PURE__ */ a("span", { className: l.modalTitle, children: k }),
|
|
86
|
+
o !== !1 && /* @__PURE__ */ a("div", { className: l.closeIcon, onClick: j, children: /* @__PURE__ */ a(
|
|
87
|
+
P,
|
|
88
|
+
{
|
|
89
|
+
name: "Close",
|
|
90
|
+
width: 12,
|
|
91
|
+
height: 12,
|
|
92
|
+
fill: "var(--Blacks-Transparencias-Black-40, rgba(0, 0, 0, 0.40)"
|
|
93
|
+
}
|
|
94
|
+
) })
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
/* @__PURE__ */ a(
|
|
99
|
+
"div",
|
|
100
|
+
{
|
|
101
|
+
className: l.modalBody,
|
|
102
|
+
style: {
|
|
103
|
+
overflowY: O ? "auto" : "hidden"
|
|
104
|
+
},
|
|
105
|
+
ref: y,
|
|
106
|
+
children: b
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
(w || p) && /* @__PURE__ */ a(
|
|
110
|
+
"div",
|
|
111
|
+
{
|
|
112
|
+
className: `${l.modalFooter} ${T ? l.withBorder : ""}`,
|
|
113
|
+
children: /* @__PURE__ */ h(
|
|
114
|
+
"div",
|
|
83
115
|
{
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
onClick: F,
|
|
114
|
-
disabled: (e == null ? void 0 : e.disabled) || !1,
|
|
115
|
-
size: (e == null ? void 0 : e.size) || "small",
|
|
116
|
-
loading: e == null ? void 0 : e.loading,
|
|
117
|
-
fullWidth: !0,
|
|
118
|
-
children: (e == null ? void 0 : e.text) || "Cancelar"
|
|
119
|
-
}
|
|
120
|
-
),
|
|
121
|
-
c && /* @__PURE__ */ d(
|
|
122
|
-
N,
|
|
123
|
-
{
|
|
124
|
-
type: "submit",
|
|
125
|
-
form: s == null ? void 0 : s.id,
|
|
126
|
-
variant: (s == null ? void 0 : s.variant) || "brand",
|
|
127
|
-
onClick: A,
|
|
128
|
-
disabled: (s == null ? void 0 : s.disabled) || !1,
|
|
129
|
-
size: (s == null ? void 0 : s.size) || "small",
|
|
130
|
-
loading: s == null ? void 0 : s.loading,
|
|
131
|
-
fullWidth: !0,
|
|
132
|
-
children: (s == null ? void 0 : s.text) || "Confirmar"
|
|
116
|
+
className: `${l.buttonsDiv} ${F ? l.fullWidthFooter : ""}`,
|
|
117
|
+
children: [
|
|
118
|
+
w && /* @__PURE__ */ a(
|
|
119
|
+
E,
|
|
120
|
+
{
|
|
121
|
+
variant: (s == null ? void 0 : s.variant) || "outline",
|
|
122
|
+
onClick: Y,
|
|
123
|
+
disabled: (s == null ? void 0 : s.disabled) || !1,
|
|
124
|
+
size: (s == null ? void 0 : s.size) || "small",
|
|
125
|
+
loading: s == null ? void 0 : s.loading,
|
|
126
|
+
fullWidth: !0,
|
|
127
|
+
children: (s == null ? void 0 : s.text) || "Cancelar"
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
p && /* @__PURE__ */ a(
|
|
131
|
+
E,
|
|
132
|
+
{
|
|
133
|
+
type: "submit",
|
|
134
|
+
form: e == null ? void 0 : e.id,
|
|
135
|
+
variant: (e == null ? void 0 : e.variant) || "brand",
|
|
136
|
+
onClick: A,
|
|
137
|
+
disabled: (e == null ? void 0 : e.disabled) || !1,
|
|
138
|
+
size: (e == null ? void 0 : e.size) || "small",
|
|
139
|
+
loading: e == null ? void 0 : e.loading,
|
|
140
|
+
fullWidth: !0,
|
|
141
|
+
children: (e == null ? void 0 : e.text) || "Confirmar"
|
|
142
|
+
}
|
|
143
|
+
)
|
|
144
|
+
]
|
|
133
145
|
}
|
|
134
146
|
)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
H
|
|
153
|
+
] })
|
|
141
154
|
}
|
|
142
155
|
),
|
|
143
156
|
document.getElementById("root") || document.body
|
|
144
157
|
) : null;
|
|
145
158
|
};
|
|
146
159
|
export {
|
|
147
|
-
|
|
160
|
+
me as Modal
|
|
148
161
|
};
|
package/package.json
CHANGED