@skbkontur/ui-kit
Version:
32 lines • 1.83 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = tslib_1.__importStar(require("react"));
var MenuItemView_1 = require("./MenuItemView");
/**
* Элемент меню.
*/
var MenuItem = /** @class */ (function (_super) {
tslib_1.__extends(MenuItem, _super);
function MenuItem() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.handleClick = function (event) {
if (!_this.props.disabled && _this.props.onClick) {
_this.props.onClick(event);
}
};
return _this;
}
MenuItem.prototype.render = function () {
var _a = this.props, alkoLink = _a.alkoLink, comment = _a.comment, disabled = _a.disabled, icon = _a.icon, loose = _a.loose, state = _a.state, children = _a.children, onClick = _a.onClick, _enableIconPadding = _a._enableIconPadding, rest = tslib_1.__rest(_a, ["alkoLink", "comment", "disabled", "icon", "loose", "state", "children", "onClick", "_enableIconPadding"]);
var isHovered = state === 'hover' && !disabled;
var isSelected = state === 'selected' && !disabled;
return (React.createElement(MenuItemView_1.MenuItemStyledContainer, tslib_1.__assign({ onClick: this.handleClick, disabled: disabled, hover: isHovered, select: isSelected, loose: loose, alkoLink: alkoLink, withIcon: !!icon || _enableIconPadding }, rest),
icon && React.createElement(MenuItemView_1.MenuItemIcon, null, icon),
typeof children === 'function' ? children(state) : children,
comment && React.createElement(MenuItemView_1.MenuItemStyledComment, { hover: isHovered }, comment)));
};
return MenuItem;
}(React.Component));
exports.default = MenuItem;
//# sourceMappingURL=MenuItem.js.map
;