choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
118 lines (95 loc) • 3.75 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
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, { Children, Component } from 'react';
import PropTypes from 'prop-types';
import { menuAllProps } from './util';
var MenuItemGroup =
/*#__PURE__*/
function (_Component) {
_inherits(MenuItemGroup, _Component);
var _super = _createSuper(MenuItemGroup);
function MenuItemGroup() {
var _this;
_classCallCheck(this, MenuItemGroup);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_defineProperty(_assertThisInitialized(_this), "renderInnerMenuItem", function (item) {
var _this$props = _this.props,
renderMenuItem = _this$props.renderMenuItem,
index = _this$props.index;
return renderMenuItem(item, index, _this.props.subMenuKey);
});
return _this;
}
_createClass(MenuItemGroup, [{
key: "render",
value: function render() {
var props = _extends({}, this.props);
var _props$className = props.className,
className = _props$className === void 0 ? '' : _props$className,
rootPrefixCls = props.rootPrefixCls;
var titleClassName = "".concat(rootPrefixCls, "-item-group-title");
var listClassName = "".concat(rootPrefixCls, "-item-group-list");
var title = props.title,
children = props.children;
menuAllProps.forEach(function (key) {
return delete props[key];
}); // Set onClick to null, to ignore propagated onClick event
delete props.onClick;
return React.createElement("li", _extends({}, props, {
className: "".concat(className, " ").concat(rootPrefixCls, "-item-group")
}), React.createElement("div", {
className: titleClassName,
title: typeof title === 'string' ? title : undefined
}, title), React.createElement("ul", {
className: listClassName
}, Children.map(children, this.renderInnerMenuItem)));
}
}]);
return MenuItemGroup;
}(Component);
_defineProperty(MenuItemGroup, "propTypes", {
renderMenuItem: PropTypes.func,
index: PropTypes.number,
className: PropTypes.string,
subMenuKey: PropTypes.string,
rootPrefixCls: PropTypes.string
});
_defineProperty(MenuItemGroup, "defaultProps", {
disabled: true
});
MenuItemGroup.isMenuItemGroup = true;
export default MenuItemGroup;
//# sourceMappingURL=MenuItemGroup.js.map