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.
- package/.eslintrc.json +19 -0
- package/.prettierrc +10 -0
- package/CHANGELOG.md +22 -0
- package/CONTRIBUTING.md +51 -0
- package/LICENSE +21 -0
- package/README.md +213 -0
- package/app/globals.css +125 -0
- package/app/layout.tsx +27 -0
- package/app/page.tsx +7 -0
- package/components/theme-provider.tsx +11 -0
- package/components/ui/accordion.tsx +66 -0
- package/components/ui/alert-dialog.tsx +157 -0
- package/components/ui/alert.tsx +66 -0
- package/components/ui/aspect-ratio.tsx +11 -0
- package/components/ui/avatar.tsx +53 -0
- package/components/ui/badge.tsx +46 -0
- package/components/ui/breadcrumb.tsx +109 -0
- package/components/ui/button-group.tsx +83 -0
- package/components/ui/button.tsx +60 -0
- package/components/ui/calendar.tsx +213 -0
- package/components/ui/card.tsx +92 -0
- package/components/ui/carousel.tsx +241 -0
- package/components/ui/chart.tsx +353 -0
- package/components/ui/checkbox.tsx +32 -0
- package/components/ui/collapsible.tsx +33 -0
- package/components/ui/command.tsx +184 -0
- package/components/ui/context-menu.tsx +252 -0
- package/components/ui/dialog.tsx +143 -0
- package/components/ui/drawer.tsx +135 -0
- package/components/ui/dropdown-menu.tsx +257 -0
- package/components/ui/empty.tsx +104 -0
- package/components/ui/field.tsx +244 -0
- package/components/ui/form.tsx +167 -0
- package/components/ui/hover-card.tsx +44 -0
- package/components/ui/input-group.tsx +169 -0
- package/components/ui/input-otp.tsx +77 -0
- package/components/ui/input.tsx +21 -0
- package/components/ui/item.tsx +193 -0
- package/components/ui/kbd.tsx +28 -0
- package/components/ui/label.tsx +24 -0
- package/components/ui/menubar.tsx +276 -0
- package/components/ui/navigation-menu.tsx +166 -0
- package/components/ui/pagination.tsx +127 -0
- package/components/ui/popover.tsx +48 -0
- package/components/ui/progress.tsx +31 -0
- package/components/ui/radio-group.tsx +45 -0
- package/components/ui/resizable.tsx +56 -0
- package/components/ui/scroll-area.tsx +58 -0
- package/components/ui/select.tsx +185 -0
- package/components/ui/separator.tsx +28 -0
- package/components/ui/sheet.tsx +139 -0
- package/components/ui/sidebar.tsx +726 -0
- package/components/ui/skeleton.tsx +13 -0
- package/components/ui/slider.tsx +63 -0
- package/components/ui/sonner.tsx +25 -0
- package/components/ui/spinner.tsx +16 -0
- package/components/ui/switch.tsx +31 -0
- package/components/ui/table.tsx +116 -0
- package/components/ui/tabs.tsx +66 -0
- package/components/ui/textarea.tsx +18 -0
- package/components/ui/toast.tsx +129 -0
- package/components/ui/toaster.tsx +35 -0
- package/components/ui/toggle-group.tsx +73 -0
- package/components/ui/toggle.tsx +47 -0
- package/components/ui/tooltip.tsx +61 -0
- package/components/ui/use-mobile.tsx +19 -0
- package/components/ui/use-toast.ts +191 -0
- package/components.json +21 -0
- package/dist/advanced/cube-root.d.ts +2 -0
- package/dist/advanced/cube-root.d.ts.map +1 -0
- package/dist/advanced/cube-root.js +4 -0
- package/dist/advanced/cube-root.js.map +1 -0
- package/dist/advanced/factorial.d.ts +2 -0
- package/dist/advanced/factorial.d.ts.map +1 -0
- package/dist/advanced/factorial.js +11 -0
- package/dist/advanced/factorial.js.map +1 -0
- package/dist/advanced/fibonacci.d.ts +2 -0
- package/dist/advanced/fibonacci.d.ts.map +1 -0
- package/dist/advanced/fibonacci.js +15 -0
- package/dist/advanced/fibonacci.js.map +1 -0
- package/dist/advanced/gcd.d.ts +2 -0
- package/dist/advanced/gcd.d.ts.map +1 -0
- package/dist/advanced/gcd.js +10 -0
- package/dist/advanced/gcd.js.map +1 -0
- package/dist/advanced/lcm.d.ts +2 -0
- package/dist/advanced/lcm.d.ts.map +1 -0
- package/dist/advanced/lcm.js +13 -0
- package/dist/advanced/lcm.js.map +1 -0
- package/dist/advanced/power.d.ts +2 -0
- package/dist/advanced/power.d.ts.map +1 -0
- package/dist/advanced/power.js +4 -0
- package/dist/advanced/power.js.map +1 -0
- package/dist/advanced/prime-check.d.ts +2 -0
- package/dist/advanced/prime-check.d.ts.map +1 -0
- package/dist/advanced/prime-check.js +14 -0
- package/dist/advanced/prime-check.js.map +1 -0
- package/dist/advanced/prime-list.d.ts +2 -0
- package/dist/advanced/prime-list.d.ts.map +1 -0
- package/dist/advanced/prime-list.js +14 -0
- package/dist/advanced/prime-list.js.map +1 -0
- package/dist/advanced/sqrt.d.ts +2 -0
- package/dist/advanced/sqrt.d.ts.map +1 -0
- package/dist/advanced/sqrt.js +6 -0
- package/dist/advanced/sqrt.js.map +1 -0
- package/dist/algebra/circle-area.d.ts +2 -0
- package/dist/algebra/circle-area.d.ts.map +1 -0
- package/dist/algebra/circle-area.js +4 -0
- package/dist/algebra/circle-area.js.map +1 -0
- package/dist/algebra/distance.d.ts +2 -0
- package/dist/algebra/distance.d.ts.map +1 -0
- package/dist/algebra/distance.js +4 -0
- package/dist/algebra/distance.js.map +1 -0
- package/dist/algebra/midpoint.d.ts +2 -0
- package/dist/algebra/midpoint.d.ts.map +1 -0
- package/dist/algebra/midpoint.js +4 -0
- package/dist/algebra/midpoint.js.map +1 -0
- package/dist/algebra/slope.d.ts +2 -0
- package/dist/algebra/slope.d.ts.map +1 -0
- package/dist/algebra/slope.js +6 -0
- package/dist/algebra/slope.js.map +1 -0
- package/dist/algebra/solve-linear.d.ts +2 -0
- package/dist/algebra/solve-linear.d.ts.map +1 -0
- package/dist/algebra/solve-linear.js +6 -0
- package/dist/algebra/solve-linear.js.map +1 -0
- package/dist/algebra/solve-quadratic.d.ts +2 -0
- package/dist/algebra/solve-quadratic.d.ts.map +1 -0
- package/dist/algebra/solve-quadratic.js +12 -0
- package/dist/algebra/solve-quadratic.js.map +1 -0
- package/dist/algebra/triangle-area.d.ts +2 -0
- package/dist/algebra/triangle-area.d.ts.map +1 -0
- package/dist/algebra/triangle-area.js +5 -0
- package/dist/algebra/triangle-area.js.map +1 -0
- package/dist/arithmetic/add.d.ts +2 -0
- package/dist/arithmetic/add.d.ts.map +1 -0
- package/dist/arithmetic/add.js +4 -0
- package/dist/arithmetic/add.js.map +1 -0
- package/dist/arithmetic/ceil.d.ts +2 -0
- package/dist/arithmetic/ceil.d.ts.map +1 -0
- package/dist/arithmetic/ceil.js +4 -0
- package/dist/arithmetic/ceil.js.map +1 -0
- package/dist/arithmetic/clamp.d.ts +2 -0
- package/dist/arithmetic/clamp.d.ts.map +1 -0
- package/dist/arithmetic/clamp.js +4 -0
- package/dist/arithmetic/clamp.js.map +1 -0
- package/dist/arithmetic/divide.d.ts +2 -0
- package/dist/arithmetic/divide.d.ts.map +1 -0
- package/dist/arithmetic/divide.js +6 -0
- package/dist/arithmetic/divide.js.map +1 -0
- package/dist/arithmetic/floor.d.ts +2 -0
- package/dist/arithmetic/floor.d.ts.map +1 -0
- package/dist/arithmetic/floor.js +4 -0
- package/dist/arithmetic/floor.js.map +1 -0
- package/dist/arithmetic/modulo.d.ts +2 -0
- package/dist/arithmetic/modulo.d.ts.map +1 -0
- package/dist/arithmetic/modulo.js +4 -0
- package/dist/arithmetic/modulo.js.map +1 -0
- package/dist/arithmetic/multiply.d.ts +2 -0
- package/dist/arithmetic/multiply.d.ts.map +1 -0
- package/dist/arithmetic/multiply.js +4 -0
- package/dist/arithmetic/multiply.js.map +1 -0
- package/dist/arithmetic/percentage.d.ts +2 -0
- package/dist/arithmetic/percentage.d.ts.map +1 -0
- package/dist/arithmetic/percentage.js +4 -0
- package/dist/arithmetic/percentage.js.map +1 -0
- package/dist/arithmetic/round.d.ts +2 -0
- package/dist/arithmetic/round.d.ts.map +1 -0
- package/dist/arithmetic/round.js +5 -0
- package/dist/arithmetic/round.js.map +1 -0
- package/dist/arithmetic/subtract.d.ts +2 -0
- package/dist/arithmetic/subtract.d.ts.map +1 -0
- package/dist/arithmetic/subtract.js +4 -0
- package/dist/arithmetic/subtract.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +277 -0
- package/dist/cli.js.map +1 -0
- package/dist/convert/c-to-f.d.ts +2 -0
- package/dist/convert/c-to-f.d.ts.map +1 -0
- package/dist/convert/c-to-f.js +4 -0
- package/dist/convert/c-to-f.js.map +1 -0
- package/dist/convert/deg-to-rad.d.ts +2 -0
- package/dist/convert/deg-to-rad.d.ts.map +1 -0
- package/dist/convert/deg-to-rad.js +4 -0
- package/dist/convert/deg-to-rad.js.map +1 -0
- package/dist/convert/f-to-c.d.ts +2 -0
- package/dist/convert/f-to-c.d.ts.map +1 -0
- package/dist/convert/f-to-c.js +4 -0
- package/dist/convert/f-to-c.js.map +1 -0
- package/dist/convert/km-to-miles.d.ts +2 -0
- package/dist/convert/km-to-miles.d.ts.map +1 -0
- package/dist/convert/km-to-miles.js +4 -0
- package/dist/convert/km-to-miles.js.map +1 -0
- package/dist/convert/miles-to-km.d.ts +2 -0
- package/dist/convert/miles-to-km.d.ts.map +1 -0
- package/dist/convert/miles-to-km.js +4 -0
- package/dist/convert/miles-to-km.js.map +1 -0
- package/dist/convert/rad-to-deg.d.ts +2 -0
- package/dist/convert/rad-to-deg.d.ts.map +1 -0
- package/dist/convert/rad-to-deg.js +4 -0
- package/dist/convert/rad-to-deg.js.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/random/random-array.d.ts +2 -0
- package/dist/random/random-array.d.ts.map +1 -0
- package/dist/random/random-array.js +4 -0
- package/dist/random/random-array.js.map +1 -0
- package/dist/random/random-float.d.ts +2 -0
- package/dist/random/random-float.d.ts.map +1 -0
- package/dist/random/random-float.js +4 -0
- package/dist/random/random-float.js.map +1 -0
- package/dist/random/random-from-array.d.ts +2 -0
- package/dist/random/random-from-array.d.ts.map +1 -0
- package/dist/random/random-from-array.js +4 -0
- package/dist/random/random-from-array.js.map +1 -0
- package/dist/random/random-int.d.ts +2 -0
- package/dist/random/random-int.d.ts.map +1 -0
- package/dist/random/random-int.js +4 -0
- package/dist/random/random-int.js.map +1 -0
- package/dist/statistics/mean.d.ts +2 -0
- package/dist/statistics/mean.d.ts.map +1 -0
- package/dist/statistics/mean.js +6 -0
- package/dist/statistics/mean.js.map +1 -0
- package/dist/statistics/median.d.ts +2 -0
- package/dist/statistics/median.d.ts.map +1 -0
- package/dist/statistics/median.js +8 -0
- package/dist/statistics/median.js.map +1 -0
- package/dist/statistics/mode.d.ts +2 -0
- package/dist/statistics/mode.d.ts.map +1 -0
- package/dist/statistics/mode.js +13 -0
- package/dist/statistics/mode.js.map +1 -0
- package/dist/statistics/product-array.d.ts +2 -0
- package/dist/statistics/product-array.d.ts.map +1 -0
- package/dist/statistics/product-array.js +4 -0
- package/dist/statistics/product-array.js.map +1 -0
- package/dist/statistics/range.d.ts +2 -0
- package/dist/statistics/range.d.ts.map +1 -0
- package/dist/statistics/range.js +6 -0
- package/dist/statistics/range.js.map +1 -0
- package/dist/statistics/std-dev.d.ts +2 -0
- package/dist/statistics/std-dev.d.ts.map +1 -0
- package/dist/statistics/std-dev.js +10 -0
- package/dist/statistics/std-dev.js.map +1 -0
- package/dist/statistics/sum-array.d.ts +2 -0
- package/dist/statistics/sum-array.d.ts.map +1 -0
- package/dist/statistics/sum-array.js +4 -0
- package/dist/statistics/sum-array.js.map +1 -0
- package/dist/statistics/variance.d.ts +2 -0
- package/dist/statistics/variance.d.ts.map +1 -0
- package/dist/statistics/variance.js +7 -0
- package/dist/statistics/variance.js.map +1 -0
- package/examples/advanced-examples.ts +31 -0
- package/examples/algebra-examples.ts +24 -0
- package/examples/arithmetic-examples.ts +24 -0
- package/examples/conversion-examples.ts +24 -0
- package/examples/statistics-examples.ts +29 -0
- package/hooks/use-mobile.ts +19 -0
- package/hooks/use-toast.ts +191 -0
- package/jest.config.js +15 -0
- package/lib/utils.ts +6 -0
- package/next.config.mjs +11 -0
- package/package.json +110 -0
- package/postcss.config.mjs +8 -0
- package/public/apple-icon.png +0 -0
- package/public/icon-dark-32x32.png +0 -0
- package/public/icon-light-32x32.png +0 -0
- package/public/icon.svg +26 -0
- package/public/placeholder-logo.png +0 -0
- package/public/placeholder-logo.svg +1 -0
- package/public/placeholder-user.jpg +0 -0
- package/public/placeholder.jpg +0 -0
- package/public/placeholder.svg +1 -0
- package/src/advanced/cube-root.ts +8 -0
- package/src/advanced/factorial.ts +12 -0
- package/src/advanced/fibonacci.ts +16 -0
- package/src/advanced/gcd.ts +14 -0
- package/src/advanced/lcm.ts +18 -0
- package/src/advanced/power.ts +9 -0
- package/src/advanced/prime-check.ts +14 -0
- package/src/advanced/prime-list.ts +16 -0
- package/src/advanced/sqrt.ts +9 -0
- package/src/algebra/circle-area.ts +8 -0
- package/src/algebra/distance.ts +11 -0
- package/src/algebra/midpoint.ts +11 -0
- package/src/algebra/slope.ts +12 -0
- package/src/algebra/solve-linear.ts +10 -0
- package/src/algebra/solve-quadratic.ts +15 -0
- package/src/algebra/triangle-area.ts +11 -0
- package/src/arithmetic/add.ts +9 -0
- package/src/arithmetic/ceil.ts +8 -0
- package/src/arithmetic/clamp.ts +10 -0
- package/src/arithmetic/divide.ts +11 -0
- package/src/arithmetic/floor.ts +8 -0
- package/src/arithmetic/modulo.ts +9 -0
- package/src/arithmetic/multiply.ts +9 -0
- package/src/arithmetic/percentage.ts +9 -0
- package/src/arithmetic/round.ts +10 -0
- package/src/arithmetic/subtract.ts +9 -0
- package/src/cli.ts +321 -0
- package/src/convert/c-to-f.ts +8 -0
- package/src/convert/deg-to-rad.ts +8 -0
- package/src/convert/f-to-c.ts +8 -0
- package/src/convert/km-to-miles.ts +8 -0
- package/src/convert/miles-to-km.ts +8 -0
- package/src/convert/rad-to-deg.ts +8 -0
- package/src/index.ts +49 -0
- package/src/random/random-array.ts +10 -0
- package/src/random/random-float.ts +9 -0
- package/src/random/random-from-array.ts +8 -0
- package/src/random/random-int.ts +9 -0
- package/src/statistics/mean.ts +9 -0
- package/src/statistics/median.ts +11 -0
- package/src/statistics/mode.ts +16 -0
- package/src/statistics/product-array.ts +8 -0
- package/src/statistics/range.ts +9 -0
- package/src/statistics/std-dev.ts +14 -0
- package/src/statistics/sum-array.ts +8 -0
- package/src/statistics/variance.ts +10 -0
- package/styles/globals.css +125 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'
|
|
5
|
+
import { CheckIcon, ChevronRightIcon, CircleIcon } from 'lucide-react'
|
|
6
|
+
|
|
7
|
+
import { cn } from '@/lib/utils'
|
|
8
|
+
|
|
9
|
+
function DropdownMenu({
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
|
12
|
+
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function DropdownMenuPortal({
|
|
16
|
+
...props
|
|
17
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
|
|
18
|
+
return (
|
|
19
|
+
<DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function DropdownMenuTrigger({
|
|
24
|
+
...props
|
|
25
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
|
|
26
|
+
return (
|
|
27
|
+
<DropdownMenuPrimitive.Trigger
|
|
28
|
+
data-slot="dropdown-menu-trigger"
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function DropdownMenuContent({
|
|
35
|
+
className,
|
|
36
|
+
sideOffset = 4,
|
|
37
|
+
...props
|
|
38
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
|
|
39
|
+
return (
|
|
40
|
+
<DropdownMenuPrimitive.Portal>
|
|
41
|
+
<DropdownMenuPrimitive.Content
|
|
42
|
+
data-slot="dropdown-menu-content"
|
|
43
|
+
sideOffset={sideOffset}
|
|
44
|
+
className={cn(
|
|
45
|
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md',
|
|
46
|
+
className,
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
</DropdownMenuPrimitive.Portal>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function DropdownMenuGroup({
|
|
55
|
+
...props
|
|
56
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
|
|
57
|
+
return (
|
|
58
|
+
<DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function DropdownMenuItem({
|
|
63
|
+
className,
|
|
64
|
+
inset,
|
|
65
|
+
variant = 'default',
|
|
66
|
+
...props
|
|
67
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
|
68
|
+
inset?: boolean
|
|
69
|
+
variant?: 'default' | 'destructive'
|
|
70
|
+
}) {
|
|
71
|
+
return (
|
|
72
|
+
<DropdownMenuPrimitive.Item
|
|
73
|
+
data-slot="dropdown-menu-item"
|
|
74
|
+
data-inset={inset}
|
|
75
|
+
data-variant={variant}
|
|
76
|
+
className={cn(
|
|
77
|
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
78
|
+
className,
|
|
79
|
+
)}
|
|
80
|
+
{...props}
|
|
81
|
+
/>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function DropdownMenuCheckboxItem({
|
|
86
|
+
className,
|
|
87
|
+
children,
|
|
88
|
+
checked,
|
|
89
|
+
...props
|
|
90
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {
|
|
91
|
+
return (
|
|
92
|
+
<DropdownMenuPrimitive.CheckboxItem
|
|
93
|
+
data-slot="dropdown-menu-checkbox-item"
|
|
94
|
+
className={cn(
|
|
95
|
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
96
|
+
className,
|
|
97
|
+
)}
|
|
98
|
+
checked={checked}
|
|
99
|
+
{...props}
|
|
100
|
+
>
|
|
101
|
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
|
102
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
103
|
+
<CheckIcon className="size-4" />
|
|
104
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
105
|
+
</span>
|
|
106
|
+
{children}
|
|
107
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function DropdownMenuRadioGroup({
|
|
112
|
+
...props
|
|
113
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
|
|
114
|
+
return (
|
|
115
|
+
<DropdownMenuPrimitive.RadioGroup
|
|
116
|
+
data-slot="dropdown-menu-radio-group"
|
|
117
|
+
{...props}
|
|
118
|
+
/>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function DropdownMenuRadioItem({
|
|
123
|
+
className,
|
|
124
|
+
children,
|
|
125
|
+
...props
|
|
126
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {
|
|
127
|
+
return (
|
|
128
|
+
<DropdownMenuPrimitive.RadioItem
|
|
129
|
+
data-slot="dropdown-menu-radio-item"
|
|
130
|
+
className={cn(
|
|
131
|
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
132
|
+
className,
|
|
133
|
+
)}
|
|
134
|
+
{...props}
|
|
135
|
+
>
|
|
136
|
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
|
137
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
138
|
+
<CircleIcon className="size-2 fill-current" />
|
|
139
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
140
|
+
</span>
|
|
141
|
+
{children}
|
|
142
|
+
</DropdownMenuPrimitive.RadioItem>
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function DropdownMenuLabel({
|
|
147
|
+
className,
|
|
148
|
+
inset,
|
|
149
|
+
...props
|
|
150
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
|
|
151
|
+
inset?: boolean
|
|
152
|
+
}) {
|
|
153
|
+
return (
|
|
154
|
+
<DropdownMenuPrimitive.Label
|
|
155
|
+
data-slot="dropdown-menu-label"
|
|
156
|
+
data-inset={inset}
|
|
157
|
+
className={cn(
|
|
158
|
+
'px-2 py-1.5 text-sm font-medium data-[inset]:pl-8',
|
|
159
|
+
className,
|
|
160
|
+
)}
|
|
161
|
+
{...props}
|
|
162
|
+
/>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function DropdownMenuSeparator({
|
|
167
|
+
className,
|
|
168
|
+
...props
|
|
169
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
|
|
170
|
+
return (
|
|
171
|
+
<DropdownMenuPrimitive.Separator
|
|
172
|
+
data-slot="dropdown-menu-separator"
|
|
173
|
+
className={cn('bg-border -mx-1 my-1 h-px', className)}
|
|
174
|
+
{...props}
|
|
175
|
+
/>
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function DropdownMenuShortcut({
|
|
180
|
+
className,
|
|
181
|
+
...props
|
|
182
|
+
}: React.ComponentProps<'span'>) {
|
|
183
|
+
return (
|
|
184
|
+
<span
|
|
185
|
+
data-slot="dropdown-menu-shortcut"
|
|
186
|
+
className={cn(
|
|
187
|
+
'text-muted-foreground ml-auto text-xs tracking-widest',
|
|
188
|
+
className,
|
|
189
|
+
)}
|
|
190
|
+
{...props}
|
|
191
|
+
/>
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function DropdownMenuSub({
|
|
196
|
+
...props
|
|
197
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
|
|
198
|
+
return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function DropdownMenuSubTrigger({
|
|
202
|
+
className,
|
|
203
|
+
inset,
|
|
204
|
+
children,
|
|
205
|
+
...props
|
|
206
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
207
|
+
inset?: boolean
|
|
208
|
+
}) {
|
|
209
|
+
return (
|
|
210
|
+
<DropdownMenuPrimitive.SubTrigger
|
|
211
|
+
data-slot="dropdown-menu-sub-trigger"
|
|
212
|
+
data-inset={inset}
|
|
213
|
+
className={cn(
|
|
214
|
+
"focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
215
|
+
className,
|
|
216
|
+
)}
|
|
217
|
+
{...props}
|
|
218
|
+
>
|
|
219
|
+
{children}
|
|
220
|
+
<ChevronRightIcon className="ml-auto size-4" />
|
|
221
|
+
</DropdownMenuPrimitive.SubTrigger>
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function DropdownMenuSubContent({
|
|
226
|
+
className,
|
|
227
|
+
...props
|
|
228
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
|
|
229
|
+
return (
|
|
230
|
+
<DropdownMenuPrimitive.SubContent
|
|
231
|
+
data-slot="dropdown-menu-sub-content"
|
|
232
|
+
className={cn(
|
|
233
|
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg',
|
|
234
|
+
className,
|
|
235
|
+
)}
|
|
236
|
+
{...props}
|
|
237
|
+
/>
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export {
|
|
242
|
+
DropdownMenu,
|
|
243
|
+
DropdownMenuPortal,
|
|
244
|
+
DropdownMenuTrigger,
|
|
245
|
+
DropdownMenuContent,
|
|
246
|
+
DropdownMenuGroup,
|
|
247
|
+
DropdownMenuLabel,
|
|
248
|
+
DropdownMenuItem,
|
|
249
|
+
DropdownMenuCheckboxItem,
|
|
250
|
+
DropdownMenuRadioGroup,
|
|
251
|
+
DropdownMenuRadioItem,
|
|
252
|
+
DropdownMenuSeparator,
|
|
253
|
+
DropdownMenuShortcut,
|
|
254
|
+
DropdownMenuSub,
|
|
255
|
+
DropdownMenuSubTrigger,
|
|
256
|
+
DropdownMenuSubContent,
|
|
257
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
2
|
+
|
|
3
|
+
import { cn } from '@/lib/utils'
|
|
4
|
+
|
|
5
|
+
function Empty({ className, ...props }: React.ComponentProps<'div'>) {
|
|
6
|
+
return (
|
|
7
|
+
<div
|
|
8
|
+
data-slot="empty"
|
|
9
|
+
className={cn(
|
|
10
|
+
'flex min-w-0 flex-1 flex-col items-center justify-center gap-6 rounded-lg border-dashed p-6 text-center text-balance md:p-12',
|
|
11
|
+
className,
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function EmptyHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
data-slot="empty-header"
|
|
22
|
+
className={cn(
|
|
23
|
+
'flex max-w-sm flex-col items-center gap-2 text-center',
|
|
24
|
+
className,
|
|
25
|
+
)}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const emptyMediaVariants = cva(
|
|
32
|
+
'flex shrink-0 items-center justify-center mb-2 [&_svg]:pointer-events-none [&_svg]:shrink-0',
|
|
33
|
+
{
|
|
34
|
+
variants: {
|
|
35
|
+
variant: {
|
|
36
|
+
default: 'bg-transparent',
|
|
37
|
+
icon: "bg-muted text-foreground flex size-10 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*='size-'])]:size-6",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
defaultVariants: {
|
|
41
|
+
variant: 'default',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
function EmptyMedia({
|
|
47
|
+
className,
|
|
48
|
+
variant = 'default',
|
|
49
|
+
...props
|
|
50
|
+
}: React.ComponentProps<'div'> & VariantProps<typeof emptyMediaVariants>) {
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
data-slot="empty-icon"
|
|
54
|
+
data-variant={variant}
|
|
55
|
+
className={cn(emptyMediaVariants({ variant, className }))}
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function EmptyTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
|
62
|
+
return (
|
|
63
|
+
<div
|
|
64
|
+
data-slot="empty-title"
|
|
65
|
+
className={cn('text-lg font-medium tracking-tight', className)}
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function EmptyDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
data-slot="empty-description"
|
|
75
|
+
className={cn(
|
|
76
|
+
'text-muted-foreground [&>a:hover]:text-primary text-sm/relaxed [&>a]:underline [&>a]:underline-offset-4',
|
|
77
|
+
className,
|
|
78
|
+
)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function EmptyContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
85
|
+
return (
|
|
86
|
+
<div
|
|
87
|
+
data-slot="empty-content"
|
|
88
|
+
className={cn(
|
|
89
|
+
'flex w-full max-w-sm min-w-0 flex-col items-center gap-4 text-sm text-balance',
|
|
90
|
+
className,
|
|
91
|
+
)}
|
|
92
|
+
{...props}
|
|
93
|
+
/>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export {
|
|
98
|
+
Empty,
|
|
99
|
+
EmptyHeader,
|
|
100
|
+
EmptyTitle,
|
|
101
|
+
EmptyDescription,
|
|
102
|
+
EmptyContent,
|
|
103
|
+
EmptyMedia,
|
|
104
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useMemo } from 'react'
|
|
4
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
5
|
+
|
|
6
|
+
import { cn } from '@/lib/utils'
|
|
7
|
+
import { Label } from '@/components/ui/label'
|
|
8
|
+
import { Separator } from '@/components/ui/separator'
|
|
9
|
+
|
|
10
|
+
function FieldSet({ className, ...props }: React.ComponentProps<'fieldset'>) {
|
|
11
|
+
return (
|
|
12
|
+
<fieldset
|
|
13
|
+
data-slot="field-set"
|
|
14
|
+
className={cn(
|
|
15
|
+
'flex flex-col gap-6',
|
|
16
|
+
'has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',
|
|
17
|
+
className,
|
|
18
|
+
)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function FieldLegend({
|
|
25
|
+
className,
|
|
26
|
+
variant = 'legend',
|
|
27
|
+
...props
|
|
28
|
+
}: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {
|
|
29
|
+
return (
|
|
30
|
+
<legend
|
|
31
|
+
data-slot="field-legend"
|
|
32
|
+
data-variant={variant}
|
|
33
|
+
className={cn(
|
|
34
|
+
'mb-3 font-medium',
|
|
35
|
+
'data-[variant=legend]:text-base',
|
|
36
|
+
'data-[variant=label]:text-sm',
|
|
37
|
+
className,
|
|
38
|
+
)}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function FieldGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
data-slot="field-group"
|
|
48
|
+
className={cn(
|
|
49
|
+
'group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4',
|
|
50
|
+
className,
|
|
51
|
+
)}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const fieldVariants = cva(
|
|
58
|
+
'group/field flex w-full gap-3 data-[invalid=true]:text-destructive',
|
|
59
|
+
{
|
|
60
|
+
variants: {
|
|
61
|
+
orientation: {
|
|
62
|
+
vertical: ['flex-col [&>*]:w-full [&>.sr-only]:w-auto'],
|
|
63
|
+
horizontal: [
|
|
64
|
+
'flex-row items-center',
|
|
65
|
+
'[&>[data-slot=field-label]]:flex-auto',
|
|
66
|
+
'has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
|
|
67
|
+
],
|
|
68
|
+
responsive: [
|
|
69
|
+
'flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto',
|
|
70
|
+
'@md/field-group:[&>[data-slot=field-label]]:flex-auto',
|
|
71
|
+
'@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
defaultVariants: {
|
|
76
|
+
orientation: 'vertical',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
function Field({
|
|
82
|
+
className,
|
|
83
|
+
orientation = 'vertical',
|
|
84
|
+
...props
|
|
85
|
+
}: React.ComponentProps<'div'> & VariantProps<typeof fieldVariants>) {
|
|
86
|
+
return (
|
|
87
|
+
<div
|
|
88
|
+
role="group"
|
|
89
|
+
data-slot="field"
|
|
90
|
+
data-orientation={orientation}
|
|
91
|
+
className={cn(fieldVariants({ orientation }), className)}
|
|
92
|
+
{...props}
|
|
93
|
+
/>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function FieldContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
98
|
+
return (
|
|
99
|
+
<div
|
|
100
|
+
data-slot="field-content"
|
|
101
|
+
className={cn(
|
|
102
|
+
'group/field-content flex flex-1 flex-col gap-1.5 leading-snug',
|
|
103
|
+
className,
|
|
104
|
+
)}
|
|
105
|
+
{...props}
|
|
106
|
+
/>
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function FieldLabel({
|
|
111
|
+
className,
|
|
112
|
+
...props
|
|
113
|
+
}: React.ComponentProps<typeof Label>) {
|
|
114
|
+
return (
|
|
115
|
+
<Label
|
|
116
|
+
data-slot="field-label"
|
|
117
|
+
className={cn(
|
|
118
|
+
'group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50',
|
|
119
|
+
'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4',
|
|
120
|
+
'has-data-[state=checked]:bg-primary/5 has-data-[state=checked]:border-primary dark:has-data-[state=checked]:bg-primary/10',
|
|
121
|
+
className,
|
|
122
|
+
)}
|
|
123
|
+
{...props}
|
|
124
|
+
/>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function FieldTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
|
129
|
+
return (
|
|
130
|
+
<div
|
|
131
|
+
data-slot="field-label"
|
|
132
|
+
className={cn(
|
|
133
|
+
'flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50',
|
|
134
|
+
className,
|
|
135
|
+
)}
|
|
136
|
+
{...props}
|
|
137
|
+
/>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function FieldDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
|
142
|
+
return (
|
|
143
|
+
<p
|
|
144
|
+
data-slot="field-description"
|
|
145
|
+
className={cn(
|
|
146
|
+
'text-muted-foreground text-sm leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance',
|
|
147
|
+
'last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5',
|
|
148
|
+
'[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4',
|
|
149
|
+
className,
|
|
150
|
+
)}
|
|
151
|
+
{...props}
|
|
152
|
+
/>
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function FieldSeparator({
|
|
157
|
+
children,
|
|
158
|
+
className,
|
|
159
|
+
...props
|
|
160
|
+
}: React.ComponentProps<'div'> & {
|
|
161
|
+
children?: React.ReactNode
|
|
162
|
+
}) {
|
|
163
|
+
return (
|
|
164
|
+
<div
|
|
165
|
+
data-slot="field-separator"
|
|
166
|
+
data-content={!!children}
|
|
167
|
+
className={cn(
|
|
168
|
+
'relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2',
|
|
169
|
+
className,
|
|
170
|
+
)}
|
|
171
|
+
{...props}
|
|
172
|
+
>
|
|
173
|
+
<Separator className="absolute inset-0 top-1/2" />
|
|
174
|
+
{children && (
|
|
175
|
+
<span
|
|
176
|
+
className="bg-background text-muted-foreground relative mx-auto block w-fit px-2"
|
|
177
|
+
data-slot="field-separator-content"
|
|
178
|
+
>
|
|
179
|
+
{children}
|
|
180
|
+
</span>
|
|
181
|
+
)}
|
|
182
|
+
</div>
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function FieldError({
|
|
187
|
+
className,
|
|
188
|
+
children,
|
|
189
|
+
errors,
|
|
190
|
+
...props
|
|
191
|
+
}: React.ComponentProps<'div'> & {
|
|
192
|
+
errors?: Array<{ message?: string } | undefined>
|
|
193
|
+
}) {
|
|
194
|
+
const content = useMemo(() => {
|
|
195
|
+
if (children) {
|
|
196
|
+
return children
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (!errors) {
|
|
200
|
+
return null
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (errors.length === 1 && errors[0]?.message) {
|
|
204
|
+
return errors[0].message
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return (
|
|
208
|
+
<ul className="ml-4 flex list-disc flex-col gap-1">
|
|
209
|
+
{errors.map(
|
|
210
|
+
(error, index) =>
|
|
211
|
+
error?.message && <li key={index}>{error.message}</li>,
|
|
212
|
+
)}
|
|
213
|
+
</ul>
|
|
214
|
+
)
|
|
215
|
+
}, [children, errors])
|
|
216
|
+
|
|
217
|
+
if (!content) {
|
|
218
|
+
return null
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<div
|
|
223
|
+
role="alert"
|
|
224
|
+
data-slot="field-error"
|
|
225
|
+
className={cn('text-destructive text-sm font-normal', className)}
|
|
226
|
+
{...props}
|
|
227
|
+
>
|
|
228
|
+
{content}
|
|
229
|
+
</div>
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export {
|
|
234
|
+
Field,
|
|
235
|
+
FieldLabel,
|
|
236
|
+
FieldDescription,
|
|
237
|
+
FieldError,
|
|
238
|
+
FieldGroup,
|
|
239
|
+
FieldLegend,
|
|
240
|
+
FieldSeparator,
|
|
241
|
+
FieldSet,
|
|
242
|
+
FieldContent,
|
|
243
|
+
FieldTitle,
|
|
244
|
+
}
|