@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.
39 lines (38 loc) • 1.92 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] = "b05716a2-3025-4d45-af0b-512b10245836", e._sentryDebugIdIdentifier = "sentry-dbid-b05716a2-3025-4d45-af0b-512b10245836");
} catch (e) {}
import { r as useTranslation } from "./translation-BFxyJ1c5.js";
import { t as useDataset } from "./useDataset-ZHrWhmsh.js";
import { t as datasetIdentifier } from "./datasetUtil-Zd4TCTDn.js";
import { t as Field } from "./Field-pcJkjIG_.js";
import { t as Select } from "./Select-CcSRI-H0.js";
import { useMemo } from "preact/hooks";
import { jsx } from "preact/jsx-runtime";
//#region src/components/Shared/fields/CountryField/CountryField.tsx
var COUNTRY_FIELD = ["country"];
function CountryField({ name = "country", data, valid, errors, labels, readonly, handleChangeFor, helperText, allowedCountries, handleBlur }) {
const { t } = useTranslation("common");
const { dataset: countriesFromApi } = useDataset(datasetIdentifier.country);
const countries = useMemo(() => countriesFromApi.filter((country) => allowedCountries ? allowedCountries.includes(country.id) : true), [allowedCountries, countriesFromApi]);
return /* @__PURE__ */ jsx(Field, {
name,
label: labels?.country || t(($) => $["country"]),
errorMessage: errors.country,
isValid: valid.country,
helper: helperText,
dataTestId: "country",
children: (childProps) => /* @__PURE__ */ jsx(Select, {
...childProps,
name,
placeholder: t(($) => $["selectCountryRegion"]),
selected: data.country,
items: countries,
readonly: (countries.length === 1 || readonly) && !!data,
onChange: handleChangeFor("country"),
onBlur: handleBlur
})
});
}
//#endregion
export { CountryField as n, COUNTRY_FIELD as t };