Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@code-forge/react-input-mask

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@code-forge/react-input-mask - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

60

dist/index.js

@@ -1,5 +0,5 @@

import { useRef as L, useLayoutEffect as O, useState as M } from "react";
const x = () => {
import { useRef as L, useLayoutEffect as O, useEffect as w, useState as M } from "react";
const U = typeof window < "u", x = U ? O : w, G = () => {
const t = L();
return O(() => {
return x(() => {
t.current && (t.current(), t.current = void 0);

@@ -9,28 +9,28 @@ }), (n) => {

};
}, g = (t, e = y) => e.test(t), d = (t, e = P) => e.test(t), G = (t) => t === "*", U = (t, e) => {
let n = t, r = 0;
return t.split("").forEach((s) => {
e[r] && (s === "*" && (n = n.replace(s, e[r]), r += 1), s === "A" && g(e[r]) && (n = n.replace(s, e[r]), r += 1), s === "9" && d(e[r]) && (n = n.replace(s, e[r]), r += 1));
}, g = (t, e = R) => e.test(t), d = (t, e = D) => e.test(t), _ = (t) => t === "*", $ = (t, e) => {
let n = t, s = 0;
return t.split("").forEach((r) => {
e[s] && (r === "*" && (n = n.replace(r, e[s]), s += 1), r === "A" && g(e[s]) && (n = n.replace(r, e[s]), s += 1), r === "9" && d(e[s]) && (n = n.replace(r, e[s]), s += 1));
}), n;
}, R = (t, e, n = 0) => t.slice(0, n) + t.slice(n, t.length).replaceAll("*", e).replaceAll("A", e).replaceAll("9", e), _ = (t, e) => t.substring(0, e).split("").filter((n) => n !== "*" && n !== "9" && n !== "A").length, $ = (t, e, n) => {
const r = U(e, t), s = _(e, t.length);
return R(r, n, t.length + s);
}, j = ({ filteredMask: t, value: e, rawValue: n, currentMaskChar: r, charRegex: s, numRegex: l }) => e.length > 1 || t.length === n.length ? !1 : !!(g(e, s) && g(r, s) || d(e, l) && d(r, l) || G(r)), k = (t, e) => {
}, y = (t, e, n = 0) => t.slice(0, n) + t.slice(n, t.length).replaceAll("*", e).replaceAll("A", e).replaceAll("9", e), j = (t, e) => t.substring(0, e).split("").filter((n) => n !== "*" && n !== "9" && n !== "A").length, k = (t, e, n) => {
const s = $(e, t), r = j(e, t.length);
return y(s, n, t.length + r);
}, K = ({ filteredMask: t, value: e, rawValue: n, currentMaskChar: s, charRegex: r, numRegex: l }) => e.length > 1 || t.length === n.length ? !1 : !!(g(e, r) && g(s, r) || d(e, l) && d(s, l) || _(s)), S = (t, e) => {
const n = Object.getOwnPropertyDescriptor(t, "value");
t.value = `${e}#`, n && n.configurable && delete t.value, t.value = e;
const r = document.createEvent("HTMLEvents");
r.initEvent("change", !0, !1), t.dispatchEvent(r), n && Object.defineProperty(t, "value", n);
}, y = /^[a-zA-Z]*$/, P = /^[0-9]*$/;
function X({ mask: t, placeholderChar: e = "_", type: n = "raw", charRegex: r = y, numRegex: s = P }) {
const l = /[^A9*]+/g, v = t == null ? void 0 : t.replace(l, ""), T = x(), [c, D] = M(""), [E, I] = M(R(t ?? "", e));
const s = document.createEvent("HTMLEvents");
s.initEvent("change", !0, !1), t.dispatchEvent(s), n && Object.defineProperty(t, "value", n);
}, R = /^[a-zA-Z]*$/, D = /^[0-9]*$/;
function F({ mask: t, placeholderChar: e = "_", type: n = "raw", charRegex: s = R, numRegex: r = D }) {
const l = /[^A9*]+/g, E = t == null ? void 0 : t.replace(l, ""), I = G(), [c, P] = M(""), [v, T] = M(y(t ?? "", e));
if (!t)
return {};
if (typeof document > "u")
return { value: E };
return { value: v };
const A = (o, u, f) => {
D(o);
const i = $(o, t, e);
I(i);
P(o);
const i = k(o, t, e);
T(i);
const a = n === "raw" ? o : i;
k(f.target, a), T(() => {
S(f.target, a), I(() => {
const p = i.indexOf(e);

@@ -41,5 +41,5 @@ u.setSelectionRange(p, p);

return { ...{
value: E,
value: v,
onKeyDown: (o) => {
const u = o.key, f = o.target, i = c.length, a = v[i];
const u = o.key, f = o.target, i = c.length, a = E[i];
if (u === "Tab" || u === "Enter")

@@ -51,8 +51,8 @@ return;

}
if (!j({
if (!K({
value: u,
currentMaskChar: a,
charRegex: r,
numRegex: s,
filteredMask: v,
charRegex: s,
numRegex: r,
filteredMask: E,
rawValue: c

@@ -67,5 +67,5 @@ }))

export {
P as DIGIT_REGEX,
y as LETTER_REGEX,
X as useInputMask
D as DIGIT_REGEX,
R as LETTER_REGEX,
F as useInputMask
};

@@ -17,3 +17,3 @@ {

"private": false,
"version": "1.0.1",
"version": "1.0.2",
"type": "module",

@@ -20,0 +20,0 @@ "main": "./dist/index.umd.cjs",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc