UNPKG

@attivio/suit

Version:

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

66 lines (52 loc) 2.53 kB
'use strict'; exports.__esModule = true; exports.default = undefined; var _class, _temp; var _react = require('react'); var _react2 = _interopRequireDefault(_react); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; } /** * A scrollable container for other components. If the size of the children is large enough that * they won't fit, scroll bars are enabled to let the user scroll to see the rest of the contents. */ var Scrollable = (_temp = _class = function (_React$Component) { _inherits(Scrollable, _React$Component); function Scrollable() { _classCallCheck(this, Scrollable); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } Scrollable.prototype.render = function render() { var overflowType = this.props.force ? 'scroll' : 'auto'; var outerStyle = Object.assign({}, this.props.style); if (this.props.height) { outerStyle.height = this.props.height; } if (this.props.width) { outerStyle.width = this.props.width; } if (this.props.vertical) { outerStyle.overflowX = overflowType; } if (this.props.horizontal) { outerStyle.overflowY = overflowType; } return _react2.default.createElement( 'div', { style: outerStyle }, this.props.children ); }; return Scrollable; }(_react2.default.Component), _class.defaultProps = { style: {}, height: null, width: null, vertical: true, horizontal: false, force: false }, _class.displayName = 'Scrollable', _temp); exports.default = Scrollable; module.exports = exports['default'];