@openconsole/shadcn 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/accordion.tsx +66 -0
  2. package/alert-dialog.tsx +196 -0
  3. package/alert.tsx +66 -0
  4. package/aspect-ratio.tsx +11 -0
  5. package/avatar.tsx +53 -0
  6. package/badge.tsx +46 -0
  7. package/breadcrumb.tsx +109 -0
  8. package/button-group.tsx +83 -0
  9. package/button.tsx +60 -0
  10. package/calendar.tsx +219 -0
  11. package/card.tsx +92 -0
  12. package/carousel.tsx +241 -0
  13. package/chart.tsx +374 -0
  14. package/checkbox.tsx +32 -0
  15. package/collapsible.tsx +33 -0
  16. package/command.tsx +184 -0
  17. package/context-menu.tsx +252 -0
  18. package/dialog.tsx +143 -0
  19. package/direction.tsx +22 -0
  20. package/drawer.tsx +135 -0
  21. package/dropdown-menu.tsx +257 -0
  22. package/empty.tsx +104 -0
  23. package/field.tsx +248 -0
  24. package/form.tsx +167 -0
  25. package/hooks/index.ts +1 -0
  26. package/hooks/use-mobile.ts +19 -0
  27. package/hover-card.tsx +44 -0
  28. package/icon.tsx +21 -0
  29. package/index.ts +59 -0
  30. package/input-group.tsx +170 -0
  31. package/input-otp.tsx +77 -0
  32. package/input.tsx +21 -0
  33. package/item.tsx +193 -0
  34. package/kbd.tsx +28 -0
  35. package/label.tsx +24 -0
  36. package/lib/index.ts +1 -0
  37. package/lib/utils.ts +6 -0
  38. package/menubar.tsx +276 -0
  39. package/native-select.tsx +62 -0
  40. package/navigation-menu.tsx +168 -0
  41. package/package.json +50 -0
  42. package/pagination.tsx +127 -0
  43. package/popover.tsx +89 -0
  44. package/progress.tsx +31 -0
  45. package/radio-group.tsx +45 -0
  46. package/resizable.tsx +53 -0
  47. package/scroll-area.tsx +58 -0
  48. package/select.tsx +187 -0
  49. package/separator.tsx +28 -0
  50. package/sheet.tsx +139 -0
  51. package/sidebar.tsx +724 -0
  52. package/skeleton.tsx +13 -0
  53. package/skill/SKILL.md +599 -0
  54. package/skill/customization.md +263 -0
  55. package/skill/rules/base-vs-radix.md +167 -0
  56. package/skill/rules/composition.md +240 -0
  57. package/skill/rules/forms.md +271 -0
  58. package/skill/rules/icons.md +136 -0
  59. package/skill/rules/styling.md +180 -0
  60. package/slider.tsx +63 -0
  61. package/sonner.tsx +40 -0
  62. package/spinner.tsx +16 -0
  63. package/switch.tsx +35 -0
  64. package/table.tsx +116 -0
  65. package/tabs.tsx +66 -0
  66. package/textarea.tsx +18 -0
  67. package/toggle-group.tsx +83 -0
  68. package/toggle.tsx +47 -0
  69. package/tooltip.tsx +61 -0
  70. package/tsconfig.json +12 -0
  71. package/tsconfig.tsbuildinfo +1 -0
