@arolariu/components
Version:
🎨 70+ beautiful, accessible React components built on Radix UI. TypeScript-first, tree-shakeable, SSR-ready. Perfect for modern web apps, design systems & rapid prototyping. Zero config, maximum flexibility! ⚡
48 lines (47 loc) • 2.31 kB
JavaScript
"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { OTPInput, OTPInputContext } from "input-otp";
import { Minus } from "lucide-react";
import { forwardRef, useContext } from "react";
import { cn } from "../../lib/utilities.js";
const InputOTP = /*#__PURE__*/ forwardRef(({ className, containerClassName, ...props }, ref)=>/*#__PURE__*/ jsx(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 = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx("div", {
ref: ref,
className: cn("flex items-center", className),
...props
}));
InputOTPGroup.displayName = "InputOTPGroup";
const InputOTPSlot = /*#__PURE__*/ forwardRef(({ index, className, ...props }, ref)=>{
const inputOTPContext = useContext(OTPInputContext);
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index];
return /*#__PURE__*/ jsxs("div", {
ref: ref,
className: cn("relative flex h-9 w-9 items-center justify-center border-y border-r border-neutral-200 text-sm shadow-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md dark:border-neutral-800", isActive && "z-10 ring-1 ring-neutral-950 dark:ring-neutral-300", className),
...props,
children: [
char,
Boolean(hasFakeCaret) && /*#__PURE__*/ jsx("div", {
className: "pointer-events-none absolute inset-0 flex items-center justify-center",
children: /*#__PURE__*/ jsx("div", {
className: "animate-caret-blink h-4 w-px bg-neutral-950 duration-1000 dark:bg-neutral-50"
})
})
]
});
});
InputOTPSlot.displayName = "InputOTPSlot";
const InputOTPSeparator = /*#__PURE__*/ forwardRef(({ ...props }, ref)=>/*#__PURE__*/ jsx("div", {
ref: ref,
role: "separator",
...props,
children: /*#__PURE__*/ jsx(Minus, {})
}));
InputOTPSeparator.displayName = "InputOTPSeparator";
export { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot };
//# sourceMappingURL=input-otp.js.map