Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

add more components

Jonathan Summers-Muirc8b87a4fd3a5
diff --git a/package-lock.json b/package-lock.json
index 4c3fb30f496..cc4d8e53db9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5235,7 +5235,8 @@
},
"node_modules/@radix-ui/react-dialog": {
"version": "1.0.4",
- "license": "MIT",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-dialog/-/react-dialog-1.0.4.tgz",
+ "integrity": "sha512-hJtRy/jPULGQZceSAP2Re6/4NpKo8im6V8P2hUqZsdFiSL8l35kYsw3qbRI6Ay5mQd2+wlLqje770eq+RJ3yZg==",
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/primitive": "1.0.1",
@@ -39349,15 +39350,15 @@
"license": "MIT",
"dependencies": {
"@headlessui/react": "^1.7.14",
- "@hookform/resolvers": "^3.1.0",
+ "@hookform/resolvers": "^3.1.1",
"@mertasan/tailwindcss-variables": "^2.2.3",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-collapsible": "^1.0.1",
"@radix-ui/react-context-menu": "^2.1.2",
- "@radix-ui/react-dialog": "^1.0.2",
+ "@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@radix-ui/react-id": "^0.0.6",
- "@radix-ui/react-label": "^2.0.1",
+ "@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-popover": "^1.0.4",
"@radix-ui/react-portal": "^1.0.1",
"@radix-ui/react-select": "^1.2.1",
@@ -39384,7 +39385,7 @@
"react-countdown": "^2.3.5",
"react-day-picker": "^8.7.1",
"react-feather": "^2.0.10",
- "react-hook-form": "^7.43.9",
+ "react-hook-form": "^7.45.0",
"react-markdown": "^8.0.3",
"react-syntax-highlighter": "^15.5.0",
"react-tooltip": "^4.2.17",
diff --git a/packages/config/tailwind.config.js b/packages/config/tailwind.config.js
index fb3aac822e1..450acfe29d4 100644
--- a/packages/config/tailwind.config.js
+++ b/packages/config/tailwind.config.js
@@ -3,6 +3,16 @@ const deepMerge = require('deepmerge')
const color = require('./../ui/build/css/tw-extend/color')
+/**
+ *
+ */
+const colorExtend = {}
+Object.values(color).map((x, i) => {
+ colorExtend[Object.keys(color)[i]] = x.cssVariable
+})
+
+console.log('colorExtend', colorExtend)
+
/**
* Generates Tailwind colors for the theme
* adds <alpha-value> as part of the hsl value
@@ -65,51 +75,15 @@ const uiConfig = ui({
*/
textColor: (theme) => ({
...theme('colors'),
- ...generateTwColorClasses('textColor', color),
- }),
- accentColor: (theme) => ({
- ...theme('colors'),
- ...generateTwColorClasses('accentColor', color),
+ ...generateTwColorClasses('foreground', color),
}),
backgroundColor: (theme) => ({
...theme('colors'),
- ...generateTwColorClasses('backgroundColor', color),
+ ...generateTwColorClasses('background', color),
}),
borderColor: (theme) => ({
...theme('colors'),
- ...generateTwColorClasses('borderColor', color),
- }),
- boxShadowColor: (theme) => ({
- ...theme('colors'),
- ...generateTwColorClasses('boxShadowColor', color),
- }),
- caretColor: (theme) => ({
- ...theme('colors'),
- ...generateTwColorClasses('caretColor', color),
- }),
- divideColor: (theme) => ({
- ...theme('colors'),
- ...generateTwColorClasses('divideColor', color),
- }),
- outlineColor: (theme) => ({
- ...theme('colors'),
- ...generateTwColorClasses('outlineColor', color),
- }),
- placeholderColor: (theme) => ({
- ...theme('colors'),
- ...generateTwColorClasses('placeholderColor', color),
- }),
- ringColor: (theme) => ({
- ...theme('colors'),
- ...generateTwColorClasses('ringColor', color),
- }),
- ringOffsetColor: (theme) => ({
- ...theme('colors'),
- ...generateTwColorClasses('ringOffsetColor', color),
- }),
- textDecorationColor: (theme) => ({
- ...theme('colors'),
- ...generateTwColorClasses('textDecorationColor', color),
+ ...generateTwColorClasses('border', color),
}),
extend: {
typography: ({ theme }) => ({
@@ -341,6 +315,9 @@ const uiConfig = ui({
sans: ['Circular', 'custom-font', 'Helvetica Neue', 'Helvetica', 'Arial', 'sans-serif'],
mono: ['Office Code Pro', 'Source Code Pro', 'Menlo', 'monospace'],
},
+ color: {
+ ...colorExtend,
+ },
},
},
plugins: [require('@tailwindcss/typography')],
diff --git a/packages/ui/package.json b/packages/ui/package.json
index e165f908618..f10b315b906 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -17,15 +17,15 @@
},
"dependencies": {
"@headlessui/react": "^1.7.14",
- "@hookform/resolvers": "^3.1.0",
+ "@hookform/resolvers": "^3.1.1",
"@mertasan/tailwindcss-variables": "^2.2.3",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-collapsible": "^1.0.1",
"@radix-ui/react-context-menu": "^2.1.2",
- "@radix-ui/react-dialog": "^1.0.2",
+ "@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@radix-ui/react-id": "^0.0.6",
- "@radix-ui/react-label": "^2.0.1",
+ "@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-popover": "^1.0.4",
"@radix-ui/react-portal": "^1.0.1",
"@radix-ui/react-select": "^1.2.1",
@@ -52,7 +52,7 @@
"react-countdown": "^2.3.5",
"react-day-picker": "^8.7.1",
"react-feather": "^2.0.10",
- "react-hook-form": "^7.43.9",
+ "react-hook-form": "^7.45.0",
"react-markdown": "^8.0.3",
"react-syntax-highlighter": "^15.5.0",
"react-tooltip": "^4.2.17",
diff --git a/packages/ui/src/components/shadcn/stories/Accordion.stories.tsx b/packages/ui/src/components/shadcn/stories/Accordion.stories.tsx
new file mode 100644
index 00000000000..5779ec75c4b
--- /dev/null
+++ b/packages/ui/src/components/shadcn/stories/Accordion.stories.tsx
@@ -0,0 +1,71 @@
+import { Button } from './../../Button'
+import {
+ Accordion,
+ AccordionContent,
+ AccordionItem,
+ AccordionTrigger,
+} from '@ui/components/shadcn/ui/accordion'
+// Button.stories.ts|tsx
+
+import type { Meta, StoryObj } from '@storybook/react'
+
+const meta: Meta<typeof Button> = {
+ /* πŸ‘‡ The title prop is optional.
+ * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
+ * to learn how to generate automatic titles
+ */
+ title: 'shadcn/Accordian',
+ component: Button,
+}
+
+export const Neutral = (args: any) => (
+ <Accordion type="single" collapsible className="w-full">
+ <div
+ className="w-32 h-32
+ bg-overlay
+ text-light
+ border
+ border-overlay
+ rounded-md p-3 shadow"
+ >
+ hello world
+ </div>
+
+ <div
+ className="
+ w-32 h-32
+ bg-destructive
+ text-lightest
+ rounded-md p-3 shadow"
+ >
+ hello world
+ </div>
+
+ <AccordionItem value="item-1">
+ <AccordionTrigger>Is it accessible?</AccordionTrigger>
+ <AccordionContent>Yes. It adheres to the WAI-ARIA design pattern.</AccordionContent>
+ </AccordionItem>
+ <AccordionItem value="item-2">
+ <AccordionTrigger>Is it styled?</AccordionTrigger>
+ <AccordionContent>
+ Yes. It comes with default styles that matches the other components&apos; aesthetic.
+ </AccordionContent>
+ </AccordionItem>
+ <AccordionItem value="item-3">
+ <AccordionTrigger>Is it animated?</AccordionTrigger>
+ <AccordionContent>
+ Yes. It's animated by default, but you can disable it if you prefer.
+ </AccordionContent>
+ </AccordionItem>
+ </Accordion>
+)
+
+export default meta
+
+type Story = StoryObj<typeof Button>
+
+/*
+ *πŸ‘‡ Render functions are a framework specific feature to allow you control on how the component renders.
+ * See https://storybook.js.org/docs/react/api/csf
+ * to learn how to use render functions.
+ */
diff --git a/packages/ui/src/components/shadcn/stories/ComboBox.stories.tsx b/packages/ui/src/components/shadcn/stories/ComboBox.stories.tsx
index 364ed3ba656..fa10820affd 100644
--- a/packages/ui/src/components/shadcn/stories/ComboBox.stories.tsx
+++ b/packages/ui/src/components/shadcn/stories/ComboBox.stories.tsx
@@ -6,10 +6,10 @@ import {
FormItem,
FormLabel,
FormMessage,
-} from '@ui/components/shadcn/form'
+} from '@ui/components/shadcn/ui/form'
import { zodResolver } from '@hookform/resolvers/zod'
import type { Meta } from '@storybook/react'
-import { Button } from '@ui/components/shadcn/button'
+import { Button } from '@ui/components/shadcn/ui/button'
import {
Command,
CommandEmpty,
@@ -17,7 +17,7 @@ import {
CommandInput,
CommandItem,
CommandList,
-} from '@ui/components/shadcn/command'
+} from '@ui/components/shadcn/ui/command'
import {
DropdownMenu,
DropdownMenuContent,
@@ -30,7 +30,7 @@ import {
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuTrigger,
-} from '@ui/components/shadcn/dropdown-menu'
+} from '@ui/components/shadcn/ui/dropdown-menu'
import { Popover, PopoverContent, PopoverTrigger } from '@ui/components/shadcn/popover'
import { toast } from '@ui/components/shadcn/use-toast'
import { cn } from '@ui/lib/utils'
diff --git a/packages/ui/src/components/shadcn/stories/Form.stories.tsx b/packages/ui/src/components/shadcn/stories/Form.stories.tsx
index e95b83311dc..aa8e9349a8b 100644
--- a/packages/ui/src/components/shadcn/stories/Form.stories.tsx
+++ b/packages/ui/src/components/shadcn/stories/Form.stories.tsx
@@ -3,7 +3,7 @@
import { zodResolver } from '@hookform/resolvers/zod'
import { IdProvider } from '@radix-ui/react-id'
import type { Meta, StoryObj } from '@storybook/react'
-import { Button } from '../button'
+import { Button } from '@ui/components/shadcn/ui/button'
import { cn } from '@ui/lib/utils'
import { format } from 'date-fns'
import { CalendarIcon } from 'lucide-react'
@@ -21,8 +21,8 @@ import {
FormItem,
FormLabel,
FormMessage,
-} from '../form'
-import { Input } from '../input'
+} from '@ui/components/shadcn/ui/form'
+import { Input } from '@ui/components/shadcn/ui/input'
const meta: Meta<typeof Form> = {
/* πŸ‘‡ The title prop is optional.
diff --git a/packages/ui/src/components/shadcn/ui/command.tsx b/packages/ui/src/components/shadcn/ui/command.tsx
new file mode 100644
index 00000000000..f1f469f2fba
--- /dev/null
+++ b/packages/ui/src/components/shadcn/ui/command.tsx
@@ -0,0 +1,143 @@
+import * as React from 'react'
+import { DialogProps } from '@radix-ui/react-dialog'
+import { Command as CommandPrimitive } from 'cmdk-supabase'
+import { Search } from 'lucide-react'
+
+import { cn } from 'src/lib/utils'
+import { Dialog, DialogContent } from '@ui/components/shadcn/ui/dialog'
+
+const Command = React.forwardRef<
+ React.ElementRef<typeof CommandPrimitive>,
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive>
+>(({ className, ...props }, ref) => (
+ <CommandPrimitive
+ ref={ref}
+ className={cn(
+ 'flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground',
+ className
+ )}
+ {...props}
+ />
+))
+Command.displayName = CommandPrimitive.displayName
+
+interface CommandDialogProps extends DialogProps {}
+
+const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
+ return (
+ <Dialog {...props}>
+ <DialogContent className="overflow-hidden p-0 shadow-lg">
+ <Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
+ {children}
+ </Command>
+ </DialogContent>
+ </Dialog>
+ )
+}
+
+const CommandInput = React.forwardRef<
+ React.ElementRef<typeof CommandPrimitive.Input>,
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
+>(({ className, ...props }, ref) => (
+ <div className="flex items-center border-b px-3" cmdk-input-wrapper="">
+ <Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
+ <CommandPrimitive.Input
+ ref={ref}
+ className={cn(
+ 'flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50',
+ className
+ )}
+ {...props}
+ />
+ </div>
+))
+
+CommandInput.displayName = CommandPrimitive.Input.displayName
+
+const CommandList = React.forwardRef<
+ React.ElementRef<typeof CommandPrimitive.List>,
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
+>(({ className, ...props }, ref) => (
+ <CommandPrimitive.List
+ ref={ref}
+ className={cn('max-h-[300px] overflow-y-auto overflow-x-hidden', className)}
+ {...props}
+ />
+))
+
+CommandList.displayName = CommandPrimitive.List.displayName
+
+const CommandEmpty = React.forwardRef<
+ React.ElementRef<typeof CommandPrimitive.Empty>,
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
+>((props, ref) => (
+ <CommandPrimitive.Empty ref={ref} className="py-6 text-center text-sm" {...props} />
+))
+
+CommandEmpty.displayName = CommandPrimitive.Empty.displayName
+
+const CommandGroup = React.forwardRef<
+ React.ElementRef<typeof CommandPrimitive.Group>,
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
+>(({ className, ...props }, ref) => (
+ <CommandPrimitive.Group
+ ref={ref}
+ className={cn(
+ 'overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground',
+ className
+ )}
+ {...props}
+ />
+))
+
+CommandGroup.displayName = CommandPrimitive.Group.displayName
+
+const CommandSeparator = React.forwardRef<
+ React.ElementRef<typeof CommandPrimitive.Separator>,
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
+>(({ className, ...props }, ref) => (
+ <CommandPrimitive.Separator
+ ref={ref}
+ className={cn('-mx-1 h-px bg-border', className)}
+ {...props}
+ />
+))
+CommandSeparator.displayName = CommandPrimitive.Separator.displayName
+
+const CommandItem = React.forwardRef<
+ React.ElementRef<typeof CommandPrimitive.Item>,
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
+>(({ className, ...props }, ref) => (
+ <CommandPrimitive.Item
+ ref={ref}
+ className={cn(
+ 'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
+ className
+ )}
+ {...props}
+ />
+))
+
+CommandItem.displayName = CommandPrimitive.Item.displayName
+
+const CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
+ return (
+ <span
+ className={cn('ml-auto text-xs tracking-widest text-muted-foreground', className)}
+ {...props}
+ />
+ )
+}
+CommandShortcut.displayName = 'CommandShortcut'
+
+export {
+ Command,
+ CommandDialog,
+ CommandInput,
+ CommandList,
+ CommandEmpty,
+ CommandGroup,
+ CommandItem,
+ CommandShortcut,
+ CommandSeparator,
+}
diff --git a/packages/ui/src/components/shadcn/ui/dialog.tsx b/packages/ui/src/components/shadcn/ui/dialog.tsx
new file mode 100644
index 00000000000..6996b731523
--- /dev/null
+++ b/packages/ui/src/components/shadcn/ui/dialog.tsx
@@ -0,0 +1,121 @@
+import * as React from "react"
+import * as DialogPrimitive from "@radix-ui/react-dialog"
+import { X } from "lucide-react"
+
+import { cn } from "src/lib/utils"
+
+const Dialog = DialogPrimitive.Root
+
+const DialogTrigger = DialogPrimitive.Trigger
+
+const DialogPortal = ({
+ className,
+ ...props
+}: DialogPrimitive.DialogPortalProps) => (
+ <DialogPrimitive.Portal className={cn(className)} {...props} />
+)
+DialogPortal.displayName = DialogPrimitive.Portal.displayName
+
+const DialogOverlay = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Overlay>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Overlay
+ ref={ref}
+ className={cn(
+ "fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
+ className
+ )}
+ {...props}
+ />
+))
+DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
+
+const DialogContent = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
+>(({ className, children, ...props }, ref) => (
+ <DialogPortal>
+ <DialogOverlay />
+ <DialogPrimitive.Content
+ ref={ref}
+ className={cn(
+ "fixed left-[50%] top-[50%] z-50 grid 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 md:w-full",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <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">
+ <X className="h-4 w-4" />
+ <span className="sr-only">Close</span>
+ </DialogPrimitive.Close>
+ </DialogPrimitive.Content>
+ </DialogPortal>
+))
+DialogContent.displayName = DialogPrimitive.Content.displayName
+
+const DialogHeader = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement>) => (
+ <div
+ className={cn(
+ "flex flex-col space-y-1.5 text-center sm:text-left",
+ className
+ )}
+ {...props}
+ />
+)
+DialogHeader.displayName = "DialogHeader"
+
+const DialogFooter = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement>) => (
+ <div
+ className={cn(
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
+ className
+ )}
+ {...props}
+ />
+)
+DialogFooter.displayName = "DialogFooter"
+
+const DialogTitle = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Title>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Title
+ ref={ref}
+ className={cn(
+ "text-lg font-semibold leading-none tracking-tight",
+ className
+ )}
+ {...props}
+ />
+))
+DialogTitle.displayName = DialogPrimitive.Title.displayName
+
+const DialogDescription = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Description>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Description
+ ref={ref}
+ className={cn("text-sm text-muted-foreground", className)}
+ {...props}
+ />
+))
+DialogDescription.displayName = DialogPrimitive.Description.displayName
+
+export {
+ Dialog,
+ DialogTrigger,
+ DialogContent,
+ DialogHeader,
+ DialogFooter,
+ DialogTitle,
+ DialogDescription,
+}
diff --git a/packages/ui/src/components/shadcn/ui/form.tsx b/packages/ui/src/components/shadcn/ui/form.tsx
new file mode 100644
index 00000000000..bbaa3471559
--- /dev/null
+++ b/packages/ui/src/components/shadcn/ui/form.tsx
@@ -0,0 +1,171 @@
+import * as React from 'react'
+import * as LabelPrimitive from '@radix-ui/react-label'
+import { Slot } from '@radix-ui/react-slot'
+import {
+ Controller,
+ ControllerProps,
+ FieldPath,
+ FieldValues,
+ FormProvider,
+ useFormContext,
+} from 'react-hook-form'
+
+import { cn } from 'src/lib/utils'
+import { Label } from '@ui/components/shadcn/ui/label'
+
+// react 17 hack
+import { useId } from '@radix-ui/react-id'
+
+const Form = FormProvider
+
+type FormFieldContextValue<
+ TFieldValues extends FieldValues = FieldValues,
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
+> = {
+ name: TName
+}
+
+const FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue)
+
+const FormField = <
+ TFieldValues extends FieldValues = FieldValues,
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
+>({
+ ...props
+}: ControllerProps<TFieldValues, TName>) => {
+ return (
+ <FormFieldContext.Provider value={{ name: props.name }}>
+ <Controller {...props} />
+ </FormFieldContext.Provider>
+ )
+}
+
+const useFormField = () => {
+ const fieldContext = React.useContext(FormFieldContext)
+ const itemContext = React.useContext(FormItemContext)
+ const { getFieldState, formState } = useFormContext()
+
+ const fieldState = getFieldState(fieldContext.name, formState)
+
+ if (!fieldContext) {
+ throw new Error('useFormField should be used within <FormField>')
+ }
+
+ const { id } = itemContext
+
+ return {
+ id,
+ name: fieldContext.name,
+ formItemId: `${id}-form-item`,
+ formDescriptionId: `${id}-form-item-description`,
+ formMessageId: `${id}-form-item-message`,
+ ...fieldState,
+ }
+}
+
+type FormItemContextValue = {
+ id: string
+}
+
+const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue)
+
+const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
+ ({ className, ...props }, ref) => {
+ // const id = React.useId()
+ const id = useId()
+
+ return (
+ <FormItemContext.Provider value={{ id }}>
+ <div ref={ref} className={cn('space-y-2', className)} {...props} />
+ </FormItemContext.Provider>
+ )
+ }
+)
+FormItem.displayName = 'FormItem'
+
+const FormLabel = React.forwardRef<
+ React.ElementRef<typeof LabelPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
+>(({ className, ...props }, ref) => {
+ const { error, formItemId } = useFormField()
+
+ return (
+ <Label
+ ref={ref}
+ className={cn(error && 'text-destructive', className)}
+ htmlFor={formItemId}
+ {...props}
+ />
+ )
+})
+FormLabel.displayName = 'FormLabel'
+
+const FormControl = React.forwardRef<
+ React.ElementRef<typeof Slot>,
+ React.ComponentPropsWithoutRef<typeof Slot>
+>(({ ...props }, ref) => {
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
+
+ return (
+ <Slot
+ ref={ref}
+ id={formItemId}
+ aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}
+ aria-invalid={!!error}
+ {...props}
+ />
+ )
+})
+FormControl.displayName = 'FormControl'
+
+const FormDescription = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes<HTMLParagraphElement>
+>(({ className, ...props }, ref) => {
+ const { formDescriptionId } = useFormField()
+
+ return (
+ <p
+ ref={ref}
+ id={formDescriptionId}
+ className={cn('text-sm text-muted-foreground', className)}
+ {...props}
+ />
+ )
+})
+FormDescription.displayName = 'FormDescription'
+
+const FormMessage = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes<HTMLParagraphElement>
+>(({ className, children, ...props }, ref) => {
+ const { error, formMessageId } = useFormField()
+ const body = error ? String(error?.message) : children
+
+ if (!body) {
+ return null
+ }
+
+ return (
+ <p
+ ref={ref}
+ id={formMessageId}
+ className={cn('text-sm font-medium text-destructive', className)}
+ {...props}
+ >
+ {body}
+ </p>
+ )
+})
+FormMessage.displayName = 'FormMessage'
+
+export {
+ useFormField,
+ Form,
+ FormItem,
+ FormLabel,
+ FormControl,
+ FormDescription,
+ FormMessage,
+ FormField,
+}
diff --git a/packages/ui/src/components/shadcn/ui/input.tsx b/packages/ui/src/components/shadcn/ui/input.tsx
new file mode 100644
index 00000000000..05bb2697173
--- /dev/null
+++ b/packages/ui/src/components/shadcn/ui/input.tsx
@@ -0,0 +1,25 @@
+import * as React from "react"
+
+import { cn } from "src/lib/utils"
+
+export interface InputProps
+ extends React.InputHTMLAttributes<HTMLInputElement> {}
+
+const Input = React.forwardRef<HTMLInputElement, InputProps>(
+ ({ className, type, ...props }, ref) => {
+ return (
+ <input
+ type={type}
+ className={cn(
+ "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
+ className
+ )}
+ ref={ref}
+ {...props}
+ />
+ )
+ }
+)
+Input.displayName = "Input"
+
+export { Input }
diff --git a/packages/ui/src/components/shadcn/ui/label.tsx b/packages/ui/src/components/shadcn/ui/label.tsx
new file mode 100644
index 00000000000..f8af5ac2f7d
--- /dev/null
+++ b/packages/ui/src/components/shadcn/ui/label.tsx
@@ -0,0 +1,24 @@
+import * as React from "react"
+import * as LabelPrimitive from "@radix-ui/react-label"
+import { cva, type VariantProps } from "class-variance-authority"
+
+import { cn } from "src/lib/utils"
+
+const labelVariants = cva(
+ "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
+)
+
+const Label = React.forwardRef<
+ React.ElementRef<typeof LabelPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
+ VariantProps<typeof labelVariants>
+>(({ className, ...props }, ref) => (
+ <LabelPrimitive.Root
+ ref={ref}
+ className={cn(labelVariants(), className)}
+ {...props}
+ />
+))
+Label.displayName = LabelPrimitive.Root.displayName
+
+export { Label }
diff --git a/packages/ui/tailwind.config.js b/packages/ui/tailwind.config.js
index dd3303279fb..a270e5f1083 100644
--- a/packages/ui/tailwind.config.js
+++ b/packages/ui/tailwind.config.js
@@ -31,7 +31,7 @@ module.exports = config({
'flash-code-slow': 'flash-code 2s forwards',
},
colors: {
- border: 'hsl(var(--border))',
+ border: 'hsl(var(--border-overlay))',
input: 'hsl(var(--input))',
ring: 'hsl(var(--ring))',
background: 'hsl(var(--background-default))',
@@ -49,7 +49,7 @@ module.exports = config({
foreground: 'hsl(var(--destructive-300))',
},
muted: {
- DEFAULT: 'hsl(var(--background-muted))',
+ DEFAULT: 'hsl(var(--border-overlay))',
foreground: 'hsl(var(--foreground-lighter))',
},
accent: {
@@ -57,8 +57,8 @@ module.exports = config({
foreground: 'hsl(var(--accent-foreground))',
},
popover: {
- DEFAULT: 'hsl(var(--border-overlay))',
- foreground: 'hsl(var(--background-default))',
+ DEFAULT: 'hsl(var(--background-overlay))',
+ foreground: 'hsl(var(--foreground-default))',
},
card: {
DEFAULT: 'hsl(var(--card))',