lite-math 1.0.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 (321) hide show
  1. package/.eslintrc.json +19 -0
  2. package/.prettierrc +10 -0
  3. package/CHANGELOG.md +22 -0
  4. package/CONTRIBUTING.md +51 -0
  5. package/LICENSE +21 -0
  6. package/README.md +213 -0
  7. package/app/globals.css +125 -0
  8. package/app/layout.tsx +27 -0
  9. package/app/page.tsx +7 -0
  10. package/components/theme-provider.tsx +11 -0
  11. package/components/ui/accordion.tsx +66 -0
  12. package/components/ui/alert-dialog.tsx +157 -0
  13. package/components/ui/alert.tsx +66 -0
  14. package/components/ui/aspect-ratio.tsx +11 -0
  15. package/components/ui/avatar.tsx +53 -0
  16. package/components/ui/badge.tsx +46 -0
  17. package/components/ui/breadcrumb.tsx +109 -0
  18. package/components/ui/button-group.tsx +83 -0
  19. package/components/ui/button.tsx +60 -0
  20. package/components/ui/calendar.tsx +213 -0
  21. package/components/ui/card.tsx +92 -0
  22. package/components/ui/carousel.tsx +241 -0
  23. package/components/ui/chart.tsx +353 -0
  24. package/components/ui/checkbox.tsx +32 -0
  25. package/components/ui/collapsible.tsx +33 -0
  26. package/components/ui/command.tsx +184 -0
  27. package/components/ui/context-menu.tsx +252 -0
  28. package/components/ui/dialog.tsx +143 -0
  29. package/components/ui/drawer.tsx +135 -0
  30. package/components/ui/dropdown-menu.tsx +257 -0
  31. package/components/ui/empty.tsx +104 -0
  32. package/components/ui/field.tsx +244 -0
  33. package/components/ui/form.tsx +167 -0
  34. package/components/ui/hover-card.tsx +44 -0
  35. package/components/ui/input-group.tsx +169 -0
  36. package/components/ui/input-otp.tsx +77 -0
  37. package/components/ui/input.tsx +21 -0
  38. package/components/ui/item.tsx +193 -0
  39. package/components/ui/kbd.tsx +28 -0
  40. package/components/ui/label.tsx +24 -0
  41. package/components/ui/menubar.tsx +276 -0
  42. package/components/ui/navigation-menu.tsx +166 -0
  43. package/components/ui/pagination.tsx +127 -0
  44. package/components/ui/popover.tsx +48 -0
  45. package/components/ui/progress.tsx +31 -0
  46. package/components/ui/radio-group.tsx +45 -0
  47. package/components/ui/resizable.tsx +56 -0
  48. package/components/ui/scroll-area.tsx +58 -0
  49. package/components/ui/select.tsx +185 -0
  50. package/components/ui/separator.tsx +28 -0
  51. package/components/ui/sheet.tsx +139 -0
  52. package/components/ui/sidebar.tsx +726 -0
  53. package/components/ui/skeleton.tsx +13 -0
  54. package/components/ui/slider.tsx +63 -0
  55. package/components/ui/sonner.tsx +25 -0
  56. package/components/ui/spinner.tsx +16 -0
  57. package/components/ui/switch.tsx +31 -0
  58. package/components/ui/table.tsx +116 -0
  59. package/components/ui/tabs.tsx +66 -0
  60. package/components/ui/textarea.tsx +18 -0
  61. package/components/ui/toast.tsx +129 -0
  62. package/components/ui/toaster.tsx +35 -0
  63. package/components/ui/toggle-group.tsx +73 -0
  64. package/components/ui/toggle.tsx +47 -0
  65. package/components/ui/tooltip.tsx +61 -0
  66. package/components/ui/use-mobile.tsx +19 -0
  67. package/components/ui/use-toast.ts +191 -0
  68. package/components.json +21 -0
  69. package/dist/advanced/cube-root.d.ts +2 -0
  70. package/dist/advanced/cube-root.d.ts.map +1 -0
  71. package/dist/advanced/cube-root.js +4 -0
  72. package/dist/advanced/cube-root.js.map +1 -0
  73. package/dist/advanced/factorial.d.ts +2 -0
  74. package/dist/advanced/factorial.d.ts.map +1 -0
  75. package/dist/advanced/factorial.js +11 -0
  76. package/dist/advanced/factorial.js.map +1 -0
  77. package/dist/advanced/fibonacci.d.ts +2 -0
  78. package/dist/advanced/fibonacci.d.ts.map +1 -0
  79. package/dist/advanced/fibonacci.js +15 -0
  80. package/dist/advanced/fibonacci.js.map +1 -0
  81. package/dist/advanced/gcd.d.ts +2 -0
  82. package/dist/advanced/gcd.d.ts.map +1 -0
  83. package/dist/advanced/gcd.js +10 -0
  84. package/dist/advanced/gcd.js.map +1 -0
  85. package/dist/advanced/lcm.d.ts +2 -0
  86. package/dist/advanced/lcm.d.ts.map +1 -0
  87. package/dist/advanced/lcm.js +13 -0
  88. package/dist/advanced/lcm.js.map +1 -0
  89. package/dist/advanced/power.d.ts +2 -0
  90. package/dist/advanced/power.d.ts.map +1 -0
  91. package/dist/advanced/power.js +4 -0
  92. package/dist/advanced/power.js.map +1 -0
  93. package/dist/advanced/prime-check.d.ts +2 -0
  94. package/dist/advanced/prime-check.d.ts.map +1 -0
  95. package/dist/advanced/prime-check.js +14 -0
  96. package/dist/advanced/prime-check.js.map +1 -0
  97. package/dist/advanced/prime-list.d.ts +2 -0
  98. package/dist/advanced/prime-list.d.ts.map +1 -0
  99. package/dist/advanced/prime-list.js +14 -0
  100. package/dist/advanced/prime-list.js.map +1 -0
  101. package/dist/advanced/sqrt.d.ts +2 -0
  102. package/dist/advanced/sqrt.d.ts.map +1 -0
  103. package/dist/advanced/sqrt.js +6 -0
  104. package/dist/advanced/sqrt.js.map +1 -0
  105. package/dist/algebra/circle-area.d.ts +2 -0
  106. package/dist/algebra/circle-area.d.ts.map +1 -0
  107. package/dist/algebra/circle-area.js +4 -0
  108. package/dist/algebra/circle-area.js.map +1 -0
  109. package/dist/algebra/distance.d.ts +2 -0
  110. package/dist/algebra/distance.d.ts.map +1 -0
  111. package/dist/algebra/distance.js +4 -0
  112. package/dist/algebra/distance.js.map +1 -0
  113. package/dist/algebra/midpoint.d.ts +2 -0
  114. package/dist/algebra/midpoint.d.ts.map +1 -0
  115. package/dist/algebra/midpoint.js +4 -0
  116. package/dist/algebra/midpoint.js.map +1 -0
  117. package/dist/algebra/slope.d.ts +2 -0
  118. package/dist/algebra/slope.d.ts.map +1 -0
  119. package/dist/algebra/slope.js +6 -0
  120. package/dist/algebra/slope.js.map +1 -0
  121. package/dist/algebra/solve-linear.d.ts +2 -0
  122. package/dist/algebra/solve-linear.d.ts.map +1 -0
  123. package/dist/algebra/solve-linear.js +6 -0
  124. package/dist/algebra/solve-linear.js.map +1 -0
  125. package/dist/algebra/solve-quadratic.d.ts +2 -0
  126. package/dist/algebra/solve-quadratic.d.ts.map +1 -0
  127. package/dist/algebra/solve-quadratic.js +12 -0
  128. package/dist/algebra/solve-quadratic.js.map +1 -0
  129. package/dist/algebra/triangle-area.d.ts +2 -0
  130. package/dist/algebra/triangle-area.d.ts.map +1 -0
  131. package/dist/algebra/triangle-area.js +5 -0
  132. package/dist/algebra/triangle-area.js.map +1 -0
  133. package/dist/arithmetic/add.d.ts +2 -0
  134. package/dist/arithmetic/add.d.ts.map +1 -0
  135. package/dist/arithmetic/add.js +4 -0
  136. package/dist/arithmetic/add.js.map +1 -0
  137. package/dist/arithmetic/ceil.d.ts +2 -0
  138. package/dist/arithmetic/ceil.d.ts.map +1 -0
  139. package/dist/arithmetic/ceil.js +4 -0
  140. package/dist/arithmetic/ceil.js.map +1 -0
  141. package/dist/arithmetic/clamp.d.ts +2 -0
  142. package/dist/arithmetic/clamp.d.ts.map +1 -0
  143. package/dist/arithmetic/clamp.js +4 -0
  144. package/dist/arithmetic/clamp.js.map +1 -0
  145. package/dist/arithmetic/divide.d.ts +2 -0
  146. package/dist/arithmetic/divide.d.ts.map +1 -0
  147. package/dist/arithmetic/divide.js +6 -0
  148. package/dist/arithmetic/divide.js.map +1 -0
  149. package/dist/arithmetic/floor.d.ts +2 -0
  150. package/dist/arithmetic/floor.d.ts.map +1 -0
  151. package/dist/arithmetic/floor.js +4 -0
  152. package/dist/arithmetic/floor.js.map +1 -0
  153. package/dist/arithmetic/modulo.d.ts +2 -0
  154. package/dist/arithmetic/modulo.d.ts.map +1 -0
  155. package/dist/arithmetic/modulo.js +4 -0
  156. package/dist/arithmetic/modulo.js.map +1 -0
  157. package/dist/arithmetic/multiply.d.ts +2 -0
  158. package/dist/arithmetic/multiply.d.ts.map +1 -0
  159. package/dist/arithmetic/multiply.js +4 -0
  160. package/dist/arithmetic/multiply.js.map +1 -0
  161. package/dist/arithmetic/percentage.d.ts +2 -0
  162. package/dist/arithmetic/percentage.d.ts.map +1 -0
  163. package/dist/arithmetic/percentage.js +4 -0
  164. package/dist/arithmetic/percentage.js.map +1 -0
  165. package/dist/arithmetic/round.d.ts +2 -0
  166. package/dist/arithmetic/round.d.ts.map +1 -0
  167. package/dist/arithmetic/round.js +5 -0
  168. package/dist/arithmetic/round.js.map +1 -0
  169. package/dist/arithmetic/subtract.d.ts +2 -0
  170. package/dist/arithmetic/subtract.d.ts.map +1 -0
  171. package/dist/arithmetic/subtract.js +4 -0
  172. package/dist/arithmetic/subtract.js.map +1 -0
  173. package/dist/cli.d.ts +3 -0
  174. package/dist/cli.d.ts.map +1 -0
  175. package/dist/cli.js +277 -0
  176. package/dist/cli.js.map +1 -0
  177. package/dist/convert/c-to-f.d.ts +2 -0
  178. package/dist/convert/c-to-f.d.ts.map +1 -0
  179. package/dist/convert/c-to-f.js +4 -0
  180. package/dist/convert/c-to-f.js.map +1 -0
  181. package/dist/convert/deg-to-rad.d.ts +2 -0
  182. package/dist/convert/deg-to-rad.d.ts.map +1 -0
  183. package/dist/convert/deg-to-rad.js +4 -0
  184. package/dist/convert/deg-to-rad.js.map +1 -0
  185. package/dist/convert/f-to-c.d.ts +2 -0
  186. package/dist/convert/f-to-c.d.ts.map +1 -0
  187. package/dist/convert/f-to-c.js +4 -0
  188. package/dist/convert/f-to-c.js.map +1 -0
  189. package/dist/convert/km-to-miles.d.ts +2 -0
  190. package/dist/convert/km-to-miles.d.ts.map +1 -0
  191. package/dist/convert/km-to-miles.js +4 -0
  192. package/dist/convert/km-to-miles.js.map +1 -0
  193. package/dist/convert/miles-to-km.d.ts +2 -0
  194. package/dist/convert/miles-to-km.d.ts.map +1 -0
  195. package/dist/convert/miles-to-km.js +4 -0
  196. package/dist/convert/miles-to-km.js.map +1 -0
  197. package/dist/convert/rad-to-deg.d.ts +2 -0
  198. package/dist/convert/rad-to-deg.d.ts.map +1 -0
  199. package/dist/convert/rad-to-deg.js +4 -0
  200. package/dist/convert/rad-to-deg.js.map +1 -0
  201. package/dist/index.d.ts +45 -0
  202. package/dist/index.d.ts.map +1 -0
  203. package/dist/index.js +45 -0
  204. package/dist/index.js.map +1 -0
  205. package/dist/random/random-array.d.ts +2 -0
  206. package/dist/random/random-array.d.ts.map +1 -0
  207. package/dist/random/random-array.js +4 -0
  208. package/dist/random/random-array.js.map +1 -0
  209. package/dist/random/random-float.d.ts +2 -0
  210. package/dist/random/random-float.d.ts.map +1 -0
  211. package/dist/random/random-float.js +4 -0
  212. package/dist/random/random-float.js.map +1 -0
  213. package/dist/random/random-from-array.d.ts +2 -0
  214. package/dist/random/random-from-array.d.ts.map +1 -0
  215. package/dist/random/random-from-array.js +4 -0
  216. package/dist/random/random-from-array.js.map +1 -0
  217. package/dist/random/random-int.d.ts +2 -0
  218. package/dist/random/random-int.d.ts.map +1 -0
  219. package/dist/random/random-int.js +4 -0
  220. package/dist/random/random-int.js.map +1 -0
  221. package/dist/statistics/mean.d.ts +2 -0
  222. package/dist/statistics/mean.d.ts.map +1 -0
  223. package/dist/statistics/mean.js +6 -0
  224. package/dist/statistics/mean.js.map +1 -0
  225. package/dist/statistics/median.d.ts +2 -0
  226. package/dist/statistics/median.d.ts.map +1 -0
  227. package/dist/statistics/median.js +8 -0
  228. package/dist/statistics/median.js.map +1 -0
  229. package/dist/statistics/mode.d.ts +2 -0
  230. package/dist/statistics/mode.d.ts.map +1 -0
  231. package/dist/statistics/mode.js +13 -0
  232. package/dist/statistics/mode.js.map +1 -0
  233. package/dist/statistics/product-array.d.ts +2 -0
  234. package/dist/statistics/product-array.d.ts.map +1 -0
  235. package/dist/statistics/product-array.js +4 -0
  236. package/dist/statistics/product-array.js.map +1 -0
  237. package/dist/statistics/range.d.ts +2 -0
  238. package/dist/statistics/range.d.ts.map +1 -0
  239. package/dist/statistics/range.js +6 -0
  240. package/dist/statistics/range.js.map +1 -0
  241. package/dist/statistics/std-dev.d.ts +2 -0
  242. package/dist/statistics/std-dev.d.ts.map +1 -0
  243. package/dist/statistics/std-dev.js +10 -0
  244. package/dist/statistics/std-dev.js.map +1 -0
  245. package/dist/statistics/sum-array.d.ts +2 -0
  246. package/dist/statistics/sum-array.d.ts.map +1 -0
  247. package/dist/statistics/sum-array.js +4 -0
  248. package/dist/statistics/sum-array.js.map +1 -0
  249. package/dist/statistics/variance.d.ts +2 -0
  250. package/dist/statistics/variance.d.ts.map +1 -0
  251. package/dist/statistics/variance.js +7 -0
  252. package/dist/statistics/variance.js.map +1 -0
  253. package/examples/advanced-examples.ts +31 -0
  254. package/examples/algebra-examples.ts +24 -0
  255. package/examples/arithmetic-examples.ts +24 -0
  256. package/examples/conversion-examples.ts +24 -0
  257. package/examples/statistics-examples.ts +29 -0
  258. package/hooks/use-mobile.ts +19 -0
  259. package/hooks/use-toast.ts +191 -0
  260. package/jest.config.js +15 -0
  261. package/lib/utils.ts +6 -0
  262. package/next.config.mjs +11 -0
  263. package/package.json +110 -0
  264. package/postcss.config.mjs +8 -0
  265. package/public/apple-icon.png +0 -0
  266. package/public/icon-dark-32x32.png +0 -0
  267. package/public/icon-light-32x32.png +0 -0
  268. package/public/icon.svg +26 -0
  269. package/public/placeholder-logo.png +0 -0
  270. package/public/placeholder-logo.svg +1 -0
  271. package/public/placeholder-user.jpg +0 -0
  272. package/public/placeholder.jpg +0 -0
  273. package/public/placeholder.svg +1 -0
  274. package/src/advanced/cube-root.ts +8 -0
  275. package/src/advanced/factorial.ts +12 -0
  276. package/src/advanced/fibonacci.ts +16 -0
  277. package/src/advanced/gcd.ts +14 -0
  278. package/src/advanced/lcm.ts +18 -0
  279. package/src/advanced/power.ts +9 -0
  280. package/src/advanced/prime-check.ts +14 -0
  281. package/src/advanced/prime-list.ts +16 -0
  282. package/src/advanced/sqrt.ts +9 -0
  283. package/src/algebra/circle-area.ts +8 -0
  284. package/src/algebra/distance.ts +11 -0
  285. package/src/algebra/midpoint.ts +11 -0
  286. package/src/algebra/slope.ts +12 -0
  287. package/src/algebra/solve-linear.ts +10 -0
  288. package/src/algebra/solve-quadratic.ts +15 -0
  289. package/src/algebra/triangle-area.ts +11 -0
  290. package/src/arithmetic/add.ts +9 -0
  291. package/src/arithmetic/ceil.ts +8 -0
  292. package/src/arithmetic/clamp.ts +10 -0
  293. package/src/arithmetic/divide.ts +11 -0
  294. package/src/arithmetic/floor.ts +8 -0
  295. package/src/arithmetic/modulo.ts +9 -0
  296. package/src/arithmetic/multiply.ts +9 -0
  297. package/src/arithmetic/percentage.ts +9 -0
  298. package/src/arithmetic/round.ts +10 -0
  299. package/src/arithmetic/subtract.ts +9 -0
  300. package/src/cli.ts +321 -0
  301. package/src/convert/c-to-f.ts +8 -0
  302. package/src/convert/deg-to-rad.ts +8 -0
  303. package/src/convert/f-to-c.ts +8 -0
  304. package/src/convert/km-to-miles.ts +8 -0
  305. package/src/convert/miles-to-km.ts +8 -0
  306. package/src/convert/rad-to-deg.ts +8 -0
  307. package/src/index.ts +49 -0
  308. package/src/random/random-array.ts +10 -0
  309. package/src/random/random-float.ts +9 -0
  310. package/src/random/random-from-array.ts +8 -0
  311. package/src/random/random-int.ts +9 -0
  312. package/src/statistics/mean.ts +9 -0
  313. package/src/statistics/median.ts +11 -0
  314. package/src/statistics/mode.ts +16 -0
  315. package/src/statistics/product-array.ts +8 -0
  316. package/src/statistics/range.ts +9 -0
  317. package/src/statistics/std-dev.ts +14 -0
  318. package/src/statistics/sum-array.ts +8 -0
  319. package/src/statistics/variance.ts +10 -0
  320. package/styles/globals.css +125 -0
  321. package/tsconfig.json +25 -0
