@dimasbaguspm/versaur 0.0.19 → 0.0.21

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.
Files changed (54) hide show
  1. package/README.md +22 -6
  2. package/dist/js/bottom-sheet-Eqduh3eY.js +495 -0
  3. package/dist/js/{selectable-multiple-input-CJXfqy1Z.js → bottom-sheet-input-DFGibm1I.js} +591 -476
  4. package/dist/js/forms/index.js +20 -17
  5. package/dist/js/{image-rectangle-CLU-GVtw.js → image-rectangle-C6cgL8R9.js} +354 -404
  6. package/dist/js/index.js +61 -53
  7. package/dist/js/layouts/index.js +5 -4
  8. package/dist/js/overlays/index.js +6 -4
  9. package/dist/js/primitive/index.js +15 -13
  10. package/dist/js/side-bar-BUACYQUo.js +397 -0
  11. package/dist/js/text-CRsIInRA.js +127 -0
  12. package/dist/js/tooltip-CDdl1U3A.js +148 -0
  13. package/dist/types/forms/bottom-sheet-input/bottom-sheet-input.d.ts +7 -0
  14. package/dist/types/forms/bottom-sheet-input/index.d.ts +2 -0
  15. package/dist/types/forms/bottom-sheet-input/types.d.ts +17 -0
  16. package/dist/types/forms/drawer-input/drawer-input.d.ts +6 -0
  17. package/dist/types/forms/drawer-input/index.d.ts +2 -0
  18. package/dist/types/forms/drawer-input/types.d.ts +18 -0
  19. package/dist/types/forms/index.d.ts +3 -0
  20. package/dist/types/forms/modal-input/index.d.ts +2 -0
  21. package/dist/types/forms/modal-input/modal-input.d.ts +6 -0
  22. package/dist/types/forms/modal-input/types.d.ts +18 -0
  23. package/dist/types/layouts/index.d.ts +1 -0
  24. package/dist/types/layouts/side-bar/index.d.ts +2 -0
  25. package/dist/types/layouts/side-bar/side-bar.atoms.d.ts +3 -0
  26. package/dist/types/layouts/side-bar/side-bar.d.ts +5 -0
  27. package/dist/types/layouts/side-bar/types.d.ts +42 -0
  28. package/dist/types/overlays/bottom-sheet/types.d.ts +2 -1
  29. package/dist/types/overlays/drawer/types.d.ts +2 -1
  30. package/dist/types/overlays/index.d.ts +1 -0
  31. package/dist/types/overlays/menu/menu.atoms.d.ts +5 -10
  32. package/dist/types/overlays/menu/menu.d.ts +2 -6
  33. package/dist/types/overlays/menu/types.d.ts +9 -14
  34. package/dist/types/overlays/menu/use-menu.d.ts +0 -1
  35. package/dist/types/overlays/modal/modal.d.ts +14 -5
  36. package/dist/types/overlays/modal/types.d.ts +7 -20
  37. package/dist/types/overlays/tooltip/index.d.ts +2 -0
  38. package/dist/types/overlays/tooltip/tooltip.d.ts +5 -0
  39. package/dist/types/overlays/tooltip/types.d.ts +33 -0
  40. package/dist/types/overlays/tooltip/use-tooltip-position.d.ts +8 -0
  41. package/dist/types/primitive/icon/types.d.ts +1 -1
  42. package/dist/types/primitive/index.d.ts +1 -0
  43. package/dist/types/primitive/no-results/index.d.ts +2 -0
  44. package/dist/types/primitive/no-results/no-results.d.ts +15 -0
  45. package/dist/types/primitive/no-results/types.d.ts +30 -0
  46. package/dist/types/primitive/table/table.atoms.d.ts +4 -6
  47. package/dist/types/primitive/table/table.d.ts +2 -1
  48. package/dist/types/primitive/table/types.d.ts +7 -4
  49. package/dist/utils/enforce-subpath-import.js +6 -0
  50. package/package.json +1 -1
  51. package/dist/js/bottom-sheet-BRv-oJL-.js +0 -646
  52. package/dist/js/form-layout-4ASWdXn8.js +0 -302
  53. package/dist/types/overlays/modal/use-escape-close.d.ts +0 -6
  54. package/dist/types/overlays/modal/use-focus-trap.d.ts +0 -6
