UNPKG

@attivio/suit

Version:

Attivio SUIT, the Search UI Toolkit, is a library for creating search clients for searching the Attivio platform.

68 lines (53 loc) 2.65 kB
var _class, _temp; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } import React from 'react'; import moment from 'moment'; import 'react-dates/initialize'; import 'react-dates/lib/css/_datepicker.css'; import { DayPickerRangeController } from 'react-dates'; /** * Component to let the user choose either a single * date or a starting/ending range. */ var DatePicker = (_temp = _class = function (_React$Component) { _inherits(DatePicker, _React$Component); function DatePicker(props) { _classCallCheck(this, DatePicker); var _this = _possibleConstructorReturn(this, _React$Component.call(this, props)); _this.state = { focused: false, focusedInput: null }; _this.setFocusedState = _this.setFocusedState.bind(_this); _this.setDate = _this.setDate.bind(_this); return _this; } DatePicker.prototype.setFocusedState = function setFocusedState(focusedInput) { this.setState({ focusedInput: focusedInput }); }; DatePicker.prototype.setDate = function setDate(event) { this.props.updateDate(new Date(event.startDate), new Date(event.endDate)); }; DatePicker.prototype.render = function render() { var startDate = moment(this.props.startingDate); var endDate = moment(this.props.endingDate); return React.createElement(DayPickerRangeController, { startDate: startDate, endDate: endDate, onDatesChange: this.setDate, focusedInput: this.state.focusedInput || 'startDate', onFocusChange: this.setFocusedState, isOutsideRange: function isOutsideRange() { return false; }, onOutsideClick: this.props.onClose, numberOfMonths: 2 }); }; return DatePicker; }(React.Component), _class.displayName = 'DatePicker', _temp); export { DatePicker as default };