{"version":3,"file":"CopyButton.xvDva5Np.mjs","names":["useState","useRef","startTransition"],"sources":["https:/framerusercontent.com/modules/nb0P7Ns1cepSCkmHj9cy/wmEdVPnRGzeNU8QIJsvZ/CopyButton.js"],"sourcesContent":["// Copy button from Mordant's contact cards (the HTML's .copy button): copies an address or a number, reads \"Copied\"\n// for a moment, then \"Copy\" again. If the clipboard is blocked it says \"Select it\" so the text can be copied by hand.\n// Colours come from the colour styles through the controls, so both themes follow.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{startTransition,useEffect,useRef,useState}from\"react\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function CopyButton(props){const{text=\"sales@mordant.example\",label=\"Copy\",doneLabel=\"Copied\",ink=\"#161616\",line=\"#c9c9c6\"}=props;const[state,setState]=useState(\"idle\");const[over,setOver]=useState(false);const timer=useRef(undefined);useEffect(()=>()=>window.clearTimeout(timer.current),[]);const copy=async()=>{let ok=false;try{await navigator.clipboard.writeText(text);ok=true;}catch{ok=false;}startTransition(()=>setState(ok?\"done\":\"manual\"));window.clearTimeout(timer.current);timer.current=window.setTimeout(()=>startTransition(()=>setState(\"idle\")),1600);};return /*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:copy,onMouseEnter:()=>setOver(true),onMouseLeave:()=>setOver(false),\"aria-live\":\"polite\",style:{...props.style,height:30,padding:\"0 12px\",margin:0,border:0,borderRadius:999,background:\"transparent\",boxShadow:`inset 0 0 0 1px ${over?ink:line}`,color:ink,font:'600 13px/1 \"Instrument Sans\", system-ui, sans-serif',whiteSpace:\"nowrap\",cursor:\"pointer\",transition:\"box-shadow .2s\"},children:state===\"done\"?doneLabel:state===\"manual\"?\"Select it\":label});}addPropertyControls(CopyButton,{text:{type:ControlType.String,title:\"Copies\",defaultValue:\"sales@mordant.example\"},label:{type:ControlType.String,title:\"Label\",defaultValue:\"Copy\"},doneLabel:{type:ControlType.String,title:\"Done\",defaultValue:\"Copied\"},ink:{type:ControlType.Color,title:\"Ink\",defaultValue:\"#161616\"},line:{type:ControlType.Color,title:\"Line\",defaultValue:\"#c9c9c6\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CopyButton\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CopyButton.map"],"mappings":"0MAMG,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,OAAK,wBAAwB,QAAM,OAAO,YAAU,SAAS,MAAI,UAAU,OAAK,WAAW,EAAW,CAAC,EAAM,GAAUA,EAAS,MAAM,EAAO,CAAC,EAAK,GAASA,EAAS,EAAK,EAAQ,EAAMC,EAAO,IAAA,EAAS,EAA2U,OAAzU,UAAkB,EAAO,aAAa,EAAM,OAAO,EAAE,CAAC,CAAC,EAAsS,EAAK,SAAS,CAAC,KAAK,SAAS,QAAQ,SAArT,CAAC,IAAI,EAAG,GAAM,GAAG,CAAC,MAAM,EAAU,UAAU,UAAU,CAAI,EAAE,EAAG,EAAK,MAAM,CAAC,EAAG,EAAM,CAAC,MAAoB,EAAS,EAAG,OAAO,QAAQ,CAAC,EAAE,EAAO,aAAa,EAAM,OAAO,EAAE,EAAM,QAAQ,EAAO,eAAeC,MAAoB,EAAS,MAAM,CAAC,EAAE,IAAI,CAAE,EAAgE,iBAAiB,EAAQ,EAAI,EAAE,iBAAiB,EAAQ,EAAK,EAAE,YAAY,SAAS,MAAM,CAAC,GAAG,EAAM,MAAM,OAAO,GAAG,QAAQ,SAAS,OAAO,EAAE,OAAO,EAAE,aAAa,IAAI,WAAW,cAAc,UAAU,mBAAmB,EAAK,EAAI,IAAO,MAAM,EAAI,KAAK,sDAAsD,WAAW,SAAS,OAAO,UAAU,WAAW,gBAAgB,EAAE,SAAS,IAAQ,OAAO,EAAU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