Skip to content

Commit

Permalink
[size] Remove unused/duplicated defaultProps & propTypes (mui#843)
Browse files Browse the repository at this point in the history
* Remove undefined from defaultProps

* Split formatting functions from DateTestField to separate helper

* Remove unused/duplicated propTypes & defaultProps

* Fix ts error in test
  • Loading branch information
dmtrKovalenko authored Jan 9, 2019
1 parent f03eccb commit b67c1ee
Show file tree
Hide file tree
Showing 30 changed files with 112 additions and 505 deletions.
4 changes: 0 additions & 4 deletions docs/src/_shared/SourcablePanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ class SourcablePanel extends PureComponent {
sourceFile: PropTypes.string.isRequired,
};

static defaultProps = {
description: undefined,
};

state = {
sourceExpanded: false,
};
Expand Down
2 changes: 0 additions & 2 deletions docs/src/layout/NavItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ NavItem.propTypes = {

NavItem.defaultProps = {
depth: 0,
children: undefined,
href: undefined,
};

export default withStyles(styles)(NavItem);
24 changes: 12 additions & 12 deletions lib/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"build/dist/material-ui-pickers.esm.js": {
"bundled": 115237,
"minified": 68052,
"gzipped": 14835,
"bundled": 106370,
"minified": 62077,
"gzipped": 14537,
"treeshaked": {
"rollup": {
"code": 50219,
"import_statements": 1317
"code": 48166,
"import_statements": 1323
},
"webpack": {
"code": 57185
"code": 55154
}
}
},
"build/dist/material-ui-pickers.umd.js": {
"bundled": 231850,
"minified": 101280,
"gzipped": 25689
"bundled": 220351,
"minified": 95434,
"gzipped": 25457
},
"build/dist/material-ui-pickers.umd.min.js": {
"bundled": 203184,
"minified": 91312,
"gzipped": 24082
"bundled": 199685,
"minified": 89206,
"gzipped": 24135
}
}
32 changes: 1 addition & 31 deletions lib/src/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import * as PropTypes from 'prop-types';
import * as React from 'react';

import PickerToolbar from '../_shared/PickerToolbar';
import ToolbarButton from '../_shared/ToolbarButton';
import { withUtils, WithUtilsProps } from '../_shared/WithUtils';
import DomainPropTypes, { DateType } from '../constants/prop-types';
import { DateType } from '../constants/prop-types';
import { MaterialUiPickersDate } from '../typings/date';
import Calendar, { RenderDay } from './components/Calendar';
import YearSelection from './components/YearSelection';
Expand Down Expand Up @@ -41,38 +39,10 @@ export interface DatePickerProps extends BaseDatePickerProps {
}

export class DatePicker extends React.PureComponent<DatePickerProps & WithUtilsProps> {
public static propTypes: any = {
date: PropTypes.object.isRequired,
minDate: DomainPropTypes.date,
maxDate: DomainPropTypes.date,
onChange: PropTypes.func.isRequired,
disablePast: PropTypes.bool,
disableFuture: PropTypes.bool,
animateYearScrolling: PropTypes.bool,
openToYearSelection: PropTypes.bool,
children: PropTypes.node,
leftArrowIcon: PropTypes.node,
rightArrowIcon: PropTypes.node,
renderDay: PropTypes.func,
utils: PropTypes.object.isRequired,
shouldDisableDate: PropTypes.func,
allowKeyboardControl: PropTypes.bool,
initialFocusedDate: DomainPropTypes.date,
};

public static defaultProps = {
minDate: '1900-01-01',
maxDate: '2100-01-01',
disablePast: false,
disableFuture: false,
allowKeyboardControl: false,
animateYearScrolling: undefined,
openToYearSelection: false,
children: null,
leftArrowIcon: undefined,
rightArrowIcon: undefined,
renderDay: undefined,
shouldDisableDate: undefined,
};

public state = {
Expand Down
45 changes: 0 additions & 45 deletions lib/src/DatePicker/DatePickerInline.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import * as PropTypes from 'prop-types';
import * as React from 'react';

import { Omit } from '@material-ui/core';
import BasePicker, { BasePickerProps } from '../_shared/BasePicker';
import DomainPropTypes from '../constants/prop-types';
import { ExtendWrapper } from '../wrappers/ExtendWrapper';
import InlineWrapper, { OuterInlineWrapperProps } from '../wrappers/InlineWrapper';
import Calendar from './components/Calendar';
Expand Down Expand Up @@ -80,49 +78,6 @@ export const DatePickerInline: React.SFC<DatePickerInlineProps> = props => {
);
};

(DatePickerInline as any).propTypes = {
onlyCalendar: PropTypes.bool,
value: DomainPropTypes.date,
minDate: DomainPropTypes.date,
maxDate: DomainPropTypes.date,
initialFocusedDate: DomainPropTypes.date,
format: PropTypes.string,
onChange: PropTypes.func.isRequired,
disablePast: PropTypes.bool,
disableFuture: PropTypes.bool,
animateYearScrolling: PropTypes.bool,
openToYearSelection: PropTypes.bool,
labelFunc: PropTypes.func,
leftArrowIcon: PropTypes.node,
rightArrowIcon: PropTypes.node,
renderDay: PropTypes.func,
shouldDisableDate: PropTypes.func,
allowKeyboardControl: PropTypes.bool,
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
autoOk: PropTypes.bool,
};

DatePickerInline.defaultProps = {
value: new Date(),
format: undefined,
minDate: '1900-01-01',
maxDate: '2100-01-01',
initialFocusedDate: undefined,
disableFuture: false,
disablePast: false,
animateYearScrolling: false,
openToYearSelection: false,
allowKeyboardControl: true,
leftArrowIcon: undefined,
rightArrowIcon: undefined,
renderDay: undefined,
labelFunc: undefined,
shouldDisableDate: undefined,
forwardedRef: undefined,
autoOk: undefined,
onlyCalendar: false,
};

export default React.forwardRef((props: DatePickerInlineProps, ref) => (
<DatePickerInline {...props} forwardedRef={ref} />
));
44 changes: 0 additions & 44 deletions lib/src/DatePicker/DatePickerModal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import * as PropTypes from 'prop-types';
import * as React from 'react';

import BasePicker, { BasePickerProps } from '../_shared/BasePicker';
import DomainPropTypes from '../constants/prop-types';
import { ExtendWrapper } from '../wrappers/ExtendWrapper';
import ModalWrapper, { ModalWrapperProps } from '../wrappers/ModalWrapper';
import DatePicker, { BaseDatePickerProps } from './DatePicker';
Expand Down Expand Up @@ -86,47 +83,6 @@ export const DatePickerModal: React.SFC<DatePickerModalProps> = props => {
);
};

(DatePickerModal as any).propTypes = {
value: DomainPropTypes.date,
minDate: DomainPropTypes.date,
maxDate: DomainPropTypes.date,
initialFocusedDate: DomainPropTypes.date,
format: PropTypes.string,
onChange: PropTypes.func.isRequired,
autoOk: PropTypes.bool,
disablePast: PropTypes.bool,
disableFuture: PropTypes.bool,
animateYearScrolling: PropTypes.bool,
openToYearSelection: PropTypes.bool,
labelFunc: PropTypes.func,
leftArrowIcon: PropTypes.node,
rightArrowIcon: PropTypes.node,
renderDay: PropTypes.func,
shouldDisableDate: PropTypes.func,
allowKeyboardControl: PropTypes.bool,
forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
};

DatePickerModal.defaultProps = {
value: new Date(),
format: undefined,
autoOk: false,
minDate: '1900-01-01',
maxDate: '2100-01-01',
initialFocusedDate: undefined,
disableFuture: false,
disablePast: false,
animateYearScrolling: false,
openToYearSelection: false,
allowKeyboardControl: true,
leftArrowIcon: undefined,
rightArrowIcon: undefined,
renderDay: undefined,
labelFunc: undefined,
shouldDisableDate: undefined,
forwardedRef: undefined,
};

export default React.forwardRef((props: DatePickerModalProps, ref) => (
<DatePickerModal {...props} forwardedRef={ref} />
));
12 changes: 2 additions & 10 deletions lib/src/DatePicker/components/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Theme } from '@material-ui/core';
import { IconButtonProps } from '@material-ui/core/IconButton';
import { findClosestEnabledDate } from '../../_helpers/date-utils';
import { withUtils, WithUtilsProps } from '../../_shared/WithUtils';
import DomainPropTypes, { DateType } from '../../constants/prop-types';
import { DateType, DomainPropTypes } from '../../constants/prop-types';
import { MaterialUiPickersDate } from '../../typings/date';
import CalendarHeader from './CalendarHeader';
import Day from './Day';
Expand Down Expand Up @@ -47,14 +47,10 @@ export class Calendar extends React.Component<CalendarProps, CalendarState> {
date: PropTypes.object.isRequired,
minDate: DomainPropTypes.date,
maxDate: DomainPropTypes.date,
classes: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired,
disablePast: PropTypes.bool,
disableFuture: PropTypes.bool,
leftArrowIcon: PropTypes.node,
rightArrowIcon: PropTypes.node,
renderDay: PropTypes.func,
theme: PropTypes.object.isRequired,
shouldDisableDate: PropTypes.func,
utils: PropTypes.object.isRequired,
allowKeyboardControl: PropTypes.bool,
Expand All @@ -66,11 +62,7 @@ export class Calendar extends React.Component<CalendarProps, CalendarState> {
maxDate: '2100-01-01',
disablePast: false,
disableFuture: false,
leftArrowIcon: undefined,
rightArrowIcon: undefined,
renderDay: undefined,
allowKeyboardControl: false,
shouldDisableDate: () => false,
allowKeyboardControl: true,
};

public static getDerivedStateFromProps(nextProps: CalendarProps, state: CalendarState) {
Expand Down
3 changes: 0 additions & 3 deletions lib/src/DatePicker/components/CalendarHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,10 @@ export const CalendarHeader: React.SFC<CalendarHeaderProps> = ({
(CalendarHeader as any).propTypes = {
currentMonth: PropTypes.object.isRequired,
onMonthChange: PropTypes.func.isRequired,
classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
leftArrowIcon: PropTypes.node,
rightArrowIcon: PropTypes.node,
disablePrevMonth: PropTypes.bool,
disableNextMonth: PropTypes.bool,
utils: PropTypes.object.isRequired,
slideDirection: PropTypes.oneOf(['right', 'left']).isRequired,
innerRef: PropTypes.any,
};
Expand Down
5 changes: 0 additions & 5 deletions lib/src/DatePicker/components/SlideTransition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,13 @@ const SlideTransition: React.SFC<SlideTransitionProps> = ({
);

(SlideTransition as any).propTypes = {
classes: PropTypes.shape({}).isRequired,
children: PropTypes.node.isRequired,
className: PropTypes.string,
slideDirection: PropTypes.oneOf(['left', 'right']).isRequired,
transKey: PropTypes.string.isRequired,
innerRef: PropTypes.any,
};

SlideTransition.defaultProps = {
className: undefined,
};

export const styles = (theme: Theme) => {
const slideTransition = theme.transitions.create('transform', {
duration: animationDuration,
Expand Down
8 changes: 3 additions & 5 deletions lib/src/DatePicker/components/YearSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as PropTypes from 'prop-types';
import * as React from 'react';
import { findDOMNode } from 'react-dom';
import { withUtils, WithUtilsProps } from '../../_shared/WithUtils';
import DomainPropTypes, { DateType } from '../../constants/prop-types';
import { DateType, DomainPropTypes } from '../../constants/prop-types';
import { MaterialUiPickersDate } from '../../typings/date';
import Year from './Year';

Expand All @@ -23,17 +23,15 @@ export class YearSelection extends React.PureComponent<YearSelectionProps> {
date: PropTypes.shape({}).isRequired,
minDate: DomainPropTypes.date,
maxDate: DomainPropTypes.date,
classes: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired,
disablePast: PropTypes.bool,
disableFuture: PropTypes.bool,
animateYearScrolling: PropTypes.bool,
utils: PropTypes.object.isRequired,
innerRef: PropTypes.any,
};

public static defaultProps = {
animateYearScrolling: false,
minDate: '1900-01-01',
maxDate: '2100-01-01',
};

public selectedYearRef?: React.ReactInstance = undefined;
Expand Down
35 changes: 3 additions & 32 deletions lib/src/DateTimePicker/DateTimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import View from './components/DateTimePickerView';
import { Omit } from '@material-ui/core';
import { withUtils, WithUtilsProps } from '../_shared/WithUtils';
import DateTimePickerView, { DateTimePickerViewType } from '../constants/DateTimePickerView';
import DomainPropTypes from '../constants/prop-types';
import { BaseDatePickerProps } from '../DatePicker/DatePicker';
import { MaterialUiPickersDate } from '../typings/date';

Expand Down Expand Up @@ -45,28 +44,9 @@ interface DateTimePickerState {

export class DateTimePicker extends React.Component<DateTimePickerProps, DateTimePickerState> {
public static propTypes: any = {
allowKeyboardControl: PropTypes.bool,
ampm: PropTypes.bool,
animateYearScrolling: PropTypes.bool,
autoSubmit: PropTypes.bool,
date: PropTypes.object.isRequired,
initialFocusedDate: PropTypes.any,
innerRef: PropTypes.any,
dateRangeIcon: PropTypes.node,
disableFuture: PropTypes.bool,
disablePast: PropTypes.bool,
leftArrowIcon: PropTypes.node,
maxDate: DomainPropTypes.date.isRequired,
minDate: DomainPropTypes.date.isRequired,
onChange: PropTypes.func.isRequired,
openTo: PropTypes.oneOf(Object.keys(DateTimePickerView).map(key => DateTimePickerView[key]))
.isRequired,
renderDay: PropTypes.func,
rightArrowIcon: PropTypes.node,
shouldDisableDate: PropTypes.func,
openTo: PropTypes.oneOf(Object.keys(DateTimePickerView).map(key => DateTimePickerView[key])),
showTabs: PropTypes.bool,
timeIcon: PropTypes.node,
utils: PropTypes.object.isRequired,
ViewContainerComponent: PropTypes.oneOfType([
PropTypes.string,
PropTypes.func,
Expand All @@ -75,19 +55,10 @@ export class DateTimePicker extends React.Component<DateTimePickerProps, DateTim
};

public static defaultProps = {
allowKeyboardControl: false,
ampm: true,
animateYearScrolling: false,
autoSubmit: true,
dateRangeIcon: undefined,
disableFuture: false,
disablePast: false,
leftArrowIcon: undefined,
renderDay: undefined,
rightArrowIcon: undefined,
shouldDisableDate: undefined,
showTabs: true,
timeIcon: undefined,
ampm: true,
openTo: 'date' as DateTimePickerView,
ViewContainerComponent: 'div',
};

Expand Down
Loading

0 comments on commit b67c1ee

Please sign in to comment.