@shafnas/react-password-validator 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ interface Props {
3
+ password: string;
4
+ confirmPassword?: string;
5
+ className?: string;
6
+ itemClassName?: string;
7
+ strengthBarClassName?: string;
8
+ }
9
+ export declare const PasswordValidator: React.FC<Props>;
10
+ export {};
@@ -0,0 +1,2 @@
1
+ import { type PasswordValidationResult } from "../utils/passwordRules";
2
+ export declare const usePasswordValidation: (password: string) => PasswordValidationResult;
@@ -0,0 +1,3 @@
1
+ export { PasswordValidator } from "./components/PasswordValidator";
2
+ export { usePasswordValidation } from "./hooks/usePasswordValidation";
3
+ export { validatePassword } from "./utils/passwordRules";
@@ -0,0 +1,409 @@
1
+ import se, { useMemo as le, forwardRef as V, createElement as O } from "react";
2
+ var g = { exports: {} }, _ = {};
3
+ var D;
4
+ function ce() {
5
+ if (D) return _;
6
+ D = 1;
7
+ var r = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
8
+ function a(s, o, l) {
9
+ var d = null;
10
+ if (l !== void 0 && (d = "" + l), o.key !== void 0 && (d = "" + o.key), "key" in o) {
11
+ l = {};
12
+ for (var m in o)
13
+ m !== "key" && (l[m] = o[m]);
14
+ } else l = o;
15
+ return o = l.ref, {
16
+ $$typeof: r,
17
+ type: s,
18
+ key: d,
19
+ ref: o !== void 0 ? o : null,
20
+ props: l
21
+ };
22
+ }
23
+ return _.Fragment = t, _.jsx = a, _.jsxs = a, _;
24
+ }
25
+ var p = {};
26
+ var U;
27
+ function ue() {
28
+ return U || (U = 1, process.env.NODE_ENV !== "production" && (function() {
29
+ function r(e) {
30
+ if (e == null) return null;
31
+ if (typeof e == "function")
32
+ return e.$$typeof === ne ? null : e.displayName || e.name || null;
33
+ if (typeof e == "string") return e;
34
+ switch (e) {
35
+ case T:
36
+ return "Fragment";
37
+ case X:
38
+ return "Profiler";
39
+ case G:
40
+ return "StrictMode";
41
+ case K:
42
+ return "Suspense";
43
+ case ee:
44
+ return "SuspenseList";
45
+ case te:
46
+ return "Activity";
47
+ }
48
+ if (typeof e == "object")
49
+ switch (typeof e.tag == "number" && console.error(
50
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
51
+ ), e.$$typeof) {
52
+ case Z:
53
+ return "Portal";
54
+ case H:
55
+ return e.displayName || "Context";
56
+ case B:
57
+ return (e._context.displayName || "Context") + ".Consumer";
58
+ case Q:
59
+ var n = e.render;
60
+ return e = e.displayName, e || (e = n.displayName || n.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
61
+ case re:
62
+ return n = e.displayName || null, n !== null ? n : r(e.type) || "Memo";
63
+ case y:
64
+ n = e._payload, e = e._init;
65
+ try {
66
+ return r(e(n));
67
+ } catch {
68
+ }
69
+ }
70
+ return null;
71
+ }
72
+ function t(e) {
73
+ return "" + e;
74
+ }
75
+ function a(e) {
76
+ try {
77
+ t(e);
78
+ var n = !1;
79
+ } catch {
80
+ n = !0;
81
+ }
82
+ if (n) {
83
+ n = console;
84
+ var c = n.error, u = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
85
+ return c.call(
86
+ n,
87
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
88
+ u
89
+ ), t(e);
90
+ }
91
+ }
92
+ function s(e) {
93
+ if (e === T) return "<>";
94
+ if (typeof e == "object" && e !== null && e.$$typeof === y)
95
+ return "<...>";
96
+ try {
97
+ var n = r(e);
98
+ return n ? "<" + n + ">" : "<...>";
99
+ } catch {
100
+ return "<...>";
101
+ }
102
+ }
103
+ function o() {
104
+ var e = j.A;
105
+ return e === null ? null : e.getOwner();
106
+ }
107
+ function l() {
108
+ return Error("react-stack-top-frame");
109
+ }
110
+ function d(e) {
111
+ if ($.call(e, "key")) {
112
+ var n = Object.getOwnPropertyDescriptor(e, "key").get;
113
+ if (n && n.isReactWarning) return !1;
114
+ }
115
+ return e.key !== void 0;
116
+ }
117
+ function m(e, n) {
118
+ function c() {
119
+ Y || (Y = !0, console.error(
120
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
121
+ n
122
+ ));
123
+ }
124
+ c.isReactWarning = !0, Object.defineProperty(e, "key", {
125
+ get: c,
126
+ configurable: !0
127
+ });
128
+ }
129
+ function k() {
130
+ var e = r(this.type);
131
+ return I[e] || (I[e] = !0, console.error(
132
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
133
+ )), e = this.props.ref, e !== void 0 ? e : null;
134
+ }
135
+ function x(e, n, c, u, R, A) {
136
+ var i = c.ref;
137
+ return e = {
138
+ $$typeof: C,
139
+ type: e,
140
+ key: n,
141
+ props: c,
142
+ _owner: u
143
+ }, (i !== void 0 ? i : null) !== null ? Object.defineProperty(e, "ref", {
144
+ enumerable: !1,
145
+ get: k
146
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
147
+ configurable: !1,
148
+ enumerable: !1,
149
+ writable: !0,
150
+ value: 0
151
+ }), Object.defineProperty(e, "_debugInfo", {
152
+ configurable: !1,
153
+ enumerable: !1,
154
+ writable: !0,
155
+ value: null
156
+ }), Object.defineProperty(e, "_debugStack", {
157
+ configurable: !1,
158
+ enumerable: !1,
159
+ writable: !0,
160
+ value: R
161
+ }), Object.defineProperty(e, "_debugTask", {
162
+ configurable: !1,
163
+ enumerable: !1,
164
+ writable: !0,
165
+ value: A
166
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
167
+ }
168
+ function E(e, n, c, u, R, A) {
169
+ var i = n.children;
170
+ if (i !== void 0)
171
+ if (u)
172
+ if (ae(i)) {
173
+ for (u = 0; u < i.length; u++)
174
+ P(i[u]);
175
+ Object.freeze && Object.freeze(i);
176
+ } else
177
+ console.error(
178
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
179
+ );
180
+ else P(i);
181
+ if ($.call(n, "key")) {
182
+ i = r(e);
183
+ var b = Object.keys(n).filter(function(oe) {
184
+ return oe !== "key";
185
+ });
186
+ u = 0 < b.length ? "{key: someKey, " + b.join(": ..., ") + ": ...}" : "{key: someKey}", M[i + u] || (b = 0 < b.length ? "{" + b.join(": ..., ") + ": ...}" : "{}", console.error(
187
+ `A props object containing a "key" prop is being spread into JSX:
188
+ let props = %s;
189
+ <%s {...props} />
190
+ React keys must be passed directly to JSX without using spread:
191
+ let props = %s;
192
+ <%s key={someKey} {...props} />`,
193
+ u,
194
+ i,
195
+ b,
196
+ i
197
+ ), M[i + u] = !0);
198
+ }
199
+ if (i = null, c !== void 0 && (a(c), i = "" + c), d(n) && (a(n.key), i = "" + n.key), "key" in n) {
200
+ c = {};
201
+ for (var N in n)
202
+ N !== "key" && (c[N] = n[N]);
203
+ } else c = n;
204
+ return i && m(
205
+ c,
206
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
207
+ ), x(
208
+ e,
209
+ i,
210
+ c,
211
+ o(),
212
+ R,
213
+ A
214
+ );
215
+ }
216
+ function P(e) {
217
+ S(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === y && (e._payload.status === "fulfilled" ? S(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
218
+ }
219
+ function S(e) {
220
+ return typeof e == "object" && e !== null && e.$$typeof === C;
221
+ }
222
+ var h = se, C = /* @__PURE__ */ Symbol.for("react.transitional.element"), Z = /* @__PURE__ */ Symbol.for("react.portal"), T = /* @__PURE__ */ Symbol.for("react.fragment"), G = /* @__PURE__ */ Symbol.for("react.strict_mode"), X = /* @__PURE__ */ Symbol.for("react.profiler"), B = /* @__PURE__ */ Symbol.for("react.consumer"), H = /* @__PURE__ */ Symbol.for("react.context"), Q = /* @__PURE__ */ Symbol.for("react.forward_ref"), K = /* @__PURE__ */ Symbol.for("react.suspense"), ee = /* @__PURE__ */ Symbol.for("react.suspense_list"), re = /* @__PURE__ */ Symbol.for("react.memo"), y = /* @__PURE__ */ Symbol.for("react.lazy"), te = /* @__PURE__ */ Symbol.for("react.activity"), ne = /* @__PURE__ */ Symbol.for("react.client.reference"), j = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, $ = Object.prototype.hasOwnProperty, ae = Array.isArray, w = console.createTask ? console.createTask : function() {
223
+ return null;
224
+ };
225
+ h = {
226
+ react_stack_bottom_frame: function(e) {
227
+ return e();
228
+ }
229
+ };
230
+ var Y, I = {}, L = h.react_stack_bottom_frame.bind(
231
+ h,
232
+ l
233
+ )(), F = w(s(l)), M = {};
234
+ p.Fragment = T, p.jsx = function(e, n, c) {
235
+ var u = 1e4 > j.recentlyCreatedOwnerStacks++;
236
+ return E(
237
+ e,
238
+ n,
239
+ c,
240
+ !1,
241
+ u ? Error("react-stack-top-frame") : L,
242
+ u ? w(s(e)) : F
243
+ );
244
+ }, p.jsxs = function(e, n, c) {
245
+ var u = 1e4 > j.recentlyCreatedOwnerStacks++;
246
+ return E(
247
+ e,
248
+ n,
249
+ c,
250
+ !0,
251
+ u ? Error("react-stack-top-frame") : L,
252
+ u ? w(s(e)) : F
253
+ );
254
+ };
255
+ })()), p;
256
+ }
257
+ var W;
258
+ function ie() {
259
+ return W || (W = 1, process.env.NODE_ENV === "production" ? g.exports = ce() : g.exports = ue()), g.exports;
260
+ }
261
+ var f = ie();
262
+ const fe = (r) => {
263
+ const t = r.length >= 8 && r.length <= 14, a = /[a-z]/.test(r), s = /[A-Z]/.test(r), o = /[0-9]/.test(r), l = /[^A-Za-z0-9]/.test(r);
264
+ return { length: t, lowercase: a, uppercase: s, number: o, symbol: l, valid: t && a && s && o && l };
265
+ }, de = (r) => le(() => fe(r), [r]);
266
+ const q = (...r) => r.filter((t, a, s) => !!t && t.trim() !== "" && s.indexOf(t) === a).join(" ").trim();
267
+ const me = (r) => r.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
268
+ const be = (r) => r.replace(
269
+ /^([A-Z])|[\s-_]+(\w)/g,
270
+ (t, a, s) => s ? s.toUpperCase() : a.toLowerCase()
271
+ );
272
+ const z = (r) => {
273
+ const t = be(r);
274
+ return t.charAt(0).toUpperCase() + t.slice(1);
275
+ };
276
+ var _e = {
277
+ xmlns: "http://www.w3.org/2000/svg",
278
+ width: 24,
279
+ height: 24,
280
+ viewBox: "0 0 24 24",
281
+ fill: "none",
282
+ stroke: "currentColor",
283
+ strokeWidth: 2,
284
+ strokeLinecap: "round",
285
+ strokeLinejoin: "round"
286
+ };
287
+ const pe = (r) => {
288
+ for (const t in r)
289
+ if (t.startsWith("aria-") || t === "role" || t === "title")
290
+ return !0;
291
+ return !1;
292
+ };
293
+ const ve = V(
294
+ ({
295
+ color: r = "currentColor",
296
+ size: t = 24,
297
+ strokeWidth: a = 2,
298
+ absoluteStrokeWidth: s,
299
+ className: o = "",
300
+ children: l,
301
+ iconNode: d,
302
+ ...m
303
+ }, k) => O(
304
+ "svg",
305
+ {
306
+ ref: k,
307
+ ..._e,
308
+ width: t,
309
+ height: t,
310
+ stroke: r,
311
+ strokeWidth: s ? Number(a) * 24 / Number(t) : a,
312
+ className: q("lucide", o),
313
+ ...!l && !pe(m) && { "aria-hidden": "true" },
314
+ ...m
315
+ },
316
+ [
317
+ ...d.map(([x, E]) => O(x, E)),
318
+ ...Array.isArray(l) ? l : [l]
319
+ ]
320
+ )
321
+ );
322
+ const J = (r, t) => {
323
+ const a = V(
324
+ ({ className: s, ...o }, l) => O(ve, {
325
+ ref: l,
326
+ iconNode: t,
327
+ className: q(
328
+ `lucide-${me(z(r))}`,
329
+ `lucide-${r}`,
330
+ s
331
+ ),
332
+ ...o
333
+ })
334
+ );
335
+ return a.displayName = z(r), a;
336
+ };
337
+ const Ee = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], he = J("check", Ee);
338
+ const Re = [
339
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
340
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
341
+ ], ge = J("x", Re), ke = (r) => {
342
+ let t = 0;
343
+ return r.length >= 2 && (t += 1), /[a-z]/.test(r) && (t += 1), /[A-Z]/.test(r) && (t += 1), /[0-9]/.test(r) && (t += 1), /[^A-Za-z0-9]/.test(r) && (t += 1), t <= 2 ? "weak" : t === 3 || t === 4 ? "medium" : "strong";
344
+ }, v = ({
345
+ ok: r,
346
+ label: t,
347
+ className: a = ""
348
+ }) => /* @__PURE__ */ f.jsxs("div", { className: `flex items-center gap-2 text-sm ${a}`, children: [
349
+ r ? /* @__PURE__ */ f.jsx(he, { className: "w-4 h-4 text-green-600" }) : /* @__PURE__ */ f.jsx(ge, { className: "w-4 h-4 text-red-500" }),
350
+ /* @__PURE__ */ f.jsx("span", { className: r ? "text-green-600" : "text-gray-500", children: t })
351
+ ] }), xe = ({
352
+ strength: r,
353
+ className: t = ""
354
+ }) => {
355
+ let a = "bg-red-500", s = "w-1/4";
356
+ return r === "medium" ? (a = "bg-yellow-400", s = "w-2/3") : r === "strong" && (a = "bg-green-600", s = "w-full"), /* @__PURE__ */ f.jsx("div", { className: `h-2 bg-gray-200 rounded-full mt-2 ${t}`, children: /* @__PURE__ */ f.jsx(
357
+ "div",
358
+ {
359
+ className: `${s} ${a} h-2 rounded-full transition-all`
360
+ }
361
+ ) });
362
+ }, ye = ({
363
+ password: r,
364
+ className: t = "",
365
+ itemClassName: a = "",
366
+ strengthBarClassName: s = ""
367
+ }) => {
368
+ const o = de(r), l = ke(r);
369
+ return /* @__PURE__ */ f.jsxs("div", { className: `rounded-lg border p-4 shadow space-y-3 ${t}`, children: [
370
+ /* @__PURE__ */ f.jsxs("div", { className: "space-y-1", children: [
371
+ /* @__PURE__ */ f.jsx(
372
+ v,
373
+ {
374
+ ok: o.length,
375
+ label: "8–14 characters",
376
+ className: a
377
+ }
378
+ ),
379
+ /* @__PURE__ */ f.jsx(
380
+ v,
381
+ {
382
+ ok: o.lowercase,
383
+ label: "Lowercase letter",
384
+ className: a
385
+ }
386
+ ),
387
+ /* @__PURE__ */ f.jsx(
388
+ v,
389
+ {
390
+ ok: o.uppercase,
391
+ label: "Uppercase letter",
392
+ className: a
393
+ }
394
+ ),
395
+ /* @__PURE__ */ f.jsx(v, { ok: o.number, label: "Number", className: a }),
396
+ /* @__PURE__ */ f.jsx(v, { ok: o.symbol, label: "Symbol", className: a })
397
+ ] }),
398
+ /* @__PURE__ */ f.jsx(xe, { strength: l, className: s }),
399
+ /* @__PURE__ */ f.jsxs("div", { className: "text-sm font-medium capitalize text-gray-700", children: [
400
+ "Strength: ",
401
+ l
402
+ ] })
403
+ ] });
404
+ };
405
+ export {
406
+ ye as PasswordValidator,
407
+ de as usePasswordValidation,
408
+ fe as validatePassword
409
+ };
@@ -0,0 +1,6 @@
1
+ (function(m,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],d):(m=typeof globalThis<"u"?globalThis:m||self,d(m.ReactPasswordValidator={},m.React))})(this,(function(m,d){"use strict";var R={exports:{}},v={};var O;function B(){if(O)return v;O=1;var r=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function a(s,o,l){var b=null;if(l!==void 0&&(b=""+l),o.key!==void 0&&(b=""+o.key),"key"in o){l={};for(var _ in o)_!=="key"&&(l[_]=o[_])}else l=o;return o=l.ref,{$$typeof:r,type:s,key:b,ref:o!==void 0?o:null,props:l}}return v.Fragment=t,v.jsx=a,v.jsxs=a,v}var E={};var C;function q(){return C||(C=1,process.env.NODE_ENV!=="production"&&(function(){function r(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Ee?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case y:return"Fragment";case ie:return"Profiler";case ue:return"StrictMode";case be:return"Suspense";case _e:return"SuspenseList";case ve:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case ce:return"Portal";case de:return e.displayName||"Context";case fe:return(e._context.displayName||"Context")+".Consumer";case me:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case pe:return n=e.displayName||null,n!==null?n:r(e.type)||"Memo";case j:n=e._payload,e=e._init;try{return r(e(n))}catch{}}return null}function t(e){return""+e}function a(e){try{t(e);var n=!1}catch{n=!0}if(n){n=console;var c=n.error,u=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",u),t(e)}}function s(e){if(e===y)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===j)return"<...>";try{var n=r(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function o(){var e=A.A;return e===null?null:e.getOwner()}function l(){return Error("react-stack-top-frame")}function b(e){if(W.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function _(e,n){function c(){z||(z=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",n))}c.isReactWarning=!0,Object.defineProperty(e,"key",{get:c,configurable:!0})}function T(){var e=r(this.type);return J[e]||(J[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function w(e,n,c,u,x,N){var i=c.ref;return e={$$typeof:V,type:e,key:n,props:c,_owner:u},(i!==void 0?i:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:T}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:x}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:N}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function g(e,n,c,u,x,N){var i=n.children;if(i!==void 0)if(u)if(he(i)){for(u=0;u<i.length;u++)D(i[u]);Object.freeze&&Object.freeze(i)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else D(i);if(W.call(n,"key")){i=r(e);var p=Object.keys(n).filter(function(Re){return Re!=="key"});u=0<p.length?"{key: someKey, "+p.join(": ..., ")+": ...}":"{key: someKey}",X[i+u]||(p=0<p.length?"{"+p.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
+ let props = %s;
3
+ <%s {...props} />
4
+ React keys must be passed directly to JSX without using spread:
5
+ let props = %s;
6
+ <%s key={someKey} {...props} />`,u,i,p,i),X[i+u]=!0)}if(i=null,c!==void 0&&(a(c),i=""+c),b(n)&&(a(n.key),i=""+n.key),"key"in n){c={};for(var S in n)S!=="key"&&(c[S]=n[S])}else c=n;return i&&_(c,typeof e=="function"?e.displayName||e.name||"Unknown":e),w(e,i,c,o(),x,N)}function D(e){U(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===j&&(e._payload.status==="fulfilled"?U(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function U(e){return typeof e=="object"&&e!==null&&e.$$typeof===V}var k=d,V=Symbol.for("react.transitional.element"),ce=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),ue=Symbol.for("react.strict_mode"),ie=Symbol.for("react.profiler"),fe=Symbol.for("react.consumer"),de=Symbol.for("react.context"),me=Symbol.for("react.forward_ref"),be=Symbol.for("react.suspense"),_e=Symbol.for("react.suspense_list"),pe=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),ve=Symbol.for("react.activity"),Ee=Symbol.for("react.client.reference"),A=k.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=Object.prototype.hasOwnProperty,he=Array.isArray,P=console.createTask?console.createTask:function(){return null};k={react_stack_bottom_frame:function(e){return e()}};var z,J={},Z=k.react_stack_bottom_frame.bind(k,l)(),G=P(s(l)),X={};E.Fragment=y,E.jsx=function(e,n,c){var u=1e4>A.recentlyCreatedOwnerStacks++;return g(e,n,c,!1,u?Error("react-stack-top-frame"):Z,u?P(s(e)):G)},E.jsxs=function(e,n,c){var u=1e4>A.recentlyCreatedOwnerStacks++;return g(e,n,c,!0,u?Error("react-stack-top-frame"):Z,u?P(s(e)):G)}})()),E}var Y;function H(){return Y||(Y=1,process.env.NODE_ENV==="production"?R.exports=B():R.exports=q()),R.exports}var f=H();const I=r=>{const t=r.length>=8&&r.length<=14,a=/[a-z]/.test(r),s=/[A-Z]/.test(r),o=/[0-9]/.test(r),l=/[^A-Za-z0-9]/.test(r);return{length:t,lowercase:a,uppercase:s,number:o,symbol:l,valid:t&&a&&s&&o&&l}},L=r=>d.useMemo(()=>I(r),[r]);const M=(...r)=>r.filter((t,a,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===a).join(" ").trim();const Q=r=>r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const K=r=>r.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,s)=>s?s.toUpperCase():a.toLowerCase());const F=r=>{const t=K(r);return t.charAt(0).toUpperCase()+t.slice(1)};var ee={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const re=r=>{for(const t in r)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const te=d.forwardRef(({color:r="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:s,className:o="",children:l,iconNode:b,..._},T)=>d.createElement("svg",{ref:T,...ee,width:t,height:t,stroke:r,strokeWidth:s?Number(a)*24/Number(t):a,className:M("lucide",o),...!l&&!re(_)&&{"aria-hidden":"true"},..._},[...b.map(([w,g])=>d.createElement(w,g)),...Array.isArray(l)?l:[l]]));const $=(r,t)=>{const a=d.forwardRef(({className:s,...o},l)=>d.createElement(te,{ref:l,iconNode:t,className:M(`lucide-${Q(F(r))}`,`lucide-${r}`,s),...o}));return a.displayName=F(r),a};const ne=$("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const ae=$("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),oe=r=>{let t=0;return r.length>=2&&(t+=1),/[a-z]/.test(r)&&(t+=1),/[A-Z]/.test(r)&&(t+=1),/[0-9]/.test(r)&&(t+=1),/[^A-Za-z0-9]/.test(r)&&(t+=1),t<=2?"weak":t===3||t===4?"medium":"strong"},h=({ok:r,label:t,className:a=""})=>f.jsxs("div",{className:`flex items-center gap-2 text-sm ${a}`,children:[r?f.jsx(ne,{className:"w-4 h-4 text-green-600"}):f.jsx(ae,{className:"w-4 h-4 text-red-500"}),f.jsx("span",{className:r?"text-green-600":"text-gray-500",children:t})]}),se=({strength:r,className:t=""})=>{let a="bg-red-500",s="w-1/4";return r==="medium"?(a="bg-yellow-400",s="w-2/3"):r==="strong"&&(a="bg-green-600",s="w-full"),f.jsx("div",{className:`h-2 bg-gray-200 rounded-full mt-2 ${t}`,children:f.jsx("div",{className:`${s} ${a} h-2 rounded-full transition-all`})})},le=({password:r,className:t="",itemClassName:a="",strengthBarClassName:s=""})=>{const o=L(r),l=oe(r);return f.jsxs("div",{className:`rounded-lg border p-4 shadow space-y-3 ${t}`,children:[f.jsxs("div",{className:"space-y-1",children:[f.jsx(h,{ok:o.length,label:"8–14 characters",className:a}),f.jsx(h,{ok:o.lowercase,label:"Lowercase letter",className:a}),f.jsx(h,{ok:o.uppercase,label:"Uppercase letter",className:a}),f.jsx(h,{ok:o.number,label:"Number",className:a}),f.jsx(h,{ok:o.symbol,label:"Symbol",className:a})]}),f.jsx(se,{strength:l,className:s}),f.jsxs("div",{className:"text-sm font-medium capitalize text-gray-700",children:["Strength: ",l]})]})};m.PasswordValidator=le,m.usePasswordValidation=L,m.validatePassword=I,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,9 @@
1
+ export interface PasswordValidationResult {
2
+ length: boolean;
3
+ lowercase: boolean;
4
+ uppercase: boolean;
5
+ number: boolean;
6
+ symbol: boolean;
7
+ valid: boolean;
8
+ }
9
+ export declare const validatePassword: (password: string) => PasswordValidationResult;
@@ -0,0 +1,2 @@
1
+ export type PasswordStrength = "weak" | "medium" | "strong";
2
+ export declare const calculateStrength: (password: string) => PasswordStrength;
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shafnas/react-password-validator",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "A reusable React password validator component with Tailwind and Lucide icons",
5
5
  "author": "Your Name",
6
6
  "license": "MIT",