UNPKG

@opensig/opendesign

Version:

<p align="center"><img src="../docs/public/opendesign-logo-light.png"/></p> <h1 align="center">opendesign</h1> <p align="center">一个 Vue 3 组件库</p> <p align="center"><b>皮肤可定制,使用 TypeScript</b></p>

58 lines (57 loc) 1.51 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const is = require("../_utils/is.js"); const vue = require("vue"); function useInputPassword(options) { const showPassword = vue.ref(true); vue.watchEffect(() => { showPassword.value = options.type.value !== "password"; }); const toggle = (show) => { if (show === void 0) { showPassword.value = !showPassword.value; } else { showPassword.value = show; } }; const onEyeClick = () => { if (options.disabled.value) { return; } if (options.showPasswordEvent === "click") { toggle(); } }; const onEyeMouseUp = () => { if (showPassword.value) { toggle(false); if (is.isTouchDevice) { window.removeEventListener("touchend", onEyeMouseUp); window.removeEventListener("touchcancel", onEyeMouseUp); } else { window.removeEventListener("mouseup", onEyeMouseUp); } } }; const onEyeMouseDown = () => { if (options.disabled.value) { return; } if (options.showPasswordEvent === "pointerdown") { toggle(true); if (is.isTouchDevice) { window.addEventListener("touchend", onEyeMouseUp); window.addEventListener("touchcancel", onEyeMouseUp); } else { window.addEventListener("mouseup", onEyeMouseUp); } } }; return { showPassword, onEyeMouseDown, onEyeMouseUp, onEyeClick }; } exports.useInputPassword = useInputPassword;