UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

72 lines (69 loc) 1.63 kB
import { c } from 'react-compiler-runtime'; import { clsx } from 'clsx'; import React, { forwardRef } from 'react'; import classes from './Text.module.css.js'; import { BoxWithFallback } from '../internal/components/BoxWithFallback.js'; import { jsx } from 'react/jsx-runtime'; import { useRefObjectAsForwardedRef } from '../hooks/useRefObjectAsForwardedRef.js'; const Text = /*#__PURE__*/forwardRef((t0, forwardedRef) => { const $ = c(14); let className; let props; let size; let t1; let weight; if ($[0] !== t0) { ({ as: t1, className, size, weight, ...props } = t0); $[0] = t0; $[1] = className; $[2] = props; $[3] = size; $[4] = t1; $[5] = weight; } else { className = $[1]; props = $[2]; size = $[3]; t1 = $[4]; weight = $[5]; } const Component = t1 === undefined ? "span" : t1; const innerRef = React.useRef(null); useRefObjectAsForwardedRef(forwardedRef, innerRef); let t2; if ($[6] !== className) { t2 = clsx(className, classes.Text); $[6] = className; $[7] = t2; } else { t2 = $[7]; } let t3; if ($[8] !== Component || $[9] !== props || $[10] !== size || $[11] !== t2 || $[12] !== weight) { t3 = /*#__PURE__*/jsx(BoxWithFallback, { as: Component, className: t2, "data-size": size, "data-weight": weight, ...props, ref: innerRef }); $[8] = Component; $[9] = props; $[10] = size; $[11] = t2; $[12] = weight; $[13] = t3; } else { t3 = $[13]; } return t3; }); Text.displayName = 'Text'; export { Text as default };