@aereamart/design-system 0.3.6 → 0.4.2
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/dist/cn.d.ts +2 -1
- package/dist/cn.js +4 -2
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-mobile.js +15 -0
- package/dist/index.d.ts +48 -37
- package/dist/index.js +48 -37
- package/dist/ui/accordion.d.ts +7 -0
- package/dist/ui/accordion.js +17 -0
- package/dist/ui/alert-dialog.d.ts +18 -0
- package/dist/ui/alert-dialog.js +42 -0
- package/dist/ui/alert.d.ts +9 -0
- package/dist/ui/alert.js +24 -0
- package/dist/ui/aspect-ratio.d.ts +3 -0
- package/dist/ui/aspect-ratio.js +6 -0
- package/dist/ui/avatar.d.ts +11 -0
- package/dist/ui/avatar.js +23 -0
- package/dist/ui/badge.d.ts +9 -0
- package/dist/ui/badge.js +24 -0
- package/dist/ui/breadcrumb.d.ts +11 -0
- package/dist/ui/breadcrumb.js +27 -0
- package/dist/ui/button.d.ts +10 -0
- package/dist/ui/button.js +35 -0
- package/dist/ui/calendar.d.ts +8 -0
- package/dist/ui/calendar.js +75 -0
- package/dist/ui/card.d.ts +9 -0
- package/dist/ui/card.js +24 -0
- package/dist/ui/carousel.d.ts +19 -0
- package/dist/ui/carousel.js +91 -0
- package/dist/ui/chart.d.ts +44 -0
- package/dist/ui/chart.js +132 -0
- package/dist/ui/checkbox.d.ts +4 -0
- package/dist/ui/checkbox.js +8 -0
- package/dist/ui/collapsible.d.ts +5 -0
- package/dist/ui/collapsible.js +13 -0
- package/dist/ui/command.d.ts +18 -0
- package/dist/ui/command.js +34 -0
- package/dist/ui/context-menu.d.ts +25 -0
- package/dist/ui/context-menu.js +51 -0
- package/dist/ui/dialog.d.ts +17 -0
- package/dist/ui/dialog.js +36 -0
- package/dist/ui/drawer.d.ts +13 -0
- package/dist/ui/drawer.js +35 -0
- package/dist/ui/dropdown-menu.d.ts +25 -0
- package/dist/ui/dropdown-menu.js +50 -0
- package/dist/ui/form.d.ts +24 -0
- package/dist/ui/form.js +58 -0
- package/dist/ui/hover-card.d.ts +6 -0
- package/dist/ui/hover-card.js +13 -0
- package/dist/ui/input-otp.d.ts +11 -0
- package/dist/ui/input-otp.js +21 -0
- package/dist/ui/input.d.ts +3 -0
- package/dist/ui/input.js +6 -0
- package/dist/ui/label.d.ts +4 -0
- package/dist/ui/label.js +8 -0
- package/dist/ui/menubar.d.ts +26 -0
- package/dist/ui/menubar.js +53 -0
- package/dist/ui/navigation-menu.d.ts +14 -0
- package/dist/ui/navigation-menu.js +31 -0
- package/dist/ui/pagination.d.ts +13 -0
- package/dist/ui/pagination.js +29 -0
- package/dist/ui/popover.d.ts +10 -0
- package/dist/ui/popover.js +26 -0
- package/dist/ui/progress.d.ts +4 -0
- package/dist/ui/progress.js +7 -0
- package/dist/ui/radio-group.d.ts +5 -0
- package/dist/ui/radio-group.js +12 -0
- package/dist/ui/resizable.d.ts +7 -0
- package/dist/ui/resizable.js +14 -0
- package/dist/ui/scroll-area.d.ts +5 -0
- package/dist/ui/scroll-area.js +12 -0
- package/dist/ui/select.d.ts +15 -0
- package/dist/ui/select.js +38 -0
- package/dist/ui/separator.d.ts +4 -0
- package/dist/ui/separator.js +7 -0
- package/dist/ui/sheet.d.ts +14 -0
- package/dist/ui/sheet.js +40 -0
- package/dist/ui/sidebar.d.ts +69 -0
- package/dist/ui/sidebar.js +211 -0
- package/dist/ui/skeleton.d.ts +2 -0
- package/dist/ui/skeleton.js +6 -0
- package/dist/ui/slider.d.ts +4 -0
- package/dist/ui/slider.js +13 -0
- package/dist/ui/sonner.d.ts +3 -0
- package/dist/ui/sonner.js +21 -0
- package/dist/ui/switch.d.ts +6 -0
- package/dist/ui/switch.js +7 -0
- package/dist/ui/table.d.ts +10 -0
- package/dist/ui/table.js +28 -0
- package/dist/ui/tabs.d.ts +11 -0
- package/dist/ui/tabs.js +28 -0
- package/dist/ui/textarea.d.ts +3 -0
- package/dist/ui/textarea.js +6 -0
- package/dist/ui/toggle-group.d.ts +9 -0
- package/dist/ui/toggle-group.js +22 -0
- package/dist/ui/toggle.d.ts +9 -0
- package/dist/ui/toggle.js +26 -0
- package/dist/ui/tooltip.d.ts +7 -0
- package/dist/ui/tooltip.js +16 -0
- package/package.json +28 -4
- package/src/cn.ts +5 -2
- package/src/hooks/use-mobile.ts +19 -0
- package/src/index.css +158 -0
- package/src/index.ts +48 -37
- package/src/ui/accordion.tsx +63 -0
- package/src/ui/alert-dialog.tsx +196 -0
- package/src/ui/alert.tsx +65 -0
- package/src/ui/aspect-ratio.tsx +9 -0
- package/src/ui/avatar.tsx +108 -0
- package/src/ui/badge.tsx +47 -0
- package/src/ui/breadcrumb.tsx +108 -0
- package/src/ui/button.tsx +63 -0
- package/src/ui/calendar.tsx +218 -0
- package/src/ui/card.tsx +91 -0
- package/src/ui/carousel.tsx +241 -0
- package/src/ui/chart.tsx +371 -0
- package/src/ui/checkbox.tsx +29 -0
- package/src/ui/collapsible.tsx +33 -0
- package/src/ui/command.tsx +184 -0
- package/src/ui/context-menu.tsx +251 -0
- package/src/ui/dialog.tsx +156 -0
- package/src/ui/drawer.tsx +134 -0
- package/src/ui/dropdown-menu.tsx +254 -0
- package/src/ui/form.tsx +165 -0
- package/src/ui/hover-card.tsx +41 -0
- package/src/ui/input-otp.tsx +76 -0
- package/src/ui/input.tsx +20 -0
- package/src/ui/label.tsx +23 -0
- package/src/ui/menubar.tsx +273 -0
- package/src/ui/navigation-menu.tsx +167 -0
- package/src/ui/pagination.tsx +127 -0
- package/src/ui/popover.tsx +88 -0
- package/src/ui/progress.tsx +28 -0
- package/src/ui/radio-group.tsx +44 -0
- package/src/ui/resizable.tsx +50 -0
- package/src/ui/scroll-area.tsx +55 -0
- package/src/ui/select.tsx +189 -0
- package/src/ui/separator.tsx +25 -0
- package/src/ui/sheet.tsx +142 -0
- package/src/ui/sidebar.tsx +724 -0
- package/src/ui/skeleton.tsx +13 -0
- package/src/ui/slider.tsx +60 -0
- package/src/ui/sonner.tsx +40 -0
- package/src/ui/switch.tsx +32 -0
- package/src/ui/table.tsx +115 -0
- package/src/ui/tabs.tsx +88 -0
- package/src/ui/textarea.tsx +17 -0
- package/src/ui/toggle-group.tsx +83 -0
- package/src/ui/toggle.tsx +46 -0
- package/src/ui/tooltip.tsx +54 -0
- package/dist/Accordion.d.ts +0 -10
- package/dist/Accordion.js +0 -12
- package/dist/AlertBanner.d.ts +0 -9
- package/dist/AlertBanner.js +0 -21
- package/dist/AppBar.d.ts +0 -7
- package/dist/AppBar.js +0 -5
- package/dist/Avatar.d.ts +0 -6
- package/dist/Avatar.js +0 -20
- package/dist/Badge.d.ts +0 -6
- package/dist/Badge.js +0 -11
- package/dist/BottomSheet.d.ts +0 -8
- package/dist/BottomSheet.js +0 -24
- package/dist/Breadcrumb.d.ts +0 -8
- package/dist/Breadcrumb.js +0 -9
- package/dist/Button.d.ts +0 -9
- package/dist/Button.js +0 -18
- package/dist/Card.d.ts +0 -7
- package/dist/Card.js +0 -6
- package/dist/Checkbox.d.ts +0 -5
- package/dist/Checkbox.js +0 -5
- package/dist/Chip.d.ts +0 -7
- package/dist/Chip.js +0 -15
- package/dist/DataTable.d.ts +0 -15
- package/dist/DataTable.js +0 -7
- package/dist/DatePicker.d.ts +0 -5
- package/dist/DatePicker.js +0 -11
- package/dist/Divider.d.ts +0 -5
- package/dist/Divider.js +0 -11
- package/dist/Drawer.d.ts +0 -10
- package/dist/Drawer.js +0 -24
- package/dist/EmptyState.d.ts +0 -7
- package/dist/EmptyState.js +0 -6
- package/dist/Input.d.ts +0 -5
- package/dist/Input.js +0 -7
- package/dist/Link.d.ts +0 -4
- package/dist/Link.js +0 -6
- package/dist/Menu.d.ts +0 -14
- package/dist/Menu.js +0 -29
- package/dist/Modal.d.ts +0 -9
- package/dist/Modal.js +0 -24
- package/dist/NavigationBar.d.ts +0 -14
- package/dist/NavigationBar.js +0 -22
- package/dist/Pagination.d.ts +0 -7
- package/dist/Pagination.js +0 -24
- package/dist/Popover.d.ts +0 -7
- package/dist/Popover.js +0 -9
- package/dist/Progress.d.ts +0 -8
- package/dist/Progress.js +0 -15
- package/dist/Radio.d.ts +0 -15
- package/dist/Radio.js +0 -8
- package/dist/SegmentedControl.d.ts +0 -13
- package/dist/SegmentedControl.js +0 -18
- package/dist/Select.d.ts +0 -5
- package/dist/Select.js +0 -7
- package/dist/Sidebar.d.ts +0 -16
- package/dist/Sidebar.js +0 -19
- package/dist/Slider.d.ts +0 -5
- package/dist/Slider.js +0 -5
- package/dist/Snackbar.d.ts +0 -12
- package/dist/Snackbar.js +0 -20
- package/dist/Spinner.d.ts +0 -3
- package/dist/Spinner.js +0 -5
- package/dist/Switch.d.ts +0 -4
- package/dist/Switch.js +0 -5
- package/dist/Tabs.d.ts +0 -14
- package/dist/Tabs.js +0 -24
- package/dist/Tag.d.ts +0 -6
- package/dist/Tag.js +0 -11
- package/dist/Textarea.d.ts +0 -5
- package/dist/Textarea.js +0 -7
- package/dist/Tooltip.d.ts +0 -7
- package/dist/Tooltip.js +0 -5
- package/dist/TreeView.d.ts +0 -12
- package/dist/TreeView.js +0 -34
- package/src/Accordion.tsx +0 -58
- package/src/AlertBanner.tsx +0 -62
- package/src/AppBar.tsx +0 -29
- package/src/Avatar.tsx +0 -42
- package/src/Badge.tsx +0 -27
- package/src/BottomSheet.tsx +0 -60
- package/src/Breadcrumb.tsx +0 -48
- package/src/Button.tsx +0 -54
- package/src/Card.tsx +0 -39
- package/src/Checkbox.tsx +0 -31
- package/src/Chip.tsx +0 -44
- package/src/DataTable.tsx +0 -64
- package/src/DatePicker.tsx +0 -44
- package/src/Divider.tsx +0 -33
- package/src/Drawer.tsx +0 -71
- package/src/EmptyState.tsx +0 -37
- package/src/Input.tsx +0 -30
- package/src/Link.tsx +0 -22
- package/src/Menu.tsx +0 -73
- package/src/Modal.tsx +0 -62
- package/src/NavigationBar.tsx +0 -68
- package/src/Pagination.tsx +0 -69
- package/src/Popover.tsx +0 -34
- package/src/Progress.tsx +0 -53
- package/src/Radio.tsx +0 -49
- package/src/SegmentedControl.tsx +0 -63
- package/src/Select.tsx +0 -32
- package/src/Sidebar.tsx +0 -73
- package/src/Slider.tsx +0 -33
- package/src/Snackbar.tsx +0 -72
- package/src/Spinner.tsx +0 -19
- package/src/Switch.tsx +0 -40
- package/src/Tabs.tsx +0 -77
- package/src/Tag.tsx +0 -29
- package/src/Textarea.tsx +0 -30
- package/src/Tooltip.tsx +0 -25
- package/src/TreeView.tsx +0 -105
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cn } from "../cn"
|
|
3
|
+
import {
|
|
4
|
+
ChevronDownIcon,
|
|
5
|
+
ChevronLeftIcon,
|
|
6
|
+
ChevronRightIcon,
|
|
7
|
+
} from "lucide-react"
|
|
8
|
+
import {
|
|
9
|
+
DayPicker,
|
|
10
|
+
getDefaultClassNames,
|
|
11
|
+
type DayButton,
|
|
12
|
+
} from "react-day-picker"
|
|
13
|
+
|
|
14
|
+
import { Button, buttonVariants } from "./button"
|
|
15
|
+
|
|
16
|
+
function Calendar({
|
|
17
|
+
className,
|
|
18
|
+
classNames,
|
|
19
|
+
showOutsideDays = true,
|
|
20
|
+
captionLayout = "label",
|
|
21
|
+
buttonVariant = "ghost",
|
|
22
|
+
formatters,
|
|
23
|
+
components,
|
|
24
|
+
...props
|
|
25
|
+
}: React.ComponentProps<typeof DayPicker> & {
|
|
26
|
+
buttonVariant?: React.ComponentProps<typeof Button>["variant"]
|
|
27
|
+
}) {
|
|
28
|
+
const defaultClassNames = getDefaultClassNames()
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<DayPicker
|
|
32
|
+
showOutsideDays={showOutsideDays}
|
|
33
|
+
className={cn(
|
|
34
|
+
"group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
|
|
35
|
+
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
|
36
|
+
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
|
37
|
+
className
|
|
38
|
+
)}
|
|
39
|
+
captionLayout={captionLayout}
|
|
40
|
+
formatters={{
|
|
41
|
+
formatMonthDropdown: (date) =>
|
|
42
|
+
date.toLocaleString("default", { month: "short" }),
|
|
43
|
+
...formatters,
|
|
44
|
+
}}
|
|
45
|
+
classNames={{
|
|
46
|
+
root: cn("w-fit", defaultClassNames.root),
|
|
47
|
+
months: cn(
|
|
48
|
+
"relative flex flex-col gap-4 md:flex-row",
|
|
49
|
+
defaultClassNames.months
|
|
50
|
+
),
|
|
51
|
+
month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
|
|
52
|
+
nav: cn(
|
|
53
|
+
"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
|
|
54
|
+
defaultClassNames.nav
|
|
55
|
+
),
|
|
56
|
+
button_previous: cn(
|
|
57
|
+
buttonVariants({ variant: buttonVariant }),
|
|
58
|
+
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
|
59
|
+
defaultClassNames.button_previous
|
|
60
|
+
),
|
|
61
|
+
button_next: cn(
|
|
62
|
+
buttonVariants({ variant: buttonVariant }),
|
|
63
|
+
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
|
64
|
+
defaultClassNames.button_next
|
|
65
|
+
),
|
|
66
|
+
month_caption: cn(
|
|
67
|
+
"flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
|
|
68
|
+
defaultClassNames.month_caption
|
|
69
|
+
),
|
|
70
|
+
dropdowns: cn(
|
|
71
|
+
"flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
|
|
72
|
+
defaultClassNames.dropdowns
|
|
73
|
+
),
|
|
74
|
+
dropdown_root: cn(
|
|
75
|
+
"relative rounded-md border border-input shadow-xs has-focus:border-ring has-focus:ring-[3px] has-focus:ring-ring/50",
|
|
76
|
+
defaultClassNames.dropdown_root
|
|
77
|
+
),
|
|
78
|
+
dropdown: cn(
|
|
79
|
+
"absolute inset-0 bg-popover opacity-0",
|
|
80
|
+
defaultClassNames.dropdown
|
|
81
|
+
),
|
|
82
|
+
caption_label: cn(
|
|
83
|
+
"font-medium select-none",
|
|
84
|
+
captionLayout === "label"
|
|
85
|
+
? "text-sm"
|
|
86
|
+
: "flex h-8 items-center gap-1 rounded-md pr-1 pl-2 text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
|
|
87
|
+
defaultClassNames.caption_label
|
|
88
|
+
),
|
|
89
|
+
month_grid: cn("w-full border-collapse", defaultClassNames.month_grid),
|
|
90
|
+
weekdays: cn("flex", defaultClassNames.weekdays),
|
|
91
|
+
weekday: cn(
|
|
92
|
+
"flex-1 rounded-md text-[0.8rem] font-normal text-muted-foreground select-none",
|
|
93
|
+
defaultClassNames.weekday
|
|
94
|
+
),
|
|
95
|
+
week: cn("mt-2 flex w-full", defaultClassNames.week),
|
|
96
|
+
week_number_header: cn(
|
|
97
|
+
"w-(--cell-size) select-none",
|
|
98
|
+
defaultClassNames.week_number_header
|
|
99
|
+
),
|
|
100
|
+
week_number: cn(
|
|
101
|
+
"text-[0.8rem] text-muted-foreground select-none",
|
|
102
|
+
defaultClassNames.week_number
|
|
103
|
+
),
|
|
104
|
+
day: cn(
|
|
105
|
+
"group/day relative aspect-square h-full w-full p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-md",
|
|
106
|
+
props.showWeekNumber
|
|
107
|
+
? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-md"
|
|
108
|
+
: "[&:first-child[data-selected=true]_button]:rounded-l-md",
|
|
109
|
+
defaultClassNames.day
|
|
110
|
+
),
|
|
111
|
+
range_start: cn(
|
|
112
|
+
"rounded-l-md bg-accent",
|
|
113
|
+
defaultClassNames.range_start
|
|
114
|
+
),
|
|
115
|
+
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
|
116
|
+
range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end),
|
|
117
|
+
today: cn(
|
|
118
|
+
"rounded-md bg-accent text-accent-foreground data-[selected=true]:rounded-none",
|
|
119
|
+
defaultClassNames.today
|
|
120
|
+
),
|
|
121
|
+
outside: cn(
|
|
122
|
+
"text-muted-foreground aria-selected:text-muted-foreground",
|
|
123
|
+
defaultClassNames.outside
|
|
124
|
+
),
|
|
125
|
+
disabled: cn(
|
|
126
|
+
"text-muted-foreground opacity-50",
|
|
127
|
+
defaultClassNames.disabled
|
|
128
|
+
),
|
|
129
|
+
hidden: cn("invisible", defaultClassNames.hidden),
|
|
130
|
+
...classNames,
|
|
131
|
+
}}
|
|
132
|
+
components={{
|
|
133
|
+
Root: ({ className, rootRef, ...props }) => {
|
|
134
|
+
return (
|
|
135
|
+
<div
|
|
136
|
+
data-slot="calendar"
|
|
137
|
+
ref={rootRef}
|
|
138
|
+
className={cn(className)}
|
|
139
|
+
{...props}
|
|
140
|
+
/>
|
|
141
|
+
)
|
|
142
|
+
},
|
|
143
|
+
Chevron: ({ className, orientation, ...props }) => {
|
|
144
|
+
if (orientation === "left") {
|
|
145
|
+
return (
|
|
146
|
+
<ChevronLeftIcon className={cn("size-4", className)} {...props} />
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (orientation === "right") {
|
|
151
|
+
return (
|
|
152
|
+
<ChevronRightIcon
|
|
153
|
+
className={cn("size-4", className)}
|
|
154
|
+
{...props}
|
|
155
|
+
/>
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<ChevronDownIcon className={cn("size-4", className)} {...props} />
|
|
161
|
+
)
|
|
162
|
+
},
|
|
163
|
+
DayButton: CalendarDayButton,
|
|
164
|
+
WeekNumber: ({ children, ...props }) => {
|
|
165
|
+
return (
|
|
166
|
+
<td {...props}>
|
|
167
|
+
<div className="flex size-(--cell-size) items-center justify-center text-center">
|
|
168
|
+
{children}
|
|
169
|
+
</div>
|
|
170
|
+
</td>
|
|
171
|
+
)
|
|
172
|
+
},
|
|
173
|
+
...components,
|
|
174
|
+
}}
|
|
175
|
+
{...props}
|
|
176
|
+
/>
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function CalendarDayButton({
|
|
181
|
+
className,
|
|
182
|
+
day,
|
|
183
|
+
modifiers,
|
|
184
|
+
...props
|
|
185
|
+
}: React.ComponentProps<typeof DayButton>) {
|
|
186
|
+
const defaultClassNames = getDefaultClassNames()
|
|
187
|
+
|
|
188
|
+
const ref = React.useRef<HTMLButtonElement>(null)
|
|
189
|
+
React.useEffect(() => {
|
|
190
|
+
if (modifiers.focused) ref.current?.focus()
|
|
191
|
+
}, [modifiers.focused])
|
|
192
|
+
|
|
193
|
+
return (
|
|
194
|
+
<Button
|
|
195
|
+
ref={ref}
|
|
196
|
+
variant="ghost"
|
|
197
|
+
size="icon"
|
|
198
|
+
data-day={day.date.toLocaleDateString()}
|
|
199
|
+
data-selected-single={
|
|
200
|
+
modifiers.selected &&
|
|
201
|
+
!modifiers.range_start &&
|
|
202
|
+
!modifiers.range_end &&
|
|
203
|
+
!modifiers.range_middle
|
|
204
|
+
}
|
|
205
|
+
data-range-start={modifiers.range_start}
|
|
206
|
+
data-range-end={modifiers.range_end}
|
|
207
|
+
data-range-middle={modifiers.range_middle}
|
|
208
|
+
className={cn(
|
|
209
|
+
"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:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-accent-foreground [&>span]:text-xs [&>span]:opacity-70",
|
|
210
|
+
defaultClassNames.day,
|
|
211
|
+
className
|
|
212
|
+
)}
|
|
213
|
+
{...props}
|
|
214
|
+
/>
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export { Calendar, CalendarDayButton }
|
package/src/ui/card.tsx
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cn } from "../cn"
|
|
3
|
+
|
|
4
|
+
function Card({ className, ...props }: React.ComponentProps<"div">) {
|
|
5
|
+
return (
|
|
6
|
+
<div
|
|
7
|
+
data-slot="card"
|
|
8
|
+
className={cn(
|
|
9
|
+
"flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",
|
|
10
|
+
className
|
|
11
|
+
)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
data-slot="card-header"
|
|
21
|
+
className={cn(
|
|
22
|
+
"@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",
|
|
23
|
+
className
|
|
24
|
+
)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
31
|
+
return (
|
|
32
|
+
<div
|
|
33
|
+
data-slot="card-title"
|
|
34
|
+
className={cn("leading-none font-semibold", className)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
data-slot="card-description"
|
|
44
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
45
|
+
{...props}
|
|
46
|
+
/>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
data-slot="card-action"
|
|
54
|
+
className={cn(
|
|
55
|
+
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
|
56
|
+
className
|
|
57
|
+
)}
|
|
58
|
+
{...props}
|
|
59
|
+
/>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
data-slot="card-content"
|
|
67
|
+
className={cn("px-6", className)}
|
|
68
|
+
{...props}
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
74
|
+
return (
|
|
75
|
+
<div
|
|
76
|
+
data-slot="card-footer"
|
|
77
|
+
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
|
|
78
|
+
{...props}
|
|
79
|
+
/>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export {
|
|
84
|
+
Card,
|
|
85
|
+
CardHeader,
|
|
86
|
+
CardFooter,
|
|
87
|
+
CardTitle,
|
|
88
|
+
CardAction,
|
|
89
|
+
CardDescription,
|
|
90
|
+
CardContent,
|
|
91
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "../cn"
|
|
5
|
+
import useEmblaCarousel, {
|
|
6
|
+
type UseEmblaCarouselType,
|
|
7
|
+
} from "embla-carousel-react"
|
|
8
|
+
import { ArrowLeft, ArrowRight } from "lucide-react"
|
|
9
|
+
|
|
10
|
+
import { Button } from "./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
|
+
}
|