@atlas-kitchen/adyen-web
Version:
3 lines (2 loc) • 3.89 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 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";import{AnalyticsInfoEvent as d}from"../../core/Analytics/AnalyticsInfoEvent.js";function l(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function h(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){l(e,t,o[t])}))}return e}function m(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 f extends t{formatProps(e){return m(h({},e),{type:p.customCard})}formatData(){const e=this.state.selectedBrandValue;return{paymentMethod:h({type:"scheme"},this.state.data,e&&{brand:e}),browserInfo:this.browserInfo,origin:!!window&&window.location.origin}}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=h({},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,m(h({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),l(this,"brand",p.card),l(this,"onBinValue",s(this)),l(this,"onFocus",(e=>{var t,o;const r=new d({type:!0===e.focus?u:c,target:a(e.fieldType)});this.submitAnalytics(r),null===(t=(o=this.props).onFocus)||void 0===t||t.call(o,e)})),l(this,"onEnterKeyPressed",((e,t)=>{var o,r;null===(o=(r=this.props).onEnterKeyPressed)||void 0===o||o.call(r,e,t)}))}}l(f,"type",p.customCard),l(f,"analyticsType","custom-scheme"),l(f,"defaultProps",{onBinLookup:()=>{},brandsConfiguration:{}});export{f as CustomCard,f as default};
//# sourceMappingURL=CustomCard.js.map