UNPKG

@xiag-stc/react-basket

Version:

Order basket view: period of stay blocks containing the hotel blocks containing the room blocks; guest data forms with variations for Airline- and Airport-TO-s

76 lines (65 loc) 2.3 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = _react2.default.createClass({ displayName: 'IconedIntegerSelect', propTypes: { icon: _react2.default.PropTypes.shape({ uri: _react2.default.PropTypes.string.isRequired, title: _react2.default.PropTypes.string.isRequired }).isRequired, value: _react2.default.PropTypes.number.isRequired, minValue: _react2.default.PropTypes.number.isRequired, maxValue: _react2.default.PropTypes.number.isRequired, onChange: _react2.default.PropTypes.func.isRequired }, render: function render() { return _react2.default.createElement( 'span', { className: 'iconed-integer-select' }, _react2.default.createElement('img', { src: this.props.icon.uri, alt: this.props.icon.title, title: this.props.icon.title }), ' ', this.theValue() ); }, theValue: function theValue() { return this.props.minValue === this.props.maxValue ? _react2.default.createElement( 'span', { className: 'iconed-integer-select-constant' }, this.props.minValue ) : this.theSelect(); }, theSelect: function theSelect() { return _react2.default.createElement( 'select', { ref: 'select', value: this.props.value, onChange: this.handleChange, className: 'form-control' }, this.theOptions() ); }, theOptions: function theOptions() { var result = []; for (var i = this.props.minValue; i <= this.props.maxValue; i++) { result.push(_react2.default.createElement( 'option', { key: 'o' + i }, i )); } return result; }, handleChange: function handleChange(_ref) { var value = _ref.target.value; this.props.onChange(parseInt(value, 10)); } });