package/calendar.tsx ADDED
@@ -0,0 +1,219 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import {
5
+ ChevronDownIcon,
6
+ ChevronLeftIcon,
7
+ ChevronRightIcon,
8
+ } from "lucide-react"
9
+ import {
10
+ DayPicker,
11
+ getDefaultClassNames,
12
+ type DayButton,
13
+ } from "react-day-picker"
14
+
15
+ import { cn } from "./lib/utils"
16
+ import { Button, buttonVariants } from "./button"
17
+
18
+ const defaultClassNames = getDefaultClassNames()
19
+
20
+ function Calendar({
21
+ className,
22
+ classNames,
23
+ showOutsideDays = true,
24
+ captionLayout = "label",
25
+ buttonVariant = "ghost",
26
+ formatters,
27
+ components,
28
+ ...props
29
+ }: React.ComponentProps<typeof DayPicker> & {
30
+ buttonVariant?: React.ComponentProps<typeof Button>["variant"]
31
+ }) {
32
+
33
+ return (
34
+ <DayPicker
35
+ showOutsideDays={showOutsideDays}
36
+ className={cn(
37
+ "group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
38
+ String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
39
+ String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
40
+ className
41
+ )}
42
+ captionLayout={captionLayout}
43
+ formatters={{
44
+ formatMonthDropdown: (date) =>
45
+ date.toLocaleString("default", { month: "short" }),
46
+ ...formatters,
47
+ }}
48
+ classNames={{
49
+ root: cn("w-fit", defaultClassNames.root),
50
+ months: cn(
51
+ "relative flex flex-col gap-4 md:flex-row",
52
+ defaultClassNames.months
53
+ ),
54
+ month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
55
+ nav: cn(
56
+ "absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
57
+ defaultClassNames.nav
58
+ ),
59
+ button_previous: cn(
60
+ buttonVariants({ variant: buttonVariant }),
61
+ "size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
62
+ defaultClassNames.button_previous
63
+ ),
64
+ button_next: cn(
65
+ buttonVariants({ variant: buttonVariant }),
66
+ "size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
67
+ defaultClassNames.button_next
68
+ ),
69
+ month_caption: cn(
70
+ "flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
71
+ defaultClassNames.month_caption
72
+ ),
73
+ dropdowns: cn(
74
+ "flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
75
+ defaultClassNames.dropdowns
76
+ ),
77
+ dropdown_root: cn(
78
+ "relative rounded-md border border-input shadow-xs has-focus:border-ring has-focus:ring-[3px] has-focus:ring-ring/50",
79
+ defaultClassNames.dropdown_root
80
+ ),
81
+ dropdown: cn(
82
+ "absolute inset-0 bg-popover opacity-0",
83
+ defaultClassNames.dropdown
84
+ ),
85
+ caption_label: cn(
86
+ "font-medium select-none",
87
+ captionLayout === "label"
88
+ ? "text-sm"
89
+ : "flex h-8 items-center gap-1 rounded-md pr-1 pl-2 text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
90
+ defaultClassNames.caption_label
91
+ ),
92
+ month_grid: "w-full border-collapse",
93
+ weekdays: cn("flex", defaultClassNames.weekdays),
94
+ weekday: cn(
95
+ "flex-1 rounded-md text-[0.8rem] font-normal text-muted-foreground select-none",
96
+ defaultClassNames.weekday
97
+ ),
98
+ week: cn("mt-2 flex w-full", defaultClassNames.week),
99
+ week_number_header: cn(
100
+ "w-(--cell-size) select-none",
101
+ defaultClassNames.week_number_header
102
+ ),
103
+ week_number: cn(
104
+ "text-[0.8rem] text-muted-foreground select-none",
105
+ defaultClassNames.week_number
106
+ ),
107
+ day: cn(
108
+ "group/day relative aspect-square h-full w-full p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-md",
109
+ props.showWeekNumber
110
+ ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-md"
111
+ : "[&:first-child[data-selected=true]_button]:rounded-l-md",
112
+ defaultClassNames.day
113
+ ),
114
+ range_start: cn(
115
+ "rounded-l-md bg-accent",
116
+ defaultClassNames.range_start
117
+ ),
118
+ range_middle: cn("rounded-none", defaultClassNames.range_middle),
119
+ range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end),
120
+ today: cn(
121
+ "rounded-md bg-accent text-accent-foreground data-[selected=true]:rounded-none",
122
+ defaultClassNames.today
123
+ ),
124
+ outside: cn(
125
+ "text-muted-foreground aria-selected:text-muted-foreground",
126
+ defaultClassNames.outside
127
+ ),
128
+ disabled: cn(
129
+ "text-muted-foreground opacity-50",
130
+ defaultClassNames.disabled
131
+ ),
132
+ hidden: cn("invisible", defaultClassNames.hidden),
133
+ ...classNames,
134
+ }}
135
+ components={{
136
+ Root: ({ className, rootRef, ...props }) => {
137
+ return (
138
+ <div
139
+ data-slot="calendar"
140
+ ref={rootRef}
141
+ className={cn(className)}
142
+ {...props}
143
+ />
144
+ )
145
+ },
146
+ Chevron: ({ className, orientation, ...props }) => {
147
+ if (orientation === "left") {
148
+ return (
149
+ <ChevronLeftIcon className={cn("size-4", className)} {...props} />
150
+ )
151
+ }
152
+
153
+ if (orientation === "right") {
154
+ return (
155
+ <ChevronRightIcon
156
+ className={cn("size-4", className)}
157
+ {...props}
158
+ />
159
+ )
160
+ }
161
+
162
+ return (
163
+ <ChevronDownIcon className={cn("size-4", className)} {...props} />
164
+ )
165
+ },
166
+ DayButton: CalendarDayButton,
167
+ WeekNumber: ({ children, ...props }) => {
168
+ return (
169
+ <td {...props}>
170
+ <div className="flex size-(--cell-size) items-center justify-center text-center">
171
+ {children}
172
+ </div>
173
+ </td>
174
+ )
175
+ },
176
+ ...components,
177
+ }}
178
+ {...props}
179
+ />
180
+ )
181
+ }
182
+
183
+ function CalendarDayButton({
184
+ className,
185
+ day,
186
+ modifiers,
187
+ ...props
188
+ }: React.ComponentProps<typeof DayButton>) {
189
+ const ref = React.useRef<HTMLButtonElement>(null)
190
+ React.useEffect(() => {
191
+ if (modifiers.focused) ref.current?.focus()
192
+ }, [modifiers.focused])
193
+
194
+ return (
195
+ <Button
196
+ ref={ref}
197
+ variant="ghost"
198
+ size="icon"
199
+ data-day={day.date.toLocaleDateString()}
200
+ data-selected-single={
201
+ modifiers.selected &&
202
+ !modifiers.range_start &&
203
+ !modifiers.range_end &&
204
+ !modifiers.range_middle
205
+ }
206
+ data-range-start={modifiers.range_start}
207
+ data-range-end={modifiers.range_end}
208
+ data-range-middle={modifiers.range_middle}
209
+ className={cn(
210
+ "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",
211
+ defaultClassNames.day,
212
+ className
213
+ )}
214
+ {...props}
215
+ />
216
+ )
217
+ }
218
+
219
+ export { Calendar, CalendarDayButton }
package/card.tsx ADDED
@@ -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
+ "flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",
11
+ className
12
+ )}
13
+ {...props}
14
+ />
15
+ )
16
+ }
17
+
18
+ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
19
+ return (
20
+ <div
21
+ data-slot="card-header"
22
+ className={cn(
23
+ "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
24
+ className
25
+ )}
26
+ {...props}
27
+ />
28
+ )
29
+ }
30
+
31
+ function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
32
+ return (
33
+ <div
34
+ data-slot="card-title"
35
+ className={cn("leading-none font-semibold", className)}
36
+ {...props}
37
+ />
38
+ )
39
+ }
40
+
41
+ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
42
+ return (
43
+ <div
44
+ data-slot="card-description"
45
+ className={cn("text-sm text-muted-foreground", 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
+ }
package/carousel.tsx ADDED
@@ -0,0 +1,241 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import useEmblaCarousel, {
5
+ type UseEmblaCarouselType,
6
+ } from "embla-carousel-react"
7
+ import { ArrowLeft, ArrowRight } from "lucide-react"
8
+
9
+ import { cn } from "./lib/utils"
10
+ import { Button } from "./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
+ }