fix field

This commit is contained in:
rizky 2024-08-14 08:38:33 -07:00
parent a489c489c9
commit fbdf9a1f4a
3 changed files with 3 additions and 76 deletions

View File

@ -123,7 +123,7 @@ export const BaseField = (prop: {
{errors.length > 0 && ( {errors.length > 0 && (
<div <div
className={cx( className={cx(
"field-error c-p-2 c-text-xs c-text-red-600", "field-error c-p-2 c-pl-0 c-text-xs c-text-red-600",
field.desc && "c-pt-0", field.desc && "c-pt-0",
css` css`

View File

@ -169,14 +169,14 @@ export const Field: FC<FieldProp> = (arg) => {
arg={arg} arg={arg}
/> />
{field.desc && ( {field.desc && (
<div className={cx("c-p-2 c-text-xs", errors.length > 0 && "c-pb-1")}> <div className={cx("c-p-2 c-pl-0 c-text-xs", errors.length > 0 && "c-pb-1")}>
{field.desc} {field.desc}
</div> </div>
)} )}
{errors.length ? ( {errors.length ? (
<div <div
className={cx( className={cx(
"field-error c-p-2 c-text-xs c-text-red-600", "field-error c-p-2 c-pl-0 c-text-xs c-text-red-600",
field.desc && "c-pt-0", field.desc && "c-pt-0",
css` css`
padding-left: 0px !important; padding-left: 0px !important;

View File

@ -1,73 +0,0 @@
import * as React from "react";
import { OTPInput, OTPInputContext } from "input-otp";
import { Dot } from "lucide-react";
import { cn } from "@/utils";
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:c-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("c-flex c-items-center", className)}
{...props}
/>
));
InputOTPGroup.displayName = "InputOTPGroup";
const InputOTPSlot = React.forwardRef<
React.ElementRef<"div">,
React.ComponentPropsWithoutRef<"div"> & { index: number }
>(({ index, className, ...props }, ref) => {
const inputOTPContext = React.useContext(OTPInputContext);
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index];
return (
<div
ref={ref}
className={cn(
"c-relative c-flex c-h-10 c-w-10 c-items-center c-justify-center c-border-y c-border-r c-border-input c-text-sm c-transition-all first:c-rounded-l-md first:c-border-l last:c-rounded-r-md",
isActive && "c-z-10 c-ring-2 c-ring-ring c-ring-offset-background",
className
)}
{...props}
>
{char}
{hasFakeCaret && (
<div className="c-pointer-events-none c-absolute c-inset-0 c-flex c-items-center c-justify-center">
<div className="c-h-4 c-w-px c-animate-caret-blink c-bg-foreground c-duration-1000" />
</div>
)}
</div>
);
});
InputOTPSlot.displayName = "InputOTPSlot";
const InputOTPSeparator = React.forwardRef<
React.ElementRef<"div">,
React.ComponentPropsWithoutRef<"div">
>(({ ...props }, ref) => (
<div ref={ref} role="separator" {...props}>
<Dot />
</div>
));
InputOTPSeparator.displayName = "InputOTPSeparator";
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };