mirror of
https://github.com/hanzoai/shadcn.git
synced 2026-11-03 03:18:52 +00:00
Squash merge of shadcn-ui/ui main branch into hanzo/ui, bringing in: - [email protected] through [email protected] releases - New apps/v4 directory structure - Registry system improvements and MCP server - Framework support (Vue, Svelte, React Native) - New templates (vite-app, monorepo-next, laravel) - Zod 4 compatibility (scoped override for zod@>4) - Test fixture corrections for alias resolution All 867 merge conflicts resolved preserving Hanzo customizations. 1020/1020 shadcn tests pass.
93 lines
2.2 KiB
TypeScript
93 lines
2.2 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import { OTPInput, OTPInputContext } from "input-otp"
|
|
|
|
import { cn } from "@/registry/bases/radix/lib/utils"
|
|
import { IconPlaceholder } from "@/app/(create)/components/icon-placeholder"
|
|
|
|
function InputOTP({
|
|
className,
|
|
containerClassName,
|
|
...props
|
|
}: React.ComponentProps<typeof OTPInput> & {
|
|
containerClassName?: string
|
|
}) {
|
|
return (
|
|
<OTPInput
|
|
data-slot="input-otp"
|
|
containerClassName={cn(
|
|
"cn-input-otp flex items-center has-disabled:opacity-50",
|
|
containerClassName
|
|
)}
|
|
spellCheck={false}
|
|
className={cn(
|
|
"cn-input-otp-input disabled:cursor-not-allowed",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function InputOTPGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
return (
|
|
<div
|
|
data-slot="input-otp-group"
|
|
className={cn("cn-input-otp-group flex items-center", className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function InputOTPSlot({
|
|
index,
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<"div"> & {
|
|
index: number
|
|
}) {
|
|
const inputOTPContext = React.useContext(OTPInputContext)
|
|
const { char, hasFakeCaret, isActive } = inputOTPContext?.slots[index] ?? {}
|
|
|
|
return (
|
|
<div
|
|
data-slot="input-otp-slot"
|
|
data-active={isActive}
|
|
className={cn(
|
|
"cn-input-otp-slot relative flex items-center justify-center data-[active=true]:z-10",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
{char}
|
|
{hasFakeCaret && (
|
|
<div className="cn-input-otp-caret pointer-events-none absolute inset-0 flex items-center justify-center">
|
|
<div className="cn-input-otp-caret-line" />
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function InputOTPSeparator({ ...props }: React.ComponentProps<"div">) {
|
|
return (
|
|
<div
|
|
data-slot="input-otp-separator"
|
|
className="cn-input-otp-separator flex items-center"
|
|
role="separator"
|
|
{...props}
|
|
>
|
|
<IconPlaceholder
|
|
lucide="MinusIcon"
|
|
tabler="IconMinus"
|
|
hugeicons="MinusSignIcon"
|
|
phosphor="MinusIcon"
|
|
remixicon="RiSubtractLine"
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
|