From 6c4ddfd51bee708c9f4eed5c44319d1ef9e3b825 Mon Sep 17 00:00:00 2001 From: Netfan Date: Tue, 10 Dec 2024 11:35:23 +0800 Subject: [PATCH] feat: modal zIndex support --- docs/src/components/common-ui/vben-drawer.md | 1 + docs/src/components/common-ui/vben-modal.md | 1 + packages/@core/ui-kit/popup-ui/src/modal/modal.ts | 6 +++++- packages/@core/ui-kit/popup-ui/src/modal/modal.vue | 2 ++ .../ui-kit/shadcn-ui/src/ui/dialog/DialogContent.vue | 12 +++++++++--- .../ui-kit/shadcn-ui/src/ui/dialog/DialogOverlay.vue | 5 +---- .../shadcn-ui/src/ui/dialog/DialogScrollContent.vue | 9 +++++++-- 7 files changed, 26 insertions(+), 10 deletions(-) diff --git a/docs/src/components/common-ui/vben-drawer.md b/docs/src/components/common-ui/vben-drawer.md index 3e7b6d4597c..97a72b3e301 100644 --- a/docs/src/components/common-ui/vben-drawer.md +++ b/docs/src/components/common-ui/vben-drawer.md @@ -96,6 +96,7 @@ const [Drawer, drawerApi] = useVbenDrawer({ | contentClass | modal内容区域的class | `string` | - | | footerClass | modal底部区域的class | `string` | - | | headerClass | modal顶部区域的class | `string` | - | +| zIndex | 抽屉的ZIndex层级 | `number` | `1000` | ### Event diff --git a/docs/src/components/common-ui/vben-modal.md b/docs/src/components/common-ui/vben-modal.md index cecf1cad815..34d2d5724df 100644 --- a/docs/src/components/common-ui/vben-modal.md +++ b/docs/src/components/common-ui/vben-modal.md @@ -107,6 +107,7 @@ const [Modal, modalApi] = useVbenModal({ | footerClass | modal底部区域的class | `string` | - | | headerClass | modal顶部区域的class | `string` | - | | bordered | 是否显示border | `boolean` | `false` | +| zIndex | 抽屉的ZIndex层级 | `number` | `1000` | ### Event diff --git a/packages/@core/ui-kit/popup-ui/src/modal/modal.ts b/packages/@core/ui-kit/popup-ui/src/modal/modal.ts index 995fa5d52a6..5508d004b9a 100644 --- a/packages/@core/ui-kit/popup-ui/src/modal/modal.ts +++ b/packages/@core/ui-kit/popup-ui/src/modal/modal.ts @@ -17,7 +17,6 @@ export interface ModalProps { * 取消按钮文字 */ cancelText?: string; - /** * 是否居中 * @default false @@ -25,6 +24,7 @@ export interface ModalProps { centered?: boolean; class?: string; + /** * 是否显示右上角的关闭按钮 * @default true @@ -117,6 +117,10 @@ export interface ModalProps { * 弹窗标题提示 */ titleTooltip?: string; + /** + * 弹窗层级 + */ + zIndex?: number; } export interface ModalState extends ModalProps { diff --git a/packages/@core/ui-kit/popup-ui/src/modal/modal.vue b/packages/@core/ui-kit/popup-ui/src/modal/modal.vue index abbca6762df..4e7d7ca78ee 100644 --- a/packages/@core/ui-kit/popup-ui/src/modal/modal.vue +++ b/packages/@core/ui-kit/popup-ui/src/modal/modal.vue @@ -81,6 +81,7 @@ const { showConfirmButton, title, titleTooltip, + zIndex, } = usePriorityValues(props, state); const shouldFullscreen = computed( @@ -194,6 +195,7 @@ const getAppendTo = computed(() => { :modal="modal" :open="state?.isOpen" :show-close="closable" + :z-index="zIndex" close-class="top-3" @close-auto-focus="handleFocusOutside" @closed="() => modalApi?.onClosed()" diff --git a/packages/@core/ui-kit/shadcn-ui/src/ui/dialog/DialogContent.vue b/packages/@core/ui-kit/shadcn-ui/src/ui/dialog/DialogContent.vue index 6c61bd522da..230fee20e10 100644 --- a/packages/@core/ui-kit/shadcn-ui/src/ui/dialog/DialogContent.vue +++ b/packages/@core/ui-kit/shadcn-ui/src/ui/dialog/DialogContent.vue @@ -26,9 +26,10 @@ const props = withDefaults( modal?: boolean; open?: boolean; showClose?: boolean; + zIndex?: number; } & DialogContentProps >(), - { appendTo: 'body', showClose: true }, + { appendTo: 'body', showClose: true, zIndex: 1000 }, ); const emits = defineEmits< { close: []; closed: []; opened: [] } & DialogContentEmits @@ -67,15 +68,20 @@ defineExpose({