@primer/react
Version:
An implementation of GitHub's Primer Design System using React
41 lines (40 loc) • 1.12 kB
JavaScript
import { fixedForwardRef } from "../utils/modern-polymorphic.js";
import { Item } from "./Item.js";
import Link from "../Link/Link.js";
import { jsx } from "react/jsx-runtime";
//#region src/ActionList/LinkItem.tsx
const LinkItemComponent = fixedForwardRef(({ active, inactiveText, variant, size, as: Component, className, ...props }, forwardedRef) => {
return /*#__PURE__*/ jsx(Item, {
className,
active,
inactiveText,
"data-inactive": inactiveText ? true : void 0,
variant,
size,
_PrivateItemWrapper: ({ children, onClick, ...rest }) => {
const clickHandler = (event) => {
onClick && onClick(event);
props.onClick && props.onClick(event);
};
if (inactiveText) return /*#__PURE__*/ jsx("span", {
...rest,
children
});
return /*#__PURE__*/ jsx(Link, {
as: Component,
...rest,
...props,
onClick: clickHandler,
ref: forwardedRef,
children
});
},
children: props.children
});
});
const LinkItem = Object.assign(LinkItemComponent, {
displayName: "ActionList.LinkItem",
__SLOT__: Symbol("ActionList.LinkItem")
});
//#endregion
export { LinkItem };