feat: migrate Modal Popover and Tooltip with shared overlay foundation
This commit is contained in:
@@ -335,3 +335,20 @@ Vaul Vue 官方已说明停止维护并推荐 Reka Drawer;新项目不采用 V
|
||||
## 独立复核方式(用户约定,2026-10-22)
|
||||
|
||||
- 复核以代码规范、设计/状态协议、公共 API、固定 HeroUI 基线差异和集成回归为主;浏览器只重点验证测量/焦点/动画等关键风险,不逐个点击全部演示。全量示例清单、编译与自动挂载仍按适用性执行,不能因减少手工点击而省略契约检查。
|
||||
|
||||
## OVERLAY-01 弹层基础设施(2026-10-22)
|
||||
|
||||
- 后续弹层先读 [弹层基础设施协议](docs/decisions/overlay-foundation.md)。`useOverlayState` / ConfigProvider 与私有 overlay 由集成人维护;其他 AI 的 ScrollShadow/Tabs 不改这些文件。
|
||||
- 复用 Reka 的 FocusScope、DismissableLayer、Presence、Teleport 与锁协议,不各自建立 document 关闭监听或 body 锁栈。Dialog、Popover、Tooltip 保留各自底座和语义。
|
||||
- OVERLAY-01 阶段先验证私有 primitive;后续公共组件已在 OVERLAY-02 迁移,具体状态见兼容矩阵。SSR Portal 挂载后插入,不得据此声明 Nuxt 或完整可访问性验收完成。
|
||||
|
||||
## OVERLAY-02 后续弹层适配约束
|
||||
|
||||
- Modal / Popover / Tooltip 已迁移,先读 [迁移与差异报告](docs/migrations/OVERLAY-02-modal-popover-tooltip.md)。三个家族和 overlay 私有适配、ConfigProvider、useOverlayState 仍由集成人维护;其他任务不要另建关闭/焦点/锁栈。
|
||||
- Trigger 自动组合只识别首个直接 Button / button / a;任意自定义组件用显式 Trigger asChild,要求唯一有效根。事件数组、capture、preventDefault 与 stopImmediatePropagation 用 Vue DOM 事件合并,不照抄私有 invoker 标记。
|
||||
- 定位层用 Reka 的实际 data-side / data-align / transform-origin;箭头方向已由底座旋转,不再叠加 RAC SVG 旋转。内容标题和 Dialog ARIA 必须检查真正的 role 节点,不只检查内部视觉层。
|
||||
- Presence 根据真实动画卸载:父容器有退出动画而 Dialog 没有时,必须协调其保留;reduced-motion 及时移除 entering。复测快速关闭再打开,不固定写死卸载计时。自定义遮罩/容器动画应保持兼容的退出时长。
|
||||
- Tooltip 定时器必须覆盖卸载、禁用、受控外部关闭再打开、其他 Tooltip 接替及中断退出。当前依赖 Reka 2.11 的 tooltip.open 协调事件与公开上下文;升级底座时回归其契约。
|
||||
- Popover 模态 closeAutoFocus 的取消能力与 Reka 有已记录差异,不在文档承诺可取消;Tooltip Provider warmup 不宣称等价 RAC 全局调度。新增能力先验证实际底座而非只改类型和表格。
|
||||
|
||||
- 动画测量态不能用未经规范化的 style 字符串精确比较:浏览器会把 `translate(0, -200%)` 序列化为 `translate(0px, -200%)`。把临时 `animation:none` 当成 reduced-motion 会提前删掉 entering,Popover/Tooltip 因而跳过进入动画。回归同时覆盖 CSSOM 两种写法、定位后开始及真正无动画路径;真实浏览器检查 animationstart/end 和时长,不只检查关闭后节点消失。
|
||||
|
||||
@@ -72,6 +72,8 @@ const groups = [
|
||||
{ title: "Label 标签", url: "/components/label" },
|
||||
{ title: "Link 链接", url: "/components/link" },
|
||||
{ title: "Meter 计量条", url: "/components/meter" },
|
||||
{ title: "Modal 模态框", url: "/components/modal" },
|
||||
{ title: "Popover 弹出框", url: "/components/popover" },
|
||||
{ title: "ProgressBar 进度条", url: "/components/progress-bar" },
|
||||
{
|
||||
title: "ProgressCircle 环形进度条",
|
||||
@@ -86,6 +88,7 @@ const groups = [
|
||||
{ title: "Switch 开关", url: "/components/switch" },
|
||||
{ title: "TextArea 多行文本框", url: "/components/textarea" },
|
||||
{ title: "TextField 文本输入框", url: "/components/text-field" },
|
||||
{ title: "Tooltip 工具提示", url: "/components/tooltip" },
|
||||
{ title: "Typography 排版", url: "/components/typography" },
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@import "tailwindcss/theme.css" layer(theme);
|
||||
@import "../../../../packages/styles/themes/shared/theme.css";
|
||||
@import "../../../../packages/styles/animations.css";
|
||||
@import "tailwindcss/utilities.css" layer(utilities);
|
||||
@source "../../demos";
|
||||
|
||||
|
||||
@@ -41,3 +41,7 @@ description: 已迁移组件及文档
|
||||
- [Checkbox 复选框](./components/checkbox)
|
||||
- [CheckboxGroup 复选框组](./components/checkbox-group)
|
||||
- [RadioGroup 单选框组](./components/radio-group)
|
||||
|
||||
- [Modal 模态框](./components/modal)
|
||||
- [Popover 弹出框](./components/popover)
|
||||
- [Tooltip 工具提示](./components/tooltip)
|
||||
|
||||
@@ -0,0 +1,307 @@
|
||||
---
|
||||
title: Modal 模态框
|
||||
description: 用于聚焦用户交互与重要内容的对话框遮罩层。
|
||||
component: modal
|
||||
group: 组件
|
||||
---
|
||||
|
||||
> 基于固定 HeroUI 3.2.6(ce90ea3)迁移。命名组件、v-model、作用域插槽与 DOM attrs 为 Vue 适配;预览、复制与高亮来自同一份 SFC。
|
||||
|
||||
## 用法
|
||||
|
||||
```ts
|
||||
import { Modal } from "@heroui-vue/components";
|
||||
```
|
||||
|
||||
<ComponentPreview name="modal-default" />
|
||||
|
||||
## 组件结构
|
||||
|
||||
Vue 使用具名组件导出。根组件也可将第一个 Button 作为触发器;明确组合时使用 ModalTrigger。
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Modal,
|
||||
ModalTrigger,
|
||||
ModalBackdrop,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalCloseTrigger,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
ModalBody,
|
||||
ModalFooter,
|
||||
ModalClose,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Modal>
|
||||
<ModalTrigger as-child><Button>Open Modal</Button></ModalTrigger>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer>
|
||||
<ModalDialog>
|
||||
<ModalCloseTrigger />
|
||||
<ModalHeader><ModalHeading>标题</ModalHeading></ModalHeader>
|
||||
<ModalBody>内容</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child><Button>关闭</Button></ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</template>
|
||||
```
|
||||
|
||||
## 示例
|
||||
|
||||
### 尺寸
|
||||
|
||||
<ComponentPreview name="modal-sizes" />
|
||||
|
||||
### 位置
|
||||
|
||||
<ComponentPreview name="modal-placements" />
|
||||
|
||||
### 滚动行为
|
||||
|
||||
<ComponentPreview name="modal-scroll-comparison" />
|
||||
|
||||
### 受控状态
|
||||
|
||||
<ComponentPreview name="modal-controlled" />
|
||||
|
||||
### 搭配表单
|
||||
|
||||
<ComponentPreview name="modal-with-form" />
|
||||
|
||||
### 自定义触发器
|
||||
|
||||
<ComponentPreview name="modal-custom-trigger" />
|
||||
|
||||
### 遮罩变体
|
||||
|
||||
<ComponentPreview name="modal-backdrop-variants" />
|
||||
|
||||
### 自定义遮罩
|
||||
|
||||
<ComponentPreview name="modal-custom-backdrop" />
|
||||
|
||||
### 关闭行为
|
||||
|
||||
<ComponentPreview name="modal-dismiss-behavior" />
|
||||
|
||||
### 关闭方式
|
||||
|
||||
<ComponentPreview name="modal-close-methods" />
|
||||
|
||||
### 自定义动画
|
||||
|
||||
<ComponentPreview name="modal-custom-animations" />
|
||||
|
||||
### 自定义 Portal
|
||||
|
||||
<ComponentPreview name="modal-custom-portal" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="modal-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
若要自定义组件类,可使用 `@layer components` 指令。[了解更多](https://tailwindcss.com/docs/adding-custom-styles#adding-component-classes)。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-modal__backdrop {
|
||||
@apply bg-gradient-to-br from-black/50 to-black/70;
|
||||
}
|
||||
|
||||
.hv-modal__dialog {
|
||||
@apply rounded-2xl border border-white/10 shadow-2xl;
|
||||
}
|
||||
|
||||
.hv-modal__header {
|
||||
@apply text-center;
|
||||
}
|
||||
|
||||
.hv-modal__close-trigger {
|
||||
@apply rounded-full bg-white/10 hover:bg-white/20;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
|
||||
|
||||
### CSS 类
|
||||
|
||||
Modal 使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/modal.css)):
|
||||
|
||||
#### 基础类
|
||||
|
||||
- `.hv-modal__trigger` — 打开 Modal 的触发元素
|
||||
- `.hv-modal__backdrop` — Modal 背后的遮罩层
|
||||
- `.hv-modal__container` — 支持 placement 的定位包裹层
|
||||
- `.hv-modal__dialog` — Modal 内容容器
|
||||
- `.hv-modal__header` — 标题与图标区域
|
||||
- `.hv-modal__body` — 主内容区域
|
||||
- `.hv-modal__footer` — 操作区域
|
||||
- `.hv-modal__close-trigger` — 关闭按钮元素
|
||||
|
||||
#### 遮罩变体
|
||||
|
||||
- `.hv-modal__backdrop--opaque` — 不透明有色遮罩(默认)
|
||||
- `.hv-modal__backdrop--blur` — 带玻璃效果的模糊遮罩
|
||||
- `.hv-modal__backdrop--transparent` — 透明遮罩(无叠加层)
|
||||
|
||||
#### 滚动变体
|
||||
|
||||
- `.hv-modal__container--scroll-outside` — 允许整个 Modal 滚动
|
||||
- `.hv-modal__dialog--scroll-inside` — 限制 Modal 高度,由 body 区域滚动
|
||||
- `.hv-modal__body--scroll-inside` — 仅 body 区域可滚动
|
||||
- `.hv-modal__body--scroll-outside` — 允许整页滚动
|
||||
|
||||
### 交互状态
|
||||
|
||||
组件支持以下交互状态:
|
||||
|
||||
- **焦点**:`:focus-visible` 或 `[data-focus-visible="true"]` — 应用于触发器、对话框与关闭按钮
|
||||
- **悬停**:`:hover` 或 `[data-hovered="true"]` — 应用于关闭按钮悬停
|
||||
- **按下**:`:active` 或 `[data-pressed="true"]` — 应用于关闭按钮按下
|
||||
- **进入**:`[data-entering]` — Modal 打开动画期间
|
||||
- **离开**:`[data-exiting]` — Modal 关闭动画期间
|
||||
- **位置**:`[data-placement="*"]` — 基于 Modal 位置(auto、top、center、bottom)
|
||||
|
||||
## API 参考
|
||||
|
||||
### Modal
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ---------- | -------------- | ------ | ---------------- |
|
||||
| `默认插槽` | `VNode / 插槽` | - | 触发器与容器元素 |
|
||||
|
||||
### ModalTrigger
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ---------- | ------------------------- | ------ | -------------- |
|
||||
| `默认插槽` | `VNode / 插槽` | - | 自定义触发内容 |
|
||||
| `class` | `string / object / array` | - | CSS 类 |
|
||||
|
||||
### ModalBackdrop
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| --------------------------- | ------------------------------------- | ---------- | -------------------- |
|
||||
| `variant` | `"opaque" \| "blur" \| "transparent"` | `"opaque"` | 遮罩叠加样式 |
|
||||
| `isDismissable` | `boolean` | `true` | 点击遮罩是否关闭 |
|
||||
| `isKeyboardDismissDisabled` | `boolean` | `false` | 是否禁用 ESC 关闭 |
|
||||
| `isOpen` | `boolean` | - | 受控打开状态 |
|
||||
| `@open-change` | `(isOpen: boolean) => void` | - | 打开状态变化处理函数 |
|
||||
| `class` | `string / object / array` | - | 遮罩 CSS 类 |
|
||||
| `to` | `HTMLElement` | - | 自定义 portal 容器 |
|
||||
|
||||
### ModalContainer
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ----------- | --------------------------------------------------- | ---------- | -------------------- |
|
||||
| `placement` | `"auto" \| "center" \| "top" \| "bottom"` | `"auto"` | Modal 在屏幕上的位置 |
|
||||
| `scroll` | `"inside" \| "outside"` | `"inside"` | 滚动行为 |
|
||||
| `size` | `"xs" \| "sm" \| "md" \| "lg" \| "cover" \| "full"` | `"md"` | Modal 尺寸变体 |
|
||||
| `class` | `string / object / array` | - | 容器 CSS 类 |
|
||||
|
||||
### ModalDialog
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------------------ | ------------------------- | ---------- | -------------- |
|
||||
| `默认插槽` | `作用域插槽 { close }` | - | 内容或渲染函数 |
|
||||
| `class` | `string / object / array` | - | CSS 类 |
|
||||
| `role` | `string` | `"dialog"` | ARIA role |
|
||||
| `aria-label` | `string` | - | 无障碍标签 |
|
||||
| `aria-labelledby` | `string` | - | 标签元素的 id |
|
||||
| `aria-describedby` | `string` | - | 描述元素的 id |
|
||||
|
||||
### ModalHeader
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ---------- | ------------------------- | ------ | -------- |
|
||||
| `默认插槽` | `VNode / 插槽` | - | 头部内容 |
|
||||
| `class` | `string / object / array` | - | CSS 类 |
|
||||
|
||||
### ModalBody
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ---------- | ------------------------- | ------ | -------- |
|
||||
| `默认插槽` | `VNode / 插槽` | - | 正文内容 |
|
||||
| `class` | `string / object / array` | - | CSS 类 |
|
||||
|
||||
### ModalFooter
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ---------- | ------------------------- | ------ | -------- |
|
||||
| `默认插槽` | `VNode / 插槽` | - | 底部内容 |
|
||||
| `class` | `string / object / array` | - | CSS 类 |
|
||||
|
||||
### ModalCloseTrigger
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ---------- | ------------------------- | ------ | -------------- |
|
||||
| `默认插槽` | `VNode / 插槽` | - | 自定义关闭按钮 |
|
||||
| `class` | `string / object / array` | - | CSS 类 |
|
||||
|
||||
### useOverlayState Hook
|
||||
|
||||
```ts
|
||||
import { useOverlayState } from "@heroui-vue/components";
|
||||
|
||||
const state = useOverlayState({
|
||||
defaultOpen: false,
|
||||
onOpenChange: console.log,
|
||||
});
|
||||
state.isOpen.value; // 当前状态(模板中的顶层 ref 自动解包)
|
||||
state.open();
|
||||
state.close();
|
||||
state.toggle();
|
||||
state.setOpen(true);
|
||||
```
|
||||
|
||||
## 无障碍
|
||||
|
||||
实现 [WAI-ARIA Dialog 模式](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/):
|
||||
|
||||
- **焦点陷阱**:焦点锁定在 Modal 内
|
||||
- **键盘**:`ESC` 关闭(启用时)、`Tab` 在元素间循环
|
||||
- **屏幕阅读器**:正确的 ARIA 属性
|
||||
- **滚动锁定**:打开时禁用 body 滚动
|
||||
|
||||
## Vue API 与组合约定
|
||||
|
||||
Root 的 `open` / `isOpen` 支持受控值,`defaultOpen` 默认 false;推荐 `v-model:open`,事件为 `update:open`、`openChange`(模板 `@open-change`)。父级拒绝请求时保持父级状态,初始值只初始化一次。第一个 Button 可自动作为触发器;自定义内容用显式 Trigger,单元素组合可设 `as-child`。Trigger 的 class/style、ARIA 与 DOM 监听落在实际触发元素,disabled、isDisabled 与加载状态会阻止激活。
|
||||
|
||||
React 的 DOM render 回调改为 `as` 加原生 attrs,例如 `as="div" data-custom="foo"`;class 函数改为 Vue 的字符串/对象/数组绑定。Enter/Space 对自定义按钮根只激活一次,调用者 preventDefault 可取消。Portal 默认 body,可由 ConfigProvider.teleportTo 或 Content/Backdrop 的 to 覆盖;目标应置于所需主题作用域中。SSR Portal 于客户端挂载后插入,尚未承诺 Nuxt 服务端收集。
|
||||
|
||||
### 状态与关闭
|
||||
|
||||
Modal 还接受 `state: OverlayState`,其优先级高于 open / isOpen;复用 `useOverlayState()`。ModalBackdrop 可脱离 Modal 单独使用 `v-model:open`,满足外部按钮控制场景。根已存在时由根统一管理状态。ModalContainer 的 size / placement / scroll 与基线相同,Body 继承滚动模式。
|
||||
|
||||
React 的 `slot="close"` 改为 `<ModalClose as-child><Button>关闭</Button></ModalClose>`;也可通过 ModalDialog 的 `v-slot="{ close }"` 自行关闭。ModalCloseTrigger 默认复用 CloseButton 的图标、可访问名称与变体。Header/Body/Footer/Icon/Heading 支持 as 与原生 attrs。
|
||||
|
||||
ModalDialog 的 ARIA/DOM 事件落在实际 role=dialog 的节点。isDismissable 与 isKeyboardDismissDisabled 位于 Backdrop,分别控制外部交互与 Escape;显式关闭不受它们影响。openAutoFocus、closeAutoFocus、escapeKeyDown、pointerDownOutside、focusOutside、interactOutside 以可取消事件透传。
|
||||
|
||||
### Vue 补充部件
|
||||
|
||||
| 部件 | 属性 / 插槽 | 默认值 | 说明 |
|
||||
| ----------------- | -------------------------------------------- | ----------------------------------------- | --------------------------------------------------------------------------- |
|
||||
| ModalHeading | as / id / class | h2 / 自动唯一 ID | 真实标题关联,显式 ID 可动态更新 |
|
||||
| ModalIcon | as / class / 默认插槽 | div | 复用基线 40px 图标容器 |
|
||||
| ModalClose | as / asChild / isDisabled | button / false / false | 显式替代 React close slot;保留取消与禁用 |
|
||||
| ModalCloseTrigger | variant / isDisabled / disabled / aria-label | default / false / false / Close | 复用 CloseButton 的同名契约,默认插槽可自定义图标 |
|
||||
| Modal | open / isOpen / defaultOpen / state | undefined / undefined / false / undefined | state 优先,推荐 v-model:open;update:open 和 openChange 的参数均为 boolean |
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Modal 模态框](./modal) · [Popover 弹出框](./popover) · [Tooltip 工具提示](./tooltip)
|
||||
@@ -0,0 +1,179 @@
|
||||
---
|
||||
title: Popover 弹出框
|
||||
description: 在由按钮或任意自定义元素触发后,于 portal 中展示丰富内容。
|
||||
component: popover
|
||||
group: 组件
|
||||
---
|
||||
|
||||
> 基于固定 HeroUI 3.2.6(ce90ea3)迁移。命名组件、v-model、作用域插槽与 DOM attrs 为 Vue 适配;预览、复制与高亮来自同一份 SFC。
|
||||
|
||||
## 用法
|
||||
|
||||
```ts
|
||||
import { Popover } from "@heroui-vue/components";
|
||||
```
|
||||
|
||||
<ComponentPreview name="popover-basic" />
|
||||
|
||||
## 组件结构
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Popover,
|
||||
PopoverTrigger,
|
||||
PopoverContent,
|
||||
PopoverArrow,
|
||||
PopoverDialog,
|
||||
PopoverHeading,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Popover>
|
||||
<PopoverTrigger as-child><Button>点击我</Button></PopoverTrigger>
|
||||
<PopoverContent>
|
||||
<PopoverArrow />
|
||||
<PopoverDialog>
|
||||
<PopoverHeading>标题</PopoverHeading>
|
||||
内容
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</template>
|
||||
```
|
||||
|
||||
## 示例
|
||||
|
||||
### 带箭头
|
||||
|
||||
<ComponentPreview name="popover-with-arrow" />
|
||||
|
||||
### 可交互内容
|
||||
|
||||
<ComponentPreview name="popover-interactive" />
|
||||
|
||||
### 位置
|
||||
|
||||
<ComponentPreview name="popover-placement" />
|
||||
|
||||
### 渲染函数
|
||||
|
||||
<ComponentPreview name="popover-render-function" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="popover-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
若要自定义组件类,可使用 `@layer components` 指令。[了解更多](https://tailwindcss.com/docs/adding-custom-styles#adding-component-classes)。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-popover {
|
||||
@apply rounded-xl shadow-2xl;
|
||||
}
|
||||
|
||||
.hv-popover__dialog {
|
||||
@apply p-4;
|
||||
}
|
||||
|
||||
.hv-popover__heading {
|
||||
@apply text-lg font-bold;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
|
||||
|
||||
### CSS 类
|
||||
|
||||
Popover 使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/popover.css)):
|
||||
|
||||
#### 基础类
|
||||
|
||||
- `.hv-popover` - Popover 根容器样式
|
||||
- `.hv-popover__dialog` - 对话框内容包裹层
|
||||
- `.hv-popover__heading` - 标题文本样式
|
||||
- `.hv-popover__trigger` - 触发元素样式
|
||||
|
||||
### 交互状态
|
||||
|
||||
组件支持以下动画相关状态:
|
||||
|
||||
- **进入**:`[data-entering]` — Popover 出现过程中应用
|
||||
- **离开**:`[data-exiting]` — Popover 消失过程中应用
|
||||
- **位置**:`[data-side="*"]` — 根据 Popover 位置应用
|
||||
- **焦点**:`:focus-visible` 或 `[data-focus-visible="true"]`
|
||||
|
||||
## API 参考
|
||||
|
||||
### Popover
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| -------------- | --------------------------- | ------- | ----------------------------- |
|
||||
| `默认插槽` | `VNode / 插槽` | - | 触发器与内容元素 |
|
||||
| `isOpen` | `boolean` | - | 控制 Popover 是否可见(受控) |
|
||||
| `defaultOpen` | `boolean` | `false` | 初始打开状态(非受控) |
|
||||
| `@open-change` | `(isOpen: boolean) => void` | - | 打开状态变化时调用 |
|
||||
|
||||
### PopoverContent
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------------ | ------------------------------------------------- | ---------- | ------------------------------------------ |
|
||||
| `默认插槽` | `VNode / 插槽` | - | 在 Popover 中展示的内容 |
|
||||
| `placement` | `"top" \| "bottom" \| "left" \| "right"` (及变体) | `"bottom"` | Popover 的位置 |
|
||||
| `offset` | `number` | `8` | 与触发元素的距离 |
|
||||
| `shouldFlip` | `boolean` | `true` | 是否允许 Popover 改变方向以适配空间 |
|
||||
| `class` | `string / object / array` | - | 额外的 CSS 类名 |
|
||||
| `as` | `string` | `"div"` | Vue 自定义根元素;自定义箭头使用默认插槽。 |
|
||||
|
||||
### PopoverDialog
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ---------- | ------------------------- | ------ | --------------- |
|
||||
| `默认插槽` | `VNode / 插槽` | - | 对话框内容 |
|
||||
| `class` | `string / object / array` | - | 额外的 CSS 类名 |
|
||||
|
||||
### PopoverTrigger
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ---------- | ------------------------- | ------ | ------------------- |
|
||||
| `默认插槽` | `VNode / 插槽` | - | 触发 Popover 的元素 |
|
||||
| `class` | `string / object / array` | - | 额外的 CSS 类名 |
|
||||
|
||||
### PopoverArrow
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ---------- | ------------------------- | -------- | -------------------------------- |
|
||||
| `class` | `string / object / array` | - | 额外的 CSS 类名 |
|
||||
| `默认插槽` | `单个 SVG VNode` | 基线箭头 | 自定义箭头,保留对应 data-slot。 |
|
||||
|
||||
## Vue API 与组合约定
|
||||
|
||||
Root 的 `open` / `isOpen` 支持受控值,`defaultOpen` 默认 false;推荐 `v-model:open`,事件为 `update:open`、`openChange`(模板 `@open-change`)。父级拒绝请求时保持父级状态,初始值只初始化一次。第一个 Button 可自动作为触发器;自定义内容用显式 Trigger,单元素组合可设 `as-child`。Trigger 的 class/style、ARIA 与 DOM 监听落在实际触发元素,disabled、isDisabled 与加载状态会阻止激活。
|
||||
|
||||
React 的 DOM render 回调改为 `as` 加原生 attrs,例如 `as="div" data-custom="foo"`;class 函数改为 Vue 的字符串/对象/数组绑定。Enter/Space 对自定义按钮根只激活一次,调用者 preventDefault 可取消。Portal 默认 body,可由 ConfigProvider.teleportTo 或 Content/Backdrop 的 to 覆盖;目标应置于所需主题作用域中。SSR Portal 于客户端挂载后插入,尚未承诺 Nuxt 服务端收集。
|
||||
|
||||
### 定位与生命周期
|
||||
|
||||
placement 支持 top/bottom/left/right 及对齐变体(如 `top start`、`right bottom`),offset 可为 0,crossOffset 默认 0,shouldFlip 默认 true,containerPadding 默认 12。实际碰撞结果以 `data-side`、`data-align` 表示;箭头由 Reka 定位旋转,不重复应用上游 SVG 旋转。保留源进入/退出动画数值及 data-entering/data-exiting,退出由 Presence 协调卸载。
|
||||
|
||||
PopoverContent 的 isNonModal 默认 false,也可在 Popover Root 设置默认值;交互丰富的内容使用 PopoverDialog,Heading 关联实际对话框名称,不生成两个嵌套 role=dialog。Content 的 isDismissable 默认 true、isKeyboardDismissDisabled 默认 false;进入焦点、外部交互和 Escape 事件可取消。默认模态模式下 closeAutoFocus 继承 Reka 的触发器恢复流程,当前用于通知;自定义取消恢复可用 isNonModal 模式,二者的焦点策略差异见迁移记录。PopoverDialog 的作用域插槽暴露 close。
|
||||
|
||||
### PopoverHeading 与内容语义
|
||||
|
||||
| 部件 | 属性 / 插槽 | 默认值 | 说明 |
|
||||
| -------------- | ------------------------------------- | ---------------- | ------------------------------------------------------------------- |
|
||||
| PopoverHeading | as / id / class / 默认插槽 | h2 / 自动唯一 ID | 动态维护对话框标题引用 |
|
||||
| PopoverDialog | as / class / 默认作用域插槽 { close } | div | 视觉内容层;ARIA 名称/描述透传到实际对话框表面,避免两个嵌套 dialog |
|
||||
| PopoverContent | isNonModal | false | 非模态时不锁定外部交互,不限制焦点范围 |
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Modal 模态框](./modal) · [Popover 弹出框](./popover) · [Tooltip 工具提示](./tooltip)
|
||||
@@ -0,0 +1,181 @@
|
||||
---
|
||||
title: Tooltip 工具提示
|
||||
description: 当用户悬停或聚焦某个元素时,展示提示性文本。
|
||||
component: tooltip
|
||||
group: 组件
|
||||
---
|
||||
|
||||
> 基于固定 HeroUI 3.2.6(ce90ea3)迁移。命名组件、v-model、作用域插槽与 DOM attrs 为 Vue 适配;预览、复制与高亮来自同一份 SFC。
|
||||
|
||||
## 用法
|
||||
|
||||
```ts
|
||||
import { Tooltip } from "@heroui-vue/components";
|
||||
```
|
||||
|
||||
<ComponentPreview name="tooltip-basic" />
|
||||
|
||||
## 组件结构
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipTrigger,
|
||||
TooltipContent,
|
||||
TooltipArrow,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Tooltip>
|
||||
<TooltipTrigger as-child><Button>Hover for tooltip</Button></TooltipTrigger>
|
||||
<TooltipContent show-arrow>
|
||||
<TooltipArrow />
|
||||
关于此元素的有用信息
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</template>
|
||||
```
|
||||
|
||||
## 示例
|
||||
|
||||
### 位置
|
||||
|
||||
<ComponentPreview name="tooltip-placement" />
|
||||
|
||||
### 带箭头
|
||||
|
||||
<ComponentPreview name="tooltip-with-arrow" />
|
||||
|
||||
### 自定义触发
|
||||
|
||||
<ComponentPreview name="tooltip-custom-trigger" />
|
||||
|
||||
### 渲染函数
|
||||
|
||||
<ComponentPreview name="tooltip-render-function" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="tooltip-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
若要自定义组件类,可使用 `@layer components` 指令。[了解更多](https://tailwindcss.com/docs/adding-custom-styles#adding-component-classes)。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-tooltip {
|
||||
@apply rounded-xl shadow-lg;
|
||||
}
|
||||
|
||||
.hv-tooltip__trigger {
|
||||
@apply cursor-help;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
|
||||
|
||||
### 全局延迟配置
|
||||
|
||||
你可以通过定义 CSS 变量,为应用中所有 Tooltip 设置默认的显示与隐藏延迟:
|
||||
|
||||
```css
|
||||
/* 在你的全局 CSS 文件中 */
|
||||
:root {
|
||||
--tooltip-delay: 1500ms;
|
||||
--tooltip-close-delay: 500ms;
|
||||
}
|
||||
|
||||
/* 也可以为浅色/深色主题设置不同的值 */
|
||||
.light,
|
||||
[data-theme="light"] {
|
||||
--tooltip-delay: 1200ms;
|
||||
}
|
||||
|
||||
.dark,
|
||||
[data-theme="dark"] {
|
||||
--tooltip-close-delay: 300ms;
|
||||
}
|
||||
```
|
||||
|
||||
值支持 `ms`、`s` 等 CSS 时间单位。在单个 Tooltip 上指定 `delay` 或 `closeDelay` 时,会覆盖这些全局设置。
|
||||
|
||||
### CSS 类
|
||||
|
||||
Tooltip 使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/tooltip.css)):
|
||||
|
||||
#### 基础类
|
||||
|
||||
- `.hv-tooltip` - 带动画的基础 Tooltip 样式
|
||||
- `.hv-tooltip__trigger` - 触发元素样式
|
||||
|
||||
### 交互状态
|
||||
|
||||
组件支持以下动画相关状态:
|
||||
|
||||
- **进入**:`[data-entering]` — Tooltip 出现过程中应用
|
||||
- **离开**:`[data-exiting]` — Tooltip 消失过程中应用
|
||||
- **位置**:`[data-side="*"]` — 根据 Tooltip 位置应用
|
||||
|
||||
## API 参考
|
||||
|
||||
### Tooltip
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| --------------------- | -------------------- | ------------------ | ------------------------------------------------------------------------------ |
|
||||
| `默认插槽` | `VNode / 插槽` | - | 触发元素与内容 |
|
||||
| `delay` | `number` | `1500` 或 CSS 变量 | 显示 Tooltip 前的延迟(毫秒);可通过 `--tooltip-delay` CSS 变量全局配置 |
|
||||
| `closeDelay` | `number` | `500` 或 CSS 变量 | 隐藏 Tooltip 前的延迟(毫秒);可通过 `--tooltip-close-delay` CSS 变量全局配置 |
|
||||
| `trigger` | `"hover" \| "focus"` | `"hover"` | Tooltip 的触发方式 |
|
||||
| `isDisabled` | `boolean` | `false` | 是否禁用 Tooltip |
|
||||
| `shouldSkipAnimation` | `boolean` | `false` | 在多个 Tooltip 之间快速切换时,是否跳过进入与退出动画 |
|
||||
|
||||
### TooltipContent
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ----------- | ------------------------------------------------- | ------------------- | ------------------------------------------ |
|
||||
| `默认插槽` | `VNode / 插槽` | - | 在 Tooltip 中展示的内容 |
|
||||
| `showArrow` | `boolean` | `false` | 是否显示箭头指示器 |
|
||||
| `offset` | `number` | `3`(带箭头时为 7) | 与触发元素的距离 |
|
||||
| `placement` | `"top" \| "bottom" \| "left" \| "right"` (及变体) | `"top"` | Tooltip 的位置 |
|
||||
| `class` | `string / object / array` | - | 额外的 CSS 类名 |
|
||||
| `as` | `string` | `"div"` | Vue 自定义根元素;自定义箭头使用默认插槽。 |
|
||||
|
||||
### TooltipTrigger
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ---------- | ------------------------- | ------ | ------------------- |
|
||||
| `默认插槽` | `VNode / 插槽` | - | 触发 Tooltip 的元素 |
|
||||
| `class` | `string / object / array` | - | 额外的 CSS 类名 |
|
||||
|
||||
### TooltipArrow
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ---------- | ------------------------- | -------- | -------------------------------- |
|
||||
| `class` | `string / object / array` | - | 额外的 CSS 类名 |
|
||||
| `默认插槽` | `单个 SVG VNode` | 基线箭头 | 自定义箭头,保留对应 data-slot。 |
|
||||
|
||||
## Vue API 与组合约定
|
||||
|
||||
Root 的 `open` / `isOpen` 支持受控值,`defaultOpen` 默认 false;推荐 `v-model:open`,事件为 `update:open`、`openChange`(模板 `@open-change`)。父级拒绝请求时保持父级状态,初始值只初始化一次。第一个 Button 可自动作为触发器;自定义内容用显式 Trigger,单元素组合可设 `as-child`。Trigger 的 class/style、ARIA 与 DOM 监听落在实际触发元素;使用 Tooltip 的 isDisabled 禁用提示。
|
||||
|
||||
React 的 DOM render 回调改为 `as` 加原生 attrs,例如 `as="div" data-custom="foo"`;class 函数改为 Vue 的字符串/对象/数组绑定。Enter/Space 对自定义按钮根只激活一次,调用者 preventDefault 可取消。Portal 默认 body,可由 ConfigProvider.teleportTo 或 Content/Backdrop 的 to 覆盖;目标应置于所需主题作用域中。SSR Portal 于客户端挂载后插入,尚未承诺 Nuxt 服务端收集。
|
||||
|
||||
### 定位与生命周期
|
||||
|
||||
placement 支持 top/bottom/left/right 及对齐变体(如 `top start`、`right bottom`),offset 可为 0,crossOffset 默认 0,shouldFlip 默认 true,containerPadding 默认 12。实际碰撞结果以 `data-side`、`data-align` 表示;箭头由 Reka 定位旋转,不重复应用上游 SVG 旋转。保留源进入/退出动画数值及 data-entering/data-exiting,退出由 Presence 协调卸载。
|
||||
|
||||
Tooltip 的 isDisabled 默认 false;trigger="hover" 同时支持键盘焦点,trigger="focus" 只在聚焦时打开。delay / closeDelay 显式值优先于触发器作用域的 CSS 时间变量(支持 ms/s),缺省 1500/500ms;失焦、点击、Escape 与外部交互立即关闭,悬停离开遵循 closeDelay。ConfigProvider 提供共享的 Reka warmup 边界;未使用 Provider 时各 Root 拥有自己的 warmup 计时。shouldSkipAnimation 默认 false,为 true 时允许 Reka instant-open 阶段跳过动画,此处与 React Aria 的全局 warmup 调度不同。
|
||||
|
||||
showArrow 选择带箭头的默认偏移(7px,否则 3px),仍需显式放置 TooltipArrow,与基线源码相同。Tooltip 通过 aria-describedby 关联隐藏的只读提示文本;可视容器保持 Reka 的语义,不能在其中放需要焦点的按钮/输入,应改用 Popover。TooltipTrigger 支持 as/asChild 和原生 attrs;普通按钮会自动组合。
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Modal 模态框](./modal) · [Popover 弹出框](./popover) · [Tooltip 工具提示](./tooltip)
|
||||
@@ -0,0 +1,61 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalBody,
|
||||
ModalClose,
|
||||
ModalCloseTrigger,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
ModalIcon,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconRocket as Rocket } from "@tabler/icons-vue";
|
||||
const VARIANT_LABELS = {
|
||||
blur: "模糊",
|
||||
opaque: "不透明",
|
||||
transparent: "透明",
|
||||
} as const;
|
||||
const variants = ["opaque", "blur", "transparent"] as const;
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-wrap gap-4">
|
||||
<template v-for="variant in variants" :key="variant">
|
||||
<Modal>
|
||||
<Button variant="secondary">{{ VARIANT_LABELS[variant] }}</Button>
|
||||
<ModalBackdrop :variant="variant">
|
||||
<ModalContainer>
|
||||
<ModalDialog class="sm:max-w-[360px]">
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
<ModalHeader>
|
||||
<ModalIcon class="bg-default text-foreground">
|
||||
<Rocket aria-hidden="true" class="size-5"></Rocket>
|
||||
</ModalIcon>
|
||||
<ModalHeading>背景:{{ VARIANT_LABELS[variant] }}</ModalHeading>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<p>
|
||||
{{
|
||||
variant === "opaque"
|
||||
? "不透明背景会完全遮挡背后内容,让用户把注意力集中在模态框上。"
|
||||
: variant === "blur"
|
||||
? "模糊背景会柔和地虚化背后内容,同时保留一定的环境上下文。"
|
||||
: "透明背景会完整保留背后内容,适合重要性较低的交互场景。"
|
||||
}}
|
||||
</p>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button class="w-full">继续</Button>
|
||||
</ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,97 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalBody,
|
||||
ModalClose,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
ModalIcon,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconInfoCircle as CircleInfo,
|
||||
IconCircleCheck as CircleCheck,
|
||||
} from "@tabler/icons-vue";
|
||||
</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">使用 ModalClose</h3>
|
||||
<p class="text-sm text-muted">
|
||||
关闭模态框的最简方式:用
|
||||
<code>ModalClose</code>
|
||||
包装模态框内的 Button,点击即可自动关闭。
|
||||
</p>
|
||||
<Modal>
|
||||
<Button variant="secondary">打开模态框</Button>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer>
|
||||
<ModalDialog class="sm:max-w-[360px]">
|
||||
<ModalHeader>
|
||||
<ModalIcon class="bg-accent-soft text-accent-soft-foreground">
|
||||
<CircleInfo aria-hidden="true" class="size-5"></CircleInfo>
|
||||
</ModalIcon>
|
||||
<ModalHeading>使用 ModalClose</ModalHeading>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<p>
|
||||
点击下方任一按钮——它们都使用
|
||||
<code>ModalClose</code>
|
||||
,会自动关闭模态框。
|
||||
</p>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button variant="secondary">取消</Button>
|
||||
</ModalClose>
|
||||
<ModalClose as-child><Button>确认</Button></ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
<h3 class="text-lg font-semibold">使用 Dialog 作用域插槽</h3>
|
||||
<p class="text-sm text-muted">
|
||||
通过 Dialog 的作用域插槽访问
|
||||
<code>close</code>
|
||||
方法,可完全控制关闭时机与方式,并在关闭前加入自定义逻辑。
|
||||
</p>
|
||||
<Modal>
|
||||
<Button variant="secondary">打开模态框</Button>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer>
|
||||
<ModalDialog class="sm:max-w-[360px]" v-slot="slotProps">
|
||||
<ModalHeader>
|
||||
<ModalIcon class="bg-success-soft text-success-soft-foreground">
|
||||
<CircleCheck aria-hidden="true" class="size-5"></CircleCheck>
|
||||
</ModalIcon>
|
||||
<ModalHeading>使用 Dialog 作用域插槽</ModalHeading>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<p>
|
||||
下方按钮使用作用域插槽中的
|
||||
<code>close</code>
|
||||
方法。可在调用
|
||||
<code>slotProps.close()</code>
|
||||
前进行校验或其他逻辑。
|
||||
</p>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button variant="secondary" @click="slotProps.close()">
|
||||
取消
|
||||
</Button>
|
||||
<Button @click="slotProps.close()">确认</Button>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,152 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
ModalBackdrop,
|
||||
ModalBody,
|
||||
ModalClose,
|
||||
ModalCloseTrigger,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
ModalIcon,
|
||||
useOverlayState,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconCircleCheck as CircleCheck } from "@tabler/icons-vue";
|
||||
const isOpen = ref(false);
|
||||
function setIsOpen(value: boolean) {
|
||||
isOpen.value = value;
|
||||
}
|
||||
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">配合 Vue 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"
|
||||
>
|
||||
<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="setIsOpen(true)">
|
||||
打开模态框
|
||||
</Button>
|
||||
<Button size="sm" variant="tertiary" @click="setIsOpen(!isOpen)">
|
||||
切换
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<ModalBackdrop v-model:open="isOpen">
|
||||
<ModalContainer>
|
||||
<ModalDialog class="sm:max-w-[360px]">
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
<ModalHeader>
|
||||
<ModalIcon class="bg-accent-soft text-accent-soft-foreground">
|
||||
<CircleCheck aria-hidden="true" class="size-5"></CircleCheck>
|
||||
</ModalIcon>
|
||||
<ModalHeading>由 ref() 控制</ModalHeading>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<p>
|
||||
该模态框由 Vue 的
|
||||
<code>ref</code>
|
||||
控制。将
|
||||
<code>open</code>
|
||||
与
|
||||
<code>update:open</code>
|
||||
传入即可在外部管理状态。
|
||||
</p>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button variant="secondary">取消</Button>
|
||||
</ModalClose>
|
||||
<ModalClose as-child><Button>确认</Button></ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</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>
|
||||
<ModalBackdrop :open="state.isOpen.value" @update:open="state.setOpen">
|
||||
<ModalContainer>
|
||||
<ModalDialog class="sm:max-w-[360px]">
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
<ModalHeader>
|
||||
<ModalIcon class="bg-success-soft text-success-soft-foreground">
|
||||
<CircleCheck aria-hidden="true" class="size-5"></CircleCheck>
|
||||
</ModalIcon>
|
||||
<ModalHeading>由 useOverlayState() 控制</ModalHeading>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<p>
|
||||
<code>useOverlayState</code>
|
||||
为常见操作提供专用方法,无需手写回调,直接使用
|
||||
<code>state.open()</code>
|
||||
、
|
||||
<code>state.close()</code>
|
||||
或
|
||||
<code>state.toggle()</code>
|
||||
即可。
|
||||
</p>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button variant="secondary">取消</Button>
|
||||
</ModalClose>
|
||||
<ModalClose as-child><Button>确认</Button></ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,115 @@
|
||||
<script setup lang="ts">
|
||||
import type { Component } from "vue";
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalBody,
|
||||
ModalClose,
|
||||
ModalCloseTrigger,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
ModalIcon,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconSparkles as Sparkles,
|
||||
IconArrowBarUp as ArrowUpFromLine,
|
||||
} from "@tabler/icons-vue";
|
||||
const iconMap: Record<string, Component> = {
|
||||
"tabler:arrow-bar-up": ArrowUpFromLine,
|
||||
"tabler:sparkles": Sparkles,
|
||||
};
|
||||
const animations = [
|
||||
{
|
||||
classNames: {
|
||||
backdrop: [
|
||||
"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)]",
|
||||
].join(" "),
|
||||
container: [
|
||||
"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)]",
|
||||
].join(" "),
|
||||
},
|
||||
description:
|
||||
"基于物理的弹性缩放,模拟高阻尼弹簧系统:快速瞬态响应与较长 settling 时间。适用于模态框与弹出层。",
|
||||
icon: "tabler:sparkles",
|
||||
name: "运动缩放",
|
||||
},
|
||||
{
|
||||
classNames: {
|
||||
backdrop: [
|
||||
"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)]",
|
||||
].join(" "),
|
||||
container: [
|
||||
"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)]",
|
||||
].join(" "),
|
||||
},
|
||||
description:
|
||||
"模拟流体阻力中的运动,摆脱机械式线性动画,呈现更自然、沉稳的质感。适用于底部抽屉或 Toast。",
|
||||
icon: "tabler:arrow-bar-up",
|
||||
name: "流体滑入",
|
||||
},
|
||||
];
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-wrap gap-4">
|
||||
<template
|
||||
v-for="{ classNames, description, icon, name } in animations"
|
||||
:key="name"
|
||||
>
|
||||
<Modal>
|
||||
<Button variant="secondary">{{ name }}</Button>
|
||||
<ModalBackdrop :class="classNames.backdrop">
|
||||
<ModalContainer :class="classNames.container">
|
||||
<ModalDialog class="sm:max-w-[360px]">
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
<ModalHeader>
|
||||
<ModalIcon class="bg-default text-foreground">
|
||||
<template v-if="!!iconMap[icon]">
|
||||
<component :is="iconMap[icon]" class="size-5"></component>
|
||||
</template>
|
||||
</ModalIcon>
|
||||
<ModalHeading>{{ name }} 动画</ModalHeading>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<p class="mt-1">{{ description }}</p>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button variant="tertiary">关闭</Button>
|
||||
</ModalClose>
|
||||
<ModalClose as-child><Button>再试一次</Button></ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,51 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalBody,
|
||||
ModalClose,
|
||||
ModalCloseTrigger,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
ModalIcon,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconSparkles as Sparkles } from "@tabler/icons-vue";
|
||||
</script>
|
||||
<template>
|
||||
<Modal>
|
||||
<Button variant="secondary">自定义背景</Button>
|
||||
<ModalBackdrop
|
||||
class="bg-linear-to-t from-black/80 via-black/40 to-transparent dark:from-zinc-800/80 dark:via-zinc-800/40"
|
||||
variant="blur"
|
||||
>
|
||||
<ModalContainer>
|
||||
<ModalDialog class="sm:max-w-[360px]">
|
||||
<ModalHeader class="items-center text-center">
|
||||
<ModalIcon class="bg-accent-soft text-accent-soft-foreground">
|
||||
<Sparkles aria-hidden="true" class="size-5"></Sparkles>
|
||||
</ModalIcon>
|
||||
<ModalHeading>高级背景</ModalHeading>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<p>
|
||||
此背景采用从底部深色过渡到顶部完全透明的精致渐变,并配合柔和的模糊效果。渐变会在浅色与深色模式下自动调整强度,以获得最佳对比度。
|
||||
</p>
|
||||
</ModalBody>
|
||||
<ModalFooter class="flex-col-reverse">
|
||||
<ModalClose as-child>
|
||||
<Button class="w-full">Amazing!</Button>
|
||||
</ModalClose>
|
||||
<ModalClose as-child>
|
||||
<Button class="w-full" variant="secondary">关闭</Button>
|
||||
</ModalClose>
|
||||
</ModalFooter>
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,66 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalCloseTrigger,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
ModalBody,
|
||||
ModalFooter,
|
||||
ModalClose,
|
||||
} from "@heroui-vue/components";
|
||||
const portalContainer = ref<HTMLElement>();
|
||||
</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="portalContainer"
|
||||
class="relative flex h-[380px] items-center justify-center overflow-hidden rounded bg-muted/20"
|
||||
style="transform: translate(0)"
|
||||
>
|
||||
<Modal v-if="portalContainer">
|
||||
<Button>打开模态框</Button>
|
||||
<ModalBackdrop :to="portalContainer" class="h-full">
|
||||
<ModalContainer class="h-full max-h-full">
|
||||
<ModalDialog class="h-full max-h-full sm:max-w-md">
|
||||
<ModalCloseTrigger />
|
||||
<ModalHeader>
|
||||
<ModalHeading>自定义 Portal</ModalHeading>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<p v-for="i in 3" :key="i" class="text-sm text-muted">
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
|
||||
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
Ut enim ad minim veniam, quis nostrud exercitation ullamco
|
||||
laboris nisi ut aliquip ex ea commodo consequat.
|
||||
</p>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button variant="secondary">关闭</Button>
|
||||
</ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,55 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalBody,
|
||||
ModalClose,
|
||||
ModalCloseTrigger,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
ModalIcon,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconCircleCheck as CircleCheck } from "@tabler/icons-vue";
|
||||
</script>
|
||||
<template>
|
||||
<Modal>
|
||||
<Button variant="secondary">打开</Button>
|
||||
<ModalBackdrop class="bg-overlay/50 dark:bg-overlay/65" variant="blur">
|
||||
<ModalContainer>
|
||||
<ModalDialog
|
||||
class="relative overflow-hidden border border-border/80 bg-surface/90 shadow-2xl ring-1 ring-black/5 backdrop-blur-xl sm:max-w-[340px] dark:border-border/90 dark:bg-surface/85 dark:ring-white/10"
|
||||
>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
class="pointer-events-none absolute inset-x-0 top-0 h-20 bg-linear-to-b from-neutral-500/8 to-transparent dark:from-neutral-400/10"
|
||||
></div>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
class="pointer-events-none absolute inset-x-10 top-0 h-px bg-linear-to-r from-transparent via-neutral-400/40 to-transparent dark:via-neutral-500/35"
|
||||
></div>
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
<ModalHeader class="relative">
|
||||
<ModalIcon
|
||||
class="bg-neutral-100 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-200"
|
||||
>
|
||||
<CircleCheck aria-hidden="true" class="size-5"></CircleCheck>
|
||||
</ModalIcon>
|
||||
<ModalHeading>更改已保存</ModalHeading>
|
||||
</ModalHeader>
|
||||
<ModalBody class="relative">
|
||||
<p class="text-sm text-muted">你的草稿已在各设备间同步。</p>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button class="w-full">完成</Button>
|
||||
</ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,61 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalBody,
|
||||
ModalClose,
|
||||
ModalCloseTrigger,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
ModalIcon,
|
||||
ModalTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconSettings as Gear } from "@tabler/icons-vue";
|
||||
</script>
|
||||
<template>
|
||||
<Modal>
|
||||
<ModalTrigger
|
||||
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-accent-soft text-accent-soft-foreground"
|
||||
>
|
||||
<Gear aria-hidden="true" class="size-6"></Gear>
|
||||
</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>
|
||||
</ModalTrigger>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer>
|
||||
<ModalDialog class="sm:max-w-[360px]">
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
<ModalHeader>
|
||||
<ModalIcon class="bg-accent-soft text-accent-soft-foreground">
|
||||
<Gear aria-hidden="true" class="size-5"></Gear>
|
||||
</ModalIcon>
|
||||
<ModalHeading>设置</ModalHeading>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<p>
|
||||
使用
|
||||
<code>Modal.Trigger</code>
|
||||
可在标准按钮之外创建自定义触发器。此示例展示带图标与说明文字的卡片式触发器。
|
||||
</p>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button variant="secondary">取消</Button>
|
||||
</ModalClose>
|
||||
<ModalClose as-child><Button>保存</Button></ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,46 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalBody,
|
||||
ModalClose,
|
||||
ModalCloseTrigger,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
ModalIcon,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconRocket as Rocket } from "@tabler/icons-vue";
|
||||
</script>
|
||||
<template>
|
||||
<Modal>
|
||||
<Button variant="secondary">打开模态框</Button>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer>
|
||||
<ModalDialog class="sm:max-w-[360px]">
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
<ModalHeader>
|
||||
<ModalIcon class="bg-default text-foreground">
|
||||
<Rocket aria-hidden="true" class="size-5"></Rocket>
|
||||
</ModalIcon>
|
||||
<ModalHeading>欢迎使用 HeroUI</ModalHeading>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<p>
|
||||
一套美观、快速、现代的 Vue UI 库,可轻松构建无障碍且高度可定制的
|
||||
Web 应用。
|
||||
</p>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button class="w-full">继续</Button>
|
||||
</ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,96 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalBody,
|
||||
ModalClose,
|
||||
ModalCloseTrigger,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
ModalIcon,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconInfoCircle as CircleInfo } from "@tabler/icons-vue";
|
||||
</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>true</code>
|
||||
。设为
|
||||
<code>false</code>
|
||||
时需通过明确操作关闭。
|
||||
</p>
|
||||
<Modal>
|
||||
<Button variant="secondary">打开模态框</Button>
|
||||
<ModalBackdrop :isDismissable="false">
|
||||
<ModalContainer>
|
||||
<ModalDialog class="sm:max-w-[360px]">
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
<ModalHeader>
|
||||
<ModalIcon class="bg-default text-foreground">
|
||||
<CircleInfo aria-hidden="true" class="size-5"></CircleInfo>
|
||||
</ModalIcon>
|
||||
<ModalHeading>isDismissable = false</ModalHeading>
|
||||
<p class="text-sm leading-5 text-muted">
|
||||
点击遮罩不会关闭此模态框
|
||||
</p>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<p>
|
||||
尝试点击遮罩区域——模态框不会关闭,必须使用关闭按钮或按 ESC
|
||||
键关闭。
|
||||
</p>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button class="w-full">关闭</Button>
|
||||
</ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</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,用户须通过明确操作关闭。
|
||||
</p>
|
||||
<Modal>
|
||||
<Button variant="secondary">打开模态框</Button>
|
||||
<ModalBackdrop isKeyboardDismissDisabled>
|
||||
<ModalContainer>
|
||||
<ModalDialog class="sm:max-w-[360px]">
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
<ModalHeader>
|
||||
<ModalIcon class="bg-default text-foreground">
|
||||
<CircleInfo aria-hidden="true" class="size-5"></CircleInfo>
|
||||
</ModalIcon>
|
||||
<ModalHeading>isKeyboardDismissDisabled = true</ModalHeading>
|
||||
<p class="text-sm leading-5 text-muted">已禁用 ESC 键</p>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<p>
|
||||
按 ESC 无反应。必须使用关闭按钮或点击遮罩才能关闭此模态框。
|
||||
</p>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button class="w-full">关闭</Button>
|
||||
</ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,66 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalBody,
|
||||
ModalClose,
|
||||
ModalCloseTrigger,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
ModalIcon,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconRocket as Rocket } from "@tabler/icons-vue";
|
||||
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">
|
||||
<template v-for="placement in placements" :key="placement">
|
||||
<Modal>
|
||||
<Button variant="secondary">{{ PLACEMENT_LABELS[placement] }}</Button>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer :placement="placement">
|
||||
<ModalDialog class="sm:max-w-[360px]">
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
<ModalHeader>
|
||||
<ModalIcon class="bg-default text-foreground">
|
||||
<Rocket aria-hidden="true" class="size-5"></Rocket>
|
||||
</ModalIcon>
|
||||
<ModalHeading>
|
||||
{{
|
||||
placement === "auto"
|
||||
? "自动定位"
|
||||
: `${PLACEMENT_LABELS[placement]}位置`
|
||||
}}
|
||||
</ModalHeading>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<p>
|
||||
{{
|
||||
placement === "auto"
|
||||
? "在移动端默认靠近底部,在桌面端居中,以获得更合适的阅读与操作体验。"
|
||||
: `模态框将锚定在视口的「${PLACEMENT_LABELS[placement]}」区域。可尝试不同 placement 查看屏幕上的定位效果。`
|
||||
}}
|
||||
</p>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button class="w-full">继续</Button>
|
||||
</ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,83 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalBody,
|
||||
ModalClose,
|
||||
ModalCloseTrigger,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
Radio,
|
||||
RadioContent,
|
||||
RadioControl,
|
||||
RadioGroup,
|
||||
RadioIndicator,
|
||||
} from "@heroui-vue/components";
|
||||
const scroll = ref<"inside" | "outside">("inside");
|
||||
function setScroll(value: "inside" | "outside") {
|
||||
scroll.value = value;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<RadioGroup
|
||||
orientation="horizontal"
|
||||
:model-value="scroll"
|
||||
@update:model-value="(value) => setScroll(value as 'inside' | 'outside')"
|
||||
>
|
||||
<Radio value="inside">
|
||||
<RadioContent>
|
||||
<RadioControl><RadioIndicator></RadioIndicator></RadioControl>
|
||||
内部
|
||||
</RadioContent>
|
||||
</Radio>
|
||||
<Radio value="outside">
|
||||
<RadioContent>
|
||||
<RadioControl><RadioIndicator></RadioIndicator></RadioControl>
|
||||
外部
|
||||
</RadioContent>
|
||||
</Radio>
|
||||
</RadioGroup>
|
||||
<Modal>
|
||||
<Button variant="secondary">
|
||||
打开模态框({{ scroll.charAt(0).toUpperCase() + scroll.slice(1) }})
|
||||
</Button>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer :scroll="scroll">
|
||||
<ModalDialog class="sm:max-w-[360px]">
|
||||
<ModalHeader>
|
||||
<ModalHeading>
|
||||
{{ scroll === "inside" ? "滚动:内部" : "滚动:外部" }}
|
||||
</ModalHeading>
|
||||
<p class="text-sm leading-5 text-muted">
|
||||
对比滚动行为——内部在模态框内滚动内容,外部允许页面滚动
|
||||
</p>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<template v-for="(_, i) in Array.from({ length: 30 })" :key="i">
|
||||
<p class="mb-3">
|
||||
段落 {{ i + 1 }}: Lorem ipsum dolor sit amet, consectetur
|
||||
adipiscing elit. Nullam pulvinar risus non risus hendrerit
|
||||
venenatis. Pellentesque sit amet hendrerit risus, sed
|
||||
porttitor quam.
|
||||
</p>
|
||||
</template>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button variant="secondary">取消</Button>
|
||||
</ModalClose>
|
||||
<ModalClose as-child><Button>确认</Button></ModalClose>
|
||||
</ModalFooter>
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,76 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalBody,
|
||||
ModalClose,
|
||||
ModalCloseTrigger,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
ModalIcon,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconRocket as Rocket } from "@tabler/icons-vue";
|
||||
const SIZE_LABELS = {
|
||||
cover: "通栏",
|
||||
full: "全屏",
|
||||
lg: "大",
|
||||
md: "中",
|
||||
sm: "小",
|
||||
xs: "超小",
|
||||
} as const;
|
||||
const sizes = ["xs", "sm", "md", "lg", "cover", "full"] as const;
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-wrap gap-4">
|
||||
<template v-for="size in sizes" :key="size">
|
||||
<Modal>
|
||||
<Button variant="secondary">{{ SIZE_LABELS[size] }}</Button>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer :size="size">
|
||||
<ModalDialog>
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
<ModalHeader>
|
||||
<ModalIcon class="bg-default text-foreground">
|
||||
<Rocket aria-hidden="true" class="size-5"></Rocket>
|
||||
</ModalIcon>
|
||||
<ModalHeading>尺寸:{{ SIZE_LABELS[size] }}</ModalHeading>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<p>
|
||||
<template v-if="size === 'cover'">
|
||||
此模态框使用
|
||||
<code>cover</code>
|
||||
尺寸:在移动端与桌面端保留边距(移动端约 16px、桌面端约
|
||||
40px)铺满可视区域,仍保持圆角与标准内边距,适合需要最大宽度又保留模态框气质的内容展示。
|
||||
</template>
|
||||
<template v-else>
|
||||
<template v-if="size === 'full'">
|
||||
此模态框使用
|
||||
<code>full</code>
|
||||
尺寸,占满整个视口,无边距、圆角或阴影,提供真正的全屏体验,适合沉浸式内容或全页交互。
|
||||
</template>
|
||||
<template v-else>
|
||||
此模态框使用
|
||||
<code>{{ size }}</code>
|
||||
尺寸。在移动端各尺寸都会接近全宽以便阅读;在桌面端则对应不同的最大宽度,以适配不同信息量。
|
||||
</template>
|
||||
</template>
|
||||
</p>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button variant="secondary">取消</Button>
|
||||
</ModalClose>
|
||||
<ModalClose as-child><Button>确认</Button></ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,94 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, useId } from "vue";
|
||||
import {
|
||||
Button,
|
||||
Input,
|
||||
Label,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalBody,
|
||||
ModalClose,
|
||||
ModalCloseTrigger,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
ModalIcon,
|
||||
Surface,
|
||||
TextField,
|
||||
useOverlayState,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconMail as Envelope } from "@tabler/icons-vue";
|
||||
const state = useOverlayState();
|
||||
const formId = useId();
|
||||
const result = ref<Record<string, FormDataEntryValue>>();
|
||||
function submit(event: SubmitEvent) {
|
||||
result.value = Object.fromEntries(
|
||||
new FormData(event.currentTarget as HTMLFormElement),
|
||||
);
|
||||
state.close();
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div>
|
||||
<Modal :state="state">
|
||||
<Button variant="secondary">打开联系表单</Button>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer placement="auto">
|
||||
<ModalDialog class="sm:max-w-md">
|
||||
<ModalCloseTrigger></ModalCloseTrigger>
|
||||
<ModalHeader>
|
||||
<ModalIcon class="bg-accent-soft text-accent-soft-foreground">
|
||||
<Envelope aria-hidden="true" class="size-5"></Envelope>
|
||||
</ModalIcon>
|
||||
<ModalHeading>联系我们</ModalHeading>
|
||||
<p class="mt-1.5 text-sm leading-5 text-muted">
|
||||
填写下方表单,我们会尽快回复。在移动端弹出键盘时,模态框会自动适配。
|
||||
</p>
|
||||
</ModalHeader>
|
||||
<ModalBody class="p-6">
|
||||
<Surface variant="default">
|
||||
<form
|
||||
:id="formId"
|
||||
class="flex flex-col gap-4"
|
||||
@submit.prevent="submit"
|
||||
>
|
||||
<TextField class="w-full" name="name" type="text">
|
||||
<Label>姓名</Label>
|
||||
<Input placeholder="输入你的姓名"></Input>
|
||||
</TextField>
|
||||
<TextField class="w-full" name="email" type="email">
|
||||
<Label>邮箱</Label>
|
||||
<Input placeholder="输入你的邮箱"></Input>
|
||||
</TextField>
|
||||
<TextField class="w-full" name="phone" type="tel">
|
||||
<Label>电话</Label>
|
||||
<Input placeholder="输入你的电话号码"></Input>
|
||||
</TextField>
|
||||
<TextField class="w-full" name="company">
|
||||
<Label>公司</Label>
|
||||
<Input placeholder="输入公司名称"></Input>
|
||||
</TextField>
|
||||
<TextField class="w-full" name="message">
|
||||
<Label>留言</Label>
|
||||
<Input placeholder="输入留言内容"></Input>
|
||||
</TextField>
|
||||
</form>
|
||||
</Surface>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child>
|
||||
<Button variant="secondary">取消</Button>
|
||||
</ModalClose>
|
||||
<Button type="submit" :form="formId">发送消息</Button>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
<p v-if="result" role="status" class="mt-3 text-sm text-muted">
|
||||
已记录表单:{{ result }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,24 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverDialog,
|
||||
PopoverHeading,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-4">
|
||||
<Popover>
|
||||
<Button>点击我</Button>
|
||||
<PopoverContent class="max-w-64">
|
||||
<PopoverDialog>
|
||||
<PopoverHeading>弹出层标题</PopoverHeading>
|
||||
<p class="mt-2 text-sm text-muted">
|
||||
这是弹出层内容,你可以在这里放置任何内容。
|
||||
</p>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,43 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverDialog,
|
||||
PopoverHeading,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Popover>
|
||||
<Button variant="secondary">详情</Button>
|
||||
<PopoverContent
|
||||
class="max-w-56 overflow-hidden rounded-xl border border-border/80 bg-surface/90 p-0 shadow-xl ring-1 ring-black/5 backdrop-blur-xl dark:border-border/90 dark:bg-surface/85 dark:ring-white/10"
|
||||
>
|
||||
<PopoverDialog class="relative p-4">
|
||||
<div
|
||||
aria-hidden="true"
|
||||
class="pointer-events-none absolute inset-x-0 top-0 h-12 bg-linear-to-b from-neutral-500/6 to-transparent dark:from-neutral-400/8"
|
||||
></div>
|
||||
<PopoverHeading
|
||||
class="relative font-medium text-neutral-800 dark:text-neutral-100"
|
||||
>
|
||||
键盘快捷键
|
||||
</PopoverHeading>
|
||||
<dl class="relative mt-3 space-y-2 text-sm">
|
||||
<div class="flex justify-between gap-4">
|
||||
<dt class="text-muted">保存</dt>
|
||||
<dd class="font-mono text-neutral-700 dark:text-neutral-300">
|
||||
⌘ S
|
||||
</dd>
|
||||
</div>
|
||||
<div class="flex justify-between gap-4">
|
||||
<dt class="text-muted">搜索</dt>
|
||||
<dd class="font-mono text-neutral-700 dark:text-neutral-300">
|
||||
⌘ K
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</template>
|
||||
@@ -0,0 +1,81 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
Avatar,
|
||||
AvatarFallback,
|
||||
AvatarImage,
|
||||
Button,
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverDialog,
|
||||
PopoverHeading,
|
||||
PopoverTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
const isFollowing = ref(false);
|
||||
function setIsFollowing(value: boolean) {
|
||||
isFollowing.value = value;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-6">
|
||||
<Popover>
|
||||
<PopoverTrigger aria-label="用户资料">
|
||||
<div class="flex items-center gap-2">
|
||||
<Avatar size="sm">
|
||||
<AvatarImage
|
||||
alt="Sarah Johnson"
|
||||
src="https://img.heroui.chat/image/avatar?w=400&h=400&u=1"
|
||||
></AvatarImage>
|
||||
<AvatarFallback>SJ</AvatarFallback>
|
||||
</Avatar>
|
||||
<div class="flex flex-col">
|
||||
<p class="text-sm font-medium">Sarah Johnson</p>
|
||||
<p class="text-xs text-muted">@sarahj</p>
|
||||
</div>
|
||||
</div>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent class="w-[320px]">
|
||||
<PopoverDialog>
|
||||
<PopoverHeading>
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-3">
|
||||
<Avatar size="md">
|
||||
<AvatarImage
|
||||
alt="Sarah Johnson"
|
||||
src="https://img.heroui.chat/image/avatar?w=400&h=400&u=1"
|
||||
></AvatarImage>
|
||||
<AvatarFallback>SJ</AvatarFallback>
|
||||
</Avatar>
|
||||
<div>
|
||||
<p class="font-semibold">Sarah Johnson</p>
|
||||
<p class="text-sm text-muted">@sarahj</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
class="rounded-full"
|
||||
size="sm"
|
||||
:variant="isFollowing ? 'tertiary' : 'primary'"
|
||||
@click="setIsFollowing(!isFollowing)"
|
||||
>
|
||||
{{ isFollowing ? "已关注" : "关注" }}
|
||||
</Button>
|
||||
</div>
|
||||
</PopoverHeading>
|
||||
<p class="mt-3 text-sm text-muted">
|
||||
产品设计师兼创意总监,打造有意义的美好体验。
|
||||
</p>
|
||||
<div class="mt-3 flex gap-4">
|
||||
<div>
|
||||
<span class="font-semibold">892</span>
|
||||
<span class="ms-1 text-sm text-muted">关注中</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="font-semibold">12.5K</span>
|
||||
<span class="ms-1 text-sm text-muted">粉丝</span>
|
||||
</div>
|
||||
</div>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,56 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Popover,
|
||||
PopoverArrow,
|
||||
PopoverContent,
|
||||
PopoverDialog,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="grid grid-cols-3 gap-4">
|
||||
<div></div>
|
||||
<Popover>
|
||||
<Button class="w-full" variant="tertiary">Top</Button>
|
||||
<PopoverContent placement="top">
|
||||
<PopoverDialog>
|
||||
<PopoverArrow></PopoverArrow>
|
||||
<p class="text-sm">顶部位置</p>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
<div></div>
|
||||
<Popover>
|
||||
<Button class="w-full" variant="tertiary">Left</Button>
|
||||
<PopoverContent placement="left">
|
||||
<PopoverDialog>
|
||||
<PopoverArrow></PopoverArrow>
|
||||
<p class="text-sm">左侧位置</p>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
<div class="flex items-center justify-center">
|
||||
<span class="text-sm text-muted">点击按钮</span>
|
||||
</div>
|
||||
<Popover>
|
||||
<Button class="w-full" variant="tertiary">Right</Button>
|
||||
<PopoverContent placement="right">
|
||||
<PopoverDialog>
|
||||
<PopoverArrow></PopoverArrow>
|
||||
<p class="text-sm">右侧位置</p>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
<div></div>
|
||||
<Popover>
|
||||
<Button class="w-full" variant="tertiary">Bottom</Button>
|
||||
<PopoverContent placement="bottom">
|
||||
<PopoverDialog>
|
||||
<PopoverArrow></PopoverArrow>
|
||||
<p class="text-sm">底部位置</p>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
<div></div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,24 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverDialog,
|
||||
PopoverHeading,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-4">
|
||||
<Popover>
|
||||
<Button>点击我</Button>
|
||||
<PopoverContent class="max-w-64" as="div" data-custom="foo">
|
||||
<PopoverDialog>
|
||||
<PopoverHeading>弹出层标题</PopoverHeading>
|
||||
<p class="mt-2 text-sm text-muted">
|
||||
这是弹出层内容,你可以在这里放置任何内容。
|
||||
</p>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Popover,
|
||||
PopoverArrow,
|
||||
PopoverContent,
|
||||
PopoverDialog,
|
||||
PopoverHeading,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconDots as Ellipsis } from "@tabler/icons-vue";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-4">
|
||||
<Popover>
|
||||
<Button variant="secondary">带箭头</Button>
|
||||
<PopoverContent class="max-w-64">
|
||||
<PopoverDialog>
|
||||
<PopoverArrow></PopoverArrow>
|
||||
<PopoverHeading>带箭头的弹出层</PopoverHeading>
|
||||
<p class="mt-2 text-sm text-muted">箭头指向触发弹出层的元素。</p>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
<Popover>
|
||||
<Button isIconOnly aria-label="更多选项" variant="tertiary">
|
||||
<Ellipsis aria-hidden="true"></Ellipsis>
|
||||
</Button>
|
||||
<PopoverContent class="max-w-64" :offset="10">
|
||||
<PopoverDialog>
|
||||
<PopoverArrow></PopoverArrow>
|
||||
<PopoverHeading>带箭头的弹出层</PopoverHeading>
|
||||
<p class="mt-2 text-sm text-muted">箭头指向触发弹出层的元素。</p>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import { Button, Tooltip, TooltipContent } from "@heroui-vue/components";
|
||||
import { IconInfoCircle as CircleInfo } from "@tabler/icons-vue";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-4">
|
||||
<Tooltip :delay="0">
|
||||
<Button variant="secondary">悬停查看</Button>
|
||||
<TooltipContent><p>这是一个工具提示</p></TooltipContent>
|
||||
</Tooltip>
|
||||
<Tooltip :delay="0">
|
||||
<Button isIconOnly aria-label="更多信息" variant="tertiary">
|
||||
<CircleInfo aria-hidden="true"></CircleInfo>
|
||||
</Button>
|
||||
<TooltipContent><p>更多信息</p></TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { Button, Tooltip, TooltipContent } from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Tooltip :delay="0">
|
||||
<Button variant="secondary">分享链接</Button>
|
||||
<TooltipContent
|
||||
class="rounded-lg border border-border/80 bg-surface px-2.5 py-1 text-xs text-foreground shadow-sm"
|
||||
>
|
||||
<p>已复制到剪贴板</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</template>
|
||||
@@ -0,0 +1,77 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarFallback,
|
||||
AvatarImage,
|
||||
Chip,
|
||||
ChipLabel,
|
||||
Tooltip,
|
||||
TooltipArrow,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconCircleCheckFilled as CircleCheckFill,
|
||||
IconHelpCircle as CircleQuestion,
|
||||
} from "@tabler/icons-vue";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-6">
|
||||
<Tooltip :delay="0">
|
||||
<TooltipTrigger aria-label="用户头像">
|
||||
<Avatar size="sm">
|
||||
<AvatarImage
|
||||
alt="Jane Doe"
|
||||
src="https://img.heroui.chat/image/avatar?w=400&h=400&u=4"
|
||||
></AvatarImage>
|
||||
<AvatarFallback>JD</AvatarFallback>
|
||||
</Avatar>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent showArrow>
|
||||
<TooltipArrow></TooltipArrow>
|
||||
<div class="flex flex-col gap-0 py-1">
|
||||
<p class="font-semibold">Jane Doe</p>
|
||||
<p class="text-xs text-muted">jane@example.com</p>
|
||||
</div>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<Tooltip :delay="0">
|
||||
<TooltipTrigger aria-label="状态标签">
|
||||
<Chip color="success">
|
||||
<CircleCheckFill aria-hidden="true" :width="12"></CircleCheckFill>
|
||||
<ChipLabel>活跃</ChipLabel>
|
||||
</Chip>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent class="flex items-center gap-1.5">
|
||||
<span class="relative flex size-2">
|
||||
<span
|
||||
class="absolute inline-flex h-full w-full animate-ping rounded-full bg-success opacity-75"
|
||||
></span>
|
||||
<span
|
||||
class="relative inline-flex size-2 rounded-full bg-success"
|
||||
></span>
|
||||
</span>
|
||||
<p>Jane 当前在线</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<Tooltip :delay="0">
|
||||
<TooltipTrigger aria-label="信息图标">
|
||||
<div class="rounded-full bg-accent-soft p-2">
|
||||
<CircleQuestion
|
||||
aria-hidden="true"
|
||||
class="text-accent"
|
||||
></CircleQuestion>
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent showArrow>
|
||||
<TooltipArrow></TooltipArrow>
|
||||
<div class="max-w-xs px-1 py-1.5">
|
||||
<p class="mb-1 font-semibold">帮助信息</p>
|
||||
<p class="text-sm text-muted">
|
||||
这是包含有关此功能更详细信息的实用工具提示。
|
||||
</p>
|
||||
</div>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,47 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Tooltip,
|
||||
TooltipArrow,
|
||||
TooltipContent,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="grid grid-cols-3 gap-4">
|
||||
<div></div>
|
||||
<Tooltip :delay="0">
|
||||
<Button class="w-full" variant="tertiary">Top</Button>
|
||||
<TooltipContent showArrow placement="top">
|
||||
<TooltipArrow></TooltipArrow>
|
||||
<p>顶部位置</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<div></div>
|
||||
<Tooltip :delay="0">
|
||||
<Button class="w-full" variant="tertiary">Left</Button>
|
||||
<TooltipContent showArrow placement="left">
|
||||
<TooltipArrow></TooltipArrow>
|
||||
<p>左侧位置</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<div class="flex items-center justify-center">
|
||||
<span class="text-sm text-muted">悬停按钮</span>
|
||||
</div>
|
||||
<Tooltip :delay="0">
|
||||
<Button class="w-full" variant="tertiary">Right</Button>
|
||||
<TooltipContent showArrow placement="right">
|
||||
<TooltipArrow></TooltipArrow>
|
||||
<p>右侧位置</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<div></div>
|
||||
<Tooltip :delay="0">
|
||||
<Button class="w-full" variant="tertiary">Bottom</Button>
|
||||
<TooltipContent showArrow placement="bottom">
|
||||
<TooltipArrow></TooltipArrow>
|
||||
<p>底部位置</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<div></div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import { Button, Tooltip, TooltipContent } from "@heroui-vue/components";
|
||||
import { IconInfoCircle as CircleInfo } from "@tabler/icons-vue";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-4">
|
||||
<Tooltip :delay="0">
|
||||
<Button variant="secondary">悬停查看</Button>
|
||||
<TooltipContent as="div" data-custom="foo">
|
||||
<p>这是一个工具提示</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<Tooltip :delay="0">
|
||||
<Button isIconOnly aria-label="更多信息" variant="tertiary">
|
||||
<CircleInfo aria-hidden="true"></CircleInfo>
|
||||
</Button>
|
||||
<TooltipContent as="div" data-custom="foo">
|
||||
<p>更多信息</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
Tooltip,
|
||||
TooltipArrow,
|
||||
TooltipContent,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex items-center gap-4">
|
||||
<Tooltip :delay="0">
|
||||
<Button variant="secondary">带箭头</Button>
|
||||
<TooltipContent showArrow>
|
||||
<TooltipArrow></TooltipArrow>
|
||||
<p>带箭头指示器的工具提示</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<Tooltip :delay="0">
|
||||
<Button variant="primary">自定义偏移</Button>
|
||||
<TooltipContent showArrow :offset="12">
|
||||
<TooltipArrow></TooltipArrow>
|
||||
<p>与触发器的自定义偏移</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,5 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import OverlayAnimationLab from "./OverlayAnimationLab.vue";
|
||||
const animationLab =
|
||||
typeof window !== "undefined" &&
|
||||
new URLSearchParams(window.location.search).has("overlay-animation");
|
||||
import OverlayLab from "./OverlayLab.vue";
|
||||
import OverlayComponentsLab from "./OverlayComponentsLab.vue";
|
||||
const componentsLab =
|
||||
typeof window !== "undefined" &&
|
||||
new URLSearchParams(window.location.search).has("overlay-components");
|
||||
const overlayLab =
|
||||
typeof window !== "undefined" &&
|
||||
new URLSearchParams(window.location.search).has("overlay-lab");
|
||||
import { Button, Card, Input, Switch } from "@heroui-vue/components";
|
||||
const dark = ref(false),
|
||||
notifications = ref(true),
|
||||
@@ -11,7 +23,10 @@ function save() {
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="lab" :data-theme="dark ? 'dark' : 'light'">
|
||||
<OverlayAnimationLab v-if="animationLab" />
|
||||
<OverlayComponentsLab v-else-if="componentsLab" />
|
||||
<OverlayLab v-else-if="overlayLab" />
|
||||
<div v-else class="lab" :data-theme="dark ? 'dark' : 'light'">
|
||||
<header>
|
||||
<a class="wordmark" href="#">
|
||||
hero
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onBeforeUnmount, ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalHeading,
|
||||
ModalCloseTrigger,
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverDialog,
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
} from "@heroui-vue/components";
|
||||
const records = ref<string[]>([]);
|
||||
let frame = 0;
|
||||
function record(event: Event) {
|
||||
const el = event.target as HTMLElement;
|
||||
const slot = el.dataset.slot;
|
||||
if (
|
||||
!slot ||
|
||||
!/^(modal-(backdrop|container|dialog)|popover-content|tooltip-content)$/.test(
|
||||
slot,
|
||||
)
|
||||
)
|
||||
return;
|
||||
const css = getComputedStyle(el);
|
||||
const ae = event as AnimationEvent;
|
||||
records.value.push(
|
||||
JSON.stringify({
|
||||
slot,
|
||||
event: event.type,
|
||||
name: ae.animationName,
|
||||
elapsed: ae.elapsedTime,
|
||||
duration: css.animationDuration,
|
||||
easing: css.animationTimingFunction,
|
||||
origin: css.transformOrigin,
|
||||
}),
|
||||
);
|
||||
if (event.type !== "animationstart") return;
|
||||
const start = performance.now();
|
||||
let last = -1;
|
||||
const sample = () => {
|
||||
if (!el.isConnected) return;
|
||||
const bucket = Math.floor((performance.now() - start) / 35);
|
||||
if (bucket !== last) {
|
||||
const c = getComputedStyle(el);
|
||||
records.value.push(
|
||||
JSON.stringify({
|
||||
slot,
|
||||
ms: Math.round(performance.now() - start),
|
||||
enter: el.dataset.entering,
|
||||
exit: el.dataset.exiting,
|
||||
opacity: c.opacity,
|
||||
transform: c.transform,
|
||||
transition: c.transitionDuration,
|
||||
}),
|
||||
);
|
||||
last = bucket;
|
||||
}
|
||||
if (performance.now() - start < 360) frame = requestAnimationFrame(sample);
|
||||
};
|
||||
sample();
|
||||
}
|
||||
onMounted(() => {
|
||||
for (const event of ["animationstart", "animationend", "animationcancel"])
|
||||
document.addEventListener(event, record, true);
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
for (const event of ["animationstart", "animationend", "animationcancel"])
|
||||
document.removeEventListener(event, record, true);
|
||||
cancelAnimationFrame(frame);
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<main class="p-8 flex flex-col gap-6">
|
||||
<h1>弹层动画诊断(真实组件)</h1>
|
||||
<p>
|
||||
基线:Modal 内容进入 250ms,遮罩进入 150ms;Popover/Tooltip 进入
|
||||
150ms;退出均 100ms。
|
||||
</p>
|
||||
<div class="flex gap-4">
|
||||
<Modal>
|
||||
<Button>动画 Modal</Button>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer>
|
||||
<ModalDialog>
|
||||
<ModalHeading>动画检查</ModalHeading>
|
||||
<ModalCloseTrigger />
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
<Popover>
|
||||
<Button>动画 Popover</Button>
|
||||
<PopoverContent>
|
||||
<PopoverDialog>Popover 内容</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
<Tooltip :delay="0" :close-delay="0">
|
||||
<Button>动画 Tooltip</Button>
|
||||
<TooltipContent>Tooltip 内容</TooltipContent>
|
||||
</Tooltip>
|
||||
<Button variant="secondary" @click="records = []">清空记录</Button>
|
||||
</div>
|
||||
<pre data-testid="animation-records" class="text-xs whitespace-pre-wrap">{{
|
||||
records.join("\n")
|
||||
}}</pre>
|
||||
</main>
|
||||
</template>
|
||||
@@ -0,0 +1,66 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalHeading,
|
||||
ModalBody,
|
||||
ModalCloseTrigger,
|
||||
ModalClose,
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverDialog,
|
||||
PopoverHeading,
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<main class="lab" style="padding: 2rem">
|
||||
<h1>公开弹层组合回归</h1>
|
||||
<Modal>
|
||||
<Button>打开主弹层</Button>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer>
|
||||
<ModalDialog>
|
||||
<ModalCloseTrigger />
|
||||
<ModalHeading>主弹层</ModalHeading>
|
||||
<ModalBody class="flex flex-col gap-4">
|
||||
<input aria-label="主层字段" />
|
||||
<Popover>
|
||||
<Button>打开定位层</Button>
|
||||
<PopoverContent>
|
||||
<PopoverDialog class="flex flex-col gap-3">
|
||||
<PopoverHeading>定位层</PopoverHeading>
|
||||
<input aria-label="定位字段" />
|
||||
<Tooltip :delay="0">
|
||||
<Button>提示触发器</Button>
|
||||
<TooltipContent>嵌套提示</TooltipContent>
|
||||
</Tooltip>
|
||||
<Modal>
|
||||
<Button>打开子模态框</Button>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer>
|
||||
<ModalDialog>
|
||||
<ModalHeading>子模态框</ModalHeading>
|
||||
<input aria-label="子层字段" />
|
||||
<ModalClose as-child>
|
||||
<Button>关闭子层</Button>
|
||||
</ModalClose>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
<ModalClose as-child><Button>关闭主层</Button></ModalClose>
|
||||
</ModalBody>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</main>
|
||||
</template>
|
||||
@@ -0,0 +1,213 @@
|
||||
<script setup lang="ts">
|
||||
import { nextTick, ref } from "vue";
|
||||
import {
|
||||
DialogTrigger,
|
||||
DialogClose,
|
||||
DialogTitle,
|
||||
DialogDescription,
|
||||
PopoverRoot,
|
||||
PopoverTrigger,
|
||||
PopoverPortal,
|
||||
PopoverContent,
|
||||
} from "../../../packages/vue/src/components/overlay/primitives";
|
||||
import { ConfigProvider, useOverlayState } from "@heroui-vue/components";
|
||||
import OverlayDialogRoot from "../../../packages/vue/src/components/overlay/OverlayDialogRoot.vue";
|
||||
import OverlayDialogContent from "../../../packages/vue/src/components/overlay/OverlayDialogContent.vue";
|
||||
import OverlayPortal from "../../../packages/vue/src/components/overlay/OverlayPortal.vue";
|
||||
import OverlayBackdrop from "../../../packages/vue/src/components/overlay/OverlayBackdrop.vue";
|
||||
|
||||
const opened = ref(false);
|
||||
const dismissable = ref(true);
|
||||
const keyboardDisabled = ref(false);
|
||||
const rejectClose = ref(false);
|
||||
const state = useOverlayState({
|
||||
isOpen: opened,
|
||||
onOpenChange(value) {
|
||||
if (value || !rejectClose.value) opened.value = value;
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ConfigProvider teleport-to="#overlay-lab-portals">
|
||||
<main class="overlay-lab">
|
||||
<h1>弹层基础设施验证</h1>
|
||||
<p>私有基础设施探针:使用自编 120ms 动画,不代表 HeroUI 公开组件效果。</p>
|
||||
<p>
|
||||
<a href="http://127.0.0.1:5173/components/modal">
|
||||
正式组件文档(5173)
|
||||
</a>
|
||||
·
|
||||
<a href="?overlay-animation">公开组件动画诊断</a>
|
||||
</p>
|
||||
<label>
|
||||
<input v-model="dismissable" type="checkbox" />
|
||||
允许外部关闭
|
||||
</label>
|
||||
<label>
|
||||
<input v-model="keyboardDisabled" type="checkbox" />
|
||||
禁用 Escape 关闭
|
||||
</label>
|
||||
<label>
|
||||
<input v-model="rejectClose" type="checkbox" />
|
||||
父级拒绝关闭
|
||||
</label>
|
||||
<output data-testid="open-state">{{ opened ? "open" : "closed" }}</output>
|
||||
<OverlayDialogRoot :state="state">
|
||||
<DialogTrigger data-testid="open-modal">打开模态探针</DialogTrigger>
|
||||
<OverlayPortal>
|
||||
<OverlayBackdrop class="lab-backdrop" data-testid="backdrop" />
|
||||
<OverlayDialogContent
|
||||
class="lab-panel"
|
||||
data-testid="modal"
|
||||
:is-dismissable="dismissable"
|
||||
:is-keyboard-dismiss-disabled="keyboardDisabled"
|
||||
>
|
||||
<DialogTitle>主弹层</DialogTitle>
|
||||
<DialogDescription>
|
||||
验证焦点循环、嵌套关闭、受控拒绝与退出生命周期。
|
||||
</DialogDescription>
|
||||
<input aria-label="主弹层输入" />
|
||||
<PopoverRoot>
|
||||
<PopoverTrigger>打开定位探针</PopoverTrigger>
|
||||
<PopoverPortal>
|
||||
<PopoverContent
|
||||
class="lab-floating"
|
||||
aria-label="定位探针"
|
||||
:side-offset="8"
|
||||
>
|
||||
<label>
|
||||
定位探针
|
||||
<input aria-label="浮层输入" />
|
||||
</label>
|
||||
</PopoverContent>
|
||||
</PopoverPortal>
|
||||
</PopoverRoot>
|
||||
<OverlayDialogRoot>
|
||||
<DialogTrigger data-testid="open-nested">
|
||||
打开嵌套弹层
|
||||
</DialogTrigger>
|
||||
<OverlayPortal>
|
||||
<OverlayBackdrop class="lab-backdrop lab-nested-backdrop" />
|
||||
<OverlayDialogContent
|
||||
class="lab-panel lab-nested-panel"
|
||||
data-testid="nested"
|
||||
>
|
||||
<DialogTitle>嵌套弹层</DialogTitle>
|
||||
<DialogDescription>
|
||||
Escape 应先关闭本层,主弹层继续锁定滚动。
|
||||
</DialogDescription>
|
||||
<input aria-label="嵌套输入" />
|
||||
<DialogClose>关闭嵌套弹层</DialogClose>
|
||||
</OverlayDialogContent>
|
||||
</OverlayPortal>
|
||||
</OverlayDialogRoot>
|
||||
<button
|
||||
@click="
|
||||
state.close();
|
||||
nextTick(state.open);
|
||||
"
|
||||
>
|
||||
快速关闭再打开
|
||||
</button>
|
||||
<DialogClose>关闭主弹层</DialogClose>
|
||||
</OverlayDialogContent>
|
||||
</OverlayPortal>
|
||||
</OverlayDialogRoot>
|
||||
<button @click="state.open">命令式打开</button>
|
||||
<button data-testid="outside">外部按钮</button>
|
||||
<div class="lab-scroll-space">滚动区域</div>
|
||||
</main>
|
||||
<div id="overlay-lab-portals" />
|
||||
</ConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.overlay-lab {
|
||||
padding: 2rem;
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
max-width: 50rem;
|
||||
margin: auto;
|
||||
}
|
||||
.overlay-lab button,
|
||||
.lab-panel button,
|
||||
.lab-panel input,
|
||||
.lab-floating input {
|
||||
border: 1px solid currentColor;
|
||||
border-radius: 0.5rem;
|
||||
padding: 0.5rem 1rem;
|
||||
}
|
||||
.lab-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 50;
|
||||
background: #0006;
|
||||
}
|
||||
.lab-panel {
|
||||
position: fixed;
|
||||
z-index: 51;
|
||||
top: 20%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: min(30rem, calc(100vw - 2rem));
|
||||
padding: 1.5rem;
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
background: var(--surface, white);
|
||||
color: var(--foreground, #111);
|
||||
border-radius: 1rem;
|
||||
box-shadow: 0 10px 40px #0003;
|
||||
}
|
||||
.lab-nested-backdrop {
|
||||
z-index: 60;
|
||||
}
|
||||
.lab-nested-panel {
|
||||
z-index: 61;
|
||||
top: 25%;
|
||||
}
|
||||
.lab-floating {
|
||||
z-index: 70;
|
||||
padding: 1rem;
|
||||
background: var(--surface, white);
|
||||
border: 1px solid currentColor;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
.lab-scroll-space {
|
||||
height: 140vh;
|
||||
}
|
||||
.lab-panel[data-state="open"],
|
||||
.lab-backdrop[data-state="open"],
|
||||
.lab-floating[data-state="open"] {
|
||||
animation: lab-enter 120ms ease-out;
|
||||
}
|
||||
.lab-panel[data-state="closed"],
|
||||
.lab-backdrop[data-state="closed"],
|
||||
.lab-floating[data-state="closed"] {
|
||||
animation: lab-exit 120ms ease-in;
|
||||
pointer-events: none;
|
||||
}
|
||||
@keyframes lab-enter {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@keyframes lab-exit {
|
||||
from {
|
||||
opacity: 1;
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.lab-panel,
|
||||
.lab-backdrop,
|
||||
.lab-floating {
|
||||
animation: none !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,5 @@
|
||||
@import "tailwindcss";
|
||||
@import "../../../packages/styles/dist/styles.css";
|
||||
@import "@heroui-vue/styles/css";
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@@ -2,16 +2,33 @@ import { defineConfig } from "vite";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import { fileURLToPath, URL } from "node:url";
|
||||
export default defineConfig({
|
||||
export default defineConfig(({ command }) => ({
|
||||
plugins: [vue(), tailwindcss()],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@heroui-vue/components": fileURLToPath(
|
||||
new URL("../../packages/vue/src/index.ts", import.meta.url),
|
||||
),
|
||||
"@heroui-vue/styles": fileURLToPath(
|
||||
new URL("../../packages/styles/src/index.ts", import.meta.url),
|
||||
),
|
||||
},
|
||||
alias: [
|
||||
...(command === "serve"
|
||||
? [
|
||||
{
|
||||
find: /^@heroui-vue\/styles\/css$/,
|
||||
replacement: fileURLToPath(
|
||||
new URL("../../packages/styles/index.css", import.meta.url),
|
||||
),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
find: /^@heroui-vue\/components$/,
|
||||
replacement: fileURLToPath(
|
||||
new URL("../../packages/vue/src/index.ts", import.meta.url),
|
||||
),
|
||||
},
|
||||
{
|
||||
find: /^@heroui-vue\/styles$/,
|
||||
replacement: fileURLToPath(
|
||||
new URL("../../packages/styles/src/index.ts", import.meta.url),
|
||||
),
|
||||
},
|
||||
],
|
||||
dedupe: ["vue"],
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
+93
-85
@@ -2,91 +2,91 @@
|
||||
|
||||
基于固定上游提交的公共组件导出清单。验证中不等于完整兼容;目前没有组件完成视觉、浏览器与完整行为验收。
|
||||
|
||||
| 组件 | 状态 | 当前能力 / 差异 |
|
||||
| -------------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| accordion | 验证中(M23) | Accordion/Item/Heading/Trigger/Panel/Body/Indicator;10/10 基线例;surface/hideSeparator;复用组键协议 |
|
||||
| alert-dialog | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| autocomplete | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| avatar | 验证中(最小实现) | Reka Avatar 加载/回退;size/color/variant;Image asChild;AvatarGroup 继承仅限直接子级 |
|
||||
| avatar-group | 验证中(最小实现) | max 截断与自动计数、显式 Count 不受截断、isGrid、overlap clip/ring;默认无 role=group |
|
||||
| badge | 验证中(最小实现) | Badge/BadgeAnchor/BadgeLabel;四角定位、圆点、文本/数字自动包装;Anchor 非链接 |
|
||||
| breadcrumbs | 验证中(M17) | Breadcrumbs/BreadcrumbsItem;7/7 基线例;ol+aria-label、末项 current、禁用/无 href span、separator 插槽;onAction 未提供,class 同时落 li/link |
|
||||
| button | 验证中(最小实现) | 基线全部 7 种变体、尺寸、isIconOnly/isDisabled/isPending;PressEvent 与 Vue click 差异见文档 |
|
||||
| button-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| card | 验证中(最小实现) | 4 种表面变体;Header/Title/Description/Content/Footer 已实现;以基线 CSS 为准 |
|
||||
| checkbox | 验证中(基线实现) | 原生 label/input;checked/isSelected、半选、primary/secondary、Content/Control/Indicator;15 个基线预览 |
|
||||
| checkbox-group | 验证中(基线实现) | 数组模型、同名重复提交、required/readonly/disabled/reset、组标签与成员描述隔离;10 个基线预览 |
|
||||
| chip | 验证中(最小实现) | color/size/variant;纯文本/数字自动包装为 ChipLabel;显式部件不重复包装;组合内容可动态切换 |
|
||||
| color-area | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-slider | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-swatch | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-swatch-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| close-button | 验证中(最小实现) | 专用 CSS/变体、默认基线 CloseIcon、插槽替换图标、isDisabled、aria-label 默认 Close;onPress 由 click 适配 |
|
||||
| combo-box | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| date-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| date-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| date-range-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| drawer | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| 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 | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| disclosure | 验证中(M21) | Disclosure/Heading/Trigger/Content/Body/Indicator;3/3 基线例;v-model:expanded;asChild 触发;高度动画映射测量变量 |
|
||||
| disclosure-group | 验证中(M22) | DisclosureGroup + useDisclosureGroupNavigation;3/3 基线例;展开键为数组(string 或 number);单选替换/多选增量 |
|
||||
| error-message | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| kbd | 验证中(最小实现) | variant;KbdAbbr keyValue 映射与 title;KbdContent;上下文类名;导出 kbdKeysMap/LabelMap |
|
||||
| link | 验证中(最小实现) | 原生 a + LinkIcon;isDisabled/asChild/焦点与 data 状态;默认图标为基线 ExternalLinkIcon;onPress 由 click 适配 |
|
||||
| popover | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| scroll-shadow | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| separator | 验证中(最小实现) | orientation/variant/decorative;默认 hr + role=separator;asChild 自定义根;Reka Separator |
|
||||
| skeleton | 验证中(最小实现) | shimmer/pulse/none、--skeleton-animation 全局默认、父级单次 shimmer;挂载后改 CSS 变量不自动更新 |
|
||||
| spinner | 验证中(最小实现) | size/color 变体、role=status、内置渐变 SVG;嵌入 Button 保持 16px;reduced-motion 支持 |
|
||||
| surface | 验证中(最小实现) | 4 种变体、data-slot、surfaceContextKey 提供当前变体;Input 文档表面示例已替换为 Surface |
|
||||
| toast | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| toggle-button | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| switch | 验证中(最小实现) | 根字段与组合部件、3 尺寸、ARIA 透传、原生/ARIA 校验、FormData/reset;PressEvent 不等价 |
|
||||
| switch-group | 验证中(布局) | vertical/horizontal;不共享选择值,已移植基线 CSS |
|
||||
| tabs | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| tag | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| tag-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| toggle-button-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| toolbar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| tooltip | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| input | 验证中(字段接入) | 接入 TextField;复用值恢复/reset/ARIA;独立使用保持兼容;完整消费验收未完成 |
|
||||
| input-group | 验证中(字段接入) | Root/Input/TextArea/Prefix/Suffix;复用 useTextControl;变体继承 TextField 可覆盖;前后缀非表单字段 |
|
||||
| textarea | 验证中(字段接入) | rows 默认 3;变体/fullWidth/受控/FormData/reset;独立页 7/7 示例;接入 useTextControl |
|
||||
| textfield | 验证中(字段接入) | 值/状态/约束/校验/ID;独立页 13/13 示例;render 自定义根类型未支持(data-* 透传) |
|
||||
| search-field | 验证中(FORM-02) | 五部件、15 基线例;共享文本内核、clear/submit/IME/reset/SSR,边界见 FORM-02 |
|
||||
| typography | 验证中(M15) | Typography/Heading/Paragraph/Code/Prose 具名导出;6/6 基线例;type/as/align/color/weight/truncate;render 映射为 as |
|
||||
| label | 验证中(通用字段) | 自动 for、Switch 内 span、状态继承;独立页 2/2 示例 |
|
||||
| description | 验证中(通用字段) | 动态 ID 清理、外部 describedby 合并;独立页 2/2 示例;SSR 包装限制见基础协议 |
|
||||
| empty-state | 验证中(M16) | 单根 EmptyState;4 个自编示例(基线无页面/示例);默认 fallback;空节点判断与上游 children 真值回退边界不同 |
|
||||
| field-error | 验证中(通用字段) | 作用域插槽 validationErrors;独立页 2/2 示例;无完整 validationDetails(见基础协议) |
|
||||
| fieldset | 验证中(FORM-02) | 四部件、3 基线例与禁用验证例;响应式禁用、首 Legend 例外,边界见 FORM-02 |
|
||||
| form | 验证中(基础设施) | native/aria 校验、FormData/reset、服务端错误;完整基线文档与生态集成未完成 |
|
||||
| header | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| radio | 验证中(基线实现) | 原生 radio + Content/Control/Indicator;须在 RadioGroup 内,成员禁用/只读、作用域状态 |
|
||||
| radio-group | 验证中(基线实现) | 标量模型、roving Tab/方向键/dir/loop、原生提交/校验/reset;12 个基线预览 |
|
||||
| input-otp | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| alert | 验证中(最小实现) | status 五态;默认图标随 status;自定义 Indicator 空内容回退;内部 Surface 重置为 default |
|
||||
| list-box | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| list-box-item | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| list-box-section | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| dropdown | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| menu | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| menu-item | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| menu-section | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| modal | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| number-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| pagination | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| select | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| meter | 验证中(M20) | Meter/Output/Track/Fill;6/6 基线例;role=meter progressbar;无 isIndeterminate;测量语义独立于 Progress |
|
||||
| slider | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| table | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| calendar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| range-calendar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| calendar-year-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| 组件 | 状态 | 当前能力 / 差异 |
|
||||
| -------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| accordion | 验证中(M23) | Accordion/Item/Heading/Trigger/Panel/Body/Indicator;10/10 基线例;surface/hideSeparator;复用组键协议 |
|
||||
| alert-dialog | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| autocomplete | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| avatar | 验证中(最小实现) | Reka Avatar 加载/回退;size/color/variant;Image asChild;AvatarGroup 继承仅限直接子级 |
|
||||
| avatar-group | 验证中(最小实现) | max 截断与自动计数、显式 Count 不受截断、isGrid、overlap clip/ring;默认无 role=group |
|
||||
| badge | 验证中(最小实现) | Badge/BadgeAnchor/BadgeLabel;四角定位、圆点、文本/数字自动包装;Anchor 非链接 |
|
||||
| breadcrumbs | 验证中(M17) | Breadcrumbs/BreadcrumbsItem;7/7 基线例;ol+aria-label、末项 current、禁用/无 href span、separator 插槽;onAction 未提供,class 同时落 li/link |
|
||||
| button | 验证中(最小实现) | 基线全部 7 种变体、尺寸、isIconOnly/isDisabled/isPending;PressEvent 与 Vue click 差异见文档 |
|
||||
| button-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| card | 验证中(最小实现) | 4 种表面变体;Header/Title/Description/Content/Footer 已实现;以基线 CSS 为准 |
|
||||
| checkbox | 验证中(基线实现) | 原生 label/input;checked/isSelected、半选、primary/secondary、Content/Control/Indicator;15 个基线预览 |
|
||||
| checkbox-group | 验证中(基线实现) | 数组模型、同名重复提交、required/readonly/disabled/reset、组标签与成员描述隔离;10 个基线预览 |
|
||||
| chip | 验证中(最小实现) | color/size/variant;纯文本/数字自动包装为 ChipLabel;显式部件不重复包装;组合内容可动态切换 |
|
||||
| color-area | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-slider | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-swatch | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| color-swatch-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| close-button | 验证中(最小实现) | 专用 CSS/变体、默认基线 CloseIcon、插槽替换图标、isDisabled、aria-label 默认 Close;onPress 由 click 适配 |
|
||||
| combo-box | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| date-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| date-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| date-range-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| drawer | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| 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 | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| disclosure | 验证中(M21) | Disclosure/Heading/Trigger/Content/Body/Indicator;3/3 基线例;v-model:expanded;asChild 触发;高度动画映射测量变量 |
|
||||
| disclosure-group | 验证中(M22) | DisclosureGroup + useDisclosureGroupNavigation;3/3 基线例;展开键为数组(string 或 number);单选替换/多选增量 |
|
||||
| error-message | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| kbd | 验证中(最小实现) | variant;KbdAbbr keyValue 映射与 title;KbdContent;上下文类名;导出 kbdKeysMap/LabelMap |
|
||||
| link | 验证中(最小实现) | 原生 a + LinkIcon;isDisabled/asChild/焦点与 data 状态;默认图标为基线 ExternalLinkIcon;onPress 由 click 适配 |
|
||||
| popover | 验证中(OVERLAY-02) | Root/Trigger/Content/Dialog/Heading/Arrow;6/6 基线例;逻辑定位/碰撞/退出/标题;模态 closeAutoFocus 不支持取消恢复,见 OVERLAY-02 |
|
||||
| scroll-shadow | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| separator | 验证中(最小实现) | orientation/variant/decorative;默认 hr + role=separator;asChild 自定义根;Reka Separator |
|
||||
| skeleton | 验证中(最小实现) | shimmer/pulse/none、--skeleton-animation 全局默认、父级单次 shimmer;挂载后改 CSS 变量不自动更新 |
|
||||
| spinner | 验证中(最小实现) | size/color 变体、role=status、内置渐变 SVG;嵌入 Button 保持 16px;reduced-motion 支持 |
|
||||
| surface | 验证中(最小实现) | 4 种变体、data-slot、surfaceContextKey 提供当前变体;Input 文档表面示例已替换为 Surface |
|
||||
| toast | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| toggle-button | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| switch | 验证中(最小实现) | 根字段与组合部件、3 尺寸、ARIA 透传、原生/ARIA 校验、FormData/reset;PressEvent 不等价 |
|
||||
| switch-group | 验证中(布局) | vertical/horizontal;不共享选择值,已移植基线 CSS |
|
||||
| tabs | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| tag | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| tag-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| toggle-button-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| toolbar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| tooltip | 验证中(OVERLAY-02) | Root/Trigger/Content/Arrow;6/6 基线例;CSS 延迟/焦点/禁用/替换/定位;Provider warmup 与 RAC 全局调度不同 |
|
||||
| input | 验证中(字段接入) | 接入 TextField;复用值恢复/reset/ARIA;独立使用保持兼容;完整消费验收未完成 |
|
||||
| input-group | 验证中(字段接入) | Root/Input/TextArea/Prefix/Suffix;复用 useTextControl;变体继承 TextField 可覆盖;前后缀非表单字段 |
|
||||
| textarea | 验证中(字段接入) | rows 默认 3;变体/fullWidth/受控/FormData/reset;独立页 7/7 示例;接入 useTextControl |
|
||||
| textfield | 验证中(字段接入) | 值/状态/约束/校验/ID;独立页 13/13 示例;render 自定义根类型未支持(data-* 透传) |
|
||||
| search-field | 验证中(FORM-02) | 五部件、15 基线例;共享文本内核、clear/submit/IME/reset/SSR,边界见 FORM-02 |
|
||||
| typography | 验证中(M15) | Typography/Heading/Paragraph/Code/Prose 具名导出;6/6 基线例;type/as/align/color/weight/truncate;render 映射为 as |
|
||||
| label | 验证中(通用字段) | 自动 for、Switch 内 span、状态继承;独立页 2/2 示例 |
|
||||
| description | 验证中(通用字段) | 动态 ID 清理、外部 describedby 合并;独立页 2/2 示例;SSR 包装限制见基础协议 |
|
||||
| empty-state | 验证中(M16) | 单根 EmptyState;4 个自编示例(基线无页面/示例);默认 fallback;空节点判断与上游 children 真值回退边界不同 |
|
||||
| field-error | 验证中(通用字段) | 作用域插槽 validationErrors;独立页 2/2 示例;无完整 validationDetails(见基础协议) |
|
||||
| fieldset | 验证中(FORM-02) | 四部件、3 基线例与禁用验证例;响应式禁用、首 Legend 例外,边界见 FORM-02 |
|
||||
| form | 验证中(基础设施) | native/aria 校验、FormData/reset、服务端错误;完整基线文档与生态集成未完成 |
|
||||
| header | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| radio | 验证中(基线实现) | 原生 radio + Content/Control/Indicator;须在 RadioGroup 内,成员禁用/只读、作用域状态 |
|
||||
| radio-group | 验证中(基线实现) | 标量模型、roving Tab/方向键/dir/loop、原生提交/校验/reset;12 个基线预览 |
|
||||
| input-otp | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| alert | 验证中(最小实现) | status 五态;默认图标随 status;自定义 Indicator 空内容回退;内部 Surface 重置为 default |
|
||||
| list-box | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| list-box-item | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| list-box-section | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| dropdown | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| menu | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| menu-item | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| menu-section | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| modal | 验证中(OVERLAY-02) | Root/Trigger/Backdrop/Container/Dialog/Heading/Header/Body/Footer/Icon/Close/CloseTrigger;14/14 基线例;焦点/锁/滚动/退出动画;Vue close 部件替代 React slot |
|
||||
| number-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| pagination | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| select | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| meter | 验证中(M20) | Meter/Output/Track/Fill;6/6 基线例;role=meter progressbar;无 isIndeterminate;测量语义独立于 Progress |
|
||||
| slider | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| table | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| calendar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| range-calendar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| calendar-year-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
|
||||
## 公共导出差异
|
||||
|
||||
@@ -182,3 +182,11 @@ React render 自定义根类型不支持;原生 attrs/具名部件/作用域
|
||||
- 共享 Link 只做了一个最小修正:无 `href` 时不再输出 `target`。文档隔离修复把全局 `h1` 作用域收回到 `.docs-main > h1`,并让预览内联代码不再被文档正文样式覆盖。
|
||||
|
||||
以上三页验证中,不代表整库完成;逐像素自动对比、真实键盘 Tab、读屏、RTL、触屏、Nuxt 水合、独立安装 dist 与 `test:browser/visual/package` 尚未建立。
|
||||
|
||||
## 弹层共享设施(OVERLAY-01,2026-10-22)
|
||||
|
||||
已提供 `useOverlayState` 与最小 `ConfigProvider`(dir / locale / teleportTo);私有 Dialog 适配已做焦点、嵌套、关闭策略、锁与 Portal 垂直验证。详情见 [协议与限制](./decisions/overlay-foundation.md)。此为 OVERLAY-01 阶段记录;后续公共组件进展见下节,完整兼容验收仍未完成。
|
||||
|
||||
## Modal / Popover / Tooltip(OVERLAY-02)
|
||||
|
||||
公共部件、源 CSS/tv、中文文档、14 + 6 + 6 个基线演示与类型/行为回归已迁移;详情见 [OVERLAY-02 报告](./migrations/OVERLAY-02-modal-popover-tooltip.md)。框架适配采用 Vue 具名组件、v-model:open、as/asChild、原生事件与作用域插槽;不承诺 React PressEvent。Popover 模态 closeAutoFocus 继承 Reka 无条件恢复触发器的策略,取消恢复需非模态模式;Tooltip warmup 由 ConfigProvider 范围共享,非 RAC 全局调度。SSR Portal 挂载后插入。未声明逐像素、全部读屏/触屏/RTL、Nuxt 或独立打包安装验收。
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
# OVERLAY-01:弹层基础设施
|
||||
|
||||
2026-10-22,起始 HEAD `b086d7f`。目标是固定 HeroUI 3.2.6 / `ce90ea3` 的 Modal、Popover、Tooltip 后续迁移基础,此为 OVERLAY-01 阶段设计记录。公共组件后续已接入,当前实现、差异及验证见 [OVERLAY-02](../migrations/OVERLAY-02-modal-popover-tooltip.md)。
|
||||
|
||||
## 分工与底座
|
||||
|
||||
- 本批由集成人维护:`composables/useOverlayState.ts`、`providers/*`、`components/overlay/*` 及相关测试。其他 AI 的 ScrollShadow / Tabs 不依赖它们,也不得修改这些协议。
|
||||
- 使用已安装的 **Reka 2.11.0**;核对本地发布包的 Dialog / FocusScope / DismissableLayer / Presence / Teleport / ConfigProvider 实现,不按同名组件猜测功能。
|
||||
- 焦点范围、aria-hidden 隔离、逐层 Escape / outside 关闭、滚动锁、指针锁和退出卸载由同一份 Reka 处理。不要再给 Modal、Popover、Select 各写一个 document 监听器或 body 锁计数器。
|
||||
- Dialog 使用 Reka Dialog;Popover 将使用 Reka Popover 的定位/碰撞与焦点策略;Tooltip 将使用 Reka Tooltip 的延迟、悬停与描述关联。只共享状态和配置,不把 Tooltip 等全部包装成 Dialog。
|
||||
- `components/overlay/*` **未加入公开包入口**。私有 primitives.ts 仅供垂直验证使用,不是 HeroUI 公共 Trigger / Close API;公开组件迁移仍须验收按钮禁用、取消、键盘和 asChild,而不能直接把 primitive 别名当成最终封装。
|
||||
|
||||
## 已公开的最小协议
|
||||
|
||||
### useOverlayState
|
||||
|
||||
参考 `packages/react/src/hooks/use-overlay-state.ts`,保留 `isOpen`、`setOpen`、`open`、`close`、`toggle`。Vue 的 `isOpen` 是只读 computed ref;JS 中读 `.value`,模板中直接使用顶层绑定的 ref。没有全局状态,两个实例互不影响。
|
||||
|
||||
```ts
|
||||
const opened = ref(false);
|
||||
const state = useOverlayState({
|
||||
isOpen: opened,
|
||||
defaultOpen: false,
|
||||
onOpenChange(next) {
|
||||
opened.value = next;
|
||||
},
|
||||
});
|
||||
state.open();
|
||||
```
|
||||
|
||||
`isOpen` 接受 boolean / ref / getter;需要父级更新时必须传 ref 或 getter,不能传 setup 时读取的快照。非 undefined 表示受控,父级拒绝时实际状态不改变;undefined 采用本地状态。defaultOpen 只初始化一次。退出受控模式恢复原本的本地状态,沿用固定 React hook 的语义,不悄悄把最后受控值当默认值。setOpen 请求即通知,即使与当前值相同;不更改父级值。
|
||||
|
||||
### ConfigProvider
|
||||
|
||||
无 DOM 包装,支持 `dir: 'ltr' | 'rtl'`(默认 ltr)、`locale: string`(默认 en-US)、`teleportTo?: string | HTMLElement`。向 Reka 透传同一配置;本库 dialog content 将 dir/lang 映射到真实节点,防止 Teleport 丢失文字方向与语言;content 显式 dir/lang 优先且可动态增删。
|
||||
|
||||
```vue
|
||||
<ConfigProvider dir="rtl" locale="ar" teleport-to="#overlay-root">
|
||||
<!-- 使用弹层的组件 -->
|
||||
</ConfigProvider>
|
||||
<div id="overlay-root" />
|
||||
```
|
||||
|
||||
每个 Provider 形成新的配置边界,省略属性使用上述默认值。locale/dir 不会重写现有原生输入的值、强制 RTL 或提供翻译字典。teleportTo 不复制主题类:自定义主题容器应将目标节点放在同一主题作用域。没有 Provider 时 Portal 默认 body,Dialog 内容沿用所在 DOM 的 dir/lang。
|
||||
|
||||
## 私有 Dialog 适配
|
||||
|
||||
| 部件 | 协议 |
|
||||
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| OverlayDialogRoot | open / defaultOpen、v-model:open、openChange;可选 state 优先于 open;modal 默认 true。永远以受控值驱动 Reka Root,避免其被动模型固定在首次模式。Root 不承接 DOM attrs,不提供强制保留隐藏内容。 |
|
||||
| OverlayPortal | to / disabled / defer;具体 to 优先于 Provider,默认 body。复用 Reka 挂载后 Teleport,不提供 forceMount。 |
|
||||
| OverlayBackdrop | 使用 Reka DialogOverlay,模态时负责滚动锁;可放在 Content 同级,保持独立 Presence。真实 attrs/class/style 透传,退出完成才释放。 |
|
||||
| OverlayDialogContent | isDismissable 默认 true;isKeyboardDismissDisabled 默认 false,二者互不代替。转发可取消的 escapeKeyDown / pointerDownOutside / focusOutside / interactOutside / openAutoFocus / closeAutoFocus。aria-modal 依据真实 modal 状态;Reka 负责 title/description 与焦点恢复。 |
|
||||
|
||||
modal=false 的 Dialog 不替代锚点 Popover。Backdrop 是锁的所有者,模态消费者必须配对使用 Backdrop + Content,不可省去 Backdrop 后宣称页面已锁定。私有部件缺少 Root 会明确报错,不静默建立独立状态。
|
||||
|
||||
退出生命周期采用 **CSS keyframes + Reka Presence**:公共组件保留上游 data-entering / data-exiting 阶段标记,底座同时提供 data-state=open / closed;保持源变量、关键帧数值与 reduced-motion。不是简单给 DOM 加标记:关闭的 data-state=closed 节点保留到动画结束,再卸载和恢复焦点/锁。不要在公共 Root 外提前 v-if,也不要添加固定时长 timeout。只支持 transition 的自定义退出动画目前不承诺;forceMount / 保留隐藏内容需要单独设计,不直接泄漏底层开关。
|
||||
|
||||
Modal 的最终 Backdrop / Container / Dialog 部件、变体、主题、布局、公共 Trigger/Close、默认标题/可选描述与动态 ID 所有权,须在下一批围绕固定基线继续实现。这批没有复制上游 Modal CSS 或添加粗略的公开 Modal 页。
|
||||
|
||||
## 验证场景与证据边界
|
||||
|
||||
- `tests/overlay-foundation.test.ts`:状态隔离/受控拒绝/动态模式;Provider 目标、ARIA 引用、卸载释放锁;动态 Escape 和取消;state 优先级;动态 attrs;缺 Root;嵌套关闭;实际 SSR 水合;dir/lang;自定义焦点事件。
|
||||
- `tests/ssr.test.ts`:node 环境下两种初始状态均不访问浏览器全局。SSR 只输出 Trigger 等原位内容,Portal 在客户端挂载后插入;初始打开不会在服务器 HTML 中输出 Dialog。这是已记录的首屏边界,不能声称已实现 Nuxt 服务端 Teleport 收集。
|
||||
- 独立工程页:`apps/playground/src/OverlayLab.vue`,`http://127.0.0.1:5175/?overlay-lab`。启动命令 `pnpm --filter @heroui-vue/playground dev --port 5175 --strictPort`;该端口是 playground 验证服务,正式文档仍固定 5173。
|
||||
- 本轮真实浏览器:进入首个输入、Tab 尾→首循环;嵌套 Escape 只关上层、焦点回到父触发器且 body overflow 仍 hidden;定位 Popover 在模态层内可输入,Escape 后返回自身触发器;最终关闭恢复外部触发器和 body overflow/pointer-events;outside 禁止/恢复、禁止 Escape、父级拒绝;快速关闭再打开只有一个 open 面板。控制台无 warn/error。
|
||||
- Playground 的 120ms 淡入/淡出只用于验证 Presence 与打断,不是 HeroUI 最终视觉。已验证动画结束后卸载;未执行逐像素、全部 reduced-motion/RTL 浏览器场景、触屏/读屏、跨 iframe、Nuxt 或打包后独立安装。
|
||||
|
||||
Modal、Popover、Tooltip 已在 OVERLAY-02 接入;其他 AI 可独立进行 ScrollShadow → Tabs。共享导出、types、package.json、导航和进度文档仍要指定单一编辑者,避免同时覆盖。
|
||||
@@ -228,3 +228,13 @@ M12 InputGroup 已经独立复核并由集成人修正共享 SSR ID 预规划,
|
||||
后续实施和复核先读 [近期迁移问题与执行清单](./migrations/M13-M20-lessons.md)。该清单把文档契约、Boolean 默认值、禁用作用域、动态 Primitive 结构、ARIA/ID、标签所有权、文档隔离与导航缺口对应到实际回归;原始复核报告保留为证据。
|
||||
|
||||
下一批安排为 [M21 Disclosure → M22 DisclosureGroup → M23 Accordion](./migrations/M21-M23-disclosure-accordion-prompt.md),含公共导航辅助函数与 16 个基线文档预览。只是一份待派发任务说明,不代表组件已实现。集成人继续维护共享协议和弹层基础设施;ScrollShadow→Tabs 后续单独派发。
|
||||
|
||||
## OVERLAY-01 之后的并行边界(2026-10-22)
|
||||
|
||||
M21–M23 已在 b086d7f 提交。集成人已实现 [弹层基建协议](./decisions/overlay-foundation.md),接下来继续 Modal,再做 Popover/Tooltip。其他 AI 可以接 ScrollShadow → Tabs,两项都不依赖公开 Modal;仍需单独派发,不把此记录视为已经开工。
|
||||
|
||||
overlay 私有实现、useOverlayState 与 ConfigProvider 由集成人维护;共享入口/types/package.json/导航/进度表由单一编辑者集成。其他 AI 不复制焦点栈、outside/Escape 监听或滚动锁,也不修改已冻结的字段与按钮事件协议。
|
||||
|
||||
## OVERLAY-02 集成完成后的边界
|
||||
|
||||
Modal / Popover / Tooltip 公共迁移与全部 26 个基线预览已接入,差异和验证见 [OVERLAY-02](./migrations/OVERLAY-02-modal-popover-tooltip.md)。共享入口、providers/composables、overlay 私有实现与三个家族归集成人;ScrollShadow → Tabs 仍可作为其他 AI 的独立批次,不代表已派发。新弹层/集合任务必须先复用现有协议,并交出焦点/名称/退出/嵌套的失败场景,不能另造全局栈。
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
# OVERLAY-02:Modal / Popover / Tooltip
|
||||
|
||||
固定 HeroUI 3.2.6 / ce90ea3,从 b086d7f 后的 OVERLAY-01 基础设施继续实施。三个家族的公共组件、类型、源 CSS/tv、中文页面与全部基线预览已接入,状态为验证中,不宣称完整兼容或逐像素一致。
|
||||
|
||||
## 交付
|
||||
|
||||
- Modal:Root、Trigger、Backdrop、Container、Dialog、Heading、Header、Body、Footer、Icon、CloseTrigger,以及 Vue 专用 Close。6 个尺寸、4 种位置、3 种遮罩、内外滚动、受控/非受控/state、Portal、关闭策略、表单与自定义动画;14/14 基线例。
|
||||
- Popover:Root、Trigger、Content、Dialog、Heading、Arrow。受控/非受控、模态/非模态、逻辑位置、碰撞、零偏移、自定义箭头、标题和退出;6/6 基线例。
|
||||
- Tooltip:Root、Trigger、Content、Arrow。hover/focus、禁用、CSS/props 延迟、关闭计时清理、定位、箭头与动画;6/6 基线例。
|
||||
- 文档保留中文基线介绍、次序、布局、样式与 API,补 Vue 组合说明及作用域插槽。26 份 SFC 共用预览/复制/高亮,全部自动编译挂载;另有三份结构示例参加编译挂载。Tabler 图标沿用项目约定。
|
||||
- 补齐固定上游使用的 tw-animate-css 1.4.0、MIT 许可和独立入口;保持源动画数值。Playground 开发读取样式源码,生产仍消费 dist,避免修复只在旧产物中生效。
|
||||
|
||||
## 设计与适配
|
||||
|
||||
复用 Reka Dialog/Popover/Tooltip、FocusScope、DismissableLayer、Presence 与 Portal。没有第二份焦点/锁/关闭栈。定位使用真实 data-side/data-align 与 Reka transform-origin,箭头由底座旋转;源 CSS 值仅做命名空间和真实状态适配。
|
||||
|
||||
Root 用 v-model:open / open / isOpen / defaultOpen;Modal 另支持 useOverlayState 的 state,state 优先。首个直接 Button/button/a 自动组合,自定义根用显式 Trigger 的 as/asChild,唯一有效根;Enter/Space 不重复原生键盘行为,保留事件数组、capture 和调用者取消。React render/className/close slot 改为 Vue as/attrs/class/插槽与 ModalClose,不承诺 React PressEvent。
|
||||
|
||||
PopoverContent 是实际 role=dialog,PopoverDialog 为内部视觉层,避免重复语义;Heading 动态注册真实标题 ID。显式 Dialog ARIA 透传到真正的角色节点。纯文本 Popover 在 Reka 未找到子焦点时聚焦内容表面,调用者取消进入焦点仍有效。
|
||||
|
||||
退出由 Presence 观察动画。Modal Container 有动画而 Dialog 无动画,适配为继承真实 Container 时长的视觉中性保留关键帧,避免内容提前消失;不使用固定 JS 卸载计时。reduced-motion、定位测量期间动画暂禁用以及过期 animationend 分开处理。自定义遮罩/容器退出时长需协调。
|
||||
|
||||
## 明确差异与边界
|
||||
|
||||
- Popover 默认模态模式的 closeAutoFocus 继承 Reka 2.11 无条件恢复 Trigger 的流程,事件用于通知,preventDefault 不能取消恢复;需要取消恢复时使用 isNonModal,其外部交互/焦点策略也相应改变。其他适用进入焦点、外部交互与 Escape 事件保留取消能力。
|
||||
- Tooltip warmup 在 ConfigProvider 范围共享,未提供 Provider 时每 Root 各自维护;不是 RAC 全局调度。shouldSkipAnimation 对应 Reka instant-open 阶段。Reka tooltip.open 事件仅用于既有 Root 接替和中断退出协调,升级需契约回归。
|
||||
- Tooltip 的描述为 Reka 隐藏文本,真实提示不接收焦点;交互内容改用 Popover。showArrow 选择默认偏移,Arrow 仍显式组合,与基线一致。
|
||||
- Portal 默认 body、Provider 可统一 to,部件可覆盖;主题类需包住目标。dir/locale 显式传入浮层,CSS 变量沿真实 DOM 继承。SSR 内容挂载后插入;不承诺 Nuxt 服务端 Teleport 收集。
|
||||
- Modal 表单例保留布局,提交实际 FormData 并显示状态,未模拟网络成功。旧 InputGroup 的 title 临时适配未顺带改写,本批公开 Tooltip 不意味着所有历史替代已回填。
|
||||
|
||||
## 验证
|
||||
|
||||
- pnpm test:23 文件 / 377 项通过,含独立 node SSR 10 项及 jsdom 实际水合。pnpm test:unit:22 文件 / 367 项通过,不含 node SSR。
|
||||
- typecheck、build:docs、build:playground、format、git diff --check 通过;文档仅既有 chunk 大小提醒。源码与构建后 dist 类型都有合法/非法值探针;dist 探针移除,不算独立安装。
|
||||
- 定向测试覆盖受控拒绝、动态标题/ARIA、Trigger 一次激活/取消/禁用、表单真实值、焦点/外部关闭、Tooltip CSS 延迟/受控重开/新 Tooltip 接替、卸载清理与 SSR 水合。
|
||||
- 真实浏览器只抽查高风险场景:5173 文档的 Modal 默认与 390×844 底部布局,内部 body 滚动/外部 backdrop 滚动,退出容器和 Dialog 同时保留、最后释放 body overflow/pointer-events;Popover 实际定位/纯文本焦点/交互内容标题;Tooltip 键盘焦点与真实 aria-describedby。
|
||||
- 5175 工程页公共 Modal → Popover → 嵌套 Modal,Escape 逐层关闭、焦点回到对应触发器、父层保留锁;内部 Tooltip Escape 不误关父层。真实悬停延迟没有用浏览器逐项手测,计时路径由自动测试覆盖。
|
||||
- 最终 Modal 截图 /tmp/heroui-vue-overlays-final.png:1280×800、浅色、进入动画完成;最后文档检查 console warn/error 为 0。未建立自动逐像素、全量读屏/触屏、所有 RTL/reduced-motion、跨 iframe、Nuxt 或打包后独立安装验收。
|
||||
|
||||
## 后续任务
|
||||
|
||||
ScrollShadow → Tabs 可按原有独立边界交给其他 AI;本报告不代表已派发。新的菜单/集合/弹层组件由集成人先核对复用现有协议,不复制全局栈。三个旧根目录截图保持原样,不在本批处理。
|
||||
|
||||
## 动画专项返工
|
||||
|
||||
用户反馈动画生硬后,以固定源码 CSS/主题曲线对照真实浏览器 animationstart/end 与中间帧;本轮没有另外运行完整 React 文档站,因此不是两套运行时的并排录像或逐像素验收。
|
||||
|
||||
发现并修复 Popover/Tooltip 进入动画被跳过:Reka 测量时暂设 animation:none,浏览器将离屏 transform 序列化为 translate(0px, -200%),原先只识别无 px 的字符串,提前清除了 entering。兼容两种 CSSOM 写法后,定位完成再播放源进入动画。
|
||||
|
||||
| 对照项 | 固定上游 | 修复后浏览器记录 |
|
||||
| -------------- | ----------------------------------------- | -------------------------------------------------------- |
|
||||
| Modal 遮罩进入 | 150ms ease-out,淡入 | 150ms,cubic-bezier(0,0,0.2,1),完整 start/end |
|
||||
| Modal 内容进入 | 250ms ease-out-quad,1.05 → 1 | 250ms,cubic-bezier(0.25,0.46,0.45,0.94),完整 start/end |
|
||||
| Popover 进入 | 150ms ease,0.9 → 1,朝触发点方向位移 4px | 150ms,0.9 → 1;定位完成后开始 |
|
||||
| Tooltip 进入 | 150ms ease,0.9 → 1,朝触发点方向位移 4px | 150ms,0.9 → 1;定位完成后开始 |
|
||||
| 浮层退出 | 100ms ease,1 → 0.95,淡出 | 100ms,完整 start/end |
|
||||
|
||||
`?overlay-animation` 是公开组件的事件/帧记录页,`?overlay-lab` 保留早期 120ms 私有探针并明确标注,二者不混作视觉基线。补充 3 项测量/无动画回归。此前 377 项为迁移阶段记录,本次完整回归为 380 项(含 node SSR 10)。
|
||||
@@ -101,3 +101,19 @@ M18–M20 的标签桥接在 Vue 使用 indicator 注册表与 SSR 直接/原生
|
||||
- 默认 Chevron 来自基线 `icons.tsx` IconChevronDown;文档图标为 Tabler;Expo 品牌图标无 Tabler 对应,演示用 IconDeviceMobile。
|
||||
- CN `(navigation)/{disclosure,disclosure-group,accordion}.mdx` 与 demos/cn 对应目录:共 16 个文档预览。
|
||||
- 组展开键由 React Set 改为 Vue `Array<string | number>`,保持 key 身份;`useDisclosureGroupNavigation` 为公开 composable。
|
||||
|
||||
## OVERLAY-01 来源(2026-10-22)
|
||||
|
||||
- `useOverlayState` 的方法和受控/非受控边界参考固定 ce90ea3 的 `packages/react/src/hooks/use-overlay-state.ts`,改为 Vue readonly computed / ref / getter,保留 Apache-2.0 来源说明。
|
||||
- Dialog 焦点、关闭栈、滚动与指针锁、Presence、Teleport、ConfigProvider 直接运行安装的 Reka UI 2.11.0(MIT),未复制其实现,也未修改 node_modules。
|
||||
- OverlayLab 是工程回归页,CSS 由本项目编写,未声称是 HeroUI Modal 或 Popover 的视觉移植。Modal / Popover / Tooltip 的源组件与样式只作下一阶段契约参考,尚未新增公开组件。
|
||||
|
||||
## OVERLAY-02 来源
|
||||
|
||||
固定 ce90ea3 / HeroUI 3.2.6:
|
||||
|
||||
- packages/react/src/components/{modal,popover,tooltip}:部件、默认值、状态/关闭/定位契约;React render/close slot 按 Vue 具名部件与作用域插槽适配。
|
||||
- packages/styles/components/{modal,popover,tooltip}.css 与对应 tv:完整源样式数值移植到 hv- 命名空间,Reka 状态/定位变量适配;保留 Apache-2.0 来源头。箭头路径来自基线 Arrow,演示图标采用 Tabler 官方 Vue 包。
|
||||
- 中文文档与 demos/cn/{modal,popover,tooltip}:14/6/6 个基线预览、介绍/结构/样式/API;模板代码与预览共用 SFC。表单例增加真实 FormData 反馈,框架差异另行说明。
|
||||
- tw-animate-css 1.4.0(与固定上游一致)提供源样式依赖的动画 utilities,未引入另一套动画运行时;MIT 许可证保存为 third-party/TW-ANIMATE-CSS-LICENSE 和 packages/styles/LICENSE.tw-animate-css。库与文档编译入口均导入,保持独立构建。
|
||||
- Reka UI 2.11.0 负责 Dialog/Popover/Tooltip/Portal/Presence/FocusScope 的真实运行时。Tooltip 仅适配其现有 tooltip.open 协调事件,不复制全局焦点或关闭栈。具体差异见 OVERLAY-02 报告。
|
||||
|
||||
@@ -437,3 +437,33 @@ typecheck / build:docs / format / git diff --check 通过。新增 `tests/disclo
|
||||
## M21–M23 最终独立复核(2026-10-22)
|
||||
|
||||
此前三轮缺陷已关闭,详见 [最终复核](./migrations/M21-M23-review.md)。正式 test 为 19 文件 / 345 项通过(含 node SSR 8);typecheck、build:docs、format、diff-check 通过,文档构建仅既有 chunk 大小提醒。独立 4 项补充探针覆盖两个家族与原生/库内按钮的 stopPropagation、双方点击/捕获次数,全部通过后移除,未计入正式数字。修正兼容矩阵的管道分隔符与测试冗余类型断言。本次没有重复逐页浏览器点击,也没有新增逐像素、读屏、Nuxt 或独立安装验收。
|
||||
|
||||
## OVERLAY-01 弹层基础设施(2026-10-22)
|
||||
|
||||
起始 `b086d7f`,由集成人实现。公开 useOverlayState / ConfigProvider;私有 Dialog Root / Portal / Backdrop / Content 复用 Reka 2.11.0;未宣布 Modal / Popover / Tooltip 已迁移。协议、来源和后续边界见 [OVERLAY-01](./decisions/overlay-foundation.md)。
|
||||
|
||||
| 检查 | 文件数 | 通过数 | 范围 |
|
||||
| --------------------------------------- | ------ | ------ | ---------------------------------- |
|
||||
| pnpm test | 20 | 359 | 含 node SSR 9,含实际水合 |
|
||||
| pnpm test:unit | 19 | 350 | 不含 node SSR,含实际水合 |
|
||||
| 最后补充无 Trigger 自动 ID 后的定向回归 | 2 | 22 | overlay-foundation 13 + node SSR 9 |
|
||||
|
||||
- typecheck、build:docs、build:playground 通过;文档构建仅既有 chunk 大小提醒。源码类型正反契约保留在 tests/types/overlay-contract.ts;dist 声明正反消费临时探针通过后移除,不算独立安装验证。
|
||||
- 浏览器工程页 `http://127.0.0.1:5175/?overlay-lab`:进入首个输入、末项 Tab 回首项、嵌套 Escape 与焦点恢复、父层保留 overflow:hidden、模态内锚点 Popover 输入/定位、外部关闭策略、禁止 Escape、父级拒绝、快速关闭再打开、最终 body overflow/pointer-events 释放。验证期间 console warn/error 为 0。
|
||||
- SSR Portal 明确挂载后插入:服务器没有 Dialog 内容,客户端实际水合后 Trigger/标题/描述 ID 可解析且无警告;不声称已完成 Nuxt 服务端 Teleport 收集。
|
||||
- Playground 是工程验证用 120ms keyframes,不是 HeroUI Modal 的公开文档/最终视觉;正式文档仍使用 5173。未新增逐像素、完整读屏/触屏、全部 RTL/reduced-motion 浏览器场景、跨 iframe 或打包后独立安装验收。此前三个根目录临时截图保持原样,本批不处理。
|
||||
|
||||
## OVERLAY-02 Modal / Popover / Tooltip
|
||||
|
||||
详细交付、差异和浏览器证据见 [OVERLAY-02](./migrations/OVERLAY-02-modal-popover-tooltip.md)。26/26 基线演示与三份结构示例编译挂载;公开组件 SSR/水合、动态标题、受控/禁用/取消、表单和 Tooltip 计时回归通过。
|
||||
|
||||
| 检查 | 文件数 | 通过数 | 范围 |
|
||||
| -------------- | ------ | ------ | -------------------------------- |
|
||||
| pnpm test | 23 | 377 | 含 node SSR 10 与 jsdom 实际水合 |
|
||||
| pnpm test:unit | 22 | 367 | 不含 node SSR |
|
||||
|
||||
typecheck、build:docs、build:playground、format、diff-check 通过;文档仅既有 chunk 大小提醒。dist 正反类型临时探针通过后删除,不算独立打包安装。浏览器抽查 Modal 内外滚动/移动布局/退出锁释放、Popover 焦点/定位、Tooltip 描述与多层 Escape;未逐个点全部示例。最终截图 1280×800 浅色,文档 console warn/error 为 0。未建立逐像素、完整读屏/触屏/RTL、Nuxt 或独立安装验证,Popover 模态 closeAutoFocus 取消及 Tooltip warmup 差异按报告保留。
|
||||
|
||||
## OVERLAY-02 动画专项复核
|
||||
|
||||
修复测量 transform 的 CSSOM px 规范化导致 Popover/Tooltip 跳过进入动画。真实浏览器事件及帧采样确认 Modal 遮罩/内容 150/250ms、Popover/Tooltip 进入 150ms、浮层退出 100ms,曲线与源 CSS 一致;详细对照见 OVERLAY-02 报告。新增 3 项测试,pnpm test 23 文件 / 380 项(含 node SSR 10);typecheck、build:docs、build:playground、format 与 diff-check 通过。未运行完整 React 站并排录像,未据此声明逐像素一致。
|
||||
|
||||
+1
-1
@@ -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",
|
||||
"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",
|
||||
"test:ssr": "vitest run tests/ssr.test.ts",
|
||||
"format": "prettier --check .",
|
||||
"format:fix": "prettier --write .",
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Wombosvideo
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Same animation utilities as the fixed HeroUI baseline (tw-animate-css, MIT). */
|
||||
@import "tw-animate-css";
|
||||
@@ -0,0 +1,374 @@
|
||||
/* Adapted from HeroUI ce90ea3. Copyright 2025 NextUI Inc.
|
||||
* Apache-2.0; see third-party/HEROUI-LICENSE. hv- namespace and Vue/Reka adapters. */
|
||||
/* -------------------------------------------------------------------------------------------------
|
||||
* Modal Component Styles
|
||||
* Block: modal
|
||||
* -----------------------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Element: trigger - the element that opens the modal
|
||||
*/
|
||||
.hv-modal__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 dialog
|
||||
*/
|
||||
.hv-modal__backdrop {
|
||||
@apply fixed inset-0 z-(--z-index-overlay);
|
||||
@apply flex flex-row items-center justify-center;
|
||||
@apply h-(--visual-viewport-height) w-full;
|
||||
|
||||
/* Entering animation */
|
||||
&[data-entering="true"] {
|
||||
@apply animate-in duration-150 ease-out fade-in-0;
|
||||
}
|
||||
|
||||
/* Exiting animation */
|
||||
&[data-exiting="true"] {
|
||||
@apply animate-out duration-100 ease-out fade-out-0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce Animation
|
||||
* CRITICAL: motion-reduce must be AFTER animate for correct override specificity
|
||||
*/
|
||||
&[data-exiting="true"],
|
||||
&[data-entering="true"] {
|
||||
@apply will-change-[opacity];
|
||||
@apply motion-reduce:animate-none;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier: backdrop--transparent
|
||||
*/
|
||||
.hv-modal__backdrop--transparent {
|
||||
@apply bg-transparent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier: backdrop--opaque
|
||||
*/
|
||||
.hv-modal__backdrop--opaque {
|
||||
@apply bg-backdrop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier: backdrop--blur
|
||||
*/
|
||||
.hv-modal__backdrop--blur {
|
||||
@apply bg-backdrop backdrop-blur-md;
|
||||
}
|
||||
|
||||
/**
|
||||
* Element: container - the positioning wrapper for the modal
|
||||
*/
|
||||
.hv-modal__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;
|
||||
|
||||
/* Entering animation */
|
||||
&[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;
|
||||
}
|
||||
}
|
||||
|
||||
/* Exiting animation */
|
||||
&[data-exiting="true"] {
|
||||
@apply animate-out duration-100 ease-out-quad fade-out-0 zoom-out-95;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce Animation
|
||||
* CRITICAL: motion-reduce must be AFTER animate for correct override specificity
|
||||
*/
|
||||
&[data-exiting="true"],
|
||||
&[data-entering="true"] {
|
||||
@apply will-change-[opacity,transform];
|
||||
@apply motion-reduce:animate-none;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier: container--scroll-outside
|
||||
*
|
||||
* The container is React Aria's modal ref, so it must stay `pointer-events: none`,
|
||||
* otherwise clicks around the dialog count as inside the modal and never dismiss it.
|
||||
* The backdrop owns the scrolling instead.
|
||||
*/
|
||||
.hv-modal__container--scroll-outside {
|
||||
@apply h-auto min-h-(--visual-viewport-height) overflow-y-visible;
|
||||
}
|
||||
|
||||
.hv-modal__backdrop:has(.hv-modal__container--scroll-outside) {
|
||||
@apply scrollbar items-start overflow-y-auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier: container--full
|
||||
*/
|
||||
.hv-modal__container--full {
|
||||
@apply p-0 sm:p-0;
|
||||
|
||||
/* Entering animation */
|
||||
&[data-entering="true"] {
|
||||
@apply slide-in-from-bottom-0 zoom-in-100;
|
||||
@apply sm:slide-in-from-bottom-0;
|
||||
}
|
||||
|
||||
/* Exiting animation */
|
||||
&[data-exiting="true"] {
|
||||
@apply zoom-out-100;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Element: dialog - the content container for the modal
|
||||
*/
|
||||
.hv-modal__dialog {
|
||||
@apply relative;
|
||||
@apply flex w-full flex-col;
|
||||
@apply bg-overlay shadow-overlay outline-none;
|
||||
border-radius: min(32px, var(--radius-3xl));
|
||||
@apply p-6;
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier: dialog--scroll-inside
|
||||
*/
|
||||
.hv-modal__dialog--scroll-inside {
|
||||
@apply max-h-full min-h-0 overflow-clip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier: dialog--scroll-outside
|
||||
*/
|
||||
.hv-modal__dialog--scroll-outside {
|
||||
@apply h-auto;
|
||||
@apply min-h-0 shrink-0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier: dialog--xs
|
||||
*/
|
||||
.hv-modal__dialog--xs {
|
||||
@apply max-w-xs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier: dialog--sm
|
||||
*/
|
||||
.hv-modal__dialog--sm {
|
||||
@apply max-w-sm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier: dialog--md
|
||||
*/
|
||||
.hv-modal__dialog--md {
|
||||
@apply max-w-md;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier: dialog--lg
|
||||
*/
|
||||
.hv-modal__dialog--lg {
|
||||
@apply max-w-lg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier: dialog--cover
|
||||
*/
|
||||
.hv-modal__dialog--cover {
|
||||
@apply h-full min-h-full w-full;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier: dialog--full
|
||||
*/
|
||||
.hv-modal__dialog--full {
|
||||
@apply h-full min-h-full w-full;
|
||||
@apply rounded-none shadow-none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Element: header - the top section with the title
|
||||
*/
|
||||
.hv-modal__header {
|
||||
@apply flex flex-col gap-3;
|
||||
@apply mb-0;
|
||||
|
||||
/* When header contains icon, use flex-col layout with gap */
|
||||
& > .hv-modal__icon {
|
||||
@apply mb-0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Element: heading - the main title text
|
||||
*/
|
||||
.hv-modal__heading {
|
||||
@apply align-middle;
|
||||
@apply text-base font-medium text-foreground;
|
||||
}
|
||||
|
||||
/**
|
||||
* Element: icon - the optional icon indicator
|
||||
*/
|
||||
.hv-modal__icon {
|
||||
@apply flex items-center justify-center;
|
||||
@apply size-10 shrink-0;
|
||||
@apply rounded-3xl select-none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Element: body - the main content area
|
||||
*/
|
||||
.hv-modal__body {
|
||||
@apply min-h-0 flex-1;
|
||||
@apply text-sm leading-[1.43] text-muted;
|
||||
@apply -m-[3px] my-0 overflow-visible p-[3px];
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier: body--scroll-inside
|
||||
*/
|
||||
.hv-modal__body--scroll-inside {
|
||||
@apply scrollbar overflow-y-auto overscroll-contain;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier: body--scroll-outside
|
||||
*/
|
||||
.hv-modal__body--scroll-outside {
|
||||
@apply overflow-y-visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Element: footer - the bottom action section
|
||||
*/
|
||||
.hv-modal__footer {
|
||||
@apply flex flex-row items-center justify-end gap-2;
|
||||
@apply mt-0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Element: close-trigger - the optional x icon button to close the modal
|
||||
*/
|
||||
.hv-modal__close-trigger {
|
||||
@apply absolute end-4 top-4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Elements Spacing
|
||||
*/
|
||||
.hv-modal__header + .hv-modal__body {
|
||||
@apply mt-2;
|
||||
}
|
||||
|
||||
.hv-modal__header + .hv-modal__footer {
|
||||
@apply mt-5;
|
||||
}
|
||||
|
||||
.hv-modal__body + .hv-modal__footer {
|
||||
@apply mt-5;
|
||||
}
|
||||
|
||||
/* Button remains a flex row when used as a Vue trigger. */
|
||||
.hv-modal__trigger.hv-button {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
/* Reka owns an inline pointer-events rule; exiting surfaces must stay inactive. */
|
||||
.hv-modal__dialog[data-exiting="true"] {
|
||||
pointer-events: none !important;
|
||||
}
|
||||
|
||||
/* RAC keeps Dialog alive with its animated Container. Reka observes the Content
|
||||
* node itself, so use a visually neutral keyframe inheriting the Container's
|
||||
* actual duration/delay (including caller utilities) before unmounting. */
|
||||
@keyframes hv-modal-retain {
|
||||
from {
|
||||
visibility: visible;
|
||||
}
|
||||
to {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
.hv-modal__dialog[data-exiting="true"] {
|
||||
animation-name: hv-modal-retain;
|
||||
animation-duration: inherit;
|
||||
animation-delay: inherit;
|
||||
animation-timing-function: linear;
|
||||
animation-fill-mode: both;
|
||||
@apply motion-reduce:animate-none;
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/* Adapted from HeroUI ce90ea3. Copyright 2025 NextUI Inc.
|
||||
* Apache-2.0; see third-party/HEROUI-LICENSE. hv- namespace and Vue/Reka adapters. */
|
||||
/* Popover component styles */
|
||||
|
||||
/* Base popover styles */
|
||||
.hv-popover {
|
||||
@apply origin-(--reka-popper-transform-origin) bg-overlay p-0 text-sm;
|
||||
border-radius: min(32px, var(--radius-3xl));
|
||||
box-shadow: var(--overlay-shadow);
|
||||
|
||||
/* Entering animations */
|
||||
&[data-entering="true"] {
|
||||
@apply animate-in duration-150 ease-smooth fade-in-0 zoom-in-90;
|
||||
|
||||
/* Placement-specific translations */
|
||||
&[data-side="top"] {
|
||||
@apply slide-in-from-bottom-1;
|
||||
}
|
||||
|
||||
&[data-side="bottom"] {
|
||||
@apply slide-in-from-top-1;
|
||||
}
|
||||
|
||||
&[data-side="left"] {
|
||||
@apply slide-in-from-right-1;
|
||||
}
|
||||
|
||||
&[data-side="right"] {
|
||||
@apply slide-in-from-left-1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Exiting animations */
|
||||
&[data-exiting="true"] {
|
||||
@apply animate-out duration-100 ease-smooth zoom-out-95 fade-out;
|
||||
/* Stays non-interactive while closing, even if the exit animation is interrupted. */
|
||||
@apply pointer-events-none;
|
||||
}
|
||||
|
||||
&[data-exiting="true"],
|
||||
&[data-entering="true"] {
|
||||
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
||||
}
|
||||
|
||||
/* Arrow styling */
|
||||
& [data-slot="popover-overlay-arrow"] {
|
||||
fill: var(--overlay);
|
||||
}
|
||||
}
|
||||
|
||||
/* Popover dialog */
|
||||
.hv-popover__dialog {
|
||||
@apply p-4 outline-none;
|
||||
}
|
||||
|
||||
/* Popover heading */
|
||||
.hv-popover__heading {
|
||||
@apply font-medium;
|
||||
}
|
||||
|
||||
/* Popover trigger */
|
||||
.hv-popover__trigger {
|
||||
@apply inline-block;
|
||||
|
||||
/**
|
||||
* Transitions
|
||||
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
|
||||
*/
|
||||
transition:
|
||||
color 150ms var(--ease-smooth),
|
||||
background-color 150ms var(--ease-smooth),
|
||||
box-shadow 150ms var(--ease-out);
|
||||
@apply motion-reduce:transition-none;
|
||||
|
||||
cursor: var(--cursor-interactive);
|
||||
|
||||
/* Focus state */
|
||||
&:focus-visible:not([data-focused]),
|
||||
&[data-focus-visible="true"] {
|
||||
@apply status-focused;
|
||||
}
|
||||
|
||||
/* Disabled state */
|
||||
&:disabled,
|
||||
&[aria-disabled="true"] {
|
||||
@apply status-disabled;
|
||||
}
|
||||
}
|
||||
|
||||
/* Reka owns an inline pointer-events rule; exiting surfaces must stay inactive. */
|
||||
.hv-popover[data-exiting="true"] {
|
||||
pointer-events: none !important;
|
||||
}
|
||||
|
||||
/* React Aria supplies this stacking level inline; Reka reads it from Content. */
|
||||
.hv-popover {
|
||||
z-index: var(--z-index-overlay);
|
||||
}
|
||||
|
||||
.hv-popover__trigger.hv-button {
|
||||
display: inline-flex;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/* Adapted from HeroUI ce90ea3. Copyright 2025 NextUI Inc.
|
||||
* Apache-2.0; see third-party/HEROUI-LICENSE. hv- namespace and Vue/Reka adapters. */
|
||||
/* Tooltip component styles */
|
||||
|
||||
/* Base tooltip styles */
|
||||
.hv-tooltip {
|
||||
@apply max-w-xs origin-(--reka-popper-transform-origin) bg-overlay p-2 text-xs break-all;
|
||||
border-radius: min(32px, var(--radius-xl));
|
||||
box-shadow: var(--overlay-shadow);
|
||||
|
||||
/* Entering animations */
|
||||
&[data-entering="true"] {
|
||||
@apply animate-in duration-150 ease-smooth fade-in-0 zoom-in-90;
|
||||
|
||||
/* Placement-specific translations */
|
||||
&[data-side="top"] {
|
||||
@apply slide-in-from-bottom-1;
|
||||
}
|
||||
|
||||
&[data-side="bottom"] {
|
||||
@apply slide-in-from-top-1;
|
||||
}
|
||||
|
||||
&[data-side="left"] {
|
||||
@apply slide-in-from-right-1;
|
||||
}
|
||||
|
||||
&[data-side="right"] {
|
||||
@apply slide-in-from-left-1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Exiting animations */
|
||||
&[data-exiting="true"] {
|
||||
@apply animate-out duration-100 ease-smooth zoom-out-95 fade-out;
|
||||
/* Stays non-interactive while closing, even if the exit animation is interrupted. */
|
||||
@apply pointer-events-none;
|
||||
}
|
||||
|
||||
&[data-exiting="true"],
|
||||
&[data-entering="true"] {
|
||||
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
||||
}
|
||||
|
||||
/* Arrow styling */
|
||||
& [data-slot="overlay-arrow"] {
|
||||
@apply stroke-border/40;
|
||||
fill: var(--overlay);
|
||||
}
|
||||
}
|
||||
|
||||
/* Tooltip trigger */
|
||||
.hv-tooltip__trigger {
|
||||
@apply inline-block;
|
||||
|
||||
/**
|
||||
* Transitions
|
||||
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
|
||||
*/
|
||||
transition:
|
||||
color 150ms var(--ease-smooth),
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/* Reka owns an inline pointer-events rule; exiting surfaces must stay inactive. */
|
||||
.hv-tooltip[data-exiting="true"] {
|
||||
pointer-events: none !important;
|
||||
}
|
||||
|
||||
/* React Aria supplies this stacking level inline; Reka reads it from Content. */
|
||||
.hv-tooltip {
|
||||
z-index: var(--z-index-overlay);
|
||||
}
|
||||
|
||||
.hv-tooltip__trigger.hv-button {
|
||||
display: inline-flex;
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
@import "./themes/shared/theme.css";
|
||||
@import "./themes/default/variables.css";
|
||||
@import "./utilities/index.css";
|
||||
@import "./animations.css";
|
||||
@import "./variants/index.css";
|
||||
@import "./components/button.css" layer(components);
|
||||
@import "./components/close-button.css" layer(components);
|
||||
@@ -120,3 +121,9 @@
|
||||
@import "./components/disclosure-group.css" layer(components);
|
||||
|
||||
@import "./components/accordion.css" layer(components);
|
||||
|
||||
@import "./components/modal.css" layer(components);
|
||||
|
||||
@import "./components/popover.css" layer(components);
|
||||
|
||||
@import "./components/tooltip.css" layer(components);
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist",
|
||||
"LICENSE"
|
||||
"LICENSE",
|
||||
"LICENSE.tw-animate-css"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
@@ -21,7 +22,8 @@
|
||||
"build": "vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"tailwind-variants": "^3.1.0"
|
||||
"tailwind-variants": "^3.1.0",
|
||||
"tw-animate-css": "1.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.1.0",
|
||||
|
||||
@@ -891,3 +891,90 @@ export const accordionVariants = tv({
|
||||
});
|
||||
|
||||
export type AccordionVariants = VariantProps<typeof accordionVariants>;
|
||||
|
||||
export const modalVariants = tv({
|
||||
defaultVariants: {
|
||||
scroll: "inside",
|
||||
size: "md",
|
||||
variant: "opaque",
|
||||
},
|
||||
slots: {
|
||||
backdrop: "hv-modal__backdrop",
|
||||
body: "hv-modal__body",
|
||||
closeTrigger: "hv-modal__close-trigger",
|
||||
container: "hv-modal__container",
|
||||
dialog: "hv-modal__dialog",
|
||||
footer: "hv-modal__footer",
|
||||
header: "hv-modal__header",
|
||||
heading: "hv-modal__heading",
|
||||
icon: "hv-modal__icon",
|
||||
trigger: "hv-modal__trigger",
|
||||
},
|
||||
variants: {
|
||||
scroll: {
|
||||
inside: {
|
||||
body: "hv-modal__body--scroll-inside",
|
||||
dialog: "hv-modal__dialog--scroll-inside",
|
||||
},
|
||||
outside: {
|
||||
body: "hv-modal__body--scroll-outside",
|
||||
container: "hv-modal__container--scroll-outside",
|
||||
dialog: "hv-modal__dialog--scroll-outside",
|
||||
},
|
||||
},
|
||||
size: {
|
||||
cover: {
|
||||
dialog: "hv-modal__dialog--cover",
|
||||
},
|
||||
full: {
|
||||
container: "hv-modal__container--full",
|
||||
dialog: "hv-modal__dialog--full",
|
||||
},
|
||||
lg: {
|
||||
dialog: "hv-modal__dialog--lg",
|
||||
},
|
||||
md: {
|
||||
dialog: "hv-modal__dialog--md",
|
||||
},
|
||||
sm: {
|
||||
dialog: "hv-modal__dialog--sm",
|
||||
},
|
||||
xs: {
|
||||
dialog: "hv-modal__dialog--xs",
|
||||
},
|
||||
},
|
||||
variant: {
|
||||
blur: {
|
||||
backdrop: "hv-modal__backdrop--blur",
|
||||
},
|
||||
opaque: {
|
||||
backdrop: "hv-modal__backdrop--opaque",
|
||||
},
|
||||
transparent: {
|
||||
backdrop: "hv-modal__backdrop--transparent",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export type ModalVariants = VariantProps<typeof modalVariants>;
|
||||
|
||||
export const popoverVariants = tv({
|
||||
slots: {
|
||||
base: "hv-popover",
|
||||
dialog: "hv-popover__dialog",
|
||||
heading: "hv-popover__heading",
|
||||
trigger: "hv-popover__trigger",
|
||||
},
|
||||
});
|
||||
|
||||
export type PopoverVariants = VariantProps<typeof popoverVariants>;
|
||||
|
||||
export const tooltipVariants = tv({
|
||||
slots: {
|
||||
base: "hv-tooltip",
|
||||
trigger: "hv-tooltip__trigger",
|
||||
},
|
||||
});
|
||||
|
||||
export type TooltipVariants = VariantProps<typeof tooltipVariants>;
|
||||
|
||||
@@ -49,6 +49,10 @@
|
||||
--skeleton-animation: shimmer; /* shimmer, pulse, none */
|
||||
|
||||
/* Tooltip Default Delays */
|
||||
/* Shared portal stacking baseline (HeroUI base/base.css). */
|
||||
--z-index-overlay: 100000;
|
||||
--z-index-toast: calc(var(--z-index-overlay) + 1);
|
||||
|
||||
--tooltip-delay: 1500ms;
|
||||
--tooltip-close-delay: 500ms;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
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 { createModalContext, modalKey } from "./context";
|
||||
import ModalTrigger from "./ModalTrigger.vue";
|
||||
export default defineComponent({
|
||||
name: "Modal",
|
||||
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(modalKey, createModalContext(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 === "ModalTrigger") found = true;
|
||||
if (
|
||||
!found &&
|
||||
(name === "Button" ||
|
||||
node.type === "button" ||
|
||||
node.type === "a")
|
||||
) {
|
||||
found = true;
|
||||
return h(
|
||||
ModalTrigger,
|
||||
{ asChild: true, key: node.key ?? undefined },
|
||||
{ default: () => node },
|
||||
);
|
||||
}
|
||||
return node;
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,55 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent, h, inject, type PropType } from "vue";
|
||||
import type { ModalVariants } from "@heroui-vue/styles";
|
||||
import Modal from "./Modal";
|
||||
import ModalBackdropSurface from "./ModalBackdropSurface.vue";
|
||||
import { modalKey } from "./context";
|
||||
export default defineComponent({
|
||||
name: "ModalBackdrop",
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
open: { type: Boolean, default: undefined },
|
||||
isOpen: { type: Boolean, default: undefined },
|
||||
defaultOpen: Boolean,
|
||||
variant: String as PropType<ModalVariants["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(modalKey, undefined);
|
||||
return () => {
|
||||
const surface = () =>
|
||||
h(
|
||||
ModalBackdropSurface,
|
||||
{
|
||||
...attrs,
|
||||
variant: props.variant,
|
||||
isDismissable: props.isDismissable,
|
||||
isKeyboardDismissDisabled: props.isKeyboardDismissDisabled,
|
||||
to: props.to,
|
||||
},
|
||||
slots,
|
||||
);
|
||||
if (parent) return surface();
|
||||
return h(
|
||||
Modal,
|
||||
{
|
||||
open: props.open,
|
||||
isOpen: props.isOpen,
|
||||
defaultOpen: props.defaultOpen,
|
||||
"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,48 @@
|
||||
<script setup lang="ts">
|
||||
import { useForwardExpose } from "reka-ui";
|
||||
import { computed, provide } from "vue";
|
||||
import { modalVariants, type ModalVariants } from "@heroui-vue/styles";
|
||||
import OverlayPortal from "../overlay/OverlayPortal.vue";
|
||||
import OverlayBackdrop from "../overlay/OverlayBackdrop.vue";
|
||||
import { modalKey, useModal } from "./context";
|
||||
import { useOverlayViewport } from "../overlay/viewport";
|
||||
import { useOverlayAnimation } from "../overlay/animation";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
variant?: ModalVariants["variant"];
|
||||
isDismissable?: boolean;
|
||||
isKeyboardDismissDisabled?: boolean;
|
||||
to?: string | HTMLElement;
|
||||
}>(),
|
||||
{ variant: "opaque", isDismissable: true, isKeyboardDismissDisabled: false },
|
||||
);
|
||||
const ctx = useModal();
|
||||
const height = useOverlayViewport();
|
||||
const { forwardRef, currentElement } = useForwardExpose();
|
||||
provide(modalKey, {
|
||||
...ctx,
|
||||
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="modalVariants({ variant }).backdrop()"
|
||||
data-slot="modal-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,17 @@
|
||||
<script setup lang="ts">
|
||||
import { modalVariants } from "@heroui-vue/styles";
|
||||
import { useModal } from "./context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
withDefaults(defineProps<{ as?: string }>(), { as: "div" });
|
||||
const ctx = useModal();
|
||||
</script>
|
||||
<template>
|
||||
<component
|
||||
:is="as"
|
||||
v-bind="$attrs"
|
||||
:class="modalVariants({ scroll: ctx.scroll.value }).body()"
|
||||
data-slot="modal-body"
|
||||
>
|
||||
<slot :close="ctx.state.close" />
|
||||
</component>
|
||||
</template>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import OverlayAction from "../overlay/OverlayAction";
|
||||
import { useModal } from "./context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
withDefaults(
|
||||
defineProps<{ as?: string; asChild?: boolean; isDisabled?: boolean }>(),
|
||||
{ as: "button" },
|
||||
);
|
||||
const ctx = useModal();
|
||||
</script>
|
||||
<template>
|
||||
<OverlayAction
|
||||
v-bind="$attrs"
|
||||
:as="as"
|
||||
:as-child="asChild"
|
||||
:is-disabled="isDisabled"
|
||||
:activate="ctx.state.close"
|
||||
>
|
||||
<slot />
|
||||
</OverlayAction>
|
||||
</template>
|
||||
@@ -0,0 +1,28 @@
|
||||
import { defineComponent, h, mergeProps, type PropType } from "vue";
|
||||
import type { CloseButtonVariants } from "@heroui-vue/styles";
|
||||
import CloseButton from "../close-button/CloseButton.vue";
|
||||
import { useModal } from "./context";
|
||||
export default defineComponent({
|
||||
name: "ModalCloseTrigger",
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
variant: String as PropType<CloseButtonVariants["variant"]>,
|
||||
isDisabled: Boolean,
|
||||
disabled: Boolean,
|
||||
},
|
||||
setup(props, { attrs, slots }) {
|
||||
const ctx = useModal();
|
||||
return () =>
|
||||
h(
|
||||
CloseButton,
|
||||
mergeProps(attrs, props, {
|
||||
class: "hv-modal__close-trigger",
|
||||
"data-slot": "modal-close-trigger",
|
||||
onClick: (event: MouseEvent) => {
|
||||
if (!event.defaultPrevented) ctx.state.close();
|
||||
},
|
||||
}),
|
||||
slots,
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, provide, ref } from "vue";
|
||||
import { modalVariants, type ModalVariants } from "@heroui-vue/styles";
|
||||
import { modalKey, useModal, type ModalPlacement } from "./context";
|
||||
import { useOverlayAnimation } from "../overlay/animation";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
placement?: ModalPlacement;
|
||||
size?: ModalVariants["size"];
|
||||
scroll?: ModalVariants["scroll"];
|
||||
as?: string;
|
||||
}>(),
|
||||
{ placement: "auto", size: "md", scroll: "inside", as: "div" },
|
||||
);
|
||||
const ctx = useModal();
|
||||
provide(modalKey, {
|
||||
...ctx,
|
||||
placement: computed(() => props.placement),
|
||||
size: computed(() => props.size),
|
||||
scroll: computed(() => props.scroll),
|
||||
});
|
||||
const container = ref<HTMLElement>();
|
||||
const { entering, exiting, onAnimationEnd } = useOverlayAnimation(
|
||||
ctx.state.isOpen,
|
||||
container,
|
||||
);
|
||||
</script>
|
||||
<template>
|
||||
<component
|
||||
:is="as"
|
||||
ref="container"
|
||||
v-bind="$attrs"
|
||||
:class="modalVariants({ size, scroll }).container()"
|
||||
data-slot="modal-container"
|
||||
:data-placement="placement"
|
||||
:data-entering="entering || undefined"
|
||||
:data-exiting="exiting || undefined"
|
||||
@animationend="onAnimationEnd"
|
||||
>
|
||||
<slot :close="ctx.state.close" />
|
||||
</component>
|
||||
</template>
|
||||
@@ -0,0 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, provide, watchEffect, onUnmounted, useAttrs } from "vue";
|
||||
import { DialogTitle } from "reka-ui";
|
||||
import { modalVariants } from "@heroui-vue/styles";
|
||||
import OverlayDialogContent from "../overlay/OverlayDialogContent.vue";
|
||||
import { surfaceContextKey } from "../surface/context";
|
||||
import { useModal } from "./context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
const props = withDefaults(defineProps<{ as?: string; id?: string }>(), {
|
||||
as: "div",
|
||||
});
|
||||
const ctx = useModal();
|
||||
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="
|
||||
modalVariants({ size: ctx.size.value, scroll: ctx.scroll.value }).dialog()
|
||||
"
|
||||
:is-dismissable="ctx.dismissable.value"
|
||||
:is-keyboard-dismiss-disabled="ctx.keyboardDisabled.value"
|
||||
data-slot="modal-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,17 @@
|
||||
<script setup lang="ts">
|
||||
import { modalVariants } from "@heroui-vue/styles";
|
||||
import { useModal } from "./context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
withDefaults(defineProps<{ as?: string }>(), { as: "div" });
|
||||
const ctx = useModal();
|
||||
</script>
|
||||
<template>
|
||||
<component
|
||||
:is="as"
|
||||
v-bind="$attrs"
|
||||
:class="'hv-modal__footer'"
|
||||
data-slot="modal-footer"
|
||||
>
|
||||
<slot :close="ctx.state.close" />
|
||||
</component>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { modalVariants } from "@heroui-vue/styles";
|
||||
import { useModal } from "./context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
withDefaults(defineProps<{ as?: string }>(), { as: "div" });
|
||||
const ctx = useModal();
|
||||
</script>
|
||||
<template>
|
||||
<component
|
||||
:is="as"
|
||||
v-bind="$attrs"
|
||||
:class="'hv-modal__header'"
|
||||
data-slot="modal-header"
|
||||
>
|
||||
<slot :close="ctx.state.close" />
|
||||
</component>
|
||||
</template>
|
||||
@@ -0,0 +1,31 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, watchEffect, onUnmounted, useId } from "vue";
|
||||
import { DialogTitle, injectDialogRootContext } from "reka-ui";
|
||||
import { useModal } from "./context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
const props = withDefaults(defineProps<{ as?: string; id?: string }>(), {
|
||||
as: "h2",
|
||||
});
|
||||
const ctx = useModal();
|
||||
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-modal__heading"
|
||||
data-slot="modal-heading"
|
||||
>
|
||||
<slot />
|
||||
</DialogTitle>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { modalVariants } from "@heroui-vue/styles";
|
||||
import { useModal } from "./context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
withDefaults(defineProps<{ as?: string }>(), { as: "div" });
|
||||
const ctx = useModal();
|
||||
</script>
|
||||
<template>
|
||||
<component
|
||||
:is="as"
|
||||
v-bind="$attrs"
|
||||
:class="'hv-modal__icon'"
|
||||
data-slot="modal-icon"
|
||||
>
|
||||
<slot :close="ctx.state.close" />
|
||||
</component>
|
||||
</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 { useModal } from "./context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
withDefaults(
|
||||
defineProps<{ as?: string; asChild?: boolean; isDisabled?: boolean }>(),
|
||||
{ as: "div" },
|
||||
);
|
||||
const ctx = useModal();
|
||||
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-modal__trigger"
|
||||
data-slot="modal-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,45 @@
|
||||
import {
|
||||
computed,
|
||||
inject,
|
||||
reactive,
|
||||
ref,
|
||||
useId,
|
||||
type ComputedRef,
|
||||
type InjectionKey,
|
||||
type Ref,
|
||||
} from "vue";
|
||||
import type { ModalVariants } from "@heroui-vue/styles";
|
||||
import type { OverlayState } from "../../composables/useOverlayState";
|
||||
export type ModalPlacement = "auto" | "top" | "center" | "bottom";
|
||||
export interface ModalContext {
|
||||
state: OverlayState;
|
||||
contentId: Ref<string>;
|
||||
defaultId: string;
|
||||
titles: Map<symbol, string>;
|
||||
placement: ComputedRef<ModalPlacement>;
|
||||
size: ComputedRef<ModalVariants["size"]>;
|
||||
scroll: ComputedRef<ModalVariants["scroll"]>;
|
||||
dismissable: ComputedRef<boolean>;
|
||||
keyboardDisabled: ComputedRef<boolean>;
|
||||
}
|
||||
export const modalKey: InjectionKey<ModalContext> = Symbol("hv-modal");
|
||||
export function useModal(required = true) {
|
||||
const ctx = inject(modalKey, undefined);
|
||||
if (!ctx && required)
|
||||
throw new Error("Modal parts require Modal or ModalBackdrop.");
|
||||
return ctx!;
|
||||
}
|
||||
export function createModalContext(state: OverlayState): ModalContext {
|
||||
const id = "hv-modal-" + useId();
|
||||
return {
|
||||
state,
|
||||
contentId: ref(id),
|
||||
defaultId: id,
|
||||
titles: reactive(new Map()),
|
||||
placement: computed(() => "auto"),
|
||||
size: computed(() => "md"),
|
||||
scroll: computed(() => "inside"),
|
||||
dismissable: computed(() => true),
|
||||
keyboardDisabled: computed(() => false),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
import {
|
||||
Comment,
|
||||
Fragment,
|
||||
Text,
|
||||
cloneVNode,
|
||||
defineComponent,
|
||||
h,
|
||||
isVNode,
|
||||
ref,
|
||||
type VNode,
|
||||
type PropType,
|
||||
} from "vue";
|
||||
import { useForwardExpose } from "reka-ui";
|
||||
import { useInheritedDisabled } from "../field/disabled";
|
||||
|
||||
export function overlayNodes(children: unknown): VNode[] {
|
||||
const result: VNode[] = [];
|
||||
for (const child of Array.isArray(children) ? children : [children]) {
|
||||
if (Array.isArray(child)) result.push(...overlayNodes(child));
|
||||
else if (isVNode(child)) {
|
||||
if (child.type === Fragment) result.push(...overlayNodes(child.children));
|
||||
else if (
|
||||
child.type !== Comment &&
|
||||
!(child.type === Text && !String(child.children).trim())
|
||||
)
|
||||
result.push(child);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
export function overlayComponentName(node: VNode): string {
|
||||
const type = node.type as { name?: string; __name?: string };
|
||||
return typeof node.type === "object" ? (type.name ?? type.__name ?? "") : "";
|
||||
}
|
||||
function handlers(value: unknown): ((event: Event) => void)[] {
|
||||
if (Array.isArray(value)) return value.flatMap(handlers);
|
||||
return typeof value === "function" ? [value as (event: Event) => void] : [];
|
||||
}
|
||||
|
||||
/** Native DOM listener arrays keep cancel/stop semantics. No synthetic emit or invoker internals. */
|
||||
export default defineComponent({
|
||||
name: "OverlayAction",
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
as: { type: String, default: "button" },
|
||||
asChild: Boolean,
|
||||
isDisabled: Boolean,
|
||||
activate: { type: Function as PropType<() => void>, required: true },
|
||||
},
|
||||
setup(props, { attrs, slots }) {
|
||||
const inherited = useInheritedDisabled(() => props.isDisabled);
|
||||
const { forwardRef } = useForwardExpose();
|
||||
const spaceDown = ref(false);
|
||||
return () => {
|
||||
const children = slots.default?.();
|
||||
const nodes = overlayNodes(children);
|
||||
if (
|
||||
props.asChild &&
|
||||
(nodes.length !== 1 || typeof nodes[0]?.type === "symbol")
|
||||
)
|
||||
throw new Error(
|
||||
"Overlay trigger asChild requires one element or component root.",
|
||||
);
|
||||
const child = props.asChild ? nodes[0]! : undefined;
|
||||
const original = child?.props ?? {};
|
||||
const disabled = () =>
|
||||
inherited.value ||
|
||||
original.isDisabled === true ||
|
||||
original.disabled === true ||
|
||||
original.isPending === true ||
|
||||
original.loading === true ||
|
||||
attrs.disabled === true;
|
||||
const guard = (event: Event) => {
|
||||
if (disabled()) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
spaceDown.value = false;
|
||||
}
|
||||
};
|
||||
const native = (el: EventTarget | null) =>
|
||||
el instanceof HTMLElement &&
|
||||
(el.tagName === "BUTTON" ||
|
||||
el.tagName === "INPUT" ||
|
||||
(el.tagName === "A" && el.hasAttribute("href")));
|
||||
const keyboardDown = (event: KeyboardEvent) => {
|
||||
if (
|
||||
event.defaultPrevented ||
|
||||
event.repeat ||
|
||||
event.isComposing ||
|
||||
native(event.currentTarget)
|
||||
)
|
||||
return;
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
(event.currentTarget as HTMLElement).click();
|
||||
}
|
||||
if (event.key === " ") {
|
||||
event.preventDefault();
|
||||
spaceDown.value = true;
|
||||
}
|
||||
};
|
||||
const keyboardUp = (event: KeyboardEvent) => {
|
||||
const pressed = spaceDown.value;
|
||||
spaceDown.value = false;
|
||||
if (
|
||||
event.key === " " &&
|
||||
pressed &&
|
||||
!event.defaultPrevented &&
|
||||
!native(event.currentTarget)
|
||||
) {
|
||||
event.preventDefault();
|
||||
(event.currentTarget as HTMLElement).click();
|
||||
}
|
||||
};
|
||||
const tag = child
|
||||
? typeof child.type === "string"
|
||||
? child.type
|
||||
: undefined
|
||||
: props.as;
|
||||
const custom =
|
||||
tag &&
|
||||
!["button", "input"].includes(tag) &&
|
||||
!(tag === "a" && (original.href ?? attrs.href));
|
||||
const merged = {
|
||||
...attrs,
|
||||
type:
|
||||
attrs.type ??
|
||||
(props.as === "button" || child?.type === "button"
|
||||
? "button"
|
||||
: undefined),
|
||||
role: attrs.role ?? original.role ?? (custom ? "button" : undefined),
|
||||
tabindex:
|
||||
attrs.tabindex ??
|
||||
original.tabindex ??
|
||||
(custom ? (disabled() ? -1 : 0) : undefined),
|
||||
disabled: disabled() || undefined,
|
||||
"aria-disabled": disabled() || undefined,
|
||||
onClickCapture: [
|
||||
guard,
|
||||
...handlers(attrs.onClickCapture),
|
||||
...handlers(original.onClickCapture),
|
||||
],
|
||||
onKeydownCapture: [
|
||||
guard,
|
||||
...handlers(attrs.onKeydownCapture),
|
||||
...handlers(original.onKeydownCapture),
|
||||
],
|
||||
onKeyupCapture: [
|
||||
guard,
|
||||
...handlers(attrs.onKeyupCapture),
|
||||
...handlers(original.onKeyupCapture),
|
||||
],
|
||||
onClick: [
|
||||
...handlers(original.onClick),
|
||||
...handlers(attrs.onClick),
|
||||
(event: Event) => {
|
||||
if (!event.defaultPrevented && !disabled()) props.activate();
|
||||
},
|
||||
],
|
||||
onKeydown: [
|
||||
...handlers(original.onKeydown),
|
||||
...handlers(attrs.onKeydown),
|
||||
keyboardDown,
|
||||
],
|
||||
onKeyup: [
|
||||
...handlers(original.onKeyup),
|
||||
...handlers(attrs.onKeyup),
|
||||
keyboardUp,
|
||||
],
|
||||
onBlur: [
|
||||
...handlers(original.onBlur),
|
||||
...handlers(attrs.onBlur),
|
||||
() => {
|
||||
spaceDown.value = false;
|
||||
},
|
||||
],
|
||||
ref: forwardRef,
|
||||
};
|
||||
if (!child) return h(props.as, merged, children);
|
||||
const copy = cloneVNode(child);
|
||||
copy.props = { ...original };
|
||||
for (const event of [
|
||||
"onClick",
|
||||
"onClickCapture",
|
||||
"onKeydown",
|
||||
"onKeyup",
|
||||
"onKeydownCapture",
|
||||
"onKeyupCapture",
|
||||
"onBlur",
|
||||
])
|
||||
delete copy.props[event];
|
||||
return cloneVNode(copy, merged, true);
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { cloneVNode, defineComponent, h } from "vue";
|
||||
import { overlayNodes } from "./OverlayAction";
|
||||
/** Canonical arrow path from HeroUI ce90ea3 (Apache-2.0); custom SVGs keep the styling slot. */
|
||||
export default defineComponent({
|
||||
inheritAttrs: false,
|
||||
props: { marker: { type: String, required: true } },
|
||||
setup(props, { attrs, slots }) {
|
||||
return () => {
|
||||
const nodes = overlayNodes(slots.default?.());
|
||||
if (nodes.length > 1)
|
||||
throw new Error("Overlay arrow requires one custom SVG root.");
|
||||
return nodes[0]
|
||||
? cloneVNode(nodes[0], { ...attrs, "data-slot": props.marker })
|
||||
: h(
|
||||
"svg",
|
||||
{
|
||||
...attrs,
|
||||
"aria-hidden": true,
|
||||
"data-slot": props.marker,
|
||||
fill: "none",
|
||||
width: 12,
|
||||
height: 12,
|
||||
viewBox: "0 0 12 12",
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
},
|
||||
[h("path", { d: "M0 0C5.48483 8 6.5 8 12 0Z" })],
|
||||
);
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { DialogOverlay, useForwardExpose } from "reka-ui";
|
||||
import { useOverlayDialog } from "./context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
withDefaults(defineProps<{ as?: string }>(), { as: "div" });
|
||||
useOverlayDialog();
|
||||
const { forwardRef } = useForwardExpose();
|
||||
</script>
|
||||
<template>
|
||||
<DialogOverlay :ref="forwardRef" :as="as" v-bind="$attrs">
|
||||
<slot />
|
||||
</DialogOverlay>
|
||||
</template>
|
||||
@@ -0,0 +1,56 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
DialogContent,
|
||||
injectDialogRootContext,
|
||||
useForwardExpose,
|
||||
type DialogContentEmits,
|
||||
} from "reka-ui";
|
||||
import { useId } from "vue";
|
||||
import { useConfig } from "../../providers/context";
|
||||
import { useOverlayDialog } from "./context";
|
||||
|
||||
defineOptions({ inheritAttrs: false });
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
as?: string;
|
||||
isDismissable?: boolean;
|
||||
isKeyboardDismissDisabled?: boolean;
|
||||
}>(),
|
||||
{ as: "div", isDismissable: true, isKeyboardDismissDisabled: false },
|
||||
);
|
||||
const emit = defineEmits<DialogContentEmits>();
|
||||
const context = useOverlayDialog();
|
||||
const config = useConfig();
|
||||
const generatedId = useId();
|
||||
// Programmatic dialogs may have no Trigger to allocate a content ID.
|
||||
const dialog = injectDialogRootContext();
|
||||
dialog.contentId ||= `hv-overlay-${generatedId}`;
|
||||
const { forwardRef } = useForwardExpose();
|
||||
|
||||
function onEscape(event: KeyboardEvent) {
|
||||
emit("escapeKeyDown", event);
|
||||
if (props.isKeyboardDismissDisabled) event.preventDefault();
|
||||
}
|
||||
function onOutside(event: DialogContentEmits["interactOutside"][0]) {
|
||||
emit("interactOutside", event);
|
||||
if (!props.isDismissable) event.preventDefault();
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<DialogContent
|
||||
:ref="forwardRef"
|
||||
:as="as"
|
||||
v-bind="$attrs"
|
||||
:dir="($attrs.dir as string | undefined) ?? config?.dir.value"
|
||||
:lang="($attrs.lang as string | undefined) ?? config?.locale.value"
|
||||
:aria-modal="context.modal.value ? true : undefined"
|
||||
@escape-key-down="onEscape"
|
||||
@interact-outside="onOutside"
|
||||
@pointer-down-outside="emit('pointerDownOutside', $event)"
|
||||
@focus-outside="emit('focusOutside', $event)"
|
||||
@open-auto-focus="emit('openAutoFocus', $event)"
|
||||
@close-auto-focus="emit('closeAutoFocus', $event)"
|
||||
>
|
||||
<slot />
|
||||
</DialogContent>
|
||||
</template>
|
||||
@@ -0,0 +1,49 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, provide, toValue } from "vue";
|
||||
import { DialogRoot } from "reka-ui";
|
||||
import {
|
||||
useOverlayState,
|
||||
type OverlayState,
|
||||
} from "../../composables/useOverlayState";
|
||||
import { overlayDialogKey } from "./context";
|
||||
|
||||
defineOptions({ inheritAttrs: false });
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
open?: boolean;
|
||||
defaultOpen?: boolean;
|
||||
state?: OverlayState;
|
||||
modal?: boolean;
|
||||
}>(),
|
||||
{ open: undefined, defaultOpen: false, modal: true },
|
||||
);
|
||||
const emit = defineEmits<{
|
||||
"update:open": [open: boolean];
|
||||
openChange: [open: boolean];
|
||||
}>();
|
||||
const state = useOverlayState({
|
||||
isOpen: () => (props.state ? toValue(props.state.isOpen) : props.open),
|
||||
defaultOpen: props.defaultOpen,
|
||||
onOpenChange(value) {
|
||||
props.state?.setOpen(value);
|
||||
emit("update:open", value);
|
||||
emit("openChange", value);
|
||||
},
|
||||
});
|
||||
provide(overlayDialogKey, { state, modal: computed(() => props.modal) });
|
||||
defineExpose({ open: state.open, close: state.close, toggle: state.toggle });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogRoot
|
||||
:open="state.isOpen.value"
|
||||
:modal="modal"
|
||||
@update:open="state.setOpen"
|
||||
>
|
||||
<slot
|
||||
:is-open="state.isOpen.value"
|
||||
:close="state.close"
|
||||
:open="state.open"
|
||||
/>
|
||||
</DialogRoot>
|
||||
</template>
|
||||
@@ -0,0 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import { DialogPortal } from "reka-ui";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
defineProps<{
|
||||
to?: string | HTMLElement;
|
||||
disabled?: boolean;
|
||||
defer?: boolean;
|
||||
}>();
|
||||
</script>
|
||||
<template>
|
||||
<DialogPortal :to="to" :disabled="disabled" :defer="defer">
|
||||
<slot />
|
||||
</DialogPortal>
|
||||
</template>
|
||||
@@ -0,0 +1,63 @@
|
||||
import { computed, nextTick, ref, watch, type Ref } from "vue";
|
||||
/** Phase markers drive source keyframes; Reka Presence still owns exit unmounting. */
|
||||
export function useOverlayAnimation(
|
||||
open: Ref<boolean>,
|
||||
element?: Ref<HTMLElement | null | undefined>,
|
||||
floating = false,
|
||||
) {
|
||||
const entering = ref(open.value);
|
||||
watch(
|
||||
open,
|
||||
(value) => {
|
||||
entering.value = value;
|
||||
},
|
||||
{ flush: "sync" },
|
||||
);
|
||||
function onAnimationEnd(event: AnimationEvent) {
|
||||
if (event.target !== event.currentTarget || !open.value) return;
|
||||
const names = getComputedStyle(event.currentTarget as HTMLElement)
|
||||
.animationName.split(",")
|
||||
.map((s) => s.trim());
|
||||
if (names.includes(event.animationName)) entering.value = false;
|
||||
}
|
||||
if (element)
|
||||
watch(
|
||||
[element, open],
|
||||
([el], _, onCleanup) => {
|
||||
if (!el) return;
|
||||
let stale = false;
|
||||
const wrapper = el.parentElement;
|
||||
const check = () => {
|
||||
if (stale || !open.value || !entering.value) return;
|
||||
// Floating UI briefly suppresses animation while measuring. Wait for placement.
|
||||
if (
|
||||
floating &&
|
||||
wrapper?.hasAttribute("data-reka-popper-content-wrapper") &&
|
||||
/translate\(0(?:px)?,\s*-200%\)/.test(wrapper.style.transform)
|
||||
)
|
||||
return;
|
||||
const animation = getComputedStyle(el).animationName;
|
||||
if (!animation || animation === "none") entering.value = false;
|
||||
};
|
||||
const observer = new MutationObserver(check);
|
||||
observer.observe(el, { attributes: true, attributeFilter: ["style"] });
|
||||
if (floating && wrapper)
|
||||
observer.observe(wrapper, {
|
||||
attributes: true,
|
||||
attributeFilter: ["style"],
|
||||
});
|
||||
const media = el.ownerDocument.defaultView?.matchMedia?.(
|
||||
"(prefers-reduced-motion: reduce)",
|
||||
);
|
||||
media?.addEventListener("change", check);
|
||||
void nextTick(check);
|
||||
onCleanup(() => {
|
||||
stale = true;
|
||||
observer.disconnect();
|
||||
media?.removeEventListener("change", check);
|
||||
});
|
||||
},
|
||||
{ flush: "post" },
|
||||
);
|
||||
return { entering, exiting: computed(() => !open.value), onAnimationEnd };
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { inject, type ComputedRef, type InjectionKey } from "vue";
|
||||
import type { OverlayState } from "../../composables/useOverlayState";
|
||||
|
||||
export interface OverlayDialogContext {
|
||||
state: OverlayState;
|
||||
modal: ComputedRef<boolean>;
|
||||
}
|
||||
export const overlayDialogKey: InjectionKey<OverlayDialogContext> =
|
||||
Symbol("hv-overlay-dialog");
|
||||
export function useOverlayDialog() {
|
||||
const context = inject(overlayDialogKey);
|
||||
if (!context)
|
||||
throw new Error("Overlay dialog parts require OverlayDialogRoot.");
|
||||
return context;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
export type OverlaySide = "top" | "bottom" | "left" | "right";
|
||||
export type OverlayPlacement =
|
||||
| OverlaySide
|
||||
| "start"
|
||||
| "end"
|
||||
| `${"top" | "bottom"} ${"start" | "end" | "left" | "right"}`
|
||||
| `${"left" | "right" | "start" | "end"} ${"top" | "bottom"}`;
|
||||
export function resolvePlacement(
|
||||
value: OverlayPlacement,
|
||||
dir: "ltr" | "rtl" = "ltr",
|
||||
) {
|
||||
const [base, edge] = value.split(" ");
|
||||
const side: OverlaySide =
|
||||
base === "start"
|
||||
? dir === "rtl"
|
||||
? "right"
|
||||
: "left"
|
||||
: base === "end"
|
||||
? dir === "rtl"
|
||||
? "left"
|
||||
: "right"
|
||||
: (base as OverlaySide);
|
||||
let align: "start" | "center" | "end" = "center";
|
||||
if (edge === "start" || edge === "top") align = "start";
|
||||
else if (edge === "end" || edge === "bottom") align = "end";
|
||||
else if (edge === "left") align = dir === "rtl" ? "end" : "start";
|
||||
else if (edge === "right") align = dir === "rtl" ? "start" : "end";
|
||||
return { side, align };
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/** Private primitive bridge, not a public HeroUI-compatible component API. */
|
||||
export {
|
||||
DialogTrigger,
|
||||
DialogClose,
|
||||
DialogTitle,
|
||||
DialogDescription,
|
||||
PopoverRoot,
|
||||
PopoverTrigger,
|
||||
PopoverPortal,
|
||||
PopoverContent,
|
||||
} from "reka-ui";
|
||||
@@ -0,0 +1,18 @@
|
||||
import { onMounted, onBeforeUnmount, ref } from "vue";
|
||||
/** CSS fallback works before mount; use the visual viewport while the keyboard is visible. */
|
||||
export function useOverlayViewport() {
|
||||
const height = ref("100dvh");
|
||||
const update = () => {
|
||||
height.value = `${window.visualViewport?.height ?? window.innerHeight}px`;
|
||||
};
|
||||
onMounted(() => {
|
||||
update();
|
||||
window.addEventListener("resize", update);
|
||||
window.visualViewport?.addEventListener("resize", update);
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener("resize", update);
|
||||
window.visualViewport?.removeEventListener("resize", update);
|
||||
});
|
||||
return height;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import { defineComponent, h, provide } from "vue";
|
||||
import { PopoverRoot } from "reka-ui";
|
||||
import { useOverlayState } from "../../composables/useOverlayState";
|
||||
import { overlayNodes, overlayComponentName } from "../overlay/OverlayAction";
|
||||
import { createPopoverContext, popoverKey } from "./context";
|
||||
import PopoverTrigger from "./PopoverTrigger.vue";
|
||||
export default defineComponent({
|
||||
name: "Popover",
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
open: { type: Boolean, default: undefined },
|
||||
isOpen: { type: Boolean, default: undefined },
|
||||
defaultOpen: Boolean,
|
||||
isNonModal: { type: Boolean, default: false },
|
||||
},
|
||||
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.open ?? props.isOpen,
|
||||
defaultOpen: props.defaultOpen,
|
||||
onOpenChange(v) {
|
||||
emit("update:open", v);
|
||||
emit("update:isOpen", v);
|
||||
emit("openChange", v);
|
||||
},
|
||||
});
|
||||
const context = createPopoverContext(state);
|
||||
provide(popoverKey, context);
|
||||
return () =>
|
||||
h(
|
||||
PopoverRoot,
|
||||
{
|
||||
open: state.isOpen.value,
|
||||
modal: !(context.contentNonModal.value ?? props.isNonModal),
|
||||
"onUpdate:open": state.setOpen,
|
||||
},
|
||||
{
|
||||
default: () => {
|
||||
let found = false;
|
||||
return overlayNodes(
|
||||
slots.default?.({
|
||||
isOpen: state.isOpen.value,
|
||||
close: state.close,
|
||||
}),
|
||||
).map((node) => {
|
||||
const name = overlayComponentName(node);
|
||||
if (name === "PopoverTrigger") found = true;
|
||||
if (
|
||||
!found &&
|
||||
(name === "Button" ||
|
||||
node.type === "button" ||
|
||||
node.type === "a")
|
||||
) {
|
||||
found = true;
|
||||
return h(
|
||||
PopoverTrigger,
|
||||
{ asChild: true, key: node.key ?? undefined },
|
||||
{ default: () => node },
|
||||
);
|
||||
}
|
||||
return node;
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { PopoverArrow as RekaArrow } from "reka-ui";
|
||||
import OverlayArrowShape from "../overlay/OverlayArrowShape";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
</script>
|
||||
<template>
|
||||
<RekaArrow v-bind="$attrs" as-child :width="12" :height="12">
|
||||
<OverlayArrowShape marker="popover-overlay-arrow">
|
||||
<slot />
|
||||
</OverlayArrowShape>
|
||||
</RekaArrow>
|
||||
</template>
|
||||
@@ -0,0 +1,147 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, provide, watchEffect, ref, watch, nextTick } from "vue";
|
||||
import {
|
||||
PopoverPortal,
|
||||
PopoverContent as RekaContent,
|
||||
useForwardExpose,
|
||||
type PopoverContentEmits,
|
||||
injectPopoverRootContext,
|
||||
} from "reka-ui";
|
||||
import { useConfig } from "../../providers/context";
|
||||
import { surfaceContextKey } from "../surface/context";
|
||||
import { resolvePlacement, type OverlayPlacement } from "../overlay/placement";
|
||||
import { useOverlayAnimation } from "../overlay/animation";
|
||||
import { usePopover } from "./context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
as?: string;
|
||||
id?: string;
|
||||
placement?: OverlayPlacement;
|
||||
offset?: number;
|
||||
crossOffset?: number;
|
||||
shouldFlip?: boolean;
|
||||
containerPadding?: number;
|
||||
to?: string | HTMLElement;
|
||||
isNonModal?: boolean;
|
||||
isDismissable?: boolean;
|
||||
isKeyboardDismissDisabled?: boolean;
|
||||
}>(),
|
||||
{
|
||||
as: "div",
|
||||
placement: "bottom",
|
||||
offset: 8,
|
||||
crossOffset: 0,
|
||||
shouldFlip: true,
|
||||
containerPadding: 12,
|
||||
isNonModal: undefined,
|
||||
isDismissable: true,
|
||||
isKeyboardDismissDisabled: false,
|
||||
},
|
||||
);
|
||||
const emit = defineEmits<PopoverContentEmits>();
|
||||
const ctx = usePopover(),
|
||||
config = useConfig(),
|
||||
root = injectPopoverRootContext();
|
||||
const originalId = ctx.contentId.value;
|
||||
watchEffect(() => {
|
||||
ctx.contentId.value = props.id ?? originalId;
|
||||
root.contentId = ctx.contentId.value;
|
||||
ctx.contentNonModal.value = props.isNonModal;
|
||||
});
|
||||
provide(surfaceContextKey, { variant: computed(() => "default" as const) });
|
||||
const position = computed(() =>
|
||||
resolvePlacement(props.placement, config?.dir.value),
|
||||
);
|
||||
const { forwardRef } = useForwardExpose();
|
||||
const contentElement = ref<HTMLElement | null>(null);
|
||||
let focusCancelled = false;
|
||||
function openFocus(event: Event) {
|
||||
emit("openAutoFocus", event);
|
||||
focusCancelled = event.defaultPrevented;
|
||||
}
|
||||
watch(
|
||||
contentElement,
|
||||
(element, _, onCleanup) => {
|
||||
let stale = false;
|
||||
onCleanup(() => {
|
||||
stale = true;
|
||||
});
|
||||
void nextTick(() => {
|
||||
if (
|
||||
!stale &&
|
||||
element?.isConnected &&
|
||||
ctx.state.isOpen.value &&
|
||||
!focusCancelled &&
|
||||
!element.contains(element.ownerDocument.activeElement)
|
||||
)
|
||||
element.focus({ preventScroll: true });
|
||||
});
|
||||
},
|
||||
{ flush: "post" },
|
||||
);
|
||||
const { entering, exiting, onAnimationEnd } = useOverlayAnimation(
|
||||
ctx.state.isOpen,
|
||||
contentElement,
|
||||
true,
|
||||
);
|
||||
function outside(event: PopoverContentEmits["interactOutside"][0]) {
|
||||
emit("interactOutside", event);
|
||||
if (!props.isDismissable) event.preventDefault();
|
||||
}
|
||||
function escape(event: KeyboardEvent) {
|
||||
emit("escapeKeyDown", event);
|
||||
if (props.isKeyboardDismissDisabled) event.preventDefault();
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<PopoverPortal :to="to">
|
||||
<RekaContent
|
||||
:ref="forwardRef"
|
||||
v-bind="$attrs"
|
||||
as-child
|
||||
:id="ctx.contentId.value"
|
||||
:side="position.side"
|
||||
:align="position.align"
|
||||
:side-offset="offset"
|
||||
:align-offset="crossOffset"
|
||||
:side-flip="shouldFlip"
|
||||
:collision-padding="containerPadding"
|
||||
class="hv-popover"
|
||||
data-slot="popover-content"
|
||||
:data-entering="entering || undefined"
|
||||
:data-exiting="exiting || undefined"
|
||||
:lang="($attrs.lang as string | undefined) ?? config?.locale.value"
|
||||
@animationend="onAnimationEnd"
|
||||
@interact-outside="outside"
|
||||
@escape-key-down="escape"
|
||||
@pointer-down-outside="emit('pointerDownOutside', $event)"
|
||||
@focus-outside="emit('focusOutside', $event)"
|
||||
@open-auto-focus="openFocus"
|
||||
@close-auto-focus="emit('closeAutoFocus', $event)"
|
||||
>
|
||||
<component
|
||||
:is="as"
|
||||
ref="contentElement"
|
||||
:aria-label="
|
||||
($attrs['aria-label'] as string | undefined) ??
|
||||
(ctx.dialogAttrs.value['aria-label'] as string | undefined)
|
||||
"
|
||||
:aria-describedby="
|
||||
($attrs['aria-describedby'] as string | undefined) ??
|
||||
(ctx.dialogAttrs.value['aria-describedby'] as string | undefined)
|
||||
"
|
||||
:aria-labelledby="
|
||||
'aria-labelledby' in $attrs
|
||||
? ($attrs['aria-labelledby'] as string)
|
||||
: (ctx.dialogAttrs.value['aria-labelledby'] as
|
||||
string | undefined) ||
|
||||
Array.from(ctx.titles.values()).join(' ') ||
|
||||
ctx.triggerId
|
||||
"
|
||||
>
|
||||
<slot :close="ctx.state.close" :is-open="ctx.state.isOpen.value" />
|
||||
</component>
|
||||
</RekaContent>
|
||||
</PopoverPortal>
|
||||
</template>
|
||||
@@ -0,0 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import { useAttrs, onBeforeUpdate, onUnmounted } from "vue";
|
||||
import { usePopover } from "./context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
withDefaults(defineProps<{ as?: string }>(), { as: "div" });
|
||||
const ctx = usePopover();
|
||||
const attrs = useAttrs();
|
||||
const keys = ["aria-label", "aria-labelledby", "aria-describedby", "role"];
|
||||
function sync() {
|
||||
const next = Object.fromEntries(
|
||||
keys.filter((key) => key in attrs).map((key) => [key, attrs[key]]),
|
||||
);
|
||||
const previous = ctx.dialogAttrs.value;
|
||||
if (keys.some((key) => next[key] !== previous[key]))
|
||||
ctx.dialogAttrs.value = next;
|
||||
}
|
||||
sync();
|
||||
onBeforeUpdate(sync);
|
||||
onUnmounted(() => {
|
||||
ctx.dialogAttrs.value = {};
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<component
|
||||
:is="as"
|
||||
v-bind="$attrs"
|
||||
class="hv-popover__dialog"
|
||||
data-slot="popover-dialog"
|
||||
>
|
||||
<slot :close="ctx.state.close" />
|
||||
</component>
|
||||
</template>
|
||||
@@ -0,0 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, useId, watchEffect, onUnmounted } from "vue";
|
||||
import { usePopover } from "./context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
const props = withDefaults(defineProps<{ as?: string; id?: string }>(), {
|
||||
as: "h2",
|
||||
});
|
||||
const ctx = usePopover(),
|
||||
key = Symbol(),
|
||||
generated = "hv-popover-heading-" + useId();
|
||||
const id = computed(() => props.id ?? generated);
|
||||
watchEffect(() => ctx.titles.set(key, id.value));
|
||||
onUnmounted(() => ctx.titles.delete(key));
|
||||
</script>
|
||||
<template>
|
||||
<component
|
||||
:is="as"
|
||||
v-bind="$attrs"
|
||||
:id="id"
|
||||
class="hv-popover__heading"
|
||||
data-slot="popover-heading"
|
||||
>
|
||||
<slot />
|
||||
</component>
|
||||
</template>
|
||||
@@ -0,0 +1,46 @@
|
||||
<script setup lang="ts">
|
||||
import { watch } from "vue";
|
||||
import {
|
||||
PopoverAnchor,
|
||||
injectPopoverRootContext,
|
||||
useForwardExpose,
|
||||
} from "reka-ui";
|
||||
import OverlayAction from "../overlay/OverlayAction";
|
||||
import { usePopover } from "./context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
withDefaults(
|
||||
defineProps<{ as?: string; asChild?: boolean; isDisabled?: boolean }>(),
|
||||
{ as: "div" },
|
||||
);
|
||||
const ctx = usePopover(),
|
||||
root = injectPopoverRootContext();
|
||||
const { forwardRef, currentElement } = useForwardExpose();
|
||||
watch(
|
||||
currentElement,
|
||||
(el) => {
|
||||
root.triggerElement.value = el;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
root.triggerId = ctx.triggerId;
|
||||
</script>
|
||||
<template>
|
||||
<PopoverAnchor as-child>
|
||||
<OverlayAction
|
||||
:ref="forwardRef"
|
||||
v-bind="$attrs"
|
||||
:id="($attrs.id as string | undefined) ?? ctx.triggerId"
|
||||
:as="as"
|
||||
:as-child="asChild"
|
||||
:is-disabled="isDisabled"
|
||||
:activate="ctx.state.toggle"
|
||||
class="hv-popover__trigger"
|
||||
data-slot="popover-trigger"
|
||||
aria-haspopup="dialog"
|
||||
:aria-expanded="ctx.state.isOpen.value"
|
||||
:aria-controls="ctx.state.isOpen.value ? ctx.contentId.value : undefined"
|
||||
>
|
||||
<slot />
|
||||
</OverlayAction>
|
||||
</PopoverAnchor>
|
||||
</template>
|
||||
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
inject,
|
||||
reactive,
|
||||
ref,
|
||||
shallowRef,
|
||||
useId,
|
||||
type InjectionKey,
|
||||
type Ref,
|
||||
} from "vue";
|
||||
import type { OverlayState } from "../../composables/useOverlayState";
|
||||
export interface PopoverContext {
|
||||
state: OverlayState;
|
||||
contentId: Ref<string>;
|
||||
triggerId: string;
|
||||
contentNonModal: Ref<boolean | undefined>;
|
||||
titles: Map<symbol, string>;
|
||||
dialogAttrs: Ref<Record<string, unknown>>;
|
||||
}
|
||||
export const popoverKey: InjectionKey<PopoverContext> = Symbol("hv-popover");
|
||||
export function usePopover() {
|
||||
const ctx = inject(popoverKey);
|
||||
if (!ctx) throw new Error("Popover parts require Popover.");
|
||||
return ctx;
|
||||
}
|
||||
export function createPopoverContext(state: OverlayState): PopoverContext {
|
||||
const id = "hv-popover-" + useId();
|
||||
return {
|
||||
state,
|
||||
contentId: ref(id + "-content"),
|
||||
triggerId: id + "-trigger",
|
||||
contentNonModal: ref(undefined),
|
||||
titles: reactive(new Map()),
|
||||
dialogAttrs: shallowRef({}),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
import {
|
||||
computed,
|
||||
defineComponent,
|
||||
h,
|
||||
onBeforeUnmount,
|
||||
onMounted,
|
||||
nextTick,
|
||||
provide,
|
||||
ref,
|
||||
watch,
|
||||
type PropType,
|
||||
} from "vue";
|
||||
import {
|
||||
TooltipProvider,
|
||||
TooltipRoot,
|
||||
injectTooltipProviderContext,
|
||||
} from "reka-ui";
|
||||
import { useOverlayState } from "../../composables/useOverlayState";
|
||||
import { overlayNodes, overlayComponentName } from "../overlay/OverlayAction";
|
||||
import { tooltipKey, cssTime } from "./context";
|
||||
import TooltipTrigger from "./TooltipTrigger.vue";
|
||||
export default defineComponent({
|
||||
name: "Tooltip",
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
open: { type: Boolean, default: undefined },
|
||||
isOpen: { type: Boolean, default: undefined },
|
||||
defaultOpen: Boolean,
|
||||
delay: Number,
|
||||
closeDelay: Number,
|
||||
trigger: { type: String as PropType<"hover" | "focus">, default: "hover" },
|
||||
isDisabled: Boolean,
|
||||
shouldSkipAnimation: Boolean,
|
||||
},
|
||||
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 hasProvider = injectTooltipProviderContext(null);
|
||||
const delayCss = ref(1500),
|
||||
closeCss = ref(500);
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
let immediate = false;
|
||||
const cancelClose = () => {
|
||||
clearTimeout(timer);
|
||||
timer = undefined;
|
||||
};
|
||||
const state = useOverlayState({
|
||||
isOpen: () => props.open ?? props.isOpen,
|
||||
defaultOpen: props.defaultOpen,
|
||||
onOpenChange(v) {
|
||||
emit("update:open", v);
|
||||
emit("update:isOpen", v);
|
||||
emit("openChange", v);
|
||||
},
|
||||
});
|
||||
const open = computed(() => !props.isDisabled && state.isOpen.value);
|
||||
const justOpening = ref(false);
|
||||
watch(open, (value) => {
|
||||
cancelClose();
|
||||
justOpening.value = value;
|
||||
if (value)
|
||||
void nextTick(() => {
|
||||
justOpening.value = false;
|
||||
});
|
||||
});
|
||||
// Reka 2.11 coordinates roots through this event. It must close the old
|
||||
// tooltip immediately, while an interrupted exit must not close itself.
|
||||
const onAnotherTooltip = () => {
|
||||
if (open.value && !justOpening.value) immediate = true;
|
||||
};
|
||||
onMounted(() =>
|
||||
document.addEventListener("tooltip.open", onAnotherTooltip, true),
|
||||
);
|
||||
onBeforeUnmount(() =>
|
||||
document.removeEventListener("tooltip.open", onAnotherTooltip, true),
|
||||
);
|
||||
function request(v: boolean) {
|
||||
cancelClose();
|
||||
if (v === open.value) {
|
||||
immediate = false;
|
||||
return;
|
||||
}
|
||||
if (v) {
|
||||
immediate = false;
|
||||
if (!props.isDisabled) state.open();
|
||||
} else if (immediate) {
|
||||
immediate = false;
|
||||
state.close();
|
||||
} else {
|
||||
const delay = props.closeDelay ?? closeCss.value;
|
||||
if (delay <= 0) state.close();
|
||||
else
|
||||
timer = setTimeout(() => {
|
||||
timer = undefined;
|
||||
state.close();
|
||||
}, delay);
|
||||
}
|
||||
}
|
||||
provide(tooltipKey, {
|
||||
open,
|
||||
justOpening,
|
||||
trigger: computed(() => props.trigger),
|
||||
skipAnimation: computed(() => props.shouldSkipAnimation),
|
||||
cancelClose,
|
||||
immediateClose: () => {
|
||||
immediate = true;
|
||||
},
|
||||
readTiming(el) {
|
||||
const css = getComputedStyle(el);
|
||||
delayCss.value = cssTime(css.getPropertyValue("--tooltip-delay"), 1500);
|
||||
closeCss.value = cssTime(
|
||||
css.getPropertyValue("--tooltip-close-delay"),
|
||||
500,
|
||||
);
|
||||
},
|
||||
});
|
||||
watch(
|
||||
() => props.isDisabled,
|
||||
(disabled) => {
|
||||
if (disabled) {
|
||||
cancelClose();
|
||||
state.close();
|
||||
}
|
||||
},
|
||||
);
|
||||
onBeforeUnmount(cancelClose);
|
||||
const root = () =>
|
||||
h(
|
||||
TooltipRoot,
|
||||
{
|
||||
open: open.value,
|
||||
disabled: props.isDisabled,
|
||||
delayDuration: props.delay ?? delayCss.value,
|
||||
"onUpdate:open": request,
|
||||
},
|
||||
{
|
||||
default: () => {
|
||||
let found = false;
|
||||
return overlayNodes(slots.default?.({ isOpen: open.value })).map(
|
||||
(node) => {
|
||||
const name = overlayComponentName(node);
|
||||
if (name === "TooltipTrigger") found = true;
|
||||
if (
|
||||
!found &&
|
||||
(name === "Button" ||
|
||||
node.type === "button" ||
|
||||
node.type === "a")
|
||||
) {
|
||||
found = true;
|
||||
return h(
|
||||
TooltipTrigger,
|
||||
{ asChild: true, key: node.key ?? undefined },
|
||||
{ default: () => node },
|
||||
);
|
||||
}
|
||||
return node;
|
||||
},
|
||||
);
|
||||
},
|
||||
},
|
||||
);
|
||||
return () =>
|
||||
hasProvider ? root() : h(TooltipProvider, {}, { default: root });
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { TooltipArrow as RekaArrow } from "reka-ui";
|
||||
import OverlayArrowShape from "../overlay/OverlayArrowShape";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
</script>
|
||||
<template>
|
||||
<RekaArrow v-bind="$attrs" as-child :width="12" :height="12">
|
||||
<OverlayArrowShape marker="overlay-arrow"><slot /></OverlayArrowShape>
|
||||
</RekaArrow>
|
||||
</template>
|
||||
@@ -0,0 +1,85 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import {
|
||||
TooltipPortal,
|
||||
TooltipContent as RekaContent,
|
||||
injectTooltipRootContext,
|
||||
useForwardExpose,
|
||||
type TooltipContentEmits,
|
||||
} from "reka-ui";
|
||||
import { useConfig } from "../../providers/context";
|
||||
import { resolvePlacement, type OverlayPlacement } from "../overlay/placement";
|
||||
import { useOverlayAnimation } from "../overlay/animation";
|
||||
import { useTooltip } from "./context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
as?: string;
|
||||
placement?: OverlayPlacement;
|
||||
offset?: number;
|
||||
crossOffset?: number;
|
||||
showArrow?: boolean;
|
||||
shouldFlip?: boolean;
|
||||
containerPadding?: number;
|
||||
to?: string | HTMLElement;
|
||||
}>(),
|
||||
{
|
||||
as: "div",
|
||||
placement: "top",
|
||||
crossOffset: 0,
|
||||
showArrow: false,
|
||||
shouldFlip: true,
|
||||
containerPadding: 12,
|
||||
},
|
||||
);
|
||||
const emit = defineEmits<TooltipContentEmits>();
|
||||
const ctx = useTooltip(),
|
||||
root = injectTooltipRootContext(),
|
||||
config = useConfig();
|
||||
const position = computed(() =>
|
||||
resolvePlacement(props.placement, config?.dir.value),
|
||||
);
|
||||
const { forwardRef, currentElement } = useForwardExpose();
|
||||
const { entering, exiting, onAnimationEnd } = useOverlayAnimation(
|
||||
ctx.open,
|
||||
currentElement,
|
||||
true,
|
||||
);
|
||||
const skip = computed(
|
||||
() => ctx.skipAnimation.value && root.stateAttribute.value === "instant-open",
|
||||
);
|
||||
function escape(e: KeyboardEvent) {
|
||||
emit("escapeKeyDown", e);
|
||||
if (!e.defaultPrevented) ctx.immediateClose();
|
||||
}
|
||||
function outside(e: Event) {
|
||||
emit("pointerDownOutside", e);
|
||||
if (!e.defaultPrevented) ctx.immediateClose();
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<TooltipPortal :to="to">
|
||||
<RekaContent
|
||||
:ref="forwardRef"
|
||||
v-bind="$attrs"
|
||||
:as="as"
|
||||
:side="position.side"
|
||||
:align="position.align"
|
||||
:side-offset="offset ?? (showArrow ? 7 : 3)"
|
||||
:align-offset="crossOffset"
|
||||
:side-flip="shouldFlip"
|
||||
:collision-padding="containerPadding"
|
||||
:lang="($attrs.lang as string | undefined) ?? config?.locale.value"
|
||||
class="hv-tooltip"
|
||||
data-slot="tooltip-content"
|
||||
:data-entering="(entering && !skip) || undefined"
|
||||
:data-exiting="(exiting && !skip) || undefined"
|
||||
@animationend="onAnimationEnd"
|
||||
@escape-key-down="escape"
|
||||
@pointer-down-outside="outside"
|
||||
@pointerenter="ctx.cancelClose"
|
||||
>
|
||||
<slot :is-open="ctx.open.value" />
|
||||
</RekaContent>
|
||||
</TooltipPortal>
|
||||
</template>
|
||||
@@ -0,0 +1,60 @@
|
||||
<script setup lang="ts">
|
||||
import { nextTick, onMounted, onBeforeUnmount } from "vue";
|
||||
import {
|
||||
TooltipTrigger as RekaTrigger,
|
||||
injectTooltipRootContext,
|
||||
useForwardExpose,
|
||||
} from "reka-ui";
|
||||
import { useTooltip } from "./context";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
withDefaults(defineProps<{ as?: string; asChild?: boolean }>(), { as: "div" });
|
||||
const ctx = useTooltip(),
|
||||
root = injectTooltipRootContext();
|
||||
const { forwardRef, currentElement } = useForwardExpose();
|
||||
let hoverGeneration = 0;
|
||||
const originalClose = root.onClose;
|
||||
root.onClose = () => {
|
||||
if (!ctx.justOpening.value) originalClose();
|
||||
};
|
||||
const originalEnter = root.onTriggerEnter,
|
||||
originalLeave = root.onTriggerLeave;
|
||||
root.onTriggerEnter = () => {
|
||||
if (ctx.trigger.value === "focus") return;
|
||||
const gen = ++hoverGeneration;
|
||||
ctx.cancelClose();
|
||||
if (currentElement.value) ctx.readTiming(currentElement.value);
|
||||
void nextTick(() => {
|
||||
if (gen === hoverGeneration) originalEnter();
|
||||
});
|
||||
};
|
||||
root.onTriggerLeave = () => {
|
||||
hoverGeneration++;
|
||||
originalLeave();
|
||||
};
|
||||
onMounted(() => {
|
||||
if (currentElement.value) ctx.readTiming(currentElement.value);
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
hoverGeneration++;
|
||||
root.onClose = originalClose;
|
||||
root.onTriggerEnter = originalEnter;
|
||||
root.onTriggerLeave = originalLeave;
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<RekaTrigger
|
||||
:ref="forwardRef"
|
||||
v-bind="$attrs"
|
||||
:as="as"
|
||||
:as-child="asChild"
|
||||
:type="as === 'button' ? 'button' : undefined"
|
||||
:role="as === 'div' && !asChild ? 'button' : undefined"
|
||||
:tabindex="as === 'div' && !asChild ? 0 : undefined"
|
||||
class="hv-tooltip__trigger"
|
||||
data-slot="tooltip-trigger"
|
||||
@blur.capture="ctx.immediateClose"
|
||||
@pointerdown.capture="ctx.immediateClose"
|
||||
>
|
||||
<slot />
|
||||
</RekaTrigger>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
import { inject, type InjectionKey, type ComputedRef, type Ref } from "vue";
|
||||
export interface TooltipContext {
|
||||
open: ComputedRef<boolean>;
|
||||
justOpening: Ref<boolean>;
|
||||
trigger: ComputedRef<"hover" | "focus">;
|
||||
skipAnimation: ComputedRef<boolean>;
|
||||
readTiming: (element: HTMLElement) => void;
|
||||
cancelClose: () => void;
|
||||
immediateClose: () => void;
|
||||
}
|
||||
export const tooltipKey: InjectionKey<TooltipContext> = Symbol("hv-tooltip");
|
||||
export function useTooltip() {
|
||||
const ctx = inject(tooltipKey);
|
||||
if (!ctx) throw new Error("Tooltip parts require Tooltip.");
|
||||
return ctx;
|
||||
}
|
||||
export function cssTime(value: string, fallback: number) {
|
||||
const match = value.trim().match(/^(\d+(?:\.\d+)?)(ms|s)$/);
|
||||
return match ? Number(match[1]) * (match[2] === "s" ? 1000 : 1) : fallback;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/* Adapted from HeroUI ce90ea3 use-overlay-state. Copyright 2025 NextUI Inc.
|
||||
* Licensed under Apache-2.0; see third-party/HEROUI-LICENSE. Vue reactive adaptation. */
|
||||
import {
|
||||
computed,
|
||||
ref,
|
||||
toValue,
|
||||
type ComputedRef,
|
||||
type MaybeRefOrGetter,
|
||||
} from "vue";
|
||||
|
||||
export interface UseOverlayStateOptions {
|
||||
/** Controlled value; pass a ref/getter to keep it reactive. Undefined selects local state. */
|
||||
isOpen?: MaybeRefOrGetter<boolean | undefined>;
|
||||
defaultOpen?: boolean;
|
||||
onOpenChange?: (isOpen: boolean) => void;
|
||||
}
|
||||
|
||||
export interface OverlayState {
|
||||
readonly isOpen: ComputedRef<boolean>;
|
||||
setOpen: (isOpen: boolean) => void;
|
||||
open: () => void;
|
||||
close: () => void;
|
||||
toggle: () => void;
|
||||
}
|
||||
|
||||
/** Vue adaptation of HeroUI ce90ea3 useOverlayState; no DOM or global singleton. */
|
||||
export function useOverlayState(
|
||||
options: UseOverlayStateOptions = {},
|
||||
): OverlayState {
|
||||
const local = ref(options.defaultOpen ?? false);
|
||||
const isOpen = computed(() => toValue(options.isOpen) ?? local.value);
|
||||
|
||||
function setOpen(value: boolean) {
|
||||
if (toValue(options.isOpen) === undefined) local.value = value;
|
||||
options.onOpenChange?.(value);
|
||||
}
|
||||
|
||||
return {
|
||||
isOpen,
|
||||
setOpen,
|
||||
open: () => setOpen(true),
|
||||
close: () => setOpen(false),
|
||||
toggle: () => setOpen(!isOpen.value),
|
||||
};
|
||||
}
|
||||
@@ -383,3 +383,86 @@ export {
|
||||
type DisclosureGroupVariants,
|
||||
type AccordionVariants,
|
||||
} from "@heroui-vue/styles";
|
||||
|
||||
export {
|
||||
useOverlayState,
|
||||
type OverlayState,
|
||||
type UseOverlayStateOptions,
|
||||
} from "./composables/useOverlayState";
|
||||
export { default as ConfigProvider } from "./providers/ConfigProvider.vue";
|
||||
export type { ConfigProviderProps } from "./types";
|
||||
|
||||
export { default as Modal } from "./components/modal/Modal";
|
||||
export type { ModalProps } from "./types";
|
||||
|
||||
export { default as ModalTrigger } from "./components/modal/ModalTrigger.vue";
|
||||
export type { ModalTriggerProps } from "./types";
|
||||
|
||||
export { default as ModalBackdrop } from "./components/modal/ModalBackdrop.vue";
|
||||
export type { ModalBackdropProps } from "./types";
|
||||
|
||||
export { default as ModalContainer } from "./components/modal/ModalContainer.vue";
|
||||
export type { ModalContainerProps } from "./types";
|
||||
|
||||
export { default as ModalDialog } from "./components/modal/ModalDialog.vue";
|
||||
export type { ModalDialogProps } from "./types";
|
||||
|
||||
export { default as ModalHeading } from "./components/modal/ModalHeading.vue";
|
||||
export type { ModalHeadingProps } from "./types";
|
||||
|
||||
export { default as ModalClose } from "./components/modal/ModalClose.vue";
|
||||
export type { ModalCloseProps } from "./types";
|
||||
|
||||
export { default as ModalCloseTrigger } from "./components/modal/ModalCloseTrigger";
|
||||
export type { ModalCloseTriggerProps } from "./types";
|
||||
|
||||
export { default as ModalHeader } from "./components/modal/ModalHeader.vue";
|
||||
export type { ModalHeaderProps } from "./types";
|
||||
|
||||
export { default as ModalFooter } from "./components/modal/ModalFooter.vue";
|
||||
export type { ModalFooterProps } from "./types";
|
||||
|
||||
export { default as ModalIcon } from "./components/modal/ModalIcon.vue";
|
||||
export type { ModalIconProps } from "./types";
|
||||
|
||||
export { default as ModalBody } from "./components/modal/ModalBody.vue";
|
||||
export type { ModalBodyProps } from "./types";
|
||||
|
||||
export { modalVariants, type ModalVariants } from "@heroui-vue/styles";
|
||||
export type { ModalPlacement } from "./components/modal/context";
|
||||
|
||||
export { default as Popover } from "./components/popover/Popover";
|
||||
export type { PopoverProps } from "./types";
|
||||
|
||||
export { default as PopoverTrigger } from "./components/popover/PopoverTrigger.vue";
|
||||
export type { PopoverTriggerProps } from "./types";
|
||||
|
||||
export { default as PopoverContent } from "./components/popover/PopoverContent.vue";
|
||||
export type { PopoverContentProps } from "./types";
|
||||
|
||||
export { default as PopoverDialog } from "./components/popover/PopoverDialog.vue";
|
||||
export type { PopoverDialogProps } from "./types";
|
||||
|
||||
export { default as PopoverHeading } from "./components/popover/PopoverHeading.vue";
|
||||
export type { PopoverHeadingProps } from "./types";
|
||||
|
||||
export { default as PopoverArrow } from "./components/popover/PopoverArrow.vue";
|
||||
export type { PopoverArrowProps } from "./types";
|
||||
|
||||
export { popoverVariants, type PopoverVariants } from "@heroui-vue/styles";
|
||||
|
||||
export { default as Tooltip } from "./components/tooltip/Tooltip";
|
||||
export type { TooltipProps } from "./types";
|
||||
|
||||
export { default as TooltipTrigger } from "./components/tooltip/TooltipTrigger.vue";
|
||||
export type { TooltipTriggerProps } from "./types";
|
||||
|
||||
export { default as TooltipContent } from "./components/tooltip/TooltipContent.vue";
|
||||
export type { TooltipContentProps } from "./types";
|
||||
|
||||
export { default as TooltipArrow } from "./components/tooltip/TooltipArrow.vue";
|
||||
export type { TooltipArrowProps } from "./types";
|
||||
|
||||
export { tooltipVariants, type TooltipVariants } from "@heroui-vue/styles";
|
||||
|
||||
export type { OverlayPlacement } from "./components/overlay/placement";
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import { ConfigProvider as RekaConfigProvider, TooltipProvider } from "reka-ui";
|
||||
import { computed, provide } from "vue";
|
||||
import { configContextKey } from "./context";
|
||||
|
||||
defineOptions({ inheritAttrs: false });
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
dir?: "ltr" | "rtl";
|
||||
locale?: string;
|
||||
teleportTo?: string | HTMLElement;
|
||||
}>(),
|
||||
{ dir: "ltr", locale: "en-US" },
|
||||
);
|
||||
provide(configContextKey, {
|
||||
dir: computed(() => props.dir),
|
||||
locale: computed(() => props.locale),
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RekaConfigProvider :dir="dir" :locale="locale" :teleport-to="teleportTo">
|
||||
<TooltipProvider><slot /></TooltipProvider>
|
||||
</RekaConfigProvider>
|
||||
</template>
|
||||
@@ -0,0 +1,11 @@
|
||||
import { inject, type ComputedRef, type InjectionKey } from "vue";
|
||||
|
||||
export interface ConfigContext {
|
||||
dir: ComputedRef<"ltr" | "rtl">;
|
||||
locale: ComputedRef<string>;
|
||||
}
|
||||
export const configContextKey: InjectionKey<ConfigContext> =
|
||||
Symbol("hv-config");
|
||||
export function useConfig() {
|
||||
return inject(configContextKey, undefined);
|
||||
}
|
||||
@@ -277,3 +277,74 @@ export type AccordionBodyProps = InstanceType<typeof AccordionBody>["$props"];
|
||||
export type AccordionIndicatorProps = InstanceType<
|
||||
typeof AccordionIndicator
|
||||
>["$props"];
|
||||
|
||||
import type ConfigProvider from "./providers/ConfigProvider.vue";
|
||||
export type ConfigProviderProps = InstanceType<typeof ConfigProvider>["$props"];
|
||||
|
||||
import type Modal from "./components/modal/Modal";
|
||||
export type ModalProps = InstanceType<typeof Modal>["$props"];
|
||||
|
||||
import type ModalTrigger from "./components/modal/ModalTrigger.vue";
|
||||
export type ModalTriggerProps = InstanceType<typeof ModalTrigger>["$props"];
|
||||
|
||||
import type ModalBackdrop from "./components/modal/ModalBackdrop.vue";
|
||||
export type ModalBackdropProps = InstanceType<typeof ModalBackdrop>["$props"];
|
||||
|
||||
import type ModalContainer from "./components/modal/ModalContainer.vue";
|
||||
export type ModalContainerProps = InstanceType<typeof ModalContainer>["$props"];
|
||||
|
||||
import type ModalDialog from "./components/modal/ModalDialog.vue";
|
||||
export type ModalDialogProps = InstanceType<typeof ModalDialog>["$props"];
|
||||
|
||||
import type ModalHeading from "./components/modal/ModalHeading.vue";
|
||||
export type ModalHeadingProps = InstanceType<typeof ModalHeading>["$props"];
|
||||
|
||||
import type ModalClose from "./components/modal/ModalClose.vue";
|
||||
export type ModalCloseProps = InstanceType<typeof ModalClose>["$props"];
|
||||
|
||||
import type ModalCloseTrigger from "./components/modal/ModalCloseTrigger";
|
||||
export type ModalCloseTriggerProps = InstanceType<
|
||||
typeof ModalCloseTrigger
|
||||
>["$props"];
|
||||
|
||||
import type ModalHeader from "./components/modal/ModalHeader.vue";
|
||||
export type ModalHeaderProps = InstanceType<typeof ModalHeader>["$props"];
|
||||
|
||||
import type ModalFooter from "./components/modal/ModalFooter.vue";
|
||||
export type ModalFooterProps = InstanceType<typeof ModalFooter>["$props"];
|
||||
|
||||
import type ModalIcon from "./components/modal/ModalIcon.vue";
|
||||
export type ModalIconProps = InstanceType<typeof ModalIcon>["$props"];
|
||||
|
||||
import type ModalBody from "./components/modal/ModalBody.vue";
|
||||
export type ModalBodyProps = InstanceType<typeof ModalBody>["$props"];
|
||||
|
||||
import type Popover from "./components/popover/Popover";
|
||||
export type PopoverProps = InstanceType<typeof Popover>["$props"];
|
||||
|
||||
import type PopoverTrigger from "./components/popover/PopoverTrigger.vue";
|
||||
export type PopoverTriggerProps = InstanceType<typeof PopoverTrigger>["$props"];
|
||||
|
||||
import type PopoverContent from "./components/popover/PopoverContent.vue";
|
||||
export type PopoverContentProps = InstanceType<typeof PopoverContent>["$props"];
|
||||
|
||||
import type PopoverDialog from "./components/popover/PopoverDialog.vue";
|
||||
export type PopoverDialogProps = InstanceType<typeof PopoverDialog>["$props"];
|
||||
|
||||
import type PopoverHeading from "./components/popover/PopoverHeading.vue";
|
||||
export type PopoverHeadingProps = InstanceType<typeof PopoverHeading>["$props"];
|
||||
|
||||
import type PopoverArrow from "./components/popover/PopoverArrow.vue";
|
||||
export type PopoverArrowProps = InstanceType<typeof PopoverArrow>["$props"];
|
||||
|
||||
import type Tooltip from "./components/tooltip/Tooltip";
|
||||
export type TooltipProps = InstanceType<typeof Tooltip>["$props"];
|
||||
|
||||
import type TooltipTrigger from "./components/tooltip/TooltipTrigger.vue";
|
||||
export type TooltipTriggerProps = InstanceType<typeof TooltipTrigger>["$props"];
|
||||
|
||||
import type TooltipContent from "./components/tooltip/TooltipContent.vue";
|
||||
export type TooltipContentProps = InstanceType<typeof TooltipContent>["$props"];
|
||||
|
||||
import type TooltipArrow from "./components/tooltip/TooltipArrow.vue";
|
||||
export type TooltipArrowProps = InstanceType<typeof TooltipArrow>["$props"];
|
||||
|
||||
Generated
+8
@@ -97,6 +97,9 @@ importers:
|
||||
tailwind-variants:
|
||||
specifier: ^3.1.0
|
||||
version: 3.3.1(tailwindcss@4.3.3)
|
||||
tw-animate-css:
|
||||
specifier: 1.4.0
|
||||
version: 1.4.0
|
||||
devDependencies:
|
||||
'@tailwindcss/vite':
|
||||
specifier: ^4.1.0
|
||||
@@ -1911,6 +1914,9 @@ packages:
|
||||
tslib@2.8.1:
|
||||
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
|
||||
|
||||
tw-animate-css@1.4.0:
|
||||
resolution: {integrity: sha512-7bziOlRqH0hJx80h/3mbicLW7o8qLsH5+RaLR2t+OHM3D0JlWGODQKQ4cxbK7WlvmUxpcj6Kgu6EKqjrGFe3QQ==}
|
||||
|
||||
typescript@5.9.3:
|
||||
resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==}
|
||||
engines: {node: '>=14.17'}
|
||||
@@ -3805,6 +3811,8 @@ snapshots:
|
||||
|
||||
tslib@2.8.1: {}
|
||||
|
||||
tw-animate-css@1.4.0: {}
|
||||
|
||||
typescript@5.9.3: {}
|
||||
|
||||
ufo@1.6.4: {}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Modal,
|
||||
ModalTrigger,
|
||||
ModalBackdrop,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalCloseTrigger,
|
||||
ModalHeader,
|
||||
ModalHeading,
|
||||
ModalBody,
|
||||
ModalFooter,
|
||||
ModalClose,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Modal>
|
||||
<ModalTrigger as-child><Button>Open Modal</Button></ModalTrigger>
|
||||
<ModalBackdrop>
|
||||
<ModalContainer>
|
||||
<ModalDialog>
|
||||
<ModalCloseTrigger />
|
||||
<ModalHeader><ModalHeading>标题</ModalHeading></ModalHeader>
|
||||
<ModalBody>内容</ModalBody>
|
||||
<ModalFooter>
|
||||
<ModalClose as-child><Button>关闭</Button></ModalClose>
|
||||
</ModalFooter>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</template>
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Popover,
|
||||
PopoverTrigger,
|
||||
PopoverContent,
|
||||
PopoverArrow,
|
||||
PopoverDialog,
|
||||
PopoverHeading,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
</script>
|
||||
<template>
|
||||
<Popover>
|
||||
<PopoverTrigger as-child><Button>点击我</Button></PopoverTrigger>
|
||||
<PopoverContent>
|
||||
<PopoverArrow />
|
||||
<PopoverDialog>
|
||||
<PopoverHeading>标题</PopoverHeading>
|
||||
内容
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</template>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user