Download node_modules/@radix-ui/react-compose-refs/dist/index.mjs from metarm/QMetaRam: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/metarm/QMetaRam/resolve/main/node_modules/%40radix-ui/react-compose-refs/dist/index.mjs
- Command line
-
hf download hf://metarm/QMetaRam/node_modules/@radix-ui/react-compose-refs/dist/index.mjs
-
curl -L -o index.mjs https://huggingface.co/metarm/QMetaRam/resolve/main/node_modules/%40radix-ui/react-compose-refs/dist/index.mjs
1.22 kB
| var __defProp = Object.defineProperty; | |
| var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); | |
| // src/compose-refs.tsx | |
| import * as React from "react"; | |
| function setRef(ref, value) { | |
| if (typeof ref === "function") { | |
| return ref(value); | |
| } else if (ref !== null && ref !== void 0) { | |
| ref.current = value; | |
| } | |
| } | |
| __name(setRef, "setRef"); | |
| function composeRefs(...refs) { | |
| return (node) => { | |
| let hasCleanup = false; | |
| const cleanups = refs.map((ref) => { | |
| const cleanup = setRef(ref, node); | |
| if (!hasCleanup && typeof cleanup == "function") { | |
| hasCleanup = true; | |
| } | |
| return cleanup; | |
| }); | |
| if (hasCleanup) { | |
| return () => { | |
| for (let i = 0; i < cleanups.length; i++) { | |
| const cleanup = cleanups[i]; | |
| if (typeof cleanup == "function") { | |
| cleanup(); | |
| } else { | |
| setRef(refs[i], null); | |
| } | |
| } | |
| }; | |
| } | |
| }; | |
| } | |
| __name(composeRefs, "composeRefs"); | |
| function useComposedRefs(...refs) { | |
| return React.useCallback(composeRefs(...refs), refs); | |
| } | |
| __name(useComposedRefs, "useComposedRefs"); | |
| export { | |
| composeRefs, | |
| useComposedRefs | |
| }; | |
| //# sourceMappingURL=index.mjs.map | |