Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing prop types #1761

Merged
merged 7 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/pages/demo/datepicker/CustomInput.example.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { styled } from '@material-ui/core';
import { styled } from '@material-ui/core/styles';
import { DesktopDatePicker } from '@material-ui/pickers';

const InputContainer = styled('div')({
Expand Down
8 changes: 4 additions & 4 deletions docs/prop-types.json

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

21 changes: 8 additions & 13 deletions lib/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
{
"build/dist/material-ui-pickers.esm.js": {
"bundled": 189105,
"minified": 101411,
"gzipped": 26429,
"bundled": 190258,
"minified": 102356,
"gzipped": 26649,
"treeshaked": {
"rollup": {
"code": 83443,
"code": 83408,
"import_statements": 2121
},
"webpack": {
"code": 92919
"code": 92884
}
}
},
"build/dist/material-ui-pickers.umd.js": {
"bundled": 300017,
"minified": 117022,
"gzipped": 33387
},
"build/dist/material-ui-pickers.umd.min.js": {
"bundled": 258671,
"minified": 107883,
"gzipped": 30626
"bundled": 301162,
"minified": 117618,
"gzipped": 33567
}
}
9 changes: 9 additions & 0 deletions lib/src/DateRangePicker/DateRangePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as React from 'react';
import * as PropTypes from 'prop-types';
import { date } from '../constants/prop-types';
import { useUtils } from '../_shared/hooks/useUtils';
import { MobileWrapper } from '../wrappers/MobileWrapper';
import { DateRangeInputProps } from './DateRangePickerInput';
Expand Down Expand Up @@ -128,6 +130,13 @@ export function makeRangePicker<TWrapper extends SomeWrapper>(Wrapper: TWrapper)
);
}

RangePickerWithStateAndWrapper.propTypes = {
value: PropTypes.arrayOf(date).isRequired,
onChange: PropTypes.func.isRequired,
startText: PropTypes.node,
endText: PropTypes.node,
};

