UNPKG

tav-ui

Version:
80 lines (75 loc) 2.87 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); var core = require('@zxcvbn-ts/core'); var antDesignVue = require('ant-design-vue'); var types = require('./types2.js'); var pluginVue_exportHelper = require('../../../../_virtual/plugin-vue_export-helper.js'); const _sfc_main = vue.defineComponent({ name: "TaStrengthMeter", components: { InputPassword: antDesignVue.Input.Password }, props: types.strengthMeterProps, emits: ["score-change", "change"], setup(props, { emit }) { const innerValueRef = vue.ref(""); const prefixCls = "ta-strength-meter"; const getPasswordStrength = vue.computed(() => { const { disabled } = props; if (disabled) return -1; const innerValue = vue.unref(innerValueRef); const score = innerValue ? core.zxcvbn(vue.unref(innerValueRef)).score : -1; emit("score-change", score); return score; }); function handleChange(e) { innerValueRef.value = e.target.value; } vue.watchEffect(() => { innerValueRef.value = props.value || ""; }); vue.watch(() => vue.unref(innerValueRef), (val) => { emit("change", val); }); return { getPasswordStrength, handleChange, prefixCls, innerValueRef }; } }); const _hoisted_1 = ["data-score"]; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_InputPassword = vue.resolveComponent("InputPassword"); return vue.openBlock(), vue.createElementBlock("div", { class: vue.normalizeClass([_ctx.prefixCls, "relative"]) }, [ _ctx.showInput ? (vue.openBlock(), vue.createBlock(_component_InputPassword, vue.mergeProps({ key: 0 }, _ctx.$attrs, { "allow-clear": "", value: _ctx.innerValueRef, disabled: _ctx.disabled, onChange: _ctx.handleChange }), vue.createSlots({ _: 2 }, [ vue.renderList(Object.keys(_ctx.$slots), (item) => { return { name: item, fn: vue.withCtx((data) => [ vue.renderSlot(_ctx.$slots, item, vue.normalizeProps(vue.guardReactiveProps(data || {}))) ]) }; }) ]), 1040, ["value", "disabled", "onChange"])) : vue.createCommentVNode("v-if", true), vue.createElementVNode("div", { class: vue.normalizeClass(`${_ctx.prefixCls}-bar`) }, [ vue.createElementVNode("div", { class: vue.normalizeClass(`${_ctx.prefixCls}-bar--fill`), "data-score": _ctx.getPasswordStrength }, null, 10, _hoisted_1) ], 2) ], 2); } var StrengthMeter = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/tav-ui/tav-ui/packages/components/strength-meter/src/strength-meter.vue"]]); exports["default"] = StrengthMeter; //# sourceMappingURL=strength-meter2.js.map