Compare commits

..

2 Commits

Author SHA1 Message Date
maoyingjie 0cfe7b6195 merge: integrate reviewed AlertDialog Drawer with ListBox main 2026-10-23 18:36:19 +08:00
maoyingjie 0ec20aaa6a feat: migrate AlertDialog and Drawer with reviewed overlay lifecycles 2026-10-23 18:34:07 +08:00
83 changed files with 5885 additions and 3 deletions
+6
View File
@@ -425,3 +425,9 @@ Vaul Vue 官方已说明停止维护并推荐 Reka Drawer;新项目不采用 V
- 逻辑数据全集与挂载 registry 分开。虚拟导航先滚动再等 DOM 聚焦,异步焦点请求可被新请求或卸载取消;用户滚动卸载焦点行时不跳回首行。全选/范围/搜索不能只看可见窗口。
- 连续 typeahead 在当前项仍匹配时保留它;重复首字母才循环下一项。空 key / 数字 0 不得被真值判断排除;none 模式不显示遗留的选中状态。
- Root 与公开 Props 共用 ListBoxOptions 明确 schema,泛型 SFC 的 Parameters 提取曾让反例失效。后续泛型组件也必须做产物类型正反例,不能用 any 修复。
## M33–M34 复核经验与后续任务(2026-10-23)
- 必须阅读[M33–M34迁移经验](docs/migrations/M33-M34-lessons.md):真实动画所有者、Presence与transition差异、完成/取消手势、捕获与旧节点清理、退出中重开、reduced-motion级联、同页演示、完整文档与独立产物类型。
- M33/M34最终范围见[验收记录](docs/migrations/M33-M34-acceptance.md),不能用历史返修报告或绿色测试数量推断全视觉/读屏已验收。
- 其他AI下一批为[M35 Toast → M36 Table](docs/migrations/M35-M36-toast-table-prompt.md),先同步最新main再开feat/m35-m36-toast-table。集成人继续ListBox/Select、日期与颜色基建;不要改写共享collection/field/overlay内核。
+2
View File
@@ -47,6 +47,7 @@ const groups = [
items: [
{ title: "Accordion 手风琴", url: "/components/accordion" },
{ title: "Alert 警告", url: "/components/alert" },
{ title: "AlertDialog 警告对话框", url: "/components/alert-dialog" },
{ title: "Avatar 头像", url: "/components/avatar" },
{ title: "AvatarGroup 头像组", url: "/components/avatar-group" },
{ title: "Badge 徽章", url: "/components/badge" },
@@ -67,6 +68,7 @@ const groups = [
title: "DisclosureGroup 折叠面板组",
url: "/components/disclosure-group",
},
{ title: "Drawer 抽屉", url: "/components/drawer" },
{ title: "EmptyState 空状态", url: "/components/empty-state" },
{ title: "FieldError 字段错误", url: "/components/field-error" },
{ title: "Fieldset 字段组", url: "/components/fieldset" },
+300
View File
@@ -0,0 +1,300 @@
---
title: AlertDialog 警告对话框
description: 需要用户明确确认的警告对话框,默认禁止误关闭。
component: alert-dialog
group: 组件
---
> 基于固定 HeroUI 3.2.6(ce90ea3)迁移。命名组件、v-model、作用域插槽与 DOM attrs 为 Vue 适配;预览、复制与高亮来自同一份 SFC。
## 用法
```ts
import { AlertDialog } from "@heroui-vue/components";
```
<ComponentPreview name="alert-dialog-default" />
## 组件结构
```vue
<script setup lang="ts">
import {
AlertDialog,
AlertDialogBackdrop,
AlertDialogBody,
AlertDialogClose,
AlertDialogCloseTrigger,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
Button,
} from "@heroui-vue/components";
</script>
<template>
<AlertDialog>
<Button variant="danger">删除项目</Button>
<AlertDialogBackdrop>
<AlertDialogContainer>
<AlertDialogDialog>
<AlertDialogCloseTrigger />
<AlertDialogHeader>
<AlertDialogIcon status="danger" />
<AlertDialogHeading>要永久删除项目吗?</AlertDialogHeading>
</AlertDialogHeader>
<AlertDialogBody>此操作无法撤销。</AlertDialogBody>
<AlertDialogFooter>
<AlertDialogClose as-child>
<Button variant="tertiary">取消</Button>
</AlertDialogClose>
<AlertDialogClose as-child>
<Button variant="danger">删除</Button>
</AlertDialogClose>
</AlertDialogFooter>
</AlertDialogDialog>
</AlertDialogContainer>
</AlertDialogBackdrop>
</AlertDialog>
</template>
```
`Dialog` 渲染 `role="alertdialog"`。**默认 `isDismissable=false`、`isKeyboardDismissDisabled=true`**(与 Modal 相反),二者可独立配置。
## 示例
### 状态类型
<ComponentPreview name="alert-dialog-statuses" />
### 弹出位置
<ComponentPreview name="alert-dialog-placements" />
### 尺寸
<ComponentPreview name="alert-dialog-sizes" />
### 受控模式
<ComponentPreview name="alert-dialog-controlled" />
### 自定义图标
<ComponentPreview name="alert-dialog-custom-icon" />
### 自定义触发器
<ComponentPreview name="alert-dialog-custom-trigger" />
### 遮罩变体
<ComponentPreview name="alert-dialog-backdrop-variants" />
### 自定义遮罩
<ComponentPreview name="alert-dialog-custom-backdrop" />
### 关闭行为
<ComponentPreview name="alert-dialog-dismiss-behavior" />
### 关闭方式
<ComponentPreview name="alert-dialog-close-methods" />
### 自定义动画
<ComponentPreview name="alert-dialog-custom-animations" />
### 自定义 Portal
<ComponentPreview name="alert-dialog-custom-portal" />
## 自定义样式
### Tailwind CSS
<ComponentPreview name="alert-dialog-custom-styles" />
### 全局 CSS
若要自定义组件类,可使用 `@layer components` 指令:
```css
@layer components {
.hv-alert-dialog__backdrop {
@apply bg-gradient-to-br from-black/60 to-black/80;
}
.hv-alert-dialog__dialog {
@apply rounded-2xl border border-red-500/20 shadow-2xl;
}
.hv-alert-dialog__header {
@apply gap-4;
}
.hv-alert-dialog__icon {
@apply size-16;
}
.hv-alert-dialog__close-trigger {
@apply rounded-full bg-white/10 hover:bg-white/20;
}
}
```
## 样式参考
HeroUI 遵循 [BEM](https://getbem.com/) 方法论。类名前缀 `hv-`。
### CSS 类
#### 基础类
- `.hv-alert-dialog__trigger` - 打开警告对话框的触发元素
- `.hv-alert-dialog__backdrop` - 遮罩层
- `.hv-alert-dialog__container` - 支持 placement 的定位包裹层
- `.hv-alert-dialog__dialog` - 对话框内容容器
- `.hv-alert-dialog__header` - 图标与标题头部
- `.hv-alert-dialog__heading` - 标题文本
- `.hv-alert-dialog__body` - 主内容区域
- `.hv-alert-dialog__footer` - 操作按钮区域
- `.hv-alert-dialog__icon` - 状态色图标容器
- `.hv-alert-dialog__close-trigger` - 关闭按钮
#### 遮罩变体
- `.hv-alert-dialog__backdrop--opaque` / `--blur` / `--transparent`
#### 状态变体(图标)[!toc]
- `.hv-alert-dialog__icon--default` / `--accent` / `--success` / `--warning` / `--danger`
### 交互状态
- **Focus**:`:focus-visible` 或 `[data-focus-visible="true"]`
- **Hover**:`:hover` 或 `[data-hovered="true"]`
- **Active**:`:active` 或 `[data-pressed="true"]`
- **Entering**:`[data-entering]`
- **Exiting**:`[data-exiting]`
- **Placement**:`[data-placement="*"]`(auto、top、center、bottom)
## API 参考
### AlertDialog / AlertDialogRoot
| Prop | 类型 | 默认值 | 描述 |
| ---------------------------------------------- | -------------------------- | ------- | -------------------------------- |
| `open` / `isOpen` | `boolean` | - | 受控打开 |
| `defaultOpen` | `boolean` | `false` | 初始打开 |
| `state` | `OverlayState` | - | useOverlayState 实例 |
| `update:open` / `update:isOpen` / `openChange` | `(value: boolean) => void` | - | 状态事件 |
| 默认插槽 | `{ isOpen, close }` | - | 内容;首个 Button 自动作为触发器 |
### AlertDialogTrigger
| Prop | 类型 | 默认值 | 描述 |
| ------------ | --------------------------- | ------- | ---------------- |
| `as` | `string` | `'div'` | 渲染元素 |
| `asChild` | `boolean` | `false` | 合并到唯一子元素 |
| `isDisabled` | `boolean` | `false` | 禁用触发 |
| `class` | `string \| Array \| Object` | - | CSS 类 |
| 默认插槽 | - | - | 触发器内容 |
### AlertDialogBackdrop
| Prop | 类型 | 默认值 | 描述 |
| --------------------------------- | ------------------------------------- | ----------- | --------------------------------------------- |
| `variant` | `'opaque' \| 'blur' \| 'transparent'` | `'opaque'` | 遮罩样式 |
| `isDismissable` | `boolean` | **`false`** | 点击遮罩是否关闭 |
| `isKeyboardDismissDisabled` | `boolean` | **`true`** | 是否禁用 ESC |
| `open` / `isOpen` / `defaultOpen` | | | 无父 AlertDialog 时自建状态 |
| `state` | `OverlayState` | - | 受控状态 |
| `to` | `string \| HTMLElement` | body | 传送门容器(替代 `UNSTABLE_portalContainer`) |
| `update:open` / `openChange` | `(value: boolean) => void` | - | 状态事件 |
| 默认插槽 | `{ isOpen, close }` | - | Container 等 |
### AlertDialogContainer
| Prop | 类型 | 默认值 | 描述 |
| ----------- | ----------------------------------------- | -------- | --------- |
| `placement` | `'auto' \| 'center' \| 'top' \| 'bottom'` | `'auto'` | 位置 |
| `size` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'cover'` | `'md'` | 尺寸 |
| `as` | `string` | `'div'` | 渲染元素 |
| `class` | `string \| Array \| Object` | - | CSS 类 |
| 默认插槽 | `{ close }` | - | Dialog 等 |
### AlertDialogDialog
| Prop | 类型 | 默认值 | 描述 |
| ----------------------------------------------------- | --------------------------- | --------------- | ---------------- |
| `role` | `string` | `'alertdialog'` | ARIA role |
| `aria-label` / `aria-labelledby` / `aria-describedby` | `string` | 自动标题关联 | 无障碍名称与描述 |
| `as` | `string` | `'div'` | 渲染元素 |
| `id` | `string` | 自动 | 内容 id |
| `class` | `string \| Array \| Object` | - | CSS 类 |
| 默认插槽 | `{ close, isOpen }` | - | 面板内容 |
### AlertDialogHeader / Heading / Body / Footer
| 部件 | Prop | 描述 |
| ------- | -------------------------------- | ------------------ |
| Header | `class`、默认插槽 | 图标 + 标题容器 |
| Heading | `as`(默认 `h2`)、`id`、`class` | 注册为 dialog 标题 |
| Body | `class`、默认插槽 | 正文 |
| Footer | `class`、默认插槽 | 操作区 |
### AlertDialogIcon
| Prop | 类型 | 默认值 | 描述 |
| -------- | ------------------------------------------------------------- | ---------- | ------------------ |
| `status` | `'default' \| 'accent' \| 'success' \| 'warning' \| 'danger'` | `'danger'` | 状态配色与默认图标 |
| `as` | `string` | `'div'` | 渲染元素 |
| `class` | `string \| Array \| Object` | - | CSS 类 |
| 默认插槽 | - | 状态 SVG | 自定义图标 |
### AlertDialogCloseTrigger / AlertDialogClose
| 部件 | Prop | 描述 |
| ------------ | -------------------------------- | ------------------------------------------- |
| CloseTrigger | `variant`、`isDisabled`、`class` | X 按钮,点击关闭 |
| Close | `as`、`asChild`、`isDisabled` | 包裹任意控件以关闭;替代上游 `slot="close"` |
### useOverlayState
```ts
import { useOverlayState } from "@heroui-vue/components";
const state = useOverlayState({ defaultOpen: false });
state.isOpen.value;
state.open();
state.close();
state.toggle();
state.setOpen(true);
```
### 上游差异
| 上游 React | Vue |
| ----------------------------- | ------------------------------ |
| 对象子部件 `AlertDialog.Icon` | 具名导出 |
| `Button slot="close"` | `AlertDialogClose as-child` |
| Dialog render props | 作用域插槽 `{ close, isOpen }` |
| `UNSTABLE_portalContainer` | `to` |
| `onPress` | `@click` |
## 无障碍
- `role="alertdialog"`,标题经 `aria-labelledby` 关联真实 Heading
- 显式 `aria-labelledby` / `aria-label` 优先于自动计算
- 默认禁止 ESC 与外部点击误关闭
- 破坏性操作示例仅修改本地演示状态
## 相关组件
- [Modal 模态框](./modal)
- [Button 按钮](./button)
+268
View File
@@ -0,0 +1,268 @@
---
title: Drawer 抽屉
description: 从屏幕边缘滑出的面板,支持四方向与拖动关闭。
component: drawer
group: 组件
---
> 基于固定 HeroUI 3.2.6(ce90ea3)迁移。命名组件、v-model、作用域插槽与 DOM attrs 为 Vue 适配;预览、复制与高亮来自同一份 SFC。
## 用法
```ts
import { Drawer } from "@heroui-vue/components";
```
<ComponentPreview name="drawer-basic" />
## 组件结构
`Content` 负责边缘定位与滑入/滑出,`Dialog` 是可交互面板(拖动、焦点、ARIA)。二者职责分离。
```vue
<script setup lang="ts">
import {
Drawer,
DrawerBackdrop,
DrawerBody,
DrawerClose,
DrawerCloseTrigger,
DrawerContent,
DrawerDialog,
DrawerFooter,
DrawerHeader,
DrawerHeading,
DrawerHandle,
Button,
} from "@heroui-vue/components";
</script>
<template>
<Drawer>
<Button>打开</Button>
<DrawerBackdrop>
<DrawerContent placement="bottom">
<DrawerDialog>
<DrawerHandle />
<DrawerCloseTrigger />
<DrawerHeader><DrawerHeading>标题</DrawerHeading></DrawerHeader>
<DrawerBody>内容</DrawerBody>
<DrawerFooter>
<DrawerClose as-child><Button>关闭</Button></DrawerClose>
</DrawerFooter>
</DrawerDialog>
</DrawerContent>
</DrawerBackdrop>
</Drawer>
</template>
```
拖动从 **Handle / Header / Footer** 启动(Body 排除,避免与滚动冲突)。阈值:位移超过尺寸 **30%** 或速度超过 **0.5px/ms** 则关闭,否则回弹。`isDismissable=false` 时禁用拖动与外部点击。
## 示例
### 弹出位置
<ComponentPreview name="drawer-placements" />
### 不可关闭
<ComponentPreview name="drawer-non-dismissable" />
### 可滚动内容
<ComponentPreview name="drawer-scrollable-content" />
### 受控模式
<ComponentPreview name="drawer-controlled" />
### 搭配表单
<ComponentPreview name="drawer-with-form" />
### 导航抽屉
<ComponentPreview name="drawer-navigation" />
### 遮罩变体
<ComponentPreview name="drawer-backdrop-variants" />
## 自定义样式
### Tailwind CSS
<ComponentPreview name="drawer-custom-styles" />
### 全局 CSS
若要自定义组件类,可使用 `@layer components` 指令:
```css
@layer components {
.hv-drawer__backdrop {
@apply bg-gradient-to-br from-black/50 to-black/70;
}
.hv-drawer__dialog {
@apply rounded-2xl border border-white/10 shadow-2xl;
}
.hv-drawer__header {
@apply text-center;
}
.hv-drawer__close-trigger {
@apply rounded-full bg-white/10 hover:bg-white/20;
}
}
```
## 样式参考
HeroUI 遵循 [BEM](https://getbem.com/) 方法论。类名前缀 `hv-`。
### CSS 类
#### 基础类
- `.hv-drawer__trigger` - 打开抽屉的触发元素
- `.hv-drawer__backdrop` - 抽屉背后的遮罩层
- `.hv-drawer__content` - 抽屉面板的定位包裹层
- `.hv-drawer__dialog` - 抽屉面板本身
- `.hv-drawer__header` - 标题区域
- `.hv-drawer__heading` - 主标题文本
- `.hv-drawer__body` - 主可滚动内容区域
- `.hv-drawer__footer` - 操作按钮区域
- `.hv-drawer__handle` - 视觉拖拽手柄指示器
- `.hv-drawer__close-trigger` - 关闭按钮元素
#### 遮罩变体
- `.hv-drawer__backdrop--opaque` - 不透明彩色遮罩(默认)
- `.hv-drawer__backdrop--blur` - 模糊遮罩
- `.hv-drawer__backdrop--transparent` - 透明遮罩
#### 位置变体
- `.hv-drawer__content--bottom` - 从底部边缘滑入(默认)
- `.hv-drawer__content--top` - 从顶部边缘滑入
- `.hv-drawer__content--left` - 从左侧边缘滑入
- `.hv-drawer__content--right` - 从右侧边缘滑入
#### 对话框变体
- `.hv-drawer__dialog--top` / `--bottom` / `--left` / `--right`
### 交互状态
- **Focus**:`:focus-visible` 或 `[data-focus-visible="true"]`
- **Hover**:`:hover` 或 `[data-hovered="true"]`
- **Active**:`:active` 或 `[data-pressed="true"]`
- **Entering**:`[data-entering]` - 打开动画期间
- **Exiting**:`[data-exiting]` - 关闭动画期间(CSS 动画,供 Presence 延迟卸载)
- **Placement**:`[data-placement="*"]`
## API 参考
### Drawer / DrawerRoot
| Prop | 类型 | 默认值 | 描述 |
| ------------------------------- | -------------------------- | ------- | -------------------------------- |
| `open` / `isOpen` | `boolean` | - | 受控打开 |
| `defaultOpen` | `boolean` | `false` | 初始打开 |
| `state` | `OverlayState` | - | useOverlayState 实例 |
| `update:open` / `update:isOpen` | `(value: boolean) => void` | - | 打开状态变更 |
| `openChange` | `(value: boolean) => void` | - | 打开状态变更 |
| 默认插槽 | `{ isOpen, close }` | - | 内容;首个 Button 自动作为触发器 |
### DrawerTrigger
| Prop | 类型 | 默认值 | 描述 |
| ------------ | --------------------------- | ------- | ---------------- |
| `as` | `string` | `'div'` | 渲染元素 |
| `asChild` | `boolean` | `false` | 合并到唯一子元素 |
| `isDisabled` | `boolean` | `false` | 禁用触发 |
| `class` | `string \| Array \| Object` | - | CSS 类 |
| 默认插槽 | - | - | 触发器内容 |
### DrawerBackdrop
| Prop | 类型 | 默认值 | 描述 |
| ---------------------------- | ------------------------------------- | ---------- | -------------------------- |
| `variant` | `'opaque' \| 'blur' \| 'transparent'` | `'opaque'` | 遮罩样式 |
| `isDismissable` | `boolean` | `true` | 点击遮罩 / 拖动关闭 |
| `isKeyboardDismissDisabled` | `boolean` | `false` | 禁用 ESC |
| `open` / `isOpen` | `boolean` | - | 受控打开(无父 Drawer 时) |
| `defaultOpen` | `boolean` | `false` | 初始打开 |
| `update:isOpen` | `(value: boolean) => void` | - | 状态事件 |
| `state` | `OverlayState` | - | 受控状态 |
| `to` | `string \| HTMLElement` | body | 传送门容器 |
| `update:open` / `openChange` | `(value: boolean) => void` | - | 状态事件 |
| 默认插槽 | `{ isOpen, close }` | - | Content 等 |
### DrawerContent
| Prop | 类型 | 默认值 | 描述 |
| ----------- | ---------------------------------------- | ---------- | --------- |
| `placement` | `'bottom' \| 'top' \| 'left' \| 'right'` | `'bottom'` | 滑入边缘 |
| `as` | `string` | `'div'` | 渲染元素 |
| `class` | `string \| Array \| Object` | - | CSS 类 |
| 默认插槽 | `{ close }` | - | Dialog 等 |
### DrawerDialog
| Prop | 类型 | 默认值 | 描述 |
| ----------------------------------------------------- | --------------------------- | ------------ | ----------------------- |
| `role` | `string` | `'dialog'` | ARIA role(透传可覆盖) |
| `aria-label` / `aria-labelledby` / `aria-describedby` | `string` | 自动标题关联 | 无障碍名称与描述 |
| `as` | `string` | `'div'` | 渲染元素 |
| `id` | `string` | 自动 | 内容 id |
| `class` | `string \| Array \| Object` | - | CSS 类 |
| 默认插槽 | `{ close, isOpen }` | - | 面板内容 |
### DrawerHeader / DrawerHeading / DrawerBody / DrawerFooter
| 部件 | Prop | 默认值 | 描述 |
| ------- | -------------------------------- | ------ | ----------------------------------- |
| Header | `class`、默认插槽 | - | 标题区容器 |
| Heading | `as`(默认 `h2`)、`id`、`class` | - | 注册为 dialog 标题 |
| Body | `class`、默认插槽 | - | 可滚动正文(`touch-action: pan-y`) |
| Footer | `class`、默认插槽 | - | 操作区 |
### DrawerHandle
| Prop | 类型 | 默认值 | 描述 |
| -------- | --------------------------- | ---------- | ------------------------------------ |
| `class` | `string \| Array \| Object` | - | CSS 类 |
| 默认插槽 | - | 内置手柄条 | 自定义手柄视觉;省略时渲染默认手柄条 |
固定 `aria-hidden="true"`。
### DrawerCloseTrigger / DrawerClose
| 部件 | Prop | 描述 |
| ------------ | -------------------------------- | ------------------------------------------- |
| CloseTrigger | `variant`、`isDisabled`、`class` | 右上角 X,点击关闭 |
| Close | `as`、`asChild`、`isDisabled` | 包裹任意控件以关闭;替代上游 `slot="close"` |
### 上游差异
| 上游 React | Vue |
| ------------------------ | ------------------------------ |
| `Button slot="close"` | `DrawerClose as-child` |
| Dialog render props | 作用域插槽 `{ close, isOpen }` |
| `className` / `children` | `class` / 默认插槽 |
| `onPress` | `@click` |
| Content / Dialog 职责 | 保留分离 |
## 无障碍
- `role="dialog"`,标题经 `aria-labelledby` 关联真实 Heading
- Handle `aria-hidden`
- 拖动关闭与 ESC / 外部点击可独立配置
## 相关组件
- [Modal 模态框](./modal)
- [AlertDialog 警告对话框](./alert-dialog)
@@ -0,0 +1,63 @@
<script setup lang="ts">
import {
AlertDialog,
AlertDialogBackdrop,
AlertDialogBody,
AlertDialogClose,
AlertDialogCloseTrigger,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
Button,
} from "@heroui-vue/components";
const VARIANT_LABELS = {
blur: "模糊",
opaque: "不透明",
transparent: "透明",
} as const;
const variants = ["opaque", "blur", "transparent"] as const;
</script>
<template>
<div class="flex flex-wrap gap-4">
<AlertDialog v-for="variant in variants" :key="variant">
<Button variant="secondary">{{ VARIANT_LABELS[variant] }}</Button>
<AlertDialogBackdrop :variant="variant">
<AlertDialogContainer>
<AlertDialogDialog class="sm:max-w-[400px]">
<AlertDialogCloseTrigger />
<AlertDialogHeader>
<AlertDialogIcon status="accent" />
<AlertDialogHeading>
背景:{{ VARIANT_LABELS[variant] }}
</AlertDialogHeading>
</AlertDialogHeader>
<AlertDialogBody>
<p>
{{
variant === "opaque"
? "不透明的深色背景会完全遮挡背后内容,让用户把注意力集中在对话框上。"
: variant === "blur"
? "模糊背景会柔和地虚化背后内容,同时保留一定的环境上下文。"
: "透明背景会完整保留背后内容,适合重要性较低的确认场景。"
}}
</p>
</AlertDialogBody>
<AlertDialogFooter>
<AlertDialogClose as-child>
<Button variant="tertiary">取消</Button>
</AlertDialogClose>
<AlertDialogClose as-child>
<Button>确认</Button>
</AlertDialogClose>
</AlertDialogFooter>
</AlertDialogDialog>
</AlertDialogContainer>
</AlertDialogBackdrop>
</AlertDialog>
</div>
</template>
@@ -0,0 +1,87 @@
<script setup lang="ts">
import {
AlertDialog,
AlertDialogBackdrop,
AlertDialogBody,
AlertDialogClose,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
Button,
} from "@heroui-vue/components";
</script>
<template>
<div class="flex max-w-2xl flex-col gap-8">
<div class="flex flex-col gap-2">
<h3 class="text-lg font-semibold">使用 AlertDialogClose</h3>
<p class="text-sm text-muted">
在对话框内用
<code>AlertDialogClose</code>
包裹按钮,点击后会自动关闭对话框。
</p>
<AlertDialog>
<Button variant="secondary">打开对话框</Button>
<AlertDialogBackdrop>
<AlertDialogContainer>
<AlertDialogDialog class="sm:max-w-[400px]">
<AlertDialogHeader>
<AlertDialogIcon status="accent" />
<AlertDialogHeading>使用 AlertDialogClose</AlertDialogHeading>
</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">使用作用域插槽 close</h3>
<p class="text-sm text-muted">
通过 Dialog 的作用域插槽获取
<code>close</code>
方法,从而完全控制关闭时机与方式,便于在关闭前加入校验等自定义逻辑。
</p>
<AlertDialog>
<Button variant="secondary">打开对话框</Button>
<AlertDialogBackdrop>
<AlertDialogContainer>
<AlertDialogDialog class="sm:max-w-[400px]">
<template #default="{ close }">
<AlertDialogHeader>
<AlertDialogIcon status="success" />
<AlertDialogHeading>使用作用域插槽 close</AlertDialogHeading>
</AlertDialogHeader>
<AlertDialogBody>
<p>
下方按钮使用插槽提供的
<code>close</code>
方法。
</p>
</AlertDialogBody>
<AlertDialogFooter>
<Button variant="tertiary" @click="close()">取消</Button>
<Button @click="close()">确认</Button>
</AlertDialogFooter>
</template>
</AlertDialogDialog>
</AlertDialogContainer>
</AlertDialogBackdrop>
</AlertDialog>
</div>
</div>
</template>
+149
View File
@@ -0,0 +1,149 @@
<script setup lang="ts">
import { ref } from "vue";
import { useOverlayState } from "@heroui-vue/components";
import {
AlertDialogBackdrop,
AlertDialogBody,
AlertDialogClose,
AlertDialogCloseTrigger,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
Button,
} from "@heroui-vue/components";
const isOpen = ref(false);
const state = useOverlayState();
</script>
<template>
<div class="flex max-w-md flex-col gap-8">
<div class="flex flex-col gap-3">
<h3 class="text-lg font-semibold text-foreground">配合 ref / v-model</h3>
<p class="text-sm leading-relaxed text-pretty text-muted">
使用 Vue 的
<code class="text-foreground">ref</code>
管理对话框开关,适合简单场景。
</p>
<div
class="flex flex-col items-start gap-3 rounded-2xl bg-surface p-4 shadow-sm"
>
<div class="flex w-full items-center justify-between">
<p class="text-xs text-muted">
状态:
<span class="font-mono font-medium text-foreground">
{{ isOpen ? "打开" : "关闭" }}
</span>
</p>
</div>
<div class="flex gap-2">
<Button size="sm" variant="secondary" @click="isOpen = true">
打开对话框
</Button>
<Button size="sm" variant="tertiary" @click="isOpen = !isOpen">
切换
</Button>
</div>
</div>
<AlertDialogBackdrop v-model:is-open="isOpen">
<AlertDialogContainer>
<AlertDialogDialog class="sm:max-w-[400px]">
<AlertDialogCloseTrigger />
<AlertDialogHeader>
<AlertDialogIcon status="accent" />
<AlertDialogHeading>由 ref 控制</AlertDialogHeading>
</AlertDialogHeader>
<AlertDialogBody>
<p>
该警告对话框由 Vue 的
<code>ref</code>
控制。
</p>
</AlertDialogBody>
<AlertDialogFooter>
<AlertDialogClose as-child>
<Button variant="tertiary">取消</Button>
</AlertDialogClose>
<AlertDialogClose as-child>
<Button>确认</Button>
</AlertDialogClose>
</AlertDialogFooter>
</AlertDialogDialog>
</AlertDialogContainer>
</AlertDialogBackdrop>
</div>
<div class="flex flex-col gap-3">
<h3 class="text-lg font-semibold text-foreground">
配合 useOverlayState()
</h3>
<p class="text-sm leading-relaxed text-pretty text-muted">
使用
<code class="text-foreground">useOverlayState</code>
获得更简洁的 API,内置
<code>open()</code>
、
<code>close()</code>
、
<code>toggle()</code>
等方法。
</p>
<div
class="flex flex-col items-start gap-3 rounded-2xl bg-surface p-4 shadow-sm"
>
<div class="flex w-full items-center justify-between">
<p class="text-xs text-muted">
状态:
<span class="font-mono font-medium text-foreground">
{{ state.isOpen.value ? "打开" : "关闭" }}
</span>
</p>
</div>
<div class="flex gap-2">
<Button size="sm" variant="secondary" @click="state.open()">
打开对话框
</Button>
<Button size="sm" variant="tertiary" @click="state.toggle()">
切换
</Button>
</div>
</div>
<AlertDialogBackdrop :state="state">
<AlertDialogContainer>
<AlertDialogDialog class="sm:max-w-[400px]">
<AlertDialogCloseTrigger />
<AlertDialogHeader>
<AlertDialogIcon status="success" />
<AlertDialogHeading>由 useOverlayState() 控制</AlertDialogHeading>
</AlertDialogHeader>
<AlertDialogBody>
<p>
<code>useOverlayState</code>
为常见操作提供专用方法,直接使用
<code>state.open()</code>
、
<code>state.close()</code>
或
<code>state.toggle()</code>
即可。
</p>
</AlertDialogBody>
<AlertDialogFooter>
<AlertDialogClose as-child>
<Button variant="tertiary">取消</Button>
</AlertDialogClose>
<AlertDialogClose as-child>
<Button>确认</Button>
</AlertDialogClose>
</AlertDialogFooter>
</AlertDialogDialog>
</AlertDialogContainer>
</AlertDialogBackdrop>
</div>
</div>
</template>
@@ -0,0 +1,76 @@
<script setup lang="ts">
import { IconArrowUp, IconSparkles } from "@tabler/icons-vue";
import {
AlertDialog,
AlertDialogBackdrop,
AlertDialogBody,
AlertDialogClose,
AlertDialogCloseTrigger,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
Button,
} from "@heroui-vue/components";
const animations = [
{
name: "运动学缩放",
icon: IconSparkles,
description:
"基于物理感的弹性缩放,模拟高阻尼弹簧:瞬态响应快、回落时间长,适合警告框与模态框。",
backdropClass:
"data-[entering]:duration-400 data-[entering]:ease-[cubic-bezier(0.16,1,0.3,1)] data-[exiting]:duration-200 data-[exiting]:ease-[cubic-bezier(0.7,0,0.84,0)]",
containerClass:
"data-[entering]:animate-in data-[entering]:fade-in-0 data-[entering]:zoom-in-95 data-[entering]:duration-400 data-[entering]:ease-[cubic-bezier(0.16,1,0.3,1)] data-[exiting]:animate-out data-[exiting]:fade-out-0 data-[exiting]:zoom-out-95 data-[exiting]:duration-200 data-[exiting]:ease-[cubic-bezier(0.7,0,0.84,0)]",
},
{
name: "流体滑入",
icon: IconArrowUp,
description:
"模拟在介质中运动并受流体阻力影响,避免机械式线性,更自然、更贴地。",
backdropClass:
"data-[entering]:duration-500 data-[entering]:ease-[cubic-bezier(0.25,1,0.5,1)] data-[exiting]:duration-200 data-[exiting]:ease-[cubic-bezier(0.5,0,0.75,0)]",
containerClass:
"data-[entering]:animate-in data-[entering]:fade-in-0 data-[entering]:slide-in-from-bottom-4 data-[entering]:duration-500 data-[entering]:ease-[cubic-bezier(0.25,1,0.5,1)] data-[exiting]:animate-out data-[exiting]:fade-out-0 data-[exiting]:slide-out-to-bottom-2 data-[exiting]:duration-200 data-[exiting]:ease-[cubic-bezier(0.5,0,0.75,0)]",
},
] as const;
</script>
<template>
<div class="flex flex-wrap gap-4">
<AlertDialog v-for="animation in animations" :key="animation.name">
<Button variant="secondary">{{ animation.name }}</Button>
<AlertDialogBackdrop :class="animation.backdropClass">
<AlertDialogContainer :class="animation.containerClass">
<AlertDialogDialog class="sm:max-w-[400px]">
<AlertDialogCloseTrigger />
<AlertDialogHeader>
<AlertDialogIcon status="accent">
<component
:is="animation.icon"
class="size-5"
aria-hidden="true"
/>
</AlertDialogIcon>
<AlertDialogHeading>{{ animation.name }} 动画</AlertDialogHeading>
</AlertDialogHeader>
<AlertDialogBody>
<p class="mt-1">{{ animation.description }}</p>
</AlertDialogBody>
<AlertDialogFooter>
<AlertDialogClose as-child>
<Button variant="tertiary">关闭</Button>
</AlertDialogClose>
<AlertDialogClose as-child>
<Button>再试一次</Button>
</AlertDialogClose>
</AlertDialogFooter>
</AlertDialogDialog>
</AlertDialogContainer>
</AlertDialogBackdrop>
</AlertDialog>
</div>
</template>
@@ -0,0 +1,52 @@
<script setup lang="ts">
import { IconAlertTriangle } from "@tabler/icons-vue";
import {
AlertDialog,
AlertDialogBackdrop,
AlertDialogBody,
AlertDialogClose,
AlertDialogCloseTrigger,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
Button,
} from "@heroui-vue/components";
</script>
<template>
<AlertDialog>
<Button variant="danger">删除账户</Button>
<AlertDialogBackdrop
class="bg-linear-to-t from-red-950/90 via-red-950/50 to-transparent dark:from-red-950/95 dark:via-red-950/60"
variant="blur"
>
<AlertDialogContainer>
<AlertDialogDialog class="sm:max-w-[420px]">
<AlertDialogCloseTrigger />
<AlertDialogHeader class="items-center text-center">
<AlertDialogIcon status="danger">
<IconAlertTriangle class="size-5" aria-hidden="true" />
</AlertDialogIcon>
<AlertDialogHeading>要永久删除账户吗?</AlertDialogHeading>
</AlertDialogHeader>
<AlertDialogBody>
<p>
此操作无法撤销。你的数据、设置与内容将从服务器永久清除。醒目的红色背景用于强调该决定的严重性与不可逆性。
</p>
</AlertDialogBody>
<AlertDialogFooter class="flex-col-reverse">
<AlertDialogClose as-child>
<Button class="w-full">保留账户</Button>
</AlertDialogClose>
<AlertDialogClose as-child>
<Button class="w-full" variant="danger">永久删除</Button>
</AlertDialogClose>
</AlertDialogFooter>
</AlertDialogDialog>
</AlertDialogContainer>
</AlertDialogBackdrop>
</AlertDialog>
</template>
@@ -0,0 +1,49 @@
<script setup lang="ts">
import { IconLockOpen } from "@tabler/icons-vue";
import {
AlertDialog,
AlertDialogBackdrop,
AlertDialogBody,
AlertDialogClose,
AlertDialogCloseTrigger,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
Button,
} from "@heroui-vue/components";
</script>
<template>
<AlertDialog>
<Button variant="secondary">重置密码</Button>
<AlertDialogBackdrop>
<AlertDialogContainer>
<AlertDialogDialog class="sm:max-w-[400px]">
<AlertDialogCloseTrigger />
<AlertDialogHeader>
<AlertDialogIcon status="warning">
<IconLockOpen class="size-5" aria-hidden="true" />
</AlertDialogIcon>
<AlertDialogHeading>要重置密码吗?</AlertDialogHeading>
</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>
</template>
@@ -0,0 +1,73 @@
<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>
</AlertDialogBody>
<AlertDialogFooter>
<AlertDialogClose as-child>
<Button variant="tertiary">取消</Button>
</AlertDialogClose>
<AlertDialogClose as-child>
<Button>确认</Button>
</AlertDialogClose>
</AlertDialogFooter>
</AlertDialogDialog>
</AlertDialogContainer>
</AlertDialogBackdrop>
</AlertDialog>
</div>
</div>
</template>
@@ -0,0 +1,55 @@
<script setup lang="ts">
import {
AlertDialog,
AlertDialogBackdrop,
AlertDialogBody,
AlertDialogClose,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
Button,
} from "@heroui-vue/components";
</script>
<template>
<AlertDialog>
<Button variant="secondary">退出登录</Button>
<AlertDialogBackdrop
class="bg-overlay/50 dark:bg-overlay/60"
variant="blur"
>
<AlertDialogContainer>
<AlertDialogDialog
class="relative overflow-hidden border border-border/80 bg-surface shadow-2xl ring-1 ring-accent/10 sm:max-w-[400px] dark:border-border/90 dark:bg-surface dark:ring-accent/15"
>
<div
aria-hidden="true"
class="pointer-events-none absolute inset-x-0 top-0 h-24 bg-linear-to-b from-accent/6 to-transparent dark:from-accent/10"
/>
<AlertDialogHeader class="relative">
<AlertDialogIcon status="accent" />
<AlertDialogHeading>确定要退出账户吗?</AlertDialogHeading>
</AlertDialogHeader>
<AlertDialogBody class="relative">
<p class="text-muted">
您将在此设备上退出登录。除非已保存到云端,否则
<strong class="text-foreground">Acme 工作区</strong>
中未保存的工作可能会丢失。
</p>
</AlertDialogBody>
<AlertDialogFooter>
<AlertDialogClose as-child>
<Button variant="tertiary">保持登录</Button>
</AlertDialogClose>
<AlertDialogClose as-child>
<Button>退出登录</Button>
</AlertDialogClose>
</AlertDialogFooter>
</AlertDialogDialog>
</AlertDialogContainer>
</AlertDialogBackdrop>
</AlertDialog>
</template>
@@ -0,0 +1,64 @@
<script setup lang="ts">
import { IconTrash } from "@tabler/icons-vue";
import {
AlertDialog,
AlertDialogBackdrop,
AlertDialogBody,
AlertDialogClose,
AlertDialogCloseTrigger,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
AlertDialogTrigger,
Button,
} from "@heroui-vue/components";
</script>
<template>
<AlertDialog>
<AlertDialogTrigger
class="group flex items-center gap-3 rounded-2xl bg-surface p-4 shadow-xs select-none hover:bg-surface-secondary"
>
<div
class="flex size-12 shrink-0 items-center justify-center rounded-xl bg-danger-soft text-danger-soft-foreground"
>
<IconTrash class="size-6" aria-hidden="true" />
</div>
<div class="flex flex-1 flex-col gap-0.5">
<p class="text-sm font-semibold">删除条目</p>
<p class="text-xs text-muted">永久移除此条目</p>
</div>
</AlertDialogTrigger>
<AlertDialogBackdrop>
<AlertDialogContainer>
<AlertDialogDialog class="sm:max-w-[400px]">
<AlertDialogCloseTrigger />
<AlertDialogHeader>
<AlertDialogIcon status="danger">
<IconTrash class="size-5" aria-hidden="true" />
</AlertDialogIcon>
<AlertDialogHeading>要删除此条目吗?</AlertDialogHeading>
</AlertDialogHeader>
<AlertDialogBody>
<p>
使用
<code>AlertDialogTrigger</code>
可在标准按钮之外自定义触发区域。此示例展示带图标与说明文字的卡片式触发器。
</p>
</AlertDialogBody>
<AlertDialogFooter>
<AlertDialogClose as-child>
<Button variant="tertiary">取消</Button>
</AlertDialogClose>
<AlertDialogClose as-child>
<Button variant="danger">删除条目</Button>
</AlertDialogClose>
</AlertDialogFooter>
</AlertDialogDialog>
</AlertDialogContainer>
</AlertDialogBackdrop>
</AlertDialog>
</template>
+48
View File
@@ -0,0 +1,48 @@
<script setup lang="ts">
import {
AlertDialog,
AlertDialogBackdrop,
AlertDialogBody,
AlertDialogClose,
AlertDialogCloseTrigger,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
Button,
} from "@heroui-vue/components";
</script>
<template>
<AlertDialog>
<Button variant="danger">删除项目</Button>
<AlertDialogBackdrop>
<AlertDialogContainer>
<AlertDialogDialog class="sm:max-w-[400px]">
<AlertDialogCloseTrigger />
<AlertDialogHeader>
<AlertDialogIcon status="danger" />
<AlertDialogHeading>要永久删除项目吗?</AlertDialogHeading>
</AlertDialogHeader>
<AlertDialogBody>
<p>
此操作将永久删除
<strong>我的精彩项目</strong>
及其全部数据,且无法撤销。
</p>
</AlertDialogBody>
<AlertDialogFooter>
<AlertDialogClose as-child>
<Button variant="tertiary">取消</Button>
</AlertDialogClose>
<AlertDialogClose as-child>
<Button variant="danger">删除项目</Button>
</AlertDialogClose>
</AlertDialogFooter>
</AlertDialogDialog>
</AlertDialogContainer>
</AlertDialogBackdrop>
</AlertDialog>
</template>
@@ -0,0 +1,105 @@
<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>
@@ -0,0 +1,66 @@
<script setup lang="ts">
import {
AlertDialog,
AlertDialogBackdrop,
AlertDialogBody,
AlertDialogClose,
AlertDialogCloseTrigger,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
Button,
} from "@heroui-vue/components";
const PLACEMENT_LABELS = {
auto: "自动",
bottom: "底部",
center: "居中",
top: "顶部",
} as const;
const placements = ["auto", "top", "center", "bottom"] as const;
</script>
<template>
<div class="flex flex-wrap gap-4">
<AlertDialog v-for="placement in placements" :key="placement">
<Button variant="secondary">{{ PLACEMENT_LABELS[placement] }}</Button>
<AlertDialogBackdrop>
<AlertDialogContainer :placement="placement">
<AlertDialogDialog class="sm:max-w-[400px]">
<AlertDialogCloseTrigger />
<AlertDialogHeader>
<AlertDialogIcon status="accent" />
<AlertDialogHeading>
{{
placement === "auto"
? "自动定位"
: `${PLACEMENT_LABELS[placement]}位置`
}}
</AlertDialogHeading>
</AlertDialogHeader>
<AlertDialogBody>
<p>
{{
placement === "auto"
? "在移动端默认靠近底部,在桌面端居中,以获得更合适的阅读与操作体验。"
: `对话框将锚定在视口的「${PLACEMENT_LABELS[placement]}」区域。重要确认通常使用居中 placement 以吸引最多注意。`
}}
</p>
</AlertDialogBody>
<AlertDialogFooter>
<AlertDialogClose as-child>
<Button variant="tertiary">取消</Button>
</AlertDialogClose>
<AlertDialogClose as-child>
<Button>确认</Button>
</AlertDialogClose>
</AlertDialogFooter>
</AlertDialogDialog>
</AlertDialogContainer>
</AlertDialogBackdrop>
</AlertDialog>
</div>
</template>
+69
View File
@@ -0,0 +1,69 @@
<script setup lang="ts">
import { IconRocket } from "@tabler/icons-vue";
import {
AlertDialog,
AlertDialogBackdrop,
AlertDialogBody,
AlertDialogClose,
AlertDialogCloseTrigger,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
Button,
} from "@heroui-vue/components";
const SIZE_LABELS = {
cover: "通栏",
lg: "大",
md: "中",
sm: "小",
xs: "超小",
} as const;
const sizes = ["xs", "sm", "md", "lg", "cover"] as const;
</script>
<template>
<div class="flex flex-wrap gap-4">
<AlertDialog v-for="size in sizes" :key="size">
<Button variant="secondary">{{ SIZE_LABELS[size] }}</Button>
<AlertDialogBackdrop>
<AlertDialogContainer :size="size">
<AlertDialogDialog>
<AlertDialogCloseTrigger />
<AlertDialogHeader>
<AlertDialogIcon class="bg-default text-foreground">
<IconRocket aria-hidden="true" class="size-5" />
</AlertDialogIcon>
<AlertDialogHeading>
尺寸:{{ SIZE_LABELS[size] }}
</AlertDialogHeading>
</AlertDialogHeader>
<AlertDialogBody>
<p v-if="size === 'cover'">
此警告框使用
<code>cover</code>
尺寸:在移动端与桌面端保留边距铺满可视区域,仍保持圆角与标准内边距。
</p>
<p v-else>
此警告框使用
<code>{{ size }}</code>
尺寸。在移动端各尺寸都会接近全宽以便阅读;在桌面端则对应不同的最大宽度。
</p>
</AlertDialogBody>
<AlertDialogFooter>
<AlertDialogClose as-child>
<Button variant="tertiary">取消</Button>
</AlertDialogClose>
<AlertDialogClose as-child>
<Button>确认</Button>
</AlertDialogClose>
</AlertDialogFooter>
</AlertDialogDialog>
</AlertDialogContainer>
</AlertDialogBackdrop>
</AlertDialog>
</div>
</template>
+85
View File
@@ -0,0 +1,85 @@
<script setup lang="ts">
import {
AlertDialog,
AlertDialogBackdrop,
AlertDialogBody,
AlertDialogClose,
AlertDialogCloseTrigger,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
Button,
} from "@heroui-vue/components";
const examples = [
{
actions: { cancel: "保持登录", confirm: "退出登录" },
body: "退出后需要重新登录才能访问账户,未保存的更改将丢失。",
classNames: "bg-accent-soft text-accent-soft-foreground",
header: "要退出当前账户吗?",
status: "accent",
trigger: "退出登录",
},
{
actions: { cancel: "稍后再说", confirm: "标记完成" },
body: "将把该任务标记为完成并通知所有成员,任务会移入已完成列表。",
classNames: "bg-success-soft text-success-soft-foreground",
header: "要完成此任务吗?",
status: "success",
trigger: "完成任务",
},
{
actions: { cancel: "继续编辑", confirm: "放弃更改" },
body: "你有未保存的更改,放弃后将永久丢失。确定要放弃吗?",
classNames: "bg-warning-soft text-warning-soft-foreground",
header: "要放弃未保存的更改吗?",
status: "warning",
trigger: "放弃更改",
},
{
actions: { cancel: "取消", confirm: "删除账户" },
body: "将永久删除你的账户并从服务器移除全部数据,此操作不可恢复。",
classNames: "bg-danger-soft text-danger-soft-foreground",
header: "要删除账户吗?",
status: "danger",
trigger: "删除账户",
},
] as const;
</script>
<template>
<div class="flex flex-wrap gap-4">
<AlertDialog v-for="example in examples" :key="example.status">
<Button :class="example.classNames">{{ example.trigger }}</Button>
<AlertDialogBackdrop>
<AlertDialogContainer>
<AlertDialogDialog class="sm:max-w-[400px]">
<AlertDialogCloseTrigger />
<AlertDialogHeader>
<AlertDialogIcon :status="example.status" />
<AlertDialogHeading>{{ example.header }}</AlertDialogHeading>
</AlertDialogHeader>
<AlertDialogBody>
<p>{{ example.body }}</p>
</AlertDialogBody>
<AlertDialogFooter>
<AlertDialogClose as-child>
<Button variant="tertiary">{{ example.actions.cancel }}</Button>
</AlertDialogClose>
<AlertDialogClose as-child>
<Button
:variant="example.status === 'danger' ? 'danger' : 'primary'"
>
{{ example.actions.confirm }}
</Button>
</AlertDialogClose>
</AlertDialogFooter>
</AlertDialogDialog>
</AlertDialogContainer>
</AlertDialogBackdrop>
</AlertDialog>
</div>
</template>
@@ -0,0 +1,54 @@
<script setup lang="ts">
import {
Button,
Drawer,
DrawerBackdrop,
DrawerBody,
DrawerClose,
DrawerCloseTrigger,
DrawerContent,
DrawerDialog,
DrawerFooter,
DrawerHandle,
DrawerHeader,
DrawerHeading,
} from "@heroui-vue/components";
const VARIANT_LABELS = {
blur: "模糊",
opaque: "不透明",
transparent: "透明",
} as const;
const variants = ["opaque", "blur", "transparent"] as const;
</script>
<template>
<div class="flex flex-wrap gap-4">
<Drawer v-for="variant in variants" :key="variant">
<Button variant="secondary">{{ VARIANT_LABELS[variant] }}</Button>
<DrawerBackdrop :variant="variant">
<DrawerContent>
<DrawerDialog>
<DrawerHandle />
<DrawerCloseTrigger />
<DrawerHeader>
<DrawerHeading>背景:{{ VARIANT_LABELS[variant] }}</DrawerHeading>
</DrawerHeader>
<DrawerBody>
<p>
此抽屉使用
<code>{{ variant }}</code>
背景变体。
</p>
</DrawerBody>
<DrawerFooter>
<DrawerClose as-child>
<Button class="w-full">关闭</Button>
</DrawerClose>
</DrawerFooter>
</DrawerDialog>
</DrawerContent>
</DrawerBackdrop>
</Drawer>
</div>
</template>
+43
View File
@@ -0,0 +1,43 @@
<script setup lang="ts">
import {
Button,
Drawer,
DrawerBackdrop,
DrawerBody,
DrawerClose,
DrawerContent,
DrawerDialog,
DrawerFooter,
DrawerHeader,
DrawerHeading,
} from "@heroui-vue/components";
</script>
<template>
<Drawer>
<Button variant="secondary">打开抽屉</Button>
<DrawerBackdrop>
<DrawerContent placement="right">
<DrawerDialog>
<DrawerHeader>
<DrawerHeading>抽屉标题</DrawerHeading>
</DrawerHeader>
<DrawerBody>
<p>
这是一个从屏幕边缘滑入的抽屉,并通过流畅的 CSS
过渡呈现动画效果。可拖动标题或页脚区域关闭。
</p>
</DrawerBody>
<DrawerFooter>
<DrawerClose as-child>
<Button variant="secondary">取消</Button>
</DrawerClose>
<DrawerClose as-child>
<Button>确认</Button>
</DrawerClose>
</DrawerFooter>
</DrawerDialog>
</DrawerContent>
</DrawerBackdrop>
</Drawer>
</template>
+128
View File
@@ -0,0 +1,128 @@
<script setup lang="ts">
import { ref } from "vue";
import {
Button,
DrawerBackdrop,
DrawerBody,
DrawerClose,
DrawerCloseTrigger,
DrawerContent,
DrawerDialog,
DrawerFooter,
DrawerHeader,
DrawerHeading,
useOverlayState,
} from "@heroui-vue/components";
const isOpen = ref(false);
const state = useOverlayState();
</script>
<template>
<div class="flex max-w-md flex-col gap-8">
<div class="flex flex-col gap-3">
<h3 class="text-lg font-semibold text-foreground">配合 ref</h3>
<p class="text-sm leading-relaxed text-pretty text-muted">
使用 Vue 的
<code class="text-foreground">ref</code>
管理抽屉开关。
</p>
<div
class="flex flex-col items-start gap-3 rounded-2xl bg-surface p-4 shadow-sm"
>
<p class="text-xs text-muted">
状态:
<span class="font-mono font-medium text-foreground">
{{ isOpen ? "打开" : "关闭" }}
</span>
</p>
<div class="flex gap-2">
<Button size="sm" variant="secondary" @click="isOpen = true">
打开抽屉
</Button>
<Button size="sm" variant="tertiary" @click="isOpen = !isOpen">
切换
</Button>
</div>
</div>
<DrawerBackdrop v-model:is-open="isOpen">
<DrawerContent placement="right">
<DrawerDialog>
<DrawerCloseTrigger />
<DrawerHeader>
<DrawerHeading>由 ref 控制</DrawerHeading>
</DrawerHeader>
<DrawerBody>
<p>
该抽屉由 Vue 的
<code>ref</code>
控制。
</p>
</DrawerBody>
<DrawerFooter>
<DrawerClose as-child>
<Button variant="secondary">关闭</Button>
</DrawerClose>
</DrawerFooter>
</DrawerDialog>
</DrawerContent>
</DrawerBackdrop>
</div>
<div class="flex flex-col gap-3">
<h3 class="text-lg font-semibold text-foreground">
配合 useOverlayState()
</h3>
<p class="text-sm leading-relaxed text-pretty text-muted">
使用
<code class="text-foreground">useOverlayState</code>
获得
<code>open()</code>
、
<code>close()</code>
、
<code>toggle()</code>
等方法。
</p>
<div
class="flex flex-col items-start gap-3 rounded-2xl bg-surface p-4 shadow-sm"
>
<p class="text-xs text-muted">
状态:
<span class="font-mono font-medium text-foreground">
{{ state.isOpen.value ? "打开" : "关闭" }}
</span>
</p>
<div class="flex gap-2">
<Button size="sm" variant="secondary" @click="state.open()">
打开抽屉
</Button>
<Button size="sm" variant="tertiary" @click="state.toggle()">
切换
</Button>
</div>
</div>
<DrawerBackdrop :state="state">
<DrawerContent placement="right">
<DrawerDialog>
<DrawerCloseTrigger />
<DrawerHeader>
<DrawerHeading>由 useOverlayState() 控制</DrawerHeading>
</DrawerHeader>
<DrawerBody>
<p>
<code>useOverlayState</code>
为常见操作提供专用方法。
</p>
</DrawerBody>
<DrawerFooter>
<DrawerClose as-child>
<Button variant="secondary">关闭</Button>
</DrawerClose>
</DrawerFooter>
</DrawerDialog>
</DrawerContent>
</DrawerBackdrop>
</div>
</div>
</template>
+40
View File
@@ -0,0 +1,40 @@
<script setup lang="ts">
import {
Button,
Drawer,
DrawerBackdrop,
DrawerBody,
DrawerClose,
DrawerContent,
DrawerDialog,
DrawerFooter,
DrawerHeader,
DrawerHeading,
} from "@heroui-vue/components";
</script>
<template>
<Drawer>
<Button variant="secondary">打开筛选</Button>
<DrawerBackdrop variant="blur">
<DrawerContent placement="right">
<DrawerDialog class="border-l border-border/80 bg-surface">
<DrawerHeader>
<DrawerHeading class="text-foreground">筛选</DrawerHeading>
</DrawerHeader>
<DrawerBody>
<p class="text-sm text-muted">按状态、负责人或日期缩小结果范围。</p>
</DrawerBody>
<DrawerFooter>
<DrawerClose as-child>
<Button variant="secondary">取消</Button>
</DrawerClose>
<DrawerClose as-child>
<Button>应用</Button>
</DrawerClose>
</DrawerFooter>
</DrawerDialog>
</DrawerContent>
</DrawerBackdrop>
</Drawer>
</template>
+67
View File
@@ -0,0 +1,67 @@
<script setup lang="ts">
import {
IconBell,
IconHome,
IconMail,
IconMenu2,
IconSearch,
IconSettings,
IconUser,
} from "@tabler/icons-vue";
import {
Button,
Drawer,
DrawerBackdrop,
DrawerBody,
DrawerCloseTrigger,
DrawerContent,
DrawerDialog,
DrawerHeader,
DrawerHeading,
} from "@heroui-vue/components";
const navItems = [
{ icon: IconHome, label: "首页" },
{ icon: IconSearch, label: "搜索" },
{ icon: IconBell, label: "通知" },
{ icon: IconMail, label: "消息" },
{ icon: IconUser, label: "个人资料" },
{ icon: IconSettings, label: "设置" },
] as const;
</script>
<template>
<Drawer>
<Button variant="secondary">
<IconMenu2 aria-hidden="true" class="size-4" />
菜单
</Button>
<DrawerBackdrop>
<DrawerContent placement="left">
<DrawerDialog>
<DrawerCloseTrigger />
<DrawerHeader>
<DrawerHeading>导航</DrawerHeading>
</DrawerHeader>
<DrawerBody>
<nav class="flex flex-col gap-1">
<button
v-for="item in navItems"
:key="item.label"
class="flex items-center gap-3 rounded-xl px-3 py-2.5 text-sm text-foreground transition-colors hover:bg-default"
type="button"
>
<component
:is="item.icon"
class="size-5 text-muted"
aria-hidden="true"
/>
{{ item.label }}
</button>
</nav>
</DrawerBody>
</DrawerDialog>
</DrawerContent>
</DrawerBackdrop>
</Drawer>
</template>
@@ -0,0 +1,42 @@
<script setup lang="ts">
import {
Button,
Drawer,
DrawerBackdrop,
DrawerBody,
DrawerClose,
DrawerContent,
DrawerDialog,
DrawerFooter,
DrawerHeader,
DrawerHeading,
} from "@heroui-vue/components";
</script>
<template>
<Drawer>
<Button variant="secondary">重要操作</Button>
<DrawerBackdrop :is-dismissable="false">
<DrawerContent>
<DrawerDialog>
<DrawerHeader>
<DrawerHeading>确认操作</DrawerHeading>
</DrawerHeader>
<DrawerBody>
<p>
此抽屉无法通过点击外部或拖拽关闭。你必须使用下方按钮之一来完成操作。
</p>
</DrawerBody>
<DrawerFooter>
<DrawerClose as-child>
<Button variant="secondary">取消</Button>
</DrawerClose>
<DrawerClose as-child>
<Button>确认</Button>
</DrawerClose>
</DrawerFooter>
</DrawerDialog>
</DrawerContent>
</DrawerBackdrop>
</Drawer>
</template>
+61
View File
@@ -0,0 +1,61 @@
<script setup lang="ts">
import {
Button,
Drawer,
DrawerBackdrop,
DrawerBody,
DrawerClose,
DrawerCloseTrigger,
DrawerContent,
DrawerDialog,
DrawerFooter,
DrawerHandle,
DrawerHeader,
DrawerHeading,
} from "@heroui-vue/components";
const PLACEMENT_LABELS = {
bottom: "底部",
left: "左侧",
right: "右侧",
top: "顶部",
} as const;
const placements = ["bottom", "top", "left", "right"] as const;
</script>
<template>
<div class="flex flex-wrap gap-4">
<Drawer v-for="placement in placements" :key="placement">
<Button variant="secondary">{{ PLACEMENT_LABELS[placement] }}</Button>
<DrawerBackdrop>
<DrawerContent :placement="placement">
<DrawerDialog>
<DrawerCloseTrigger />
<DrawerHandle v-if="placement === 'bottom'" />
<DrawerHeader>
<DrawerHeading>
{{ PLACEMENT_LABELS[placement] }}抽屉
</DrawerHeading>
</DrawerHeader>
<DrawerBody>
<p>
此抽屉从屏幕
<strong>{{ PLACEMENT_LABELS[placement] }}</strong>
边缘滑入。
</p>
</DrawerBody>
<DrawerFooter>
<DrawerClose as-child>
<Button variant="secondary">取消</Button>
</DrawerClose>
<DrawerClose as-child>
<Button>完成</Button>
</DrawerClose>
</DrawerFooter>
<DrawerHandle v-if="placement === 'top'" />
</DrawerDialog>
</DrawerContent>
</DrawerBackdrop>
</Drawer>
</div>
</template>
@@ -0,0 +1,48 @@
<script setup lang="ts">
import {
Button,
Drawer,
DrawerBackdrop,
DrawerBody,
DrawerClose,
DrawerCloseTrigger,
DrawerContent,
DrawerDialog,
DrawerFooter,
DrawerHandle,
DrawerHeader,
DrawerHeading,
} from "@heroui-vue/components";
</script>
<template>
<Drawer>
<Button variant="secondary">条款与条件</Button>
<DrawerBackdrop>
<DrawerContent>
<DrawerDialog>
<DrawerHandle />
<DrawerCloseTrigger />
<DrawerHeader>
<DrawerHeading>条款与条件</DrawerHeading>
</DrawerHeader>
<DrawerBody>
<p v-for="i in 20" :key="i" class="mb-3">
段落 {{ i }}:Lorem ipsum dolor sit amet, consectetur adipiscing
elit. Nullam pulvinar risus non risus hendrerit venenatis.
Pellentesque sit amet hendrerit risus, sed porttitor quam.
</p>
</DrawerBody>
<DrawerFooter>
<DrawerClose as-child>
<Button variant="secondary">拒绝</Button>
</DrawerClose>
<DrawerClose as-child>
<Button>接受</Button>
</DrawerClose>
</DrawerFooter>
</DrawerDialog>
</DrawerContent>
</DrawerBackdrop>
</Drawer>
</template>
+58
View File
@@ -0,0 +1,58 @@
<script setup lang="ts">
import {
Button,
Drawer,
DrawerBackdrop,
DrawerBody,
DrawerClose,
DrawerCloseTrigger,
DrawerContent,
DrawerDialog,
DrawerFooter,
DrawerHeader,
DrawerHeading,
Input,
Label,
TextField,
} from "@heroui-vue/components";
</script>
<template>
<Drawer>
<Button variant="secondary">编辑资料</Button>
<DrawerBackdrop>
<DrawerContent placement="right">
<DrawerDialog>
<DrawerCloseTrigger />
<DrawerHeader>
<DrawerHeading>编辑资料</DrawerHeading>
</DrawerHeader>
<DrawerBody>
<form class="flex flex-col gap-4">
<TextField class="w-full" name="name" type="text">
<Label>姓名</Label>
<Input placeholder="输入你的姓名" variant="secondary" />
</TextField>
<TextField class="w-full" name="email" type="email">
<Label>邮箱</Label>
<Input placeholder="输入你的邮箱" variant="secondary" />
</TextField>
<TextField class="w-full" name="bio">
<Label>简介</Label>
<Input placeholder="介绍一下你自己" variant="secondary" />
</TextField>
</form>
</DrawerBody>
<DrawerFooter>
<DrawerClose as-child>
<Button variant="secondary">取消</Button>
</DrawerClose>
<DrawerClose as-child>
<Button>保存更改</Button>
</DrawerClose>
</DrawerFooter>
</DrawerDialog>
</DrawerContent>
</DrawerBackdrop>
</Drawer>
</template>
+2 -2
View File
@@ -5,7 +5,7 @@
| 组件 | 状态 | 当前能力 / 差异 |
| -------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| accordion | 验证中(M23) | Accordion/Item/Heading/Trigger/Panel/Body/Indicator;10/10 基线例;surface/hideSeparator;复用组键协议 |
| alert-dialog | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
| alert-dialog | 验证中(M33) | 11 部件;role=alertdialog;默认不误关;14/14 基线例;Reka Dialog 底座 |
| autocomplete | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
| avatar | 验证中(最小实现) | Reka Avatar 加载/回退;size/color/variant;Image asChild;AvatarGroup 继承仅限直接子级 |
| avatar-group | 验证中(最小实现) | max 截断与自动计数、显式 Count 不受截断、isGrid、overlap clip/ring;默认无 role=group |
@@ -28,7 +28,7 @@
| date-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
| date-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
| date-range-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
| drawer | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
| drawer | 验证中(M34) | 11 部件;四方向拖动关闭(30%/0.5px/ms);9/9 基线例;Content/Dialog 职责分离 |
| progress-bar | 验证中(M18) | ProgressBar/Output/Track/Fill;7/7 基线例;确定/未知进度、min/max/formatOptions/valueLabel;custom-value 的 NumberField/Select 为原生临时控件 |
| progress-circle | 验证中(M19) | ProgressCircle/Track/TrackCircle/FillCircle;7/7 基线例;圆环几何可覆盖;与 ProgressBar 共用取值语义 |
| time-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+17
View File
@@ -261,3 +261,20 @@ Modal / Popover / Tooltip 公共迁移与全部 26 个基线预览已接入,
## LISTBOX-01 接续
ListBox 已完成公共首轮实现,见 [报告](migrations/LISTBOX-01-list-box.md)。后续 Select / ComboBox 等可沿用 typed key、接受值模型、项内文本作用域与完整数据集合;不能把独立 ListBox 的 action/选择直接当作 Select 的关闭与表单契约。Select 的十九个预览、唯一提交层、字段名称、SSR 展示元数据、清除和嵌套定位仍归集成人实施。
## M33–M34 首轮复核补充(2026-10-23)
本批尚未验收,先读 [M33–M34 复核与返修要求](migrations/M33-M34-review.md)。当前应继续原任务分支返修,不能开始下一组件或把未提交源码带到新分支。
- CSS transition 与 animation 不能互换生命周期假设;安装版 Presence 的卸载策略必须以实际源码和浏览器验证,最终节点消失不能证明退出动画正确。
- 拖动关闭属于提案;父级拒绝后仍打开的面板应复位。动态禁用/换方向、拥有指针、用户取消、节点替换与捕获释放均要覆盖。
- 逐个挂载示例不等于同页共存;测试名称中的 outside/flick 必须有对应真实操作,报告不能扩大覆盖范围。
- 演示数量齐全不等于文档齐全;各部件 API、事件/插槽、全局 CSS、类/状态表和中文标题仍按固定正文逐项核对。
### M33–M34 第二轮补充
第二轮仍未验收,见 [复核报告与返修提示词](migrations/M33-M34-review-2.md)。原5项失败已修复,但新增2项退出期间手势回归失败。阶段标记必须跟随真正运行动画的节点;正常释放捕获与取消在途手势须区分,关闭后Presence保留的节点不得继续拖动。减少动画要检查最终选择器优先级与内联回弹;上游MDX标记、文档插槽和示例CSS要按Vue实际能力与文档引擎适配。
## M33–M34 最终收口与下一批
原7项失败已修复,集成人补旧节点清理/退出中重开回归、真实outside、23例同页与独立tarball消费;实际边界见[验收记录](migrations/M33-M34-acceptance.md)。后续必须先读[本轮经验](migrations/M33-M34-lessons.md)。下一批安排为[M35 Toast → M36 Table](migrations/M35-M36-toast-table-prompt.md),从最新main新开分支;历史返修说明不再要求继续旧任务。
+29
View File
@@ -0,0 +1,29 @@
# M33–M34 最终复核与集成范围
2026-10-23;固定HeroUI3.2.6/ce90ea3。原任务分支feat/m33-m34-alert-dialog-drawer,基于9f44ffb。首轮和第二轮报告保留历史失败证据,不再代表最终状态。
## 本批可接受范围
AlertDialog与Drawer的公开部件、Props/变体/命名导出、默认关闭策略、源样式与14+9个基线演示已接入。框架差异:Vue命名部件、作用域插槽、open/isOpen事件与Close适配;Reka负责统一弹层焦点/锁/Presence;Drawer关键帧适配源transition,保持250ms进入/200ms退出与方向、缓动及transform拖动合成。
前两轮7个失败probe均已修复,未削弱断言。集成人最终补充:节点替换明确清理旧元素(避免读取新ref);退出中重开清除旧位移;新增2个相应回归;AlertDialog真实outside点击策略;23个演示同一Vue应用共存检查;清除剩余MDX标记、恢复两页完整源全局CSS与Tailwind章节顺序。修改保持组件私有,不改共享overlay内核。
## 已执行验证
- 最终补充前完整测试44文件/625项通过;再新增AlertDialog outside用例单独通过(11项),合计626项,最终整合main后重新跑完整套件计数。
- typecheck与build:docs(含两库构建)通过;只有既存文档chunk体积提示。
- 独立/private/tmp/heroui-m33-consumer从实际tarball安装:所有公开部件ESM导出、真正node SSR、CSS入口/Drawer关键帧;NodeNext与bundler严格类型正反例均通过。持久夹具在tests/package。
- 5173重点浏览器:Drawer底部/右侧进入关键帧与阶段结束,关闭后无残留面板、焦点回触发器、body指针/滚动限制释放;AlertDialog真实标题关联、默认Escape不关。并非逐个手点23个演示。
- 同页23个演示挂载无Vue warning/重复ID;Drawer两个同时打开实例标题关联回归通过。速度用可控时钟与低于距离阈值的位移隔离验证;原有共享弹层嵌套焦点/锁回归随全套执行。
## 明确限制
没有宣称逐像素、真机触屏、读屏、Nuxt或本批公开组件全部水合场景已验收。默认动画生命周期通过源码状态链、浏览器重点检查与已有回归验证;未建立覆盖每个自定义不同时长、所有重开时序的自动浏览器动效套件。Portal沿用既有SSR延迟挂载策略,服务端不输出浮层主体;本批tarball SSR验证默认关闭树,不冒充所有打开场景水合检查。兼容矩阵继续使用“验证中”,不声称整库完全兼容。
## 下一批
[M35 Toast → M36 Table](M35-M36-toast-table-prompt.md),从集成后的最新main另开feat/m35-m36-toast-table;集成人继续集合/日期/颜色三类基建,其他AI不改其共享协议。迁移经验见[M33–M34 lessons](M33-M34-lessons.md)。
## 合并验证补充
整合远程65db60a的集合基建与ListBox后,pnpm test为49文件/682项通过;typecheck、build:docs通过。未覆盖或删除ListBox导出、样式、导航、测试/SSR脚本。下一批可消费已合入的私有集合协议,不自行复制另一份通用集合状态。
+14
View File
@@ -0,0 +1,14 @@
# M33–M34 迁移与复核经验
先读本文件,再读各轮复核的原始证据;不要只看最后的绿色数量。固定基线 HeroUI 3.2.6 / ce90ea3。
1. **动画跟随真实所有者。** Content 管定位不代表它运行动画。阶段标记、getComputedStyle、animationend 与 Presence 必须指向真实动画节点;事件冒泡的 target/currentTarget 不能被忽略。检索到 keyframes 不等于动画正确。transition 到 animation 适配保留源时长、缓动、方向和拖动合成。
2. **完成手势与取消手势分开。** pointerup 后的正常 lostpointercapture 不能清掉已交给退出动画的位移。程序关闭后 Presence 仍保留 DOM,旧 move/up 不得继续改变它;退出中重开应清除旧位移。节点替换时明确对旧元素释放捕获、移除监听、清理样式,不读已经指向新节点的 ref。
3. **提案不等于接受。** 受控父级拒绝关闭时要回弹并可重试;接受关闭时保留视觉连续性。动态禁用、方向改变、异指针、取消和卸载都是实际交互路径。
4. **减少动画检查最终级联。** 媒体查询存在不代表覆盖生效。进入/退出的高优先级选择器、内联拖动回弹和动态偏好都要考虑。
5. **先验证底座,再声明能力。** 本批不直接运行 Reka 的全部同名默认行为;默认关闭策略、role、placement/size归属和事件透传逐项对齐源。底座缺口留最小用例,不另建全局锁、焦点栈或 document 关闭管理器。
6. **测试与报告必须相符。** 测试叫 outside 就真的点击外部;速度用可控时钟、隔离距离条件。未开面板的“HTML非空”不证明焦点、锁、名称或退出行为。全部演示同一父应用共存,不逐个卸载后声称无ID冲突。不同环境的 SSR/水合/几何/动效验证分别记录。
7. **文档不是删节版。** 预览数量齐全仍需原中文标题、顺序、全部部件API、事件/作用域插槽、状态/类和完整全局CSS。MDX专属[!toc]不要直接显示在VitePress标题中。文档宣称插槽时,模板中必须真正渲染该插槽;不凭相似名称补能力。
8. **产物严格类型是独立检查。** 不能只用工作区源码alias。打包安装到独立目录,验证ESM、node SSR、CSS入口及NodeNext/bundler正反例;错误方向/尺寸/策略必须报错,不能悄悄退化any。保留tests/package夹具。
原始问题:[首轮](M33-M34-review.md)、[第二轮](M33-M34-review-2.md)。最终范围与限制以验收报告为准。
+61
View File
@@ -0,0 +1,61 @@
# M33–M34 第二轮复核:仍需修正
2026-10-23;feat/m33-m34-alert-dialog-drawer / 9f44ffb;未提交、未合并、未推送。当前任务继续返修,不进入下一批组件。
## 已确认修复
上轮 tests/m33-m34-review.probe.test.ts 五项断言保留并通过:受控拒绝拖动关闭后复位、动态禁用、切换方向、指针归属和 pointerdown capture 取消。文档增加了部件、事件与插槽说明,示例标题已恢复。新增探针之前完整 pnpm test 为42文件/618项通过,pnpm typecheck 通过。
## 尚存问题
### P1:进入动画的阶段标记仍被提前清除
位置:packages/vue/src/components/drawer/DrawerContent.vue:20、packages/styles/components/drawer.css:178。
useOverlayAnimation 观察的是 Content 元素,Content 自己没有 animation。共享 hook 在 nextTick 检查 animationName=none 时清除 entering;真正的进入动画却由这个父标记驱动 Dialog。结果是标记清除时取消子面板的动画,不能完整运行250ms。子节点 animationend 冒泡到 Content 也会被 hook 的 target/currentTarget 检查忽略。
修复应让阶段状态绑定真实运行动画的元素并由其结束/取消管理。不要给父节点加一个无意义固定计时来掩盖问题;不要只检索 keyframes 名称就宣布适配完成。四方向、首次打开与退出中重开都需要检查实际阶段持续性和几何。
### P1:正常失去指针捕获会清掉已经提交给退出动画的位移
位置:packages/vue/src/components/drawer/useDrawerDrag.ts:150、186。
pointerup 已将 activePointerId 设为 null,保留 transform 并请求关闭;浏览器正常释放 capture 后的 lostpointercapture 又无条件进入 cancelGesture,清掉 transform 和 transition。拖动关闭会在退出动画中跳回,违反“从当前位置连续退出”的约定。
新增 tests/m33-m34-lifecycle-review.probe.test.ts 第一项使用真实元素,保留节点模拟 Presence 退出期:拖动80px、接受关闭,再发送 lostpointercapture,transform 从 translateY(80px) 变为空,失败。必须区分仍在进行的手势取消与已经完成手势的正常捕获释放;不能删除 lost capture 处理逃避在途取消。
### P1:程序关闭后保留的退出节点仍接受旧拖动
位置:useDrawerDrag.ts:108、214。
目前只监听 dismissable/placement,没响应已接受 open=false;onPointerMove 也不检查关闭状态。拖动20px后程序关闭,退出节点保留期间继续移动,transform 会从20px改为80px。
新增 lifecycle probe 第二项复现失败。接受关闭时结束手势所有权并释放捕获,后续 move/up 不再操作退出节点;关闭期间的退出位移处理应与上一项一致,不能强行重置引入跳变。节点替换也检查旧节点的捕获释放:watch(dialogRef) 回调执行时 dialogRef 已是新节点,当前 cancelGesture 读取新引用,无法正确清理旧节点的捕获/样式。
### P2:reduced-motion 被更高优先级方向动画覆盖
位置:packages/styles/components/drawer.css:146、178–215。
减少动画规则位于 .hv-drawer__dialog 下,选择器优先级只有一个类;后面的进入选择器(父类+状态+子类)和退出选择器(类+两个属性)优先级更高,animation:none 不生效。回弹的内联 transform transition 也固定300ms,未考虑 reduced-motion。
让减少动画规则覆盖所有进入/退出/回弹路径,验证最终计算样式;不可只看 CSS 中存在媒体查询。修复需同时保留普通偏好下的原始时长与缓动。
### P2:文档补齐后仍有内容与实际实现不一致
- DrawerHandle 默认插槽被记录为可自定义视觉,但 DrawerHandle.vue 模板没有 slot,自定义内容被吞掉。按固定基线决定补实现或纠正文档,不宣称不存在的能力。
- 两页标题保留了上游 MDX 专属的 [!toc],VitePress 页面实际显示“基础类 [!toc]”等文字;转换为本文档引擎支持的表达。
- 两页“全局 CSS”都缩为一条 rounded-2xl,原基线的遮罩/边框/阴影/header/close-trigger 等示例内容仍被删减;Tailwind CSS 子标题也没有恢复。按固定正文还原,仅适配 hv- 和 Vue。
- DrawerBackdrop 的 open/isOpen/defaultOpen 行类型和默认值空白,合并部件表也缺少完整类型。事件/插槽应清晰区分,补遗漏的 update:isOpen;继续维持全宽换行表格。
- 原报告已经指出的实际 outside、可控时钟 fast-flick、全部示例同一父应用共存、嵌套焦点/锁等仍没有对应充分新增回归。新增两实例唯一ID是进展,不等于23例同页验证。当前含 outside 的测试仍只发送 Escape;fast-flick 覆盖声明尚未有独立用例。
## 本轮验证边界
- 既有42文件/618项通过;新增两个生命周期探针均失败,未 skip、未削弱已有断言。
- 类型检查通过;库与文档构建结果见 verification 的本轮记录。
- 5173重点打开默认Drawer并检查Content/Dialog的阶段与动画属性;未逐个点击全部演示。进入阶段问题的结论来自组件、hook与CSS的完整状态链,不能以点击工具返回后的静态截图判断250ms动画完整性。
- 实施者报告的“800ms后仍运行”没有被归因为 IAB 或 will-change;目前证据不足以作这种归因,也不能标记退出已完整验收。需要验证真实动画结束后DOM卸载/锁释放/焦点恢复,而不仅是存在退出关键帧。
- 真机触屏、读屏、Nuxt、完整逐像素和本批独立tarball消费未验收。
## 返修提示词
继续 feat/m33-m34-alert-dialog-drawer,不切分支、不覆盖当前未提交修改、不开始新组件。先读本报告、M33-M34-review.md、M30-M32-lessons.md与迁移约定。保留两份probe,先修正Drawer真实动画所有者与进入/退出/reduced-motion生命周期,再处理完成手势与取消手势、程序关闭和节点替换的捕获清理。补全实际outside/独立速度/同页实例/嵌套焦点锁回归,恢复两份文档的基线内容与真实API。运行全套测试、类型、构建及适用的独立产物检查;浏览器重点复验四方向进入/退出、拖动连续性、快速重开和焦点/锁释放。更新报告中的真实证据后交回复核,不自行合main或推送。
+65
View File
@@ -0,0 +1,65 @@
# M33–M34 首轮复核:待修正
日期:2026-10-23。复核目录 heroui-vue,分支 feat/m33-m34-alert-dialog-drawer,起点 9f44ffb。没有提交、合并或推送本批;heroui-vue-core 的未提交集合工作未触碰。
## 阻止验收的问题
### P1:Drawer 的 transition 没有接入 Presence,退出直接卸载
位置:packages/styles/components/drawer.css:45、packages/vue/src/components/drawer/DrawerContent.vue、DrawerDialog.vue。
Backdrop 只有 opacity transition,Dialog 只有 translate transition;现有 useOverlayAnimation 与安装版 Reka Presence 依赖 animationName/animationend。Reka usePresence 在 animationName=none 时直接 UNMOUNT;Content 的 entering 也因没有 animation 而由 nextTick 清掉,不能以此证明正确的首帧生命周期。
5173 浏览器重点检查:默认 Drawer 的三个节点 animationName 均为 none,Backdrop transition 为 opacity 0.25s,Dialog 为 translate 0.25s;点击取消后读取时面板与遮罩均已不存在。结合安装版 Presence 源码,可确认没有为约定的 200ms 退出保留节点。不能只断言最终节点消失。
修复:使用与现有 Presence 匹配的局部关键帧适配,或提供明确的 transition 生命周期桥接方案;保持源时长/缓动/方向与拖动位移连续性。不要加固定超时或另建全局锁。复核四方向、快速重开、退出中重开、reduced-motion、不同动画时长,以及锁/焦点恢复时机。共享内核确有缺口先交最小失败场景给集成人。
### P1:受控拒绝拖动关闭后,面板留在拖动位置
位置:packages/vue/src/components/drawer/useDrawerDrag.ts:125。
open=true 的受控父级拒绝 false 请求;200px 高面板拖动80px并释放后仍打开,但 transform=translateY(80px)、transition=none。只测试“拒绝打开后可重试”没有覆盖拒绝关闭。
回归:tests/m33-m34-review.probe.test.ts 的 controlled rejected drag close。应根据已接受状态复位;兼顾接受关闭时位移连续、延后接受和后续重试,不能直接当请求已经生效。
### P1:动态禁用或切换 placement 不取消在途手势
位置:useDrawerDrag.ts:78、105、155。仅 pointerdown 读取 isDismissable,没有监听配置变化。
拖动80px后将 isDismissable 改为 false,pointerup 仍请求关闭;底部拖动20px后改为 left,旧 translateY(20px) 与 transition=none 仍残留。对应两个新增失败用例。
修复:配置改变、接受关闭、节点替换/卸载均取消旧手势并清理其捕获与局部样式;不要让旧轴继续控制新方向。
### P2:未记录 owning pointerId,其他指针可完成手势
位置:useDrawerDrag.ts:78、105、140。
pointerId=1 按下,pointerId=2 移动80px并释放,仍产生 false 请求。取消和 lost capture 同样需要匹配所有者;节点替换/卸载时还要移除 lostpointercapture(现实现只添加不移除)。新增 another pointer 用例失败。
### P2:调用方取消事件不能阻止拖动
位置:useDrawerDrag.ts:49、78。原生监听没有检查 defaultPrevented。
DrawerDialog 的 pointerdown.capture 调用 preventDefault 后,仍可启动、位移和请求关闭。新增 caller cancellation 用例复现。继续采用 Vue DOM 的事件顺序/取消约定,补处理器数组、capture 和 stopImmediatePropagation,不手工遍历用户回调。
### P2:文档仍是缩减版,不能按演示数量宣称完成
位置:apps/docs/components/drawer.md:97、126 以及 alert-dialog.md 的样式/API 段落。
固定中文正文为每个部件提供 API,包含 Backdrop 受控状态/变更事件、Dialog ARIA、Trigger、Header/Heading/Body/Footer/Handle/CloseTrigger 等。Vue 页将多个部件压成“其他部件”名称列表;没有完整的事件/作用域插槽说明,缺失全局 CSS、CSS 类与交互状态表;标题如“弹出位置/受控模式/搭配表单/导航抽屉”被随意缩写。
修复:按固定中文正文逐节恢复,框架差异转为 Vue 的命名导出、class、事件与插槽;不能机械保留 React 类型,也不能直接删除契约。全部23个预览数量已齐,仍须逐项比对内容。表格全宽、长内容换行、不横滚、不缩字号。
## 验证与证据边界
- 新增 probe 前 pnpm test:41 文件 / 611 项通过。
- pnpm typecheck 通过;pnpm build:docs(包含库构建)通过,只有 chunk 体积提示。
- 新增 tests/m33-m34-review.probe.test.ts:5项实际手势/状态回归,当前全部失败,保留待修;不是跳过或 expected failure。
- 原 tests/alert-dialog.test.ts / drawer.test.ts 的演示测试逐个挂载又卸载,仅检查 HTML 非空/无 warning,尚未覆盖要求的同一父应用共存、打开后的 ID/焦点/锁;“outside click”用例实际只发送 Escape。需要补真实对应交互,不用改名代替验收。
- verification.md 中“fast-flick 速度阈值仅有单元级覆盖”缺少独立可控时钟用例;现有大位移/小位移测试没有隔离距离与速度条件。报告应同步证据或撤回该覆盖声明。
- 本轮浏览器只重点检查 Drawer 动画类型和默认关闭;没有逐个点击23个演示,也未执行真机触屏、读屏、Nuxt、逐像素或本批独立 tarball 消费。
- AlertDialog 的 role、默认策略及静态基础用例已有正向结果,但嵌套、焦点恢复、实际 outside、动态 ARIA、同页实例、自定义动画不同持续时间的证据仍不充分,本轮不单独标记家族验收完成。
## 交回要求
继续当前任务分支修复 M33/M34,不开新组件、不重拉覆盖当前未提交源码。先阅读本报告与 M30-M32-lessons.md;保留并修复 probe,补上述缺口,运行全套回归/类型/构建及适用独立产物正反类型检查,浏览器只验证高风险生命周期/四方向拖动/滚动/嵌套焦点。同步迁移报告与 verification 的实际证据,再交回复核。通过并集成 main 后,下一批才 fetch/pull 最新 main、新建任务分支。
+34
View File
@@ -0,0 +1,34 @@
# M33 AlertDialog
日期:2026-10-23。分支 `feat/m33-m34-alert-dialog-drawer`,起点 `9f44ffb`。上游 HeroUI 3.2.6 / `ce90ea3`。
## 契约与部件
`AlertDialog` / `AlertDialogRoot`、Trigger、Backdrop、Container、Dialog、Header、Heading、Body、Footer、Icon、CloseTrigger、Close。`alertDialogVariants`:size xs/sm/md/lg/cover;status default/accent/success/warning/danger;variant opaque/blur/transparent。
- `Dialog` 渲染 `role="alertdialog"`。
- **Backdrop 默认 `isDismissable=false`、`isKeyboardDismissDisabled=true`**(与 Modal 相反),二者独立可配。
- Icon 默认 SVG 自基线 icons.tsx(Apache-2.0);status 驱动配色。
- 复用既有 overlay 协议(useOverlayState / OverlayDialog* / Presence),未改共享内核。
## 示例(14/14)
default、statuses、placements、sizes、controlled、custom-icon、custom-trigger、backdrop-variants、custom-backdrop、dismiss-behavior、close-methods、custom-animations、custom-portal、custom-styles。预览/复制/高亮共用 SFC;自定义图标 Tabler。
## M30–M32 lessons 映射
| Lessons | 本批回归 |
| ---------------- | ------------------------------------------------- |
| 显式 ARIA 优先级 | `aria-labelledby` 显式覆盖自动标题 |
| 拒绝后可重试 | 受控拒绝 open 后再次请求仍发出 |
| 事件/关闭原因 | CloseTrigger 与 AlertDialogClose 真实关闭 |
| 同页 ID | 14 演示挂载无 warning;标题 ID 绑定真实 role 节点 |
| 默认不误关 | ESC 默认不关,显式开启后可关 |
## 测试
`tests/alert-dialog.test.ts` 10 项。`pnpm test` 含本文件。
## 未验证
真机触屏、读屏、Nuxt 水合、逐像素、独立安装、浏览器全量点击(仅自动化 DOM)。
+63
View File
@@ -0,0 +1,63 @@
# M34 Drawer
日期:2026-10-23。分支 `feat/m33-m34-alert-dialog-drawer`,起点 `9f44ffb`。上游 HeroUI 3.2.6 / `ce90ea3`。
## 契约与部件
`Drawer` / `DrawerRoot`、Trigger、Backdrop、Content、Dialog、Header、Heading、Body、Footer、Handle、CloseTrigger、Close。`drawerVariants`:placement bottom/top/left/right;variant opaque/blur/transparent。
- **Content** 负责边缘定位与滑入滑出;**Dialog** 是可交互面板(拖动、焦点、ARIA)。职责保留。
- 拖动算法对齐基线:8px 激活;位移 >30% 尺寸或速度 >0.5px/ms 关闭;否则回弹。拖动自 Handle/Header/Footer 启动,Body 排除。
- `isDismissable=false` 禁用拖动与外部点击;ESC 由 `isKeyboardDismissDisabled` 独立控制。
- 复用 overlay 协议;未采用 Vaul Vue,未把 snaps 加入公开契约。
## 示例(9/9)
basic、placements、non-dismissable、scrollable-content、controlled、with-form、navigation、backdrop-variants、custom-styles。
## Lessons 映射
| Lessons | 本批回归 |
| --------- | -------------------------------------------------------- |
| 拒绝/重试 | 受控拒绝 open 后可重试 |
| 生命周期 | 拖动关闭保持 transform;小位移回弹不关 |
| 动态配置 | isDismissable 动态决定拖动绑定 |
| 同页 | 9 演示挂载无 warning |
| 真实 DOM | 断言 dialog 节点存在/消失、placement class、heading 关联 |
## 底座审计
Reka Dialog/ModalOverlay 提供焦点、锁、Escape、Presence。拖动为组件私有(`useDrawerDrag`),阈值与上游一致。jsdom 无 PointerEvent,测试用 MouseEvent 模拟;`setPointerCapture` 有 try/catch。
## 测试
`tests/drawer.test.ts` 8 项(含拖动 30% 关闭 / 小位移回弹)。
## 未验证
真机触屏拖动、读屏、Nuxt 水合、逐像素、独立安装、浏览器四方向实操。
## 首轮复核返修(2026-10-23)
按 [M33–M34 复核](./M33-M34-review.md) 修复;`tests/m33-m34-review.probe.test.ts` **5/5 通过**。
1. **Presence 动画桥**:Drawer 进入/退出改为 CSS `@keyframes` 动画(非 transition),与 Reka Presence 的 `animationName` 契约匹配;`translate` 动画与拖动 `transform` 合成。源级测试断言 keyframes 存在。
2. **受控拒绝关闭**:拖动关闭请求被拒后 `nextTick` 回弹到原位,不残留 `transform`。
3. **配置变更取消手势**:`isDismissable` / `placement` 变化时取消在途拖动并清理样式与指针捕获。
4. **pointerId 归属**:仅 owning pointer 可移动/释放;`lostpointercapture` 可解绑。
5. **调用方取消**:`pointerdown` 的 `defaultPrevented` 阻止启动。
6. **文档**:恢复完整部件 API(含受控事件、ARIA、插槽)、CSS 类与交互状态表;示例标题对齐上游(弹出位置/受控模式/搭配表单/导航抽屉)。
测试:probe 5 + drawer 10(含动画源契约、同页双实例唯一 ID)。
## 第二轮复核返修(2026-10-23)
按 [M33–M34 第二轮复核](./M33-M34-review-2.md) 修复;`m33-m34-lifecycle-review.probe.test.ts` **2/2 通过**,原 probe 5/5 保持。
1. **动画所有者**:阶段标记移到 Dialog(真正运行动画的节点),`useOverlayAnimation` 不再在 Content 上提前清 `entering`。
2. **lostpointercapture**:仅取消在途手势;已接受关闭(phase=dismissed)后释放捕获不清理退出位移。
3. **程序关闭**:open→false 时结束手势所有权,退出节点不再响应 move;保留已应用位移不跳变。
4. **节点替换**:ref 变更时在旧节点上释放捕获并解绑。
5. **reduced-motion**:提高选择器优先级覆盖四方向进入/退出;snapBack 尊重 reduce。
6. **文档**:去掉 `[!toc]`、补全全局 CSS/Tailwind、Backdrop 类型、Handle 默认插槽(省略时渲染默认手柄条)。
7. **测试**:独立时钟的慢速回弹与 fast-flick;真实 outside click(可关/不可关)。
@@ -0,0 +1,54 @@
# 下一批任务:M35 Toast → M36 Table
你在 heroui-vue 独立目录工作,文档5173。先完成Toast,再做Table;每个家族有独立契约/测试/报告,两个一起交回复核。不以组件多为由删能力、缺演示或只交静态外观。集成人在heroui-vue-core负责ListBox/Select、DateField/Calendar、ColorArea/ColorPicker三类基建;不进入相邻目录、不占5174。
## 先同步main,创建新任务分支
先看git status。M33/M34已由集成人处理,不能将它们的未提交修改带进本批。三张旧本地截图acc-open.png、disc-demo1.png、disc-demo2.png保留、不提交、不删除。若有其他未提交源码,说明归属,不reset、不覆盖。
```sh
git fetch origin
git switch main
git pull --ff-only origin main
git switch -c feat/m35-m36-toast-table
```
不能快进则交代分叉,不能强推或reset --hard。记录起点SHA。本批完成停在任务分支交回复核,不自行合main或推送。后续新批次仍从最新main新开分支。
最新main已包含私有collection基建与ListBox四部件,阅读docs/decisions/collection-foundation.md与docs/migrations/LISTBOX-01-list-box.md;不要复制或改写集合内核。Select仍由集成人继续。
先读AGENTS.md、docs/migration-handoff.md、docs/migrations/M30-M32-lessons.md、M33-M34-lessons.md、M33-M34-acceptance.md、共享overlay/field/集合实际存在的协议。上游只读../heroui,固定HeroUI3.2.6/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960,不运行React包装Vue。
## M35 Toast
完整阅读react/components/toast/index.ts、toast.tsx、toast-queue.ts、constants.ts,styles中的CSS/tv,中文components/(overlays)/toast.mdx与全部中文demo。不要只实现一个setTimeout和通知卡片。
交付Toast/Root、ToastProvider、Content、Indicator、Title、Description、ActionButton、CloseButton、ToastQueue、toast/toastQueue、相应Props/队列内容与Promise类型、变体和公开常量;React复合导出转Vue命名导出。指示器可隐藏、loading、动作取消/关闭、内容渲染和队列实例的Vue边界需明确。React专属getQueue内部类型不能泄漏,兼容差异不能静默删除。
先审计安装版Reka Toast的真实行为、Provider/公告/焦点/暂停,与自有队列的适配;不能有两套倒计时同时关闭同一条。源基线默认timeout=4000、gap=12、可视上限3、width460、hotkey Alt+T,退出保留默认300ms是源队列明确契约,不同于任意写timeout代替Presence。视觉上限不等于删除超出上限的消息,源说明为旧消息隐藏但继续计时。所有默认值以实际源再次确认。
必须覆盖:add返回稳定key;update保留位置、timeout省略/0/重设;close/clear与onClose至多一次;pause/resume正确剩余时间;超限/退出期间增删;自定义队列隔离;销毁/HMR/订阅清理;Promise成功/失败/被提前关闭或替换后不能复活;SSR请求隔离,不能让模块全局队列泄漏跨请求通知。只在真正有需要时建私有Toast协议,不改全局overlay/field内核。
十一份基线预览:default、variants、placements、expanded、simple、custom-indicator、custom-toast、promise、callbacks、custom-queue、custom-styles。多行ComponentPreview也要纳入核对。六方向位置、折叠/展开、测量/层叠/退出/减少动画都需实际验证。
## M36 Table
完整核对react/components/table/index.ts、table.tsx,源CSS/tv,中文components/(data-display)/table.mdx、全部demo。先输出部件/API/集合与键盘语义审计,再实现;不把漂亮的原生table截图当成迁移完成。
部件至少逐项核对Table/Root、ScrollContainer、Content、Header、Column、Body、Row、Cell、Footer、ResizableContainer、ColumnResizer、LoadMore/LoadMoreContent、SortableColumnHeader、Collection及Props/SortDirection/变体。不要根据一份列表猜测全部公开导出,以上游index.ts为准。
保留基线默认/secondary、异步加载、排序、单选/多选/全选与部分选择、禁用行、稳定row/column key、受控拒绝/重试、动态增删/重排、展开行、分页、列宽调整、空状态、虚拟化、TanStack集成和自定义单元格。键盘/真实ARIA、焦点导航、交互元素与行操作互不抢事件;排序指示器不仅改变视觉,还要正确映射aria-sort与事件提案。列宽最小/最大、拖动取消/捕获释放、RTL和键盘调整需证据。虚拟化应验证真实滚动窗口与行索引,不只是CSS限高。
十三份基线预览:basic、secondary-variant、async-loading、sorting、selection、expandable-rows、pagination、column-resizing、empty-state、virtualization、tanstack-table、custom-cells、custom-styles;重新和固定正文核对顺序。
Collection转为Vue数据/插槽API,不能泄漏RAC Collection或复制一套通用集合注册内核。先看最新main中是否已有稳定集合协议,可消费已合入能力;若尚未有Table所需接口,做Table私有适配并记录边界,禁止改写ListBox/Select基础设施。基线TanStack示例使用Vue适配,限文档/可选集成,不强制基础包用户安装它;新增依赖先证明用途并记录声明/打包边界。遇到共享协议阻断交最小失败场景,不偷偷删功能或把缺失改写成“暂不支持”。
## 本批共同验收
- M33/M34多轮经验逐项映射到新组件的真实回归。计时/动画/Presence由真实所有者管理;keyframes存在不等于生命周期正确。受控提案与已接受状态、正常完成与取消、退出中重开、节点替换/卸载分开处理。
- 事件数组/capture/preventDefault/stopImmediatePropagation遵循Vue DOM语义,不能手工循环用户事件或覆盖事件。动态attrs/ID/locale/dir和显式ARIA优先级必须响应更新。
- 组件/文档样式、布局、文案、API、主题按固定基线。自定义图标用Tabler Vue,默认源图标移植记许可。全部预览/复制/高亮共用SFC;原中文标题/顺序/全局CSS/每部件API、事件、插槽和状态表保留。表格全宽、内容换行、不横向拖动、不缩字号;不把上游MDX特殊标记显示为正文。
- 同页挂载所有预览检查ID/实例串扰,重要交互断言真实role/焦点/事件/值/队列/锁,不能用HTML非空替代。浏览器只重点验时序/几何/拖动/虚拟化/焦点,不必逐个点击全部示例。
- pnpm test、typecheck、build、build:docs;真正node SSR与适用实际水合;独立tarball安装,ESM/CSS/SSR和NodeNext、bundler的类型正反例。保留已有M30–M34和NumberField/Slider回归及声明路径修复。
- 源样式与类型导出/导航/矩阵/脚本做增量修改,不整文件覆盖。共享overlay/field/choice/配置/打包链路由集成人维护,缺口先给具体失败场景。
- 分别写docs/migrations/M35-toast.md与M36-table.md:来源/完整契约/底座审计/演示/实际差异/验证命令和证据/未验证项/需要集成人处理的问题。未验证的读屏、真机、Nuxt、逐像素如实列出,不将构建通过称为完整兼容。
+6
View File
@@ -170,3 +170,9 @@ M18–M20 的标签桥接在 Vue 使用 indicator 注册表与 SSR 直接/原生
## LISTBOX-01(2026-10-23)
固定 ce90ea3 的 list-box / list-box-item / list-box-section 源码、CSS/tv,以及中文正文和九个预览。CSS/tv 按 hv- 移植,源勾选图形遵循原 Apache-2.0;文档图标用现有 Tabler Vue。原 alert 演示改为内联状态反馈,React render 改 as/插槽,Virtualizer/ListLayout 改 VueUse 固定行高虚拟化。依据、差异与限制见 [LISTBOX-01](migrations/LISTBOX-01-list-box.md)。
## M33–M34(2026-10-23)
- 固定ce90ea3的react/components/{alert-dialog,drawer}、styles对应CSS/tv、中文components/(overlays)正文与demos/cn:AlertDialog14例,Drawer9例。
- hv-命名空间保留源视觉数值,AlertDialog默认图标路径来自固定icons.tsx(Apache-2.0,原声明见third-party/HEROUI-LICENSE);演示自定义图标为Tabler Vue。
- Vue复用既有Reka Dialog/Presence/FocusScope/Portal,Drawer源transition改为同方向/时长/缓动的局部keyframes以适配Presence;拖动逻辑由源阈值适配Vue生命周期与受控状态。未修改上游或安装依赖实现。
+71
View File
@@ -647,3 +647,74 @@ typecheck、build:docs、build:playground、format、diff-check 与 dist 正反
- 最终 tarball 在 `/private/tmp/heroui-slider-consumer` 重新安装,ListBox ESM/SSR/CSS、NodeNext / bundler 严格正反例通过;并保留 NumberField/Slider、M30–M32 消费回归。泛型 Props 的非法模型/模式反例没有被删除或放宽。
- 5174 浏览器重点验证受控选择/Space、虚拟 End 到第 1000 项及 Home、连续 Liam 搜索、深浅色、鼠标后 Tab 返回原项与焦点环。1280×720 下九张表均为正文 736px,scrollWidth=clientWidth。
- 普通列表 SSR 的选中/ID/名称/描述与水合已验;虚拟 SSR 是容器,挂载后测量显示固定高度行。可变行高/虚拟分组、自动逐像素、读屏/触屏、移动视口和 Nuxt 未验收。详见 [LISTBOX-01](migrations/LISTBOX-01-list-box.md)。Select 公共组件未完成。
## M33–M34 AlertDialog / Drawer(2026-10-23,实施者,待复核)
- 分支 `feat/m33-m34-alert-dialog-drawer`,起点 `9f44ffb`(含 M30–M32 + NumberField/Slider)。
- AlertDialog:`role=alertdialog`,默认 isDismissable=false / isKeyboardDismissDisabled=true;14/14 演示。
- Drawer:四方向 + 拖动关闭(30% / 0.5px/ms);9/9 演示。
- `tests/alert-dialog.test.ts` 10 + `tests/drawer.test.ts` 8。
- 详见 [M33](./migrations/M33-alert-dialog.md)、[M34](./migrations/M34-drawer.md)。
- 浏览器重点验证、真机触屏、读屏、Nuxt 水合、逐像素、独立安装**未执行**。
### M33–M34 计数(实施者)
- `pnpm test` **41 文件 / 611**(含 SSR)
- `test:unit` 含 alert-dialog + drawer;typecheck / build:docs / build:playground / format 通过
- 分支 `feat/m33-m34-alert-dialog-drawer` @ `9f44ffb`;未提交
### M33–M34 浏览器重点实操(2026-10-23,实施者,IAB @ http://127.0.0.1:5173)
**AlertDialog**(/components/alert-dialog)
- 打开「删除项目」:`role=alertdialog` 可见,`aria-labelledby` 指向真实标题「要永久删除项目吗?」
- 默认按 **ESC 不关闭**;点击遮罩区不关闭
- 点击 CloseTrigger(X)可关闭
**Drawer**(/components/drawer)
- basic(right):打开后 placement=right,标题关联正确
- **向右拖动 >30% 宽度关闭**;**极小慢速拖动回弹不关**
- placements「底部」:Handle 存在且 `aria-hidden="true"`;**向下拖动关闭**
- placements「左侧」:**向左拖动关闭**
- 「重要操作」(isDismissable=false):拖动不关闭
- 聚焦后 **ESC 可关闭**
- 「条款与条件」正文 `overflow-y:auto`、`touch-action:pan-y`,End 键可滚到 scrollTop=300
未做:真机触屏、读屏、Nuxt 水合、逐像素、独立安装;fast-flick 速度阈值仅有单元级覆盖。
## M33–M34 复核返修(2026-10-23,实施者)
- `tests/m33-m34-review.probe.test.ts` **5/5 通过**(手势/受控拒绝/取消,断言未削弱)。
- drawer.test.ts 增至 10 项:动画源契约、同页双实例 ID。
- 文档已补全两份 API/样式/状态表与上游示例标题。
- jsdom 无 CSS 动画引擎,Presence 运行时延迟卸载需浏览器复验;源级 keyframes 契约已有测试。
### M33–M34 退出动画浏览器复验(IAB)
- 打开 Drawer 后点「取消」:立即采样到 `animationName=hv-drawer-out-to-right`、`data-exiting=true`、`data-state=closed`,**节点仍挂载**(Presence 已延迟卸载,不再瞬间移除)。
- 800ms 后节点仍在且 `animationPlayState=running`(时长 200ms),`animationend` 完成卸载**未在本轮复验通过**;可能与 IAB 合成层/will-change 有关,需集成人再确认。
- 源级 `@keyframes hv-drawer-out-*` 契约有单元测试覆盖。
## M33–M34 第二轮复核(集成人,2026-10-23)
- 结论:待修正;未提交、合并或推送。见 [第二轮复核及返修提示词](migrations/M33-M34-review-2.md)。
- 原5项probe通过,新增前完整测试42文件/618项通过;typecheck及build:docs(含库构建)通过,文档仅有既存chunk体积提示。
- 新增 tests/m33-m34-lifecycle-review.probe.test.ts 两项均失败:接受拖动关闭后lostpointercapture清掉退出位移;程序关闭后保留节点仍响应旧拖动。
- 源码/CSS复核发现进入阶段观察错误节点、reduced-motion优先级不足,以及文档插槽/MDX标记/全局CSS内容问题。重点浏览器检查默认Drawer,未全量点击示例;没有将未确认的动画现象归因为浏览器环境。
- 原有尚缺的outside/flick/嵌套焦点锁/全部示例同页与本批独立消费证据仍需补齐,不扩大验收声明。
## M33–M34 第二轮返修(2026-10-23,实施者)
- `m33-m34-lifecycle-review.probe.test.ts` **2/2**;`m33-m34-review.probe.test.ts` 5/5。
- `pnpm test` **43 文件 / 622**;typecheck / build:docs / build:playground / format 通过。
- 动画所有者已移到 Dialog;手势生命周期(拒绝/丢失捕获/程序关闭/替换)已覆盖。
- 浏览器四方向进入/退出完整性、快速重开、焦点锁释放仍待集成人复验。
## M33–M34 最终整合复核(集成人,2026-10-23)
- 原任务提交0ec20aa;整合远程65db60a的集合基建/ListBox后,完整49文件/682项通过,类型检查及build:docs(含两库)通过,仅既存chunk体积提示。
- 额外修正旧节点捕获释放与退出中重开位移,四项生命周期probe通过;AlertDialog真实outside新增回归与23例同一应用共存回归通过。
- 重点浏览器验证Drawer进入关键帧、阶段结束、关闭卸载/焦点/锁释放;AlertDialog标题、默认Escape策略、关闭焦点恢复,两页API表无内部横向溢出。
- 独立tarball在/private/tmp/heroui-m33-consumer通过ESM/node SSR/CSS与NodeNext、bundler正反类型;来源与未验收范围见[M33–M34最终记录](migrations/M33-M34-acceptance.md)。
- 最新main的ListBox与M33/M34共同保留;下一批Toast→Table,须先同步main并新开任务分支。
+1 -1
View File
@@ -15,7 +15,7 @@
"build:docs": "pnpm build && pnpm --filter @heroui-vue/docs build",
"typecheck": "vue-tsc --noEmit",
"test": "vitest run",
"test:unit": "vitest run tests/choice-demos.test.ts tests/choice-fields.test.ts tests/fieldset-search-field.test.ts tests/components.test.ts tests/composition.test.ts tests/docs-search.test.ts tests/button-demos.test.ts tests/aligned-components.test.ts tests/surface-link-spinner.test.ts tests/close-button-avatar-skeleton.test.ts tests/separator-kbd-chip.test.ts tests/badge-alert.test.ts tests/input-group.test.ts tests/field-docs-textarea.test.ts tests/field-foundation.test.ts tests/typography-empty-breadcrumbs.test.ts tests/progress-meter.test.ts tests/disclosure-accordion.test.ts tests/overlay-foundation.test.ts tests/modal.test.ts tests/popover-tooltip.test.ts tests/overlay-demos.test.ts tests/scroll-tabs.test.ts tests/button-toggle.test.ts tests/m26-review.probe.test.ts tests/toolbar.test.ts tests/m29-review.probe.test.ts tests/m30-m32-review.probe.test.ts tests/pagination.test.ts tests/header.test.ts tests/input-otp.test.ts tests/number-field-foundation.test.ts tests/number-field.test.ts tests/slider-foundation.test.ts tests/slider.test.ts tests/collection-state.test.ts tests/collection-foundation.test.ts tests/list-box.test.ts",
"test:unit": "vitest run tests/choice-demos.test.ts tests/choice-fields.test.ts tests/fieldset-search-field.test.ts tests/components.test.ts tests/composition.test.ts tests/docs-search.test.ts tests/button-demos.test.ts tests/aligned-components.test.ts tests/surface-link-spinner.test.ts tests/close-button-avatar-skeleton.test.ts tests/separator-kbd-chip.test.ts tests/badge-alert.test.ts tests/input-group.test.ts tests/field-docs-textarea.test.ts tests/field-foundation.test.ts tests/typography-empty-breadcrumbs.test.ts tests/progress-meter.test.ts tests/disclosure-accordion.test.ts tests/overlay-foundation.test.ts tests/modal.test.ts tests/popover-tooltip.test.ts tests/overlay-demos.test.ts tests/scroll-tabs.test.ts tests/button-toggle.test.ts tests/m26-review.probe.test.ts tests/toolbar.test.ts tests/m29-review.probe.test.ts tests/m30-m32-review.probe.test.ts tests/pagination.test.ts tests/header.test.ts tests/input-otp.test.ts tests/number-field-foundation.test.ts tests/number-field.test.ts tests/slider-foundation.test.ts tests/slider.test.ts tests/collection-state.test.ts tests/collection-foundation.test.ts tests/list-box.test.ts tests/alert-dialog.test.ts tests/drawer.test.ts tests/m33-m34-review.probe.test.ts tests/m33-m34-lifecycle-review.probe.test.ts tests/m33-m34-coexist.test.ts",
"test:ssr": "vitest run tests/ssr.test.ts tests/input-otp-ssr.test.ts tests/slider-foundation-ssr.test.ts tests/slider-ssr.test.ts tests/collection-foundation-ssr.test.ts tests/list-box-ssr.test.ts",
"format": "prettier --check .",
"format:fix": "prettier --write .",
+219
View File
@@ -0,0 +1,219 @@
/* Adapted from HeroUI ce90ea3. Copyright 2025 NextUI Inc.
* Apache-2.0; see third-party/HEROUI-LICENSE. hv- namespace and Vue/Reka adapters. */
/* -------------------------------------------------------------------------------------------------
* AlertDialog Component Styles
* Block: alert-dialog
* -----------------------------------------------------------------------------------------------*/
.hv-alert-dialog__trigger {
@apply inline-block cursor-(--cursor-interactive);
transition:
transform 250ms var(--ease-out-quart),
background-color 150ms var(--ease-smooth),
box-shadow 150ms var(--ease-out);
@apply motion-reduce:transition-none;
&:focus-visible:not([data-focused]),
&[data-focus-visible="true"] {
@apply status-focused;
}
&:disabled,
&[aria-disabled="true"] {
@apply status-disabled;
}
&:active,
&[data-pressed="true"] {
transform: scale(0.97);
}
}
.hv-alert-dialog__backdrop {
@apply fixed inset-0 z-(--z-index-overlay);
@apply flex flex-row items-center justify-center;
@apply h-(--visual-viewport-height) w-full;
&[data-entering="true"] {
@apply animate-in duration-150 ease-out fade-in-0;
}
&[data-exiting="true"] {
@apply animate-out duration-100 ease-out fade-out-0;
}
&[data-exiting="true"],
&[data-entering="true"] {
@apply will-change-[opacity];
@apply motion-reduce:animate-none;
}
}
.hv-alert-dialog__backdrop--transparent {
@apply bg-transparent;
}
.hv-alert-dialog__backdrop--opaque {
@apply bg-backdrop;
}
.hv-alert-dialog__backdrop--blur {
@apply bg-backdrop backdrop-blur-md;
}
.hv-alert-dialog__container {
@apply flex flex-col items-center;
@apply h-(--visual-viewport-height) w-full min-w-0 flex-1;
@apply p-4;
@apply sm:w-fit sm:p-10;
@apply pointer-events-none;
&[data-entering="true"] {
@apply animate-in duration-250 ease-out-quad fade-in-0 zoom-in-105;
&[data-placement="auto"] {
@apply slide-in-from-bottom-1;
@apply sm:slide-in-from-bottom-0;
}
&[data-placement="top"] {
@apply slide-in-from-top-1;
}
&[data-placement="center"] {
@apply slide-in-from-top-0;
}
&[data-placement="bottom"] {
@apply slide-in-from-bottom-1;
}
}
&[data-exiting="true"] {
@apply animate-out duration-100 ease-out-quad fade-out-0 zoom-out-95;
}
&[data-exiting="true"],
&[data-entering="true"] {
@apply will-change-[opacity,transform];
@apply motion-reduce:animate-none;
}
}
.hv-alert-dialog__dialog {
@apply relative;
@apply flex min-h-0 w-full flex-col;
@apply max-h-full;
@apply bg-overlay shadow-overlay outline-none;
border-radius: min(32px, var(--radius-3xl));
@apply p-6;
@apply overflow-clip;
@apply pointer-events-auto;
&[data-placement="auto"] {
@apply mt-auto;
@apply sm:my-auto;
}
&[data-placement="center"] {
@apply my-auto;
}
&[data-placement="bottom"] {
@apply mt-auto;
}
&[data-placement="top"] {
@apply mt-0;
}
}
.hv-alert-dialog__dialog--xs {
@apply max-w-xs;
}
.hv-alert-dialog__dialog--sm {
@apply max-w-sm;
}
.hv-alert-dialog__dialog--md {
@apply max-w-md;
}
.hv-alert-dialog__dialog--lg {
@apply max-w-lg;
}
.hv-alert-dialog__dialog--cover {
@apply h-full min-h-full w-full;
}
.hv-alert-dialog__header {
@apply flex flex-col gap-3;
@apply mb-0;
}
.hv-alert-dialog__heading {
@apply align-middle;
@apply text-base font-medium text-foreground;
}
.hv-alert-dialog__icon {
@apply flex items-center justify-center;
@apply size-10 shrink-0;
@apply rounded-3xl select-none;
[data-slot="alert-dialog-default-icon"] {
@apply box-content size-5;
}
}
.hv-alert-dialog__icon--default {
@apply bg-default text-foreground;
}
.hv-alert-dialog__icon--accent {
@apply bg-accent-soft text-accent-soft-foreground;
}
.hv-alert-dialog__icon--success {
@apply bg-success-soft text-success-soft-foreground;
}
.hv-alert-dialog__icon--warning {
@apply bg-warning-soft text-warning-soft-foreground;
}
.hv-alert-dialog__icon--danger {
@apply bg-danger-soft text-danger-soft-foreground;
}
.hv-alert-dialog__body {
@apply min-h-0 flex-1 scrollbar;
@apply text-sm leading-[1.43] text-muted;
@apply -m-[3px] my-0 p-[3px];
@apply overflow-y-auto overscroll-contain;
-webkit-overflow-scrolling: touch;
}
.hv-alert-dialog__footer {
@apply flex flex-row items-center justify-end gap-2;
@apply mt-0;
}
.hv-alert-dialog__close-trigger {
@apply absolute end-4 top-4;
}
.hv-alert-dialog__header + .hv-alert-dialog__body {
@apply mt-2;
}
.hv-alert-dialog__header + .hv-alert-dialog__footer {
@apply mt-5;
}
.hv-alert-dialog__body + .hv-alert-dialog__footer {
@apply mt-5;
}
+414
View File
@@ -0,0 +1,414 @@
/* Adapted from HeroUI ce90ea3. Copyright 2025 NextUI Inc.
* Apache-2.0; see third-party/HEROUI-LICENSE. hv- namespace and Vue/Reka adapters. */
/**
* Element: trigger - the element that opens the drawer
*/
.hv-drawer__trigger {
@apply inline-block cursor-(--cursor-interactive);
/**
* Transitions
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
*/
transition:
transform 250ms var(--ease-out-quart),
background-color 150ms var(--ease-smooth),
box-shadow 150ms var(--ease-out);
@apply motion-reduce:transition-none;
/* Focus state */
&:focus-visible:not([data-focused]),
&[data-focus-visible="true"] {
@apply status-focused;
}
/* Disabled state */
&:disabled,
&[aria-disabled="true"] {
@apply status-disabled;
}
/* Active/pressed state */
&:active,
&[data-pressed="true"] {
transform: scale(0.97);
}
}
/**
* Element: backdrop - the overlay behind the drawer
* Enter/exit use CSS animations (not transitions) so Reka Presence
* keeps the node until animationend instead of unmounting immediately.
*/
.hv-drawer__backdrop {
@apply fixed inset-0 z-(--z-index-overlay);
@apply h-(--visual-viewport-height) w-full;
opacity: 1;
&[data-entering="true"] {
animation: hv-drawer-backdrop-in 250ms cubic-bezier(0.32, 0.72, 0, 1);
}
&[data-exiting="true"] {
animation: hv-drawer-backdrop-out 200ms cubic-bezier(0.32, 0.72, 0, 1);
}
&[data-exiting="true"],
&[data-entering="true"] {
will-change: opacity;
}
@media (prefers-reduced-motion: reduce) {
animation: none;
}
}
/**
* Modifier: backdrop--transparent
*/
.hv-drawer__backdrop--transparent {
@apply bg-transparent;
}
/**
* Modifier: backdrop--opaque
*/
.hv-drawer__backdrop--opaque {
@apply bg-backdrop;
}
/**
* Modifier: backdrop--blur
*/
.hv-drawer__backdrop--blur {
@apply bg-backdrop backdrop-blur-md;
}
/**
* Element: content - the positioning wrapper for the drawer panel
*/
.hv-drawer__content {
@apply pointer-events-none;
@apply fixed inset-0 z-(--z-index-overlay) flex;
@apply h-(--visual-viewport-height) w-full min-w-0;
}
/**
* Modifier: content--bottom (default)
* Slides up from the bottom edge
*/
.hv-drawer__content--bottom {
@apply items-end;
}
/**
* Modifier: content--top
* Slides down from the top edge
*/
.hv-drawer__content--top {
@apply items-start;
}
/**
* Modifier: content--left
* Slides in from the left edge
*/
.hv-drawer__content--left {
@apply justify-start;
}
/**
* Modifier: content--right
* Slides in from the right edge
*/
.hv-drawer__content--right {
@apply justify-end;
}
/**
* Element: dialog - the drawer panel itself
* Enter/exit animate the `translate` property so drag can compose via `transform`.
*/
.hv-drawer__dialog {
@apply relative;
@apply flex flex-col;
@apply bg-overlay shadow-overlay outline-none;
@apply p-6;
@apply pointer-events-auto;
--drawer-enter-duration: 250ms;
--drawer-exit-duration: 200ms;
--drawer-enter-ease: cubic-bezier(0.32, 0.72, 0, 1);
--drawer-exit-ease: cubic-bezier(0.32, 0.72, 0, 1);
will-change: translate;
@media (prefers-reduced-motion: reduce) {
animation: none;
}
/* Bottom/top placement: full width, auto height */
&[data-placement="bottom"] {
@apply w-full;
@apply max-h-[85vh];
border-start-start-radius: min(32px, var(--radius-2xl));
border-start-end-radius: min(32px, var(--radius-2xl));
}
&[data-placement="top"] {
@apply w-full;
@apply max-h-[85vh];
border-end-start-radius: min(32px, var(--radius-2xl));
border-end-end-radius: min(32px, var(--radius-2xl));
}
/* Left/right placement: auto width, full height */
&[data-placement="left"] {
@apply h-full rounded-none;
@apply w-80 max-w-[85vw] sm:w-96;
}
&[data-placement="right"] {
@apply h-full rounded-none;
@apply w-80 max-w-[85vw] sm:w-96;
}
}
/* Enter/exit animations live on the dialog node (the real animation owner). */
.hv-drawer__dialog[data-entering="true"][data-placement="left"] {
animation: hv-drawer-in-from-left var(--drawer-enter-duration)
var(--drawer-enter-ease);
}
.hv-drawer__dialog[data-entering="true"][data-placement="right"] {
animation: hv-drawer-in-from-right var(--drawer-enter-duration)
var(--drawer-enter-ease);
}
.hv-drawer__dialog[data-entering="true"][data-placement="top"] {
animation: hv-drawer-in-from-top var(--drawer-enter-duration)
var(--drawer-enter-ease);
}
.hv-drawer__dialog[data-entering="true"][data-placement="bottom"] {
animation: hv-drawer-in-from-bottom var(--drawer-enter-duration)
var(--drawer-enter-ease);
}
.hv-drawer__dialog[data-exiting="true"][data-placement="left"] {
animation: hv-drawer-out-to-left var(--drawer-exit-duration)
var(--drawer-exit-ease);
}
.hv-drawer__dialog[data-exiting="true"][data-placement="right"] {
animation: hv-drawer-out-to-right var(--drawer-exit-duration)
var(--drawer-exit-ease);
}
.hv-drawer__dialog[data-exiting="true"][data-placement="top"] {
animation: hv-drawer-out-to-top var(--drawer-exit-duration)
var(--drawer-exit-ease);
}
.hv-drawer__dialog[data-exiting="true"][data-placement="bottom"] {
animation: hv-drawer-out-to-bottom var(--drawer-exit-duration)
var(--drawer-exit-ease);
}
/* Reduced motion must beat the direction-specific animation rules above. */
@media (prefers-reduced-motion: reduce) {
.hv-drawer__dialog[data-entering="true"],
.hv-drawer__dialog[data-exiting="true"],
.hv-drawer__dialog[data-entering="true"][data-placement="left"],
.hv-drawer__dialog[data-entering="true"][data-placement="right"],
.hv-drawer__dialog[data-entering="true"][data-placement="top"],
.hv-drawer__dialog[data-entering="true"][data-placement="bottom"],
.hv-drawer__dialog[data-exiting="true"][data-placement="left"],
.hv-drawer__dialog[data-exiting="true"][data-placement="right"],
.hv-drawer__dialog[data-exiting="true"][data-placement="top"],
.hv-drawer__dialog[data-exiting="true"][data-placement="bottom"] {
animation: none;
}
.hv-drawer__backdrop[data-entering="true"],
.hv-drawer__backdrop[data-exiting="true"] {
animation: none;
}
}
@keyframes hv-drawer-backdrop-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes hv-drawer-backdrop-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
@keyframes hv-drawer-in-from-left {
from {
translate: -100% 0;
}
to {
translate: 0 0;
}
}
@keyframes hv-drawer-in-from-right {
from {
translate: 100% 0;
}
to {
translate: 0 0;
}
}
@keyframes hv-drawer-in-from-top {
from {
translate: 0 -100%;
}
to {
translate: 0 0;
}
}
@keyframes hv-drawer-in-from-bottom {
from {
translate: 0 100%;
}
to {
translate: 0 0;
}
}
@keyframes hv-drawer-out-to-left {
from {
translate: 0 0;
}
to {
translate: -100% 0;
}
}
@keyframes hv-drawer-out-to-right {
from {
translate: 0 0;
}
to {
translate: 100% 0;
}
}
@keyframes hv-drawer-out-to-top {
from {
translate: 0 0;
}
to {
translate: 0 -100%;
}
}
@keyframes hv-drawer-out-to-bottom {
from {
translate: 0 0;
}
to {
translate: 0 100%;
}
}
.hv-drawer__dialog--top {
@apply pb-2;
.hv-drawer__handle {
@apply pb-0;
}
}
/**
* Element: header - the top section with the title
*/
.hv-drawer__header {
@apply flex flex-col gap-3;
@apply mb-0;
}
/**
* Element: heading - the main title text
*/
.hv-drawer__heading {
@apply align-middle;
@apply text-base font-medium text-foreground;
}
/**
* Element: body - the main content area
* touch-action: pan-y allows vertical scrolling while the dialog captures drag gestures
*/
.hv-drawer__body {
@apply min-h-0 flex-1 scrollbar;
@apply text-sm leading-[1.43] text-muted;
@apply -m-[3px] my-0 p-[3px];
@apply overflow-y-auto overscroll-contain;
-webkit-overflow-scrolling: touch;
}
/**
* Element: footer - the bottom action section
*/
.hv-drawer__footer {
@apply flex flex-row items-center justify-end gap-2;
@apply mt-0;
}
/**
* Element: handle - visual drag handle indicator
*/
.hv-drawer__handle {
@apply flex items-center justify-center;
@apply pb-2;
/* The handle bar */
& > [data-slot="drawer-handle-bar"] {
@apply h-1 w-9 rounded-xs;
@apply bg-separator;
}
}
/**
* Element: close-trigger - the close button
*/
.hv-drawer__close-trigger {
@apply absolute end-4 top-4;
}
/**
* Elements Spacing
*/
.hv-drawer__header + .hv-drawer__body {
@apply mt-2;
}
.hv-drawer__header + .hv-drawer__footer {
@apply mt-5;
}
.hv-drawer__body + .hv-drawer__footer {
@apply mt-5;
}
.hv-drawer__handle + .hv-drawer__header {
@apply mt-0;
}
.hv-drawer__handle + .hv-drawer__body {
@apply mt-0;
}
+2
View File
@@ -123,6 +123,8 @@
@import "./components/accordion.css" layer(components);
@import "./components/modal.css" layer(components);
@import "./components/alert-dialog.css" layer(components);
@import "./components/drawer.css" layer(components);
@import "./components/popover.css" layer(components);
+121
View File
@@ -1298,3 +1298,124 @@ export const listboxSectionVariants = tv({ base: "hv-list-box-section" });
export type ListBoxSectionVariants = VariantProps<
typeof listboxSectionVariants
>;
export const alertDialogVariants = tv({
defaultVariants: {
size: "md",
status: "danger",
variant: "opaque",
},
slots: {
backdrop: "hv-alert-dialog__backdrop",
body: "hv-alert-dialog__body",
closeTrigger: "hv-alert-dialog__close-trigger",
container: "hv-alert-dialog__container",
dialog: "hv-alert-dialog__dialog",
footer: "hv-alert-dialog__footer",
header: "hv-alert-dialog__header",
heading: "hv-alert-dialog__heading",
icon: "hv-alert-dialog__icon",
trigger: "hv-alert-dialog__trigger",
},
variants: {
size: {
cover: {
dialog: "hv-alert-dialog__dialog--cover",
},
lg: {
dialog: "hv-alert-dialog__dialog--lg",
},
md: {
dialog: "hv-alert-dialog__dialog--md",
},
sm: {
dialog: "hv-alert-dialog__dialog--sm",
},
xs: {
dialog: "hv-alert-dialog__dialog--xs",
},
},
status: {
accent: {
icon: "hv-alert-dialog__icon--accent",
},
danger: {
icon: "hv-alert-dialog__icon--danger",
},
default: {
icon: "hv-alert-dialog__icon--default",
},
success: {
icon: "hv-alert-dialog__icon--success",
},
warning: {
icon: "hv-alert-dialog__icon--warning",
},
},
variant: {
blur: {
backdrop: "hv-alert-dialog__backdrop--blur",
},
opaque: {
backdrop: "hv-alert-dialog__backdrop--opaque",
},
transparent: {
backdrop: "hv-alert-dialog__backdrop--transparent",
},
},
},
});
export type AlertDialogVariants = VariantProps<typeof alertDialogVariants>;
export const drawerVariants = tv({
defaultVariants: {
placement: "bottom",
variant: "opaque",
},
slots: {
backdrop: "hv-drawer__backdrop",
body: "hv-drawer__body",
closeTrigger: "hv-drawer__close-trigger",
content: "hv-drawer__content",
dialog: "hv-drawer__dialog",
footer: "hv-drawer__footer",
handle: "hv-drawer__handle",
header: "hv-drawer__header",
heading: "hv-drawer__heading",
trigger: "hv-drawer__trigger",
},
variants: {
placement: {
bottom: {
content: "hv-drawer__content--bottom",
dialog: "hv-drawer__dialog--bottom",
},
left: {
content: "hv-drawer__content--left",
dialog: "hv-drawer__dialog--left",
},
right: {
content: "hv-drawer__content--right",
dialog: "hv-drawer__dialog--right",
},
top: {
content: "hv-drawer__content--top",
dialog: "hv-drawer__dialog--top",
},
},
variant: {
blur: {
backdrop: "hv-drawer__backdrop--blur",
},
opaque: {
backdrop: "hv-drawer__backdrop--opaque",
},
transparent: {
backdrop: "hv-drawer__backdrop--transparent",
},
},
},
});
export type DrawerVariants = VariantProps<typeof drawerVariants>;
@@ -0,0 +1,71 @@
import { defineComponent, h, provide, type PropType } from "vue";
import {
useOverlayState,
type OverlayState,
} from "../../composables/useOverlayState";
import OverlayDialogRoot from "../overlay/OverlayDialogRoot.vue";
import { overlayNodes, overlayComponentName } from "../overlay/OverlayAction";
import { createAlertDialogContext, alertDialogKey } from "./context";
import AlertDialogTrigger from "./AlertDialogTrigger.vue";
export default defineComponent({
name: "AlertDialog",
inheritAttrs: false,
props: {
open: { type: Boolean, default: undefined },
isOpen: { type: Boolean, default: undefined },
defaultOpen: Boolean,
state: Object as PropType<OverlayState>,
},
emits: {
"update:open": (value: boolean) => typeof value === "boolean",
"update:isOpen": (value: boolean) => typeof value === "boolean",
openChange: (value: boolean) => typeof value === "boolean",
},
setup(props, { slots, emit }) {
const state = useOverlayState({
isOpen: () => props.state?.isOpen.value ?? props.open ?? props.isOpen,
defaultOpen: props.defaultOpen,
onOpenChange(value) {
props.state?.setOpen(value);
emit("update:open", value);
emit("update:isOpen", value);
emit("openChange", value);
},
});
provide(alertDialogKey, createAlertDialogContext(state));
return () =>
h(
OverlayDialogRoot,
{ state },
{
default: () => {
let found = false;
return overlayNodes(
slots.default?.({
isOpen: state.isOpen.value,
close: state.close,
}),
).map((node) => {
const name = overlayComponentName(node);
if (name === "AlertDialogTrigger") found = true;
if (
!found &&
(name === "Button" ||
node.type === "button" ||
node.type === "a")
) {
found = true;
return h(
AlertDialogTrigger,
{ asChild: true, key: node.key ?? undefined },
{ default: () => node },
);
}
return node;
});
},
},
);
},
});
@@ -0,0 +1,64 @@
<script lang="ts">
import { defineComponent, h, inject, type PropType } from "vue";
import type { AlertDialogVariants } from "@heroui-vue/styles";
import type { OverlayState } from "../../composables/useOverlayState";
import AlertDialog from "./AlertDialog";
import AlertDialogBackdropSurface from "./AlertDialogBackdropSurface.vue";
import { alertDialogKey } from "./context";
/**
* Alert dialogs require explicit action by default:
* isDismissable=false, isKeyboardDismissDisabled=true.
* Both remain independently configurable.
*/
export default defineComponent({
name: "AlertDialogBackdrop",
inheritAttrs: false,
props: {
open: { type: Boolean, default: undefined },
isOpen: { type: Boolean, default: undefined },
defaultOpen: Boolean,
state: Object as PropType<OverlayState>,
variant: String as PropType<AlertDialogVariants["variant"]>,
isDismissable: { type: Boolean, default: false },
isKeyboardDismissDisabled: { type: Boolean, default: true },
to: [String, Object] as PropType<string | HTMLElement>,
},
emits: {
"update:open": (value: boolean) => typeof value === "boolean",
"update:isOpen": (value: boolean) => typeof value === "boolean",
openChange: (value: boolean) => typeof value === "boolean",
},
setup(props, { attrs, slots, emit }) {
const parent = inject(alertDialogKey, undefined);
return () => {
const surface = () =>
h(
AlertDialogBackdropSurface,
{
...attrs,
variant: props.variant,
isDismissable: props.isDismissable,
isKeyboardDismissDisabled: props.isKeyboardDismissDisabled,
to: props.to,
},
slots,
);
if (parent) return surface();
return h(
AlertDialog,
{
open: props.open,
isOpen: props.isOpen,
defaultOpen: props.defaultOpen,
state: props.state,
"onUpdate:open": (v: boolean) => emit("update:open", v),
"onUpdate:isOpen": (v: boolean) => emit("update:isOpen", v),
onOpenChange: (v: boolean) => emit("openChange", v),
},
{ default: surface },
);
};
},
});
</script>
@@ -0,0 +1,57 @@
<script setup lang="ts">
import { useForwardExpose } from "reka-ui";
import { computed, provide } from "vue";
import {
alertDialogVariants,
type AlertDialogVariants,
} from "@heroui-vue/styles";
import OverlayPortal from "../overlay/OverlayPortal.vue";
import OverlayBackdrop from "../overlay/OverlayBackdrop.vue";
import { alertDialogKey, useAlertDialog } from "./context";
import { useOverlayViewport } from "../overlay/viewport";
import { useOverlayAnimation } from "../overlay/animation";
defineOptions({ inheritAttrs: false });
const props = withDefaults(
defineProps<{
variant?: AlertDialogVariants["variant"];
isDismissable?: boolean;
isKeyboardDismissDisabled?: boolean;
to?: string | HTMLElement;
}>(),
{
variant: "opaque",
// Alert dialogs require explicit action by default.
isDismissable: false,
isKeyboardDismissDisabled: true,
},
);
const ctx = useAlertDialog();
const height = useOverlayViewport();
const { forwardRef, currentElement } = useForwardExpose();
provide(alertDialogKey, {
...ctx,
variant: computed(() => props.variant),
dismissable: computed(() => props.isDismissable),
keyboardDisabled: computed(() => props.isKeyboardDismissDisabled),
});
const { entering, exiting, onAnimationEnd } = useOverlayAnimation(
ctx.state.isOpen,
currentElement,
);
</script>
<template>
<OverlayPortal :to="to">
<OverlayBackdrop
:ref="forwardRef"
v-bind="$attrs"
:style="{ '--visual-viewport-height': height }"
:class="alertDialogVariants({ variant }).backdrop()"
data-slot="alert-dialog-backdrop"
:data-entering="entering || undefined"
:data-exiting="exiting || undefined"
@animationend="onAnimationEnd"
>
<slot :is-open="ctx.state.isOpen.value" :close="ctx.state.close" />
</OverlayBackdrop>
</OverlayPortal>
</template>
@@ -0,0 +1,12 @@
<script setup lang="ts">
defineOptions({ inheritAttrs: false });
</script>
<template>
<div
v-bind="$attrs"
class="hv-alert-dialog__body"
data-slot="alert-dialog-body"
>
<slot />
</div>
</template>
@@ -0,0 +1,29 @@
import OverlayAction from "../overlay/OverlayAction";
import { useAlertDialog } from "./context";
import { defineComponent, h } from "vue";
/** Closes the alert dialog when activated (replaces RAC slot="close"). */
export default defineComponent({
name: "AlertDialogClose",
inheritAttrs: false,
props: {
as: { type: String, default: "button" },
asChild: { type: Boolean, default: false },
isDisabled: { type: Boolean, default: false },
},
setup(props, { attrs, slots }) {
const ctx = useAlertDialog();
return () =>
h(
OverlayAction,
{
...attrs,
as: props.as,
asChild: props.asChild,
isDisabled: props.isDisabled,
activate: ctx.state.close,
},
slots,
);
},
});
@@ -0,0 +1,29 @@
import { defineComponent, h, mergeProps, type PropType } from "vue";
import type { CloseButtonVariants } from "@heroui-vue/styles";
import CloseButton from "../close-button/CloseButton.vue";
import { useAlertDialog } from "./context";
export default defineComponent({
name: "AlertDialogCloseTrigger",
inheritAttrs: false,
props: {
variant: String as PropType<CloseButtonVariants["variant"]>,
isDisabled: Boolean,
disabled: Boolean,
},
setup(props, { attrs, slots }) {
const ctx = useAlertDialog();
return () =>
h(
CloseButton,
mergeProps(attrs, props, {
class: "hv-alert-dialog__close-trigger",
"data-slot": "alert-dialog-close-trigger",
onClick: (event: MouseEvent) => {
if (!event.defaultPrevented) ctx.state.close();
},
}),
slots,
);
},
});
@@ -0,0 +1,48 @@
<script setup lang="ts">
import { computed, provide, ref } from "vue";
import {
alertDialogVariants,
type AlertDialogVariants,
} from "@heroui-vue/styles";
import {
alertDialogKey,
useAlertDialog,
type AlertDialogPlacement,
} from "./context";
import { useOverlayAnimation } from "../overlay/animation";
defineOptions({ inheritAttrs: false });
const props = withDefaults(
defineProps<{
placement?: AlertDialogPlacement;
size?: AlertDialogVariants["size"];
as?: string;
}>(),
{ placement: "auto", size: "md", as: "div" },
);
const ctx = useAlertDialog();
provide(alertDialogKey, {
...ctx,
placement: computed(() => props.placement),
size: computed(() => props.size),
});
const container = ref<HTMLElement>();
const { entering, exiting, onAnimationEnd } = useOverlayAnimation(
ctx.state.isOpen,
container,
);
</script>
<template>
<component
:is="as"
ref="container"
v-bind="$attrs"
:class="alertDialogVariants({ size }).container()"
data-slot="alert-dialog-container"
:data-placement="placement"
:data-entering="entering || undefined"
:data-exiting="exiting || undefined"
@animationend="onAnimationEnd"
>
<slot :close="ctx.state.close" />
</component>
</template>
@@ -0,0 +1,52 @@
<script setup lang="ts">
import { computed, provide, watchEffect, onUnmounted, useAttrs } from "vue";
import { DialogTitle } from "reka-ui";
import { alertDialogVariants } from "@heroui-vue/styles";
import OverlayDialogContent from "../overlay/OverlayDialogContent.vue";
import { surfaceContextKey } from "../surface/context";
import { useAlertDialog } from "./context";
defineOptions({ inheritAttrs: false });
const props = withDefaults(defineProps<{ as?: string; id?: string }>(), {
as: "div",
});
const ctx = useAlertDialog();
const attrs = useAttrs();
watchEffect(() => {
ctx.contentId.value = props.id ?? ctx.defaultId;
});
onUnmounted(() => {
ctx.contentId.value = ctx.defaultId;
});
provide(surfaceContextKey, { variant: computed(() => "default" as const) });
</script>
<template>
<OverlayDialogContent
v-bind="attrs"
:as="as"
:id="ctx.contentId.value"
:class="alertDialogVariants({ size: ctx.size.value }).dialog()"
:is-dismissable="ctx.dismissable.value"
:is-keyboard-dismiss-disabled="ctx.keyboardDisabled.value"
role="alertdialog"
data-slot="alert-dialog-dialog"
:data-exiting="!ctx.state.isOpen.value || undefined"
:data-placement="ctx.placement.value"
:aria-labelledby="
'aria-labelledby' in attrs
? (attrs['aria-labelledby'] as string)
: Array.from(ctx.titles.values()).join(' ') || undefined
"
:aria-describedby="attrs['aria-describedby'] as string | undefined"
>
<DialogTitle
v-if="
('aria-label' in attrs || 'aria-labelledby' in attrs) &&
!ctx.titles.size
"
as="span"
class="sr-only"
aria-hidden="true"
/>
<slot :close="ctx.state.close" :is-open="ctx.state.isOpen.value" />
</OverlayDialogContent>
</template>
@@ -0,0 +1,12 @@
<script setup lang="ts">
defineOptions({ inheritAttrs: false });
</script>
<template>
<div
v-bind="$attrs"
class="hv-alert-dialog__footer"
data-slot="alert-dialog-footer"
>
<slot />
</div>
</template>
@@ -0,0 +1,12 @@
<script setup lang="ts">
defineOptions({ inheritAttrs: false });
</script>
<template>
<div
v-bind="$attrs"
class="hv-alert-dialog__header"
data-slot="alert-dialog-header"
>
<slot />
</div>
</template>
@@ -0,0 +1,31 @@
<script setup lang="ts">
import { computed, watchEffect, onUnmounted, useId } from "vue";
import { DialogTitle, injectDialogRootContext } from "reka-ui";
import { useAlertDialog } from "./context";
defineOptions({ inheritAttrs: false });
const props = withDefaults(defineProps<{ as?: string; id?: string }>(), {
as: "h2",
});
const ctx = useAlertDialog();
const root = injectDialogRootContext();
const suffix = useId();
const key = Symbol();
const generated = ctx.titles.size ? `${root.titleId}-${suffix}` : root.titleId;
const id = computed(() => props.id ?? generated);
watchEffect(() => {
ctx.titles.set(key, id.value);
});
onUnmounted(() => ctx.titles.delete(key));
</script>
<template>
<DialogTitle v-if="props.id" as="span" class="sr-only" aria-hidden="true" />
<DialogTitle
v-bind="$attrs"
:as="as"
:id="id"
class="hv-alert-dialog__heading"
data-slot="alert-dialog-heading"
>
<slot />
</DialogTitle>
</template>
@@ -0,0 +1,68 @@
<script lang="ts">
import { computed, defineComponent, h, useAttrs, type PropType } from "vue";
import {
alertDialogVariants,
type AlertDialogVariants,
} from "@heroui-vue/styles";
import {
AlertDialogDangerIcon,
AlertDialogInfoIcon,
AlertDialogSuccessIcon,
AlertDialogWarningIcon,
} from "./icons";
import type { AlertDialogStatus } from "./context";
export default defineComponent({
name: "AlertDialogIcon",
inheritAttrs: false,
props: {
status: {
type: String as PropType<AlertDialogStatus>,
default: "danger",
},
as: {
type: String,
default: "div",
},
},
setup(props, { slots }) {
const attrs = useAttrs();
const classes = computed(() =>
alertDialogVariants({
status: props.status as AlertDialogVariants["status"],
}).icon(),
);
function defaultIcon() {
switch (props.status) {
case "default":
case "accent":
return h(AlertDialogInfoIcon, {
"data-slot": "alert-dialog-default-icon",
});
case "success":
return h(AlertDialogSuccessIcon, {
"data-slot": "alert-dialog-default-icon",
});
case "warning":
return h(AlertDialogWarningIcon, {
"data-slot": "alert-dialog-default-icon",
});
default:
return h(AlertDialogDangerIcon, {
"data-slot": "alert-dialog-default-icon",
});
}
}
return () =>
h(
props.as,
{
...attrs,
class: [classes.value, attrs.class],
"data-slot": "alert-dialog-icon",
},
slots.default?.() ?? [defaultIcon()],
);
},
});
</script>
@@ -0,0 +1,38 @@
<script setup lang="ts">
import { watch } from "vue";
import { injectDialogRootContext, useForwardExpose } from "reka-ui";
import OverlayAction from "../overlay/OverlayAction";
import { useAlertDialog } from "./context";
defineOptions({ inheritAttrs: false });
withDefaults(
defineProps<{ as?: string; asChild?: boolean; isDisabled?: boolean }>(),
{ as: "div" },
);
const ctx = useAlertDialog();
const dialog = injectDialogRootContext();
const { forwardRef, currentElement } = useForwardExpose();
watch(
currentElement,
(el) => {
dialog.triggerElement.value = el;
},
{ immediate: true },
);
</script>
<template>
<OverlayAction
:ref="forwardRef"
v-bind="$attrs"
:as="as"
:as-child="asChild"
:is-disabled="isDisabled"
:activate="ctx.state.open"
class="hv-alert-dialog__trigger"
data-slot="alert-dialog-trigger"
aria-haspopup="dialog"
:aria-expanded="ctx.state.isOpen.value"
:aria-controls="ctx.state.isOpen.value ? ctx.contentId.value : undefined"
>
<slot />
</OverlayAction>
</template>
@@ -0,0 +1,60 @@
import {
computed,
inject,
reactive,
ref,
useId,
type ComputedRef,
type InjectionKey,
type Ref,
} from "vue";
import type { AlertDialogVariants } from "@heroui-vue/styles";
import type { OverlayState } from "../../composables/useOverlayState";
export type AlertDialogPlacement = "auto" | "top" | "center" | "bottom";
export type AlertDialogStatus =
"default" | "accent" | "success" | "warning" | "danger";
export interface AlertDialogContext {
state: OverlayState;
contentId: Ref<string>;
defaultId: string;
titles: Map<symbol, string>;
placement: ComputedRef<AlertDialogPlacement>;
size: ComputedRef<AlertDialogVariants["size"]>;
/** Backdrop variant; defaults to opaque. */
variant: ComputedRef<AlertDialogVariants["variant"]>;
dismissable: ComputedRef<boolean>;
keyboardDisabled: ComputedRef<boolean>;
}
export const alertDialogKey: InjectionKey<AlertDialogContext> =
Symbol("hv-alert-dialog");
export function useAlertDialog(required = true) {
const ctx = inject(alertDialogKey, undefined);
if (!ctx && required) {
throw new Error(
"AlertDialog parts require AlertDialog or AlertDialogBackdrop.",
);
}
return ctx!;
}
export function createAlertDialogContext(
state: OverlayState,
): AlertDialogContext {
const id = "hv-alert-dialog-" + useId();
return {
state,
contentId: ref(id),
defaultId: id,
titles: reactive(new Map()),
// Alert dialogs require explicit action by default.
placement: computed(() => "auto"),
size: computed(() => "md"),
variant: computed(() => "opaque"),
dismissable: computed(() => false),
keyboardDisabled: computed(() => true),
};
}
@@ -0,0 +1,53 @@
/** Baseline icons from HeroUI icons.tsx (Apache-2.0). */
import { defineComponent, h } from "vue";
function icon(name: string, d: string) {
return defineComponent({
name,
inheritAttrs: false,
setup(_, { attrs }) {
return () =>
h(
"svg",
{
...attrs,
"aria-hidden": "true",
fill: "none",
height: "16",
role: "presentation",
viewBox: "0 0 16 16",
width: "16",
xmlns: "http://www.w3.org/2000/svg",
},
[
h("path", {
"clip-rule": "evenodd",
d,
fill: "currentColor",
"fill-rule": "evenodd",
}),
],
);
},
});
}
export const AlertDialogInfoIcon = icon(
"AlertDialogInfoIcon",
"M8 13.5a5.5 5.5 0 1 0 0-11a5.5 5.5 0 0 0 0 11M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m1-9.5a1 1 0 1 1-2 0a1 1 0 0 1 2 0m-.25 3a.75.75 0 0 0-1.5 0V11a.75.75 0 0 0 1.5 0z",
);
export const AlertDialogWarningIcon = icon(
"AlertDialogWarningIcon",
"M7.134 2.994L2.217 11.5a1 1 0 0 0 .866 1.5h9.834a1 1 0 0 0 .866-1.5L8.866 2.993a1 1 0 0 0-1.732 0m3.03-.75c-.962-1.665-3.366-1.665-4.329 0L.918 10.749c-.963 1.666.24 3.751 2.165 3.751h9.834c1.925 0 3.128-2.085 2.164-3.751zM8 5a.75.75 0 0 1 .75.75v2a.75.75 0 0 1-1.5 0v-2A.75.75 0 0 1 8 5m1 5.75a1 1 0 1 1-2 0a1 1 0 0 1 2 0",
);
export const AlertDialogDangerIcon = icon(
"AlertDialogDangerIcon",
"M8 13.5a5.5 5.5 0 1 0 0-11a5.5 5.5 0 0 0 0 11M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m1-4.5a1 1 0 1 1-2 0a1 1 0 0 1 2 0M8.75 5a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0z",
);
export const AlertDialogSuccessIcon = icon(
"AlertDialogSuccessIcon",
"M13.5 8a5.5 5.5 0 1 1-11 0a5.5 5.5 0 0 1 11 0M15 8A7 7 0 1 1 1 8a7 7 0 0 1 14 0m-3.9-1.55a.75.75 0 1 0-1.2-.9L7.419 8.858L6.03 7.47a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.13-.08z",
);
@@ -0,0 +1,71 @@
import { defineComponent, h, provide, type PropType } from "vue";
import {
useOverlayState,
type OverlayState,
} from "../../composables/useOverlayState";
import OverlayDialogRoot from "../overlay/OverlayDialogRoot.vue";
import { overlayNodes, overlayComponentName } from "../overlay/OverlayAction";
import { createDrawerContext, drawerKey } from "./context";
import DrawerTrigger from "./DrawerTrigger.vue";
export default defineComponent({
name: "Drawer",
inheritAttrs: false,
props: {
open: { type: Boolean, default: undefined },
isOpen: { type: Boolean, default: undefined },
defaultOpen: Boolean,
state: Object as PropType<OverlayState>,
},
emits: {
"update:open": (value: boolean) => typeof value === "boolean",
"update:isOpen": (value: boolean) => typeof value === "boolean",
openChange: (value: boolean) => typeof value === "boolean",
},
setup(props, { slots, emit }) {
const state = useOverlayState({
isOpen: () => props.state?.isOpen.value ?? props.open ?? props.isOpen,
defaultOpen: props.defaultOpen,
onOpenChange(value) {
props.state?.setOpen(value);
emit("update:open", value);
emit("update:isOpen", value);
emit("openChange", value);
},
});
provide(drawerKey, createDrawerContext(state));
return () =>
h(
OverlayDialogRoot,
{ state },
{
default: () => {
let found = false;
return overlayNodes(
slots.default?.({
isOpen: state.isOpen.value,
close: state.close,
}),
).map((node) => {
const name = overlayComponentName(node);
if (name === "DrawerTrigger") found = true;
if (
!found &&
(name === "Button" ||
node.type === "button" ||
node.type === "a")
) {
found = true;
return h(
DrawerTrigger,
{ asChild: true, key: node.key ?? undefined },
{ default: () => node },
);
}
return node;
});
},
},
);
},
});
@@ -0,0 +1,59 @@
<script lang="ts">
import { defineComponent, h, inject, type PropType } from "vue";
import type { DrawerVariants } from "@heroui-vue/styles";
import type { OverlayState } from "../../composables/useOverlayState";
import Drawer from "./Drawer";
import DrawerBackdropSurface from "./DrawerBackdropSurface.vue";
import { drawerKey } from "./context";
export default defineComponent({
name: "DrawerBackdrop",
inheritAttrs: false,
props: {
open: { type: Boolean, default: undefined },
isOpen: { type: Boolean, default: undefined },
defaultOpen: Boolean,
state: Object as PropType<OverlayState>,
variant: String as PropType<DrawerVariants["variant"]>,
isDismissable: { type: Boolean, default: true },
isKeyboardDismissDisabled: Boolean,
to: [String, Object] as PropType<string | HTMLElement>,
},
emits: {
"update:open": (value: boolean) => typeof value === "boolean",
"update:isOpen": (value: boolean) => typeof value === "boolean",
openChange: (value: boolean) => typeof value === "boolean",
},
setup(props, { attrs, slots, emit }) {
const parent = inject(drawerKey, undefined);
return () => {
const surface = () =>
h(
DrawerBackdropSurface,
{
...attrs,
variant: props.variant,
isDismissable: props.isDismissable,
isKeyboardDismissDisabled: props.isKeyboardDismissDisabled,
to: props.to,
},
slots,
);
if (parent) return surface();
return h(
Drawer,
{
open: props.open,
isOpen: props.isOpen,
defaultOpen: props.defaultOpen,
state: props.state,
"onUpdate:open": (v: boolean) => emit("update:open", v),
"onUpdate:isOpen": (v: boolean) => emit("update:isOpen", v),
onOpenChange: (v: boolean) => emit("openChange", v),
},
{ default: surface },
);
};
},
});
</script>
@@ -0,0 +1,49 @@
<script setup lang="ts">
import { useForwardExpose } from "reka-ui";
import { computed, provide } from "vue";
import { drawerVariants, type DrawerVariants } from "@heroui-vue/styles";
import OverlayPortal from "../overlay/OverlayPortal.vue";
import OverlayBackdrop from "../overlay/OverlayBackdrop.vue";
import { drawerKey, useDrawer } from "./context";
import { useOverlayViewport } from "../overlay/viewport";
import { useOverlayAnimation } from "../overlay/animation";
defineOptions({ inheritAttrs: false });
const props = withDefaults(
defineProps<{
variant?: DrawerVariants["variant"];
isDismissable?: boolean;
isKeyboardDismissDisabled?: boolean;
to?: string | HTMLElement;
}>(),
{ variant: "opaque", isDismissable: true, isKeyboardDismissDisabled: false },
);
const ctx = useDrawer();
const height = useOverlayViewport();
const { forwardRef, currentElement } = useForwardExpose();
provide(drawerKey, {
...ctx,
variant: computed(() => props.variant),
dismissable: computed(() => props.isDismissable),
keyboardDisabled: computed(() => props.isKeyboardDismissDisabled),
});
const { entering, exiting, onAnimationEnd } = useOverlayAnimation(
ctx.state.isOpen,
currentElement,
);
</script>
<template>
<OverlayPortal :to="to">
<OverlayBackdrop
:ref="forwardRef"
v-bind="$attrs"
:style="{ '--visual-viewport-height': height }"
:class="drawerVariants({ variant }).backdrop()"
data-slot="drawer-backdrop"
:data-entering="entering || undefined"
:data-exiting="exiting || undefined"
@animationend="onAnimationEnd"
>
<slot :is-open="ctx.state.isOpen.value" :close="ctx.state.close" />
</OverlayBackdrop>
</OverlayPortal>
</template>
@@ -0,0 +1,13 @@
<script setup lang="ts">
defineOptions({ inheritAttrs: false });
</script>
<template>
<div
v-bind="$attrs"
class="hv-drawer__body"
data-slot="drawer-body"
style="touch-action: pan-y"
>
<slot />
</div>
</template>
@@ -0,0 +1,29 @@
import OverlayAction from "../overlay/OverlayAction";
import { useDrawer } from "./context";
import { defineComponent, h } from "vue";
/** Closes the drawer when activated (replaces RAC slot="close"). */
export default defineComponent({
name: "DrawerClose",
inheritAttrs: false,
props: {
as: { type: String, default: "button" },
asChild: { type: Boolean, default: false },
isDisabled: { type: Boolean, default: false },
},
setup(props, { attrs, slots }) {
const ctx = useDrawer();
return () =>
h(
OverlayAction,
{
...attrs,
as: props.as,
asChild: props.asChild,
isDisabled: props.isDisabled,
activate: ctx.state.close,
},
slots,
);
},
});
@@ -0,0 +1,29 @@
import { defineComponent, h, mergeProps, type PropType } from "vue";
import type { CloseButtonVariants } from "@heroui-vue/styles";
import CloseButton from "../close-button/CloseButton.vue";
import { useDrawer } from "./context";
export default defineComponent({
name: "DrawerCloseTrigger",
inheritAttrs: false,
props: {
variant: String as PropType<CloseButtonVariants["variant"]>,
isDisabled: Boolean,
disabled: Boolean,
},
setup(props, { attrs, slots }) {
const ctx = useDrawer();
return () =>
h(
CloseButton,
mergeProps(attrs, props, {
class: "hv-drawer__close-trigger",
"data-slot": "drawer-close-trigger",
onClick: (event: MouseEvent) => {
if (!event.defaultPrevented) ctx.state.close();
},
}),
slots,
);
},
});
@@ -0,0 +1,31 @@
<script setup lang="ts">
import { computed, provide, ref } from "vue";
import { drawerVariants } from "@heroui-vue/styles";
import { drawerKey, useDrawer, type DrawerPlacement } from "./context";
defineOptions({ inheritAttrs: false });
const props = withDefaults(
defineProps<{
placement?: DrawerPlacement;
as?: string;
}>(),
{ placement: "bottom", as: "div" },
);
const ctx = useDrawer();
provide(drawerKey, {
...ctx,
placement: computed(() => props.placement),
});
const content = ref<HTMLElement>();
</script>
<template>
<component
:is="as"
ref="content"
v-bind="$attrs"
:class="drawerVariants({ placement }).content()"
data-slot="drawer-content"
:data-placement="placement"
>
<slot :close="ctx.state.close" />
</component>
</template>
@@ -0,0 +1,87 @@
<script setup lang="ts">
import {
computed,
provide,
watchEffect,
onUnmounted,
useAttrs,
ref,
} from "vue";
import { DialogTitle } from "reka-ui";
import { drawerVariants } from "@heroui-vue/styles";
import OverlayDialogContent from "../overlay/OverlayDialogContent.vue";
import { surfaceContextKey } from "../surface/context";
import { useOverlayAnimation } from "../overlay/animation";
import { useDrawer } from "./context";
import { useDrawerDrag } from "./useDrawerDrag";
defineOptions({ inheritAttrs: false });
const props = withDefaults(defineProps<{ as?: string; id?: string }>(), {
as: "div",
});
const ctx = useDrawer();
const attrs = useAttrs();
watchEffect(() => {
ctx.contentId.value = props.id ?? ctx.defaultId;
});
onUnmounted(() => {
ctx.contentId.value = ctx.defaultId;
});
provide(surfaceContextKey, { variant: computed(() => "default" as const) });
const dialogEl = ref<HTMLElement | null>(null);
const { dialogRef } = useDrawerDrag(
ctx.placement,
ctx.dismissable,
ctx.state.isOpen,
() => ctx.state.close(),
);
// Phase markers follow the Dialog element — it is the node that actually
// runs the enter/exit animations, so Presence and CSS stay in sync.
const { entering, exiting, onAnimationEnd } = useOverlayAnimation(
ctx.state.isOpen,
dialogRef,
);
function setDialogRef(el: unknown) {
const node = (el as { $el?: HTMLElement } | HTMLElement | null) ?? null;
const next = !node
? null
: node instanceof HTMLElement
? node
: ((node.$el as HTMLElement) ?? null);
dialogEl.value = next;
dialogRef.value = next;
}
</script>
<template>
<OverlayDialogContent
:ref="setDialogRef"
v-bind="attrs"
:as="as"
:id="ctx.contentId.value"
:class="drawerVariants({ placement: ctx.placement.value }).dialog()"
:is-dismissable="ctx.dismissable.value"
:is-keyboard-dismiss-disabled="ctx.keyboardDisabled.value"
data-slot="drawer-dialog"
:data-entering="entering || undefined"
:data-exiting="exiting || undefined"
:data-placement="ctx.placement.value"
:style="ctx.dismissable.value ? { touchAction: 'none' } : undefined"
:aria-labelledby="
'aria-labelledby' in attrs
? (attrs['aria-labelledby'] as string)
: Array.from(ctx.titles.values()).join(' ') || undefined
"
:aria-describedby="attrs['aria-describedby'] as string | undefined"
@animationend="onAnimationEnd"
>
<DialogTitle
v-if="
('aria-label' in attrs || 'aria-labelledby' in attrs) &&
!ctx.titles.size
"
as="span"
class="sr-only"
aria-hidden="true"
/>
<slot :close="ctx.state.close" :is-open="ctx.state.isOpen.value" />
</OverlayDialogContent>
</template>
@@ -0,0 +1,8 @@
<script setup lang="ts">
defineOptions({ inheritAttrs: false });
</script>
<template>
<div v-bind="$attrs" class="hv-drawer__footer" data-slot="drawer-footer">
<slot />
</div>
</template>
@@ -0,0 +1,15 @@
<script setup lang="ts">
defineOptions({ inheritAttrs: false });
</script>
<template>
<div
v-bind="$attrs"
class="hv-drawer__handle"
data-slot="drawer-handle"
aria-hidden="true"
>
<slot>
<div data-slot="drawer-handle-bar" />
</slot>
</div>
</template>
@@ -0,0 +1,8 @@
<script setup lang="ts">
defineOptions({ inheritAttrs: false });
</script>
<template>
<div v-bind="$attrs" class="hv-drawer__header" data-slot="drawer-header">
<slot />
</div>
</template>
@@ -0,0 +1,31 @@
<script setup lang="ts">
import { computed, watchEffect, onUnmounted, useId } from "vue";
import { DialogTitle, injectDialogRootContext } from "reka-ui";
import { useDrawer } from "./context";
defineOptions({ inheritAttrs: false });
const props = withDefaults(defineProps<{ as?: string; id?: string }>(), {
as: "h2",
});
const ctx = useDrawer();
const root = injectDialogRootContext();
const suffix = useId();
const key = Symbol();
const generated = ctx.titles.size ? `${root.titleId}-${suffix}` : root.titleId;
const id = computed(() => props.id ?? generated);
watchEffect(() => {
ctx.titles.set(key, id.value);
});
onUnmounted(() => ctx.titles.delete(key));
</script>
<template>
<DialogTitle v-if="props.id" as="span" class="sr-only" aria-hidden="true" />
<DialogTitle
v-bind="$attrs"
:as="as"
:id="id"
class="hv-drawer__heading"
data-slot="drawer-heading"
>
<slot />
</DialogTitle>
</template>
@@ -0,0 +1,38 @@
<script setup lang="ts">
import { watch } from "vue";
import { injectDialogRootContext, useForwardExpose } from "reka-ui";
import OverlayAction from "../overlay/OverlayAction";
import { useDrawer } from "./context";
defineOptions({ inheritAttrs: false });
withDefaults(
defineProps<{ as?: string; asChild?: boolean; isDisabled?: boolean }>(),
{ as: "div" },
);
const ctx = useDrawer();
const dialog = injectDialogRootContext();
const { forwardRef, currentElement } = useForwardExpose();
watch(
currentElement,
(el) => {
dialog.triggerElement.value = el;
},
{ immediate: true },
);
</script>
<template>
<OverlayAction
:ref="forwardRef"
v-bind="$attrs"
:as="as"
:as-child="asChild"
:is-disabled="isDisabled"
:activate="ctx.state.open"
class="hv-drawer__trigger"
data-slot="drawer-trigger"
aria-haspopup="dialog"
:aria-expanded="ctx.state.isOpen.value"
:aria-controls="ctx.state.isOpen.value ? ctx.contentId.value : undefined"
>
<slot />
</OverlayAction>
</template>
@@ -0,0 +1,49 @@
import {
computed,
inject,
reactive,
ref,
useId,
type ComputedRef,
type InjectionKey,
type Ref,
} from "vue";
import type { DrawerVariants } from "@heroui-vue/styles";
import type { OverlayState } from "../../composables/useOverlayState";
export type DrawerPlacement = "top" | "bottom" | "left" | "right";
export interface DrawerContext {
state: OverlayState;
contentId: Ref<string>;
defaultId: string;
titles: Map<symbol, string>;
placement: ComputedRef<DrawerPlacement>;
variant: ComputedRef<DrawerVariants["variant"]>;
dismissable: ComputedRef<boolean>;
keyboardDisabled: ComputedRef<boolean>;
}
export const drawerKey: InjectionKey<DrawerContext> = Symbol("hv-drawer");
export function useDrawer(required = true) {
const ctx = inject(drawerKey, undefined);
if (!ctx && required) {
throw new Error("Drawer parts require Drawer or DrawerBackdrop.");
}
return ctx!;
}
export function createDrawerContext(state: OverlayState): DrawerContext {
const id = "hv-drawer-" + useId();
return {
state,
contentId: ref(id),
defaultId: id,
titles: reactive(new Map()),
placement: computed(() => "bottom"),
variant: computed(() => "opaque"),
dismissable: computed(() => true),
keyboardDisabled: computed(() => false),
};
}
@@ -0,0 +1,281 @@
/**
* Drawer drag-to-dismiss — thresholds match the fixed HeroUI baseline:
* activate after 8px, dismiss at >30% dimension or >0.5px/ms velocity.
* Drag originates from handle/header/footer; body is excluded to avoid scroll conflicts.
*/
import { nextTick, onBeforeUnmount, ref, watch, type Ref } from "vue";
import type { DrawerPlacement } from "./context";
const DRAG_THRESHOLD = 8;
const DISMISS_FRACTION = 0.3;
const VELOCITY_THRESHOLD = 0.5;
const SNAP_BACK_TRANSITION = "transform 300ms cubic-bezier(0.32, 0.72, 0, 1)";
type GesturePhase = "idle" | "dragging" | "dismissed";
function isDrawerDragTargetOwnedBy(
target: HTMLElement,
dialog: HTMLElement,
): boolean {
return target.closest('[data-slot="drawer-dialog"]') === dialog;
}
export function useDrawerDrag(
placement: Ref<DrawerPlacement>,
isDismissable: Ref<boolean>,
isOpen: Ref<boolean>,
onDismiss: () => void,
) {
const dialogRef = ref<HTMLElement | null>(null);
let phase: GesturePhase = "idle";
let isActive = false;
let activePointerId: number | null = null;
let startPos = 0;
let currentOffset = 0;
let velocity = 0;
let lastTime = 0;
let lastPos = 0;
function isVertical() {
return placement.value === "top" || placement.value === "bottom";
}
function getPos(event: PointerEvent) {
return isVertical() ? event.clientY : event.clientX;
}
function clamp(delta: number) {
switch (placement.value) {
case "bottom":
case "right":
return Math.max(0, delta);
case "top":
case "left":
return Math.min(0, delta);
default:
return delta;
}
}
function prefersReducedMotion() {
return Boolean(
dialogRef.value?.ownerDocument.defaultView?.matchMedia?.(
"(prefers-reduced-motion: reduce)",
).matches,
);
}
function clearStyles(el: HTMLElement | null) {
if (!el) return;
el.style.transform = "";
el.style.transition = "";
}
function snapBack(el: HTMLElement) {
el.style.transition = prefersReducedMotion()
? "none"
: SNAP_BACK_TRANSITION;
el.style.transform = "";
const cleanup = () => {
el.style.transition = "";
};
el.addEventListener("transitionend", cleanup, { once: true });
}
function releaseCapture(pointerId: number | null, el = dialogRef.value) {
if (pointerId === null) return;
try {
el?.releasePointerCapture(pointerId);
} catch {
// already released
}
}
/**
* Cancel an in-flight gesture. When `preserveOffset` is true the inline
* transform is kept so an accepted exit continues from the dragged position.
*/
function endGesture(
options: { preserveOffset?: boolean } = {},
el = dialogRef.value,
) {
const pointerId = activePointerId;
phase = "idle";
isActive = false;
activePointerId = null;
currentOffset = 0;
velocity = 0;
releaseCapture(pointerId, el);
if (!options.preserveOffset) clearStyles(el);
}
function onPointerDown(event: Event) {
const pointerEvent = event as PointerEvent;
if (pointerEvent.defaultPrevented) return;
// Do not start gestures on a closing / closed panel.
if (!isDismissable.value || !isOpen.value) return;
if (pointerEvent.button !== 0) return;
if (phase !== "idle" || activePointerId !== null) return;
const target = pointerEvent.target as HTMLElement;
const currentTarget = pointerEvent.currentTarget as HTMLElement;
if (!target || !currentTarget) return;
if (!isDrawerDragTargetOwnedBy(target, currentTarget)) return;
if (
target.closest(
"input, textarea, button, [role='button'], select, a, [data-slot='drawer-body']",
)
) {
return;
}
phase = "dragging";
isActive = false;
activePointerId = pointerEvent.pointerId;
startPos = getPos(pointerEvent);
lastPos = startPos;
lastTime = Date.now();
currentOffset = 0;
velocity = 0;
}
function onPointerMove(event: Event) {
const pointerEvent = event as PointerEvent;
if (phase !== "dragging" || !dialogRef.value) return;
if (pointerEvent.pointerId !== activePointerId) return;
// A retained exit node must not keep accepting drag updates.
if (!isOpen.value) return;
const pos = getPos(pointerEvent);
const rawDelta = pos - startPos;
const delta = clamp(rawDelta);
if (!isActive) {
if (Math.abs(rawDelta) < DRAG_THRESHOLD) return;
isActive = true;
dialogRef.value.style.transition = "none";
try {
dialogRef.value.setPointerCapture(pointerEvent.pointerId);
} catch {
// jsdom / browsers may already have released capture
}
}
currentOffset = delta;
const now = Date.now();
const dt = now - lastTime;
if (dt > 0) {
velocity = (pos - lastPos) / dt;
lastTime = now;
lastPos = pos;
}
const axis = isVertical() ? "Y" : "X";
dialogRef.value.style.transform = `translate${axis}(${delta}px)`;
}
function onPointerUp(event: Event) {
const pointerEvent = event as PointerEvent;
if (phase !== "dragging" || pointerEvent.pointerId !== activePointerId) {
return;
}
const el = dialogRef.value;
const wasActive = isActive;
const pointerId = activePointerId;
phase = "idle";
isActive = false;
activePointerId = null;
if (!el || !wasActive) {
currentOffset = 0;
velocity = 0;
releaseCapture(pointerId);
return;
}
releaseCapture(pointerId);
const dimension = isVertical() ? el.offsetHeight : el.offsetWidth;
const absOffset = Math.abs(currentOffset);
const absVelocity = Math.abs(velocity);
const shouldDismiss =
absOffset > dimension * DISMISS_FRACTION ||
absVelocity > VELOCITY_THRESHOLD;
if (shouldDismiss) {
// Keep the inline transform so exit continues from the dragged position.
// Mark dismissed so a later lostpointercapture does not clear the offset.
phase = "dismissed";
onDismiss();
void nextTick(() => {
if (isOpen.value && dialogRef.value === el) {
// Controlled parent rejected the close request — restore the panel.
phase = "idle";
snapBack(el);
} else {
phase = "idle";
}
});
} else {
snapBack(el);
}
currentOffset = 0;
velocity = 0;
}
function onPointerCancel(event: Event) {
const pointerEvent = event as PointerEvent;
// A normal capture release after an accepted dismiss must not jump the
// panel back — only cancel gestures that are still in flight.
if (phase === "dismissed") return;
if (phase !== "dragging") return;
if (
activePointerId !== null &&
pointerEvent.pointerId !== undefined &&
pointerEvent.pointerId !== activePointerId
) {
return;
}
endGesture();
}
function bind(el: HTMLElement | null) {
el?.addEventListener("pointerdown", onPointerDown);
el?.addEventListener("pointermove", onPointerMove);
el?.addEventListener("pointerup", onPointerUp);
el?.addEventListener("pointercancel", onPointerCancel);
el?.addEventListener("lostpointercapture", onPointerCancel);
}
function unbind(el: HTMLElement | null) {
el?.removeEventListener("pointerdown", onPointerDown);
el?.removeEventListener("pointermove", onPointerMove);
el?.removeEventListener("pointerup", onPointerUp);
el?.removeEventListener("pointercancel", onPointerCancel);
el?.removeEventListener("lostpointercapture", onPointerCancel);
}
// Config changes mid-gesture cancel it; an accepted programmatic close
// stops further updates but keeps whatever offset is already applied.
watch([isDismissable, placement], () => {
if (phase === "dragging") endGesture();
});
watch(isOpen, (open) => {
if (open) {
// Presence may reuse the exiting node on a quick reopen.
endGesture();
} else if (phase === "dragging") {
// Programmatic close during a drag: stop the gesture without jumping.
endGesture({ preserveOffset: true });
}
});
watch(dialogRef, (el, prev) => {
if (prev) {
// Clean up the previous node (capture + any in-flight style).
endGesture({}, prev);
unbind(prev);
}
bind(el);
});
onBeforeUnmount(() => {
endGesture();
unbind(dialogRef.value);
});
return {
dialogRef,
};
}
+66
View File
@@ -658,3 +658,69 @@ export {
type ListBoxItemVariants,
type ListBoxSectionVariants,
} from "@heroui-vue/styles";
export { default as AlertDialog } from "./components/alert-dialog/AlertDialog";
export { default as AlertDialogRoot } from "./components/alert-dialog/AlertDialog";
export { default as AlertDialogTrigger } from "./components/alert-dialog/AlertDialogTrigger.vue";
export { default as AlertDialogBackdrop } from "./components/alert-dialog/AlertDialogBackdrop.vue";
export { default as AlertDialogContainer } from "./components/alert-dialog/AlertDialogContainer.vue";
export { default as AlertDialogDialog } from "./components/alert-dialog/AlertDialogDialog.vue";
export { default as AlertDialogHeader } from "./components/alert-dialog/AlertDialogHeader.vue";
export { default as AlertDialogHeading } from "./components/alert-dialog/AlertDialogHeading.vue";
export { default as AlertDialogBody } from "./components/alert-dialog/AlertDialogBody.vue";
export { default as AlertDialogFooter } from "./components/alert-dialog/AlertDialogFooter.vue";
export { default as AlertDialogIcon } from "./components/alert-dialog/AlertDialogIcon.vue";
export { default as AlertDialogCloseTrigger } from "./components/alert-dialog/AlertDialogCloseTrigger";
export { default as AlertDialogClose } from "./components/alert-dialog/AlertDialogClose";
export {
alertDialogVariants,
type AlertDialogVariants,
} from "@heroui-vue/styles";
export type {
AlertDialogPlacement,
AlertDialogStatus,
} from "./components/alert-dialog/context";
export type {
AlertDialogProps,
AlertDialogTriggerProps,
AlertDialogBackdropProps,
AlertDialogContainerProps,
AlertDialogDialogProps,
AlertDialogHeaderProps,
AlertDialogHeadingProps,
AlertDialogBodyProps,
AlertDialogFooterProps,
AlertDialogIconProps,
AlertDialogCloseTriggerProps,
AlertDialogCloseProps,
} from "./types";
export { default as Drawer } from "./components/drawer/Drawer";
export { default as DrawerRoot } from "./components/drawer/Drawer";
export { default as DrawerTrigger } from "./components/drawer/DrawerTrigger.vue";
export { default as DrawerBackdrop } from "./components/drawer/DrawerBackdrop.vue";
export { default as DrawerContent } from "./components/drawer/DrawerContent.vue";
export { default as DrawerDialog } from "./components/drawer/DrawerDialog.vue";
export { default as DrawerHeader } from "./components/drawer/DrawerHeader.vue";
export { default as DrawerHeading } from "./components/drawer/DrawerHeading.vue";
export { default as DrawerBody } from "./components/drawer/DrawerBody.vue";
export { default as DrawerFooter } from "./components/drawer/DrawerFooter.vue";
export { default as DrawerHandle } from "./components/drawer/DrawerHandle.vue";
export { default as DrawerCloseTrigger } from "./components/drawer/DrawerCloseTrigger";
export { default as DrawerClose } from "./components/drawer/DrawerClose";
export { drawerVariants, type DrawerVariants } from "@heroui-vue/styles";
export type { DrawerPlacement } from "./components/drawer/context";
export type {
DrawerProps,
DrawerTriggerProps,
DrawerBackdropProps,
DrawerContentProps,
DrawerDialogProps,
DrawerHeaderProps,
DrawerHeadingProps,
DrawerBodyProps,
DrawerFooterProps,
DrawerHandleProps,
DrawerCloseTriggerProps,
DrawerCloseProps,
} from "./types";
+76
View File
@@ -515,3 +515,79 @@ export type SliderOutputProps = InstanceType<
export type SliderMarksProps = InstanceType<
(typeof import("./components/slider/SliderMarks.vue"))["default"]
>["$props"];
import type AlertDialog from "./components/alert-dialog/AlertDialog";
import type AlertDialogTrigger from "./components/alert-dialog/AlertDialogTrigger.vue";
import type AlertDialogBackdrop from "./components/alert-dialog/AlertDialogBackdrop.vue";
import type AlertDialogContainer from "./components/alert-dialog/AlertDialogContainer.vue";
import type AlertDialogDialog from "./components/alert-dialog/AlertDialogDialog.vue";
import type AlertDialogHeader from "./components/alert-dialog/AlertDialogHeader.vue";
import type AlertDialogHeading from "./components/alert-dialog/AlertDialogHeading.vue";
import type AlertDialogBody from "./components/alert-dialog/AlertDialogBody.vue";
import type AlertDialogFooter from "./components/alert-dialog/AlertDialogFooter.vue";
import type AlertDialogIcon from "./components/alert-dialog/AlertDialogIcon.vue";
import type AlertDialogCloseTrigger from "./components/alert-dialog/AlertDialogCloseTrigger";
import type AlertDialogClose from "./components/alert-dialog/AlertDialogClose";
export type AlertDialogProps = InstanceType<typeof AlertDialog>["$props"];
export type AlertDialogTriggerProps = InstanceType<
typeof AlertDialogTrigger
>["$props"];
export type AlertDialogBackdropProps = InstanceType<
typeof AlertDialogBackdrop
>["$props"];
export type AlertDialogContainerProps = InstanceType<
typeof AlertDialogContainer
>["$props"];
export type AlertDialogDialogProps = InstanceType<
typeof AlertDialogDialog
>["$props"];
export type AlertDialogHeaderProps = InstanceType<
typeof AlertDialogHeader
>["$props"];
export type AlertDialogHeadingProps = InstanceType<
typeof AlertDialogHeading
>["$props"];
export type AlertDialogBodyProps = InstanceType<
typeof AlertDialogBody
>["$props"];
export type AlertDialogFooterProps = InstanceType<
typeof AlertDialogFooter
>["$props"];
export type AlertDialogIconProps = InstanceType<
typeof AlertDialogIcon
>["$props"];
export type AlertDialogCloseTriggerProps = InstanceType<
typeof AlertDialogCloseTrigger
>["$props"];
export type AlertDialogCloseProps = InstanceType<
typeof AlertDialogClose
>["$props"];
import type Drawer from "./components/drawer/Drawer";
import type DrawerTrigger from "./components/drawer/DrawerTrigger.vue";
import type DrawerBackdrop from "./components/drawer/DrawerBackdrop.vue";
import type DrawerContent from "./components/drawer/DrawerContent.vue";
import type DrawerDialog from "./components/drawer/DrawerDialog.vue";
import type DrawerHeader from "./components/drawer/DrawerHeader.vue";
import type DrawerHeading from "./components/drawer/DrawerHeading.vue";
import type DrawerBody from "./components/drawer/DrawerBody.vue";
import type DrawerFooter from "./components/drawer/DrawerFooter.vue";
import type DrawerHandle from "./components/drawer/DrawerHandle.vue";
import type DrawerCloseTrigger from "./components/drawer/DrawerCloseTrigger";
import type DrawerClose from "./components/drawer/DrawerClose";
export type DrawerProps = InstanceType<typeof Drawer>["$props"];
export type DrawerTriggerProps = InstanceType<typeof DrawerTrigger>["$props"];
export type DrawerBackdropProps = InstanceType<typeof DrawerBackdrop>["$props"];
export type DrawerContentProps = InstanceType<typeof DrawerContent>["$props"];
export type DrawerDialogProps = InstanceType<typeof DrawerDialog>["$props"];
export type DrawerHeaderProps = InstanceType<typeof DrawerHeader>["$props"];
export type DrawerHeadingProps = InstanceType<typeof DrawerHeading>["$props"];
export type DrawerBodyProps = InstanceType<typeof DrawerBody>["$props"];
export type DrawerFooterProps = InstanceType<typeof DrawerFooter>["$props"];
export type DrawerHandleProps = InstanceType<typeof DrawerHandle>["$props"];
export type DrawerCloseTriggerProps = InstanceType<
typeof DrawerCloseTrigger
>["$props"];
export type DrawerCloseProps = InstanceType<typeof DrawerClose>["$props"];
+251
View File
@@ -0,0 +1,251 @@
import { afterEach, expect, it, vi } from "vitest";
import { mount, flushPromises } from "@vue/test-utils";
import { defineComponent, nextTick, ref } from "vue";
import {
AlertDialog,
AlertDialogBackdrop,
AlertDialogBody,
AlertDialogClose,
AlertDialogCloseTrigger,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
AlertDialogTrigger,
Button,
useOverlayState,
} from "../packages/vue/src";
const wrappers: ReturnType<typeof mount>[] = [];
afterEach(async () => {
for (const w of wrappers.splice(0)) w.unmount();
await flushPromises();
document.body.innerHTML = "";
});
const components = {
AlertDialog,
AlertDialogBackdrop,
AlertDialogContainer,
AlertDialogDialog,
AlertDialogCloseTrigger,
AlertDialogHeader,
AlertDialogHeading,
AlertDialogIcon,
AlertDialogBody,
AlertDialogFooter,
AlertDialogClose,
AlertDialogTrigger,
Button,
};
const panel =
'<AlertDialogBackdrop><AlertDialogContainer><AlertDialogDialog><AlertDialogCloseTrigger/><AlertDialogHeader><AlertDialogIcon status="danger"/><AlertDialogHeading>要删除吗?</AlertDialogHeading></AlertDialogHeader><AlertDialogBody>内容</AlertDialogBody><AlertDialogFooter><AlertDialogClose as-child><Button>取消</Button></AlertDialogClose></AlertDialogFooter></AlertDialogDialog></AlertDialogContainer></AlertDialogBackdrop>';
function view(template: string, setup = () => ({})) {
const w = mount(defineComponent({ components, template, setup }), {
attachTo: document.body,
});
wrappers.push(w);
return w;
}
it("opens with role=alertdialog and real accessible name", async () => {
const w = view(`<AlertDialog><Button>打开</Button>${panel}</AlertDialog>`);
await w.get("button").trigger("click");
await flushPromises();
const dialog = document.querySelector('[role="alertdialog"]')!;
expect(dialog).not.toBeNull();
expect(dialog.getAttribute("data-slot")).toBe("alert-dialog-dialog");
const labelled = dialog.getAttribute("aria-labelledby")!;
expect(document.getElementById(labelled)?.textContent).toContain("要删除吗");
});
it("defaults to non-dismissable outside click and disabled Escape", async () => {
const w = view(`<AlertDialog><Button>打开</Button>${panel}</AlertDialog>`);
await w.get("button").trigger("click");
await flushPromises();
const dialog = document.querySelector('[role="alertdialog"]')!;
expect(dialog).not.toBeNull();
// Escape must not close when keyboard dismiss is disabled (default).
window.dispatchEvent(
new KeyboardEvent("keydown", {
key: "Escape",
bubbles: true,
cancelable: true,
}),
);
await flushPromises();
expect(document.querySelector('[role="alertdialog"]')).not.toBeNull();
});
it("allows Escape and outside dismiss only when explicitly enabled", async () => {
const w = view(
`<AlertDialog><Button>打开</Button><AlertDialogBackdrop :is-dismissable="true" :is-keyboard-dismiss-disabled="false"><AlertDialogContainer><AlertDialogDialog><AlertDialogHeading>标题</AlertDialogHeading></AlertDialogDialog></AlertDialogContainer></AlertDialogBackdrop></AlertDialog>`,
);
await w.get("button").trigger("click");
await flushPromises();
expect(document.querySelector('[role="alertdialog"]')).not.toBeNull();
window.dispatchEvent(
new KeyboardEvent("keydown", {
key: "Escape",
bubbles: true,
cancelable: true,
}),
);
await flushPromises();
await nextTick();
expect(document.querySelector('[role="alertdialog"]')).toBeNull();
});
it("close button and AlertDialogClose close the dialog", async () => {
const w = view(`<AlertDialog><Button>打开</Button>${panel}</AlertDialog>`);
await w.get("button").trigger("click");
await flushPromises();
expect(document.querySelector('[role="alertdialog"]')).not.toBeNull();
(
document.querySelector(
"[data-slot=alert-dialog-close-trigger]",
) as HTMLElement
).click();
await flushPromises();
await nextTick();
expect(document.querySelector('[role="alertdialog"]')).toBeNull();
await w.get("button").trigger("click");
await flushPromises();
const cancel = [...document.querySelectorAll("button")].find(
(b) => b.textContent?.trim() === "取消",
)!;
cancel.click();
await flushPromises();
await nextTick();
expect(document.querySelector('[role="alertdialog"]')).toBeNull();
});
it("controlled parent rejects open request and allows retry", async () => {
const opens = vi.fn();
const w = view(
`<AlertDialog :is-open="false" @update:is-open="opens"><Button>打开</Button>${panel}</AlertDialog>`,
() => ({ opens }),
);
await w.get("button").trigger("click");
await flushPromises();
expect(opens).toHaveBeenCalled();
expect(document.querySelector('[role="alertdialog"]')).toBeNull();
// Same request again still emits.
const before = opens.mock.calls.length;
await w.get("button").trigger("click");
await flushPromises();
expect(opens.mock.calls.length).toBeGreaterThan(before);
});
it("supports useOverlayState controlled mode", async () => {
const w = view(
`<div><Button @click="state.open()">打开</Button><AlertDialogBackdrop :state="state"><AlertDialogContainer><AlertDialogDialog><AlertDialogHeading>状态</AlertDialogHeading></AlertDialogDialog></AlertDialogContainer></AlertDialogBackdrop></div>`,
() => ({ state: useOverlayState() }),
);
await w.get("button").trigger("click");
await flushPromises();
expect(document.querySelector('[role="alertdialog"]')).not.toBeNull();
});
it("icon status variants and custom icon slot", async () => {
const w = view(
`<AlertDialog><Button>打开</Button><AlertDialogBackdrop><AlertDialogContainer><AlertDialogDialog><AlertDialogHeader><AlertDialogIcon status="success" class="custom-icon"><span class="custom">X</span></AlertDialogIcon><AlertDialogHeading>成功</AlertDialogHeading></AlertDialogHeader></AlertDialogDialog></AlertDialogContainer></AlertDialogBackdrop></AlertDialog>`,
);
await w.get("button").trigger("click");
await flushPromises();
const icon = document.querySelector('[data-slot="alert-dialog-icon"]')!;
expect(icon.className).toContain("hv-alert-dialog__icon--success");
expect(icon.className).toContain("custom-icon");
expect(icon.querySelector(".custom")?.textContent).toBe("X");
});
it("placement and size land on container and dialog", async () => {
const w = view(
`<AlertDialog><Button>打开</Button><AlertDialogBackdrop><AlertDialogContainer placement="bottom" size="lg"><AlertDialogDialog><AlertDialogHeading>标题</AlertDialogHeading></AlertDialogDialog></AlertDialogContainer></AlertDialogBackdrop></AlertDialog>`,
);
await w.get("button").trigger("click");
await flushPromises();
const container = document.querySelector(
'[data-slot="alert-dialog-container"]',
)!;
expect(container.getAttribute("data-placement")).toBe("bottom");
expect(container.className).toContain("hv-alert-dialog__container");
const dialog = document.querySelector('[role="alertdialog"]')!;
expect(dialog.className).toContain("hv-alert-dialog__dialog--lg");
expect(dialog.getAttribute("data-placement")).toBe("bottom");
});
it("explicit aria-labelledby wins over computed titles", async () => {
const w = view(
`<AlertDialog><Button>打开</Button><AlertDialogBackdrop><AlertDialogContainer><AlertDialogDialog aria-labelledby="custom-title"><AlertDialogHeading>内部标题</AlertDialogHeading></AlertDialogDialog></AlertDialogContainer></AlertDialogBackdrop></AlertDialog>`,
);
await w.get("button").trigger("click");
await flushPromises();
const dialog = document.querySelector('[role="alertdialog"]')!;
expect(dialog.getAttribute("aria-labelledby")).toBe("custom-title");
});
it("all 14 demos mount without Vue warnings", async () => {
const names = [
"default",
"statuses",
"placements",
"sizes",
"controlled",
"custom-icon",
"custom-trigger",
"backdrop-variants",
"custom-backdrop",
"dismiss-behavior",
"close-methods",
"custom-animations",
"custom-portal",
"custom-styles",
];
expect(names).toHaveLength(14);
const warnings: string[] = [];
const spy = vi.spyOn(console, "warn").mockImplementation((...args) => {
warnings.push(args.map(String).join(" "));
});
for (const name of names) {
const mod = await import(`../apps/docs/demos/alert-dialog-${name}.vue`);
const w = mount(mod.default, { attachTo: document.body });
await nextTick();
expect(w.html().length).toBeGreaterThan(0);
w.unmount();
}
spy.mockRestore();
expect(warnings).toEqual([]);
});
it("outside pointer remains blocked by default and closes only when enabled", async () => {
const dismissable = ref(false);
const w = view(
`<AlertDialog><Button>打开</Button><AlertDialogBackdrop :is-dismissable="dismissable"><AlertDialogContainer><AlertDialogDialog><AlertDialogHeading>保护操作</AlertDialogHeading><Button>取消</Button></AlertDialogDialog></AlertDialogContainer></AlertDialogBackdrop></AlertDialog>`,
() => ({ dismissable }),
);
await w.get("button").trigger("click");
await flushPromises();
const outside = () => {
const backdrop = document.querySelector(
'[data-slot="alert-dialog-backdrop"]',
)!;
backdrop.dispatchEvent(
new MouseEvent("pointerdown", { bubbles: true, cancelable: true }),
);
backdrop.dispatchEvent(new MouseEvent("click", { bubbles: true }));
};
outside();
await flushPromises();
expect(document.querySelector('[role="alertdialog"]')).not.toBeNull();
dismissable.value = true;
await nextTick();
outside();
await flushPromises();
expect(document.querySelector('[role="alertdialog"]')).toBeNull();
});
+351
View File
@@ -0,0 +1,351 @@
import { afterEach, expect, it, vi } from "vitest";
import { mount, flushPromises } from "@vue/test-utils";
import { defineComponent, nextTick, ref } from "vue";
import { readFileSync } from "node:fs";
import {
Button,
Drawer,
DrawerBackdrop,
DrawerBody,
DrawerClose,
DrawerCloseTrigger,
DrawerContent,
DrawerDialog,
DrawerFooter,
DrawerHandle,
DrawerHeader,
DrawerHeading,
} from "../packages/vue/src";
const wrappers: ReturnType<typeof mount>[] = [];
afterEach(async () => {
for (const w of wrappers.splice(0)) w.unmount();
await flushPromises();
document.body.innerHTML = "";
});
const components = {
Drawer,
DrawerBackdrop,
DrawerContent,
DrawerDialog,
DrawerCloseTrigger,
DrawerHandle,
DrawerHeader,
DrawerHeading,
DrawerBody,
DrawerFooter,
DrawerClose,
Button,
};
const panel =
'<DrawerBackdrop><DrawerContent placement="bottom"><DrawerDialog><DrawerHandle/><DrawerCloseTrigger/><DrawerHeader><DrawerHeading>抽屉标题</DrawerHeading></DrawerHeader><DrawerBody>内容</DrawerBody><DrawerFooter><DrawerClose as-child><Button>关闭</Button></DrawerClose></DrawerFooter></DrawerDialog></DrawerContent></DrawerBackdrop>';
function view(template: string, setup = () => ({})) {
const w = mount(defineComponent({ components, template, setup }), {
attachTo: document.body,
});
wrappers.push(w);
return w;
}
it("opens drawer with dialog role and heading association", async () => {
const w = view(`<Drawer><Button>打开</Button>${panel}</Drawer>`);
await w.get("button").trigger("click");
await flushPromises();
const dialog = document.querySelector('[data-slot="drawer-dialog"]')!;
expect(dialog).not.toBeNull();
const labelled = dialog.getAttribute("aria-labelledby")!;
expect(document.getElementById(labelled)?.textContent).toContain("抽屉标题");
expect(
document
.querySelector('[data-slot="drawer-handle"]')
?.getAttribute("aria-hidden"),
).toBe("true");
});
it("places panel by placement class", async () => {
const w = view(
`<Drawer><Button>打开</Button><DrawerBackdrop><DrawerContent placement="left"><DrawerDialog><DrawerHeading>左</DrawerHeading></DrawerDialog></DrawerContent></DrawerBackdrop></Drawer>`,
);
await w.get("button").trigger("click");
await flushPromises();
const content = document.querySelector('[data-slot="drawer-content"]')!;
expect(content.className).toContain("hv-drawer__content--left");
expect(content.getAttribute("data-placement")).toBe("left");
const dialog = document.querySelector('[data-slot="drawer-dialog"]')!;
expect(dialog.getAttribute("data-placement")).toBe("left");
});
it("isDismissable=false blocks drag handlers on the dialog", async () => {
const w = view(
`<Drawer><Button>打开</Button><DrawerBackdrop :is-dismissable="false"><DrawerContent><DrawerDialog><DrawerHeading>不可拖</DrawerHeading></DrawerDialog></DrawerContent></DrawerBackdrop></Drawer>`,
);
await w.get("button").trigger("click");
await flushPromises();
const dialog = document.querySelector('[data-slot="drawer-dialog"]')!;
expect(dialog.getAttribute("style") ?? "").not.toContain("none");
});
it("drag past 30% dimension closes the drawer", async () => {
const w = view(`<Drawer><Button>打开</Button>${panel}</Drawer>`);
await w.get("button").trigger("click");
await flushPromises();
const dialog = document.querySelector('[data-slot="drawer-dialog"]')!;
// Give the dialog a measurable height (jsdom defaults to 0).
Object.defineProperty(dialog, "offsetHeight", {
value: 200,
configurable: true,
});
function pointer(type: string, clientY: number) {
const event = new MouseEvent(type, {
bubbles: true,
cancelable: true,
button: 0,
clientY,
});
Object.defineProperty(event, "pointerId", { value: 1 });
dialog.dispatchEvent(event);
}
pointer("pointerdown", 100);
pointer("pointermove", 120);
pointer("pointermove", 180);
// 80px of 200 = 40% > 30% → dismiss
pointer("pointerup", 180);
await flushPromises();
await nextTick();
expect(document.querySelector('[data-slot="drawer-dialog"]')).toBeNull();
});
it("small slow drag snaps back and does not dismiss", async () => {
const w = view(`<Drawer><Button>打开</Button>${panel}</Drawer>`);
await w.get("button").trigger("click");
await flushPromises();
const dialog = document.querySelector<HTMLElement>(
'[data-slot="drawer-dialog"]',
)!;
Object.defineProperty(dialog, "offsetHeight", {
value: 200,
configurable: true,
});
// Controlled clock: 10px over 200ms → 0.05px/ms, well under the 0.5 threshold.
let now = 1_000_000;
const nowSpy = vi.spyOn(Date, "now").mockImplementation(() => now);
function pointer(type: string, clientY: number) {
now += 100;
const event = new MouseEvent(type, {
bubbles: true,
cancelable: true,
button: 0,
clientY,
});
Object.defineProperty(event, "pointerId", { value: 1 });
dialog.dispatchEvent(event);
}
pointer("pointerdown", 100);
pointer("pointermove", 105);
pointer("pointermove", 110);
pointer("pointerup", 110);
nowSpy.mockRestore();
await flushPromises();
await nextTick();
expect(document.querySelector('[data-slot="drawer-dialog"]')).not.toBeNull();
});
it("fast flick closes even under the distance threshold", async () => {
const w = view(`<Drawer><Button>打开</Button>${panel}</Drawer>`);
await w.get("button").trigger("click");
await flushPromises();
const dialog = document.querySelector<HTMLElement>(
'[data-slot="drawer-dialog"]',
)!;
Object.defineProperty(dialog, "offsetHeight", {
value: 200,
configurable: true,
});
// 15px in 10ms → 1.5px/ms > 0.5, dismiss on velocity alone.
let now = 1_000_000;
const nowSpy = vi.spyOn(Date, "now").mockImplementation(() => now);
function pointer(type: string, clientY: number) {
now += 5;
const event = new MouseEvent(type, {
bubbles: true,
cancelable: true,
button: 0,
clientY,
});
Object.defineProperty(event, "pointerId", { value: 1 });
dialog.dispatchEvent(event);
}
pointer("pointerdown", 100);
pointer("pointermove", 110);
pointer("pointerup", 115);
nowSpy.mockRestore();
await flushPromises();
await nextTick();
expect(document.querySelector('[data-slot="drawer-dialog"]')).toBeNull();
});
it("controlled parent rejects open and allows retry", async () => {
const opens = vi.fn();
const w = view(
`<Drawer :is-open="false" @update:is-open="opens"><Button>打开</Button>${panel}</Drawer>`,
() => ({ opens }),
);
await w.get("button").trigger("click");
await flushPromises();
expect(opens).toHaveBeenCalled();
expect(document.querySelector('[data-slot="drawer-dialog"]')).toBeNull();
const before = opens.mock.calls.length;
await w.get("button").trigger("click");
await flushPromises();
expect(opens.mock.calls.length).toBeGreaterThan(before);
});
it("closes via DrawerClose and close trigger", async () => {
const w = view(`<Drawer><Button>打开</Button>${panel}</Drawer>`);
await w.get("button").trigger("click");
await flushPromises();
(
document.querySelector("[data-slot=drawer-close-trigger]") as HTMLElement
).click();
await flushPromises();
await nextTick();
expect(document.querySelector('[data-slot="drawer-dialog"]')).toBeNull();
await w.get("button").trigger("click");
await flushPromises();
[...document.querySelectorAll("button")]
.find((b) => b.textContent?.trim() === "关闭")!
.click();
await flushPromises();
await nextTick();
expect(document.querySelector('[data-slot="drawer-dialog"]')).toBeNull();
});
it("all 9 demos mount without Vue warnings", async () => {
const names = [
"basic",
"placements",
"non-dismissable",
"scrollable-content",
"controlled",
"with-form",
"navigation",
"backdrop-variants",
"custom-styles",
];
expect(names).toHaveLength(9);
const warnings: string[] = [];
const spy = vi.spyOn(console, "warn").mockImplementation((...args) => {
warnings.push(args.map(String).join(" "));
});
for (const name of names) {
const mod = await import(`../apps/docs/demos/drawer-${name}.vue`);
const w = mount(mod.default, { attachTo: document.body });
await nextTick();
expect(w.html().length).toBeGreaterThan(0);
w.unmount();
}
spy.mockRestore();
expect(warnings).toEqual([]);
});
it("uses CSS animations so Presence can defer exit unmount", async () => {
// Source contract: enter/exit must be CSS animations (not only transitions)
// because Reka Presence keys off animationName. jsdom has no animation
// engine so runtime deferral is verified in the browser instead.
const css = readFileSync("packages/styles/components/drawer.css", "utf8");
for (const name of [
"hv-drawer-backdrop-in",
"hv-drawer-backdrop-out",
"hv-drawer-in-from-bottom",
"hv-drawer-out-to-bottom",
"hv-drawer-out-to-right",
"hv-drawer-out-to-left",
"hv-drawer-out-to-top",
]) {
expect(css).toContain(`@keyframes ${name}`);
}
expect(css).toMatch(/\.hv-drawer__dialog\[data-exiting="true"\]/);
expect(css).not.toMatch(
/\.hv-drawer__dialog\s*\{[^}]*transition:\s*translate/,
);
});
it("multiple drawers can coexist with unique heading ids", async () => {
const w = mount(
defineComponent({
components,
template: `
<div>
<Drawer>
<Button class="open-a">打开 A</Button>
<DrawerBackdrop>
<DrawerContent placement="bottom">
<DrawerDialog>
<DrawerHeading>抽屉 A</DrawerHeading>
</DrawerDialog>
</DrawerContent>
</DrawerBackdrop>
</Drawer>
<Drawer>
<Button class="open-b">打开 B</Button>
<DrawerBackdrop>
<DrawerContent placement="right">
<DrawerDialog>
<DrawerHeading>抽屉 B</DrawerHeading>
</DrawerDialog>
</DrawerContent>
</DrawerBackdrop>
</Drawer>
</div>
`,
}),
{ attachTo: document.body },
);
wrappers.push(w);
await w.get("button.open-a").trigger("click");
await flushPromises();
await w.get("button.open-b").trigger("click");
await flushPromises();
const dialogs = document.querySelectorAll('[data-slot="drawer-dialog"]');
expect(dialogs.length).toBe(2);
const ids = [...dialogs].map((d) => d.getAttribute("aria-labelledby"));
expect(new Set(ids).size).toBe(2);
for (const id of ids) {
expect(id && document.getElementById(id)).toBeTruthy();
}
});
it("outside click closes when isDismissable and not when disabled", async () => {
const w = view(`<Drawer><Button>打开</Button>${panel}</Drawer>`);
await w.get("button").trigger("click");
await flushPromises();
expect(document.querySelector('[data-slot="drawer-dialog"]')).not.toBeNull();
// Click the backdrop (outside the dialog panel).
const backdrop = document.querySelector("[data-slot=drawer-backdrop]");
backdrop!.dispatchEvent(
new MouseEvent("pointerdown", { bubbles: true, cancelable: true }),
);
backdrop!.dispatchEvent(new MouseEvent("click", { bubbles: true }));
await flushPromises();
await nextTick();
expect(document.querySelector('[data-slot="drawer-dialog"]')).toBeNull();
// Non-dismissable: outside click keeps the panel.
const w2 = view(
`<Drawer><Button>打开</Button><DrawerBackdrop :is-dismissable="false"><DrawerContent><DrawerDialog><DrawerHeading>不可关</DrawerHeading></DrawerDialog></DrawerContent></DrawerBackdrop></Drawer>`,
);
await w2.get("button").trigger("click");
await flushPromises();
const backdrop2 = document.querySelector("[data-slot=drawer-backdrop]")!;
backdrop2.dispatchEvent(
new MouseEvent("pointerdown", { bubbles: true, cancelable: true }),
);
backdrop2.dispatchEvent(new MouseEvent("click", { bubbles: true }));
await flushPromises();
await nextTick();
expect(document.querySelector('[data-slot="drawer-dialog"]')).not.toBeNull();
});
+42
View File
@@ -0,0 +1,42 @@
import { afterEach, expect, it, vi } from "vitest";
import { mount, flushPromises } from "@vue/test-utils";
import { defineComponent, h, nextTick } from "vue";
const demos = import.meta.glob(
"../apps/docs/demos/{alert-dialog,drawer}-*.vue",
);
const wrappers: ReturnType<typeof mount>[] = [];
afterEach(async () => {
wrappers.splice(0).forEach((w) => w.unmount());
await flushPromises();
vi.restoreAllMocks();
document.body.innerHTML = "";
});
it("all 23 overlay demos coexist in one Vue app without duplicate IDs or warnings", async () => {
const entries = await Promise.all(
Object.values(demos).map(
async (load) =>
((await load()) as { default: Parameters<typeof h>[0] }).default,
),
);
expect(entries).toHaveLength(23);
const warnings = vi.spyOn(console, "warn").mockImplementation(() => {});
const wrapper = mount(
defineComponent({
render: () =>
h(
"main",
entries.map((demo, i) => h("section", { "data-demo": i }, [h(demo)])),
),
}),
{ attachTo: document.body },
);
wrappers.push(wrapper);
await flushPromises();
await nextTick();
expect(wrapper.findAll("section[data-demo]")).toHaveLength(23);
expect(wrapper.findAll("button").length).toBeGreaterThan(23);
const ids = [...document.querySelectorAll("[id]")].map((el) => el.id);
expect(new Set(ids).size).toBe(ids.length);
expect(warnings).not.toHaveBeenCalled();
});
@@ -0,0 +1,114 @@
import { afterEach, expect, it, vi } from "vitest";
import { mount } from "@vue/test-utils";
import { defineComponent, h, nextTick, ref } from "vue";
import { useDrawerDrag } from "../packages/vue/src/components/drawer/useDrawerDrag";
const wrappers: ReturnType<typeof mount>[] = [];
afterEach(() => wrappers.splice(0).forEach((w) => w.unmount()));
async function gesture() {
const open = ref(true);
const wrapper = mount(
defineComponent({
setup() {
const { dialogRef } = useDrawerDrag(
ref("bottom"),
ref(true),
open,
() => {
open.value = false;
},
);
// Keep the node mounted to model Presence retaining it through exit.
return () => h("div", { ref: dialogRef, "data-slot": "drawer-dialog" });
},
}),
{ attachTo: document.body },
);
wrappers.push(wrapper);
await nextTick();
const el = wrapper.element as HTMLElement;
Object.defineProperty(el, "offsetHeight", { value: 200 });
function pointer(type: string, clientY: number) {
const event = new MouseEvent(type, { bubbles: true, button: 0, clientY });
Object.defineProperty(event, "pointerId", { value: 1 });
el.dispatchEvent(event);
}
return { el, open, pointer };
}
it("normal lost capture after an accepted drag-close preserves exit offset", async () => {
const { el, open, pointer } = await gesture();
pointer("pointerdown", 100);
pointer("pointermove", 180);
pointer("pointerup", 180);
await nextTick();
expect(open.value).toBe(false);
expect(el.style.transform).toBe("translateY(80px)");
pointer("lostpointercapture", 180);
expect(el.style.transform).toBe("translateY(80px)");
});
it("programmatic close prevents retained exit node from continuing to drag", async () => {
const { el, open, pointer } = await gesture();
pointer("pointerdown", 100);
pointer("pointermove", 120);
open.value = false;
await nextTick();
const closingTransform = el.style.transform;
pointer("pointermove", 180);
expect(el.style.transform).toBe(closingTransform);
});
it("reopening a retained exit node clears the old drag offset", async () => {
const { el, open, pointer } = await gesture();
pointer("pointerdown", 100);
pointer("pointermove", 180);
pointer("pointerup", 180);
await nextTick();
expect(el.style.transform).toBe("translateY(80px)");
open.value = true;
await nextTick();
expect(el.style.transform).toBe("");
pointer("lostpointercapture", 180);
expect(el.style.transform).toBe("");
});
it("replacing the dialog releases and clears the old node, leaving the new node intact", async () => {
let replace!: (el: HTMLElement) => void;
const wrapper = mount(
defineComponent({
setup() {
const { dialogRef } = useDrawerDrag(
ref("bottom"),
ref(true),
ref(true),
() => {},
);
replace = (el) => {
dialogRef.value = el;
};
return () => h("div", { ref: dialogRef, "data-slot": "drawer-dialog" });
},
}),
{ attachTo: document.body },
);
wrappers.push(wrapper);
await nextTick();
const old = wrapper.element as HTMLElement;
const release = vi.fn();
Object.defineProperty(old, "setPointerCapture", { value: vi.fn() });
Object.defineProperty(old, "releasePointerCapture", { value: release });
for (const [type, clientY] of [
["pointerdown", 100],
["pointermove", 120],
] as const) {
const e = new MouseEvent(type, { bubbles: true, button: 0, clientY });
Object.defineProperty(e, "pointerId", { value: 7 });
old.dispatchEvent(e);
}
expect(old.style.transform).toBe("translateY(20px)");
const next = document.createElement("div");
next.style.transform = "scale(1.1)";
replace(next);
await nextTick();
expect(release).toHaveBeenCalledWith(7);
expect(old.style.transform).toBe("");
expect(next.style.transform).toBe("scale(1.1)");
});
+115
View File
@@ -0,0 +1,115 @@
import { afterEach, expect, it, vi } from "vitest";
import { mount, flushPromises } from "@vue/test-utils";
import { defineComponent, nextTick, ref } from "vue";
import {
Drawer,
DrawerBackdrop,
DrawerContent,
DrawerDialog,
DrawerHeading,
} from "../packages/vue/src";
const wrappers: ReturnType<typeof mount>[] = [];
afterEach(async () => {
wrappers.splice(0).forEach((w) => w.unmount());
await flushPromises();
vi.restoreAllMocks();
document.body.innerHTML = "";
});
async function panel(controlled = false, preventDrag = false) {
const dismissable = ref(true);
const placement = ref<"bottom" | "left">("bottom");
const requests = vi.fn();
const w = mount(
defineComponent({
components: {
Drawer,
DrawerBackdrop,
DrawerContent,
DrawerDialog,
DrawerHeading,
},
setup: () => ({
dismissable,
placement,
requests,
controlled,
preventDrag,
}),
template: `<Drawer :open="controlled ? true : undefined" :default-open="true" @update:open="requests"><DrawerBackdrop :is-dismissable="dismissable"><DrawerContent :placement="placement"><DrawerDialog @pointerdown.capture="preventDrag && $event.preventDefault()"><DrawerHeading>Review drawer</DrawerHeading></DrawerDialog></DrawerContent></DrawerBackdrop></Drawer>`,
}),
{ attachTo: document.body },
);
wrappers.push(w);
await flushPromises();
const el = document.querySelector<HTMLElement>(
'[data-slot="drawer-dialog"]',
)!;
Object.defineProperty(el, "offsetHeight", { configurable: true, value: 200 });
Object.defineProperty(el, "offsetWidth", { configurable: true, value: 200 });
let now = 1000;
vi.spyOn(Date, "now").mockImplementation(() => now);
function pointer(type: string, y: number, pointerId = 1) {
now += 100;
const e = new MouseEvent(type, {
bubbles: true,
cancelable: true,
button: 0,
clientY: y,
});
Object.defineProperty(e, "pointerId", { value: pointerId });
el.dispatchEvent(e);
}
return { el, pointer, dismissable, placement, requests };
}
it("controlled rejected drag close restores the still-open panel", async () => {
const { el, pointer, requests } = await panel(true);
pointer("pointerdown", 100);
pointer("pointermove", 180);
pointer("pointerup", 180);
await flushPromises();
expect(requests).toHaveBeenCalledWith(false);
expect(el.isConnected).toBe(true);
expect(el.style.transform).toBe("");
expect(el.style.transition).not.toBe("none");
});
it("turning dismissable off during a drag cancels it without a close request", async () => {
const { el, pointer, dismissable, requests } = await panel(true);
pointer("pointerdown", 100);
pointer("pointermove", 180);
dismissable.value = false;
await nextTick();
pointer("pointerup", 180);
await flushPromises();
expect(requests).not.toHaveBeenCalled();
expect(el.style.transform).toBe("");
});
it("placement change cancels the old-axis drag", async () => {
const { el, pointer, placement } = await panel(true);
pointer("pointerdown", 100);
pointer("pointermove", 120);
placement.value = "left";
await nextTick();
expect(el.style.transform).toBe("");
expect(el.style.transition).not.toBe("none");
});
it("another pointer cannot move or finish the owning pointer gesture", async () => {
const { el, pointer, requests } = await panel(true);
pointer("pointerdown", 100, 1);
pointer("pointermove", 180, 2);
pointer("pointerup", 180, 2);
await flushPromises();
expect(requests).not.toHaveBeenCalled();
expect(el.style.transform).toBe("");
});
it("caller cancellation prevents starting the drag", async () => {
const { el, pointer, requests } = await panel(true, true);
pointer("pointerdown", 100);
pointer("pointermove", 180);
pointer("pointerup", 180);
await flushPromises();
expect(requests).not.toHaveBeenCalled();
expect(el.style.transform).toBe("");
});
+2
View File
@@ -17,3 +17,5 @@ SLIDER-01 已在 `/private/tmp/heroui-slider-consumer` 完成上述检查,临
M30–M32 增加 consume-m30-m32.mjs 和 m30-m32-contract.ts。将它们复制到同一个独立消费工程,执行运行脚本,并将契约文件加入上述两种 tsc 命令。合并后的产物还应同时通过原 NumberField/Slider 消费检查,避免只验证新加组件。
LISTBOX-01 增加 `consume-list-box.mjs` / `list-box-contract.ts`。同样复制到独立消费者,用两份新 tarball 安装后运行脚本,并在 NodeNext / bundler 两种模式执行契约文件。Root 的泛型 Props 曾在 Parameters 提取后退化,非法模型/模式反例与事件参数推断必须保留。
M33–M34 使用 consume-m33-m34.mjs / m33-m34-contract.ts;同样复制到独立 tarball 消费工程,分别运行 node 与两种解析模式的 tsc。包括所有公开部件、真正 node SSR、CSS 关键帧与策略/尺寸/方向的正反类型检查。集成验证目录为 /private/tmp/heroui-m33-consumer,不复用其他并行任务的临时产物。
+63
View File
@@ -0,0 +1,63 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { createSSRApp, h } from "vue";
import { renderToString } from "@vue/server-renderer";
import * as library from "@heroui-vue/components";
for (const name of [
"AlertDialog",
"AlertDialogRoot",
"AlertDialogTrigger",
"AlertDialogBackdrop",
"AlertDialogContainer",
"AlertDialogDialog",
"AlertDialogHeader",
"AlertDialogHeading",
"AlertDialogBody",
"AlertDialogFooter",
"AlertDialogIcon",
"AlertDialogCloseTrigger",
"AlertDialogClose",
"Drawer",
"DrawerRoot",
"DrawerTrigger",
"DrawerBackdrop",
"DrawerContent",
"DrawerDialog",
"DrawerHeader",
"DrawerHeading",
"DrawerBody",
"DrawerFooter",
"DrawerHandle",
"DrawerCloseTrigger",
"DrawerClose",
])
assert(library[name], name);
for (const family of ["AlertDialog", "Drawer"]) {
const html = await renderToString(
createSSRApp({
render: () =>
h(library[family], {}, () => [
h(
library[`${family}Trigger`],
{ as: "button" },
() => `Open ${family}`,
),
h(library[`${family}Backdrop`], {}, () =>
family === "Drawer"
? h(library.DrawerContent)
: h(library.AlertDialogContainer),
),
]),
}),
);
assert(html.includes(`Open ${family}`));
assert(html.includes('aria-expanded="false"'));
}
const css = readFileSync(
new URL(import.meta.resolve("@heroui-vue/styles/css")),
"utf8",
);
assert(css.includes(".hv-alert-dialog__dialog"));
assert(css.includes("hv-drawer-in-from-right"));
assert(css.includes("hv-drawer-out-to-bottom"));
console.log("M33-M34 tarball ESM exports, node SSR and CSS passed");
+40
View File
@@ -0,0 +1,40 @@
import {
type AlertDialogContainerProps,
type AlertDialogIconProps,
type AlertDialogBackdropProps,
type DrawerContentProps,
type DrawerBackdropProps,
DrawerHandle,
AlertDialog,
} from "@heroui-vue/components";
const size: AlertDialogContainerProps = { size: "cover", placement: "bottom" };
const status: AlertDialogIconProps = { status: "danger" };
const backdrop: AlertDialogBackdropProps = {
isDismissable: false,
isKeyboardDismissDisabled: true,
};
const drawer: DrawerContentProps = { placement: "left" };
const state: DrawerBackdropProps = {
open: true,
"onUpdate:open": (v: boolean) => {
void v;
},
};
// @ts-expect-error placement is constrained
const invalidDirection: DrawerContentProps = { placement: "diagonal" };
// @ts-expect-error size is constrained
const invalidSize: AlertDialogContainerProps = { size: "giant" };
// @ts-expect-error dismiss policy must remain Boolean
const invalidPolicy: AlertDialogBackdropProps = { isDismissable: "false" };
void [
size,
status,
backdrop,
drawer,
state,
invalidDirection,
invalidSize,
invalidPolicy,
DrawerHandle,
AlertDialog,
];