return React.forwardRef<
HTMLDivElement,
React.ComponentProps<typeof RangePickerWithStateAndWrapper>
Expand Down
19 changes: 17 additions & 2 deletions lib/src/DateRangePicker/DateRangePickerInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import * as PropTypes from 'prop-types';
import { RangeInput, DateRange } from './RangeTypes';
import { useUtils } from '../_shared/hooks/useUtils';
import { makeStyles } from '@material-ui/core/styles';
Expand Down Expand Up @@ -32,8 +33,12 @@ export const useStyles = makeStyles(

export interface ExportedDateRangePickerInputProps {
/**
* Render input component for date range. Where `props` – [TextField](https://material-ui.com/api/text-field/#textfield-api) component props
* @example ```jsx
* The `renderInput` prop allows you to customize the rendered input.
* The `startProps` and `endProps` arguments of this render prop contains props of [TextField](https://material-ui.com/api/text-field/#textfield-api),
* that you need to forward to the range start/end inputs respectively.
* Pay specific attention to the `ref` and `inputProps` keys.
* @example
* ```jsx
* <DateRangePicker
* renderInput={(startProps, endProps) => (
<>
Expand Down Expand Up @@ -183,3 +188,13 @@ export const DateRangePickerInput: React.FC<DateRangeInputProps> = ({
</div>
);
};

DateRangePickerInput.propTypes = {
acceptRegex: PropTypes.instanceOf(RegExp),
getOpenDialogAriaText: PropTypes.func,
mask: PropTypes.string,
OpenPickerButtonProps: PropTypes.object,
openPickerIcon: PropTypes.node,
renderInput: PropTypes.func.isRequired,
rifmFormatter: PropTypes.func,
};
6 changes: 6 additions & 0 deletions lib/src/DateRangePicker/DateRangePickerView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import * as PropTypes from 'prop-types';
import { isRangeValid } from '../_helpers/date-utils';
import { MaterialUiPickersDate } from '../typings/date';
import { BasePickerProps } from '../typings/BasePicker';
Expand Down Expand Up @@ -212,3 +213,8 @@ export const DateRangePickerView: React.FC<DateRangePickerViewProps> = ({
</div>
);
};

DateRangePickerView.propTypes = {
disableAutoMonthSwitching: PropTypes.bool,
calendars: PropTypes.oneOf([1, 2, 3]),
};
2 changes: 1 addition & 1 deletion lib/src/Picker/Picker.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import clsx from 'clsx';
import KeyboardDateInput from '../_shared/KeyboardDateInput';
import { useViews } from '../_shared/hooks/useViews';
import { makeStyles } from '@material-ui/core/styles';
import { DateTimePickerView } from '../DateTimePicker';
import { ParsableDate } from '../constants/prop-types';
import { BasePickerProps } from '../typings/BasePicker';
import { MaterialUiPickersDate } from '../typings/date';
import { DatePickerView } from '../DatePicker/DatePicker';
import { KeyboardDateInput } from '../_shared/KeyboardDateInput';
import { useIsLandscape } from '../_shared/hooks/useIsLandscape';
import { DIALOG_WIDTH, VIEW_HEIGHT } from '../constants/dimensions';
import { WrapperVariantContext } from '../wrappers/WrapperVariantContext';
Expand Down
11 changes: 10 additions & 1 deletion lib/src/_shared/KeyboardDateInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import * as PropTypes from 'prop-types';
import IconButton from '@material-ui/core/IconButton';
import InputAdornment from '@material-ui/core/InputAdornment';
import { useUtils } from './hooks/useUtils';
Expand Down Expand Up @@ -50,4 +51,12 @@ export const KeyboardDateInput: React.FC<DateInputProps & DateInputRefs> = ({
});
};

export default KeyboardDateInput;
KeyboardDateInput.propTypes = {
renderInput: PropTypes.func.isRequired,
mask: PropTypes.string,
rifmFormatter: PropTypes.func,
openPickerIcon: PropTypes.node,
OpenPickerButtonProps: PropTypes.object,
acceptRegex: PropTypes.instanceOf(RegExp),
getOpenDialogAriaText: PropTypes.func,
};
15 changes: 13 additions & 2 deletions lib/src/_shared/PureDateInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import * as PropTypes from 'prop-types';
import { onSpaceOrEnter } from '../_helpers/utils';
import { ParsableDate } from '../constants/prop-types';
import { MaterialUiPickersDate } from '../typings/date';
Expand Down Expand Up @@ -27,7 +28,9 @@ export interface DateInputProps<TInputValue = ParsableDate, TDateValue = Materia
// ?? TODO when it will be possible to display "empty" date in datepicker use it instead of ignoring invalid inputs
ignoreInvalidInputs?: boolean;
/**
* Render input component. Where `props` – [TextField](https://material-ui.com/api/text-field/#textfield-api) component props
* The `renderInput` prop allows you to customize the rendered input.
* The `props` argument of this render prop contains props of [TextField](https://material-ui.com/api/text-field/#textfield-api) that you need to forward.
* Pay specific attention to the `ref` and `inputProps` keys.
* @example ```jsx
* renderInput={props => <TextField {...props} />}
* ````
Expand Down Expand Up @@ -136,4 +139,12 @@ export const PureDateInput: React.FC<DateInputProps & DateInputRefs> = ({
});
};

PureDateInput.displayName = 'PureDateInput';
PureDateInput.propTypes = {
acceptRegex: PropTypes.instanceOf(RegExp),
getOpenDialogAriaText: PropTypes.func,
mask: PropTypes.string,
OpenPickerButtonProps: PropTypes.object,
openPickerIcon: PropTypes.node,
renderInput: PropTypes.func.isRequired,
rifmFormatter: PropTypes.func,
};
2 changes: 1 addition & 1 deletion lib/src/constants/prop-types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as PropTypes from 'prop-types';
import { MaterialUiPickersDate } from '../typings/date';

const date = PropTypes.oneOfType([
export const date = PropTypes.oneOfType([
PropTypes.object,
PropTypes.string,
PropTypes.number,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/wrappers/DesktopWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import * as PropTypes from 'prop-types';
import KeyboardDateInput from '../_shared/KeyboardDateInput';
import Popover, { PopoverProps } from '@material-ui/core/Popover';
import { WrapperProps } from './Wrapper';
import { StaticWrapperProps } from './StaticWrapper';
import { makeStyles } from '@material-ui/core/styles';
import { InnerMobileWrapperProps } from './MobileWrapper';
import { WrapperVariantContext } from './WrapperVariantContext';
import { IS_TOUCH_DEVICE_MEDIA } from '../constants/dimensions';
import { KeyboardDateInput } from '../_shared/KeyboardDateInput';
import { InnerDesktopPopperWrapperProps } from './DesktopPopperWrapper';

export interface InnerDesktopWrapperProps {
Expand Down