-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1536 from topcoder-platform/develop
v0.20.8
- Loading branch information
Showing
10 changed files
with
222 additions
and
35 deletions.
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React, { useEffect, useState, useImperativeHandle, forwardRef } from 'react' | ||
import PropTypes from 'prop-types' | ||
import 'react-day-picker/lib/style.css' | ||
import 'rc-time-picker/assets/index.css' | ||
import DateTime from '@nateradebaugh/react-datetime' | ||
import '@nateradebaugh/react-datetime/scss/styles.scss' | ||
|
||
const DateInput = forwardRef(({ | ||
onChange, | ||
value, | ||
isValidDate, | ||
dateFormat, | ||
timeFormat, | ||
className | ||
}, ref) => { | ||
const [localValue, setLocalValue] = useState(value) | ||
useEffect(() => { | ||
setLocalValue(value) | ||
}, [value]) | ||
|
||
useImperativeHandle(ref, () => ({ | ||
forceReset: () => { | ||
setLocalValue(value) | ||
} | ||
})) | ||
|
||
return ( | ||
<DateTime | ||
className={className} | ||
value={localValue} | ||
onChange={newValue => { | ||
setLocalValue(newValue) | ||
}} | ||
onBlur={onChange} | ||
isValidDate={isValidDate} | ||
dateFormat={dateFormat} | ||
timeFormat={timeFormat} | ||
/> | ||
) | ||
}) | ||
|
||
DateInput.defaultProps = { | ||
onChange: () => {}, | ||
isValidDate: () => true, | ||
value: null, | ||
dateFormat: null, | ||
timeFormat: null, | ||
className: null | ||
} | ||
|
||
DateInput.propTypes = { | ||
onChange: PropTypes.func, | ||
isValidDate: PropTypes.func, | ||
value: PropTypes.any, | ||
dateFormat: PropTypes.string, | ||
timeFormat: PropTypes.string, | ||
className: PropTypes.string | ||
} | ||
export default DateInput |
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
Oops, something went wrong.