{"version":3,"file":"index.cjs","names":[],"sources":["../../../src/utils/mergeRefs/index.ts"],"sourcesContent":["import { isFunction } from '@modern-kit/utils';\n\n/**\n * @description 여러 ref 객체를 하나의 ref 객체로 병합합니다.\n *\n * @template T - 참조 객체의 타입\n * @param {React.Ref<T>[]} refs 병합할 참조 객체 배열\n * @returns {((node: T) => void)} 병합된 참조 객체\n *\n * @example\n * ```tsx\n * const ref1 = useRef<HTMLDivElement>(null);\n * const ref2 = useRef<HTMLDivElement>(null);\n * const mergedRef = mergeRefs(ref1, ref2);\n *\n * <div ref={mergedRef} />\n * ```\n */\nexport const mergeRefs = <T = unknown>(\n  ...refs: React.Ref<T>[]\n): ((node: T) => void) => {\n  return (node: T) =>\n    refs.forEach((ref) => {\n      if (isFunction(ref)) {\n        ref(node);\n      } else if (ref != null) {\n        const refToUse = ref as React.RefObject<T>;\n        refToUse.current = node;\n      }\n    });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,MAAa,aACX,GAAG,SACqB;CACxB,QAAQ,SACN,KAAK,SAAS,QAAQ;EACpB,KAAA,GAAA,kBAAA,YAAe,IAAI,EACjB,IAAI,KAAK;OACJ,IAAI,OAAO,MAAM;GACtB,MAAM,WAAW;GACjB,SAAS,UAAU;;GAErB"}