UNPKG

choerodon-ui

Version:

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

99 lines (77 loc) 3.05 kB
import _extends from "@babel/runtime/helpers/extends"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; 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 classNames from 'classnames'; import { getPrefixCls } from '../configure'; var CheckableTag = /*#__PURE__*/ function (_Component) { _inherits(CheckableTag, _Component); var _super = _createSuper(CheckableTag); function CheckableTag() { var _this; _classCallCheck(this, CheckableTag); _this = _super.apply(this, arguments); _this.handleClick = function () { var _this$props = _this.props, checked = _this$props.checked, onChange = _this$props.onChange; if (onChange) { onChange(!checked); } }; return _this; } _createClass(CheckableTag, [{ key: "render", value: function render() { var _classNames; var _this$props2 = this.props, customizePrefixCls = _this$props2.prefixCls, className = _this$props2.className, checked = _this$props2.checked, restProps = _objectWithoutProperties(_this$props2, ["prefixCls", "className", "checked"]); var prefixCls = getPrefixCls('tag', customizePrefixCls); var cls = classNames(prefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-checkable"), true), _defineProperty(_classNames, "".concat(prefixCls, "-checkable-checked"), checked), _classNames), className); delete restProps.onChange; // TypeScript cannot check delete now. return React.createElement("div", _extends({}, restProps, { className: cls, onClick: this.handleClick })); } }]); return CheckableTag; }(Component); export { CheckableTag as default }; CheckableTag.displayName = 'CheckableTag'; //# sourceMappingURL=CheckableTag.js.map