UNPKG

@adyen/adyen-web

Version:

[![npm](https://img.shields.io/npm/v/@adyen/adyen-web.svg)](https://www.npmjs.com/package/@adyen/adyen-web)

3 lines (2 loc) 1.96 kB
import{createElement as o}from"../../../external/preact/dist/preact.js";import{useRef as t,useCallback as e}from"../../../external/preact/hooks/dist/hooks.js";import n from"./Button.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";import{copyToClipboard as a}from"../../../utils/clipboard.js";import{SingletonTooltipProvider as s,useTooltip as i}from"../Tooltip/SingletonTooltipProvider.js";const c=s=>{const{i18n:c}=r(),p=t(null),{showTooltip:l,hideTooltip:C}=i(),u=e(()=>{a(s.text),l({anchorRef:p,text:c.get("button.copied")})},[s.text,c,l]),d=e(o=>{"Enter"!==o.key&&"Enter"!==o.code&&" "!==o.key&&"Space"!==o.code||o.stopPropagation()},[C]),m=e(o=>{"Enter"!==o.key&&"Enter"!==o.code&&" "!==o.key&&"Space"!==o.code||o.stopPropagation(),"Escape"!==o.key&&"Escape"!==o.code||(o.stopPropagation(),C())},[C]),y=e(()=>{l({anchorRef:p,text:c.get("button.copy")})},[p,c,l]);return o(n,{...s,variant:"iconOnly",buttonRef:p,ariaLabel:s.ariaLabel??c.get("button.copy"),onMouseEnter:y,onMouseLeave:C,onFocus:y,onBlur:C,onClick:u,onKeyPress:d,onKeyDown:m},o("svg",{className:"adyen-checkout__button--iconOnly__icon",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},o("path",{d:"M3.5 1.25C2.25736 1.25 1.25 2.25736 1.25 3.5V8.5C1.25 9.74264 2.25736 10.75 3.5 10.75H5.25V12.5C5.25 13.7426 6.25736 14.75 7.5 14.75H12.5C13.7426 14.75 14.75 13.7426 14.75 12.5V7.5C14.75 6.25736 13.7426 5.25 12.5 5.25H10.75V3.5C10.75 2.25736 9.74264 1.25 8.5 1.25H3.5ZM9.25 5.25H7.5C6.25736 5.25 5.25 6.25736 5.25 7.5V9.25H3.5C3.08579 9.25 2.75 8.91421 2.75 8.5V3.5C2.75 3.08579 3.08579 2.75 3.5 2.75H8.5C8.91421 2.75 9.25 3.08579 9.25 3.5V5.25ZM6.75 12.5V7.5C6.75 7.08579 7.08579 6.75 7.5 6.75H12.5C12.9142 6.75 13.25 7.08579 13.25 7.5V12.5C13.25 12.9142 12.9142 13.25 12.5 13.25H7.5C7.08579 13.25 6.75 12.9142 6.75 12.5Z"})))},p=t=>o(s,null,o(c,t));export{p as CopyIconButton}; //# sourceMappingURL=CopyIconButton.js.map