@blueprintjs/datetime
Advanced tools
Comparing version 1.13.0 to 1.14.0
/// <reference types="react" /> | ||
import * as moment from "moment"; | ||
import { AbstractComponent, IPopoverProps, IProps, Position } from "@blueprintjs/core"; | ||
import { AbstractComponent, HTMLInputProps, IInputGroupProps, IPopoverProps, IProps, Position } from "@blueprintjs/core"; | ||
import { IDatePickerBaseProps } from "./datePickerCore"; | ||
@@ -33,2 +33,8 @@ import { TimePickerPrecision } from "./timePicker"; | ||
/** | ||
* Props to pass to the [input group](#core/components/forms/input-group.javascript-api). | ||
* `disabled` and `value` will be ignored in favor of the top-level props on this component. | ||
* `type` is fixed to "text" and `ref` is not supported; use `inputRef` instead. | ||
*/ | ||
inputProps?: HTMLInputProps & IInputGroupProps; | ||
/** | ||
* The error message to display when the date selected is invalid. | ||
@@ -111,2 +117,4 @@ * @default "Invalid date" | ||
private setInputRef; | ||
/** safe wrapper around invoking input props event handler (prop defaults to undefined) */ | ||
private safeInvokeInputProp(name, e); | ||
} |
@@ -56,3 +56,3 @@ /* | ||
}; | ||
_this.handleInputFocus = function () { | ||
_this.handleInputFocus = function (e) { | ||
var valueString = dateUtils_1.isMomentNull(_this.state.value) ? "" : _this.state.value.format(_this.props.format); | ||
@@ -65,2 +65,3 @@ if (_this.props.openOnFocus) { | ||
} | ||
_this.safeInvokeInputProp("onFocus", e); | ||
}; | ||
@@ -71,2 +72,3 @@ _this.handleInputClick = function (e) { | ||
} | ||
_this.safeInvokeInputProp("onClick", e); | ||
}; | ||
@@ -91,4 +93,5 @@ _this.handleInputChange = function (e) { | ||
} | ||
_this.safeInvokeInputProp("onChange", e); | ||
}; | ||
_this.handleInputBlur = function () { | ||
_this.handleInputBlur = function (e) { | ||
var valueString = _this.state.valueString; | ||
@@ -123,5 +126,8 @@ var value = moment(valueString, _this.props.format); | ||
} | ||
_this.safeInvokeInputProp("onBlur", e); | ||
}; | ||
_this.setInputRef = function (el) { | ||
_this.inputRef = el; | ||
var _a = _this.props.inputProps, inputProps = _a === void 0 ? {} : _a; | ||
core_1.Utils.safeInvoke(inputProps.inputRef, el); | ||
}; | ||
@@ -146,8 +152,10 @@ var defaultValue = _this.props.defaultValue ? dateUtils_1.fromDateToMoment(_this.props.defaultValue) : moment(null); | ||
// assign default empty object here to prevent mutation | ||
var _b = this.props.popoverProps, popoverProps = _b === void 0 ? {} : _b; | ||
var _b = this.props, _c = _b.inputProps, inputProps = _c === void 0 ? {} : _c, _d = _b.popoverProps, popoverProps = _d === void 0 ? {} : _d; | ||
// exclude ref (comes from HTMLInputProps typings, not InputGroup) | ||
var ref = inputProps.ref, htmlInputProps = tslib_1.__rest(inputProps, ["ref"]); | ||
var inputClasses = classNames({ | ||
"pt-intent-danger": !(this.isMomentValidAndInRange(date) || dateUtils_1.isMomentNull(date) || dateString === ""), | ||
}); | ||
}, inputProps.className); | ||
return (React.createElement(core_1.Popover, tslib_1.__assign({ inline: true, isOpen: this.state.isOpen && !this.props.disabled, position: this.props.popoverPosition }, popoverProps, { autoFocus: false, enforceFocus: false, content: popoverContent, onClose: this.handleClosePopover, popoverClassName: classNames("pt-dateinput-popover", popoverProps.popoverClassName) }), | ||
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 }))); | ||
React.createElement(core_1.InputGroup, tslib_1.__assign({ placeholder: this.props.format, rightElement: this.props.rightElement }, htmlInputProps, { className: inputClasses, disabled: this.props.disabled, inputRef: this.setInputRef, type: "text", onBlur: this.handleInputBlur, onChange: this.handleInputChange, onClick: this.handleInputClick, onFocus: this.handleInputFocus, value: dateString })))); | ||
}; | ||
@@ -174,2 +182,7 @@ DateInput.prototype.componentWillReceiveProps = function (nextProps) { | ||
}; | ||
/** safe wrapper around invoking input props event handler (prop defaults to undefined) */ | ||
DateInput.prototype.safeInvokeInputProp = function (name, e) { | ||
var _a = this.props.inputProps, inputProps = _a === void 0 ? {} : _a; | ||
core_1.Utils.safeInvoke(inputProps[name], e); | ||
}; | ||
return DateInput; | ||
@@ -176,0 +189,0 @@ }(core_1.AbstractComponent)); |
@@ -37,4 +37,5 @@ /// <reference types="react" /> | ||
/** | ||
* Props to pass to the end-date input. | ||
* Props to pass to the end-date [input group](#core/components/forms/input-group.javascript-api). | ||
* `disabled` and `value` will be ignored in favor of the top-level props on this component. | ||
* `ref` is not supported; use `inputRef` instead. | ||
*/ | ||
@@ -98,4 +99,5 @@ endInputProps?: HTMLInputProps & IInputGroupProps; | ||
/** | ||
* Props to pass to the start-date input. | ||
* Props to pass to the start-date [input group](#core/components/forms/input-group.javascript-api). | ||
* `disabled` and `value` will be ignored in favor of the top-level props on this component. | ||
* `ref` is not supported; use `inputRef` instead. | ||
*/ | ||
@@ -102,0 +104,0 @@ startInputProps?: HTMLInputProps & IInputGroupProps; |
{ | ||
"name": "@blueprintjs/datetime", | ||
"version": "1.13.0", | ||
"version": "1.14.0", | ||
"description": "Components for interacting with dates and times", | ||
@@ -18,6 +18,6 @@ "main": "dist/index.js", | ||
"bourbon": "4.2.6", | ||
"react": "15.4.0", | ||
"react-addons-css-transition-group": "15.4.0", | ||
"react-addons-test-utils": "15.4.0", | ||
"react-dom": "15.4.0" | ||
"react": "15.5.1", | ||
"react-addons-css-transition-group": "15.5.1", | ||
"react-addons-test-utils": "15.5.1", | ||
"react-dom": "15.5.1" | ||
}, | ||
@@ -24,0 +24,0 @@ "repository": { |
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
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
1128957
10169