UNPKG

@theguild/components

Version:
22 lines (21 loc) 757 B
"use client"; import { jsx } from "react/jsx-runtime"; import { useEffect, useRef } from "react"; function InputShake({ severity }) { const ref = useRef(null); const prevSeverityRef = useRef(severity); useEffect(() => { const shouldShake = prevSeverityRef.current !== "critical" && severity === "critical"; prevSeverityRef.current = severity; const container = ref.current?.parentElement; if (container && shouldShake) { container.classList.add("animate-shake"); const cleanUp = () => container.classList.remove("animate-shake"); container.addEventListener("animationend", cleanUp, { once: true }); } }, [severity]); return /* @__PURE__ */ jsx("div", { ref, className: "hidden" }); } export { InputShake };