@attivio/suit
Version:
Attivio SUIT, the Search UI Toolkit, is a library for creating search clients for searching the Attivio platform.
57 lines (46 loc) • 2.26 kB
JavaScript
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';
/**
* 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 React.createElement(
'div',
{ style: outerStyle },
this.props.children
);
};
return Scrollable;
}(React.Component), _class.defaultProps = {
style: {},
height: null,
width: null,
vertical: true,
horizontal: false,
force: false
}, _class.displayName = 'Scrollable', _temp);
export { Scrollable as default };