UNPKG

choerodon-ui

Version:

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

90 lines (77 loc) 2.69 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 _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; import _inherits from "@babel/runtime/helpers/inherits"; import _createSuper from "@babel/runtime/helpers/createSuper"; 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 /*#__PURE__*/React.createElement("span", { className: "".concat(prefixCls, "-label") }, text); } }, { key: "renderSwitchFloatLabel", value: function renderSwitchFloatLabel() { var prefixCls = this.prefixCls; return /*#__PURE__*/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(_objectSpread({}, CheckBox.defaultProps), {}, { suffixCls: 'switch' }); __decorate([autobind], Switch.prototype, "handleKeyDown", null); Switch = __decorate([observer], Switch); export default Switch; //# sourceMappingURL=Switch.js.map