@primer/react
Version:
An implementation of GitHub's Primer Design System using React
190 lines (187 loc) • 4.63 kB
JavaScript
import { c } from 'react-compiler-runtime';
import { forwardRef } from 'react';
import { IconButton } from '../../Button/IconButton.js';
import { ButtonComponent } from '../../Button/Button.js';
import { clsx } from 'clsx';
import styles from './TextInputInnerAction.module.css.js';
import { jsx, Fragment } from 'react/jsx-runtime';
import { Tooltip } from '../../TooltipV2/Tooltip.js';
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: styles.ConditionalTooltip,
children: 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(32);
let ariaLabel;
let ariaLabelledBy;
let children;
let className;
let icon;
let rest;
let sxProp;
let t1;
let tooltipDirection;
if ($[0] !== t0) {
({
"aria-label": ariaLabel,
"aria-labelledby": ariaLabelledBy,
tooltipDirection,
children,
icon,
sx: sxProp,
className,
variant: t1,
...rest
} = t0);
$[0] = t0;
$[1] = ariaLabel;
$[2] = ariaLabelledBy;
$[3] = children;
$[4] = className;
$[5] = icon;
$[6] = rest;
$[7] = sxProp;
$[8] = t1;
$[9] = tooltipDirection;
} else {
ariaLabel = $[1];
ariaLabelledBy = $[2];
children = $[3];
className = $[4];
icon = $[5];
rest = $[6];
sxProp = $[7];
t1 = $[8];
tooltipDirection = $[9];
}
const variant = t1 === undefined ? "invisible" : t1;
const t2 = variant === "invisible" && styles.Invisible;
let t3;
if ($[10] !== className || $[11] !== t2) {
t3 = clsx(t2, className);
$[10] = className;
$[11] = t2;
$[12] = t3;
} else {
t3 = $[12];
}
let t4;
if ($[13] !== sxProp) {
t4 = sxProp || {};
$[13] = sxProp;
$[14] = t4;
} else {
t4 = $[14];
}
let t5;
if ($[15] !== t3 || $[16] !== t4) {
t5 = {
className: t3,
sx: t4
};
$[15] = t3;
$[16] = t4;
$[17] = t5;
} else {
t5 = $[17];
}
const styleProps = t5;
if (icon && !ariaLabel || !children && !ariaLabel) {
console.warn("Use the `aria-label` prop to provide an accessible label for assistive technology");
}
let t6;
if ($[18] !== ariaLabel || $[19] !== ariaLabelledBy) {
t6 = ariaLabel ? {
"aria-label": ariaLabel
} : ariaLabelledBy ? {
"aria-labelledby": ariaLabelledBy
} : {
"aria-label": ""
};
$[18] = ariaLabel;
$[19] = ariaLabelledBy;
$[20] = t6;
} else {
t6 = $[20];
}
const accessibleLabel = t6;
let t7;
if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
t7 = clsx("TextInput-action", styles.TextInputAction);
$[21] = t7;
} else {
t7 = $[21];
}
let t8;
if ($[22] !== accessibleLabel || $[23] !== ariaLabel || $[24] !== children || $[25] !== forwardedRef || $[26] !== icon || $[27] !== rest || $[28] !== styleProps || $[29] !== tooltipDirection || $[30] !== variant) {
var _tooltipDirection;
t8 = /*#__PURE__*/jsx("span", {
className: t7,
children: icon && !children && ariaLabel ? /*#__PURE__*/jsx(IconButton, {
...accessibleLabel,
tooltipDirection: (_tooltipDirection = tooltipDirection) !== null && _tooltipDirection !== void 0 ? _tooltipDirection : "s",
variant: variant,
type: "button",
icon: icon,
size: "small",
...styleProps,
...rest,
ref: forwardedRef
}) : /*#__PURE__*/jsx(ConditionalTooltip, {
"aria-label": ariaLabel,
children: /*#__PURE__*/jsx(ButtonComponent, {
variant: variant,
type: "button",
...styleProps,
...rest,
ref: forwardedRef,
children: children
})
})
});
$[22] = accessibleLabel;
$[23] = ariaLabel;
$[24] = children;
$[25] = forwardedRef;
$[26] = icon;
$[27] = rest;
$[28] = styleProps;
$[29] = tooltipDirection;
$[30] = variant;
$[31] = t8;
} else {
t8 = $[31];
}
return t8;
});
export { TextInputAction as default };