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.

56 lines (55 loc) 2.04 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] = "c4c76eff-2990-4190-92d9-7286b43c4e1d", e._sentryDebugIdIdentifier = "sentry-dbid-c4c76eff-2990-4190-92d9-7286b43c4e1d"); } catch (e) {} import { t as useAnalyticsContext } from "./useAnalyticsContext-BVFDMrVE.js"; import cx from "classnames"; import { Fragment, jsx, jsxs } from "preact/jsx-runtime"; //#region src/components/ui/atoms/Checkbox/Checkbox.tsx function Checkbox({ id, name, value, className, label, isInvalid, onChange, helper, checked, readonly, disabled, enableTracking = false, "aria-required": ariaRequired, "aria-invalid": ariaInvalid, "aria-describedby": ariaDescribedBy }) { const userEvents = useAnalyticsContext(); const handleChange = (newValue) => { if (enableTracking) userEvents.addFieldEvent("Interacted with form field", { actionType: "input", field: name, returnValue: String(newValue) }); onChange(newValue); }; const helperId = `${id}-helper`; return /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx("input", { id, name, value, "aria-describedby": `${helper ? helperId : ""} ${ariaDescribedBy ?? ""}`.trim(), "aria-invalid": ariaInvalid || isInvalid, "aria-required": ariaRequired, readOnly: readonly, disabled, checked, className: cx([ "adyen-kyc-checkbox__input", [className], { "adyen-kyc-checkbox__input--invalid": isInvalid } ]), type: "checkbox", onClick: (event) => { event.stopPropagation(); handleChange(!checked); } }), /* @__PURE__ */ jsx("label", { htmlFor: id, className: "adyen-kyc-checkbox__label", children: label }), helper && /* @__PURE__ */ jsx("span", { id: helperId, className: "adyen-kyc-checkbox__helper-text", children: helper }) ] }); } //#endregion export { Checkbox as t };