mirror of
https://github.com/hanzoai/ui.git
synced 2026-11-21 00:18:41 +00:00
- Convert @/registry/default/* imports to relative paths in pkg/ui - Fix sidebar, input, textarea, popover import references - Update block component imports to use relative paths - Add index-core.ts, index-blocks.ts, index-standard.ts exports - Add publish workflow - Bump versions: - @hanzo/ui: 5.3.3 → 5.3.18 - @hanzo/auth: 2.5.4 → 2.5.5 - @hanzo/commerce: 7.3.7 → 7.3.8
96 lines
2.2 KiB
TypeScript
96 lines
2.2 KiB
TypeScript
// @ts-nocheck
|
|
'use client'
|
|
|
|
import { zodResolver } from '@hookform/resolvers/zod'
|
|
import * as z from 'zod'
|
|
import { useForm } from 'react-hook-form'
|
|
|
|
import {
|
|
Button,
|
|
Input
|
|
} from '@hanzo/ui/primitives'
|
|
|
|
import {
|
|
Form,
|
|
FormControl,
|
|
FormField,
|
|
FormItem,
|
|
FormMessage,
|
|
} from '@hanzo/ui/form'
|
|
|
|
import { cn } from '@hanzo/ui/util'
|
|
|
|
const formSchema = z.object({
|
|
email: z.string().email(),
|
|
password: z.string().min(2, 'Password must be at least 2 characters'),
|
|
})
|
|
|
|
const EmailPasswordForm: React.FC<{
|
|
onSubmit: (email: string, password: string) => void
|
|
isLoading: boolean
|
|
className?: string
|
|
inputClx?: string
|
|
prompt?: string
|
|
}> = ({
|
|
onSubmit,
|
|
isLoading,
|
|
className,
|
|
inputClx,
|
|
prompt='Login'
|
|
}) => {
|
|
const form = useForm<z.infer<typeof formSchema>>({
|
|
resolver: zodResolver(formSchema),
|
|
defaultValues: {
|
|
email: '',
|
|
password: '',
|
|
},
|
|
})
|
|
|
|
return (
|
|
<Form {...form}>
|
|
<form
|
|
onSubmit={form.handleSubmit(({email, password}) => onSubmit(email, password))}
|
|
className={cn('text-left', className)}
|
|
>
|
|
<FormField
|
|
control={form.control}
|
|
name='email'
|
|
render={({ field }) => (
|
|
<FormItem className='space-y-1'>
|
|
<FormControl>
|
|
<Input
|
|
{...field}
|
|
className={inputClx}
|
|
placeholder='Email'
|
|
disabled={isLoading}
|
|
/>
|
|
</FormControl>
|
|
<FormMessage />
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
<FormField
|
|
control={form.control}
|
|
name='password'
|
|
render={({ field }) => (
|
|
<FormItem className='space-y-1'>
|
|
<FormControl>
|
|
<Input
|
|
type='password'
|
|
{...field}
|
|
className={inputClx}
|
|
placeholder='Password'
|
|
disabled={isLoading}
|
|
/>
|
|
</FormControl>
|
|
<FormMessage />
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
<Button type='submit' className='w-full' disabled={isLoading}>{prompt}</Button>
|
|
</form>
|
|
</Form>
|
|
)
|
|
}
|
|
|
|
export default EmailPasswordForm |