UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

138 lines (137 loc) 4.14 kB
import { Tooltip } from "../../TooltipV2/Tooltip.js"; import { IconButton } from "../../Button/IconButton.js"; import { ButtonComponent } from "../../Button/Button.js"; import TextInputInnerAction_module_css_default from "./TextInputInnerAction.module.css.js"; import { c } from "react-compiler-runtime"; import { clsx } from "clsx"; import { Fragment, jsx } from "react/jsx-runtime"; import { forwardRef } from "react"; //#region src/internal/components/TextInputInnerAction.tsx const ConditionalTooltip = (t0) => { const $ = c(6); const { "aria-label": ariaLabel, children, tooltipDirection } = t0; let t1; if ($[0] !== ariaLabel || $[1] !== children || $[2] !== tooltipDirection) { t1 = ariaLabel ? /*#__PURE__*/ jsx(Tooltip, { text: ariaLabel, direction: tooltipDirection, className: TextInputInnerAction_module_css_default.ConditionalTooltip, children }) : children; $[0] = ariaLabel; $[1] = children; $[2] = tooltipDirection; $[3] = t1; } else t1 = $[3]; let t2; if ($[4] !== t1) { t2 = /*#__PURE__*/ jsx(Fragment, { children: t1 }); $[4] = t1; $[5] = t2; } else t2 = $[5]; return t2; }; const TextInputAction = /*#__PURE__*/ forwardRef((t0, forwardedRef) => { const $ = c(28); let ariaLabel; let ariaLabelledBy; let children; let className; let icon; let rest; let t1; let tooltipDirection; if ($[0] !== t0) { ({"aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, tooltipDirection, children, icon, className, variant: t1, ...rest} = t0); $[0] = t0; $[1] = ariaLabel; $[2] = ariaLabelledBy; $[3] = children; $[4] = className; $[5] = icon; $[6] = rest; $[7] = t1; $[8] = tooltipDirection; } else { ariaLabel = $[1]; ariaLabelledBy = $[2]; children = $[3]; className = $[4]; icon = $[5]; rest = $[6]; t1 = $[7]; tooltipDirection = $[8]; } const variant = t1 === void 0 ? "invisible" : t1; const t2 = variant === "invisible" && TextInputInnerAction_module_css_default.Invisible; let t3; if ($[9] !== className || $[10] !== t2) { t3 = clsx(t2, className); $[9] = className; $[10] = t2; $[11] = t3; } else t3 = $[11]; let t4; if ($[12] !== t3) { t4 = { className: t3 }; $[12] = t3; $[13] = t4; } else t4 = $[13]; const styleProps = t4; if (icon && !ariaLabel || !children && !ariaLabel) console.warn("Use the `aria-label` prop to provide an accessible label for assistive technology"); let t5; if ($[14] !== ariaLabel || $[15] !== ariaLabelledBy) { t5 = ariaLabel ? { "aria-label": ariaLabel } : ariaLabelledBy ? { "aria-labelledby": ariaLabelledBy } : { "aria-label": "" }; $[14] = ariaLabel; $[15] = ariaLabelledBy; $[16] = t5; } else t5 = $[16]; const accessibleLabel = t5; let t6; if ($[17] === Symbol.for("react.memo_cache_sentinel")) { t6 = clsx("TextInput-action", TextInputInnerAction_module_css_default.TextInputAction); $[17] = t6; } else t6 = $[17]; let t7; if ($[18] !== accessibleLabel || $[19] !== ariaLabel || $[20] !== children || $[21] !== forwardedRef || $[22] !== icon || $[23] !== rest || $[24] !== styleProps || $[25] !== tooltipDirection || $[26] !== variant) { var _tooltipDirection; t7 = /*#__PURE__*/ jsx("span", { className: t6, "data-component": "TextInput.Action", children: icon && !children && ariaLabel ? /*#__PURE__*/ jsx(IconButton, { ...accessibleLabel, tooltipDirection: (_tooltipDirection = tooltipDirection) !== null && _tooltipDirection !== void 0 ? _tooltipDirection : "s", variant, type: "button", icon, size: "small", ...styleProps, ...rest, ref: forwardedRef }) : /*#__PURE__*/ jsx(ConditionalTooltip, { "aria-label": ariaLabel, children: /*#__PURE__*/ jsx(ButtonComponent, { variant, type: "button", ...styleProps, ...rest, ref: forwardedRef, children }) }) }); $[18] = accessibleLabel; $[19] = ariaLabel; $[20] = children; $[21] = forwardedRef; $[22] = icon; $[23] = rest; $[24] = styleProps; $[25] = tooltipDirection; $[26] = variant; $[27] = t7; } else t7 = $[27]; return t7; }); //#endregion export { TextInputAction as default };