import { ReactStore } from '../../store/ReactStore'; import { type ItemEqualityComparer } from '../../internals/itemEquality'; import { PopupTriggerMap } from '../../utils/popups/PopupTriggerMap'; import type { SelectRoot } from '../root/SelectRoot'; /** * Value-to-label data, as either a record keyed by value or an explicit list * (which is what non-string values need). */ export type SelectItems = Record | ReadonlyArray<{ value: unknown; label: string; }>; /** * Resolves a value's label from the consumer's `items`, falling back to the * labels items registered as they mounted. */ export declare function resolveSelectLabel(items: SelectItems | undefined, labelsByValue: Map, value: unknown, comparer?: ItemEqualityComparer): string | undefined; export type State = { open: boolean; openProp: boolean | undefined; /** * The uncontrolled selected value. Read through the `value` selector, which * resolves the controlled prop first. */ value: unknown; /** * The controlled `value` prop, when provided. */ valueProp: unknown; /** * Labels registered by `Select.ItemText` as items mount. */ labelsByValue: Map; /** * The consumer's value-to-label data. Items only register their labels once * they mount, which cannot happen before the popup is first opened — so a * closed select can only render its selected label from this. */ items: SelectItems | undefined; /** * Whether more than one item can be selected, which makes `value` an array. */ multiple: boolean; /** * How an item's value is matched against the selection. Defaults to * `Object.is`, so object values need one of their own. */ isItemEqualToValue: ItemEqualityComparer; disabled: boolean; readOnly: boolean; required: boolean; disablePointerDismissal: boolean; /** * The anchor's native node, carried across the portal boundary. */ triggerNode: unknown; /** * The id of the `Select.Label`, associated with the trigger. `undefined` when * there is no label. */ labelId: string | undefined; update: (() => void) | undefined; /** * The trigger's measured width, used to size the popup. */ triggerWidth: number | undefined; /** * The trigger's measured height. */ triggerHeight: number | undefined; /** * The payload of the trigger the select was opened by, handed to the root's * children when they are a function. */ payload: unknown; /** * The id of the trigger the select is associated with, or `null` for none. */ triggerId: string | null; /** * The controlled `triggerId` prop, when provided. */ triggerIdProp: string | null | undefined; }; type Context = { onValueChange: ((value: any, eventDetails: SelectRoot.ChangeEventDetails) => void) | undefined; onOpenChange: ((open: boolean, eventDetails: SelectRoot.ChangeEventDetails) => void) | undefined; /** * Called once an enter or exit animation has settled, reported by the consumer * through `settled(open)`. zest does not animate anything, so it cannot know * when an animation ends — the consumer drives it and owns the signal. */ onOpenChangeComplete: ((open: boolean, eventDetails: SelectRoot.ChangeEventDetails) => void) | undefined; /** * Every trigger bound to this select, by id. A handle resolves `open(id)` * through this, which is what lets a trigger rendered outside the root open it. */ triggerNodes: PopupTriggerMap; }; declare const selectors: { open: (state: State) => boolean; value: (state: State) => unknown; labelsByValue: (state: State) => Map; items: (state: State) => SelectItems | undefined; multiple: (state: State) => boolean; isItemEqualToValue: (state: State) => ItemEqualityComparer; /** * Whether one item's value is selected. * * Items subscribe to this boolean rather than to the whole selection, so * choosing one row in a long list re-renders only the rows whose answer * actually changed — not every row. `useSyncExternalStore` bails out on an * unchanged value, which is what makes that work. */ isSelected: (args_0: State, itemValue: unknown) => boolean; disabled: (state: State) => boolean; readOnly: (state: State) => boolean; required: (state: State) => boolean; triggerNode: (state: State) => unknown; labelId: (state: State) => string | undefined; update: (state: State) => (() => void) | undefined; triggerWidth: (state: State) => number | undefined; triggerHeight: (state: State) => number | undefined; disablePointerDismissal: (state: State) => boolean; payload: (state: State) => unknown; triggerId: (state: State) => string | null; }; export declare class SelectStore extends ReactStore, Context, typeof selectors> { constructor(initialState?: Partial); setOpen: (nextOpen: boolean, eventDetails: SelectRoot.ChangeEventDetails) => void; /** * Reports that the enter or exit animation for `open` has settled. zest never * animates, so only the consumer knows when their animation finished; calling * this fires `onOpenChangeComplete` with the reason of the last committed * change. Fire-once per settle: a repeated call with the same value is ignored. */ settled: (open: boolean) => void; /** * The event details of the last committed open/close, for `onOpenChangeComplete`. */ private lastChangeEventDetails; /** * The last value `settled` fired for, so the same settle is not reported twice. */ private lastSettledOpen; setValue: (nextValue: unknown, eventDetails: SelectRoot.ChangeEventDetails) => void; registerLabel: (value: unknown, label: string) => void; } export {}; //# sourceMappingURL=SelectStore.d.ts.map