prometeo-design-system 2.9.4 → 2.9.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.
@@ -1,6 +0,0 @@
1
- export * from './exports/DrawerDesktop'
2
- export {}
3
- import PrometeoDesignSystem from './exports/DrawerDesktop'
4
- export default PrometeoDesignSystem
5
- export * from './exports/DrawerDesktop'
6
- export {}
@@ -1,192 +0,0 @@
1
- import { j as l } from "./jsx-runtime-DKDX3adD.js";
2
- import { c as h } from "./cn-B6yFEsav.js";
3
- import { c as k } from "./index-BOQuZ0gG.js";
4
- import { createPortal as E } from "react-dom";
5
- import { forwardRef as V, useRef as u, useState as N, useEffect as d, useCallback as f, useImperativeHandle as I } from "react";
6
- import { a as P } from "./Icons-DtFC5DJ7.js";
7
- import B from "./Button.es.js";
8
- const L = V((t, s) => {
9
- const n = u(null), [e, a] = N(t.defaultOpen || !1), [r, y] = N(null), b = u(t.onClose), c = u(r), {
10
- modal: i = !1,
11
- children: m,
12
- className: w,
13
- direction: C = "left",
14
- attachToParent: x = !1,
15
- closeOnOverlayClick: o = !1,
16
- hideCloseButton: T = !1
17
- } = t, g = u(o), O = u(e);
18
- c.current = r, d(() => {
19
- O.current = e;
20
- }, [e]), d(() => {
21
- c.current = r;
22
- }, [r]), d(() => {
23
- g.current = o;
24
- }, [o]);
25
- const R = (p) => {
26
- if (!n.current)
27
- return;
28
- const z = n.current;
29
- z && !z.contains(p.target) && g.current && O.current && v();
30
- };
31
- d(() => {
32
- if (!g.current || i || !e)
33
- return;
34
- const p = setTimeout(() => {
35
- document.addEventListener("click", R);
36
- }, 0);
37
- return () => {
38
- clearTimeout(p), document.removeEventListener("click", R);
39
- };
40
- }, [o, e, i]), d(() => {
41
- b.current = t.onClose;
42
- }, [t.onClose]);
43
- const j = f((p) => {
44
- y(p ?? null), a(!0);
45
- }, []), v = f(() => {
46
- a(!1), b.current?.(c.current), setTimeout(() => y(null), 300);
47
- }, []);
48
- I(
49
- s,
50
- () => ({
51
- open: j,
52
- close: v,
53
- isOpen: e,
54
- getContext: () => c.current
55
- }),
56
- [e, j, v]
57
- );
58
- const D = /* @__PURE__ */ l.jsx(
59
- Y,
60
- {
61
- context: r,
62
- ref: n,
63
- isOpen: e,
64
- close: v,
65
- direction: C,
66
- modal: i,
67
- className: w,
68
- attachToParent: x,
69
- closeOnOverlayClick: o,
70
- hideCloseButton: T,
71
- children: typeof m == "function" ? m(r) : m
72
- }
73
- );
74
- return x ? D : E(D, document.body);
75
- });
76
- L.displayName = "DrawerDesktopV2";
77
- const Y = ({
78
- ref: t,
79
- children: s,
80
- direction: n = "left",
81
- isOpen: e,
82
- close: a,
83
- modal: r = !1,
84
- className: y,
85
- attachToParent: b = !1,
86
- closeOnOverlayClick: c = !1,
87
- hideCloseButton: i = !1,
88
- context: m
89
- }) => {
90
- d(() => {
91
- if (e && r) {
92
- const o = window.scrollY;
93
- return document.body.style.position = "fixed", document.body.style.top = `-${o}px`, document.body.style.width = "100%", () => {
94
- document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", window.scrollTo(0, o);
95
- };
96
- }
97
- }, [e, r]);
98
- const w = k("border-neutral-strong-default", {
99
- variants: {
100
- isOpen: {
101
- true: "desktop-drawer-visible",
102
- false: "desktop-drawer-hidden"
103
- },
104
- direction: {
105
- left: "left-0 border-r-[1px] border-l-0",
106
- right: "right-0 border-l-[1px] border-r-0"
107
- }
108
- }
109
- }), C = k(
110
- "fixed inset-0 bg-black/60 z-[55] cursor-default",
111
- {
112
- variants: {
113
- isOpen: {
114
- true: "drawer-overlay-visible",
115
- false: "drawer-overlay-hidden"
116
- }
117
- }
118
- }
119
- ), x = k("", {
120
- variants: {
121
- direction: {
122
- left: "right-0",
123
- right: "left-0"
124
- }
125
- }
126
- });
127
- return /* @__PURE__ */ l.jsxs(l.Fragment, { children: [
128
- r && /* @__PURE__ */ l.jsx(
129
- "div",
130
- {
131
- className: h(C({ isOpen: e })),
132
- onClick: (o) => {
133
- o.preventDefault(), o.stopPropagation(), c && a();
134
- },
135
- "aria-hidden": "true"
136
- }
137
- ),
138
- /* @__PURE__ */ l.jsxs(
139
- "div",
140
- {
141
- ref: t,
142
- className: h(
143
- "bg-neutral-strong-default h-full top-0 z-60 w-max overflow-y-auto",
144
- b ? "absolute" : "fixed",
145
- w({ isOpen: e, direction: n }),
146
- !i && "p-4 pt-10",
147
- y
148
- ),
149
- role: "dialog",
150
- "aria-modal": r,
151
- children: [
152
- !i && /* @__PURE__ */ l.jsx(
153
- B,
154
- {
155
- icon: /* @__PURE__ */ l.jsx(P, { size: 24 }),
156
- animate: !1,
157
- type: "button",
158
- size: "small",
159
- variant: "text",
160
- onClick: a,
161
- label: "",
162
- color: "secondary",
163
- className: h(
164
- "absolute top-0 z-50",
165
- x({ direction: n })
166
- ),
167
- "aria-label": "Close drawer"
168
- }
169
- ),
170
- typeof s == "function" ? s(m) : s
171
- ]
172
- }
173
- )
174
- ] });
175
- }, J = () => {
176
- const t = u(null), s = f((r) => {
177
- t.current?.open(r);
178
- }, []), n = f(() => {
179
- t.current?.close();
180
- }, []), e = f(() => t.current?.isOpen ?? !1, []), a = f(() => t.current?.getContext() ?? null, []);
181
- return {
182
- isOpen: e,
183
- open: s,
184
- close: n,
185
- drawerRef: t,
186
- getContext: a
187
- };
188
- };
189
- export {
190
- L as default,
191
- J as useDrawerDesktop
192
- };
@@ -1,6 +0,0 @@
1
- export * from './exports/DrawerMobile'
2
- export {}
3
- import PrometeoDesignSystem from './exports/DrawerMobile'
4
- export default PrometeoDesignSystem
5
- export * from './exports/DrawerMobile'
6
- export {}
@@ -1,242 +0,0 @@
1
- import { j as m } from "./jsx-runtime-DKDX3adD.js";
2
- import { c as _ } from "./cn-B6yFEsav.js";
3
- import { forwardRef as V, useState as $, useRef as v, 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: w = ["60%"], setSnap: d, snap: u, attachToParent: x = !1 } = l, [R, Y] = $(u || "0%"), [M, r] = $(null), O = v(g), T = v(d), f = v(M), p = v(/* @__PURE__ */ new Set());
7
- O.current = g, f.current = M, y(() => {
8
- s && S();
9
- }, [s]), y(() => {
10
- T.current = d;
11
- }, [d]);
12
- const j = c(() => {
13
- Y("0%"), O.current?.(f.current), setTimeout(() => r(null), 300);
14
- }, []), S = c((h, k) => {
15
- Y(h || w[0] || "60%"), r(k ?? null);
16
- }, [w]), H = Q(() => R !== "0%", [R]);
17
- y(() => {
18
- p.current.forEach((h) => {
19
- try {
20
- h(H);
21
- } catch {
22
- }
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);
30
- }),
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: w, hideOnClose: d = !1, unmountChildrenOnClose: u = !1, header: x, modal: R = !1, closeOnOverlayClick: Y = !1, context: M }) => {
36
- const r = v(null), O = v(null), T = v(null), f = v(null), p = v(null), j = c(() => {
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();
42
- if (n.length === 0) return e;
43
- if (Math.abs(t) > 0.05)
44
- if (t > 0) {
45
- const a = n.filter((i) => i < e);
46
- return a.length > 0 ? Math.max(...a) : d ? 0 : B;
47
- } else {
48
- const a = n.filter((i) => i > e);
49
- if (a.length > 0)
50
- return Math.min(...a);
51
- }
52
- return n.reduce((a, i) => Math.abs(i - e) < Math.abs(a - e) ? i : a);
53
- }, [j]), H = c((e) => {
54
- if (w && g) {
55
- const t = o && r.current?.parentElement?.offsetHeight || window.innerHeight, n = e <= B ? "0%" : `${Math.round(e / t * 100)}%`;
56
- w(n);
57
- }
58
- }, [w, g, o]), F = c((e) => {
59
- r.current && (r.current.style.transition = P, r.current.style.height = `${e}px`);
60
- }, [w, 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;
64
- }
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
- 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) => {
75
- if (!r.current) return;
76
- const t = e.touches[0], n = r.current.offsetHeight;
77
- f.current = {
78
- isDragging: !1,
79
- startY: t.clientY,
80
- startHeight: n,
81
- lastY: t.clientY,
82
- lastTime: Date.now(),
83
- velocity: 0
84
- };
85
- }, []), k = c((e) => {
86
- if (!r.current) return;
87
- const t = e, n = r.current.offsetHeight;
88
- f.current = {
89
- isDragging: !1,
90
- startY: t.clientY,
91
- startHeight: n,
92
- lastY: t.clientY,
93
- lastTime: Date.now(),
94
- velocity: 0
95
- };
96
- }, []), z = c((e) => {
97
- 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%";
102
- }
103
- if (a) {
104
- e.preventDefault();
105
- const i = Date.now(), I = i - n.lastTime;
106
- if (I > 0) {
107
- const A = (t.clientY - n.lastY) / I;
108
- n.velocity = n.velocity * 0.8 + A * 0.2;
109
- }
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`;
113
- }
114
- }, [o]), q = c((e) => {
115
- 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%";
120
- }
121
- if (a) {
122
- e.preventDefault();
123
- const i = Date.now(), I = i - n.lastTime;
124
- if (I > 0) {
125
- const A = (t.clientY - n.lastY) / I;
126
- n.velocity = n.velocity * 0.8 + A * 0.2;
127
- }
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`;
131
- }
132
- }, [o]), b = c(() => {
133
- if (!f.current || !r.current) return;
134
- const e = f.current;
135
- if (e.isDragging) {
136
- N();
137
- const t = r.current.offsetHeight, n = S(t, e.velocity);
138
- H(n);
139
- }
140
- f.current = null;
141
- }, [S, F, N]);
142
- y(() => {
143
- const e = T.current;
144
- 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", k, { 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", k), e.removeEventListener("mousemove", q), e.removeEventListener("mouseup", b), e.removeEventListener("mouseleave", b);
147
- };
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;
154
- const e = r.current;
155
- if (!e) return;
156
- const t = (n) => {
157
- n.propertyName === "height" && !E && s === "0%" && J(!1);
158
- };
159
- return e.addEventListener("transitionend", t), () => {
160
- e.removeEventListener("transitionend", t);
161
- };
162
- }, [E, s, u]), /* @__PURE__ */ m.jsxs(m.Fragment, { children: [
163
- R && /* @__PURE__ */ m.jsx(
164
- "div",
165
- {
166
- className: _(E ? "fixed inset-0 bg-black/40 z-55 cursor-default" : "hidden"),
167
- onClick: (e) => {
168
- e.preventDefault(), e.stopPropagation(), Y && H(0);
169
- },
170
- "aria-hidden": "true"
171
- }
172
- ),
173
- /* @__PURE__ */ m.jsxs(
174
- "div",
175
- {
176
- ref: r,
177
- className: _(
178
- o ? "absolute" : "fixed",
179
- "z-60 bottom-0 w-full overflow-hidden",
180
- "bg-neutral-default-default",
181
- "border-t border-neutral-strong-default rounded-t-[12px]",
182
- E ? "" : "border-neutral-weak",
183
- D,
184
- "flex flex-col items-center",
185
- "touch-none select-none"
186
- ),
187
- children: [
188
- /* @__PURE__ */ m.jsx(
189
- "div",
190
- {
191
- ref: T,
192
- className: "w-full absolute top-0 h-11 flex items-center justify-center cursor-grab active:cursor-grabbing z-50 bg-inherit!",
193
- children: /* @__PURE__ */ m.jsx("span", { className: "w-12 h-1 rounded-full bg-neutral-weak-default" })
194
- }
195
- ),
196
- 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,
197
- /* @__PURE__ */ m.jsx(
198
- "div",
199
- {
200
- ref: O,
201
- className: _(
202
- "w-full h-full overflow-y-auto px-4 pb-4 ",
203
- x ? "mt-22" : "mt-11"
204
- ),
205
- style: {
206
- overscrollBehavior: "contain",
207
- overflow: E ? "auto" : "hidden"
208
- },
209
- children: (!u || U) && (typeof l == "function" ? l(M) : l)
210
- }
211
- )
212
- ]
213
- }
214
- )
215
- ] });
216
- }, oe = () => {
217
- const l = v(null), [o, D] = $(!1), s = c((d, u) => {
218
- l.current?.open(d, u);
219
- }, []), g = c(() => {
220
- l.current?.close();
221
- }, []), w = c(() => l.current?.getContext() ?? null, []);
222
- return y(() => {
223
- const d = l.current?.subscribeOpenChange;
224
- if (!d) return;
225
- const u = d((x) => {
226
- D(x);
227
- });
228
- return () => {
229
- u && u();
230
- };
231
- }, [l.current?.subscribeOpenChange]), {
232
- isOpen: o,
233
- open: s,
234
- close: g,
235
- drawerRef: l,
236
- getContext: w
237
- };
238
- };
239
- export {
240
- se as default,
241
- oe as useDrawerMobile
242
- };
@@ -1,4 +0,0 @@
1
- export { default } from '../components/Drawer/DrawerDesktop';
2
- export { useDrawerDesktop } from '../components/Drawer/useDrawerDesktop';
3
- export type { DrawerDesktopProps } from '../components/Drawer/DrawerDesktop';
4
- export type { DrawerDesktopHandle } from '../components/Drawer/DrawerDesktop';
@@ -1,4 +0,0 @@
1
- export { default } from '../components/Drawer/DrawerMobile';
2
- export { useDrawerMobile } from '../components/Drawer/useDrawerMobile';
3
- export type { DrawerMobileProps } from '../components/Drawer/DrawerMobile';
4
- export type { DrawerMobileHandle } from '../components/Drawer/DrawerMobile';