mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-11 22:44:56 +02:00
remove forward ref
This commit is contained in:
parent
521bbbf1d6
commit
f14379a1c8
25 changed files with 2067 additions and 1779 deletions
|
@ -6,34 +6,45 @@ import { Dot } from "lucide-react"
|
|||
|
||||
import { cn } from "@app/lib/cn"
|
||||
|
||||
const InputOTP = React.forwardRef<
|
||||
React.ElementRef<typeof OTPInput>,
|
||||
React.ComponentPropsWithoutRef<typeof OTPInput>
|
||||
>(({ className, containerClassName, ...props }, ref) => (
|
||||
<OTPInput
|
||||
ref={ref}
|
||||
containerClassName={cn(
|
||||
"flex items-center gap-2 has-disabled:opacity-50",
|
||||
containerClassName
|
||||
)}
|
||||
className={cn("disabled:cursor-not-allowed", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
const InputOTP = (
|
||||
{
|
||||
ref,
|
||||
className,
|
||||
containerClassName,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<typeof OTPInput> & {
|
||||
ref: React.RefObject<React.ElementRef<typeof OTPInput>>;
|
||||
}
|
||||
) => (<OTPInput
|
||||
ref={ref}
|
||||
containerClassName={cn(
|
||||
"flex items-center gap-2 has-disabled:opacity-50",
|
||||
containerClassName
|
||||
)}
|
||||
className={cn("disabled:cursor-not-allowed", className)}
|
||||
{...props}
|
||||
/>)
|
||||
InputOTP.displayName = "InputOTP"
|
||||
|
||||
const InputOTPGroup = React.forwardRef<
|
||||
React.ElementRef<"div">,
|
||||
React.ComponentPropsWithoutRef<"div">
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div ref={ref} className={cn("flex items-center", className)} {...props} />
|
||||
))
|
||||
const InputOTPGroup = (
|
||||
{
|
||||
ref,
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<"div"> & {
|
||||
ref: React.RefObject<React.ElementRef<"div">>;
|
||||
}
|
||||
) => (<div ref={ref} className={cn("flex items-center", className)} {...props} />)
|
||||
InputOTPGroup.displayName = "InputOTPGroup"
|
||||
|
||||
const InputOTPSlot = React.forwardRef<
|
||||
React.ElementRef<"div">,
|
||||
React.ComponentPropsWithoutRef<"div"> & { index: number }
|
||||
>(({ index, className, ...props }, ref) => {
|
||||
const InputOTPSlot = (
|
||||
{
|
||||
ref,
|
||||
index,
|
||||
className,
|
||||
...props
|
||||
}
|
||||
) => {
|
||||
const inputOTPContext = React.useContext(OTPInputContext)
|
||||
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index]
|
||||
|
||||
|
@ -55,17 +66,19 @@ const InputOTPSlot = React.forwardRef<
|
|||
)}
|
||||
</div>
|
||||
)
|
||||
})
|
||||
}
|
||||
InputOTPSlot.displayName = "InputOTPSlot"
|
||||
|
||||
const InputOTPSeparator = React.forwardRef<
|
||||
React.ElementRef<"div">,
|
||||
React.ComponentPropsWithoutRef<"div">
|
||||
>(({ ...props }, ref) => (
|
||||
<div ref={ref} role="separator" {...props}>
|
||||
<Dot />
|
||||
</div>
|
||||
))
|
||||
const InputOTPSeparator = (
|
||||
{
|
||||
ref,
|
||||
...props
|
||||
}: React.ComponentPropsWithoutRef<"div"> & {
|
||||
ref: React.RefObject<React.ElementRef<"div">>;
|
||||
}
|
||||
) => (<div ref={ref} role="separator" {...props}>
|
||||
<Dot />
|
||||
</div>)
|
||||
InputOTPSeparator.displayName = "InputOTPSeparator"
|
||||
|
||||
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue