prometeo-design-system 4.6.4 → 4.6.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/DialogModal.es.js +123 -112
- package/package.json +1 -1
package/dist/DialogModal.es.js
CHANGED
|
@@ -1,162 +1,173 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { c } from "./cn-B6yFEsav.js";
|
|
5
|
-
const
|
|
6
|
-
({ children:
|
|
7
|
-
const [
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
}, []),
|
|
12
|
-
|
|
1
|
+
import { j as e } from "./jsx-runtime-DKDX3adD.js";
|
|
2
|
+
import { forwardRef as Q, memo as j, useState as L, useRef as F, useCallback as x, useImperativeHandle as W, Children as R, isValidElement as U } from "react";
|
|
3
|
+
import { createPortal as X } from "react-dom";
|
|
4
|
+
import { c as p } from "./cn-B6yFEsav.js";
|
|
5
|
+
const V = Q(
|
|
6
|
+
({ children: t, onClose: n, className: o, attachToParent: s = !1, zindex: v = 40, debugMode: a = !1, safeMarginSize: _ = 24, title: T, scroll: m = "content" }, $) => {
|
|
7
|
+
const [N, z] = L(!1), [D, O] = L(null), k = F(n), w = F(D);
|
|
8
|
+
k.current = n, w.current = D;
|
|
9
|
+
const P = x((f) => {
|
|
10
|
+
O(f ?? null), z(!0);
|
|
11
|
+
}, []), E = x(() => {
|
|
12
|
+
z(!1), k.current?.(w.current), setTimeout(() => O(null), 300);
|
|
13
13
|
}, []);
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
W(
|
|
15
|
+
$,
|
|
16
16
|
() => ({
|
|
17
|
-
open:
|
|
18
|
-
close:
|
|
19
|
-
isOpen:
|
|
20
|
-
getContext: () =>
|
|
17
|
+
open: P,
|
|
18
|
+
close: E,
|
|
19
|
+
isOpen: N,
|
|
20
|
+
getContext: () => w.current
|
|
21
21
|
}),
|
|
22
|
-
[
|
|
22
|
+
[P, E, N]
|
|
23
23
|
);
|
|
24
|
-
const
|
|
24
|
+
const q = `max-[500px]:max-w-[calc(100%-32px)]
|
|
25
25
|
max-[1200px]:max-w-[min(800px,calc(100%-32px))]
|
|
26
|
-
min-[1200px]:max-w-[min(1224px,calc(100%-100px))] min-[1200px]:min-w-[1100px]
|
|
27
|
-
let
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
26
|
+
min-[1200px]:max-w-[min(1224px,calc(100%-100px))] min-[1200px]:min-w-[1100px]`;
|
|
27
|
+
let C, b;
|
|
28
|
+
typeof t == "function" ? (console.log("es un child de tipo function"), C = t(D), b = R.toArray(C), console.log(b, "Child array")) : (C = t, b = R.toArray(C));
|
|
29
|
+
const B = (f) => {
|
|
30
|
+
const l = {
|
|
31
|
+
header: null,
|
|
32
|
+
titleContent: null,
|
|
33
|
+
content: null,
|
|
34
|
+
footer: null,
|
|
35
|
+
middleChildren: []
|
|
36
|
+
}, S = (r) => {
|
|
37
|
+
if (!U(r)) {
|
|
38
|
+
l.middleChildren.push(r);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (r.type === g && !l.titleContent) {
|
|
42
|
+
l.titleContent = r;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (r.type === d && !l.header) {
|
|
46
|
+
const i = r.props;
|
|
47
|
+
l.header = /* @__PURE__ */ e.jsx(d, { ...i, debugMode: a, children: i.children });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (r.type === u && !l.content) {
|
|
51
|
+
const i = r.props;
|
|
52
|
+
l.content = /* @__PURE__ */ e.jsx(u, { ...i, debugMode: a, scroll: m, children: i.children });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (r.type === h && !l.footer) {
|
|
56
|
+
const i = r.props;
|
|
57
|
+
l.footer = /* @__PURE__ */ e.jsx(h, { ...i, debugMode: a, children: i.children });
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const G = r.props;
|
|
61
|
+
G?.children && R.toArray(G.children).forEach(S), r.type !== d && r.type !== u && r.type !== h && r.type !== g && l.middleChildren.push(r);
|
|
62
|
+
};
|
|
63
|
+
return f.forEach(S), l;
|
|
64
|
+
};
|
|
65
|
+
let { header: c, titleContent: y, content: J, footer: K, middleChildren: A } = B(b);
|
|
66
|
+
if (!c && T && (c = /* @__PURE__ */ e.jsx(d, { title: T, debugMode: a }), y = null), c && y && U(c)) {
|
|
67
|
+
const f = c.props;
|
|
68
|
+
f.title && (c = /* @__PURE__ */ e.jsx(d, { ...f, title: "", debugMode: a, children: y }), y = null);
|
|
58
69
|
}
|
|
59
|
-
const
|
|
70
|
+
const H = J ?? (A.length ? /* @__PURE__ */ e.jsx(u, { debugMode: a, scroll: m, children: A }) : null), I = /* @__PURE__ */ e.jsx(e.Fragment, { children: N && /* @__PURE__ */ e.jsx(
|
|
60
71
|
"div",
|
|
61
72
|
{
|
|
62
73
|
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/30 backdrop-blur-[1.5px]",
|
|
63
|
-
style: { zIndex:
|
|
64
|
-
onClick:
|
|
65
|
-
children: /* @__PURE__ */
|
|
74
|
+
style: { zIndex: v },
|
|
75
|
+
onClick: E,
|
|
76
|
+
children: /* @__PURE__ */ e.jsxs(
|
|
66
77
|
"div",
|
|
67
78
|
{
|
|
68
|
-
onClick: (
|
|
69
|
-
className:
|
|
79
|
+
onClick: (f) => f.stopPropagation(),
|
|
80
|
+
className: p(
|
|
70
81
|
"bg-neutral-default-default rounded-lg shadow-lg border-neutral-strong-default border relative ",
|
|
71
82
|
"max-h-[calc(100%-128px)] h-dvh w-full",
|
|
72
83
|
"flex flex-col ",
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
q,
|
|
85
|
+
o
|
|
75
86
|
),
|
|
76
87
|
style: {
|
|
77
|
-
"--safe-margin-size": `${
|
|
88
|
+
"--safe-margin-size": `${_}px`
|
|
78
89
|
},
|
|
79
90
|
children: [
|
|
80
|
-
/* @__PURE__ */
|
|
91
|
+
/* @__PURE__ */ e.jsx(
|
|
81
92
|
"div",
|
|
82
93
|
{
|
|
83
|
-
className:
|
|
94
|
+
className: p(
|
|
84
95
|
"absolute bg-transparent z-[-1] -top-(--safe-margin-size) -left-(--safe-margin-size) -right-(--safe-margin-size) -bottom-(--safe-margin-size)",
|
|
85
|
-
|
|
96
|
+
a && "after:content-['SECURE_MARGIN'] after:text-red-300 after:prometeo-fonts-label-small after:ml-2 "
|
|
86
97
|
),
|
|
87
98
|
style: {
|
|
88
|
-
background:
|
|
89
|
-
border:
|
|
99
|
+
background: a ? "#FF393973" : "auto",
|
|
100
|
+
border: a ? "solid 1px #FF3939" : ""
|
|
90
101
|
}
|
|
91
102
|
}
|
|
92
103
|
),
|
|
93
|
-
/* @__PURE__ */
|
|
104
|
+
/* @__PURE__ */ e.jsxs("div", { className: p(
|
|
94
105
|
"flex flex-col h-full",
|
|
95
|
-
|
|
96
|
-
|
|
106
|
+
m === "dialog" && "overflow-y-auto",
|
|
107
|
+
m === "content" && "overflow-hidden"
|
|
97
108
|
), children: [
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
109
|
+
c,
|
|
110
|
+
m === "dialog" ? /* @__PURE__ */ e.jsx("div", { className: "flex flex-col flex-1", children: H }) : H,
|
|
111
|
+
K
|
|
101
112
|
] })
|
|
102
113
|
]
|
|
103
114
|
}
|
|
104
115
|
)
|
|
105
116
|
}
|
|
106
117
|
) });
|
|
107
|
-
return
|
|
118
|
+
return s ? I : X(I, document.body);
|
|
108
119
|
}
|
|
109
120
|
);
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
"flex flex-col
|
|
113
|
-
|
|
114
|
-
|
|
121
|
+
V.displayName = "Dialog";
|
|
122
|
+
const u = j(({ children: t, className: n, debugMode: o, scroll: s }) => /* @__PURE__ */ e.jsx("div", { className: p(
|
|
123
|
+
"flex flex-col p-4",
|
|
124
|
+
o && "border-2 border-dashed border-red-500 bg-red-200/40 relative after:content-['CONTENT'] after:absolute after:top-2 after:left-1/2 after:w-max after:h-full after:text-red-500 ",
|
|
125
|
+
n,
|
|
115
126
|
// Para scroll='content', este componente necesita su propio scroll y altura mínima
|
|
116
|
-
|
|
127
|
+
s === "content" && "overflow-y-auto min-h-0 flex-1 ",
|
|
117
128
|
// Para scroll='dialog', el contenido debe ocupar todo el espacio disponible pero sin scroll
|
|
118
|
-
|
|
119
|
-
), children:
|
|
120
|
-
|
|
121
|
-
const g =
|
|
129
|
+
s === "dialog" && "flex-1 min-h-max "
|
|
130
|
+
), children: t }));
|
|
131
|
+
u.displayName = "DialogContent";
|
|
132
|
+
const g = j(({ children: t, className: n, debugMode: o }) => /* @__PURE__ */ e.jsx("h1", { className: p("prometeo-fonts-headline-small text-neutral-strong-default w-max", o && 'bg-red-400/40 relative after:content-["TITLE"] after:absolute after:top-0 after:-translate-y-5 after:left-0 after:w-max after:h-full after:text-red-500 after:prometeo-fonts-label-large', n), children: t }));
|
|
122
133
|
g.displayName = "DialogTitle";
|
|
123
|
-
const
|
|
134
|
+
const d = j(({ children: t, className: n, title: o, debugMode: s }) => /* @__PURE__ */ e.jsxs("div", { className: p(
|
|
124
135
|
"p-4",
|
|
125
|
-
|
|
126
|
-
|
|
136
|
+
s && "border-2 border-dashed border-red-600 bg-red-200/40! relative after:content-['HEADER'] after:absolute after:top-1 after:left-1/2 after:w-max after:h-full after:text-red-500",
|
|
137
|
+
n
|
|
127
138
|
), children: [
|
|
128
|
-
|
|
129
|
-
|
|
139
|
+
o && /* @__PURE__ */ e.jsx(g, { debugMode: s, children: o }),
|
|
140
|
+
t
|
|
130
141
|
] }));
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
142
|
+
d.displayName = "DialogHeader";
|
|
143
|
+
const h = j(({ children: t, className: n, debugMode: o }) => /* @__PURE__ */ e.jsx("div", { className: p(
|
|
144
|
+
o && "border-2 border-dashed border-red-600 bg-red-200/40! relative after:content-['FOOTER'] after:absolute after:top-1 after:left-1/2 after:w-max after:h-full after:text-red-500",
|
|
134
145
|
"border-t border-neutral-strong-default p-4",
|
|
135
|
-
|
|
136
|
-
), children:
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
Content:
|
|
140
|
-
Header:
|
|
141
|
-
Footer:
|
|
146
|
+
n
|
|
147
|
+
), children: t }));
|
|
148
|
+
h.displayName = "DialogFooter";
|
|
149
|
+
const Y = Object.assign(V, {
|
|
150
|
+
Content: u,
|
|
151
|
+
Header: d,
|
|
152
|
+
Footer: h,
|
|
142
153
|
Title: g
|
|
143
154
|
});
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
}, []),
|
|
149
|
-
|
|
150
|
-
}, []),
|
|
155
|
+
Y.displayName = "DialogModal";
|
|
156
|
+
const re = () => {
|
|
157
|
+
const t = F(null), n = x((a) => {
|
|
158
|
+
t.current?.open(a);
|
|
159
|
+
}, []), o = x(() => {
|
|
160
|
+
t.current?.close();
|
|
161
|
+
}, []), s = x(() => t.current?.isOpen ?? !1, []), v = x(() => t.current?.getContext() ?? null, []);
|
|
151
162
|
return {
|
|
152
|
-
ref:
|
|
153
|
-
open:
|
|
154
|
-
close:
|
|
155
|
-
isOpen:
|
|
156
|
-
getContext:
|
|
163
|
+
ref: t,
|
|
164
|
+
open: n,
|
|
165
|
+
close: o,
|
|
166
|
+
isOpen: s,
|
|
167
|
+
getContext: v
|
|
157
168
|
};
|
|
158
169
|
};
|
|
159
170
|
export {
|
|
160
|
-
|
|
161
|
-
|
|
171
|
+
Y as default,
|
|
172
|
+
re as useDialogControl
|
|
162
173
|
};
|