@dimasbaguspm/versaur 0.0.20 → 0.0.22

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,493 +0,0 @@
1
- import { c as i, j as o, a as l } from "./index-DOdDlCoL.js";
2
- import m, { createContext as w, useContext as h, forwardRef as d, useRef as N, useEffect as R, useCallback as k } from "react";
3
- import C from "react-dom";
4
- const g = w(null);
5
- function D() {
6
- const t = h(g);
7
- if (!t)
8
- throw new Error(
9
- "Modal components must be used within a ModalRoot component"
10
- );
11
- return t;
12
- }
13
- const E = i(
14
- "fixed inset-0 z-60 transition-opacity duration-300 bg-foreground/30 backdrop-blur-md flex items-center justify-center transition-opacity duration-200 ease-in-out",
15
- {
16
- variants: {
17
- placement: {
18
- top: "items-start",
19
- center: "items-center"
20
- }
21
- },
22
- defaultVariants: {
23
- placement: "center"
24
- }
25
- }
26
- ), F = i(
27
- [
28
- "z-61 bg-white rounded-lg shadow-xl fixed",
29
- "flex flex-col",
30
- "outline-none",
31
- "mx-4",
32
- "transition-all duration-200 ease-in-out "
33
- ],
34
- {
35
- variants: {
36
- size: {
37
- sm: "w-[20rem] max-w-sm",
38
- // 20rem, 320px
39
- md: "w-[28rem] max-w-md",
40
- // 28rem, 448px
41
- lg: "w-[36rem] max-w-lg",
42
- // 36rem, 576px
43
- "fit-content": "w-fit max-w-full"
44
- // Fit content, no max width
45
- },
46
- placement: {
47
- top: "top-8 left-1/2 -translate-x-1/2",
48
- center: "top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"
49
- },
50
- isOpen: {
51
- true: "opacity-100 scale-100",
52
- false: "opacity-0 scale-95 pointer-events-none"
53
- }
54
- },
55
- defaultVariants: {
56
- size: "md",
57
- placement: "center",
58
- isOpen: !1
59
- }
60
- }
61
- ), M = d(
62
- ({ className: t, ...a }, e) => /* @__PURE__ */ o.jsx(
63
- "div",
64
- {
65
- ref: e,
66
- className: l("px-6 pt-6 pb-2 text-lg font-semibold", t),
67
- ...a
68
- }
69
- )
70
- ), S = d(
71
- ({ className: t, ...a }, e) => /* @__PURE__ */ o.jsx(
72
- "div",
73
- {
74
- ref: e,
75
- className: l("px-6 py-4 flex justify-end gap-2", t),
76
- ...a
77
- }
78
- )
79
- ), z = d(
80
- ({ className: t, ...a }, e) => /* @__PURE__ */ o.jsx("div", { ref: e, className: l("px-6 py-2", t), ...a })
81
- ), H = d(
82
- (t, a) => {
83
- const { isOpen: e, placement: r, onClose: n } = D();
84
- return /* @__PURE__ */ o.jsx(
85
- "div",
86
- {
87
- ref: a,
88
- role: "presentation",
89
- tabIndex: -1,
90
- "aria-modal": "true",
91
- onClick: n,
92
- className: l(
93
- E({ placement: r }),
94
- e ? "opacity-100" : "opacity-0 pointer-events-none"
95
- ),
96
- ...t
97
- }
98
- );
99
- }
100
- );
101
- function p(t, a, e) {
102
- const r = N(null);
103
- return R(() => {
104
- const n = (s) => {
105
- s.key === "Escape" && t && r.current && r.current.contains(document.activeElement) && !e && a();
106
- };
107
- return t && (document.addEventListener("keydown", n), document.body.style.overflow = "hidden", r.current?.focus()), () => {
108
- document.removeEventListener("keydown", n), document.body.style.overflow = "unset";
109
- };
110
- }, [t, a, e, r]), r;
111
- }
112
- const b = ({
113
- container: t,
114
- children: a
115
- }) => {
116
- if (typeof window > "u" || typeof document > "u")
117
- return /* @__PURE__ */ o.jsx(o.Fragment, { children: a });
118
- const e = t ?? document.body;
119
- return e ? C.createPortal(a, e) : /* @__PURE__ */ o.jsx(o.Fragment, { children: a });
120
- }, I = ({
121
- isOpen: t,
122
- onClose: a,
123
- size: e = "md",
124
- placement: r = "center",
125
- children: n,
126
- container: s,
127
- ...u
128
- }) => {
129
- const c = {
130
- isOpen: t,
131
- onClose: a,
132
- size: e,
133
- placement: r
134
- }, f = p(t, a);
135
- return /* @__PURE__ */ o.jsx(b, { container: s, children: /* @__PURE__ */ o.jsx(g.Provider, { value: c, children: /* @__PURE__ */ o.jsxs(
136
- "div",
137
- {
138
- className: l(
139
- "fixed z-50 inset-0 pointer-events-none",
140
- t && "pointer-events-auto"
141
- ),
142
- children: [
143
- /* @__PURE__ */ o.jsx(H, {}),
144
- /* @__PURE__ */ o.jsx(
145
- "div",
146
- {
147
- ref: f,
148
- className: l(F({ size: e, placement: r, isOpen: t })),
149
- role: "dialog",
150
- tabIndex: -1,
151
- "aria-hidden": !t,
152
- ...u,
153
- children: n
154
- }
155
- )
156
- ]
157
- }
158
- ) }) });
159
- }, ie = Object.assign(I, {
160
- Header: M,
161
- Body: z,
162
- Footer: S
163
- }), y = w(null);
164
- function x() {
165
- const t = h(y);
166
- if (!t)
167
- throw new Error(
168
- "Drawer components must be used within a DrawerRoot component"
169
- );
170
- return t;
171
- }
172
- const T = i(
173
- "fixed inset-0 z-50 transition-opacity duration-300 bg-foreground/30 backdrop-blur-md",
174
- {
175
- variants: {
176
- state: {
177
- open: "opacity-100",
178
- closed: "opacity-0 pointer-events-none"
179
- }
180
- },
181
- defaultVariants: {
182
- state: "closed"
183
- }
184
- }
185
- ), P = i("fixed z-50 shadow-xl flex flex-col", {
186
- variants: {
187
- position: {
188
- left: "left-0 top-0 bottom-0 border-r",
189
- right: "right-0 top-0 bottom-0 border-l"
190
- },
191
- size: {
192
- sm: "w-80",
193
- md: "w-96",
194
- lg: "w-[28rem]",
195
- xl: "w-[32rem]",
196
- "3/4": "w-[75vw]",
197
- full: "w-full"
198
- },
199
- variant: {
200
- default: "bg-white border-border",
201
- glass: "bg-white/10 backdrop-blur-lg border-white/20"
202
- },
203
- transitionType: {
204
- slide: "transition-transform duration-300 ease-in-out",
205
- fade: "transition-opacity duration-300 ease-in-out"
206
- }
207
- },
208
- defaultVariants: {
209
- position: "right",
210
- size: "md",
211
- variant: "default",
212
- transitionType: "slide"
213
- }
214
- }), L = i("flex-shrink-0 px-6", {
215
- variants: {
216
- variant: {
217
- default: "bg-white",
218
- glass: "bg-transparent "
219
- },
220
- tab: {
221
- true: "pt-4 pb-2",
222
- false: "border-b border-border py-4 "
223
- }
224
- },
225
- defaultVariants: {
226
- variant: "default",
227
- tab: !1
228
- }
229
- }), _ = i("flex-1 overflow-y-auto px-6 py-4", {
230
- variants: {
231
- variant: {
232
- default: "bg-white",
233
- glass: "bg-transparent"
234
- }
235
- },
236
- defaultVariants: {
237
- variant: "default"
238
- }
239
- }), q = i("flex-shrink-0 px-6 py-4 border-t", {
240
- variants: {
241
- variant: {
242
- default: "bg-white border-border",
243
- glass: "bg-transparent border-white/10"
244
- },
245
- responsiveFlex: {
246
- true: "flex flex-row gap-3 sm:justify-end [&>*]:sm:flex-grow-0 [&>*]:flex-grow",
247
- false: "flex gap-2"
248
- }
249
- },
250
- defaultVariants: {
251
- variant: "default",
252
- responsiveFlex: !0
253
- }
254
- }), A = m.forwardRef(({ className: t, ...a }, e) => {
255
- const { isOpen: r, onClose: n } = x(), s = () => {
256
- n();
257
- };
258
- return /* @__PURE__ */ o.jsx(
259
- "div",
260
- {
261
- ref: e,
262
- onClick: s,
263
- className: l(
264
- T({
265
- state: r ? "open" : "closed"
266
- }),
267
- t
268
- ),
269
- ...a
270
- }
271
- );
272
- }), G = m.forwardRef(
273
- ({ children: t, className: a, hasTab: e, ...r }, n) => {
274
- const { variant: s } = x();
275
- return /* @__PURE__ */ o.jsx(
276
- "div",
277
- {
278
- ref: n,
279
- className: l(
280
- L({ variant: s, tab: !!e }),
281
- a
282
- ),
283
- ...r,
284
- children: t
285
- }
286
- );
287
- }
288
- ), J = d(
289
- ({ children: t, className: a, ...e }, r) => /* @__PURE__ */ o.jsx("div", { ref: r, className: l("[&>div]:px-6", a), ...e, children: t })
290
- ), K = m.forwardRef(
291
- ({ children: t, className: a, ...e }, r) => {
292
- const { variant: n } = x();
293
- return /* @__PURE__ */ o.jsx(
294
- "div",
295
- {
296
- ref: r,
297
- className: l(_({ variant: n }), a),
298
- ...e,
299
- children: t
300
- }
301
- );
302
- }
303
- ), Q = m.forwardRef(
304
- ({ children: t, className: a, responsiveFlex: e = !0, ...r }, n) => {
305
- const { variant: s } = x();
306
- return /* @__PURE__ */ o.jsx(
307
- "div",
308
- {
309
- ref: n,
310
- className: l(
311
- q({ variant: s, responsiveFlex: e }),
312
- a
313
- ),
314
- ...r,
315
- children: t
316
- }
317
- );
318
- }
319
- ), U = ({
320
- container: t,
321
- children: a,
322
- isOpen: e,
323
- onClose: r,
324
- position: n = "right",
325
- size: s = "md",
326
- variant: u = "default",
327
- transitionType: c = "slide",
328
- className: f,
329
- ...j
330
- }) => {
331
- const v = k(() => {
332
- r(!1);
333
- }, [r]), V = {
334
- isOpen: e,
335
- onClose: v,
336
- position: n,
337
- size: s,
338
- variant: u,
339
- transitionType: c
340
- }, B = p(e, v);
341
- return /* @__PURE__ */ o.jsx(b, { container: t, children: /* @__PURE__ */ o.jsx(y.Provider, { value: V, children: /* @__PURE__ */ o.jsxs(
342
- "div",
343
- {
344
- className: l(
345
- "fixed z-50 inset-0 pointer-events-none",
346
- e && "pointer-events-auto"
347
- ),
348
- children: [
349
- /* @__PURE__ */ o.jsx(A, {}),
350
- /* @__PURE__ */ o.jsx(
351
- "div",
352
- {
353
- ref: B,
354
- tabIndex: -1,
355
- role: e ? "dialog" : void 0,
356
- "aria-modal": e ? "true" : void 0,
357
- className: l(
358
- P({
359
- position: n,
360
- size: s,
361
- variant: u,
362
- transitionType: c
363
- }),
364
- c === "slide" ? [
365
- !e && n === "left" && "-translate-x-full",
366
- !e && n === "right" && "translate-x-full"
367
- ] : [
368
- "left-0 right-0 top-0 bottom-0",
369
- e ? "opacity-100" : "opacity-0 pointer-events-none"
370
- ],
371
- f
372
- ),
373
- ...j,
374
- children: e && a
375
- }
376
- )
377
- ]
378
- }
379
- ) }) });
380
- }, de = Object.assign(U, {
381
- Header: G,
382
- Tab: J,
383
- Body: K,
384
- Footer: Q
385
- }), W = i(
386
- [
387
- "fixed left-0 bottom-0 z-40 w-full max-h-[90dvh] bg-background rounded-t-xl shadow-lg border-t border-border rounded-lg",
388
- "transition-transform duration-300 ease-in-out will-change-transform"
389
- ],
390
- {
391
- variants: {
392
- open: {
393
- true: "translate-y-0",
394
- false: "translate-y-full"
395
- }
396
- },
397
- defaultVariants: {
398
- open: !1
399
- }
400
- }
401
- ), X = i(
402
- ["fixed inset-0 z-40 duration-300"],
403
- {
404
- variants: {
405
- open: {
406
- true: "backdrop-blur-md bg-foreground/30",
407
- false: "pointer-events-none"
408
- }
409
- },
410
- defaultVariants: {
411
- open: !1
412
- }
413
- }
414
- ), Y = i("px-4 pt-4 pb-2"), Z = i("px-4 py-2"), $ = i("px-4 pt-2 pb-4"), O = d(function({ className: a, ...e }, r) {
415
- return /* @__PURE__ */ o.jsx(
416
- "h2",
417
- {
418
- ref: r,
419
- className: ["text-lg font-semibold text-foreground", a].filter(Boolean).join(" "),
420
- ...e
421
- }
422
- );
423
- }), ee = d(({ className: t, ...a }, e) => /* @__PURE__ */ o.jsx(
424
- "div",
425
- {
426
- ref: e,
427
- className: Y({ className: t }),
428
- ...a
429
- }
430
- )), te = d(
431
- ({ className: t, ...a }, e) => /* @__PURE__ */ o.jsx(
432
- "div",
433
- {
434
- ref: e,
435
- className: Z({ className: t }),
436
- ...a
437
- }
438
- )
439
- ), ae = d(({ className: t, ...a }, e) => /* @__PURE__ */ o.jsx(
440
- "div",
441
- {
442
- ref: e,
443
- className: $({ className: t }),
444
- ...a
445
- }
446
- )), oe = (...t) => (a) => {
447
- t.forEach((e) => {
448
- typeof e == "function" ? e(a) : e && "current" in e && (e.current = a);
449
- });
450
- }, re = d(
451
- ({ isOpen: t, children: a, className: e, onClose: r, container: n, ...s }, u) => {
452
- const c = p(t, r), f = () => {
453
- r?.();
454
- };
455
- return /* @__PURE__ */ o.jsxs(b, { container: n, children: [
456
- /* @__PURE__ */ o.jsx(
457
- "div",
458
- {
459
- className: X({ open: t }),
460
- "aria-hidden": "true",
461
- onClick: f
462
- }
463
- ),
464
- /* @__PURE__ */ o.jsx(
465
- "div",
466
- {
467
- ref: oe(u, c),
468
- className: l(
469
- W({
470
- open: t
471
- }),
472
- e
473
- ),
474
- role: "dialog",
475
- "aria-modal": "true",
476
- tabIndex: -1,
477
- ...s,
478
- children: a
479
- }
480
- )
481
- ] });
482
- }
483
- ), ce = Object.assign(re, {
484
- Header: ee,
485
- Title: O,
486
- Body: te,
487
- Footer: ae
488
- });
489
- export {
490
- ce as B,
491
- de as D,
492
- ie as M
493
- };