Skip to content

Commit

Permalink
Revert "[DateTime] Add dayPickerProps to datetime components" (#1693)
Browse files Browse the repository at this point in the history
* Revert "Prepare Release 1.31.0 (#1687)"

This reverts commit b55feef.

* Revert "[DateTime] Add dayPickerProps to datetime components (#1647)"

This reverts commit 21f63bc.
  • Loading branch information
cmslewis authored Oct 9, 2017
1 parent b55feef commit 84b7b56
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 557 deletions.
12 changes: 0 additions & 12 deletions packages/datetime/src/dateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import * as classNames from "classnames";
import * as moment from "moment";
import * as React from "react";
import * as ReactDayPicker from "react-day-picker";

import {
AbstractComponent,
Expand Down Expand Up @@ -50,16 +49,6 @@ export interface IDateInputProps extends IDatePickerBaseProps, IProps {
*/
closeOnSelection?: boolean;

/**
* Props to pass to ReactDayPicker. See API documentation
* [here](http://react-day-picker.js.org/docs/api-daypicker.html).
*
* The following props are managed by the component and cannot be configured:
* `canChangeMonth`, `captionElement`, `fromMonth` (use `minDate`), `month` (use
* `initialMonth`), `toMonth` (use `maxDate`).
*/
dayPickerProps?: ReactDayPicker.Props;

/**
* Whether the date input is non-interactive.
* @default false
Expand Down Expand Up @@ -158,7 +147,6 @@ export interface IDateInputState {
export class DateInput extends AbstractComponent<IDateInputProps, IDateInputState> {
public static defaultProps: IDateInputProps = {
closeOnSelection: true,
dayPickerProps: {},
disabled: false,
format: "YYYY-MM-DD",
invalidDateMessage: "Invalid date",
Expand Down
53 changes: 7 additions & 46 deletions packages/datetime/src/datePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ export interface IDatePickerProps extends IDatePickerBaseProps, IProps {
*/
canClearSelection?: boolean;

/**
* Props to pass to ReactDayPicker. See API documentation
* [here](http://react-day-picker.js.org/docs/api-daypicker.html).
*
* The following props are managed by the component and cannot be configured:
* `canChangeMonth`, `captionElement`, `fromMonth` (use `minDate`), `month` (use
* `initialMonth`), `toMonth` (use `maxDate`).
*/
dayPickerProps?: ReactDayPicker.Props;

/**
* Initial day the calendar will display as selected.
* This should not be set if `value` is set.
Expand Down Expand Up @@ -71,7 +61,6 @@ export interface IDatePickerState {
export class DatePicker extends AbstractComponent<IDatePickerProps, IDatePickerState> {
public static defaultProps: IDatePickerProps = {
canClearSelection: true,
dayPickerProps: {},
maxDate: getDefaultMaxDate(),
minDate: getDefaultMinDate(),
showActionsBar: false,
Expand Down Expand Up @@ -117,30 +106,20 @@ export class DatePicker extends AbstractComponent<IDatePickerProps, IDatePickerS
}

public render() {
const {
className,
dayPickerProps,
locale,
localeUtils,
maxDate,
minDate,
modifiers,
showActionsBar,
} = this.props;
const { className, locale, localeUtils, maxDate, minDate, showActionsBar } = this.props;
const { displayMonth, displayYear } = this.state;

return (
<div className={classNames(Classes.DATEPICKER, className)}>
<ReactDayPicker
enableOutsideDays={true}
locale={locale}
localeUtils={localeUtils}
modifiers={modifiers}
{...dayPickerProps}
canChangeMonth={true}
captionElement={this.renderCaption}
disabledDays={this.getDisabledDaysModifier()}
disabledDays={this.disabledDays}
enableOutsideDays={true}
fromMonth={minDate}
locale={locale}
localeUtils={localeUtils}
modifiers={this.props.modifiers}
month={new Date(displayYear, displayMonth)}
onDayClick={this.handleDayClick}
onMonthChange={this.handleMonthChange}
Expand Down Expand Up @@ -192,12 +171,6 @@ export class DatePicker extends AbstractComponent<IDatePickerProps, IDatePickerS

private disabledDays = (day: Date) => !DateUtils.isDayInRange(day, [this.props.minDate, this.props.maxDate]);

private getDisabledDaysModifier = () => {
const { dayPickerProps: { disabledDays } } = this.props;

return disabledDays instanceof Array ? [this.disabledDays, ...disabledDays] : [this.disabledDays, disabledDays];
};

private renderCaption = (props: ReactDayPicker.CaptionElementProps) => (
<DatePickerCaption
{...props}
Expand Down Expand Up @@ -225,13 +198,7 @@ export class DatePicker extends AbstractComponent<IDatePickerProps, IDatePickerS
);
}

private handleDayClick = (
day: Date,
modifiers: ReactDayPicker.DayModifiers,
e: React.MouseEvent<HTMLDivElement>,
) => {
Utils.safeInvoke(this.props.dayPickerProps.onDayClick, day, modifiers, e);

private handleDayClick = (day: Date, modifiers: ReactDayPicker.DayModifiers) => {
let newValue = day;

if (this.props.canClearSelection && modifiers.selected) {
Expand Down Expand Up @@ -301,8 +268,6 @@ export class DatePicker extends AbstractComponent<IDatePickerProps, IDatePickerS
}
}

Utils.safeInvoke(this.props.dayPickerProps.onMonthChange, value);

this.setStateWithValueIfUncontrolled({ displayMonth, displayYear }, value);
};

Expand All @@ -314,8 +279,6 @@ export class DatePicker extends AbstractComponent<IDatePickerProps, IDatePickerS
Utils.safeInvoke(this.props.onChange, value, false);
}

Utils.safeInvoke(this.props.dayPickerProps.onMonthChange, value);

this.setStateWithValueIfUncontrolled({ displayMonth }, value);
};

Expand All @@ -340,8 +303,6 @@ export class DatePicker extends AbstractComponent<IDatePickerProps, IDatePickerS
}
}

Utils.safeInvoke(this.props.dayPickerProps.onMonthChange, value);

this.setStateWithValueIfUncontrolled({ displayMonth, displayYear }, value);
};

Expand Down
12 changes: 0 additions & 12 deletions packages/datetime/src/dateRangeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import * as classNames from "classnames";
import * as moment from "moment";
import * as React from "react";
import * as ReactDayPicker from "react-day-picker";

import {
AbstractComponent,
Expand Down Expand Up @@ -62,16 +61,6 @@ export interface IDateRangeInputProps extends IDatePickerBaseProps, IProps {
*/
contiguousCalendarMonths?: boolean;

/**
* Props to pass to ReactDayPicker. See API documentation
* [here](http://react-day-picker.js.org/docs/api-daypicker.html).
*
* The following props are managed by the component and cannot be configured:
* `canChangeMonth`, `captionElement`, `numberOfMonths`, `fromMonth` (use
* `minDate`), `month` (use `initialMonth`), `toMonth` (use `maxDate`).
*/
dayPickerProps?: ReactDayPicker.Props;

/**
* The default date range to be used in the component when uncontrolled.
* This will be ignored if `value` is set.
Expand Down Expand Up @@ -218,7 +207,6 @@ export class DateRangeInput extends AbstractComponent<IDateRangeInputProps, IDat
allowSingleDayRange: false,
closeOnSelection: true,
contiguousCalendarMonths: true,
dayPickerProps: {},
disabled: false,
endInputProps: {},
format: "YYYY-MM-DD",
Expand Down
Loading

1 comment on commit 84b7b56

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert "[DateTime] Add dayPickerProps to datetime components" (#1693)

Preview: documentation
Coverage: core | datetime

Please sign in to comment.