{"version":3,"sources":["../src/useForwardedRef.ts"],"names":[],"mappings":";AACA,SAAuB,WAAW,cAAc;AAEzC,SAAS,gBAAmB,KAAsB;AACxD,QAAM,WAAW,OAAU,IAAI;AAI/B,YAAU,MAAM;AACf,QAAI,CAAC;AAAK;AACV,QAAI,OAAO,QAAQ,YAAY;AAC9B,UAAI,SAAS,OAAO;AAAA,IACrB,OAAO;AACN,UAAI,UAAU,SAAS;AAAA,IACxB;AAAA,EACD,CAAC;AAED,SAAO;AACR","sourcesContent":["'use client'\nimport { ForwardedRef, useEffect, useRef } from \"react\";\n\nexport function useForwardedRef<T>(ref: ForwardedRef<T>) {\n\tconst innerRef = useRef<T>(null);\n\n\t// This useEffect runs after every render to update the forwarded ref in sync with the inner ref that needs to be assignd to the component.\n\t// It needs to be in a useEffect because the ref value is not available until after the render is complete.\n\tuseEffect(() => {\n\t\tif (!ref) return;\n\t\tif (typeof ref === \"function\") {\n\t\t\tref(innerRef.current);\n\t\t} else {\n\t\t\tref.current = innerRef.current;\n\t\t}\n\t});\n\n\treturn innerRef;\n}\n"]}