@@ -0,0 +1,213 @@
1
+ 'use client'
2
+
3
+ import * as React from 'react'
4
+ import {
5
+ ChevronDownIcon,
6
+ ChevronLeftIcon,
7
+ ChevronRightIcon,
8
+ } from 'lucide-react'
9
+ import { DayButton, DayPicker, getDefaultClassNames } from 'react-day-picker'
10
+
11
+ import { cn } from '@/lib/utils'
12
+ import { Button, buttonVariants } from '@/components/ui/button'
13
+
14
+ function Calendar({
15
+ className,
16
+ classNames,
17
+ showOutsideDays = true,
18
+ captionLayout = 'label',
19
+ buttonVariant = 'ghost',
20
+ formatters,
21
+ components,
22
+ ...props
23
+ }: React.ComponentProps<typeof DayPicker> & {
24
+ buttonVariant?: React.ComponentProps<typeof Button>['variant']
25
+ }) {
26
+ const defaultClassNames = getDefaultClassNames()
27
+
28
+ return (
29
+ <DayPicker
30
+ showOutsideDays={showOutsideDays}
31
+ className={cn(
32
+ 'bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent',
33
+ String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
34
+ String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
35
+ className,
36
+ )}
37
+ captionLayout={captionLayout}
38
+ formatters={{
39
+ formatMonthDropdown: (date) =>
40
+ date.toLocaleString('default', { month: 'short' }),
41
+ ...formatters,
42
+ }}
43
+ classNames={{
44
+ root: cn('w-fit', defaultClassNames.root),
45
+ months: cn(
46
+ 'flex gap-4 flex-col md:flex-row relative',
47
+ defaultClassNames.months,
48
+ ),
49
+ month: cn('flex flex-col w-full gap-4', defaultClassNames.month),
50
+ nav: cn(
51
+ 'flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between',
52
+ defaultClassNames.nav,
53
+ ),
54
+ button_previous: cn(
55
+ buttonVariants({ variant: buttonVariant }),
56
+ 'size-(--cell-size) aria-disabled:opacity-50 p-0 select-none',
57
+ defaultClassNames.button_previous,
58
+ ),
59
+ button_next: cn(
60
+ buttonVariants({ variant: buttonVariant }),
61
+ 'size-(--cell-size) aria-disabled:opacity-50 p-0 select-none',
62
+ defaultClassNames.button_next,
63
+ ),
64
+ month_caption: cn(
65
+ 'flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)',
66
+ defaultClassNames.month_caption,
67
+ ),
68
+ dropdowns: cn(
69
+ 'w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5',
70
+ defaultClassNames.dropdowns,
71
+ ),
72
+ dropdown_root: cn(
73
+ 'relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md',
74
+ defaultClassNames.dropdown_root,
75
+ ),
76
+ dropdown: cn(
77
+ 'absolute bg-popover inset-0 opacity-0',
78
+ defaultClassNames.dropdown,
79
+ ),
80
+ caption_label: cn(
81
+ 'select-none font-medium',
82
+ captionLayout === 'label'
83
+ ? 'text-sm'
84
+ : 'rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5',
85
+ defaultClassNames.caption_label,
86
+ ),
87
+ table: 'w-full border-collapse',
88
+ weekdays: cn('flex', defaultClassNames.weekdays),
89
+ weekday: cn(
90
+ 'text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none',
91
+ defaultClassNames.weekday,
92
+ ),
93
+ week: cn('flex w-full mt-2', defaultClassNames.week),
94
+ week_number_header: cn(
95
+ 'select-none w-(--cell-size)',
96
+ defaultClassNames.week_number_header,
97
+ ),
98
+ week_number: cn(
99
+ 'text-[0.8rem] select-none text-muted-foreground',
100
+ defaultClassNames.week_number,
101
+ ),
102
+ day: cn(
103
+ 'relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none',
104
+ defaultClassNames.day,
105
+ ),
106
+ range_start: cn(
107
+ 'rounded-l-md bg-accent',
108
+ defaultClassNames.range_start,
109
+ ),
110
+ range_middle: cn('rounded-none', defaultClassNames.range_middle),
111
+ range_end: cn('rounded-r-md bg-accent', defaultClassNames.range_end),
112
+ today: cn(
113
+ 'bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none',
114
+ defaultClassNames.today,
115
+ ),
116
+ outside: cn(
117
+ 'text-muted-foreground aria-selected:text-muted-foreground',
118
+ defaultClassNames.outside,
119
+ ),
120
+ disabled: cn(
121
+ 'text-muted-foreground opacity-50',
122
+ defaultClassNames.disabled,
123
+ ),
124
+ hidden: cn('invisible', defaultClassNames.hidden),
125
+ ...classNames,
126
+ }}
127
+ components={{
128
+ Root: ({ className, rootRef, ...props }) => {
129
+ return (
130
+ <div
131
+ data-slot="calendar"
132
+ ref={rootRef}
133
+ className={cn(className)}
134
+ {...props}
135
+ />
136
+ )
137
+ },
138
+ Chevron: ({ className, orientation, ...props }) => {
139
+ if (orientation === 'left') {
140
+ return (
141
+ <ChevronLeftIcon className={cn('size-4', className)} {...props} />
142
+ )
143
+ }
144
+
145
+ if (orientation === 'right') {
146
+ return (
147
+ <ChevronRightIcon
148
+ className={cn('size-4', className)}
149
+ {...props}
150
+ />
151
+ )
152
+ }
153
+
154
+ return (
155
+ <ChevronDownIcon className={cn('size-4', className)} {...props} />
156
+ )
157
+ },
158
+ DayButton: CalendarDayButton,
159
+ WeekNumber: ({ children, ...props }) => {
160
+ return (
161
+ <td {...props}>
162
+ <div className="flex size-(--cell-size) items-center justify-center text-center">
163
+ {children}
164
+ </div>
165
+ </td>
166
+ )
167
+ },
168
+ ...components,
169
+ }}
170
+ {...props}
171
+ />
172
+ )
173
+ }
174
+
175
+ function CalendarDayButton({
176
+ className,
177
+ day,
178
+ modifiers,
179
+ ...props
180
+ }: React.ComponentProps<typeof DayButton>) {
181
+ const defaultClassNames = getDefaultClassNames()
182
+
183
+ const ref = React.useRef<HTMLButtonElement>(null)
184
+ React.useEffect(() => {
185
+ if (modifiers.focused) ref.current?.focus()
186
+ }, [modifiers.focused])
187
+
188
+ return (
189
+ <Button
190
+ ref={ref}
191
+ variant="ghost"
192
+ size="icon"
193
+ data-day={day.date.toLocaleDateString()}
194
+ data-selected-single={
195
+ modifiers.selected &&
196
+ !modifiers.range_start &&
197
+ !modifiers.range_end &&
198
+ !modifiers.range_middle
199
+ }
200
+ data-range-start={modifiers.range_start}
201
+ data-range-end={modifiers.range_end}
202
+ data-range-middle={modifiers.range_middle}
203
+ className={cn(
204
+ 'data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70',
205
+ defaultClassNames.day,
206
+ className,
207
+ )}
208
+ {...props}
209
+ />
210
+ )
211
+ }
212
+
213
+ export { Calendar, CalendarDayButton }
@@ -0,0 +1,92 @@
1
+ import * as React from 'react'
2
+
3
+ import { cn } from '@/lib/utils'
4
+
5
+ function Card({ className, ...props }: React.ComponentProps<'div'>) {
6
+ return (
7
+ <div
8
+ data-slot="card"
9
+ className={cn(
10
+ 'bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm',
11
+ className,
12
+ )}
13
+ {...props}
14
+ />
15
+ )
16
+ }
17
+
18
+ function CardHeader({ className, ...props }: React.ComponentProps<'div'>) {
19
+ return (
20
+ <div
21
+ data-slot="card-header"
22
+ className={cn(
23
+ '@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6',
24
+ className,
25
+ )}
26
+ {...props}
27
+ />
28
+ )
29
+ }
30
+
31
+ function CardTitle({ className, ...props }: React.ComponentProps<'div'>) {
32
+ return (
33
+ <div
34
+ data-slot="card-title"
35
+ className={cn('leading-none font-semibold', className)}
36
+ {...props}
37
+ />
38
+ )
39
+ }
40
+
41
+ function CardDescription({ className, ...props }: React.ComponentProps<'div'>) {
42
+ return (
43
+ <div
44
+ data-slot="card-description"
45
+ className={cn('text-muted-foreground text-sm', className)}
46
+ {...props}
47
+ />
48
+ )
49
+ }
50
+
51
+ function CardAction({ className, ...props }: React.ComponentProps<'div'>) {
52
+ return (
53
+ <div
54
+ data-slot="card-action"
55
+ className={cn(
56
+ 'col-start-2 row-span-2 row-start-1 self-start justify-self-end',
57
+ className,
58
+ )}
59
+ {...props}
60
+ />
61
+ )
62
+ }
63
+
64
+ function CardContent({ className, ...props }: React.ComponentProps<'div'>) {
65
+ return (
66
+ <div
67
+ data-slot="card-content"
68
+ className={cn('px-6', className)}
69
+ {...props}
70
+ />
71
+ )
72
+ }
73
+
74
+ function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
75
+ return (
76
+ <div
77
+ data-slot="card-footer"
78
+ className={cn('flex items-center px-6 [.border-t]:pt-6', className)}
79
+ {...props}
80
+ />
81
+ )
82
+ }
83
+
84
+ export {
85
+ Card,
86
+ CardHeader,
87
+ CardFooter,
88
+ CardTitle,
89
+ CardAction,
90
+ CardDescription,
91
+ CardContent,
92
+ }
@@ -0,0 +1,241 @@
1
+ 'use client'
2
+
3
+ import * as React from 'react'
4
+ import useEmblaCarousel, {
5
+ type UseEmblaCarouselType,
6
+ } from 'embla-carousel-react'
7
+ import { ArrowLeft, ArrowRight } from 'lucide-react'
8
+
9
+ import { cn } from '@/lib/utils'
10
+ import { Button } from '@/components/ui/button'
11
+
12
+ type CarouselApi = UseEmblaCarouselType[1]
13
+ type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
14
+ type CarouselOptions = UseCarouselParameters[0]
15
+ type CarouselPlugin = UseCarouselParameters[1]
16
+
17
+ type CarouselProps = {
18
+ opts?: CarouselOptions
19
+ plugins?: CarouselPlugin
20
+ orientation?: 'horizontal' | 'vertical'
21
+ setApi?: (api: CarouselApi) => void
22
+ }
23
+
24
+ type CarouselContextProps = {
25
+ carouselRef: ReturnType<typeof useEmblaCarousel>[0]
26
+ api: ReturnType<typeof useEmblaCarousel>[1]
27
+ scrollPrev: () => void
28
+ scrollNext: () => void
29
+ canScrollPrev: boolean
30
+ canScrollNext: boolean
31
+ } & CarouselProps
32
+
33
+ const CarouselContext = React.createContext<CarouselContextProps | null>(null)
34
+
35
+ function useCarousel() {
36
+ const context = React.useContext(CarouselContext)
37
+
38
+ if (!context) {
39
+ throw new Error('useCarousel must be used within a <Carousel />')
40
+ }
41
+
42
+ return context
43
+ }
44
+
45
+ function Carousel({
46
+ orientation = 'horizontal',
47
+ opts,
48
+ setApi,
49
+ plugins,
50
+ className,
51
+ children,
52
+ ...props
53
+ }: React.ComponentProps<'div'> & CarouselProps) {
54
+ const [carouselRef, api] = useEmblaCarousel(
55
+ {
56
+ ...opts,
57
+ axis: orientation === 'horizontal' ? 'x' : 'y',
58
+ },
59
+ plugins,
60
+ )
61
+ const [canScrollPrev, setCanScrollPrev] = React.useState(false)
62
+ const [canScrollNext, setCanScrollNext] = React.useState(false)
63
+
64
+ const onSelect = React.useCallback((api: CarouselApi) => {
65
+ if (!api) return
66
+ setCanScrollPrev(api.canScrollPrev())
67
+ setCanScrollNext(api.canScrollNext())
68
+ }, [])
69
+
70
+ const scrollPrev = React.useCallback(() => {
71
+ api?.scrollPrev()
72
+ }, [api])
73
+
74
+ const scrollNext = React.useCallback(() => {
75
+ api?.scrollNext()
76
+ }, [api])
77
+
78
+ const handleKeyDown = React.useCallback(
79
+ (event: React.KeyboardEvent<HTMLDivElement>) => {
80
+ if (event.key === 'ArrowLeft') {
81
+ event.preventDefault()
82
+ scrollPrev()
83
+ } else if (event.key === 'ArrowRight') {
84
+ event.preventDefault()
85
+ scrollNext()
86
+ }
87
+ },
88
+ [scrollPrev, scrollNext],
89
+ )
90
+
91
+ React.useEffect(() => {
92
+ if (!api || !setApi) return
93
+ setApi(api)
94
+ }, [api, setApi])
95
+
96
+ React.useEffect(() => {
97
+ if (!api) return
98
+ onSelect(api)
99
+ api.on('reInit', onSelect)
100
+ api.on('select', onSelect)
101
+
102
+ return () => {
103
+ api?.off('select', onSelect)
104
+ }
105
+ }, [api, onSelect])
106
+
107
+ return (
108
+ <CarouselContext.Provider
109
+ value={{
110
+ carouselRef,
111
+ api: api,
112
+ opts,
113
+ orientation:
114
+ orientation || (opts?.axis === 'y' ? 'vertical' : 'horizontal'),
115
+ scrollPrev,
116
+ scrollNext,
117
+ canScrollPrev,
118
+ canScrollNext,
119
+ }}
120
+ >
121
+ <div
122
+ onKeyDownCapture={handleKeyDown}
123
+ className={cn('relative', className)}
124
+ role="region"
125
+ aria-roledescription="carousel"
126
+ data-slot="carousel"
127
+ {...props}
128
+ >
129
+ {children}
130
+ </div>
131
+ </CarouselContext.Provider>
132
+ )
133
+ }
134
+
135
+ function CarouselContent({ className, ...props }: React.ComponentProps<'div'>) {
136
+ const { carouselRef, orientation } = useCarousel()
137
+
138
+ return (
139
+ <div
140
+ ref={carouselRef}
141
+ className="overflow-hidden"
142
+ data-slot="carousel-content"
143
+ >
144
+ <div
145
+ className={cn(
146
+ 'flex',
147
+ orientation === 'horizontal' ? '-ml-4' : '-mt-4 flex-col',
148
+ className,
149
+ )}
150
+ {...props}
151
+ />
152
+ </div>
153
+ )
154
+ }
155
+
156
+ function CarouselItem({ className, ...props }: React.ComponentProps<'div'>) {
157
+ const { orientation } = useCarousel()
158
+
159
+ return (
160
+ <div
161
+ role="group"
162
+ aria-roledescription="slide"
163
+ data-slot="carousel-item"
164
+ className={cn(
165
+ 'min-w-0 shrink-0 grow-0 basis-full',
166
+ orientation === 'horizontal' ? 'pl-4' : 'pt-4',
167
+ className,
168
+ )}
169
+ {...props}
170
+ />
171
+ )
172
+ }
173
+
174
+ function CarouselPrevious({
175
+ className,
176
+ variant = 'outline',
177
+ size = 'icon',
178
+ ...props
179
+ }: React.ComponentProps<typeof Button>) {
180
+ const { orientation, scrollPrev, canScrollPrev } = useCarousel()
181
+
182
+ return (
183
+ <Button
184
+ data-slot="carousel-previous"
185
+ variant={variant}
186
+ size={size}
187
+ className={cn(
188
+ 'absolute size-8 rounded-full',
189
+ orientation === 'horizontal'
190
+ ? 'top-1/2 -left-12 -translate-y-1/2'
191
+ : '-top-12 left-1/2 -translate-x-1/2 rotate-90',
192
+ className,
193
+ )}
194
+ disabled={!canScrollPrev}
195
+ onClick={scrollPrev}
196
+ {...props}
197
+ >
198
+ <ArrowLeft />
199
+ <span className="sr-only">Previous slide</span>
200
+ </Button>
201
+ )
202
+ }
203
+
204
+ function CarouselNext({
205
+ className,
206
+ variant = 'outline',
207
+ size = 'icon',
208
+ ...props
209
+ }: React.ComponentProps<typeof Button>) {
210
+ const { orientation, scrollNext, canScrollNext } = useCarousel()
211
+
212
+ return (
213
+ <Button
214
+ data-slot="carousel-next"
215
+ variant={variant}
216
+ size={size}
217
+ className={cn(
218
+ 'absolute size-8 rounded-full',
219
+ orientation === 'horizontal'
220
+ ? 'top-1/2 -right-12 -translate-y-1/2'
221
+ : '-bottom-12 left-1/2 -translate-x-1/2 rotate-90',
222
+ className,
223
+ )}
224
+ disabled={!canScrollNext}
225
+ onClick={scrollNext}
226
+ {...props}
227
+ >
228
+ <ArrowRight />
229
+ <span className="sr-only">Next slide</span>
230
+ </Button>
231
+ )
232
+ }
233
+
234
+ export {
235
+ type CarouselApi,
236
+ Carousel,
237
+ CarouselContent,
238
+ CarouselItem,
239
+ CarouselPrevious,
240
+ CarouselNext,
241
+ }