perf: improve modal and drawer component documentation and fix known problems (#4264)

* feat: improve modal and drawer component documentation and fix known problems

* chore: update ci
This commit is contained in:
Vben
2024-08-28 22:26:35 +08:00
committed by GitHub
parent 84816ef769
commit 36e7ca19a1
54 changed files with 882 additions and 176 deletions

View File

@@ -38,7 +38,6 @@ export class DrawerApi {
isOpen: false,
loading: false,
modal: true,
sharedData: {},
title: '',
};
@@ -93,7 +92,11 @@ export class DrawerApi {
* 取消操作
*/
onCancel() {
this.api.onCancel?.();
if (this.api.onCancel) {
this.api.onCancel?.();
} else {
this.close();
}
}
/**

View File

@@ -1,6 +1,8 @@
<script lang="ts" setup>
import type { DrawerProps, ExtendedDrawerApi } from './drawer';
import { ref, watch } from 'vue';
import { useIsMobile, usePriorityValue } from '@vben-core/composables';
import { Info, X } from '@vben-core/icons';
import {
@@ -31,6 +33,8 @@ const props = withDefaults(defineProps<Props>(), {
drawerApi: undefined,
});
const wrapperRef = ref<HTMLElement>();
const { isMobile } = useIsMobile();
const state = props.drawerApi?.useStore?.();
@@ -47,6 +51,18 @@ const confirmText = usePriorityValue('confirmText', props, state);
const closeOnClickModal = usePriorityValue('closeOnClickModal', props, state);
const closeOnPressEscape = usePriorityValue('closeOnPressEscape', props, state);
watch(
() => showLoading.value,
(v) => {
if (v && wrapperRef.value) {
wrapperRef.value.scrollTo({
// behavior: 'smooth',
top: 0,
});
}
},
);
function interactOutside(e: Event) {
if (!closeOnClickModal.value) {
e.preventDefault();
@@ -129,9 +145,10 @@ function pointerDownOutside(e: Event) {
</SheetHeader>
<div
ref="wrapperRef"
:class="
cn('relative flex-1 p-3', contentClass, {
'overflow-y-auto': !showLoading,
cn('relative flex-1 overflow-y-auto p-3', contentClass, {
'overflow-hidden': showLoading,
})
"
>