This repository has been archived by the owner on Dec 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
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 #1507 from metasfresh/dev-1387
- Loading branch information
Showing
10 changed files
with
160 additions
and
27 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
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
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,69 @@ | ||
import React from "react"; | ||
import DateTime from "react-datetime"; | ||
import CalendarContainer from "react-datetime/src/CalendarContainer"; | ||
import TetherComponent from "react-tether"; | ||
|
||
export default class TetheredDateTime extends DateTime { | ||
render() { | ||
const { open } = this.state; | ||
let className = | ||
"rdt" + | ||
(this.props.className | ||
? Array.isArray(this.props.className) | ||
? " " + this.props.className.join(" ") | ||
: " " + this.props.className | ||
: ""); | ||
let children = []; | ||
|
||
if (this.props.input) { | ||
const props = { | ||
type: "text", | ||
className: "form-control", | ||
onFocus: this.openCalendar, | ||
onChange: this.onInputChange, | ||
onKeyDown: this.onInputKey, | ||
value: this.state.inputValue, | ||
...this.props.inputProps | ||
}; | ||
|
||
if (this.props.renderInput) { | ||
children = [ | ||
<div key="i">{this.props.renderInput(props, this.openCalendar)}</div> | ||
]; | ||
} else { | ||
children = [<input key="i" {...props} />]; | ||
} | ||
} else { | ||
className += " rdtStatic"; | ||
} | ||
|
||
return ( | ||
<div className={className}> | ||
<TetherComponent | ||
attachment="top left" | ||
targetAttachment="bottom left" | ||
constraints={[ | ||
{ | ||
to: "scrollParent" | ||
}, | ||
{ | ||
to: "window", | ||
pin: ["bottom"] | ||
} | ||
]} | ||
> | ||
{children} | ||
{open && ( | ||
<div className="rdtPicker"> | ||
<CalendarContainer | ||
view={this.state.currentView} | ||
viewProps={this.getComponentProps()} | ||
onClickOutside={this.handleClickOutside} | ||
/> | ||
</div> | ||
)} | ||
</TetherComponent> | ||
</div> | ||
); | ||
} | ||
} |
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