import Calendar from "@sbmdkl/nepali-datepicker-reactjs"; import '@sbmdkl/nepali-datepicker-reactjs/dist/index.css'; import React, { useEffect, useState } from "react"; import NepaliDate from "nepali-date-converter"; import { AdToBs, getTomorrowEnglishDate, getYesterdayEnglishDate } from "@/helpers/date.helper" import { Label } from "../ui/label"; interface NepaliDateFieldProps { children?: React.ReactNode; wrapperClassName?: string; id?: string; className?: string; label?: string; labelStyle?: "label-left" | 'label-top'; labelWidth?: String; name?: string; status?: string; disabled?: boolean; value?: any; defaultValue?: any; formGroup?: string; hasIcon?: string; size?: string; placeholder?: string; rows?: number; hint?: string; required?: boolean; hidden?: boolean; fieldErrors?: Array; helpText?: String; onChange?: (e: any) => void; step?: string; disableFutureDate?: boolean; position?: "bottom" | "left"; disablePastDate?: boolean; isToday? : boolean } const NepaliDateField: React.FC = ({ className = "", id, wrapperClassName = "", children, label, labelStyle, labelWidth, name, status, disabled, value, defaultValue, formGroup, hasIcon, size, placeholder, rows, hint, required, fieldErrors = [], helpText, hidden = false, onChange, disableFutureDate, position = "bottom", disablePastDate, isToday = false , ...props }) => { const today = new NepaliDate().format("YYYY-MM-DD"); const tomorrow = getTomorrowEnglishDate(); const previousDay = getYesterdayEnglishDate(); const currentNepaliDate = new NepaliDate().format("YYYY-MM-DD"); const tomorrowNepaliDate = AdToBs(tomorrow); const yesterdayNepaliDate = AdToBs(previousDay); useEffect(() => { if (disabled) { document.querySelector('._1oYOS')?.setAttribute('disabled', 'true'); } else { document.querySelector('._1oYOS')?.removeAttribute('disabled'); } }, [disabled]); return (
{label && ( )}
{children} {helpText && (
{helpText}
)} {fieldErrors.map((item: string, index: any) => ( {item}

))}
); }; export default NepaliDateField;