@adyen/adyen-web
Version:
[](https://www.npmjs.com/package/@adyen/adyen-web)
3 lines (2 loc) • 3.11 kB
JavaScript
import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/uuid.js";import r from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as o}from"../../../core/Analytics/constants.js";import{on as n,off as s}from"../../../utils/listenerUtils.js";import{createSdkData as i}from"../../../utils/createSdkData.js";function a(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function c(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),o.forEach(function(e){a(t,e,r[e])})}return t}function u(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 r=Object.getOwnPropertySymbols(t);e.push.apply(e,r)}return e}(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}class h{buildElementProps(t){this.props=this.formatProps(c({},this.constructor.defaultProps,t))}formatProps(t){return t}formatData(){return{}}submitAnalytics(t){return null}handleKeyPress(t){return null}setState(t){this.state=c({},this.state,t)}get data(){var t;const e=this.state.order||this.props.order,r=this.formatData(),n=this.core.modules.risk.data,s=null!==(t=this.core.modules.analytics.checkoutAttemptId)&&void 0!==t?t:o,a=i(s,n);return r.paymentMethod&&s&&(r.paymentMethod.checkoutAttemptId=s),r.paymentMethod&&a&&(r.paymentMethod.sdkData=a),u(c({},n&&{riskData:{clientData:n}},e&&{order:{orderData:e.orderData,pspReference:e.pspReference}},r),{clientStateDataIndicator:!0})}activate(){}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error("Component could not mount. Root node was not found.");return this._node&&this.unmount(),this._node=r,n(this._node,"keypress",this.handleKeyPress,!1),this._component=this.render(),t(this._component,r),this}update(t){return this.props=this.formatProps(c({},this.props,t)),this.state={},this.unmount().mount(this._node)}unmount(){return s(this._node,"keypress",this.handleKeyPress),this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,o){a(this,"_id",`${this.constructor.type}-${e()}`),a(this,"core",void 0),a(this,"props",void 0),a(this,"state",{}),a(this,"_component",void 0),a(this,"_node",null);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new r("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(o),this.handleKeyPress=this.handleKeyPress.bind(this)}}a(h,"defaultProps",{});export{h as default};
//# sourceMappingURL=BaseElement.js.map