@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.
110 lines (109 loc) • 4.77 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] = "f4a773aa-824d-4b24-a395-5cd505158ab8", e._sentryDebugIdIdentifier = "sentry-dbid-f4a773aa-824d-4b24-a395-5cd505158ab8");
} catch (e) {}
import { r as summaryItem } from "./summaryItem-uDWmtYtt.js";
import { t as isEmpty } from "./isEmpty-BVlBH98t.js";
import { r as mapSchemaFieldsToApiScriptLocalization } from "./mapAddressLocalizationToJpAddressSchema-CBeBTFmC.js";
import { jsx, jsxs } from "preact/jsx-runtime";
//#region src/components/Shared/forms/Address/localized/jp/mapJpAddressSummary.tsx
var mapJpAddressSummary = (data, datasetUtils) => {
if (!data) return {};
return {
country: datasetUtils.getCountryName("JP") ?? "JP",
postalCode: summaryItem("postalCode", data.postalCode),
stateOrProvince: summaryItem("prefecture", /* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx("p", { children: data.jaHaniStateOrProvince }),
/* @__PURE__ */ jsx("p", { children: data.jaKanaStateOrProvince }),
/* @__PURE__ */ jsx("p", { children: data.stateOrProvince })
] })),
city: summaryItem("districtTownAreaCityWard", /* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx("p", { children: data.jaHaniCity }),
/* @__PURE__ */ jsx("p", { children: data.jaKanaCity }),
/* @__PURE__ */ jsx("p", { children: data.city })
] })),
otherAddressInformation: summaryItem("chomeAndBanchi", data.otherAddressInformation),
address: summaryItem("buildingNameFloorRoomNumberEtc", /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", { children: data.jaHaniAddress }), /* @__PURE__ */ jsx("p", { children: data.address })] }))
};
};
var mapJpAddressSummaryNewSummary = (data, datasetUtils) => {
if (!data) return {};
return {
country: datasetUtils.getCountryName("JP") ?? "JP",
postalCode: data.postalCode,
prefecture: /* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx("p", { children: data.jaHaniStateOrProvince }),
/* @__PURE__ */ jsx("p", { children: data.jaKanaStateOrProvince }),
/* @__PURE__ */ jsx("p", { children: data.stateOrProvince })
] }),
districtTownAreaCityWard: /* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx("p", { children: data.jaHaniCity }),
/* @__PURE__ */ jsx("p", { children: data.jaKanaCity }),
/* @__PURE__ */ jsx("p", { children: data.city })
] }),
chomeAndBanchi: data.otherAddressInformation,
buildingNameFloorRoomNumberEtc: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", { children: data.jaHaniAddress }), /* @__PURE__ */ jsx("p", { children: data.address })] })
};
};
//#endregion
//#region src/utils/textTransformation/toFullWidth.ts
var applyDelta = (delta) => (char) => String.fromCharCode(char.charCodeAt(0) + delta);
/**
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize#nfkc
*/
var standardNormalization = (input) => input.normalize("NFKC");
/**
* The order here does matter, since the characters matched by each converter may overlap.
*/
var converters = [
{
name: "latin",
match: /[!-~]/g,
convert: applyDelta(65248)
},
{
name: "hangul1",
match: /[ᄀ-ᄒ]/g,
convert: standardNormalization
},
{
name: "hangul2",
match: /[ᅡ-ᅵ]/g,
convert: standardNormalization
},
{
name: "katakana",
match: /[\uff60-\uff9f]+/g,
convert: standardNormalization
},
{
name: "extras",
match: /[¢£¬¯¦¥₩\u0020|←↑→↓■°]/g,
convert: (char) => {
return "¢£¬ ̄¦¥₩ |←↑→↓■○"["¢£¬¯¦¥₩ |←↑→↓■°".indexOf(char)];
}
}
];
/**
* Replaces half-width characters with full-width characters.
* Includes Latin characters, Katakana, Hangul and various symbols.
*/
var toFullWidth = (value) => {
let input = value;
for (const { match, convert } of converters) input = input.replaceAll(match, convert);
return input;
};
//#endregion
//#region src/components/Shared/forms/Address/localized/jp/mapJpAddressSchemaToAddressLocalizations.ts
var mapJpAddressSchemaToAddressLocalizations = (data) => {
if (!data) return [];
return [mapSchemaFieldsToApiScriptLocalization(data, "jaHani"), mapSchemaFieldsToApiScriptLocalization(data, "jaKana")].filter(({ fields }) => !isEmpty(fields)).map(({ script, fields }) => ({
script,
fields: {
city: fields.city,
..."address" in fields ? { street: fields.address } : void 0
}
}));
};
//#endregion
export { mapJpAddressSummaryNewSummary as i, toFullWidth as n, mapJpAddressSummary as r, mapJpAddressSchemaToAddressLocalizations as t };