@atlas-kitchen/adyen-web
Version:
3 lines (2 loc) • 2.4 kB
JavaScript
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({}),[h,y]=n({}),[C,f]=n(!1),[g,S]=n(null),[F,V]=n([]),[B,E]=n(""),k=r((()=>s(i,{sfp:l},{dualBrandSelectElements:F,setDualBrandSelectElements:V,setSelectedBrandValue:E,issuingCountryCode:g,setIssuingCountryCode:S})),[F,g]);return this.processBinLookupResponse=(e,o)=>{k.processBinLookup(e,o)},this.dualBrandingChangeHandler=k.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:h,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)}}),[h,p,u,B]),e(a,{ref:l,...d(i),type:i.brand,onChange:e=>{y({...h,...e.data}),c({...u,...e.errors}),m({...p,...e.valid}),f(e.isSfpValid)},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