@arolariu/components 0.1.2 → 0.3.0

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 (360) hide show
  1. package/DEBUGGING.md +396 -396
  2. package/LICENSE.md +21 -21
  3. package/changelog.md +120 -118
  4. package/dist/components/ui/accordion.d.ts +6 -6
  5. package/dist/components/ui/accordion.d.ts.map +1 -1
  6. package/dist/components/ui/accordion.js +20 -28
  7. package/dist/components/ui/accordion.js.map +1 -1
  8. package/dist/components/ui/alert-dialog.d.ts +19 -13
  9. package/dist/components/ui/alert-dialog.d.ts.map +1 -1
  10. package/dist/components/ui/alert-dialog.js +40 -63
  11. package/dist/components/ui/alert-dialog.js.map +1 -1
  12. package/dist/components/ui/alert.d.ts +7 -8
  13. package/dist/components/ui/alert.d.ts.map +1 -1
  14. package/dist/components/ui/alert.js +18 -21
  15. package/dist/components/ui/alert.js.map +1 -1
  16. package/dist/components/ui/aspect-ratio.d.ts +1 -2
  17. package/dist/components/ui/aspect-ratio.d.ts.map +1 -1
  18. package/dist/components/ui/aspect-ratio.js +1 -8
  19. package/dist/components/ui/aspect-ratio.js.map +1 -1
  20. package/dist/components/ui/avatar.d.ts +5 -5
  21. package/dist/components/ui/avatar.d.ts.map +1 -1
  22. package/dist/components/ui/avatar.js +17 -20
  23. package/dist/components/ui/avatar.js.map +1 -1
  24. package/dist/components/ui/background-beams.d.ts.map +1 -1
  25. package/dist/components/ui/background-beams.js +6 -6
  26. package/dist/components/ui/background-beams.js.map +1 -1
  27. package/dist/components/ui/badge.d.ts +7 -7
  28. package/dist/components/ui/badge.d.ts.map +1 -1
  29. package/dist/components/ui/badge.js +9 -12
  30. package/dist/components/ui/badge.js.map +1 -1
  31. package/dist/components/ui/breadcrumb.d.ts +17 -9
  32. package/dist/components/ui/breadcrumb.d.ts.map +1 -1
  33. package/dist/components/ui/breadcrumb.js +32 -39
  34. package/dist/components/ui/breadcrumb.js.map +1 -1
  35. package/dist/components/ui/bubble-background.d.ts +1 -1
  36. package/dist/components/ui/bubble-background.d.ts.map +1 -1
  37. package/dist/components/ui/bubble-background.js +13 -13
  38. package/dist/components/ui/bubble-background.js.map +1 -1
  39. package/dist/components/ui/button-group.d.ts +13 -0
  40. package/dist/components/ui/button-group.d.ts.map +1 -0
  41. package/dist/components/ui/button-group.js +47 -0
  42. package/dist/components/ui/button-group.js.map +1 -0
  43. package/dist/components/ui/button.d.ts +8 -7
  44. package/dist/components/ui/button.d.ts.map +1 -1
  45. package/dist/components/ui/button.js +16 -15
  46. package/dist/components/ui/button.js.map +1 -1
  47. package/dist/components/ui/calendar.d.ts.map +1 -1
  48. package/dist/components/ui/calendar.js +22 -22
  49. package/dist/components/ui/calendar.js.map +1 -1
  50. package/dist/components/ui/card.d.ts +7 -8
  51. package/dist/components/ui/card.d.ts.map +1 -1
  52. package/dist/components/ui/card.js +33 -46
  53. package/dist/components/ui/card.js.map +1 -1
  54. package/dist/components/ui/carousel.d.ts +7 -8
  55. package/dist/components/ui/carousel.d.ts.map +1 -1
  56. package/dist/components/ui/carousel.js +30 -21
  57. package/dist/components/ui/carousel.js.map +1 -1
  58. package/dist/components/ui/chart.d.ts +37 -29
  59. package/dist/components/ui/chart.d.ts.map +1 -1
  60. package/dist/components/ui/chart.js +29 -27
  61. package/dist/components/ui/chart.js.map +1 -1
  62. package/dist/components/ui/checkbox.d.ts +2 -2
  63. package/dist/components/ui/checkbox.d.ts.map +1 -1
  64. package/dist/components/ui/checkbox.js +11 -13
  65. package/dist/components/ui/checkbox.js.map +1 -1
  66. package/dist/components/ui/collapsible.d.ts +4 -5
  67. package/dist/components/ui/collapsible.d.ts.map +1 -1
  68. package/dist/components/ui/collapsible.js +3 -20
  69. package/dist/components/ui/collapsible.js.map +1 -1
  70. package/dist/components/ui/command.d.ts +79 -17
  71. package/dist/components/ui/command.d.ts.map +1 -1
  72. package/dist/components/ui/command.js +52 -77
  73. package/dist/components/ui/command.js.map +1 -1
  74. package/dist/components/ui/context-menu.d.ts +23 -21
  75. package/dist/components/ui/context-menu.d.ts.map +1 -1
  76. package/dist/components/ui/context-menu.js +60 -104
  77. package/dist/components/ui/context-menu.js.map +1 -1
  78. package/dist/components/ui/counting-number.d.ts +1 -1
  79. package/dist/components/ui/counting-number.d.ts.map +1 -1
  80. package/dist/components/ui/counting-number.js +4 -3
  81. package/dist/components/ui/counting-number.js.map +1 -1
  82. package/dist/components/ui/dialog.d.ts +17 -13
  83. package/dist/components/ui/dialog.d.ts.map +1 -1
  84. package/dist/components/ui/dialog.js +38 -66
  85. package/dist/components/ui/dialog.js.map +1 -1
  86. package/dist/components/ui/dot-background.d.ts +10 -17
  87. package/dist/components/ui/dot-background.d.ts.map +1 -1
  88. package/dist/components/ui/dot-background.js +2 -2
  89. package/dist/components/ui/dot-background.js.map +1 -1
  90. package/dist/components/ui/drawer.d.ts +20 -11
  91. package/dist/components/ui/drawer.d.ts.map +1 -1
  92. package/dist/components/ui/drawer.js +37 -62
  93. package/dist/components/ui/drawer.js.map +1 -1
  94. package/dist/components/ui/dropdown-menu.d.ts +23 -21
  95. package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
  96. package/dist/components/ui/dropdown-menu.js +65 -109
  97. package/dist/components/ui/dropdown-menu.js.map +1 -1
  98. package/dist/components/ui/dropdrawer.d.ts +3 -3
  99. package/dist/components/ui/dropdrawer.d.ts.map +1 -1
  100. package/dist/components/ui/dropdrawer.js +13 -16
  101. package/dist/components/ui/dropdrawer.js.map +1 -1
  102. package/dist/components/ui/empty.d.ts +13 -0
  103. package/dist/components/ui/empty.d.ts.map +1 -0
  104. package/dist/components/ui/empty.js +65 -0
  105. package/dist/components/ui/empty.js.map +1 -0
  106. package/dist/components/ui/field.d.ts +25 -0
  107. package/dist/components/ui/field.d.ts.map +1 -0
  108. package/dist/components/ui/field.js +135 -0
  109. package/dist/components/ui/field.js.map +1 -0
  110. package/dist/components/ui/fireworks-background.d.ts.map +1 -1
  111. package/dist/components/ui/fireworks-background.js +1 -1
  112. package/dist/components/ui/fireworks-background.js.map +1 -1
  113. package/dist/components/ui/flip-button.d.ts +1 -1
  114. package/dist/components/ui/flip-button.d.ts.map +1 -1
  115. package/dist/components/ui/flip-button.js +3 -3
  116. package/dist/components/ui/flip-button.js.map +1 -1
  117. package/dist/components/ui/form.d.ts +7 -8
  118. package/dist/components/ui/form.d.ts.map +1 -1
  119. package/dist/components/ui/form.js +29 -28
  120. package/dist/components/ui/form.js.map +1 -1
  121. package/dist/components/ui/gradient-background.d.ts +1 -1
  122. package/dist/components/ui/gradient-background.d.ts.map +1 -1
  123. package/dist/components/ui/gradient-background.js +2 -2
  124. package/dist/components/ui/gradient-background.js.map +1 -1
  125. package/dist/components/ui/gradient-text.d.ts +1 -1
  126. package/dist/components/ui/gradient-text.d.ts.map +1 -1
  127. package/dist/components/ui/gradient-text.js +5 -5
  128. package/dist/components/ui/gradient-text.js.map +1 -1
  129. package/dist/components/ui/highlight-text.d.ts +1 -1
  130. package/dist/components/ui/highlight-text.d.ts.map +1 -1
  131. package/dist/components/ui/highlight-text.js +3 -3
  132. package/dist/components/ui/highlight-text.js.map +1 -1
  133. package/dist/components/ui/hole-background.d.ts.map +1 -1
  134. package/dist/components/ui/hole-background.js +11 -10
  135. package/dist/components/ui/hole-background.js.map +1 -1
  136. package/dist/components/ui/hover-card.d.ts +5 -5
  137. package/dist/components/ui/hover-card.d.ts.map +1 -1
  138. package/dist/components/ui/hover-card.js +12 -26
  139. package/dist/components/ui/hover-card.js.map +1 -1
  140. package/dist/components/ui/input-group.d.ts +17 -0
  141. package/dist/components/ui/input-group.d.ts.map +1 -0
  142. package/dist/components/ui/input-group.js +91 -0
  143. package/dist/components/ui/input-group.js.map +1 -0
  144. package/dist/components/ui/input-otp.d.ts +31 -8
  145. package/dist/components/ui/input-otp.d.ts.map +1 -1
  146. package/dist/components/ui/input-otp.js +24 -27
  147. package/dist/components/ui/input-otp.js.map +1 -1
  148. package/dist/components/ui/input.d.ts +1 -1
  149. package/dist/components/ui/input.d.ts.map +1 -1
  150. package/dist/components/ui/input.js +7 -8
  151. package/dist/components/ui/input.js.map +1 -1
  152. package/dist/components/ui/item.d.ts +24 -0
  153. package/dist/components/ui/item.d.ts.map +1 -0
  154. package/dist/components/ui/item.js +122 -0
  155. package/dist/components/ui/item.js.map +1 -0
  156. package/dist/components/ui/kbd.d.ts +5 -0
  157. package/dist/components/ui/kbd.d.ts.map +1 -0
  158. package/dist/components/ui/kbd.js +21 -0
  159. package/dist/components/ui/kbd.js.map +1 -0
  160. package/dist/components/ui/label.d.ts +3 -2
  161. package/dist/components/ui/label.d.ts.map +1 -1
  162. package/dist/components/ui/label.js +9 -8
  163. package/dist/components/ui/label.js.map +1 -1
  164. package/dist/components/ui/menubar.d.ts +20 -18
  165. package/dist/components/ui/menubar.d.ts.map +1 -1
  166. package/dist/components/ui/menubar.js +75 -95
  167. package/dist/components/ui/menubar.js.map +1 -1
  168. package/dist/components/ui/navigation-menu.d.ts +11 -13
  169. package/dist/components/ui/navigation-menu.d.ts.map +1 -1
  170. package/dist/components/ui/navigation-menu.js +39 -58
  171. package/dist/components/ui/navigation-menu.js.map +1 -1
  172. package/dist/components/ui/pagination.d.ts +25 -10
  173. package/dist/components/ui/pagination.d.ts.map +1 -1
  174. package/dist/components/ui/pagination.js +33 -41
  175. package/dist/components/ui/pagination.js.map +1 -1
  176. package/dist/components/ui/popover.d.ts +6 -6
  177. package/dist/components/ui/popover.d.ts.map +1 -1
  178. package/dist/components/ui/popover.js +10 -26
  179. package/dist/components/ui/popover.js.map +1 -1
  180. package/dist/components/ui/progress.d.ts +2 -2
  181. package/dist/components/ui/progress.d.ts.map +1 -1
  182. package/dist/components/ui/progress.js +8 -10
  183. package/dist/components/ui/progress.js.map +1 -1
  184. package/dist/components/ui/radio-group.d.ts +3 -3
  185. package/dist/components/ui/radio-group.d.ts.map +1 -1
  186. package/dist/components/ui/radio-group.js +17 -20
  187. package/dist/components/ui/radio-group.js.map +1 -1
  188. package/dist/components/ui/resizable.d.ts +21 -6
  189. package/dist/components/ui/resizable.d.ts.map +1 -1
  190. package/dist/components/ui/resizable.js +9 -21
  191. package/dist/components/ui/resizable.js.map +1 -1
  192. package/dist/components/ui/ripple-button.d.ts +1 -1
  193. package/dist/components/ui/ripple-button.d.ts.map +1 -1
  194. package/dist/components/ui/ripple-button.js +4 -4
  195. package/dist/components/ui/ripple-button.js.map +1 -1
  196. package/dist/components/ui/scratcher.d.ts.map +1 -1
  197. package/dist/components/ui/scratcher.js +7 -5
  198. package/dist/components/ui/scratcher.js.map +1 -1
  199. package/dist/components/ui/scroll-area.d.ts +3 -3
  200. package/dist/components/ui/scroll-area.d.ts.map +1 -1
  201. package/dist/components/ui/scroll-area.js +14 -18
  202. package/dist/components/ui/scroll-area.js.map +1 -1
  203. package/dist/components/ui/select.d.ts +11 -13
  204. package/dist/components/ui/select.d.ts.map +1 -1
  205. package/dist/components/ui/select.js +55 -78
  206. package/dist/components/ui/select.js.map +1 -1
  207. package/dist/components/ui/separator.d.ts +2 -2
  208. package/dist/components/ui/separator.d.ts.map +1 -1
  209. package/dist/components/ui/separator.js +7 -8
  210. package/dist/components/ui/separator.js.map +1 -1
  211. package/dist/components/ui/sheet.d.ts +24 -12
  212. package/dist/components/ui/sheet.d.ts.map +1 -1
  213. package/dist/components/ui/sheet.js +56 -68
  214. package/dist/components/ui/sheet.js.map +1 -1
  215. package/dist/components/ui/sidebar.d.ts +35 -39
  216. package/dist/components/ui/sidebar.d.ts.map +1 -1
  217. package/dist/components/ui/sidebar.js +115 -124
  218. package/dist/components/ui/sidebar.js.map +1 -1
  219. package/dist/components/ui/skeleton.d.ts +1 -1
  220. package/dist/components/ui/skeleton.d.ts.map +1 -1
  221. package/dist/components/ui/skeleton.js +2 -3
  222. package/dist/components/ui/skeleton.js.map +1 -1
  223. package/dist/components/ui/slider.d.ts +2 -2
  224. package/dist/components/ui/slider.d.ts.map +1 -1
  225. package/dist/components/ui/slider.js +12 -31
  226. package/dist/components/ui/slider.js.map +1 -1
  227. package/dist/components/ui/sonner.d.ts +4 -2
  228. package/dist/components/ui/sonner.d.ts.map +1 -1
  229. package/dist/components/ui/sonner.js +8 -5
  230. package/dist/components/ui/sonner.js.map +1 -1
  231. package/dist/components/ui/spinner.d.ts +4 -0
  232. package/dist/components/ui/spinner.d.ts.map +1 -0
  233. package/dist/components/ui/spinner.js +16 -0
  234. package/dist/components/ui/spinner.js.map +1 -0
  235. package/dist/components/ui/switch.d.ts +2 -2
  236. package/dist/components/ui/switch.d.ts.map +1 -1
  237. package/dist/components/ui/switch.js +8 -10
  238. package/dist/components/ui/switch.js.map +1 -1
  239. package/dist/components/ui/table.d.ts +9 -9
  240. package/dist/components/ui/table.d.ts.map +1 -1
  241. package/dist/components/ui/table.js +40 -49
  242. package/dist/components/ui/table.js.map +1 -1
  243. package/dist/components/ui/tabs.d.ts +6 -6
  244. package/dist/components/ui/tabs.d.ts.map +1 -1
  245. package/dist/components/ui/tabs.js +18 -27
  246. package/dist/components/ui/tabs.js.map +1 -1
  247. package/dist/components/ui/textarea.d.ts +1 -1
  248. package/dist/components/ui/textarea.d.ts.map +1 -1
  249. package/dist/components/ui/textarea.js +7 -8
  250. package/dist/components/ui/textarea.js.map +1 -1
  251. package/dist/components/ui/toggle-group.d.ts +9 -4
  252. package/dist/components/ui/toggle-group.d.ts.map +1 -1
  253. package/dist/components/ui/toggle-group.js +12 -16
  254. package/dist/components/ui/toggle-group.js.map +1 -1
  255. package/dist/components/ui/toggle.d.ts +9 -6
  256. package/dist/components/ui/toggle.d.ts.map +1 -1
  257. package/dist/components/ui/toggle.js +8 -9
  258. package/dist/components/ui/toggle.js.map +1 -1
  259. package/dist/components/ui/tooltip.d.ts +6 -6
  260. package/dist/components/ui/tooltip.d.ts.map +1 -1
  261. package/dist/components/ui/tooltip.js +14 -39
  262. package/dist/components/ui/tooltip.js.map +1 -1
  263. package/dist/components/ui/typewriter.d.ts.map +1 -1
  264. package/dist/components/ui/typewriter.js +9 -9
  265. package/dist/components/ui/typewriter.js.map +1 -1
  266. package/dist/hooks/useIsMobile.d.ts +2 -5
  267. package/dist/hooks/useIsMobile.d.ts.map +1 -1
  268. package/dist/hooks/useIsMobile.js +1 -1
  269. package/dist/hooks/useIsMobile.js.map +1 -1
  270. package/dist/hooks/useWindowSize.d.ts +0 -1
  271. package/dist/hooks/useWindowSize.d.ts.map +1 -1
  272. package/dist/hooks/useWindowSize.js +1 -1
  273. package/dist/hooks/useWindowSize.js.map +1 -1
  274. package/dist/index.css +841 -1128
  275. package/dist/index.css.map +1 -1
  276. package/dist/index.d.ts +43 -37
  277. package/dist/index.d.ts.map +1 -1
  278. package/dist/index.js +11 -5
  279. package/dist/lib/utilities.d.ts +9 -0
  280. package/dist/lib/utilities.d.ts.map +1 -0
  281. package/dist/lib/{utils.js → utilities.js} +1 -1
  282. package/dist/lib/utilities.js.map +1 -0
  283. package/package.json +121 -90
  284. package/{README.md → readme.md} +627 -627
  285. package/src/components/ui/accordion.tsx +55 -66
  286. package/src/components/ui/alert-dialog.tsx +124 -160
  287. package/src/components/ui/alert.tsx +56 -69
  288. package/src/components/ui/aspect-ratio.tsx +7 -12
  289. package/src/components/ui/avatar.tsx +43 -53
  290. package/src/components/ui/background-beams.tsx +145 -142
  291. package/src/components/ui/badge.tsx +39 -48
  292. package/src/components/ui/breadcrumb.tsx +94 -117
  293. package/src/components/ui/bubble-background.tsx +170 -189
  294. package/src/components/ui/button-group.tsx +69 -0
  295. package/src/components/ui/button.tsx +55 -61
  296. package/src/components/ui/calendar.tsx +175 -216
  297. package/src/components/ui/card.tsx +64 -97
  298. package/src/components/ui/carousel.tsx +216 -241
  299. package/src/components/ui/chart.tsx +293 -385
  300. package/src/components/ui/checkbox.tsx +27 -32
  301. package/src/components/ui/collapsible.tsx +11 -34
  302. package/src/components/ui/command.tsx +138 -184
  303. package/src/components/ui/context-menu.tsx +186 -255
  304. package/src/components/ui/counting-number.tsx +92 -108
  305. package/src/components/ui/dialog.tsx +106 -146
  306. package/src/components/ui/dot-background.tsx +153 -158
  307. package/src/components/ui/drawer.tsx +105 -141
  308. package/src/components/ui/dropdown-menu.tsx +188 -260
  309. package/src/components/ui/dropdrawer.tsx +865 -973
  310. package/src/components/ui/empty.tsx +86 -0
  311. package/src/components/ui/field.tsx +198 -0
  312. package/src/components/ui/fireworks-background.tsx +325 -378
  313. package/src/components/ui/flip-button.tsx +89 -110
  314. package/src/components/ui/form.tsx +144 -174
  315. package/src/components/ui/gradient-background.tsx +30 -43
  316. package/src/components/ui/gradient-text.tsx +62 -65
  317. package/src/components/ui/highlight-text.tsx +54 -71
  318. package/src/components/ui/hole-background.tsx +326 -361
  319. package/src/components/ui/hover-card.tsx +29 -44
  320. package/src/components/ui/input-group.tsx +145 -0
  321. package/src/components/ui/input-otp.tsx +66 -77
  322. package/src/components/ui/input.tsx +21 -22
  323. package/src/components/ui/item.tsx +163 -0
  324. package/src/components/ui/kbd.tsx +31 -0
  325. package/src/components/ui/label.tsx +23 -24
  326. package/src/components/ui/menubar.tsx +233 -279
  327. package/src/components/ui/navigation-menu.tsx +120 -171
  328. package/src/components/ui/pagination.tsx +92 -129
  329. package/src/components/ui/popover.tsx +33 -48
  330. package/src/components/ui/progress.tsx +24 -31
  331. package/src/components/ui/radio-group.tsx +43 -45
  332. package/src/components/ui/resizable.tsx +38 -56
  333. package/src/components/ui/ripple-button.tsx +90 -111
  334. package/src/components/ui/scratcher.tsx +167 -171
  335. package/src/components/ui/scroll-area.tsx +42 -58
  336. package/src/components/ui/select.tsx +145 -191
  337. package/src/components/ui/separator.tsx +26 -28
  338. package/src/components/ui/sheet.tsx +112 -145
  339. package/src/components/ui/sidebar.tsx +664 -729
  340. package/src/components/ui/skeleton.tsx +15 -19
  341. package/src/components/ui/slider.tsx +23 -63
  342. package/src/components/ui/sonner.tsx +36 -26
  343. package/src/components/ui/spinner.tsx +18 -0
  344. package/src/components/ui/switch.tsx +28 -31
  345. package/src/components/ui/table.tsx +93 -119
  346. package/src/components/ui/tabs.tsx +54 -66
  347. package/src/components/ui/textarea.tsx +21 -20
  348. package/src/components/ui/toggle-group.tsx +53 -73
  349. package/src/components/ui/toggle.tsx +44 -47
  350. package/src/components/ui/tooltip.tsx +32 -61
  351. package/src/components/ui/typewriter.tsx +173 -188
  352. package/src/hooks/useIsMobile.tsx +42 -45
  353. package/src/hooks/useWindowSize.tsx +66 -72
  354. package/src/index.css +67 -67
  355. package/src/index.ts +342 -408
  356. package/src/lib/utilities.ts +12 -0
  357. package/dist/lib/utils.d.ts +0 -7
  358. package/dist/lib/utils.d.ts.map +0 -1
  359. package/dist/lib/utils.js.map +0 -1
  360. package/src/lib/utils.ts +0 -10
