UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

117 lines (116 loc) 3.3 kB
import Octicon from "../Octicon/Octicon.js"; import StateLabel_module_css_default from "./StateLabel.module.css.js"; import { c } from "react-compiler-runtime"; import { clsx } from "clsx"; import { jsx, jsxs } from "react/jsx-runtime"; import { forwardRef } from "react"; import { AlertIcon, ArchiveIcon, GitMergeIcon, GitMergeQueueIcon, GitPullRequestClosedIcon, GitPullRequestDraftIcon, GitPullRequestIcon, IssueClosedIcon, IssueDraftIcon, IssueOpenedIcon, ShieldCheckIcon, ShieldIcon, ShieldSlashIcon, ShieldXIcon, SkipIcon } from "@primer/octicons-react"; //#region src/StateLabel/StateLabel.tsx const octiconMap = { issueOpened: IssueOpenedIcon, pullOpened: GitPullRequestIcon, issueClosed: IssueClosedIcon, issueClosedNotPlanned: SkipIcon, pullClosed: GitPullRequestClosedIcon, pullMerged: GitMergeIcon, draft: GitPullRequestDraftIcon, issueDraft: IssueDraftIcon, pullQueued: GitMergeQueueIcon, unavailable: AlertIcon, alertOpened: ShieldIcon, alertFixed: ShieldCheckIcon, alertDismissed: ShieldSlashIcon, alertClosed: ShieldXIcon, open: null, closed: null, archived: ArchiveIcon }; const labelMap = { issueOpened: "Issue", pullOpened: "Pull request", issueClosed: "Issue", issueClosedNotPlanned: "Issue, not planned", pullClosed: "Pull request", pullMerged: "Pull request", draft: "Pull request", issueDraft: "Issue", pullQueued: "Pull request", unavailable: "", alertOpened: "Alert", alertFixed: "Alert", alertDismissed: "Alert", alertClosed: "Alert", archived: "Archived", open: "", closed: "" }; const StateLabel = /*#__PURE__*/ forwardRef((t0, ref) => { const $ = c(21); let children; let className; let rest; let size; let status; let variant; if ($[0] !== t0) { ({children, status, size, variant, className, ...rest} = t0); $[0] = t0; $[1] = children; $[2] = className; $[3] = rest; $[4] = size; $[5] = status; $[6] = variant; } else { children = $[1]; className = $[2]; rest = $[3]; size = $[4]; status = $[5]; variant = $[6]; } const noIconStatus = status === "open" || status === "closed"; const inferredSize = size || (variant === "small" ? "small" : "medium"); let t1; if ($[7] !== className) { t1 = clsx(StateLabel_module_css_default.StateLabel, className); $[7] = className; $[8] = t1; } else t1 = $[8]; let t2; if ($[9] !== inferredSize || $[10] !== noIconStatus || $[11] !== status) { t2 = !noIconStatus && /*#__PURE__*/ jsx(Octicon, { "data-size-small": inferredSize === "small" ? "" : void 0, icon: octiconMap[status], "aria-label": labelMap[status], className: StateLabel_module_css_default.Icon }); $[9] = inferredSize; $[10] = noIconStatus; $[11] = status; $[12] = t2; } else t2 = $[12]; let t3; if ($[13] !== children || $[14] !== inferredSize || $[15] !== ref || $[16] !== rest || $[17] !== status || $[18] !== t1 || $[19] !== t2) { t3 = /*#__PURE__*/ jsxs("span", { ...rest, ref, className: t1, "data-size": inferredSize, "data-status": status, children: [t2, children] }); $[13] = children; $[14] = inferredSize; $[15] = ref; $[16] = rest; $[17] = status; $[18] = t1; $[19] = t2; $[20] = t3; } else t3 = $[20]; return t3; }); StateLabel.displayName = "StateLabel"; //#endregion export { StateLabel as default };