UNPKG

vue-password-strength-meter

Version:
1 lines 11.5 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("zxcvbn")):"function"==typeof define&&define.amd?define("Password",["zxcvbn"],t):"object"==typeof exports?exports.Password=t(require("zxcvbn")):e.Password=t(e.zxcvbn)}(this,function(e){return function(e){function t(r){if(s[r])return s[r].exports;var n=s[r]={exports:{},id:r,loaded:!1};return e[r].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var s={};return t.m=e,t.c=s,t.p="",t(0)}([function(e,t,s){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var n=s(4),o=r(n);e.exports=o.default},function(e,t,s){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var n=s(10),o=r(n);t.default={name:"VuePasswordStrengthMeter",inheritAttrs:!1,props:{value:{type:String},secureLength:{type:Number,default:7},badge:{type:Boolean,default:!0},toggle:{type:Boolean,default:!1},showPassword:{type:Boolean,default:!1},referenceValue:{type:String,default:"input"},showStrengthMeter:{type:Boolean,default:!0},strengthMeterOnly:{type:Boolean,default:!1},defaultClass:{type:String,default:"Password__field"},disabledClass:{type:String,default:"Password__field--disabled"},errorClass:{type:String,default:"Password__badge--error"},successClass:{type:String,default:"Password__badge--success"},strengthMeterClass:{type:String,default:"Password__strength-meter"},strengthMeterFillClass:{type:String,default:"Password__strength-meter--fill"},labelShow:{type:String,default:"Show Password"},labelHide:{type:String,default:"Hide Password"},userInputs:{type:Array,default:function(){return[]}}},data:function(){return{password:null,_showPassword:!1}},methods:{togglePassword:function(){this.$data._showPassword?(this.$emit("hide"),this.$data._showPassword=!1):(this.$emit("show"),this.$data._showPassword=!0)},emitValue:function(e,t){this.$emit(e,t),this.password=t}},computed:{passwordStrength:function(){return this.password?(0,o.default)(this.password,this.userInputs.length>=1?this.userInputs:null).score:null},isSecure:function(){return this.password?this.password.length>=this.secureLength:null},isActive:function(){return this.password&&this.password.length>0},passwordCount:function(){return this.password&&(this.password.length>this.secureLength?this.secureLength+"+":this.password.length)},inputType:function(){return this.$data._showPassword||this.showPassword?"text":"password"},showPasswordLabel:function(){return this.$data._showPassword||this.showPassword?this.labelHide:this.labelShow}},watch:{value:function(e){this.strengthMeterOnly&&this.emitValue("input",e)},passwordStrength:function(e){this.$emit("score",e),this.$emit("feedback",(0,o.default)(this.password).feedback)}}}},function(e,t,s){t=e.exports=s(3)(!1),t.push([e.id,'[v-cloak]{display:none}.Password{max-width:400px;margin:0 auto}.Password__group{position:relative}.Password__strength-meter{position:relative;height:3px;background:#ddd;margin:10px auto 20px;border-radius:3px}.Password__strength-meter:after,.Password__strength-meter:before{content:"";height:inherit;background:transparent;display:block;border-color:#fff;border-style:solid;border-width:0 5px;position:absolute;width:20%;z-index:10}.Password__strength-meter:before{left:20%}.Password__strength-meter:after{right:20%}.Password__strength-meter--fill{background:transparent;height:inherit;position:absolute;width:0;border-radius:inherit;transition:width .5s ease-in-out,background .25s}.Password__strength-meter--fill[data-score="0"]{background:darkred;width:20%}.Password__strength-meter--fill[data-score="1"]{background:#ff4500;width:40%}.Password__strength-meter--fill[data-score="2"]{background:orange;width:60%}.Password__strength-meter--fill[data-score="3"]{background:#9acd32;width:80%}.Password__strength-meter--fill[data-score="4"]{background:green;width:100%}.Password__field{background-color:#f1f1f1;border:1px solid #f1f1f1;border-radius:2px;box-sizing:border-box;font-size:14px;padding:13px;width:100%}.Password__field--disabled{background-color:#f6f6f6;border:1px solid #f6f6f6}.Password__icons{position:absolute;top:0;right:0;height:100%;display:flex;flex-direction:row;justify-content:flex-end;align-items:center}.Password__badge,.Password__toggle{line-height:1.1;margin-right:13px}.Password__badge{position:relative;color:#fff;border-radius:6px;padding:3px;width:30px;height:15px;font-size:14px;display:flex;justify-content:center;align-items:center}.Password__badge--error{background:red}.Password__badge--success{background:#1bbf1b}.btn-clean{appearance:none;background:none;border:none;cursor:pointer;outline:none;color:#777;padding:0}.btn-clean svg{fill:currentColor}.btn-clean:focus,.btn-clean:hover{color:#404b69}',""])},function(e,t){function s(e,t){var s=e[1]||"",n=e[3];if(!n)return s;if(t&&"function"==typeof btoa){var o=r(n),a=n.sources.map(function(e){return"/*# sourceURL="+n.sourceRoot+e+" */"});return[s].concat(a).concat([o]).join("\n")}return[s].join("\n")}function r(e){var t=btoa(unescape(encodeURIComponent(JSON.stringify(e)))),s="sourceMappingURL=data:application/json;charset=utf-8;base64,"+t;return"/*# "+s+" */"}e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var r=s(t,e);return t[2]?"@media "+t[2]+"{"+r+"}":r}).join("")},t.i=function(e,s){"string"==typeof e&&(e=[[null,e,""]]);for(var r={},n=0;n<this.length;n++){var o=this[n][0];"number"==typeof o&&(r[o]=!0)}for(n=0;n<e.length;n++){var a=e[n];"number"==typeof a[0]&&r[a[0]]||(s&&!a[2]?a[2]=s:s&&(a[2]="("+a[2]+") and ("+s+")"),t.push(a))}},t}},function(e,t,s){function r(e){s(7)}var n=s(5)(s(1),s(6),r,null,null);e.exports=n.exports},function(e,t){e.exports=function(e,t,s,r,n){var o,a=e=e||{},i=typeof e.default;"object"!==i&&"function"!==i||(o=e,a=e.default);var d="function"==typeof a?a.options:a;t&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns),r&&(d._scopeId=r);var u;if(n?(u=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),s&&s.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(n)},d._ssrRegister=u):s&&(u=s),u){var l=d.functional,c=l?d.render:d.beforeCreate;l?d.render=function(e,t){return u.call(t),c(e,t)}:d.beforeCreate=c?[].concat(c,u):[u]}return{esModule:o,exports:a,options:d}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{staticClass:"Password"},[e.strengthMeterOnly?e._e():s("div",{staticClass:"Password__group"},[s("input",e._b({ref:e.referenceValue,class:[e.defaultClass,e.$attrs.disabled?e.disabledClass:""],attrs:{type:e.inputType},domProps:{value:e.value},on:{input:function(t){return e.emitValue("input",t.target.value)},blur:function(t){return e.emitValue("blur",t.target.value)},focus:function(t){return e.emitValue("focus",t.target.value)}}},"input",e.$attrs,!1)),e._v(" "),s("div",{staticClass:"Password__icons"},[e.badge?s("div",{staticClass:"Password__badge",class:[e.isSecure?e.successClass:"",!e.isSecure&&e.isActive?e.errorClass:""]},[e._v("\n "+e._s(e.passwordCount)+"\n ")]):e._e(),e._v(" "),e.toggle?s("div",{staticClass:"Password__toggle"},[s("button",{staticClass:"btn-clean",attrs:{type:"button","aria-label":e.showPasswordLabel,tabindex:"-1"},on:{click:function(t){return t.preventDefault(),e.togglePassword()}}},[this.$data._showPassword?s("svg",{attrs:{version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"}},[s("title",[e._v(e._s(e.showPasswordLabel))]),e._v(" "),s("path",{attrs:{d:"M12 9c1.641 0 3 1.359 3 3s-1.359 3-3 3-3-1.359-3-3 1.359-3 3-3zM12 17.016c2.766 0 5.016-2.25 5.016-5.016s-2.25-5.016-5.016-5.016-5.016 2.25-5.016 5.016 2.25 5.016 5.016 5.016zM12 4.5c5.016 0 9.281 3.094 11.016 7.5-1.734 4.406-6 7.5-11.016 7.5s-9.281-3.094-11.016-7.5c1.734-4.406 6-7.5 11.016-7.5z"}})]):s("svg",{attrs:{version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"}},[s("title",[e._v(e._s(e.showPasswordLabel))]),e._v(" "),s("path",{attrs:{d:"M11.859 9h0.141c1.641 0 3 1.359 3 3v0.188zM7.547 9.797c-0.328 0.656-0.563 1.406-0.563 2.203 0 2.766 2.25 5.016 5.016 5.016 0.797 0 1.547-0.234 2.203-0.563l-1.547-1.547c-0.188 0.047-0.422 0.094-0.656 0.094-1.641 0-3-1.359-3-3 0-0.234 0.047-0.469 0.094-0.656zM2.016 4.266l1.266-1.266 17.719 17.719-1.266 1.266c-1.124-1.11-2.256-2.213-3.375-3.328-1.359 0.563-2.813 0.844-4.359 0.844-5.016 0-9.281-3.094-11.016-7.5 0.797-1.969 2.109-3.656 3.75-4.969-0.914-0.914-1.812-1.844-2.719-2.766zM12 6.984c-0.656 0-1.266 0.141-1.828 0.375l-2.156-2.156c1.219-0.469 2.578-0.703 3.984-0.703 5.016 0 9.234 3.094 10.969 7.5-0.75 1.875-1.922 3.469-3.422 4.734l-2.906-2.906c0.234-0.563 0.375-1.172 0.375-1.828 0-2.766-2.25-5.016-5.016-5.016z"}})])])]):e._e()])]),e._v(" "),e.showStrengthMeter?s("div",{class:[e.strengthMeterClass]},[s("div",{class:[e.strengthMeterFillClass],attrs:{"data-score":e.passwordStrength}})]):e._e()])},staticRenderFns:[]}},function(e,t,s){var r=s(2);"string"==typeof r&&(r=[[e.id,r,""]]),r.locals&&(e.exports=r.locals);s(8)("091d3898",r,!0,{})},function(e,t,s){function r(e){for(var t=0;t<e.length;t++){var s=e[t],r=l[s.id];if(r){r.refs++;for(var n=0;n<r.parts.length;n++)r.parts[n](s.parts[n]);for(;n<s.parts.length;n++)r.parts.push(o(s.parts[n]));r.parts.length>s.parts.length&&(r.parts.length=s.parts.length)}else{for(var a=[],n=0;n<s.parts.length;n++)a.push(o(s.parts[n]));l[s.id]={id:s.id,refs:1,parts:a}}}}function n(){var e=document.createElement("style");return e.type="text/css",c.appendChild(e),e}function o(e){var t,s,r=document.querySelector("style["+_+'~="'+e.id+'"]');if(r){if(h)return g;r.parentNode.removeChild(r)}if(b){var o=p++;r=f||(f=n()),t=a.bind(null,r,o,!1),s=a.bind(null,r,o,!0)}else r=n(),t=i.bind(null,r),s=function(){r.parentNode.removeChild(r)};return t(e),function(r){if(r){if(r.css===e.css&&r.media===e.media&&r.sourceMap===e.sourceMap)return;t(e=r)}else s()}}function a(e,t,s,r){var n=s?"":r.css;if(e.styleSheet)e.styleSheet.cssText=v(t,n);else{var o=document.createTextNode(n),a=e.childNodes;a[t]&&e.removeChild(a[t]),a.length?e.insertBefore(o,a[t]):e.appendChild(o)}}function i(e,t){var s=t.css,r=t.media,n=t.sourceMap;if(r&&e.setAttribute("media",r),w.ssrId&&e.setAttribute(_,t.id),n&&(s+="\n/*# sourceURL="+n.sources[0]+" */",s+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+" */"),e.styleSheet)e.styleSheet.cssText=s;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(s))}}var d="undefined"!=typeof document,u=s(9),l={},c=d&&(document.head||document.getElementsByTagName("head")[0]),f=null,p=0,h=!1,g=function(){},w=null,_="data-vue-ssr-id",b="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());e.exports=function(e,t,s,n){h=s,w=n||{};var o=u(e,t);return r(o),function(t){for(var s=[],n=0;n<o.length;n++){var a=o[n],i=l[a.id];i.refs--,s.push(i)}t?(o=u(e,t),r(o)):o=[];for(var n=0;n<s.length;n++){var i=s[n];if(0===i.refs){for(var d=0;d<i.parts.length;d++)i.parts[d]();delete l[i.id]}}}};var v=function(){var e=[];return function(t,s){return e[t]=s,e.filter(Boolean).join("\n")}}()},function(e,t){e.exports=function(e,t){for(var s=[],r={},n=0;n<t.length;n++){var o=t[n],a=o[0],i=o[1],d=o[2],u=o[3],l={id:e+":"+n,css:i,media:d,sourceMap:u};r[a]?r[a].parts.push(l):s.push(r[a]={id:a,parts:[l]})}return s}},function(t,s){t.exports=e}])});