106 lines
3.8 KiB
Vue
106 lines
3.8 KiB
Vue
<script setup lang="ts">
|
||
import { IconInfoCircle } from "@tabler/icons-vue";
|
||
import {
|
||
AlertDialog,
|
||
AlertDialogBackdrop,
|
||
AlertDialogBody,
|
||
AlertDialogClose,
|
||
AlertDialogCloseTrigger,
|
||
AlertDialogContainer,
|
||
AlertDialogDialog,
|
||
AlertDialogFooter,
|
||
AlertDialogHeader,
|
||
AlertDialogHeading,
|
||
AlertDialogIcon,
|
||
Button,
|
||
} from "@heroui-vue/components";
|
||
</script>
|
||
|
||
<template>
|
||
<div class="flex max-w-sm flex-col gap-6">
|
||
<div class="flex flex-col gap-2">
|
||
<h3 class="text-lg font-semibold">isDismissable</h3>
|
||
<p class="text-sm text-muted">
|
||
控制是否允许通过点击遮罩关闭对话框。警告框通常需要明确操作,因此默认为
|
||
<code>false</code>
|
||
。对重要性较低的确认,可设为
|
||
<code>true</code>
|
||
。
|
||
</p>
|
||
<AlertDialog>
|
||
<Button variant="secondary">打开警告对话框</Button>
|
||
<AlertDialogBackdrop :is-dismissable="false">
|
||
<AlertDialogContainer>
|
||
<AlertDialogDialog class="sm:max-w-[400px]">
|
||
<AlertDialogCloseTrigger />
|
||
<AlertDialogHeader>
|
||
<AlertDialogIcon status="danger">
|
||
<IconInfoCircle class="size-5" aria-hidden="true" />
|
||
</AlertDialogIcon>
|
||
<AlertDialogHeading>isDismissable = false</AlertDialogHeading>
|
||
<p class="text-sm leading-5 text-muted">
|
||
点击遮罩不会关闭此对话框
|
||
</p>
|
||
</AlertDialogHeader>
|
||
<AlertDialogBody>
|
||
<p>
|
||
尝试点击遮罩区域——对话框不会关闭,必须通过底部操作按钮关闭。
|
||
</p>
|
||
</AlertDialogBody>
|
||
<AlertDialogFooter>
|
||
<AlertDialogClose as-child>
|
||
<Button variant="tertiary">取消</Button>
|
||
</AlertDialogClose>
|
||
<AlertDialogClose as-child>
|
||
<Button>确认</Button>
|
||
</AlertDialogClose>
|
||
</AlertDialogFooter>
|
||
</AlertDialogDialog>
|
||
</AlertDialogContainer>
|
||
</AlertDialogBackdrop>
|
||
</AlertDialog>
|
||
</div>
|
||
|
||
<div class="flex flex-col gap-2">
|
||
<h3 class="text-lg font-semibold">isKeyboardDismissDisabled</h3>
|
||
<p class="text-sm text-muted">
|
||
控制是否允许通过 ESC 关闭。警告框通常需要明确操作,因此默认为
|
||
<code>true</code>
|
||
(禁用 ESC)。设为
|
||
<code>false</code>
|
||
时将允许 ESC 关闭。
|
||
</p>
|
||
<AlertDialog>
|
||
<Button variant="secondary">打开警告对话框</Button>
|
||
<AlertDialogBackdrop :is-keyboard-dismiss-disabled="true">
|
||
<AlertDialogContainer>
|
||
<AlertDialogDialog class="sm:max-w-[400px]">
|
||
<AlertDialogCloseTrigger />
|
||
<AlertDialogHeader>
|
||
<AlertDialogIcon status="accent">
|
||
<IconInfoCircle class="size-5" aria-hidden="true" />
|
||
</AlertDialogIcon>
|
||
<AlertDialogHeading>
|
||
isKeyboardDismissDisabled = true
|
||
</AlertDialogHeading>
|
||
<p class="text-sm leading-5 text-muted">已禁用 ESC 关闭</p>
|
||
</AlertDialogHeader>
|
||
<AlertDialogBody>
|
||
<p>按下 ESC 不会有任何反应,必须通过操作按钮关闭此对话框。</p>
|
||
</AlertDialogBody>
|
||
<AlertDialogFooter>
|
||
<AlertDialogClose as-child>
|
||
<Button variant="tertiary">取消</Button>
|
||
</AlertDialogClose>
|
||
<AlertDialogClose as-child>
|
||
<Button>确认</Button>
|
||
</AlertDialogClose>
|
||
</AlertDialogFooter>
|
||
</AlertDialogDialog>
|
||
</AlertDialogContainer>
|
||
</AlertDialogBackdrop>
|
||
</AlertDialog>
|
||
</div>
|
||
</div>
|
||
</template>
|