@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) • 3.69 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] = "485a88df-cd44-49cb-9c76-e406539856a0", e._sentryDebugIdIdentifier = "sentry-dbid-485a88df-cd44-49cb-9c76-e406539856a0");
} catch (e) {}
import { createContext } from "preact";
//#region src/utils/entriesOf.ts
var entriesOf = (object) => Object.entries(object);
var valuesOf = (object) => Object.values(object);
var keysOf = (object) => Object.keys(object);
//#endregion
//#region src/utils/genUtils.ts
var keyIsInObject = (key, obj) => key in obj;
/**
* 'Destructures' properties from object - returns a new object only containing those properties that were asked for (including if those properties
* have values that are falsy: null, undefined, false, '').
*
* @param propertiesToKeep - property names to select: can be either 'regular' arguments (comma separated list) or an array
* @returns - an object with a function 'from' that accepts a single argument - the object from which to choose properties.
* This function returns a new object - a copy of the original but only including the desired properties
*
* @example const strippedObj = pick('cardType', 'securityCode').from(cardObject);
* @example const strippedObj = pick(['cardType', 'securityCode']).from(cardObject);
*/
var pick = (...propertiesToKeep) => ({ from: (obj) => propertiesToKeep.map((k) => keyIsInObject(k, obj) ? { [k]: obj[k] } : {}).reduce((res, o) => ({
...res,
...o
}), {}) });
/**
*'Destructures' properties from object, returning a new object containing all the original objects properties except those that were specifically rejected
*
* @param propertiesToDrop - property names to reject: can be either 'regular' arguments (comma separated list) or an array
* @returns - an object with a function 'from' that accepts a single argument - the object from which to reject properties.
* This function returns a new object - a copy of the original but excluding the selected properties
*
* @example const strippedObj = drop('permittedLengths', 'pattern', 'startingRules').from(cardObject);
* @example const strippedObj = drop(['permittedLengths', 'pattern', 'startingRules']).from(cardObject);
*/
var drop = (...propertiesToDrop) => ({ from: (obj) => {
return pick(...keysOf(obj).filter((k) => !propertiesToDrop.includes(k))).from(obj);
} });
/**
* Compares 2 arrays of (primitive) values to see if they are the same
* re. https://sebhastian.com/javascript-compare-array/
*/
var doArraysMatch = (arr1, arr2) => arr1.length === arr2.length && arr1.every((element) => arr2.includes(element));
/**
* Recursively compare 2 objects
*/
var objectsDeepEqual = (x, y) => {
if (x && y && typeof x === "object" && typeof y === "object") {
if (x instanceof File && y instanceof File) return x === y;
if (Object.keys(x).length !== Object.keys(y).length) return false;
return keysOf(x).every((key) => objectsDeepEqual(x[key], y[key]));
}
return x === y;
};
function cloneObject(object) {
return structuredClone(object);
}
var noop = () => {};
var AnalyticsContext = createContext({
addEvent: noop,
addJourneyEvent: noop,
addTaskEvent: noop,
addPageEvent: noop,
addFieldEvent: noop,
startEvent: noop,
subscribe: noop,
trackExperiment: noop,
updateBaseTrackingPayload: noop,
updateSharedEventProperties: noop,
unsubscribe: noop
});
//#endregion
export { noop as a, entriesOf as c, drop as i, keysOf as l, cloneObject as n, objectsDeepEqual as o, doArraysMatch as r, pick as s, AnalyticsContext as t, valuesOf as u };