38 lines
1.6 KiB
TypeScript
38 lines
1.6 KiB
TypeScript
|
|
import * as React from "react";
|
||
|
|
import { Calendar } from "lucide-react";
|
||
|
|
import { cn } from "../../lib/utils";
|
||
|
|
|
||
|
|
export interface DateInputProps
|
||
|
|
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type"> {}
|
||
|
|
|
||
|
|
const DateInput = React.forwardRef<HTMLInputElement, DateInputProps>(
|
||
|
|
({ className, ...props }, ref) => {
|
||
|
|
return (
|
||
|
|
<div className="relative">
|
||
|
|
<input
|
||
|
|
type="date"
|
||
|
|
ref={ref}
|
||
|
|
className={cn(
|
||
|
|
"flex h-10 w-full rounded-xl border border-slate-300 bg-white px-4 py-2 pr-10 text-sm text-slate-900",
|
||
|
|
"placeholder:text-slate-400",
|
||
|
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#002147] focus-visible:border-transparent",
|
||
|
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
||
|
|
// Esconder o ícone nativo do calendário e tornar toda a área clicável
|
||
|
|
"[&::-webkit-calendar-picker-indicator]:opacity-0 [&::-webkit-calendar-picker-indicator]:absolute [&::-webkit-calendar-picker-indicator]:right-0 [&::-webkit-calendar-picker-indicator]:w-full [&::-webkit-calendar-picker-indicator]:h-full [&::-webkit-calendar-picker-indicator]:cursor-pointer",
|
||
|
|
"[&::-webkit-inner-spin-button]:hidden [&::-webkit-outer-spin-button]:hidden",
|
||
|
|
// Firefox
|
||
|
|
"[&::-moz-calendar-picker-indicator]:opacity-0",
|
||
|
|
className
|
||
|
|
)}
|
||
|
|
{...props}
|
||
|
|
/>
|
||
|
|
<Calendar className="absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" />
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
);
|
||
|
|
DateInput.displayName = "DateInput";
|
||
|
|
|
||
|
|
export { DateInput };
|
||
|
|
|