prometeo-design-system 5.0.2 → 5.1.1

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