viser-react
Version:
viser-react is react of viser.
103 lines (81 loc) • 3.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var PropTypes = _interopRequireWildcard(require("prop-types"));
var React = _interopRequireWildcard(require("react"));
var ReactDOM = _interopRequireWildcard(require("react-dom"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var __extends = void 0 && (void 0).__extends || function () {
var _extendStatics = function extendStatics(d, b) {
_extendStatics = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b) {
if (b.hasOwnProperty(p)) d[p] = b[p];
}
};
return _extendStatics(d, b);
};
return function (d, b) {
_extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var isReact16 = ReactDOM.createPortal !== undefined;
function generateRandomNum() {
return Math.floor(new Date().getTime() + Math.random() * 10000).toString();
}
var FacetView = function (_super) {
__extends(FacetView, _super);
function FacetView(props) {
var _this = _super.call(this, props) || this;
_this.displayName = 'FacetView';
_this.state = {
hasInViews: true,
viewId: _this.props.viewId || generateRandomNum(),
viewType: 'facet'
};
return _this;
}
FacetView.prototype.getChildContext = function () {
return {
hasInViews: this.state.hasInViews,
viewId: this.state.viewId,
viewType: this.state.viewType
};
};
FacetView.prototype.componentDidUpdate = function () {
this.context.centralizedUpdates(this);
};
FacetView.prototype.componentDidMount = function () {
this.context.centralizedUpdates(this);
};
FacetView.prototype.render = function () {
if (isReact16) {
return this.props.children;
} else {
return React.Children.only(this.props.children);
}
};
FacetView.childContextTypes = {
hasInViews: PropTypes.bool,
viewId: PropTypes.string,
viewType: PropTypes.string
};
FacetView.contextTypes = {
centralizedUpdates: PropTypes.func,
hasInViews: PropTypes.bool,
viewType: PropTypes.string
};
return FacetView;
}(React.Component);
var _default = FacetView;
exports.default = _default;