Skip to content

Commit

Permalink
[core] Fix internal typing
Browse files Browse the repository at this point in the history
  • Loading branch information
nmay231 committed Oct 18, 2023
1 parent 7003239 commit 15f7254
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/mantine-core/src/components/FileInput/FileInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const _FileInput = factory<FileInputFactory>((_props, ref) => {
const [_value, setValue] = useUncontrolled<null | File | File[]>({
value,
defaultValue,
onChange,
onChange: onChange as any,
finalValue: multiple ? [] : null,
});

Expand Down
2 changes: 1 addition & 1 deletion src/mantine-dates/src/components/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const DatePicker: DatePickerComponent = factory<DatePickerFactory>((_prop
allowSingleDateInRange,
value,
defaultValue,
onChange,
onChange: onChange as any,
onMouseLeave,
applyTimezone: !__timezoneApplied,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ export const DateTimePicker = factory<DateTimePickerFactory>((_props, ref) => {
}
};

const handleDateChange = (date: Date) => {
setValue(assignTime(_value!, date));
const handleDateChange = (date: DateValue) => {
if (date) {
setValue(assignTime(_value, date));
}
timeInputRef.current?.focus();
};

Expand Down
4 changes: 3 additions & 1 deletion src/mantine-dates/src/components/MonthPicker/MonthPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const MonthPicker: MonthPickerComponent = factory<MonthPickerFactory>((_p
onMonthSelect,
__updateDateOnMonthSelect,
__timezoneApplied,
onLevelChange,
...others
} = props;

Expand All @@ -92,7 +93,7 @@ export const MonthPicker: MonthPickerComponent = factory<MonthPickerFactory>((_p
allowSingleDateInRange,
value,
defaultValue,
onChange,
onChange: onChange as any,
onMouseLeave,
applyTimezone: !__timezoneApplied,
});
Expand Down Expand Up @@ -122,6 +123,7 @@ export const MonthPicker: MonthPickerComponent = factory<MonthPickerFactory>((_p
})}
classNames={resolvedClassNames}
styles={resolvedStyles}
onLevelChange={onLevelChange as any}
{...others}
date={shiftTimezone('add', others.date, ctx.getTimezone(), __timezoneApplied)}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/mantine-dates/src/components/YearPicker/YearPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const YearPicker: YearPickerComponent = factory<YearPickerFactory>((_prop
allowSingleDateInRange,
value,
defaultValue,
onChange,
onChange: onChange as any,
onMouseLeave,
applyTimezone: !__timezoneApplied,
});
Expand Down
4 changes: 2 additions & 2 deletions src/mantine-hooks/src/use-local-storage/create-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ function serializeJSON<T>(value: T, hookName: string) {
}
}

function deserializeJSON(value: string) {
function deserializeJSON(value: string | undefined) {
try {
return JSON.parse(value);
return value && JSON.parse(value);
} catch {
return value;
}
Expand Down

0 comments on commit 15f7254

Please sign in to comment.