prometeo-design-system 2.5.3 → 2.5.4

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,72 +1,72 @@
1
1
  import { j as g } from "./jsx-runtime-DKDX3adD.js";
2
- import { c as G } from "./cn-B6yFEsav.js";
3
- import { forwardRef as J, useState as _, useRef as h, useEffect as F, useCallback as c, useMemo as q, useImperativeHandle as K } from "react";
4
- import { createPortal as Q } from "react-dom";
5
- const W = 44, U = "height 0.5s cubic-bezier(0.32, 0.72, 0, 1)", ee = J((a, o) => {
6
- const { children: x, defaultOpen: s = !1, onClose: f, snapPoints: d = ["60%"], setSnap: v, snap: w, attachToParent: O = !1 } = a, [E, r] = _(w || "0%"), [C, Y] = _(null), u = h(f), p = h(v), b = h(C);
7
- u.current = f, b.current = C, F(() => {
8
- s && H();
9
- }, [s]), F(() => {
10
- p.current = v;
11
- }, [v]);
2
+ import { c as W } from "./cn-B6yFEsav.js";
3
+ import { forwardRef as K, useState as B, useRef as v, useEffect as F, useCallback as c, useMemo as J, useImperativeHandle as Q } from "react";
4
+ import { createPortal as U } from "react-dom";
5
+ const A = 44, V = "height 0.5s cubic-bezier(0.32, 0.72, 0, 1)", te = K((u, s) => {
6
+ const { children: y, defaultOpen: o = !1, onClose: a, snapPoints: d = ["60%"], setSnap: w, snap: p, attachToParent: O = !1 } = u, [E, x] = B(p || "0%"), [r, C] = B(null), Y = v(a), f = v(w), m = v(r);
7
+ Y.current = a, m.current = r, F(() => {
8
+ o && b();
9
+ }, [o]), F(() => {
10
+ f.current = w;
11
+ }, [w]);
12
12
  const M = c(() => {
13
- r("0%"), u.current?.(b.current), setTimeout(() => Y(null), 300);
14
- }, []), H = c((L, R) => {
15
- console.log(L || d[0] || "60%"), r(L || d[0] || "60%"), Y(R ?? null);
16
- }, [d]), S = q(() => E !== "0%", [E]);
17
- K(o, () => ({
18
- open: H,
13
+ x("0%"), Y.current?.(m.current), setTimeout(() => C(null), 300);
14
+ }, []), b = c((H, N) => {
15
+ console.log(H || d[0] || "60%"), x(H || d[0] || "60%"), C(N ?? null);
16
+ }, [d]), S = J(() => E !== "0%", [E]);
17
+ Q(s, () => ({
18
+ open: b,
19
19
  close: M,
20
20
  isOpen: S,
21
- getContext: () => b.current
22
- }), [H, M, S]);
23
- const y = w || E;
24
- return O ? /* @__PURE__ */ g.jsx(B, { ...a, snap: y, setSnap: r, children: x }) : Q(/* @__PURE__ */ g.jsx(B, { ...a, snap: y, setSnap: r, children: x }), document.body);
25
- }), B = ({ children: a, attachToParent: o = !1, className: x, snap: s, snapPoints: f = ["60%"], setSnap: d, hideOnClose: v = !1, header: w, modal: O = !1, closeOnOverlayClick: E = !1 }) => {
26
- const r = h(null), C = h(null), Y = h(null), u = h(null), p = h(null), b = c(() => {
21
+ getContext: () => m.current
22
+ }), [b, M, S]);
23
+ const L = p || E;
24
+ return O ? /* @__PURE__ */ g.jsx(q, { ...u, snap: L, setSnap: x, context: r, children: y }) : U(/* @__PURE__ */ g.jsx(q, { ...u, snap: L, setSnap: x, context: r, children: y }), document.body);
25
+ }), q = ({ children: u, attachToParent: s = !1, className: y, snap: o, snapPoints: a = ["60%"], setSnap: d, hideOnClose: w = !1, header: p, modal: O = !1, closeOnOverlayClick: E = !1, context: x }) => {
26
+ const r = v(null), C = v(null), Y = v(null), f = v(null), m = v(null), M = c(() => {
27
27
  if (!r.current) return [];
28
- console.log(f, "snapPoints");
29
- const e = o && r.current.parentElement?.offsetHeight || window.innerHeight;
30
- return f?.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) || [];
31
- }, [f, o]), M = c((e, t) => {
32
- const n = b();
28
+ console.log(a, "snapPoints");
29
+ const e = s && r.current.parentElement?.offsetHeight || window.innerHeight;
30
+ return a?.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) || [];
31
+ }, [a, s]), b = c((e, t) => {
32
+ const n = M();
33
33
  if (n.length === 0) return e;
34
34
  if (Math.abs(t) > 0.05)
35
35
  if (t > 0) {
36
36
  const l = n.filter((i) => i < e);
37
- return l.length > 0 ? Math.max(...l) : v ? 0 : W;
37
+ return l.length > 0 ? Math.max(...l) : w ? 0 : A;
38
38
  } else {
39
39
  const l = n.filter((i) => i > e);
40
40
  if (l.length > 0)
41
41
  return Math.min(...l);
42
42
  }
43
43
  return n.reduce((l, i) => Math.abs(i - e) < Math.abs(l - e) ? i : l);
44
- }, [b]), H = c((e) => {
45
- if (d && f) {
46
- const t = o && r.current?.parentElement?.offsetHeight || window.innerHeight, n = e <= W ? "0%" : `${Math.round(e / t * 100)}%`;
44
+ }, [M]), S = c((e) => {
45
+ if (d && a) {
46
+ const t = s && r.current?.parentElement?.offsetHeight || window.innerHeight, n = e <= A ? "0%" : `${Math.round(e / t * 100)}%`;
47
47
  d(n);
48
48
  }
49
- }, [d, f, o]), S = c((e) => {
50
- r.current && (r.current.style.transition = U, r.current.style.height = `${e}px`);
51
- }, [d, f, o]), y = c(() => {
52
- if (p.current && o) {
53
- const { scrollY: e } = p.current;
54
- document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", window.scrollTo(0, e), p.current = null;
49
+ }, [d, a, s]), L = c((e) => {
50
+ r.current && (r.current.style.transition = V, r.current.style.height = `${e}px`);
51
+ }, [d, a, s]), R = c(() => {
52
+ if (m.current && s) {
53
+ const { scrollY: e } = m.current;
54
+ document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", window.scrollTo(0, e), m.current = null;
55
55
  }
56
- }, [o]);
56
+ }, [s]);
57
57
  F(() => () => {
58
- y();
59
- }, [y]), F(() => {
60
- if (!r.current || !s) return;
61
- console.log(s, "new snap");
62
- const e = o && r.current.parentElement?.offsetHeight || window.innerHeight;
58
+ R();
59
+ }, [R]), F(() => {
60
+ if (!r.current || !o) return;
61
+ console.log(o, "new snap");
62
+ const e = s && r.current.parentElement?.offsetHeight || window.innerHeight;
63
63
  let t = 0;
64
- typeof s == "string" && s.endsWith("%") ? parseFloat(s) <= 0 ? t = v ? 0 : W : 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), S(t);
65
- }, [s, o]);
66
- const N = c((e) => {
64
+ typeof o == "string" && o.endsWith("%") ? parseFloat(o) <= 0 ? t = w ? 0 : A : 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), L(t);
65
+ }, [o, s]);
66
+ const H = c((e) => {
67
67
  if (!r.current) return;
68
68
  const t = e.touches[0], n = r.current.offsetHeight;
69
- u.current = {
69
+ f.current = {
70
70
  isDragging: !1,
71
71
  startY: t.clientY,
72
72
  startHeight: n,
@@ -74,10 +74,10 @@ const W = 44, U = "height 0.5s cubic-bezier(0.32, 0.72, 0, 1)", ee = J((a, o) =>
74
74
  lastTime: Date.now(),
75
75
  velocity: 0
76
76
  };
77
- }, []), L = c((e) => {
77
+ }, []), N = c((e) => {
78
78
  if (!r.current) return;
79
79
  const t = e, n = r.current.offsetHeight;
80
- u.current = {
80
+ f.current = {
81
81
  isDragging: !1,
82
82
  startY: t.clientY,
83
83
  startHeight: n,
@@ -85,67 +85,67 @@ const W = 44, U = "height 0.5s cubic-bezier(0.32, 0.72, 0, 1)", ee = J((a, o) =>
85
85
  lastTime: Date.now(),
86
86
  velocity: 0
87
87
  };
88
- }, []), R = c((e) => {
89
- if (!u.current || !r.current) return;
90
- const t = e.touches[0], n = u.current, D = n.startY - t.clientY, l = n.isDragging || Math.abs(D) > 5;
91
- if (!n.isDragging && l && (n.isDragging = !0, o)) {
88
+ }, []), I = c((e) => {
89
+ if (!f.current || !r.current) return;
90
+ const t = e.touches[0], n = f.current, D = n.startY - t.clientY, l = n.isDragging || Math.abs(D) > 5;
91
+ if (!n.isDragging && l && (n.isDragging = !0, s)) {
92
92
  const i = window.scrollY;
93
- p.current = { scrollY: i }, document.body.style.position = "fixed", document.body.style.top = `-${i}px`, document.body.style.width = "100%";
93
+ m.current = { scrollY: i }, document.body.style.position = "fixed", document.body.style.top = `-${i}px`, document.body.style.width = "100%";
94
94
  }
95
95
  if (l) {
96
96
  e.preventDefault();
97
97
  const i = Date.now(), j = i - n.lastTime;
98
98
  if (j > 0) {
99
- const z = (t.clientY - n.lastY) / j;
100
- n.velocity = n.velocity * 0.8 + z * 0.2;
99
+ const G = (t.clientY - n.lastY) / j;
100
+ n.velocity = n.velocity * 0.8 + G * 0.2;
101
101
  }
102
102
  n.lastY = t.clientY, n.lastTime = i;
103
- const k = n.startHeight + D, T = o && r.current.parentElement?.offsetHeight || window.innerHeight, $ = Math.max(0, Math.min(k, T));
104
- r.current.style.transition = "none", r.current.style.height = `${$}px`;
103
+ const T = n.startHeight + D, $ = s && r.current.parentElement?.offsetHeight || window.innerHeight, z = Math.max(0, Math.min(T, $));
104
+ r.current.style.transition = "none", r.current.style.height = `${z}px`;
105
105
  }
106
- }, [o]), A = c((e) => {
107
- if (!u.current || !r.current) return;
108
- const t = e, n = u.current, D = n.startY - t.clientY, l = n.isDragging || Math.abs(D) > 5;
109
- if (!n.isDragging && l && (n.isDragging = !0, o)) {
106
+ }, [s]), _ = c((e) => {
107
+ if (!f.current || !r.current) return;
108
+ const t = e, n = f.current, D = n.startY - t.clientY, l = n.isDragging || Math.abs(D) > 5;
109
+ if (!n.isDragging && l && (n.isDragging = !0, s)) {
110
110
  const i = window.scrollY;
111
- p.current = { scrollY: i }, document.body.style.position = "fixed", document.body.style.top = `-${i}px`, document.body.style.width = "100%";
111
+ m.current = { scrollY: i }, document.body.style.position = "fixed", document.body.style.top = `-${i}px`, document.body.style.width = "100%";
112
112
  }
113
113
  if (l) {
114
114
  e.preventDefault();
115
115
  const i = Date.now(), j = i - n.lastTime;
116
116
  if (j > 0) {
117
- const z = (t.clientY - n.lastY) / j;
118
- n.velocity = n.velocity * 0.8 + z * 0.2;
117
+ const G = (t.clientY - n.lastY) / j;
118
+ n.velocity = n.velocity * 0.8 + G * 0.2;
119
119
  }
120
120
  n.lastY = t.clientY, n.lastTime = i;
121
- const k = n.startHeight + D, T = o && r.current.parentElement?.offsetHeight || window.innerHeight, $ = Math.max(0, Math.min(k, T));
122
- r.current.style.transition = "none", r.current.style.height = `${$}px`;
121
+ const T = n.startHeight + D, $ = s && r.current.parentElement?.offsetHeight || window.innerHeight, z = Math.max(0, Math.min(T, $));
122
+ r.current.style.transition = "none", r.current.style.height = `${z}px`;
123
123
  }
124
- }, [o]), m = c(() => {
125
- if (!u.current || !r.current) return;
126
- const e = u.current;
124
+ }, [s]), h = c(() => {
125
+ if (!f.current || !r.current) return;
126
+ const e = f.current;
127
127
  if (e.isDragging) {
128
- y();
129
- const t = r.current.offsetHeight, n = M(t, e.velocity);
130
- H(n);
128
+ R();
129
+ const t = r.current.offsetHeight, n = b(t, e.velocity);
130
+ S(n);
131
131
  }
132
- u.current = null;
133
- }, [M, S, y]);
132
+ f.current = null;
133
+ }, [b, L, R]);
134
134
  F(() => {
135
135
  const e = Y.current;
136
136
  if (e)
137
- return e.addEventListener("touchstart", N, { passive: !1 }), e.addEventListener("touchmove", R, { passive: !1 }), e.addEventListener("touchend", m), e.addEventListener("touchcancel", m), e.addEventListener("mousedown", L, { passive: !1 }), e.addEventListener("mousemove", A, { passive: !1 }), e.addEventListener("mouseup", m), e.addEventListener("mouseleave", m), () => {
138
- e.removeEventListener("touchstart", N), e.removeEventListener("touchmove", R), e.removeEventListener("touchend", m), e.removeEventListener("touchcancel", m), e.removeEventListener("mousedown", L), e.removeEventListener("mousemove", A), e.removeEventListener("mouseup", m), e.removeEventListener("mouseleave", m);
137
+ return e.addEventListener("touchstart", H, { passive: !1 }), e.addEventListener("touchmove", I, { passive: !1 }), e.addEventListener("touchend", h), e.addEventListener("touchcancel", h), e.addEventListener("mousedown", N, { passive: !1 }), e.addEventListener("mousemove", _, { passive: !1 }), e.addEventListener("mouseup", h), e.addEventListener("mouseleave", h), () => {
138
+ e.removeEventListener("touchstart", H), e.removeEventListener("touchmove", I), e.removeEventListener("touchend", h), e.removeEventListener("touchcancel", h), e.removeEventListener("mousedown", N), e.removeEventListener("mousemove", _), e.removeEventListener("mouseup", h), e.removeEventListener("mouseleave", h);
139
139
  };
140
- }, [N, R, m]);
141
- const I = q(() => s !== "0%", [s]);
140
+ }, [H, I, h]);
141
+ const k = J(() => o !== "0%", [o]);
142
142
  return /* @__PURE__ */ g.jsxs(g.Fragment, { children: [
143
143
  O && /* @__PURE__ */ g.jsx(
144
144
  "div",
145
145
  {
146
- className: G(I ? "fixed inset-0 bg-black/40 z-55 cursor-default" : "hidden"),
146
+ className: W(k ? "fixed inset-0 bg-black/40 z-55 cursor-default" : "hidden"),
147
147
  onClick: (e) => {
148
- e.preventDefault(), e.stopPropagation(), E && H(0);
148
+ e.preventDefault(), e.stopPropagation(), E && S(0);
149
149
  },
150
150
  "aria-hidden": "true"
151
151
  }
@@ -154,13 +154,13 @@ const W = 44, U = "height 0.5s cubic-bezier(0.32, 0.72, 0, 1)", ee = J((a, o) =>
154
154
  "div",
155
155
  {
156
156
  ref: r,
157
- className: G(
158
- o ? "absolute" : "fixed",
157
+ className: W(
158
+ s ? "absolute" : "fixed",
159
159
  "z-60 bottom-0 w-full overflow-hidden",
160
160
  "bg-neutral-default-default",
161
161
  "border-t border-neutral-strong-default rounded-t-[12px]",
162
- I ? "" : "border-neutral-weak",
163
- x,
162
+ k ? "" : "border-neutral-weak",
163
+ y,
164
164
  "flex flex-col items-center",
165
165
  "touch-none select-none"
166
166
  ),
@@ -173,41 +173,41 @@ const W = 44, U = "height 0.5s cubic-bezier(0.32, 0.72, 0, 1)", ee = J((a, o) =>
173
173
  children: /* @__PURE__ */ g.jsx("span", { className: "w-12 h-1 rounded-full bg-neutral-weak-default" })
174
174
  }
175
175
  ),
176
- typeof w == "string" ? /* @__PURE__ */ g.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: w }) : w,
176
+ typeof p == "string" ? /* @__PURE__ */ g.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: p }) : p,
177
177
  /* @__PURE__ */ g.jsx(
178
178
  "div",
179
179
  {
180
180
  ref: C,
181
- className: G(
181
+ className: W(
182
182
  "w-full h-full overflow-y-auto px-4 pb-4 ",
183
- w ? "mt-22" : "mt-11"
183
+ p ? "mt-22" : "mt-11"
184
184
  ),
185
185
  style: {
186
186
  overscrollBehavior: "contain",
187
- overflow: I ? "auto" : "hidden"
187
+ overflow: k ? "auto" : "hidden"
188
188
  },
189
- children: a
189
+ children: typeof u == "function" ? u(x) : u
190
190
  }
191
191
  )
192
192
  ]
193
193
  }
194
194
  )
195
195
  ] });
