@adyen/adyen-platform-experience-web
Version:

21 lines (20 loc) • 517 B
JavaScript
import { InteractionKeyCode as t } from "../../types.js";
const u = [
t.BACKSPACE,
t.DELETE,
t.ARROW_LEFT,
t.ARROW_RIGHT,
t.ARROW_UP,
t.ARROW_DOWN,
t.TAB
], R = ({ event: s, inputType: c, onValidInput: o }) => {
const i = s.currentTarget, { key: e } = s, n = /^[0-9.,-]$/.test(e), l = /[.,]/.test(i.value), a = e === "." || e === ",", r = u.includes(e);
if (c === "number" && !r && (!n || l && a)) {
s.preventDefault();
return;
}
o?.(s);
};
export {
R as filterDisallowedCharacters
};