Skip to content

51374 add no defined ranges option #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions demo/src/components/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,33 @@ export default class Main extends Component {
</div>
</Section>

<Section title="DateRangePicker - 2 month with no Defined Ranges">
<div>
<input
type="text"
readOnly
value={formatDateDisplay(this.state.dateRangePicker.selection.startDate)}
/>
<input
type="text"
readOnly
value={formatDateDisplay(this.state.dateRangePicker.selection.endDate)}
/>
</div>
<div>
<DateRangePicker
onChange={this.handleRangeChange.bind(this, 'dateRangePicker')}
showSelectionPreview={true}
moveRangeOnFirstSelection={false}
className={'PreviewArea'}
months={2}
ranges={[this.state.dateRangePicker.selection]}
direction="horizontal"
showDefinedRange={false}
/>
</div>
</Section>

<Section title="DateRangePicker - Vertical Infinite">
<div>
<input
Expand Down
20 changes: 11 additions & 9 deletions src/components/DateRangePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ class DateRangePicker extends Component {
const { focusedRange } = this.state;
return (
<div className={classnames(this.styles.dateRangePickerWrapper, this.props.className)}>
<DefinedRange
focusedRange={focusedRange}
onPreviewChange={value => this.dateRange.updatePreview(value)}
{...this.props}
range={this.props.ranges[focusedRange[0]]}
className={undefined}
onChange={specialHandleChange}
label={this.props.label}
/>
{ this.props.showDefinedRange !== false ? (
<DefinedRange
focusedRange={focusedRange}
onPreviewChange={value => this.dateRange.updatePreview(value)}
{...this.props}
range={this.props.ranges[focusedRange[0]]}
className={undefined}
onChange={specialHandleChange}
label={this.props.label}
/>
) : null}
<DateRange
onRangeFocusChange={focusedRange => this.setState({ focusedRange })}
focusedRange={focusedRange}
Expand Down