@@ -40,33 +40,23 @@ export default defineComponent({
40
40
default : true ,
41
41
} ,
42
42
iconRender : Function ,
43
+ visible : { type : Boolean , default : undefined } ,
44
+ onUpdate :visible : Function as PropType < ( visible : boolean ) => void > ;
43
45
} ,
44
46
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 ) ;
60
54
}
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 ;
66
58
}
67
- visible . value = ! visible . value ;
68
- } ;
69
-
59
+ } )
70
60
const inputRef = shallowRef ( ) ;
71
61
const focus = ( ) => {
72
62
inputRef . value ?. focus ( ) ;
0 commit comments