feat: migrate AlertDialog and Drawer with reviewed overlay lifecycles
This commit is contained in:
@@ -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)
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user