{"version":3,"file":"CopyToClipboardCustomView.CegqrsIL.mjs","names":["useState","useRef","useCallback","startTransition"],"sources":["https:/framerusercontent.com/modules/TV14eu0ozHH5KNrhL5Jl/g21GJ29qIdin3mdPMCEM/CopyToClipboardCustomView.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{motion,AnimatePresence}from\"framer-motion\";import{useRef,useEffect,useState,useCallback,startTransition}from\"react\";function getTooltipWrapperStyle(position,offset){const base={position:\"absolute\",pointerEvents:\"none\",zIndex:10,display:\"flex\",justifyContent:\"center\"};const isTop=position.startsWith(\"top\");const align=position.split(\"-\")[1];if(isTop){base.bottom=`calc(100% + ${offset}px)`;}else{base.top=`calc(100% + ${offset}px)`;}if(align===\"left\"){base.left=0;}else if(align===\"center\"){base.left=0;base.right=0;}else{base.right=0;}return base;}const tooltipTransition={duration:.15,ease:[.25,.46,.45,.94]};function getTooltipMotion(position){const isTop=position.startsWith(\"top\");const y=isTop?0:0;return{initial:{opacity:0,y},animate:{opacity:1,y:0},exit:{opacity:0,y},transition:tooltipTransition};}/**\n * @framerDisableUnlink\n * @framerIntrinsicWidth 200\n * @framerIntrinsicHeight 48\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function CopyToClipboard(props){const{value,children,hoverTooltip,copiedTooltip,tooltipPosition,tooltipOffset,style}=props;const[isHovered,setIsHovered]=useState(false);const[isCopied,setIsCopied]=useState(false);const copyTimerRef=useRef(0);useEffect(()=>{return()=>{if(copyTimerRef.current)clearTimeout(copyTimerRef.current);};},[]);const handleClick=useCallback(()=>{navigator.clipboard.writeText(value);startTransition(()=>{setIsCopied(true);});if(copyTimerRef.current)clearTimeout(copyTimerRef.current);copyTimerRef.current=window.setTimeout(()=>{startTransition(()=>{setIsCopied(false);});},1500);},[value]);const tooltipWrapperStyle=getTooltipWrapperStyle(tooltipPosition,tooltipOffset);const motionProps=getTooltipMotion(tooltipPosition);const showHoverTooltip=isHovered&&!isCopied&&hoverTooltip.length>0;const showCopiedTooltip=isCopied&&copiedTooltip.length>0;return /*#__PURE__*/_jsxs(\"div\",{style:{...style,position:\"relative\",cursor:\"pointer\"},onClick:handleClick,onMouseEnter:()=>startTransition(()=>setIsHovered(true)),onMouseLeave:()=>startTransition(()=>setIsHovered(false)),children:[children,/*#__PURE__*/_jsxs(AnimatePresence,{mode:\"wait\",children:[showHoverTooltip&&/*#__PURE__*/_jsx(\"div\",{style:tooltipWrapperStyle,children:/*#__PURE__*/_jsx(motion.div,{...motionProps,children:hoverTooltip.map((child,i)=>/*#__PURE__*/_jsx(\"div\",{style:{display:\"contents\"},children:child},i))})},\"hover-wrapper\"),showCopiedTooltip&&/*#__PURE__*/_jsx(\"div\",{style:tooltipWrapperStyle,children:/*#__PURE__*/_jsx(motion.div,{...motionProps,children:copiedTooltip.map((child,i)=>/*#__PURE__*/_jsx(\"div\",{style:{display:\"contents\"},children:child},i))})},\"copied-wrapper\")]})]});}CopyToClipboard.defaultProps={value:\"Copy me\",children:[],hoverTooltip:[],copiedTooltip:[],tooltipPosition:\"top-center\",tooltipOffset:-4};addPropertyControls(CopyToClipboard,{value:{type:ControlType.String,title:\"Value\",defaultValue:\"Copy me\",description:\"Text copied to clipboard on click\"},children:{type:ControlType.ComponentInstance,title:\"Content\"},hoverTooltip:{type:ControlType.ComponentInstance,title:\"Hover Tooltip\"},copiedTooltip:{type:ControlType.ComponentInstance,title:\"Copied Tooltip\"},tooltipPosition:{type:ControlType.Enum,title:\"Tooltip Position\",options:[\"top-left\",\"top-center\",\"top-right\",\"bottom-left\",\"bottom-center\",\"bottom-right\"],optionTitles:[\"Top Left\",\"Top Center\",\"Top Right\",\"Bottom Left\",\"Bottom Center\",\"Bottom Right\"],defaultValue:\"top-center\"},tooltipOffset:{type:ControlType.Number,title:\"Tooltip Offset\",defaultValue:-4,min:-48,max:48,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CopyToClipboard\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerDisableUnlink\":\"* @framerIntrinsicWidth 200\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"48\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CopyToClipboardCustomView.map"],"mappings":"qRAAwO,SAAS,EAAuB,EAAS,EAAO,CAAC,IAAM,EAAK,CAAC,SAAS,WAAW,cAAc,OAAO,OAAO,GAAG,QAAQ,OAAO,eAAe,SAAS,CAAO,EAAM,EAAS,WAAW,MAAM,CAAO,EAAM,EAAS,MAAM,IAAI,CAAC,GAAsM,OAAhM,EAAO,EAAK,OAAO,eAAe,EAAO,KAAW,EAAK,IAAI,eAAe,EAAO,KAAS,IAAQ,OAAQ,EAAK,KAAK,GAAW,IAAQ,WAAU,EAAK,KAAK,GAAqB,EAAK,MAAM,GAAU,EAAoE,SAAS,EAAiB,EAAS,CAA0D,OAA7C,EAAS,WAAW,MAAM,CAAyB,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAE,CAAC,WAAW,EAAkB,CAMv5B,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,QAAM,WAAS,eAAa,gBAAc,kBAAgB,gBAAc,SAAO,EAAW,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAM,CAAC,EAAS,GAAaA,EAAS,GAAM,CAAO,EAAaC,EAAO,EAAE,CAAC,UAAyB,CAAI,EAAa,SAAQ,aAAa,EAAa,QAAQ,EAAK,EAAE,CAAC,CAAC,IAAM,EAAYC,MAAgB,CAAC,EAAU,UAAU,UAAU,EAAM,CAAC,MAAoB,CAAC,EAAY,GAAK,EAAG,CAAI,EAAa,SAAQ,aAAa,EAAa,QAAQ,CAAC,EAAa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