prometeo-design-system 7.3.6 → 7.3.8

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.
@@ -0,0 +1 @@
1
+ .prometeo-dialog-backdrop{position:fixed;inset:0;background:#0000004d;backdrop-filter:blur(1.5px);-webkit-backdrop-filter:blur(1.5px);opacity:0;pointer-events:auto;transition:opacity .15s ease-out}.prometeo-dialog-backdrop[data-open=true]{opacity:1}.prometeo-dialog-backdrop[data-closing=true]{opacity:0;transition:opacity .1s ease-in;pointer-events:none}
@@ -0,0 +1,6 @@
1
+ export * from './exports/Dialog'
2
+ export {}
3
+ import PrometeoDesignSystem from './exports/Dialog'
4
+ export default PrometeoDesignSystem
5
+ export * from './exports/Dialog'
6
+ export {}
@@ -0,0 +1,278 @@
1
+ import { j as n } from "./jsx-runtime-GkKLlHH4.js";
2
+ import { useContext as Z, createContext as $, forwardRef as ee, memo as O, useRef as h, useState as R, useCallback as p, useEffect as I, useImperativeHandle as ne, useMemo as q } from "react";
3
+ import { createPortal as te } from "react-dom";
4
+ import { c as v } from "./cn-B6yFEsav.js";
5
+ import { M as re } from "./MenuFloating-Bew5qbpJ.js";
6
+ import oe from "./CardBackground.es.js";
7
+ import se from "./IconButton.es.js";
8
+ import { Close as le } from "./Icons/Close.es.js";
9
+ const L = $(null);
10
+ function ae() {
11
+ const e = Z(L);
12
+ if (!e)
13
+ throw new Error(
14
+ "Dialog compound components must be used inside <Dialog>"
15
+ );
16
+ return e;
17
+ }
18
+ const M = 100, k = O(function({
19
+ title: r,
20
+ description: t,
21
+ className: l
22
+ }) {
23
+ const { hideCloseButton: s, closeDialog: a } = ae();
24
+ return /* @__PURE__ */ n.jsxs("div", { className: v("flex flex-col gap-4 pt-2 ", l), children: [
25
+ /* @__PURE__ */ n.jsxs("div", { className: "flex items-baseline justify-center gap-2 pl-4 pr-2 ", children: [
26
+ r && /* @__PURE__ */ n.jsx("span", { className: "prometeo-fonts-title-medium text-neutral-default-default", children: r }),
27
+ !s && /* @__PURE__ */ n.jsx("div", { className: "flex-1 flex justify-end", children: /* @__PURE__ */ n.jsx(
28
+ se,
29
+ {
30
+ icon: le,
31
+ variant: "text",
32
+ color: "neutral",
33
+ size: "small",
34
+ onClick: a
35
+ }
36
+ ) })
37
+ ] }),
38
+ t && /* @__PURE__ */ n.jsx("p", { className: "prometeo-fonts-body-small text-neutral-secondary-default px-4", children: t })
39
+ ] });
40
+ });
41
+ k.displayName = "Dialog.Header";
42
+ const P = O(function({
43
+ children: r,
44
+ className: t
45
+ }) {
46
+ return /* @__PURE__ */ n.jsx("div", { className: v("px-4 py-0 flex flex-col gap-4 ", t), children: r });
47
+ });
48
+ P.displayName = "Dialog.Content";
49
+ const U = O(function({
50
+ children: r,
51
+ className: t
52
+ }) {
53
+ return /* @__PURE__ */ n.jsx(
54
+ "div",
55
+ {
56
+ className: v(
57
+ "p-4 pt-2 flex flex-row gap-3 items-center",
58
+ t
59
+ ),
60
+ children: r
61
+ }
62
+ );
63
+ });
64
+ U.displayName = "Dialog.Footer";
65
+ const X = O(function({
66
+ layoutContext: r,
67
+ shouldRenderChildren: t,
68
+ hasAutoHeader: l,
69
+ title: s,
70
+ description: a,
71
+ cardBackground: o,
72
+ className: c,
73
+ children: i
74
+ }) {
75
+ return /* @__PURE__ */ n.jsxs(
76
+ "div",
77
+ {
78
+ className: v(
79
+ "relative flex flex-col radius-medium overflow-hidden dropshadow-400",
80
+ "border border-neutral-default-default",
81
+ c
82
+ ),
83
+ children: [
84
+ /* @__PURE__ */ n.jsx(
85
+ oe,
86
+ {
87
+ ...o ?? {},
88
+ className: v("absolute inset-0 z-0", o?.className)
89
+ }
90
+ ),
91
+ /* @__PURE__ */ n.jsx("div", { className: "relative z-10 flex flex-col gap-4 min-h-0 overflow-hidden", children: /* @__PURE__ */ n.jsx(L.Provider, { value: r, children: t && /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
92
+ l && /* @__PURE__ */ n.jsx(k, { title: s, description: a }),
93
+ i
94
+ ] }) }) })
95
+ ]
96
+ }
97
+ );
98
+ });
99
+ X.displayName = "Dialog.Card";
100
+ function ce({
101
+ triggerRef: e,
102
+ anchorRef: r,
103
+ placement: t,
104
+ offset: l = 4,
105
+ matchTriggerWidth: s,
106
+ attachToParent: a = !1,
107
+ closeOnScroll: o = !0,
108
+ closeOnClickOutside: c = !0,
109
+ zIndex: i = 50,
110
+ avoidElements: u,
111
+ cardBackground: N,
112
+ title: b,
113
+ description: D,
114
+ hideCloseButton: w = !1,
115
+ modal: m = !1,
116
+ unmountChildrenOnClose: j = !0,
117
+ onClose: T,
118
+ onOpen: A,
119
+ children: _,
120
+ className: G
121
+ }, J) {
122
+ const f = h(null), H = h(T), S = h(A);
123
+ H.current = T, S.current = A;
124
+ const [F, C] = R("hidden"), [K, E] = R(
125
+ () => !j
126
+ ), g = h(null), d = p(() => {
127
+ g.current && (clearTimeout(g.current), g.current = null);
128
+ }, []), z = p(
129
+ (x) => {
130
+ d(), m && C("open"), j && E(!0), f.current?.open(x), S.current?.(x);
131
+ },
132
+ [m, j, d]
133
+ ), y = p(() => {
134
+ m && (d(), C("closing"), g.current = setTimeout(() => {
135
+ C("hidden"), g.current = null;
136
+ }, M)), f.current?.close();
137
+ }, [m, d]), Q = p(() => {
138
+ j && E(!1), H.current?.(f.current?.getContext() ?? null);
139
+ }, [j]);
140
+ I(() => {
141
+ const x = f.current;
142
+ if (!(!x || !m))
143
+ return x.subscribeOpenChange((Y) => {
144
+ Y || C((B) => B !== "open" ? B : (d(), g.current = setTimeout(() => {
145
+ C("hidden"), g.current = null;
146
+ }, M), "closing"));
147
+ });
148
+ }, [m, d]), I(() => d, [d]), ne(
149
+ J,
150
+ () => ({
151
+ open: z,
152
+ close: y,
153
+ get isOpen() {
154
+ return f.current?.isOpen ?? !1;
155
+ },
156
+ getContext: () => f.current?.getContext() ?? null,
157
+ subscribeOpenChange: (x) => f.current?.subscribeOpenChange(x) ?? (() => {
158
+ })
159
+ }),
160
+ [z, y]
161
+ );
162
+ const V = q(
163
+ () => ({ hideCloseButton: w, closeDialog: y }),
164
+ [w, y]
165
+ ), W = b != null || D != null;
166
+ return /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
167
+ m && F !== "hidden" && te(
168
+ /* @__PURE__ */ n.jsx(
169
+ "div",
170
+ {
171
+ className: "prometeo-dialog-backdrop",
172
+ "data-open": F === "open" ? "true" : void 0,
173
+ "data-closing": F === "closing" ? "true" : void 0,
174
+ style: { zIndex: i - 1 }
175
+ }
176
+ ),
177
+ document.body
178
+ ),
179
+ /* @__PURE__ */ n.jsx(
180
+ re,
181
+ {
182
+ ref: f,
183
+ triggerRef: e,
184
+ anchorRef: r,
185
+ placement: t,
186
+ offset: l,
187
+ matchTriggerWidth: s,
188
+ attachToParent: a,
189
+ closeOnScroll: o,
190
+ closeOnClickOutside: c,
191
+ zIndex: i,
192
+ avoidElements: u,
193
+ onClose: Q,
194
+ children: /* @__PURE__ */ n.jsx(
195
+ X,
196
+ {
197
+ layoutContext: V,
198
+ shouldRenderChildren: K,
199
+ hasAutoHeader: W,
200
+ title: b,
201
+ description: D,
202
+ cardBackground: N,
203
+ className: G,
204
+ children: _
205
+ }
206
+ )
207
+ }
208
+ )
209
+ ] });
210
+ }
211
+ const ie = ee(ce), be = Object.assign(ie, {
212
+ Header: k,
213
+ Content: P,
214
+ Footer: U
215
+ });
216
+ function De() {
217
+ const e = h(null), r = h(null), t = p((o) => {
218
+ e.current?.open(o);
219
+ }, []), l = p(() => {
220
+ e.current?.close();
221
+ }, []), s = p((o) => {
222
+ e.current?.isOpen ? e.current.close() : e.current?.open(o);
223
+ }, []), a = p((o) => {
224
+ let c = null, i = null, u = !0, N = 0;
225
+ const b = () => {
226
+ if (!u) return;
227
+ const D = e.current;
228
+ if (!D) {
229
+ N < 10 && (N++, c = requestAnimationFrame(b));
230
+ return;
231
+ }
232
+ i = D.subscribeOpenChange(o);
233
+ };
234
+ return b(), () => {
235
+ u = !1, c !== null && cancelAnimationFrame(c), i?.();
236
+ };
237
+ }, []);
238
+ return q(
239
+ () => ({
240
+ ref: e,
241
+ triggerRef: r,
242
+ open: t,
243
+ close: l,
244
+ toggle: s,
245
+ get isOpen() {
246
+ return e.current?.isOpen ?? !1;
247
+ },
248
+ subscribeOpenChange: a
249
+ }),
250
+ [t, l, s, a]
251
+ );
252
+ }
253
+ function je(e, r) {
254
+ const [t, l] = R(
255
+ () => e.current?.isOpen ?? !1
256
+ );
257
+ return I(() => {
258
+ let s = null, a = null, o = !0, c = 0;
259
+ const i = () => {
260
+ if (!o) return;
261
+ const u = e.current;
262
+ if (!u) {
263
+ c < 10 && (c++, s = requestAnimationFrame(i));
264
+ return;
265
+ }
266
+ l(u.isOpen), a = u.subscribeOpenChange(l);
267
+ };
268
+ return i(), () => {
269
+ o = !1, s !== null && cancelAnimationFrame(s), a?.();
270
+ };
271
+ }, [e, r]), t;
272
+ }
273
+ export {
274
+ be as Dialog,
275
+ be as default,
276
+ De as useDialogControl,
277
+ je as useDialogState
278
+ };