feat: migrate Select with field, collection and SSR contracts

This commit is contained in:
maoyingjie
2026-10-23 22:05:44 +08:00
parent 65db60a7ac
commit 2b569451b6
52 changed files with 4172 additions and 33 deletions
@@ -0,0 +1,28 @@
import type { ComputedRef, InjectionKey } from "vue";
import type { CollectionKey } from "./keys";
export interface CollectionRecord {
key: CollectionKey;
text: string;
disabled: boolean;
}
export interface OwnedCollection {
items: () => CollectionRecord[];
focus: (edge: "first" | "last" | "selected") => Promise<void>;
}
/** A field composite may own a ListBox, without adding another value store. */
export interface CollectionOwner {
keys: ComputedRef<readonly CollectionKey[]>;
mode: ComputedRef<"single" | "multiple">;
disabled: ComputedRef<boolean>;
readOnly: ComputedRef<boolean>;
disabledKeys: ComputedRef<readonly CollectionKey[]>;
id: string;
labelledBy: () => string | undefined;
ariaLabel: () => string | undefined;
request: (keys: CollectionKey[]) => void;
action: (key: CollectionKey) => void;
leave: () => void;
connect: (collection: OwnedCollection) => () => void;
}
export const collectionOwnerKey: InjectionKey<CollectionOwner | undefined> =
Symbol("hv-collection-owner");