@primer/react
Version:
An implementation of GitHub's Primer Design System using React
92 lines (91 loc) • 2.94 kB
JavaScript
import Spinner from "../../Spinner/Spinner.js";
import TextInputInnerVisualSlot_module_css_default from "./TextInputInnerVisualSlot.module.css.js";
import { c } from "react-compiler-runtime";
import { clsx } from "clsx";
import { jsx, jsxs } from "react/jsx-runtime";
//#region src/internal/components/TextInputInnerVisualSlot.tsx
const TextInputInnerVisualSlot = (t0) => {
const $ = c(21);
const { children, hasLoadingIndicator, showLoadingIndicator, visualPosition, id, componentPrefix: t1 } = t0;
const componentPrefix = t1 === void 0 ? "TextInput" : t1;
const isLeading = visualPosition === "leading";
if (!children && !hasLoadingIndicator || isLeading && !children && !showLoadingIndicator) return null;
if (!hasLoadingIndicator) {
const t2 = isLeading ? `${componentPrefix}.LeadingVisual` : `${componentPrefix}.TrailingVisual`;
let t3;
if ($[0] !== children || $[1] !== id || $[2] !== t2) {
t3 = /*#__PURE__*/ jsx("span", {
className: "TextInput-icon",
id,
"aria-hidden": "true",
"data-component": t2,
children
});
$[0] = children;
$[1] = id;
$[2] = t2;
$[3] = t3;
} else t3 = $[3];
return t3;
}
const t2 = isLeading ? `${componentPrefix}.LeadingVisual` : `${componentPrefix}.TrailingVisual`;
let t3;
if ($[4] !== children || $[5] !== showLoadingIndicator) {
t3 = children && /*#__PURE__*/ jsx("div", {
className: clsx(showLoadingIndicator ? TextInputInnerVisualSlot_module_css_default.SpinnerHidden : TextInputInnerVisualSlot_module_css_default.SpinnerVisible),
children
});
$[4] = children;
$[5] = showLoadingIndicator;
$[6] = t3;
} else t3 = $[6];
const t4 = showLoadingIndicator ? TextInputInnerVisualSlot_module_css_default.SpinnerVisible : TextInputInnerVisualSlot_module_css_default.SpinnerHidden;
const t5 = children && TextInputInnerVisualSlot_module_css_default.Spinner;
const t6 = children && isLeading && TextInputInnerVisualSlot_module_css_default.SpinnerLeading;
let t7;
if ($[7] !== t4 || $[8] !== t5 || $[9] !== t6) {
t7 = clsx(t4, t5, t6);
$[7] = t4;
$[8] = t5;
$[9] = t6;
$[10] = t7;
} else t7 = $[10];
const t8 = children ? void 0 : "small";
let t9;
if ($[11] !== t7 || $[12] !== t8) {
t9 = /*#__PURE__*/ jsx(Spinner, {
srText: null,
className: t7,
size: t8
});
$[11] = t7;
$[12] = t8;
$[13] = t9;
} else t9 = $[13];
let t10;
if ($[14] !== id || $[15] !== t3 || $[16] !== t9) {
t10 = /*#__PURE__*/ jsxs("div", {
className: TextInputInnerVisualSlot_module_css_default.Box,
id,
children: [t3, t9]
});
$[14] = id;
$[15] = t3;
$[16] = t9;
$[17] = t10;
} else t10 = $[17];
let t11;
if ($[18] !== t10 || $[19] !== t2) {
t11 = /*#__PURE__*/ jsx("span", {
className: "TextInput-icon",
"data-component": t2,
children: t10
});
$[18] = t10;
$[19] = t2;
$[20] = t11;
} else t11 = $[20];
return t11;
};
//#endregion
export { TextInputInnerVisualSlot as default };