@@ -1,110 +1,89 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import {
5
- type HTMLMotionProps,
6
- type Transition,
7
- type Variant,
8
- motion,
9
- } from "motion/react";
10
-
11
- import { cn } from "@/lib/utils";
12
-
13
- type FlipDirection = "top" | "bottom" | "left" | "righ";
14
-
15
- interface FlipButtonProps extends HTMLMotionProps<"button"> {
16
- frontText: string;
17
- backText: string;
18
- transition?: Transition;
19
- frontClassName?: string;
20
- backClassName?: string;
21
- from?: FlipDirection;
22
- }
23
-
24
- const defaultSpanClassName =
25
- "absolute inset-0 flex items-center justify-center rounded-lg";
26
-
27
- const FlipButton = React.forwardRef<HTMLButtonElement, FlipButtonProps>(
28
- (
29
- {
30
- frontText,
31
- backText,
32
- transition = { type: "spring", stiffness: 280, damping: 20 },
33
- className,
34
- frontClassName,
35
- backClassName,
36
- from = "top",
37
- ...props
38
- },
39
- ref,
40
- ) => {
41
- const isVertical = from === "top" || from === "bottom";
42
- const rotateAxis = isVertical ? "rotateX" : "rotateY";
43
-
44
- const frontOffset = from === "top" || from === "left" ? "50%" : "-50%";
45
- const backOffset = from === "top" || from === "left" ? "-50%" : "50%";
46
-
47
- const buildVariant = (
48
- opacity: number,
49
- rotation: number,
50
- offset: string | null = null,
51
- ): Variant => ({
52
- opacity,
53
- [rotateAxis]: rotation,
54
- ...(isVertical && offset !== null ? { y: offset } : {}),
55
- ...(!isVertical && offset !== null ? { x: offset } : {}),
56
- });
57
-
58
- const frontVariants = {
59
- initial: buildVariant(1, 0, "0%"),
60
- hover: buildVariant(0, 90, frontOffset),
61
- };
62
-
63
- const backVariants = {
64
- initial: buildVariant(0, 90, backOffset),
65
- hover: buildVariant(1, 0, "0%"),
66
- };
67
-
68
- return (
69
- <motion.button
70
- ref={ref}
71
- initial="initial"
72
- whileHover="hover"
73
- whileTap={{ scale: 0.95 }}
74
- className={cn(
75
- "relative inline-block h-10 px-4 py-2 text-sm font-medium cursor-pointer perspective-[1000px] focus:outline-none",
76
- className,
77
- )}
78
- {...props}
79
- >
80
- <motion.span
81
- variants={frontVariants}
82
- transition={transition}
83
- className={cn(
84
- defaultSpanClassName,
85
- "bg-muted text-black dark:text-white",
86
- frontClassName,
87
- )}
88
- >
89
- {frontText}
90
- </motion.span>
91
- <motion.span
92
- variants={backVariants}
93
- transition={transition}
94
- className={cn(
95
- defaultSpanClassName,
96
- "bg-primary text-primary-foreground",
97
- backClassName,
98
- )}
99
- >
100
- {backText}
101
- </motion.span>
102
- <span className="invisible">{frontText}</span>
103
- </motion.button>
104
- );
105
- },
106
- );
107
-
108
- FlipButton.displayName = "FlipButton";
109
-
110
- export { FlipButton, type FlipButtonProps, type FlipDirection };
1
+ "use client";
2
+
3
+ import {type HTMLMotionProps, type Transition, type Variant, motion} from "motion/react";
4
+ import * as React from "react";
5
+
6
+ import {cn} from "@/lib/utilities";
7
+
8
+ type FlipDirection = "top" | "bottom" | "left" | "righ";
9
+
10
+ interface FlipButtonProps extends HTMLMotionProps<"button"> {
11
+ frontText: string;
12
+ backText: string;
13
+ transition?: Transition;
14
+ frontClassName?: string;
15
+ backClassName?: string;
16
+ from?: FlipDirection;
17
+ }
18
+
19
+ const defaultSpanClassName = "absolute inset-0 flex items-center justify-center rounded-lg";
20
+
21
+ const FlipButton = React.forwardRef<HTMLButtonElement, FlipButtonProps>(
22
+ (
23
+ {
24
+ frontText,
25
+ backText,
26
+ transition = {type: "spring", stiffness: 280, damping: 20},
27
+ className,
28
+ frontClassName,
29
+ backClassName,
30
+ from = "top",
31
+ ...props
32
+ },
33
+ ref,
34
+ ) => {
35
+ const isVertical = from === "top" || from === "bottom";
36
+ const rotateAxis = isVertical ? "rotateX" : "rotateY";
37
+
38
+ const frontOffset = from === "top" || from === "left" ? "50%" : "-50%";
39
+ const backOffset = from === "top" || from === "left" ? "-50%" : "50%";
40
+
41
+ const buildVariant = (opacity: number, rotation: number, offset: string | null = null): Variant => ({
42
+ opacity,
43
+ [rotateAxis]: rotation,
44
+ ...(isVertical && offset !== null ? {y: offset} : {}),
45
+ ...(!isVertical && offset !== null ? {x: offset} : {}),
46
+ });
47
+
48
+ const frontVariants = {
49
+ initial: buildVariant(1, 0, "0%"),
50
+ hover: buildVariant(0, 90, frontOffset),
51
+ };
52
+
53
+ const backVariants = {
54
+ initial: buildVariant(0, 90, backOffset),
55
+ hover: buildVariant(1, 0, "0%"),
56
+ };
57
+
58
+ return (
59
+ <motion.button
60
+ ref={ref}
61
+ initial='initial'
62
+ whileHover='hover'
63
+ whileTap={{scale: 0.95}}
64
+ className={cn(
65
+ "relative inline-block h-10 cursor-pointer px-4 py-2 text-sm font-medium perspective-[1000px] focus:outline-none",
66
+ className,
67
+ )}
68
+ {...props}>
69
+ <motion.span
70
+ variants={frontVariants}
71
+ transition={transition}
72
+ className={cn(defaultSpanClassName, "bg-muted text-black dark:text-white", frontClassName)}>
73
+ {frontText}
74
+ </motion.span>
75
+ <motion.span
76
+ variants={backVariants}
77
+ transition={transition}
78
+ className={cn(defaultSpanClassName, "bg-primary text-primary-foreground", backClassName)}>
79
+ {backText}
80
+ </motion.span>
81
+ <span className='invisible'>{frontText}</span>
82
+ </motion.button>
83
+ );
84
+ },
85
+ );
86
+
87
+ FlipButton.displayName = "FlipButton";
88
+
89
+ export {FlipButton, type FlipButtonProps, type FlipDirection};
@@ -1,174 +1,144 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import * as LabelPrimitive from "@radix-ui/react-label";
5
- import { Slot } from "@radix-ui/react-slot";
6
- import {
7
- Controller,
8
- FormProvider,
9
- useFormContext,
10
- useFormState,
11
- type ControllerProps,
12
- type FieldPath,
13
- type FieldValues,
14
- } from "react-hook-form";
15
-
16
- import { cn } from "@/lib/utils";
17
- import { Label } from "@/components/ui/label";
18
-
19
- const Form = FormProvider;
20
-
21
- type FormFieldContextValue<
22
- TFieldValues extends FieldValues = FieldValues,
23
- TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
24
- > = {
25
- name: TName;
26
- };
27
-
28
- const FormFieldContext = React.createContext<FormFieldContextValue>(
29
- {} as FormFieldContextValue,
30
- );
31
-
32
- const FormField = <
33
- TFieldValues extends FieldValues = FieldValues,
34
- TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
35
- >({
36
- ...props
37
- }: ControllerProps<TFieldValues, TName>) => {
38
- return (
39
- <FormFieldContext.Provider value={{ name: props.name }}>
40
- <Controller {...props} />
41
- </FormFieldContext.Provider>
42
- );
43
- };
44
-
45
- const useFormField = () => {
46
- const fieldContext = React.useContext(FormFieldContext);
47
- const itemContext = React.useContext(FormItemContext);
48
- const { getFieldState } = useFormContext();
49
- const formState = useFormState({ name: fieldContext.name });
50
- const fieldState = getFieldState(fieldContext.name, formState);
51
-
52
- if (!fieldContext) {
53
- throw new Error("useFormField should be used within <FormField>");
54
- }
55
-
56
- const { id } = itemContext;
57
-
58
- return {
59
- id,
60
- name: fieldContext.name,
61
- formItemId: `${id}-form-item`,
62
- formDescriptionId: `${id}-form-item-description`,
63
- formMessageId: `${id}-form-item-message`,
64
- ...fieldState,
65
- };
66
- };
67
-
68
- type FormItemContextValue = {
69
- id: string;
70
- };
71
-
72
- const FormItemContext = React.createContext<FormItemContextValue>(
73
- {} as FormItemContextValue,
74
- );
75
-
76
- function FormItem({ className, ...props }: React.ComponentProps<"div">) {
77
- const id = React.useId();
78
-
79
- return (
80
- <FormItemContext.Provider value={{ id }}>
81
- <div
82
- data-slot="form-item"
83
- className={cn("grid gap-2", className)}
84
- {...props}
85
- />
86
- </FormItemContext.Provider>
87
- );
88
- }
89
-
90
- function FormLabel({
91
- className,
92
- ...props
93
- }: React.ComponentProps<typeof LabelPrimitive.Root>) {
94
- const { error, formItemId } = useFormField();
95
-
96
- return (
97
- <Label
98
- data-slot="form-label"
99
- data-error={!!error}
100
- className={cn(
101
- "data-[error=true]:text-red-500 dark:data-[error=true]:text-red-900",
102
- className,
103
- )}
104
- htmlFor={formItemId}
105
- {...props}
106
- />
107
- );
108
- }
109
-
110
- function FormControl({ ...props }: React.ComponentProps<typeof Slot>) {
111
- const { error, formItemId, formDescriptionId, formMessageId } =
112
- useFormField();
113
-
114
- return (
115
- <Slot
116
- data-slot="form-control"
117
- id={formItemId}
118
- aria-describedby={
119
- !error
120
- ? `${formDescriptionId}`
121
- : `${formDescriptionId} ${formMessageId}`
122
- }
123
- aria-invalid={!!error}
124
- {...props}
125
- />
126
- );
127
- }
128
-
129
- function FormDescription({ className, ...props }: React.ComponentProps<"p">) {
130
- const { formDescriptionId } = useFormField();
131
-
132
- return (
133
- <p
134
- data-slot="form-description"
135
- id={formDescriptionId}
136
- className={cn(
137
- "text-neutral-500 text-sm dark:text-neutral-400",
138
- className,
139
- )}
140
- {...props}
141
- />
142
- );
143
- }
144
-
145
- function FormMessage({ className, ...props }: React.ComponentProps<"p">) {
146
- const { error, formMessageId } = useFormField();
147
- const body = error ? String(error?.message ?? "") : props.children;
148
-
149
- if (!body) {
150
- return null;
151
- }
152
-
153
- return (
154
- <p
155
- data-slot="form-message"
156
- id={formMessageId}
157
- className={cn("text-red-500 text-sm dark:text-red-900", className)}
158
- {...props}
159
- >
160
- {body}
161
- </p>
162
- );
163
- }
164
-
165
- export {
166
- useFormField,
167
- Form,
168
- FormItem,
169
- FormLabel,
170
- FormControl,
171
- FormDescription,
172
- FormMessage,
173
- FormField,
174
- };
1
+ "use client";
2
+
3
+ import * as LabelPrimitive from "@radix-ui/react-label";
4
+ import {Slot} from "@radix-ui/react-slot";
5
+ import * as React from "react";
6
+ import {Controller, FormProvider, useFormContext, type ControllerProps, type FieldPath, type FieldValues} from "react-hook-form";
7
+
8
+ import {Label} from "@/components/ui/label";
9
+ import {cn} from "@/lib/utilities";
10
+
11
+ const Form = FormProvider;
12
+
13
+ type FormFieldContextValue<
14
+ TFieldValues extends FieldValues = FieldValues,
15
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
16
+ > = {
17
+ name: TName;
18
+ };
19
+
20
+ const FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);
21
+
22
+ const FormField = <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({
23
+ ...props
24
+ }: ControllerProps<TFieldValues, TName>) => {
25
+ return (
26
+ <FormFieldContext.Provider value={{name: props.name}}>
27
+ <Controller {...props} />
28
+ </FormFieldContext.Provider>
29
+ );
30
+ };
31
+
32
+ const useFormField = () => {
33
+ const fieldContext = React.useContext(FormFieldContext);
34
+ const itemContext = React.useContext(FormItemContext);
35
+ const {getFieldState, formState} = useFormContext();
36
+
37
+ const fieldState = getFieldState(fieldContext.name, formState);
38
+
39
+ if (!fieldContext) {
40
+ throw new Error("useFormField should be used within <FormField>");
41
+ }
42
+
43
+ const {id} = itemContext;
44
+
45
+ return {
46
+ id,
47
+ name: fieldContext.name,
48
+ formItemId: `${id}-form-item`,
49
+ formDescriptionId: `${id}-form-item-description`,
50
+ formMessageId: `${id}-form-item-message`,
51
+ ...fieldState,
52
+ };
53
+ };
54
+
55
+ type FormItemContextValue = {
56
+ id: string;
57
+ };
58
+
59
+ const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);
60
+
61
+ const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({className, ...props}, ref) => {
62
+ const id = React.useId();
63
+
64
+ return (
65
+ <FormItemContext.Provider value={{id}}>
66
+ <div
67
+ ref={ref}
68
+ className={cn("space-y-2", className)}
69
+ {...props}
70
+ />
71
+ </FormItemContext.Provider>
72
+ );
73
+ });
74
+ FormItem.displayName = "FormItem";
75
+
76
+ const FormLabel = React.forwardRef<
77
+ React.ElementRef<typeof LabelPrimitive.Root>,
78
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
79
+ >(({className, ...props}, ref) => {
80
+ const {error, formItemId} = useFormField();
81
+
82
+ return (
83
+ <Label
84
+ ref={ref}
85
+ className={cn(error && "text-red-500 dark:text-red-900", className)}
86
+ htmlFor={formItemId}
87
+ {...props}
88
+ />
89
+ );
90
+ });
91
+ FormLabel.displayName = "FormLabel";
92
+
93
+ const FormControl = React.forwardRef<React.ElementRef<typeof Slot>, React.ComponentPropsWithoutRef<typeof Slot>>(({...props}, ref) => {
94
+ const {error, formItemId, formDescriptionId, formMessageId} = useFormField();
95
+
96
+ return (
97
+ <Slot
98
+ ref={ref}
99
+ id={formItemId}
100
+ aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}
101
+ aria-invalid={!!error}
102
+ {...props}
103
+ />
104
+ );
105
+ });
106
+ FormControl.displayName = "FormControl";
107
+
108
+ const FormDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(({className, ...props}, ref) => {
109
+ const {formDescriptionId} = useFormField();
110
+
111
+ return (
112
+ <p
113
+ ref={ref}
114
+ id={formDescriptionId}
115
+ className={cn("text-[0.8rem] text-neutral-500 dark:text-neutral-400", className)}
116
+ {...props}
117
+ />
118
+ );
119
+ });
120
+ FormDescription.displayName = "FormDescription";
121
+
122
+ const FormMessage = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
123
+ ({className, children, ...props}, ref) => {
124
+ const {error, formMessageId} = useFormField();
125
+ const body = error ? String(error?.message ?? "") : children;
126
+
127
+ if (!body) {
128
+ return null;
129
+ }
130
+
131
+ return (
132
+ <p
133
+ ref={ref}
134
+ id={formMessageId}
135
+ className={cn("text-[0.8rem] font-medium text-red-500 dark:text-red-900", className)}
136
+ {...props}>
137
+ {body}
138
+ </p>
139
+ );
140
+ },
141
+ );
142
+ FormMessage.displayName = "FormMessage";
143
+
144
+ export {Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField};
@@ -1,43 +1,30 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import { HTMLMotionProps, motion, type Transition } from "motion/react";
5
-
6
- import { cn } from "@/lib/utils";
7
-
8
- interface GradientBackgroundProps extends HTMLMotionProps<"div"> {
9
- transition?: Transition;
10
- }
11
-
12
- const GradientBackground = React.forwardRef<
13
- HTMLDivElement,
14
- GradientBackgroundProps
15
- >(
16
- (
17
- {
18
- className,
19
- transition = { duration: 15, ease: "easeInOut", repeat: Infinity },
20
- ...props
21
- },
22
- ref,
23
- ) => {
24
- return (
25
- <motion.div
26
- ref={ref}
27
- className={cn(
28
- "size-full bg-gradient-to-br from-blue-500 via-purple-500 to-pink-500 bg-[length:400%_400%]",
29
- className,
30
- )}
31
- animate={{
32
- backgroundPosition: ["0% 50%", "100% 50%", "0% 50%"],
33
- }}
34
- transition={transition}
35
- {...props}
36
- />
37
- );
38
- },
39
- );
40
-
41
- GradientBackground.displayName = "GradientBackground";
42
-
43
- export { GradientBackground, type GradientBackgroundProps };
1
+ "use client";
2
+
3
+ import {HTMLMotionProps, motion, type Transition} from "motion/react";
4
+ import * as React from "react";
5
+
6
+ import {cn} from "@/lib/utilities";
7
+
8
+ interface GradientBackgroundProps extends HTMLMotionProps<"div"> {
9
+ transition?: Transition;
10
+ }
11
+
12
+ const GradientBackground = React.forwardRef<HTMLDivElement, GradientBackgroundProps>(
13
+ ({className, transition = {duration: 15, ease: "easeInOut", repeat: Infinity}, ...props}, ref) => {
14
+ return (
15
+ <motion.div
16
+ ref={ref}
17
+ className={cn("size-full bg-gradient-to-br from-blue-500 via-purple-500 to-pink-500 bg-[length:400%_400%]", className)}
18
+ animate={{
19
+ backgroundPosition: ["0% 50%", "100% 50%", "0% 50%"],
20
+ }}
21
+ transition={transition}
22
+ {...props}
23
+ />
24
+ );
25
+ },
26
+ );
27
+
28
+ GradientBackground.displayName = "GradientBackground";
29
+
30
+ export {GradientBackground, type GradientBackgroundProps};