@bazza-ui/react 0.1.0-canary.10 → 0.1.0-canary.12

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.
Files changed (37) hide show
  1. package/dist/chunk-5T5B5SPR.cjs.map +1 -1
  2. package/dist/{chunk-BFOY762U.js → chunk-65TSJ7MA.js} +2 -2
  3. package/dist/{chunk-BFOY762U.js.map → chunk-65TSJ7MA.js.map} +1 -1
  4. package/dist/{chunk-W4ACKMIZ.cjs → chunk-EYMK7XHC.cjs} +2 -2
  5. package/dist/chunk-EYMK7XHC.cjs.map +1 -0
  6. package/dist/chunk-JFEVUUPC.cjs.map +1 -1
  7. package/dist/chunk-M4G6J7DP.cjs.map +1 -1
  8. package/dist/chunk-SCDHQZFI.cjs.map +1 -1
  9. package/dist/chunk-XMZZ62VJ.cjs.map +1 -1
  10. package/dist/combobox/index.cjs +1 -1
  11. package/dist/combobox/index.cjs.map +1 -1
  12. package/dist/combobox/index.js +1 -1
  13. package/dist/command-menu/index.cjs +1 -1
  14. package/dist/command-menu/index.cjs.map +1 -1
  15. package/dist/command-menu/index.js +1 -1
  16. package/dist/context-menu/index.cjs +1 -1
  17. package/dist/context-menu/index.cjs.map +1 -1
  18. package/dist/context-menu/index.js +1 -1
  19. package/dist/dropdown-menu/index.cjs +1 -1
  20. package/dist/dropdown-menu/index.cjs.map +1 -1
  21. package/dist/dropdown-menu/index.js +1 -1
  22. package/dist/dropdown-menu/index.js.map +1 -1
  23. package/dist/internal/listbox/index.cjs.map +1 -1
  24. package/dist/internal/popup-menu/index.cjs +1 -1
  25. package/dist/internal/popup-menu/index.cjs.map +1 -1
  26. package/dist/internal/popup-menu/index.js +1 -1
  27. package/dist/kbd/index.cjs.map +1 -1
  28. package/dist/loaders/index.cjs.map +1 -1
  29. package/dist/select/index.cjs +1 -1
  30. package/dist/select/index.cjs.map +1 -1
  31. package/dist/select/index.d.cts +22 -2
  32. package/dist/select/index.d.ts +22 -2
  33. package/dist/select/index.js +1 -1
  34. package/dist/select/index.js.map +1 -1
  35. package/dist/video-player/index.cjs.map +1 -1
  36. package/package.json +1 -1
  37. package/dist/chunk-W4ACKMIZ.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/ui/ui/packages/react/dist/chunk-EYMK7XHC.cjs","../src/internal/popup-menu/contexts/focus-owner-context.ts","../src/internal/popup-menu/contexts/open-chain-context.ts","../src/internal/popup-menu/contexts/popup-menu-context.ts","../src/internal/popup-menu/contexts/popup-surface-id-context.ts","../src/internal/popup-menu/contexts/submenu-context.ts","../src/internal/popup-menu/contexts/subpage-context.ts","../src/internal/popup-menu/contexts/subpage-stack-context.ts","../src/internal/popup-menu/store/FocusOwnerStore.ts","../src/internal/popup-menu/hooks/use-popup-menu-root.ts","../src/internal/popup-menu/menu-tree/resolve.ts"],"names":["FocusOwnerContext","useFocusOwner","context","OpenChainContext","useOpenChain","PopupMenuContext","usePopupMenuContext","useMaybePopupMenuContext","PopupSurfaceIdContext","usePopupSurfaceId","SubmenuContext","useSubmenuContext","useMaybeSubmenuContext","SubpageContext","useSubpageContext","useMaybeSubpageContext","SubpageStackContext","useSubpageStack","useMaybeSubpageStack","selectors","createSelector","state","surfaceId","FocusOwnerStore","ReactStore","id","isPopupMenuNode","value","encodeDefinitionPathEntry","entry","encoded","index","codeUnit","isSafe"],"mappings":"AAAA,ugCAAyM,o0FCElL,IAOjBA,EAAAA,CAA0B,EAAA,CAAA,aAAA,CAAsC,IAAI,CAAA,CAEnE,SAASC,EAAAA,CAAAA,CAAiC,CAC/C,IAAMC,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWF,EAAiB,CAAA,CAClD,EAAA,CAAI,CAACE,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,gEACF,CAAA,CAEF,OAAOA,CACT,CCjBA,IAOMC,EAAAA,CAAyB,EAAA,CAAA,aAAA,CAAqC,IAAI,CAAA,CAEjE,SAASC,EAAAA,CAAAA,CAA+B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EAClD,KAAA,CAAM,OAAA,CAASA,CAAAA,CAAwB,cAAc,CAAA,EACrD,KAAA,CAAM,OAAA,CAASA,CAAAA,CAAwB,QAAQ,CAAA,EAC/C,OAAQA,CAAAA,CAAwB,KAAA,EAAU,QAAA,EAC1C,QAAA,GAAYA,CAEhB,CAEA,SAASC,EAAAA,CAA0BC,CAAAA,CAAuB,CACxD,IAAIC,CAAAA,CAAU,EAAA,CACd,GAAA,CAAA,IAASC,CAAAA,CAAQ,CAAA,CAAGA,CAAAA,CAAQF,CAAAA,CAAM,MAAA,CAAQE,CAAAA,EAAS,CAAA,CAAG,CACpD,IAAMC,CAAAA,CAAWH,CAAAA,CAAM,UAAA,CAAWE,CAAK,CAAA,CACjCE,CAAAA,CACHD,CAAAA,EAAY,EAAA,EAAQA,CAAAA,EAAY,EAAA,EAChCA,CAAAA,EAAY,EAAA,EAAQA,CAAAA,EAAY,GAAA,EAChCA,CAAAA,EAAY,EAAA,EAAQA,CAAAA,EAAY,EAAA,EACjCA,CAAAA,GAAa,EAAA,EACbA,CAAAA,GAAa,EAAA,EACbA,CAAAA,GAAa,GAAA,EACbA,CAAAA,GAAa,EAAA,CACfF,CAAAA,EAAWG,CAAAA,CACP,MAAA,CAAO,YAAA,CAAaD,CAAQ,CAAA,CAC5B,CAAA,CAAA,EAAIA,CAAAA,CAAS,QAAA,CAAS,EAAE,CAAA,CAAE,QAAA,CAAS,CAAA,CAAG,GAAG,CAAC,CAAA,CAAA","file":"/home/runner/work/ui/ui/packages/react/dist/chunk-EYMK7XHC.cjs","sourcesContent":[null,"'use client'\n\nimport * as React from 'react'\nimport type { FocusOwnerStore } from '../store/FocusOwnerStore.js'\n\n// ============================================================================\n// Focus Owner Context\n// ============================================================================\n\nconst FocusOwnerContext = React.createContext<FocusOwnerStore | null>(null)\n\nexport function useFocusOwner(): FocusOwnerStore {\n const context = React.useContext(FocusOwnerContext)\n if (!context) {\n throw new Error(\n 'FocusOwner components must be used within a FocusOwnerProvider',\n )\n }\n return context\n}\n\nexport function useMaybeFocusOwner(): FocusOwnerStore | null {\n return React.useContext(FocusOwnerContext)\n}\n\nexport { FocusOwnerContext }\n","'use client'\n\nimport * as React from 'react'\nimport type { OpenChainStore } from '../store/OpenChainStore.js'\n\n// ============================================================================\n// Open Chain Context\n// ============================================================================\n\nconst OpenChainContext = React.createContext<OpenChainStore | null>(null)\n\nexport function useOpenChain(): OpenChainStore {\n const context = React.useContext(OpenChainContext)\n if (!context) {\n throw new Error(\n 'OpenChain components must be used within an OpenChainProvider',\n )\n }\n return context\n}\n\nexport function useMaybeOpenChain(): OpenChainStore | null {\n return React.useContext(OpenChainContext)\n}\n\nexport { OpenChainContext }\n","'use client'\n\nimport * as React from 'react'\nimport type {\n ListboxStore,\n VirtualItem,\n} from '../../listbox/store/ListboxStore.js'\nimport type {\n HighlightChangeEventDetails,\n PopupMenuOpenChangeReason,\n} from '../events.js'\n\n// ============================================================================\n// Popup Menu Context\n// ============================================================================\n// Shared root-level context for popup menus (DropdownMenu, ContextMenu).\n// Provides core menu functionality to all child components.\n\n/**\n * Virtual anchor for positioning the menu at a specific point.\n * Used by ContextMenu to position at cursor location.\n */\nexport interface VirtualAnchor {\n getBoundingClientRect(): DOMRect\n}\n\n/**\n * Virtualization configuration passed from Root/Submenu to Surface.\n */\nexport interface VirtualizationConfig {\n /** Whether virtualization mode is enabled */\n virtualized: boolean\n /** Pre-registered items for virtualization */\n items: VirtualItem[]\n /**\n * Callback when highlighted item changes (for scroll sync).\n * The third parameter contains event details including the reason for the change.\n */\n onHighlightChange?: (\n id: string | null,\n index: number,\n eventDetails: HighlightChangeEventDetails,\n ) => void\n}\n\n/**\n * Shared context value for popup menus.\n * Both DropdownMenu.Root and ContextMenu.Root provide this context.\n */\nexport interface PopupMenuContextValue {\n /** The Listbox store instance */\n store: ListboxStore\n /** Whether this menu tree currently ignores user interaction. */\n disabled: boolean\n /** Nesting depth: 0 = root menu, 1+ = submenu */\n depth: number\n /** Close the entire menu tree (deepest submenu to root, sequentially) */\n closeAll: (reason?: PopupMenuOpenChangeReason, event?: Event) => void\n /**\n * Internal: when true, Surface handles Tab explicitly (close the tree, or\n * cycle through focus zones). Enabled only by DropdownMenu.Root and\n * ContextMenu.Root — never Select or Combobox.\n */\n explicitTabBehavior: boolean\n /**\n * Internal: what Tab does under `explicitTabBehavior` when the surface (and\n * its ancestors) have no focus-zone tabbables. `'close'` closes the whole\n * tree (dropdown/context-menu). `'inert'` swallows the event, keeping focus\n * where it is (command palette).\n */\n tabWithoutZones: 'close' | 'inert'\n /** Register a surface (submenu) for closeAll tracking. Returns unregister function. */\n registerSurface: (\n depth: number,\n setOpen: (open: boolean) => void,\n ) => () => void\n /** Virtualization configuration (if enabled) */\n virtualization?: VirtualizationConfig\n /**\n * Virtual anchor for positioning.\n * Used by ContextMenu to position at cursor location.\n * DropdownMenu uses the Popover's anchor (trigger button) instead.\n */\n virtualAnchor?: VirtualAnchor\n /**\n * Type of menu for positioning logic.\n * - 'dropdown': positions relative to trigger button\n * - 'context': positions at cursor with fixed positioning\n */\n menuType: 'dropdown' | 'context'\n /**\n * When to close the menu on outside interactions.\n * - 'pointerdown': Close immediately when pointer is pressed outside (default)\n * - 'click': Close when a full click (pointerdown + pointerup) occurs outside\n * @default 'pointerdown'\n */\n closeOnOutsidePress: 'click' | 'pointerdown'\n}\n\nconst PopupMenuContext = React.createContext<PopupMenuContextValue | null>(null)\n\n/**\n * Hook to access the popup menu context.\n * Throws if used outside a popup menu.\n */\nexport function usePopupMenuContext(): PopupMenuContextValue {\n const context = React.useContext(PopupMenuContext)\n if (!context) {\n throw new Error(\n 'PopupMenu components must be used within a PopupMenu.Root or ContextMenu.Root',\n )\n }\n return context\n}\n\n/**\n * Hook to optionally access the popup menu context.\n * Returns null if used outside a popup menu.\n */\nexport function useMaybePopupMenuContext(): PopupMenuContextValue | null {\n return React.useContext(PopupMenuContext)\n}\n\n// Re-export for convenience\nexport type { VirtualItem }\nexport { PopupMenuContext }\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Popup Surface ID Context\n// ============================================================================\n\n/**\n * Context for passing surfaceId from Popup to Surface.\n * This ensures Popup and Surface share the same ID for data attribute tracking.\n *\n * For root menus, Popup generates the ID and provides it via this context.\n * For submenus, the ID comes from SubmenuContext.childSurfaceId instead.\n */\nconst PopupSurfaceIdContext = React.createContext<string | null>(null)\n\nexport function usePopupSurfaceId(): string | null {\n return React.useContext(PopupSurfaceIdContext)\n}\n\nexport { PopupSurfaceIdContext }\n","'use client'\n\nimport * as React from 'react'\n\nexport interface SubmenuContextValue {\n /** Whether the submenu is open */\n open: boolean\n /** Set the submenu open state */\n setOpen: (open: boolean) => void\n /**\n * Latch set by explicit close actions (keyboard ArrowLeft/Ctrl+H/Escape-in-submenu,\n * or clicking the open trigger). While set and the trigger remains highlighted,\n * pointer/keyboard auto-open is suppressed. Reset when highlight leaves the trigger.\n */\n suppressAutoOpenRef: React.MutableRefObject<boolean>\n /** Reference to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>\n /** Reference to the submenu content element (for aim guard rect calculations) */\n contentRef: React.RefObject<HTMLElement | null>\n /** Surface ID of the parent menu (for keyboard navigation back) */\n parentSurfaceId: string\n /** Surface ID of this submenu (for keyboard navigation into) */\n childSurfaceId: string\n /**\n * Whether pressing Escape in this submenu closes the entire menu from the root.\n * When true, Escape closes the entire menu tree.\n * When false, Escape only closes this submenu and moves focus to the parent.\n * @default true\n */\n closeRootOnEsc: boolean\n}\n\nconst SubmenuContext = React.createContext<SubmenuContextValue | null>(null)\n\nexport function useSubmenuContext(): SubmenuContextValue {\n const context = React.useContext(SubmenuContext)\n if (!context) {\n throw new Error('SubmenuTrigger must be used within a Submenu')\n }\n return context\n}\n\nexport function useMaybeSubmenuContext(): SubmenuContextValue | null {\n return React.useContext(SubmenuContext)\n}\n\nexport { SubmenuContext }\n","'use client'\n\nimport * as React from 'react'\n\nexport interface SubpageContextValue {\n /** Current page ID. */\n pageId: string\n /** Surface ID for this page. */\n surfaceId: string\n /** Surface ID for the previous page, if available. */\n parentSurfaceId: string | null\n /** Whether this page is currently active. */\n isActive: boolean\n /** Whether Escape should close the entire menu tree from this page. */\n closeRootOnEsc: boolean\n /** Navigate back one page. Returns true when navigation happened. */\n goBack: () => boolean\n}\n\nconst SubpageContext = React.createContext<SubpageContextValue | null>(null)\n\nexport function useSubpageContext(): SubpageContextValue {\n const context = React.useContext(SubpageContext)\n if (!context) {\n throw new Error(\n 'Subpage components must be used within a PopupMenu.Subpage',\n )\n }\n return context\n}\n\nexport function useMaybeSubpageContext(): SubpageContextValue | null {\n return React.useContext(SubpageContext)\n}\n\nexport { SubpageContext }\n","'use client'\n\nimport * as React from 'react'\n\nexport interface SubpageRegistration {\n pageId: string\n surfaceId: string\n closeRootOnEsc: boolean\n}\n\nexport interface SubpageStackContextValue {\n /** Active page ID; `null` when the root surface is active. */\n activePageId: string | null\n /** Surface ID of the root surface. */\n rootSurfaceId: string\n /** Surface ID for the currently active page. */\n activeSurfaceId: string\n /** Whether there is a previous page to navigate back to. */\n canGoBack: boolean\n /** Whether Escape in the active page should close the entire menu tree. */\n shouldCloseRootOnEsc: boolean\n /** Open page IDs, bottom to top; empty at root. */\n stack: readonly string[]\n /** Register a page and return an unregister cleanup. */\n registerPage: (registration: SubpageRegistration) => () => void\n /** Push a page onto the stack. Returns true when navigation happened. */\n openPage: (pageId: string) => boolean\n /** Pop one page from the stack. Returns true when navigation happened. */\n goBack: () => boolean\n /** Resolve a surface ID for a page ID. */\n getSurfaceId: (pageId: string) => string | null\n}\n\nconst SubpageStackContext =\n React.createContext<SubpageStackContextValue | null>(null)\n\nexport function useSubpageStack(): SubpageStackContextValue {\n const context = React.useContext(SubpageStackContext)\n if (!context) {\n throw new Error('Subpage components must be used within a PopupMenu.Popup')\n }\n return context\n}\n\nexport function useMaybeSubpageStack(): SubpageStackContextValue | null {\n return React.useContext(SubpageStackContext)\n}\n\nexport { SubpageStackContext }\n","import { createSelector, ReactStore } from '@base-ui/utils/store'\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface FocusOwnerState {\n /** Which surface currently owns focus (surfaceId or null) */\n ownerId: string | null\n}\n\n// ============================================================================\n// Selectors\n// ============================================================================\n\nconst selectors = {\n ownerId: createSelector((state: FocusOwnerState) => state.ownerId),\n isOwner: createSelector(\n (state: FocusOwnerState, surfaceId: string) => state.ownerId === surfaceId,\n ),\n}\n\n// ============================================================================\n// Store\n// ============================================================================\n\n/**\n * Tracks which menu surface owns DOM focus.\n * Single instance per menu tree (created at root, shared via context).\n *\n * Used by: DropdownMenu, ContextMenu\n * Not used by: Select, CommandMenu (single surface)\n */\nexport class FocusOwnerStore extends ReactStore<\n FocusOwnerState,\n Record<string, never>,\n typeof selectors\n> {\n constructor() {\n super({ ownerId: null }, {}, selectors)\n }\n\n /**\n * Set the owner surface ID.\n * Call this when focus should transfer to a new surface.\n */\n setOwnerId(id: string | null) {\n this.set('ownerId', id)\n }\n\n /**\n * Clear the owner (set to null).\n * Call this when the menu tree closes.\n */\n clearOwner() {\n this.set('ownerId', null)\n }\n}\n\nexport type { FocusOwnerState as State }\n","'use client'\n\nimport * as React from 'react'\nimport type { ChangeEventDetails } from '../../../utils/events/index.js'\nimport {\n createChangeEventDetails,\n REASONS,\n} from '../../../utils/events/index.js'\nimport { ensureInputModalityTracking } from '../../../utils/input-modality.js'\nimport { ListboxStore, type VirtualItem } from '../../listbox/index.js'\nimport type { VirtualizationConfig } from '../contexts/popup-menu-context.js'\nimport type {\n HighlightChangeEventDetails,\n PopupMenuHighlightChangeHandler,\n PopupMenuOpenChangeReason,\n} from '../events.js'\nimport type { MenuTreeResolver } from '../menu-tree/resolver.js'\nimport { createMenuTreeResolver } from '../menu-tree/resolver.js'\nimport type { GetResolvedIdFn, PopupMenuIdScope } from '../menu-tree/types.js'\nimport { FocusOwnerStore } from '../store/FocusOwnerStore.js'\nimport { OpenChainStore } from '../store/OpenChainStore.js'\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface UsePopupMenuRootParams {\n /**\n * Computes canonical Resolved IDs for data-first content from the Unresolved Menu Node (definitional facts only).\n * @default explicit `def.id` verbatim, else the joined definition path\n * Read once when the menu root mounts — later changes have no effect.\n */\n getResolvedId?: GetResolvedIdFn\n /** Definition Key uniqueness scope. Read once when the menu root mounts. */\n idScope?: PopupMenuIdScope\n /**\n * Callback when the open state changes.\n * The second parameter contains event details including the reason for the change.\n */\n onOpenChange?: (\n open: boolean,\n eventDetails: ChangeEventDetails<string>,\n ) => void\n\n /**\n * Whether the menu is initially open.\n * @default false\n */\n defaultOpen?: boolean\n\n /**\n * Whether virtualization mode is enabled.\n * @default false\n */\n virtualized?: boolean\n\n /**\n * Pre-registered items for virtualization.\n */\n items?: VirtualItem[]\n\n /**\n * Callback when the highlighted item changes. `id` is first; `node` is the\n * resolved menu node enrichment and may be null.\n * The fourth parameter contains event details including the reason for the change.\n */\n onHighlightChange?: PopupMenuHighlightChangeHandler<HighlightChangeEventDetails>\n\n /**\n * When to close the menu on outside interactions.\n * - 'pointerdown': Close immediately when pointer is pressed outside (default)\n * - 'click': Close when a full click (pointerdown + pointerup) occurs outside\n * @default 'pointerdown'\n */\n closeOnOutsidePress?: 'click' | 'pointerdown'\n\n /**\n * Whether the menu should ignore user interaction.\n * Can be controlled declaratively via this prop, or imperatively via actionsRef.setDisabled().\n * @default false\n */\n disabled?: boolean\n\n /**\n * Initial disabled state for imperative usage.\n * Ignored when `disabled` prop is true.\n * @default false\n */\n defaultDisabled?: boolean\n}\n\nexport interface PopupMenuRootActions {\n /** Close the menu tree imperatively. */\n close: () => void\n /** Unmount the popup imperatively (when keep-mounted mode is enabled). */\n unmount: () => void\n /** Enable/disable the menu tree imperatively. */\n setDisabled: (disabled: boolean) => void\n}\n\nexport interface UsePopupMenuRootReturn {\n /** The menu-tree resolver for this menu root. */\n menuTreeResolver: MenuTreeResolver\n /** The Listbox store instance */\n store: ListboxStore\n /** The FocusOwner store instance */\n focusOwnerStore: FocusOwnerStore\n /** The OpenChain store instance */\n openChainStore: OpenChainStore\n /** Register a surface (submenu) for closeAll tracking */\n registerSurface: (\n depth: number,\n setOpen: (open: boolean) => void,\n ) => () => void\n /** Close the entire menu tree */\n closeAll: (reason?: PopupMenuOpenChangeReason, event?: Event) => void\n /** Virtualization configuration (if enabled) */\n virtualization: VirtualizationConfig | undefined\n /** Handle open state change (updates store and clears stores on close) */\n handleOpenChange: (\n open: boolean,\n reason?: PopupMenuOpenChangeReason,\n event?: Event,\n ) => void\n /** Whether the menu currently ignores user interaction. */\n disabled: boolean\n /** Update imperative disabled state. */\n setDisabled: (disabled: boolean) => void\n}\n\n// ============================================================================\n// Hook\n// ============================================================================\n\n/**\n * Hook that creates and manages the core stores and utilities for popup menus.\n * Used by both DropdownMenu.Root and ContextMenu.Root.\n *\n * Provides:\n * - ListboxStore for item management\n * - FocusOwnerStore for focus tracking across submenus\n * - OpenChainStore for tracking open submenu chain\n * - Surface registry for closeAll functionality\n */\nexport function usePopupMenuRoot(\n params: UsePopupMenuRootParams = {},\n): UsePopupMenuRootReturn {\n const {\n onOpenChange,\n defaultOpen = false,\n virtualized = false,\n items: itemsProp,\n onHighlightChange,\n closeOnOutsidePress = 'pointerdown',\n disabled: disabledProp = false,\n defaultDisabled = false,\n getResolvedId,\n idScope = 'surface',\n } = params\n\n const menuTreeResolverRef = React.useRef<MenuTreeResolver | null>(null)\n if (menuTreeResolverRef.current === null) {\n menuTreeResolverRef.current = createMenuTreeResolver({\n getResolvedId,\n idScope,\n })\n }\n const menuTreeResolver = menuTreeResolverRef.current\n\n const handleHighlightChange = React.useCallback(\n (\n id: string | null,\n index: number,\n eventDetails: HighlightChangeEventDetails,\n ) => {\n onHighlightChange?.(\n id,\n id === null ? null : (menuTreeResolver.getNodeById(id) ?? null),\n index,\n eventDetails,\n )\n },\n [menuTreeResolver, onHighlightChange],\n )\n\n const [imperativeDisabled, setImperativeDisabled] =\n React.useState(defaultDisabled)\n const disabled = disabledProp || imperativeDisabled\n\n const setDisabled = React.useCallback((nextDisabled: boolean) => {\n setImperativeDisabled(nextDisabled)\n }, [])\n\n // Begin tracking global input modality so the store can attribute opens to\n // mouse/touch/pen/keyboard. Idempotent; installed once for the whole app.\n React.useEffect(() => {\n ensureInputModalityTracking()\n }, [])\n\n // Track outside pointer events to distinguish outside-press from focus-out\n // When a pointerdown happens outside the menu, we store it so that if a\n // focus-out close happens immediately after, we can treat it as outside-press\n const outsidePointerEventRef = React.useRef<PointerEvent | null>(null)\n\n // Create stable callback wrapper for onOpenChange that converts focus-out to outside-press\n // when the close was triggered by a pointer event outside the menu\n const stableOnOpenChange = React.useCallback(\n (open: boolean, eventDetails: ChangeEventDetails<string>) => {\n // If closing due to focus-out but we have a stored outside pointer event,\n // convert the reason to outside-press for better cancel() support\n if (\n !open &&\n eventDetails.reason === REASONS.focusOut &&\n outsidePointerEventRef.current\n ) {\n const pointerEvent = outsidePointerEventRef.current\n outsidePointerEventRef.current = null\n\n // Create new event details with outside-press reason and the pointer event\n const convertedDetails = createChangeEventDetails(\n REASONS.outsidePress,\n pointerEvent,\n )\n\n onOpenChange?.(open, convertedDetails)\n\n // If the converted callback canceled, also cancel the original\n if (convertedDetails.isCanceled) {\n eventDetails.cancel()\n }\n return\n }\n\n // Clear the pointer event ref if we're not using it\n outsidePointerEventRef.current = null\n\n onOpenChange?.(open, eventDetails)\n },\n [onOpenChange],\n )\n\n // Create the store instance\n const store = ListboxStore.useStore(\n undefined,\n { open: defaultOpen },\n {\n onOpenChange: stableOnOpenChange,\n },\n )\n\n // Get current open state for the pointer event listener\n const isOpen = store.useState('open')\n\n // Create focus owner store (single instance for entire menu tree)\n const focusOwnerStoreRef = React.useRef<FocusOwnerStore | null>(null)\n if (!focusOwnerStoreRef.current) {\n focusOwnerStoreRef.current = new FocusOwnerStore()\n }\n const focusOwnerStore = focusOwnerStoreRef.current\n\n // Create open chain store (single instance for entire menu tree)\n const openChainStoreRef = React.useRef<OpenChainStore | null>(null)\n if (!openChainStoreRef.current) {\n openChainStoreRef.current = new OpenChainStore()\n }\n const openChainStore = openChainStoreRef.current\n\n // Registry for tracking open submenus (for closeAll)\n type SurfaceEntry = { depth: number; setOpen: (open: boolean) => void }\n const surfaceRegistryRef = React.useRef<Map<string, SurfaceEntry>>(new Map())\n\n // Register a surface (submenu) for closeAll tracking\n const registerSurface = React.useCallback(\n (depth: number, setOpen: (open: boolean) => void) => {\n const id = Math.random().toString(36).slice(2)\n surfaceRegistryRef.current.set(id, { depth, setOpen })\n return () => {\n surfaceRegistryRef.current.delete(id)\n }\n },\n [],\n )\n\n // Close the entire menu tree from deepest submenu to root\n const closeAll = React.useCallback(\n (reason: PopupMenuOpenChangeReason = REASONS.itemPress, event?: Event) => {\n // Sort surfaces by depth (deepest first)\n const surfaces = [...surfaceRegistryRef.current.values()].sort(\n (a, b) => b.depth - a.depth,\n )\n\n // Close each submenu from deepest to shallowest\n for (const surface of surfaces) {\n surface.setOpen(false)\n }\n\n // Finally close the root\n store.setOpen(false, reason, event)\n\n // Clear focus ownership and open chain\n focusOwnerStore.clearOwner()\n openChainStore.clear()\n },\n [store, focusOwnerStore, openChainStore],\n )\n\n // Ref to hold closeAll for use in the pointerdown effect\n const closeAllRef = React.useRef(closeAll)\n closeAllRef.current = closeAll\n\n // Listen for pointerdown events on document to detect outside clicks\n // This is a single listener at the root level that handles the entire menu tree.\n // Behavior depends on closeOnOutsidePress:\n // - 'pointerdown': Close immediately when pointer is pressed outside\n // - 'click': Store event and convert focus-out to outside-press reason\n React.useEffect(() => {\n if (!isOpen || disabled) {\n outsidePointerEventRef.current = null\n return\n }\n\n const handlePointerDown = (event: PointerEvent) => {\n const target = event.target as Element | null\n if (!target) return\n\n // Check if the pointerdown is inside any part of the menu tree or its triggers\n // base-ui sets data-open on popups and data-popup-open on triggers\n const isInsidePopup = target.closest('[data-open]') !== null\n const isInsideTrigger = target.closest('[data-popup-open]') !== null\n const isInside = isInsidePopup || isInsideTrigger\n\n if (closeOnOutsidePress === 'pointerdown' && !isInside) {\n // Close entire menu tree immediately on pointerdown outside\n closeAllRef.current(REASONS.outsidePress, event)\n } else {\n // Store the event for focus-out-to-outside-press conversion\n outsidePointerEventRef.current = event\n }\n }\n\n // Use capture phase to see the event before any stopPropagation\n document.addEventListener('pointerdown', handlePointerDown, true)\n return () => {\n document.removeEventListener('pointerdown', handlePointerDown, true)\n outsidePointerEventRef.current = null\n }\n }, [isOpen, closeOnOutsidePress, disabled])\n\n // Handle open state change\n const handleOpenChange = React.useCallback(\n (\n newOpen: boolean,\n reason: PopupMenuOpenChangeReason = REASONS.none,\n event?: Event,\n ) => {\n const isImperativeAction = reason === REASONS.imperativeAction\n\n // Ignore user-driven open/close interactions while disabled.\n if (disabled && !isImperativeAction) {\n return\n }\n\n store.setOpen(newOpen, reason, event)\n // Clear focus ownership and open chain when menu closes\n if (!newOpen) {\n focusOwnerStore.clearOwner()\n openChainStore.clear()\n }\n },\n [store, focusOwnerStore, openChainStore, disabled],\n )\n\n // Memoize listbox wiring config\n const virtualization = React.useMemo(() => {\n if (!virtualized && !onHighlightChange) {\n return undefined\n }\n\n return {\n virtualized,\n items: itemsProp ?? [],\n onHighlightChange: handleHighlightChange,\n }\n }, [virtualized, itemsProp, handleHighlightChange, onHighlightChange])\n\n return {\n menuTreeResolver,\n store,\n focusOwnerStore,\n openChainStore,\n registerSurface,\n closeAll,\n virtualization,\n handleOpenChange,\n disabled,\n setDisabled,\n }\n}\n","import { slugify } from '../../listbox/utils/normalize.js'\nimport type { NodeDef } from '../data-first/types.js'\nimport type {\n GetResolvedIdFn,\n PopupMenuIdScope,\n PopupMenuNode,\n UnresolvedMenuNode,\n} from './types.js'\n\nexport function isPopupMenuNode(value: unknown): value is PopupMenuNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'def' in value &&\n typeof (value as PopupMenuNode).id === 'string' &&\n typeof (value as PopupMenuNode).definitionKey === 'string' &&\n Array.isArray((value as PopupMenuNode).definitionPath) &&\n Array.isArray((value as PopupMenuNode).children) &&\n typeof (value as PopupMenuNode).depth === 'number' &&\n 'parent' in value\n )\n}\n\nfunction encodeDefinitionPathEntry(entry: string): string {\n let encoded = ''\n for (let index = 0; index < entry.length; index += 1) {\n const codeUnit = entry.charCodeAt(index)\n const isSafe =\n (codeUnit >= 0x41 && codeUnit <= 0x5a) ||\n (codeUnit >= 0x61 && codeUnit <= 0x7a) ||\n (codeUnit >= 0x30 && codeUnit <= 0x39) ||\n codeUnit === 0x2e ||\n codeUnit === 0x5f ||\n codeUnit === 0x7e ||\n codeUnit === 0x2d\n encoded += isSafe\n ? String.fromCharCode(codeUnit)\n : `%${codeUnit.toString(16).padStart(4, '0')}`\n }\n return encoded\n}\n\n/** Default Resolved ID, using surface-scoped encoded paths unless menu scope is selected. */\nexport function defaultGetResolvedId(\n node: UnresolvedMenuNode,\n idScope: PopupMenuIdScope = 'surface',\n): string {\n if (idScope === 'menu') return node.definitionKey\n return node.definitionPath.map(encodeDefinitionPathEntry).join('/')\n}\n\n/** Definition Key for a def: explicit `id` verbatim, else slugified `value`. */\nexport function definitionKeyForDef(def: NodeDef): string {\n switch (def.kind) {\n case 'group':\n case 'radio-group':\n return def.id\n case 'separator':\n return def.id\n default:\n return def.id ?? slugify(def.value)\n }\n}\n\n/** Child defs of a def, in def order; empty for leaf kinds. */\nexport function childDefsOf(def: NodeDef): readonly NodeDef[] {\n switch (def.kind) {\n case 'group':\n case 'radio-group':\n return def.nodes\n case 'submenu':\n case 'subpage':\n case 'tree-item':\n return def.nodes ?? []\n default:\n return []\n }\n}\n\n/** Kinds whose Definition Key is part of their descendants' definition paths. */\nexport function contributesDefinitionPath(def: NodeDef): boolean {\n return def.kind === 'submenu' || def.kind === 'subpage'\n}\n\n/**\n * Resolve a def list into node instances under `parent`.\n * `basePath` is the path segments contributed by ancestors (the parent's\n * `definitionPath` when the parent contributes a segment, otherwise the parent's\n * own base path); pass `[]` for roots.\n */\nexport function resolveNodeDefs(\n defs: readonly NodeDef[],\n parent: PopupMenuNode | null,\n basePath: readonly string[],\n getResolvedId: GetResolvedIdFn,\n): PopupMenuNode[] {\n return defs.map((def, index) => {\n const definitionKey = definitionKeyForDef(def)\n const definitionPath = [...basePath, definitionKey]\n const unresolved: UnresolvedMenuNode = {\n def,\n kind: def.kind,\n definitionKey,\n definitionPath,\n parent,\n children: [],\n depth: parent ? parent.depth + 1 : 0,\n index,\n }\n // Call the seam before spreading so the node reflects any reads the seam\n // performs on the final definitional facts (spread-then-call would copy\n // the fields before the seam runs).\n const id = getResolvedId(unresolved)\n const node: PopupMenuNode = { ...unresolved, id }\n node.children = resolveNodeDefs(\n childDefsOf(def),\n node,\n contributesDefinitionPath(def) ? node.definitionPath : basePath,\n getResolvedId,\n )\n return node\n })\n}\n\n/**\n * The branch's resolved static children: the Menu Nodes whose def is one of\n * the branch def's authored `nodes`, in `children` order. Loader results are\n * grafted as children too but are never in `def.nodes`, so they are excluded\n * whether the graft appended to or replaced the static children.\n */\nexport function staticChildrenOf(branch: PopupMenuNode): PopupMenuNode[] {\n const authored = (branch.def as { nodes?: readonly NodeDef[] }).nodes\n if (!authored || authored.length === 0) return []\n const authoredSet = new Set<NodeDef>(authored)\n return branch.children.filter((child) => authoredSet.has(child.def))\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/kbd/utils/parse-keybinding.ts","../src/kbd/utils/platform.ts"],"names":["keyAliases","normalizeKey","key","createChord","parseKeybinding","keys","trimmed","chordValue","chord","tokenValue","token","getKeyLabel","platform","normalizedKey","getChordLabels","isCtrl","isMeta","labels","isApplePlatform","nav","usePlatform","override","setPlatform"],"mappings":"AAeA,u8BAAMA,CAAAA,CAAqC,CACzC,GAAA,CAAK,QAAA,CACL,MAAA,CAAQ,OAAA,CACR,GAAA,CAAK,QAAA,CACL,EAAA,CAAI,SAAA,CACJ,IAAA,CAAM,WAAA,CACN,IAAA,CAAM,WAAA,CACN,KAAA,CAAO,YAAA,CACP,KAAA,CAAO,OAAA,CACP,QAAA,CAAU,OAAA,CACV,IAAA,CAAM,G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AA,EAAYA,CAAAA,CAAI,QAAA,EAAYA,CAAAA,CAAI,SAAA,CAEpE,MAAO,uBAAA,CAAwB,IAAA,CAAKP,CAAQ,CAC9C,CAOO,SAASQ,CAAAA,CAAYC,CAAAA,CAA+B,CACzD,GAAM,CAACT,CAAAA,CAAUU,CAAW,CAAA,CAAU,CAAA,CAAA,QAAA,CAAmB,OAAO,CAAA,CAEhE,OAAM,CAAA,CAAA,SAAA,CAAU,CAAA,CAAA,EAAM,CAChBD,CAAAA,GAAa,KAAA,CAAA,EAAaH,CAAAA,CAAgB,CAAA,EAC5CI,CAAAA,CAAY,OAAO,CAEvB,CAAA,CAAG,CAACD,CAAQ,CAAC,CAAA,kBAENA,CAAAA,SAAYT,GACrB,CAAA,0EAAA","file":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-JFEVUUPC.cjs","sourcesContent":["export interface KeyChord {\n meta: boolean\n ctrl: boolean\n alt: boolean\n shift: boolean\n mod: boolean\n key: string | null\n}\n\nexport interface Keybinding {\n chords: KeyChord[]\n}\n\ntype Platform = 'apple' | 'other'\n\nconst keyAliases: Record<string, string> = {\n esc: 'escape',\n return: 'enter',\n del: 'delete',\n up: 'arrowup',\n down: 'arrowdown',\n left: 'arrowleft',\n right: 'arrowright',\n space: 'space',\n spacebar: 'space',\n plus: '+',\n}\n\nfunction normalizeKey(key: string): string {\n return keyAliases[key] ?? key\n}\n\nfunction createChord(): KeyChord {\n return {\n meta: false,\n ctrl: false,\n alt: false,\n shift: false,\n mod: false,\n key: null,\n }\n}\n\nexport function parseKeybinding(keys: string): Keybinding {\n const trimmed = keys.trim()\n\n if (trimmed.length === 0) {\n return { chords: [] }\n }\n\n return {\n chords: trimmed.split(/\\s+/).map((chordValue) => {\n const chord = createChord()\n\n for (const tokenValue of chordValue.split('+')) {\n const token = tokenValue.trim().toLowerCase()\n\n if (token === '') {\n // Skip empty tokens from trailing/leading/double \"+\" (e.g. \"mod+\").\n // A literal \"+\" key is expressed with the \"plus\" alias.\n continue\n }\n\n if (token === 'mod') {\n chord.mod = true\n } else if (\n token === 'meta' ||\n token === 'cmd' ||\n token === 'command' ||\n token === 'win' ||\n token === 'super'\n ) {\n chord.meta = true\n } else if (token === 'ctrl' || token === 'control') {\n chord.ctrl = true\n } else if (token === 'alt' || token === 'option' || token === 'opt') {\n chord.alt = true\n } else if (token === 'shift') {\n chord.shift = true\n } else {\n if (chord.key !== null) {\n throw new Error(\n `Keybinding chord \"${chordValue}\" contains multiple keys: \"${chord.key}\" and \"${token}\"`,\n )\n }\n\n chord.key = normalizeKey(token)\n }\n }\n\n return chord\n }),\n }\n}\n\nexport function getKeyLabel(key: string, platform: Platform): string {\n const normalizedKey = key.toLowerCase()\n\n switch (normalizedKey) {\n case 'enter':\n return platform === 'apple' ? '↵' : 'Enter'\n case 'escape':\n return 'Esc'\n case 'backspace':\n return platform === 'apple' ? '⌫' : 'Backspace'\n case 'delete':\n return platform === 'apple' ? '⌦' : 'Del'\n case 'tab':\n return platform === 'apple' ? '⇥' : 'Tab'\n case 'space':\n return 'Space'\n case 'arrowup':\n return '↑'\n case 'arrowdown':\n return '↓'\n case 'arrowleft':\n return '←'\n case 'arrowright':\n return '→'\n default:\n if (normalizedKey.length === 1) {\n return normalizedKey.toUpperCase()\n }\n\n return normalizedKey.charAt(0).toUpperCase() + normalizedKey.slice(1)\n }\n}\n\nexport function getChordLabels(chord: KeyChord, platform: Platform): string[] {\n const isCtrl = chord.ctrl || (platform === 'other' && chord.mod)\n const isMeta = chord.meta || (platform === 'apple' && chord.mod)\n const labels: string[] = []\n\n if (isCtrl) {\n labels.push(platform === 'apple' ? '⌃' : 'Ctrl')\n }\n\n if (chord.alt) {\n labels.push(platform === 'apple' ? '⌥' : 'Alt')\n }\n\n if (chord.shift) {\n labels.push(platform === 'apple' ? '⇧' : 'Shift')\n }\n\n if (isMeta) {\n labels.push(platform === 'apple' ? '⌘' : 'Win')\n }\n\n if (chord.key !== null) {\n labels.push(getKeyLabel(chord.key, platform))\n }\n\n return labels\n}\n","'use client'\n\nimport * as React from 'react'\n\ntype Platform = 'apple' | 'other'\n\ninterface NavigatorWithUserAgentData extends Navigator {\n userAgentData?: {\n platform?: string\n }\n}\n\nexport function isApplePlatform(): boolean {\n if (typeof navigator === 'undefined') {\n return false\n }\n\n const nav = navigator as NavigatorWithUserAgentData\n const platform = nav.userAgentData?.platform || nav.platform || nav.userAgent\n\n return /mac|iphone|ipad|ipod/i.test(platform)\n}\n\n/**\n * Returns the current platform while keeping the first client render aligned with\n * SSR. Without an override, this starts as \"other\" and corrects to \"apple\" after\n * mount when appropriate, avoiding hydration mismatches.\n */\nexport function usePlatform(override?: Platform): Platform {\n const [platform, setPlatform] = React.useState<Platform>('other')\n\n React.useEffect(() => {\n if (override === undefined && isApplePlatform()) {\n setPlatform('apple')\n }\n }, [override])\n\n return override ?? platform\n}\n"]}
