UNPKG

choerodon-ui

Version:

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

123 lines (103 loc) 3.45 kB
import _objectSpread from "@babel/runtime/helpers/objectSpread2"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _get from "@babel/runtime/helpers/get"; 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 { __decorate } from "tslib"; import React from 'react'; import { observer } from 'mobx-react'; import KeyCode from '../../../es/_util/KeyCode'; import { CheckBox } from '../check-box/CheckBox'; import autobind from '../_util/autobind'; var Switch = /*#__PURE__*/ function (_CheckBox) { _inherits(Switch, _CheckBox); var _super = _createSuper(Switch); function Switch() { _classCallCheck(this, Switch); return _super.apply(this, arguments); } _createClass(Switch, [{ key: "handleKeyDown", value: function handleKeyDown(e) { if (e.keyCode === KeyCode.LEFT) { this.setChecked(false); } else if (e.keyCode === KeyCode.RIGHT) { this.setChecked(true); } _get(_getPrototypeOf(Switch.prototype), "handleKeyDown", this).call(this, e); } }, { key: "getLabelText", value: function getLabelText() { return undefined; } }, { key: "getTextNode", value: function getTextNode() { var prefixCls = this.prefixCls, _this$props = this.props, children = _this$props.children, unCheckedChildren = _this$props.unCheckedChildren; var text = this.isChecked() ? children : unCheckedChildren || children; return React.createElement("span", { className: "".concat(prefixCls, "-label") }, text); } }, { key: "renderSwitchFloatLabel", value: function renderSwitchFloatLabel() { var prefixCls = this.prefixCls; return React.createElement("span", { className: "".concat(prefixCls, "-float-label") }, this.getLabelChildren()); } }, { key: "renderInner", value: function renderInner() { return undefined; } }]); return Switch; }(CheckBox); Switch.displayName = 'Switch'; /** * tooltip disable sign */ // eslint-disable-next-line camelcase Switch.__PRO_SWITCH = true; // eslint-disable-next-line camelcase Switch.__IS_IN_CELL_EDITOR = true; Switch.defaultProps = _objectSpread({}, CheckBox.defaultProps, { suffixCls: 'switch' }); __decorate([autobind], Switch.prototype, "handleKeyDown", null); Switch = __decorate([observer], Switch); export default Switch; //# sourceMappingURL=Switch.js.map