import { forwardRef } from 'react'; import styled from '@emotion/styled'; import { formatToHumanReadableDate } from '~/utils'; import DatePicker from './DatePicker'; export type StyledCalendarContainerProps = { editModeHorizontalAlign?: 'left' | 'right'; }; const StyledInputContainer = styled.div` display: flex; padding: ${({ theme }) => theme.spacing(2)}; `; const StyledCalendarContainer = styled.div` background: ${({ theme }) => theme.background.secondary}; border: 1px solid ${({ theme }) => theme.border.color.light}; border-radius: ${({ theme }) => theme.border.radius.md}; box-shadow: ${({ theme }) => theme.boxShadow.strong}; margin-top: 1px; position: absolute; z-index: 1; `; type DivProps = React.HTMLProps; export const DateDisplay = forwardRef( ({ value, onClick }, ref) => ( {value && formatToHumanReadableDate(new Date(value as string))} ), ); type DatePickerContainerProps = { children: React.ReactNode; }; export const DatePickerContainer = ({ children }: DatePickerContainerProps) => { return {children}; }; type OwnProps = { value: Date | null | undefined; onChange: (newDate: Date) => void; }; export function DateInputEdit({ onChange, value }: OwnProps) { return ( } customCalendarContainer={DatePickerContainer} /> ); }