@adyen/kyc-components
Version:
This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.
76 lines (75 loc) • 2.76 kB
JavaScript
try {
let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "2f917980-8fb3-4bca-9327-7e80cdbdf89d", e._sentryDebugIdIdentifier = "sentry-dbid-2f917980-8fb3-4bca-9327-7e80cdbdf89d");
} catch (e) {}
import { i as Typography, r as useTranslation } from "./translation-BYvhW5zA.js";
import { t as Button } from "./Button-i8I2dHP8.js";
import { i as useAnalyticsContext, t as Modal } from "./Modal-BLP2aF-u.js";
import { useEffect, useState } from "preact/hooks";
import { jsx, jsxs } from "preact/jsx-runtime";
var Confirm_module_default = {
confirm: "_confirm_1aprd_1",
"confirm-message": "_confirm-message_1aprd_8",
confirmMessage: "_confirm-message_1aprd_8",
"confirm-actions": "_confirm-actions_1aprd_14",
confirmActions: "_confirm-actions_1aprd_14"
};
//#endregion
//#region src/components/ui/molecules/Confirm/Confirm.tsx
var Confirm = ({ description, cancelText, confirmText, critical = false, onCancel, onConfirm, title, analyticsEventLabel }) => {
const { t } = useTranslation("ui");
const userEvents = useAnalyticsContext();
const [isInFlight, setIsInFlight] = useState(false);
const showCancelButton = onCancel !== void 0;
const buttonVariant = critical ? "critical" : "primary";
useEffect(() => {
userEvents.addTaskEvent("Opened modal", {
actionType: "open",
label: analyticsEventLabel
});
}, []);
const handleConfirm = async () => {
setIsInFlight(true);
try {
await onConfirm();
} finally {
setIsInFlight(false);
}
};
return /* @__PURE__ */ jsx(Modal, {
size: "small",
transition: "dropIn",
showCloseButton: false,
ariaLabel: title,
children: /* @__PURE__ */ jsxs("div", {
className: Confirm_module_default.confirm,
children: [/* @__PURE__ */ jsxs("div", {
className: Confirm_module_default.confirmMessage,
children: [/* @__PURE__ */ jsx(Typography, {
variant: "title",
el: "h3",
children: title
}), description && /* @__PURE__ */ jsx(Typography, {
variant: "body",
el: "p",
children: description
})]
}), /* @__PURE__ */ jsxs("div", {
className: Confirm_module_default.confirmActions,
children: [showCancelButton && /* @__PURE__ */ jsx(Button, {
onClick: onCancel,
variant: "secondary",
disabled: isInFlight,
children: cancelText ?? t(($) => $["cancel"])
}), /* @__PURE__ */ jsx(Button, {
onClick: handleConfirm,
variant: buttonVariant,
loading: isInFlight,
children: confirmText ?? t(($) => $["confirm"])
})]
})]
})
});
};
//#endregion
export { Confirm as t };