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.
Files changed (2) hide show
  1. package/dist/DialogModal.es.js +123 -112
  2. package/package.json +1 -1
@@ -1,162 +1,173 @@
1
- import { j as t } from "./jsx-runtime-DKDX3adD.js";
2
- import { forwardRef as _, memo as b, useState as H, useRef as R, useCallback as p, useImperativeHandle as $, Children as q, isValidElement as I } from "react";
3
- import { createPortal as B } from "react-dom";
4
- import { c } from "./cn-B6yFEsav.js";
5
- const A = _(
6
- ({ children: r, onClose: a, className: n, attachToParent: o = !1, zindex: y = 40, debugMode: l = !1, safeMarginSize: S = 24, title: j, scroll: x = "content" }, G) => {
7
- const [C, F] = H(!1), [v, T] = H(null), z = R(a), N = R(v);
8
- z.current = a, N.current = v;
9
- const O = p((e) => {
10
- T(e ?? null), F(!0);
11
- }, []), D = p(() => {
12
- F(!1), z.current?.(N.current), setTimeout(() => T(null), 300);
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
- G,
14
+ W(
15
+ $,
16
16
  () => ({
17
- open: O,
18
- close: D,
19
- isOpen: C,
20
- getContext: () => N.current
17
+ open: P,
18
+ close: E,
19
+ isOpen: N,
20
+ getContext: () => w.current
21
21
  }),
22
- [O, D, C]
22
+ [P, E, N]
23
23
  );
24
- const L = `max-[500px]:max-w-[calc(100%-32px)]
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]`, U = typeof r == "function" ? r(v) : r, V = q.toArray(U);
27
- let s = null, u = null, w = null;
28
- const h = [];
29
- let E = null;
30
- if (V.forEach((e) => {
31
- if (!I(e)) {
32
- h.push(e);
33
- return;
34
- }
35
- if (e.type === g && !j) {
36
- u = e;
37
- return;
38
- }
39
- if (e.type === i && !s) {
40
- const f = e.props;
41
- s = /* @__PURE__ */ t.jsx(i, { ...f, debugMode: l, children: f.children });
42
- return;
43
- }
44
- if (e.type === d && !w) {
45
- const f = e.props;
46
- w = /* @__PURE__ */ t.jsx(d, { ...f, debugMode: l, scroll: x, children: f.children });
47
- return;
48
- }
49
- if (e.type === m && !E) {
50
- const f = e.props;
51
- E = /* @__PURE__ */ t.jsx(m, { ...f, debugMode: l, children: f.children });
52
- return;
53
- }
54
- e.type !== i && e.type !== d && e.type !== m && e.type !== g && h.push(e);
55
- }), !s && j && (s = /* @__PURE__ */ t.jsx(i, { title: j, debugMode: l }), u = null), s && u && I(s)) {
56
- const e = s.props;
57
- e.title && (s = /* @__PURE__ */ t.jsx(i, { ...e, title: "", debugMode: l, children: u }), u = null);
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 k = w ?? (h.length ? /* @__PURE__ */ t.jsx(d, { debugMode: l, scroll: x, children: h }) : null), P = /* @__PURE__ */ t.jsx(t.Fragment, { children: C && /* @__PURE__ */ t.jsx(
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: y },
64
- onClick: D,
65
- children: /* @__PURE__ */ t.jsxs(
74
+ style: { zIndex: v },
75
+ onClick: E,
76
+ children: /* @__PURE__ */ e.jsxs(
66
77
  "div",
67
78
  {
68
- onClick: (e) => e.stopPropagation(),
69
- className: c(
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
- L,
74
- n
84
+ q,
85
+ o
75
86
  ),
76
87
  style: {
77
- "--safe-margin-size": `${S}px`
88
+ "--safe-margin-size": `${_}px`
78
89
  },
79
90
  children: [
80
- /* @__PURE__ */ t.jsx(
91
+ /* @__PURE__ */ e.jsx(
81
92
  "div",
82
93
  {
83
- className: c(
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
- l && "after:content-['SECURE_MARGIN'] after:text-red-300 after:prometeo-fonts-label-small after:ml-2 "
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: l ? "#FF393973" : "auto",
89
- border: l ? "solid 1px #FF3939" : ""
99
+ background: a ? "#FF393973" : "auto",
100
+ border: a ? "solid 1px #FF3939" : ""
90
101
  }
91
102
  }
92
103
  ),
93
- /* @__PURE__ */ t.jsxs("div", { className: c(
104
+ /* @__PURE__ */ e.jsxs("div", { className: p(
94
105
  "flex flex-col h-full",
95
- x === "dialog" && "overflow-y-auto",
96
- x === "content" && "overflow-hidden"
106
+ m === "dialog" && "overflow-y-auto",
107
+ m === "content" && "overflow-hidden"
97
108
  ), children: [
98
- s,
99
- x === "dialog" ? /* @__PURE__ */ t.jsx("div", { className: "flex flex-col flex-1", children: k }) : k,
100
- E
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 o ? P : B(P, document.body);
118
+ return s ? I : X(I, document.body);
108
119
  }
109
120
  );
110
- A.displayName = "Dialog";
111
- const d = b(({ children: r, className: a, debugMode: n, scroll: o }) => /* @__PURE__ */ t.jsx("div", { className: c(
112
- "flex flex-col gap-4 p-4",
113
- n && "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 ",
114
- a,
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
- o === "content" && "overflow-y-auto min-h-0 flex-1 ",
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
- o === "dialog" && "flex-1 min-h-max "
119
- ), children: r }));
120
- d.displayName = "DialogContent";
121
- const g = b(({ children: r, className: a, debugMode: n }) => /* @__PURE__ */ t.jsx("h1", { className: c("prometeo-fonts-headline-small text-neutral-strong-default w-max", n && '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', a), children: r }));
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 i = b(({ children: r, className: a, title: n, debugMode: o }) => /* @__PURE__ */ t.jsxs("div", { className: c(
134
+ const d = j(({ children: t, className: n, title: o, debugMode: s }) => /* @__PURE__ */ e.jsxs("div", { className: p(
124
135
  "p-4",
125
- o && "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",
126
- a
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
- n && /* @__PURE__ */ t.jsx(g, { debugMode: o, children: n }),
129
- r
139
+ o && /* @__PURE__ */ e.jsx(g, { debugMode: s, children: o }),
140
+ t
130
141
  ] }));
131
- i.displayName = "DialogHeader";
132
- const m = b(({ children: r, className: a, debugMode: n }) => /* @__PURE__ */ t.jsx("div", { className: c(
133
- n && "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",
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
- a
136
- ), children: r }));
137
- m.displayName = "DialogFooter";
138
- const J = Object.assign(A, {
139
- Content: d,
140
- Header: i,
141
- Footer: m,
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
- J.displayName = "DialogModal";
145
- const Y = () => {
146
- const r = R(null), a = p((l) => {
147
- r.current?.open(l);
148
- }, []), n = p(() => {
149
- r.current?.close();
150
- }, []), o = p(() => r.current?.isOpen ?? !1, []), y = p(() => r.current?.getContext() ?? null, []);
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: r,
153
- open: a,
154
- close: n,
155
- isOpen: o,
156
- getContext: y
163
+ ref: t,
164
+ open: n,
165
+ close: o,
166
+ isOpen: s,
167
+ getContext: v
157
168
  };
158
169
  };
159
170
  export {
160
- J as default,
161
- Y as useDialogControl
171
+ Y as default,
172
+ re as useDialogControl
162
173
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prometeo-design-system",
3
3
  "private": false,
4
- "version": "4.6.4",
4
+ "version": "4.6.5",
5
5
  "type": "module",
6
6
  "description": "design kit system",
7
7
  "main": "dist/prometeo-design-system.umd.js",