@arolariu/components
Version:
🎨 70+ beautiful, accessible React components built on Base UI. TypeScript-first, CSS Modules styling, tree-shakeable, SSR-ready. Perfect for modern web apps, design systems & rapid prototyping. Zero config, maximum flexibility! ⚡
57 lines (56 loc) • 2.84 kB
JavaScript
"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { OTPInput, OTPInputContext, REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS, REGEXP_ONLY_DIGITS_AND_CHARS } from "input-otp";
import { Minus } from "lucide-react";
import { cn } from "../../lib/utilities.js";
import input_otp_module from "./input-otp.module.js";
import * as __rspack_external_react from "react";
const DEFAULT_SLOT_PLACEHOLDER_CHARACTER = "·";
const InputOTP = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, containerClassName, ...props }, ref)=>/*#__PURE__*/ jsx(OTPInput, {
ref: ref,
containerClassName: cn(input_otp_module.container, containerClassName),
className: cn(input_otp_module.input, className),
...props
}));
const InputOTPGroup = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx("div", {
ref: ref,
className: cn(input_otp_module.group, className),
...props
}));
const InputOTPSlot = /*#__PURE__*/ __rspack_external_react.forwardRef(({ index, className, ...props }, ref)=>{
const inputOTPContext = __rspack_external_react.useContext(OTPInputContext);
const slot = inputOTPContext.slots[index];
if (!slot) throw new Error(`InputOTPSlot could not find slot at index ${index}.`);
const { char, hasFakeCaret, isActive, placeholderChar } = slot;
const shouldRenderPlaceholderCharacter = null === char && false === hasFakeCaret;
const displayCharacter = shouldRenderPlaceholderCharacter ? placeholderChar ?? DEFAULT_SLOT_PLACEHOLDER_CHARACTER : char;
return /*#__PURE__*/ jsxs("div", {
ref: ref,
className: cn(input_otp_module.slot, isActive && input_otp_module.slotActive, className),
...props,
children: [
displayCharacter,
Boolean(hasFakeCaret) && /*#__PURE__*/ jsx("div", {
className: input_otp_module.fakeCaretContainer,
children: /*#__PURE__*/ jsx("div", {
className: input_otp_module.fakeCaret
})
})
]
});
});
const InputOTPSeparator = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx("div", {
ref: ref,
role: "separator",
className: cn(input_otp_module.separator, className),
...props,
children: /*#__PURE__*/ jsx(Minus, {
className: input_otp_module.separatorIcon
})
}));
InputOTP.displayName = "InputOTP";
InputOTPGroup.displayName = "InputOTPGroup";
InputOTPSlot.displayName = "InputOTPSlot";
InputOTPSeparator.displayName = "InputOTPSeparator";
export { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS, REGEXP_ONLY_DIGITS_AND_CHARS };
//# sourceMappingURL=input-otp.js.map