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.
@@ -1 +1 @@
1
- ._modalOverlay_1347c_1{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#0009;display:flex;justify-content:center;align-items:center;animation:_overlayFadeIn_1347c_1 .25s ease-in-out forwards;overflow:hidden}._modalOverlay_1347c_1._closing_1347c_15{animation:_overlayFadeOut_1347c_1 .25s ease-in-out forwards}@keyframes _overlayFadeIn_1347c_1{0%{opacity:0}to{opacity:1}}@keyframes _overlayFadeOut_1347c_1{0%{opacity:1}to{opacity:0}}._modal_1347c_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_1347c_48{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;gap:8px}._modalHeader_1347c_48._withBorder_1347c_56{border-bottom:1px solid var(--Blacks-Transparencias-Black-20, rgba(0, 0, 0, .2))}._modalTitle_1347c_61{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_1347c_72{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_1347c_85{display:flex;flex-direction:column;flex:1;padding:0 16px 16px}._modalBody_1347c_85::-webkit-scrollbar{display:none}._modalFooter_1347c_96._withBorder_1347c_56{border-top:1px solid var(--Blacks-Transparencias-Black-20, rgba(0, 0, 0, .2))}._buttonsDiv_1347c_101{display:grid;grid-template-columns:1fr 1fr;margin-left:auto;width:fit-content;gap:19px;padding-inline:16px;margin-block:16px}._buttonsDiv_1347c_101 :only-child{grid-column:2}
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 d, jsxs as v } from "react/jsx-runtime";
2
- import { useRef as I, useState as m, useEffect as X } from "react";
3
- import { Icon as Z } from "../../icons/Icon.js";
4
- import { useScrollLock as M } from "../../hooks/useScrollLock.js";
5
- import { Button as N } from "../Button/Button.js";
6
- import { r as P } from "../../index-CGDUIzcq.js";
7
- import '../../assets/index7.css';const q = "_modalOverlay_1347c_1", G = "_closing_1347c_15", J = "_modal_1347c_1", K = "_modalHeader_1347c_48", Q = "_withBorder_1347c_56", U = "_modalTitle_1347c_61", n = "_closeIcon_1347c_72", u = "_modalBody_1347c_85", B = "_modalFooter_1347c_96", ss = "_buttonsDiv_1347c_101", l = {
8
- modalOverlay: q,
9
- closing: G,
10
- modal: J,
11
- modalHeader: K,
12
- withBorder: Q,
13
- modalTitle: U,
14
- closeIcon: n,
15
- modalBody: u,
16
- modalFooter: B,
17
- buttonsDiv: ss
18
- }, hs = ({
19
- isOpen: y,
20
- title: b,
21
- children: g,
22
- width: S = 752,
23
- confirmButton: s,
24
- cancelButton: e,
25
- zIndex: k,
26
- className: O,
27
- style: f,
28
- onClickOverlay: h,
29
- onClose: i,
30
- closeModal: H,
31
- withScroll: $ = !0,
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 w = I(null), [D, p] = m(!1), _ = I(null), [T, z] = m(!1), [R, L] = m(!1);
35
- M(y);
36
- const o = () => {
37
- p(!0), setTimeout(() => {
38
- H(), p(!1);
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
- }, j = async (a) => {
44
+ }, W = async (d) => {
41
45
  var r;
42
- (r = w.current) != null && r.contains(a.target) || h !== !1 && (typeof h == "function" && await h(), o());
43
- }, t = async () => {
44
- i !== !1 && (typeof i == "function" && await i(), o());
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
- s != null && s.action && await s.action(), o();
47
- }, F = async () => {
48
- e != null && e.action && await e.action(), o();
49
- }, Y = e && Object.keys(e).length > 0, V = s && Object.keys(s).length > 0, C = Y && (e.show ?? !0), c = V && (s.show ?? !0), W = `${l.modal} ${O || ""}`;
50
- return X(() => {
51
- if (!_.current) return;
52
- const a = _.current, r = () => {
53
- L(a.scrollTop > 0), z(a.scrollHeight > a.clientHeight);
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(), a.addEventListener("scroll", r);
56
- const E = new ResizeObserver(r);
57
- return E.observe(a), () => {
58
- a.removeEventListener("scroll", r), E.disconnect();
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
- }, [g]), y ? P.createPortal(
61
- /* @__PURE__ */ d(
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 + (k || 0) },
66
- onClick: j,
67
- children: /* @__PURE__ */ v(
68
- "div",
69
- {
70
- className: W,
71
- style: { width: S, ...f },
72
- ref: w,
73
- ...x,
74
- children: [
75
- /* @__PURE__ */ v(
76
- "div",
77
- {
78
- className: `${l.modalHeader} ${R ? l.withBorder : ""}`,
79
- children: [
80
- b && /* @__PURE__ */ d("span", { className: l.modalTitle, children: b }),
81
- i !== !1 && /* @__PURE__ */ d("div", { className: l.closeIcon, onClick: t, children: /* @__PURE__ */ d(
82
- Z,
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
- name: "Close",
85
- width: 12,
86
- height: 12,
87
- fill: "var(--Blacks-Transparencias-Black-40, rgba(0, 0, 0, 0.40)"
88
- }
89
- ) })
90
- ]
91
- }
92
- ),
93
- /* @__PURE__ */ d(
94
- "div",
95
- {
96
- className: l.modalBody,
97
- style: {
98
- overflowY: $ ? "auto" : "hidden"
99
- },
100
- ref: _,
101
- children: g
102
- }
103
- ),
104
- (C || c) && /* @__PURE__ */ d(
105
- "div",
106
- {
107
- className: `${l.modalFooter} ${T ? l.withBorder : ""}`,
108
- children: /* @__PURE__ */ v("div", { className: l.buttonsDiv, children: [
109
- C && /* @__PURE__ */ d(
110
- N,
111
- {
112
- variant: (e == null ? void 0 : e.variant) || "outline",
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
- hs as Modal
160
+ me as Modal
148
161
  };
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.4.4",
4
+ "version": "1.4.5",
5
5
  "author": "BMI Ahorro España",
6
6
  "contributors": [
7
7
  "José Ramón Jiménez <jrjimenez@bmicos.com>",