prometeo-design-system 6.3.8 → 6.4.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.
@@ -1,119 +1,120 @@
1
- import { j as m } from "./jsx-runtime-GkKLlHH4.js";
2
- import { c as R } from "./cn-B6yFEsav.js";
3
- import { c as j } from "./index-BOQuZ0gG.js";
1
+ import { j as l } from "./jsx-runtime-GkKLlHH4.js";
2
+ import { c as k } from "./cn-B6yFEsav.js";
3
+ import { c as R } from "./index-BOQuZ0gG.js";
4
4
  import { createPortal as B } from "react-dom";
5
- import { forwardRef as L, useRef as p, useState as v, useEffect as a, useCallback as x, useImperativeHandle as Y } from "react";
5
+ import { forwardRef as L, useRef as d, useState as O, useEffect as o, useCallback as N, useImperativeHandle as Y } from "react";
6
6
  import F from "./Button.es.js";
7
7
  import { Close as H } from "./Icons/Close.es.js";
8
- const $ = L((t, i) => {
9
- const l = p(null), [e, u] = v(t.defaultOpen || !1), [r, s] = v(null), d = p(t.onClose), c = p(r), b = p(/* @__PURE__ */ new Set()), {
10
- modal: y = !1,
11
- children: f,
12
- className: g,
13
- direction: O = "left",
14
- attachToParent: h = !1,
15
- closeOnOverlayClick: n = !1,
16
- hideCloseButton: N = !1,
17
- unmountChildrenOnClose: C = !1,
18
- zindex: T = 35
19
- } = t, k = p(n), D = p(e);
20
- c.current = r;
21
- const [V, P] = v(() => !C);
22
- a(() => {
23
- C && e && P(!0);
24
- }, [e, C]), a(() => {
25
- D.current = e;
26
- }, [e]), a(() => {
27
- c.current = r;
28
- }, [r]), a(() => {
29
- k.current = n;
30
- }, [n]);
31
- const I = (o) => {
32
- if (!l.current)
8
+ import { u as Z } from "./useDrawerControl-Cy-mkJxV.js";
9
+ const $ = L((s, f) => {
10
+ const c = d(null), [e, m] = O(s.defaultOpen || !1), [t, y] = O(null), b = d(s.onClose), i = d(t), u = d(/* @__PURE__ */ new Set()), {
11
+ modal: p = !1,
12
+ children: a,
13
+ className: w,
14
+ direction: C = "left",
15
+ attachToParent: x = !1,
16
+ closeOnOverlayClick: r = !1,
17
+ hideCloseButton: T = !1,
18
+ unmountChildrenOnClose: h = !1,
19
+ zindex: S = 35
20
+ } = s, g = d(r), j = d(e);
21
+ i.current = t;
22
+ const [V, P] = O(() => !h);
23
+ o(() => {
24
+ h && e && P(!0);
25
+ }, [e, h]), o(() => {
26
+ j.current = e;
27
+ }, [e]), o(() => {
28
+ i.current = t;
29
+ }, [t]), o(() => {
30
+ g.current = r;
31
+ }, [r]);
32
+ const z = (n) => {
33
+ if (!c.current)
33
34
  return;
34
- const E = l.current;
35
- E && !E.contains(o.target) && k.current && D.current && w();
35
+ const E = c.current;
36
+ E && !E.contains(n.target) && g.current && j.current && v();
36
37
  };
37
- a(() => {
38
- if (!k.current || y || !e)
38
+ o(() => {
39
+ if (!g.current || p || !e)
39
40
  return;
40
- const o = setTimeout(() => {
41
- document.addEventListener("click", I);
41
+ const n = setTimeout(() => {
42
+ document.addEventListener("click", z);
42
43
  }, 0);
43
44
  return () => {
44
- clearTimeout(o), document.removeEventListener("click", I);
45
+ clearTimeout(n), document.removeEventListener("click", z);
45
46
  };
46
- }, [n, e, y]), a(() => {
47
- d.current = t.onClose;
48
- }, [t.onClose]);
49
- const z = x((o) => {
50
- s(o ?? null), u(!0);
51
- }, []), w = x(() => {
52
- u(!1), d.current?.(c.current), setTimeout(() => s(null), 300);
47
+ }, [r, e, p]), o(() => {
48
+ b.current = s.onClose;
49
+ }, [s.onClose]);
50
+ const D = N((n) => {
51
+ y(n ?? null), m(!0);
52
+ }, []), v = N(() => {
53
+ m(!1), b.current?.(i.current), setTimeout(() => y(null), 300);
53
54
  }, []);
54
- a(() => {
55
- b.current.forEach((o) => {
55
+ o(() => {
56
+ u.current.forEach((n) => {
56
57
  try {
57
- o(e);
58
+ n(e);
58
59
  } catch {
59
60
  }
60
61
  });
61
62
  }, [e]), Y(
62
- i,
63
+ f,
63
64
  () => ({
64
- open: z,
65
- close: w,
65
+ open: D,
66
+ close: v,
66
67
  isOpen: e,
67
- subscribeOpenChange: (o) => (b.current.add(o), () => {
68
- b.current.delete(o);
68
+ subscribeOpenChange: (n) => (u.current.add(n), () => {
69
+ u.current.delete(n);
69
70
  }),
70
- getContext: () => c.current
71
+ getContext: () => i.current
71
72
  }),
72
- [e, z, w]
73
+ [e, D, v]
73
74
  );
74
- const S = /* @__PURE__ */ m.jsx(
75
+ const I = /* @__PURE__ */ l.jsx(
75
76
  q,
76
77
  {
77
- context: r,
78
- ref: l,
78
+ context: t,
79
+ ref: c,
79
80
  isOpen: e,
80
- close: w,
81
- direction: O,
82
- modal: y,
83
- className: g,
84
- attachToParent: h,
85
- closeOnOverlayClick: n,
86
- hideCloseButton: N,
87
- zindex: T,
88
- children: (!C || V) && (typeof f == "function" ? f(r) : f)
81
+ close: v,
82
+ direction: C,
83
+ modal: p,
84
+ className: w,
85
+ attachToParent: x,
86
+ closeOnOverlayClick: r,
87
+ hideCloseButton: T,
88
+ zindex: S,
89
+ children: (!h || V) && (typeof a == "function" ? a(t) : a)
89
90
  }
90
91
  );
91
- return h ? S : B(S, document.body);
92
+ return x ? I : B(I, document.body);
92
93
  });
93
94
  $.displayName = "DrawerDesktopV2";
94
95
  const q = ({
95
- ref: t,
96
- children: i,
97
- direction: l = "left",
96
+ ref: s,
97
+ children: f,
98
+ direction: c = "left",
98
99
  isOpen: e,
99
- close: u,
100
- modal: r = !1,
101
- className: s,
102
- attachToParent: d = !1,
103
- closeOnOverlayClick: c = !1,
104
- hideCloseButton: b = !1,
105
- context: y,
106
- zindex: f = 499
100
+ close: m,
101
+ modal: t = !1,
102
+ className: y,
103
+ attachToParent: b = !1,
104
+ closeOnOverlayClick: i = !1,
105
+ hideCloseButton: u = !1,
106
+ context: p,
107
+ zindex: a = 499
107
108
  }) => {
108
- a(() => {
109
- if (e && r) {
110
- const n = window.scrollY;
111
- return document.body.style.position = "fixed", document.body.style.top = `-${n}px`, document.body.style.width = "100%", () => {
112
- document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", window.scrollTo(0, n);
109
+ o(() => {
110
+ if (e && t) {
111
+ const r = window.scrollY;
112
+ return document.body.style.position = "fixed", document.body.style.top = `-${r}px`, document.body.style.width = "100%", () => {
113
+ document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", window.scrollTo(0, r);
113
114
  };
114
115
  }
115
- }, [e, r]);
116
- const g = j("border-neutral-strong-default", {
116
+ }, [e, t]);
117
+ const w = R("border-neutral-strong-default", {
117
118
  variants: {
118
119
  isOpen: {
119
120
  true: "desktop-drawer-visible",
@@ -124,7 +125,7 @@ const q = ({
124
125
  right: "right-0 border-l-[1px] border-r-0"
125
126
  }
126
127
  }
127
- }), O = j(
128
+ }), C = R(
128
129
  "fixed inset-0 bg-black/60 z-[55] cursor-default",
129
130
  {
130
131
  variants: {
@@ -134,7 +135,7 @@ const q = ({
134
135
  }
135
136
  }
136
137
  }
137
- ), h = j("", {
138
+ ), x = R("", {
138
139
  variants: {
139
140
  direction: {
140
141
  left: "right-0",
@@ -142,82 +143,60 @@ const q = ({
142
143
  }
143
144
  }
144
145
  });
145
- return /* @__PURE__ */ m.jsxs(m.Fragment, { children: [
146
- r && /* @__PURE__ */ m.jsx(
146
+ return /* @__PURE__ */ l.jsxs(l.Fragment, { children: [
147
+ t && /* @__PURE__ */ l.jsx(
147
148
  "div",
148
149
  {
149
- className: R(O({ isOpen: e })),
150
- style: { zIndex: f },
151
- onClick: (n) => {
152
- n.preventDefault(), n.stopPropagation(), c && u();
150
+ className: k(C({ isOpen: e })),
151
+ style: { zIndex: a },
152
+ onClick: (r) => {
153
+ r.preventDefault(), r.stopPropagation(), i && m();
153
154
  },
154
155
  "aria-hidden": "true"
155
156
  }
156
157
  ),
157
- /* @__PURE__ */ m.jsxs(
158
+ /* @__PURE__ */ l.jsxs(
158
159
  "div",
159
160
  {
160
- ref: t,
161
- className: R(
161
+ ref: s,
162
+ className: k(
162
163
  "bg-neutral-strong-default h-full top-0 z-60 w-max overflow-y-auto",
163
- d ? "absolute" : "fixed",
164
- g({ isOpen: e, direction: l }),
165
- !b && "p-4 pt-10",
166
- s
164
+ b ? "absolute" : "fixed",
165
+ w({ isOpen: e, direction: c }),
166
+ !u && "p-4 pt-10",
167
+ y
167
168
  ),
168
169
  role: "dialog",
169
- "aria-modal": r,
170
- style: { zIndex: f + 1 },
170
+ "aria-modal": t,
171
+ style: { zIndex: a + 1 },
171
172
  children: [
172
- !b && /* @__PURE__ */ m.jsx(
173
+ !u && /* @__PURE__ */ l.jsx(
173
174
  F,
174
175
  {
175
- icon: /* @__PURE__ */ m.jsx(H, { size: 24 }),
176
+ icon: /* @__PURE__ */ l.jsx(H, { size: 24 }),
176
177
  animate: !1,
177
178
  animateIcon: !1,
178
179
  type: "button",
179
180
  size: "small",
180
181
  variant: "text",
181
- onClick: u,
182
+ onClick: m,
182
183
  label: "",
183
184
  color: "secondary",
184
- className: R(
185
+ className: k(
185
186
  "absolute top-0 z-50",
186
- h({ direction: l })
187
+ x({ direction: c })
187
188
  ),
188
189
  "aria-label": "Close drawer",
189
- style: { zIndex: f + 2 }
190
+ style: { zIndex: a + 2 }
190
191
  }
191
192
  ),
192
- typeof i == "function" ? i(y) : i
193
+ typeof f == "function" ? f(p) : f
193
194
  ]
194
195
  }
195
196
  )
196
197
  ] });
197
- }, W = () => {
198
- const t = p(null), [i, l] = v(!1), e = x((s) => {
199
- t.current?.open(s);
200
- }, []), u = x(() => {
201
- t.current?.close();
202
- }, []), r = x(() => t.current?.getContext() ?? null, []);
203
- return a(() => {
204
- const s = t.current?.subscribeOpenChange;
205
- if (!s) return;
206
- const d = s((c) => {
207
- l(c);
208
- });
209
- return () => {
210
- d && d();
211
- };
212
- }, [t.current?.subscribeOpenChange]), {
213
- isOpen: i,
214
- open: e,
215
- close: u,
216
- drawerRef: t,
217
- getContext: r
218
- };
219
198
  };
220
199
  export {
221
200
  $ as default,
222
- W as useDrawerDesktop
201
+ Z as useDrawerControl
223
202
  };