UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

163 lines (160 loc) 3.61 kB
import { c } from 'react-compiler-runtime'; import { isElement } from 'react-is'; import classes from './SegmentedControl.module.css.js'; import { clsx } from 'clsx'; import { jsx } from 'react/jsx-runtime'; import { Tooltip } from '../TooltipV2/Tooltip.js'; const SegmentedControlIconButton = t0 => { const $ = c(35); let Icon; let ariaLabel; let className; let description; let disabled; let props; let selected; let tooltipDirection; if ($[0] !== t0) { ({ "aria-label": ariaLabel, icon: Icon, selected, className, description, tooltipDirection, disabled, ...props } = t0); $[0] = t0; $[1] = Icon; $[2] = ariaLabel; $[3] = className; $[4] = description; $[5] = disabled; $[6] = props; $[7] = selected; $[8] = tooltipDirection; } else { Icon = $[1]; ariaLabel = $[2]; className = $[3]; description = $[4]; disabled = $[5]; props = $[6]; selected = $[7]; tooltipDirection = $[8]; } let ariaDisabled; let rest; if ($[9] !== props) { ({ "aria-disabled": ariaDisabled, ...rest } = props); $[9] = props; $[10] = ariaDisabled; $[11] = rest; } else { ariaDisabled = $[10]; rest = $[11]; } let t1; if ($[12] !== className) { t1 = clsx(classes.Item, className); $[12] = className; $[13] = t1; } else { t1 = $[13]; } const t2 = selected || undefined; const t3 = description ? undefined : "label"; const t4 = description ? description : ariaLabel; const t5 = description ? ariaLabel : undefined; const t6 = disabled || ariaDisabled || undefined; let t7; if ($[14] === Symbol.for("react.memo_cache_sentinel")) { t7 = clsx(classes.Button, classes.IconButton); $[14] = t7; } else { t7 = $[14]; } let t8; if ($[15] === Symbol.for("react.memo_cache_sentinel")) { t8 = clsx(classes.Content, "segmentedControl-content"); $[15] = t8; } else { t8 = $[15]; } let t9; if ($[16] !== Icon) { t9 = isElement(Icon) ? Icon : /*#__PURE__*/jsx(Icon, {}); $[16] = Icon; $[17] = t9; } else { t9 = $[17]; } let t10; if ($[18] !== t9) { t10 = /*#__PURE__*/jsx("span", { className: t8, children: t9 }); $[18] = t9; $[19] = t10; } else { t10 = $[19]; } let t11; if ($[20] !== rest || $[21] !== selected || $[22] !== t10 || $[23] !== t5 || $[24] !== t6) { t11 = /*#__PURE__*/jsx("button", { type: "button", "aria-current": selected, "aria-label": t5, "aria-disabled": t6, className: t7, ...rest, children: t10 }); $[20] = rest; $[21] = selected; $[22] = t10; $[23] = t5; $[24] = t6; $[25] = t11; } else { t11 = $[25]; } let t12; if ($[26] !== t11 || $[27] !== t3 || $[28] !== t4 || $[29] !== tooltipDirection) { t12 = /*#__PURE__*/jsx(Tooltip, { type: t3, text: t4, direction: tooltipDirection, children: t11 }); $[26] = t11; $[27] = t3; $[28] = t4; $[29] = tooltipDirection; $[30] = t12; } else { t12 = $[30]; } let t13; if ($[31] !== t1 || $[32] !== t12 || $[33] !== t2) { t13 = /*#__PURE__*/jsx("li", { className: t1, "data-selected": t2, children: t12 }); $[31] = t1; $[32] = t12; $[33] = t2; $[34] = t13; } else { t13 = $[34]; } return t13; }; SegmentedControlIconButton.__SLOT__ = Symbol('SegmentedControl.IconButton'); export { SegmentedControlIconButton, SegmentedControlIconButton as default };