@ichaingo/ui 1.1.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/.babelrc +12 -0
- package/README.md +103 -0
- package/components.json +21 -0
- package/dist/accordion.d.ts +13 -0
- package/dist/accordion.mjs +64 -0
- package/dist/alert-dialog.d.ts +27 -0
- package/dist/alert-dialog.mjs +146 -0
- package/dist/alert.d.ts +16 -0
- package/dist/alert.mjs +66 -0
- package/dist/aspect-ratio.d.ts +6 -0
- package/dist/aspect-ratio.mjs +10 -0
- package/dist/avatar.d.ts +11 -0
- package/dist/avatar.mjs +53 -0
- package/dist/badge.d.ts +14 -0
- package/dist/badge.mjs +39 -0
- package/dist/breadcrumb.d.ts +20 -0
- package/dist/breadcrumb.mjs +102 -0
- package/dist/button.d.ts +15 -0
- package/dist/button.mjs +49 -0
- package/dist/calendar.d.ts +23 -0
- package/dist/calendar.mjs +173 -0
- package/dist/card.d.ts +18 -0
- package/dist/card.mjs +90 -0
- package/dist/carousel.d.ts +42 -0
- package/dist/carousel.mjs +177 -0
- package/dist/checkbox.d.ts +7 -0
- package/dist/checkbox.mjs +31 -0
- package/dist/collapsible.d.ts +10 -0
- package/dist/collapsible.mjs +34 -0
- package/dist/command.d.ts +31 -0
- package/dist/command.mjs +170 -0
- package/dist/context-menu.d.ts +42 -0
- package/dist/context-menu.mjs +223 -0
- package/dist/dialog.d.ts +27 -0
- package/dist/dialog.mjs +136 -0
- package/dist/dropdown-menu.d.ts +42 -0
- package/dist/dropdown-menu.mjs +231 -0
- package/dist/form.d.ts +38 -0
- package/dist/form.mjs +101 -0
- package/dist/hover-card.d.ts +11 -0
- package/dist/hover-card.mjs +38 -0
- package/dist/input.d.ts +6 -0
- package/dist/input.mjs +21 -0
- package/dist/label.d.ts +7 -0
- package/dist/label.mjs +23 -0
- package/dist/menubar.d.ts +44 -0
- package/dist/menubar.mjs +251 -0
- package/dist/navigation-menu.d.ts +26 -0
- package/dist/navigation-menu.mjs +170 -0
- package/dist/pagination.d.ts +33 -0
- package/dist/pagination.mjs +116 -0
- package/dist/popover.d.ts +13 -0
- package/dist/popover.mjs +44 -0
- package/dist/progress.d.ts +7 -0
- package/dist/progress.mjs +31 -0
- package/dist/radio-group.d.ts +9 -0
- package/dist/radio-group.mjs +45 -0
- package/dist/resizable.d.ts +13 -0
- package/dist/resizable.mjs +48 -0
- package/dist/scroll-area.d.ts +9 -0
- package/dist/scroll-area.mjs +60 -0
- package/dist/select.d.ts +27 -0
- package/dist/select.mjs +169 -0
- package/dist/separator.d.ts +7 -0
- package/dist/separator.mjs +26 -0
- package/dist/sheet.d.ts +23 -0
- package/dist/sheet.mjs +126 -0
- package/dist/skeleton.d.ts +5 -0
- package/dist/skeleton.mjs +15 -0
- package/dist/slider.d.ts +7 -0
- package/dist/slider.mjs +63 -0
- package/dist/sonner.d.ts +6 -0
- package/dist/sonner.mjs +22 -0
- package/dist/switch.d.ts +7 -0
- package/dist/switch.mjs +31 -0
- package/dist/table.d.ts +20 -0
- package/dist/table.mjs +114 -0
- package/dist/tabs.d.ts +13 -0
- package/dist/tabs.mjs +67 -0
- package/dist/textarea.d.ts +6 -0
- package/dist/textarea.mjs +18 -0
- package/dist/toggle-group.d.ts +16 -0
- package/dist/toggle-group.mjs +62 -0
- package/dist/toggle.d.ts +14 -0
- package/dist/toggle.mjs +43 -0
- package/dist/tooltip.d.ts +13 -0
- package/dist/tooltip.mjs +55 -0
- package/dist/utils-B7J70Nno.js +8 -0
- package/eslint.config.mjs +12 -0
- package/package.json +273 -0
- package/postcss.config.js +6 -0
- package/src/components/ui/accordion.tsx +64 -0
- package/src/components/ui/alert-dialog.tsx +155 -0
- package/src/components/ui/alert.tsx +66 -0
- package/src/components/ui/aspect-ratio.tsx +9 -0
- package/src/components/ui/avatar.tsx +51 -0
- package/src/components/ui/badge.tsx +46 -0
- package/src/components/ui/breadcrumb.tsx +109 -0
- package/src/components/ui/button.tsx +59 -0
- package/src/components/ui/calendar.tsx +211 -0
- package/src/components/ui/card.tsx +92 -0
- package/src/components/ui/carousel.tsx +239 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/collapsible.tsx +31 -0
- package/src/components/ui/command.tsx +182 -0
- package/src/components/ui/context-menu.tsx +250 -0
- package/src/components/ui/dialog.tsx +141 -0
- package/src/components/ui/dropdown-menu.tsx +255 -0
- package/src/components/ui/form.tsx +165 -0
- package/src/components/ui/hover-card.tsx +42 -0
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/label.tsx +24 -0
- package/src/components/ui/menubar.tsx +274 -0
- package/src/components/ui/navigation-menu.tsx +168 -0
- package/src/components/ui/pagination.tsx +125 -0
- package/src/components/ui/popover.tsx +46 -0
- package/src/components/ui/progress.tsx +29 -0
- package/src/components/ui/radio-group.tsx +43 -0
- package/src/components/ui/resizable.tsx +54 -0
- package/src/components/ui/scroll-area.tsx +56 -0
- package/src/components/ui/select.tsx +183 -0
- package/src/components/ui/separator.tsx +26 -0
- package/src/components/ui/sheet.tsx +137 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/slider.tsx +61 -0
- package/src/components/ui/sonner.tsx +23 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/table.tsx +114 -0
- package/src/components/ui/tabs.tsx +64 -0
- package/src/components/ui/textarea.tsx +18 -0
- package/src/components/ui/toggle-group.tsx +71 -0
- package/src/components/ui/toggle.tsx +45 -0
- package/src/components/ui/tooltip.tsx +59 -0
- package/src/index.ts +46 -0
- package/src/lib/utils.ts +6 -0
- package/src/style.css +0 -0
- package/tailwind.config.js +52 -0
- package/tsconfig.json +19 -0
- package/tsconfig.lib.json +54 -0
- package/tsconfig.spec.json +32 -0
- package/vite.config.ts +136 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot"
|
|
3
|
+
import { ChevronRight, MoreHorizontal } from "lucide-react"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
function Breadcrumb({ ...props }: React.ComponentProps<"nav">) {
|
|
8
|
+
return <nav aria-label="breadcrumb" data-slot="breadcrumb" {...props} />
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) {
|
|
12
|
+
return (
|
|
13
|
+
<ol
|
|
14
|
+
data-slot="breadcrumb-list"
|
|
15
|
+
className={cn(
|
|
16
|
+
"text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) {
|
|
25
|
+
return (
|
|
26
|
+
<li
|
|
27
|
+
data-slot="breadcrumb-item"
|
|
28
|
+
className={cn("inline-flex items-center gap-1.5", className)}
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function BreadcrumbLink({
|
|
35
|
+
asChild,
|
|
36
|
+
className,
|
|
37
|
+
...props
|
|
38
|
+
}: React.ComponentProps<"a"> & {
|
|
39
|
+
asChild?: boolean
|
|
40
|
+
}) {
|
|
41
|
+
const Comp = asChild ? Slot : "a"
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Comp
|
|
45
|
+
data-slot="breadcrumb-link"
|
|
46
|
+
className={cn("hover:text-foreground transition-colors", className)}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) {
|
|
53
|
+
return (
|
|
54
|
+
<span
|
|
55
|
+
data-slot="breadcrumb-page"
|
|
56
|
+
role="link"
|
|
57
|
+
aria-disabled="true"
|
|
58
|
+
aria-current="page"
|
|
59
|
+
className={cn("text-foreground font-normal", className)}
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function BreadcrumbSeparator({
|
|
66
|
+
children,
|
|
67
|
+
className,
|
|
68
|
+
...props
|
|
69
|
+
}: React.ComponentProps<"li">) {
|
|
70
|
+
return (
|
|
71
|
+
<li
|
|
72
|
+
data-slot="breadcrumb-separator"
|
|
73
|
+
role="presentation"
|
|
74
|
+
aria-hidden="true"
|
|
75
|
+
className={cn("[&>svg]:size-3.5", className)}
|
|
76
|
+
{...props}
|
|
77
|
+
>
|
|
78
|
+
{children ?? <ChevronRight />}
|
|
79
|
+
</li>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function BreadcrumbEllipsis({
|
|
84
|
+
className,
|
|
85
|
+
...props
|
|
86
|
+
}: React.ComponentProps<"span">) {
|
|
87
|
+
return (
|
|
88
|
+
<span
|
|
89
|
+
data-slot="breadcrumb-ellipsis"
|
|
90
|
+
role="presentation"
|
|
91
|
+
aria-hidden="true"
|
|
92
|
+
className={cn("flex size-9 items-center justify-center", className)}
|
|
93
|
+
{...props}
|
|
94
|
+
>
|
|
95
|
+
<MoreHorizontal className="size-4" />
|
|
96
|
+
<span className="sr-only">More</span>
|
|
97
|
+
</span>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
Breadcrumb,
|
|
103
|
+
BreadcrumbList,
|
|
104
|
+
BreadcrumbItem,
|
|
105
|
+
BreadcrumbLink,
|
|
106
|
+
BreadcrumbPage,
|
|
107
|
+
BreadcrumbSeparator,
|
|
108
|
+
BreadcrumbEllipsis,
|
|
109
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot"
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default:
|
|
13
|
+
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
|
14
|
+
destructive:
|
|
15
|
+
"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
16
|
+
outline:
|
|
17
|
+
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
18
|
+
secondary:
|
|
19
|
+
"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
|
20
|
+
ghost:
|
|
21
|
+
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
22
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
23
|
+
},
|
|
24
|
+
size: {
|
|
25
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
26
|
+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
27
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
28
|
+
icon: "size-9",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
variant: "default",
|
|
33
|
+
size: "default",
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
function Button({
|
|
39
|
+
className,
|
|
40
|
+
variant,
|
|
41
|
+
size,
|
|
42
|
+
asChild = false,
|
|
43
|
+
...props
|
|
44
|
+
}: React.ComponentProps<"button"> &
|
|
45
|
+
VariantProps<typeof buttonVariants> & {
|
|
46
|
+
asChild?: boolean
|
|
47
|
+
}) {
|
|
48
|
+
const Comp = asChild ? Slot : "button"
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Comp
|
|
52
|
+
data-slot="button"
|
|
53
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
54
|
+
{...props}
|
|
55
|
+
/>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { Button, buttonVariants }
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import {
|
|
3
|
+
ChevronDownIcon,
|
|
4
|
+
ChevronLeftIcon,
|
|
5
|
+
ChevronRightIcon,
|
|
6
|
+
} from "lucide-react"
|
|
7
|
+
import { DayButton, DayPicker, getDefaultClassNames } from "react-day-picker"
|
|
8
|
+
|
|
9
|
+
import { cn } from "@/lib/utils"
|
|
10
|
+
import { Button, buttonVariants } from "@/components/ui/button"
|
|
11
|
+
|
|
12
|
+
function Calendar({
|
|
13
|
+
className,
|
|
14
|
+
classNames,
|
|
15
|
+
showOutsideDays = true,
|
|
16
|
+
captionLayout = "label",
|
|
17
|
+
buttonVariant = "ghost",
|
|
18
|
+
formatters,
|
|
19
|
+
components,
|
|
20
|
+
...props
|
|
21
|
+
}: React.ComponentProps<typeof DayPicker> & {
|
|
22
|
+
buttonVariant?: React.ComponentProps<typeof Button>["variant"]
|
|
23
|
+
}) {
|
|
24
|
+
const defaultClassNames = getDefaultClassNames()
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<DayPicker
|
|
28
|
+
showOutsideDays={showOutsideDays}
|
|
29
|
+
className={cn(
|
|
30
|
+
"bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
|
|
31
|
+
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
|
32
|
+
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
|
33
|
+
className
|
|
34
|
+
)}
|
|
35
|
+
captionLayout={captionLayout}
|
|
36
|
+
formatters={{
|
|
37
|
+
formatMonthDropdown: (date) =>
|
|
38
|
+
date.toLocaleString("default", { month: "short" }),
|
|
39
|
+
...formatters,
|
|
40
|
+
}}
|
|
41
|
+
classNames={{
|
|
42
|
+
root: cn("w-fit", defaultClassNames.root),
|
|
43
|
+
months: cn(
|
|
44
|
+
"flex gap-4 flex-col md:flex-row relative",
|
|
45
|
+
defaultClassNames.months
|
|
46
|
+
),
|
|
47
|
+
month: cn("flex flex-col w-full gap-4", defaultClassNames.month),
|
|
48
|
+
nav: cn(
|
|
49
|
+
"flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between",
|
|
50
|
+
defaultClassNames.nav
|
|
51
|
+
),
|
|
52
|
+
button_previous: cn(
|
|
53
|
+
buttonVariants({ variant: buttonVariant }),
|
|
54
|
+
"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
|
|
55
|
+
defaultClassNames.button_previous
|
|
56
|
+
),
|
|
57
|
+
button_next: cn(
|
|
58
|
+
buttonVariants({ variant: buttonVariant }),
|
|
59
|
+
"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
|
|
60
|
+
defaultClassNames.button_next
|
|
61
|
+
),
|
|
62
|
+
month_caption: cn(
|
|
63
|
+
"flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",
|
|
64
|
+
defaultClassNames.month_caption
|
|
65
|
+
),
|
|
66
|
+
dropdowns: cn(
|
|
67
|
+
"w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",
|
|
68
|
+
defaultClassNames.dropdowns
|
|
69
|
+
),
|
|
70
|
+
dropdown_root: cn(
|
|
71
|
+
"relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",
|
|
72
|
+
defaultClassNames.dropdown_root
|
|
73
|
+
),
|
|
74
|
+
dropdown: cn(
|
|
75
|
+
"absolute bg-popover inset-0 opacity-0",
|
|
76
|
+
defaultClassNames.dropdown
|
|
77
|
+
),
|
|
78
|
+
caption_label: cn(
|
|
79
|
+
"select-none font-medium",
|
|
80
|
+
captionLayout === "label"
|
|
81
|
+
? "text-sm"
|
|
82
|
+
: "rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5",
|
|
83
|
+
defaultClassNames.caption_label
|
|
84
|
+
),
|
|
85
|
+
table: "w-full border-collapse",
|
|
86
|
+
weekdays: cn("flex", defaultClassNames.weekdays),
|
|
87
|
+
weekday: cn(
|
|
88
|
+
"text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none",
|
|
89
|
+
defaultClassNames.weekday
|
|
90
|
+
),
|
|
91
|
+
week: cn("flex w-full mt-2", defaultClassNames.week),
|
|
92
|
+
week_number_header: cn(
|
|
93
|
+
"select-none w-(--cell-size)",
|
|
94
|
+
defaultClassNames.week_number_header
|
|
95
|
+
),
|
|
96
|
+
week_number: cn(
|
|
97
|
+
"text-[0.8rem] select-none text-muted-foreground",
|
|
98
|
+
defaultClassNames.week_number
|
|
99
|
+
),
|
|
100
|
+
day: cn(
|
|
101
|
+
"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",
|
|
102
|
+
defaultClassNames.day
|
|
103
|
+
),
|
|
104
|
+
range_start: cn(
|
|
105
|
+
"rounded-l-md bg-accent",
|
|
106
|
+
defaultClassNames.range_start
|
|
107
|
+
),
|
|
108
|
+
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
|
109
|
+
range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end),
|
|
110
|
+
today: cn(
|
|
111
|
+
"bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",
|
|
112
|
+
defaultClassNames.today
|
|
113
|
+
),
|
|
114
|
+
outside: cn(
|
|
115
|
+
"text-muted-foreground aria-selected:text-muted-foreground",
|
|
116
|
+
defaultClassNames.outside
|
|
117
|
+
),
|
|
118
|
+
disabled: cn(
|
|
119
|
+
"text-muted-foreground opacity-50",
|
|
120
|
+
defaultClassNames.disabled
|
|
121
|
+
),
|
|
122
|
+
hidden: cn("invisible", defaultClassNames.hidden),
|
|
123
|
+
...classNames,
|
|
124
|
+
}}
|
|
125
|
+
components={{
|
|
126
|
+
Root: ({ className, rootRef, ...props }) => {
|
|
127
|
+
return (
|
|
128
|
+
<div
|
|
129
|
+
data-slot="calendar"
|
|
130
|
+
ref={rootRef}
|
|
131
|
+
className={cn(className)}
|
|
132
|
+
{...props}
|
|
133
|
+
/>
|
|
134
|
+
)
|
|
135
|
+
},
|
|
136
|
+
Chevron: ({ className, orientation, ...props }) => {
|
|
137
|
+
if (orientation === "left") {
|
|
138
|
+
return (
|
|
139
|
+
<ChevronLeftIcon className={cn("size-4", className)} {...props} />
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (orientation === "right") {
|
|
144
|
+
return (
|
|
145
|
+
<ChevronRightIcon
|
|
146
|
+
className={cn("size-4", className)}
|
|
147
|
+
{...props}
|
|
148
|
+
/>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<ChevronDownIcon className={cn("size-4", className)} {...props} />
|
|
154
|
+
)
|
|
155
|
+
},
|
|
156
|
+
DayButton: CalendarDayButton,
|
|
157
|
+
WeekNumber: ({ children, ...props }) => {
|
|
158
|
+
return (
|
|
159
|
+
<td {...props}>
|
|
160
|
+
<div className="flex size-(--cell-size) items-center justify-center text-center">
|
|
161
|
+
{children}
|
|
162
|
+
</div>
|
|
163
|
+
</td>
|
|
164
|
+
)
|
|
165
|
+
},
|
|
166
|
+
...components,
|
|
167
|
+
}}
|
|
168
|
+
{...props}
|
|
169
|
+
/>
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function CalendarDayButton({
|
|
174
|
+
className,
|
|
175
|
+
day,
|
|
176
|
+
modifiers,
|
|
177
|
+
...props
|
|
178
|
+
}: React.ComponentProps<typeof DayButton>) {
|
|
179
|
+
const defaultClassNames = getDefaultClassNames()
|
|
180
|
+
|
|
181
|
+
const ref = React.useRef<HTMLButtonElement>(null)
|
|
182
|
+
React.useEffect(() => {
|
|
183
|
+
if (modifiers.focused) ref.current?.focus()
|
|
184
|
+
}, [modifiers.focused])
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<Button
|
|
188
|
+
ref={ref}
|
|
189
|
+
variant="ghost"
|
|
190
|
+
size="icon"
|
|
191
|
+
data-day={day.date.toLocaleDateString()}
|
|
192
|
+
data-selected-single={
|
|
193
|
+
modifiers.selected &&
|
|
194
|
+
!modifiers.range_start &&
|
|
195
|
+
!modifiers.range_end &&
|
|
196
|
+
!modifiers.range_middle
|
|
197
|
+
}
|
|
198
|
+
data-range-start={modifiers.range_start}
|
|
199
|
+
data-range-end={modifiers.range_end}
|
|
200
|
+
data-range-middle={modifiers.range_middle}
|
|
201
|
+
className={cn(
|
|
202
|
+
"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",
|
|
203
|
+
defaultClassNames.day,
|
|
204
|
+
className
|
|
205
|
+
)}
|
|
206
|
+
{...props}
|
|
207
|
+
/>
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
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-1.5 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,239 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import useEmblaCarousel, {
|
|
3
|
+
type UseEmblaCarouselType,
|
|
4
|
+
} from "embla-carousel-react"
|
|
5
|
+
import { ArrowLeft, ArrowRight } from "lucide-react"
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils"
|
|
8
|
+
import { Button } from "@/components/ui/button"
|
|
9
|
+
|
|
10
|
+
type CarouselApi = UseEmblaCarouselType[1]
|
|
11
|
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
|
|
12
|
+
type CarouselOptions = UseCarouselParameters[0]
|
|
13
|
+
type CarouselPlugin = UseCarouselParameters[1]
|
|
14
|
+
|
|
15
|
+
type CarouselProps = {
|
|
16
|
+
opts?: CarouselOptions
|
|
17
|
+
plugins?: CarouselPlugin
|
|
18
|
+
orientation?: "horizontal" | "vertical"
|
|
19
|
+
setApi?: (api: CarouselApi) => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type CarouselContextProps = {
|
|
23
|
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0]
|
|
24
|
+
api: ReturnType<typeof useEmblaCarousel>[1]
|
|
25
|
+
scrollPrev: () => void
|
|
26
|
+
scrollNext: () => void
|
|
27
|
+
canScrollPrev: boolean
|
|
28
|
+
canScrollNext: boolean
|
|
29
|
+
} & CarouselProps
|
|
30
|
+
|
|
31
|
+
const CarouselContext = React.createContext<CarouselContextProps | null>(null)
|
|
32
|
+
|
|
33
|
+
function useCarousel() {
|
|
34
|
+
const context = React.useContext(CarouselContext)
|
|
35
|
+
|
|
36
|
+
if (!context) {
|
|
37
|
+
throw new Error("useCarousel must be used within a <Carousel />")
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return context
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function Carousel({
|
|
44
|
+
orientation = "horizontal",
|
|
45
|
+
opts,
|
|
46
|
+
setApi,
|
|
47
|
+
plugins,
|
|
48
|
+
className,
|
|
49
|
+
children,
|
|
50
|
+
...props
|
|
51
|
+
}: React.ComponentProps<"div"> & CarouselProps) {
|
|
52
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
53
|
+
{
|
|
54
|
+
...opts,
|
|
55
|
+
axis: orientation === "horizontal" ? "x" : "y",
|
|
56
|
+
},
|
|
57
|
+
plugins
|
|
58
|
+
)
|
|
59
|
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false)
|
|
60
|
+
const [canScrollNext, setCanScrollNext] = React.useState(false)
|
|
61
|
+
|
|
62
|
+
const onSelect = React.useCallback((api: CarouselApi) => {
|
|
63
|
+
if (!api) return
|
|
64
|
+
setCanScrollPrev(api.canScrollPrev())
|
|
65
|
+
setCanScrollNext(api.canScrollNext())
|
|
66
|
+
}, [])
|
|
67
|
+
|
|
68
|
+
const scrollPrev = React.useCallback(() => {
|
|
69
|
+
api?.scrollPrev()
|
|
70
|
+
}, [api])
|
|
71
|
+
|
|
72
|
+
const scrollNext = React.useCallback(() => {
|
|
73
|
+
api?.scrollNext()
|
|
74
|
+
}, [api])
|
|
75
|
+
|
|
76
|
+
const handleKeyDown = React.useCallback(
|
|
77
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
78
|
+
if (event.key === "ArrowLeft") {
|
|
79
|
+
event.preventDefault()
|
|
80
|
+
scrollPrev()
|
|
81
|
+
} else if (event.key === "ArrowRight") {
|
|
82
|
+
event.preventDefault()
|
|
83
|
+
scrollNext()
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
[scrollPrev, scrollNext]
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
React.useEffect(() => {
|
|
90
|
+
if (!api || !setApi) return
|
|
91
|
+
setApi(api)
|
|
92
|
+
}, [api, setApi])
|
|
93
|
+
|
|
94
|
+
React.useEffect(() => {
|
|
95
|
+
if (!api) return
|
|
96
|
+
onSelect(api)
|
|
97
|
+
api.on("reInit", onSelect)
|
|
98
|
+
api.on("select", onSelect)
|
|
99
|
+
|
|
100
|
+
return () => {
|
|
101
|
+
api?.off("select", onSelect)
|
|
102
|
+
}
|
|
103
|
+
}, [api, onSelect])
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<CarouselContext.Provider
|
|
107
|
+
value={{
|
|
108
|
+
carouselRef,
|
|
109
|
+
api: api,
|
|
110
|
+
opts,
|
|
111
|
+
orientation:
|
|
112
|
+
orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
113
|
+
scrollPrev,
|
|
114
|
+
scrollNext,
|
|
115
|
+
canScrollPrev,
|
|
116
|
+
canScrollNext,
|
|
117
|
+
}}
|
|
118
|
+
>
|
|
119
|
+
<div
|
|
120
|
+
onKeyDownCapture={handleKeyDown}
|
|
121
|
+
className={cn("relative", className)}
|
|
122
|
+
role="region"
|
|
123
|
+
aria-roledescription="carousel"
|
|
124
|
+
data-slot="carousel"
|
|
125
|
+
{...props}
|
|
126
|
+
>
|
|
127
|
+
{children}
|
|
128
|
+
</div>
|
|
129
|
+
</CarouselContext.Provider>
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
134
|
+
const { carouselRef, orientation } = useCarousel()
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<div
|
|
138
|
+
ref={carouselRef}
|
|
139
|
+
className="overflow-hidden"
|
|
140
|
+
data-slot="carousel-content"
|
|
141
|
+
>
|
|
142
|
+
<div
|
|
143
|
+
className={cn(
|
|
144
|
+
"flex",
|
|
145
|
+
orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
|
|
146
|
+
className
|
|
147
|
+
)}
|
|
148
|
+
{...props}
|
|
149
|
+
/>
|
|
150
|
+
</div>
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
|
|
155
|
+
const { orientation } = useCarousel()
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<div
|
|
159
|
+
role="group"
|
|
160
|
+
aria-roledescription="slide"
|
|
161
|
+
data-slot="carousel-item"
|
|
162
|
+
className={cn(
|
|
163
|
+
"min-w-0 shrink-0 grow-0 basis-full",
|
|
164
|
+
orientation === "horizontal" ? "pl-4" : "pt-4",
|
|
165
|
+
className
|
|
166
|
+
)}
|
|
167
|
+
{...props}
|
|
168
|
+
/>
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function CarouselPrevious({
|
|
173
|
+
className,
|
|
174
|
+
variant = "outline",
|
|
175
|
+
size = "icon",
|
|
176
|
+
...props
|
|
177
|
+
}: React.ComponentProps<typeof Button>) {
|
|
178
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel()
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<Button
|
|
182
|
+
data-slot="carousel-previous"
|
|
183
|
+
variant={variant}
|
|
184
|
+
size={size}
|
|
185
|
+
className={cn(
|
|
186
|
+
"absolute size-8 rounded-full",
|
|
187
|
+
orientation === "horizontal"
|
|
188
|
+
? "top-1/2 -left-12 -translate-y-1/2"
|
|
189
|
+
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
190
|
+
className
|
|
191
|
+
)}
|
|
192
|
+
disabled={!canScrollPrev}
|
|
193
|
+
onClick={scrollPrev}
|
|
194
|
+
{...props}
|
|
195
|
+
>
|
|
196
|
+
<ArrowLeft />
|
|
197
|
+
<span className="sr-only">Previous slide</span>
|
|
198
|
+
</Button>
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function CarouselNext({
|
|
203
|
+
className,
|
|
204
|
+
variant = "outline",
|
|
205
|
+
size = "icon",
|
|
206
|
+
...props
|
|
207
|
+
}: React.ComponentProps<typeof Button>) {
|
|
208
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel()
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<Button
|
|
212
|
+
data-slot="carousel-next"
|
|
213
|
+
variant={variant}
|
|
214
|
+
size={size}
|
|
215
|
+
className={cn(
|
|
216
|
+
"absolute size-8 rounded-full",
|
|
217
|
+
orientation === "horizontal"
|
|
218
|
+
? "top-1/2 -right-12 -translate-y-1/2"
|
|
219
|
+
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
220
|
+
className
|
|
221
|
+
)}
|
|
222
|
+
disabled={!canScrollNext}
|
|
223
|
+
onClick={scrollNext}
|
|
224
|
+
{...props}
|
|
225
|
+
>
|
|
226
|
+
<ArrowRight />
|
|
227
|
+
<span className="sr-only">Next slide</span>
|
|
228
|
+
</Button>
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export {
|
|
233
|
+
type CarouselApi,
|
|
234
|
+
Carousel,
|
|
235
|
+
CarouselContent,
|
|
236
|
+
CarouselItem,
|
|
237
|
+
CarouselPrevious,
|
|
238
|
+
CarouselNext,
|
|
239
|
+
}
|