Spaces:
Configuration error
Configuration error
Download web/apps/labelstudio/src/components/CopyableTooltip/CopyableTooltip.jsx from bisalsaha/lebel-studio: direct link, hf CLI and curl.
- Browser
- Download file 724 Bytes
-
https://huggingface.co/spaces/bisalsaha/lebel-studio/resolve/main/web/apps/labelstudio/src/components/CopyableTooltip/CopyableTooltip.jsx
- Command line
-
hf download hf://spaces/bisalsaha/lebel-studio/web/apps/labelstudio/src/components/CopyableTooltip/CopyableTooltip.jsx
-
curl -L -o CopyableTooltip.jsx https://huggingface.co/spaces/bisalsaha/lebel-studio/resolve/main/web/apps/labelstudio/src/components/CopyableTooltip/CopyableTooltip.jsx
724 Bytes
| import { Children, cloneElement, forwardRef, useCallback } from "react"; | |
| import { useCopyText } from "../../hooks/useCopyText"; | |
| import { Tooltip } from "@humansignal/ui"; | |
| export const CopyableTooltip = forwardRef(({ children, title, textForCopy, ...restProps }, ref) => { | |
| const [copied, copyText] = useCopyText({ defaultText: textForCopy }); | |
| const clickHandler = useCallback((e) => { | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| copyText(); | |
| }, []); | |
| const child = Children.only(children); | |
| const clone = cloneElement(child, { | |
| ...child.props, | |
| ref, | |
| onClick: clickHandler, | |
| }); | |
| return <Tooltip title={copied ? "Copied!" : title} onClick={clickHandler} {...restProps} children={clone} />; | |
| }); | |