@bazza-ui/react 0.0.0-snapshot-20260205122957

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,659 @@
1
+ import { ReactStore } from '@base-ui/utils/store';
2
+ import * as React$1 from 'react';
3
+
4
+ declare const triggerPress: "trigger-press";
5
+ declare const triggerHover: "trigger-hover";
6
+ declare const triggerFocus: "trigger-focus";
7
+ declare const triggerContextMenu: "trigger-context-menu";
8
+ declare const escapeKey: "escape-key";
9
+ declare const outsidePress: "outside-press";
10
+ declare const focusOut: "focus-out";
11
+ declare const itemPress: "item-press";
12
+ declare const itemKeyboardSelect: "item-keyboard-select";
13
+ declare const closePress: "close-press";
14
+ declare const inputChange: "input-change";
15
+ declare const inputClear: "input-clear";
16
+ declare const clearPress: "clear-press";
17
+ declare const listNavigation: "list-navigation";
18
+ declare const submenuTrigger: "submenu-trigger";
19
+ declare const siblingOpen: "sibling-open";
20
+ declare const pointer: "pointer";
21
+ declare const keyboard: "keyboard";
22
+ declare const auto: "auto";
23
+ declare const imperativeAction: "imperative-action";
24
+ declare const none: "none";
25
+
26
+ /**
27
+ * Maps event reason strings to their corresponding native DOM event types.
28
+ * This provides type-safe access to the native event based on the reason.
29
+ */
30
+ interface ReasonToEventMap {
31
+ [none]: Event;
32
+ [triggerPress]: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent;
33
+ [triggerHover]: MouseEvent | PointerEvent;
34
+ [triggerFocus]: FocusEvent;
35
+ [triggerContextMenu]: MouseEvent;
36
+ [escapeKey]: KeyboardEvent;
37
+ [outsidePress]: MouseEvent | PointerEvent | TouchEvent;
38
+ [focusOut]: FocusEvent | KeyboardEvent;
39
+ [itemPress]: MouseEvent | PointerEvent | KeyboardEvent;
40
+ [itemKeyboardSelect]: KeyboardEvent;
41
+ [closePress]: MouseEvent | PointerEvent | KeyboardEvent;
42
+ [inputChange]: InputEvent | Event;
43
+ [inputClear]: InputEvent | FocusEvent | Event;
44
+ [clearPress]: MouseEvent | PointerEvent | KeyboardEvent;
45
+ [listNavigation]: KeyboardEvent;
46
+ [submenuTrigger]: MouseEvent | PointerEvent | KeyboardEvent;
47
+ [siblingOpen]: Event;
48
+ [pointer]: MouseEvent | PointerEvent;
49
+ [keyboard]: KeyboardEvent;
50
+ [imperativeAction]: Event;
51
+ }
52
+ /**
53
+ * Maps a reason string to the corresponding native event type.
54
+ * Falls back to `Event` for unknown reasons.
55
+ */
56
+ type ReasonToEvent<Reason extends string> = Reason extends keyof ReasonToEventMap ? ReasonToEventMap[Reason] : Event;
57
+ /**
58
+ * Details object passed to change event handlers (onOpenChange, onValueChange, etc.)
59
+ *
60
+ * @template Reason - The union of allowed reason strings for this event
61
+ * @template CustomProperties - Additional component-specific properties
62
+ */
63
+ interface ChangeEventDetails<Reason extends string, CustomProperties extends object = {}> {
64
+ /**
65
+ * The reason why this state change occurred.
66
+ * Use this to conditionally handle different scenarios.
67
+ *
68
+ * @example
69
+ * ```tsx
70
+ * onOpenChange={(open, details) => {
71
+ * if (details.reason === 'escape-key') {
72
+ * // Handle escape key differently
73
+ * }
74
+ * }}
75
+ * ```
76
+ */
77
+ reason: Reason;
78
+ /**
79
+ * The native DOM event that triggered this change.
80
+ * May be a synthetic event in some cases.
81
+ */
82
+ event: ReasonToEvent<Reason>;
83
+ /**
84
+ * Cancels the state change.
85
+ * When called, the component's internal state will not update.
86
+ *
87
+ * @example
88
+ * ```tsx
89
+ * onOpenChange={(open, details) => {
90
+ * if (!open && details.reason === 'outside-press') {
91
+ * details.cancel() // Prevent closing on outside press
92
+ * }
93
+ * }}
94
+ * ```
95
+ */
96
+ cancel: () => void;
97
+ /**
98
+ * Allows the native event to propagate.
99
+ * By default, some events (like Escape key) stop propagation
100
+ * to prevent parent popups from closing simultaneously.
101
+ */
102
+ allowPropagation: () => void;
103
+ /**
104
+ * Whether `cancel()` has been called.
105
+ */
106
+ readonly isCanceled: boolean;
107
+ /**
108
+ * Whether `allowPropagation()` has been called.
109
+ */
110
+ readonly isPropagationAllowed: boolean;
111
+ /**
112
+ * The element that triggered this event, if applicable.
113
+ */
114
+ trigger: Element | undefined;
115
+ }
116
+ /**
117
+ * Details object for generic events that don't support cancellation.
118
+ * Used for events like onHighlightChange where cancellation doesn't make sense.
119
+ *
120
+ * @template Reason - The union of allowed reason strings for this event
121
+ * @template CustomProperties - Additional component-specific properties
122
+ */
123
+ interface GenericEventDetails<Reason extends string, CustomProperties extends object = {}> {
124
+ /**
125
+ * The reason why this event occurred.
126
+ */
127
+ reason: Reason;
128
+ /**
129
+ * The native DOM event that triggered this event.
130
+ */
131
+ event: ReasonToEvent<Reason>;
132
+ }
133
+
134
+ /**
135
+ * Reasons why a popup menu's open state changed.
136
+ */
137
+ type PopupMenuOpenChangeReason = typeof triggerPress | typeof triggerHover | typeof triggerFocus | typeof triggerContextMenu | typeof escapeKey | typeof outsidePress | typeof focusOut | typeof itemPress | typeof closePress | typeof listNavigation | typeof submenuTrigger | typeof siblingOpen | typeof imperativeAction | typeof none;
138
+ /**
139
+ * Event details for popup menu open state changes.
140
+ */
141
+ type PopupMenuOpenChangeEventDetails = ChangeEventDetails<PopupMenuOpenChangeReason>;
142
+ /**
143
+ * Reasons why highlight changed.
144
+ */
145
+ type HighlightChangeReason = typeof pointer | typeof keyboard | typeof auto | typeof none;
146
+ /**
147
+ * Event details for highlight changes.
148
+ */
149
+ type HighlightChangeEventDetails = GenericEventDetails<HighlightChangeReason, {
150
+ index: number;
151
+ }>;
152
+ /**
153
+ * Reasons why a checkbox item's checked state changed.
154
+ */
155
+ type CheckedChangeReason = typeof itemPress | typeof itemKeyboardSelect;
156
+ /**
157
+ * Event details for checkbox item checked state changes.
158
+ */
159
+ type CheckedChangeEventDetails = ChangeEventDetails<CheckedChangeReason>;
160
+ /**
161
+ * Reasons why a radio group's value changed.
162
+ */
163
+ type RadioValueChangeReason = typeof itemPress | typeof itemKeyboardSelect;
164
+ /**
165
+ * Event details for radio group value changes.
166
+ */
167
+ type RadioValueChangeEventDetails = ChangeEventDetails<RadioValueChangeReason>;
168
+
169
+ interface ItemContextValue {
170
+ /** Unique ID for this item (for DOM id attribute) */
171
+ id: string;
172
+ /** Whether the item is highlighted */
173
+ highlighted: boolean;
174
+ /** Whether the item is disabled */
175
+ disabled: boolean;
176
+ /** Keyboard shortcut for this item */
177
+ shortcut?: string;
178
+ }
179
+ declare const ItemContext: React$1.Context<ItemContextValue | null>;
180
+ declare function useItemContext(): ItemContextValue;
181
+ declare function useMaybeItemContext(): ItemContextValue | null;
182
+
183
+ type FilterFn = (value: string, search: string, keywords?: string[]) => number;
184
+ interface ItemRegistration {
185
+ value: string;
186
+ keywords?: string[];
187
+ groupId?: string;
188
+ disabled?: boolean;
189
+ /** Whether this item is a submenu trigger */
190
+ isSubmenuTrigger?: boolean;
191
+ /** Single character keyboard shortcut to trigger this item */
192
+ shortcut?: string;
193
+ /** Whether selecting this item should close the menu (default: true) */
194
+ closeOnClick?: boolean;
195
+ }
196
+ /**
197
+ * Pre-registered item for virtualization.
198
+ * This allows the store to know about all items even when they're not mounted.
199
+ * The `value` field serves as both the unique identifier and the filtering value.
200
+ */
201
+ interface VirtualItem {
202
+ /** Value used as unique identifier and for filtering/matching */
203
+ value: string;
204
+ /** Additional keywords for filtering */
205
+ keywords?: string[];
206
+ /** Whether the item is disabled */
207
+ disabled?: boolean;
208
+ }
209
+ type HighlightSource = 'keyboard' | 'pointer' | 'auto' | null;
210
+ /**
211
+ * Refs for DOM elements used for scroll behavior.
212
+ * These are stored outside of reactive state to avoid unnecessary re-renders.
213
+ */
214
+ interface DOMRefs {
215
+ /** Ref to the list/scroll container element */
216
+ listRef: React.RefObject<HTMLElement | null>;
217
+ /** Map of item ID to ref for the item's DOM element */
218
+ itemRefs: Map<string, React.RefObject<HTMLElement | null>>;
219
+ }
220
+ interface ListboxState {
221
+ /** Whether the listbox is open */
222
+ open: boolean;
223
+ /** Current search query */
224
+ search: string;
225
+ /** Currently highlighted item ID */
226
+ highlightedId: string | null;
227
+ /** Source of the current highlight (keyboard or pointer) */
228
+ highlightSource: HighlightSource;
229
+ /** Whether an Input is present in the Surface */
230
+ hasInput: boolean;
231
+ /** Whether the input is currently active (rendered) when hideUntilActive mode is used */
232
+ inputActive: boolean;
233
+ /** Pending search character typed before input was active */
234
+ pendingSearch: string;
235
+ /** Filtered results: item ID to score */
236
+ filteredItems: Map<string, number>;
237
+ /** Groups that have at least one visible item */
238
+ visibleGroups: Set<string>;
239
+ /** Count of visible items */
240
+ filteredCount: number;
241
+ /** Counter to trigger re-filtering when items change */
242
+ filterTrigger: number;
243
+ /** Whether virtualization mode is enabled */
244
+ virtualized: boolean;
245
+ /** Count of virtual items (from items prop) */
246
+ virtualItemsCount: number;
247
+ }
248
+ interface ListboxContext {
249
+ /** Filter function or false to disable filtering */
250
+ filter: FilterFn | false;
251
+ /** Whether to loop navigation */
252
+ loop: boolean;
253
+ /**
254
+ * Controls auto-highlighting behavior when the menu opens.
255
+ * - `true`: highlight the first item (default)
256
+ * - `false`: don't auto-highlight any item
257
+ * - `string`: highlight the item with this specific value
258
+ */
259
+ autoHighlightFirst: boolean | string;
260
+ /**
261
+ * Whether to clear search on close.
262
+ * - `true`: clear immediately when menu closes (default)
263
+ * - `false`: preserve search when menu closes
264
+ * - `'after-exit'`: clear after exit animation completes (requires Surface to call clearSearch)
265
+ */
266
+ clearSearchOnClose: boolean | 'after-exit';
267
+ /** Whether hideUntilActive mode is enabled */
268
+ hideUntilActive: boolean;
269
+ /** ID for the list element (for aria-activedescendant) */
270
+ listId: string;
271
+ /** ID for the input element */
272
+ inputId: string;
273
+ /** Map of item ID to registration data */
274
+ readonly items: Map<string, ItemRegistration>;
275
+ /** Map of group ID to set of item IDs */
276
+ readonly groups: Map<string, Set<string>>;
277
+ /** Map of item ID to onSelect callback */
278
+ readonly itemSelects: Map<string, () => void>;
279
+ /** Map of submenu trigger ID to open callback */
280
+ readonly submenuOpens: Map<string, () => void>;
281
+ /** Map of submenu trigger ID to close callback */
282
+ readonly submenuCloses: Map<string, () => void>;
283
+ /** Map of shortcut key to item ID */
284
+ readonly shortcuts: Map<string, string>;
285
+ /**
286
+ * Callback when open state changes.
287
+ * The second parameter contains event details including the reason for the change.
288
+ */
289
+ onOpenChange: (open: boolean, eventDetails: PopupMenuOpenChangeEventDetails) => void;
290
+ /** Callback when search state changes */
291
+ onSearchChange: ((search: string) => void) | undefined;
292
+ /**
293
+ * Pre-registered items for virtualization.
294
+ * When provided, navigation uses this array order instead of DOM registration order.
295
+ */
296
+ virtualItems: VirtualItem[];
297
+ /**
298
+ * Consumer-provided ordered list of item values when filter={false}.
299
+ * Used to determine correct navigation/highlight order when consumer handles filtering externally.
300
+ * Must always be provided when filter={false}.
301
+ */
302
+ orderedItems: string[];
303
+ /**
304
+ * Callback when highlighted item changes and needs scroll sync.
305
+ * Called only when the item is not in the DOM (virtualized out of view).
306
+ * Useful for synchronizing with virtualizers (scrollToIndex).
307
+ * The third parameter contains event details including the reason for the change.
308
+ */
309
+ onHighlightChange: ((id: string | null, index: number, eventDetails: HighlightChangeEventDetails) => void) | undefined;
310
+ /**
311
+ * DOM refs for scroll behavior.
312
+ * Stored in context (not state) to avoid re-renders.
313
+ */
314
+ refs: DOMRefs;
315
+ /**
316
+ * Callback when menu close animation completes.
317
+ * Used for resetting row width measurements.
318
+ */
319
+ onCloseComplete?: () => void;
320
+ /**
321
+ * Last known pointer position for detecting actual pointer movement.
322
+ * Used to prevent "phantom" highlights when content shifts under a stationary pointer.
323
+ */
324
+ lastPointerPosition: {
325
+ x: number;
326
+ y: number;
327
+ } | null;
328
+ }
329
+ declare const selectors: {
330
+ open: (state: ListboxState) => boolean;
331
+ search: (state: ListboxState) => string;
332
+ highlightedId: (state: ListboxState) => string | null;
333
+ highlightSource: (state: ListboxState) => HighlightSource;
334
+ hasInput: (state: ListboxState) => boolean;
335
+ inputActive: (state: ListboxState) => boolean;
336
+ pendingSearch: (state: ListboxState) => string;
337
+ filteredCount: (state: ListboxState) => number;
338
+ filteredItems: (state: ListboxState) => Map<string, number>;
339
+ visibleGroups: (state: ListboxState) => Set<string>;
340
+ virtualized: (state: ListboxState) => boolean;
341
+ isHighlighted: (state: ListboxState, itemId: string) => boolean;
342
+ isGroupVisible: (state: ListboxState, groupId: string) => boolean;
343
+ getItemScore: (state: ListboxState, itemId: string) => number;
344
+ hasSearchWithNoResults: (state: ListboxState) => boolean;
345
+ };
346
+ /**
347
+ * Core store for listbox-like components.
348
+ * Handles item registration, filtering, navigation, and highlight state.
349
+ *
350
+ * Used by: DropdownMenu, ContextMenu, Select, CommandMenu
351
+ */
352
+ declare class ListboxStore extends ReactStore<ListboxState, ListboxContext, typeof selectors> {
353
+ constructor(initialState?: Partial<ListboxState>, context?: Partial<ListboxContext>);
354
+ /**
355
+ * Set the open state with event details.
356
+ *
357
+ * @param open - The new open state
358
+ * @param reason - The reason for the state change (default: 'none')
359
+ * @param event - The native DOM event that triggered the change (optional)
360
+ */
361
+ setOpen(open: boolean, reason?: PopupMenuOpenChangeReason, event?: Event): void;
362
+ setSearch(search: string): void;
363
+ setHighlightedId(id: string | null, cause?: HighlightSource): void;
364
+ /**
365
+ * Notify listeners about highlight changes.
366
+ * Called whenever highlightedId changes, regardless of virtualization or DOM state.
367
+ * Useful for virtualization scroll sync, analytics, or any other tracking needs.
368
+ *
369
+ * @param id - The newly highlighted item ID (or null if cleared)
370
+ * @param cause - What caused the highlight change
371
+ */
372
+ private notifyHighlightChange;
373
+ /**
374
+ * Scroll the highlighted item into view.
375
+ * Uses native scrollIntoView if the element is in the DOM.
376
+ * For virtualized lists, the onHighlightChange callback (called from setHighlightedId)
377
+ * should handle scrolling via the virtualizer.
378
+ *
379
+ * @param id - The item ID to scroll into view
380
+ */
381
+ private scrollItemIntoView;
382
+ setHasInput(hasInput: boolean): void;
383
+ setInputActive(active: boolean): void;
384
+ setPendingSearch(search: string): void;
385
+ setHideUntilActive(enabled: boolean): void;
386
+ setVirtualized(virtualized: boolean): void;
387
+ setVirtualItems(items: VirtualItem[]): void;
388
+ /**
389
+ * Set the consumer-provided ordered items.
390
+ * Used when filter={false} and consumer controls item order/visibility.
391
+ * Must always be provided when filter={false}.
392
+ *
393
+ * @param items - Array of item IDs in display order
394
+ */
395
+ setOrderedItems(items: string[]): void;
396
+ /**
397
+ * Try to auto-highlight when an item registers.
398
+ * This handles the case where orderedItems was set before items mounted.
399
+ * Only highlights if:
400
+ * - filter={false} (using orderedItems)
401
+ * - Menu is open
402
+ * - No item is currently highlighted
403
+ * - autoHighlightFirst is enabled
404
+ * - The registering item is the first in orderedItems
405
+ */
406
+ private maybeAutoHighlightOnRegister;
407
+ setOnHighlightChange(callback: ((id: string | null, index: number, eventDetails: HighlightChangeEventDetails) => void) | undefined): void;
408
+ /**
409
+ * Set the list element ref for scroll container detection.
410
+ */
411
+ setListRef(ref: React.RefObject<HTMLElement | null>): void;
412
+ /**
413
+ * Register an item's DOM ref for scrollIntoView behavior.
414
+ * Returns a cleanup function.
415
+ */
416
+ registerItemRef(id: string, ref: React.RefObject<HTMLElement | null>): () => void;
417
+ /**
418
+ * Check if pointer has moved and should allow highlight.
419
+ * This prevents "phantom" highlights when content shifts under a stationary pointer
420
+ * (e.g., when search results change or menu items reorder).
421
+ *
422
+ * @param x - Current pointer X position
423
+ * @param y - Current pointer Y position
424
+ * @returns true if pointer has actually moved and highlight should be allowed
425
+ */
426
+ shouldAllowPointerHighlight(x: number, y: number): boolean;
427
+ /**
428
+ * Reset pointer position tracking.
429
+ * Call this when the menu opens or content changes significantly.
430
+ */
431
+ resetPointerPosition(): void;
432
+ /**
433
+ * Pre-register virtual items so they appear in filteredItems.
434
+ * This allows filtering to work for items that aren't mounted yet.
435
+ */
436
+ private preRegisterVirtualItems;
437
+ registerItem(id: string, registration: ItemRegistration): () => void;
438
+ registerGroup(id: string): () => void;
439
+ registerItemSelect(id: string, onSelect: (() => void) | undefined): () => void;
440
+ registerSubmenuOpen(id: string, onOpen: (() => void) | undefined): () => void;
441
+ registerSubmenuClose(id: string, onClose: (() => void) | undefined): () => void;
442
+ /**
443
+ * Close all submenus except the one with the given ID.
444
+ * Used when hovering over a new submenu trigger to close sibling submenus.
445
+ */
446
+ closeSiblingSubmenus(exceptId: string | null): void;
447
+ highlightNext(): void;
448
+ highlightPrev(): void;
449
+ selectHighlighted(): void;
450
+ /**
451
+ * Select an item by its keyboard shortcut.
452
+ * Returns true if an item was found and selected, false otherwise.
453
+ */
454
+ selectByShortcut(key: string): boolean;
455
+ openSubmenuForHighlighted(): void;
456
+ isHighlightedSubmenuTrigger(): boolean;
457
+ /**
458
+ * Get the item registration for the highlighted item.
459
+ * Returns undefined if no item is highlighted.
460
+ */
461
+ getHighlightedItem(): ItemRegistration | undefined;
462
+ clearSearch(): void;
463
+ highlightFirstItem(): void;
464
+ /**
465
+ * Apply auto-highlight based on the current context.autoHighlightFirst value.
466
+ * Called by Surface after updating the context to ensure correct value is used.
467
+ */
468
+ applyAutoHighlight(): void;
469
+ /**
470
+ * Highlight a specific item by its value.
471
+ * If the item is not visible or doesn't exist, falls back to highlighting the first item.
472
+ * Scrolls the highlighted item into view.
473
+ */
474
+ highlightItemByValue(value: string): void;
475
+ /**
476
+ * Returns whether filtering is disabled (consumer handles filtering externally).
477
+ */
478
+ isFilterDisabled(): boolean;
479
+ getVisibleItemIds(): string[];
480
+ /**
481
+ * Get the index of an item in the visible items list.
482
+ * Returns -1 if the item is not found or not visible.
483
+ */
484
+ getVisibleItemIndex(id: string): number;
485
+ /**
486
+ * Get the index of an item in the virtualItems array.
487
+ * This is used for virtualizer scrollToIndex which needs the raw array index,
488
+ * not the filtered/visible index.
489
+ * Returns -1 if not found or not in virtualized mode.
490
+ */
491
+ getVirtualItemIndex(value: string): number;
492
+ /**
493
+ * Validates and updates the highlighted item.
494
+ * This is the single source of truth for highlight management.
495
+ *
496
+ * @param options.forceFirst - Force highlight first item even if current is valid
497
+ * @param options.filteredItems - Use this map instead of state (for mid-update calls)
498
+ * @param options.newSearch - The search query for filteredItems (to detect search cleared)
499
+ */
500
+ private validateHighlight;
501
+ private recomputeFilteredItems;
502
+ static useStore(externalStore: ListboxStore | undefined, initialState?: Partial<ListboxState>, context?: Partial<ListboxContext>): ListboxStore;
503
+ }
504
+
505
+ /**
506
+ * Aim guard refs for submenu navigation.
507
+ * Optional - only needed for popup menus with submenus.
508
+ */
509
+ interface AimGuardRefs {
510
+ /** Whether aim guard is currently active */
511
+ aimGuardActiveRef: React$1.RefObject<boolean>;
512
+ /** The depth at which aim guard is active (null when not guarding) */
513
+ guardedDepthRef: React$1.RefObject<number | null>;
514
+ }
515
+ /**
516
+ * Parameters for the useListboxItem hook.
517
+ */
518
+ interface UseListboxItemParams {
519
+ /**
520
+ * Explicit unique identifier for this item in the store.
521
+ * Takes highest priority for item registration.
522
+ * Used by data-first APIs to ensure consistent IDs.
523
+ */
524
+ id?: string;
525
+ /**
526
+ * Unique value for this item used as identifier and for filtering.
527
+ * If not provided, will be inferred from textContent.
528
+ * Used for registration when `id` is not provided.
529
+ */
530
+ value?: string;
531
+ /**
532
+ * Additional keywords to match against when filtering.
533
+ * Useful for aliases or synonyms.
534
+ */
535
+ keywords?: string[];
536
+ /**
537
+ * Whether this item is disabled.
538
+ * Disabled items are not selectable and are skipped during keyboard navigation.
539
+ */
540
+ disabled?: boolean;
541
+ /**
542
+ * Whether to force render this item regardless of filter results.
543
+ * @default false
544
+ */
545
+ forceMount?: boolean;
546
+ /**
547
+ * Keyboard shortcut to trigger this item.
548
+ * When the menu is focused and the user presses this key, the item will be selected.
549
+ * Should be a single character (e.g., "1", "a", etc.).
550
+ */
551
+ shortcut?: string;
552
+ /**
553
+ * Whether this item is a submenu trigger (for store registration).
554
+ * @default false
555
+ */
556
+ isSubmenuTrigger?: boolean;
557
+ /**
558
+ * Callback when this item is selected (via click or Enter key).
559
+ * For simple items, pass this directly. For checkbox/radio items,
560
+ * use registerSelect() to register a dynamic handler.
561
+ */
562
+ onSelect?: () => void;
563
+ /**
564
+ * Whether selecting this item should close the menu.
565
+ * @default true
566
+ */
567
+ closeOnClick?: boolean;
568
+ /**
569
+ * Callback invoked after selection occurs (via click).
570
+ * Called with the item's ID. The consumer handles any
571
+ * post-selection behavior like closing menus.
572
+ */
573
+ onAfterSelect?: (itemId: string) => void;
574
+ /**
575
+ * Children (used for text content inference when value is not provided).
576
+ */
577
+ children?: React$1.ReactNode;
578
+ /**
579
+ * Optional aim guard refs for popup menu navigation.
580
+ * When provided, pointer move events will respect the aim guard.
581
+ */
582
+ aimGuard?: AimGuardRefs;
583
+ }
584
+ /**
585
+ * Return value from the useListboxItem hook.
586
+ */
587
+ interface UseListboxItemReturn {
588
+ /** Unique ID for this item (DOM ID for aria-activedescendant) */
589
+ id: string;
590
+ /**
591
+ * Store identifier for this item.
592
+ * Use this when calling store methods like setHighlightedId, registerSubmenuOpen, etc.
593
+ * This is the `value` prop (or inferred from textContent).
594
+ */
595
+ storeId: string;
596
+ /** Ref to attach to the item element */
597
+ ref: React$1.RefObject<HTMLDivElement | null>;
598
+ /** Whether item is currently highlighted */
599
+ isHighlighted: boolean;
600
+ /** Whether item should be rendered (passes filter) */
601
+ isVisible: boolean;
602
+ /** Context value to provide to children via ItemContext.Provider */
603
+ contextValue: ItemContextValue;
604
+ /**
605
+ * Event handlers to spread on the element.
606
+ * These handle click, pointer move, and pointer down events.
607
+ */
608
+ handlers: {
609
+ onClick: React$1.MouseEventHandler<HTMLDivElement>;
610
+ onPointerMove: React$1.PointerEventHandler<HTMLDivElement>;
611
+ onPointerDown: React$1.PointerEventHandler<HTMLDivElement>;
612
+ };
613
+ /**
614
+ * Register a custom onSelect handler.
615
+ * This is useful for checkbox/radio items where the select behavior
616
+ * needs to be customized (e.g., toggle checked state).
617
+ * Returns an unregister function.
618
+ */
619
+ registerSelect: (handler: (() => void) | undefined) => () => void;
620
+ }
621
+ /**
622
+ * Hook that provides all shared logic for navigatable/highlightable listbox items.
623
+ *
624
+ * This hook handles:
625
+ * - Item registration with the listbox store
626
+ * - Highlight state management (keyboard and pointer)
627
+ * - Filter/search visibility
628
+ * - Scroll into view on keyboard navigation
629
+ * - Click, pointer move, and pointer down event handlers
630
+ * - Optional aim guard integration (for submenu navigation)
631
+ *
632
+ * @example
633
+ * ```tsx
634
+ * function CustomItem(props) {
635
+ * const item = useListboxItem({
636
+ * value: props.value,
637
+ * disabled: props.disabled,
638
+ * onSelect: props.onSelect,
639
+ * })
640
+ *
641
+ * if (!item.isVisible) return null
642
+ *
643
+ * return (
644
+ * <ItemContext.Provider value={item.contextValue}>
645
+ * <div
646
+ * ref={item.ref}
647
+ * {...item.handlers}
648
+ * data-highlighted={item.isHighlighted || undefined}
649
+ * >
650
+ * {props.children}
651
+ * </div>
652
+ * </ItemContext.Provider>
653
+ * )
654
+ * }
655
+ * ```
656
+ */
657
+ declare function useListboxItem(params: UseListboxItemParams): UseListboxItemReturn;
658
+
659
+ export { type AimGuardRefs as A, type HighlightSource as B, type ChangeEventDetails as C, type DOMRefs as D, type CheckedChangeReason as E, type FilterFn as F, type GenericEventDetails as G, type HighlightChangeEventDetails as H, type ItemRegistration as I, type CheckedChangeEventDetails as J, type RadioValueChangeEventDetails as K, type ListboxContext as L, type PopupMenuOpenChangeReason as P, type RadioValueChangeReason as R, type UseListboxItemParams as U, type VirtualItem as V, inputChange as a, inputClear as b, imperativeAction as c, triggerContextMenu as d, escapeKey as e, focusOut as f, closePress as g, siblingOpen as h, itemPress as i, triggerHover as j, keyboard as k, listNavigation as l, triggerFocus as m, none as n, outsidePress as o, pointer as p, type ListboxState as q, ListboxStore as r, submenuTrigger as s, triggerPress as t, type ItemContextValue as u, useItemContext as v, useMaybeItemContext as w, ItemContext as x, type UseListboxItemReturn as y, useListboxItem as z };