Skip to content

Commit

Permalink
Support "empty" value in pickers' UX (mui#1770)
Browse files Browse the repository at this point in the history
* Support empty dates for the DatePicker

* Support empty dates for TimePicker

* Support empty dates for mobile toobars

* Support empty dates in YearSelection

* Introduce `toolbarPlaceholder` prop for customization of empty date text

* Add tests

* Do not dispatch `changeFocusedDay` on each mount

* Fix crashes when rendering empty date with luxon and moment

* [TimePicker] Do not throw validation error if value={null}

* Update props description for TimePicker validation props

* Refactor ternary operator to aviod negatiation

* Remove `defaultHighlight` prop
  • Loading branch information
dmtrKovalenko authored May 17, 2020
1 parent cc7b04c commit b87e674
Show file tree
Hide file tree
Showing 28 changed files with 372 additions and 215 deletions.
10 changes: 9 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"cSpell.words": ["Formik", "Notistack", "Sourcable", "Unparsed", "ampm", "patreon"],
"cSpell.words": [
"Formik",
"Notistack",
"Sourcable",
"Unparsed",
"ampm",
"datetimepicker",
"patreon"
],
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"typescript.tsdk": "node_modules/typescript/lib",
"javascript.implicitProjectConfig.checkJs": true
Expand Down
11 changes: 6 additions & 5 deletions docs/pages/demo/datepicker/DatePickers.example.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,35 @@ function DatePickersVariants(props) {
return (
<Fragment>
<MobileDatePicker
renderInput={props => <TextField {...props} />}
clearable
label="For mobile"
value={selectedDate}
onChange={date => handleDateChange(date)}
inputFormat={props.__willBeReplacedGetFormatString({
moment: 'MM/DD/YYYY',
dateFns: 'MM/dd/yyyy',
})}
toolbarPlaceholder="Enter Date"
value={selectedDate}
onChange={date => handleDateChange(date)}
renderInput={props => <TextField {...props} />}
/>

<DesktopDatePicker
autoOk
label="For desktop"
renderInput={props => <TextField {...props} />}
minDate={new Date('2017-01-01')}
value={selectedDate}
onChange={date => handleDateChange(date)}
renderInput={props => <TextField {...props} />}
/>

<DatePicker
disableFuture
renderInput={props => <TextField {...props} />}
label="Responsive"
openTo="year"
views={['year', 'month', 'date']}
value={selectedDate}
onChange={date => handleDateChange(date)}
renderInput={props => <TextField {...props} />}
/>
</Fragment>
);
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/demo/timepicker/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Hidden } from '@material-ui/core';

import * as TimeValidation from './TimeValidation.example';
import * as BasicTimePicker from './BasicTimePicker.example';
import * as InlineTimePicker from './InlineTimePicker.example';
import * as TimePickers from './TimePickers.example';
import * as StaticTimePicker from './StaticTimePicker.example';
import * as SecondsTimePicker from './SecondsTimePicker.example';

Expand All @@ -27,7 +27,7 @@ A time picker should adjust to a user’s preferred time setting, i.e. the 12-ho

#### Responsiveness

<Example source={InlineTimePicker} />
<Example source={TimePickers} />

#### Time Validation

Expand Down
142 changes: 78 additions & 64 deletions docs/prop-types.json

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

21 changes: 13 additions & 8 deletions lib/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
{
"build/dist/material-ui-pickers.esm.js": {
"bundled": 190258,
"minified": 102356,
"gzipped": 26649,
"bundled": 191749,
"minified": 102786,
"gzipped": 26840,
"treeshaked": {
"rollup": {
"code": 83408,
"code": 83738,
"import_statements": 2121
},
"webpack": {
"code": 92884
"code": 93230
}
}
},
"build/dist/material-ui-pickers.umd.js": {
"bundled": 301162,
"minified": 117618,
"gzipped": 33567
"bundled": 302846,
"minified": 118066,
"gzipped": 33767
},
"build/dist/material-ui-pickers.umd.min.js": {
"bundled": 260318,
"minified": 108307,
"gzipped": 30847
}
}
Loading

0 comments on commit b87e674

Please sign in to comment.