graft-react
Version:
react admin and helper components for graft-db
51 lines (50 loc) • 1.94 kB
JavaScript
;
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
var React = require("react");
var ReactDOM = require("react-dom");
;
function WithStyles(css) {
return function (Wrapped) {
return (function (_super) {
__extends(WithStyles, _super);
function WithStyles() {
return _super !== null && _super.apply(this, arguments) || this;
}
WithStyles.prototype.componentDidMount = function () {
var el = ReactDOM.findDOMNode(this);
var doc = el.ownerDocument;
var style = doc.createElement('style');
style.type = 'text/css';
if (style.styleSheet) {
style.styleSheet.cssText = css.toString();
}
else {
style.appendChild(doc.createTextNode(css.toString()));
}
doc.head.appendChild(style);
this.styleNode = style;
};
WithStyles.prototype.componentWillUnmount = function () {
this.styleNode.parentNode.removeChild(this.styleNode);
this.styleNode = null;
};
WithStyles.prototype.render = function () {
return (React.createElement(Wrapped, __assign({}, this.props)));
};
return WithStyles;
}(React.Component));
};
}
exports.WithStyles = WithStyles;