Skip to content

Commit

Permalink
fix: replace deprecated usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraS committed Jan 27, 2025
1 parent 7018420 commit f0ee1e9
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function DatePicker({className, ...props}: DatePickerProps) {
) : (
<Calendar {...calendarProps} />
)}
{state.hasTime && (
{state.formatInfo.hasTime && (
<div className={b('time-field-wrapper')}>
<DateField {...timeInputProps} />
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/components/DatePicker/MobileCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand All @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/components/DatePicker/hooks/datePickerStateFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export function datePickerStateFactory<T, O extends DatePickerStateOptions<T>>({
}
};

if (dateFieldState.hasTime && !selectedTime) {
if (dateFieldState.formatInfo.hasTime && !selectedTime) {
selectedTime = dateFieldState.displayValue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/DatePicker/hooks/useDatePickerProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function useDatePickerProps<T extends DateTime | RangeValue<DateTime>>(
readOnly: props.readOnly,
onUpdate: (d) => {
state.setDateValue(d);
if (!state.hasTime) {
if (!state.formatInfo.hasTime) {
focusInput();
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/RangeDatePicker/RangeDatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className={b(null, className)} {...groupProps}>
Expand All @@ -44,7 +44,7 @@ export function RangeDatePicker({className, ...props}: RangeDatePickerProps) {
) : (
<RangeCalendar {...calendarProps} value={state.value} />
)}
{state.hasTime && (
{state.formatInfo.hasTime && (
<div className={b('time-field-wrapper')}>
<RangeDateField {...timeInputProps} />
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/components/RelativeDatePicker/RelativeDatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div {...groupProps} ref={handleRef} className={b(null, props.className)}>
Expand Down

0 comments on commit f0ee1e9

Please sign in to comment.