UNPKG

choerodon-ui

Version:

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

103 lines (85 loc) 3.02 kB
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"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; 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 shallowequal from 'lodash/isEqual'; var ExpandIcon = /*#__PURE__*/ function (_Component) { _inherits(ExpandIcon, _Component); var _super = _createSuper(ExpandIcon); function ExpandIcon() { _classCallCheck(this, ExpandIcon); return _super.apply(this, arguments); } _createClass(ExpandIcon, [{ key: "shouldComponentUpdate", value: function shouldComponentUpdate(nextProps) { return !shallowequal(nextProps, this.props); } }, { key: "render", value: function render() { var _this$props = this.props, expandable = _this$props.expandable, prefixCls = _this$props.prefixCls, onExpand = _this$props.onExpand, needIndentSpaced = _this$props.needIndentSpaced, expanded = _this$props.expanded, record = _this$props.record; if (expandable) { var expandClassName = expanded ? 'expanded' : 'collapsed'; return React.createElement("span", { className: "".concat(prefixCls, "-expand-icon ").concat(prefixCls, "-").concat(expandClassName), onClick: function onClick(e) { return onExpand(record, e); } }); } else if (needIndentSpaced) { return React.createElement("span", { className: "".concat(prefixCls, "-expand-icon ").concat(prefixCls, "-spaced") }); } return null; } }]); return ExpandIcon; }(Component); _defineProperty(ExpandIcon, "propTypes", { record: PropTypes.object, prefixCls: PropTypes.string, expandable: PropTypes.any, expanded: PropTypes.bool, needIndentSpaced: PropTypes.bool, onExpand: PropTypes.func }); export { ExpandIcon as default }; //# sourceMappingURL=ExpandIcon.js.map