1
+ {"version":3,"sources":["../src/kbd/utils/parse-keybinding.ts","../src/kbd/utils/platform.ts"],"names":["keyAliases","normalizeKey","key","createChord","parseKeybinding","keys","trimmed","chordValue","chord","tokenValue","token","getKeyLabel","platform","normalizedKey","getChordLabels","isCtrl","isMeta","labels","isApplePlatform","nav","usePlatform","override","setPlatform"],"mappings":"AAeA,u8BAAMA,CAAAA,CAAqC,CACzC,GAAA,CAAK,QAAA,CACL,MAAA,CAAQ,OAAA,CACR,GAAA,CAAK,QAAA,CACL,EAAA,CAAI,SAAA,CACJ,IAAA,CAAM,WAAA,CACN,IAAA,CAAM,WAAA,CACN,KAAA,CAAO,YAAA,CACP,KAAA,CAAO,OAAA,CACP,QAAA,CAAU,OAAA,CACV,IAAA,CAAM,GACR,CAAA,CAEA,SAASC,CAAAA,CAAaC,CAAAA,CAAqB,CACzC,wBAAOF,CAAAA,CAAWE,CAAG,CAAA,SAAKA,GAC5B,CAEA,SAASC,CAAAA,CAAAA,CAAwB,CAC/B,MAAO,CACL,IAAA,CAAM,CAAA,CAAA,CACN,IAAA,CAAM,CAAA,CAAA,CACN,GAAA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A,CAAmB,OAAO,CAAA,CAEhE,OAAM,CAAA,CAAA,SAAA,CAAU,CAAA,CAAA,EAAM,CAChBD,CAAAA,GAAa,KAAA,CAAA,EAAaH,CAAAA,CAAgB,CAAA,EAC5CI,CAAAA,CAAY,OAAO,CAEvB,CAAA,CAAG,CAACD,CAAQ,CAAC,CAAA,kBAENA,CAAAA,SAAYT,GACrB,CAAA,0EAAA","file":"/home/runner/work/ui/ui/packages/react/dist/chunk-JFEVUUPC.cjs","sourcesContent":["export interface KeyChord {\n meta: boolean\n ctrl: boolean\n alt: boolean\n shift: boolean\n mod: boolean\n key: string | null\n}\n\nexport interface Keybinding {\n chords: KeyChord[]\n}\n\ntype Platform = 'apple' | 'other'\n\nconst keyAliases: Record<string, string> = {\n esc: 'escape',\n return: 'enter',\n del: 'delete',\n up: 'arrowup',\n down: 'arrowdown',\n left: 'arrowleft',\n right: 'arrowright',\n space: 'space',\n spacebar: 'space',\n plus: '+',\n}\n\nfunction normalizeKey(key: string): string {\n return keyAliases[key] ?? key\n}\n\nfunction createChord(): KeyChord {\n return {\n meta: false,\n ctrl: false,\n alt: false,\n shift: false,\n mod: false,\n key: null,\n }\n}\n\nexport function parseKeybinding(keys: string): Keybinding {\n const trimmed = keys.trim()\n\n if (trimmed.length === 0) {\n return { chords: [] }\n }\n\n return {\n chords: trimmed.split(/\\s+/).map((chordValue) => {\n const chord = createChord()\n\n for (const tokenValue of chordValue.split('+')) {\n const token = tokenValue.trim().toLowerCase()\n\n if (token === '') {\n // Skip empty tokens from trailing/leading/double \"+\" (e.g. \"mod+\").\n // A literal \"+\" key is expressed with the \"plus\" alias.\n continue\n }\n\n if (token === 'mod') {\n chord.mod = true\n } else if (\n token === 'meta' ||\n token === 'cmd' ||\n token === 'command' ||\n token === 'win' ||\n token === 'super'\n ) {\n chord.meta = true\n } else if (token === 'ctrl' || token === 'control') {\n chord.ctrl = true\n } else if (token === 'alt' || token === 'option' || token === 'opt') {\n chord.alt = true\n } else if (token === 'shift') {\n chord.shift = true\n } else {\n if (chord.key !== null) {\n throw new Error(\n `Keybinding chord \"${chordValue}\" contains multiple keys: \"${chord.key}\" and \"${token}\"`,\n )\n }\n\n chord.key = normalizeKey(token)\n }\n }\n\n return chord\n }),\n }\n}\n\nexport function getKeyLabel(key: string, platform: Platform): string {\n const normalizedKey = key.toLowerCase()\n\n switch (normalizedKey) {\n case 'enter':\n return platform === 'apple' ? '↵' : 'Enter'\n case 'escape':\n return 'Esc'\n case 'backspace':\n return platform === 'apple' ? '⌫' : 'Backspace'\n case 'delete':\n return platform === 'apple' ? '⌦' : 'Del'\n case 'tab':\n return platform === 'apple' ? '⇥' : 'Tab'\n case 'space':\n return 'Space'\n case 'arrowup':\n return '↑'\n case 'arrowdown':\n return '↓'\n case 'arrowleft':\n return '←'\n case 'arrowright':\n return '→'\n default:\n if (normalizedKey.length === 1) {\n return normalizedKey.toUpperCase()\n }\n\n return normalizedKey.charAt(0).toUpperCase() + normalizedKey.slice(1)\n }\n}\n\nexport function getChordLabels(chord: KeyChord, platform: Platform): string[] {\n const isCtrl = chord.ctrl || (platform === 'other' && chord.mod)\n const isMeta = chord.meta || (platform === 'apple' && chord.mod)\n const labels: string[] = []\n\n if (isCtrl) {\n labels.push(platform === 'apple' ? '⌃' : 'Ctrl')\n }\n\n if (chord.alt) {\n labels.push(platform === 'apple' ? '⌥' : 'Alt')\n }\n\n if (chord.shift) {\n labels.push(platform === 'apple' ? '⇧' : 'Shift')\n }\n\n if (isMeta) {\n labels.push(platform === 'apple' ? '⌘' : 'Win')\n }\n\n if (chord.key !== null) {\n labels.push(getKeyLabel(chord.key, platform))\n }\n\n return labels\n}\n","'use client'\n\nimport * as React from 'react'\n\ntype Platform = 'apple' | 'other'\n\ninterface NavigatorWithUserAgentData extends Navigator {\n userAgentData?: {\n platform?: string\n }\n}\n\nexport function isApplePlatform(): boolean {\n if (typeof navigator === 'undefined') {\n return false\n }\n\n const nav = navigator as NavigatorWithUserAgentData\n const platform = nav.userAgentData?.platform || nav.platform || nav.userAgent\n\n return /mac|iphone|ipad|ipod/i.test(platform)\n}\n\n/**\n * Returns the current platform while keeping the first client render aligned with\n * SSR. Without an override, this starts as \"other\" and corrects to \"apple\" after\n * mount when appropriate, avoiding hydration mismatches.\n */\nexport function usePlatform(override?: Platform): Platform {\n const [platform, setPlatform] = React.useState<Platform>('other')\n\n React.useEffect(() => {\n if (override === undefined && isApplePlatform()) {\n setPlatform('apple')\n }\n }, [override])\n\n return override ?? platform\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-M4G6J7DP.cjs"],"names":[],"mappings":"AAAA,6EAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc","file":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-M4G6J7DP.cjs"}
1
+ {"version":3,"sources":["/home/runner/work/ui/ui/packages/react/dist/chunk-M4G6J7DP.cjs"],"names":[],"mappings":"AAAA,6EAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc","file":"/home/runner/work/ui/ui/packages/react/dist/chunk-M4G6J7DP.cjs"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/merge-element-props.ts"],"names":["mergeElementProps","internalProps","externalProps","mergeProps","wrapEventHandlers","props","wrappedProps","propName","propValue","isEventHandler","event","args","makeEventPreventable","key","value"],"mappings":"AAAA,iIAAiD,SAMjCA,CAAAA,CAIdC,CAAAA,CAA8BC,CAAAA,CAA8B,CAC5D,OAAOC,oCAAAA,CACLF,CACAG,CAAAA,CAAqBF,CAAa,CACpC,CACF,CAEA,SAASE,CAAAA,CACPC,CAAAA,CACA,CACA,IAAMC,CAAAA,CAAe,CAAE,GAAGD,CAAM,CAAA,CAEhC,GAAA,CAAA,IAAWE,EAAAA,GAAYD,CAAAA,CAAc,CACnC,IAAME,CAAAA,CAAYF,CAAAA,CAAaC,CAAQ,CAAA,CACnCE,CAAAA,CAAeF,CAAAA,CAAUC,CAAS,CAAA,EAAA,CACpCF,CAAAA,CAAaC,CAAQ,CAAA,CAAI,CACvBG,CAAAA,CAAAA,GACGC,CAAAA,CAAAA,EAAAA,CAEHC,8CAAAA,CAEA,CAAA,CACOJ,CAAAA,CAAUE,CAAAA,CAAO,GAAGC,CAAI,CAAA,CAAA,CAGrC,CAEA,OAAOL,CACT,CAEA,SAASG,CAAAA,CACPI,CAAAA,CACAC,CAAAA,CACuE,CACvE,OACED,CAAAA,CAAI,UAAA,CAAW,CAAC,CAAA,GAAM,GAAA,EACtBA,CAAAA,CAAI,UAAA,CAAW,CAAC,CAAA,GAAM,GAAA,EACtBA,CAAAA,CAAI,UAAA,CAAW,CAAC,CAAA,EAAK,EAAA,EACrBA,CAAAA,CAAI,UAAA,CAAW,CAAC,CAAA,EAAK,EAAA,EACrB,OAAOC,CAAAA,EAAU,UAErB,CAAA,cAAA","file":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-SCDHQZFI.cjs","sourcesContent":["import { makeEventPreventable, mergeProps } from '@base-ui/react/merge-props'\nimport type * as React from 'react'\n\ntype ElementType = React.ElementType\ntype ElementProps<T extends ElementType> = React.ComponentPropsWithRef<T>\n\nexport function mergeElementProps<\n T extends ElementType,\n InternalProps extends Record<string, unknown> = ElementProps<T>,\n ExternalProps extends Partial<ElementProps<T>> = Partial<ElementProps<T>>,\n>(internalProps: InternalProps, externalProps: ExternalProps) {\n return mergeProps<T>(\n internalProps as ElementProps<T>,\n wrapEventHandlers<T>(externalProps) as ElementProps<T>,\n ) as InternalProps & ExternalProps\n}\n\nfunction wrapEventHandlers<T extends ElementType>(\n props: Partial<ElementProps<T>>,\n) {\n const wrappedProps = { ...props } as Record<string, unknown>\n\n for (const propName in wrappedProps) {\n const propValue = wrappedProps[propName]\n if (isEventHandler(propName, propValue)) {\n wrappedProps[propName] = (\n event: React.SyntheticEvent,\n ...args: unknown[]\n ) => {\n makeEventPreventable(\n event as Parameters<typeof makeEventPreventable>[0],\n )\n return propValue(event, ...args)\n }\n }\n }\n\n return wrappedProps as Partial<ElementProps<T>>\n}\n\nfunction isEventHandler(\n key: string,\n value: unknown,\n): value is (event: React.SyntheticEvent, ...args: unknown[]) => unknown {\n return (\n key.charCodeAt(0) === 111 &&\n key.charCodeAt(1) === 110 &&\n key.charCodeAt(2) >= 65 &&\n key.charCodeAt(2) <= 90 &&\n typeof value === 'function'\n )\n}\n"]}
1
+ {"version":3,"sources":["../src/utils/merge-element-props.ts"],"names":["mergeElementProps","internalProps","externalProps","mergeProps","wrapEventHandlers","props","wrappedProps","propName","propValue","isEventHandler","event","args","makeEventPreventable","key","value"],"mappings":"AAAA,iIAAiD,SAMjCA,CAAAA,CAIdC,CAAAA,CAA8BC,CAAAA,CAA8B,CAC5D,OAAOC,oCAAAA,CACLF,CACAG,CAAAA,CAAqBF,CAAa,CACpC,CACF,CAEA,SAASE,CAAAA,CACPC,CAAAA,CACA,CACA,IAAMC,CAAAA,CAAe,CAAE,GAAGD,CAAM,CAAA,CAEhC,GAAA,CAAA,IAAWE,EAAAA,GAAYD,CAAAA,CAAc,CACnC,IAAME,CAAAA,CAAYF,CAAAA,CAAaC,CAAQ,CAAA,CACnCE,CAAAA,CAAeF,CAAAA,CAAUC,CAAS,CAAA,EAAA,CACpCF,CAAAA,CAAaC,CAAQ,CAAA,CAAI,CACvBG,CAAAA,CAAAA,GACGC,CAAAA,CAAAA,EAAAA,CAEHC,8CAAAA,CAEA,CAAA,CACOJ,CAAAA,CAAUE,CAAAA,CAAO,GAAGC,CAAI,CAAA,CAAA,CAGrC,CAEA,OAAOL,CACT,CAEA,SAASG,CAAAA,CACPI,CAAAA,CACAC,CAAAA,CACuE,CACvE,OACED,CAAAA,CAAI,UAAA,CAAW,CAAC,CAAA,GAAM,GAAA,EACtBA,CAAAA,CAAI,UAAA,CAAW,CAAC,CAAA,GAAM,GAAA,EACtBA,CAAAA,CAAI,UAAA,CAAW,CAAC,CAAA,EAAK,EAAA,EACrBA,CAAAA,CAAI,UAAA,CAAW,CAAC,CAAA,EAAK,EAAA,EACrB,OAAOC,CAAAA,EAAU,UAErB,CAAA,cAAA","file":"/home/runner/work/ui/ui/packages/react/dist/chunk-SCDHQZFI.cjs","sourcesContent":["import { makeEventPreventable, mergeProps } from '@base-ui/react/merge-props'\nimport type * as React from 'react'\n\ntype ElementType = React.ElementType\ntype ElementProps<T extends ElementType> = React.ComponentPropsWithRef<T>\n\nexport function mergeElementProps<\n T extends ElementType,\n InternalProps extends Record<string, unknown> = ElementProps<T>,\n ExternalProps extends Partial<ElementProps<T>> = Partial<ElementProps<T>>,\n>(internalProps: InternalProps, externalProps: ExternalProps) {\n return mergeProps<T>(\n internalProps as ElementProps<T>,\n wrapEventHandlers<T>(externalProps) as ElementProps<T>,\n ) as InternalProps & ExternalProps\n}\n\nfunction wrapEventHandlers<T extends ElementType>(\n props: Partial<ElementProps<T>>,\n) {\n const wrappedProps = { ...props } as Record<string, unknown>\n\n for (const propName in wrappedProps) {\n const propValue = wrappedProps[propName]\n if (isEventHandler(propName, propValue)) {\n wrappedProps[propName] = (\n event: React.SyntheticEvent,\n ...args: unknown[]\n ) => {\n makeEventPreventable(\n event as Parameters<typeof makeEventPreventable>[0],\n )\n return propValue(event, ...args)\n }\n }\n }\n\n return wrappedProps as Partial<ElementProps<T>>\n}\n\nfunction isEventHandler(\n key: string,\n value: unknown,\n): value is (event: React.SyntheticEvent, ...args: unknown[]) => unknown {\n return (\n key.charCodeAt(0) === 111 &&\n key.charCodeAt(1) === 110 &&\n key.charCodeAt(2) >= 65 &&\n key.charCodeAt(2) <= 90 &&\n typeof value === 'function'\n )\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-XMZZ62VJ.cjs","../src/internal/listbox/contexts/group-context.ts","../src/internal/listbox/contexts/item-context.ts","../src/internal/listbox/contexts/listbox-context.ts","../src/internal/listbox/contexts/row-width-context.ts","../src/internal/listbox/contexts/surface-context.ts","../src/internal/listbox/hooks/use-listbox-item.ts","../src/internal/listbox/utils/normalize.ts"],"names":["GroupContext","useGroupContext","ItemContext","useItemContext","context","useMaybeItemContext","ListboxContext","useListboxContext","useMaybeListboxContext","RowWidthContext","useRowWidthContext","useMaybeRowWidthContext","SurfaceContext","useSurfaceContext","useMaybeSurfaceContext","normalizeValue","value","deburr","slugify","useListboxItem","params","idProp","valueProp","keywords","disabled","activatable","forceMount","shortcut","forceOrder","forceScore","isSubmenuTrigger","onSelect","closeOnClick","onAfterSelect","children","aimGuard","store","groupContext","depth","ref","rowId","rowElement","setRowElement","inferredValue","setInferredValue","textContent","registrationId","generatedDomId","domId"],"mappings":"AAAA,ugCAAyC,uWCElB,IAoBjBA,EAAAA,CAAqB,CAAA,CAAA,aAAA,CAAwC,IAAI,CAAA,CAEhE,SAASC,CAAAA,CAAAA,CAA4C,CAC1D,OAAa,CAAA,CAAA,UAAA,CAAWD,EAAY,CACtC,CCxBA,IAiBME,CAAAA,CAAoB,CAAA,CAAA,aAAA,CAAuC,IAAI,CAAA,CAE9D,SAASC,EAAAA,CAAAA,CAAmC,CACjD,IAAMC,CAAAA,CAAgB,CAAA,CAAA,UAAA,CAAWF,CAAW,CAAA,CAC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KAAA,CAAM,CAAA,CAC7BC,CAAAA,kBAAQ3B,CAAAA,SAAU,CAAA,KAAA,EAAQ0B,CAAc,CAAA,GAAA","file":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-XMZZ62VJ.cjs","sourcesContent":[null,"'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Group Context (for items to know their parent group)\n// ============================================================================\n\nexport interface GroupPositional {\n first?: boolean\n last?: boolean\n firstInGroup?: boolean\n lastInGroup?: boolean\n firstGroup?: boolean\n lastGroup?: boolean\n}\n\nexport interface GroupContextValue {\n groupId?: string\n positional?: GroupPositional\n}\n\nconst GroupContext = React.createContext<GroupContextValue | null>(null)\n\nexport function useGroupContext(): GroupContextValue | null {\n return React.useContext(GroupContext)\n}\n\nexport { GroupContext }\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Item Context (for child components like indicators to access item state)\n// ============================================================================\n\nexport interface ItemContextValue {\n /** Unique ID for this item (for DOM id attribute) */\n id: string\n /** Whether the item is highlighted */\n highlighted: boolean\n /** Whether the item is disabled */\n disabled: boolean\n /** Keyboard shortcut for this item */\n shortcut?: string\n}\n\nconst ItemContext = React.createContext<ItemContextValue | null>(null)\n\nexport function useItemContext(): ItemContextValue {\n const context = React.useContext(ItemContext)\n if (!context) {\n throw new Error('Item child components must be used within an Item')\n }\n return context\n}\n\nexport function useMaybeItemContext(): ItemContextValue | null {\n return React.useContext(ItemContext)\n}\n\nexport { ItemContext }\n","'use client'\n\nimport * as React from 'react'\nimport type { HighlightChangeEventDetails } from '../../popup-menu/events.js'\nimport type { ListboxStore, VirtualItem } from '../store/ListboxStore.js'\n\n/**\n * Virtualization configuration passed from Root/Submenu to Surface.\n */\nexport interface VirtualizationConfig {\n /** Whether virtualization mode is enabled */\n virtualized: boolean\n /** Pre-registered items for virtualization */\n items: VirtualItem[]\n /**\n * Callback when highlighted item changes (for scroll sync).\n * The third parameter contains event details including the reason for the change.\n */\n onHighlightChange?: (\n id: string | null,\n index: number,\n eventDetails: HighlightChangeEventDetails,\n ) => void\n}\n\nexport interface ListboxContextValue {\n /** The Listbox store instance */\n store: ListboxStore\n /** Nesting depth: 0 = root menu, 1+ = submenu */\n depth: number\n /** Close the entire menu tree (deepest submenu to root, sequentially) */\n closeAll: () => void\n /** Register a surface (submenu) for closeAll tracking. Returns unregister function. */\n registerSurface: (\n depth: number,\n setOpen: (open: boolean) => void,\n ) => () => void\n /** Virtualization configuration (if enabled) */\n virtualization?: VirtualizationConfig\n}\n\nconst ListboxContext = React.createContext<ListboxContextValue | null>(null)\n\nexport function useListboxContext(): ListboxContextValue {\n const context = React.useContext(ListboxContext)\n if (!context) {\n throw new Error('Listbox components must be used within a Listbox provider')\n }\n return context\n}\n\nexport function useMaybeListboxContext(): ListboxContextValue | null {\n return React.useContext(ListboxContext)\n}\n\nexport { ListboxContext }\n","'use client'\n\nimport * as React from 'react'\n\n/**\n * Context value for row width measurement.\n * Provided by List when `measureRowWidth` is enabled.\n */\nexport interface RowWidthContextValue {\n /**\n * Queue a row element for width measurement.\n * Call this when a row mounts or becomes visible.\n *\n * @param element - The DOM element to measure\n * @param id - Unique identifier for this row (used to avoid re-measuring)\n */\n queueMeasurement: (element: HTMLElement, id: string) => void\n}\n\n/**\n * Context for row width measurement.\n * Items use this to self-register for measurement.\n */\nexport const RowWidthContext = React.createContext<RowWidthContextValue | null>(\n null,\n)\n\nif (process.env.NODE_ENV !== 'production') {\n RowWidthContext.displayName = 'RowWidthContext'\n}\n\n/**\n * Hook to get the row width context.\n * Throws an error if used outside of a List with `measureRowWidth` enabled.\n */\nexport function useRowWidthContext(): RowWidthContextValue {\n const context = React.useContext(RowWidthContext)\n if (!context) {\n throw new Error(\n 'useRowWidthContext must be used within a List with measureRowWidth enabled',\n )\n }\n return context\n}\n\n/**\n * Hook to optionally get the row width context.\n * Returns null if not within a List with `measureRowWidth` enabled.\n * This is the preferred hook for items that should work both with and without measurement.\n */\nexport function useMaybeRowWidthContext(): RowWidthContextValue | null {\n return React.useContext(RowWidthContext)\n}\n","'use client'\n\nimport * as React from 'react'\nimport type { ListboxStore } from '../store/ListboxStore.js'\n\n// Re-export types from the store for convenience\nexport type {\n FilterFn,\n ItemRegistration,\n} from '../store/ListboxStore.js'\n\n// ============================================================================\n// Surface Context\n// ============================================================================\n\nexport interface SurfaceContextValue {\n /** The Listbox store instance */\n store: ListboxStore\n /** Unique identifier for this surface */\n surfaceId: string\n}\n\nconst SurfaceContext = React.createContext<SurfaceContextValue | null>(null)\n\nexport function useSurfaceContext(): SurfaceContextValue {\n const context = React.useContext(SurfaceContext)\n if (!context) {\n throw new Error('Listbox components must be used within a Surface provider')\n }\n return context\n}\n\nexport function useMaybeSurfaceContext(): SurfaceContextValue | null {\n return React.useContext(SurfaceContext)\n}\n\nexport { SurfaceContext }\n","'use client'\n\nimport * as React from 'react'\nimport { useGroupContext } from '../contexts/group-context.js'\nimport type { ItemContextValue } from '../contexts/item-context.js'\nimport { useListboxContext } from '../contexts/listbox-context.js'\nimport { useMaybeRowWidthContext } from '../contexts/row-width-context.js'\nimport { useSurfaceContext } from '../contexts/surface-context.js'\nimport { normalizeValue } from '../utils/normalize.js'\n\n/**\n * Aim guard refs for submenu navigation.\n * Optional - only needed for popup menus with submenus.\n */\nexport interface AimGuardRefs {\n /** Whether aim guard is currently active */\n aimGuardActiveRef: React.RefObject<boolean>\n /** The depth at which aim guard is active (null when not guarding) */\n guardedDepthRef: React.RefObject<number | null>\n}\n\n/**\n * Parameters for the useListboxItem hook.\n */\nexport interface UseListboxItemParams {\n /**\n * Explicit unique identifier for this item in the store.\n * Takes highest priority for item registration.\n * Used by data-first APIs to ensure consistent IDs.\n */\n id?: string\n\n /**\n * Unique value for this item used as identifier and for filtering.\n * If not provided, will be inferred from textContent.\n * Used for registration when `id` is not provided.\n */\n value?: string\n\n /**\n * Additional keywords to match against when filtering.\n * Useful for aliases or synonyms.\n */\n keywords?: string[]\n\n /**\n * Whether this item is disabled.\n * Disabled items are not selectable and are skipped during keyboard navigation.\n */\n disabled?: boolean\n\n /**\n * Whether this item can be activated via Enter or click.\n * Non-activatable items remain highlightable.\n * @default true\n */\n activatable?: boolean\n\n /**\n * Whether to force render this item regardless of filter results.\n * @default false\n */\n forceMount?: boolean\n\n /**\n * Keyboard shortcut to trigger this item.\n * When the menu is focused and the user presses this key, the item will be selected.\n * Should be a single character (e.g., \"1\", \"a\", etc.).\n */\n shortcut?: string\n\n /**\n * Forces this row's relative order during score-based sorting.\n * Lower values appear earlier.\n * @default 0\n */\n forceOrder?: number\n\n /**\n * Overrides this row's computed fuzzy-match score.\n * Useful for pinning or manually ranking rows in score-based views.\n */\n forceScore?: number\n\n /**\n * Whether this item is a submenu trigger (for store registration).\n * @default false\n */\n isSubmenuTrigger?: boolean\n\n /**\n * Callback when this item is selected (via click or Enter key).\n * For simple items, pass this directly. For checkbox/radio items,\n * use registerSelect() to register a dynamic handler.\n */\n onSelect?: () => void\n\n /**\n * Whether selecting this item should close the menu.\n * @default true\n */\n closeOnClick?: boolean\n\n /**\n * Callback invoked after selection occurs (via click).\n * Called with the item's ID. The consumer handles any\n * post-selection behavior like closing menus.\n */\n onAfterSelect?: (itemId: string) => void\n\n /**\n * Children (used for text content inference when value is not provided).\n */\n children?: React.ReactNode\n\n /**\n * Optional aim guard refs for popup menu navigation.\n * When provided, pointer move events will respect the aim guard.\n */\n aimGuard?: AimGuardRefs\n}\n\n/**\n * Return value from the useListboxItem hook.\n */\nexport interface UseListboxItemReturn {\n /** Unique ID for this item (DOM ID for aria-activedescendant) */\n id: string\n\n /**\n * Store identifier for this item.\n * Use this when calling store methods like setHighlightedId, registerSubmenuOpen, etc.\n * This is the `value` prop (or inferred from textContent).\n */\n storeId: string\n\n /** Ref to attach to the item element */\n ref: React.RefObject<HTMLDivElement | null>\n\n /** Callback ref that tracks the mounted row element for positional attributes. Merge into the rendered element's ref. */\n rowRef: (element: HTMLElement | null) => void\n\n /** Positional state among visible rows (all false in virtualized mode). */\n positional: {\n first: boolean\n last: boolean\n firstInGroup: boolean\n lastInGroup: boolean\n }\n\n /** Whether item is currently highlighted */\n isHighlighted: boolean\n\n /** Whether item should be rendered (passes filter) */\n isVisible: boolean\n\n /** Context value to provide to children via ItemContext.Provider */\n contextValue: ItemContextValue\n\n /**\n * Event handlers to spread on the element.\n * These handle click, pointer move, and pointer down events.\n */\n handlers: {\n onClick: React.MouseEventHandler<HTMLDivElement>\n onPointerMove: React.PointerEventHandler<HTMLDivElement>\n onPointerDown: React.PointerEventHandler<HTMLDivElement>\n }\n\n /**\n * Register a custom onSelect handler.\n * This is useful for checkbox/radio items where the select behavior\n * needs to be customized (e.g., toggle checked state).\n * Returns an unregister function.\n */\n registerSelect: (handler: (() => void) | undefined) => () => void\n}\n\n/**\n * Hook that provides all shared logic for navigatable/highlightable listbox items.\n *\n * This hook handles:\n * - Item registration with the listbox store\n * - Highlight state management (keyboard and pointer)\n * - Filter/search visibility\n * - Scroll into view on keyboard navigation\n * - Click, pointer move, and pointer down event handlers\n * - Optional aim guard integration (for submenu navigation)\n *\n * @example\n * ```tsx\n * function CustomItem(props) {\n * const item = useListboxItem({\n * value: props.value,\n * disabled: props.disabled,\n * onSelect: props.onSelect,\n * })\n *\n * if (!item.isVisible) return null\n *\n * return (\n * <ItemContext.Provider value={item.contextValue}>\n * <div\n * ref={item.ref}\n * {...item.handlers}\n * data-highlighted={item.isHighlighted || undefined}\n * >\n * {props.children}\n * </div>\n * </ItemContext.Provider>\n * )\n * }\n * ```\n */\nexport function useListboxItem(\n params: UseListboxItemParams,\n): UseListboxItemReturn {\n const {\n id: idProp,\n value: valueProp,\n keywords,\n disabled = false,\n activatable = true,\n forceMount = false,\n shortcut,\n forceOrder,\n forceScore,\n isSubmenuTrigger = false,\n onSelect,\n closeOnClick = true,\n onAfterSelect,\n children,\n aimGuard,\n } = params\n\n const { store } = useSurfaceContext()\n const groupContext = useGroupContext()\n const { depth } = useListboxContext()\n\n const ref = React.useRef<HTMLDivElement>(null)\n\n // Positional row registry: stable per-instance row id + mounted element\n const rowId = React.useId()\n const [rowElement, setRowElement] = React.useState<HTMLElement | null>(null)\n\n React.useLayoutEffect(() => {\n if (!rowElement) return undefined\n return store.registerRow(rowId, rowElement, {\n kind: 'item',\n groupId: groupContext?.groupId,\n })\n }, [rowElement, rowId, groupContext?.groupId, store])\n\n // Infer value from textContent if not provided\n const [inferredValue, setInferredValue] = React.useState<string>('')\n\n // biome-ignore lint/correctness/useExhaustiveDependencies(children): children is an intentional trigger dep — re-infer the value from textContent when content changes\n React.useLayoutEffect(() => {\n if (idProp === undefined && valueProp === undefined && ref.current) {\n const textContent = ref.current.textContent?.trim() ?? ''\n setInferredValue(textContent)\n }\n }, [idProp, valueProp, children])\n\n // Registration ID priority: id prop > value prop > textContent inference\n // This ensures data-first APIs can provide explicit IDs that match their internal tracking\n // Note: valueProp is normalized (trimmed) to match cmdk's behavior\n const registrationId = idProp ?? (normalizeValue(valueProp) || inferredValue)\n\n // Generate a stable ID for DOM id attribute (aria-activedescendant, etc.)\n // When id prop is provided (data-first APIs), use it directly for DOM ID\n // This ensures aria-activedescendant works correctly with composite IDs\n const generatedDomId = React.useId()\n const domId = idProp ?? `item-${generatedDomId}`\n\n // Stabilize keywords to prevent infinite loops when passed as inline arrays\n // We use JSON.stringify to compare by value rather than reference\n // Keywords are also normalized (trimmed) to match cmdk's behavior\n const normalizedKeywords = keywords\n ?.map((k) => normalizeValue(k))\n .filter(Boolean)\n const keywordsKey = normalizedKeywords\n ? JSON.stringify(normalizedKeywords)\n : undefined\n\n // Register item with store (using registrationId as the unique identifier)\n // biome-ignore lint/correctness/useExhaustiveDependencies: keywordsKey is a stable by-value stand-in for normalizedKeywords — depending on the array itself (new identity every render) causes an infinite register/recompute loop\n React.useEffect(() => {\n if (!registrationId && !forceMount) return\n\n const unregister = store.registerItem(registrationId, {\n value: registrationId,\n keywords: normalizedKeywords,\n groupId: groupContext?.groupId,\n disabled,\n activatable,\n isSubmenuTrigger,\n shortcut,\n forceOrder,\n forceScore,\n closeOnClick,\n })\n\n return unregister\n }, [\n registrationId,\n keywordsKey,\n groupContext?.groupId,\n disabled,\n activatable,\n isSubmenuTrigger,\n shortcut,\n forceOrder,\n forceScore,\n closeOnClick,\n store,\n forceMount,\n ])\n\n // Register DOM ref with store for scroll behavior\n React.useEffect(() => {\n if (!registrationId) return\n return store.registerItemRef(registrationId, ref)\n }, [registrationId, store])\n\n // Register for row width measurement if enabled\n const rowWidthContext = useMaybeRowWidthContext()\n\n React.useLayoutEffect(() => {\n if (rowWidthContext && ref.current && registrationId) {\n rowWidthContext.queueMeasurement(ref.current, registrationId)\n }\n }, [rowWidthContext, registrationId])\n\n // Register onSelect handler if provided directly\n React.useEffect(() => {\n if (!onSelect || !registrationId) return\n return store.registerItemSelect(registrationId, onSelect)\n }, [registrationId, onSelect, store])\n\n // Use selectors to get derived state (using registrationId as identifier)\n const normalizedSearch = store.useState('normalizedSearch')\n const isHighlighted = store.useState('isHighlighted', registrationId)\n const isFirstRow = store.useState('isFirstRow', rowId)\n const isLastRow = store.useState('isLastRow', rowId)\n const isFirstInGroup = store.useState('isFirstInGroup', rowId)\n const isLastInGroup = store.useState('isLastInGroup', rowId)\n const score = store.useState('getItemScore', registrationId)\n\n // Check if filtering is disabled (consumer handles filtering externally)\n const filterDisabled = store.isFilterDisabled()\n\n // Determine visibility based on filter score\n // When filterDisabled, consumer handles filtering so all items are visible\n const hasSearch = normalizedSearch.length > 0\n const isVisible = forceMount || filterDisabled || !hasSearch || score > 0\n\n // Note: Scroll behavior is now handled by the store's setHighlightedId method.\n // It uses the registered DOM refs to call scrollIntoView when the element exists,\n // or falls back to onHighlightChange for virtualizer sync.\n\n // Event handlers\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return\n if (disabled) return\n if (activatable === false) return\n if (!registrationId) return\n\n event.preventDefault()\n\n // Call the registered onSelect handler via store\n const registeredHandler = store.context.itemSelects.get(registrationId)\n registeredHandler?.()\n\n // Notify consumer that selection occurred (for closing menus, etc.)\n onAfterSelect?.(registrationId)\n },\n [disabled, activatable, store, registrationId, onAfterSelect],\n )\n\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n event.preventDefault()\n },\n [],\n )\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return\n if (disabled) return\n if (!registrationId) return\n\n // Don't highlight if aim guard is active at this depth (user is moving toward submenu)\n // Only block highlighting in the same menu where the trigger is located\n if (aimGuard) {\n const { aimGuardActiveRef, guardedDepthRef } = aimGuard\n if (aimGuardActiveRef.current && guardedDepthRef.current === depth)\n return\n }\n\n // Check if pointer has actually moved - prevents phantom highlights when\n // content shifts under a stationary pointer (e.g., search results changing)\n if (!store.shouldAllowPointerHighlight(event.clientX, event.clientY)) {\n return\n }\n\n // Highlight on hover (using registrationId as identifier)\n store.setHighlightedId(registrationId)\n },\n [disabled, aimGuard, depth, store, registrationId],\n )\n\n // Context value for child components\n const contextValue: ItemContextValue = React.useMemo(\n () => ({\n id: domId,\n highlighted: isHighlighted,\n disabled,\n shortcut,\n }),\n [domId, isHighlighted, disabled, shortcut],\n )\n\n // Register a custom select handler (for checkbox/radio items)\n const registerSelect = React.useCallback(\n (handler: (() => void) | undefined) => {\n if (!registrationId) return () => {}\n return store.registerItemSelect(registrationId, handler)\n },\n [store, registrationId],\n )\n\n const handlers = React.useMemo(\n () => ({\n onClick: handleClick,\n onPointerMove: handlePointerMove,\n onPointerDown: handlePointerDown,\n }),\n [handleClick, handlePointerMove, handlePointerDown],\n )\n\n const contextPositional = groupContext?.positional\n const positional = React.useMemo(\n () => ({\n first: contextPositional?.first ?? isFirstRow,\n last: contextPositional?.last ?? isLastRow,\n firstInGroup: contextPositional?.firstInGroup ?? isFirstInGroup,\n lastInGroup: contextPositional?.lastInGroup ?? isLastInGroup,\n }),\n [contextPositional, isFirstRow, isLastRow, isFirstInGroup, isLastInGroup],\n )\n\n return {\n id: domId,\n storeId: registrationId,\n ref,\n rowRef: setRowElement,\n positional,\n isHighlighted,\n isVisible,\n contextValue,\n handlers,\n registerSelect,\n }\n}\n","/**\n * Normalizes a value string for use in filtering and identification.\n * Trims leading/trailing whitespace to match cmdk's behavior.\n *\n * @param value - The value to normalize\n * @returns The trimmed value, or empty string if value is nullish\n */\nexport function normalizeValue(value: string | undefined | null): string {\n return value?.trim() ?? ''\n}\n\n/**\n * Remove diacritics/accents from a string so unaccented queries match accented\n * content (e.g. \"cafe\" matches \"café\", \"municao\" matches \"munição\").\n *\n * Uses Unicode NFD decomposition and strips combining marks. Characters that\n * do not decompose into a base letter plus a combining mark (e.g. \"ø\", \"ł\")\n * are intentionally left unchanged.\n *\n * @param value - The value to fold\n * @returns The value with combining diacritical marks removed\n */\nexport function deburr(value: string): string {\n return value.normalize('NFD').replace(/\\p{Diacritic}/gu, '')\n}\n\n/**\n * Converts a value string to a URL-safe slug for use in IDs.\n * - Trims whitespace\n * - Converts to lowercase\n * - Replaces spaces with hyphens\n * - Removes non-alphanumeric characters (except hyphens)\n * - Collapses multiple hyphens into one\n * - Removes leading/trailing hyphens\n *\n * @example\n * slugify(\"User Settings\") // \"user-settings\"\n * slugify(\" Hello World! \") // \"hello-world\"\n * slugify(\"Café & Co.\") // \"caf-co\"\n *\n * @param value - The value to slugify\n * @returns The slugified value, or empty string if value is nullish\n */\nexport function slugify(value: string | undefined | null): string {\n if (!value) return ''\n\n return (\n value\n .trim()\n .toLowerCase()\n // Replace spaces with hyphens\n .replace(/\\s+/g, '-')\n // Remove non-alphanumeric characters (except hyphens)\n .replace(/[^a-z0-9-]/g, '')\n // Collapse multiple hyphens into one\n .replace(/-+/g, '-')\n // Remove leading/trailing hyphens\n .replace(/^-|-$/g, '')\n )\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/ui/ui/packages/react/dist/chunk-XMZZ62VJ.cjs","../src/internal/listbox/contexts/group-context.ts","../src/internal/listbox/contexts/item-context.ts","../src/internal/listbox/contexts/listbox-context.ts","../src/internal/listbox/contexts/row-width-context.ts","../src/internal/listbox/contexts/surface-context.ts","../src/internal/listbox/hooks/use-listbox-item.ts","../src/internal/listbox/utils/normalize.ts"],"names":["GroupContext","useGroupContext","ItemContext","useItemContext","context","useMaybeItemContext","ListboxContext","useListboxContext","useMaybeListboxContext","RowWidthContext","useRowWidthContext","useMaybeRowWidthContext","SurfaceContext","useSurfaceContext","useMaybeSurfaceContext","normalizeValue","value","deburr","slugify","useListboxItem","params","idProp","valueProp","keywords","disabled","activatable","forceMount","shortcut","forceOrder","forceScore","isSubmenuTrigger","onSelect","closeOnClick","onAfterSelect","children","aimGuard","store","groupContext","depth","ref","rowId","rowElement","setRowElement","inferredValue","setInferredValue","textContent","registrationId","generatedDomId","domId"],"mappings":"AAAA,ugCAAyC,uWCElB,IAoBjBA,EAAAA,CAAqB,CAAA,CAAA,aAAA,CAAwC,IAAI,CAAA,CAEhE,SAASC,CAAAA,CAAAA,CAA4C,CAC1D,OAAa,CAAA,CAAA,UAAA,CAAWD,EAAY,CACtC,CCxBA,IAiBME,CAAAA,CAAoB,CAAA,CAAA,aAAA,CAAuC,IAAI,CAAA,CAE9D,SAASC,EAAAA,CAAAA,CAAmC,CACjD,IAAMC,CAAAA,CAAgB,CAAA,CAAA,UAAA,CAAWF,CAAW,CAAA,CAC5C,EAAA,CAAI,CAACE,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,mDAAmD,CAAA,CAErE,OAAOA,CACT,CAEO,SAASC,EAAAA,CAAAA,CAA+C,CAC7D,OAAa,CAAA,CAAA,UAAA,CAAWH,CAAW,CACrC,CC7BA,IAuCMI,CAAAA,CAAuB,CAAA,CAAA,aAAA,CAA0C,IAAI,CAAA,CAEpE,SAASC,CAAAA,CAAAA,CAAyC,CACvD,IAAMH,CAAAA,CAAgB,CAAA,CAAA,UAAA,CAAWE,CAAc,CAAA,CAC/C,EAAA,CAAI,CAACF,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,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OL,CAAAA,CAAM,WAAA,CAAYI,CAAAA,CAAOC,CAAAA,CAAY,CAC1C,IAAA,CAAM,MAAA,CACN,OAAA,iBAASJ,CAAAA,6BAAc,SACzB,CAAC,CACH,CAAA,CAAG,CAACI,CAAAA,CAAYD,CAAAA,iBAAOH,CAAAA,6BAAc,SAAA,CAASD,CAAK,CAAC,CAAA,CAGpD,GAAM,CAACO,CAAAA,CAAeC,CAAgB,CAAA,CAAU,CAAA,CAAA,QAAA,CAAiB,EAAE,CAAA,CAG7D,CAAA,CAAA,eAAA,CAAgB,CAAA,CAAA,EAAM,CAC1B,EAAA,CAAIvB,CAAAA,GAAW,KAAA,CAAA,EAAaC,CAAAA,GAAc,KAAA,CAAA,EAAaiB,CAAAA,CAAI,OAAA,CAAS,CAClE,IAAMM,CAAAA,kCAAcN,CAAAA,qBAAI,OAAA,qBAAQ,WAAA,6BAAa,IAAA,mBAAK,GAAA,SAAK,IAAA,CACvDK,CAAAA,CAAiBC,CAAW,CAC9B,CACF,CAAA,CAAG,CAACxB,CAAAA,CAAQC,CAAAA,CAAWY,CAAQ,CAAC,CAAA,CAKhC,IAAMY,CAAAA,kBAAiBzB,CAAAA,SAAAA,CAAWN,CAAAA,CAAeO,CAAS,CAAA,EAAKqB,CAAAA,GAAAA,CAKzDI,CAAAA,CAAuB,CAAA,CAAA,KAAA,CAAM,CAAA,CAC7BC,CAAAA,kBAAQ3B,CAAAA,SAAU,CAAA,KAAA,EAAQ0B,CAAc,CAAA,GAAA","file":"/home/runner/work/ui/ui/packages/react/dist/chunk-XMZZ62VJ.cjs","sourcesContent":[null,"'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Group Context (for items to know their parent group)\n// ============================================================================\n\nexport interface GroupPositional {\n first?: boolean\n last?: boolean\n firstInGroup?: boolean\n lastInGroup?: boolean\n firstGroup?: boolean\n lastGroup?: boolean\n}\n\nexport interface GroupContextValue {\n groupId?: string\n positional?: GroupPositional\n}\n\nconst GroupContext = React.createContext<GroupContextValue | null>(null)\n\nexport function useGroupContext(): GroupContextValue | null {\n return React.useContext(GroupContext)\n}\n\nexport { GroupContext }\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Item Context (for child components like indicators to access item state)\n// ============================================================================\n\nexport interface ItemContextValue {\n /** Unique ID for this item (for DOM id attribute) */\n id: string\n /** Whether the item is highlighted */\n highlighted: boolean\n /** Whether the item is disabled */\n disabled: boolean\n /** Keyboard shortcut for this item */\n shortcut?: string\n}\n\nconst ItemContext = React.createContext<ItemContextValue | null>(null)\n\nexport function useItemContext(): ItemContextValue {\n const context = React.useContext(ItemContext)\n if (!context) {\n throw new Error('Item child components must be used within an Item')\n }\n return context\n}\n\nexport function useMaybeItemContext(): ItemContextValue | null {\n return React.useContext(ItemContext)\n}\n\nexport { ItemContext }\n","'use client'\n\nimport * as React from 'react'\nimport type { HighlightChangeEventDetails } from '../../popup-menu/events.js'\nimport type { ListboxStore, VirtualItem } from '../store/ListboxStore.js'\n\n/**\n * Virtualization configuration passed from Root/Submenu to Surface.\n */\nexport interface VirtualizationConfig {\n /** Whether virtualization mode is enabled */\n virtualized: boolean\n /** Pre-registered items for virtualization */\n items: VirtualItem[]\n /**\n * Callback when highlighted item changes (for scroll sync).\n * The third parameter contains event details including the reason for the change.\n */\n onHighlightChange?: (\n id: string | null,\n index: number,\n eventDetails: HighlightChangeEventDetails,\n ) => void\n}\n\nexport interface ListboxContextValue {\n /** The Listbox store instance */\n store: ListboxStore\n /** Nesting depth: 0 = root menu, 1+ = submenu */\n depth: number\n /** Close the entire menu tree (deepest submenu to root, sequentially) */\n closeAll: () => void\n /** Register a surface (submenu) for closeAll tracking. Returns unregister function. */\n registerSurface: (\n depth: number,\n setOpen: (open: boolean) => void,\n ) => () => void\n /** Virtualization configuration (if enabled) */\n virtualization?: VirtualizationConfig\n}\n\nconst ListboxContext = React.createContext<ListboxContextValue | null>(null)\n\nexport function useListboxContext(): ListboxContextValue {\n const context = React.useContext(ListboxContext)\n if (!context) {\n throw new Error('Listbox components must be used within a Listbox provider')\n }\n return context\n}\n\nexport function useMaybeListboxContext(): ListboxContextValue | null {\n return React.useContext(ListboxContext)\n}\n\nexport { ListboxContext }\n","'use client'\n\nimport * as React from 'react'\n\n/**\n * Context value for row width measurement.\n * Provided by List when `measureRowWidth` is enabled.\n */\nexport interface RowWidthContextValue {\n /**\n * Queue a row element for width measurement.\n * Call this when a row mounts or becomes visible.\n *\n * @param element - The DOM element to measure\n * @param id - Unique identifier for this row (used to avoid re-measuring)\n */\n queueMeasurement: (element: HTMLElement, id: string) => void\n}\n\n/**\n * Context for row width measurement.\n * Items use this to self-register for measurement.\n */\nexport const RowWidthContext = React.createContext<RowWidthContextValue | null>(\n null,\n)\n\nif (process.env.NODE_ENV !== 'production') {\n RowWidthContext.displayName = 'RowWidthContext'\n}\n\n/**\n * Hook to get the row width context.\n * Throws an error if used outside of a List with `measureRowWidth` enabled.\n */\nexport function useRowWidthContext(): RowWidthContextValue {\n const context = React.useContext(RowWidthContext)\n if (!context) {\n throw new Error(\n 'useRowWidthContext must be used within a List with measureRowWidth enabled',\n )\n }\n return context\n}\n\n/**\n * Hook to optionally get the row width context.\n * Returns null if not within a List with `measureRowWidth` enabled.\n * This is the preferred hook for items that should work both with and without measurement.\n */\nexport function useMaybeRowWidthContext(): RowWidthContextValue | null {\n return React.useContext(RowWidthContext)\n}\n","'use client'\n\nimport * as React from 'react'\nimport type { ListboxStore } from '../store/ListboxStore.js'\n\n// Re-export types from the store for convenience\nexport type {\n FilterFn,\n ItemRegistration,\n} from '../store/ListboxStore.js'\n\n// ============================================================================\n// Surface Context\n// ============================================================================\n\nexport interface SurfaceContextValue {\n /** The Listbox store instance */\n store: ListboxStore\n /** Unique identifier for this surface */\n surfaceId: string\n}\n\nconst SurfaceContext = React.createContext<SurfaceContextValue | null>(null)\n\nexport function useSurfaceContext(): SurfaceContextValue {\n const context = React.useContext(SurfaceContext)\n if (!context) {\n throw new Error('Listbox components must be used within a Surface provider')\n }\n return context\n}\n\nexport function useMaybeSurfaceContext(): SurfaceContextValue | null {\n return React.useContext(SurfaceContext)\n}\n\nexport { SurfaceContext }\n","'use client'\n\nimport * as React from 'react'\nimport { useGroupContext } from '../contexts/group-context.js'\nimport type { ItemContextValue } from '../contexts/item-context.js'\nimport { useListboxContext } from '../contexts/listbox-context.js'\nimport { useMaybeRowWidthContext } from '../contexts/row-width-context.js'\nimport { useSurfaceContext } from '../contexts/surface-context.js'\nimport { normalizeValue } from '../utils/normalize.js'\n\n/**\n * Aim guard refs for submenu navigation.\n * Optional - only needed for popup menus with submenus.\n */\nexport interface AimGuardRefs {\n /** Whether aim guard is currently active */\n aimGuardActiveRef: React.RefObject<boolean>\n /** The depth at which aim guard is active (null when not guarding) */\n guardedDepthRef: React.RefObject<number | null>\n}\n\n/**\n * Parameters for the useListboxItem hook.\n */\nexport interface UseListboxItemParams {\n /**\n * Explicit unique identifier for this item in the store.\n * Takes highest priority for item registration.\n * Used by data-first APIs to ensure consistent IDs.\n */\n id?: string\n\n /**\n * Unique value for this item used as identifier and for filtering.\n * If not provided, will be inferred from textContent.\n * Used for registration when `id` is not provided.\n */\n value?: string\n\n /**\n * Additional keywords to match against when filtering.\n * Useful for aliases or synonyms.\n */\n keywords?: string[]\n\n /**\n * Whether this item is disabled.\n * Disabled items are not selectable and are skipped during keyboard navigation.\n */\n disabled?: boolean\n\n /**\n * Whether this item can be activated via Enter or click.\n * Non-activatable items remain highlightable.\n * @default true\n */\n activatable?: boolean\n\n /**\n * Whether to force render this item regardless of filter results.\n * @default false\n */\n forceMount?: boolean\n\n /**\n * Keyboard shortcut to trigger this item.\n * When the menu is focused and the user presses this key, the item will be selected.\n * Should be a single character (e.g., \"1\", \"a\", etc.).\n */\n shortcut?: string\n\n /**\n * Forces this row's relative order during score-based sorting.\n * Lower values appear earlier.\n * @default 0\n */\n forceOrder?: number\n\n /**\n * Overrides this row's computed fuzzy-match score.\n * Useful for pinning or manually ranking rows in score-based views.\n */\n forceScore?: number\n\n /**\n * Whether this item is a submenu trigger (for store registration).\n * @default false\n */\n isSubmenuTrigger?: boolean\n\n /**\n * Callback when this item is selected (via click or Enter key).\n * For simple items, pass this directly. For checkbox/radio items,\n * use registerSelect() to register a dynamic handler.\n */\n onSelect?: () => void\n\n /**\n * Whether selecting this item should close the menu.\n * @default true\n */\n closeOnClick?: boolean\n\n /**\n * Callback invoked after selection occurs (via click).\n * Called with the item's ID. The consumer handles any\n * post-selection behavior like closing menus.\n */\n onAfterSelect?: (itemId: string) => void\n\n /**\n * Children (used for text content inference when value is not provided).\n */\n children?: React.ReactNode\n\n /**\n * Optional aim guard refs for popup menu navigation.\n * When provided, pointer move events will respect the aim guard.\n */\n aimGuard?: AimGuardRefs\n}\n\n/**\n * Return value from the useListboxItem hook.\n */\nexport interface UseListboxItemReturn {\n /** Unique ID for this item (DOM ID for aria-activedescendant) */\n id: string\n\n /**\n * Store identifier for this item.\n * Use this when calling store methods like setHighlightedId, registerSubmenuOpen, etc.\n * This is the `value` prop (or inferred from textContent).\n */\n storeId: string\n\n /** Ref to attach to the item element */\n ref: React.RefObject<HTMLDivElement | null>\n\n /** Callback ref that tracks the mounted row element for positional attributes. Merge into the rendered element's ref. */\n rowRef: (element: HTMLElement | null) => void\n\n /** Positional state among visible rows (all false in virtualized mode). */\n positional: {\n first: boolean\n last: boolean\n firstInGroup: boolean\n lastInGroup: boolean\n }\n\n /** Whether item is currently highlighted */\n isHighlighted: boolean\n\n /** Whether item should be rendered (passes filter) */\n isVisible: boolean\n\n /** Context value to provide to children via ItemContext.Provider */\n contextValue: ItemContextValue\n\n /**\n * Event handlers to spread on the element.\n * These handle click, pointer move, and pointer down events.\n */\n handlers: {\n onClick: React.MouseEventHandler<HTMLDivElement>\n onPointerMove: React.PointerEventHandler<HTMLDivElement>\n onPointerDown: React.PointerEventHandler<HTMLDivElement>\n }\n\n /**\n * Register a custom onSelect handler.\n * This is useful for checkbox/radio items where the select behavior\n * needs to be customized (e.g., toggle checked state).\n * Returns an unregister function.\n */\n registerSelect: (handler: (() => void) | undefined) => () => void\n}\n\n/**\n * Hook that provides all shared logic for navigatable/highlightable listbox items.\n *\n * This hook handles:\n * - Item registration with the listbox store\n * - Highlight state management (keyboard and pointer)\n * - Filter/search visibility\n * - Scroll into view on keyboard navigation\n * - Click, pointer move, and pointer down event handlers\n * - Optional aim guard integration (for submenu navigation)\n *\n * @example\n * ```tsx\n * function CustomItem(props) {\n * const item = useListboxItem({\n * value: props.value,\n * disabled: props.disabled,\n * onSelect: props.onSelect,\n * })\n *\n * if (!item.isVisible) return null\n *\n * return (\n * <ItemContext.Provider value={item.contextValue}>\n * <div\n * ref={item.ref}\n * {...item.handlers}\n * data-highlighted={item.isHighlighted || undefined}\n * >\n * {props.children}\n * </div>\n * </ItemContext.Provider>\n * )\n * }\n * ```\n */\nexport function useListboxItem(\n params: UseListboxItemParams,\n): UseListboxItemReturn {\n const {\n id: idProp,\n value: valueProp,\n keywords,\n disabled = false,\n activatable = true,\n forceMount = false,\n shortcut,\n forceOrder,\n forceScore,\n isSubmenuTrigger = false,\n onSelect,\n closeOnClick = true,\n onAfterSelect,\n children,\n aimGuard,\n } = params\n\n const { store } = useSurfaceContext()\n const groupContext = useGroupContext()\n const { depth } = useListboxContext()\n\n const ref = React.useRef<HTMLDivElement>(null)\n\n // Positional row registry: stable per-instance row id + mounted element\n const rowId = React.useId()\n const [rowElement, setRowElement] = React.useState<HTMLElement | null>(null)\n\n React.useLayoutEffect(() => {\n if (!rowElement) return undefined\n return store.registerRow(rowId, rowElement, {\n kind: 'item',\n groupId: groupContext?.groupId,\n })\n }, [rowElement, rowId, groupContext?.groupId, store])\n\n // Infer value from textContent if not provided\n const [inferredValue, setInferredValue] = React.useState<string>('')\n\n // biome-ignore lint/correctness/useExhaustiveDependencies(children): children is an intentional trigger dep — re-infer the value from textContent when content changes\n React.useLayoutEffect(() => {\n if (idProp === undefined && valueProp === undefined && ref.current) {\n const textContent = ref.current.textContent?.trim() ?? ''\n setInferredValue(textContent)\n }\n }, [idProp, valueProp, children])\n\n // Registration ID priority: id prop > value prop > textContent inference\n // This ensures data-first APIs can provide explicit IDs that match their internal tracking\n // Note: valueProp is normalized (trimmed) to match cmdk's behavior\n const registrationId = idProp ?? (normalizeValue(valueProp) || inferredValue)\n\n // Generate a stable ID for DOM id attribute (aria-activedescendant, etc.)\n // When id prop is provided (data-first APIs), use it directly for DOM ID\n // This ensures aria-activedescendant works correctly with composite IDs\n const generatedDomId = React.useId()\n const domId = idProp ?? `item-${generatedDomId}`\n\n // Stabilize keywords to prevent infinite loops when passed as inline arrays\n // We use JSON.stringify to compare by value rather than reference\n // Keywords are also normalized (trimmed) to match cmdk's behavior\n const normalizedKeywords = keywords\n ?.map((k) => normalizeValue(k))\n .filter(Boolean)\n const keywordsKey = normalizedKeywords\n ? JSON.stringify(normalizedKeywords)\n : undefined\n\n // Register item with store (using registrationId as the unique identifier)\n // biome-ignore lint/correctness/useExhaustiveDependencies: keywordsKey is a stable by-value stand-in for normalizedKeywords — depending on the array itself (new identity every render) causes an infinite register/recompute loop\n React.useEffect(() => {\n if (!registrationId && !forceMount) return\n\n const unregister = store.registerItem(registrationId, {\n value: registrationId,\n keywords: normalizedKeywords,\n groupId: groupContext?.groupId,\n disabled,\n activatable,\n isSubmenuTrigger,\n shortcut,\n forceOrder,\n forceScore,\n closeOnClick,\n })\n\n return unregister\n }, [\n registrationId,\n keywordsKey,\n groupContext?.groupId,\n disabled,\n activatable,\n isSubmenuTrigger,\n shortcut,\n forceOrder,\n forceScore,\n closeOnClick,\n store,\n forceMount,\n ])\n\n // Register DOM ref with store for scroll behavior\n React.useEffect(() => {\n if (!registrationId) return\n return store.registerItemRef(registrationId, ref)\n }, [registrationId, store])\n\n // Register for row width measurement if enabled\n const rowWidthContext = useMaybeRowWidthContext()\n\n React.useLayoutEffect(() => {\n if (rowWidthContext && ref.current && registrationId) {\n rowWidthContext.queueMeasurement(ref.current, registrationId)\n }\n }, [rowWidthContext, registrationId])\n\n // Register onSelect handler if provided directly\n React.useEffect(() => {\n if (!onSelect || !registrationId) return\n return store.registerItemSelect(registrationId, onSelect)\n }, [registrationId, onSelect, store])\n\n // Use selectors to get derived state (using registrationId as identifier)\n const normalizedSearch = store.useState('normalizedSearch')\n const isHighlighted = store.useState('isHighlighted', registrationId)\n const isFirstRow = store.useState('isFirstRow', rowId)\n const isLastRow = store.useState('isLastRow', rowId)\n const isFirstInGroup = store.useState('isFirstInGroup', rowId)\n const isLastInGroup = store.useState('isLastInGroup', rowId)\n const score = store.useState('getItemScore', registrationId)\n\n // Check if filtering is disabled (consumer handles filtering externally)\n const filterDisabled = store.isFilterDisabled()\n\n // Determine visibility based on filter score\n // When filterDisabled, consumer handles filtering so all items are visible\n const hasSearch = normalizedSearch.length > 0\n const isVisible = forceMount || filterDisabled || !hasSearch || score > 0\n\n // Note: Scroll behavior is now handled by the store's setHighlightedId method.\n // It uses the registered DOM refs to call scrollIntoView when the element exists,\n // or falls back to onHighlightChange for virtualizer sync.\n\n // Event handlers\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return\n if (disabled) return\n if (activatable === false) return\n if (!registrationId) return\n\n event.preventDefault()\n\n // Call the registered onSelect handler via store\n const registeredHandler = store.context.itemSelects.get(registrationId)\n registeredHandler?.()\n\n // Notify consumer that selection occurred (for closing menus, etc.)\n onAfterSelect?.(registrationId)\n },\n [disabled, activatable, store, registrationId, onAfterSelect],\n )\n\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n event.preventDefault()\n },\n [],\n )\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return\n if (disabled) return\n if (!registrationId) return\n\n // Don't highlight if aim guard is active at this depth (user is moving toward submenu)\n // Only block highlighting in the same menu where the trigger is located\n if (aimGuard) {\n const { aimGuardActiveRef, guardedDepthRef } = aimGuard\n if (aimGuardActiveRef.current && guardedDepthRef.current === depth)\n return\n }\n\n // Check if pointer has actually moved - prevents phantom highlights when\n // content shifts under a stationary pointer (e.g., search results changing)\n if (!store.shouldAllowPointerHighlight(event.clientX, event.clientY)) {\n return\n }\n\n // Highlight on hover (using registrationId as identifier)\n store.setHighlightedId(registrationId)\n },\n [disabled, aimGuard, depth, store, registrationId],\n )\n\n // Context value for child components\n const contextValue: ItemContextValue = React.useMemo(\n () => ({\n id: domId,\n highlighted: isHighlighted,\n disabled,\n shortcut,\n }),\n [domId, isHighlighted, disabled, shortcut],\n )\n\n // Register a custom select handler (for checkbox/radio items)\n const registerSelect = React.useCallback(\n (handler: (() => void) | undefined) => {\n if (!registrationId) return () => {}\n return store.registerItemSelect(registrationId, handler)\n },\n [store, registrationId],\n )\n\n const handlers = React.useMemo(\n () => ({\n onClick: handleClick,\n onPointerMove: handlePointerMove,\n onPointerDown: handlePointerDown,\n }),\n [handleClick, handlePointerMove, handlePointerDown],\n )\n\n const contextPositional = groupContext?.positional\n const positional = React.useMemo(\n () => ({\n first: contextPositional?.first ?? isFirstRow,\n last: contextPositional?.last ?? isLastRow,\n firstInGroup: contextPositional?.firstInGroup ?? isFirstInGroup,\n lastInGroup: contextPositional?.lastInGroup ?? isLastInGroup,\n }),\n [contextPositional, isFirstRow, isLastRow, isFirstInGroup, isLastInGroup],\n )\n\n return {\n id: domId,\n storeId: registrationId,\n ref,\n rowRef: setRowElement,\n positional,\n isHighlighted,\n isVisible,\n contextValue,\n handlers,\n registerSelect,\n }\n}\n","/**\n * Normalizes a value string for use in filtering and identification.\n * Trims leading/trailing whitespace to match cmdk's behavior.\n *\n * @param value - The value to normalize\n * @returns The trimmed value, or empty string if value is nullish\n */\nexport function normalizeValue(value: string | undefined | null): string {\n return value?.trim() ?? ''\n}\n\n/**\n * Remove diacritics/accents from a string so unaccented queries match accented\n * content (e.g. \"cafe\" matches \"café\", \"municao\" matches \"munição\").\n *\n * Uses Unicode NFD decomposition and strips combining marks. Characters that\n * do not decompose into a base letter plus a combining mark (e.g. \"ø\", \"ł\")\n * are intentionally left unchanged.\n *\n * @param value - The value to fold\n * @returns The value with combining diacritical marks removed\n */\nexport function deburr(value: string): string {\n return value.normalize('NFD').replace(/\\p{Diacritic}/gu, '')\n}\n\n/**\n * Converts a value string to a URL-safe slug for use in IDs.\n * - Trims whitespace\n * - Converts to lowercase\n * - Replaces spaces with hyphens\n * - Removes non-alphanumeric characters (except hyphens)\n * - Collapses multiple hyphens into one\n * - Removes leading/trailing hyphens\n *\n * @example\n * slugify(\"User Settings\") // \"user-settings\"\n * slugify(\" Hello World! \") // \"hello-world\"\n * slugify(\"Café & Co.\") // \"caf-co\"\n *\n * @param value - The value to slugify\n * @returns The slugified value, or empty string if value is nullish\n */\nexport function slugify(value: string | undefined | null): string {\n if (!value) return ''\n\n return (\n value\n .trim()\n .toLowerCase()\n // Replace spaces with hyphens\n .replace(/\\s+/g, '-')\n // Remove non-alphanumeric characters (except hyphens)\n .replace(/[^a-z0-9-]/g, '')\n // Collapse multiple hyphens into one\n .replace(/-+/g, '-')\n // Remove leading/trailing hyphens\n .replace(/^-|-$/g, '')\n )\n}\n"]}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk5T5B5SPRcjs = require('../chunk-5T5B5SPR.cjs');var _chunkW4ACKMIZcjs = require('../chunk-W4ACKMIZ.cjs');var _chunkXMZZ62VJcjs = require('../chunk-XMZZ62VJ.cjs');var _chunkM4G6J7DPcjs = require('../chunk-M4G6J7DP.cjs');var zo={};_chunkM4G6J7DPcjs.a.call(void 0, zo,{Arrow:()=>_chunkW4ACKMIZcjs.s,Backdrop:()=>_chunkW4ACKMIZcjs.t,Clear:()=>Me,Empty:()=>_chunkW4ACKMIZcjs.U,Group:()=>_chunkW4ACKMIZcjs.pa,GroupLabel:()=>_chunkW4ACKMIZcjs.W,Icon:()=>_chunkW4ACKMIZcjs.T,Input:()=>we,InputWrapper:()=>ke,Item:()=>Te,ItemIndicator:()=>He,ItemLabel:()=>Oe,List:()=>_chunkW4ACKMIZcjs.ba,Popup:()=>_chunkW4ACKMIZcjs.J,Portal:()=>_chunkW4ACKMIZcjs.K,Positioner:()=>De,Root:()=>Ae,ScrollDownArrow:()=>_chunkW4ACKMIZcjs.ea,ScrollUpArrow:()=>_chunkW4ACKMIZcjs.da,Separator:()=>_chunkW4ACKMIZcjs.sa,Surface:()=>Fe,useComboboxPositionerContext:()=>Ee});var _userender = require('@base-ui/react/use-render');var _react = require('react'); var _ = _interopRequireWildcard(_react); var xe = _interopRequireWildcard(_react); var ne = _interopRequireWildcard(_react); var Ce = _interopRequireWildcard(_react); var se = _interopRequireWildcard(_react); var T = _interopRequireWildcard(_react); var re = _interopRequireWildcard(_react); var E = _interopRequireWildcard(_react); var le = _interopRequireWildcard(_react); var Ie = _interopRequireWildcard(_react); var Y = _interopRequireWildcard(_react); var U = _interopRequireWildcard(_react); var h = _interopRequireWildcard(_react); var Z = _interopRequireWildcard(_react);var ko={slot:"bazzaui-combobox-clear"};var Me=_.forwardRef(function(e,o){let{keepMounted:i=!1,disabled:u,render:s,className:p,style:c,onClick:a,onPointerDown:t,...P}=e,m=_chunkW4ACKMIZcjs.w.call(void 0, ),b=_nullishCoalesce(u, () => (m.disabled)),I=m.multiple?m.values.length>0:m.value!=="",d=_.useCallback(R=>{_optionalChain([a, 'optionalCall', _2 => _2(R)]),!R.defaultPrevented&&(m.multiple?m.onValuesChange([]):m.onValueChange(""),m.onInputValueChange(""))},[a,m]),g=_.useCallback(R=>{R.preventDefault(),_optionalChain([t, 'optionalCall', _3 => _3(R)])},[t]),l=_.useMemo(()=>({hasValue:I,disabled:b}),[I,b]),S=_userender.useRender.call(void 0, {render:s,ref:o,state:l,props:{...P,[ko.slot]:"",type:"button",tabIndex:-1,"aria-label":"Clear selection",disabled:b||!I,className:p,style:c,onClick:d,onPointerDown:g},enabled:i||I,defaultTagName:"button"});return!i&&!I?null:S});var fe=xe.createContext(null);function Ee(){return xe.useContext(fe)}var Le=Ce.createContext(!1);function To(){return Ce.useContext(Le)}var Q={slot:"bazzaui-combobox-input",open:"data-open",closed:"data-closed",disabled:"data-disabled",placeholder:"data-placeholder"};function Ho(x){let{comboboxContext:e,open:o}=x,i=e.multiple?e.values.length>0:!_chunkW4ACKMIZcjs.Q.call(void 0, e.value),u=se.useCallback(c=>{let a=_chunkW4ACKMIZcjs.S.call(void 0, c,e.itemToStringValue),t=e.itemTextRegistry.get(a);if(t!==void 0)return t;let P=_chunk5T5B5SPRcjs.f.call(void 0, e.items,a);if(typeof P=="string")return P;let m=_chunkW4ACKMIZcjs.R.call(void 0, c,e.itemToStringLabel);if(m&&m!==a)return m},[e.itemTextRegistry,e.items,e.itemToStringLabel,e.itemToStringValue]),s=se.useMemo(()=>{if(!i)return"";if(e.multiple){let t=e.values.map(P=>{let m=u(P);return m!==void 0?m:_chunkW4ACKMIZcjs.R.call(void 0, P,e.itemToStringLabel)||_chunkW4ACKMIZcjs.S.call(void 0, P,e.itemToStringValue)}).filter(Boolean);return t.length<=2?t.join(", "):`${t.length} selected`}let c=e.value;if(c==null)return"";let a=u(c);return a!==void 0?a:_chunkW4ACKMIZcjs.R.call(void 0, c,e.itemToStringLabel)||_chunkW4ACKMIZcjs.S.call(void 0, c,e.itemToStringValue)},[i,e.multiple,e.value,e.values,e.itemToStringLabel,e.itemToStringValue,u]),p=se.useMemo(()=>o?e.inputValue:s,[o,s,e.inputValue]);return{hasValue:i,displayValue:p,selectedLabel:s,getValueText:u}}function Oo(x){let{comboboxContext:e,store:o,focusOwnerStore:i,open:u,disabled:s,cursorBehavior:p,hasValue:c,getValueText:a,onFocus:t,onBlur:P,onClick:m,onKeyDown:b}=x,I=T.useRef(!1),d=T.useRef(!1),g=T.useRef(!1),l=T.useRef(null),S=T.useRef(null),R=T.useRef(null);T.useEffect(()=>{if(!u)return;let n=f=>{let r=e.inputRef.current,v=e.inputWrapperRef.current,y=document.getElementById(e.listId),O=f.target,W=_optionalChain([r, 'optionalAccess', _4 => _4.contains, 'call', _5 => _5(O)]),z=_optionalChain([v, 'optionalAccess', _6 => _6.contains, 'call', _7 => _7(O)]),ee=_optionalChain([y, 'optionalAccess', _8 => _8.contains, 'call', _9 => _9(O)]);!W&&!z&&!ee&&(R.current=f)};return document.addEventListener("pointerdown",n,!0),()=>{document.removeEventListener("pointerdown",n,!0),R.current=null}},[u,e.inputRef,e.inputWrapperRef,e.listId]),T.useLayoutEffect(()=>{let n=e.inputRef.current;if(n&&u&&S.current){let{start:f,end:r}=S.current,v=n.selectionStart,y=n.value.length;v===y&&f!==y&&n.setSelectionRange(f,r),S.current=null}});let L=T.useRef(u);T.useLayoutEffect(()=>{if(u&&!L.current){if(I.current){I.current=!1,L.current=u;return}if(g.current){g.current=!1,d.current=!1,l.current=null,L.current=u;return}if(d.current&&p==="none"){let f=e.inputRef.current,r=l.current;f&&r!==null&&requestAnimationFrame(()=>{let v=f.value.length,y=Math.min(r,v);f.setSelectionRange(y,y)}),d.current=!1,l.current=null,L.current=u;return}c&&e.multiple&&e.onInputValueChange("");let n=e.inputRef.current;if(n){let f=n.value.length;p==="select-all"&&f>0?requestAnimationFrame(()=>{n.setSelectionRange(0,n.value.length)}):p==="end"&&f>0&&requestAnimationFrame(()=>{n.setSelectionRange(n.value.length,n.value.length)})}}L.current=u},[u,e,c,p]);let w=T.useCallback(n=>{let f=n.target,r=f.value,v=f.selectionStart,y=f.selectionEnd;v!==null&&y!==null&&(S.current={start:v,end:y}),e.onInputValueChange(r),e.setFilterActive(),o.setSearch(r),o.state.open||(I.current=!0,e.openCombobox())},[e,o]),k=T.useCallback(n=>{if(_optionalChain([t, 'optionalCall', _10 => _10(n)]),n.defaultPrevented)return;let f=o.state.open;if(f&&(g.current=!0),e.openOnFocus&&!s&&!f){if(c&&!e.multiple){let r=_nullishCoalesce(a(e.value), () => (_chunkW4ACKMIZcjs.R.call(void 0, e.value,e.itemToStringLabel)));e.onInputValueChange(r)}e.openCombobox()}},[t,e,s,o,c,a]),V=T.useCallback(n=>{_optionalChain([P, 'optionalCall', _11 => _11(n)]),!n.defaultPrevented&&requestAnimationFrame(()=>{let f=document.activeElement,v=_optionalChain([document, 'access', _12 => _12.getElementById, 'call', _13 => _13(e.listId), 'optionalAccess', _14 => _14.contains, 'call', _15 => _15(f)]),y=f===e.inputRef.current;if(!v&&!y){g.current=!1;let O=R.current,W=O?_chunkXMZZ62VJcjs.a.outsidePress:_chunkXMZZ62VJcjs.a.focusOut;R.current=null,e.closeCombobox(W,_nullishCoalesce(O, () => (void 0)))}})},[P,e]),A=T.useCallback(n=>{if(_optionalChain([m, 'optionalCall', _16 => _16(n)]),n.defaultPrevented)return;let f=o.state.open;if(!s&&!f){let r=n.target;if(p==="none"){let v=r.selectionStart;l.current=v,d.current=!0}if(c&&!e.multiple){let v=_nullishCoalesce(a(e.value), () => (_chunkW4ACKMIZcjs.R.call(void 0, e.value,e.itemToStringLabel)));e.onInputValueChange(v)}e.openCombobox()}else f&&(g.current=!0)},[m,e,s,o,p,c,a]),K=T.useCallback(n=>{if(_optionalChain([b, 'optionalCall', _17 => _17(n)]),!n.defaultPrevented){if(u&&n.key==="Escape"){n.preventDefault(),e.closeCombobox(_chunkXMZZ62VJcjs.a.escapeKey);return}if(!u&&(n.key==="ArrowDown"||n.key==="ArrowUp"||n.key==="Enter")){if(n.preventDefault(),c&&!e.multiple){let f=_nullishCoalesce(a(e.value), () => (_chunkW4ACKMIZcjs.R.call(void 0, e.value,e.itemToStringLabel)));e.onInputValueChange(f)}e.openCombobox();return}}},[u,e,b,c,a]),{handleKeyDown:j}=_chunkW4ACKMIZcjs.P.call(void 0, {store:o,surfaceId:"combobox-input",focusOwnerStore:i,depth:0,submenuContext:null,subpageContext:null,enabled:u,enableTypeToSearch:!1,onKeyDown:K,closeAll:e.closeCombobox,skipFocusOwnerCheck:!0});return{handleChange:w,handleFocus:k,handleBlur:V,handleClick:A,handleKeyDown:j,selectionRef:S}}var we=ne.forwardRef(function(e,o){let{placeholder:i,disabled:u,cursorBehavior:s="none",render:p,className:c,style:a,onFocus:t,onBlur:P,onClick:m,onKeyDown:b,...I}=e,d=_chunkW4ACKMIZcjs.w.call(void 0, ),g=_chunkW4ACKMIZcjs.d.call(void 0, ),l=_chunkW4ACKMIZcjs.a.call(void 0, ),S=To(),R=(_nullishCoalesce(u, () => (d.disabled)))||g.disabled,L=_chunk5T5B5SPRcjs.f.call(void 0, d.items,""),w=_nullishCoalesce(_nullishCoalesce(i, () => ((typeof L=="string"?L:void 0))), () => (d.placeholder)),k=g.store.useState("open"),{hasValue:V,displayValue:A,getValueText:K}=Ho({comboboxContext:d,open:k}),{handleChange:j,handleFocus:n,handleBlur:f,handleClick:r,handleKeyDown:v}=Oo({comboboxContext:d,store:g.store,focusOwnerStore:l,open:k,disabled:R,cursorBehavior:s,hasValue:V,getValueText:K,onFocus:t,onBlur:P,onClick:m,onKeyDown:b}),y={[Q.slot]:""};k?y[Q.open]="":y[Q.closed]="",R&&(y[Q.disabled]=""),V||(y[Q.placeholder]=""),d.layout==="input-embedded"&&(y["data-input-embedded"]="");let O=ne.useCallback(M=>{d.setInputElement(M),typeof o=="function"?o(M):o&&(o.current=M)},[o,d]),W=ne.useMemo(()=>({open:k,disabled:R,placeholder:!V}),[k,R,V]),z=d.layout==="input-embedded"&&!S?{position:"relative",zIndex:1}:void 0;return _userender.useRender.call(void 0, {render:p,ref:O,state:W,props:{...I,...y,type:"text",role:"combobox","aria-autocomplete":"list","aria-expanded":k,"aria-controls":d.listId,"aria-haspopup":"listbox",autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:R,placeholder:V?void 0:w,className:c,style:{...z,...a},value:A,onChange:j,onFocus:n,onBlur:f,onClick:r,onKeyDown:v},defaultTagName:"input"})});var ge={slot:"bazzaui-combobox-input-wrapper",open:"data-open"};var _jsxruntime = require('react/jsx-runtime');var Rt={open:x=>x?{[ge.open]:""}:null},ke= exports.ComboboxInputWrapper =re.forwardRef(function(e,o){let{render:i,className:u,style:s,children:p,...c}=e,{store:a}=_chunkW4ACKMIZcjs.d.call(void 0, ),t=_chunkW4ACKMIZcjs.w.call(void 0, ),P=a.useState("open"),m=re.useMemo(()=>({open:P}),[P]),b=t.layout==="input-embedded"?{position:"relative",zIndex:1}:{position:"relative"},I=re.useCallback(g=>{t.setInputWrapperElement(g),typeof o=="function"?o(g):o&&(o.current=g)},[o,t]),d=_userender.useRender.call(void 0, {render:i,ref:I,state:m,stateAttributesMapping:Rt,props:{...c,[ge.slot]:"",className:u,style:{...b,...s},children:p},defaultTagName:"div"});return _jsxruntime.jsx.call(void 0, Le.Provider,{value:!0,children:d})});var q={slot:"bazzaui-combobox-item",highlighted:"data-highlighted",disabled:"data-disabled",selected:"data-selected",first:"data-first",last:"data-last",firstInGroup:"data-first-in-group",lastInGroup:"data-last-in-group"};var he=le.createContext(null);function ue(){let x=le.useContext(he);if(!x)throw new Error("ComboboxItem child components must be used within a Combobox.Item");return x}function yt(){return le.useContext(he)}var Vt={highlighted:x=>x?{[q.highlighted]:""}:null,disabled:x=>x?{[q.disabled]:""}:null,selected:x=>x?{[q.selected]:""}:null,first:x=>x?{[q.first]:""}:null,last:x=>x?{[q.last]:""}:null,firstInGroup:x=>x?{[q.firstInGroup]:""}:null,lastInGroup:x=>x?{[q.lastInGroup]:""}:null};function Mt(x,e){let{value:o,textValue:i,keywords:u,disabled:s=!1,onSelect:p,forceMount:c=!1,render:a,className:t,style:P,onClick:m,onPointerDown:b,onPointerMove:I,children:d,...g}=x,l=_chunkW4ACKMIZcjs.w.call(void 0, ),S=E.useMemo(()=>_chunkW4ACKMIZcjs.S.call(void 0, o,l.itemToStringValue),[o,l.itemToStringValue]),R=E.useId(),L=o===null?`combobox-clear-${R}`:void 0,w=E.useMemo(()=>_chunk5T5B5SPRcjs.e.call(void 0, l.items,S),[l.items,S]),k=_optionalChain([w, 'optionalAccess', _18 => _18.label]),V=E.useMemo(()=>_chunkW4ACKMIZcjs.R.call(void 0, o,l.itemToStringLabel),[o,l.itemToStringLabel]),A=E.useMemo(()=>{if(i!==void 0)return i;if(typeof k=="string")return k;if(V&&V!==S)return V},[i,k,V,S]),K=E.useMemo(()=>_chunk5T5B5SPRcjs.g.call(void 0, u,[typeof k=="string"?k:V&&V!==S?V:void 0,..._nullishCoalesce(_optionalChain([w, 'optionalAccess', _19 => _19.keywords]), () => ([]))]),[u,k,V,S,w]),j=E.useRef(A),n=l.multiple?_chunk5T5B5SPRcjs.c.call(void 0, l.values,o,l.isItemEqualToValue):l.value!==""&&_chunk5T5B5SPRcjs.b.call(void 0, l.value,o,l.isItemEqualToValue),f=l.closeOnSelect,r=_chunkW4ACKMIZcjs.O.call(void 0, {id:L,value:S,keywords:K,disabled:s,forceMount:c,closeOnClick:f,children:d});E.useEffect(()=>{let M=()=>{if(!s){if(l.multiple)if(o==null)l.onValuesChange([]);else{let me=n?_chunk5T5B5SPRcjs.d.call(void 0, l.values,o,l.isItemEqualToValue):[...l.values,o];l.onValuesChange(me)}else l.onValueChange(o);_optionalChain([p, 'optionalCall', _20 => _20()])}};return r.registerSelect(M)},[s,l,o,n,p,r]),E.useEffect(()=>{let M=j.current;if(M)return l.registerItemText(S,M)},[S,l]),E.useEffect(()=>{!A&&typeof d=="string"&&(j.current=d,l.registerItemText(S,d))},[d,A,S,l]);let v=E.useMemo(()=>({highlighted:r.isHighlighted,disabled:s,selected:n,first:r.positional.first,last:r.positional.last,firstInGroup:r.positional.firstInGroup,lastInGroup:r.positional.lastInGroup}),[r.isHighlighted,s,n,r.positional]),y=E.useMemo(()=>({id:r.id,value:o,textValue:A,highlighted:r.isHighlighted,disabled:s,selected:n}),[r.id,o,A,r.isHighlighted,s,n]),O=E.useCallback(M=>{_optionalChain([m, 'optionalCall', _21 => _21(M)]),M.defaultPrevented||r.handlers.onClick(M)},[m,r.handlers]),W=E.useCallback(M=>{r.handlers.onPointerDown(M),_optionalChain([b, 'optionalCall', _22 => _22(M)])},[r.handlers,b]),z=E.useCallback(M=>{_optionalChain([I, 'optionalCall', _23 => _23(M)]),M.defaultPrevented||r.handlers.onPointerMove(M)},[I,r.handlers]),ee=_userender.useRender.call(void 0, {render:a,ref:[r.ref,r.rowRef,e],state:v,stateAttributesMapping:Vt,props:{...g,[q.slot]:"",id:r.id,role:"option",tabIndex:-1,"aria-selected":n,"aria-disabled":s||void 0,className:t,style:P,onClick:O,onPointerMove:z,onPointerDown:W,children:d},enabled:r.isVisible,defaultTagName:"div"});return r.isVisible?_jsxruntime.jsx.call(void 0, he.Provider,{value:y,children:ee}):null}var Te=E.forwardRef(Mt);var Pe={slot:"bazzaui-combobox-item-indicator",selected:"data-selected"};var wt={selected:x=>x?{[Pe.selected]:""}:null},He= exports.ComboboxItemIndicator =Ie.forwardRef(function(e,o){let{keepMounted:i=!1,render:u,className:s,style:p,...c}=e,a=ue(),t=Ie.useMemo(()=>({selected:a.selected}),[a.selected]),P=_userender.useRender.call(void 0, {render:u,ref:o,state:t,stateAttributesMapping:wt,props:{...c,[Pe.slot]:"","aria-hidden":!0,className:s,style:p},enabled:i||a.selected,defaultTagName:"span"});return!i&&!a.selected?null:P});var Do={slot:"bazzaui-combobox-item-label"};var Oe=Y.forwardRef(function(e,o){let{render:i,className:u,style:s,children:p,...c}=e,a=_chunkW4ACKMIZcjs.w.call(void 0, ),t=ue(),P=_chunkW4ACKMIZcjs.S.call(void 0, t.value,a.itemToStringValue),m=Y.useMemo(()=>{if(p!==void 0)return p;let I=_chunk5T5B5SPRcjs.f.call(void 0, a.items,P);return I!==void 0?I:t.textValue!==void 0?t.textValue:P},[p,a.items,P,t.textValue]),b=Y.useMemo(()=>({value:P,selected:t.selected,highlighted:t.highlighted,disabled:t.disabled}),[P,t.selected,t.highlighted,t.disabled]);return Y.useEffect(()=>{if(typeof m=="string")return a.registerItemText(P,m)},[m,a,P]),_userender.useRender.call(void 0, {render:i,ref:o,state:b,props:{...c,[Do.slot]:"",className:u,style:s,children:m},defaultTagName:"span"})});var _popover = require('@base-ui/react/popover');var Re={slot:"bazzaui-combobox-positioner"};function Tt(x,e,o,i){let u=o+i*2;if(x==="top"){let c=-(e+i),a=e+i;return{width:u,marginBottom:c,paddingTop:i,paddingLeft:i,paddingRight:i,paddingBottom:a}}let s=-(e+i),p=e+i;return{width:u,marginTop:s,paddingTop:p,paddingLeft:i,paddingRight:i,paddingBottom:i}}var De=U.forwardRef(function(e,o){let{layout:i,popupPadding:u=8,side:s="bottom",align:p,sideOffset:c=4,anchor:a,className:t,style:P,children:m,...b}=e,I=_chunkW4ACKMIZcjs.w.call(void 0, ),d=_nullishCoalesce(i, () => (I.layout)),g=d==="input-embedded",l=_nullishCoalesce(a, () => (I.inputWrapperRef.current))?I.inputWrapperRef:I.inputRef,S=g?0:c,R=g?"center":_nullishCoalesce(p, () => ("start")),{inputHeight:L,inputWidth:w}=I,k=w+u*2,V={...P,...g?{zIndex:0}:{}};if(g)return _jsxruntime.jsx.call(void 0, _popover.Popover.Positioner,{ref:o,side:s,align:R,sideOffset:S,anchor:l,className:t,style:V,"data-input-embedded":"",[Re.slot]:"",...b,render:(n,f)=>{let r=f.side,v={layout:d,side:r,align:f.align,inputHeight:I.inputHeight},y={"--combobox-input-height":`${L}px`,"--combobox-input-width":`${w}px`,"--combobox-popup-padding":`${u}px`,"--combobox-popup-width":`${k}px`},O=Tt(r,L,w,u),W=U.Children.map(m,z=>U.isValidElement(z)?U.cloneElement(z,{style:{...O,...z.props.style},"data-side":r}):z);return _jsxruntime.jsx.call(void 0, fe.Provider,{value:v,children:_jsxruntime.jsx.call(void 0, "div",{...n,style:{...n.style,...y},"data-side":r,children:W})})}});let A={layout:d,side:s,align:R,inputHeight:I.inputHeight},K={"--combobox-input-height":`${L}px`,"--combobox-input-width":`${w}px`},j={...V,...K};return _jsxruntime.jsx.call(void 0, fe.Provider,{value:A,children:_jsxruntime.jsx.call(void 0, _popover.Popover.Positioner,{ref:o,side:s,align:R,sideOffset:S,anchor:l,className:t,style:j,[Re.slot]:"",...b,children:m})})});function Ae(x){let{open:e,onOpenChange:o,actionsRef:i,defaultOpen:u=!1,value:s,defaultValue:p,onValueChange:c,multiple:a=!1,values:t,defaultValues:P,onValuesChange:m,isItemEqualToValue:b=_chunk5T5B5SPRcjs.a,itemToStringLabel:I,itemToStringValue:d,inputValue:g,defaultInputValue:l="",onInputValueChange:S,name:R,form:L,required:w,disabled:k=!1,placeholder:V="Search...",items:A,modal:K=!1,closeOnSelect:j,openOnFocus:n=!0,virtualized:f=!1,virtualItems:r,onHighlightChange:v,layout:y="floating",onOpenChangeComplete:O,debug:W,children:z,...ee}=x,M=h.useCallback((C,H,G,be)=>_optionalChain([v, 'optionalCall', _24 => _24(C,G,be)]),[v]),me=h.useId(),ce=h.useRef(null),Se=h.useRef(null),[ze,Be]=h.useState(0),[We,je]=h.useState(0),Ge=h.useCallback(C=>{if(ce.current=C,C&&!Se.current){let H=C.getBoundingClientRect();Be(H.height),je(H.width)}},[]),Ne=h.useCallback(C=>{if(Se.current=C,C){let H=C.getBoundingClientRect();Be(H.height),je(H.width)}},[]),{store:B,focusOwnerStore:$o,openChainStore:Jo,registerSurface:Xo,closeAll:_o,virtualization:Qo,handleOpenChange:qe,disabled:$,setDisabled:Ke,menuTreeResolver:Yo}=_chunkW4ACKMIZcjs.q.call(void 0, {onOpenChange:o,defaultOpen:u,virtualized:f,items:r,onHighlightChange:M,disabled:k}),ye=h.useRef(null);h.useImperativeHandle(i,()=>({close:()=>{_optionalChain([ye, 'access', _25 => _25.current, 'optionalAccess', _26 => _26.close, 'call', _27 => _27()])},unmount:()=>{_optionalChain([ye, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.unmount, 'call', _30 => _30()])},setDisabled:Ke}),[Ke]),B.useControlledProp("openProp",e);let Zo=B.useState("open"),Ue=h.useCallback((C,H,G)=>{$&&H!==_chunkXMZZ62VJcjs.a.imperativeAction||!C&&ce.current&&document.activeElement===ce.current||qe(C,H,G)},[qe,$]),et=h.useCallback(C=>{!C&&B.context.clearSearchOnClose==="after-exit"&&(B.clearSearch(),B.setInputActive(!1)),C||B.clearHighlight(),_optionalChain([O, 'optionalCall', _31 => _31(C)])},[B,O]),ot=h.useCallback((C,H)=>{Ue(C,H.reason,H.event)},[Ue]),[tt,nt]=h.useState(p!==void 0?p:null),J=s!==void 0?s:tt,$e=h.useCallback(C=>{s===void 0&&nt(C),_optionalChain([c, 'optionalCall', _32 => _32(C)])},[s,c]),[rt,at]=h.useState(_nullishCoalesce(P, () => ([]))),ae=t!==void 0?t:rt,Je=h.useCallback(C=>{t===void 0&&at(C),_optionalChain([m, 'optionalCall', _33 => _33(C)])},[t,m]),[ve,st]=h.useState(l),Xe=g!==void 0?g:ve,_e=h.useCallback(C=>{g===void 0&&st(C),_optionalChain([S, 'optionalCall', _34 => _34(C)])},[g,S]),Qe=h.useRef(new Map),Ye=h.useCallback((C,H)=>(Qe.current.set(C,H),()=>{}),[]),Ze=_nullishCoalesce(j, () => (!a)),Ve=h.useRef({type:"active"}),[,lt]=h.useState({type:"active"}),X=h.useCallback(C=>{Ve.current=C,lt(C)},[]),eo=Ve.current,oo=h.useCallback(()=>{X({type:"active"})},[X]),to=h.useCallback(()=>{$||(!a&&J!=null?X({type:"showAll"}):X({type:"active"}),B.setOpen(!0))},[$,B,a,J,X]),no=h.useCallback((C,H)=>{let G=Ve.current,be=G.type==="active"?ve:G.type==="showAll"?"":G.search;X({type:"frozen",search:be}),B.setOpen(!1,C,H)},[B,X,ve]),ut=h.useMemo(()=>({multiple:a,value:J,values:ae,onValueChange:$e,onValuesChange:Je,isItemEqualToValue:b,itemToStringLabel:I,itemToStringValue:d,inputValue:Xe,onInputValueChange:_e,name:R,form:L,required:w,disabled:$,placeholder:V,items:A,itemTextRegistry:Qe.current,registerItemText:Ye,listId:me,inputRef:ce,setInputElement:Ge,inputWrapperRef:Se,setInputWrapperElement:Ne,closeOnSelect:Ze,openOnFocus:n,openCombobox:to,closeCombobox:no,filterMode:eo,setFilterActive:oo,inputHeight:ze,inputWidth:We,layout:y}),[a,J,ae,$e,Je,b,I,d,Xe,_e,R,L,w,$,V,A,Ye,me,Ge,Ne,Ze,n,to,no,eo,oo,ze,We,y]),it=h.useMemo(()=>R?a?ae.length>0?ae.map((C,H)=>{let G=_chunkW4ACKMIZcjs.S.call(void 0, C,d);return _jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:R,value:G,form:L,required:w&&H===0},G)}):_jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:R,value:"",form:L,required:w}):_jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:R,value:J!=null?_chunkW4ACKMIZcjs.S.call(void 0, J,d):"",form:L,required:w}):null,[R,L,w,a,J,ae,d]);return _jsxruntime.jsx.call(void 0, _chunkW4ACKMIZcjs.v.Provider,{value:ut,children:_jsxruntime.jsxs.call(void 0, _chunkW4ACKMIZcjs.N,{menuTreeResolver:Yo,store:B,focusOwnerStore:$o,openChainStore:Jo,disabled:$,depth:0,closeAll:_o,registerSurface:Xo,virtualization:Qo,menuType:"dropdown",componentName:"combobox",debug:W,children:[it,_jsxruntime.jsx.call(void 0, _popover.Popover.Root,{...ee,open:Zo,onOpenChange:ot,onOpenChangeComplete:et,modal:K,actionsRef:i?ye:void 0,children:z})]})})}var Fo={slot:"bazzaui-combobox-surface"};var Fe=Z.forwardRef(function(e,o){let{autoHighlightFirst:i,clearSearchOnClose:u=!0,search:s,onSearchChange:p,onPointerMove:c,...a}=e,t=_chunkW4ACKMIZcjs.w.call(void 0, ),P=Z.useCallback(g=>{_optionalChain([c, 'optionalCall', _35 => _35(g)]);let l=t.inputRef.current;l&&document.activeElement!==l&&l.focus()},[c,t.inputRef]),m=Z.useMemo(()=>{let g=_nullishCoalesce(i, () => (!0));if(g==="selected"){let l=t.multiple?t.values[0]:t.value;return l!=null?_chunkW4ACKMIZcjs.S.call(void 0, l,t.itemToStringValue):!0}return g},[i,t.multiple,t.value,t.values,t.itemToStringValue]),{filterMode:b}=t,I=_nullishCoalesce(s, () => ((b.type==="active"?t.inputValue:b.type==="showAll"?"":b.search))),d=Z.useCallback(g=>{t.onInputValueChange(g),_optionalChain([p, 'optionalCall', _36 => _36(g)])},[t,p]);return _jsxruntime.jsx.call(void 0, _chunkW4ACKMIZcjs.fa,{ref:o,autoHighlightFirst:m,clearSearchOnClose:u,search:I,onSearchChange:d,onPointerMove:P,skipAutoFocus:!0,[Fo.slot]:"",...a})});var Bo=(p=>(p.slot="bazzaui-combobox-arrow",p.open="data-open",p.closed="data-closed",p.side="data-side",p.align="data-align",p.uncentered="data-uncentered",p))(Bo||{});var Wo=(s=>(s.slot="bazzaui-combobox-backdrop",s.open="data-open",s.closed="data-closed",s.startingStyle="data-starting-style",s.endingStyle="data-ending-style",s))(Wo||{});var jo=(e=>(e.slot="bazzaui-combobox-empty",e))(jo||{});var Go=(e=>(e.slot="bazzaui-combobox-group",e))(Go||{});var No=(e=>(e.slot="bazzaui-combobox-group-label",e))(No||{});var At={slot:"bazzaui-combobox-icon",open:"data-popup-open"};var qo=(o=>(o.slot="bazzaui-combobox-list",o.list="data-popup-menu-list",o))(qo||{});var Ko=(b=>(b.slot="bazzaui-combobox-popup",b.open="data-open",b.closed="data-closed",b.side="data-side",b.align="data-align",b.startingStyle="data-starting-style",b.endingStyle="data-ending-style",b.instant="data-instant",b.focused="data-focused",b.hasOpenSubmenu="data-has-open-submenu",b.submenu="data-submenu",b.navigating="data-navigating",b))(Ko||{});var Ft={slotUp:"bazzaui-combobox-scroll-up-arrow",slotDown:"bazzaui-combobox-scroll-down-arrow",direction:"data-direction",side:"data-side"};var Uo=(e=>(e.slot="bazzaui-combobox-separator",e))(Uo||{});exports.Combobox = zo; exports.ComboboxArrowDataAttributes = Bo; exports.ComboboxBackdropDataAttributes = Wo; exports.ComboboxClear = Me; exports.ComboboxEmptyDataAttributes = jo; exports.ComboboxGroupDataAttributes = Go; exports.ComboboxGroupLabelDataAttributes = No; exports.ComboboxIconDataAttributes = At; exports.ComboboxInput = we; exports.ComboboxInputDataAttributes = Q; exports.ComboboxInputWrapper = ke; exports.ComboboxInputWrapperDataAttributes = ge; exports.ComboboxItem = Te; exports.ComboboxItemDataAttributes = q; exports.ComboboxItemIndicator = He; exports.ComboboxItemIndicatorDataAttributes = Pe; exports.ComboboxItemLabel = Oe; exports.ComboboxListCssVars = _chunkW4ACKMIZcjs.aa; exports.ComboboxListDataAttributes = qo; exports.ComboboxPopupDataAttributes = Ko; exports.ComboboxPositioner = De; exports.ComboboxPositionerCssVars = _chunkW4ACKMIZcjs.L; exports.ComboboxPositionerDataAttributes = Re; exports.ComboboxRoot = Ae; exports.ComboboxScrollArrowDataAttributes = Ft; exports.ComboboxSeparatorDataAttributes = Uo; exports.ComboboxStore = _chunkXMZZ62VJcjs.y; exports.ComboboxSurface = Fe; exports.commandScore = _chunkXMZZ62VJcjs.w; exports.defaultFilter = _chunkXMZZ62VJcjs.x; exports.useComboboxContext = _chunkW4ACKMIZcjs.w; exports.useComboboxItemContext = ue; exports.useComboboxPositionerContext = Ee; exports.useMaybeComboboxContext = _chunkW4ACKMIZcjs.x; exports.useMaybeComboboxItemContext = yt; exports.useMaybeSurfaceContext = _chunkXMZZ62VJcjs.q; exports.useSurfaceContext = _chunkXMZZ62VJcjs.p;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk5T5B5SPRcjs = require('../chunk-5T5B5SPR.cjs');var _chunkEYMK7XHCcjs = require('../chunk-EYMK7XHC.cjs');var _chunkXMZZ62VJcjs = require('../chunk-XMZZ62VJ.cjs');var _chunkM4G6J7DPcjs = require('../chunk-M4G6J7DP.cjs');var zo={};_chunkM4G6J7DPcjs.a.call(void 0, zo,{Arrow:()=>_chunkEYMK7XHCcjs.s,Backdrop:()=>_chunkEYMK7XHCcjs.t,Clear:()=>Me,Empty:()=>_chunkEYMK7XHCcjs.U,Group:()=>_chunkEYMK7XHCcjs.pa,GroupLabel:()=>_chunkEYMK7XHCcjs.W,Icon:()=>_chunkEYMK7XHCcjs.T,Input:()=>we,InputWrapper:()=>ke,Item:()=>Te,ItemIndicator:()=>He,ItemLabel:()=>Oe,List:()=>_chunkEYMK7XHCcjs.ba,Popup:()=>_chunkEYMK7XHCcjs.J,Portal:()=>_chunkEYMK7XHCcjs.K,Positioner:()=>De,Root:()=>Ae,ScrollDownArrow:()=>_chunkEYMK7XHCcjs.ea,ScrollUpArrow:()=>_chunkEYMK7XHCcjs.da,Separator:()=>_chunkEYMK7XHCcjs.sa,Surface:()=>Fe,useComboboxPositionerContext:()=>Ee});var _userender = require('@base-ui/react/use-render');var _react = require('react'); var _ = _interopRequireWildcard(_react); var xe = _interopRequireWildcard(_react); var ne = _interopRequireWildcard(_react); var Ce = _interopRequireWildcard(_react); var se = _interopRequireWildcard(_react); var T = _interopRequireWildcard(_react); var re = _interopRequireWildcard(_react); var E = _interopRequireWildcard(_react); var le = _interopRequireWildcard(_react); var Ie = _interopRequireWildcard(_react); var Y = _interopRequireWildcard(_react); var U = _interopRequireWildcard(_react); var h = _interopRequireWildcard(_react); var Z = _interopRequireWildcard(_react);var ko={slot:"bazzaui-combobox-clear"};var Me=_.forwardRef(function(e,o){let{keepMounted:i=!1,disabled:u,render:s,className:p,style:c,onClick:a,onPointerDown:t,...P}=e,m=_chunkEYMK7XHCcjs.w.call(void 0, ),b=_nullishCoalesce(u, () => (m.disabled)),I=m.multiple?m.values.length>0:m.value!=="",d=_.useCallback(R=>{_optionalChain([a, 'optionalCall', _2 => _2(R)]),!R.defaultPrevented&&(m.multiple?m.onValuesChange([]):m.onValueChange(""),m.onInputValueChange(""))},[a,m]),g=_.useCallback(R=>{R.preventDefault(),_optionalChain([t, 'optionalCall', _3 => _3(R)])},[t]),l=_.useMemo(()=>({hasValue:I,disabled:b}),[I,b]),S=_userender.useRender.call(void 0, {render:s,ref:o,state:l,props:{...P,[ko.slot]:"",type:"button",tabIndex:-1,"aria-label":"Clear selection",disabled:b||!I,className:p,style:c,onClick:d,onPointerDown:g},enabled:i||I,defaultTagName:"button"});return!i&&!I?null:S});var fe=xe.createContext(null);function Ee(){return xe.useContext(fe)}var Le=Ce.createContext(!1);function To(){return Ce.useContext(Le)}var Q={slot:"bazzaui-combobox-input",open:"data-open",closed:"data-closed",disabled:"data-disabled",placeholder:"data-placeholder"};function Ho(x){let{comboboxContext:e,open:o}=x,i=e.multiple?e.values.length>0:!_chunkEYMK7XHCcjs.Q.call(void 0, e.value),u=se.useCallback(c=>{let a=_chunkEYMK7XHCcjs.S.call(void 0, c,e.itemToStringValue),t=e.itemTextRegistry.get(a);if(t!==void 0)return t;let P=_chunk5T5B5SPRcjs.f.call(void 0, e.items,a);if(typeof P=="string")return P;let m=_chunkEYMK7XHCcjs.R.call(void 0, c,e.itemToStringLabel);if(m&&m!==a)return m},[e.itemTextRegistry,e.items,e.itemToStringLabel,e.itemToStringValue]),s=se.useMemo(()=>{if(!i)return"";if(e.multiple){let t=e.values.map(P=>{let m=u(P);return m!==void 0?m:_chunkEYMK7XHCcjs.R.call(void 0, P,e.itemToStringLabel)||_chunkEYMK7XHCcjs.S.call(void 0, P,e.itemToStringValue)}).filter(Boolean);return t.length<=2?t.join(", "):`${t.length} selected`}let c=e.value;if(c==null)return"";let a=u(c);return a!==void 0?a:_chunkEYMK7XHCcjs.R.call(void 0, c,e.itemToStringLabel)||_chunkEYMK7XHCcjs.S.call(void 0, c,e.itemToStringValue)},[i,e.multiple,e.value,e.values,e.itemToStringLabel,e.itemToStringValue,u]),p=se.useMemo(()=>o?e.inputValue:s,[o,s,e.inputValue]);return{hasValue:i,displayValue:p,selectedLabel:s,getValueText:u}}function Oo(x){let{comboboxContext:e,store:o,focusOwnerStore:i,open:u,disabled:s,cursorBehavior:p,hasValue:c,getValueText:a,onFocus:t,onBlur:P,onClick:m,onKeyDown:b}=x,I=T.useRef(!1),d=T.useRef(!1),g=T.useRef(!1),l=T.useRef(null),S=T.useRef(null),R=T.useRef(null);T.useEffect(()=>{if(!u)return;let n=f=>{let r=e.inputRef.current,v=e.inputWrapperRef.current,y=document.getElementById(e.listId),O=f.target,W=_optionalChain([r, 'optionalAccess', _4 => _4.contains, 'call', _5 => _5(O)]),z=_optionalChain([v, 'optionalAccess', _6 => _6.contains, 'call', _7 => _7(O)]),ee=_optionalChain([y, 'optionalAccess', _8 => _8.contains, 'call', _9 => _9(O)]);!W&&!z&&!ee&&(R.current=f)};return document.addEventListener("pointerdown",n,!0),()=>{document.removeEventListener("pointerdown",n,!0),R.current=null}},[u,e.inputRef,e.inputWrapperRef,e.listId]),T.useLayoutEffect(()=>{let n=e.inputRef.current;if(n&&u&&S.current){let{start:f,end:r}=S.current,v=n.selectionStart,y=n.value.length;v===y&&f!==y&&n.setSelectionRange(f,r),S.current=null}});let L=T.useRef(u);T.useLayoutEffect(()=>{if(u&&!L.current){if(I.current){I.current=!1,L.current=u;return}if(g.current){g.current=!1,d.current=!1,l.current=null,L.current=u;return}if(d.current&&p==="none"){let f=e.inputRef.current,r=l.current;f&&r!==null&&requestAnimationFrame(()=>{let v=f.value.length,y=Math.min(r,v);f.setSelectionRange(y,y)}),d.current=!1,l.current=null,L.current=u;return}c&&e.multiple&&e.onInputValueChange("");let n=e.inputRef.current;if(n){let f=n.value.length;p==="select-all"&&f>0?requestAnimationFrame(()=>{n.setSelectionRange(0,n.value.length)}):p==="end"&&f>0&&requestAnimationFrame(()=>{n.setSelectionRange(n.value.length,n.value.length)})}}L.current=u},[u,e,c,p]);let w=T.useCallback(n=>{let f=n.target,r=f.value,v=f.selectionStart,y=f.selectionEnd;v!==null&&y!==null&&(S.current={start:v,end:y}),e.onInputValueChange(r),e.setFilterActive(),o.setSearch(r),o.state.open||(I.current=!0,e.openCombobox())},[e,o]),k=T.useCallback(n=>{if(_optionalChain([t, 'optionalCall', _10 => _10(n)]),n.defaultPrevented)return;let f=o.state.open;if(f&&(g.current=!0),e.openOnFocus&&!s&&!f){if(c&&!e.multiple){let r=_nullishCoalesce(a(e.value), () => (_chunkEYMK7XHCcjs.R.call(void 0, e.value,e.itemToStringLabel)));e.onInputValueChange(r)}e.openCombobox()}},[t,e,s,o,c,a]),V=T.useCallback(n=>{_optionalChain([P, 'optionalCall', _11 => _11(n)]),!n.defaultPrevented&&requestAnimationFrame(()=>{let f=document.activeElement,v=_optionalChain([document, 'access', _12 => _12.getElementById, 'call', _13 => _13(e.listId), 'optionalAccess', _14 => _14.contains, 'call', _15 => _15(f)]),y=f===e.inputRef.current;if(!v&&!y){g.current=!1;let O=R.current,W=O?_chunkXMZZ62VJcjs.a.outsidePress:_chunkXMZZ62VJcjs.a.focusOut;R.current=null,e.closeCombobox(W,_nullishCoalesce(O, () => (void 0)))}})},[P,e]),A=T.useCallback(n=>{if(_optionalChain([m, 'optionalCall', _16 => _16(n)]),n.defaultPrevented)return;let f=o.state.open;if(!s&&!f){let r=n.target;if(p==="none"){let v=r.selectionStart;l.current=v,d.current=!0}if(c&&!e.multiple){let v=_nullishCoalesce(a(e.value), () => (_chunkEYMK7XHCcjs.R.call(void 0, e.value,e.itemToStringLabel)));e.onInputValueChange(v)}e.openCombobox()}else f&&(g.current=!0)},[m,e,s,o,p,c,a]),K=T.useCallback(n=>{if(_optionalChain([b, 'optionalCall', _17 => _17(n)]),!n.defaultPrevented){if(u&&n.key==="Escape"){n.preventDefault(),e.closeCombobox(_chunkXMZZ62VJcjs.a.escapeKey);return}if(!u&&(n.key==="ArrowDown"||n.key==="ArrowUp"||n.key==="Enter")){if(n.preventDefault(),c&&!e.multiple){let f=_nullishCoalesce(a(e.value), () => (_chunkEYMK7XHCcjs.R.call(void 0, e.value,e.itemToStringLabel)));e.onInputValueChange(f)}e.openCombobox();return}}},[u,e,b,c,a]),{handleKeyDown:j}=_chunkEYMK7XHCcjs.P.call(void 0, {store:o,surfaceId:"combobox-input",focusOwnerStore:i,depth:0,submenuContext:null,subpageContext:null,enabled:u,enableTypeToSearch:!1,onKeyDown:K,closeAll:e.closeCombobox,skipFocusOwnerCheck:!0});return{handleChange:w,handleFocus:k,handleBlur:V,handleClick:A,handleKeyDown:j,selectionRef:S}}var we=ne.forwardRef(function(e,o){let{placeholder:i,disabled:u,cursorBehavior:s="none",render:p,className:c,style:a,onFocus:t,onBlur:P,onClick:m,onKeyDown:b,...I}=e,d=_chunkEYMK7XHCcjs.w.call(void 0, ),g=_chunkEYMK7XHCcjs.d.call(void 0, ),l=_chunkEYMK7XHCcjs.a.call(void 0, ),S=To(),R=(_nullishCoalesce(u, () => (d.disabled)))||g.disabled,L=_chunk5T5B5SPRcjs.f.call(void 0, d.items,""),w=_nullishCoalesce(_nullishCoalesce(i, () => ((typeof L=="string"?L:void 0))), () => (d.placeholder)),k=g.store.useState("open"),{hasValue:V,displayValue:A,getValueText:K}=Ho({comboboxContext:d,open:k}),{handleChange:j,handleFocus:n,handleBlur:f,handleClick:r,handleKeyDown:v}=Oo({comboboxContext:d,store:g.store,focusOwnerStore:l,open:k,disabled:R,cursorBehavior:s,hasValue:V,getValueText:K,onFocus:t,onBlur:P,onClick:m,onKeyDown:b}),y={[Q.slot]:""};k?y[Q.open]="":y[Q.closed]="",R&&(y[Q.disabled]=""),V||(y[Q.placeholder]=""),d.layout==="input-embedded"&&(y["data-input-embedded"]="");let O=ne.useCallback(M=>{d.setInputElement(M),typeof o=="function"?o(M):o&&(o.current=M)},[o,d]),W=ne.useMemo(()=>({open:k,disabled:R,placeholder:!V}),[k,R,V]),z=d.layout==="input-embedded"&&!S?{position:"relative",zIndex:1}:void 0;return _userender.useRender.call(void 0, {render:p,ref:O,state:W,props:{...I,...y,type:"text",role:"combobox","aria-autocomplete":"list","aria-expanded":k,"aria-controls":d.listId,"aria-haspopup":"listbox",autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:R,placeholder:V?void 0:w,className:c,style:{...z,...a},value:A,onChange:j,onFocus:n,onBlur:f,onClick:r,onKeyDown:v},defaultTagName:"input"})});var ge={slot:"bazzaui-combobox-input-wrapper",open:"data-open"};var _jsxruntime = require('react/jsx-runtime');var Rt={open:x=>x?{[ge.open]:""}:null},ke= exports.ComboboxInputWrapper =re.forwardRef(function(e,o){let{render:i,className:u,style:s,children:p,...c}=e,{store:a}=_chunkEYMK7XHCcjs.d.call(void 0, ),t=_chunkEYMK7XHCcjs.w.call(void 0, ),P=a.useState("open"),m=re.useMemo(()=>({open:P}),[P]),b=t.layout==="input-embedded"?{position:"relative",zIndex:1}:{position:"relative"},I=re.useCallback(g=>{t.setInputWrapperElement(g),typeof o=="function"?o(g):o&&(o.current=g)},[o,t]),d=_userender.useRender.call(void 0, {render:i,ref:I,state:m,stateAttributesMapping:Rt,props:{...c,[ge.slot]:"",className:u,style:{...b,...s},children:p},defaultTagName:"div"});return _jsxruntime.jsx.call(void 0, Le.Provider,{value:!0,children:d})});var q={slot:"bazzaui-combobox-item",highlighted:"data-highlighted",disabled:"data-disabled",selected:"data-selected",first:"data-first",last:"data-last",firstInGroup:"data-first-in-group",lastInGroup:"data-last-in-group"};var he=le.createContext(null);function ue(){let x=le.useContext(he);if(!x)throw new Error("ComboboxItem child components must be used within a Combobox.Item");return x}function yt(){return le.useContext(he)}var Vt={highlighted:x=>x?{[q.highlighted]:""}:null,disabled:x=>x?{[q.disabled]:""}:null,selected:x=>x?{[q.selected]:""}:null,first:x=>x?{[q.first]:""}:null,last:x=>x?{[q.last]:""}:null,firstInGroup:x=>x?{[q.firstInGroup]:""}:null,lastInGroup:x=>x?{[q.lastInGroup]:""}:null};function Mt(x,e){let{value:o,textValue:i,keywords:u,disabled:s=!1,onSelect:p,forceMount:c=!1,render:a,className:t,style:P,onClick:m,onPointerDown:b,onPointerMove:I,children:d,...g}=x,l=_chunkEYMK7XHCcjs.w.call(void 0, ),S=E.useMemo(()=>_chunkEYMK7XHCcjs.S.call(void 0, o,l.itemToStringValue),[o,l.itemToStringValue]),R=E.useId(),L=o===null?`combobox-clear-${R}`:void 0,w=E.useMemo(()=>_chunk5T5B5SPRcjs.e.call(void 0, l.items,S),[l.items,S]),k=_optionalChain([w, 'optionalAccess', _18 => _18.label]),V=E.useMemo(()=>_chunkEYMK7XHCcjs.R.call(void 0, o,l.itemToStringLabel),[o,l.itemToStringLabel]),A=E.useMemo(()=>{if(i!==void 0)return i;if(typeof k=="string")return k;if(V&&V!==S)return V},[i,k,V,S]),K=E.useMemo(()=>_chunk5T5B5SPRcjs.g.call(void 0, u,[typeof k=="string"?k:V&&V!==S?V:void 0,..._nullishCoalesce(_optionalChain([w, 'optionalAccess', _19 => _19.keywords]), () => ([]))]),[u,k,V,S,w]),j=E.useRef(A),n=l.multiple?_chunk5T5B5SPRcjs.c.call(void 0, l.values,o,l.isItemEqualToValue):l.value!==""&&_chunk5T5B5SPRcjs.b.call(void 0, l.value,o,l.isItemEqualToValue),f=l.closeOnSelect,r=_chunkEYMK7XHCcjs.O.call(void 0, {id:L,value:S,keywords:K,disabled:s,forceMount:c,closeOnClick:f,children:d});E.useEffect(()=>{let M=()=>{if(!s){if(l.multiple)if(o==null)l.onValuesChange([]);else{let me=n?_chunk5T5B5SPRcjs.d.call(void 0, l.values,o,l.isItemEqualToValue):[...l.values,o];l.onValuesChange(me)}else l.onValueChange(o);_optionalChain([p, 'optionalCall', _20 => _20()])}};return r.registerSelect(M)},[s,l,o,n,p,r]),E.useEffect(()=>{let M=j.current;if(M)return l.registerItemText(S,M)},[S,l]),E.useEffect(()=>{!A&&typeof d=="string"&&(j.current=d,l.registerItemText(S,d))},[d,A,S,l]);let v=E.useMemo(()=>({highlighted:r.isHighlighted,disabled:s,selected:n,first:r.positional.first,last:r.positional.last,firstInGroup:r.positional.firstInGroup,lastInGroup:r.positional.lastInGroup}),[r.isHighlighted,s,n,r.positional]),y=E.useMemo(()=>({id:r.id,value:o,textValue:A,highlighted:r.isHighlighted,disabled:s,selected:n}),[r.id,o,A,r.isHighlighted,s,n]),O=E.useCallback(M=>{_optionalChain([m, 'optionalCall', _21 => _21(M)]),M.defaultPrevented||r.handlers.onClick(M)},[m,r.handlers]),W=E.useCallback(M=>{r.handlers.onPointerDown(M),_optionalChain([b, 'optionalCall', _22 => _22(M)])},[r.handlers,b]),z=E.useCallback(M=>{_optionalChain([I, 'optionalCall', _23 => _23(M)]),M.defaultPrevented||r.handlers.onPointerMove(M)},[I,r.handlers]),ee=_userender.useRender.call(void 0, {render:a,ref:[r.ref,r.rowRef,e],state:v,stateAttributesMapping:Vt,props:{...g,[q.slot]:"",id:r.id,role:"option",tabIndex:-1,"aria-selected":n,"aria-disabled":s||void 0,className:t,style:P,onClick:O,onPointerMove:z,onPointerDown:W,children:d},enabled:r.isVisible,defaultTagName:"div"});return r.isVisible?_jsxruntime.jsx.call(void 0, he.Provider,{value:y,children:ee}):null}var Te=E.forwardRef(Mt);var Pe={slot:"bazzaui-combobox-item-indicator",selected:"data-selected"};var wt={selected:x=>x?{[Pe.selected]:""}:null},He= exports.ComboboxItemIndicator =Ie.forwardRef(function(e,o){let{keepMounted:i=!1,render:u,className:s,style:p,...c}=e,a=ue(),t=Ie.useMemo(()=>({selected:a.selected}),[a.selected]),P=_userender.useRender.call(void 0, {render:u,ref:o,state:t,stateAttributesMapping:wt,props:{...c,[Pe.slot]:"","aria-hidden":!0,className:s,style:p},enabled:i||a.selected,defaultTagName:"span"});return!i&&!a.selected?null:P});var Do={slot:"bazzaui-combobox-item-label"};var Oe=Y.forwardRef(function(e,o){let{render:i,className:u,style:s,children:p,...c}=e,a=_chunkEYMK7XHCcjs.w.call(void 0, ),t=ue(),P=_chunkEYMK7XHCcjs.S.call(void 0, t.value,a.itemToStringValue),m=Y.useMemo(()=>{if(p!==void 0)return p;let I=_chunk5T5B5SPRcjs.f.call(void 0, a.items,P);return I!==void 0?I:t.textValue!==void 0?t.textValue:P},[p,a.items,P,t.textValue]),b=Y.useMemo(()=>({value:P,selected:t.selected,highlighted:t.highlighted,disabled:t.disabled}),[P,t.selected,t.highlighted,t.disabled]);return Y.useEffect(()=>{if(typeof m=="string")return a.registerItemText(P,m)},[m,a,P]),_userender.useRender.call(void 0, {render:i,ref:o,state:b,props:{...c,[Do.slot]:"",className:u,style:s,children:m},defaultTagName:"span"})});var _popover = require('@base-ui/react/popover');var Re={slot:"bazzaui-combobox-positioner"};function Tt(x,e,o,i){let u=o+i*2;if(x==="top"){let c=-(e+i),a=e+i;return{width:u,marginBottom:c,paddingTop:i,paddingLeft:i,paddingRight:i,paddingBottom:a}}let s=-(e+i),p=e+i;return{width:u,marginTop:s,paddingTop:p,paddingLeft:i,paddingRight:i,paddingBottom:i}}var De=U.forwardRef(function(e,o){let{layout:i,popupPadding:u=8,side:s="bottom",align:p,sideOffset:c=4,anchor:a,className:t,style:P,children:m,...b}=e,I=_chunkEYMK7XHCcjs.w.call(void 0, ),d=_nullishCoalesce(i, () => (I.layout)),g=d==="input-embedded",l=_nullishCoalesce(a, () => (I.inputWrapperRef.current))?I.inputWrapperRef:I.inputRef,S=g?0:c,R=g?"center":_nullishCoalesce(p, () => ("start")),{inputHeight:L,inputWidth:w}=I,k=w+u*2,V={...P,...g?{zIndex:0}:{}};if(g)return _jsxruntime.jsx.call(void 0, _popover.Popover.Positioner,{ref:o,side:s,align:R,sideOffset:S,anchor:l,className:t,style:V,"data-input-embedded":"",[Re.slot]:"",...b,render:(n,f)=>{let r=f.side,v={layout:d,side:r,align:f.align,inputHeight:I.inputHeight},y={"--combobox-input-height":`${L}px`,"--combobox-input-width":`${w}px`,"--combobox-popup-padding":`${u}px`,"--combobox-popup-width":`${k}px`},O=Tt(r,L,w,u),W=U.Children.map(m,z=>U.isValidElement(z)?U.cloneElement(z,{style:{...O,...z.props.style},"data-side":r}):z);return _jsxruntime.jsx.call(void 0, fe.Provider,{value:v,children:_jsxruntime.jsx.call(void 0, "div",{...n,style:{...n.style,...y},"data-side":r,children:W})})}});let A={layout:d,side:s,align:R,inputHeight:I.inputHeight},K={"--combobox-input-height":`${L}px`,"--combobox-input-width":`${w}px`},j={...V,...K};return _jsxruntime.jsx.call(void 0, fe.Provider,{value:A,children:_jsxruntime.jsx.call(void 0, _popover.Popover.Positioner,{ref:o,side:s,align:R,sideOffset:S,anchor:l,className:t,style:j,[Re.slot]:"",...b,children:m})})});function Ae(x){let{open:e,onOpenChange:o,actionsRef:i,defaultOpen:u=!1,value:s,defaultValue:p,onValueChange:c,multiple:a=!1,values:t,defaultValues:P,onValuesChange:m,isItemEqualToValue:b=_chunk5T5B5SPRcjs.a,itemToStringLabel:I,itemToStringValue:d,inputValue:g,defaultInputValue:l="",onInputValueChange:S,name:R,form:L,required:w,disabled:k=!1,placeholder:V="Search...",items:A,modal:K=!1,closeOnSelect:j,openOnFocus:n=!0,virtualized:f=!1,virtualItems:r,onHighlightChange:v,layout:y="floating",onOpenChangeComplete:O,debug:W,children:z,...ee}=x,M=h.useCallback((C,H,G,be)=>_optionalChain([v, 'optionalCall', _24 => _24(C,G,be)]),[v]),me=h.useId(),ce=h.useRef(null),Se=h.useRef(null),[ze,Be]=h.useState(0),[We,je]=h.useState(0),Ge=h.useCallback(C=>{if(ce.current=C,C&&!Se.current){let H=C.getBoundingClientRect();Be(H.height),je(H.width)}},[]),Ne=h.useCallback(C=>{if(Se.current=C,C){let H=C.getBoundingClientRect();Be(H.height),je(H.width)}},[]),{store:B,focusOwnerStore:$o,openChainStore:Jo,registerSurface:Xo,closeAll:_o,virtualization:Qo,handleOpenChange:qe,disabled:$,setDisabled:Ke,menuTreeResolver:Yo}=_chunkEYMK7XHCcjs.q.call(void 0, {onOpenChange:o,defaultOpen:u,virtualized:f,items:r,onHighlightChange:M,disabled:k}),ye=h.useRef(null);h.useImperativeHandle(i,()=>({close:()=>{_optionalChain([ye, 'access', _25 => _25.current, 'optionalAccess', _26 => _26.close, 'call', _27 => _27()])},unmount:()=>{_optionalChain([ye, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.unmount, 'call', _30 => _30()])},setDisabled:Ke}),[Ke]),B.useControlledProp("openProp",e);let Zo=B.useState("open"),Ue=h.useCallback((C,H,G)=>{$&&H!==_chunkXMZZ62VJcjs.a.imperativeAction||!C&&ce.current&&document.activeElement===ce.current||qe(C,H,G)},[qe,$]),et=h.useCallback(C=>{!C&&B.context.clearSearchOnClose==="after-exit"&&(B.clearSearch(),B.setInputActive(!1)),C||B.clearHighlight(),_optionalChain([O, 'optionalCall', _31 => _31(C)])},[B,O]),ot=h.useCallback((C,H)=>{Ue(C,H.reason,H.event)},[Ue]),[tt,nt]=h.useState(p!==void 0?p:null),J=s!==void 0?s:tt,$e=h.useCallback(C=>{s===void 0&&nt(C),_optionalChain([c, 'optionalCall', _32 => _32(C)])},[s,c]),[rt,at]=h.useState(_nullishCoalesce(P, () => ([]))),ae=t!==void 0?t:rt,Je=h.useCallback(C=>{t===void 0&&at(C),_optionalChain([m, 'optionalCall', _33 => _33(C)])},[t,m]),[ve,st]=h.useState(l),Xe=g!==void 0?g:ve,_e=h.useCallback(C=>{g===void 0&&st(C),_optionalChain([S, 'optionalCall', _34 => _34(C)])},[g,S]),Qe=h.useRef(new Map),Ye=h.useCallback((C,H)=>(Qe.current.set(C,H),()=>{}),[]),Ze=_nullishCoalesce(j, () => (!a)),Ve=h.useRef({type:"active"}),[,lt]=h.useState({type:"active"}),X=h.useCallback(C=>{Ve.current=C,lt(C)},[]),eo=Ve.current,oo=h.useCallback(()=>{X({type:"active"})},[X]),to=h.useCallback(()=>{$||(!a&&J!=null?X({type:"showAll"}):X({type:"active"}),B.setOpen(!0))},[$,B,a,J,X]),no=h.useCallback((C,H)=>{let G=Ve.current,be=G.type==="active"?ve:G.type==="showAll"?"":G.search;X({type:"frozen",search:be}),B.setOpen(!1,C,H)},[B,X,ve]),ut=h.useMemo(()=>({multiple:a,value:J,values:ae,onValueChange:$e,onValuesChange:Je,isItemEqualToValue:b,itemToStringLabel:I,itemToStringValue:d,inputValue:Xe,onInputValueChange:_e,name:R,form:L,required:w,disabled:$,placeholder:V,items:A,itemTextRegistry:Qe.current,registerItemText:Ye,listId:me,inputRef:ce,setInputElement:Ge,inputWrapperRef:Se,setInputWrapperElement:Ne,closeOnSelect:Ze,openOnFocus:n,openCombobox:to,closeCombobox:no,filterMode:eo,setFilterActive:oo,inputHeight:ze,inputWidth:We,layout:y}),[a,J,ae,$e,Je,b,I,d,Xe,_e,R,L,w,$,V,A,Ye,me,Ge,Ne,Ze,n,to,no,eo,oo,ze,We,y]),it=h.useMemo(()=>R?a?ae.length>0?ae.map((C,H)=>{let G=_chunkEYMK7XHCcjs.S.call(void 0, C,d);return _jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:R,value:G,form:L,required:w&&H===0},G)}):_jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:R,value:"",form:L,required:w}):_jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:R,value:J!=null?_chunkEYMK7XHCcjs.S.call(void 0, J,d):"",form:L,required:w}):null,[R,L,w,a,J,ae,d]);return _jsxruntime.jsx.call(void 0, _chunkEYMK7XHCcjs.v.Provider,{value:ut,children:_jsxruntime.jsxs.call(void 0, _chunkEYMK7XHCcjs.N,{menuTreeResolver:Yo,store:B,focusOwnerStore:$o,openChainStore:Jo,disabled:$,depth:0,closeAll:_o,registerSurface:Xo,virtualization:Qo,menuType:"dropdown",componentName:"combobox",debug:W,children:[it,_jsxruntime.jsx.call(void 0, _popover.Popover.Root,{...ee,open:Zo,onOpenChange:ot,onOpenChangeComplete:et,modal:K,actionsRef:i?ye:void 0,children:z})]})})}var Fo={slot:"bazzaui-combobox-surface"};var Fe=Z.forwardRef(function(e,o){let{autoHighlightFirst:i,clearSearchOnClose:u=!0,search:s,onSearchChange:p,onPointerMove:c,...a}=e,t=_chunkEYMK7XHCcjs.w.call(void 0, ),P=Z.useCallback(g=>{_optionalChain([c, 'optionalCall', _35 => _35(g)]);let l=t.inputRef.current;l&&document.activeElement!==l&&l.focus()},[c,t.inputRef]),m=Z.useMemo(()=>{let g=_nullishCoalesce(i, () => (!0));if(g==="selected"){let l=t.multiple?t.values[0]:t.value;return l!=null?_chunkEYMK7XHCcjs.S.call(void 0, l,t.itemToStringValue):!0}return g},[i,t.multiple,t.value,t.values,t.itemToStringValue]),{filterMode:b}=t,I=_nullishCoalesce(s, () => ((b.type==="active"?t.inputValue:b.type==="showAll"?"":b.search))),d=Z.useCallback(g=>{t.onInputValueChange(g),_optionalChain([p, 'optionalCall', _36 => _36(g)])},[t,p]);return _jsxruntime.jsx.call(void 0, _chunkEYMK7XHCcjs.fa,{ref:o,autoHighlightFirst:m,clearSearchOnClose:u,search:I,onSearchChange:d,onPointerMove:P,skipAutoFocus:!0,[Fo.slot]:"",...a})});var Bo=(p=>(p.slot="bazzaui-combobox-arrow",p.open="data-open",p.closed="data-closed",p.side="data-side",p.align="data-align",p.uncentered="data-uncentered",p))(Bo||{});var Wo=(s=>(s.slot="bazzaui-combobox-backdrop",s.open="data-open",s.closed="data-closed",s.startingStyle="data-starting-style",s.endingStyle="data-ending-style",s))(Wo||{});var jo=(e=>(e.slot="bazzaui-combobox-empty",e))(jo||{});var Go=(e=>(e.slot="bazzaui-combobox-group",e))(Go||{});var No=(e=>(e.slot="bazzaui-combobox-group-label",e))(No||{});var At={slot:"bazzaui-combobox-icon",open:"data-popup-open"};var qo=(o=>(o.slot="bazzaui-combobox-list",o.list="data-popup-menu-list",o))(qo||{});var Ko=(b=>(b.slot="bazzaui-combobox-popup",b.open="data-open",b.closed="data-closed",b.side="data-side",b.align="data-align",b.startingStyle="data-starting-style",b.endingStyle="data-ending-style",b.instant="data-instant",b.focused="data-focused",b.hasOpenSubmenu="data-has-open-submenu",b.submenu="data-submenu",b.navigating="data-navigating",b))(Ko||{});var Ft={slotUp:"bazzaui-combobox-scroll-up-arrow",slotDown:"bazzaui-combobox-scroll-down-arrow",direction:"data-direction",side:"data-side"};var Uo=(e=>(e.slot="bazzaui-combobox-separator",e))(Uo||{});exports.Combobox = zo; exports.ComboboxArrowDataAttributes = Bo; exports.ComboboxBackdropDataAttributes = Wo; exports.ComboboxClear = Me; exports.ComboboxEmptyDataAttributes = jo; exports.ComboboxGroupDataAttributes = Go; exports.ComboboxGroupLabelDataAttributes = No; exports.ComboboxIconDataAttributes = At; exports.ComboboxInput = we; exports.ComboboxInputDataAttributes = Q; exports.ComboboxInputWrapper = ke; exports.ComboboxInputWrapperDataAttributes = ge; exports.ComboboxItem = Te; exports.ComboboxItemDataAttributes = q; exports.ComboboxItemIndicator = He; exports.ComboboxItemIndicatorDataAttributes = Pe; exports.ComboboxItemLabel = Oe; exports.ComboboxListCssVars = _chunkEYMK7XHCcjs.aa; exports.ComboboxListDataAttributes = qo; exports.ComboboxPopupDataAttributes = Ko; exports.ComboboxPositioner = De; exports.ComboboxPositionerCssVars = _chunkEYMK7XHCcjs.L; exports.ComboboxPositionerDataAttributes = Re; exports.ComboboxRoot = Ae; exports.ComboboxScrollArrowDataAttributes = Ft; exports.ComboboxSeparatorDataAttributes = Uo; exports.ComboboxStore = _chunkXMZZ62VJcjs.y; exports.ComboboxSurface = Fe; exports.commandScore = _chunkXMZZ62VJcjs.w; exports.defaultFilter = _chunkXMZZ62VJcjs.x; exports.useComboboxContext = _chunkEYMK7XHCcjs.w; exports.useComboboxItemContext = ue; exports.useComboboxPositionerContext = Ee; exports.useMaybeComboboxContext = _chunkEYMK7XHCcjs.x; exports.useMaybeComboboxItemContext = yt; exports.useMaybeSurfaceContext = _chunkXMZZ62VJcjs.q; exports.useSurfaceContext = _chunkXMZZ62VJcjs.p;
2
2
  //# sourceMappingURL=index.cjs.map