office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
50 lines • 2.12 kB
JavaScript
import * as tslib_1 from "tslib";
import * as React from 'react';
var ListPage = /** @class */ (function (_super) {
tslib_1.__extends(ListPage, _super);
function ListPage(props) {
var _this = _super.call(this, props) || this;
_this._rootElement = React.createRef();
_this.state = {
hiddenStyle: undefined,
backgroundColor: "rgba(" +
Math.floor(255 * Math.random()) +
"," +
Math.floor(255 * Math.random()) +
"," +
Math.floor(255 * Math.random()) +
"1)"
};
return _this;
}
ListPage.prototype.componentWillReceiveProps = function (newProps) {
if (this.props.visible !== newProps.visible) {
var hiddenStyle = undefined;
if (!newProps.visible) {
var rootRect = this._rootElement.current.getBoundingClientRect();
hiddenStyle = {
height: rootRect.height
};
}
this.setState({ hiddenStyle: hiddenStyle });
}
};
ListPage.prototype.render = function () {
var hiddenStyle = this.state.hiddenStyle;
return (React.createElement("div", { ref: this._rootElement, style: hiddenStyle }, hiddenStyle ? undefined : this._renderItems()));
};
ListPage.prototype._renderItems = function () {
var cells = [];
var startIndex = this.props.startIndex;
var _a = this.props, endIndex = _a.endIndex, items = _a.items, _b = _a.onRenderCell, onRenderCell = _b === void 0 ? function () { return React.createElement("div", null); } : _b;
for (; startIndex <= endIndex; startIndex++) {
var item = items[startIndex];
var key = item.key || String(startIndex);
cells.push(React.createElement("div", { key: key }, onRenderCell(items[startIndex], startIndex)));
}
return cells;
};
return ListPage;
}(React.PureComponent));
export { ListPage };
//# sourceMappingURL=ListPage.js.map