UNPKG

choerodon-ui

Version:

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

103 lines (86 loc) 3.13 kB
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 { __decorate } from "tslib"; import React, { Component } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import shallowequal from 'lodash/isEqual'; import Icon from '../icon'; import autobind from '../_util/autobind'; 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: "handleClick", value: function handleClick(e) { e.stopPropagation(); var onChange = this.props.onChange; onChange(e); } }, { key: "render", value: function render() { var _classNames; var _this$props = this.props, prefixCls = _this$props.prefixCls, expanded = _this$props.expanded, expandable = _this$props.expandable; var iconPrefixCls = "".concat(prefixCls, "-expand-icon"); var classString = classNames(iconPrefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(iconPrefixCls, "-expanded"), expanded), _defineProperty(_classNames, "".concat(iconPrefixCls, "-spaced"), !expandable), _classNames)); return React.createElement(Icon, { type: "baseline-arrow_right", className: classString, onClick: expandable ? this.handleClick : undefined, tabIndex: expandable ? 0 : -1 }); } }]); return ExpandIcon; }(Component); export { ExpandIcon as default }; ExpandIcon.propTypes = { expandable: PropTypes.bool, expanded: PropTypes.bool, onChange: PropTypes.func.isRequired }; __decorate([autobind], ExpandIcon.prototype, "handleClick", null); //# sourceMappingURL=ExpandIcon.js.map