196
- }, te = () => {
197
- const a = h(null), o = c((d, v) => {
198
- a.current?.open(d, v);
199
- }, []), x = c(() => {
200
- a.current?.close();
201
- }, []), s = c(() => a.current?.isOpen ?? !1, []), f = c(() => a.current?.getContext() ?? null, []);
196
+ }, ne = () => {
197
+ const u = v(null), s = c((d, w) => {
198
+ u.current?.open(d, w);
199
+ }, []), y = c(() => {
200
+ u.current?.close();
201
+ }, []), o = c(() => u.current?.isOpen ?? !1, []), a = c(() => u.current?.getContext() ?? null, []);
202
202
  return {
203
- isOpen: s,
204
- open: o,
205
- close: x,
206
- drawerRef: a,
207
- getContext: f
203
+ isOpen: o,
204
+ open: s,
205
+ close: y,
206
+ drawerRef: u,
207
+ getContext: a
208
208
  };
209
209
  };
210
210
  export {
211
- ee as default,
212
- te as useDrawerMobile
211
+ te as default,
212
+ ne as useDrawerMobile
213
213
  };
@@ -1,6 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  export interface DrawerMobileProps<TContext = unknown> {
3
- children?: React.ReactNode;
3
+ children?: React.ReactNode | ((context: TContext | null) => React.ReactNode);
4
4
  defaultOpen?: boolean;
5
5
  onClose?: (context: TContext | null) => void;
6
6
  snap?: string | number | null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prometeo-design-system",
3
3
  "private": false,
4
- "version": "2.5.3",
4
+ "version": "2.5.4",
5
5
  "type": "module",
6
6
  "description": "design kit system",
7
7
  "main": "dist/prometeo-design-system.umd.js",