/** @jsxImportSource @emotion/react */ import Calendar from '@/@widgets/calendar/Calendar'; import { MQ } from '@/libs/themes'; import { Interpolation, Theme } from '@emotion/react'; import { HTMLAttributes, ReactNode, useEffect, useRef, useState } from 'react'; import { useModalStatic } from '../modal/pice/useModalStatic'; // type Props = { zIndex?: number; format?: 'yyyy-mm-dd' | 'yyyy-mm' | 'yyyy'; open: boolean; onClose: () => void; clickOutSideClose?: boolean; windowScreenScroll?: boolean; date: Date; minDate?: Date; maxDate?: Date; onClick: (date: Date | null | any) => void; colors?: { backgroundColor?: string; cancelTabColor?: string }; } & Omit, 'color'>; // const CalendarModal = ({ open, onClose, format = 'yyyy-mm-dd', date, onClick, windowScreenScroll = false, clickOutSideClose = true, zIndex, ...props }: Props) => { const ref = useRef(null); const [delayedOpen, setDelayedOpen] = useState(false); const handleCancel = () => { setDelayedOpen(false); const timeout = setTimeout(() => onClose(), 100); return () => clearTimeout(timeout); }; useEffect(() => { if (open) { const timeout = setTimeout(() => setDelayedOpen(true), 50); return () => clearTimeout(timeout); } else { setDelayedOpen(false); } }, [open]); useModalStatic({ ref, open: delayedOpen, onCancel: handleCancel, clickOutSideClose, windowScreenScroll, }); if (!open) return null; return ( <> {open && (
)}
{ onClick(date); handleCancel(); }} maxDate={props.maxDate} minDate={props.minDate} {...props} />
); }; export default CalendarModal; // // const flexT: Interpolation = { position: 'relative', display: 'flex', flexDirection: 'column', alignItems: 'center', width: '100%', height: '100%', transition: '0.2s ease-in-out', }; // const Fixed = ({ children, open, zIndex }: { children: ReactNode; open: boolean; zIndex?: number }) => (
{children}
);