zent
Version:
一套前端设计语言和基于React的实现
39 lines (38 loc) • 1.71 kB
JavaScript
import { __assign, __extends } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import { Component } from 'react';
import cx from 'classnames';
import { getExtraStyle } from './utils';
var MenuItem = (function (_super) {
__extends(MenuItem, _super);
function MenuItem() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.handleClick = function (e) {
var _a = _this.props, specKey = _a.specKey, onClick = _a.onClick, disabled = _a.disabled, isInline = _a.isInline, handleSelect = _a.handleSelect;
if (disabled)
return;
if (isInline) {
handleSelect(specKey);
}
onClick(e, specKey);
};
return _this;
}
MenuItem.prototype.render = function () {
var _a = this.props, specKey = _a.specKey, className = _a.className, children = _a.children, disabled = _a.disabled, isInline = _a.isInline, selectedKey = _a.selectedKey, depth = _a.depth, inlineIndent = _a.inlineIndent;
var isSelected = selectedKey === specKey;
var styleObj = getExtraStyle({
isInline: isInline,
depth: depth,
inlineIndent: inlineIndent,
});
return (_jsx("li", __assign({ className: cx('zent-menu-item', className, {
'zent-menu__inline-item': isInline,
'zent-menu__inline-item-selected': isSelected,
'zent-menu-item-disabled': disabled,
}), style: styleObj, onClick: this.handleClick, "data-zv": '10.0.17' }, { children: children }), void 0));
};
return MenuItem;
}(Component));
export { MenuItem };
export default MenuItem;