@adyen/adyen-web
Version:
[](https://www.npmjs.com/package/@adyen/adyen-web)
3 lines (2 loc) • 2.61 kB
JavaScript
import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import n from"./CustomCardInput/CustomCardInput.js";import s from"../../utils/browserInfo.js";import o from"../internal/SecuredFields/binLookup/triggerBinLookUp.js";import{getCardImageUrl as r,fieldTypeToSnakeCase as i}from"../internal/SecuredFields/utils.js";import{TxVariants as a}from"../tx-variants.js";import{AnalyticsInfoEvent as p,InfoEventType as u}from"../../core/Analytics/events/AnalyticsInfoEvent.js";function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class c extends t{formatProps(e){return{...e,type:a.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}}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??r(e.brand,this.resources),e))),this.props.onBinLookup(t)}get isValid(){return!!this.state.isValid}get browserInfo(){return s()}componentToRender(){return e(n,{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,onSubmitAnalytics:this.submitAnalytics})}constructor(...e){super(...e),d(this,"brand",a.card),d(this,"onBinValue",o(this)),d(this,"onFocus",e=>{const t=new p({component:this.type,type:!0===e.focus?u.focus:u.unfocus,target:i(e.fieldType)});this.submitAnalytics(t),this.props.onFocus?.(e)}),d(this,"onEnterKeyPressed",(e,t)=>{this.props.onEnterKeyPressed?.(e,t)})}}d(c,"type",a.customCard),d(c,"defaultProps",{onBinLookup:()=>{},brandsConfiguration:{}});export{c as CustomCard,c as default};
//# sourceMappingURL=CustomCard.js.map