forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve
renderInput
spreading experience (mui#1760)
* Improve input customization exprience and add new examples * Remove data-mui-test from renderInput props * Fix Cypress tests and ts error
- Loading branch information
1 parent
30c5bed
commit 7d6525b
Showing
10 changed files
with
109 additions
and
64 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React, { useState } from 'react'; | ||
import { styled } from '@material-ui/core'; | ||
import { DesktopDatePicker } from '@material-ui/pickers'; | ||
|
||
const InputContainer = styled('div')({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
}); | ||
|
||
function CustomInput() { | ||
const [selectedDate, handleDateChange] = useState(new Date()); | ||
|
||
return ( | ||
<DesktopDatePicker | ||
label="Advanced keyboard" | ||
value={selectedDate} | ||
onChange={date => handleDateChange(date)} | ||
renderInput={({ ref, inputProps, InputProps }) => ( | ||
<InputContainer ref={ref}> | ||
<input {...inputProps} /> | ||
{InputProps?.endAdornment} | ||
</InputContainer> | ||
)} | ||
/> | ||
); | ||
} | ||
|
||
export default CustomInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
docs/pages/demo/daterangepicker/CustomRangeInputs.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React, { useState } from 'react'; | ||
import { DateRangePicker, DateRange } from '@material-ui/pickers'; | ||
|
||
function CustomRangeInputs() { | ||
const [selectedDate, handleDateChange] = useState<DateRange>([null, null]); | ||
|
||
return ( | ||
<DateRangePicker | ||
label="Advanced keyboard" | ||
value={selectedDate} | ||
onChange={date => handleDateChange(date)} | ||
renderInput={(startProps, endProps) => ( | ||
<> | ||
<input ref={startProps.ref as React.Ref<HTMLInputElement>} {...startProps.inputProps} /> | ||
<input ref={endProps.ref as React.Ref<HTMLInputElement>} {...endProps.inputProps} /> | ||
</> | ||
)} | ||
/> | ||
); | ||
} | ||
|
||
export default CustomRangeInputs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
{ | ||
"build/dist/material-ui-pickers.esm.js": { | ||
"bundled": 188938, | ||
"minified": 101335, | ||
"gzipped": 26402, | ||
"bundled": 189105, | ||
"minified": 101411, | ||
"gzipped": 26429, | ||
"treeshaked": { | ||
"rollup": { | ||
"code": 83375, | ||
"code": 83443, | ||
"import_statements": 2121 | ||
}, | ||
"webpack": { | ||
"code": 92851 | ||
"code": 92919 | ||
} | ||
} | ||
}, | ||
"build/dist/material-ui-pickers.umd.js": { | ||
"bundled": 299832, | ||
"minified": 116954, | ||
"gzipped": 33374 | ||
"bundled": 300017, | ||
"minified": 117022, | ||
"gzipped": 33387 | ||
}, | ||
"build/dist/material-ui-pickers.umd.min.js": { | ||
"bundled": 258486, | ||
"minified": 107815, | ||
"gzipped": 30601 | ||
"bundled": 258671, | ||
"minified": 107883, | ||
"gzipped": 30626 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters