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
|
||||
多选模式下,上游 `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`:
|
||||
@@ -437,15 +437,17 @@ Autocomplete 组件使用以下 CSS 类([查看源码样式](https://github.co
|
||||
| `isPlaceholder` | `boolean` | 是否没有选中项 |
|
||||
| `defaultChildren` | `string`(上游为 `ReactNode`) | 缺省文本(选中项文本以逗号连接,否则占位符) |
|
||||
| `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` hook(`contains` / `startsWith` / `endsWith` 与 `sensitivity`)在本库没有对应导出。替代方式:
|
||||
|
||||
- `AutocompleteFilter` 的默认谓词等价于 `useFilter({ sensitivity: "base" }).contains`:按 `ConfigProvider` 的 locale 折叠大小写与变音符号,`cafe` 能命中 `Café`
|
||||
- 调用方自行过滤数据时(虚拟化、异步数据源),可从包根导入 `createBaseContains`(与默认谓词同一实现)保持语义一致:`const { locale } = useLocale(); const contains = createBaseContains(locale.value)`
|
||||
- 需要 `startsWith` / `endsWith` 等语义时,直接给 `:filter="(text, input) => …"` 传函数
|
||||
- 数据源或调用方已过滤时(异步、虚拟化示例),传 `:filter="() => true"` 避免二次过滤
|
||||
|
||||
|
||||
Reference in New Issue
Block a user