prometeo-design-system 5.1.0 → 5.2.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.
@@ -97,7 +97,6 @@ const oe = he(
97
97
  key: Math.random(),
98
98
  ...l,
99
99
  className: x(l?.className, "contents")
100
- // display: contents
101
100
  }, ...O);
102
101
  }
103
102
  if (l?.children) {
@@ -221,7 +220,7 @@ const b = D(({ children: r, className: d, debugMode: i, expandX: s, expandY: f,
221
220
  ), E = f ? { flexGrow: t ?? 1, flexBasis: 0 } : void 0;
222
221
  return /* @__PURE__ */ a.jsx("div", { style: E, className: x(
223
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",
224
- "border-t border-neutral-strong-default p-4 w-full flex flex-row justify-end",
223
+ "border-t border-neutral-strong-default p-4 w-full flex flex-row justify-end gap-4",
225
224
  m,
226
225
  d
227
226
  ), children: r });
@@ -1,77 +1,92 @@
1
- import { j as m } from "./jsx-runtime-GkKLlHH4.js";
1
+ import { j as w } from "./jsx-runtime-GkKLlHH4.js";
2
2
  import { c as _ } from "./cn-B6yFEsav.js";
3
- import { forwardRef as V, useState as $, useRef as w, useEffect as y, useCallback as c, useMemo as Q, useImperativeHandle as X } from "react";
4
- import { createPortal as Z } from "react-dom";
5
- const B = 44, P = "height 0.5s cubic-bezier(0.32, 0.72, 0, 1)", se = V((l, o) => {
6
- const { children: D, defaultOpen: s = !1, onClose: g, snapPoints: v = ["60%"], setSnap: d, snap: u, attachToParent: x = !1 } = l, [R, Y] = $(u || "0%"), [M, r] = $(null), k = w(g), O = w(d), f = w(M), p = w(/* @__PURE__ */ new Set());
7
- k.current = g, f.current = M, y(() => {
8
- s && S();
9
- }, [s]), y(() => {
10
- O.current = d;
11
- }, [d]);
12
- const j = c(() => {
13
- Y("0%"), k.current?.(f.current), setTimeout(() => r(null), 300);
14
- }, []), S = c((h, T) => {
15
- Y(h || v[0] || "60%"), r(T ?? null);
16
- }, [v]), H = Q(() => R !== "0%", [R]);
17
- y(() => {
18
- p.current.forEach((h) => {
3
+ import { forwardRef as P, useState as $, useRef as p, useEffect as H, useCallback as l, useMemo as X, useImperativeHandle as ee } from "react";
4
+ import { createPortal as te } from "react-dom";
5
+ const J = 44, ne = "height 0.5s cubic-bezier(0.32, 0.72, 0, 1)", ce = P((u, s) => {
6
+ const { children: M, defaultOpen: o = !1, onClose: h, snapPoints: d = ["auto"], setSnap: g, snap: a, attachToParent: m = !1 } = u, [j, S] = $(a || "0%"), [L, r] = $(null), D = p(h), O = p(g), f = p(L), b = p(/* @__PURE__ */ new Set());
7
+ D.current = h, f.current = L, H(() => {
8
+ o && R();
9
+ }, [o]), H(() => {
10
+ O.current = g;
11
+ }, [g]);
12
+ const F = l(() => {
13
+ S("0%"), D.current?.(f.current), setTimeout(() => r(null), 300);
14
+ }, []), R = l((y, T) => {
15
+ S(y || d[0] || "60%"), r(T ?? null);
16
+ }, [d]), E = X(() => j !== "0%", [j]);
17
+ H(() => {
18
+ b.current.forEach((y) => {
19
19
  try {
20
- h(H);
20
+ y(E);
21
21
  } catch {
22
22
  }
23
23
  });
24
- }, [H]), X(o, () => ({
25
- open: S,
26
- close: j,
27
- isOpen: H,
28
- subscribeOpenChange: (h) => (p.current.add(h), () => {
29
- p.current.delete(h);
24
+ }, [E]), ee(s, () => ({
25
+ open: R,
26
+ close: F,
27
+ isOpen: E,
28
+ subscribeOpenChange: (y) => (b.current.add(y), () => {
29
+ b.current.delete(y);
30
30
  }),
31
31
  getContext: () => f.current
32
- }), [S, j, H]);
33
- const F = u || R;
34
- return x ? /* @__PURE__ */ m.jsx(K, { ...l, snap: F, setSnap: Y, context: M, children: D }) : Z(/* @__PURE__ */ m.jsx(K, { ...l, snap: F, setSnap: Y, context: M, children: D }), document.body);
35
- }), K = ({ children: l, attachToParent: o = !1, className: D, snap: s, snapPoints: g = ["60%"], setSnap: v, hideOnClose: d = !1, unmountChildrenOnClose: u = !1, header: x, modal: R = !1, closeOnOverlayClick: Y = !1, context: M }) => {
36
- const r = w(null), k = w(null), O = w(null), f = w(null), p = w(null), j = c(() => {
32
+ }), [R, F, E]);
33
+ const N = a || j;
34
+ return m ? /* @__PURE__ */ w.jsx(V, { ...u, snap: N, setSnap: S, context: L, children: M }) : te(/* @__PURE__ */ w.jsx(V, { ...u, snap: N, setSnap: S, context: L, children: M }), document.body);
35
+ }), V = ({ children: u, attachToParent: s = !1, className: M, snap: o, snapPoints: h = ["60%"], setSnap: d, hideOnClose: g = !1, unmountChildrenOnClose: a = !1, header: m, modal: j = !1, closeOnOverlayClick: S = !1, context: L }) => {
36
+ const r = p(null), D = p(null), O = p(null), f = p(null), b = p(null), F = l(() => {
37
37
  if (!r.current) return [];
38
- const e = o && r.current.parentElement?.offsetHeight || window.innerHeight;
39
- return g?.map((t) => typeof t == "string" && t.endsWith("%") ? parseFloat(t) > 100 ? e : parseFloat(t) / 100 * e : typeof t == "string" && t.endsWith("px") ? parseFloat(t) : typeof t == "number" && t >= 0 && t <= 1 ? t * e : typeof t == "number" ? t : 0) || [];
40
- }, [g, o]), S = c((e, t) => {
41
- const n = j();
38
+ const e = s && r.current.parentElement?.offsetHeight || window.innerHeight;
39
+ return h?.filter((t) => t !== "auto").map((t) => typeof t == "string" && t.endsWith("%") ? parseFloat(t) > 100 ? e : parseFloat(t) / 100 * e : typeof t == "string" && t.endsWith("px") ? parseFloat(t) : typeof t == "number" && t >= 0 && t <= 1 ? t * e : typeof t == "number" ? t : 0) || [];
40
+ }, [h, s]), R = l(() => (m ? 88 : 44) + 16, [m]), E = l(() => D.current?.scrollHeight ?? 0, []), N = l((e, t, n) => {
41
+ const v = n + t, i = Math.min(100, v / e * 100);
42
+ return `${Math.round(i)}%`;
43
+ }, []), z = l((e, t) => {
44
+ const n = F();
42
45
  if (n.length === 0) return e;
43
46
  if (Math.abs(t) > 0.05)
44
47
  if (t > 0) {
45
- const a = n.filter((i) => i < e);
46
- return a.length > 0 ? Math.max(...a) : d ? 0 : B;
48
+ const i = n.filter((c) => c < e);
49
+ return i.length > 0 ? Math.max(...i) : g ? 0 : J;
47
50
  } else {
48
- const a = n.filter((i) => i > e);
49
- if (a.length > 0)
50
- return Math.min(...a);
51
+ const i = n.filter((c) => c > e);
52
+ if (i.length > 0)
53
+ return Math.min(...i);
51
54
  }
52
- return n.reduce((a, i) => Math.abs(i - e) < Math.abs(a - e) ? i : a);
53
- }, [j]), H = c((e) => {
54
- if (v && g) {
55
- const t = o && r.current?.parentElement?.offsetHeight || window.innerHeight, n = e <= B ? "0%" : `${Math.round(e / t * 100)}%`;
56
- v(n);
55
+ return n.reduce((i, c) => Math.abs(c - e) < Math.abs(i - e) ? c : i);
56
+ }, [F]), y = l((e) => {
57
+ if (d && h) {
58
+ const t = s && r.current?.parentElement?.offsetHeight || window.innerHeight, n = e <= J ? "0%" : `${Math.round(e / t * 100)}%`;
59
+ d(n);
57
60
  }
58
- }, [v, g, o]), F = c((e) => {
59
- r.current && (r.current.style.transition = P, r.current.style.height = `${e}px`);
60
- }, [v, g, o]), N = c(() => {
61
- if (p.current && o) {
62
- const { scrollY: e } = p.current;
63
- document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", window.scrollTo(0, e), p.current = null;
61
+ }, [d, h, s]), T = l((e) => {
62
+ r.current && (r.current.style.transition = ne, r.current.style.height = `${e}px`);
63
+ }, [d, h, s]), k = l(() => {
64
+ if (b.current && s) {
65
+ const { scrollY: e } = b.current;
66
+ document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", window.scrollTo(0, e), b.current = null;
67
+ }
68
+ }, [s]);
69
+ H(() => () => {
70
+ k();
71
+ }, [k]), H(() => {
72
+ if (!r.current || !o) return;
73
+ const e = s && r.current.parentElement?.offsetHeight || window.innerHeight;
74
+ if (o === "auto") {
75
+ T(e), requestAnimationFrame(() => {
76
+ requestAnimationFrame(() => {
77
+ if (D.current && D.current.children.length > 0) {
78
+ const n = E(), v = R(), i = N(e, n, v);
79
+ d(i);
80
+ } else
81
+ d("100%");
82
+ });
83
+ });
84
+ return;
64
85
  }
65
- }, [o]);
66
- y(() => () => {
67
- N();
68
- }, [N]), y(() => {
69
- if (!r.current || !s) return;
70
- const e = o && r.current.parentElement?.offsetHeight || window.innerHeight;
71
86
  let t = 0;
72
- typeof s == "string" && s.endsWith("%") ? parseFloat(s) <= 0 ? t = d ? 0 : B : t = parseFloat(s) / 100 * e : typeof s == "string" && s.endsWith("px") ? t = parseFloat(s) : typeof s == "number" && (s >= 0 && s <= 1 ? t = s * e : t = s), F(t);
73
- }, [s, o]);
74
- const h = c((e) => {
87
+ typeof o == "string" && o.endsWith("%") ? parseFloat(o) <= 0 ? t = g ? 0 : J : t = parseFloat(o) / 100 * e : typeof o == "string" && o.endsWith("px") ? t = parseFloat(o) : typeof o == "number" && (o >= 0 && o <= 1 ? t = o * e : t = o), T(t);
88
+ }, [o, s, E, R, N, d]);
89
+ const A = l((e) => {
75
90
  if (!r.current) return;
76
91
  const t = e.touches[0], n = r.current.offsetHeight;
77
92
  f.current = {
@@ -82,7 +97,7 @@ const B = 44, P = "height 0.5s cubic-bezier(0.32, 0.72, 0, 1)", se = V((l, o) =>
82
97
  lastTime: Date.now(),
83
98
  velocity: 0
84
99
  };
85
- }, []), T = c((e) => {
100
+ }, []), K = l((e) => {
86
101
  if (!r.current) return;
87
102
  const t = e, n = r.current.offsetHeight;
88
103
  f.current = {
@@ -93,152 +108,152 @@ const B = 44, P = "height 0.5s cubic-bezier(0.32, 0.72, 0, 1)", se = V((l, o) =>
93
108
  lastTime: Date.now(),
94
109
  velocity: 0
95
110
  };
96
- }, []), z = c((e) => {
111
+ }, []), C = l((e) => {
97
112
  if (!f.current || !r.current) return;
98
- const t = e.touches[0], n = f.current, L = n.startY - t.clientY, a = n.isDragging || Math.abs(L) > 5;
99
- if (!n.isDragging && a && (n.isDragging = !0, o)) {
100
- const i = window.scrollY;
101
- p.current = { scrollY: i }, document.body.style.position = "fixed", document.body.style.top = `-${i}px`, document.body.style.width = "100%";
113
+ const t = e.touches[0], n = f.current, v = n.startY - t.clientY, i = n.isDragging || Math.abs(v) > 5;
114
+ if (!n.isDragging && i && (n.isDragging = !0, s)) {
115
+ const c = window.scrollY;
116
+ b.current = { scrollY: c }, document.body.style.position = "fixed", document.body.style.top = `-${c}px`, document.body.style.width = "100%";
102
117
  }
103
- if (a) {
118
+ if (i) {
104
119
  e.preventDefault();
105
- const i = Date.now(), I = i - n.lastTime;
120
+ const c = Date.now(), I = c - n.lastTime;
106
121
  if (I > 0) {
107
- const A = (t.clientY - n.lastY) / I;
108
- n.velocity = n.velocity * 0.8 + A * 0.2;
122
+ const q = (t.clientY - n.lastY) / I;
123
+ n.velocity = n.velocity * 0.8 + q * 0.2;
109
124
  }
110
- n.lastY = t.clientY, n.lastTime = i;
111
- const C = n.startHeight + L, G = o && r.current.parentElement?.offsetHeight || window.innerHeight, W = Math.max(0, Math.min(C, G));
112
- r.current.style.transition = "none", r.current.style.height = `${W}px`;
125
+ n.lastY = t.clientY, n.lastTime = c;
126
+ const G = n.startHeight + v, W = s && r.current.parentElement?.offsetHeight || window.innerHeight, B = Math.max(0, Math.min(G, W));
127
+ r.current.style.transition = "none", r.current.style.height = `${B}px`;
113
128
  }
114
- }, [o]), q = c((e) => {
129
+ }, [s]), Q = l((e) => {
115
130
  if (!f.current || !r.current) return;
116
- const t = e, n = f.current, L = n.startY - t.clientY, a = n.isDragging || Math.abs(L) > 5;
117
- if (!n.isDragging && a && (n.isDragging = !0, o)) {
118
- const i = window.scrollY;
119
- p.current = { scrollY: i }, document.body.style.position = "fixed", document.body.style.top = `-${i}px`, document.body.style.width = "100%";
131
+ const t = e, n = f.current, v = n.startY - t.clientY, i = n.isDragging || Math.abs(v) > 5;
132
+ if (!n.isDragging && i && (n.isDragging = !0, s)) {
133
+ const c = window.scrollY;
134
+ b.current = { scrollY: c }, document.body.style.position = "fixed", document.body.style.top = `-${c}px`, document.body.style.width = "100%";
120
135
  }
121
- if (a) {
136
+ if (i) {
122
137
  e.preventDefault();
123
- const i = Date.now(), I = i - n.lastTime;
138
+ const c = Date.now(), I = c - n.lastTime;
124
139
  if (I > 0) {
125
- const A = (t.clientY - n.lastY) / I;
126
- n.velocity = n.velocity * 0.8 + A * 0.2;
140
+ const q = (t.clientY - n.lastY) / I;
141
+ n.velocity = n.velocity * 0.8 + q * 0.2;
127
142
  }
128
- n.lastY = t.clientY, n.lastTime = i;
129
- const C = n.startHeight + L, G = o && r.current.parentElement?.offsetHeight || window.innerHeight, W = Math.max(0, Math.min(C, G));
130
- r.current.style.transition = "none", r.current.style.height = `${W}px`;
143
+ n.lastY = t.clientY, n.lastTime = c;
144
+ const G = n.startHeight + v, W = s && r.current.parentElement?.offsetHeight || window.innerHeight, B = Math.max(0, Math.min(G, W));
145
+ r.current.style.transition = "none", r.current.style.height = `${B}px`;
131
146
  }
132
- }, [o]), b = c(() => {
147
+ }, [s]), x = l(() => {
133
148
  if (!f.current || !r.current) return;
134
149
  const e = f.current;
135
150
  if (e.isDragging) {
136
- N();
137
- const t = r.current.offsetHeight, n = S(t, e.velocity);
138
- H(n);
151
+ k();
152
+ const t = r.current.offsetHeight, n = z(t, e.velocity);
153
+ y(n);
139
154
  }
140
155
  f.current = null;
141
- }, [S, F, N]);
142
- y(() => {
156
+ }, [z, T, k]);
157
+ H(() => {
143
158
  const e = O.current;
144
159
  if (e)
145
- return e.addEventListener("touchstart", h, { passive: !1 }), e.addEventListener("touchmove", z, { passive: !1 }), e.addEventListener("touchend", b), e.addEventListener("touchcancel", b), e.addEventListener("mousedown", T, { passive: !1 }), e.addEventListener("mousemove", q, { passive: !1 }), e.addEventListener("mouseup", b), e.addEventListener("mouseleave", b), () => {
146
- e.removeEventListener("touchstart", h), e.removeEventListener("touchmove", z), e.removeEventListener("touchend", b), e.removeEventListener("touchcancel", b), e.removeEventListener("mousedown", T), e.removeEventListener("mousemove", q), e.removeEventListener("mouseup", b), e.removeEventListener("mouseleave", b);
160
+ return e.addEventListener("touchstart", A, { passive: !1 }), e.addEventListener("touchmove", C, { passive: !1 }), e.addEventListener("touchend", x), e.addEventListener("touchcancel", x), e.addEventListener("mousedown", K, { passive: !1 }), e.addEventListener("mousemove", Q, { passive: !1 }), e.addEventListener("mouseup", x), e.addEventListener("mouseleave", x), () => {
161
+ e.removeEventListener("touchstart", A), e.removeEventListener("touchmove", C), e.removeEventListener("touchend", x), e.removeEventListener("touchcancel", x), e.removeEventListener("mousedown", K), e.removeEventListener("mousemove", Q), e.removeEventListener("mouseup", x), e.removeEventListener("mouseleave", x);
147
162
  };
148
- }, [h, z, b]);
149
- const E = Q(() => s !== "0%", [s]), [U, J] = $(() => u ? s !== "0%" : !0);
150
- return y(() => {
151
- u && E && J(!0);
152
- }, [E, u]), y(() => {
153
- if (!u) return;
163
+ }, [A, C, x]);
164
+ const Y = X(() => o !== "0%", [o]), [Z, U] = $(() => a ? o !== "0%" : !0);
165
+ return H(() => {
166
+ a && Y && U(!0);
167
+ }, [Y, a]), H(() => {
168
+ if (!a) return;
154
169
  const e = r.current;
155
170
  if (!e) return;
156
171
  const t = (n) => {
157
- n.propertyName === "height" && !E && s === "0%" && J(!1);
172
+ n.propertyName === "height" && !Y && o === "0%" && U(!1);
158
173
  };
159
174
  return e.addEventListener("transitionend", t), () => {
160
175
  e.removeEventListener("transitionend", t);
161
176
  };
162
- }, [E, s, u]), /* @__PURE__ */ m.jsxs(m.Fragment, { children: [
163
- R && /* @__PURE__ */ m.jsx(
177
+ }, [Y, o, a]), /* @__PURE__ */ w.jsxs(w.Fragment, { children: [
178
+ j && /* @__PURE__ */ w.jsx(
164
179
  "div",
165
180
  {
166
- className: _(E ? "fixed inset-0 bg-black/40 z-55 cursor-default" : "hidden"),
181
+ className: _(Y ? "fixed inset-0 bg-black/40 z-55 cursor-default" : "hidden"),
167
182
  onClick: (e) => {
168
- e.preventDefault(), e.stopPropagation(), Y && H(0);
183
+ e.preventDefault(), e.stopPropagation(), S && y(0);
169
184
  },
170
185
  "aria-hidden": "true"
171
186
  }
172
187
  ),
173
- /* @__PURE__ */ m.jsxs(
188
+ /* @__PURE__ */ w.jsxs(
174
189
  "div",
175
190
  {
176
191
  ref: r,
177
192
  className: _(
178
193
  "h-0",
179
- o ? "absolute" : "fixed",
194
+ s ? "absolute" : "fixed",
180
195
  "z-60 bottom-0 w-full overflow-hidden",
181
196
  "bg-neutral-default-default",
182
197
  "border-t border-neutral-strong-default rounded-t-[12px]",
183
- E ? "" : "border-neutral-weak",
184
- D,
198
+ Y ? "" : "border-neutral-weak",
199
+ M,
185
200
  "flex flex-col items-center",
186
201
  "touch-none select-none"
187
202
  ),
188
203
  children: [
189
- /* @__PURE__ */ m.jsx(
204
+ /* @__PURE__ */ w.jsx(
190
205
  "div",
191
206
  {
192
207
  ref: O,
193
208
  className: "w-full absolute top-0 h-11 flex items-center justify-center cursor-grab active:cursor-grabbing z-50 bg-inherit!",
194
- children: /* @__PURE__ */ m.jsx("span", { className: "w-12 h-1 rounded-full bg-neutral-weak-default" })
209
+ children: /* @__PURE__ */ w.jsx("span", { className: "w-12 h-1 rounded-full bg-neutral-weak-default" })
195
210
  }
196
211
  ),
197
- typeof x == "string" ? /* @__PURE__ */ m.jsx("p", { className: " prometeo-fonts-headline-small text-neutral-default-default w-full h-11 bg-inherit absolute top-11 z-50 px-4", children: x }) : x,
198
- /* @__PURE__ */ m.jsx(
212
+ typeof m == "string" ? /* @__PURE__ */ w.jsx("p", { className: " prometeo-fonts-headline-small text-neutral-default-default w-full h-11 bg-inherit absolute top-11 z-50 px-4", children: m }) : m,
213
+ /* @__PURE__ */ w.jsx(
199
214
  "div",
200
215
  {
201
- ref: k,
216
+ ref: D,
202
217
  className: _(
203
218
  "drawer-mobile-content prometeo-scrollbar-thin-weak",
204
- E ? "drawer-mobile-content--open" : "drawer-mobile-content--closed",
219
+ Y ? "drawer-mobile-content--open" : "drawer-mobile-content--closed",
205
220
  "w-full h-full px-4 pb-4 ",
206
- x ? "mt-22" : "mt-11"
221
+ m ? "mt-22" : "mt-11"
207
222
  ),
208
223
  style: {
209
224
  overscrollBehavior: "contain"
210
225
  },
211
- children: (!u || U) && (typeof l == "function" ? l(M) : l)
226
+ children: (!a || Z) && (typeof u == "function" ? u(L) : u)
212
227
  }
213
228
  )
214
229
  ]
215
230
  }
216
231
  )
217
232
  ] });
218
- }, oe = () => {
219
- const l = w(null), [o, D] = $(!1), s = c((d, u) => {
220
- l.current?.open(d, u);
221
- }, []), g = c(() => {
222
- l.current?.close();
223
- }, []), v = c(() => l.current?.getContext() ?? null, []);
224
- return y(() => {
225
- const d = l.current?.subscribeOpenChange;
226
- if (!d) return;
227
- const u = d((x) => {
228
- D(x);
233
+ }, le = () => {
234
+ const u = p(null), [s, M] = $(!1), o = l((g, a) => {
235
+ u.current?.open(g, a);
236
+ }, []), h = l(() => {
237
+ u.current?.close();
238
+ }, []), d = l(() => u.current?.getContext() ?? null, []);
239
+ return H(() => {
240
+ const g = u.current?.subscribeOpenChange;
241
+ if (!g) return;
242
+ const a = g((m) => {
243
+ M(m);
229
244
  });
230
245
  return () => {
231
- u && u();
246
+ a && a();
232
247
  };
233
- }, [l.current?.subscribeOpenChange]), {
234
- isOpen: o,
235
- open: s,
236
- close: g,
237
- drawerRef: l,
238
- getContext: v
248
+ }, [u.current?.subscribeOpenChange]), {
249
+ isOpen: s,
250
+ open: o,
251
+ close: h,
252
+ drawerRef: u,
253
+ getContext: d
239
254
  };
240
255
  };
241
256
  export {
242
- se as default,
243
- oe as useDrawerMobile
257
+ ce as default,
258
+ le as useDrawerMobile
244
259
  };