fix: disable link navigation and align breadcrumb actions and date focus
This commit is contained in:
@@ -127,19 +127,33 @@ Breadcrumbs 组件使用以下 CSS 类([查看源码样式](https://github.com
|
|||||||
|
|
||||||
### Breadcrumbs
|
### Breadcrumbs
|
||||||
|
|
||||||
| 属性 | 类型 | 默认值 | 描述 |
|
| 属性 | 类型 | 默认值 | 描述 |
|
||||||
| ------------ | --------------------------- | --------------- | ------------------------------------------------ |
|
| ------------ | --------------------------- | ------------------------ | ------------------------------------------------ |
|
||||||
| `aria-label` | `string` | `'Breadcrumbs'` | 面包屑列表的可访问名称。 |
|
| `aria-label` | `string` | 随 ConfigProvider locale | 面包屑列表的可访问名称,显式值优先。 |
|
||||||
| `isDisabled` | `boolean` | `false` | 是否禁用所有面包屑链接。 |
|
| `isDisabled` | `boolean` | `false` | 是否禁用所有面包屑链接。 |
|
||||||
| `as` | `string` | `'ol'` | 自定义根元素标签;对应上游 `render` 的元素替换。 |
|
| `as` | `string` | `'ol'` | 自定义根元素标签;对应上游 `render` 的元素替换。 |
|
||||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定)。 |
|
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定)。 |
|
||||||
| 默认插槽 | - | - | `BreadcrumbsItem` 列表。 |
|
| 默认插槽 | - | - | `BreadcrumbsItem` 列表。 |
|
||||||
| `#separator` | - | 默认右箭头图标 | 自定义各项之间的分隔符。 |
|
| `#separator` | - | 默认右箭头图标 | 自定义各项之间的分隔符。 |
|
||||||
|
|
||||||
根元素同时接收其余 `$attrs`(`data-*`、`id`、`style`、事件等);`aria-label` 为空字符串时回退为 `Breadcrumbs`。`isDisabled` 通过既有禁用作用域传给内部 `Link`,不复制禁用逻辑。
|
根元素同时接收其余 `$attrs`(`data-*`、`id`、`style`、事件等);`aria-label` 未传或为空字符串时按当前 `ConfigProvider` locale 本地化(默认 en-US 的 Breadcrumbs、zh-CN 的“导航栏”)。`isDisabled` 通过既有禁用作用域传给内部 `Link`,不复制禁用逻辑。
|
||||||
|
|
||||||
|
### action 事件
|
||||||
|
|
||||||
|
`@action="onAction"` 在非当前、未禁用项被点击或通过 Enter 激活后触发一次。事件参数为项的 `id`(若提供),否则为 Vue `key`,均未提供时使用从 0 开始的位置索引。数字 `0`、字符串 `"0"` 与空字符串分别保留,不做真值回退。调用方 `@click.prevent` 或 `stopImmediatePropagation()` 可以取消该 action;事件本身不替代 href 的浏览器导航。
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<Breadcrumbs @action="(key) => console.log(key)">
|
||||||
|
<BreadcrumbsItem :id="0">首页</BreadcrumbsItem>
|
||||||
|
<BreadcrumbsItem id="">产品</BreadcrumbsItem>
|
||||||
|
<BreadcrumbsItem>当前页</BreadcrumbsItem>
|
||||||
|
</Breadcrumbs>
|
||||||
|
```
|
||||||
|
|
||||||
### BreadcrumbsItem
|
### BreadcrumbsItem
|
||||||
|
|
||||||
|
`id?: string | number` 指定 action 身份,同时透传为 li 的 DOM id;请保持 DOM id 唯一。未传时从 Vue key(或位置索引)取得事件身份。
|
||||||
|
|
||||||
| 属性 | 类型 | 默认值 | 描述 |
|
| 属性 | 类型 | 默认值 | 描述 |
|
||||||
| ------------ | --------------------------- | ------- | -------------------------------------------------------------------------------- |
|
| ------------ | --------------------------- | ------- | -------------------------------------------------------------------------------- |
|
||||||
| `href` | `string` | - | 链接 URL;未提供时渲染不可导航的 `span[role="link"]`,当前项与禁用项也不可导航。 |
|
| `href` | `string` | - | 链接 URL;未提供时渲染不可导航的 `span[role="link"]`,当前项与禁用项也不可导航。 |
|
||||||
@@ -151,22 +165,22 @@ Breadcrumbs 组件使用以下 CSS 类([查看源码样式](https://github.com
|
|||||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类;同时合并到 `li` 与内部链接。 |
|
| `class` | `string \| Array \| Object` | - | 附加 CSS 类;同时合并到 `li` 与内部链接。 |
|
||||||
| 默认插槽 | `{ isCurrent, isDisabled }` | - | 项内容;可用作用域状态渲染条件内容。 |
|
| 默认插槽 | `{ isCurrent, isDisabled }` | - | 项内容;可用作用域状态渲染条件内容。 |
|
||||||
|
|
||||||
`li` 根节点接收除事件处理器外的 `$attrs`;`onClick`、`onKeydown`、`onFocus` 等事件绑定到真实链接,从而复用 `Link` 的禁用拦截与事件顺序。`isLast` 和 `separatorSlot` 由 `Breadcrumbs` 自动注入,不列入公开 `BreadcrumbsItemProps` 类型或 API 表,调用方无需设置。
|
`li` 根节点接收除事件处理器外的 `$attrs`;`onClick`、`onKeydown`、`onFocus` 等事件绑定到真实链接,从而复用 `Link` 的禁用拦截与事件顺序。`isLast`、`separatorSlot` 和 `itemKey` 由 `Breadcrumbs` 自动注入,不列入公开 `BreadcrumbsItemProps` 类型或 API 表,调用方无需设置。
|
||||||
|
|
||||||
### 上游差异
|
### 上游差异
|
||||||
|
|
||||||
| 上游 React 能力 | Vue 实现 |
|
| 上游 React 能力 | Vue 实现 |
|
||||||
| ----------------------------- | ------------------------------------------ |
|
| ----------------------------- | --------------------------------------------- |
|
||||||
| `Breadcrumbs.Item` 对象子部件 | 独立具名导出 `BreadcrumbsItem` |
|
| `Breadcrumbs.Item` 对象子部件 | 独立具名导出 `BreadcrumbsItem` |
|
||||||
| `separator: ReactNode` | `#separator` 插槽,默认图标从基线 SVG 移植 |
|
| `separator: ReactNode` | `#separator` 插槽,默认图标从基线 SVG 移植 |
|
||||||
| `render` 函数 | `as` 更换元素,属性直接透传 |
|
| `render` 函数 | `as` 更换元素,属性直接透传 |
|
||||||
| `className` / `children` | `class` / 默认插槽 |
|
| `className` / `children` | `class` / 默认插槽 |
|
||||||
| `onAction` | 未提供;使用链接原生行为或 `@click` |
|
| `onAction` | `@action(key)`,取消的点击与禁用/当前项不触发 |
|
||||||
|
|
||||||
## 无障碍
|
## 无障碍
|
||||||
|
|
||||||
- 根元素是 `ol`,默认带 `aria-label="Breadcrumbs"`。固定基线的 React Aria Components `Breadcrumbs` 实际渲染 `ol` 而不是 `nav`;中文文档中的“导航地标”描述与源码 DOM 不完全一致,本实现以固定提交源码为准。需要独立导航地标时,可由应用在外层使用 `<nav>`。
|
- 根元素是 `ol`,默认带 `aria-label="Breadcrumbs"`。固定基线的 React Aria Components `Breadcrumbs` 实际渲染 `ol` 而不是 `nav`;中文文档中的“导航地标”描述与源码 DOM 不完全一致,本实现以固定提交源码为准。需要独立导航地标时,可由应用在外层使用 `<nav>`。
|
||||||
- 默认名称是英文常量,不随 locale 自动本地化;需要本地化时显式传入 `aria-label`。
|
- 默认名称随 ConfigProvider locale 动态更新;显式 `aria-label` 优先,未收录的语言回退英文。
|
||||||
- 最后一项自动附加 `aria-current="page"`,并以 `role="link"`、`aria-disabled="true"`、`tabindex="-1"` 的 `span` 呈现,不可 Tab 聚焦或激活。
|
- 最后一项自动附加 `aria-current="page"`,并以 `role="link"`、`aria-disabled="true"`、`tabindex="-1"` 的 `span` 呈现,不可 Tab 聚焦或激活。
|
||||||
- 带 `href` 的可导航非当前项使用原生 `a`,支持标准 Tab、Enter 与浏览器链接行为;未提供 `href` 的非当前项、禁用的非当前项与当前项均以 `span[role="link"]` 呈现。禁用/当前项带 `aria-disabled="true"`、`tabindex="-1"`,不保留 `href`,点击被拦截;未禁用的无 `href` 项保留 `tabindex="0"`。RAC 的禁用 span 省略 `tabindex`,Vue Link 保留 `-1` 供程序化聚焦,两者都不能通过 Tab 聚焦。
|
- 带 `href` 的可导航非当前项使用原生 `a`,支持标准 Tab、Enter 与浏览器链接行为;未提供 `href` 的非当前项、禁用的非当前项与当前项均以 `span[role="link"]` 呈现。禁用/当前项带 `aria-disabled="true"`、`tabindex="-1"`,不保留 `href`,点击被拦截;未禁用的无 `href` 项保留 `tabindex="0"`。RAC 的禁用 span 省略 `tabindex`,Vue Link 保留 `-1` 供程序化聚焦,两者都不能通过 Tab 聚焦。
|
||||||
- 分隔符默认标记为 `aria-hidden="true"` 与 `role="presentation"`,不进入可访问名称。
|
- 分隔符默认标记为 `aria-hidden="true"` 与 `role="presentation"`,不进入可访问名称。
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ DatePicker 支持与真实 Vue/Reka 状态同步的 data 属性与伪状态:
|
|||||||
|
|
||||||
- **Open**:触发器上 `[data-open="true"]`
|
- **Open**:触发器上 `[data-open="true"]`
|
||||||
- **Disabled**:触发器上 `[data-disabled="true"]` 或 `[aria-disabled="true"]`
|
- **Disabled**:触发器上 `[data-disabled="true"]` 或 `[aria-disabled="true"]`
|
||||||
- **Focus visible**:触发器上 `:focus-visible` 或 `[data-focus-visible="true"]`。当前 `data-focus-visible` 在任何聚焦时置位(含鼠标点击聚焦),与键盘专属焦点环语义不完全一致;修复列入 HD 队列(HD-06-LINK-FOCUS)
|
- **Focus visible**:触发器上 `:focus-visible` 或 `[data-focus-visible="true"]`。聚焦时按真实 DOM 的 `:focus-visible` 判定,鼠标与键盘路径区分;关闭弹层恢复焦点时同样遵循浏览器判定
|
||||||
- **Hover**:触发器上 `:hover`
|
- **Hover**:触发器上 `:hover`
|
||||||
- **Invalid**:根容器上 `[data-invalid="true"]` 或 `[aria-invalid="true"]`
|
- **Invalid**:根容器上 `[data-invalid="true"]` 或 `[aria-invalid="true"]`
|
||||||
- **Read only**:根容器上 `[data-readonly="true"]`
|
- **Read only**:根容器上 `[data-readonly="true"]`
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ DateRangePicker 支持与真实 Vue/Reka 状态同步的 data 属性与伪状态
|
|||||||
|
|
||||||
- **Open**:触发器上 `[data-open="true"]`
|
- **Open**:触发器上 `[data-open="true"]`
|
||||||
- **Disabled**:触发器上 `[data-disabled="true"]` 或 `[aria-disabled="true"]`
|
- **Disabled**:触发器上 `[data-disabled="true"]` 或 `[aria-disabled="true"]`
|
||||||
- **Focus visible**:触发器上 `:focus-visible` 或 `[data-focus-visible="true"]`。当前 `data-focus-visible` 在任何聚焦时置位(含鼠标点击聚焦),与键盘专属焦点环语义不完全一致;修复列入 HD 队列(HD-06-LINK-FOCUS)
|
- **Focus visible**:触发器上 `:focus-visible` 或 `[data-focus-visible="true"]`。聚焦时按真实 DOM 的 `:focus-visible` 判定,鼠标与键盘路径区分;关闭弹层恢复焦点时同样遵循浏览器判定
|
||||||
- **Hover**:触发器上 `:hover`
|
- **Hover**:触发器上 `:hover`
|
||||||
- **Invalid**:根容器上 `[data-invalid="true"]` 或 `[aria-invalid="true"]`
|
- **Invalid**:根容器上 `[data-invalid="true"]` 或 `[aria-invalid="true"]`
|
||||||
- **Read only**:根容器上 `[data-readonly="true"]`
|
- **Read only**:根容器上 `[data-readonly="true"]`
|
||||||
|
|||||||
@@ -132,14 +132,14 @@ Link 使用以下 CSS 类:
|
|||||||
| `target` | `string` | — | 在何处打开链接文档;省略时使用浏览器同窗口默认行为,不输出 target 属性 |
|
| `target` | `string` | — | 在何处打开链接文档;省略时使用浏览器同窗口默认行为,不输出 target 属性 |
|
||||||
| `rel` | `string` | - | 当前文档与链接文档的关系 |
|
| `rel` | `string` | - | 当前文档与链接文档的关系 |
|
||||||
| `download` | `boolean \| string` | - | 触发下载而非导航;`true` 渲染 `download`,`false`/未传省略属性 |
|
| `download` | `boolean \| string` | - | 触发下载而非导航;`true` 渲染 `download`,`false`/未传省略属性 |
|
||||||
| `isDisabled` | `boolean` | `false` | 禁用指针与键盘交互;保留可聚焦与 `aria-disabled` |
|
| `isDisabled` | `boolean` | `false` | 禁用激活,移除导航/下载属性;保留 `aria-disabled` 与程序化聚焦 |
|
||||||
| `asChild` | `boolean` | `false` | 合并到默认插槽唯一元素,并补充 `role="link"` 与 `tabindex="0"` |
|
| `asChild` | `boolean` | `false` | 合并到默认插槽唯一元素,并补充 `role="link"` 与 `tabindex="0"` |
|
||||||
| `autoFocus` | `boolean` | - | 挂载后聚焦真实 DOM 根元素(含 asChild) |
|
| `autoFocus` | `boolean` | - | 挂载后聚焦真实 DOM 根元素(含 asChild) |
|
||||||
| `class` | `string` | - | 与默认样式合并的自定义类 |
|
| `class` | `string` | - | 与默认样式合并的自定义类 |
|
||||||
|
|
||||||
默认插槽渲染链接内部内容。作用域插槽提供 `isDisabled`、`isHovered`、`isPressed`、`isFocused`、`isFocusVisible`。`@click` 等 DOM 事件通过 attrs 透传;`isDisabled` 时阻止激活(含 Vue 合并后的监听器数组)。React Aria 的 `onPress` / `PressEvent` 由原生 `click` 适配,不等价。
|
默认插槽渲染链接内部内容。作用域插槽提供 `isDisabled`、`isHovered`、`isPressed`、`isFocused`、`isFocusVisible`。`@click` 等 DOM 事件通过 attrs 透传;`isDisabled` 时阻止激活(含 Vue 合并后的监听器数组)。React Aria 的 `onPress` / `PressEvent` 由原生 `click` 适配,不等价。
|
||||||
|
|
||||||
`asChild` 适用于 `<a>`、`RouterLink` 等已具备导航能力的元素,以及需要自定义外观的 `span`/`div`:非原生可激活元素会获得 `role="link"`、`tabindex="0"`,Enter 触发一次激活(与点击同一 `click` 路径)。自定义元素上的 `href` 不会由浏览器直接导航,请用 `a` / 路由组件作为 asChild 目标,或在 `@click` 中自行处理跳转。禁用时仍可聚焦以便读出 `aria-disabled`,但不会激活。
|
`asChild` 适用于 `<a>`、`RouterLink` 等已具备导航能力的元素,以及需要自定义外观的 `span`/`div`:非原生可激活元素会获得 `role="link"`、`tabindex="0"`,Enter 触发一次激活(与点击同一 `click` 路径)。自定义元素上的 `href` 不会由浏览器直接导航,请用 `a` / 路由组件作为 asChild 目标,或在 `@click` 中自行处理跳转。禁用时移除根元素的 `href`、`target`、`download`,包括 asChild 子元素自带的对应属性;`tabindex="-1"` 排除 Tab 顺序,仍可通过暴露的 `focus()` 程序化聚焦。重新启用后恢复属性,保留用户处理器和子元素 ref。自定义路由组件应把合并后的属性透传到真实根元素,不应自行覆盖禁用态的导航属性。
|
||||||
|
|
||||||
### LinkIcon
|
### LinkIcon
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,13 @@ import { defineAsyncComponent } from "vue";
|
|||||||
|
|
||||||
// Keep regression URLs stable; load only the selected harness.
|
// Keep regression URLs stable; load only the selected harness.
|
||||||
const labs = [
|
const labs = [
|
||||||
|
{
|
||||||
|
key: "link-focus",
|
||||||
|
title: "链接与日期焦点",
|
||||||
|
component: defineAsyncComponent(
|
||||||
|
() => import("../../../tests/fixtures/link-focus.vue"),
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "button-group-dropdown",
|
key: "button-group-dropdown",
|
||||||
title: "按钮组与下拉根属性",
|
title: "按钮组与下拉根属性",
|
||||||
|
|||||||
@@ -294,3 +294,8 @@ HD-01(2026-10-28):按钮/切换组与导航示例已恢复固定cn基线
|
|||||||
## HD-05 styles 导出与全局边框回退(2026-10-28)
|
## HD-05 styles 导出与全局边框回退(2026-10-28)
|
||||||
|
|
||||||
`@heroui-vue/styles` 增量补齐固定源缺失的 5 个 tv 映射与类型:`labelVariants`/`descriptionVariants`/`fieldErrorVariants`/`textFieldVariants`/`switchGroupVariants`(hv- 命名空间,变体集合与默认值与 `heroui/packages/styles/src/components/{label,description,field-error,textfield,switch-group}/*.styles.ts` 逐键一致),`@heroui-vue/components` 再导出同一组函数与 `*Variants` 类型。Label/Description/FieldError/useTextField/SwitchGroup 改为消费同一映射,状态类只保留一处来源,渲染类输出不变(tests/shared-field-styles.test.ts 钉住映射输出与组件输出一致)。恢复 `base` 层全局边框色回退 `border-color: var(--border, currentColor)`(与固定源 base/base.css 同选择器、同层序:preflight 之后);独立 tarball 消费者真实浏览器验证浅/深 `--border`、显式边框色(含字段透明边框)、调用方普通 CSS 覆盖(含与库同选择器的注入规则)与 `--border` 缺失时的 currentColor 回退,CSSOM 确认规则位于 base 层且无 `!important`。`view-transition-name`/`::view-transition` 两条上游全局规则经核查无使用证据(库与文档站均未使用 View Transitions API),不迁移、不建专项。chip `size:"md"`、kbd `variant:"default"` 等效默认类、reduced-motion、Spinner 定尺、Table th 行头、定位补偿与 HD-01~HD-04 成果均未改动。见 [任务结果](tasks/results/HD-05-STYLES.md)。
|
`@heroui-vue/styles` 增量补齐固定源缺失的 5 个 tv 映射与类型:`labelVariants`/`descriptionVariants`/`fieldErrorVariants`/`textFieldVariants`/`switchGroupVariants`(hv- 命名空间,变体集合与默认值与 `heroui/packages/styles/src/components/{label,description,field-error,textfield,switch-group}/*.styles.ts` 逐键一致),`@heroui-vue/components` 再导出同一组函数与 `*Variants` 类型。Label/Description/FieldError/useTextField/SwitchGroup 改为消费同一映射,状态类只保留一处来源,渲染类输出不变(tests/shared-field-styles.test.ts 钉住映射输出与组件输出一致)。恢复 `base` 层全局边框色回退 `border-color: var(--border, currentColor)`(与固定源 base/base.css 同选择器、同层序:preflight 之后);独立 tarball 消费者真实浏览器验证浅/深 `--border`、显式边框色(含字段透明边框)、调用方普通 CSS 覆盖(含与库同选择器的注入规则)与 `--border` 缺失时的 currentColor 回退,CSSOM 确认规则位于 base 层且无 `!important`。`view-transition-name`/`::view-transition` 两条上游全局规则经核查无使用证据(库与文档站均未使用 View Transitions API),不迁移、不建专项。chip `size:"md"`、kbd `variant:"default"` 等效默认类、reduced-motion、Spinner 定尺、Table th 行头、定位补偿与 HD-01~HD-04 成果均未改动。见 [任务结果](tasks/results/HD-05-STYLES.md)。
|
||||||
|
|
||||||
|
|
||||||
|
## HD-06 链接与日期焦点(2026-10-29)
|
||||||
|
|
||||||
|
禁用 Link 移除 href/target/download,包括 asChild 子节点的导航属性,保持 aria-disabled、tabindex=-1 与暴露的 focus;启用恢复,用户事件取消和子 ref 保留。Breadcrumbs 当前/禁用项原已用 span,不重复改写;新增按 ConfigProvider locale 的默认名称及 @action(key),保持 id/key 的数字0与空串身份,取消的激活不通知 action。两个日期触发器按实际 :focus-visible 更新状态标记,鼠标/Tab/关闭恢复由浏览器判定。证据见 [HD-06结果](tasks/results/HD-06-LINK-FOCUS.md)。
|
||||||
|
|||||||
@@ -27,3 +27,5 @@
|
|||||||
- [结果](results/HD-05-STYLES.md)逐条核销:范围1 styles入口增量补 labelVariants/descriptionVariants/fieldErrorVariants/textFieldVariants/switchGroupVariants 五映射与类型(变体/默认值/slot 与固定源逐键一致),Label/Description/FieldError/useTextField/SwitchGroup 改为消费同一映射(类输出不变,映射↔组件一致性单测钉住);范围2 恢复 base 层全局 border-color: var(--border, currentColor) 回退(与固定源同层同序),独立 tarball 消费者真实浏览器验证浅/深、默认边框、显式色(含字段透明边框)、调用方普通/同选择器覆盖、--border 缺失 currentColor 回退,CSSOM 证 base 层无 !important;范围3 view-transition 两规则核查无使用证据,记录无需修改不建专项;范围4 chip/kbd/reduced-motion/Spinner/Table th/定位补偿与 HD-01~HD-04 成果零改动(未恢复日期弹层 w-full 强制规则)。全量111文件1634项、typecheck、build:docs、shared-styles/api-root-aliases/handbook-styles 最终tarball(运行时+类型两种解析)通过;任务卡 checks 重复项已清理并补实际检查。
|
- [结果](results/HD-05-STYLES.md)逐条核销:范围1 styles入口增量补 labelVariants/descriptionVariants/fieldErrorVariants/textFieldVariants/switchGroupVariants 五映射与类型(变体/默认值/slot 与固定源逐键一致),Label/Description/FieldError/useTextField/SwitchGroup 改为消费同一映射(类输出不变,映射↔组件一致性单测钉住);范围2 恢复 base 层全局 border-color: var(--border, currentColor) 回退(与固定源同层同序),独立 tarball 消费者真实浏览器验证浅/深、默认边框、显式色(含字段透明边框)、调用方普通/同选择器覆盖、--border 缺失 currentColor 回退,CSSOM 证 base 层无 !important;范围3 view-transition 两规则核查无使用证据,记录无需修改不建专项;范围4 chip/kbd/reduced-motion/Spinner/Table th/定位补偿与 HD-01~HD-04 成果零改动(未恢复日期弹层 w-full 强制规则)。全量111文件1634项、typecheck、build:docs、shared-styles/api-root-aliases/handbook-styles 最终tarball(运行时+类型两种解析)通过;任务卡 checks 重复项已清理并补实际检查。
|
||||||
|
|
||||||
- HD-05 已验收:独立复核0b303476c2d682a47157f345fcc0a5ab0a23aa8d,实施dc859fb无功能阻断,仅纠正结果记录CSS特异性表述。全量111文件1634项、类型、文档构建、shared-styles/api-root-aliases/handbook-styles最终tarball及本轮独立消费者5198浅深/覆盖/回退均通过。按用户授权合入main并push origin/main;工作区释放,下一项HD-06-LINK-FOCUS未启动。停止本轮5198,保留原5173/5174及他人5199服务。
|
- HD-05 已验收:独立复核0b303476c2d682a47157f345fcc0a5ab0a23aa8d,实施dc859fb无功能阻断,仅纠正结果记录CSS特异性表述。全量111文件1634项、类型、文档构建、shared-styles/api-root-aliases/handbook-styles最终tarball及本轮独立消费者5198浅深/覆盖/回退均通过。按用户授权合入main并push origin/main;工作区释放,下一项HD-06-LINK-FOCUS未启动。停止本轮5198,保留原5173/5174及他人5199服务。
|
||||||
|
|
||||||
|
- HD-06-LINK-FOCUS执行中:分支task/hd-06-link-focus,起点680a592e7b95bd52592edc19d1b8654b30b53a1c;本会话亲自实施并按用户授权验收后合并push。范围:Link禁用导航/asChild/ref、日期真实focus-visible、Breadcrumbs locale/action。5173保持,5174原已停止,本轮重新启动用于公开组合浏览器验收。
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!-- task-metadata
|
<!-- task-metadata
|
||||||
{"base":"db5670f4e1efe0e6ef7433002de5fb0a4a284f84","upstream":"ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960","status":"pending","requires":["docs/tasks/HD-QUEUE.md"],"sources":["packages/react/src/components/breadcrumbs/breadcrumbs.tsx"],"checks":["pnpm exec vitest run tests/surface-link-spinner.test.ts tests/date-picker-demos.test.ts tests/date-range-picker-demos.test.ts tests/regressions/navigation-otp/public-contracts.test.ts","pnpm typecheck"]}
|
{"base":"db5670f4e1efe0e6ef7433002de5fb0a4a284f84","upstream":"ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960","status":"implemented","requires":["docs/tasks/HD-QUEUE.md"],"sources":["packages/react/src/components/breadcrumbs/breadcrumbs.tsx"],"checks":["pnpm exec vitest run tests/surface-link-spinner.test.ts tests/typography-empty-breadcrumbs.test.ts tests/date-picker-demos.test.ts tests/date-range-picker-demos.test.ts tests/regressions/navigation-otp/public-contracts.test.ts","pnpm typecheck","node scripts/check-package.mjs link-focus api-root-aliases date-picker date-range-picker"]}
|
||||||
-->
|
-->
|
||||||
# HD-06-LINK-FOCUS:禁用链接与日期键盘焦点
|
# HD-06-LINK-FOCUS:禁用链接与日期键盘焦点
|
||||||
|
|
||||||
@@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
## 执行范围
|
## 执行范围
|
||||||
|
|
||||||
- [ ] 修 Link 禁用后仍保留可导航 href 的问题,覆盖 target/download/asChild 与动态禁用;保持事件取消和 attrs/ref 合并。Breadcrumbs 逐项核对,它内部部分路径已使用 span,不能一概判为同一缺陷。
|
- [x] 修 Link 禁用后仍保留可导航 href 的问题,覆盖 target/download/asChild 与动态禁用;保持事件取消和 attrs/ref 合并。Breadcrumbs 逐项核对,它内部部分路径已使用 span,不能一概判为同一缺陷。
|
||||||
- [ ] DatePickerTrigger/DateRangePickerTrigger 使用真实 focus-visible 判定或共享焦点设施;不能 @focus 无条件置 true。
|
- [x] DatePickerTrigger/DateRangePickerTrigger 使用真实 focus-visible 判定或共享焦点设施;不能 @focus 无条件置 true。
|
||||||
- [ ] 补 Breadcrumbs 当前 locale 的默认可访问名称及 Vue action 事件,保留显式 aria-label 优先级和数字0/空key身份。
|
- [x] 补 Breadcrumbs 当前 locale 的默认可访问名称及 Vue action 事件,保留显式 aria-label 优先级和数字0/空key身份。
|
||||||
|
|
||||||
## 用户可见通过条件
|
## 用户可见通过条件
|
||||||
|
|
||||||
|
|||||||
@@ -361,3 +361,8 @@ Button/ButtonGroup/ToggleButton/ToggleButtonGroup与指定Accordion/Disclosure
|
|||||||
|
|
||||||
- packages/styles/src/index.ts 的 `labelVariants`/`descriptionVariants`/`fieldErrorVariants`/`textFieldVariants`/`switchGroupVariants`:移植 `heroui/packages/styles/src/components/{label/label,description/description,field-error/field-error,textfield/textfield,switch-group/switch-group}.styles.ts`,仅加 `hv-` 前缀;变体键、默认值与 slot 集合逐键保留(Apache-2.0,见 third-party/HEROUI-LICENSE)。
|
- packages/styles/src/index.ts 的 `labelVariants`/`descriptionVariants`/`fieldErrorVariants`/`textFieldVariants`/`switchGroupVariants`:移植 `heroui/packages/styles/src/components/{label/label,description/description,field-error/field-error,textfield/textfield,switch-group/switch-group}.styles.ts`,仅加 `hv-` 前缀;变体键、默认值与 slot 集合逐键保留(Apache-2.0,见 third-party/HEROUI-LICENSE)。
|
||||||
- packages/styles/base/base.css:移植 `heroui/packages/styles/base/base.css` 的边框色继承规则(`*, ::after, ::before, ::backdrop, ::file-selector-button { border-color: var(--border, currentColor) }`),导入序保持 preflight 之后的 base 层。同文件的 `:root { view-transition-name: none }` 与 `::view-transition { pointer-events: none }` 未移植:库与文档站均无 View Transitions API 使用证据,按 HD-05 约定记录无需修改,不建立专项。
|
- packages/styles/base/base.css:移植 `heroui/packages/styles/base/base.css` 的边框色继承规则(`*, ::after, ::before, ::backdrop, ::file-selector-button { border-color: var(--border, currentColor) }`),导入序保持 preflight 之后的 base 层。同文件的 `:root { view-transition-name: none }` 与 `::view-transition { pointer-events: none }` 未移植:库与文档站均无 View Transitions API 使用证据,按 HD-05 约定记录无需修改,不建立专项。
|
||||||
|
|
||||||
|
|
||||||
|
### HD-06(2026-10-29)
|
||||||
|
|
||||||
|
Link/Breadcrumbs 对照固定 ce90ea3;Breadcrumbs 的34种名称移植自该上游锁文件的 react-aria 3.52.1 `dist/private/intl/breadcrumbs`,仅数据,不引入 React 运行时。Adobe Apache-2.0声明保留于第三方许可及组件包 `LICENSE.react-aria`(随 tarball发布)。Vue identity采用 id/key/index,事件为 @action。日期焦点标记适配真实 DOM :focus-visible。
|
||||||
|
|||||||
@@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright 2019 Adobe
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
@@ -4,7 +4,8 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist",
|
||||||
|
"LICENSE.react-aria"
|
||||||
],
|
],
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ import {
|
|||||||
import { breadcrumbsVariants } from "@heroui-vue/styles";
|
import { breadcrumbsVariants } from "@heroui-vue/styles";
|
||||||
import { disabledContextKey, useInheritedDisabled } from "../field/disabled";
|
import { disabledContextKey, useInheritedDisabled } from "../field/disabled";
|
||||||
import BreadcrumbsItem from "./BreadcrumbsItem.vue";
|
import BreadcrumbsItem from "./BreadcrumbsItem.vue";
|
||||||
|
import { useLocale } from "../../providers/context";
|
||||||
|
import { breadcrumbsLabel } from "./locale";
|
||||||
|
import { breadcrumbsActionKey } from "./context";
|
||||||
|
|
||||||
function flattenChildren(
|
function flattenChildren(
|
||||||
nodes: VNodeChild[],
|
nodes: VNodeChild[],
|
||||||
@@ -46,7 +49,7 @@ export default defineComponent({
|
|||||||
props: {
|
props: {
|
||||||
ariaLabel: {
|
ariaLabel: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "Breadcrumbs",
|
default: undefined,
|
||||||
},
|
},
|
||||||
isDisabled: {
|
isDisabled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -58,7 +61,10 @@ export default defineComponent({
|
|||||||
default: "ol",
|
default: "ol",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props, { attrs, slots }) {
|
emits: { action: (_key: string | number) => true },
|
||||||
|
setup(props, { attrs, slots, emit }) {
|
||||||
|
const { locale } = useLocale();
|
||||||
|
provide(breadcrumbsActionKey, (key) => emit("action", key));
|
||||||
const variants = breadcrumbsVariants();
|
const variants = breadcrumbsVariants();
|
||||||
// Merge with ancestor Fieldset/disabled scopes; never shadow parent true.
|
// Merge with ancestor Fieldset/disabled scopes; never shadow parent true.
|
||||||
const disabled = useInheritedDisabled(() => props.isDisabled);
|
const disabled = useInheritedDisabled(() => props.isDisabled);
|
||||||
@@ -73,6 +79,7 @@ export default defineComponent({
|
|||||||
const isLast = ++index === total;
|
const isLast = ++index === total;
|
||||||
return cloneVNode(node, {
|
return cloneVNode(node, {
|
||||||
isLast,
|
isLast,
|
||||||
|
itemKey: node.props?.id ?? node.key ?? index - 1,
|
||||||
separatorSlot: slots.separator,
|
separatorSlot: slots.separator,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -82,7 +89,7 @@ export default defineComponent({
|
|||||||
{
|
{
|
||||||
...attrs,
|
...attrs,
|
||||||
class: [variants.base(), attrs.class],
|
class: [variants.base(), attrs.class],
|
||||||
"aria-label": props.ariaLabel || "Breadcrumbs",
|
"aria-label": props.ariaLabel || breadcrumbsLabel(locale.value),
|
||||||
"data-slot": "breadcrumbs",
|
"data-slot": "breadcrumbs",
|
||||||
},
|
},
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
cloneVNode,
|
cloneVNode,
|
||||||
defineComponent,
|
defineComponent,
|
||||||
h,
|
h,
|
||||||
|
inject,
|
||||||
isVNode,
|
isVNode,
|
||||||
useAttrs,
|
useAttrs,
|
||||||
type PropType,
|
type PropType,
|
||||||
@@ -14,6 +15,7 @@ import {
|
|||||||
import { breadcrumbsVariants } from "@heroui-vue/styles";
|
import { breadcrumbsVariants } from "@heroui-vue/styles";
|
||||||
import { useInheritedDisabled } from "../field/disabled";
|
import { useInheritedDisabled } from "../field/disabled";
|
||||||
import Link from "../link/Link.vue";
|
import Link from "../link/Link.vue";
|
||||||
|
import { breadcrumbsActionKey } from "./context";
|
||||||
import BreadcrumbsSeparatorIcon from "./BreadcrumbsSeparatorIcon.vue";
|
import BreadcrumbsSeparatorIcon from "./BreadcrumbsSeparatorIcon.vue";
|
||||||
|
|
||||||
function flattenChildren(
|
function flattenChildren(
|
||||||
@@ -57,6 +59,10 @@ export default defineComponent({
|
|||||||
name: "BreadcrumbsItem",
|
name: "BreadcrumbsItem",
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
|
id: {
|
||||||
|
type: [String, Number] as PropType<string | number>,
|
||||||
|
default: undefined,
|
||||||
|
},
|
||||||
href: {
|
href: {
|
||||||
type: String,
|
type: String,
|
||||||
default: undefined,
|
default: undefined,
|
||||||
@@ -77,6 +83,11 @@ export default defineComponent({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
/** Identity supplied by the parent from id/key/index. */
|
||||||
|
itemKey: {
|
||||||
|
type: [String, Number] as PropType<string | number>,
|
||||||
|
default: undefined,
|
||||||
|
},
|
||||||
/** Set by Breadcrumbs for the final item. */
|
/** Set by Breadcrumbs for the final item. */
|
||||||
isLast: {
|
isLast: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -94,6 +105,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props, { attrs, slots }) {
|
setup(props, { attrs, slots }) {
|
||||||
|
const action = inject(breadcrumbsActionKey, undefined);
|
||||||
const variants = breadcrumbsVariants();
|
const variants = breadcrumbsVariants();
|
||||||
const disabled = useInheritedDisabled(
|
const disabled = useInheritedDisabled(
|
||||||
() => props.isDisabled || props.isLast,
|
() => props.isDisabled || props.isLast,
|
||||||
@@ -136,6 +148,19 @@ export default defineComponent({
|
|||||||
else rootAttrs[key] = value;
|
else rootAttrs[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onClick = linkAttrs.onClick;
|
||||||
|
linkAttrs.onClick = [
|
||||||
|
...(Array.isArray(onClick) ? onClick : onClick ? [onClick] : []),
|
||||||
|
(event: MouseEvent) => {
|
||||||
|
if (
|
||||||
|
!event.defaultPrevented &&
|
||||||
|
!disabled.value &&
|
||||||
|
props.itemKey !== undefined
|
||||||
|
)
|
||||||
|
action?.(props.itemKey);
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const content =
|
const content =
|
||||||
slots.default?.({
|
slots.default?.({
|
||||||
isCurrent: current,
|
isCurrent: current,
|
||||||
@@ -172,6 +197,7 @@ export default defineComponent({
|
|||||||
props.as,
|
props.as,
|
||||||
{
|
{
|
||||||
...rootAttrs,
|
...rootAttrs,
|
||||||
|
id: props.id == null ? undefined : String(props.id),
|
||||||
class: [variants.item(), callerClass],
|
class: [variants.item(), callerClass],
|
||||||
"data-slot": "breadcrumbs-item",
|
"data-slot": "breadcrumbs-item",
|
||||||
"data-current": current ? "true" : undefined,
|
"data-current": current ? "true" : undefined,
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import type { InjectionKey } from "vue";
|
||||||
|
export const breadcrumbsActionKey: InjectionKey<
|
||||||
|
(key: string | number) => void
|
||||||
|
> = Symbol("breadcrumbs-action");
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// Breadcrumb labels from react-aria 3.52.1 (fixed upstream lockfile).
|
||||||
|
// Copyright Adobe. Apache-2.0; see third-party/REACT-ARIA-LICENSE.
|
||||||
|
const labels: Record<string, string> = {
|
||||||
|
"ar-AE": "عناصر الواجهة",
|
||||||
|
"bg-BG": "Трохи хляб",
|
||||||
|
"cs-CZ": "Popis cesty",
|
||||||
|
"da-DK": "Brødkrummer",
|
||||||
|
"de-DE": "Breadcrumbs",
|
||||||
|
"el-GR": "Πλοηγήσεις breadcrumb",
|
||||||
|
"en-US": "Breadcrumbs",
|
||||||
|
"es-ES": "Migas de pan",
|
||||||
|
"et-EE": "Lingiread",
|
||||||
|
"fi-FI": "Navigointilinkit",
|
||||||
|
"fr-FR": "Chemin de navigation",
|
||||||
|
"he-IL": "שבילי ניווט",
|
||||||
|
"hr-HR": "Navigacijski putovi",
|
||||||
|
"hu-HU": "Morzsamenü",
|
||||||
|
"it-IT": "Breadcrumb",
|
||||||
|
"ja-JP": "パンくずリスト",
|
||||||
|
"ko-KR": "탐색 표시",
|
||||||
|
"lt-LT": "Naršymo kelias",
|
||||||
|
"lv-LV": "Atpakaļceļi",
|
||||||
|
"nb-NO": "Navigasjonsstier",
|
||||||
|
"nl-NL": "Broodkruimels",
|
||||||
|
"pl-PL": "Struktura nawigacyjna",
|
||||||
|
"pt-BR": "Caminho detalhado",
|
||||||
|
"pt-PT": "Categorias",
|
||||||
|
"ro-RO": "Miez de pâine",
|
||||||
|
"ru-RU": "Навигация",
|
||||||
|
"sk-SK": "Navigačné prvky Breadcrumbs",
|
||||||
|
"sl-SI": "Drobtine",
|
||||||
|
"sr-SP": "Putanje navigacije",
|
||||||
|
"sv-SE": "Sökvägar",
|
||||||
|
"tr-TR": "İçerik haritaları",
|
||||||
|
"uk-UA": "Навігаційна стежка",
|
||||||
|
"zh-CN": "导航栏",
|
||||||
|
"zh-TW": "導覽列",
|
||||||
|
};
|
||||||
|
export function breadcrumbsLabel(locale: string): string {
|
||||||
|
try {
|
||||||
|
const requested = new Intl.Locale(locale);
|
||||||
|
if (labels[requested.baseName]) return labels[requested.baseName]!;
|
||||||
|
const expanded = requested.maximize();
|
||||||
|
const candidates = Object.keys(labels).filter(
|
||||||
|
(key) => new Intl.Locale(key).language === requested.language,
|
||||||
|
);
|
||||||
|
const key =
|
||||||
|
candidates.find(
|
||||||
|
(key) => new Intl.Locale(key).maximize().script === expanded.script,
|
||||||
|
) ?? candidates[0];
|
||||||
|
return labels[key ?? "en-US"]!;
|
||||||
|
} catch {
|
||||||
|
return labels["en-US"]!;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -77,7 +77,11 @@ watch(
|
|||||||
:data-open="popover.state.isOpen.value || undefined"
|
:data-open="popover.state.isOpen.value || undefined"
|
||||||
:data-disabled="disabled || undefined"
|
:data-disabled="disabled || undefined"
|
||||||
:data-focus-visible="focusVisible || undefined"
|
:data-focus-visible="focusVisible || undefined"
|
||||||
@focus="focusVisible = true"
|
@focus="
|
||||||
|
focusVisible = ($event.currentTarget as HTMLElement).matches(
|
||||||
|
':focus-visible',
|
||||||
|
)
|
||||||
|
"
|
||||||
@blur="focusVisible = false"
|
@blur="focusVisible = false"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
|
|||||||
@@ -77,7 +77,11 @@ watch(
|
|||||||
:data-open="popover.state.isOpen.value || undefined"
|
:data-open="popover.state.isOpen.value || undefined"
|
||||||
:data-disabled="disabled || undefined"
|
:data-disabled="disabled || undefined"
|
||||||
:data-focus-visible="focusVisible || undefined"
|
:data-focus-visible="focusVisible || undefined"
|
||||||
@focus="focusVisible = true"
|
@focus="
|
||||||
|
focusVisible = ($event.currentTarget as HTMLElement).matches(
|
||||||
|
':focus-visible',
|
||||||
|
)
|
||||||
|
"
|
||||||
@blur="focusVisible = false"
|
@blur="focusVisible = false"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ import {
|
|||||||
onMounted,
|
onMounted,
|
||||||
watch,
|
watch,
|
||||||
onBeforeUnmount,
|
onBeforeUnmount,
|
||||||
|
onUpdated,
|
||||||
} from "vue";
|
} from "vue";
|
||||||
import { Primitive } from "reka-ui";
|
import LinkPrimitive from "./LinkPrimitive";
|
||||||
import { linkVariants } from "@heroui-vue/styles";
|
import { linkVariants } from "@heroui-vue/styles";
|
||||||
import { linkContextKey } from "./context";
|
import { linkContextKey } from "./context";
|
||||||
|
|
||||||
@@ -187,6 +188,7 @@ const passthroughAttrs = computed(() => {
|
|||||||
return rest;
|
return rest;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const onRootAuxClickCapture = (e: Event) => guardClick(e, undefined);
|
||||||
const onRootClickCapture = (e: Event) =>
|
const onRootClickCapture = (e: Event) =>
|
||||||
guardClick(e, liveAttr("onClickCapture"));
|
guardClick(e, liveAttr("onClickCapture"));
|
||||||
const onRootClickBubble = (e: Event) => guardClick(e, liveAttr("onClick"));
|
const onRootClickBubble = (e: Event) => guardClick(e, liveAttr("onClick"));
|
||||||
@@ -200,6 +202,7 @@ let bound: HTMLElement | null = null;
|
|||||||
|
|
||||||
function unbindRoot() {
|
function unbindRoot() {
|
||||||
if (!bound) return;
|
if (!bound) return;
|
||||||
|
bound.removeEventListener("auxclick", onRootAuxClickCapture, true);
|
||||||
bound.removeEventListener("click", onRootClickCapture, true);
|
bound.removeEventListener("click", onRootClickCapture, true);
|
||||||
bound.removeEventListener("click", onRootClickBubble, false);
|
bound.removeEventListener("click", onRootClickBubble, false);
|
||||||
bound.removeEventListener("keydown", onRootKeydownCapture, true);
|
bound.removeEventListener("keydown", onRootKeydownCapture, true);
|
||||||
@@ -212,6 +215,7 @@ function bindRoot(el: HTMLElement) {
|
|||||||
if (bound === el) return;
|
if (bound === el) return;
|
||||||
unbindRoot();
|
unbindRoot();
|
||||||
bound = el;
|
bound = el;
|
||||||
|
el.addEventListener("auxclick", onRootAuxClickCapture, true);
|
||||||
el.addEventListener("click", onRootClickCapture, true);
|
el.addEventListener("click", onRootClickCapture, true);
|
||||||
el.addEventListener("click", onRootClickBubble, false);
|
el.addEventListener("click", onRootClickBubble, false);
|
||||||
el.addEventListener("keydown", onRootKeydownCapture, true);
|
el.addEventListener("keydown", onRootKeydownCapture, true);
|
||||||
@@ -219,13 +223,20 @@ function bindRoot(el: HTMLElement) {
|
|||||||
el.addEventListener("keyup", onRootKeyup, false);
|
el.addEventListener("keyup", onRootKeyup, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let rootInstance: unknown;
|
||||||
function setRoot(raw: unknown) {
|
function setRoot(raw: unknown) {
|
||||||
|
rootInstance = raw;
|
||||||
const el = resolveElement(raw);
|
const el = resolveElement(raw);
|
||||||
element.value = el;
|
element.value = el;
|
||||||
if (el) bindRoot(el);
|
if (el) bindRoot(el);
|
||||||
else unbindRoot();
|
else unbindRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onUpdated(() => {
|
||||||
|
const el = resolveElement(rootInstance);
|
||||||
|
if (el !== element.value) setRoot(rootInstance);
|
||||||
|
});
|
||||||
|
|
||||||
function focus(e: FocusEvent) {
|
function focus(e: FocusEvent) {
|
||||||
focused.value = true;
|
focused.value = true;
|
||||||
focusVisible.value = (e.target as HTMLElement).matches(":focus-visible");
|
focusVisible.value = (e.target as HTMLElement).matches(":focus-visible");
|
||||||
@@ -253,17 +264,20 @@ defineExpose({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Primitive
|
<LinkPrimitive
|
||||||
:ref="setRoot"
|
:ref="setRoot"
|
||||||
as="a"
|
:is-disabled="disabled"
|
||||||
:as-child="asChild"
|
:as-child="asChild"
|
||||||
v-bind="passthroughAttrs"
|
v-bind="passthroughAttrs"
|
||||||
:href="href"
|
:href="disabled ? undefined : href"
|
||||||
:target="href ? target : undefined"
|
:target="!disabled && href ? target : undefined"
|
||||||
:rel="rel"
|
:rel="rel"
|
||||||
:download="downloadAttr"
|
:download="disabled ? undefined : downloadAttr"
|
||||||
:class="slots.base()"
|
:class="slots.base()"
|
||||||
:role="(attrs.role as string | undefined) ?? (asChild ? 'link' : undefined)"
|
:role="
|
||||||
|
(attrs.role as string | undefined) ??
|
||||||
|
(asChild || disabled ? 'link' : undefined)
|
||||||
|
"
|
||||||
:tabindex="
|
:tabindex="
|
||||||
disabled
|
disabled
|
||||||
? -1
|
? -1
|
||||||
@@ -296,5 +310,5 @@ defineExpose({
|
|||||||
:is-focused="focused"
|
:is-focused="focused"
|
||||||
:is-focus-visible="focusVisible"
|
:is-focus-visible="focusVisible"
|
||||||
/>
|
/>
|
||||||
</Primitive>
|
</LinkPrimitive>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import { cloneVNode, defineComponent, h, mergeProps } from "vue";
|
||||||
|
import { overlayNodes } from "../overlay/OverlayAction";
|
||||||
|
|
||||||
|
/** Slot composition with disabled navigation attributes taking precedence.
|
||||||
|
* Preserve the child's ref rather than letting a slot implementation delete it. */
|
||||||
|
export default defineComponent({
|
||||||
|
name: "LinkPrimitive",
|
||||||
|
inheritAttrs: false,
|
||||||
|
props: { asChild: Boolean, isDisabled: Boolean },
|
||||||
|
setup(props, { attrs, slots }) {
|
||||||
|
return () => {
|
||||||
|
const children = slots.default?.();
|
||||||
|
if (!props.asChild) return h("a", attrs, children);
|
||||||
|
const nodes = overlayNodes(children);
|
||||||
|
if (nodes.length !== 1 || typeof nodes[0]?.type === "symbol")
|
||||||
|
throw new Error("Link asChild requires one element or component root.");
|
||||||
|
const child = nodes[0]!;
|
||||||
|
const { ref: _ref, ...childProps } = child.props ?? {};
|
||||||
|
const merged = mergeProps(attrs, childProps);
|
||||||
|
if (props.isDisabled) {
|
||||||
|
const block = (event: Event) => {
|
||||||
|
if (
|
||||||
|
event instanceof KeyboardEvent &&
|
||||||
|
!["Enter", " ", "Spacebar"].includes(event.key)
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
};
|
||||||
|
// The child's native capture listener is installed before Link's root
|
||||||
|
// listeners. Gate it here so disabled activation cannot run child code.
|
||||||
|
merged.onClickCapture = block;
|
||||||
|
merged.onAuxclickCapture = block;
|
||||||
|
for (const key of ["onKeydownCapture", "onKeyupCapture"]) {
|
||||||
|
const handler = merged[key];
|
||||||
|
merged[key] = [
|
||||||
|
block,
|
||||||
|
...(Array.isArray(handler) ? handler : handler ? [handler] : []),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.assign(merged, {
|
||||||
|
href: null,
|
||||||
|
target: null,
|
||||||
|
download: null,
|
||||||
|
ping: null,
|
||||||
|
tabindex: -1,
|
||||||
|
tabIndex: -1,
|
||||||
|
"aria-disabled": "true",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return cloneVNode({ ...child, props: {} }, merged, true);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -187,7 +187,7 @@ export type BreadcrumbsProps = InstanceType<typeof Breadcrumbs>["$props"];
|
|||||||
/** Public item props; Root injects `isLast` / `separatorSlot` internally. */
|
/** Public item props; Root injects `isLast` / `separatorSlot` internally. */
|
||||||
export type BreadcrumbsItemProps = Omit<
|
export type BreadcrumbsItemProps = Omit<
|
||||||
InstanceType<typeof BreadcrumbsItem>["$props"],
|
InstanceType<typeof BreadcrumbsItem>["$props"],
|
||||||
"isLast" | "separatorSlot"
|
"isLast" | "separatorSlot" | "itemKey"
|
||||||
>;
|
>;
|
||||||
|
|
||||||
import type SearchFieldGroup from "./components/search-field/SearchFieldGroup.vue";
|
import type SearchFieldGroup from "./components/search-field/SearchFieldGroup.vue";
|
||||||
|
|||||||
@@ -118,3 +118,35 @@ describe("DatePicker documentation", () => {
|
|||||||
expect(document.querySelectorAll('[name="time"]')).toHaveLength(1);
|
expect(document.querySelectorAll('[name="time"]')).toHaveLength(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.each(["date-picker", "date-range-picker"])(
|
||||||
|
"%s trigger uses actual focus-visible state",
|
||||||
|
async (name) => {
|
||||||
|
const Demo =
|
||||||
|
name === "date-picker"
|
||||||
|
? (await import("../apps/docs/demos/date-picker-basic.vue")).default
|
||||||
|
: (await import("../apps/docs/demos/date-range-picker-basic.vue"))
|
||||||
|
.default;
|
||||||
|
const w = mount(Demo, { attachTo: document.body });
|
||||||
|
wrappers.push(w);
|
||||||
|
const trigger = w.get(`[data-slot="${name}-trigger"]`);
|
||||||
|
let visible = false;
|
||||||
|
const original = trigger.element.matches.bind(trigger.element);
|
||||||
|
const spy = vi
|
||||||
|
.spyOn(trigger.element, "matches")
|
||||||
|
.mockImplementation((selector) =>
|
||||||
|
selector === ":focus-visible" ? visible : original(selector),
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
await trigger.trigger("focus");
|
||||||
|
expect(trigger.attributes("data-focus-visible")).toBeUndefined();
|
||||||
|
visible = true;
|
||||||
|
await trigger.trigger("focus");
|
||||||
|
expect(trigger.attributes("data-focus-visible")).toBe("true");
|
||||||
|
await trigger.trigger("blur");
|
||||||
|
expect(trigger.attributes("data-focus-visible")).toBeUndefined();
|
||||||
|
} finally {
|
||||||
|
spy.mockRestore();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|||||||
Vendored
+66
@@ -0,0 +1,66 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from "vue";
|
||||||
|
import {
|
||||||
|
Link,
|
||||||
|
Breadcrumbs,
|
||||||
|
BreadcrumbsItem,
|
||||||
|
ConfigProvider,
|
||||||
|
} from "@heroui-vue/components";
|
||||||
|
import SinglePicker from "../../apps/docs/demos/date-picker-basic.vue";
|
||||||
|
import RangePicker from "../../apps/docs/demos/date-range-picker-basic.vue";
|
||||||
|
const disabled = ref(true),
|
||||||
|
locale = ref("zh-CN");
|
||||||
|
const nativeLink = ref<{ focus: () => void }>();
|
||||||
|
const actions = ref<(string | number)[]>([]);
|
||||||
|
const clicks = ref(0),
|
||||||
|
childClicks = ref(0);
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<main style="padding: 24px; display: grid; gap: 24px">
|
||||||
|
<label>
|
||||||
|
<input v-model="disabled" type="checkbox" />
|
||||||
|
禁用链接
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
语言
|
||||||
|
<select v-model="locale">
|
||||||
|
<option>zh-CN</option>
|
||||||
|
<option>en-US</option>
|
||||||
|
<option>fr-FR</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<Link
|
||||||
|
ref="nativeLink"
|
||||||
|
id="native-link"
|
||||||
|
href="#link-destination"
|
||||||
|
target="_blank"
|
||||||
|
download="example.txt"
|
||||||
|
:is-disabled="disabled"
|
||||||
|
@click="clicks++"
|
||||||
|
>
|
||||||
|
原生链接
|
||||||
|
</Link>
|
||||||
|
<Link id="child-link" as-child :is-disabled="disabled" @click="clicks++">
|
||||||
|
<a
|
||||||
|
href="#child-destination"
|
||||||
|
target="_blank"
|
||||||
|
download="child.txt"
|
||||||
|
@click="childClicks++"
|
||||||
|
>
|
||||||
|
子链接
|
||||||
|
</a>
|
||||||
|
</Link>
|
||||||
|
<button @click="nativeLink?.focus()">聚焦原生链接</button>
|
||||||
|
<output id="link-counts">{{ clicks }}/{{ childClicks }}</output>
|
||||||
|
<ConfigProvider :locale="locale">
|
||||||
|
<Breadcrumbs :is-disabled="disabled" @action="actions.push($event)">
|
||||||
|
<BreadcrumbsItem :key="0">数字零</BreadcrumbsItem>
|
||||||
|
<BreadcrumbsItem key="">空标识</BreadcrumbsItem>
|
||||||
|
<BreadcrumbsItem>当前页</BreadcrumbsItem>
|
||||||
|
</Breadcrumbs>
|
||||||
|
</ConfigProvider>
|
||||||
|
<output id="actions">{{ JSON.stringify(actions) }}</output>
|
||||||
|
<section id="single"><SinglePicker /></section>
|
||||||
|
<section id="range"><RangePicker /></section>
|
||||||
|
</main>
|
||||||
|
</template>
|
||||||
@@ -856,5 +856,20 @@
|
|||||||
["Typography", "TypographyRoot"]
|
["Typography", "TypographyRoot"]
|
||||||
],
|
],
|
||||||
"css": []
|
"css": []
|
||||||
|
},
|
||||||
|
"link-focus": {
|
||||||
|
"exports": [
|
||||||
|
"Link",
|
||||||
|
"Breadcrumbs",
|
||||||
|
"BreadcrumbsItem",
|
||||||
|
"DatePickerTrigger",
|
||||||
|
"DateRangePickerTrigger"
|
||||||
|
],
|
||||||
|
"css": [
|
||||||
|
".hv-link",
|
||||||
|
".hv-breadcrumbs",
|
||||||
|
".hv-date-picker__trigger",
|
||||||
|
".hv-date-range-picker__trigger"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import type {
|
||||||
|
BreadcrumbsProps,
|
||||||
|
BreadcrumbsItemProps,
|
||||||
|
LinkProps,
|
||||||
|
} from "@heroui-vue/components";
|
||||||
|
const root: BreadcrumbsProps = {
|
||||||
|
onAction: (key: string | number) => {
|
||||||
|
void key;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const item: BreadcrumbsItemProps = { id: 0 };
|
||||||
|
const link: LinkProps = {
|
||||||
|
href: "/files",
|
||||||
|
asChild: true,
|
||||||
|
isDisabled: true,
|
||||||
|
download: "file.txt",
|
||||||
|
};
|
||||||
|
// @ts-expect-error keys include numeric identities
|
||||||
|
const wrongAction: BreadcrumbsProps = { onAction: (_key: boolean) => {} };
|
||||||
|
// @ts-expect-error internal collection identity injection is not a public item prop
|
||||||
|
const privateKey: BreadcrumbsItemProps = { itemKey: 0 };
|
||||||
|
void item;
|
||||||
|
void root;
|
||||||
|
void link;
|
||||||
|
void wrongAction;
|
||||||
|
void privateKey;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, it, expect } from "vitest";
|
import { describe, it, expect, vi } from "vitest";
|
||||||
import { mount } from "@vue/test-utils";
|
import { mount } from "@vue/test-utils";
|
||||||
import { h, inject, defineComponent, nextTick } from "vue";
|
import { h, inject, defineComponent, nextTick, ref } from "vue";
|
||||||
import {
|
import {
|
||||||
Surface,
|
Surface,
|
||||||
surfaceContextKey,
|
surfaceContextKey,
|
||||||
@@ -96,7 +96,7 @@ describe("Link", () => {
|
|||||||
});
|
});
|
||||||
const a = w.get("a");
|
const a = w.get("a");
|
||||||
expect(a.attributes("aria-disabled")).toBe("true");
|
expect(a.attributes("aria-disabled")).toBe("true");
|
||||||
expect(a.attributes("href")).toBe("#");
|
expect(a.attributes("href")).toBeUndefined();
|
||||||
await a.trigger("click");
|
await a.trigger("click");
|
||||||
expect(clicks).toBe(0);
|
expect(clicks).toBe(0);
|
||||||
expect(captureClicks).toBe(0);
|
expect(captureClicks).toBe(0);
|
||||||
@@ -559,3 +559,116 @@ it("omits the implicit same-window target so host routers can intercept navigati
|
|||||||
expect(explicit.attributes("target")).toBe("_self");
|
expect(explicit.attributes("target")).toBe("_self");
|
||||||
explicit.unmount();
|
explicit.unmount();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.each([false, true])(
|
||||||
|
"removes disabled navigation attributes and restores them dynamically (asChild=%s)",
|
||||||
|
async (asChild) => {
|
||||||
|
const click = vi.fn();
|
||||||
|
const childCapture = vi.fn();
|
||||||
|
const childRef = ref<HTMLElement>();
|
||||||
|
const w = mount(Link, {
|
||||||
|
props: {
|
||||||
|
asChild,
|
||||||
|
href: "#parent",
|
||||||
|
target: "_blank",
|
||||||
|
download: "parent.txt",
|
||||||
|
isDisabled: true,
|
||||||
|
},
|
||||||
|
attrs: { class: "consumer", onClick: click, "data-test": "kept" },
|
||||||
|
slots: {
|
||||||
|
default: () =>
|
||||||
|
asChild
|
||||||
|
? h(
|
||||||
|
"a",
|
||||||
|
{
|
||||||
|
href: "#child",
|
||||||
|
target: "_self",
|
||||||
|
download: "child.txt",
|
||||||
|
ref: childRef,
|
||||||
|
tabIndex: 0,
|
||||||
|
onClickCapture: childCapture,
|
||||||
|
},
|
||||||
|
"link",
|
||||||
|
)
|
||||||
|
: "link",
|
||||||
|
},
|
||||||
|
attachTo: document.body,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const root = w.get("a");
|
||||||
|
expect(root.attributes("href")).toBeUndefined();
|
||||||
|
expect(root.attributes("target")).toBeUndefined();
|
||||||
|
expect(root.attributes("download")).toBeUndefined();
|
||||||
|
expect(root.attributes("aria-disabled")).toBe("true");
|
||||||
|
expect(root.attributes("tabindex")).toBe("-1");
|
||||||
|
expect(root.classes()).toContain("consumer");
|
||||||
|
expect(root.attributes("data-test")).toBe("kept");
|
||||||
|
if (asChild) expect(childRef.value).toBe(root.element);
|
||||||
|
const event = new MouseEvent("click", {
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: true,
|
||||||
|
});
|
||||||
|
root.element.dispatchEvent(event);
|
||||||
|
expect(event.defaultPrevented).toBe(true);
|
||||||
|
const middle = new MouseEvent("auxclick", {
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: true,
|
||||||
|
button: 1,
|
||||||
|
});
|
||||||
|
root.element.dispatchEvent(middle);
|
||||||
|
expect(middle.defaultPrevented).toBe(true);
|
||||||
|
expect(click).not.toHaveBeenCalled();
|
||||||
|
expect(childCapture).not.toHaveBeenCalled();
|
||||||
|
await w.setProps({ isDisabled: false });
|
||||||
|
expect(root.attributes("href")).toBe(asChild ? "#child" : "#parent");
|
||||||
|
expect(root.attributes("download")).toBe(
|
||||||
|
asChild ? "child.txt" : "parent.txt",
|
||||||
|
);
|
||||||
|
await root.trigger("click");
|
||||||
|
expect(click).toHaveBeenCalledTimes(1);
|
||||||
|
if (asChild) expect(childCapture).toHaveBeenCalledTimes(1);
|
||||||
|
await w.setProps({ isDisabled: true });
|
||||||
|
expect(root.attributes("href")).toBeUndefined();
|
||||||
|
} finally {
|
||||||
|
w.unmount();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
it("preserves forwarding child refs and handlers while respecting cancellation", async () => {
|
||||||
|
const child = vi.fn(),
|
||||||
|
parent = vi.fn();
|
||||||
|
const forwardedRef = ref();
|
||||||
|
const Forwarded = defineComponent({
|
||||||
|
inheritAttrs: false,
|
||||||
|
setup(_, { attrs }) {
|
||||||
|
return () => h("a", attrs, "forwarded");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const w = mount(Link, {
|
||||||
|
props: { asChild: true, isDisabled: true },
|
||||||
|
attrs: {
|
||||||
|
onClick: parent,
|
||||||
|
onClickCapture: (e: Event) => e.preventDefault(),
|
||||||
|
},
|
||||||
|
slots: {
|
||||||
|
default: () =>
|
||||||
|
h(Forwarded, { href: "#forwarded", ref: forwardedRef, onClick: child }),
|
||||||
|
},
|
||||||
|
attachTo: document.body,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
expect(w.get("a").attributes("href")).toBeUndefined();
|
||||||
|
await w.get("a").trigger("click");
|
||||||
|
expect(child).not.toHaveBeenCalled();
|
||||||
|
await w.setProps({ isDisabled: false });
|
||||||
|
expect(forwardedRef.value.$el).toBe(w.get("a").element);
|
||||||
|
const event = new MouseEvent("click", { bubbles: true, cancelable: true });
|
||||||
|
w.get("a").element.dispatchEvent(event);
|
||||||
|
expect(event.defaultPrevented).toBe(true);
|
||||||
|
expect(parent).toHaveBeenCalledTimes(1);
|
||||||
|
expect(child).toHaveBeenCalledTimes(1);
|
||||||
|
} finally {
|
||||||
|
w.unmount();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { describe, it, expect, vi, afterEach } from "vitest";
|
|||||||
import { mount } from "@vue/test-utils";
|
import { mount } from "@vue/test-utils";
|
||||||
import { defineComponent, h, nextTick, ref } from "vue";
|
import { defineComponent, h, nextTick, ref } from "vue";
|
||||||
import {
|
import {
|
||||||
|
ConfigProvider,
|
||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
BreadcrumbsItem,
|
BreadcrumbsItem,
|
||||||
EmptyState,
|
EmptyState,
|
||||||
@@ -799,3 +800,84 @@ describe("Breadcrumbs", () => {
|
|||||||
w.unmount();
|
w.unmount();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("localizes breadcrumb labels dynamically while explicit names take precedence", async () => {
|
||||||
|
const locale = ref("en-US"),
|
||||||
|
label = ref<string>();
|
||||||
|
const w = mount(
|
||||||
|
defineComponent({
|
||||||
|
render: () =>
|
||||||
|
h(ConfigProvider, { locale: locale.value }, () =>
|
||||||
|
h(Breadcrumbs, { "aria-label": label.value }, () =>
|
||||||
|
h(BreadcrumbsItem, {}, () => "current"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
expect(w.get("ol").attributes("aria-label")).toBe("Breadcrumbs");
|
||||||
|
locale.value = "zh-CN";
|
||||||
|
await nextTick();
|
||||||
|
expect(w.get("ol").attributes("aria-label")).toBe("导航栏");
|
||||||
|
label.value = "自定义路径";
|
||||||
|
await nextTick();
|
||||||
|
locale.value = "fr-FR";
|
||||||
|
await nextTick();
|
||||||
|
expect(w.get("ol").attributes("aria-label")).toBe("自定义路径");
|
||||||
|
label.value = "";
|
||||||
|
await nextTick();
|
||||||
|
expect(w.get("ol").attributes("aria-label")).toBe("Chemin de navigation");
|
||||||
|
} finally {
|
||||||
|
w.unmount();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("emits one breadcrumb action preserving zero/empty identities, respecting cancellation and disabled/current items", async () => {
|
||||||
|
const action = vi.fn(),
|
||||||
|
disabled = ref(false),
|
||||||
|
cancel = ref(false);
|
||||||
|
const w = mount(
|
||||||
|
defineComponent({
|
||||||
|
render: () =>
|
||||||
|
h(Breadcrumbs, { isDisabled: disabled.value, onAction: action }, () => [
|
||||||
|
h(
|
||||||
|
BreadcrumbsItem,
|
||||||
|
{
|
||||||
|
key: 0,
|
||||||
|
onClick: (e: Event) => {
|
||||||
|
if (cancel.value) e.preventDefault();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
() => "zero",
|
||||||
|
),
|
||||||
|
h(BreadcrumbsItem, { key: "" }, () => "empty"),
|
||||||
|
h(
|
||||||
|
BreadcrumbsItem,
|
||||||
|
{ key: "string-key", id: "0" },
|
||||||
|
() => "string zero",
|
||||||
|
),
|
||||||
|
h(BreadcrumbsItem, { key: "current" }, () => "current"),
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
{ attachTo: document.body },
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
const links = () => w.findAll('[data-slot="link"]');
|
||||||
|
await links()[0].trigger("click");
|
||||||
|
expect(action).toHaveBeenLastCalledWith(0);
|
||||||
|
await links()[1].trigger("keydown", { key: "Enter" });
|
||||||
|
expect(action).toHaveBeenLastCalledWith("");
|
||||||
|
await links()[2].trigger("click");
|
||||||
|
expect(action).toHaveBeenLastCalledWith("0");
|
||||||
|
expect(action).toHaveBeenCalledTimes(3);
|
||||||
|
cancel.value = true;
|
||||||
|
await nextTick();
|
||||||
|
await links()[0].trigger("click");
|
||||||
|
await links()[3].trigger("click");
|
||||||
|
disabled.value = true;
|
||||||
|
await nextTick();
|
||||||
|
await links()[1].trigger("click");
|
||||||
|
expect(action).toHaveBeenCalledTimes(3);
|
||||||
|
} finally {
|
||||||
|
w.unmount();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
Vendored
+201
@@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright 2019 Adobe
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
Reference in New Issue
Block a user