-
Notifications
You must be signed in to change notification settings - Fork 832
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve input customization exprience and add new examples
- Loading branch information
1 parent
30c5bed
commit d9c7277
Showing
8 changed files
with
90 additions
and
49 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
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