diff --git a/src/components/Calendar/CalendarDate/styles.css b/src/components/Calendar/CalendarDate/styles.css index f84adecc..4a19b922 100644 --- a/src/components/Calendar/CalendarDate/styles.css +++ b/src/components/Calendar/CalendarDate/styles.css @@ -5,6 +5,7 @@ &.today { color: var(--dui-color-accent); + border: var(--dui-width-separator-thin) solid var(--dui-color-separator); font-weight: var(--dui-font-weight-bold); } diff --git a/src/components/Calendar/index.tsx b/src/components/Calendar/index.tsx index d8e84e30..6b29338b 100644 --- a/src/components/Calendar/index.tsx +++ b/src/components/Calendar/index.tsx @@ -196,6 +196,34 @@ function Calendar

(props: Props

) { optionsPopupContentClassName={styles.popupContent} /> +

+ + + +
{weekDayNames.map((wd) => ( @@ -260,34 +288,6 @@ function Calendar

(props: Props

) { Please select a valid year and month to view the dates

)} -
- - - -
); } diff --git a/src/components/DateInput/index.tsx b/src/components/DateInput/index.tsx index ba3a8099..c273e13f 100644 --- a/src/components/DateInput/index.tsx +++ b/src/components/DateInput/index.tsx @@ -11,10 +11,12 @@ import { import useUiModeClassName from '../../hooks/useUiModeClassName'; import useBlurEffect from '../../hooks/useBlurEffect'; import useBooleanState from '../../hooks/useBooleanState'; +import useModalState from '../../hooks/useModalState'; import InputContainer, { Props as InputContainerProps } from '../InputContainer'; import RawInput, { Props as RawInputProps } from '../RawInput'; import Button from '../Button'; import Popup from '../Popup'; +import Modal from '../Modal'; import Calendar, { Props as CalendarProps } from '../Calendar'; import { Props as CalendarDateProps } from '../Calendar/CalendarDate'; import { genericMemo, ymdToDateString } from '../../utils'; @@ -28,6 +30,7 @@ type InheritedProps = (Omit & export interface Props extends InheritedProps { inputElementRef?: React.RefObject; inputClassName?: string; + showInModal?: boolean; } function DateInput(props: Props) { @@ -55,6 +58,7 @@ function DateInput(props: Props) { onChange, name, value, + showInModal, ...dateInputProps } = props; @@ -72,6 +76,30 @@ function DateInput(props: Props) { toggleShowCalendar, ] = useBooleanState(false); + const [ + dateModalShown, + setDateModalVisible, + setDateModalHidden, + ] = useModalState(false); + + const handleShowCalendar = React.useCallback(() => { + if (showInModal) { + setDateModalVisible(); + } + toggleShowCalendar(); + }, [ + showInModal, + setDateModalVisible, + toggleShowCalendar, + ]); + + const handleFocus = React.useCallback(() => { + if (showInModal) { + setDateModalVisible(); + } + setShowCalendarTrue(); + }, [showInModal, setShowCalendarTrue, setDateModalVisible]); + const handlePopupBlur = React.useCallback( (isClickedOnPopup: boolean, isClickedOnParent: boolean, e: MouseEvent) => { const isClickedWithin = isClickedOnPopup || isClickedOnParent; @@ -104,8 +132,17 @@ function DateInput(props: Props) { onChange(ymdToDateString(year, month, day), name); } setShowCalendarFalse(); + if (showInModal) { + setDateModalHidden(); + } }, - [name, onChange, setShowCalendarFalse], + [ + name, + onChange, + setShowCalendarFalse, + setDateModalHidden, + showInModal, + ], ); const handleClearButtonClick = React.useCallback(() => { @@ -138,7 +175,7 @@ function DateInput(props: Props) {