@adyen/adyen-web
Version:
[](https://www.npmjs.com/package/@adyen/adyen-web)
3 lines (2 loc) • 1.86 kB
JavaScript
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 s}from"../../../utils/clipboard.js";import{SingletonTooltipProvider as i,useTooltip as a}from"../Tooltip/SingletonTooltipProvider.js";import{stopPropagationForActionKeys as p}from"./stopPropagationForActionKeys.js";const c=i=>{const{i18n:c}=r(),l=t(null),{showTooltip:C,hideTooltip:u}=a(),m=e(()=>{s(i.text),C({anchorRef:l,text:c.get("button.copied")})},[i.text,c,C]),f=e(o=>{p(o),"Escape"!==o.key&&"Escape"!==o.code||(o.stopPropagation(),u())},[u]),h=e(()=>{C({anchorRef:l,text:c.get("button.copy")})},[l,c,C]);return o(n,{...i,variant:"iconOnly",buttonRef:l,ariaLabel:i.ariaLabel??c.get("button.copy"),onMouseEnter:h,onMouseLeave:u,onFocus:h,onBlur:u,onClick:m,onKeyPress:p,onKeyDown:f},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"})))},l=t=>o(i,null,o(c,t));export{l as CopyIconButton};
//# sourceMappingURL=CopyIconButton.js.map