@atlas-kitchen/adyen-web
Version:
3 lines (2 loc) • 2.8 kB
JavaScript
import{createElement as e}from"../../external/preact/dist/preact.js";import{UIElement as t}from"../internal/UIElement/UIElement.js";import o from"./CustomCardInput/CustomCardInput.js";import{CoreProvider as s}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 d,ANALYTICS_UNFOCUS_STR as u}from"../../core/Analytics/constants.js";import{AnalyticsInfoEvent as c}from"../../core/Analytics/AnalyticsInfoEvent.js";function h(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}class m 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}}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(s,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},e(o,{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),h(this,"brand",p.card),h(this,"onBinValue",r(this)),h(this,"onFocus",(e=>{const t=new c({type:!0===e.focus?d:u,target:a(e.fieldType)});this.submitAnalytics(t),this.props.onFocus?.(e)})),h(this,"onEnterKeyPressed",((e,t)=>{this.props.onEnterKeyPressed?.(e,t)}))}}h(m,"type",p.customCard),h(m,"analyticsType","custom-scheme"),h(m,"defaultProps",{onBinLookup:()=>{},brandsConfiguration:{}});export{m as CustomCard,m as default};
//# sourceMappingURL=CustomCard.js.map