@org-design-system/components 0.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/LICENSE +19 -0
- package/README.md +43 -0
- package/dist/index.css +30 -0
- package/dist/index.d.mts +95 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +18 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +66 -0
- package/src/components/alert-dialog.tsx +199 -0
- package/src/components/avatar.tsx +111 -0
- package/src/components/badge.tsx +49 -0
- package/src/components/button.tsx +119 -0
- package/src/components/card.tsx +103 -0
- package/src/components/checkbox.tsx +33 -0
- package/src/components/input.tsx +19 -0
- package/src/components/label.tsx +24 -0
- package/src/components/popover.tsx +89 -0
- package/src/components/select.tsx +192 -0
- package/src/components/textarea.tsx +18 -0
- package/src/index.css +30 -0
- package/src/index.ts +13 -0
- package/src/lib/utils.ts +6 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot"
|
|
4
|
+
|
|
5
|
+
import { cn } from "../lib/utils"
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
"group/button inline-flex shrink-0 items-center justify-center font-medium whitespace-nowrap transition-all outline-none select-none active:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
solid: "",
|
|
13
|
+
soft: "",
|
|
14
|
+
surface: "border",
|
|
15
|
+
outline: "border bg-transparent",
|
|
16
|
+
ghost: "bg-transparent",
|
|
17
|
+
link: "bg-transparent underline-offset-4 hover:underline",
|
|
18
|
+
},
|
|
19
|
+
intent: {
|
|
20
|
+
primary: "",
|
|
21
|
+
neutral: "",
|
|
22
|
+
success: "",
|
|
23
|
+
warning: "",
|
|
24
|
+
error: "",
|
|
25
|
+
},
|
|
26
|
+
size: {
|
|
27
|
+
xl: "h-12 px-[18px] text-base gap-2 rounded-[--radius-lg]",
|
|
28
|
+
lg: "h-10 px-3.5 text-sm gap-1.5 rounded-[--radius-lg]",
|
|
29
|
+
md: "h-9 px-3 text-sm gap-1 rounded-[--radius-md]",
|
|
30
|
+
sm: "h-8 px-3 text-sm gap-1 rounded-[--radius-md]",
|
|
31
|
+
xs: "h-6 px-1.5 text-xs gap-0.5 rounded-[--radius-md]",
|
|
32
|
+
icon: "size-9 p-0",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
compoundVariants: [
|
|
36
|
+
// Solid Intent
|
|
37
|
+
{ variant: "solid", intent: "primary", className: "bg-[var(--color-blue-10)] text-white hover:bg-[var(--color-blue-9)]" },
|
|
38
|
+
{ variant: "solid", intent: "neutral", className: "bg-[var(--color-gray-12)] text-white hover:bg-[var(--color-gray-11)] dark:bg-[var(--color-gray-2)] dark:text-[var(--color-gray-12)] dark:hover:bg-[var(--color-gray-3)]" },
|
|
39
|
+
{ variant: "solid", intent: "success", className: "bg-[var(--color-green-9)] text-white hover:bg-[var(--color-green-10)]" },
|
|
40
|
+
{ variant: "solid", intent: "warning", className: "bg-[var(--color-yellow-9)] text-white hover:bg-[var(--color-yellow-10)]" },
|
|
41
|
+
{ variant: "solid", intent: "error", className: "bg-[var(--color-red-9)] text-white hover:bg-[var(--color-red-10)]" },
|
|
42
|
+
|
|
43
|
+
// Soft Intent
|
|
44
|
+
{ variant: "soft", intent: "primary", className: "bg-[var(--color-blue-alpha-2)] text-[var(--color-blue-11)] hover:bg-[var(--color-blue-alpha-3)]" },
|
|
45
|
+
{ variant: "soft", intent: "neutral", className: "bg-[var(--color-gray-alpha-2)] text-[var(--color-gray-12)] hover:bg-[var(--color-gray-alpha-3)]" },
|
|
46
|
+
{ variant: "soft", intent: "success", className: "bg-[var(--color-green-alpha-2)] text-[var(--color-green-11)] hover:bg-[var(--color-green-alpha-3)]" },
|
|
47
|
+
{ variant: "soft", intent: "warning", className: "bg-[var(--color-yellow-alpha-2)] text-[var(--color-yellow-11)] hover:bg-[var(--color-yellow-alpha-3)]" },
|
|
48
|
+
{ variant: "soft", intent: "error", className: "bg-[var(--color-red-alpha-2)] text-[var(--color-red-11)] hover:bg-[var(--color-red-alpha-3)]" },
|
|
49
|
+
|
|
50
|
+
// Outline Intent
|
|
51
|
+
{ variant: "outline", intent: "primary", className: "border-[var(--color-blue-alpha-4)] text-[var(--color-blue-11)] hover:bg-[var(--color-blue-alpha-2)]" },
|
|
52
|
+
{ variant: "outline", intent: "neutral", className: "border-[var(--color-gray-alpha-4)] text-[var(--color-gray-12)] hover:bg-[var(--color-gray-alpha-2)]" },
|
|
53
|
+
{ variant: "outline", intent: "success", className: "border-[var(--color-green-alpha-4)] text-[var(--color-green-11)] hover:bg-[var(--color-green-alpha-2)]" },
|
|
54
|
+
{ variant: "outline", intent: "warning", className: "border-[var(--color-yellow-alpha-4)] text-[var(--color-yellow-11)] hover:bg-[var(--color-yellow-alpha-2)]" },
|
|
55
|
+
{ variant: "outline", intent: "error", className: "border-[var(--color-red-alpha-4)] text-[var(--color-red-11)] hover:bg-[var(--color-red-alpha-2)]" },
|
|
56
|
+
|
|
57
|
+
// Ghost Intent
|
|
58
|
+
{ variant: "ghost", intent: "primary", className: "text-[var(--color-blue-11)] hover:bg-[var(--color-blue-alpha-2)]" },
|
|
59
|
+
{ variant: "ghost", intent: "neutral", className: "text-[var(--color-gray-12)] hover:bg-[var(--color-gray-alpha-2)]" },
|
|
60
|
+
{ variant: "ghost", intent: "success", className: "text-[var(--color-green-11)] hover:bg-[var(--color-green-alpha-2)]" },
|
|
61
|
+
{ variant: "ghost", intent: "warning", className: "text-[var(--color-yellow-11)] hover:bg-[var(--color-yellow-alpha-2)]" },
|
|
62
|
+
{ variant: "ghost", intent: "error", className: "text-[var(--color-red-11)] hover:bg-[var(--color-red-alpha-2)]" },
|
|
63
|
+
],
|
|
64
|
+
defaultVariants: {
|
|
65
|
+
variant: "solid",
|
|
66
|
+
intent: "primary",
|
|
67
|
+
size: "md",
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
type Prettify<T> = {
|
|
73
|
+
[K in keyof T]: T[K];
|
|
74
|
+
} & {};
|
|
75
|
+
|
|
76
|
+
interface ButtonProps
|
|
77
|
+
extends React.ComponentProps<"button">,
|
|
78
|
+
Prettify<VariantProps<typeof buttonVariants>> {
|
|
79
|
+
asChild?: boolean
|
|
80
|
+
leftIcon?: React.ReactNode
|
|
81
|
+
rightIcon?: React.ReactNode
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function Button({
|
|
85
|
+
className,
|
|
86
|
+
variant,
|
|
87
|
+
intent,
|
|
88
|
+
size,
|
|
89
|
+
asChild = false,
|
|
90
|
+
leftIcon,
|
|
91
|
+
rightIcon,
|
|
92
|
+
children,
|
|
93
|
+
...props
|
|
94
|
+
}: ButtonProps) {
|
|
95
|
+
const Comp = asChild ? Slot : "button"
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<Comp
|
|
99
|
+
data-slot="button"
|
|
100
|
+
data-variant={variant}
|
|
101
|
+
data-intent={intent}
|
|
102
|
+
data-size={size}
|
|
103
|
+
className={cn(buttonVariants({ variant, intent, size, className }))}
|
|
104
|
+
{...props}
|
|
105
|
+
>
|
|
106
|
+
{asChild ? (
|
|
107
|
+
children
|
|
108
|
+
) : (
|
|
109
|
+
<>
|
|
110
|
+
{leftIcon && <span className="inline-flex shrink-0">{leftIcon}</span>}
|
|
111
|
+
{children}
|
|
112
|
+
{rightIcon && <span className="inline-flex shrink-0">{rightIcon}</span>}
|
|
113
|
+
</>
|
|
114
|
+
)}
|
|
115
|
+
</Comp>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { Button, buttonVariants }
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
import { cn } from "../lib/utils"
|
|
4
|
+
|
|
5
|
+
function Card({
|
|
6
|
+
className,
|
|
7
|
+
size = "default",
|
|
8
|
+
...props
|
|
9
|
+
}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
|
|
10
|
+
return (
|
|
11
|
+
<div
|
|
12
|
+
data-slot="card"
|
|
13
|
+
data-size={size}
|
|
14
|
+
className={cn(
|
|
15
|
+
"group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
|
|
16
|
+
className
|
|
17
|
+
)}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
24
|
+
return (
|
|
25
|
+
<div
|
|
26
|
+
data-slot="card-header"
|
|
27
|
+
className={cn(
|
|
28
|
+
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",
|
|
29
|
+
className
|
|
30
|
+
)}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
data-slot="card-title"
|
|
40
|
+
className={cn(
|
|
41
|
+
"text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
|
|
42
|
+
className
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
50
|
+
return (
|
|
51
|
+
<div
|
|
52
|
+
data-slot="card-description"
|
|
53
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
54
|
+
{...props}
|
|
55
|
+
/>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
60
|
+
return (
|
|
61
|
+
<div
|
|
62
|
+
data-slot="card-action"
|
|
63
|
+
className={cn(
|
|
64
|
+
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
|
65
|
+
className
|
|
66
|
+
)}
|
|
67
|
+
{...props}
|
|
68
|
+
/>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
73
|
+
return (
|
|
74
|
+
<div
|
|
75
|
+
data-slot="card-content"
|
|
76
|
+
className={cn("px-4 group-data-[size=sm]/card:px-3", className)}
|
|
77
|
+
{...props}
|
|
78
|
+
/>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
83
|
+
return (
|
|
84
|
+
<div
|
|
85
|
+
data-slot="card-footer"
|
|
86
|
+
className={cn(
|
|
87
|
+
"flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3",
|
|
88
|
+
className
|
|
89
|
+
)}
|
|
90
|
+
{...props}
|
|
91
|
+
/>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export {
|
|
96
|
+
Card,
|
|
97
|
+
CardHeader,
|
|
98
|
+
CardFooter,
|
|
99
|
+
CardTitle,
|
|
100
|
+
CardAction,
|
|
101
|
+
CardDescription,
|
|
102
|
+
CardContent,
|
|
103
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Checkbox as CheckboxPrimitive } from "radix-ui"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../lib/utils"
|
|
7
|
+
import { CheckIcon } from "@org-design-system/icons"
|
|
8
|
+
|
|
9
|
+
function Checkbox({
|
|
10
|
+
className,
|
|
11
|
+
...props
|
|
12
|
+
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
|
13
|
+
return (
|
|
14
|
+
<CheckboxPrimitive.Root
|
|
15
|
+
data-slot="checkbox"
|
|
16
|
+
className={cn(
|
|
17
|
+
"peer relative flex size-4 shrink-0 items-center justify-center rounded-sm border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary",
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
>
|
|
22
|
+
<CheckboxPrimitive.Indicator
|
|
23
|
+
data-slot="checkbox-indicator"
|
|
24
|
+
className="grid place-content-center text-current transition-none [&>svg]:size-3.5"
|
|
25
|
+
>
|
|
26
|
+
<CheckIcon
|
|
27
|
+
/>
|
|
28
|
+
</CheckboxPrimitive.Indicator>
|
|
29
|
+
</CheckboxPrimitive.Root>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { Checkbox }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
import { cn } from "../lib/utils"
|
|
4
|
+
|
|
5
|
+
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
|
6
|
+
return (
|
|
7
|
+
<input
|
|
8
|
+
type={type}
|
|
9
|
+
data-slot="input"
|
|
10
|
+
className={cn(
|
|
11
|
+
"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
|
12
|
+
className
|
|
13
|
+
)}
|
|
14
|
+
{...props}
|
|
15
|
+
/>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { Input }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Label as LabelPrimitive } from "radix-ui"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../lib/utils"
|
|
7
|
+
|
|
8
|
+
function Label({
|
|
9
|
+
className,
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
|
12
|
+
return (
|
|
13
|
+
<LabelPrimitive.Root
|
|
14
|
+
data-slot="label"
|
|
15
|
+
className={cn(
|
|
16
|
+
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { Label }
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Popover as PopoverPrimitive } from "radix-ui"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../lib/utils"
|
|
7
|
+
|
|
8
|
+
function Popover({
|
|
9
|
+
...props
|
|
10
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
|
|
11
|
+
return <PopoverPrimitive.Root data-slot="popover" {...props} />
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function PopoverTrigger({
|
|
15
|
+
...props
|
|
16
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
|
|
17
|
+
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function PopoverContent({
|
|
21
|
+
className,
|
|
22
|
+
align = "center",
|
|
23
|
+
sideOffset = 4,
|
|
24
|
+
...props
|
|
25
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
|
|
26
|
+
return (
|
|
27
|
+
<PopoverPrimitive.Portal>
|
|
28
|
+
<PopoverPrimitive.Content
|
|
29
|
+
data-slot="popover-content"
|
|
30
|
+
align={align}
|
|
31
|
+
sideOffset={sideOffset}
|
|
32
|
+
className={cn(
|
|
33
|
+
"z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
34
|
+
className
|
|
35
|
+
)}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
</PopoverPrimitive.Portal>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function PopoverAnchor({
|
|
43
|
+
...props
|
|
44
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
|
|
45
|
+
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function PopoverHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
49
|
+
return (
|
|
50
|
+
<div
|
|
51
|
+
data-slot="popover-header"
|
|
52
|
+
className={cn("flex flex-col gap-0.5 text-sm", className)}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function PopoverTitle({ className, ...props }: React.ComponentProps<"h2">) {
|
|
59
|
+
return (
|
|
60
|
+
<div
|
|
61
|
+
data-slot="popover-title"
|
|
62
|
+
className={cn("font-medium", className)}
|
|
63
|
+
{...props}
|
|
64
|
+
/>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function PopoverDescription({
|
|
69
|
+
className,
|
|
70
|
+
...props
|
|
71
|
+
}: React.ComponentProps<"p">) {
|
|
72
|
+
return (
|
|
73
|
+
<p
|
|
74
|
+
data-slot="popover-description"
|
|
75
|
+
className={cn("text-muted-foreground", className)}
|
|
76
|
+
{...props}
|
|
77
|
+
/>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export {
|
|
82
|
+
Popover,
|
|
83
|
+
PopoverAnchor,
|
|
84
|
+
PopoverContent,
|
|
85
|
+
PopoverDescription,
|
|
86
|
+
PopoverHeader,
|
|
87
|
+
PopoverTitle,
|
|
88
|
+
PopoverTrigger,
|
|
89
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Select as SelectPrimitive } from "radix-ui"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../lib/utils"
|
|
7
|
+
import { ChevronDownIcon, CheckIcon, ChevronUpIcon } from "lucide-react"
|
|
8
|
+
|
|
9
|
+
function Select({
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof SelectPrimitive.Root>) {
|
|
12
|
+
return <SelectPrimitive.Root data-slot="select" {...props} />
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function SelectGroup({
|
|
16
|
+
className,
|
|
17
|
+
...props
|
|
18
|
+
}: React.ComponentProps<typeof SelectPrimitive.Group>) {
|
|
19
|
+
return (
|
|
20
|
+
<SelectPrimitive.Group
|
|
21
|
+
data-slot="select-group"
|
|
22
|
+
className={cn("scroll-my-1 p-1", className)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function SelectValue({
|
|
29
|
+
...props
|
|
30
|
+
}: React.ComponentProps<typeof SelectPrimitive.Value>) {
|
|
31
|
+
return <SelectPrimitive.Value data-slot="select-value" {...props} />
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function SelectTrigger({
|
|
35
|
+
className,
|
|
36
|
+
size = "default",
|
|
37
|
+
children,
|
|
38
|
+
...props
|
|
39
|
+
}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
|
|
40
|
+
size?: "sm" | "default"
|
|
41
|
+
}) {
|
|
42
|
+
return (
|
|
43
|
+
<SelectPrimitive.Trigger
|
|
44
|
+
data-slot="select-trigger"
|
|
45
|
+
data-size={size}
|
|
46
|
+
className={cn(
|
|
47
|
+
"flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
48
|
+
className
|
|
49
|
+
)}
|
|
50
|
+
{...props}
|
|
51
|
+
>
|
|
52
|
+
{children}
|
|
53
|
+
<SelectPrimitive.Icon asChild>
|
|
54
|
+
<ChevronDownIcon className="pointer-events-none size-4 text-muted-foreground" />
|
|
55
|
+
</SelectPrimitive.Icon>
|
|
56
|
+
</SelectPrimitive.Trigger>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function SelectContent({
|
|
61
|
+
className,
|
|
62
|
+
children,
|
|
63
|
+
position = "item-aligned",
|
|
64
|
+
align = "center",
|
|
65
|
+
...props
|
|
66
|
+
}: React.ComponentProps<typeof SelectPrimitive.Content>) {
|
|
67
|
+
return (
|
|
68
|
+
<SelectPrimitive.Portal>
|
|
69
|
+
<SelectPrimitive.Content
|
|
70
|
+
data-slot="select-content"
|
|
71
|
+
data-align-trigger={position === "item-aligned"}
|
|
72
|
+
className={cn("relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", position ==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className )}
|
|
73
|
+
position={position}
|
|
74
|
+
align={align}
|
|
75
|
+
{...props}
|
|
76
|
+
>
|
|
77
|
+
<SelectScrollUpButton />
|
|
78
|
+
<SelectPrimitive.Viewport
|
|
79
|
+
data-position={position}
|
|
80
|
+
className={cn(
|
|
81
|
+
"data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)",
|
|
82
|
+
position === "popper" && ""
|
|
83
|
+
)}
|
|
84
|
+
>
|
|
85
|
+
{children}
|
|
86
|
+
</SelectPrimitive.Viewport>
|
|
87
|
+
<SelectScrollDownButton />
|
|
88
|
+
</SelectPrimitive.Content>
|
|
89
|
+
</SelectPrimitive.Portal>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function SelectLabel({
|
|
94
|
+
className,
|
|
95
|
+
...props
|
|
96
|
+
}: React.ComponentProps<typeof SelectPrimitive.Label>) {
|
|
97
|
+
return (
|
|
98
|
+
<SelectPrimitive.Label
|
|
99
|
+
data-slot="select-label"
|
|
100
|
+
className={cn("px-1.5 py-1 text-xs text-muted-foreground", className)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function SelectItem({
|
|
107
|
+
className,
|
|
108
|
+
children,
|
|
109
|
+
...props
|
|
110
|
+
}: React.ComponentProps<typeof SelectPrimitive.Item>) {
|
|
111
|
+
return (
|
|
112
|
+
<SelectPrimitive.Item
|
|
113
|
+
data-slot="select-item"
|
|
114
|
+
className={cn(
|
|
115
|
+
"relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
|
116
|
+
className
|
|
117
|
+
)}
|
|
118
|
+
{...props}
|
|
119
|
+
>
|
|
120
|
+
<span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center">
|
|
121
|
+
<SelectPrimitive.ItemIndicator>
|
|
122
|
+
<CheckIcon className="pointer-events-none" />
|
|
123
|
+
</SelectPrimitive.ItemIndicator>
|
|
124
|
+
</span>
|
|
125
|
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
126
|
+
</SelectPrimitive.Item>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function SelectSeparator({
|
|
131
|
+
className,
|
|
132
|
+
...props
|
|
133
|
+
}: React.ComponentProps<typeof SelectPrimitive.Separator>) {
|
|
134
|
+
return (
|
|
135
|
+
<SelectPrimitive.Separator
|
|
136
|
+
data-slot="select-separator"
|
|
137
|
+
className={cn("pointer-events-none -mx-1 my-1 h-px bg-border", className)}
|
|
138
|
+
{...props}
|
|
139
|
+
/>
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function SelectScrollUpButton({
|
|
144
|
+
className,
|
|
145
|
+
...props
|
|
146
|
+
}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
|
|
147
|
+
return (
|
|
148
|
+
<SelectPrimitive.ScrollUpButton
|
|
149
|
+
data-slot="select-scroll-up-button"
|
|
150
|
+
className={cn(
|
|
151
|
+
"z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",
|
|
152
|
+
className
|
|
153
|
+
)}
|
|
154
|
+
{...props}
|
|
155
|
+
>
|
|
156
|
+
<ChevronUpIcon
|
|
157
|
+
/>
|
|
158
|
+
</SelectPrimitive.ScrollUpButton>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function SelectScrollDownButton({
|
|
163
|
+
className,
|
|
164
|
+
...props
|
|
165
|
+
}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
|
|
166
|
+
return (
|
|
167
|
+
<SelectPrimitive.ScrollDownButton
|
|
168
|
+
data-slot="select-scroll-down-button"
|
|
169
|
+
className={cn(
|
|
170
|
+
"z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",
|
|
171
|
+
className
|
|
172
|
+
)}
|
|
173
|
+
{...props}
|
|
174
|
+
>
|
|
175
|
+
<ChevronDownIcon
|
|
176
|
+
/>
|
|
177
|
+
</SelectPrimitive.ScrollDownButton>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export {
|
|
182
|
+
Select,
|
|
183
|
+
SelectContent,
|
|
184
|
+
SelectGroup,
|
|
185
|
+
SelectItem,
|
|
186
|
+
SelectLabel,
|
|
187
|
+
SelectScrollDownButton,
|
|
188
|
+
SelectScrollUpButton,
|
|
189
|
+
SelectSeparator,
|
|
190
|
+
SelectTrigger,
|
|
191
|
+
SelectValue,
|
|
192
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
import { cn } from "../lib/utils"
|
|
4
|
+
|
|
5
|
+
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
|
6
|
+
return (
|
|
7
|
+
<textarea
|
|
8
|
+
data-slot="textarea"
|
|
9
|
+
className={cn(
|
|
10
|
+
"flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
|
11
|
+
className
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { Textarea }
|
package/src/index.css
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
@import "../../tokens/src/index.css";
|
|
3
|
+
@import "../../tokens/src/component.css";
|
|
4
|
+
|
|
5
|
+
@source "./components/**/*.tsx";
|
|
6
|
+
|
|
7
|
+
@theme {
|
|
8
|
+
/* Mapping for shadcn components that expect these variables */
|
|
9
|
+
--color-background: var(--color-surface-bg);
|
|
10
|
+
--color-foreground: var(--color-text-primary);
|
|
11
|
+
|
|
12
|
+
--color-primary: var(--color-green-9);
|
|
13
|
+
--color-primary-foreground: var(--color-gray-1);
|
|
14
|
+
|
|
15
|
+
--color-secondary: var(--color-gray-alpha-3);
|
|
16
|
+
--color-secondary-foreground: var(--color-text-primary);
|
|
17
|
+
|
|
18
|
+
--color-muted: var(--color-gray-alpha-2);
|
|
19
|
+
--color-muted-foreground: var(--color-text-secondary);
|
|
20
|
+
|
|
21
|
+
--color-accent: var(--color-green-alpha-2);
|
|
22
|
+
--color-accent-foreground: var(--color-text-focus);
|
|
23
|
+
|
|
24
|
+
--color-destructive: var(--color-red-9);
|
|
25
|
+
--color-destructive-foreground: var(--color-gray-1);
|
|
26
|
+
|
|
27
|
+
--color-border: var(--color-stroke-primary);
|
|
28
|
+
--color-input: var(--color-stroke-primary);
|
|
29
|
+
--color-ring: var(--color-surface-focus);
|
|
30
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This file is auto-generated by sync-components.ts
|
|
2
|
+
export * from './components/alert-dialog';
|
|
3
|
+
export * from './components/avatar';
|
|
4
|
+
export * from './components/badge';
|
|
5
|
+
export * from './components/button';
|
|
6
|
+
export * from './components/card';
|
|
7
|
+
export * from './components/checkbox';
|
|
8
|
+
export * from './components/input';
|
|
9
|
+
export * from './components/label';
|
|
10
|
+
export * from './components/popover';
|
|
11
|
+
export * from './components/select';
|
|
12
|
+
export * from './components/textarea';
|
|
13
|
+
export * from './lib/utils';
|