UNPKG

wix-style-react

Version:
54 lines (38 loc) 3.08 kB
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _class, _temp; function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } 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, { Component } from 'react'; import PropTypes from 'prop-types'; import ButtonOld from '../Backoffice/Button'; import ButtonNew from './Button'; import deprecationLog from '../utils/deprecationLog'; import { allValidators } from '../utils/propTypes'; // NOTE: This is a class an not an SFC because our Tooltip can NOT accept SFC as children. var Button = (_temp = _class = function (_Component) { _inherits(Button, _Component); function Button() { _classCallCheck(this, Button); return _possibleConstructorReturn(this, (Button.__proto__ || Object.getPrototypeOf(Button)).apply(this, arguments)); } _createClass(Button, [{ key: 'render', value: function render() { var _props = this.props, upgrade = _props.upgrade, rest = _objectWithoutProperties(_props, ['upgrade']); return this.props.upgrade && React.createElement(ButtonNew, rest) || React.createElement(ButtonOld, rest); } }]); return Button; }(Component), _class.propTypes = { upgrade: allValidators(PropTypes.bool, function (props, propName) { if (!props[propName]) { deprecationLog('Using "Button" with current api is deprecated. In order to upgrade to the new Button api just use "<Button upgrade/>" and follow "5.1 Button" changed api docs.'); } }) }, _temp); Button.displayName = 'Button'; export default Button;