Files
heroui-vue/apps/docs/demos/alert-dialog-custom-portal.vue
maoyingjie 53e76f676d fix(demos): restore form, overlay and toast demos to the pinned cn baseline
HD-02 scope, all against heroui ce90ea3 cn sources:

- card: add the text-primary class to the coin icons (source parity);
  card-with-form drops the added required validation and inline business
  note, restores the plain href="#" forgot-password link and the baseline
  alert("表单提交成功!") submit feedback (autocomplete kept: no visible
  impact, allowed by the task card)
- input-group-with-textarea: restore the four Tooltips and the Enter Kbd
  hint; drop the stale "Tooltip 组件尚未迁移" note from input-group.md
- alert-dialog: restore the h-px top light line in custom-styles and the
  truncated/missing description text in sizes/custom-portal/
  custom-animations (+ controlled); align the fluid-slide icon with the
  modal mapping (IconArrowBarUp for gravity-ui:arrow-up-from-line)
- toast: restore the upstream demo layout shells (variants/simple/
  custom-indicator/custom-queue) and the action button default variant:
  ToastActionButton now falls back to the Button defaults (primary/md)
  like upstream ToastActionButton, so variants' actions render primary,
  danger stays danger and default stays tertiary; toast.md defaults fixed
- submit demos: restore baseline feedback and structure — alert() for
  card/fieldset/form/checkbox/checkbox-group/switch/select/combo-box/
  autocomplete and console.log for search/number/time field form examples;
  modal-with-form returns to the close-only footer (no submit/result row);
  drop the added inline status/result rows and the max-w-full/
  max-sm:min-w-0 width guards from the restored demos
- radio-group-validation: add the missing text-muted to the result line;
  label.md invalid example gives the real control its invalid state and
  matches the baseline input shape

Tests re-pinned to the baseline contracts (alert/console/close behavior,
four tooltips + Kbd, positional modal footer); full suite 110 files /
1617 tests, typecheck, build:docs and the m35-m36 tarball contract pass.
2026-10-28 14:10:10 +08:00

81 lines
2.8 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { ref } from "vue";
import {
AlertDialog,
AlertDialogBackdrop,
AlertDialogBody,
AlertDialogClose,
AlertDialogCloseTrigger,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
Button,
} from "@heroui-vue/components";
const portalEl = ref<HTMLElement | null>(null);
</script>
<template>
<div class="flex flex-col gap-4">
<div>
<p class="text-sm">
将警告对话框渲染到自定义容器,而不是
<code>document.body</code>
</p>
<p class="text-sm text-muted">
为容器应用
<code class="rounded px-1 py-0.5 text-xs">
transform: translateZ(0)
</code>
可创建新的层叠上下文。
</p>
</div>
<div
ref="portalEl"
class="relative flex h-[380px] items-center justify-center overflow-hidden rounded bg-muted/20"
style="transform: translate(0)"
>
<AlertDialog v-if="portalEl">
<Button>打开警告对话框</Button>
<AlertDialogBackdrop class="h-full" :to="portalEl">
<AlertDialogContainer class="h-full max-h-full">
<AlertDialogDialog class="h-full max-h-full sm:max-w-md">
<AlertDialogCloseTrigger />
<AlertDialogHeader>
<AlertDialogIcon status="accent" />
<AlertDialogHeading>自定义传送门</AlertDialogHeading>
</AlertDialogHeader>
<AlertDialogBody>
<p class="text-sm text-muted">
此段为示例占位文案,用于演示在自定义容器内渲染对话框时的滚动与排版效果。实际项目中请替换为真实说明内容。
</p>
<p class="text-sm text-muted">
通过将浮层挂载到局部容器,可以配合裁剪、缩放或卡片布局,避免遮挡整个页面,同时仍保持焦点管理与无障碍行为。
</p>
<p class="text-sm text-muted">
若容器存在
<code>transform</code>
或
<code>filter</code>
等属性,请注意浏览器会为其创建新的包含块,从而影响定位与层级关系。
</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>