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)

85 lines (84 loc) 2.93 kB
import { jsx as e } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js"; import r from "classnames"; import { createRef as i } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/dist/preact.module.js"; import a from "../BaseElement.js"; /* empty css */ import { FALLBACK_ENV as m } from "../../../core/utils.js"; import c from "../../../core/Context/preact/CoreProvider.js"; import { AnalyticsProvider as p } from "../../../core/Context/analytics/preact/AnalyticsProvider.js"; import { ConfigProvider as l } from "../../../core/ConfigContext/preact/context.js"; class N extends a { componentRef = null; componentToRender = null; compRef; customClassNames; elementRef; onContactSupport; constructor(t) { super(t), this.setState = this.setState.bind(this), this.onContactSupport = t.onContactSupport, this.elementRef = this, this.compRef = i(); } 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() { return this.constructor?.type; } formatProps(t) { return t; } /** * Formats the component data output */ formatData() { return { ...this.state }; } setState(t) { this.state = { ...this.state, ...t }; } setUIElementStatus; setStatus(t, n) { return this.componentRef?.setStatus ? this.componentRef.setStatus(t, n) : this.setUIElementStatus?.(t), this; } render() { const t = this.props.core, n = this.props.onError || t.onError || null, o = t.update.bind(t); t.session.errorHandler = n; const s = () => this.compRef.current; return /* @__PURE__ */ e(l, { type: this.type, session: t.session, children: /* @__PURE__ */ e( c, { componentRef: s, environment: t.options.environment || m, i18n: t.localization.i18n, getCdnConfig: t.getCdnConfig, getImageAsset: t.getImageAsset, getDatasetAsset: t.getDatasetAsset, getCdnDataset: t.getCdnDataset, loadingContext: t.loadingContext, externalErrorHandler: n, updateCore: o, children: /* @__PURE__ */ e(p, { componentName: this.displayName, analyticsEnabled: t?.analyticsEnabled ?? !0, children: this.componentToRender && /* @__PURE__ */ e("section", { ref: this.compRef, className: r("adyen-pe-component", this.customClassNames), "data-testid": "component-root", children: /* @__PURE__ */ e("div", { className: "adyen-pe-component__container", children: this.componentToRender() }) }) }) } ) }, performance.now()); } } export { N as UIElement, N as default };