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:
maoyingjie
2026-10-29 13:46:13 +08:00
parent c34faccd70
commit c8d54abefb
21 changed files with 1020 additions and 173 deletions
@@ -446,3 +446,94 @@ it("ComboBox trigger retains a caller disabled attribute", async () => {
)!.disabled,
).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");
});