prometeo-design-system 5.0.2 → 5.1.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/dist/DialogModal.es.js +177 -137
- package/package.json +1 -1
package/dist/DialogModal.es.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { c } from "./cn-B6yFEsav.js";
|
|
1
|
+
import { j as a } from "./jsx-runtime-GkKLlHH4.js";
|
|
2
|
+
import { forwardRef as he, memo as D, useState as te, useRef as A, useCallback as v, useImperativeHandle as me, Children as N, isValidElement as T, createElement as j, cloneElement as ne } from "react";
|
|
3
|
+
import { createPortal as Ee } from "react-dom";
|
|
4
|
+
import { c as x } from "./cn-B6yFEsav.js";
|
|
5
5
|
import { c as ge } from "./index-BOQuZ0gG.js";
|
|
6
|
-
const
|
|
7
|
-
({ children:
|
|
8
|
-
const [
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
}, []),
|
|
13
|
-
|
|
6
|
+
const oe = he(
|
|
7
|
+
({ children: r, onClose: d, className: i, attachToParent: s = !1, zindex: f = 40, debugMode: t = !1, safeMarginSize: m = 24, title: E, scroll: p = "content", size: re = "medium" }, ae) => {
|
|
8
|
+
const [X, H] = te(!1), [k, S] = te(null), G = A(d), W = A(k);
|
|
9
|
+
G.current = d, W.current = k;
|
|
10
|
+
const V = v((g) => {
|
|
11
|
+
S(g ?? null), H(!0);
|
|
12
|
+
}, []), B = v(() => {
|
|
13
|
+
H(!1), G.current?.(W.current), setTimeout(() => S(null), 300);
|
|
14
14
|
}, []);
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
me(
|
|
16
|
+
ae,
|
|
17
17
|
() => ({
|
|
18
|
-
open:
|
|
19
|
-
close:
|
|
20
|
-
isOpen:
|
|
21
|
-
getContext: () =>
|
|
18
|
+
open: V,
|
|
19
|
+
close: B,
|
|
20
|
+
isOpen: X,
|
|
21
|
+
getContext: () => W.current
|
|
22
22
|
}),
|
|
23
|
-
[
|
|
23
|
+
[V, B, X]
|
|
24
24
|
);
|
|
25
|
-
const
|
|
25
|
+
const le = ge("max-h-[calc(100%-80px)]", {
|
|
26
26
|
variants: {
|
|
27
27
|
size: {
|
|
28
28
|
medium: " max-w-[min(740px,calc(100%-32px))]",
|
|
@@ -30,185 +30,225 @@ const Q = xe(
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
-
let
|
|
34
|
-
typeof
|
|
35
|
-
const
|
|
36
|
-
const
|
|
33
|
+
let P, F;
|
|
34
|
+
typeof r == "function" ? (P = r(k), F = N.toArray(P)) : (P = r, F = N.toArray(P));
|
|
35
|
+
const se = (g) => {
|
|
36
|
+
const e = {
|
|
37
37
|
headerProps: null,
|
|
38
38
|
titleContent: null,
|
|
39
39
|
contentProps: null,
|
|
40
40
|
footerProps: null,
|
|
41
|
-
middleChildren: []
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
middleChildren: [],
|
|
42
|
+
allExpandInfo: {
|
|
43
|
+
headerExpandX: !1,
|
|
44
|
+
headerExpandY: !1,
|
|
45
|
+
contentExpandX: !1,
|
|
46
|
+
contentExpandY: !1,
|
|
47
|
+
footerExpandX: !1,
|
|
48
|
+
footerExpandY: !1
|
|
49
|
+
}
|
|
50
|
+
}, Y = (n) => {
|
|
51
|
+
if (!T(n)) return;
|
|
52
|
+
const o = n.props;
|
|
53
|
+
n.type === C ? (e.allExpandInfo.headerExpandX = e.allExpandInfo.headerExpandX || !!o?.expandX, e.allExpandInfo.headerExpandY = e.allExpandInfo.headerExpandY || !!o?.expandY) : n.type === y ? (e.allExpandInfo.contentExpandX = e.allExpandInfo.contentExpandX || !!o?.expandX, e.allExpandInfo.contentExpandY = e.allExpandInfo.contentExpandY || !!o?.expandY) : n.type === b && (e.allExpandInfo.footerExpandX = e.allExpandInfo.footerExpandX || !!o?.expandX, e.allExpandInfo.footerExpandY = e.allExpandInfo.footerExpandY || !!o?.expandY), o?.children && N.toArray(o.children).forEach(Y);
|
|
54
|
+
};
|
|
55
|
+
return g.forEach((n) => {
|
|
56
|
+
if (Y(n), !T(n)) {
|
|
57
|
+
e.middleChildren.push(n);
|
|
45
58
|
return;
|
|
46
59
|
}
|
|
47
|
-
if (
|
|
48
|
-
|
|
60
|
+
if (n.type === w && !e.titleContent) {
|
|
61
|
+
e.titleContent = n;
|
|
49
62
|
return;
|
|
50
63
|
}
|
|
51
|
-
if (
|
|
52
|
-
const
|
|
53
|
-
|
|
64
|
+
if (n.type === C && !e.headerProps) {
|
|
65
|
+
const o = n.props;
|
|
66
|
+
e.headerProps = o;
|
|
54
67
|
return;
|
|
55
68
|
}
|
|
56
|
-
if (
|
|
57
|
-
const
|
|
58
|
-
|
|
69
|
+
if (n.type === y && !e.contentProps) {
|
|
70
|
+
const o = n.props;
|
|
71
|
+
e.contentProps = o;
|
|
59
72
|
return;
|
|
60
73
|
}
|
|
61
|
-
if (
|
|
62
|
-
const
|
|
63
|
-
|
|
74
|
+
if (n.type === b && !e.footerProps) {
|
|
75
|
+
const o = n.props;
|
|
76
|
+
e.footerProps = o;
|
|
64
77
|
return;
|
|
65
78
|
}
|
|
66
|
-
|
|
67
|
-
|
|
79
|
+
e.middleChildren.push(n);
|
|
80
|
+
}), e;
|
|
81
|
+
}, de = (g, e, Y, n) => {
|
|
82
|
+
const o = (u) => {
|
|
83
|
+
if (!T(u))
|
|
84
|
+
return u;
|
|
85
|
+
const l = u.props;
|
|
86
|
+
if (u.type === w)
|
|
87
|
+
return /* @__PURE__ */ j(w, { ...l, debugMode: t, key: Math.random() }, l.children);
|
|
88
|
+
if (u.type === C)
|
|
89
|
+
return /* @__PURE__ */ j(C, { ...l, debugMode: t, expandWeight: e, key: Math.random() }, l.children);
|
|
90
|
+
if (u.type === y)
|
|
91
|
+
return /* @__PURE__ */ j(y, { ...l, debugMode: t, scroll: p, expandWeight: Y, key: Math.random() }, l.children);
|
|
92
|
+
if (u.type === b)
|
|
93
|
+
return /* @__PURE__ */ j(b, { ...l, debugMode: t, expandWeight: n, key: Math.random() }, l.children);
|
|
94
|
+
if (u.type === "form") {
|
|
95
|
+
const O = l?.children ? N.toArray(l.children).map(o) : [];
|
|
96
|
+
return ne(u, {
|
|
97
|
+
key: Math.random(),
|
|
98
|
+
...l,
|
|
99
|
+
className: x(l?.className, "contents")
|
|
100
|
+
// display: contents
|
|
101
|
+
}, ...O);
|
|
102
|
+
}
|
|
103
|
+
if (l?.children) {
|
|
104
|
+
const O = N.toArray(l.children).map(o);
|
|
105
|
+
return ne(u, { key: Math.random() }, ...O);
|
|
106
|
+
}
|
|
107
|
+
return u;
|
|
68
108
|
};
|
|
69
|
-
return
|
|
109
|
+
return g.map(o);
|
|
70
110
|
};
|
|
71
|
-
let { headerProps:
|
|
72
|
-
!
|
|
73
|
-
...
|
|
111
|
+
let { headerProps: $, titleContent: I, contentProps: L, footerProps: U, middleChildren: ie, allExpandInfo: c } = se(F), h = $ ? { ...$ } : null, R = L ? { ...L } : null, z = U ? { ...U } : null;
|
|
112
|
+
!h && E && (h = { title: E, children: null }, I = null), h && I && h.title && (h = {
|
|
113
|
+
...h,
|
|
74
114
|
title: "",
|
|
75
|
-
children:
|
|
76
|
-
},
|
|
77
|
-
const
|
|
78
|
-
"--safe-margin-size": `${
|
|
115
|
+
children: I
|
|
116
|
+
}, I = null);
|
|
117
|
+
const fe = c.headerExpandX || c.contentExpandX || c.footerExpandX, _ = c.headerExpandY || c.contentExpandY || c.footerExpandY, pe = [c.headerExpandY, c.contentExpandY, c.footerExpandY].filter(Boolean).length, q = c.contentExpandY ? pe > 1 ? 2 : 1 : void 0, J = c.headerExpandY ? 1 : void 0, K = c.footerExpandY ? 1 : void 0, Q = de(ie, J, q, K), ce = h ? /* @__PURE__ */ a.jsx(C, { ...h, debugMode: t, expandWeight: J, children: h.children }) : null, Z = (R ? /* @__PURE__ */ a.jsx(y, { ...R, debugMode: t, scroll: p, expandWeight: q, children: R.children }) : null) ?? (Q.length ? Q : null), xe = z ? /* @__PURE__ */ a.jsx(b, { ...z, debugMode: t, expandWeight: K, children: z.children }) : null, ue = fe ? "w-full" : "w-auto", M = {
|
|
118
|
+
"--safe-margin-size": `${m}px`
|
|
79
119
|
};
|
|
80
|
-
|
|
81
|
-
const
|
|
120
|
+
_ && (M.height = `calc(100% - ${m * 2}px)`);
|
|
121
|
+
const ee = /* @__PURE__ */ a.jsx(a.Fragment, { children: X && /* @__PURE__ */ a.jsx(
|
|
82
122
|
"div",
|
|
83
123
|
{
|
|
84
124
|
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/30 backdrop-blur-[1.5px]",
|
|
85
|
-
style: { zIndex:
|
|
86
|
-
onClick:
|
|
87
|
-
children: /* @__PURE__ */
|
|
125
|
+
style: { zIndex: f },
|
|
126
|
+
onClick: B,
|
|
127
|
+
children: /* @__PURE__ */ a.jsxs(
|
|
88
128
|
"div",
|
|
89
129
|
{
|
|
90
|
-
onClick: (
|
|
91
|
-
className:
|
|
130
|
+
onClick: (g) => g.stopPropagation(),
|
|
131
|
+
className: x(
|
|
92
132
|
"bg-neutral-default-default rounded-lg shadow-lg border-neutral-strong-default border relative ",
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
133
|
+
ue,
|
|
134
|
+
p === "content" ? "" : "prometeo-scrollbar-thin!",
|
|
135
|
+
p === "dialog" && "overflow-auto ",
|
|
136
|
+
p === "content" && "",
|
|
97
137
|
"flex flex-col ",
|
|
98
|
-
|
|
138
|
+
le({ size: re })
|
|
99
139
|
// className
|
|
100
140
|
),
|
|
101
|
-
style:
|
|
141
|
+
style: M,
|
|
102
142
|
children: [
|
|
103
|
-
/* @__PURE__ */
|
|
143
|
+
/* @__PURE__ */ a.jsx(
|
|
104
144
|
"div",
|
|
105
145
|
{
|
|
106
|
-
className:
|
|
146
|
+
className: x(
|
|
107
147
|
"absolute bg-transparent z-[-1] -top-(--safe-margin-size) -left-(--safe-margin-size) -right-(--safe-margin-size) -bottom-(--safe-margin-size)",
|
|
108
|
-
|
|
148
|
+
t && "after:content-['SECURE_MARGIN'] after:text-red-300 after:prometeo-fonts-label-small after:ml-2 "
|
|
109
149
|
),
|
|
110
150
|
style: {
|
|
111
|
-
background:
|
|
112
|
-
border:
|
|
151
|
+
background: t ? "#FF393973" : "auto",
|
|
152
|
+
border: t ? "solid 1px #FF3939" : ""
|
|
113
153
|
}
|
|
114
154
|
}
|
|
115
155
|
),
|
|
116
|
-
/* @__PURE__ */
|
|
156
|
+
/* @__PURE__ */ a.jsxs("div", { className: x(
|
|
117
157
|
"flex flex-col h-auto prometeo-scrollbar-thin!",
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
158
|
+
_ && "flex-1 min-h-0",
|
|
159
|
+
p === "dialog" && "overflow-hidden min-w-max min-h-max",
|
|
160
|
+
p === "content" && "overflow-hidden",
|
|
161
|
+
i
|
|
122
162
|
), children: [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
163
|
+
ce,
|
|
164
|
+
p === "dialog" ? /* @__PURE__ */ a.jsx("div", { className: "flex flex-col flex-1", children: Z }) : Z,
|
|
165
|
+
xe
|
|
126
166
|
] })
|
|
127
167
|
]
|
|
128
168
|
}
|
|
129
169
|
)
|
|
130
170
|
}
|
|
131
171
|
) });
|
|
132
|
-
return
|
|
172
|
+
return s ? ee : Ee(ee, document.body);
|
|
133
173
|
}
|
|
134
174
|
);
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
),
|
|
141
|
-
return /* @__PURE__ */
|
|
175
|
+
oe.displayName = "Dialog";
|
|
176
|
+
const y = D(({ children: r, className: d, debugMode: i, scroll: s, expandX: f, expandY: t, expandWeight: m }) => {
|
|
177
|
+
const E = x(
|
|
178
|
+
f && "w-full min-w-0",
|
|
179
|
+
t && "flex-1 min-h-0"
|
|
180
|
+
), p = t ? { flexGrow: m ?? 1, flexBasis: 0 } : void 0;
|
|
181
|
+
return /* @__PURE__ */ a.jsx("div", { style: p, className: x(
|
|
142
182
|
"flex flex-col p-4 prometeo-scrollbar-thin!",
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
183
|
+
i && "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 ",
|
|
184
|
+
E,
|
|
185
|
+
d,
|
|
146
186
|
// Para scroll='content', este componente necesita su propio scroll y altura mínima
|
|
147
|
-
|
|
187
|
+
s === "content" && "overflow-y-auto min-h-0 flex-1 ",
|
|
148
188
|
// Para scroll='dialog', el contenido debe ocupar todo el espacio disponible pero sin scroll
|
|
149
|
-
|
|
150
|
-
), children:
|
|
189
|
+
s === "dialog" && "flex-1 min-h-max "
|
|
190
|
+
), children: r });
|
|
151
191
|
});
|
|
152
|
-
|
|
153
|
-
const w =
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
192
|
+
y.displayName = "DialogContent";
|
|
193
|
+
const w = D(({ children: r, className: d, debugMode: i, expandX: s, expandY: f }) => {
|
|
194
|
+
const t = x(
|
|
195
|
+
s && "w-full min-w-0",
|
|
196
|
+
f && "flex-1 min-h-0"
|
|
157
197
|
);
|
|
158
|
-
return /* @__PURE__ */
|
|
198
|
+
return /* @__PURE__ */ a.jsx("h1", { className: x("prometeo-fonts-headline-small text-neutral-strong-default w-max", i && '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', t, d), children: r });
|
|
159
199
|
});
|
|
160
200
|
w.displayName = "DialogTitle";
|
|
161
|
-
const
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
),
|
|
166
|
-
return /* @__PURE__ */
|
|
201
|
+
const C = D(({ children: r, className: d, title: i, debugMode: s, expandX: f, expandY: t, expandWeight: m }) => {
|
|
202
|
+
const E = x(
|
|
203
|
+
f && "w-full min-w-0",
|
|
204
|
+
t && "flex-1 min-h-0"
|
|
205
|
+
), p = t ? { flexGrow: m ?? 1, flexBasis: 0 } : void 0;
|
|
206
|
+
return /* @__PURE__ */ a.jsxs("div", { style: p, className: x(
|
|
167
207
|
"px-6 pt-8 pb-4 flex flex-col",
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
208
|
+
E,
|
|
209
|
+
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",
|
|
210
|
+
d
|
|
171
211
|
), children: [
|
|
172
|
-
|
|
173
|
-
|
|
212
|
+
i && /* @__PURE__ */ a.jsx(w, { debugMode: s, children: i }),
|
|
213
|
+
r
|
|
174
214
|
] });
|
|
175
215
|
});
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
),
|
|
182
|
-
return /* @__PURE__ */
|
|
183
|
-
|
|
184
|
-
"border-t border-neutral-strong-default p-4 w-full flex",
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
), children:
|
|
216
|
+
C.displayName = "DialogHeader";
|
|
217
|
+
const b = D(({ children: r, className: d, debugMode: i, expandX: s, expandY: f, expandWeight: t }) => {
|
|
218
|
+
const m = x(
|
|
219
|
+
s && "w-full min-w-0",
|
|
220
|
+
f && "flex-1 min-h-0 flex-col"
|
|
221
|
+
), E = f ? { flexGrow: t ?? 1, flexBasis: 0 } : void 0;
|
|
222
|
+
return /* @__PURE__ */ a.jsx("div", { style: E, className: x(
|
|
223
|
+
i && "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",
|
|
224
|
+
"border-t border-neutral-strong-default p-4 w-full flex flex-row justify-end",
|
|
225
|
+
m,
|
|
226
|
+
d
|
|
227
|
+
), children: r });
|
|
188
228
|
});
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
Content:
|
|
192
|
-
Header:
|
|
193
|
-
Footer:
|
|
229
|
+
b.displayName = "DialogFooter";
|
|
230
|
+
const ye = Object.assign(oe, {
|
|
231
|
+
Content: y,
|
|
232
|
+
Header: C,
|
|
233
|
+
Footer: b,
|
|
194
234
|
Title: w
|
|
195
235
|
});
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
}, []),
|
|
201
|
-
|
|
202
|
-
}, []),
|
|
236
|
+
ye.displayName = "DialogModal";
|
|
237
|
+
const Ie = () => {
|
|
238
|
+
const r = A(null), d = v((t) => {
|
|
239
|
+
r.current?.open(t);
|
|
240
|
+
}, []), i = v(() => {
|
|
241
|
+
r.current?.close();
|
|
242
|
+
}, []), s = v(() => r.current?.isOpen ?? !1, []), f = v(() => r.current?.getContext() ?? null, []);
|
|
203
243
|
return {
|
|
204
|
-
ref:
|
|
205
|
-
open:
|
|
206
|
-
close:
|
|
207
|
-
isOpen:
|
|
208
|
-
getContext:
|
|
244
|
+
ref: r,
|
|
245
|
+
open: d,
|
|
246
|
+
close: i,
|
|
247
|
+
isOpen: s,
|
|
248
|
+
getContext: f
|
|
209
249
|
};
|
|
210
250
|
};
|
|
211
251
|
export {
|
|
212
|
-
|
|
213
|
-
|
|
252
|
+
ye as default,
|
|
253
|
+
Ie as useDialogControl
|
|
214
254
|
};
|