Skip to content

Commit

Permalink
Upgrade react-datepicker to the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
simenko committed Sep 6, 2021
1 parent 82480de commit 034c595
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 63 deletions.
2 changes: 1 addition & 1 deletion docs/components/ComponentsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface MenuItemProps extends ActionLinkProps {
const NavItems = styled.div``;

const MenuItem = styled(ActionLink)<MenuItemProps>(
themed(
themed<MenuItemProps>(
({ selected, theme }) => `
position: relative;
display: block;
Expand Down
4 changes: 2 additions & 2 deletions docs/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ interface ContentColumn {
}

const ContentColumn = styled('div')<ContentColumn>(
themed(
themed<ContentColumn>(
({ hasSidebar, theme }) => `
flex: 1;
padding: ${distance.xxlarge} ${distance.xlarge};
${
hasSidebar
? `margin-left: ${tocColumnWidth}px;`
: `width: ${theme.breakpoints.large}px;
: `width: ${theme.breakpoints.large}px;
margin: 0 auto;`
}
`,
Expand Down
2 changes: 1 addition & 1 deletion docs/components/SectionRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface SectionRendererProps {
}

const SectionRenderer: React.SFC<SectionRendererProps> = props => {
const { description, content, sections, components, depth, slug, pagePerSection } = props;
const { description, content, sections, components, depth, slug, pagePerSection, name } = props;

return (
<section>
Expand Down
108 changes: 59 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@
}
},
"dependencies": {
"@types/react-datepicker": "^2.8.0",
"date-fns": "^2.3.0",
"memoize-one": "^5.1.0",
"react-datepicker": "^2.8.0",
"react-datepicker": "^4.2.1",
"react-onclickoutside": "^6.7.1",
"typescript-plugin-inner-jsx": "^0.1.9"
},
Expand All @@ -66,6 +65,7 @@
"@types/jest-image-snapshot": "^2.8.0",
"@types/puppeteer": "^1.12.1",
"@types/react": "^16.14.14",
"@types/react-datepicker": "^4.1.5",
"@types/react-dom": "^16.9.14",
"@types/react-onclickoutside": "^6.7.0",
"@types/react-router": "^4.4.1",
Expand Down
6 changes: 3 additions & 3 deletions src/components/DateField/CustomReactDatepicker.part.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ const getHeaderRender = ({
months = defaultMonths,
}: {
months: CustomReactDatepickerProps['months'];
}): ReactDatePickerProps['renderCustomHeader'] => ({ date, increaseMonth, decreaseMonth, changeYear }) => {
}): ReactDatePickerProps<unknown>['renderCustomHeader'] => ({ date, increaseMonth, decreaseMonth, changeYear }) => {
const monthName = months[date.getMonth()];
const year = date.getFullYear();
return (
Expand All @@ -352,7 +352,7 @@ const getHeaderRender = ({
);
};

export interface CustomReactDatepickerProps extends ReactDatePickerProps {
export interface CustomReactDatepickerProps extends ReactDatePickerProps<unknown> {
months?: Array<string>;
weekDays?: Array<string>;
}
Expand All @@ -364,7 +364,7 @@ export const CustomReactDatepicker: React.FC<CustomReactDatepickerProps> = ({
...props
}) => (
<ReactDatePickerContainer>
<ReactDatePicker
<ReactDatePicker<unknown>
locale={patchLocale(enGB, weekDays, months)}
renderCustomHeader={getHeaderRender({ months })}
showMonthYearPicker={showMonthYearPicker}
Expand Down
10 changes: 5 additions & 5 deletions src/components/DateField/DateFieldInt.part.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export interface DateFieldBasicProps extends FormContextProps, TextInputProps {
}

export type DateFieldProps = DateFieldBasicProps &
Omit<ReactDatePickerProps, keyof typeof excludedReactDatePickerProps>;
Omit<ReactDatePickerProps<unknown>, keyof typeof excludedReactDatePickerProps>;

interface DateFieldState {
value: string;
Expand Down Expand Up @@ -232,15 +232,15 @@ class DateFieldInt extends React.Component<DateFieldProps, DateFieldState> {
}
}

private changeValue: ReactDatePickerProps['onChange'] = inputDate => {
private changeValue: ReactDatePickerProps<unknown>['onChange'] = inputDate => {
const { dateFormat = DefaultDateFormat, locale } = this.props;
const date = inputDate || undefined;
const value = safeDateFormat(date, {
const value = safeDateFormat(date as Date, {
dateFormat,
locale,
});

this.change(date, value);
this.change(date as Date, value);
};

private changeInput = (e: React.FocusEvent<HTMLInputElement>) => {
Expand Down Expand Up @@ -322,7 +322,7 @@ class DateFieldInt extends React.Component<DateFieldProps, DateFieldState> {
...rest
} = this.props;

const datePickerProps = {} as ReactDatePickerProps;
const datePickerProps = {} as ReactDatePickerProps<unknown>;
const customInputProps = {} as Omit<DateFieldBasicProps, 'onChange' | 'children'>;
Object.keys(rest).forEach(propName => {
if (excludedReactDatePickerProps[propName]) {
Expand Down

0 comments on commit 034c595

Please sign in to comment.