@foundrykit/primitives 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/components.json +20 -0
- package/dist/chunk-A3U73FA7.js +33 -0
- package/dist/chunk-AADRFFPH.js +171 -0
- package/dist/chunk-FUWID6MC.js +42 -0
- package/dist/chunk-FYCANIVJ.js +69 -0
- package/dist/chunk-I44GXEPN.js +20 -0
- package/dist/chunk-J4CRGO2P.js +46 -0
- package/dist/chunk-J57CV3VT.js +28 -0
- package/dist/chunk-KZMSLRLW.js +25 -0
- package/dist/chunk-PHMEWMFS.js +233 -0
- package/dist/chunk-QL4XJD7Y.js +24 -0
- package/dist/chunk-SKR3J46C.js +17 -0
- package/dist/chunk-U2EIVYWP.js +33 -0
- package/dist/chunk-UZIMC7AQ.js +63 -0
- package/dist/chunk-VSXKLSEP.js +105 -0
- package/dist/chunk-VVNIYCKH.js +55 -0
- package/dist/chunk-XQAJQKO7.js +47 -0
- package/dist/chunk-YTUI6MCB.js +52 -0
- package/dist/components/avatar/index.cjs +92 -0
- package/dist/components/avatar/index.d.cts +9 -0
- package/dist/components/avatar/index.d.ts +9 -0
- package/dist/components/avatar/index.js +11 -0
- package/dist/components/badge/index.cjs +67 -0
- package/dist/components/badge/index.d.cts +13 -0
- package/dist/components/badge/index.d.ts +13 -0
- package/dist/components/badge/index.js +8 -0
- package/dist/components/breadcrumb/index.cjs +135 -0
- package/dist/components/breadcrumb/index.d.cts +14 -0
- package/dist/components/breadcrumb/index.d.ts +14 -0
- package/dist/components/breadcrumb/index.js +18 -0
- package/dist/components/button/index.cjs +77 -0
- package/dist/components/button/index.d.cts +15 -0
- package/dist/components/button/index.d.ts +15 -0
- package/dist/components/button/index.js +8 -0
- package/dist/components/card/index.cjs +102 -0
- package/dist/components/card/index.d.cts +10 -0
- package/dist/components/card/index.d.ts +10 -0
- package/dist/components/card/index.js +16 -0
- package/dist/components/checkbox/index.cjs +68 -0
- package/dist/components/checkbox/index.d.cts +7 -0
- package/dist/components/checkbox/index.d.ts +7 -0
- package/dist/components/checkbox/index.js +7 -0
- package/dist/components/dropdown/index.cjs +282 -0
- package/dist/components/dropdown/index.d.cts +28 -0
- package/dist/components/dropdown/index.d.ts +28 -0
- package/dist/components/dropdown/index.js +35 -0
- package/dist/components/input/index.cjs +59 -0
- package/dist/components/input/index.d.cts +7 -0
- package/dist/components/input/index.d.ts +7 -0
- package/dist/components/input/index.js +6 -0
- package/dist/components/label/index.cjs +59 -0
- package/dist/components/label/index.d.cts +7 -0
- package/dist/components/label/index.d.ts +7 -0
- package/dist/components/label/index.js +7 -0
- package/dist/components/popover/index.cjs +84 -0
- package/dist/components/popover/index.d.cts +10 -0
- package/dist/components/popover/index.d.ts +10 -0
- package/dist/components/popover/index.js +13 -0
- package/dist/components/radio-group/index.cjs +83 -0
- package/dist/components/radio-group/index.d.cts +8 -0
- package/dist/components/radio-group/index.d.ts +8 -0
- package/dist/components/radio-group/index.js +9 -0
- package/dist/components/select/index.cjs +215 -0
- package/dist/components/select/index.d.cts +18 -0
- package/dist/components/select/index.d.ts +18 -0
- package/dist/components/select/index.js +25 -0
- package/dist/components/separator/index.cjs +63 -0
- package/dist/components/separator/index.d.cts +7 -0
- package/dist/components/separator/index.d.ts +7 -0
- package/dist/components/separator/index.js +7 -0
- package/dist/components/skeleton/index.cjs +41 -0
- package/dist/components/skeleton/index.d.cts +5 -0
- package/dist/components/skeleton/index.d.ts +5 -0
- package/dist/components/skeleton/index.js +6 -0
- package/dist/components/switch/index.cjs +68 -0
- package/dist/components/switch/index.d.cts +7 -0
- package/dist/components/switch/index.d.ts +7 -0
- package/dist/components/switch/index.js +7 -0
- package/dist/components/tabs/index.cjs +107 -0
- package/dist/components/tabs/index.d.cts +10 -0
- package/dist/components/tabs/index.d.ts +10 -0
- package/dist/components/tabs/index.js +13 -0
- package/dist/components/textarea/index.cjs +44 -0
- package/dist/components/textarea/index.d.cts +6 -0
- package/dist/components/textarea/index.d.ts +6 -0
- package/dist/components/textarea/index.js +6 -0
- package/dist/index.cjs +1275 -0
- package/dist/index.d.cts +46 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +298 -0
- package/eslint.config.js +4 -0
- package/package.json +67 -0
- package/postcss.config.mjs +6 -0
- package/registry.json +51 -0
- package/src/components/avatar/config.ts +46 -0
- package/src/components/avatar/index.tsx +53 -0
- package/src/components/badge/config.ts +56 -0
- package/src/components/badge/index.tsx +46 -0
- package/src/components/breadcrumb/config.ts +121 -0
- package/src/components/breadcrumb/index.tsx +109 -0
- package/src/components/button/config.ts +76 -0
- package/src/components/button/index.tsx +62 -0
- package/src/components/card/config.ts +89 -0
- package/src/components/card/index.tsx +83 -0
- package/src/components/checkbox/config.ts +46 -0
- package/src/components/checkbox/index.tsx +32 -0
- package/src/components/dialog/config.ts +582 -0
- package/src/components/dialog/index.tsx +143 -0
- package/src/components/dropdown/config.ts +262 -0
- package/src/components/dropdown/index.tsx +257 -0
- package/src/components/input/config.ts +64 -0
- package/src/components/input/index.tsx +25 -0
- package/src/components/label/config.ts +72 -0
- package/src/components/label/index.tsx +24 -0
- package/src/components/popover/config.ts +219 -0
- package/src/components/popover/index.tsx +48 -0
- package/src/components/radio-group/config.ts +303 -0
- package/src/components/radio-group/index.tsx +45 -0
- package/src/components/select/config.ts +277 -0
- package/src/components/select/index.tsx +185 -0
- package/src/components/separator/config.ts +63 -0
- package/src/components/separator/index.tsx +28 -0
- package/src/components/skeleton/config.ts +77 -0
- package/src/components/skeleton/index.tsx +13 -0
- package/src/components/switch/config.ts +165 -0
- package/src/components/switch/index.tsx +31 -0
- package/src/components/tabs/config.ts +335 -0
- package/src/components/tabs/index.tsx +66 -0
- package/src/components/textarea/config.ts +117 -0
- package/src/components/textarea/index.tsx +18 -0
- package/src/index.ts +87 -0
- package/tsconfig.json +9 -0
- package/tsconfig.lint.json +8 -0
- package/tsup.config.ts +29 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog"
|
|
5
|
+
import { XIcon } from "lucide-react"
|
|
6
|
+
|
|
7
|
+
import { cn } from "@foundrykit/utils"
|
|
8
|
+
|
|
9
|
+
function Dialog({
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
|
12
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function DialogTrigger({
|
|
16
|
+
...props
|
|
17
|
+
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
|
18
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function DialogPortal({
|
|
22
|
+
...props
|
|
23
|
+
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
|
24
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function DialogClose({
|
|
28
|
+
...props
|
|
29
|
+
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
|
30
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function DialogOverlay({
|
|
34
|
+
className,
|
|
35
|
+
...props
|
|
36
|
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
37
|
+
return (
|
|
38
|
+
<DialogPrimitive.Overlay
|
|
39
|
+
data-slot="dialog-overlay"
|
|
40
|
+
className={cn(
|
|
41
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
42
|
+
className
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function DialogContent({
|
|
50
|
+
className,
|
|
51
|
+
children,
|
|
52
|
+
showCloseButton = true,
|
|
53
|
+
...props
|
|
54
|
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
55
|
+
showCloseButton?: boolean
|
|
56
|
+
}) {
|
|
57
|
+
return (
|
|
58
|
+
<DialogPortal data-slot="dialog-portal">
|
|
59
|
+
<DialogOverlay />
|
|
60
|
+
<DialogPrimitive.Content
|
|
61
|
+
data-slot="dialog-content"
|
|
62
|
+
className={cn(
|
|
63
|
+
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
|
|
64
|
+
className
|
|
65
|
+
)}
|
|
66
|
+
{...props}
|
|
67
|
+
>
|
|
68
|
+
{children}
|
|
69
|
+
{showCloseButton && (
|
|
70
|
+
<DialogPrimitive.Close
|
|
71
|
+
data-slot="dialog-close"
|
|
72
|
+
className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
|
73
|
+
>
|
|
74
|
+
<XIcon />
|
|
75
|
+
<span className="sr-only">Close</span>
|
|
76
|
+
</DialogPrimitive.Close>
|
|
77
|
+
)}
|
|
78
|
+
</DialogPrimitive.Content>
|
|
79
|
+
</DialogPortal>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
84
|
+
return (
|
|
85
|
+
<div
|
|
86
|
+
data-slot="dialog-header"
|
|
87
|
+
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
|
|
88
|
+
{...props}
|
|
89
|
+
/>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
94
|
+
return (
|
|
95
|
+
<div
|
|
96
|
+
data-slot="dialog-footer"
|
|
97
|
+
className={cn(
|
|
98
|
+
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
99
|
+
className
|
|
100
|
+
)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function DialogTitle({
|
|
107
|
+
className,
|
|
108
|
+
...props
|
|
109
|
+
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
|
110
|
+
return (
|
|
111
|
+
<DialogPrimitive.Title
|
|
112
|
+
data-slot="dialog-title"
|
|
113
|
+
className={cn("text-lg leading-none font-semibold", className)}
|
|
114
|
+
{...props}
|
|
115
|
+
/>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function DialogDescription({
|
|
120
|
+
className,
|
|
121
|
+
...props
|
|
122
|
+
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
|
123
|
+
return (
|
|
124
|
+
<DialogPrimitive.Description
|
|
125
|
+
data-slot="dialog-description"
|
|
126
|
+
className={cn("text-muted-foreground text-sm", className)}
|
|
127
|
+
{...props}
|
|
128
|
+
/>
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export {
|
|
133
|
+
Dialog,
|
|
134
|
+
DialogClose,
|
|
135
|
+
DialogContent,
|
|
136
|
+
DialogDescription,
|
|
137
|
+
DialogFooter,
|
|
138
|
+
DialogHeader,
|
|
139
|
+
DialogOverlay,
|
|
140
|
+
DialogPortal,
|
|
141
|
+
DialogTitle,
|
|
142
|
+
DialogTrigger,
|
|
143
|
+
}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const dropdownConfig: ComponentConfig = {
|
|
4
|
+
name: 'Dropdown Menu',
|
|
5
|
+
description:
|
|
6
|
+
'Accessible dropdown menu component with multiple subcomponents for building complex menus',
|
|
7
|
+
category: 'primitives',
|
|
8
|
+
tags: ['navigation', 'interactive', 'menu'],
|
|
9
|
+
preview: {
|
|
10
|
+
type: 'static',
|
|
11
|
+
html: '<div class="flex h-12 w-full items-center justify-center rounded-md bg-gray-200"><div class="relative"><button class="px-3 py-1.5 bg-white border border-gray-300 rounded text-sm">Menu ▼</button><div class="absolute top-full mt-1 w-32 bg-white border border-gray-300 rounded shadow-lg"><div class="px-2 py-1.5 text-sm">Item 1</div><div class="px-2 py-1.5 text-sm">Item 2</div></div></div></div>',
|
|
12
|
+
},
|
|
13
|
+
variants: [
|
|
14
|
+
{
|
|
15
|
+
name: 'Basic Menu',
|
|
16
|
+
description: 'Simple dropdown menu with basic items',
|
|
17
|
+
code: `<DropdownMenu>
|
|
18
|
+
<DropdownMenuTrigger>Open Menu</DropdownMenuTrigger>
|
|
19
|
+
<DropdownMenuContent>
|
|
20
|
+
<DropdownMenuItem>Item 1</DropdownMenuItem>
|
|
21
|
+
<DropdownMenuItem>Item 2</DropdownMenuItem>
|
|
22
|
+
<DropdownMenuItem>Item 3</DropdownMenuItem>
|
|
23
|
+
</DropdownMenuContent>
|
|
24
|
+
</DropdownMenu>`,
|
|
25
|
+
preview: {
|
|
26
|
+
type: 'component',
|
|
27
|
+
component: 'DropdownMenu',
|
|
28
|
+
props: {
|
|
29
|
+
defaultOpen: false,
|
|
30
|
+
children: [
|
|
31
|
+
{
|
|
32
|
+
component: 'DropdownMenuTrigger',
|
|
33
|
+
props: { children: 'Open Menu' },
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
component: 'DropdownMenuContent',
|
|
37
|
+
props: {
|
|
38
|
+
children: [
|
|
39
|
+
{
|
|
40
|
+
component: 'DropdownMenuItem',
|
|
41
|
+
props: { children: 'Item 1' },
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
component: 'DropdownMenuItem',
|
|
45
|
+
props: { children: 'Item 2' },
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
component: 'DropdownMenuItem',
|
|
49
|
+
props: { children: 'Item 3' },
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'With Separator',
|
|
60
|
+
description: 'Dropdown menu with separator between items',
|
|
61
|
+
code: `<DropdownMenu>
|
|
62
|
+
<DropdownMenuTrigger>Open Menu</DropdownMenuTrigger>
|
|
63
|
+
<DropdownMenuContent>
|
|
64
|
+
<DropdownMenuItem>Item 1</DropdownMenuItem>
|
|
65
|
+
<DropdownMenuItem>Item 2</DropdownMenuItem>
|
|
66
|
+
<DropdownMenuSeparator />
|
|
67
|
+
<DropdownMenuItem>Item 3</DropdownMenuItem>
|
|
68
|
+
</DropdownMenuContent>
|
|
69
|
+
</DropdownMenu>`,
|
|
70
|
+
preview: {
|
|
71
|
+
type: 'component',
|
|
72
|
+
component: 'DropdownMenu',
|
|
73
|
+
props: {
|
|
74
|
+
defaultOpen: false,
|
|
75
|
+
children: [
|
|
76
|
+
{
|
|
77
|
+
component: 'DropdownMenuTrigger',
|
|
78
|
+
props: { children: 'Open Menu' },
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
component: 'DropdownMenuContent',
|
|
82
|
+
props: {
|
|
83
|
+
children: [
|
|
84
|
+
{
|
|
85
|
+
component: 'DropdownMenuItem',
|
|
86
|
+
props: { children: 'Item 1' },
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
component: 'DropdownMenuItem',
|
|
90
|
+
props: { children: 'Item 2' },
|
|
91
|
+
},
|
|
92
|
+
{ component: 'DropdownMenuSeparator', props: {} },
|
|
93
|
+
{
|
|
94
|
+
component: 'DropdownMenuItem',
|
|
95
|
+
props: { children: 'Item 3' },
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'With Checkbox Items',
|
|
106
|
+
description: 'Dropdown menu with checkbox items for multiple selection',
|
|
107
|
+
code: `<DropdownMenu>
|
|
108
|
+
<DropdownMenuTrigger>Options</DropdownMenuTrigger>
|
|
109
|
+
<DropdownMenuContent>
|
|
110
|
+
<DropdownMenuCheckboxItem checked>Option 1</DropdownMenuCheckboxItem>
|
|
111
|
+
<DropdownMenuCheckboxItem>Option 2</DropdownMenuCheckboxItem>
|
|
112
|
+
<DropdownMenuCheckboxItem>Option 3</DropdownMenuCheckboxItem>
|
|
113
|
+
</DropdownMenuContent>
|
|
114
|
+
</DropdownMenu>`,
|
|
115
|
+
preview: {
|
|
116
|
+
type: 'component',
|
|
117
|
+
component: 'DropdownMenu',
|
|
118
|
+
props: {
|
|
119
|
+
defaultOpen: false,
|
|
120
|
+
children: [
|
|
121
|
+
{
|
|
122
|
+
component: 'DropdownMenuTrigger',
|
|
123
|
+
props: { children: 'Options' },
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
component: 'DropdownMenuContent',
|
|
127
|
+
props: {
|
|
128
|
+
children: [
|
|
129
|
+
{
|
|
130
|
+
component: 'DropdownMenuCheckboxItem',
|
|
131
|
+
props: { checked: true, children: 'Option 1' },
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
component: 'DropdownMenuCheckboxItem',
|
|
135
|
+
props: { children: 'Option 2' },
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
component: 'DropdownMenuCheckboxItem',
|
|
139
|
+
props: { children: 'Option 3' },
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'With Destructive Item',
|
|
150
|
+
description: 'Dropdown menu with destructive action item',
|
|
151
|
+
code: `<DropdownMenu>
|
|
152
|
+
<DropdownMenuTrigger>Actions</DropdownMenuTrigger>
|
|
153
|
+
<DropdownMenuContent>
|
|
154
|
+
<DropdownMenuItem>Edit</DropdownMenuItem>
|
|
155
|
+
<DropdownMenuItem>Copy</DropdownMenuItem>
|
|
156
|
+
<DropdownMenuItem variant="destructive">Delete</DropdownMenuItem>
|
|
157
|
+
</DropdownMenuContent>
|
|
158
|
+
</DropdownMenu>`,
|
|
159
|
+
preview: {
|
|
160
|
+
type: 'component',
|
|
161
|
+
component: 'DropdownMenu',
|
|
162
|
+
props: {
|
|
163
|
+
defaultOpen: false,
|
|
164
|
+
children: [
|
|
165
|
+
{
|
|
166
|
+
component: 'DropdownMenuTrigger',
|
|
167
|
+
props: { children: 'Actions' },
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
component: 'DropdownMenuContent',
|
|
171
|
+
props: {
|
|
172
|
+
children: [
|
|
173
|
+
{
|
|
174
|
+
component: 'DropdownMenuItem',
|
|
175
|
+
props: { children: 'Edit' },
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
component: 'DropdownMenuItem',
|
|
179
|
+
props: { children: 'Copy' },
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
component: 'DropdownMenuItem',
|
|
183
|
+
props: { variant: 'destructive', children: 'Delete' },
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: 'With Submenu',
|
|
194
|
+
description: 'Dropdown menu with nested submenu',
|
|
195
|
+
code: `<DropdownMenu>
|
|
196
|
+
<DropdownMenuTrigger>More Options</DropdownMenuTrigger>
|
|
197
|
+
<DropdownMenuContent>
|
|
198
|
+
<DropdownMenuItem>Item 1</DropdownMenuItem>
|
|
199
|
+
<DropdownMenuSub>
|
|
200
|
+
<DropdownMenuSubTrigger>More</DropdownMenuSubTrigger>
|
|
201
|
+
<DropdownMenuSubContent>
|
|
202
|
+
<DropdownMenuItem>Sub Item 1</DropdownMenuItem>
|
|
203
|
+
<DropdownMenuItem>Sub Item 2</DropdownMenuItem>
|
|
204
|
+
</DropdownMenuSubContent>
|
|
205
|
+
</DropdownMenuSub>
|
|
206
|
+
</DropdownMenuContent>
|
|
207
|
+
</DropdownMenu>`,
|
|
208
|
+
preview: {
|
|
209
|
+
type: 'component',
|
|
210
|
+
component: 'DropdownMenu',
|
|
211
|
+
props: {
|
|
212
|
+
defaultOpen: false,
|
|
213
|
+
children: [
|
|
214
|
+
{
|
|
215
|
+
component: 'DropdownMenuTrigger',
|
|
216
|
+
props: { children: 'More Options' },
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
component: 'DropdownMenuContent',
|
|
220
|
+
props: {
|
|
221
|
+
children: [
|
|
222
|
+
{
|
|
223
|
+
component: 'DropdownMenuItem',
|
|
224
|
+
props: { children: 'Item 1' },
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
component: 'DropdownMenuSub',
|
|
228
|
+
props: {
|
|
229
|
+
children: [
|
|
230
|
+
{
|
|
231
|
+
component: 'DropdownMenuSubTrigger',
|
|
232
|
+
props: { children: 'More' },
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
component: 'DropdownMenuSubContent',
|
|
236
|
+
props: {
|
|
237
|
+
children: [
|
|
238
|
+
{
|
|
239
|
+
component: 'DropdownMenuItem',
|
|
240
|
+
props: { children: 'Sub Item 1' },
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
component: 'DropdownMenuItem',
|
|
244
|
+
props: { children: 'Sub Item 2' },
|
|
245
|
+
},
|
|
246
|
+
],
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
],
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
],
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
],
|
|
260
|
+
dependencies: ['utils'],
|
|
261
|
+
files: ['components/primitives/dropdown/index.tsx'],
|
|
262
|
+
};
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
5
|
+
import { CheckIcon, ChevronRightIcon, CircleIcon } from 'lucide-react';
|
|
6
|
+
|
|
7
|
+
import { cn } from '@foundrykit/utils';
|
|
8
|
+
|
|
9
|
+
function DropdownMenu({
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
|
12
|
+
return <DropdownMenuPrimitive.Root data-slot='dropdown-menu' {...props} />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function DropdownMenuPortal({
|
|
16
|
+
...props
|
|
17
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
|
|
18
|
+
return (
|
|
19
|
+
<DropdownMenuPrimitive.Portal data-slot='dropdown-menu-portal' {...props} />
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function DropdownMenuTrigger({
|
|
24
|
+
...props
|
|
25
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
|
|
26
|
+
return (
|
|
27
|
+
<DropdownMenuPrimitive.Trigger
|
|
28
|
+
data-slot='dropdown-menu-trigger'
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function DropdownMenuContent({
|
|
35
|
+
className,
|
|
36
|
+
sideOffset = 4,
|
|
37
|
+
...props
|
|
38
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
|
|
39
|
+
return (
|
|
40
|
+
<DropdownMenuPrimitive.Portal>
|
|
41
|
+
<DropdownMenuPrimitive.Content
|
|
42
|
+
data-slot='dropdown-menu-content'
|
|
43
|
+
sideOffset={sideOffset}
|
|
44
|
+
className={cn(
|
|
45
|
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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 max-h-(--radix-dropdown-menu-content-available-height) origin-(--radix-dropdown-menu-content-transform-origin) z-50 min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border p-1 shadow-md',
|
|
46
|
+
className
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
</DropdownMenuPrimitive.Portal>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function DropdownMenuGroup({
|
|
55
|
+
...props
|
|
56
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
|
|
57
|
+
return (
|
|
58
|
+
<DropdownMenuPrimitive.Group data-slot='dropdown-menu-group' {...props} />
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function DropdownMenuItem({
|
|
63
|
+
className,
|
|
64
|
+
inset,
|
|
65
|
+
variant = 'default',
|
|
66
|
+
...props
|
|
67
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
|
68
|
+
inset?: boolean;
|
|
69
|
+
variant?: 'default' | 'destructive';
|
|
70
|
+
}) {
|
|
71
|
+
return (
|
|
72
|
+
<DropdownMenuPrimitive.Item
|
|
73
|
+
data-slot='dropdown-menu-item'
|
|
74
|
+
data-inset={inset}
|
|
75
|
+
data-variant={variant}
|
|
76
|
+
className={cn(
|
|
77
|
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
78
|
+
className
|
|
79
|
+
)}
|
|
80
|
+
{...props}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function DropdownMenuCheckboxItem({
|
|
86
|
+
className,
|
|
87
|
+
children,
|
|
88
|
+
checked,
|
|
89
|
+
...props
|
|
90
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {
|
|
91
|
+
return (
|
|
92
|
+
<DropdownMenuPrimitive.CheckboxItem
|
|
93
|
+
data-slot='dropdown-menu-checkbox-item'
|
|
94
|
+
className={cn(
|
|
95
|
+
"focus:bg-accent focus:text-accent-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 pl-8 pr-2 text-sm data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
96
|
+
className
|
|
97
|
+
)}
|
|
98
|
+
checked={checked}
|
|
99
|
+
{...props}
|
|
100
|
+
>
|
|
101
|
+
<span className='pointer-events-none absolute left-2 flex size-3.5 items-center justify-center'>
|
|
102
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
103
|
+
<CheckIcon className='size-4' />
|
|
104
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
105
|
+
</span>
|
|
106
|
+
{children}
|
|
107
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function DropdownMenuRadioGroup({
|
|
112
|
+
...props
|
|
113
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
|
|
114
|
+
return (
|
|
115
|
+
<DropdownMenuPrimitive.RadioGroup
|
|
116
|
+
data-slot='dropdown-menu-radio-group'
|
|
117
|
+
{...props}
|
|
118
|
+
/>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function DropdownMenuRadioItem({
|
|
123
|
+
className,
|
|
124
|
+
children,
|
|
125
|
+
...props
|
|
126
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {
|
|
127
|
+
return (
|
|
128
|
+
<DropdownMenuPrimitive.RadioItem
|
|
129
|
+
data-slot='dropdown-menu-radio-item'
|
|
130
|
+
className={cn(
|
|
131
|
+
"focus:bg-accent focus:text-accent-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 pl-8 pr-2 text-sm data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
132
|
+
className
|
|
133
|
+
)}
|
|
134
|
+
{...props}
|
|
135
|
+
>
|
|
136
|
+
<span className='pointer-events-none absolute left-2 flex size-3.5 items-center justify-center'>
|
|
137
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
138
|
+
<CircleIcon className='size-2 fill-current' />
|
|
139
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
140
|
+
</span>
|
|
141
|
+
{children}
|
|
142
|
+
</DropdownMenuPrimitive.RadioItem>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function DropdownMenuLabel({
|
|
147
|
+
className,
|
|
148
|
+
inset,
|
|
149
|
+
...props
|
|
150
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
|
|
151
|
+
inset?: boolean;
|
|
152
|
+
}) {
|
|
153
|
+
return (
|
|
154
|
+
<DropdownMenuPrimitive.Label
|
|
155
|
+
data-slot='dropdown-menu-label'
|
|
156
|
+
data-inset={inset}
|
|
157
|
+
className={cn(
|
|
158
|
+
'px-2 py-1.5 text-sm font-medium data-[inset]:pl-8',
|
|
159
|
+
className
|
|
160
|
+
)}
|
|
161
|
+
{...props}
|
|
162
|
+
/>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function DropdownMenuSeparator({
|
|
167
|
+
className,
|
|
168
|
+
...props
|
|
169
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
|
|
170
|
+
return (
|
|
171
|
+
<DropdownMenuPrimitive.Separator
|
|
172
|
+
data-slot='dropdown-menu-separator'
|
|
173
|
+
className={cn('bg-border -mx-1 my-1 h-px', className)}
|
|
174
|
+
{...props}
|
|
175
|
+
/>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function DropdownMenuShortcut({
|
|
180
|
+
className,
|
|
181
|
+
...props
|
|
182
|
+
}: React.ComponentProps<'span'>) {
|
|
183
|
+
return (
|
|
184
|
+
<span
|
|
185
|
+
data-slot='dropdown-menu-shortcut'
|
|
186
|
+
className={cn(
|
|
187
|
+
'text-muted-foreground ml-auto text-xs tracking-widest',
|
|
188
|
+
className
|
|
189
|
+
)}
|
|
190
|
+
{...props}
|
|
191
|
+
/>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function DropdownMenuSub({
|
|
196
|
+
...props
|
|
197
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
|
|
198
|
+
return <DropdownMenuPrimitive.Sub data-slot='dropdown-menu-sub' {...props} />;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function DropdownMenuSubTrigger({
|
|
202
|
+
className,
|
|
203
|
+
inset,
|
|
204
|
+
children,
|
|
205
|
+
...props
|
|
206
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
207
|
+
inset?: boolean;
|
|
208
|
+
}) {
|
|
209
|
+
return (
|
|
210
|
+
<DropdownMenuPrimitive.SubTrigger
|
|
211
|
+
data-slot='dropdown-menu-sub-trigger'
|
|
212
|
+
data-inset={inset}
|
|
213
|
+
className={cn(
|
|
214
|
+
'focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground outline-hidden flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm data-[inset]:pl-8',
|
|
215
|
+
className
|
|
216
|
+
)}
|
|
217
|
+
{...props}
|
|
218
|
+
>
|
|
219
|
+
{children}
|
|
220
|
+
<ChevronRightIcon className='ml-auto size-4' />
|
|
221
|
+
</DropdownMenuPrimitive.SubTrigger>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function DropdownMenuSubContent({
|
|
226
|
+
className,
|
|
227
|
+
...props
|
|
228
|
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
|
|
229
|
+
return (
|
|
230
|
+
<DropdownMenuPrimitive.SubContent
|
|
231
|
+
data-slot='dropdown-menu-sub-content'
|
|
232
|
+
className={cn(
|
|
233
|
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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 origin-(--radix-dropdown-menu-content-transform-origin) z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg',
|
|
234
|
+
className
|
|
235
|
+
)}
|
|
236
|
+
{...props}
|
|
237
|
+
/>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export {
|
|
242
|
+
DropdownMenu,
|
|
243
|
+
DropdownMenuPortal,
|
|
244
|
+
DropdownMenuTrigger,
|
|
245
|
+
DropdownMenuContent,
|
|
246
|
+
DropdownMenuGroup,
|
|
247
|
+
DropdownMenuLabel,
|
|
248
|
+
DropdownMenuItem,
|
|
249
|
+
DropdownMenuCheckboxItem,
|
|
250
|
+
DropdownMenuRadioGroup,
|
|
251
|
+
DropdownMenuRadioItem,
|
|
252
|
+
DropdownMenuSeparator,
|
|
253
|
+
DropdownMenuShortcut,
|
|
254
|
+
DropdownMenuSub,
|
|
255
|
+
DropdownMenuSubTrigger,
|
|
256
|
+
DropdownMenuSubContent,
|
|
257
|
+
};
|