diff --git a/src/components/DatePicker/DatePicker.tsx b/src/components/DatePicker/DatePicker.tsx index 03caabf..6d7b6a7 100644 --- a/src/components/DatePicker/DatePicker.tsx +++ b/src/components/DatePicker/DatePicker.tsx @@ -68,7 +68,7 @@ export function DatePicker({className, ...props}: DatePickerProps) { ) : ( )} - {state.hasTime && ( + {state.formatInfo.hasTime && (
diff --git a/src/components/DatePicker/MobileCalendar.tsx b/src/components/DatePicker/MobileCalendar.tsx index 2609a34..14c3eec 100644 --- a/src/components/DatePicker/MobileCalendar.tsx +++ b/src/components/DatePicker/MobileCalendar.tsx @@ -21,9 +21,9 @@ interface MobileCalendarProps { } export function MobileCalendar({props, state}: MobileCalendarProps) { let type: InputDateType = 'date'; - if (state.hasTime && state.hasDate) { + if (state.formatInfo.hasTime && state.formatInfo.hasDate) { type = 'datetime-local'; - } else if (state.hasTime) { + } else if (state.formatInfo.hasTime) { type = 'time'; } @@ -48,13 +48,13 @@ export function MobileCalendar({props, state}: MobileCalendarProps) { format: getDateFormat(type), timeZone: 'system', }).timeZone(state.timeZone, true); - let newDate = state.hasDate + let newDate = state.formatInfo.hasDate ? localDate : createPlaceholderValue({ placeholderValue: props.placeholderValue?.timeZone(state.timeZone), timeZone: state.timeZone, }); - if (state.hasTime) { + if (state.formatInfo.hasTime) { newDate = mergeDateTime(newDate, localDate); } else if (state.value) { newDate = mergeDateTime(newDate, state.value.timeZone(state.timeZone)); diff --git a/src/components/DatePicker/hooks/datePickerStateFactory.ts b/src/components/DatePicker/hooks/datePickerStateFactory.ts index 9440592..9b21849 100644 --- a/src/components/DatePicker/hooks/datePickerStateFactory.ts +++ b/src/components/DatePicker/hooks/datePickerStateFactory.ts @@ -211,7 +211,7 @@ export function datePickerStateFactory>({ } }; - if (dateFieldState.hasTime && !selectedTime) { + if (dateFieldState.formatInfo.hasTime && !selectedTime) { selectedTime = dateFieldState.displayValue; } diff --git a/src/components/DatePicker/hooks/useDatePickerProps.ts b/src/components/DatePicker/hooks/useDatePickerProps.ts index 3629b0c..2d5334f 100644 --- a/src/components/DatePicker/hooks/useDatePickerProps.ts +++ b/src/components/DatePicker/hooks/useDatePickerProps.ts @@ -158,7 +158,7 @@ export function useDatePickerProps>( readOnly: props.readOnly, onUpdate: (d) => { state.setDateValue(d); - if (!state.hasTime) { + if (!state.formatInfo.hasTime) { focusInput(); } }, diff --git a/src/components/RangeDatePicker/RangeDatePicker.tsx b/src/components/RangeDatePicker/RangeDatePicker.tsx index 559a1bf..f3f8b36 100644 --- a/src/components/RangeDatePicker/RangeDatePicker.tsx +++ b/src/components/RangeDatePicker/RangeDatePicker.tsx @@ -31,7 +31,7 @@ export function RangeDatePicker({className, ...props}: RangeDatePickerProps) { const {groupProps, fieldProps, calendarButtonProps, popupProps, calendarProps, timeInputProps} = useDatePickerProps(state, props); - const isOnlyTime = state.hasTime && !state.hasDate; + const isOnlyTime = state.formatInfo.hasTime && !state.formatInfo.hasDate; return (
@@ -44,7 +44,7 @@ export function RangeDatePicker({className, ...props}: RangeDatePickerProps) { ) : ( )} - {state.hasTime && ( + {state.formatInfo.hasTime && (
diff --git a/src/components/RelativeDatePicker/RelativeDatePicker.tsx b/src/components/RelativeDatePicker/RelativeDatePicker.tsx index c41aa28..13c1cac 100644 --- a/src/components/RelativeDatePicker/RelativeDatePicker.tsx +++ b/src/components/RelativeDatePicker/RelativeDatePicker.tsx @@ -65,7 +65,8 @@ export function RelativeDatePicker(props: RelativeDatePickerProps) { const handleRef = useForkRef(anchorRef, groupProps.ref); const isMobile = useMobile(); - const isOnlyTime = state.datePickerState.hasTime && !state.datePickerState.hasDate; + const isOnlyTime = + state.datePickerState.formatInfo.hasTime && !state.datePickerState.formatInfo.hasDate; return (