Commit de12babd314ac831d3cb645f42dbf8a476075623
1 parent
b387681c
fix(modal): add v-model support for visible
Showing
3 changed files
with
11 additions
and
10 deletions
src/components/Modal/src/BasicModal.vue
@@ -81,7 +81,7 @@ | @@ -81,7 +81,7 @@ | ||
81 | components: { Modal, ModalWrapper, ModalClose, ModalFooter, ModalHeader }, | 81 | components: { Modal, ModalWrapper, ModalClose, ModalFooter, ModalHeader }, |
82 | inheritAttrs: false, | 82 | inheritAttrs: false, |
83 | props: basicProps, | 83 | props: basicProps, |
84 | - emits: ['visible-change', 'height-change', 'cancel', 'ok', 'register'], | 84 | + emits: ['visible-change', 'height-change', 'cancel', 'ok', 'register', 'update:visible'], |
85 | setup(props, { emit, attrs }) { | 85 | setup(props, { emit, attrs }) { |
86 | const visibleRef = ref(false); | 86 | const visibleRef = ref(false); |
87 | const propsRef = ref<Partial<ModalProps> | null>(null); | 87 | const propsRef = ref<Partial<ModalProps> | null>(null); |
@@ -157,6 +157,7 @@ | @@ -157,6 +157,7 @@ | ||
157 | () => unref(visibleRef), | 157 | () => unref(visibleRef), |
158 | (v) => { | 158 | (v) => { |
159 | emit('visible-change', v); | 159 | emit('visible-change', v); |
160 | + emit('update:visible', v); | ||
160 | instance && modalMethods.emitVisible?.(v, instance.uid); | 161 | instance && modalMethods.emitVisible?.(v, instance.uid); |
161 | nextTick(() => { | 162 | nextTick(() => { |
162 | if (props.scrollTop && v && unref(modalWrapperRef)) { | 163 | if (props.scrollTop && v && unref(modalWrapperRef)) { |
@@ -180,7 +181,7 @@ | @@ -180,7 +181,7 @@ | ||
180 | } | 181 | } |
181 | 182 | ||
182 | visibleRef.value = false; | 183 | visibleRef.value = false; |
183 | - emit('cancel'); | 184 | + emit('cancel', e); |
184 | } | 185 | } |
185 | 186 | ||
186 | /** | 187 | /** |
@@ -193,8 +194,8 @@ | @@ -193,8 +194,8 @@ | ||
193 | visibleRef.value = !!props.visible; | 194 | visibleRef.value = !!props.visible; |
194 | } | 195 | } |
195 | 196 | ||
196 | - function handleOk() { | ||
197 | - emit('ok'); | 197 | + function handleOk(e: Event) { |
198 | + emit('ok', e); | ||
198 | } | 199 | } |
199 | 200 | ||
200 | function handleHeightChange(height: string) { | 201 | function handleHeightChange(height: string) { |
src/components/Modal/src/components/ModalClose.vue
@@ -35,8 +35,8 @@ | @@ -35,8 +35,8 @@ | ||
35 | ]; | 35 | ]; |
36 | }); | 36 | }); |
37 | 37 | ||
38 | - function handleCancel() { | ||
39 | - emit('cancel'); | 38 | + function handleCancel(e: Event) { |
39 | + emit('cancel', e); | ||
40 | } | 40 | } |
41 | function handleFullScreen(e: Event) { | 41 | function handleFullScreen(e: Event) { |
42 | e?.stopPropagation(); | 42 | e?.stopPropagation(); |
src/components/Modal/src/components/ModalFooter.vue
@@ -26,12 +26,12 @@ | @@ -26,12 +26,12 @@ | ||
26 | props: basicProps, | 26 | props: basicProps, |
27 | emits: ['ok', 'cancel'], | 27 | emits: ['ok', 'cancel'], |
28 | setup(_, { emit }) { | 28 | setup(_, { emit }) { |
29 | - function handleOk() { | ||
30 | - emit('ok'); | 29 | + function handleOk(e: Event) { |
30 | + emit('ok', e); | ||
31 | } | 31 | } |
32 | 32 | ||
33 | - function handleCancel() { | ||
34 | - emit('cancel'); | 33 | + function handleCancel(e: Event) { |
34 | + emit('cancel', e); | ||
35 | } | 35 | } |
36 | return { handleOk, handleCancel }; | 36 | return { handleOk, handleCancel }; |
37 | }, | 37 | }, |