UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

82 lines (81 loc) 2.69 kB
var m = Object.defineProperty; var p = (s, e, t) => e in s ? m(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t; var o = (s, e, t) => p(s, typeof e != "symbol" ? e + "" : e, t); import { jsx as r } from "../../../external/preact/jsx-runtime/dist/jsxRuntime.module.js"; import c from "../../../core/Context/CoreProvider.js"; import l from "../BaseElement.js"; /* empty css */ import h from "classnames"; import { createRef as d } from "../../../external/preact/dist/preact.module.js"; import { ConfigProvider as u } from "../../../core/ConfigContext/context.js"; class N extends l { constructor(t) { super(t); o(this, "componentRef", null); o(this, "componentToRender", null); o(this, "elementRef"); o(this, "onContactSupport"); o(this, "customClassNames"); o(this, "compRef"); o(this, "setUIElementStatus"); this.setState = this.setState.bind(this), this.onContactSupport = t.onContactSupport, this.elementRef = this, this.compRef = d(); } get isValid() { return !!this.state.isValid; } /** * Get the element's displayable name */ get displayName() { return this.type; } /** * Get the element accessible name, used in the aria-label of the button that controls selected component */ get accessibleName() { return this.displayName; } /** * Return the type of an element */ get type() { var t; return (t = this.constructor) == null ? void 0 : t.type; } formatProps(t) { return t; } /** * Formats the component data output */ formatData() { return { ...this.state }; } setState(t) { this.state = { ...this.state, ...t }; } setStatus(t, i) { var n, a; return (n = this.componentRef) != null && n.setStatus ? this.componentRef.setStatus(t, i) : (a = this.setUIElementStatus) == null || a.call(this, t), this; } render() { const t = this.props.core, i = t.update.bind(t), n = this.props.onError || t.onError || null; return t.session.errorHandler = n, /* @__PURE__ */ r(u, { type: this.type, session: t.session, children: /* @__PURE__ */ r( c, { i18n: t.localization.i18n, loadingContext: t.loadingContext, updateCore: i, externalErrorHandler: n, componentRef: this.compRef, children: this.componentToRender && /* @__PURE__ */ r("div", { ref: this.compRef, className: h("adyen-pe-component", this.customClassNames), children: /* @__PURE__ */ r("div", { className: "adyen-pe-component__container", children: this.componentToRender() }) }) } ) }, performance.now()); } } export { N as UIElement, N as default };