@yuno-payments/dashboard-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,14 +1,15 @@
1
1
  import { j as e } from "../../../_virtual/jsx-runtime.js";
2
- import * as i from "react";
2
+ import * as a from "react";
3
3
  import { createPortal as F } from "react-dom";
4
- import { cva as p } from "../../../node_modules/class-variance-authority/dist/index.js";
4
+ import { cva as y } from "../../../node_modules/class-variance-authority/dist/index.js";
5
5
  import { cn as d, normalizeDimension as w } from "../../../lib/utils.js";
6
- import { useBodyScrollLock as R } from "../../../hooks/use-body-scroll-lock.js";
7
- import { useEscapeKey as H } from "../../../hooks/use-escape-key.js";
8
- import { DialogHeader as I } from "../../molecules/dialog-header/dialog-header.js";
9
- import { DialogContent as K } from "../../molecules/dialog-content/dialog-content.js";
10
- import { DialogFooter as O } from "../../molecules/dialog-footer/dialog-footer.js";
11
- const P = p(
6
+ import { useBodyScrollLock as O } from "../../../hooks/use-body-scroll-lock.js";
7
+ import { useOverlayPresence as P } from "../../../hooks/use-overlay-presence.js";
8
+ import { useEscapeKey as R } from "../../../hooks/use-escape-key.js";
9
+ import { DialogHeader as H } from "../../molecules/dialog-header/dialog-header.js";
10
+ import { DialogContent as I } from "../../molecules/dialog-content/dialog-content.js";
11
+ import { DialogFooter as K } from "../../molecules/dialog-footer/dialog-footer.js";
12
+ const W = y(
12
13
  "fixed inset-0 flex items-center justify-center p-4",
13
14
  {
14
15
  variants: {
@@ -22,7 +23,7 @@ const P = p(
22
23
  verticalAlign: "center"
23
24
  }
24
25
  }
25
- ), W = p(
26
+ ), q = y(
26
27
  "relative bg-background rounded-lg shadow-lg border border-border max-h-[90vh] overflow-hidden flex flex-col",
27
28
  {
28
29
  variants: {
@@ -38,15 +39,15 @@ const P = p(
38
39
  size: "default"
39
40
  }
40
41
  }
41
- ), q = i.forwardRef(
42
+ ), G = a.forwardRef(
42
43
  ({
43
- className: y,
44
+ className: p,
44
45
  verticalAlign: b,
45
46
  title: h,
46
- open: a,
47
+ open: i,
47
48
  closeIcon: o,
48
49
  buttons: j = [],
49
- widthContainer: l,
50
+ widthContainer: r,
50
51
  heightContainer: c,
51
52
  backButtonAction: z,
52
53
  showActions: N = !0,
@@ -56,27 +57,27 @@ const P = p(
56
57
  headerClassName: S,
57
58
  contentClassName: T,
58
59
  footerClassName: V,
59
- zIndex: r,
60
+ zIndex: l,
60
61
  ...A
61
62
  }, C) => {
62
- const [s, L] = i.useState(!1), [n, u] = i.useState(a), [f, g] = i.useState(!1);
63
- if (i.useEffect(() => {
63
+ const [s, L] = a.useState(!1), [n, u] = a.useState(i), [f, g] = a.useState(!1);
64
+ if (a.useEffect(() => {
64
65
  const t = () => {
65
66
  L(window.innerWidth <= 599);
66
67
  };
67
68
  return t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
68
- }, []), i.useEffect(() => {
69
+ }, []), a.useEffect(() => {
69
70
  let t, m;
70
- return a ? (u(!0), t = setTimeout(() => g(!0), 10)) : n && (g(!1), m = setTimeout(() => {
71
+ return i ? (u(!0), t = setTimeout(() => g(!0), 10)) : n && (g(!1), m = setTimeout(() => {
71
72
  u(!1);
72
73
  }, 600)), () => {
73
74
  t && clearTimeout(t), m && clearTimeout(m);
74
75
  };
75
- }, [a, n]), R(a), H(a, o), !n) return null;
76
+ }, [i, n]), O(i), P(i), R(i, o), !n) return null;
76
77
  const M = {
77
- width: l && !s ? w(l) : void 0,
78
+ width: r && !s ? w(r) : void 0,
78
79
  height: c && !s ? w(c) : void 0
79
- }, x = r !== void 0 ? { zIndex: r } : void 0, v = r === void 0 ? "z-dialog" : void 0, B = /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
80
+ }, x = l !== void 0 ? { zIndex: l } : void 0, v = l === void 0 ? "z-dialog" : void 0, B = /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
80
81
  /* @__PURE__ */ e.jsx(
81
82
  "div",
82
83
  {
@@ -93,7 +94,7 @@ const P = p(
93
94
  /* @__PURE__ */ e.jsx(
94
95
  "div",
95
96
  {
96
- className: d(P({ verticalAlign: b }), v),
97
+ className: d(W({ verticalAlign: b }), v),
97
98
  style: x,
98
99
  children: /* @__PURE__ */ e.jsxs(
99
100
  "div",
@@ -101,13 +102,13 @@ const P = p(
101
102
  ref: C,
102
103
  className: d(
103
104
  "yuno-dialog",
104
- W({
105
+ q({
105
106
  size: s ? "fullscreen" : "default"
106
107
  }),
107
108
  "transition-all duration-600 ease-out",
108
109
  f ? "opacity-100 scale-100 translate-y-0" : "opacity-0 scale-98 -translate-y-2",
109
- l && !s && "max-w-none",
110
- y
110
+ r && !s && "max-w-none",
111
+ p
111
112
  ),
112
113
  style: M,
113
114
  role: "dialog",
@@ -115,7 +116,7 @@ const P = p(
115
116
  ...A,
116
117
  children: [
117
118
  D && /* @__PURE__ */ e.jsx(
118
- I,
119
+ H,
119
120
  {
120
121
  title: h,
121
122
  onClose: o,
@@ -124,8 +125,8 @@ const P = p(
124
125
  className: S
125
126
  }
126
127
  ),
127
- /* @__PURE__ */ e.jsx(K, { className: T, children: E }),
128
- N && /* @__PURE__ */ e.jsx(O, { buttons: j, className: V })
128
+ /* @__PURE__ */ e.jsx(I, { className: T, children: E }),
129
+ N && /* @__PURE__ */ e.jsx(K, { buttons: j, className: V })
129
130
  ]
130
131
  }
131
132
  )
@@ -135,7 +136,7 @@ const P = p(
135
136
  return F(B, document.body);
136
137
  }
137
138
  );
138
- q.displayName = "Dialog";
139
+ G.displayName = "Dialog";
139
140
  export {
140
- q as Dialog
141
+ G as Dialog
141
142
  };
@@ -4,11 +4,12 @@ import { createPortal as H } from "react-dom";
4
4
  import { cva as g } from "../../../node_modules/class-variance-authority/dist/index.js";
5
5
  import { cn as r, normalizeDimension as p } from "../../../lib/utils.js";
6
6
  import { useBodyScrollLock as M } from "../../../hooks/use-body-scroll-lock.js";
7
- import { useEscapeKey as R } from "../../../hooks/use-escape-key.js";
8
- import { Icon as W } from "../../atoms/icon/icon.js";
7
+ import { useOverlayPresence as R } from "../../../hooks/use-overlay-presence.js";
8
+ import { useEscapeKey as W } from "../../../hooks/use-escape-key.js";
9
+ import { Icon as D } from "../../atoms/icon/icon.js";
9
10
  import { Button as x } from "../../atoms/button/button.js";
10
11
  import { Typography as b } from "../../atoms/typography/typography.js";
11
- const D = g(
12
+ const F = g(
12
13
  "fixed z-sheet bg-background shadow-lg transition-transform duration-300 ease-in-out",
13
14
  {
14
15
  variants: {
@@ -38,7 +39,7 @@ const D = g(
38
39
  isOpen: !1
39
40
  }
40
41
  }
41
- ), F = g(
42
+ ), K = g(
42
43
  "fixed inset-0 z-sheet bg-black/50 transition-opacity duration-300",
43
44
  {
44
45
  variants: {
@@ -51,7 +52,7 @@ const D = g(
51
52
  isOpen: !1
52
53
  }
53
54
  }
54
- ), K = i.forwardRef(
55
+ ), L = i.forwardRef(
55
56
  ({
56
57
  className: y,
57
58
  side: s = "right",
@@ -60,8 +61,8 @@ const D = g(
60
61
  open: a,
61
62
  onClose: n,
62
63
  buttons: c = [],
63
- width: j,
64
- height: v,
64
+ width: v,
65
+ height: j,
65
66
  showHeader: O = !0,
66
67
  showFooter: N = !0,
67
68
  children: w,
@@ -72,7 +73,7 @@ const D = g(
72
73
  ...V
73
74
  }, E) => {
74
75
  const [I, f] = i.useState(!1), [u, h] = i.useState(!1);
75
- if (M(a), R(a, n), i.useEffect(() => {
76
+ if (M(a), R(a), W(a, n), i.useEffect(() => {
76
77
  if (a) {
77
78
  f(!0);
78
79
  const t = setTimeout(() => h(!0), 10);
@@ -83,14 +84,14 @@ const D = g(
83
84
  return () => clearTimeout(t);
84
85
  }
85
86
  }, [a]), !I) return null;
86
- const d = p(j), m = p(v), A = {
87
- ...d && (s === "left" || s === "right") ? { width: d, maxWidth: d } : {},
88
- ...m && (s === "top" || s === "bottom") ? { height: m, maxHeight: m } : {}
87
+ const m = p(v), d = p(j), A = {
88
+ ...m && (s === "left" || s === "right") ? { width: m, maxWidth: m } : {},
89
+ ...d && (s === "top" || s === "bottom") ? { height: d, maxHeight: d } : {}
89
90
  }, B = /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
90
91
  /* @__PURE__ */ e.jsx(
91
92
  "div",
92
93
  {
93
- className: F({ isOpen: u }),
94
+ className: K({ isOpen: u }),
94
95
  onClick: n,
95
96
  "aria-hidden": "true"
96
97
  }
@@ -99,7 +100,7 @@ const D = g(
99
100
  "div",
100
101
  {
101
102
  ref: E,
102
- className: r(D({ side: s, isOpen: u }), y),
103
+ className: r(F({ side: s, isOpen: u }), y),
103
104
  style: A,
104
105
  role: "dialog",
105
106
  "aria-modal": "true",
@@ -144,7 +145,7 @@ const D = g(
144
145
  onClick: n,
145
146
  "aria-label": "Close",
146
147
  className: "h-6 w-6",
147
- children: /* @__PURE__ */ e.jsx(W, { name: "X", size: "md" })
148
+ children: /* @__PURE__ */ e.jsx(D, { name: "X", size: "md" })
148
149
  }
149
150
  )
150
151
  ]
@@ -175,7 +176,7 @@ const D = g(
175
176
  return H(B, document.body);
176
177
  }
177
178
  );
178
- K.displayName = "Sheet";
179
+ L.displayName = "Sheet";
179
180
  export {
180
- K as Sheet
181
+ L as Sheet
181
182
  };
@@ -0,0 +1,9 @@
1
+ export declare const OVERLAY_EVENT = "yuno-overlay";
2
+ /**
3
+ * Broadcasts an overlay open/close event while `isOpen` is true. Call it from
4
+ * any blocking-overlay component (Dialog, Sheet) alongside its other lifecycle
5
+ * hooks.
6
+ *
7
+ * @param isOpen - Whether the overlay is currently open
8
+ */
9
+ export declare function useOverlayPresence(isOpen: boolean): void;
@@ -0,0 +1,18 @@
1
+ import { useEffect as r } from "react";
2
+ const o = "yuno-overlay";
3
+ let t = 0;
4
+ function n(e) {
5
+ typeof window > "u" || window.dispatchEvent(new CustomEvent(o, { detail: { open: e } }));
6
+ }
7
+ function i(e) {
8
+ r(() => {
9
+ if (e)
10
+ return t === 0 && n(!0), t++, () => {
11
+ t--, t === 0 && n(!1);
12
+ };
13
+ }, [e]);
14
+ }
15
+ export {
16
+ o as OVERLAY_EVENT,
17
+ i as useOverlayPresence
18
+ };