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.74 kB
import{createElement as t}from"../../../external/preact/dist/preact.js";import{UIElement as e}from"../../internal/UIElement/UIElement.js";import s from"../../internal/IssuerList/IssuerList.js";import r from"../../../utils/get-issuer-image.js";import{FALLBACK_CONTEXT as i}from"../../../core/config.js";import o from"../../internal/RedirectButton/RedirectButton.js";function n(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function p(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{},r=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(s).filter(function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable}))),r.forEach(function(e){n(t,e,s[e])})}return t}function a(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e.push.apply(e,s)}return e}(Object(e)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(e,s))}),t}class u extends e{formatProps(t){const e=t.details&&t.details.length&&(t.details.find(t=>"issuer"===t.key)||{}).items||t.issuers||[];return a(p({},t),{issuers:e})}formatData(){var t,e;return{paymentMethod:{type:this.type,issuer:null===(e=this.state)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.issuer}}}get isValid(){var t;return 0===this.props.issuers.length||!!(null===(t=this.state)||void 0===t?void 0:t.isValid)}get brands(){return this.props.showPaymentMethodItemImages?this.props.issuers.map(t=>({icon:t.icon,name:t.id})):[]}componentToRender(){return this.props.issuers.length>0?t(s,a(p({ref:t=>{this.componentRef=t},items:this.props.issuers,highlightedIds:this.props.highlightedIssuers},this.props,this.state),{showImage:this.props.showImage,type:this.constructor.type,onChange:this.setState,onSubmit:this.submit,payButton:this.payButton,contextualText:this.props.i18n.get("issuerList.selectField.contextualText"),onSubmitAnalytics:this.submitAnalytics})):t(o,a(p({showPayButton:this.props.showPayButton,name:this.props.name},this.props),{onSubmit:this.submit,payButton:this.payButton,ref:t=>{this.componentRef=t}}))}constructor(t,e){super(t,e);const s=t=>this.resources.getImage(t);if(this.props.showImage){const t=r({loadingContext:this.props.loadingContext},this.constructor.type,s);this.props.issuers=this.props.issuers.map(e=>a(p({},e),{icon:t(e.id)}))}}}n(u,"defaultProps",{showImage:!0,issuers:[],highlightedIssuers:[],loadingContext:i,showPaymentMethodItemImages:!1});export{u as default}; //# sourceMappingURL=IssuerListContainer.js.map