@primer/react
Version:
An implementation of GitHub's Primer Design System using React
73 lines (72 loc) • 2.11 kB
JavaScript
import { IconButton } from "../Button/IconButton.js";
import { c } from "react-compiler-runtime";
import { jsx } from "react/jsx-runtime";
import { forwardRef } from "react";
//#region src/ActionList/GroupHeadingTrailingAction.tsx
/**
* Props for `ActionList.GroupHeading.TrailingAction`.
*
* Mirrors the shape of `ActionList.TrailingAction` so the API is consistent
* across `ActionList.Item` and `ActionList.GroupHeading`. The only
* difference is that `icon` is required here — group headings are not
* interactive on their own, so the action must always render as a square
* IconButton with a uniform hit target.
*/
const GroupHeadingTrailingActionImpl = /*#__PURE__*/ forwardRef((t0, forwardedRef) => {
const $ = c(15);
let icon;
let label;
let props;
let t1;
let t2;
let t3;
if ($[0] !== t0) {
({as: t1, icon, label, href: t2, tooltipDirection: t3, ...props} = t0);
$[0] = t0;
$[1] = icon;
$[2] = label;
$[3] = props;
$[4] = t1;
$[5] = t2;
$[6] = t3;
} else {
icon = $[1];
label = $[2];
props = $[3];
t1 = $[4];
t2 = $[5];
t3 = $[6];
}
const as = t1 === void 0 ? "button" : t1;
const href = t2 === void 0 ? null : t2;
const tooltipDirection = t3 === void 0 ? "w" : t3;
let t4;
if ($[7] !== as || $[8] !== forwardedRef || $[9] !== href || $[10] !== icon || $[11] !== label || $[12] !== props || $[13] !== tooltipDirection) {
t4 = /*#__PURE__*/ jsx(IconButton, {
as,
"aria-label": label,
icon,
variant: "invisible",
size: "small",
tooltipDirection,
href,
ref: forwardedRef,
"data-component": "ActionList.GroupHeading.TrailingAction",
...props
});
$[7] = as;
$[8] = forwardedRef;
$[9] = href;
$[10] = icon;
$[11] = label;
$[12] = props;
$[13] = tooltipDirection;
$[14] = t4;
} else t4 = $[14];
return t4;
});
GroupHeadingTrailingActionImpl.displayName = "ActionList.GroupHeading.TrailingAction";
GroupHeadingTrailingActionImpl.__SLOT__ = Symbol("ActionList.GroupHeading.TrailingAction");
const GroupHeadingTrailingAction = GroupHeadingTrailingActionImpl;
//#endregion
export { GroupHeadingTrailingAction };