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)

74 lines (73 loc) 2.28 kB
import { jsx as c } from "../../../external/preact/jsx-runtime/dist/jsxRuntime.module.js"; import { ARIA_ERROR_SUFFIX as u } from "../../../core/Errors/constants.js"; import k from "classnames"; import { forwardRef as q } from "../../../external/preact/compat/dist/compat.module.js"; import { useCallback as r } from "../../../external/preact/hooks/dist/hooks.module.js"; /* empty css */ import { Fragment as w } from "../../../external/preact/dist/preact.module.js"; import { hasOwnProperty as P } from "../../../utils/struct/property.js"; function h({ onInput: i, onKeyUp: d, trimOnBlur: l, onBlurHandler: e, onBlur: t, onFocusHandler: s, errorMessage: f, ...p }, v) { const { autoCorrect: A, classNameModifiers: m, isInvalid: n, isValid: C, readonly: I = !1, spellCheck: O, type: y, uniqueId: o, isCollatingErrors: $, disabled: g } = p; P(p, "onChange") && console.error("Error: Form fields that rely on InputBase may not have an onChange property"); const N = r( (a) => { i == null || i(a); }, [i] ), R = r( (a) => { d && d(a); }, [d] ), b = r( (a) => { e == null || e(a), l && (a.target.value = a.target.value.trim()), t == null || t(a); }, [t, e, l] ), x = r( (a) => { s == null || s(a); }, [s] ), E = k( "adyen-pe-input", [`adyen-pe-input--${y}`], p.className, { "adyen-pe-input--invalid": n, "adyen-pe-input--valid": C }, m == null ? void 0 : m.map((a) => `adyen-pe-input--${a}`) ), { classNameModifiers: V, uniqueId: j, isInvalid: D, isValid: F, isCollatingErrors: S, ..._ } = p; return /* @__PURE__ */ c(w, { children: [ /* @__PURE__ */ c( "input", { id: o, ..._, type: y, className: E, readOnly: I, "aria-describedby": $ ? void 0 : `${o}${u}`, "aria-invalid": n, onInput: N, onBlurCapture: b, onFocus: x, onKeyUp: R, disabled: g, ref: v } ), n && f && /* @__PURE__ */ c("span", { className: "adyen-pe-input__invalid-value", id: `${o}${u}`, children: f }) ] }); } h.defaultProps = { type: "text", classNameModifiers: [], onInput: () => { } }; const Q = q(h); export { Q as default };