package/README.md CHANGED
@@ -1,7 +1,21 @@
1
+
1
2
  # Versaur UI
2
3
 
3
- A modern React UI library built with TypeScript and Tailwind CSS, featuring tree-shakable
4
- components
4
+ <p align="left">
5
+ <a href="https://www.npmjs.com/package/@dimasbaguspm/versaur" target="_blank" rel="noopener noreferrer">
6
+ <img src="https://img.shields.io/npm/v/%40dimasbaguspm%2Fversaur?style=flat-square&color=%23e07a5f" alt="NPM Version" />
7
+ </a>
8
+ <a href="https://www.npmjs.com/package/@dimasbaguspm/versaur" target="_blank" rel="noopener noreferrer">
9
+ <img src="https://img.shields.io/npm/dy/%40dimasbaguspm%2Fversaur?style=flat-square&color=%2381b29a" alt="NPM Downloads" />
10
+ </a>
11
+ <a href="https://www.npmjs.com/package/@dimasbaguspm/versaur" target="_blank" rel="noopener noreferrer">
12
+ <img src="https://img.shields.io/npm/last-update/%40dimasbaguspm%2Fversaur?style=flat-square&color=%2384a5c0" alt="NPM Last Update" />
13
+ </a>
14
+ </p>
15
+
16
+ A modern React UI library built with TypeScript and Tailwind CSS, featuring tree-shakable components
17
+
18
+ Website: [versaur.dimasbaguspm.com](https://versaur.dimasbaguspm.com)
5
19
 
6
20
 
7
21
  ## Features
@@ -19,7 +33,9 @@ components
19
33
  ## Installation
20
34
 
21
35
  ```bash
22
- yarn install @dimasbaguspm/versaur
36
+ npm install @dimasbaguspm/versaur
37
+ yarn add @dimasbaguspm/versaur
38
+ bun add @dimasbaguspm/versaur
23
39
  ```
24
40
 
25
41
  ## Usage
@@ -27,13 +43,13 @@ yarn install @dimasbaguspm/versaur
27
43
  ### Import all components
28
44
 
29
45
  ```tsx
30
- import { Button, Input, Card } from '@dimasbaguspm/versaur'
46
+ import { Button, Input, Drawer } from '@dimasbaguspm/versaur'
31
47
  ```
32
48
 
33
49
  ### Tree-shakable imports
34
50
 
35
51
  ```tsx
36
- // Import only what you need
52
+ // import only what you need
37
53
  import { Button } from '@dimasbaguspm/versaur/primitive'
38
54
  ```
39
55
 
@@ -47,7 +63,7 @@ Versaur provides an ESLint rule to enforce sub-path imports for optimal tree-sha
47
63
  1. In your FlatConfig file (e.g., `eslint.config.js`), import and spread the rule:
48
64
 
49
65
  ```js
50
- // eslint.config.js
66
+ // eslint.config.{js|ts}
51
67
  import { versaurEnforceSubpathImport } from '@dimasbaguspm/versaur/enforce-subpath-import'
52
68
 
53
69
  export default [
@@ -0,0 +1,495 @@
1
+ import { c as i, j as o, a as l } from "./index-DOdDlCoL.js";
2
+ import m, { createContext as h, useContext as g, forwardRef as d, useRef as R, useEffect as w, useCallback as k } from "react";
3
+ import C from "react-dom";
4
+ const y = h(null);
5
+ function D() {
6
+ const t = g(y);
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 = R(null);
103
+ return w(() => {
104
+ r.current && r.current.focus();
105
+ }, []), w(() => {
106
+ const n = (s) => {
107
+ s.key === "Escape" && t && r.current && r.current.contains(document.activeElement) && !e && a();
108
+ };
109
+ return t && (document.addEventListener("keydown", n), document.body.style.overflow = "hidden"), () => {
110
+ document.removeEventListener("keydown", n), document.body.style.overflow = "unset";
111
+ };
112
+ }, [t, a, e, r]), r;
113
+ }
114
+ const b = ({
115
+ container: t,
116
+ children: a
117
+ }) => {
118
+ if (typeof window > "u" || typeof document > "u")
119
+ return /* @__PURE__ */ o.jsx(o.Fragment, { children: a });
120
+ const e = t ?? document.body;
121
+ return e ? C.createPortal(a, e) : /* @__PURE__ */ o.jsx(o.Fragment, { children: a });
122
+ }, I = ({
123
+ isOpen: t,
124
+ onClose: a,
125
+ size: e = "md",
126
+ placement: r = "center",
127
+ children: n,
128
+ container: s,
129
+ ...u
130
+ }) => {
131
+ const c = {
132
+ isOpen: t,
133
+ onClose: a,
134
+ size: e,
135
+ placement: r
136
+ }, f = p(t, a);
137
+ return /* @__PURE__ */ o.jsx(b, { container: s, children: /* @__PURE__ */ o.jsx(y.Provider, { value: c, children: /* @__PURE__ */ o.jsxs(
138
+ "div",
139
+ {
140
+ className: l(
141
+ "fixed z-50 inset-0 pointer-events-none",
142
+ t && "pointer-events-auto"
143
+ ),
144
+ children: [
145
+ /* @__PURE__ */ o.jsx(H, {}),
146
+ /* @__PURE__ */ o.jsx(
147
+ "div",
148
+ {
149
+ ref: f,
150
+ className: l(F({ size: e, placement: r, isOpen: t })),
151
+ role: "dialog",
152
+ tabIndex: -1,
153
+ "aria-hidden": !t,
154
+ ...u,
155
+ children: n
156
+ }
157
+ )
158
+ ]
159
+ }
160
+ ) }) });
161
+ }, ie = Object.assign(I, {
162
+ Header: M,
163
+ Body: z,
164
+ Footer: S
165
+ }), j = h(null);
166
+ function x() {
167
+ const t = g(j);
168
+ if (!t)
169
+ throw new Error(
170
+ "Drawer components must be used within a DrawerRoot component"
171
+ );
172
+ return t;
173
+ }
174
+ const T = i(
175
+ "fixed inset-0 z-50 transition-opacity duration-300 bg-foreground/30 backdrop-blur-md",
176
+ {
177
+ variants: {
178
+ state: {
179
+ open: "opacity-100",
180
+ closed: "opacity-0 pointer-events-none"
181
+ }
182
+ },
183
+ defaultVariants: {
184
+ state: "closed"
185
+ }
186
+ }
187
+ ), P = i("fixed z-50 shadow-xl flex flex-col", {
188
+ variants: {
189
+ position: {
190
+ left: "left-0 top-0 bottom-0 border-r",
191
+ right: "right-0 top-0 bottom-0 border-l"
192
+ },
193
+ size: {
194
+ sm: "w-80",
195
+ md: "w-96",
196
+ lg: "w-[28rem]",
197
+ xl: "w-[32rem]",
198
+ "3/4": "w-[75vw]",
199
+ full: "w-full"
200
+ },
201
+ variant: {
202
+ default: "bg-white border-border",
203
+ glass: "bg-white/10 backdrop-blur-lg border-white/20"
204
+ },
205
+ transitionType: {
206
+ slide: "transition-transform duration-300 ease-in-out",
207
+ fade: "transition-opacity duration-300 ease-in-out"
208
+ }
209
+ },
210
+ defaultVariants: {
211
+ position: "right",
212
+ size: "md",
213
+ variant: "default",
214
+ transitionType: "slide"
215
+ }
216
+ }), L = i("flex-shrink-0 px-6", {
217
+ variants: {
218
+ variant: {
219
+ default: "bg-white",
220
+ glass: "bg-transparent "
221
+ },
222
+ tab: {
223
+ true: "pt-4 pb-2",
224
+ false: "border-b border-border py-4 "
225
+ }
226
+ },
227
+ defaultVariants: {
228
+ variant: "default",
229
+ tab: !1
230
+ }
231
+ }), _ = i("flex-1 overflow-y-auto px-6 py-4", {
232
+ variants: {
233
+ variant: {
234
+ default: "bg-white",
235
+ glass: "bg-transparent"
236
+ }
237
+ },
238
+ defaultVariants: {
239
+ variant: "default"
240
+ }
241
+ }), q = i("flex-shrink-0 px-6 py-4 border-t", {
242
+ variants: {
243
+ variant: {
244
+ default: "bg-white border-border",
245
+ glass: "bg-transparent border-white/10"
246
+ },
247
+ responsiveFlex: {
248
+ true: "flex flex-row gap-3 sm:justify-end [&>*]:sm:flex-grow-0 [&>*]:flex-grow",
249
+ false: "flex gap-2"
250
+ }
251
+ },
252
+ defaultVariants: {
253
+ variant: "default",
254
+ responsiveFlex: !0
255
+ }
256
+ }), A = m.forwardRef(({ className: t, ...a }, e) => {
257
+ const { isOpen: r, onClose: n } = x(), s = () => {
258
+ n();
259
+ };
260
+ return /* @__PURE__ */ o.jsx(
261
+ "div",
262
+ {
263
+ ref: e,
264
+ onClick: s,
265
+ className: l(
266
+ T({
267
+ state: r ? "open" : "closed"
268
+ }),
269
+ t
270
+ ),
271
+ ...a
272
+ }
273
+ );
274
+ }), G = m.forwardRef(
275
+ ({ children: t, className: a, hasTab: e, ...r }, n) => {
276
+ const { variant: s } = x();
277
+ return /* @__PURE__ */ o.jsx(
278
+ "div",
279
+ {
280
+ ref: n,
281
+ className: l(
282
+ L({ variant: s, tab: !!e }),
283
+ a
284
+ ),
285
+ ...r,
286
+ children: t
287
+ }
288
+ );
289
+ }
290
+ ), J = d(
291
+ ({ children: t, className: a, ...e }, r) => /* @__PURE__ */ o.jsx("div", { ref: r, className: l("[&>div]:px-6", a), ...e, children: t })
292
+ ), K = m.forwardRef(
293
+ ({ children: t, className: a, ...e }, r) => {
294
+ const { variant: n } = x();
295
+ return /* @__PURE__ */ o.jsx(
296
+ "div",
297
+ {
298
+ ref: r,
299
+ className: l(_({ variant: n }), a),
300
+ ...e,
301
+ children: t
302
+ }
303
+ );
304
+ }
305
+ ), Q = m.forwardRef(
306
+ ({ children: t, className: a, responsiveFlex: e = !0, ...r }, n) => {
307
+ const { variant: s } = x();
308
+ return /* @__PURE__ */ o.jsx(
309
+ "div",
310
+ {
311
+ ref: n,
312
+ className: l(
313
+ q({ variant: s, responsiveFlex: e }),
314
+ a
315
+ ),
316
+ ...r,
317
+ children: t
318
+ }
319
+ );
320
+ }
321
+ ), U = ({
322
+ container: t,
323
+ children: a,
324
+ isOpen: e,
325
+ onClose: r,
326
+ position: n = "right",
327
+ size: s = "md",
328
+ variant: u = "default",
329
+ transitionType: c = "slide",
330
+ className: f,
331
+ ...V
332
+ }) => {
333
+ const v = k(() => {
334
+ r(!1);
335
+ }, [r]), B = {
336
+ isOpen: e,
337
+ onClose: v,
338
+ position: n,
339
+ size: s,
340
+ variant: u,
341
+ transitionType: c
342
+ }, N = p(e, v);
343
+ return /* @__PURE__ */ o.jsx(b, { container: t, children: /* @__PURE__ */ o.jsx(j.Provider, { value: B, children: /* @__PURE__ */ o.jsxs(
344
+ "div",
345
+ {
346
+ className: l(
347
+ "fixed z-50 inset-0 pointer-events-none",
348
+ e && "pointer-events-auto"
349
+ ),
350
+ children: [
351
+ /* @__PURE__ */ o.jsx(A, {}),
352
+ /* @__PURE__ */ o.jsx(
353
+ "div",
354
+ {
355
+ ref: N,
356
+ tabIndex: -1,
357
+ role: e ? "dialog" : void 0,
358
+ "aria-modal": e ? "true" : void 0,
359
+ className: l(
360
+ P({
361
+ position: n,
362
+ size: s,
363
+ variant: u,
364
+ transitionType: c
365
+ }),
366
+ c === "slide" ? [
367
+ !e && n === "left" && "-translate-x-full",
368
+ !e && n === "right" && "translate-x-full"
369
+ ] : [
370
+ "left-0 right-0 top-0 bottom-0",
371
+ e ? "opacity-100" : "opacity-0 pointer-events-none"
372
+ ],
373
+ f
374
+ ),
375
+ ...V,
376
+ children: e && a
377
+ }
378
+ )
379
+ ]
380
+ }
381
+ ) }) });
382
+ }, de = Object.assign(U, {
383
+ Header: G,
384
+ Tab: J,
385
+ Body: K,
386
+ Footer: Q
387
+ }), W = i(
388
+ [
389
+ "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",
390
+ "transition-transform duration-300 ease-in-out will-change-transform"
391
+ ],
392
+ {
393
+ variants: {
394
+ open: {
395
+ true: "translate-y-0",
396
+ false: "translate-y-full"
397
+ }
398
+ },
399
+ defaultVariants: {
400
+ open: !1
401
+ }
402
+ }
403
+ ), X = i(
404
+ ["fixed inset-0 z-40 duration-300"],
405
+ {
406
+ variants: {
407
+ open: {
408
+ true: "backdrop-blur-md bg-foreground/30",
409
+ false: "pointer-events-none"
410
+ }
411
+ },
412
+ defaultVariants: {
413
+ open: !1
414
+ }
415
+ }
416
+ ), 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) {
417
+ return /* @__PURE__ */ o.jsx(
418
+ "h2",
419
+ {
420
+ ref: r,
421
+ className: ["text-lg font-semibold text-foreground", a].filter(Boolean).join(" "),
422
+ ...e
423
+ }
424
+ );
425
+ }), ee = d(({ className: t, ...a }, e) => /* @__PURE__ */ o.jsx(
426
+ "div",
427
+ {
428
+ ref: e,
429
+ className: Y({ className: t }),
430
+ ...a
431
+ }
432
+ )), te = d(
433
+ ({ className: t, ...a }, e) => /* @__PURE__ */ o.jsx(
434
+ "div",
435
+ {
436
+ ref: e,
437
+ className: Z({ className: t }),
438
+ ...a
439
+ }
440
+ )
441
+ ), ae = d(({ className: t, ...a }, e) => /* @__PURE__ */ o.jsx(
442
+ "div",
443
+ {
444
+ ref: e,
445
+ className: $({ className: t }),
446
+ ...a
447
+ }
448
+ )), oe = (...t) => (a) => {
449
+ t.forEach((e) => {
450
+ typeof e == "function" ? e(a) : e && "current" in e && (e.current = a);
451
+ });
452
+ }, re = d(
453
+ ({ isOpen: t, children: a, className: e, onClose: r, container: n, ...s }, u) => {
454
+ const c = p(t, r), f = () => {
455
+ r?.();
456
+ };
457
+ return /* @__PURE__ */ o.jsxs(b, { container: n, children: [
458
+ /* @__PURE__ */ o.jsx(
459
+ "div",
460
+ {
461
+ className: X({ open: t }),
462
+ "aria-hidden": "true",
463
+ onClick: f
464
+ }
465
+ ),
466
+ /* @__PURE__ */ o.jsx(
467
+ "div",
468
+ {
469
+ ref: oe(u, c),
470
+ className: l(
471
+ W({
472
+ open: t
473
+ }),
474
+ e
475
+ ),
476
+ role: "dialog",
477
+ "aria-modal": "true",
478
+ tabIndex: -1,
479
+ ...s,
480
+ children: a
481
+ }
482
+ )
483
+ ] });
484
+ }
485
+ ), ce = Object.assign(re, {
486
+ Header: ee,
487
+ Title: O,
488
+ Body: te,
489
+ Footer: ae
490
+ });
491
+ export {
492
+ ce as B,
493
+ de as D,
494
+ ie as M
495
+ };