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.76 kB
import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import s from"./CustomCardInput/CustomCardInput.js";import{CoreProvider as o}from"../../core/Context/CoreProvider.js";import n from"../../utils/browserInfo.js";import r from"../internal/SecuredFields/binLookup/triggerBinLookUp.js";import{getCardImageUrl as i,fieldTypeToSnakeCase as a}from"../internal/SecuredFields/utils.js";import{TxVariants as p}from"../tx-variants.js";import{ANALYTICS_FOCUS_STR as u,ANALYTICS_UNFOCUS_STR as d}from"../../core/Analytics/constants.js";function c(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class h extends t{formatProps(e){return{...e,type:p.customCard}}formatData(){const e=this.state.selectedBrandValue;return{paymentMethod:{type:"scheme",...this.state.data,...e&&{brand:e}},browserInfo:this.browserInfo,origin:!!window&&window.location.origin}}submitAnalytics(e){super.submitAnalytics(e,this.props)}updateStyles(e){return this.componentRef?.updateStyles&&this.componentRef.updateStyles(e),this}setFocusOn(e){return this.componentRef?.setFocusOn&&this.componentRef.setFocusOn(e),this}processBinLookupResponse(e){return this.componentRef?.processBinLookupResponse&&this.componentRef.processBinLookupResponse(e),this}dualBrandingChangeHandler(e){return this.componentRef?.dualBrandingChangeHandler&&this.componentRef.dualBrandingChangeHandler(e),this}handleUnsupportedCard(e){return this.componentRef?.handleUnsupportedCard&&this.componentRef.handleUnsupportedCard(e),this}onBinLookup(e){const t={...e};t.rootNode=this._node,t.isReset||(t.supportedBrandsRaw=e.supportedBrandsRaw?.map((e=>(e.brandImageUrl=this.props.brandsConfiguration[e.brand]?.icon??i(e.brand,this.resources),e)))),this.props.onBinLookup(t)}get isValid(){return!!this.state.isValid}get browserInfo(){return n()}render(){return e(o,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},e(s,{ref:e=>{this.componentRef=e},...this.props,...this.state,handleKeyPress:this.handleKeyPress,rootNode:this._node,onChange:this.setState,onBinValue:this.onBinValue,implementationType:"custom",resources:this.resources,brand:this.brand,onFocus:this.onFocus}))}constructor(...e){super(...e),c(this,"brand",p.card),c(this,"onBinValue",r(this)),c(this,"onFocus",(e=>{this.submitAnalytics({type:!0===e.focus?u:d,target:a(e.fieldType)}),this.props.onFocus?.(e)})),c(this,"onEnterKeyPressed",((e,t)=>{this.props.onEnterKeyPressed?.(e,t)}))}}c(h,"type",p.customCard),c(h,"analyticsType","custom-scheme"),c(h,"defaultProps",{onBinLookup:()=>{},brandsConfiguration:{}});export{h as CustomCard,h as default}; //# sourceMappingURL=CustomCard.js.map