UNPKG

@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.

164 lines (163 loc) 6.75 kB
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] = "0cbf339c-78fd-4420-a6f3-db98e766e76e", e._sentryDebugIdIdentifier = "sentry-dbid-0cbf339c-78fd-4420-a6f3-db98e766e76e"); } catch (e) {} import { r as useTranslation } from "./translation-BYvhW5zA.js"; import { n as IconButton, t as Button } from "./Button-i8I2dHP8.js"; import { t as TaskVerificationStatus } from "./TaskVerificationStatus-CKHPTEpH.js"; import { i as TaskStatuses } from "./taskStatus-BtekPA8E.js"; import { t as Card } from "./Card-BCGLpdw7.js"; import { t as VerificationErrorAlert } from "./VerificationErrorAlert-B_RKlfIG.js"; import { t as Confirm } from "./Confirm-CA-gL38n.js"; import { n as getRoleTagVariant, t as getRoleName } from "./roleMetadata-v10ns9iG.js"; import { t as Tag } from "./Tag-CNeDHqKp.js"; import { useCallback, useEffect, useRef, useState } from "preact/hooks"; import { jsx, jsxs } from "preact/jsx-runtime"; //#region src/hooks/useClickAwayListener.tsx function useClickAwayListener(ref, onClickAway) { const handleClickAway = useCallback((event) => { if (ref.current && !event.composedPath().includes(ref.current)) onClickAway(); }, [ref, onClickAway]); useEffect(() => { document.addEventListener("mousedown", handleClickAway); return () => { document.removeEventListener("mousedown", handleClickAway); }; }, [handleClickAway]); } var ClickAwayWrapper = ({ children, onClickAway, ...divProps }) => { const ref = useRef(null); useClickAwayListener(ref, onClickAway); return /* @__PURE__ */ jsx("div", { ref, ...divProps, children }); }; var ActionsMenu_module_default = { "actions-menu": "_actions-menu_1beo6_1", actionsMenu: "_actions-menu_1beo6_1", "actions-menu-option": "_actions-menu-option_1beo6_14", actionsMenuOption: "_actions-menu-option_1beo6_14" }; //#endregion //#region src/components/ui/atoms/ActionsMenu/ActionsMenu.tsx var ActionsMenu = ({ options, open, setOpen }) => { const menuItems = options.map(({ label, onSelect, icon }) => /* @__PURE__ */ jsx(Button, { onClick: (event) => { event.stopPropagation(); setOpen(false); onSelect(); }, variant: "tertiary", icon, children: label }, label)); return open ? /* @__PURE__ */ jsx(ClickAwayWrapper, { onClickAway: () => { setOpen(false); }, className: ActionsMenu_module_default.actionsMenu, role: "menu", children: menuItems }) : null; }; var EntityAssociation_module_default = { "entity-association-wrapper": "_entity-association-wrapper_13p8c_1", entityAssociationWrapper: "_entity-association-wrapper_13p8c_1", "entity-association": "_entity-association_13p8c_1", entityAssociation: "_entity-association_13p8c_1", "entity-association-top": "_entity-association-top_13p8c_12", entityAssociationTop: "_entity-association-top_13p8c_12", "entity-association-title": "_entity-association-title_13p8c_17", entityAssociationTitle: "_entity-association-title_13p8c_17", "entity-association-info": "_entity-association-info_13p8c_29", entityAssociationInfo: "_entity-association-info_13p8c_29", "entity-association-tag": "_entity-association-tag_13p8c_35", entityAssociationTag: "_entity-association-tag_13p8c_35", "entity-association-actions": "_entity-association-actions_13p8c_39", entityAssociationActions: "_entity-association-actions_13p8c_39", "entity-association-alert": "_entity-association-alert_13p8c_43", entityAssociationAlert: "_entity-association-alert_13p8c_43", card: "_card_13p8c_48" }; //#endregion //#region src/components/Shared/EntityAssociation/EntityAssociation.tsx var EntityAssociation = ({ name, types, status, actions, problems, infoContent, onNavigateToEntity, deleteEntity, isDeleteDisabled }) => { const { t } = useTranslation("common"); const [showingActions, setShowingActions] = useState(false); const [isConfirmShown, setIsConfirmShown] = useState(false); const isDeletable = !!deleteEntity; const handleRemoveIntent = (event) => { event.stopPropagation(); setIsConfirmShown(true); }; const dismissConfirm = () => { setIsConfirmShown(false); }; return /* @__PURE__ */ jsxs("div", { className: EntityAssociation_module_default.entityAssociationWrapper, children: [/* @__PURE__ */ jsx(Card, { onClick: onNavigateToEntity, children: /* @__PURE__ */ jsxs("div", { className: EntityAssociation_module_default.entityAssociation, children: [ /* @__PURE__ */ jsxs("div", { className: EntityAssociation_module_default.entityAssociationTop, children: [/* @__PURE__ */ jsx("h3", { className: EntityAssociation_module_default.entityAssociationTitle, children: name }), /* @__PURE__ */ jsxs("div", { className: EntityAssociation_module_default.entityAssociationInfo, children: [ /* @__PURE__ */ jsx(TaskVerificationStatus, { status }), actions && /* @__PURE__ */ jsxs("div", { className: EntityAssociation_module_default.entityAssociationActions, children: [/* @__PURE__ */ jsx(IconButton, { variant: "tertiary", icon: "more-horiz", onClick: (event) => { event.stopPropagation(); setShowingActions(!showingActions); }, ariaLabel: t(($) => $["toggleAssociationMenu"], { name }) }), /* @__PURE__ */ jsx(ActionsMenu, { options: actions, open: showingActions, setOpen: setShowingActions })] }), isDeletable && /* @__PURE__ */ jsx(IconButton, { ariaLabel: t(($) => $["delete"]), icon: "bin", variant: "tertiary", onClick: handleRemoveIntent, disabled: isConfirmShown || isDeleteDisabled }) ] })] }), /* @__PURE__ */ jsx("div", { children: types.map((type) => /* @__PURE__ */ jsx(Tag, { className: EntityAssociation_module_default.entityAssociationTag, variant: getRoleTagVariant(type), children: t(($) => $[getRoleName(type)]) }, type)) }), status === TaskStatuses.ERROR && /* @__PURE__ */ jsx(VerificationErrorAlert, { className: EntityAssociation_module_default.entityAssociationAlert, problems }), infoContent ] }) }), isConfirmShown && isDeletable && /* @__PURE__ */ jsx(Confirm, { title: t(($) => $["deleteItem"], { item: name }), description: t(($) => $["thisActionIsPermanent"]), onConfirm: deleteEntity, confirmText: t(($) => $["delete"]), onCancel: dismissConfirm, critical: true })] }); }; //#endregion export { EntityAssociation as t };