@srcroot/ui 0.0.55 → 0.0.56
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/README.md +151 -151
- package/dist/index.d.ts +0 -0
- package/dist/index.js +33 -17
- package/package.json +7 -2
- package/src/registry/analytics/google-analytics.tsx +36 -39
- package/src/registry/analytics/google-tag-manager.tsx +62 -65
- package/src/registry/analytics/meta-pixel.tsx +44 -47
- package/src/registry/analytics/microsoft-clarity.tsx +31 -34
- package/src/registry/analytics/tiktok-pixel.tsx +34 -37
- package/src/registry/lib/utils.ts +0 -0
- package/src/registry/themes/v3/blue.css +157 -157
- package/src/registry/themes/v3/glass.css +153 -153
- package/src/registry/themes/v3/gray.css +157 -157
- package/src/registry/themes/v3/green.css +157 -157
- package/src/registry/themes/v3/neutral.css +157 -157
- package/src/registry/themes/v3/orange.css +157 -157
- package/src/registry/themes/v3/rose.css +157 -157
- package/src/registry/themes/v3/slate.css +157 -157
- package/src/registry/themes/v3/stone.css +157 -157
- package/src/registry/themes/v3/violet.css +186 -186
- package/src/registry/themes/v3/zinc.css +157 -157
- package/src/registry/themes/v4/blue.css +184 -184
- package/src/registry/themes/v4/glass.css +180 -180
- package/src/registry/themes/v4/gray.css +184 -184
- package/src/registry/themes/v4/green.css +184 -184
- package/src/registry/themes/v4/neutral.css +184 -184
- package/src/registry/themes/v4/orange.css +184 -184
- package/src/registry/themes/v4/rose.css +184 -184
- package/src/registry/themes/v4/slate.css +184 -184
- package/src/registry/themes/v4/stone.css +184 -184
- package/src/registry/themes/v4/violet.css +184 -184
- package/src/registry/themes/v4/zinc.css +184 -184
- package/src/registry/ui/accordion.tsx +164 -165
- package/src/registry/ui/alert-dialog.tsx +213 -214
- package/src/registry/ui/alert.tsx +73 -76
- package/src/registry/ui/aspect-ratio.tsx +44 -47
- package/src/registry/ui/avatar.tsx +96 -97
- package/src/registry/ui/badge.tsx +52 -55
- package/src/registry/ui/breadcrumb.tsx +147 -150
- package/src/registry/ui/button-group.tsx +64 -67
- package/src/registry/ui/button.tsx +71 -72
- package/src/registry/ui/calendar.tsx +514 -515
- package/src/registry/ui/card.tsx +88 -91
- package/src/registry/ui/carousel.tsx +214 -214
- package/src/registry/ui/chart.tsx +373 -373
- package/src/registry/ui/chatbot.tsx +86 -13
- package/src/registry/ui/checkbox.tsx +93 -94
- package/src/registry/ui/collapsible.tsx +107 -108
- package/src/registry/ui/combobox.tsx +171 -171
- package/src/registry/ui/command.tsx +300 -300
- package/src/registry/ui/container.tsx +44 -47
- package/src/registry/ui/context-menu.tsx +221 -221
- package/src/registry/ui/date-picker.tsx +228 -228
- package/src/registry/ui/dialog.tsx +269 -270
- package/src/registry/ui/drawer.tsx +10 -4
- package/src/registry/ui/dropdown-menu.tsx +529 -530
- package/src/registry/ui/empty-state.tsx +0 -2
- package/src/registry/ui/file-upload.tsx +0 -0
- package/src/registry/ui/floating-dock.tsx +0 -0
- package/src/registry/ui/form-field.tsx +91 -94
- package/src/registry/ui/google-analytics.tsx +38 -0
- package/src/registry/ui/google-tag-manager.tsx +64 -0
- package/src/registry/ui/hover-card.tsx +223 -223
- package/src/registry/ui/image.tsx +144 -147
- package/src/registry/ui/input-group.tsx +82 -85
- package/src/registry/ui/input.tsx +125 -125
- package/src/registry/ui/kbd.tsx +60 -63
- package/src/registry/ui/label.tsx +36 -37
- package/src/registry/ui/loading-spinner.tsx +108 -111
- package/src/registry/ui/map.tsx +0 -0
- package/src/registry/ui/marquee.tsx +2 -0
- package/src/registry/ui/menubar.tsx +246 -246
- package/src/registry/ui/meta-pixel.tsx +46 -0
- package/src/registry/ui/microsoft-clarity.tsx +33 -0
- package/src/registry/ui/native-select.tsx +49 -52
- package/src/registry/ui/otp-input.tsx +152 -155
- package/src/registry/ui/pagination.tsx +149 -152
- package/src/registry/ui/patterns.tsx +28 -0
- package/src/registry/ui/popover.tsx +226 -227
- package/src/registry/ui/progress.tsx +51 -52
- package/src/registry/ui/radio.tsx +99 -102
- package/src/registry/ui/resizable.tsx +314 -314
- package/src/registry/ui/scroll-animation.tsx +45 -0
- package/src/registry/ui/scroll-area.tsx +121 -122
- package/src/registry/ui/scroll-to-top.tsx +0 -0
- package/src/registry/ui/search.tsx +147 -150
- package/src/registry/ui/select.tsx +292 -293
- package/src/registry/ui/separator.tsx +46 -47
- package/src/registry/ui/sheet.tsx +6 -3
- package/src/registry/ui/sidebar.tsx +628 -628
- package/src/registry/ui/skeleton.tsx +26 -29
- package/src/registry/ui/slider.tsx +196 -197
- package/src/registry/ui/slot.tsx +69 -72
- package/src/registry/ui/star-rating.tsx +131 -134
- package/src/registry/ui/switch.tsx +72 -73
- package/src/registry/ui/table-of-contents.tsx +96 -96
- package/src/registry/ui/table.tsx +138 -139
- package/src/registry/ui/tabs.tsx +124 -125
- package/src/registry/ui/text.tsx +61 -64
- package/src/registry/ui/textarea.tsx +41 -42
- package/src/registry/ui/theme-switcher.tsx +66 -66
- package/src/registry/ui/tiktok-pixel.tsx +36 -0
- package/src/registry/ui/toast.tsx +97 -98
- package/src/registry/ui/toggle-group.tsx +129 -129
- package/src/registry/ui/toggle.tsx +72 -72
- package/src/registry/ui/tooltip.tsx +143 -144
- package/src/registry/ui/whatsapp.tsx +0 -0
|
@@ -1,139 +1,138 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import { cn } from "@/lib/utils"
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Table components for data display
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* <Table>
|
|
11
|
-
* <TableHeader>
|
|
12
|
-
* <TableRow>
|
|
13
|
-
* <TableHead>Name</TableHead>
|
|
14
|
-
* <TableHead>Email</TableHead>
|
|
15
|
-
* </TableRow>
|
|
16
|
-
* </TableHeader>
|
|
17
|
-
* <TableBody>
|
|
18
|
-
* <TableRow>
|
|
19
|
-
* <TableCell>John Doe</TableCell>
|
|
20
|
-
* <TableCell>john@example.com</TableCell>
|
|
21
|
-
* </TableRow>
|
|
22
|
-
* </TableBody>
|
|
23
|
-
* </Table>
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const Table = React.forwardRef<
|
|
27
|
-
HTMLTableElement,
|
|
28
|
-
React.HTMLAttributes<HTMLTableElement> & { containerClassName?: string }
|
|
29
|
-
>(({ className, containerClassName, ...props }, ref) => (
|
|
30
|
-
<div className={cn("relative w-full overflow-auto", containerClassName)}>
|
|
31
|
-
<table
|
|
32
|
-
ref={ref}
|
|
33
|
-
className={cn("w-full caption-bottom text-sm", className)}
|
|
34
|
-
{...props}
|
|
35
|
-
/>
|
|
36
|
-
</div>
|
|
37
|
-
))
|
|
38
|
-
Table.displayName = "Table"
|
|
39
|
-
|
|
40
|
-
const TableHeader = React.forwardRef<
|
|
41
|
-
HTMLTableSectionElement,
|
|
42
|
-
React.HTMLAttributes<HTMLTableSectionElement>
|
|
43
|
-
>(({ className, ...props }, ref) => (
|
|
44
|
-
<thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
|
|
45
|
-
))
|
|
46
|
-
TableHeader.displayName = "TableHeader"
|
|
47
|
-
|
|
48
|
-
const TableBody = React.forwardRef<
|
|
49
|
-
HTMLTableSectionElement,
|
|
50
|
-
React.HTMLAttributes<HTMLTableSectionElement>
|
|
51
|
-
>(({ className, ...props }, ref) => (
|
|
52
|
-
<tbody
|
|
53
|
-
ref={ref}
|
|
54
|
-
className={cn("[&_tr:last-child]:border-0", className)}
|
|
55
|
-
{...props}
|
|
56
|
-
/>
|
|
57
|
-
))
|
|
58
|
-
TableBody.displayName = "TableBody"
|
|
59
|
-
|
|
60
|
-
const TableFooter = React.forwardRef<
|
|
61
|
-
HTMLTableSectionElement,
|
|
62
|
-
React.HTMLAttributes<HTMLTableSectionElement>
|
|
63
|
-
>(({ className, ...props }, ref) => (
|
|
64
|
-
<tfoot
|
|
65
|
-
ref={ref}
|
|
66
|
-
className={cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className)}
|
|
67
|
-
{...props}
|
|
68
|
-
/>
|
|
69
|
-
))
|
|
70
|
-
TableFooter.displayName = "TableFooter"
|
|
71
|
-
|
|
72
|
-
const TableRow = React.forwardRef<
|
|
73
|
-
HTMLTableRowElement,
|
|
74
|
-
React.HTMLAttributes<HTMLTableRowElement>
|
|
75
|
-
>(({ className, ...props }, ref) => (
|
|
76
|
-
<tr
|
|
77
|
-
ref={ref}
|
|
78
|
-
className={cn(
|
|
79
|
-
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
|
80
|
-
className
|
|
81
|
-
)}
|
|
82
|
-
{...props}
|
|
83
|
-
/>
|
|
84
|
-
))
|
|
85
|
-
TableRow.displayName = "TableRow"
|
|
86
|
-
|
|
87
|
-
const TableHead = React.forwardRef<
|
|
88
|
-
HTMLTableCellElement,
|
|
89
|
-
React.ThHTMLAttributes<HTMLTableCellElement>
|
|
90
|
-
>(({ className, ...props }, ref) => (
|
|
91
|
-
<th
|
|
92
|
-
ref={ref}
|
|
93
|
-
className={cn(
|
|
94
|
-
"h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
95
|
-
className
|
|
96
|
-
)}
|
|
97
|
-
{...props}
|
|
98
|
-
/>
|
|
99
|
-
))
|
|
100
|
-
TableHead.displayName = "TableHead"
|
|
101
|
-
|
|
102
|
-
const TableCell = React.forwardRef<
|
|
103
|
-
HTMLTableCellElement,
|
|
104
|
-
React.TdHTMLAttributes<HTMLTableCellElement>
|
|
105
|
-
>(({ className, ...props }, ref) => (
|
|
106
|
-
<td
|
|
107
|
-
ref={ref}
|
|
108
|
-
className={cn(
|
|
109
|
-
"p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
110
|
-
className
|
|
111
|
-
)}
|
|
112
|
-
{...props}
|
|
113
|
-
/>
|
|
114
|
-
))
|
|
115
|
-
TableCell.displayName = "TableCell"
|
|
116
|
-
|
|
117
|
-
const TableCaption = React.forwardRef<
|
|
118
|
-
HTMLTableCaptionElement,
|
|
119
|
-
React.HTMLAttributes<HTMLTableCaptionElement>
|
|
120
|
-
>(({ className, ...props }, ref) => (
|
|
121
|
-
<caption
|
|
122
|
-
ref={ref}
|
|
123
|
-
className={cn("mt-4 text-sm text-muted-foreground", className)}
|
|
124
|
-
{...props}
|
|
125
|
-
/>
|
|
126
|
-
))
|
|
127
|
-
TableCaption.displayName = "TableCaption"
|
|
128
|
-
|
|
129
|
-
export {
|
|
130
|
-
Table,
|
|
131
|
-
TableHeader,
|
|
132
|
-
TableBody,
|
|
133
|
-
TableFooter,
|
|
134
|
-
TableHead,
|
|
135
|
-
TableRow,
|
|
136
|
-
TableCell,
|
|
137
|
-
TableCaption,
|
|
138
|
-
}
|
|
139
|
-
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "@/lib/utils"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Table components for data display
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* <Table>
|
|
11
|
+
* <TableHeader>
|
|
12
|
+
* <TableRow>
|
|
13
|
+
* <TableHead>Name</TableHead>
|
|
14
|
+
* <TableHead>Email</TableHead>
|
|
15
|
+
* </TableRow>
|
|
16
|
+
* </TableHeader>
|
|
17
|
+
* <TableBody>
|
|
18
|
+
* <TableRow>
|
|
19
|
+
* <TableCell>John Doe</TableCell>
|
|
20
|
+
* <TableCell>john@example.com</TableCell>
|
|
21
|
+
* </TableRow>
|
|
22
|
+
* </TableBody>
|
|
23
|
+
* </Table>
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const Table = React.forwardRef<
|
|
27
|
+
HTMLTableElement,
|
|
28
|
+
React.HTMLAttributes<HTMLTableElement> & { containerClassName?: string }
|
|
29
|
+
>(({ className, containerClassName, ...props }, ref) => (
|
|
30
|
+
<div className={cn("relative w-full overflow-auto", containerClassName)}>
|
|
31
|
+
<table
|
|
32
|
+
ref={ref}
|
|
33
|
+
className={cn("w-full caption-bottom text-sm", className)}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
37
|
+
))
|
|
38
|
+
Table.displayName = "Table"
|
|
39
|
+
|
|
40
|
+
const TableHeader = React.forwardRef<
|
|
41
|
+
HTMLTableSectionElement,
|
|
42
|
+
React.HTMLAttributes<HTMLTableSectionElement>
|
|
43
|
+
>(({ className, ...props }, ref) => (
|
|
44
|
+
<thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
|
|
45
|
+
))
|
|
46
|
+
TableHeader.displayName = "TableHeader"
|
|
47
|
+
|
|
48
|
+
const TableBody = React.forwardRef<
|
|
49
|
+
HTMLTableSectionElement,
|
|
50
|
+
React.HTMLAttributes<HTMLTableSectionElement>
|
|
51
|
+
>(({ className, ...props }, ref) => (
|
|
52
|
+
<tbody
|
|
53
|
+
ref={ref}
|
|
54
|
+
className={cn("[&_tr:last-child]:border-0", className)}
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
))
|
|
58
|
+
TableBody.displayName = "TableBody"
|
|
59
|
+
|
|
60
|
+
const TableFooter = React.forwardRef<
|
|
61
|
+
HTMLTableSectionElement,
|
|
62
|
+
React.HTMLAttributes<HTMLTableSectionElement>
|
|
63
|
+
>(({ className, ...props }, ref) => (
|
|
64
|
+
<tfoot
|
|
65
|
+
ref={ref}
|
|
66
|
+
className={cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className)}
|
|
67
|
+
{...props}
|
|
68
|
+
/>
|
|
69
|
+
))
|
|
70
|
+
TableFooter.displayName = "TableFooter"
|
|
71
|
+
|
|
72
|
+
const TableRow = React.forwardRef<
|
|
73
|
+
HTMLTableRowElement,
|
|
74
|
+
React.HTMLAttributes<HTMLTableRowElement>
|
|
75
|
+
>(({ className, ...props }, ref) => (
|
|
76
|
+
<tr
|
|
77
|
+
ref={ref}
|
|
78
|
+
className={cn(
|
|
79
|
+
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
|
80
|
+
className
|
|
81
|
+
)}
|
|
82
|
+
{...props}
|
|
83
|
+
/>
|
|
84
|
+
))
|
|
85
|
+
TableRow.displayName = "TableRow"
|
|
86
|
+
|
|
87
|
+
const TableHead = React.forwardRef<
|
|
88
|
+
HTMLTableCellElement,
|
|
89
|
+
React.ThHTMLAttributes<HTMLTableCellElement>
|
|
90
|
+
>(({ className, ...props }, ref) => (
|
|
91
|
+
<th
|
|
92
|
+
ref={ref}
|
|
93
|
+
className={cn(
|
|
94
|
+
"h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
95
|
+
className
|
|
96
|
+
)}
|
|
97
|
+
{...props}
|
|
98
|
+
/>
|
|
99
|
+
))
|
|
100
|
+
TableHead.displayName = "TableHead"
|
|
101
|
+
|
|
102
|
+
const TableCell = React.forwardRef<
|
|
103
|
+
HTMLTableCellElement,
|
|
104
|
+
React.TdHTMLAttributes<HTMLTableCellElement>
|
|
105
|
+
>(({ className, ...props }, ref) => (
|
|
106
|
+
<td
|
|
107
|
+
ref={ref}
|
|
108
|
+
className={cn(
|
|
109
|
+
"p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
110
|
+
className
|
|
111
|
+
)}
|
|
112
|
+
{...props}
|
|
113
|
+
/>
|
|
114
|
+
))
|
|
115
|
+
TableCell.displayName = "TableCell"
|
|
116
|
+
|
|
117
|
+
const TableCaption = React.forwardRef<
|
|
118
|
+
HTMLTableCaptionElement,
|
|
119
|
+
React.HTMLAttributes<HTMLTableCaptionElement>
|
|
120
|
+
>(({ className, ...props }, ref) => (
|
|
121
|
+
<caption
|
|
122
|
+
ref={ref}
|
|
123
|
+
className={cn("mt-4 text-sm text-muted-foreground", className)}
|
|
124
|
+
{...props}
|
|
125
|
+
/>
|
|
126
|
+
))
|
|
127
|
+
TableCaption.displayName = "TableCaption"
|
|
128
|
+
|
|
129
|
+
export {
|
|
130
|
+
Table,
|
|
131
|
+
TableHeader,
|
|
132
|
+
TableBody,
|
|
133
|
+
TableFooter,
|
|
134
|
+
TableHead,
|
|
135
|
+
TableRow,
|
|
136
|
+
TableCell,
|
|
137
|
+
TableCaption,
|
|
138
|
+
}
|
package/src/registry/ui/tabs.tsx
CHANGED
|
@@ -1,125 +1,124 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import { cn } from "@/lib/utils"
|
|
5
|
-
|
|
6
|
-
interface TabsContextValue {
|
|
7
|
-
value: string
|
|
8
|
-
onValueChange: (value: string) => void
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const TabsContext = React.createContext<TabsContextValue | null>(null)
|
|
12
|
-
|
|
13
|
-
interface TabsProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
14
|
-
value?: string
|
|
15
|
-
onValueChange?: (value: string) => void
|
|
16
|
-
defaultValue?: string
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Tabs component with keyboard navigation
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* <Tabs defaultValue="tab1">
|
|
24
|
-
* <TabsList>
|
|
25
|
-
* <TabsTrigger value="tab1">Tab 1</TabsTrigger>
|
|
26
|
-
* <TabsTrigger value="tab2">Tab 2</TabsTrigger>
|
|
27
|
-
* </TabsList>
|
|
28
|
-
* <TabsContent value="tab1">Content 1</TabsContent>
|
|
29
|
-
* <TabsContent value="tab2">Content 2</TabsContent>
|
|
30
|
-
* </Tabs>
|
|
31
|
-
*/
|
|
32
|
-
const Tabs = React.forwardRef<HTMLDivElement, TabsProps>(
|
|
33
|
-
({ className, value: controlledValue, onValueChange, defaultValue = "", children, ...props }, ref) => {
|
|
34
|
-
const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue)
|
|
35
|
-
|
|
36
|
-
const value = controlledValue !== undefined ? controlledValue : uncontrolledValue
|
|
37
|
-
const setValue = onValueChange || setUncontrolledValue
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<TabsContext.Provider value={{ value, onValueChange: setValue }}>
|
|
41
|
-
<div ref={ref} className={cn("", className)} {...props}>
|
|
42
|
-
{children}
|
|
43
|
-
</div>
|
|
44
|
-
</TabsContext.Provider>
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
)
|
|
48
|
-
Tabs.displayName = "Tabs"
|
|
49
|
-
|
|
50
|
-
const TabsList = React.forwardRef<
|
|
51
|
-
HTMLDivElement,
|
|
52
|
-
React.HTMLAttributes<HTMLDivElement>
|
|
53
|
-
>(({ className, ...props }, ref) => (
|
|
54
|
-
<div
|
|
55
|
-
ref={ref}
|
|
56
|
-
role="tablist"
|
|
57
|
-
className={cn(
|
|
58
|
-
"inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
|
|
59
|
-
className
|
|
60
|
-
)}
|
|
61
|
-
{...props}
|
|
62
|
-
/>
|
|
63
|
-
))
|
|
64
|
-
TabsList.displayName = "TabsList"
|
|
65
|
-
|
|
66
|
-
interface TabsTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
67
|
-
value: string
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const TabsTrigger = React.forwardRef<HTMLButtonElement, TabsTriggerProps>(
|
|
71
|
-
({ className, value, ...props }, ref) => {
|
|
72
|
-
const context = React.useContext(TabsContext)
|
|
73
|
-
if (!context) throw new Error("TabsTrigger must be used within Tabs")
|
|
74
|
-
|
|
75
|
-
const isSelected = context.value === value
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<button
|
|
79
|
-
ref={ref}
|
|
80
|
-
type="button"
|
|
81
|
-
role="tab"
|
|
82
|
-
aria-selected={isSelected}
|
|
83
|
-
tabIndex={isSelected ? 0 : -1}
|
|
84
|
-
className={cn(
|
|
85
|
-
"inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
86
|
-
isSelected && "bg-background text-foreground shadow",
|
|
87
|
-
className
|
|
88
|
-
)}
|
|
89
|
-
onClick={() => context.onValueChange(value)}
|
|
90
|
-
{...props}
|
|
91
|
-
/>
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
)
|
|
95
|
-
TabsTrigger.displayName = "TabsTrigger"
|
|
96
|
-
|
|
97
|
-
interface TabsContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
98
|
-
value: string
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const TabsContent = React.forwardRef<HTMLDivElement, TabsContentProps>(
|
|
102
|
-
({ className, value, ...props }, ref) => {
|
|
103
|
-
const context = React.useContext(TabsContext)
|
|
104
|
-
if (!context) throw new Error("TabsContent must be used within Tabs")
|
|
105
|
-
|
|
106
|
-
if (context.value !== value) return null
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<div
|
|
110
|
-
ref={ref}
|
|
111
|
-
role="tabpanel"
|
|
112
|
-
tabIndex={0}
|
|
113
|
-
className={cn(
|
|
114
|
-
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
115
|
-
className
|
|
116
|
-
)}
|
|
117
|
-
{...props}
|
|
118
|
-
/>
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
)
|
|
122
|
-
TabsContent.displayName = "TabsContent"
|
|
123
|
-
|
|
124
|
-
export { Tabs, TabsList, TabsTrigger, TabsContent }
|
|
125
|
-
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "@/lib/utils"
|
|
5
|
+
|
|
6
|
+
interface TabsContextValue {
|
|
7
|
+
value: string
|
|
8
|
+
onValueChange: (value: string) => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const TabsContext = React.createContext<TabsContextValue | null>(null)
|
|
12
|
+
|
|
13
|
+
interface TabsProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
14
|
+
value?: string
|
|
15
|
+
onValueChange?: (value: string) => void
|
|
16
|
+
defaultValue?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Tabs component with keyboard navigation
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <Tabs defaultValue="tab1">
|
|
24
|
+
* <TabsList>
|
|
25
|
+
* <TabsTrigger value="tab1">Tab 1</TabsTrigger>
|
|
26
|
+
* <TabsTrigger value="tab2">Tab 2</TabsTrigger>
|
|
27
|
+
* </TabsList>
|
|
28
|
+
* <TabsContent value="tab1">Content 1</TabsContent>
|
|
29
|
+
* <TabsContent value="tab2">Content 2</TabsContent>
|
|
30
|
+
* </Tabs>
|
|
31
|
+
*/
|
|
32
|
+
const Tabs = React.forwardRef<HTMLDivElement, TabsProps>(
|
|
33
|
+
({ className, value: controlledValue, onValueChange, defaultValue = "", children, ...props }, ref) => {
|
|
34
|
+
const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue)
|
|
35
|
+
|
|
36
|
+
const value = controlledValue !== undefined ? controlledValue : uncontrolledValue
|
|
37
|
+
const setValue = onValueChange || setUncontrolledValue
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<TabsContext.Provider value={{ value, onValueChange: setValue }}>
|
|
41
|
+
<div ref={ref} className={cn("", className)} {...props}>
|
|
42
|
+
{children}
|
|
43
|
+
</div>
|
|
44
|
+
</TabsContext.Provider>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
Tabs.displayName = "Tabs"
|
|
49
|
+
|
|
50
|
+
const TabsList = React.forwardRef<
|
|
51
|
+
HTMLDivElement,
|
|
52
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
53
|
+
>(({ className, ...props }, ref) => (
|
|
54
|
+
<div
|
|
55
|
+
ref={ref}
|
|
56
|
+
role="tablist"
|
|
57
|
+
className={cn(
|
|
58
|
+
"inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
|
|
59
|
+
className
|
|
60
|
+
)}
|
|
61
|
+
{...props}
|
|
62
|
+
/>
|
|
63
|
+
))
|
|
64
|
+
TabsList.displayName = "TabsList"
|
|
65
|
+
|
|
66
|
+
interface TabsTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
67
|
+
value: string
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const TabsTrigger = React.forwardRef<HTMLButtonElement, TabsTriggerProps>(
|
|
71
|
+
({ className, value, ...props }, ref) => {
|
|
72
|
+
const context = React.useContext(TabsContext)
|
|
73
|
+
if (!context) throw new Error("TabsTrigger must be used within Tabs")
|
|
74
|
+
|
|
75
|
+
const isSelected = context.value === value
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<button
|
|
79
|
+
ref={ref}
|
|
80
|
+
type="button"
|
|
81
|
+
role="tab"
|
|
82
|
+
aria-selected={isSelected}
|
|
83
|
+
tabIndex={isSelected ? 0 : -1}
|
|
84
|
+
className={cn(
|
|
85
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
86
|
+
isSelected && "bg-background text-foreground shadow",
|
|
87
|
+
className
|
|
88
|
+
)}
|
|
89
|
+
onClick={() => context.onValueChange(value)}
|
|
90
|
+
{...props}
|
|
91
|
+
/>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
TabsTrigger.displayName = "TabsTrigger"
|
|
96
|
+
|
|
97
|
+
interface TabsContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
98
|
+
value: string
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const TabsContent = React.forwardRef<HTMLDivElement, TabsContentProps>(
|
|
102
|
+
({ className, value, ...props }, ref) => {
|
|
103
|
+
const context = React.useContext(TabsContext)
|
|
104
|
+
if (!context) throw new Error("TabsContent must be used within Tabs")
|
|
105
|
+
|
|
106
|
+
if (context.value !== value) return null
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<div
|
|
110
|
+
ref={ref}
|
|
111
|
+
role="tabpanel"
|
|
112
|
+
tabIndex={0}
|
|
113
|
+
className={cn(
|
|
114
|
+
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
115
|
+
className
|
|
116
|
+
)}
|
|
117
|
+
{...props}
|
|
118
|
+
/>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
TabsContent.displayName = "TabsContent"
|
|
123
|
+
|
|
124
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent }
|
package/src/registry/ui/text.tsx
CHANGED
|
@@ -1,64 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
Text
|
|
62
|
-
|
|
63
|
-
export { Text, textVariants }
|
|
64
|
-
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
+
import { cn } from "@/lib/utils"
|
|
4
|
+
|
|
5
|
+
const textVariants = cva("", {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
h1: "scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",
|
|
9
|
+
h2: "scroll-m-20 text-3xl font-semibold tracking-tight",
|
|
10
|
+
h3: "scroll-m-20 text-2xl font-semibold tracking-tight",
|
|
11
|
+
h4: "scroll-m-20 text-xl font-semibold tracking-tight",
|
|
12
|
+
h5: "scroll-m-20 text-lg font-semibold tracking-tight",
|
|
13
|
+
h6: "scroll-m-20 text-base font-semibold tracking-tight",
|
|
14
|
+
p: "leading-7 [&:not(:first-child)]:mt-6",
|
|
15
|
+
lead: "text-xl text-muted-foreground",
|
|
16
|
+
large: "text-lg font-semibold",
|
|
17
|
+
small: "text-sm font-medium leading-none",
|
|
18
|
+
muted: "text-sm text-muted-foreground",
|
|
19
|
+
code: "relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
variant: "p",
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
type TextVariants = VariantProps<typeof textVariants>
|
|
28
|
+
|
|
29
|
+
interface TextProps extends TextVariants {
|
|
30
|
+
className?: string
|
|
31
|
+
children?: React.ReactNode
|
|
32
|
+
as?: "p" | "span" | "div" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "label"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Text component for typography
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* // As a heading
|
|
40
|
+
* <Text as="h1" variant="h1">Page Title</Text>
|
|
41
|
+
*
|
|
42
|
+
* // Using heading styles on a different element
|
|
43
|
+
* <Text as="span" variant="h2">Styled as H2</Text>
|
|
44
|
+
*
|
|
45
|
+
* // Muted text
|
|
46
|
+
* <Text variant="muted">Secondary information</Text>
|
|
47
|
+
*/
|
|
48
|
+
const Text = React.forwardRef<HTMLElement, TextProps>(
|
|
49
|
+
({ as: Component = "p", className, variant, ...props }, ref) => {
|
|
50
|
+
return (
|
|
51
|
+
<Component
|
|
52
|
+
ref={ref as any}
|
|
53
|
+
className={cn(textVariants({ variant }), className)}
|
|
54
|
+
{...props}
|
|
55
|
+
/>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
Text.displayName = "Text"
|
|
60
|
+
|
|
61
|
+
export { Text, textVariants }
|