UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

77 lines (76 loc) 2.56 kB
import { jsx as t } from "../../../external/preact/jsx-runtime/dist/jsxRuntime.module.js"; import a from "classnames"; import { useState as f, useCallback as p } from "../../../external/preact/hooks/dist/hooks.module.js"; import u from "../../../core/Context/useCoreContext.js"; import { ButtonVariant as h } from "../Button/types.js"; import { Tooltip as s } from "../Tooltip/Tooltip.js"; /* empty css */ import L from "../Button/Button.js"; import { Icon as k } from "../Icon/Icon.js"; const I = ({ textToCopy: o, isHovered: l, buttonLabel: i, showCopyTextTooltip: d = !0, type: e = "Link", ...m }) => { const { i18n: n } = u(), [_, c] = f(n.get("copy")), y = p(async () => { if (o) try { await navigator.clipboard.writeText(o), c(n.get("copied")); } catch (x) { console.log(x); } }, [n, o]), r = p(() => { c(n.get("copy")); }, [n]); return /* @__PURE__ */ t( "span", { className: a("adyen-pe-copy-text__container", { "adyen-pe-copy-text__container--information": e === "Link" }), ...m, children: [ d ? /* @__PURE__ */ t(s, { content: o, isContainerHovered: l, children: /* @__PURE__ */ t( "span", { className: a({ "adyen-pe-copy-text__label": e !== "Default", "adyen-pe-copy-text__information": e === "Link", "adyen-pe-copy-text__text": e === "Text" }), children: i || o } ) }) : /* @__PURE__ */ t( "span", { className: a({ "adyen-pe-copy-text__label": e !== "Default", "adyen-pe-copy-text__information": e === "Link", "adyen-pe-copy-text__text": e === "Text" }), children: i || o } ), /* @__PURE__ */ t(s, { content: _, children: /* @__PURE__ */ t( L, { variant: h.TERTIARY, className: "adyen-pe-copy-text", onClick: y, onBlur: r, onMouseLeaveCapture: r, "data-testid": "copyText", children: /* @__PURE__ */ t( "div", { className: a("adyen-pe-copy-text__icon", { "adyen-pe-copy-text__icon--information": e === "Link" }), children: /* @__PURE__ */ t(k, { name: "copy", "data-testid": "copy-icon" }) } ) } ) }) ] } ); }; export { I as default };