Skip to content

Commit eec5e40

Browse files
authored
Update Password.tsx
1 parent 4a14906 commit eec5e40

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

components/input/Password.tsx

+13-23
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,23 @@ export default defineComponent({
4040
default: true,
4141
},
4242
iconRender: Function,
43+
visible: { type: Boolean, default: undefined },
44+
onUpdate:visible: Function as PropType<(visible: boolean) => void>;
4345
},
4446
setup(props, { slots, attrs, expose }) {
45-
let visible: ShallowRef<boolean> = undefined;
46-
47-
if (typeof props.visibilityToggle === 'boolean') {
48-
visible = shallowRef(false);
49-
} else {
50-
visible = shallowRef(props.visibilityToggle.visible);
51-
// eslint-disable-next-line vue/no-setup-props-destructure
52-
const { visibilityToggle } = props;
53-
function _onVisibleChange(visible: boolean) {
54-
visibilityToggle.onVisibleChange(visible);
55-
}
56-
57-
watch(visible, () => {
58-
_onVisibleChange(visible.value);
59-
});
47+
const visible = shallowRef(false);
48+
const onVisibleChange(v: boolean) {
49+
const { disabled } = props;
50+
if (disabled) {
51+
return;
52+
}
53+
props['onUpdate:visible']?.(!v);
6054
}
61-
62-
const onVisibleChange = () => {
63-
const { disabled } = props;
64-
if (disabled) {
65-
return;
55+
watchEffect(()=> {
56+
if(props.visible !== undefined) {
57+
visible.value = props.visible;
6658
}
67-
visible.value = !visible.value;
68-
};
69-
59+
})
7060
const inputRef = shallowRef();
7161
const focus = () => {
7262
inputRef.value?.focus();

0 commit comments

Comments
 (0)