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) 2.45 kB
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as o,useState as n,useMemo as r,useEffect as t}from"../../../external/preact/hooks/dist/hooks.js";import a from"../../internal/SecuredFields/SFP/SecuredFieldsProvider.js";import s from"../../internal/SecuredFields/binLookup/extensions.js";function i(i){const l=o(null),[u,c]=n({}),[p,m]=n({}),[y,h]=n({}),[C,S]=n(!1),[f,g]=n(null),[F,V]=n([]),[B,E]=n(""),b=r(()=>s(i,{sfp:l},{dualBrandSelectElements:F,setDualBrandSelectElements:V,setSelectedBrandValue:E,issuingCountryCode:f,setIssuingCountryCode:g}),[F,f]);return this.processBinLookupResponse=(e,o)=>{b.processBinLookup(e,o)},this.dualBrandingChangeHandler=b.handleDualBrandSelection,t(()=>(this.setFocusOn=l.current.setFocusOn,this.updateStyles=l.current.updateStyles,this.showValidation=l.current.showValidation,this.handleUnsupportedCard=l.current.handleUnsupportedCard,()=>{l.current.destroy()}),[]),t(()=>{const e=l.current.mapErrorsToValidationRuleResult(),o={...u,...e};if(i.onChange({data:y,valid:p,errors:o,isValid:C,selectedBrandValue:B}),Object.keys(o).length){const e=Object.entries(o).map(([e,o])=>({fieldType:e,...o||{error:"",rootNode:this.props.rootNode}}));this.props.onValidationError?.(e)}},[y,p,u,B]),e(a,{ref:l,...d(i),type:i.brand,componentType:i.type,onChange:e=>{h({...y,...e.data}),c({...u,...e.errors}),m({...p,...e.valid}),S(e.isSfpValid)},onSubmitAnalytics:i.onSubmitAnalytics,render:()=>null})}i.defaultProps={onChange:()=>{},onError:()=>{},onValidationError:()=>{}};const d=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{i as default}; //# sourceMappingURL=CustomCardInput.js.map