@gunjo/ui 0.0.1-alpha.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/README.md +129 -0
- package/design/atoms-metadata.json +82 -0
- package/design/molecules-metadata.json +130 -0
- package/design/organisms-metadata.json +38 -0
- package/design/templates-metadata.json +38 -0
- package/package.json +158 -0
- package/src/components/atoms/Alert.tsx +63 -0
- package/src/components/atoms/Avatar.tsx +57 -0
- package/src/components/atoms/Badge.tsx +30 -0
- package/src/components/atoms/Button.tsx +29 -0
- package/src/components/atoms/ButtonVariants.ts +37 -0
- package/src/components/atoms/Checkbox.tsx +52 -0
- package/src/components/atoms/Img.tsx +102 -0
- package/src/components/atoms/Input.tsx +37 -0
- package/src/components/atoms/Kbd.tsx +22 -0
- package/src/components/atoms/Label.tsx +22 -0
- package/src/components/atoms/Progress.tsx +38 -0
- package/src/components/atoms/RadioGroup.tsx +86 -0
- package/src/components/atoms/Select.tsx +28 -0
- package/src/components/atoms/Separator.tsx +33 -0
- package/src/components/atoms/Skeleton.tsx +36 -0
- package/src/components/atoms/Slider.tsx +26 -0
- package/src/components/atoms/Spinner.tsx +34 -0
- package/src/components/atoms/Switch.tsx +47 -0
- package/src/components/atoms/Textarea.tsx +34 -0
- package/src/components/atoms/ToggleGroup.tsx +60 -0
- package/src/components/atoms/ToolPill.tsx +77 -0
- package/src/components/atoms/generated/default-variant-keys.ts +36 -0
- package/src/components/atoms/generated/variant-keys.ts +61 -0
- package/src/components/generated/component-manifest.ts +741 -0
- package/src/components/generated/component-style-hints.ts +1262 -0
- package/src/components/molecules/AIChatInput.tsx +140 -0
- package/src/components/molecules/AIChatMessage.tsx +109 -0
- package/src/components/molecules/Accordion.tsx +99 -0
- package/src/components/molecules/Breadcrumb.tsx +115 -0
- package/src/components/molecules/Calendar.tsx +60 -0
- package/src/components/molecules/Card.tsx +78 -0
- package/src/components/molecules/Carousel.tsx +261 -0
- package/src/components/molecules/Command.tsx +152 -0
- package/src/components/molecules/ContextMenu.tsx +200 -0
- package/src/components/molecules/Dialog.tsx +122 -0
- package/src/components/molecules/DropdownMenu.tsx +200 -0
- package/src/components/molecules/FilterButton.tsx +133 -0
- package/src/components/molecules/Form.tsx +90 -0
- package/src/components/molecules/HoverCard.tsx +29 -0
- package/src/components/molecules/List.tsx +120 -0
- package/src/components/molecules/Menubar.tsx +231 -0
- package/src/components/molecules/Modal.tsx +66 -0
- package/src/components/molecules/NotificationCenter.tsx +118 -0
- package/src/components/molecules/Pagination.tsx +118 -0
- package/src/components/molecules/Popover.tsx +31 -0
- package/src/components/molecules/ProgressWidget.tsx +40 -0
- package/src/components/molecules/Resizable.tsx +47 -0
- package/src/components/molecules/ScrollArea.tsx +48 -0
- package/src/components/molecules/Sheet.tsx +140 -0
- package/src/components/molecules/SidebarItem.tsx +134 -0
- package/src/components/molecules/SortButton.tsx +56 -0
- package/src/components/molecules/StatusBar.tsx +41 -0
- package/src/components/molecules/Stepper.tsx +108 -0
- package/src/components/molecules/Table.tsx +117 -0
- package/src/components/molecules/Tabs.tsx +64 -0
- package/src/components/molecules/Toast.tsx +57 -0
- package/src/components/molecules/Tooltip.tsx +30 -0
- package/src/components/molecules/generated/default-variant-keys.ts +22 -0
- package/src/components/molecules/generated/variant-keys.ts +33 -0
- package/src/components/organisms/AppRail.tsx +28 -0
- package/src/components/organisms/CommandPalette.tsx +58 -0
- package/src/components/organisms/FileUploader.tsx +151 -0
- package/src/components/organisms/FloatingPanel.tsx +46 -0
- package/src/components/organisms/InspectorPanel.tsx +65 -0
- package/src/components/organisms/RightRail.tsx +29 -0
- package/src/components/organisms/ShareModal.tsx +182 -0
- package/src/components/organisms/SpatialCanvas.tsx +36 -0
- package/src/components/organisms/ToastProvider.tsx +49 -0
- package/src/components/templates/AuthTemplate.tsx +58 -0
- package/src/components/templates/BannalyzeTemplate.tsx +55 -0
- package/src/components/templates/ChatTemplate.tsx +55 -0
- package/src/components/templates/DashboardTemplate.tsx +34 -0
- package/src/components/templates/EditorTemplate.tsx +46 -0
- package/src/components/templates/KanbanTemplate.tsx +38 -0
- package/src/components/templates/LandingTemplate.tsx +53 -0
- package/src/components/templates/MediaLibraryTemplate.tsx +55 -0
- package/src/components/templates/SettingsTemplate.tsx +48 -0
- package/src/globals.css +108 -0
- package/src/index.ts +89 -0
- package/src/lib/utils.ts +6 -0
- package/tailwind-preset.js +11 -0
- package/tailwind-theme-extend.cjs +86 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog"
|
|
5
|
+
import { X } from "lucide-react"
|
|
6
|
+
|
|
7
|
+
import { cn } from "../../lib/utils"
|
|
8
|
+
|
|
9
|
+
const Dialog = DialogPrimitive.Root
|
|
10
|
+
|
|
11
|
+
const DialogTrigger = DialogPrimitive.Trigger
|
|
12
|
+
|
|
13
|
+
const DialogPortal = DialogPrimitive.Portal
|
|
14
|
+
|
|
15
|
+
const DialogClose = DialogPrimitive.Close
|
|
16
|
+
|
|
17
|
+
const DialogOverlay = React.forwardRef<
|
|
18
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
19
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
20
|
+
>(({ className, ...props }, ref) => (
|
|
21
|
+
<DialogPrimitive.Overlay
|
|
22
|
+
ref={ref}
|
|
23
|
+
className={cn(
|
|
24
|
+
"fixed inset-0 z-50 bg-overlay/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
25
|
+
className
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
))
|
|
30
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
|
|
31
|
+
|
|
32
|
+
const DialogContent = React.forwardRef<
|
|
33
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
34
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
35
|
+
>(({ className, children, ...props }, ref) => (
|
|
36
|
+
<DialogPortal>
|
|
37
|
+
<DialogOverlay />
|
|
38
|
+
<DialogPrimitive.Content
|
|
39
|
+
ref={ref}
|
|
40
|
+
className={cn(
|
|
41
|
+
"fixed left-[50%] top-[50%] z-50 grid w-[512px] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
42
|
+
className
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
>
|
|
46
|
+
{children}
|
|
47
|
+
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
|
48
|
+
<X className="h-4 w-4" />
|
|
49
|
+
<span className="sr-only">Close</span>
|
|
50
|
+
</DialogPrimitive.Close>
|
|
51
|
+
</DialogPrimitive.Content>
|
|
52
|
+
</DialogPortal>
|
|
53
|
+
))
|
|
54
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName
|
|
55
|
+
|
|
56
|
+
const DialogHeader = ({
|
|
57
|
+
className,
|
|
58
|
+
...props
|
|
59
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
60
|
+
<div
|
|
61
|
+
className={cn(
|
|
62
|
+
"flex flex-col space-y-1.5 text-center sm:text-left",
|
|
63
|
+
className
|
|
64
|
+
)}
|
|
65
|
+
{...props}
|
|
66
|
+
/>
|
|
67
|
+
)
|
|
68
|
+
DialogHeader.displayName = "DialogHeader"
|
|
69
|
+
|
|
70
|
+
const DialogFooter = ({
|
|
71
|
+
className,
|
|
72
|
+
...props
|
|
73
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
74
|
+
<div
|
|
75
|
+
className={cn(
|
|
76
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
77
|
+
className
|
|
78
|
+
)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
)
|
|
82
|
+
DialogFooter.displayName = "DialogFooter"
|
|
83
|
+
|
|
84
|
+
const DialogTitle = React.forwardRef<
|
|
85
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
86
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
87
|
+
>(({ className, ...props }, ref) => (
|
|
88
|
+
<DialogPrimitive.Title
|
|
89
|
+
ref={ref}
|
|
90
|
+
className={cn(
|
|
91
|
+
"text-lg font-semibold leading-none tracking-tight",
|
|
92
|
+
className
|
|
93
|
+
)}
|
|
94
|
+
{...props}
|
|
95
|
+
/>
|
|
96
|
+
))
|
|
97
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName
|
|
98
|
+
|
|
99
|
+
const DialogDescription = React.forwardRef<
|
|
100
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
101
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
102
|
+
>(({ className, ...props }, ref) => (
|
|
103
|
+
<DialogPrimitive.Description
|
|
104
|
+
ref={ref}
|
|
105
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
106
|
+
{...props}
|
|
107
|
+
/>
|
|
108
|
+
))
|
|
109
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName
|
|
110
|
+
|
|
111
|
+
export {
|
|
112
|
+
Dialog,
|
|
113
|
+
DialogPortal,
|
|
114
|
+
DialogOverlay,
|
|
115
|
+
DialogClose,
|
|
116
|
+
DialogTrigger,
|
|
117
|
+
DialogContent,
|
|
118
|
+
DialogHeader,
|
|
119
|
+
DialogFooter,
|
|
120
|
+
DialogTitle,
|
|
121
|
+
DialogDescription,
|
|
122
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
|
|
5
|
+
import { Check, ChevronRight, Circle } from "lucide-react"
|
|
6
|
+
|
|
7
|
+
import { cn } from "../../lib/utils"
|
|
8
|
+
|
|
9
|
+
const DropdownMenu = DropdownMenuPrimitive.Root
|
|
10
|
+
|
|
11
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
|
|
12
|
+
|
|
13
|
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group
|
|
14
|
+
|
|
15
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal
|
|
16
|
+
|
|
17
|
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub
|
|
18
|
+
|
|
19
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
|
|
20
|
+
|
|
21
|
+
const DropdownMenuSubTrigger = React.forwardRef<
|
|
22
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
|
23
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
24
|
+
inset?: boolean
|
|
25
|
+
}
|
|
26
|
+
>(({ className, inset, children, ...props }, ref) => (
|
|
27
|
+
<DropdownMenuPrimitive.SubTrigger
|
|
28
|
+
ref={ref}
|
|
29
|
+
className={cn(
|
|
30
|
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent/50",
|
|
31
|
+
inset && "pl-8",
|
|
32
|
+
className
|
|
33
|
+
)}
|
|
34
|
+
{...props}
|
|
35
|
+
>
|
|
36
|
+
{children}
|
|
37
|
+
<ChevronRight className="ml-auto h-4 w-4" />
|
|
38
|
+
</DropdownMenuPrimitive.SubTrigger>
|
|
39
|
+
))
|
|
40
|
+
DropdownMenuSubTrigger.displayName =
|
|
41
|
+
DropdownMenuPrimitive.SubTrigger.displayName
|
|
42
|
+
|
|
43
|
+
const DropdownMenuSubContent = React.forwardRef<
|
|
44
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
|
45
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
|
46
|
+
>(({ className, ...props }, ref) => (
|
|
47
|
+
<DropdownMenuPrimitive.SubContent
|
|
48
|
+
ref={ref}
|
|
49
|
+
className={cn(
|
|
50
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",
|
|
51
|
+
className
|
|
52
|
+
)}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
))
|
|
56
|
+
DropdownMenuSubContent.displayName =
|
|
57
|
+
DropdownMenuPrimitive.SubContent.displayName
|
|
58
|
+
|
|
59
|
+
const DropdownMenuContent = React.forwardRef<
|
|
60
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
|
61
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
|
62
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
63
|
+
<DropdownMenuPrimitive.Portal>
|
|
64
|
+
<DropdownMenuPrimitive.Content
|
|
65
|
+
ref={ref}
|
|
66
|
+
sideOffset={sideOffset}
|
|
67
|
+
className={cn(
|
|
68
|
+
"z-50 flex flex-col w-[180px] min-w-[8rem] overflow-hidden rounded-md rounded-lg border bg-popover p-1 text-popover-foreground shadow-md 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",
|
|
69
|
+
className
|
|
70
|
+
)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
</DropdownMenuPrimitive.Portal>
|
|
74
|
+
))
|
|
75
|
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
|
|
76
|
+
|
|
77
|
+
const DropdownMenuItem = React.forwardRef<
|
|
78
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
79
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
|
80
|
+
inset?: boolean
|
|
81
|
+
}
|
|
82
|
+
>(({ className, inset, ...props }, ref) => (
|
|
83
|
+
<DropdownMenuPrimitive.Item
|
|
84
|
+
ref={ref}
|
|
85
|
+
className={cn(
|
|
86
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
87
|
+
inset && "pl-8",
|
|
88
|
+
className
|
|
89
|
+
)}
|
|
90
|
+
{...props}
|
|
91
|
+
/>
|
|
92
|
+
))
|
|
93
|
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
|
|
94
|
+
|
|
95
|
+
const DropdownMenuCheckboxItem = React.forwardRef<
|
|
96
|
+
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
|
97
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
|
98
|
+
>(({ className, children, checked, ...props }, ref) => (
|
|
99
|
+
<DropdownMenuPrimitive.CheckboxItem
|
|
100
|
+
ref={ref}
|
|
101
|
+
className={cn(
|
|
102
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
103
|
+
className
|
|
104
|
+
)}
|
|
105
|
+
checked={checked}
|
|
106
|
+
{...props}
|
|
107
|
+
>
|
|
108
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
109
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
110
|
+
<Check className="h-4 w-4" />
|
|
111
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
112
|
+
</span>
|
|
113
|
+
{children}
|
|
114
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
|
115
|
+
))
|
|
116
|
+
DropdownMenuCheckboxItem.displayName =
|
|
117
|
+
DropdownMenuPrimitive.CheckboxItem.displayName
|
|
118
|
+
|
|
119
|
+
const DropdownMenuRadioItem = React.forwardRef<
|
|
120
|
+
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
|
121
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
|
|
122
|
+
>(({ className, children, ...props }, ref) => (
|
|
123
|
+
<DropdownMenuPrimitive.RadioItem
|
|
124
|
+
ref={ref}
|
|
125
|
+
className={cn(
|
|
126
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
127
|
+
className
|
|
128
|
+
)}
|
|
129
|
+
{...props}
|
|
130
|
+
>
|
|
131
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
132
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
133
|
+
<Circle className="h-2 w-2 fill-current" />
|
|
134
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
135
|
+
</span>
|
|
136
|
+
{children}
|
|
137
|
+
</DropdownMenuPrimitive.RadioItem>
|
|
138
|
+
))
|
|
139
|
+
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName
|
|
140
|
+
|
|
141
|
+
const DropdownMenuLabel = React.forwardRef<
|
|
142
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
|
143
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
|
144
|
+
inset?: boolean
|
|
145
|
+
}
|
|
146
|
+
>(({ className, inset, ...props }, ref) => (
|
|
147
|
+
<DropdownMenuPrimitive.Label
|
|
148
|
+
ref={ref}
|
|
149
|
+
className={cn(
|
|
150
|
+
"px-3 py-2 text-xs font-semibold text-muted-foreground",
|
|
151
|
+
inset && "pl-8",
|
|
152
|
+
className
|
|
153
|
+
)}
|
|
154
|
+
{...props}
|
|
155
|
+
/>
|
|
156
|
+
))
|
|
157
|
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
|
|
158
|
+
|
|
159
|
+
const DropdownMenuSeparator = React.forwardRef<
|
|
160
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
|
161
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
|
162
|
+
>(({ className, ...props }, ref) => (
|
|
163
|
+
<DropdownMenuPrimitive.Separator
|
|
164
|
+
ref={ref}
|
|
165
|
+
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
|
166
|
+
{...props}
|
|
167
|
+
/>
|
|
168
|
+
))
|
|
169
|
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
|
|
170
|
+
|
|
171
|
+
const DropdownMenuShortcut = ({
|
|
172
|
+
className,
|
|
173
|
+
...props
|
|
174
|
+
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
175
|
+
return (
|
|
176
|
+
<span
|
|
177
|
+
className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
|
|
178
|
+
{...props}
|
|
179
|
+
/>
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
DropdownMenuShortcut.displayName = "DropdownMenuShortcut"
|
|
183
|
+
|
|
184
|
+
export {
|
|
185
|
+
DropdownMenu,
|
|
186
|
+
DropdownMenuTrigger,
|
|
187
|
+
DropdownMenuContent,
|
|
188
|
+
DropdownMenuItem,
|
|
189
|
+
DropdownMenuCheckboxItem,
|
|
190
|
+
DropdownMenuRadioItem,
|
|
191
|
+
DropdownMenuLabel,
|
|
192
|
+
DropdownMenuSeparator,
|
|
193
|
+
DropdownMenuShortcut,
|
|
194
|
+
DropdownMenuGroup,
|
|
195
|
+
DropdownMenuPortal,
|
|
196
|
+
DropdownMenuSub,
|
|
197
|
+
DropdownMenuSubContent,
|
|
198
|
+
DropdownMenuSubTrigger,
|
|
199
|
+
DropdownMenuRadioGroup,
|
|
200
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Filter as FilterIcon, Check } from "lucide-react"
|
|
5
|
+
import { Button, ButtonProps } from "../atoms/Button"
|
|
6
|
+
import { Popover, PopoverTrigger, PopoverContent } from "./Popover"
|
|
7
|
+
import { Command, CommandGroup, CommandItem, CommandList } from "./Command"
|
|
8
|
+
import { cn } from "../../lib/utils"
|
|
9
|
+
import { Badge } from "../atoms/Badge"
|
|
10
|
+
import type { FilterButtonVariantKey } from "./generated/variant-keys"
|
|
11
|
+
import { filterButtonDefaultVariantKey } from "./generated/default-variant-keys"
|
|
12
|
+
|
|
13
|
+
export interface FilterOption {
|
|
14
|
+
label: string
|
|
15
|
+
value: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface FilterButtonProps extends ButtonProps {
|
|
19
|
+
title?: string
|
|
20
|
+
options: FilterOption[]
|
|
21
|
+
selectedValues: Set<string>
|
|
22
|
+
onFilterChange: (values: Set<string>) => void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const FilterButton = React.forwardRef<HTMLButtonElement, FilterButtonProps>(
|
|
26
|
+
({ className, title = "Filter", options, selectedValues, onFilterChange, variant = "outline", size = "sm", ...props }, ref) => {
|
|
27
|
+
const [isOpen, setIsOpen] = React.useState(false)
|
|
28
|
+
|
|
29
|
+
const triggerStyles: Record<FilterButtonVariantKey, string> = {
|
|
30
|
+
default: "flex flex-col items-center h-9 py-2 px-3 gap-2 rounded-md border border-dashed",
|
|
31
|
+
popover: "flex flex-col w-[200px] rounded-lg border border-primary/40 bg-primary/5 text-primary",
|
|
32
|
+
selected: "flex flex-col items-center h-9 py-2 px-3 gap-2 rounded-md border border-primary bg-primary/10 text-primary",
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const triggerVariant: FilterButtonVariantKey =
|
|
36
|
+
selectedValues.size > 0 ? "selected" : isOpen ? "popover" : filterButtonDefaultVariantKey
|
|
37
|
+
|
|
38
|
+
const handleSelect = (value: string) => {
|
|
39
|
+
const newSet = new Set(selectedValues)
|
|
40
|
+
if (newSet.has(value)) {
|
|
41
|
+
newSet.delete(value)
|
|
42
|
+
} else {
|
|
43
|
+
newSet.add(value)
|
|
44
|
+
}
|
|
45
|
+
onFilterChange(newSet)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Popover open={isOpen} onOpenChange={setIsOpen}>
|
|
50
|
+
<PopoverTrigger asChild>
|
|
51
|
+
<Button
|
|
52
|
+
ref={ref}
|
|
53
|
+
variant={variant}
|
|
54
|
+
size={size}
|
|
55
|
+
className={cn(triggerStyles[triggerVariant], className)}
|
|
56
|
+
{...props}
|
|
57
|
+
>
|
|
58
|
+
<FilterIcon className="h-4 w-4" />
|
|
59
|
+
<span>{title}</span>
|
|
60
|
+
{selectedValues.size > 0 && (
|
|
61
|
+
<>
|
|
62
|
+
<div className="hidden space-x-1 lg:flex bg-transparent">
|
|
63
|
+
{selectedValues.size > 2 ? (
|
|
64
|
+
<Badge variant="secondary" className="rounded-sm px-1 font-normal">
|
|
65
|
+
{selectedValues.size} selected
|
|
66
|
+
</Badge>
|
|
67
|
+
) : (
|
|
68
|
+
options
|
|
69
|
+
.filter((option) => selectedValues.has(option.value))
|
|
70
|
+
.map((option) => (
|
|
71
|
+
<Badge
|
|
72
|
+
key={option.value}
|
|
73
|
+
variant="secondary"
|
|
74
|
+
className="rounded-sm px-1 font-normal text-[10px]"
|
|
75
|
+
>
|
|
76
|
+
{option.label}
|
|
77
|
+
</Badge>
|
|
78
|
+
))
|
|
79
|
+
)}
|
|
80
|
+
</div>
|
|
81
|
+
</>
|
|
82
|
+
)}
|
|
83
|
+
</Button>
|
|
84
|
+
</PopoverTrigger>
|
|
85
|
+
<PopoverContent className="w-[200px] p-0" align="start">
|
|
86
|
+
<Command>
|
|
87
|
+
<CommandList>
|
|
88
|
+
<CommandGroup>
|
|
89
|
+
{options.map((option) => {
|
|
90
|
+
const isSelected = selectedValues.has(option.value)
|
|
91
|
+
return (
|
|
92
|
+
<CommandItem
|
|
93
|
+
key={option.value}
|
|
94
|
+
onSelect={() => handleSelect(option.value)}
|
|
95
|
+
>
|
|
96
|
+
<div
|
|
97
|
+
className={cn(
|
|
98
|
+
"mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
|
|
99
|
+
isSelected
|
|
100
|
+
? "bg-primary text-primary-foreground"
|
|
101
|
+
: "opacity-50 [&_svg]:invisible"
|
|
102
|
+
)}
|
|
103
|
+
>
|
|
104
|
+
<Check className={cn("h-4 w-4")} />
|
|
105
|
+
</div>
|
|
106
|
+
<span>{option.label}</span>
|
|
107
|
+
</CommandItem>
|
|
108
|
+
)
|
|
109
|
+
})}
|
|
110
|
+
</CommandGroup>
|
|
111
|
+
{selectedValues.size > 0 && (
|
|
112
|
+
<>
|
|
113
|
+
<div className="h-px bg-border mx-1 my-1" />
|
|
114
|
+
<CommandGroup>
|
|
115
|
+
<CommandItem
|
|
116
|
+
onSelect={() => onFilterChange(new Set())}
|
|
117
|
+
className="justify-center text-center"
|
|
118
|
+
>
|
|
119
|
+
Clear filters
|
|
120
|
+
</CommandItem>
|
|
121
|
+
</CommandGroup>
|
|
122
|
+
</>
|
|
123
|
+
)}
|
|
124
|
+
</CommandList>
|
|
125
|
+
</Command>
|
|
126
|
+
</PopoverContent>
|
|
127
|
+
</Popover>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
FilterButton.displayName = "FilterButton"
|
|
132
|
+
|
|
133
|
+
export { FilterButton }
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cva } from "class-variance-authority"
|
|
3
|
+
import { cn } from "../../lib/utils"
|
|
4
|
+
|
|
5
|
+
const formFieldVariants = cva("flex flex-col gap-1.5 p-4")
|
|
6
|
+
|
|
7
|
+
export interface FormFieldProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
8
|
+
|
|
9
|
+
const FormField = React.forwardRef<HTMLDivElement, FormFieldProps>(
|
|
10
|
+
({ className, ...props }, ref) => (
|
|
11
|
+
<div ref={ref} className={cn(formFieldVariants(), className)} {...props} />
|
|
12
|
+
)
|
|
13
|
+
)
|
|
14
|
+
FormField.displayName = "FormField"
|
|
15
|
+
|
|
16
|
+
export interface FormLabelProps
|
|
17
|
+
extends React.LabelHTMLAttributes<HTMLLabelElement> {}
|
|
18
|
+
|
|
19
|
+
const FormLabel = React.forwardRef<HTMLLabelElement, FormLabelProps>(
|
|
20
|
+
({ className, ...props }, ref) => (
|
|
21
|
+
<label
|
|
22
|
+
ref={ref}
|
|
23
|
+
className={cn(
|
|
24
|
+
"text-sm font-medium leading-none text-foreground",
|
|
25
|
+
className
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
)
|
|
30
|
+
)
|
|
31
|
+
FormLabel.displayName = "FormLabel"
|
|
32
|
+
|
|
33
|
+
export interface FormControlProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
34
|
+
|
|
35
|
+
const FormControl = React.forwardRef<HTMLDivElement, FormControlProps>(
|
|
36
|
+
({ className, ...props }, ref) => (
|
|
37
|
+
<div ref={ref} className={cn(className)} {...props} />
|
|
38
|
+
)
|
|
39
|
+
)
|
|
40
|
+
FormControl.displayName = "FormControl"
|
|
41
|
+
|
|
42
|
+
export interface FormDescriptionProps
|
|
43
|
+
extends React.HTMLAttributes<HTMLParagraphElement> {}
|
|
44
|
+
|
|
45
|
+
const FormDescription = React.forwardRef<
|
|
46
|
+
HTMLParagraphElement,
|
|
47
|
+
FormDescriptionProps
|
|
48
|
+
>(({ className, ...props }, ref) => (
|
|
49
|
+
<p
|
|
50
|
+
ref={ref}
|
|
51
|
+
className={cn("text-xs font-normal text-muted-foreground", className)}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
))
|
|
55
|
+
FormDescription.displayName = "FormDescription"
|
|
56
|
+
|
|
57
|
+
export interface FormMessageProps
|
|
58
|
+
extends React.HTMLAttributes<HTMLParagraphElement> {}
|
|
59
|
+
|
|
60
|
+
const FormMessage = React.forwardRef<HTMLParagraphElement, FormMessageProps>(
|
|
61
|
+
({ className, children, ...props }, ref) => (
|
|
62
|
+
<p
|
|
63
|
+
ref={ref}
|
|
64
|
+
className={cn("text-xs font-medium text-destructive", className)}
|
|
65
|
+
{...props}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
</p>
|
|
69
|
+
)
|
|
70
|
+
)
|
|
71
|
+
FormMessage.displayName = "FormMessage"
|
|
72
|
+
|
|
73
|
+
export interface FormProps extends React.FormHTMLAttributes<HTMLFormElement> {}
|
|
74
|
+
|
|
75
|
+
const Form = React.forwardRef<HTMLFormElement, FormProps>(
|
|
76
|
+
({ className, ...props }, ref) => (
|
|
77
|
+
<form ref={ref} className={cn("flex flex-col gap-4", className)} {...props} />
|
|
78
|
+
)
|
|
79
|
+
)
|
|
80
|
+
Form.displayName = "Form"
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
Form,
|
|
84
|
+
FormField,
|
|
85
|
+
FormLabel,
|
|
86
|
+
FormControl,
|
|
87
|
+
FormDescription,
|
|
88
|
+
FormMessage,
|
|
89
|
+
formFieldVariants,
|
|
90
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as HoverCardPrimitive from "@radix-ui/react-hover-card"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../lib/utils"
|
|
7
|
+
|
|
8
|
+
const HoverCard = HoverCardPrimitive.Root
|
|
9
|
+
|
|
10
|
+
const HoverCardTrigger = HoverCardPrimitive.Trigger
|
|
11
|
+
|
|
12
|
+
const HoverCardContent = React.forwardRef<
|
|
13
|
+
React.ElementRef<typeof HoverCardPrimitive.Content>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
|
|
15
|
+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
|
16
|
+
<HoverCardPrimitive.Content
|
|
17
|
+
ref={ref}
|
|
18
|
+
align={align}
|
|
19
|
+
sideOffset={sideOffset}
|
|
20
|
+
className={cn(
|
|
21
|
+
"z-50 flex flex-col items-center w-64 w-[256px] gap-2 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",
|
|
22
|
+
className
|
|
23
|
+
)}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
))
|
|
27
|
+
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName
|
|
28
|
+
|
|
29
|
+
export { HoverCard, HoverCardTrigger, HoverCardContent }
|