winbox-ui-next
Version:
We Design Vue 2.0: A Vue.js 3 UI Library
94 lines (93 loc) • 2.99 kB
JavaScript
import { defineComponent, ref, resolveComponent, openBlock, createBlock, createSlots, withCtx, renderSlot, withModifiers, createCommentVNode } from "vue";
import IconHover from "../_components/icon-hover.js";
import IconEye from "../icon/icon-eye/index.js";
import IconEyeInvisible from "../icon/icon-eye-invisible/index.js";
import _Input from "./input.js";
import _export_sfc from "../_virtual/plugin-vue_export-helper";
const _sfc_main = defineComponent({
name: "InputPassword",
components: {
IconEye,
IconEyeInvisible,
AIconHover: IconHover,
AInput: _Input
},
props: {
invisibleButton: {
type: Boolean,
default: true
}
},
setup() {
const inputRef = ref();
const invisible = ref(true);
const handleInvisible = () => {
invisible.value = !invisible.value;
};
return {
inputRef,
invisible,
handleInvisible
};
},
methods: {
focus() {
var _a;
(_a = this.inputRef) == null ? void 0 : _a.focus();
},
blur() {
var _a;
(_a = this.inputRef) == null ? void 0 : _a.blur();
}
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_icon_eye = resolveComponent("icon-eye");
const _component_icon_eye_invisible = resolveComponent("icon-eye-invisible");
const _component_a_icon_hover = resolveComponent("a-icon-hover");
const _component_a_input = resolveComponent("a-input");
return openBlock(), createBlock(_component_a_input, {
ref: "inputRef",
type: _ctx.invisible ? "password" : "text"
}, createSlots({ _: 2 }, [
_ctx.$slots.prepend ? {
name: "prepend",
fn: withCtx(() => [
renderSlot(_ctx.$slots, "prepend")
])
} : void 0,
_ctx.$slots.prefix ? {
name: "prefix",
fn: withCtx(() => [
renderSlot(_ctx.$slots, "prefix")
])
} : void 0,
_ctx.invisibleButton || _ctx.$slots.suffix ? {
name: "suffix",
fn: withCtx(() => [
_ctx.invisibleButton ? (openBlock(), createBlock(_component_a_icon_hover, {
key: 0,
onClick: _ctx.handleInvisible,
onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {
}, ["prevent"])),
onMouseup: _cache[1] || (_cache[1] = withModifiers(() => {
}, ["prevent"]))
}, {
default: withCtx(() => [
!_ctx.invisible ? (openBlock(), createBlock(_component_icon_eye, { key: 0 })) : (openBlock(), createBlock(_component_icon_eye_invisible, { key: 1 }))
]),
_: 1
}, 8, ["onClick"])) : createCommentVNode("v-if", true),
renderSlot(_ctx.$slots, "suffix")
])
} : void 0,
_ctx.$slots.append ? {
name: "append",
fn: withCtx(() => [
renderSlot(_ctx.$slots, "append")
])
} : void 0
]), 1032, ["type"]);
}
var InputPassword = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export { InputPassword as default };