UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

103 lines (102 loc) 2.24 kB
import SkeletonBox_module_css_default from "./SkeletonBox.module.css.js"; import { c } from "react-compiler-runtime"; import { clsx } from "clsx"; import { jsx } from "react/jsx-runtime"; import React, { useEffect, useState } from "react"; //#region src/Skeleton/SkeletonBox.tsx const SkeletonBox = /*#__PURE__*/ React.forwardRef(function SkeletonBox(t0, ref) { const $ = c(25); let className; let delay; let height; let props; let style; let t1; let width; if ($[0] !== t0) { ({height, width, className, style, delay, "data-component": t1, ...props} = t0); $[0] = t0; $[1] = className; $[2] = delay; $[3] = height; $[4] = props; $[5] = style; $[6] = t1; $[7] = width; } else { className = $[1]; delay = $[2]; height = $[3]; props = $[4]; style = $[5]; t1 = $[6]; width = $[7]; } const dataComponent = t1 === void 0 ? "SkeletonBox" : t1; const [isVisible, setIsVisible] = useState(!delay); let t2; let t3; if ($[8] !== delay) { t2 = () => { if (delay) { const timeoutId = setTimeout(() => { setIsVisible(true); }, typeof delay === "number" ? delay : delay === "short" ? 300 : 1e3); return () => clearTimeout(timeoutId); } }; t3 = [delay]; $[8] = delay; $[9] = t2; $[10] = t3; } else { t2 = $[9]; t3 = $[10]; } useEffect(t2, t3); if (!isVisible) return null; const t4 = ref; let t5; if ($[11] !== className) { t5 = clsx(className, SkeletonBox_module_css_default.SkeletonBox); $[11] = className; $[12] = t5; } else t5 = $[12]; let t6; if ($[13] !== style) { t6 = style || {}; $[13] = style; $[14] = t6; } else t6 = $[14]; let t7; if ($[15] !== height || $[16] !== t6 || $[17] !== width) { t7 = { height, width, ...t6 }; $[15] = height; $[16] = t6; $[17] = width; $[18] = t7; } else t7 = $[18]; let t8; if ($[19] !== dataComponent || $[20] !== props || $[21] !== t4 || $[22] !== t5 || $[23] !== t7) { t8 = /*#__PURE__*/ jsx("div", { ref: t4, className: t5, style: t7, ...props, "data-component": dataComponent }); $[19] = dataComponent; $[20] = props; $[21] = t4; $[22] = t5; $[23] = t7; $[24] = t8; } else t8 = $[24]; return t8; }); //#endregion export { SkeletonBox };