@blueprintjs/datetime
Advanced tools
Comparing version 1.11.0 to 1.12.0
@@ -5,2 +5,3 @@ /// <reference types="react" /> | ||
import { IDatePickerBaseProps } from "./datePickerCore"; | ||
import { TimePickerPrecision } from "./timePicker"; | ||
export interface IDateInputProps extends IDatePickerBaseProps, IProps { | ||
@@ -74,2 +75,7 @@ /** | ||
value?: Date; | ||
/** | ||
* Adds a time chooser to the bottom of the popover. | ||
* Passed to the `DateTimePicker` component. | ||
*/ | ||
timePrecision?: TimePickerPrecision; | ||
} | ||
@@ -76,0 +82,0 @@ export interface IDateInputState { |
@@ -17,2 +17,3 @@ /* | ||
var datePickerCore_1 = require("./datePickerCore"); | ||
var dateTimePicker_1 = require("./dateTimePicker"); | ||
var DateInput = (function (_super) { | ||
@@ -133,7 +134,10 @@ tslib_1.__extends(DateInput, _super); | ||
var date = this.state.isInputFocused ? moment(this.state.valueString, this.props.format) : this.state.value; | ||
var popoverContent = (React.createElement(datePicker_1.DatePicker, tslib_1.__assign({}, this.props, { canClearSelection: this.props.canClearSelection, defaultValue: null, onChange: this.handleDateChange, value: this.isMomentValidAndInRange(this.state.value) ? dateUtils_1.fromMomentToDate(this.state.value) : null }))); | ||
var sharedProps = tslib_1.__assign({}, this.props, { onChange: this.handleDateChange, value: this.isMomentValidAndInRange(this.state.value) ? dateUtils_1.fromMomentToDate(this.state.value) : null }); | ||
var popoverContent = this.props.timePrecision === undefined | ||
? React.createElement(datePicker_1.DatePicker, tslib_1.__assign({}, sharedProps)) | ||
: React.createElement(dateTimePicker_1.DateTimePicker, tslib_1.__assign({}, sharedProps, { timePickerProps: { precision: this.props.timePrecision } })); | ||
var inputClasses = classNames({ | ||
"pt-intent-danger": !(this.isMomentValidAndInRange(date) || dateUtils_1.isMomentNull(date) || dateString === ""), | ||
}); | ||
return (React.createElement(core_1.Popover, { autoFocus: false, content: popoverContent, enforceFocus: false, inline: true, isOpen: this.state.isOpen, onClose: this.handleClosePopover, popoverClassName: "pt-dateinput-popover", position: this.props.popoverPosition }, | ||
return (React.createElement(core_1.Popover, { autoFocus: false, content: popoverContent, enforceFocus: false, inline: true, isOpen: this.state.isOpen && !this.props.disabled, onClose: this.handleClosePopover, popoverClassName: "pt-dateinput-popover", position: this.props.popoverPosition }, | ||
React.createElement(core_1.InputGroup, { className: inputClasses, disabled: this.props.disabled, inputRef: this.setInputRef, type: "text", onBlur: this.handleInputBlur, onChange: this.handleInputChange, onClick: this.handleInputClick, onFocus: this.handleInputFocus, placeholder: this.props.format, rightElement: this.props.rightElement, value: dateString }))); | ||
@@ -140,0 +144,0 @@ }; |
/// <reference types="react" /> | ||
import * as moment from "moment"; | ||
import { AbstractComponent, IInputGroupProps, IProps } from "@blueprintjs/core"; | ||
import { AbstractComponent, IInputGroupProps, IPopoverProps, IProps } from "@blueprintjs/core"; | ||
import { DateRange, DateRangeBoundary } from "./common/dateUtils"; | ||
import { IDatePickerBaseProps } from "./datePickerCore"; | ||
import { IDateRangeShortcut } from "./dateRangePicker"; | ||
export interface IDateRangeInputProps extends IDatePickerBaseProps, IProps { | ||
@@ -20,2 +21,8 @@ /** | ||
/** | ||
* Whether displayed months in the calendar are contiguous. | ||
* If false, each side of the calendar can move independently to non-contiguous months. | ||
* @default true | ||
*/ | ||
contiguousCalendarMonths?: boolean; | ||
/** | ||
* The default date range to be used in the component when uncontrolled. | ||
@@ -72,2 +79,7 @@ * This will be ignored if `value` is set. | ||
/** | ||
* The props to pass to the popover. | ||
* `autoFocus`, `content`, and `enforceFocus` will be ignored to avoid compromising usability. | ||
*/ | ||
popoverProps?: Partial<IPopoverProps>; | ||
/** | ||
* Whether the entire text field should be selected on focus. | ||
@@ -78,2 +90,10 @@ * @default false | ||
/** | ||
* Whether shortcuts to quickly select a range of dates are displayed or not. | ||
* If `true`, preset shortcuts will be displayed. | ||
* If `false`, no shortcuts will be displayed. | ||
* If an array is provided, the custom shortcuts will be displayed. | ||
* @default true | ||
*/ | ||
shortcuts?: boolean | IDateRangeShortcut[]; | ||
/** | ||
* Props to pass to the start-date input. | ||
@@ -80,0 +100,0 @@ */ |
@@ -91,3 +91,3 @@ /* | ||
}; | ||
_this.handleDateRangePickerHoverChange = function (hoveredRange, day) { | ||
_this.handleDateRangePickerHoverChange = function (hoveredRange, _hoveredDay, hoveredBoundary) { | ||
// ignore mouse events in the date-range picker if the popover is animating closed. | ||
@@ -98,143 +98,30 @@ if (!_this.state.isOpen) { | ||
if (hoveredRange == null) { | ||
// undo whatever focus changes we made while hovering | ||
// over various calendar dates | ||
var isEndInputFocused_1 = (_this.state.boundaryToModify === dateUtils_1.DateRangeBoundary.END); | ||
var isStartInputFocused_1 = !isEndInputFocused_1; | ||
var lastFocusedField = (isEndInputFocused_1) ? dateUtils_1.DateRangeBoundary.END : dateUtils_1.DateRangeBoundary.START; | ||
// undo whatever focus changes we made while hovering over various calendar dates | ||
var isEndInputFocused = (_this.state.boundaryToModify === dateUtils_1.DateRangeBoundary.END); | ||
_this.setState({ | ||
isEndInputFocused: isEndInputFocused_1, | ||
isStartInputFocused: isStartInputFocused_1, | ||
lastFocusedField: lastFocusedField, | ||
isEndInputFocused: isEndInputFocused, | ||
endHoverString: null, | ||
isStartInputFocused: !isEndInputFocused, | ||
lastFocusedField: _this.state.boundaryToModify, | ||
startHoverString: null, | ||
}); | ||
return; | ||
} | ||
var _a = _this.state, selectedStart = _a.selectedStart, selectedEnd = _a.selectedEnd, boundaryToModify = _a.boundaryToModify; | ||
var _b = dateUtils_1.fromDateRangeToMomentDateRange(hoveredRange), hoveredStart = _b[0], hoveredEnd = _b[1]; | ||
var _c = [hoveredStart, hoveredEnd].map(function (momentDate) { | ||
return _this.getFormattedDateString(momentDate); | ||
}), startHoverString = _c[0], endHoverString = _c[1]; | ||
var _d = [hoveredStart, hoveredEnd].map(function (d) { return !dateUtils_1.isMomentNull(d); }), isHoveredStartDefined = _d[0], isHoveredEndDefined = _d[1]; | ||
var _f = [selectedStart, selectedEnd].map(function (d) { return !dateUtils_1.isMomentNull(d); }), isStartDateSelected = _f[0], isEndDateSelected = _f[1]; | ||
var isModifyingStartBoundary = boundaryToModify === dateUtils_1.DateRangeBoundary.START; | ||
var isModifyingEndBoundary = !isModifyingStartBoundary; | ||
var hoveredDay = dateUtils_1.fromDateToMoment(day); | ||
// pull the existing values from state; we may not overwrite them. | ||
var _g = _this.state, isStartInputFocused = _g.isStartInputFocused, isEndInputFocused = _g.isEndInputFocused; | ||
if (isStartDateSelected && isEndDateSelected) { | ||
if (isHoveredStartDefined && isHoveredEndDefined) { | ||
if (hoveredStart.isSame(selectedStart, "day")) { | ||
// we'd be modifying the end date on click | ||
isStartInputFocused = false; | ||
isEndInputFocused = true; | ||
} | ||
else if (hoveredEnd.isSame(selectedEnd, "day")) { | ||
// we'd be modifying the start date on click | ||
isStartInputFocused = true; | ||
isEndInputFocused = false; | ||
} | ||
} | ||
else if (isHoveredStartDefined) { | ||
if (isModifyingStartBoundary && hoveredDay.isSame(selectedEnd, "day")) { | ||
// we'd be deselecting the end date on click | ||
isStartInputFocused = false; | ||
isEndInputFocused = true; | ||
} | ||
else if (isModifyingStartBoundary) { | ||
// we'd be specifying a new start date and clearing the end date on click | ||
isStartInputFocused = true; | ||
isEndInputFocused = false; | ||
} | ||
else { | ||
// we'd be deselecting the end date on click | ||
isStartInputFocused = false; | ||
isEndInputFocused = true; | ||
} | ||
} | ||
else if (isHoveredEndDefined) { | ||
if (isModifyingEndBoundary && hoveredDay.isSame(selectedStart, "day")) { | ||
// we'd be deselecting the start date on click | ||
isStartInputFocused = true; | ||
isEndInputFocused = false; | ||
} | ||
else if (isModifyingEndBoundary) { | ||
// we'd be specifying a new end date (clearing the start date) on click | ||
isStartInputFocused = false; | ||
isEndInputFocused = true; | ||
} | ||
else { | ||
// we'd be deselecting the start date on click | ||
isStartInputFocused = true; | ||
isEndInputFocused = false; | ||
} | ||
} | ||
else { | ||
var _a = dateUtils_1.fromDateRangeToMomentDateRange(hoveredRange), hoveredStart = _a[0], hoveredEnd = _a[1]; | ||
var isStartInputFocused = (hoveredBoundary != null) | ||
? hoveredBoundary === dateUtils_1.DateRangeBoundary.START | ||
: _this.state.isStartInputFocused; | ||
var isEndInputFocused = (hoveredBoundary != null) | ||
? hoveredBoundary === dateUtils_1.DateRangeBoundary.END | ||
: _this.state.isEndInputFocused; | ||
_this.setState({ | ||
isStartInputFocused: isStartInputFocused, | ||
isEndInputFocused: isEndInputFocused, | ||
endHoverString: _this.getFormattedDateString(hoveredEnd), | ||
lastFocusedField: (isStartInputFocused) ? dateUtils_1.DateRangeBoundary.START : dateUtils_1.DateRangeBoundary.END, | ||
shouldSelectAfterUpdate: _this.props.selectAllOnFocus, | ||
startHoverString: _this.getFormattedDateString(hoveredStart), | ||
wasLastFocusChangeDueToHover: true, | ||
}); | ||
} | ||
else if (isStartDateSelected) { | ||
if (isHoveredStartDefined && isHoveredEndDefined) { | ||
if (hoveredStart.isSame(selectedStart, "day")) { | ||
// we'd be modifying the end date on click, so focus the end field | ||
isStartInputFocused = false; | ||
isEndInputFocused = true; | ||
} | ||
else if (hoveredEnd.isSame(selectedStart, "day")) { | ||
// we'd be modifying the start date on click, so focus the start field | ||
isStartInputFocused = true; | ||
isEndInputFocused = false; | ||
} | ||
} | ||
else if (isHoveredStartDefined) { | ||
// we'd be replacing the start date on click | ||
isStartInputFocused = true; | ||
isEndInputFocused = false; | ||
} | ||
else if (isHoveredEndDefined) { | ||
// we'd be converting the selected start date to an end date | ||
isStartInputFocused = false; | ||
isEndInputFocused = true; | ||
} | ||
else { | ||
// we'd be deselecting start date on click | ||
isStartInputFocused = true; | ||
isEndInputFocused = false; | ||
} | ||
} | ||
else if (isEndDateSelected) { | ||
if (isHoveredStartDefined && isHoveredEndDefined) { | ||
if (hoveredEnd.isSame(selectedEnd, "day")) { | ||
// we'd be modifying the start date on click | ||
isStartInputFocused = true; | ||
isEndInputFocused = false; | ||
} | ||
else if (hoveredStart.isSame(selectedEnd, "day")) { | ||
// we'd be modifying the end date on click | ||
isStartInputFocused = false; | ||
isEndInputFocused = true; | ||
} | ||
} | ||
else if (isHoveredEndDefined) { | ||
// we'd be replacing the end date on click | ||
isStartInputFocused = false; | ||
isEndInputFocused = true; | ||
} | ||
else if (isHoveredStartDefined) { | ||
// we'd be converting the selected end date to a start date | ||
isStartInputFocused = true; | ||
isEndInputFocused = false; | ||
} | ||
else { | ||
// we'd be deselecting end date on click | ||
isStartInputFocused = false; | ||
isEndInputFocused = true; | ||
} | ||
} | ||
_this.setState({ | ||
startHoverString: startHoverString, | ||
endHoverString: endHoverString, | ||
isStartInputFocused: isStartInputFocused, | ||
isEndInputFocused: isEndInputFocused, | ||
lastFocusedField: (isStartInputFocused) ? dateUtils_1.DateRangeBoundary.START : dateUtils_1.DateRangeBoundary.END, | ||
shouldSelectAfterUpdate: _this.props.selectAllOnFocus, | ||
wasLastFocusChangeDueToHover: true, | ||
}); | ||
}; | ||
@@ -404,2 +291,3 @@ // Callbacks - Input | ||
_this.setState({ isOpen: false }); | ||
core_1.Utils.safeInvoke(_this.props.popoverProps.onClose); | ||
}; | ||
@@ -633,6 +521,6 @@ _this.dateStringToMoment = function (dateString) { | ||
var _a = this.props, startInputProps = _a.startInputProps, endInputProps = _a.endInputProps; | ||
var popoverContent = (React.createElement(dateRangePicker_1.DateRangePicker, { allowSingleDayRange: this.props.allowSingleDayRange, onChange: this.handleDateRangePickerChange, onHoverChange: this.handleDateRangePickerHoverChange, maxDate: this.props.maxDate, minDate: this.props.minDate, boundaryToModify: this.state.boundaryToModify, value: this.getSelectedRange() })); | ||
// allow custom props for each input group, but pass them in an order | ||
// that guarantees only some props are overridable. | ||
return (React.createElement(core_1.Popover, { autoFocus: false, content: popoverContent, enforceFocus: false, inline: true, isOpen: this.state.isOpen, onClose: this.handlePopoverClose, position: core_1.Position.BOTTOM_LEFT }, | ||
var popoverContent = (React.createElement(dateRangePicker_1.DateRangePicker, { allowSingleDayRange: this.props.allowSingleDayRange, boundaryToModify: this.state.boundaryToModify, contiguousCalendarMonths: this.props.contiguousCalendarMonths, onChange: this.handleDateRangePickerChange, onHoverChange: this.handleDateRangePickerHoverChange, maxDate: this.props.maxDate, minDate: this.props.minDate, shortcuts: this.props.shortcuts, value: this.getSelectedRange() })); | ||
// allow custom props for the popover and each input group, but pass them in an order that | ||
// guarantees only some props are overridable. | ||
return (React.createElement(core_1.Popover, tslib_1.__assign({ inline: true, isOpen: this.state.isOpen, position: core_1.Position.BOTTOM_LEFT }, this.props.popoverProps, { autoFocus: false, content: popoverContent, enforceFocus: false, onClose: this.handlePopoverClose }), | ||
React.createElement("div", { className: core_1.Classes.CONTROL_GROUP }, | ||
@@ -685,2 +573,3 @@ React.createElement(core_1.InputGroup, tslib_1.__assign({}, startInputProps, { className: this.getInputClasses(dateUtils_1.DateRangeBoundary.START, startInputProps), disabled: this.props.disabled, inputRef: this.refHandlers.startInputRef, onBlur: this.handleStartInputBlur, onChange: this.handleStartInputChange, onClick: this.handleInputClick, onFocus: this.handleStartInputFocus, onKeyDown: this.handleInputKeyDown, onMouseDown: this.handleInputMouseDown, placeholder: this.getInputPlaceholderString(dateUtils_1.DateRangeBoundary.START), value: this.getInputDisplayString(dateUtils_1.DateRangeBoundary.START) })), | ||
closeOnSelection: true, | ||
contiguousCalendarMonths: true, | ||
disabled: false, | ||
@@ -694,3 +583,5 @@ endInputProps: {}, | ||
overlappingDatesMessage: "Overlapping dates", | ||
popoverProps: {}, | ||
selectAllOnFocus: false, | ||
shortcuts: true, | ||
startInputProps: {}, | ||
@@ -697,0 +588,0 @@ }; |
@@ -27,7 +27,2 @@ /// <reference types="react" /> | ||
/** | ||
* Initial `DateRange` the calendar will display as selected. | ||
* This should not be set if `value` is set. | ||
*/ | ||
defaultValue?: DateRange; | ||
/** | ||
* Whether displayed months in the calendar are contiguous. | ||
@@ -39,2 +34,7 @@ * If false, each side of the calendar can move independently to non-contiguous months. | ||
/** | ||
* Initial `DateRange` the calendar will display as selected. | ||
* This should not be set if `value` is set. | ||
*/ | ||
defaultValue?: DateRange; | ||
/** | ||
* Called when the user selects a day. | ||
@@ -51,3 +51,3 @@ * If no days are selected, it will pass `[null, null]`. | ||
*/ | ||
onHoverChange?: (hoveredDates: DateRange, hoveredDay: Date) => void; | ||
onHoverChange?: (hoveredDates: DateRange, hoveredDay: Date, hoveredBoundary: DateRangeBoundary) => void; | ||
/** | ||
@@ -90,6 +90,2 @@ * Whether shortcuts to quickly select a range of dates are displayed or not. | ||
private handleDayClick; | ||
private getNextValue(currentRange, day); | ||
private isDateOverlappingOtherBoundary(date, otherBoundaryDate, boundary); | ||
private createRangeForBoundary(boundaryDate, otherBoundaryDate, boundary); | ||
private createRange(a, b); | ||
private getShorcutClickHandler(nextValue); | ||
@@ -96,0 +92,0 @@ private handleNextState(nextValue); |
@@ -21,2 +21,3 @@ /* | ||
var datePickerCore_1 = require("./datePickerCore"); | ||
var dateRangeSelectionStrategy_1 = require("./dateRangeSelectionStrategy"); | ||
var DateRangePicker = (function (_super) { | ||
@@ -73,5 +74,5 @@ tslib_1.__extends(DateRangePicker, _super); | ||
} | ||
var nextHoverValue = _this.getNextValue(_this.state.value, day); | ||
_this.setState({ hoverValue: nextHoverValue }); | ||
core_1.Utils.safeInvoke(_this.props.onHoverChange, nextHoverValue, day); | ||
var _a = dateRangeSelectionStrategy_1.DateRangeSelectionStrategy.getNextState(_this.state.value, day, _this.props.allowSingleDayRange, _this.props.boundaryToModify), dateRange = _a.dateRange, boundary = _a.boundary; | ||
_this.setState({ hoverValue: dateRange }); | ||
core_1.Utils.safeInvoke(_this.props.onHoverChange, dateRange, day, boundary); | ||
}; | ||
@@ -82,5 +83,4 @@ _this.handleDayMouseLeave = function (_e, day, modifiers) { | ||
} | ||
var nextHoverValue = undefined; | ||
_this.setState({ hoverValue: nextHoverValue }); | ||
core_1.Utils.safeInvoke(_this.props.onHoverChange, nextHoverValue, day); | ||
_this.setState({ hoverValue: undefined }); | ||
core_1.Utils.safeInvoke(_this.props.onHoverChange, undefined, day, undefined); | ||
}; | ||
@@ -93,3 +93,3 @@ _this.handleDayClick = function (e, day, modifiers) { | ||
} | ||
var nextValue = _this.getNextValue(_this.state.value, day); | ||
var nextValue = dateRangeSelectionStrategy_1.DateRangeSelectionStrategy.getNextState(_this.state.value, day, _this.props.allowSingleDayRange, _this.props.boundaryToModify).dateRange; | ||
// update the hovered date range after click to show the newly selected | ||
@@ -281,106 +281,2 @@ // state, at leasts until the mouse moves again | ||
}; | ||
DateRangePicker.prototype.getNextValue = function (currentRange, day) { | ||
var start = currentRange[0], end = currentRange[1]; | ||
var nextValue; | ||
var allowSingleDayRange = this.props.allowSingleDayRange; | ||
// rename for conciseness | ||
var boundary = this.props.boundaryToModify; | ||
if (boundary != null) { | ||
var boundaryDate = (boundary === dateUtils_1.DateRangeBoundary.START) ? start : end; | ||
var otherBoundaryDate = (boundary === dateUtils_1.DateRangeBoundary.START) ? end : start; | ||
if (boundaryDate == null && otherBoundaryDate == null) { | ||
nextValue = this.createRangeForBoundary(day, null, boundary); | ||
} | ||
else if (boundaryDate != null && otherBoundaryDate == null) { | ||
var nextBoundaryDate = DateUtils.areSameDay(boundaryDate, day) ? null : day; | ||
nextValue = this.createRangeForBoundary(nextBoundaryDate, null, boundary); | ||
} | ||
else if (boundaryDate == null && otherBoundaryDate != null) { | ||
if (DateUtils.areSameDay(day, otherBoundaryDate)) { | ||
var _a = (allowSingleDayRange) | ||
? [otherBoundaryDate, otherBoundaryDate] | ||
: [null, null], nextBoundaryDate = _a[0], nextOtherBoundaryDate = _a[1]; | ||
nextValue = this.createRangeForBoundary(nextBoundaryDate, nextOtherBoundaryDate, boundary); | ||
} | ||
else if (this.isDateOverlappingOtherBoundary(day, otherBoundaryDate, boundary)) { | ||
nextValue = this.createRangeForBoundary(otherBoundaryDate, day, boundary); | ||
} | ||
else { | ||
nextValue = this.createRangeForBoundary(day, otherBoundaryDate, boundary); | ||
} | ||
} | ||
else { | ||
// both boundaryDate and otherBoundaryDate are already defined | ||
if (DateUtils.areSameDay(boundaryDate, day)) { | ||
var isSingleDayRangeSelected = DateUtils.areSameDay(boundaryDate, otherBoundaryDate); | ||
var nextOtherBoundaryDate = isSingleDayRangeSelected ? null : otherBoundaryDate; | ||
nextValue = this.createRangeForBoundary(null, nextOtherBoundaryDate, boundary); | ||
} | ||
else if (DateUtils.areSameDay(day, otherBoundaryDate)) { | ||
var _b = (allowSingleDayRange) | ||
? [otherBoundaryDate, otherBoundaryDate] | ||
: [boundaryDate, null], nextBoundaryDate = _b[0], nextOtherBoundaryDate = _b[1]; | ||
nextValue = this.createRangeForBoundary(nextBoundaryDate, nextOtherBoundaryDate, boundary); | ||
} | ||
else if (this.isDateOverlappingOtherBoundary(day, otherBoundaryDate, boundary)) { | ||
nextValue = this.createRangeForBoundary(day, null, boundary); | ||
} | ||
else { | ||
// extend the date range with an earlier boundaryDate date | ||
nextValue = this.createRangeForBoundary(day, otherBoundaryDate, boundary); | ||
} | ||
} | ||
} | ||
else { | ||
if (start == null && end == null) { | ||
nextValue = [day, null]; | ||
} | ||
else if (start != null && end == null) { | ||
nextValue = this.createRange(day, start); | ||
} | ||
else if (start == null && end != null) { | ||
nextValue = this.createRange(day, end); | ||
} | ||
else { | ||
var isStart = DateUtils.areSameDay(start, day); | ||
var isEnd = DateUtils.areSameDay(end, day); | ||
if (isStart && isEnd) { | ||
nextValue = [null, null]; | ||
} | ||
else if (isStart) { | ||
nextValue = [null, end]; | ||
} | ||
else if (isEnd) { | ||
nextValue = [start, null]; | ||
} | ||
else { | ||
nextValue = [day, null]; | ||
} | ||
} | ||
} | ||
return nextValue; | ||
}; | ||
DateRangePicker.prototype.isDateOverlappingOtherBoundary = function (date, otherBoundaryDate, boundary) { | ||
return (boundary === dateUtils_1.DateRangeBoundary.START) | ||
? date > otherBoundaryDate | ||
: date < otherBoundaryDate; | ||
}; | ||
DateRangePicker.prototype.createRangeForBoundary = function (boundaryDate, otherBoundaryDate, boundary) { | ||
if (boundary === dateUtils_1.DateRangeBoundary.START) { | ||
return [boundaryDate, otherBoundaryDate]; | ||
} | ||
else if (boundary === dateUtils_1.DateRangeBoundary.END) { | ||
return [otherBoundaryDate, boundaryDate]; | ||
} | ||
else { | ||
return this.createRange(boundaryDate, otherBoundaryDate); | ||
} | ||
}; | ||
DateRangePicker.prototype.createRange = function (a, b) { | ||
// clicking the same date again will clear it | ||
if (!this.props.allowSingleDayRange && DateUtils.areSameDay(a, b)) { | ||
return [null, null]; | ||
} | ||
return a < b ? [a, b] : [b, a]; | ||
}; | ||
DateRangePicker.prototype.getShorcutClickHandler = function (nextValue) { | ||
@@ -387,0 +283,0 @@ var _this = this; |
@@ -30,2 +30,7 @@ /// <reference types="react" /> | ||
value?: Date; | ||
/** | ||
* Allows the user to clear the selection by clicking the currently selected day. | ||
* @default true | ||
*/ | ||
canClearSelection?: boolean; | ||
} | ||
@@ -32,0 +37,0 @@ export interface IDateTimePickerState { |
@@ -46,3 +46,3 @@ /* | ||
return (React.createElement("div", { className: classNames(Classes.DATETIMEPICKER, this.props.className) }, | ||
React.createElement(datePicker_1.DatePicker, tslib_1.__assign({}, this.props.datePickerProps, { onChange: this.handleDateChange, value: value })), | ||
React.createElement(datePicker_1.DatePicker, tslib_1.__assign({}, this.props.datePickerProps, { canClearSelection: this.props.canClearSelection, onChange: this.handleDateChange, value: value })), | ||
React.createElement(timePicker_1.TimePicker, tslib_1.__assign({}, this.props.timePickerProps, { onChange: this.handleTimeChange, value: value })))); | ||
@@ -61,2 +61,3 @@ }; | ||
DateTimePicker.defaultProps = { | ||
canClearSelection: true, | ||
defaultValue: new Date(), | ||
@@ -63,0 +64,0 @@ }; |
{ | ||
"version": "2.0.0", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"declaration": true, | ||
@@ -17,4 +18,7 @@ "experimentalDecorators": true, | ||
"stripInternal": true, | ||
"target": "es5" | ||
"target": "es5", | ||
"paths": { | ||
"@blueprintjs/docs": ["../../docs/dist/index"] | ||
} | ||
} | ||
} |
{ | ||
"name": "@blueprintjs/datetime", | ||
"version": "1.11.0", | ||
"version": "1.12.0", | ||
"description": "Components for interacting with dates and times", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98
9930
1106885