UNPKG

@adyen/adyen-web

Version:

[![npm](https://img.shields.io/npm/v/@adyen/adyen-web.svg)](https://www.npmjs.com/package/@adyen/adyen-web)

3 lines (2 loc) 3.3 kB
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as o,useState as n,useMemo as t,useEffect as r}from"../../../external/preact/hooks/dist/hooks.js";import a from"../../internal/SecuredFields/SFP/SecuredFieldsProvider.js";import i from"../../internal/SecuredFields/binLookup/extensions.js";function s(e,o,n){return o in e?Object.defineProperty(e,o,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[o]=n,e}function l(e){for(var o=1;o<arguments.length;o++){var n=null!=arguments[o]?arguments[o]:{},t=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),t.forEach(function(o){s(e,o,n[o])})}return e}function d(e,o){return o=null!=o?o:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):function(e){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);o.push.apply(o,n)}return o}(Object(o)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}),e}function u(s){const u=o(null),[p,y]=n({}),[m,f]=n({}),[b,g]=n({}),[h,S]=n(!1),[O,C]=n(null),[j,F]=n([]),[P,V]=n(""),E=t(()=>i(s,{sfp:u},{dualBrandSelectElements:j,setDualBrandSelectElements:F,setSelectedBrandValue:V,issuingCountryCode:O,setIssuingCountryCode:C}),[j,O]);return this.processBinLookupResponse=(e,o)=>{E.processBinLookup(e,o)},this.dualBrandingChangeHandler=E.handleDualBrandSelection,r(()=>(this.setFocusOn=u.current.setFocusOn,this.updateStyles=u.current.updateStyles,this.showValidation=u.current.showValidation,this.handleUnsupportedCard=u.current.handleUnsupportedCard,()=>{u.current.destroy()}),[]),r(()=>{const e=u.current.mapErrorsToValidationRuleResult(),o=l({},p,e);if(s.onChange({data:b,valid:m,errors:o,isValid:h,selectedBrandValue:P}),Object.keys(o).length){var n,t;const e=Object.entries(o).map(([e,o])=>l({fieldType:e},o||{error:"",rootNode:this.props.rootNode}));null===(n=(t=this.props).onValidationError)||void 0===n||n.call(t,e)}},[b,m,p,P]),e(a,d(l({ref:u},c(s)),{type:s.brand,componentType:s.type,onChange:e=>{g(l({},b,e.data)),y(l({},p,e.errors)),f(l({},m,e.valid)),S(e.isSfpValid)},onSubmitAnalytics:s.onSubmitAnalytics,render:()=>null}))}u.defaultProps={onChange:()=>{},onError:()=>{},onValidationError:()=>{}};const c=e=>({autoFocus:e.autoFocus,brands:e.brands,brandsConfiguration:e.brandsConfiguration,clientKey:e.clientKey,forceCompat:e.forceCompat,i18n:e.i18n,implementationType:e.implementationType,keypadFix:e.keypadFix,legacyInputMode:e.legacyInputMode,loadingContext:e.loadingContext,minimumExpiryDate:e.minimumExpiryDate,onAdditionalSFConfig:e.onAdditionalSFConfig,onAdditionalSFRemoved:e.onAdditionalSFRemoved,onAllValid:e.onAllValid,onAutoComplete:e.onAutoComplete,onBinValue:e.onBinValue,onBrand:e.onBrand,onConfigSuccess:e.onConfigSuccess,handleKeyPress:e.handleKeyPress,onError:e.onError,onFieldValid:e.onFieldValid,onFocus:e.onFocus,onLoad:e.onLoad,rootNode:e.rootNode,showWarnings:e.showWarnings,styles:e.styles,trimTrailingSeparator:e.trimTrailingSeparator,resources:e.resources,maskSecurityCode:e.maskSecurityCode,placeholders:e.placeholders});export{u as default}; //# sourceMappingURL=CustomCardInput.js.map