feat(collections): auto incremental async loading, shared filtering and submenu delay
HD-10 scope, against heroui ce90ea3 collection sources and their react-aria/react-stately dependencies: - the ComboBox async demo now auto-loads on scroll-to-bottom (IntersectionObserver sentinel + fill chain mirroring the pinned ListBoxLoadMoreItem re-observe semantics), never duplicates requests (loading guards + monotonic sequence token), drops stale responses on query switches, keeps a retry path for failures (injectable mock failure) and documents its differences from the pinned SWAPI source; the Select demo's observer stays untouched (real-network scroll triggering verified in browser) - the Autocomplete virtualization demo and the default filter share one locale-sensitive matcher: createBaseContains (Intl.Collator base sensitivity, cafe matches Cafe with accent folding) is now exported from the package root - Autocomplete trigger semantics verified complete (single tab stop, Enter/Space/Escape/Delete/IME, single and multiple selection) and the scoped slots gained composition data instead of child copying: AutocompleteValue exposes selectedItem and per-entry source item, the ComboBox root exposes selectedItem - DropdownSubmenuTrigger exposes the pinned delay contract (default 200ms): the controlled open gate retimes Reka's fixed 100ms hover, keyboard opens stay immediate and cancel the pending hover, pointer leave cancels; the dead side/align forwarding is gone (Reka fixes the submenu side per direction); Button/Avatar trigger layout compensation kept after browser proof it is what wins the cascade - tests/fixtures/collections-rtl.vue drives the real-browser delay and RTL geometry checks; b02-pickers contract pins the new export and slot typing Full suite 111 files / 1666 tests, typecheck, build:docs and the b02-pickers + api-root-aliases tarball contracts pass.
This commit is contained in:
@@ -162,7 +162,7 @@ Autocomplete 组件支持两种视觉变体:
|
|||||||
::: warning
|
::: warning
|
||||||
多选模式下,上游 `Autocomplete.Value` 会把每个选中项在 `ListBox.Item` 中的 children 复制到触发器中,并以符合当前语言环境的分隔符连接:仅包含文本的选项显示为纯文本,但复选框、头像等可见内容会随每个选中项各出现一次;函数形式的 children 也始终以 `isSelected: false` 调用。
|
多选模式下,上游 `Autocomplete.Value` 会把每个选中项在 `ListBox.Item` 中的 children 复制到触发器中,并以符合当前语言环境的分隔符连接:仅包含文本的选项显示为纯文本,但复选框、头像等可见内容会随每个选中项各出现一次;函数形式的 children 也始终以 `isSelected: false` 调用。
|
||||||
|
|
||||||
本库不复制子树,而是给 `AutocompleteValue` 的作用域插槽提供 `selectedItems`(`{ key, textValue }[]`)与 `selectedText`(纯文本),因此不存在上述重复渲染问题,但函数形式的插槽同样不携带 `isSelected`。
|
本库不复制子树,而是给 `AutocompleteValue` 的作用域插槽提供 `selectedItems`(`{ key, textValue, item? }[]`,`item` 为根 `items` 中的源数据项)、`selectedItem`(首个选中项)与 `selectedText`(纯文本),调用方可直接用源数据组合头像、可移除标签等丰富展示,因此不存在上述重复渲染问题,但函数形式的插槽同样不携带 `isSelected`。
|
||||||
:::
|
:::
|
||||||
|
|
||||||
如需以纯文本显示选中值,请使用 `selectedText`:
|
如需以纯文本显示选中值,请使用 `selectedText`:
|
||||||
@@ -437,15 +437,17 @@ Autocomplete 组件使用以下 CSS 类([查看源码样式](https://github.co
|
|||||||
| `isPlaceholder` | `boolean` | 是否没有选中项 |
|
| `isPlaceholder` | `boolean` | 是否没有选中项 |
|
||||||
| `defaultChildren` | `string`(上游为 `ReactNode`) | 缺省文本(选中项文本以逗号连接,否则占位符) |
|
| `defaultChildren` | `string`(上游为 `ReactNode`) | 缺省文本(选中项文本以逗号连接,否则占位符) |
|
||||||
| `selectedText` | `string` | 选中项 `textValue` 的连接文本 |
|
| `selectedText` | `string` | 选中项 `textValue` 的连接文本 |
|
||||||
| `selectedItems` | `Array<{ key, textValue }>` | 选中项 |
|
| `selectedItems` | `Array<{ key, textValue, item? }>` | 选中项;`item` 为根 `items` 中的源数据项(集合自发现的项没有) |
|
||||||
|
| `selectedItem` | `{ key, textValue, item? } \| null` | 首个选中项(单选即所选项),便于单选组合 |
|
||||||
|
|
||||||
上游 `state.selectedItems`(节点)在本库中是上表的 `selectedItems`(数据);不复制 item 子树,见「多选」说明。
|
上游 `state.selectedItems`(节点)在本库中是上表的 `selectedItems`(数据,条目携带源数据 `item`);不复制 item 子树,见「多选」说明。
|
||||||
|
|
||||||
### 过滤函数(`useFilter` 替代)
|
### 过滤函数(`useFilter` 替代)
|
||||||
|
|
||||||
上游页面导出的 `useFilter` hook(`contains` / `startsWith` / `endsWith` 与 `sensitivity`)在本库没有对应导出。替代方式:
|
上游页面导出的 `useFilter` hook(`contains` / `startsWith` / `endsWith` 与 `sensitivity`)在本库没有对应导出。替代方式:
|
||||||
|
|
||||||
- `AutocompleteFilter` 的默认谓词等价于 `useFilter({ sensitivity: "base" }).contains`:按 `ConfigProvider` 的 locale 折叠大小写与变音符号,`cafe` 能命中 `Café`
|
- `AutocompleteFilter` 的默认谓词等价于 `useFilter({ sensitivity: "base" }).contains`:按 `ConfigProvider` 的 locale 折叠大小写与变音符号,`cafe` 能命中 `Café`
|
||||||
|
- 调用方自行过滤数据时(虚拟化、异步数据源),可从包根导入 `createBaseContains`(与默认谓词同一实现)保持语义一致:`const { locale } = useLocale(); const contains = createBaseContains(locale.value)`
|
||||||
- 需要 `startsWith` / `endsWith` 等语义时,直接给 `:filter="(text, input) => …"` 传函数
|
- 需要 `startsWith` / `endsWith` 等语义时,直接给 `:filter="(text, input) => …"` 传函数
|
||||||
- 数据源或调用方已过滤时(异步、虚拟化示例),传 `:filter="() => true"` 避免二次过滤
|
- 数据源或调用方已过滤时(异步、虚拟化示例),传 `:filter="() => true"` 避免二次过滤
|
||||||
|
|
||||||
|
|||||||
@@ -133,6 +133,8 @@ import {
|
|||||||
|
|
||||||
<ComponentPreview name="combo-box-asynchronous-loading" />
|
<ComponentPreview name="combo-box-asynchronous-loading" />
|
||||||
|
|
||||||
|
示例的本地数据源模拟固定源的 SWAPI 请求状态机(搜索过滤、游标分页、加载中、滚动到底自动增量加载、取消旧请求与过期响应保护、失败重试);与 SWAPI 的差异是数据为固定 12 条本地角色、延迟为模拟值,失败由「模拟加载失败」开关注入。加载行位于 ListBox 之外(固定源为 `ListBoxLoadMoreItem` 行内哨兵),自动触发语义一致。
|
||||||
|
|
||||||
### 默认选中项
|
### 默认选中项
|
||||||
|
|
||||||
<ComponentPreview name="combo-box-default-selected-key" />
|
<ComponentPreview name="combo-box-default-selected-key" />
|
||||||
@@ -314,7 +316,7 @@ ComboBox 组件使用以下 CSS 类([查看源码样式](https://github.com/he
|
|||||||
| `placeholder` | `string` | `'Select an item'` | `ComboBoxValue` 的缺省占位文本(上游根上没有该 prop,由 `ComboBoxValue` 的 placeholder 表达) |
|
| `placeholder` | `string` | `'Select an item'` | `ComboBoxValue` 的缺省占位文本(上游根上没有该 prop,由 `ComboBoxValue` 的 placeholder 表达) |
|
||||||
| `as` | `string` | `'div'` | 自定义根元素标签 |
|
| `as` | `string` | `'div'` | 自定义根元素标签 |
|
||||||
| `as-child` | `boolean` | `false` | 使用唯一子元素作为根节点并合并属性 |
|
| `as-child` | `boolean` | `false` | 使用唯一子元素作为根节点并合并属性 |
|
||||||
| 默认插槽 | `{ isOpen, inputValue, selectedKey, selectedKeys }` | - | 组件内容;作用域提供当前状态 |
|
| 默认插槽 | `{ isOpen, inputValue, selectedKey, selectedKeys, selectedItem }` | - | 组件内容;作用域提供当前状态 |
|
||||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
||||||
|
|
||||||
事件:
|
事件:
|
||||||
@@ -334,7 +336,7 @@ ComboBox 组件使用以下 CSS 类([查看源码样式](https://github.com/he
|
|||||||
|
|
||||||
### 作用域插槽与渲染状态
|
### 作用域插槽与渲染状态
|
||||||
|
|
||||||
默认插槽提供 `{ isOpen, inputValue, selectedKey, selectedKeys }`。上游的 `Render Props` 表格里还有 `state` 与 `selectedItem`:本库不暴露 React Aria 的 state 对象,选中项数据可从 `records`/`selectedKeys` 派生(示例见 `@update:model-value` 与 `ComboBoxValue` 的作用域插槽),该差异不另设等价 prop。
|
默认插槽提供 `{ isOpen, inputValue, selectedKey, selectedKeys, selectedItem }`。上游的 `Render Props` 表格里还有 `state` 与 `selectedItem`:`selectedItem` 以作用域数据补齐(根 `items` 中与单选 key 匹配的源数据项;多选或自定义值时为 `null`,`ComboBoxValue` 的 `selectedItems` 条目也携带同源 `item`),调用方可直接用自己的数据对象组合展示,无需按键反查;本库不暴露 React Aria 的 state 对象,该差异不另设等价 prop。
|
||||||
|
|
||||||
### ComboBoxInputGroup
|
### ComboBoxInputGroup
|
||||||
|
|
||||||
@@ -350,7 +352,7 @@ ComboBox 组件使用以下 CSS 类([查看源码样式](https://github.com/he
|
|||||||
| Prop | 类型 | 默认值 | 描述 |
|
| Prop | 类型 | 默认值 | 描述 |
|
||||||
| ------------- | ---------------------------------- | -------------------- | ----------------------------- |
|
| ------------- | ---------------------------------- | -------------------- | ----------------------------- |
|
||||||
| `placeholder` | `string`(上游为 `ReactNode`) | 根上的 `placeholder` | 未选中任何项时的占位文本 |
|
| `placeholder` | `string`(上游为 `ReactNode`) | 根上的 `placeholder` | 未选中任何项时的占位文本 |
|
||||||
| 默认插槽 | `{ isPlaceholder, selectedItems }` | - | 自定义已选值展示 |
|
| 默认插槽 | `{ isPlaceholder, selectedItems }` | - | 自定义已选值展示;`selectedItems` 条目为 `{ key, textValue, item? }`(`item` 为根 `items` 中的源数据项) |
|
||||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
||||||
|
|
||||||
### ComboBoxTrigger
|
### ComboBoxTrigger
|
||||||
|
|||||||
@@ -370,6 +370,7 @@ Dropdown 使用 Menu、MenuItem 与 MenuSection 作为底层组件。以下类
|
|||||||
| Slots / Props | 说明 |
|
| Slots / Props | 说明 |
|
||||||
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| 默认插槽 | 第一个子节点是触发条目,其余子节点渲染进子菜单内容 |
|
| 默认插槽 | 第一个子节点是触发条目,其余子节点渲染进子菜单内容 |
|
||||||
|
| `delay` | 悬停展开延迟(毫秒),默认 `200`(与固定源 `useSubmenuTrigger` 一致);键盘展开立即生效并取消挂起的悬停展开,指针离开取消 |
|
||||||
| `class`/ARIA | 合并到触发条目元素上 |
|
| `class`/ARIA | 合并到触发条目元素上 |
|
||||||
| 面板参数 | 嵌套 `DropdownPopover` 的 `offset`/`crossOffset`/`shouldFlip`/`containerPadding`/`loop`/`to`、`class`/`style`/`id`/`data-*`/ARIA 与事件都会传给子菜单面板;`isKeyboardDismissDisabled` 为真时 Esc 既不关子层也不关父层,`shouldCloseOnInteractOutside` 返回 `false` 时外部交互不关闭 |
|
| 面板参数 | 嵌套 `DropdownPopover` 的 `offset`/`crossOffset`/`shouldFlip`/`containerPadding`/`loop`/`to`、`class`/`style`/`id`/`data-*`/ARIA 与事件都会传给子菜单面板;`isKeyboardDismissDisabled` 为真时 Esc 既不关子层也不关父层,`shouldCloseOnInteractOutside` 返回 `false` 时外部交互不关闭 |
|
||||||
|
|
||||||
@@ -408,7 +409,7 @@ Dropdown 组件实现 ARIA 菜单模式,并提供:
|
|||||||
- 部件导出为具名组件(`DropdownRoot` / `DropdownTrigger` / …),触发器需要显式包裹,官方是把 `Button` 直接放在 `Dropdown` 下。
|
- 部件导出为具名组件(`DropdownRoot` / `DropdownTrigger` / …),触发器需要显式包裹,官方是把 `Button` 直接放在 `Dropdown` 下。
|
||||||
- `Selection`/`Set` 改为 `MenuKey[]`;`onAction`/`onSelectionChange`/`onClose` 改为 Vue 事件;`isOpen`/`onOpenChange` 改为 `open` + `v-model:open`。
|
- `Selection`/`Set` 改为 `MenuKey[]`;`onAction`/`onSelectionChange`/`onClose` 改为 Vue 事件;`isOpen`/`onOpenChange` 改为 `open` + `v-model:open`。
|
||||||
- 官方 `items` + 渲染函数的数据驱动集合用 `v-for` 表达;`renderEmptyState` 对应 `empty` 插槽。不提供 React Collection 对象模型。
|
- 官方 `items` + 渲染函数的数据驱动集合用 `v-for` 表达;`renderEmptyState` 对应 `empty` 插槽。不提供 React Collection 对象模型。
|
||||||
- 子菜单悬停展开延迟由底层固定为 100ms,未暴露官方 `delay`(默认 200ms);子菜单面板的 `side`/`align` 由底层固定,只有偏移与碰撞参数可调。
|
- 子菜单悬停展开延迟由 `DropdownSubmenuTrigger` 的 `delay` 配置(默认 200ms,与固定源 `useSubmenuTrigger` 一致):底层 Reka 的固定 100ms 悬停计时被重定为该延迟,键盘展开立即生效并取消挂起的悬停展开,指针离开取消;子菜单面板的 `side`/`align` 由底层固定(贴父项向右、RTL 反向),只有偏移与碰撞参数可调。
|
||||||
- `DropdownTrigger` 的作用域插槽只提供 `{ isOpen }`,`DropdownPopover` 只提供 `{ isEntering, isExiting, placement }`;官方 Button/Popover 的完整 render props 未全部覆盖。
|
- `DropdownTrigger` 的作用域插槽只提供 `{ isOpen }`,`DropdownPopover` 只提供 `{ isEntering, isExiting, placement }`;官方 Button/Popover 的完整 render props 未全部覆盖。
|
||||||
- `DropdownRoot` 额外渲染一层 `.hv-dropdown` 包裹元素(官方该类没有 DOM 宿主),承载根级 class、style、id、ARIA、data 属性与原生事件。作为 `ButtonGroup` 直接子级时仍保留该容器,接缝样式按容器在组内的位置适配内部触发按钮;根级属性与捕获事件的行为不变。
|
- `DropdownRoot` 额外渲染一层 `.hv-dropdown` 包裹元素(官方该类没有 DOM 宿主),承载根级 class、style、id、ARIA、data 属性与原生事件。作为 `ButtonGroup` 直接子级时仍保留该容器,接缝样式按容器在组内的位置适配内部触发按钮;根级属性与捕获事件的行为不变。
|
||||||
- 条目 `id` 是业务 key,DOM id 为实例级;官方把 key 直接作为 DOM id(Vue 端避免数字 `0` 与字符串 `"0"` 冲突)。
|
- 条目 `id` 是业务 key,DOM id 为实例级;官方把 key 直接作为 DOM id(Vue 端避免数字 `0` 与字符串 `"0"` 冲突)。
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
AutocompletePopover,
|
AutocompletePopover,
|
||||||
AutocompleteTrigger,
|
AutocompleteTrigger,
|
||||||
AutocompleteValue,
|
AutocompleteValue,
|
||||||
|
createBaseContains,
|
||||||
Description,
|
Description,
|
||||||
EmptyState,
|
EmptyState,
|
||||||
Label,
|
Label,
|
||||||
@@ -20,6 +21,7 @@ import {
|
|||||||
SearchFieldGroup,
|
SearchFieldGroup,
|
||||||
SearchFieldInput,
|
SearchFieldInput,
|
||||||
SearchFieldSearchIcon,
|
SearchFieldSearchIcon,
|
||||||
|
useLocale,
|
||||||
type ListBoxKey,
|
type ListBoxKey,
|
||||||
} from "@heroui-vue/components";
|
} from "@heroui-vue/components";
|
||||||
|
|
||||||
@@ -97,15 +99,19 @@ const allUsers = generateUsers(1000);
|
|||||||
const selectedKey = ref<ListBoxKey | null>(null);
|
const selectedKey = ref<ListBoxKey | null>(null);
|
||||||
const searchQuery = ref("");
|
const searchQuery = ref("");
|
||||||
|
|
||||||
|
// 与 AutocompleteFilter 默认谓词共用同一实现(locale 敏感、大小写与变音折叠,
|
||||||
|
// 例如 cafe 能匹配 Café);本示例自行过滤以驱动虚拟滚动,故关闭集合二次过滤。
|
||||||
|
const { locale } = useLocale();
|
||||||
|
const contains = computed(() => createBaseContains(locale.value));
|
||||||
|
|
||||||
const filteredUsers = computed(() => {
|
const filteredUsers = computed(() => {
|
||||||
const query = searchQuery.value.trim().toLocaleLowerCase();
|
const query = searchQuery.value.trim();
|
||||||
|
|
||||||
if (!query) return allUsers;
|
if (!query) return allUsers;
|
||||||
|
|
||||||
return allUsers.filter(
|
return allUsers.filter(
|
||||||
(user) =>
|
(user) =>
|
||||||
user.name.toLocaleLowerCase().includes(query) ||
|
contains.value(user.name, query) || contains.value(user.email, query),
|
||||||
user.email.toLocaleLowerCase().includes(query),
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
<!-- 适配:源示例请求 SWAPI,这里用本地异步源演示相同状态(取消旧请求、加载中、增量加载)。 -->
|
<!-- 适配说明:固定源此例请求 SWAPI(swapi.py4e.com/api/people,useAsyncList 游标分页 + 行内 ListBoxLoadMoreItem 哨兵)。
|
||||||
|
本示例改用本地异步源模拟同一状态机:搜索过滤、游标分页、加载中、滚动到底自动增量加载、
|
||||||
|
取消旧请求与过期响应保护、失败重试。与 SWAPI 的差异:数据为固定 12 条本地角色(非 82 条远端人员),
|
||||||
|
网络延迟为固定 300ms 模拟(不可观测 DNS/网络错误),失败由「模拟加载失败」开关注入。
|
||||||
|
加载行位于 ListBox 之外(基线为 ListBoxLoadMoreItem 的行内加载行),自动触发语义一致。 -->
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onBeforeUnmount, onMounted, ref } from "vue";
|
import { onBeforeUnmount, onMounted, ref } from "vue";
|
||||||
|
import { useIntersectionObserver } from "@vueuse/core";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
ComboBox,
|
ComboBox,
|
||||||
@@ -39,12 +44,18 @@ const characters: Character[] = [
|
|||||||
{ id: "Boba Fett", name: "Boba Fett" },
|
{ id: "Boba Fett", name: "Boba Fett" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const simulateFailure = ref(false);
|
||||||
const inputValue = ref("");
|
const inputValue = ref("");
|
||||||
const items = ref<Character[]>([]);
|
const items = ref<Character[]>([]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const loadingMore = ref(false);
|
const loadingMore = ref(false);
|
||||||
|
const error = ref(false);
|
||||||
const hasMore = ref(false);
|
const hasMore = ref(false);
|
||||||
|
const sentinel = ref<HTMLElement>();
|
||||||
|
const sentinelVisible = ref(false);
|
||||||
let controller: AbortController | undefined;
|
let controller: AbortController | undefined;
|
||||||
|
/** Monotonic request token: stale responses are dropped even without abort. */
|
||||||
|
let sequence = 0;
|
||||||
|
|
||||||
function matches(query: string) {
|
function matches(query: string) {
|
||||||
const text = query.trim().toLocaleLowerCase();
|
const text = query.trim().toLocaleLowerCase();
|
||||||
@@ -54,21 +65,17 @@ function matches(query: string) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function load(query: string, offset: number, append: boolean) {
|
function mockPage(query: string, offset: number, signal: AbortSignal) {
|
||||||
controller?.abort();
|
return new Promise<Character[]>((resolve, reject) => {
|
||||||
const current = new AbortController();
|
|
||||||
|
|
||||||
controller = current;
|
|
||||||
if (append) loadingMore.value = true;
|
|
||||||
else loading.value = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const page = await new Promise<Character[]>((resolve, reject) => {
|
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
|
if (simulateFailure.value) {
|
||||||
|
reject(new Error("模拟加载失败"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
resolve(matches(query).slice(offset, offset + PAGE_SIZE));
|
resolve(matches(query).slice(offset, offset + PAGE_SIZE));
|
||||||
}, PAGE_DELAY);
|
}, PAGE_DELAY);
|
||||||
|
|
||||||
current.signal.addEventListener(
|
signal.addEventListener(
|
||||||
"abort",
|
"abort",
|
||||||
() => {
|
() => {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
@@ -77,16 +84,34 @@ async function load(query: string, offset: number, append: boolean) {
|
|||||||
{ once: true },
|
{ once: true },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (current.signal.aborted) return;
|
async function load(query: string, offset: number, append: boolean) {
|
||||||
|
controller?.abort();
|
||||||
|
const current = new AbortController();
|
||||||
|
const token = ++sequence;
|
||||||
|
|
||||||
|
controller = current;
|
||||||
|
error.value = false;
|
||||||
|
if (append) loadingMore.value = true;
|
||||||
|
else loading.value = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const page = await mockPage(query, offset, current.signal);
|
||||||
|
|
||||||
|
// A newer request superseded this one: drop the stale response.
|
||||||
|
if (current.signal.aborted || token !== sequence) return;
|
||||||
|
|
||||||
items.value = append ? [...items.value, ...page] : page;
|
items.value = append ? [...items.value, ...page] : page;
|
||||||
hasMore.value = offset + page.length < matches(query).length;
|
hasMore.value = offset + page.length < matches(query).length;
|
||||||
} catch {
|
} catch {
|
||||||
if (current.signal.aborted) return;
|
if (current.signal.aborted || token !== sequence) return;
|
||||||
|
|
||||||
|
error.value = true;
|
||||||
|
if (!append) {
|
||||||
items.value = [];
|
items.value = [];
|
||||||
hasMore.value = false;
|
hasMore.value = false;
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
// A newer request owns the flags once it has taken over the controller.
|
// A newer request owns the flags once it has taken over the controller.
|
||||||
if (controller === current) {
|
if (controller === current) {
|
||||||
@@ -94,6 +119,11 @@ async function load(query: string, offset: number, append: boolean) {
|
|||||||
loadingMore.value = false;
|
loadingMore.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Chain-fill: the fresh page may leave the sentinel inside the viewport, in
|
||||||
|
// which case scrolling is not needed to request the next one.
|
||||||
|
if (sentinelVisible.value && hasMore.value && !error.value)
|
||||||
|
queueMicrotask(() => maybeLoadMore());
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleInputChange(next: string) {
|
function handleInputChange(next: string) {
|
||||||
@@ -101,11 +131,25 @@ function handleInputChange(next: string) {
|
|||||||
void load(next, 0, false);
|
void load(next, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadMore() {
|
function maybeLoadMore() {
|
||||||
if (loading.value || loadingMore.value || !hasMore.value) return;
|
if (loading.value || loadingMore.value || error.value || !hasMore.value) return;
|
||||||
void load(inputValue.value, items.value.length, true);
|
void load(inputValue.value, items.value.length, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function retry() {
|
||||||
|
if (loading.value || loadingMore.value) return;
|
||||||
|
void load(inputValue.value, items.value.length, items.value.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scroll-to-bottom auto incremental loading: the sentinel drives the loads and
|
||||||
|
// in-flight requests are never duplicated. When a fresh page does not push the
|
||||||
|
// sentinel out of view, the load chain keeps filling (the pinned
|
||||||
|
// ListBoxLoadMoreItem re-observes per collection change for the same effect).
|
||||||
|
useIntersectionObserver(sentinel, ([entry]) => {
|
||||||
|
sentinelVisible.value = !!entry?.isIntersecting;
|
||||||
|
if (entry?.isIntersecting) maybeLoadMore();
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
void load(inputValue.value, 0, false);
|
void load(inputValue.value, 0, false);
|
||||||
});
|
});
|
||||||
@@ -116,6 +160,7 @@ onBeforeUnmount(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<div class="flex flex-col gap-2">
|
||||||
<ComboBox
|
<ComboBox
|
||||||
allows-empty-collection
|
allows-empty-collection
|
||||||
class="w-[256px]"
|
class="w-[256px]"
|
||||||
@@ -127,7 +172,7 @@ onBeforeUnmount(() => {
|
|||||||
<Input placeholder="星球大战角色…" />
|
<Input placeholder="星球大战角色…" />
|
||||||
<ComboBoxTrigger />
|
<ComboBoxTrigger />
|
||||||
</ComboBoxInputGroup>
|
</ComboBoxInputGroup>
|
||||||
<ComboBoxPopover>
|
<ComboBoxPopover class="max-h-80">
|
||||||
<ListBox :aria-busy="loading || undefined">
|
<ListBox :aria-busy="loading || undefined">
|
||||||
<ListBoxItem
|
<ListBoxItem
|
||||||
v-for="item in items"
|
v-for="item in items"
|
||||||
@@ -142,15 +187,23 @@ onBeforeUnmount(() => {
|
|||||||
<EmptyState />
|
<EmptyState />
|
||||||
</template>
|
</template>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
<div v-if="hasMore" class="flex items-center justify-center gap-2 py-2">
|
<div ref="sentinel" aria-hidden="true" class="h-px" />
|
||||||
|
<div
|
||||||
|
v-if="loadingMore || error"
|
||||||
|
class="flex items-center justify-center gap-2 py-2"
|
||||||
|
role="status"
|
||||||
|
>
|
||||||
<template v-if="loadingMore">
|
<template v-if="loadingMore">
|
||||||
<Spinner size="sm" />
|
<Spinner size="sm" />
|
||||||
<span class="text-sm text-muted" role="status">加载更多…</span>
|
<span class="text-sm text-muted">加载更多…</span>
|
||||||
</template>
|
</template>
|
||||||
<Button v-else variant="ghost" size="sm" @click="loadMore">
|
<Button v-else variant="ghost" size="sm" @click="retry">重试</Button>
|
||||||
加载更多…
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</ComboBoxPopover>
|
</ComboBoxPopover>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
|
<label class="flex items-center gap-2 text-sm text-muted">
|
||||||
|
<input v-model="simulateFailure" type="checkbox" />
|
||||||
|
模拟加载失败(本地数据源注入;SWAPI 场景为真实网络错误)
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -24,6 +24,13 @@ const labs = [
|
|||||||
() => import("../../../tests/fixtures/table-layout.vue"),
|
() => import("../../../tests/fixtures/table-layout.vue"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "collections-rtl",
|
||||||
|
title: "子菜单延迟与 RTL 定位",
|
||||||
|
component: defineAsyncComponent(
|
||||||
|
() => import("../../../tests/fixtures/collections-rtl.vue"),
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "button-group-dropdown",
|
key: "button-group-dropdown",
|
||||||
title: "按钮组与下拉根属性",
|
title: "按钮组与下拉根属性",
|
||||||
|
|||||||
@@ -306,3 +306,7 @@ TextField/SearchField共享autoFocus、组内focus状态、字段级validationEr
|
|||||||
## HD-08 Table 空状态、排序焦点与列宽(2026-10-29)
|
## HD-08 Table 空状态、排序焦点与列宽(2026-10-29)
|
||||||
|
|
||||||
TableBody 空状态默认跨全部实际叶子列(含选择列与包装渲染的 TableColumn,随列增减响应式更新;未测量环境回退 1),显式 `colspan` 仍优先;保持 vnode 级空判定,不执行未知组件 setup/render 探测。排序保持列头单一激活路径:点击、Enter、Space 各一次(真实浏览器三手势逐一计数),触发按钮保留键盘焦点与 API,把真实 `:focus-visible` 转发到 `th` 的 `[data-focus-visible]` 钩子,焦点环回到基线位置(th 内嵌 2px 环,按钮 UA 轮廓在列内抑制),浅深主题均实测;`aria-sort="none"` 对可排序未排序列属基线行为(react-aria useTableColumnHeader 同款),维持不变。`defaultWidth="Nfr"` 按固定源权重语义实现(移植 react-stately TableColumnLayout/TableUtils 的 flex-grow 解析,Apache-2.0):px/百分比固定列先扣、fr 列按权重分享剩余宽度、min/max 以违规冻结+再分配收敛、整数级联取整保证列宽和等于表宽;存在 fr 列时未设宽度的列按 `1fr` 参与并启用 `table-layout: fixed` 精确几何,容器缩放重分配、拖动列冻结为像素宽度、RTL 几何一致且拖动方向相反,未测量环境(jsdom)保持原生宽度。保留原生 `th scope=row`、圆角选择器与 resizer `z-index` 修复;`.table__cell` 的 `text-start font-normal` 经实测确认会阻断调用方祖先继承(祖先 font-bold/text-center 不下传),收窄为 `th.hv-table__cell { text-align: inherit; font-weight: inherit }`:行头保持基线 td 排版同时保留调用方级联。真实浏览器几何/拖动/焦点验证见 [任务结果](tasks/results/HD-08-TABLE.md)。
|
TableBody 空状态默认跨全部实际叶子列(含选择列与包装渲染的 TableColumn,随列增减响应式更新;未测量环境回退 1),显式 `colspan` 仍优先;保持 vnode 级空判定,不执行未知组件 setup/render 探测。排序保持列头单一激活路径:点击、Enter、Space 各一次(真实浏览器三手势逐一计数),触发按钮保留键盘焦点与 API,把真实 `:focus-visible` 转发到 `th` 的 `[data-focus-visible]` 钩子,焦点环回到基线位置(th 内嵌 2px 环,按钮 UA 轮廓在列内抑制),浅深主题均实测;`aria-sort="none"` 对可排序未排序列属基线行为(react-aria useTableColumnHeader 同款),维持不变。`defaultWidth="Nfr"` 按固定源权重语义实现(移植 react-stately TableColumnLayout/TableUtils 的 flex-grow 解析,Apache-2.0):px/百分比固定列先扣、fr 列按权重分享剩余宽度、min/max 以违规冻结+再分配收敛、整数级联取整保证列宽和等于表宽;存在 fr 列时未设宽度的列按 `1fr` 参与并启用 `table-layout: fixed` 精确几何,容器缩放重分配、拖动列冻结为像素宽度、RTL 几何一致且拖动方向相反,未测量环境(jsdom)保持原生宽度。保留原生 `th scope=row`、圆角选择器与 resizer `z-index` 修复;`.table__cell` 的 `text-start font-normal` 经实测确认会阻断调用方祖先继承(祖先 font-bold/text-center 不下传),收窄为 `th.hv-table__cell { text-align: inherit; font-weight: inherit }`:行头保持基线 td 排版同时保留调用方级联。真实浏览器几何/拖动/焦点验证见 [任务结果](tasks/results/HD-08-TABLE.md)。
|
||||||
|
|
||||||
|
## HD-10 异步加载、过滤与触发器语义(2026-10-29)
|
||||||
|
|
||||||
|
ComboBox 异步例补滚动到底自动增量加载(IntersectionObserver 哨兵 + 续载链,等价固定源 ListBoxLoadMoreItem 的集合变更重挂载语义),保留取消旧请求(AbortController)与过期响应保护(单调序号令牌);查询切换不混入旧数据;失败进入错误态并可重试(本地数据源以「模拟加载失败」开关注入失败)。本地数据源与固定源 SWAPI 的差异(12 条本地角色/模拟 300ms 延迟/可注入失败)已在示例注释与 combo-box.md 说明。Select 异步例的 IntersectionObserver 未重复实现,真实网络滚动触发经浏览器验证(20→180 条无重复)。Autocomplete 虚拟化例与默认过滤共用 `createBaseContains`(Intl.Collator base 敏感,大小写与变音折叠,cafe 匹配 Café);该匹配器从包根公开,与默认谓词同一实现。Autocomplete 触发器语义经真实浏览器核实:role=button/tabindex=0 为单一 Tab 停靠点(clear button tabindex=-1)、Tab 离开组合、Enter/Space 打开、Escape 关闭并回焦、Delete/Backspace 清除、组合输入(isComposing/229)不触发;插槽数据补齐组合能力——`AutocompleteValue` 提供 `selectedItem` 与携带源数据 `item` 的 `selectedItems`,`ComboBox` 根插槽补 `selectedItem`(均取自根 `items`,集合自发现项为 undefined),不执行未知组件 setup/render、不复制子组件。Dropdown 子菜单 hover 延迟对齐固定源 `useSubmenuTrigger` 契约:新增 `delay`(默认 200ms),底层 Reka 的固定 100ms 悬停计时经受控 open 门重定为该延迟,键盘展开立即生效并取消挂起悬停、指针离开取消;RTL 定位由 Reka 按方向固定(贴父项向右、RTL 向左),真实浏览器 RTL/LTR 几何与延迟实测见 [任务结果](tasks/results/HD-10-COLLECTIONS.md)。Button/Avatar 触发器布局补偿保留(浏览器证据:补偿规则胜出,inline-flex 经 flex 子项块化显示为 flex,非基线 inline-block)。
|
||||||
|
|||||||
@@ -374,3 +374,9 @@ Link/Breadcrumbs 对照固定 ce90ea3;Breadcrumbs 的34种名称移植自该
|
|||||||
|
|
||||||
- packages/vue/src/components/table/widths.ts:移植 react-stately `TableUtils.js`(`calculateColumnSizes` flex-grow 列宽解析、min/max 违规冻结、级联取整)与 `TableColumnLayout.js` 的默认宽度语义(未设宽度按 `1fr`),Apache-2.0;仅函数级移植,无新状态内核。
|
- packages/vue/src/components/table/widths.ts:移植 react-stately `TableUtils.js`(`calculateColumnSizes` flex-grow 列宽解析、min/max 违规冻结、级联取整)与 `TableColumnLayout.js` 的默认宽度语义(未设宽度按 `1fr`),Apache-2.0;仅函数级移植,无新状态内核。
|
||||||
- 排序焦点环转发与空状态跨列自适应为 Vue 适配(基线由 RAC useTableColumnHeader 的 press/focus 与 TableBody colSpan 承担);`aria-sort` 的 `"none"` 输出与基线 useTableColumnHeader 一致,不作改动。
|
- 排序焦点环转发与空状态跨列自适应为 Vue 适配(基线由 RAC useTableColumnHeader 的 press/focus 与 TableBody colSpan 承担);`aria-sort` 的 `"none"` 输出与基线 useTableColumnHeader 一致,不作改动。
|
||||||
|
|
||||||
|
## HD-10 来源(2026-10-29)
|
||||||
|
|
||||||
|
- 子菜单 hover 延迟契约对齐 react-aria `useSubmenuTrigger`(`delay` 默认 200ms、任何 open 请求先取消挂起定时、指针离开取消),Apache-2.0;实现为受控 open 门 + 定时器(Reka 2.11 的固定 100ms 悬停计时不可配置,见 DropdownSubmenuTrigger.vue 注释)。
|
||||||
|
- Autocomplete/ComboBox 的 `selectedItem`/`selectedItems.item` 插槽数据对应上游 `selectedItem`/`(T | null)[] selectedItems` 的值语义;以 Vue 插槽数据补齐,不复制 item 子树(固定源 Callout 的 children 复制行为不移植)。
|
||||||
|
- `createBaseContains` 与 `useFilter({sensitivity:"base"}).contains` 语义一致(locale 敏感折叠),作为公开过滤器与默认谓词共用。
|
||||||
|
|||||||
@@ -453,6 +453,7 @@ export default defineComponent({
|
|||||||
textValue:
|
textValue:
|
||||||
records.value.find((record) => record.key === key)?.text ??
|
records.value.find((record) => record.key === key)?.text ??
|
||||||
String(key),
|
String(key),
|
||||||
|
item: props.items?.find((entry) => entry.id === key),
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
selectionMode: computed(() => props.selectionMode),
|
selectionMode: computed(() => props.selectionMode),
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export default defineComponent({
|
|||||||
defaultChildren,
|
defaultChildren,
|
||||||
selectedText,
|
selectedText,
|
||||||
selectedItems,
|
selectedItems,
|
||||||
|
selectedItem: selectedItems[0] ?? null,
|
||||||
}) ?? defaultChildren;
|
}) ?? defaultChildren;
|
||||||
return h(
|
return h(
|
||||||
"span",
|
"span",
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ import type { CollectionRecord, OwnedCollection } from "../collection/owner";
|
|||||||
import type { useChoiceField } from "../choice/shared";
|
import type { useChoiceField } from "../choice/shared";
|
||||||
|
|
||||||
export type AutocompleteValue = CollectionKey | CollectionKey[] | null;
|
export type AutocompleteValue = CollectionKey | CollectionKey[] | null;
|
||||||
export interface AutocompleteSelectedItem {
|
export interface AutocompleteSelectedItem<T = AutocompleteItem> {
|
||||||
key: CollectionKey;
|
key: CollectionKey;
|
||||||
textValue: string;
|
textValue: string;
|
||||||
|
/** Source entry from the root `items` (absent for collection-discovered items). */
|
||||||
|
item?: T;
|
||||||
}
|
}
|
||||||
export interface AutocompleteOptions {
|
export interface AutocompleteOptions {
|
||||||
modelValue?: AutocompleteValue;
|
modelValue?: AutocompleteValue;
|
||||||
@@ -42,6 +44,12 @@ export interface AutocompleteValueState {
|
|||||||
/** Accepted `textValue`s joined by ", ". */
|
/** Accepted `textValue`s joined by ", ". */
|
||||||
selectedText: string;
|
selectedText: string;
|
||||||
selectedItems: AutocompleteSelectedItem[];
|
selectedItems: AutocompleteSelectedItem[];
|
||||||
|
/**
|
||||||
|
* First accepted entry (the single-select selection), or null. Entries carry
|
||||||
|
* the source `items` data in `item` so callers can compose rich trigger
|
||||||
|
* content from their own records without re-mapping keys.
|
||||||
|
*/
|
||||||
|
selectedItem: AutocompleteSelectedItem | null;
|
||||||
}
|
}
|
||||||
/** Scoped-slot state of the `Autocomplete` root. */
|
/** Scoped-slot state of the `Autocomplete` root. */
|
||||||
export interface AutocompleteState {
|
export interface AutocompleteState {
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ export default defineComponent({
|
|||||||
inputValue: string;
|
inputValue: string;
|
||||||
selectedKey: CollectionKey | null;
|
selectedKey: CollectionKey | null;
|
||||||
selectedKeys: CollectionKey[];
|
selectedKeys: CollectionKey[];
|
||||||
|
selectedItem: ComboBoxItem | null;
|
||||||
}) => VNodeChild;
|
}) => VNodeChild;
|
||||||
}>,
|
}>,
|
||||||
props: {
|
props: {
|
||||||
@@ -653,6 +654,7 @@ export default defineComponent({
|
|||||||
textValue:
|
textValue:
|
||||||
records.value.find((record) => record.key === key)?.text ??
|
records.value.find((record) => record.key === key)?.text ??
|
||||||
String(key),
|
String(key),
|
||||||
|
item: props.items?.find((entry) => entry.id === key),
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
selectionMode: computed(() => props.selectionMode),
|
selectionMode: computed(() => props.selectionMode),
|
||||||
@@ -792,6 +794,10 @@ export default defineComponent({
|
|||||||
? null
|
? null
|
||||||
: (value.value as CollectionKey | null),
|
: (value.value as CollectionKey | null),
|
||||||
selectedKeys: [...keys.value],
|
selectedKeys: [...keys.value],
|
||||||
|
selectedItem:
|
||||||
|
(!Array.isArray(value.value) && value.value != null
|
||||||
|
? (props.items?.find((entry) => entry.id === value.value) ?? null)
|
||||||
|
: null) ?? null,
|
||||||
});
|
});
|
||||||
const children = Array.isArray(rendered)
|
const children = Array.isArray(rendered)
|
||||||
? rendered
|
? rendered
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ export interface ComboBoxState {
|
|||||||
inputValue: string;
|
inputValue: string;
|
||||||
selectedKey: CollectionKey | null;
|
selectedKey: CollectionKey | null;
|
||||||
selectedKeys: CollectionKey[];
|
selectedKeys: CollectionKey[];
|
||||||
|
/**
|
||||||
|
* Source entry from the root `items` matching the single selected key
|
||||||
|
* (null in multiple mode or for custom/discovered values). Lets callers
|
||||||
|
* compose rich value displays from their own data without re-mapping keys.
|
||||||
|
*/
|
||||||
|
selectedItem: ComboBoxItem | null;
|
||||||
}
|
}
|
||||||
/** Scoped-slot state of `ComboBoxValue`. */
|
/** Scoped-slot state of `ComboBoxValue`. */
|
||||||
export interface ComboBoxValueState {
|
export interface ComboBoxValueState {
|
||||||
@@ -26,6 +32,8 @@ export interface ComboBoxValueState {
|
|||||||
export interface ComboBoxSelectedItem {
|
export interface ComboBoxSelectedItem {
|
||||||
key: CollectionKey;
|
key: CollectionKey;
|
||||||
textValue: string;
|
textValue: string;
|
||||||
|
/** Source entry from the root `items` (absent for collection-discovered items). */
|
||||||
|
item?: ComboBoxItem;
|
||||||
}
|
}
|
||||||
/** Props shared by the SFC and the context; keep one schema. */
|
/** Props shared by the SFC and the context; keep one schema. */
|
||||||
export interface ComboBoxOptions {
|
export interface ComboBoxOptions {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
inject,
|
inject,
|
||||||
isVNode,
|
isVNode,
|
||||||
nextTick,
|
nextTick,
|
||||||
|
onBeforeUnmount,
|
||||||
onMounted,
|
onMounted,
|
||||||
provide,
|
provide,
|
||||||
ref,
|
ref,
|
||||||
@@ -31,8 +32,6 @@ import {
|
|||||||
submenuOpenKey,
|
submenuOpenKey,
|
||||||
} from "../menu/context";
|
} from "../menu/context";
|
||||||
import { useOverlayAnimation } from "../overlay/animation";
|
import { useOverlayAnimation } from "../overlay/animation";
|
||||||
import { resolvePlacement, type OverlayPlacement } from "../overlay/placement";
|
|
||||||
import { useConfig } from "../../providers/context";
|
|
||||||
import { elementFromValue, menuSurfaceFromVNode } from "./dom";
|
import { elementFromValue, menuSurfaceFromVNode } from "./dom";
|
||||||
import DropdownPopover from "./DropdownPopover.vue";
|
import DropdownPopover from "./DropdownPopover.vue";
|
||||||
|
|
||||||
@@ -104,16 +103,72 @@ function inheritedProps(props: Record<string, unknown> | null) {
|
|||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "DropdownSubmenuTrigger",
|
name: "DropdownSubmenuTrigger",
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
setup(_, { slots }) {
|
props: {
|
||||||
|
/**
|
||||||
|
* Hover-to-open delay in ms (the pinned useSubmenuTrigger contract).
|
||||||
|
* Keyboard and programmatic opens stay immediate and cancel the pending
|
||||||
|
* hover open, matching the baseline.
|
||||||
|
*/
|
||||||
|
delay: { type: Number, default: 200 },
|
||||||
|
},
|
||||||
|
setup(props, { slots }) {
|
||||||
const attrs = useAttrs();
|
const attrs = useAttrs();
|
||||||
const dropdownCtx = inject(dropdownContextKey, null);
|
const dropdownCtx = inject(dropdownContextKey, null);
|
||||||
const config = useConfig();
|
|
||||||
provide(submenuContentKey, true);
|
provide(submenuContentKey, true);
|
||||||
|
|
||||||
const subOpen = ref(false);
|
const subOpen = ref(false);
|
||||||
const triggerRef = ref<unknown>(null);
|
const triggerRef = ref<unknown>(null);
|
||||||
const contentElement = ref<HTMLElement | null>(null);
|
const contentElement = ref<HTMLElement | null>(null);
|
||||||
const fallbackId = useId();
|
const fallbackId = useId();
|
||||||
|
/**
|
||||||
|
* Reka's MenuSubTrigger opens submenus after a fixed 100ms hover, while the
|
||||||
|
* pinned source waits `delay` (200ms by default). The controlled open gate
|
||||||
|
* below defers hover-driven opens to the configured delay: our own timer
|
||||||
|
* owns the hover open, early hover requests are swallowed, and keyboard
|
||||||
|
* opens (which arrive during a keydown) cancel the pending timer and open
|
||||||
|
* at once like the baseline.
|
||||||
|
*/
|
||||||
|
const hoverOpenTimer = ref<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
let duringKeydown = false;
|
||||||
|
function clearHoverOpen() {
|
||||||
|
if (hoverOpenTimer.value) {
|
||||||
|
clearTimeout(hoverOpenTimer.value);
|
||||||
|
hoverOpenTimer.value = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function scheduleHoverOpen() {
|
||||||
|
if (hoverOpenTimer.value || subOpen.value) return;
|
||||||
|
if (!(props.delay > 0)) {
|
||||||
|
subOpen.value = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
hoverOpenTimer.value = setTimeout(() => {
|
||||||
|
hoverOpenTimer.value = null;
|
||||||
|
subOpen.value = true;
|
||||||
|
}, props.delay);
|
||||||
|
}
|
||||||
|
function itemPointerMove(event: Event) {
|
||||||
|
if ((event as MouseEvent).defaultPrevented) return;
|
||||||
|
// Same gate as Reka's SubTrigger: only mouse hover starts the open.
|
||||||
|
if ((event as PointerEvent).pointerType !== "mouse") return;
|
||||||
|
scheduleHoverOpen();
|
||||||
|
}
|
||||||
|
function itemPointerLeave() {
|
||||||
|
clearHoverOpen();
|
||||||
|
}
|
||||||
|
function globalKeydownCapture() {
|
||||||
|
duringKeydown = true;
|
||||||
|
queueMicrotask(() => {
|
||||||
|
duringKeydown = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
onMounted(() =>
|
||||||
|
window.addEventListener("keydown", globalKeydownCapture, true),
|
||||||
|
);
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
window.removeEventListener("keydown", globalKeydownCapture, true);
|
||||||
|
clearHoverOpen();
|
||||||
|
});
|
||||||
const contentAttrs = {
|
const contentAttrs = {
|
||||||
label: ref<string | undefined>(),
|
label: ref<string | undefined>(),
|
||||||
labelledBy: ref<string | undefined>(),
|
labelledBy: ref<string | undefined>(),
|
||||||
@@ -224,9 +279,6 @@ export default defineComponent({
|
|||||||
if (!CONTROL_PROPS.has(key)) domProps[key] = value;
|
if (!CONTROL_PROPS.has(key)) domProps[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const placement = (popoverProps.placement as OverlayPlacement) ?? "end";
|
|
||||||
const position = resolvePlacement(placement, config?.dir.value ?? "ltr");
|
|
||||||
|
|
||||||
panelConfig.dismissDisabled =
|
panelConfig.dismissDisabled =
|
||||||
(popoverProps.isKeyboardDismissDisabled as boolean | undefined) ??
|
(popoverProps.isKeyboardDismissDisabled as boolean | undefined) ??
|
||||||
false;
|
false;
|
||||||
@@ -234,8 +286,10 @@ export default defineComponent({
|
|||||||
popoverProps.shouldCloseOnInteractOutside as
|
popoverProps.shouldCloseOnInteractOutside as
|
||||||
((event: Event) => boolean) | undefined;
|
((event: Event) => boolean) | undefined;
|
||||||
|
|
||||||
// Reka fixes the submenu side/align to the parent convention, so only
|
// Reka's MenuSubContent fixes the submenu side/align to the parent
|
||||||
// the offsets/collision props can be forwarded.
|
// convention (right in LTR, left in RTL) and only accepts the offsets /
|
||||||
|
// collision props here: forwarded side/align attrs never reach the
|
||||||
|
// popper placement (the template binding wins), so they are not passed.
|
||||||
const panelProps: Record<string, unknown> = {
|
const panelProps: Record<string, unknown> = {
|
||||||
sideOffset:
|
sideOffset:
|
||||||
(popoverProps.sideOffset as number | undefined) ??
|
(popoverProps.sideOffset as number | undefined) ??
|
||||||
@@ -256,9 +310,6 @@ export default defineComponent({
|
|||||||
contentAttrs.loop.value ??
|
contentAttrs.loop.value ??
|
||||||
false,
|
false,
|
||||||
};
|
};
|
||||||
const side = (popoverProps.side as string | undefined) ?? position.side;
|
|
||||||
const align =
|
|
||||||
(popoverProps.align as string | undefined) ?? position.align;
|
|
||||||
|
|
||||||
const keydownChain = [
|
const keydownChain = [
|
||||||
...asArray(popoverProps.onKeydown as Handler),
|
...asArray(popoverProps.onKeydown as Handler),
|
||||||
@@ -309,6 +360,14 @@ export default defineComponent({
|
|||||||
{
|
{
|
||||||
open: subOpen.value,
|
open: subOpen.value,
|
||||||
"onUpdate:open": (value: boolean) => {
|
"onUpdate:open": (value: boolean) => {
|
||||||
|
if (value) {
|
||||||
|
// Reka's fixed 100ms hover timer requests the open before the
|
||||||
|
// configured delay; the delay owns that open instead. Keyboard
|
||||||
|
// opens arrive during a keydown and pass through at once,
|
||||||
|
// cancelling the pending hover open like the baseline.
|
||||||
|
if (hoverOpenTimer.value && !duringKeydown) return;
|
||||||
|
clearHoverOpen();
|
||||||
|
} else clearHoverOpen();
|
||||||
subOpen.value = value;
|
subOpen.value = value;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -333,6 +392,9 @@ export default defineComponent({
|
|||||||
// Escape with focus on the trigger (pointer-opened
|
// Escape with focus on the trigger (pointer-opened
|
||||||
// submenu) must also close only this level.
|
// submenu) must also close only this level.
|
||||||
onKeydown: handleEscape,
|
onKeydown: handleEscape,
|
||||||
|
// Hover intent drives the configured open delay.
|
||||||
|
onPointermove: itemPointerMove,
|
||||||
|
onPointerleave: itemPointerLeave,
|
||||||
})
|
})
|
||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
@@ -347,8 +409,7 @@ export default defineComponent({
|
|||||||
{
|
{
|
||||||
...domProps,
|
...domProps,
|
||||||
...panelProps,
|
...panelProps,
|
||||||
side,
|
// experiment: stop forwarding side/align
|
||||||
align,
|
|
||||||
...ariaProps,
|
...ariaProps,
|
||||||
class: [
|
class: [
|
||||||
dropdownCtx?.slots.value.popover(),
|
dropdownCtx?.slots.value.popover(),
|
||||||
|
|||||||
@@ -449,6 +449,13 @@ export {
|
|||||||
} from "./composables/useOverlayState";
|
} from "./composables/useOverlayState";
|
||||||
export { default as ConfigProvider } from "./providers/ConfigProvider.vue";
|
export { default as ConfigProvider } from "./providers/ConfigProvider.vue";
|
||||||
export { useLocale } from "./providers/context";
|
export { useLocale } from "./providers/context";
|
||||||
|
/**
|
||||||
|
* Locale-aware base-sensitivity substring matcher (case + diacritic folding,
|
||||||
|
* e.g. `cafe` matches `Café`). Same implementation as the Autocomplete /
|
||||||
|
* ComboBox default filter; use it when a caller filters its own data for the
|
||||||
|
* component (virtualized or async sources) and wants matching semantics.
|
||||||
|
*/
|
||||||
|
export { createBaseContains } from "./components/collection/match";
|
||||||
export type { ConfigProviderProps } from "./types";
|
export type { ConfigProviderProps } from "./types";
|
||||||
|
|
||||||
export { default as Modal } from "./components/modal/Modal";
|
export { default as Modal } from "./components/modal/Modal";
|
||||||
|
|||||||
@@ -1316,3 +1316,113 @@ it("menu-level close policy wins over the section mode default", async () => {
|
|||||||
await nextTick();
|
await nextTick();
|
||||||
expect(document.querySelector('[data-slot="menu-item"]')).not.toBeNull();
|
expect(document.querySelector('[data-slot="menu-item"]')).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function mountSubmenuWithDelay(delay?: number) {
|
||||||
|
mountApp(
|
||||||
|
() => () =>
|
||||||
|
h(DropdownRoot, { defaultOpen: true }, () => [
|
||||||
|
h(DropdownTrigger, {}, () => h(Button, () => "菜单")),
|
||||||
|
h(DropdownPopover, {}, () =>
|
||||||
|
h(DropdownMenu, {}, () => [
|
||||||
|
h(DropdownSubmenuTrigger, { delay }, () => [
|
||||||
|
h(DropdownItem, { id: "share", textValue: "分享" }, () => [
|
||||||
|
h(Label, () => "分享"),
|
||||||
|
h(DropdownSubmenuIndicator),
|
||||||
|
]),
|
||||||
|
h(DropdownPopover, {}, () =>
|
||||||
|
h(DropdownMenu, {}, () =>
|
||||||
|
h(
|
||||||
|
DropdownItem,
|
||||||
|
{ id: "whatsapp", textValue: "WhatsApp" },
|
||||||
|
() => h(Label, () => "WhatsApp"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hoverMove(node: Element) {
|
||||||
|
node.dispatchEvent(pointer("pointermove", { pointerType: "mouse" }));
|
||||||
|
}
|
||||||
|
|
||||||
|
function subContent() {
|
||||||
|
return document.querySelector("[data-submenu-content]");
|
||||||
|
}
|
||||||
|
|
||||||
|
it("submenu hover opens after the baseline delay (200ms), not Reka's fixed 100ms", async () => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
mountSubmenuWithDelay();
|
||||||
|
await flushPromises();
|
||||||
|
await nextTick();
|
||||||
|
const trigger = document.querySelector(
|
||||||
|
'[data-slot="menu-item"][data-has-submenu="true"]',
|
||||||
|
) as HTMLElement;
|
||||||
|
hoverMove(trigger);
|
||||||
|
// Reka's own 100ms timer requests the open; the configured delay defers it.
|
||||||
|
await vi.advanceTimersByTimeAsync(150);
|
||||||
|
await nextTick();
|
||||||
|
expect(subContent()).toBeNull();
|
||||||
|
await vi.advanceTimersByTimeAsync(100);
|
||||||
|
await nextTick();
|
||||||
|
expect(subContent()).toBeTruthy();
|
||||||
|
vi.useRealTimers();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("submenu hover honors a custom delay and pointer leave cancels it", async () => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
mountSubmenuWithDelay(600);
|
||||||
|
await flushPromises();
|
||||||
|
await nextTick();
|
||||||
|
const trigger = document.querySelector(
|
||||||
|
'[data-slot="menu-item"][data-has-submenu="true"]',
|
||||||
|
) as HTMLElement;
|
||||||
|
hoverMove(trigger);
|
||||||
|
await vi.advanceTimersByTimeAsync(400);
|
||||||
|
await nextTick();
|
||||||
|
expect(subContent()).toBeNull();
|
||||||
|
trigger.dispatchEvent(pointer("pointerleave", { pointerType: "mouse" }));
|
||||||
|
await vi.advanceTimersByTimeAsync(500);
|
||||||
|
await nextTick();
|
||||||
|
expect(subContent()).toBeNull();
|
||||||
|
// A fresh hover re-arms the full delay.
|
||||||
|
hoverMove(trigger);
|
||||||
|
await vi.advanceTimersByTimeAsync(300);
|
||||||
|
await nextTick();
|
||||||
|
expect(subContent()).toBeNull();
|
||||||
|
await vi.advanceTimersByTimeAsync(350);
|
||||||
|
await nextTick();
|
||||||
|
expect(subContent()).toBeTruthy();
|
||||||
|
vi.useRealTimers();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("keyboard submenu open is immediate and cancels the pending hover open", async () => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
mountSubmenuWithDelay();
|
||||||
|
await flushPromises();
|
||||||
|
await nextTick();
|
||||||
|
const trigger = document.querySelector(
|
||||||
|
'[data-slot="menu-item"][data-has-submenu="true"]',
|
||||||
|
) as HTMLElement;
|
||||||
|
hoverMove(trigger);
|
||||||
|
await vi.advanceTimersByTimeAsync(50);
|
||||||
|
trigger.focus();
|
||||||
|
trigger.dispatchEvent(
|
||||||
|
new KeyboardEvent("keydown", {
|
||||||
|
key: "ArrowRight",
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
await flushPromises();
|
||||||
|
await nextTick();
|
||||||
|
expect(subContent()).toBeTruthy();
|
||||||
|
// The cancelled hover timer must not produce a second open request later.
|
||||||
|
await vi.advanceTimersByTimeAsync(400);
|
||||||
|
await nextTick();
|
||||||
|
expect(subContent()).toBeTruthy();
|
||||||
|
vi.useRealTimers();
|
||||||
|
});
|
||||||
|
|||||||
@@ -218,3 +218,113 @@ describe("ComboBox docs and demos", () => {
|
|||||||
mounted.pop();
|
mounted.pop();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("asynchronous loading demo", () => {
|
||||||
|
class FakeIntersectionObserver {
|
||||||
|
static instances: FakeIntersectionObserver[] = [];
|
||||||
|
callback: (entries: unknown[]) => void;
|
||||||
|
constructor(callback: (entries: unknown[]) => void) {
|
||||||
|
this.callback = callback;
|
||||||
|
FakeIntersectionObserver.instances.push(this);
|
||||||
|
}
|
||||||
|
observe() {}
|
||||||
|
unobserve() {}
|
||||||
|
disconnect() {}
|
||||||
|
trigger(isIntersecting: boolean) {
|
||||||
|
this.callback([{ isIntersecting }]);
|
||||||
|
}
|
||||||
|
static last() {
|
||||||
|
return FakeIntersectionObserver.instances.at(-1)!;
|
||||||
|
}
|
||||||
|
static reset() {
|
||||||
|
FakeIntersectionObserver.instances = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function mountAsyncDemo() {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
vi.stubGlobal("IntersectionObserver", FakeIntersectionObserver);
|
||||||
|
FakeIntersectionObserver.reset();
|
||||||
|
const demo = (
|
||||||
|
await import("../apps/docs/demos/combo-box-asynchronous-loading.vue")
|
||||||
|
).default;
|
||||||
|
const w = mount(demo, { attachTo: document.body });
|
||||||
|
mounted.push(w);
|
||||||
|
// Initial page resolves on the simulated latency.
|
||||||
|
await vi.advanceTimersByTimeAsync(350);
|
||||||
|
await nextTick();
|
||||||
|
(w.get('[data-slot="input"]').element as HTMLInputElement).focus();
|
||||||
|
await nextTick();
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
const optionNames = () =>
|
||||||
|
[...document.querySelectorAll('[role="option"]')].map((node) =>
|
||||||
|
node.textContent?.trim(),
|
||||||
|
);
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
vi.useRealTimers();
|
||||||
|
vi.unstubAllGlobals();
|
||||||
|
FakeIntersectionObserver.reset();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("auto-loads the next page when the sentinel intersects, without duplicate requests", async () => {
|
||||||
|
const w = await mountAsyncDemo();
|
||||||
|
expect(optionNames()).toHaveLength(4);
|
||||||
|
// Two intersections in the same tick must start one request only: a
|
||||||
|
// duplicated fetch would append the same offset twice.
|
||||||
|
FakeIntersectionObserver.last().trigger(true);
|
||||||
|
FakeIntersectionObserver.last().trigger(true);
|
||||||
|
await vi.advanceTimersByTimeAsync(350);
|
||||||
|
await nextTick();
|
||||||
|
const afterFirst = optionNames();
|
||||||
|
expect(afterFirst).toHaveLength(8);
|
||||||
|
expect(new Set(afterFirst).size).toBe(8);
|
||||||
|
// The chain fills the remaining page while the sentinel stays visible.
|
||||||
|
await vi.advanceTimersByTimeAsync(350);
|
||||||
|
await nextTick();
|
||||||
|
expect(optionNames()).toHaveLength(12);
|
||||||
|
expect(document.body.textContent).not.toContain("加载更多…");
|
||||||
|
void w;
|
||||||
|
});
|
||||||
|
|
||||||
|
it("drops stale responses when the query switches mid-flight", async () => {
|
||||||
|
await mountAsyncDemo();
|
||||||
|
const input = document.querySelector<HTMLInputElement>(
|
||||||
|
'[data-slot="input"]',
|
||||||
|
)!;
|
||||||
|
input.value = "vader";
|
||||||
|
input.dispatchEvent(new Event("input", { bubbles: true }));
|
||||||
|
await vi.advanceTimersByTimeAsync(100);
|
||||||
|
input.value = "solo";
|
||||||
|
input.dispatchEvent(new Event("input", { bubbles: true }));
|
||||||
|
await vi.advanceTimersByTimeAsync(800);
|
||||||
|
await nextTick();
|
||||||
|
const names = optionNames();
|
||||||
|
expect(names).toEqual(["Han Solo"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("retries a failed page from the error state", async () => {
|
||||||
|
const w = await mountAsyncDemo();
|
||||||
|
const checkbox = w.get('input[type="checkbox"]');
|
||||||
|
await checkbox.setValue(true);
|
||||||
|
FakeIntersectionObserver.last().trigger(true);
|
||||||
|
await vi.advanceTimersByTimeAsync(350);
|
||||||
|
await nextTick();
|
||||||
|
// The error row renders inside the teleported popover surface.
|
||||||
|
expect(document.body.textContent).toContain("重试");
|
||||||
|
expect(optionNames()).toHaveLength(4);
|
||||||
|
await checkbox.setValue(false);
|
||||||
|
const retry = [...document.querySelectorAll("button")].find(
|
||||||
|
(button) => button.textContent?.trim() === "重试",
|
||||||
|
)!;
|
||||||
|
expect(retry).toBeTruthy();
|
||||||
|
retry.click();
|
||||||
|
await vi.advanceTimersByTimeAsync(350);
|
||||||
|
await nextTick();
|
||||||
|
expect(document.body.textContent).not.toContain("重试");
|
||||||
|
expect(optionNames()).toHaveLength(8);
|
||||||
|
void w;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Vendored
+88
@@ -0,0 +1,88 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, defineComponent, h, ref } from "vue";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
ConfigProvider,
|
||||||
|
DropdownItem,
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownPopover,
|
||||||
|
DropdownRoot,
|
||||||
|
DropdownSubmenuIndicator,
|
||||||
|
DropdownSubmenuTrigger,
|
||||||
|
DropdownTrigger,
|
||||||
|
Label,
|
||||||
|
useLocale,
|
||||||
|
} from "@heroui-vue/components";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HD-10 submenu verification harness: the pinned RTL behaviour (submenu flips
|
||||||
|
* to the left of its trigger) and the configurable hover delay, driven through
|
||||||
|
* the public ConfigProvider direction contract.
|
||||||
|
*/
|
||||||
|
const rtl = ref(true);
|
||||||
|
const opened = ref(0);
|
||||||
|
const localeDir = useLocale().dir;
|
||||||
|
const probe = computed(() => `outer-dir=${localeDir.value}`);
|
||||||
|
const InnerProbe = defineComponent({
|
||||||
|
setup() {
|
||||||
|
const dir = useLocale().dir;
|
||||||
|
return () =>
|
||||||
|
h("output", { "data-probe-inner": "" }, `inner-dir=${dir.value}`);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<main style="padding: 24px; display: grid; gap: 16px; justify-items: center">
|
||||||
|
<label>
|
||||||
|
<input v-model="rtl" type="checkbox" />
|
||||||
|
RTL(ConfigProvider dir)
|
||||||
|
</label>
|
||||||
|
<output data-probe>{{ probe }}</output>
|
||||||
|
<ConfigProvider :dir="rtl ? 'rtl' : 'ltr'">
|
||||||
|
<InnerProbe />
|
||||||
|
<div style="width: 700px; display: flex; justify-content: center">
|
||||||
|
<DropdownRoot :dir="rtl ? 'rtl' : 'ltr'" @open-change="opened++">
|
||||||
|
<DropdownTrigger>
|
||||||
|
<Button aria-label="菜单">菜单</Button>
|
||||||
|
</DropdownTrigger>
|
||||||
|
<DropdownPopover>
|
||||||
|
<DropdownMenu aria-label="示例菜单">
|
||||||
|
<DropdownItem id="copy" text-value="复制">
|
||||||
|
<Label>复制</Label>
|
||||||
|
</DropdownItem>
|
||||||
|
<!-- Baseline default delay: 200ms. -->
|
||||||
|
<DropdownSubmenuTrigger>
|
||||||
|
<DropdownItem id="share" text-value="分享">
|
||||||
|
<Label>分享(默认延迟)</Label>
|
||||||
|
<DropdownSubmenuIndicator />
|
||||||
|
</DropdownItem>
|
||||||
|
<DropdownPopover>
|
||||||
|
<DropdownMenu aria-label="分享">
|
||||||
|
<DropdownItem id="mail" text-value="邮件">
|
||||||
|
<Label>邮件</Label>
|
||||||
|
</DropdownItem>
|
||||||
|
</DropdownMenu>
|
||||||
|
</DropdownPopover>
|
||||||
|
</DropdownSubmenuTrigger>
|
||||||
|
<!-- Custom delay: 600ms. -->
|
||||||
|
<DropdownSubmenuTrigger :delay="600">
|
||||||
|
<DropdownItem id="more" text-value="更多">
|
||||||
|
<Label>更多(600ms 延迟)</Label>
|
||||||
|
<DropdownSubmenuIndicator />
|
||||||
|
</DropdownItem>
|
||||||
|
<DropdownPopover>
|
||||||
|
<DropdownMenu aria-label="更多">
|
||||||
|
<DropdownItem id="report" text-value="举报">
|
||||||
|
<Label>举报</Label>
|
||||||
|
</DropdownItem>
|
||||||
|
</DropdownMenu>
|
||||||
|
</DropdownPopover>
|
||||||
|
</DropdownSubmenuTrigger>
|
||||||
|
</DropdownMenu>
|
||||||
|
</DropdownPopover>
|
||||||
|
</DropdownRoot>
|
||||||
|
</div>
|
||||||
|
</ConfigProvider>
|
||||||
|
</main>
|
||||||
|
</template>
|
||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
ComboBoxValue,
|
ComboBoxValue,
|
||||||
ListBox,
|
ListBox,
|
||||||
ListBoxItem,
|
ListBoxItem,
|
||||||
|
createBaseContains,
|
||||||
type AutocompleteItem,
|
type AutocompleteItem,
|
||||||
type AutocompleteProps,
|
type AutocompleteProps,
|
||||||
type AutocompleteState,
|
type AutocompleteState,
|
||||||
@@ -152,8 +153,11 @@ const badComboEvent = h(ComboBox, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Root scoped slots expose the open/selection state.
|
// Root scoped slots expose the open/selection state.
|
||||||
|
const sharedMatcher: (text: string, query: string) => boolean =
|
||||||
|
createBaseContains("zh-CN");
|
||||||
|
void sharedMatcher("Café", "cafe");
|
||||||
const comboState = (state: ComboBoxState): string =>
|
const comboState = (state: ComboBoxState): string =>
|
||||||
`${state.isOpen}:${state.inputValue}:${state.selectedKeys.length}`;
|
`${state.isOpen}:${state.inputValue}:${state.selectedKeys.length}:${state.selectedItem?.textValue ?? ""}`;
|
||||||
const autocompleteState = (state: AutocompleteState): string =>
|
const autocompleteState = (state: AutocompleteState): string =>
|
||||||
`${state.isOpen}:${state.selectedKeys.length}`;
|
`${state.isOpen}:${state.selectedKeys.length}`;
|
||||||
const comboValueState = (state: ComboBoxValueState): string =>
|
const comboValueState = (state: ComboBoxValueState): string =>
|
||||||
@@ -191,6 +195,9 @@ const autocompleteTree = h(Autocomplete, { "aria-label": "州" }, () => [
|
|||||||
const placeholder: boolean = state.isPlaceholder;
|
const placeholder: boolean = state.isPlaceholder;
|
||||||
const joined: string = state.selectedText || state.defaultChildren;
|
const joined: string = state.selectedText || state.defaultChildren;
|
||||||
const keys = state.selectedItems.map((item) => item.key);
|
const keys = state.selectedItems.map((item) => item.key);
|
||||||
|
// Source `items` data rides along for rich trigger composition.
|
||||||
|
const source = state.selectedItem?.item?.textValue ?? "";
|
||||||
|
void source;
|
||||||
return placeholder ? joined : keys.join(",");
|
return placeholder ? joined : keys.join(",");
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -80,7 +80,8 @@
|
|||||||
"AutocompletePopover",
|
"AutocompletePopover",
|
||||||
"AutocompleteFilter",
|
"AutocompleteFilter",
|
||||||
"comboBoxVariants",
|
"comboBoxVariants",
|
||||||
"autocompleteVariants"
|
"autocompleteVariants",
|
||||||
|
"createBaseContains"
|
||||||
],
|
],
|
||||||
"css": [
|
"css": [
|
||||||
".hv-combo-box",
|
".hv-combo-box",
|
||||||
@@ -169,7 +170,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"color-field-protocol": {
|
"color-field-protocol": {
|
||||||
"exports": ["ColorPicker"],
|
"exports": [
|
||||||
|
"ColorPicker"
|
||||||
|
],
|
||||||
"css": [
|
"css": [
|
||||||
".hv-color-field",
|
".hv-color-field",
|
||||||
".hv-color-input-group",
|
".hv-color-input-group",
|
||||||
@@ -180,8 +183,13 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"color-foundation": {
|
"color-foundation": {
|
||||||
"exports": ["ColorPicker"],
|
"exports": [
|
||||||
"css": [".hv-color-area", ".hv-color-area__thumb"]
|
"ColorPicker"
|
||||||
|
],
|
||||||
|
"css": [
|
||||||
|
".hv-color-area",
|
||||||
|
".hv-color-area__thumb"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"color-picker-protocol": {
|
"color-picker-protocol": {
|
||||||
"exports": [
|
"exports": [
|
||||||
@@ -198,7 +206,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"color-slider-foundation": {
|
"color-slider-foundation": {
|
||||||
"exports": ["ColorPicker"],
|
"exports": [
|
||||||
|
"ColorPicker"
|
||||||
|
],
|
||||||
"css": [
|
"css": [
|
||||||
".hv-color-slider",
|
".hv-color-slider",
|
||||||
".hv-color-slider__track",
|
".hv-color-slider__track",
|
||||||
@@ -290,7 +300,11 @@
|
|||||||
"PaginationItem",
|
"PaginationItem",
|
||||||
"PaginationLink"
|
"PaginationLink"
|
||||||
],
|
],
|
||||||
"css": ["hv-header", "hv-pagination", "hv-input-otp"]
|
"css": [
|
||||||
|
"hv-header",
|
||||||
|
"hv-pagination",
|
||||||
|
"hv-input-otp"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"m33-m34": {
|
"m33-m34": {
|
||||||
"exports": [
|
"exports": [
|
||||||
@@ -402,7 +416,10 @@
|
|||||||
"Label",
|
"Label",
|
||||||
"sliderVariants"
|
"sliderVariants"
|
||||||
],
|
],
|
||||||
"css": [".hv-slider__track", "hv-slider__thumb"]
|
"css": [
|
||||||
|
".hv-slider__track",
|
||||||
|
"hv-slider__thumb"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"color-swatch": {
|
"color-swatch": {
|
||||||
"exports": [
|
"exports": [
|
||||||
@@ -607,7 +624,12 @@
|
|||||||
"FieldError",
|
"FieldError",
|
||||||
"Button"
|
"Button"
|
||||||
],
|
],
|
||||||
"css": [".hv-textfield", ".hv-input", ".hv-field-error", ".hv-button"]
|
"css": [
|
||||||
|
".hv-textfield",
|
||||||
|
".hv-input",
|
||||||
|
".hv-field-error",
|
||||||
|
".hv-button"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"api-root-aliases": {
|
"api-root-aliases": {
|
||||||
"exports": [
|
"exports": [
|
||||||
@@ -778,88 +800,334 @@
|
|||||||
"TypographyRoot"
|
"TypographyRoot"
|
||||||
],
|
],
|
||||||
"aliases": [
|
"aliases": [
|
||||||
["Accordion", "AccordionRoot"],
|
[
|
||||||
["Alert", "AlertRoot"],
|
"Accordion",
|
||||||
["AlertDialog", "AlertDialogRoot"],
|
"AccordionRoot"
|
||||||
["Autocomplete", "AutocompleteRoot"],
|
],
|
||||||
["Avatar", "AvatarRoot"],
|
[
|
||||||
["AvatarGroup", "AvatarGroupRoot"],
|
"Alert",
|
||||||
["Badge", "BadgeRoot"],
|
"AlertRoot"
|
||||||
["Breadcrumbs", "BreadcrumbsRoot"],
|
],
|
||||||
["Button", "ButtonRoot"],
|
[
|
||||||
["ButtonGroup", "ButtonGroupRoot"],
|
"AlertDialog",
|
||||||
["Calendar", "CalendarRoot"],
|
"AlertDialogRoot"
|
||||||
["Card", "CardRoot"],
|
],
|
||||||
["Checkbox", "CheckboxRoot"],
|
[
|
||||||
["Chip", "ChipRoot"],
|
"Autocomplete",
|
||||||
["CloseButton", "CloseButtonRoot"],
|
"AutocompleteRoot"
|
||||||
["ColorArea", "ColorAreaRoot"],
|
],
|
||||||
["ColorField", "ColorFieldRoot"],
|
[
|
||||||
["ColorInputGroup", "ColorInputGroupRoot"],
|
"Avatar",
|
||||||
["ColorPicker", "ColorPickerRoot"],
|
"AvatarRoot"
|
||||||
["ColorSlider", "ColorSliderRoot"],
|
],
|
||||||
["ColorSwatch", "ColorSwatchRoot"],
|
[
|
||||||
["ColorSwatchPicker", "ColorSwatchPickerRoot"],
|
"AvatarGroup",
|
||||||
["ComboBox", "ComboBoxRoot"],
|
"AvatarGroupRoot"
|
||||||
["DateField", "DateFieldRoot"],
|
],
|
||||||
["DateInputGroup", "DateInputGroupRoot"],
|
[
|
||||||
["DatePicker", "DatePickerRoot"],
|
"Badge",
|
||||||
["DateRangePicker", "DateRangePickerRoot"],
|
"BadgeRoot"
|
||||||
["Description", "DescriptionRoot"],
|
],
|
||||||
["Disclosure", "DisclosureRoot"],
|
[
|
||||||
["DisclosureGroup", "DisclosureGroupRoot"],
|
"Breadcrumbs",
|
||||||
["Drawer", "DrawerRoot"],
|
"BreadcrumbsRoot"
|
||||||
["Dropdown", "DropdownRoot"],
|
],
|
||||||
["EmptyState", "EmptyStateRoot"],
|
[
|
||||||
["ErrorMessage", "ErrorMessageRoot"],
|
"Button",
|
||||||
["FieldError", "FieldErrorRoot"],
|
"ButtonRoot"
|
||||||
["Fieldset", "FieldsetRoot"],
|
],
|
||||||
["Form", "FormRoot"],
|
[
|
||||||
["Header", "HeaderRoot"],
|
"ButtonGroup",
|
||||||
["Input", "InputRoot"],
|
"ButtonGroupRoot"
|
||||||
["InputGroup", "InputGroupRoot"],
|
],
|
||||||
["InputOTP", "InputOTPRoot"],
|
[
|
||||||
["Kbd", "KbdRoot"],
|
"Calendar",
|
||||||
["Label", "LabelRoot"],
|
"CalendarRoot"
|
||||||
["Link", "LinkRoot"],
|
],
|
||||||
["ListBox", "ListBoxRoot"],
|
[
|
||||||
["ListBoxItem", "ListBoxItemRoot"],
|
"Card",
|
||||||
["ListBoxSection", "ListBoxSectionRoot"],
|
"CardRoot"
|
||||||
["Menu", "MenuRoot"],
|
],
|
||||||
["MenuItem", "MenuItemRoot"],
|
[
|
||||||
["MenuSection", "MenuSectionRoot"],
|
"Checkbox",
|
||||||
["Meter", "MeterRoot"],
|
"CheckboxRoot"
|
||||||
["Modal", "ModalRoot"],
|
],
|
||||||
["NumberField", "NumberFieldRoot"],
|
[
|
||||||
["Pagination", "PaginationRoot"],
|
"Chip",
|
||||||
["Popover", "PopoverRoot"],
|
"ChipRoot"
|
||||||
["ProgressBar", "ProgressBarRoot"],
|
],
|
||||||
["ProgressCircle", "ProgressCircleRoot"],
|
[
|
||||||
["Radio", "RadioRoot"],
|
"CloseButton",
|
||||||
["RadioGroup", "RadioGroupRoot"],
|
"CloseButtonRoot"
|
||||||
["RangeCalendar", "RangeCalendarRoot"],
|
],
|
||||||
["ScrollShadow", "ScrollShadowRoot"],
|
[
|
||||||
["SearchField", "SearchFieldRoot"],
|
"ColorArea",
|
||||||
["Select", "SelectRoot"],
|
"ColorAreaRoot"
|
||||||
["Separator", "SeparatorRoot"],
|
],
|
||||||
["Skeleton", "SkeletonRoot"],
|
[
|
||||||
["Slider", "SliderRoot"],
|
"ColorField",
|
||||||
["Spinner", "SpinnerRoot"],
|
"ColorFieldRoot"
|
||||||
["Surface", "SurfaceRoot"],
|
],
|
||||||
["Switch", "SwitchRoot"],
|
[
|
||||||
["SwitchGroup", "SwitchGroupRoot"],
|
"ColorInputGroup",
|
||||||
["Table", "TableRoot"],
|
"ColorInputGroupRoot"
|
||||||
["Tabs", "TabsRoot"],
|
],
|
||||||
["Tag", "TagRoot"],
|
[
|
||||||
["TagGroup", "TagGroupRoot"],
|
"ColorPicker",
|
||||||
["TextArea", "TextAreaRoot"],
|
"ColorPickerRoot"
|
||||||
["TextField", "TextFieldRoot"],
|
],
|
||||||
["TimeField", "TimeFieldRoot"],
|
[
|
||||||
["ToggleButton", "ToggleButtonRoot"],
|
"ColorSlider",
|
||||||
["ToggleButtonGroup", "ToggleButtonGroupRoot"],
|
"ColorSliderRoot"
|
||||||
["Toolbar", "ToolbarRoot"],
|
],
|
||||||
["Tooltip", "TooltipRoot"],
|
[
|
||||||
["Typography", "TypographyRoot"]
|
"ColorSwatch",
|
||||||
|
"ColorSwatchRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"ColorSwatchPicker",
|
||||||
|
"ColorSwatchPickerRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"ComboBox",
|
||||||
|
"ComboBoxRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"DateField",
|
||||||
|
"DateFieldRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"DateInputGroup",
|
||||||
|
"DateInputGroupRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"DatePicker",
|
||||||
|
"DatePickerRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"DateRangePicker",
|
||||||
|
"DateRangePickerRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Description",
|
||||||
|
"DescriptionRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Disclosure",
|
||||||
|
"DisclosureRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"DisclosureGroup",
|
||||||
|
"DisclosureGroupRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Drawer",
|
||||||
|
"DrawerRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Dropdown",
|
||||||
|
"DropdownRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"EmptyState",
|
||||||
|
"EmptyStateRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"ErrorMessage",
|
||||||
|
"ErrorMessageRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"FieldError",
|
||||||
|
"FieldErrorRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Fieldset",
|
||||||
|
"FieldsetRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Form",
|
||||||
|
"FormRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Header",
|
||||||
|
"HeaderRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Input",
|
||||||
|
"InputRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"InputGroup",
|
||||||
|
"InputGroupRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"InputOTP",
|
||||||
|
"InputOTPRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Kbd",
|
||||||
|
"KbdRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Label",
|
||||||
|
"LabelRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Link",
|
||||||
|
"LinkRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"ListBox",
|
||||||
|
"ListBoxRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"ListBoxItem",
|
||||||
|
"ListBoxItemRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"ListBoxSection",
|
||||||
|
"ListBoxSectionRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Menu",
|
||||||
|
"MenuRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"MenuItem",
|
||||||
|
"MenuItemRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"MenuSection",
|
||||||
|
"MenuSectionRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Meter",
|
||||||
|
"MeterRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Modal",
|
||||||
|
"ModalRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"NumberField",
|
||||||
|
"NumberFieldRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Pagination",
|
||||||
|
"PaginationRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Popover",
|
||||||
|
"PopoverRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"ProgressBar",
|
||||||
|
"ProgressBarRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"ProgressCircle",
|
||||||
|
"ProgressCircleRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Radio",
|
||||||
|
"RadioRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"RadioGroup",
|
||||||
|
"RadioGroupRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"RangeCalendar",
|
||||||
|
"RangeCalendarRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"ScrollShadow",
|
||||||
|
"ScrollShadowRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"SearchField",
|
||||||
|
"SearchFieldRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Select",
|
||||||
|
"SelectRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Separator",
|
||||||
|
"SeparatorRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Skeleton",
|
||||||
|
"SkeletonRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Slider",
|
||||||
|
"SliderRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Spinner",
|
||||||
|
"SpinnerRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Surface",
|
||||||
|
"SurfaceRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Switch",
|
||||||
|
"SwitchRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"SwitchGroup",
|
||||||
|
"SwitchGroupRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Table",
|
||||||
|
"TableRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Tabs",
|
||||||
|
"TabsRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Tag",
|
||||||
|
"TagRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"TagGroup",
|
||||||
|
"TagGroupRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"TextArea",
|
||||||
|
"TextAreaRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"TextField",
|
||||||
|
"TextFieldRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"TimeField",
|
||||||
|
"TimeFieldRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"ToggleButton",
|
||||||
|
"ToggleButtonRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"ToggleButtonGroup",
|
||||||
|
"ToggleButtonGroupRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Toolbar",
|
||||||
|
"ToolbarRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Tooltip",
|
||||||
|
"TooltipRoot"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Typography",
|
||||||
|
"TypographyRoot"
|
||||||
|
]
|
||||||
],
|
],
|
||||||
"css": []
|
"css": []
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -446,3 +446,94 @@ it("ComboBox trigger retains a caller disabled attribute", async () => {
|
|||||||
)!.disabled,
|
)!.disabled,
|
||||||
).toBe(true);
|
).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Autocomplete value slot carries the source items for trigger composition", async () => {
|
||||||
|
const source = [{ id: 1, textValue: "Kate", avatarUrl: "/kate.png" }];
|
||||||
|
let state: {
|
||||||
|
isPlaceholder: boolean;
|
||||||
|
selectedItem: { key: unknown; item?: { avatarUrl?: string } } | null;
|
||||||
|
selectedItems: { key: unknown; item?: { avatarUrl?: string } }[];
|
||||||
|
} | null = null;
|
||||||
|
const w = mount(
|
||||||
|
defineComponent({
|
||||||
|
render: () =>
|
||||||
|
h(
|
||||||
|
Autocomplete,
|
||||||
|
{
|
||||||
|
items: source as never,
|
||||||
|
defaultValue: 1,
|
||||||
|
"aria-label": "Picker",
|
||||||
|
selectionMode: "single",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
default: () => [
|
||||||
|
h(AutocompleteTrigger, null, {
|
||||||
|
default: () =>
|
||||||
|
h(AutocompleteValue, null, {
|
||||||
|
default: (slotState: typeof state) => {
|
||||||
|
state = slotState as never;
|
||||||
|
return "";
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
h(AutocompletePopover, null, {
|
||||||
|
default: () =>
|
||||||
|
h(ListBox, null, {
|
||||||
|
default: () =>
|
||||||
|
source.map((item) =>
|
||||||
|
h(
|
||||||
|
ListBoxItem,
|
||||||
|
{ id: item.id, textValue: item.textValue },
|
||||||
|
() => item.textValue,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
{ attachTo: document.body },
|
||||||
|
);
|
||||||
|
roots.push(w);
|
||||||
|
await tick();
|
||||||
|
expect(state).not.toBeNull();
|
||||||
|
expect(state!.isPlaceholder).toBe(false);
|
||||||
|
// The source entry rides along: no consumer-side key lookups needed.
|
||||||
|
expect(state!.selectedItem?.key).toBe(1);
|
||||||
|
expect(state!.selectedItem?.item?.avatarUrl).toBe("/kate.png");
|
||||||
|
expect(state!.selectedItems[0].item?.avatarUrl).toBe("/kate.png");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("ComboBox root slot exposes the selected source item", async () => {
|
||||||
|
const source = [
|
||||||
|
{ id: "a", textValue: "Alpha", meta: "first" },
|
||||||
|
{ id: "b", textValue: "Beta", meta: "second" },
|
||||||
|
];
|
||||||
|
let state: { selectedItem: { id?: unknown; meta?: unknown } | null } | null =
|
||||||
|
null;
|
||||||
|
const w = mount(
|
||||||
|
defineComponent({
|
||||||
|
render: () =>
|
||||||
|
h(
|
||||||
|
ComboBox,
|
||||||
|
{ items: source as never, defaultValue: "b", "aria-label": "Picker" },
|
||||||
|
{
|
||||||
|
default: (slotState: typeof state) => {
|
||||||
|
state = slotState as never;
|
||||||
|
return [
|
||||||
|
h(ComboBoxInputGroup, null, {
|
||||||
|
default: () => [h(Input), h(ComboBoxTrigger)],
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
{ attachTo: document.body },
|
||||||
|
);
|
||||||
|
roots.push(w);
|
||||||
|
await tick();
|
||||||
|
expect(state!.selectedItem?.id).toBe("b");
|
||||||
|
expect(state!.selectedItem?.meta).toBe("second");
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user