@vectara/vectara-ui
Version:
Vectara's design system, codified as a React and Sass component library
35 lines (34 loc) • 1.89 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import classNames from "classnames";
import { VuiIcon } from "../icon/Icon";
import { useVuiContext } from "../context/Context";
export const VuiMenuListButton = (_a) => {
var { className, isActive, onClick, href, icon, children, append } = _a, rest = __rest(_a, ["className", "isActive", "onClick", "href", "icon", "children", "append"]);
const { createLink } = useVuiContext();
const classes = classNames("vuiMenuListButton", className, {
"vuiMenuListButton-isActive": isActive
});
const content = (_jsxs(_Fragment, { children: [icon && _jsx(VuiIcon, Object.assign({ size: "s" }, { children: icon })), children && _jsx("span", Object.assign({ className: "vuiMenuListButton__label" }, { children: children })), append] }));
let button;
if (href && !rest.disabled) {
button = createLink(Object.assign({ href,
onClick, children: (
//* Wrap a button otherwise the flex layout breaks */}
_jsx("button", Object.assign({ className: classes, tabIndex: -1 }, { children: content }))) }, rest));
}
else {
button = (_jsx("button", Object.assign({ type: "button", className: classes, onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick() }, rest, { children: content })));
}
return button;
};