UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

111 lines (92 loc) 3.28 kB
import _extends from "@babel/runtime/helpers/extends"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _inherits from "@babel/runtime/helpers/inherits"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; function _createSuper(Derived) { function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } return function () { var Super = _getPrototypeOf(Derived), result; if (isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } import React, { Component } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import omit from 'lodash/omit'; import RcSwitch from '../rc-components/switch'; import { Size } from '../_util/enum'; import { getPrefixCls } from '../configure'; var Switch = /*#__PURE__*/ function (_Component) { _inherits(Switch, _Component); var _super = _createSuper(Switch); function Switch() { var _this; _classCallCheck(this, Switch); _this = _super.apply(this, arguments); _this.saveSwitch = function (node) { _this.rcSwitch = node; }; return _this; } _createClass(Switch, [{ key: "focus", value: function focus() { this.rcSwitch.focus(); } }, { key: "blur", value: function blur() { this.rcSwitch.blur(); } }, { key: "render", value: function render() { var _classNames; var _this$props = this.props, customizePrefixCls = _this$props.prefixCls, size = _this$props.size, loading = _this$props.loading, _this$props$className = _this$props.className, className = _this$props$className === void 0 ? '' : _this$props$className; var prefixCls = getPrefixCls('switch', customizePrefixCls); var classes = classNames(className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-small"), size === Size.small), _defineProperty(_classNames, "".concat(prefixCls, "-loading"), loading), _classNames)); return React.createElement(RcSwitch, _extends({}, omit(this.props, ['loading']), { prefixCls: prefixCls, className: classes, ref: this.saveSwitch })); } }]); return Switch; }(Component); export { Switch as default }; Switch.displayName = 'Switch'; Switch.propTypes = { prefixCls: PropTypes.string, // size=default and size=large are the same size: PropTypes.oneOf([Size.small, Size["default"], Size.large]), className: PropTypes.string }; //# sourceMappingURL=index.js.map