veza/apps/web/dist_verification/assets/PasswordStrengthIndicator-foHQcebK.js
2026-02-07 20:36:48 +01:00

1 line
1.6 KiB
JavaScript

import{j as s}from"./vendor-react-YMhRUmcb.js";function f({password:a}){const u=e=>{const l=[];let t=0;e.length>=12?t++:l.push(`Au moins 12 caractères (${e.length}/12)`),/[a-z]/.test(e)&&/[A-Z]/.test(e)?t++:(/[a-z]/.test(e)||l.push("Une minuscule"),/[A-Z]/.test(e)||l.push("Une majuscule")),/\d/.test(e)?t++:l.push("Un chiffre"),/[^a-zA-Z\d]/.test(e)?t++:l.push("Un caractère spécial (!@#$%^&*...)");let r,i;return t<=1?(r="Très faible",i="bg-destructive"):t===2?(r="Faible",i="bg-kodo-gold"):t===3?(r="Moyen",i="bg-kodo-gold"):t===4?(r="Fort",i="bg-success"):(r="Très fort",i="bg-success"),{level:t,label:r,color:i,requirements:l}};if(!a)return null;const{level:n,label:o,color:d,requirements:c}=u(a),m=n/4*100;return s.jsxs("div",{className:"mt-2 space-y-2",role:"status","aria-live":"polite","aria-atomic":"true",children:[s.jsxs("div",{children:[s.jsx("div",{className:"w-full bg-kodo-slate rounded-full h-2",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":4,"aria-label":`Force du mot de passe: ${o}`,children:s.jsx("div",{className:`${d} h-2 rounded-full transition-all`,style:{width:`${m}%`},"aria-hidden":"true"})}),s.jsxs("p",{className:"text-xs text-muted-foreground mt-1",id:"password-strength-label",children:["Force: ",s.jsx("span",{"aria-live":"polite",children:o})]})]}),c.length>0&&s.jsxs("div",{className:"text-xs text-muted-foreground",children:[s.jsx("p",{className:"font-medium mb-1",children:"Requis :"}),s.jsx("ul",{className:"list-disc list-inside space-y-0.5",children:c.map((e,l)=>s.jsx("li",{className:"text-destructive",children:e},l))})]})]})}export{f as P};