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) 3.85 kB
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 r}from"../../core/Context/CoreProvider.js";import n from"../../utils/browserInfo.js";import s 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 c}from"../../core/Analytics/constants.js";function d(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function l(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter((function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable})))),r.forEach((function(t){d(e,t,o[t])}))}return e}function h(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(t)).forEach((function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))})),e}class m extends t{formatProps(e){return h(l({},e),{type:p.customCard})}formatData(){const e=this.state.selectedBrandValue;return{paymentMethod:l({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){var t;return(null===(t=this.componentRef)||void 0===t?void 0:t.updateStyles)&&this.componentRef.updateStyles(e),this}setFocusOn(e){var t;return(null===(t=this.componentRef)||void 0===t?void 0:t.setFocusOn)&&this.componentRef.setFocusOn(e),this}processBinLookupResponse(e){var t;return(null===(t=this.componentRef)||void 0===t?void 0:t.processBinLookupResponse)&&this.componentRef.processBinLookupResponse(e),this}dualBrandingChangeHandler(e){var t;return(null===(t=this.componentRef)||void 0===t?void 0:t.dualBrandingChangeHandler)&&this.componentRef.dualBrandingChangeHandler(e),this}handleUnsupportedCard(e){var t;return(null===(t=this.componentRef)||void 0===t?void 0:t.handleUnsupportedCard)&&this.componentRef.handleUnsupportedCard(e),this}onBinLookup(e){const t=l({},e);var o;(t.rootNode=this._node,t.isReset)||(t.supportedBrandsRaw=null===(o=e.supportedBrandsRaw)||void 0===o?void 0:o.map((e=>{var t,o;return e.brandImageUrl=null!==(o=null===(t=this.props.brandsConfiguration[e.brand])||void 0===t?void 0:t.icon)&&void 0!==o?o:i(e.brand,this.resources),e})));this.props.onBinLookup(t)}get isValid(){return!!this.state.isValid}get browserInfo(){return n()}render(){return e(r,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},e(o,h(l({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),d(this,"brand",p.card),d(this,"onBinValue",s(this)),d(this,"onFocus",(e=>{var t,o;this.submitAnalytics({type:!0===e.focus?u:c,target:a(e.fieldType)}),null===(t=(o=this.props).onFocus)||void 0===t||t.call(o,e)})),d(this,"onEnterKeyPressed",((e,t)=>{var o,r;null===(o=(r=this.props).onEnterKeyPressed)||void 0===o||o.call(r,e,t)}))}}d(m,"type",p.customCard),d(m,"analyticsType","custom-scheme"),d(m,"defaultProps",{onBinLookup:()=>{},brandsConfiguration:{}});export{m as CustomCard,m as default}; //# sourceMappingURL=CustomCard.js.map