@acusti/dropdown 1.0.0-alpha.3 → 1.0.0-alpha.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown.js","names":["createContext","Item","DropdownContextValue","registerSubmenu","registration","SubmenuRegistration","element","HTMLElement","onActiveItem","payload","onClose","onOpen","onSubmitItem","DropdownContext","MenubarContextValue","moveOpen","fromElement","direction","notifyClosed","notifyOpened","registerMember","member","MenubarMember","close","focusTrigger","isOpen","open","MenubarContext","getBestMatch","SyntheticEvent","Item","ITEM_SELECTOR","SUBMENU_SELECTOR","DISABLED_ITEM_SELECTOR","OnToggleSubmenu","item","HTMLElement","isExpanded","MaybeHTMLElement","getBodyElement","dropdownElement","querySelector","getLevelRoot","element","closest","getSubmenuOfItem","submenu","owner","parentElement","getParentItem","levelRoot","getItemLabel","innerText","clone","cloneNode","Array","from","querySelectorAll","remove","textContent","trim","getItemPath","path","parentItem","label","unshift","value","dataset","uktValue","getItemElements","bodyElement","root","candidates","length","filter","matches","items","HTMLCollection","children","getItemForTarget","target","targetLevelRoot","contains","itemElements","find","itemElement","getActiveItemElements","actives","getActiveItemElement","getDeepestExpandedItem","expanded","isItemExpanded","getAttribute","submenuIdCounter","ensureSubmenuAria","hasAttribute","setAttribute","id","annotateParentItems","expandItem","onToggleSubmenu","collapseItem","expandedDescendants","descendant","active","uktActive","collapseItemsOutsidePath","expandedItems","reverse","clearItemElementsState","forEach","setActiveChain","chain","Set","add","has","BaseSetActiveItemPayload","event","Event","index","indexAddend","isExactMatch","onActiveItem","payload","text","setActiveItem","Omit","currentDeepest","lastIndex","currentActiveIndex","findIndex","nextActiveIndex","Math","max","min","itemTexts","map","textToCompare","toLowerCase","itemText","startsWith","bestMatch","nextActiveItem","scrollableParent","isScrollable","scrollHeight","clientHeight","parentRect","getBoundingClientRect","itemRect","isAboveTop","top","isBelowBottom","bottom","scrollTop","Point","x","y","isPointInTriangle","p","a","b","c","cross","u","v","w","d1","d2","d3","hasNegative","hasPositive","clsx","CSSProperties","FocusEvent","ReactFocusEvent","KeyboardEvent","ReactKeyboardEvent","MouseEvent","ReactMouseEvent","ReactNode","useMemo","useRef","MenubarContext","MenubarContextValue","MenubarMember","MenubarProps","children","className","style","compareDocumentOrder","a","b","element","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","NON_MENU_CONTROL_SELECTOR","Menubar","t0","$","_c","t1","Symbol","for","Set","membersRef","engagedMemberRef","t2","Array","from","current","sort","getOrderedMembersRef","getOrderedMembers","t3","moveOpen","fromElement","direction","members","length","index","findIndex","member","nextIndex","close","open","focusTrigger","notifyClosed","notifyOpened","element_0","member_0","isOpen","registerMember","member_1","add","delete","contextValue","t4","event","key","members_0","some","_temp","eventTarget","target","HTMLElement","index_0","member_3","contains","preventDefault","stopPropagation","direction_0","handleKeyDown","t5","eventTarget_0","members_1","m","member_4","find","m_0","closest","openMember","switchToMemberAt","t6","event_0","handleFocus","t7","event_1","handleMouseOver","t8","t9","t10","member_2","useKeyboardEvents","isEventTargetUsingKeyEvent","clsx","Children","cloneElement","CSSProperties","Fragment","isValidElement","MouseEvent","ReactMouseEvent","ReactElement","ReactNode","SyntheticEvent","useContext","useEffect","useId","useMemo","useRef","useState","DropdownContext","DropdownContextValue","MenubarContext","SubmenuRegistration","styles","annotateParentItems","collapseItem","collapseItemsOutsidePath","expandItem","getActiveItemElement","getDeepestExpandedItem","getItemElements","getItemForTarget","getItemPath","getLevelRoot","getParentItem","getSubmenuOfItem","isItemExpanded","isPointInTriangle","Point","setActiveItem","Item","element","MaybeHTMLElement","event","Event","HTMLElement","label","path","Array","ItemPathEntry","value","Props","allowCreate","allowEmpty","children","ChildrenTuple","className","disabled","hasItems","isOpenOnMount","isSearchable","keepOpenOnSubmit","name","onActiveItem","payload","onClick","onClose","onMouseDown","onMouseUp","onOpen","onSubmitItem","openOnHover","placeholder","style","Record","tabIndex","MousePosition","clientX","clientY","TimeoutID","ReturnType","setTimeout","CHILDREN_ERROR","CLICKABLE_SELECTOR","FOCUSABLE_SELECTOR","TEXT_INPUT_SELECTOR","SUBMENU_DISCLOSURE_DELAY","SAFE_AREA_TIMEOUT","HOVER_CLOSE_DELAY","Dropdown","props","$","_c","parentDropdown","t0","RootDropdown","t1","t2","t3","styleFromProps","undefined","childrenCount","count","Error","console","error","trigger","isOpen","setIsOpen","isOpening","setIsOpening","dropdownElement","setDropdownElement","bodyId","popupRole","menubar","inputElementRef","closingTimerRef","isOpeningTimerRef","currentInputMethodRef","clearEnteredCharactersTimerRef","enteredCharactersRef","mouseDownPositionRef","disclosureTimerRef","pendingDisclosureItemRef","t4","Symbol","for","Set","submenuRegistrationsRef","pointerRef","lastMouseEventRef","safeAreaRef","safeAreaTimerRef","wasInSafeAreaRef","hoverCloseTimerRef","allowCreateRef","allowEmptyRef","hasItemsRef","isOpenRef","isOpeningRef","keepOpenOnSubmitRef","onCloseRef","onOpenRef","onSubmitItemRef","valueRef","t5","t6","current","isMountedRef","t7","t8","t9","registerSubmenu","registration","add","delete","dropdownContextValue","t10","key","registration_0","contains","dispatchToSubmenus","t11","payload_0","handleActiveItem","t12","item","isExpanded","registration_1","handleToggleSubmenu","t13","clearTimeout","clearDisclosureTimer","t14","t15","t16","activeElement","submenu","hasAttribute","syncSubmenuDisclosure","t17","clearSafeAreaTimer","t18","t19","t20","x","y","safeArea","parent","submenu_0","submenuRect","getBoundingClientRect","parentRect","nearX","left","right","apex","top","bottom","isPointerInSafeArea","t21","targetElement","pointer","target","ownerDocument","elementFromPoint","item_0","commitPointerTarget","t22","event_0","pointer_0","nativeEvent","target_0","submenu_1","isOverParent","trackSafeArea","t23","clearHoverCloseTimer","t24","t25","t26","options","keepMenubarEngaged","notifyClosed","closeDropdown","t27","handleDropdownMouseEnter","t28","handleDropdownMouseLeave","t29","firstElementChild","firstChild","focusable","matches","querySelector","focus","focusTrigger","t30","registerMember","close","open","t31","t32","notifyOpened","t33","event_1","submenuOfActive","firstItem","itemLabel","innerText","blur","nextValue","dataset","uktValue","eventTarget","click","clickableElements","querySelectorAll","length","clickableElement","payload_1","handleSubmitItem","t34","event_2","initialPosition","Math","abs","handleMouseMove","t35","event_3","eventTarget_0","closest","hoveredRoot","classList","item_1","handleMouseOver","t36","event_4","relatedTarget","Node","isLeavingDropdown","activeItem","eventRelatedTarget","uktActive","handleMouseOut","t37","event_5","handleMouseDown","t38","event_6","eventTarget_1","clickedRoot","targetBody","isInOwnBody","Boolean","clickedItem","handleMouseUp","t39","event_7","altKey","ctrlKey","key_0","metaKey","eventTarget_2","onEventHandled","stopPropagation","preventDefault","isEventTargetingDropdown","nestedRoot","isTargetUsingKeyEvents","isEditingCharacters","test","slice","isExactMatch","text","index","indexAddend","activeElement_0","submenu_2","firstItem_0","moveOpen","activeElement_1","levelRoot","parentItem","handleKeyDown","t40","ignoreUsedKeyboardEvents","onKeyDown","t41","ref","inputElement","HTMLInputElement","handleGlobalMouseDown","t42","target_1","eventTarget_3","handleGlobalMouseUp","t43","target_2","eventTarget_4","handleGlobalFocusIn","t44","target_3","eventTarget_5","document","addEventListener","handleInput","event_8","input","isDeleting","removeEventListener","handleRef","handleBodyRef","_temp","triggerProps","t45","t46","ref_0","showPopover","INERT_SUBMENU_PROPS","const","SubmenuDropdown","itemRef","warnedRef","inertProps","filter","propName","join","labelContent","body","default","Menubar","MenubarProps"],"sources":["../src/context.ts","../src/Dropdown.css?inline","../src/helpers.ts","../src/Menubar.tsx","../src/Dropdown.tsx"],"sourcesContent":["import { createContext } from 'react';\n\nimport { type Item } from './Dropdown.js';\n\nexport type DropdownContextValue = {\n registerSubmenu: (registration: SubmenuRegistration) => () => void;\n};\n\nexport type SubmenuRegistration = {\n element: HTMLElement;\n onActiveItem?: (payload: Item) => void;\n onClose?: () => unknown;\n onOpen?: () => unknown;\n onSubmitItem?: (payload: Item) => void;\n};\n\n// Provided by a menu Dropdown; a Dropdown that finds this context renders as a\n// submenu (parent item + data-ukt-submenu) instead of a root dropdown.\nexport const DropdownContext = createContext<DropdownContextValue | null>(null);\n\nexport type MenubarContextValue = {\n moveOpen: (fromElement: HTMLElement, direction: -1 | 1) => void;\n notifyClosed: (element: HTMLElement) => void;\n notifyOpened: (element: HTMLElement) => void;\n registerMember: (member: MenubarMember) => () => void;\n};\n\nexport type MenubarMember = {\n close: () => void;\n element: HTMLElement;\n focusTrigger: () => void;\n isOpen: () => boolean;\n open: () => void;\n};\n\nexport const MenubarContext = createContext<MenubarContextValue | null>(null);\n",":root {\n --uktdd-font-family:\n system-ui, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue,\n Helvetica, Arial, sans-serif;\n --uktdd-body-bg-color: #fff;\n --uktdd-body-bg-color-hover: rgb(105, 162, 249);\n --uktdd-body-color-hover: #fff;\n --uktdd-body-buffer: 10px;\n --uktdd-body-max-height: calc(100dvh - var(--uktdd-body-buffer));\n --uktdd-body-max-width: calc(100dvw - var(--uktdd-body-buffer));\n --uktdd-body-min-height: 30px;\n --uktdd-body-pad-bottom: 0.5em;\n --uktdd-body-pad-left: 0.6875em;\n --uktdd-body-pad-right: 0.6875em;\n --uktdd-body-pad-top: 0.5em;\n --uktdd-body-min-width: min(50px, 100%);\n --uktdd-body-position-area: bottom span-right;\n --uktdd-body-position-try-fallbacks:\n --uktdd-top-left, --uktdd-bottom-right, --uktdd-top-right;\n /* gap between the trigger and the body, applied as a symmetric\n margin-block so it lands on whichever side the body attaches to and\n auto-reverses when position-try flips it above/below the trigger. A\n margin establishes no containing block, so it’s safe on dropdowns with\n submenus */\n --uktdd-body-gap: 0px;\n --uktdd-body-color: canvastext;\n --uktdd-body-bg-color-path: #dcdcdc;\n --uktdd-body-color-path: currentColor;\n --uktdd-label-pad-right: 0.625em;\n --uktdd-submenu-position-area: inline-end span-block-end;\n --uktdd-submenu-position-try-fallbacks: --uktdd-submenu-inline-start;\n /* like --uktdd-body-gap but on the inline axis, since submenus open to\n the side; auto-reverses when they flip to the opposite inline edge */\n --uktdd-submenu-gap: 0px;\n --uktdd-menubar-trigger-bg-color-active: rgba(0, 0, 0, 0.12);\n}\n\n.uktdropdown,\n.uktdropdown-trigger {\n font-family: var(--uktdd-font-family);\n}\n\n.uktdropdown {\n width: max-content;\n anchor-scope: --uktdd-anchor;\n\n &.disabled {\n pointer-events: none;\n }\n\n > * {\n cursor: default;\n }\n\n > :first-child {\n anchor-name: --uktdd-anchor;\n }\n}\n\n.uktdropdown-label {\n display: flex;\n align-items: center;\n}\n\n.uktdropdown-label-text {\n padding-right: var(--uktdd-label-pad-right);\n}\n\n.uktdropdown-body {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n position: fixed;\n position-anchor: --uktdd-anchor;\n position-area: var(--uktdd-body-position-area);\n position-try-order: most-height;\n position-try-fallbacks: var(--uktdd-body-position-try-fallbacks);\n min-block-size: min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));\n max-block-size: min(var(--uktdd-body-max-height), 100%);\n min-inline-size: min(var(--uktdd-body-min-width), var(--uktdd-body-max-width));\n max-inline-size: var(--uktdd-body-max-width);\n inline-size: max-content;\n overflow: hidden;\n /* the body renders in the top layer via popover=\"manual\" so an ancestor’s\n transform / filter / contain can’t become its containing block, and the\n top layer handles stacking (no z-index). The UA-popover box resets that\n must beat a consumer’s global [popover] styles live in the\n div.uktdropdown-body rule below; these cosmetics stay overridable */\n color: inherit;\n background-color: var(--uktdd-body-bg-color);\n box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);\n\n &.has-items {\n user-select: none;\n }\n\n [data-ukt-active] {\n background-color: var(--uktdd-body-bg-color-hover);\n color: var(--uktdd-body-color-hover);\n }\n\n /* an active item is on the path — not deepest — while a deeper highlight\n exists or the pointer is inside its submenu; macOS mutes the parent\n even when the pointer is over a separator or disabled submenu item */\n [data-ukt-active]:has([data-ukt-submenu] [data-ukt-active]),\n [data-ukt-active]:has([data-ukt-submenu]:hover) {\n background-color: var(--uktdd-body-bg-color-path);\n color: var(--uktdd-body-color-path);\n }\n\n [data-ukt-item][aria-disabled=\"true\"] {\n opacity: 0.5;\n pointer-events: none;\n }\n\n /* the expanded parent item anchors its submenu; anchor-scope keeps each\n level’s submenu bound to its own parent item */\n [data-ukt-item] {\n anchor-scope: --uktdd-submenu-anchor;\n }\n\n /* parent items get a macOS-style disclosure chevron, right-aligned */\n :is([data-ukt-item], [data-ukt-value])[aria-haspopup=\"menu\"] {\n position: relative;\n padding-inline-end: 2em;\n\n &::after {\n content: \"\";\n position: absolute;\n inset-inline-end: 0.9em;\n inset-block-start: 50%;\n inline-size: 0.3em;\n block-size: 0.3em;\n border-block-start: 0.14em solid currentColor;\n border-inline-end: 0.14em solid currentColor;\n translate: 0 -50%;\n rotate: 45deg;\n }\n\n &:dir(rtl)::after {\n rotate: -45deg;\n }\n }\n\n [data-ukt-item][aria-expanded=\"true\"] {\n anchor-name: --uktdd-submenu-anchor;\n\n > [data-ukt-submenu] {\n display: block;\n }\n }\n\n [data-ukt-submenu] {\n box-sizing: border-box;\n display: none;\n /* an explicit color so items don’t inherit the white highlight color\n from their active parent item (the submenu is its DOM child) */\n color: var(--uktdd-body-color);\n position: fixed;\n position-anchor: --uktdd-submenu-anchor;\n position-area: var(--uktdd-submenu-position-area);\n position-try-fallbacks: var(--uktdd-submenu-position-try-fallbacks);\n z-index: 2;\n margin-block: 0;\n margin-inline: var(--uktdd-submenu-gap);\n padding: var(--uktdd-body-pad-top) var(--uktdd-body-pad-right)\n var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);\n inline-size: max-content;\n max-inline-size: var(--uktdd-body-max-width);\n max-block-size: var(--uktdd-body-max-height);\n overflow: auto;\n overscroll-behavior: contain;\n list-style: none;\n background-color: var(--uktdd-body-bg-color);\n box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);\n }\n}\n\n/* The body is a popover, so a consumer’s global [popover] rules match it and\n tie .uktdropdown-body on specificity (both 0,1,0), letting source order\n decide — which can clobber the body’s box geometry. Reset the UA-popover box\n at div.uktdropdown-body (0,1,1): the lightest bump that still beats a bare\n [popover] (0,1,0), so the layout holds regardless of a consumer’s popover\n styles, while the body’s cosmetics stay overridable at 0,1,0. */\ndiv.uktdropdown-body {\n inset: auto;\n block-size: auto;\n margin-block: var(--uktdd-body-gap);\n margin-inline: 0;\n border: 0;\n padding: 0;\n}\n\n.uktmenubar {\n display: flex;\n align-items: stretch;\n width: max-content;\n font-family: var(--uktdd-font-family);\n\n /* the open menu’s trigger reads as active, like the highlighted item in\n the macOS menu bar; the default tints over whatever background the\n trigger already has, so it works regardless of how it’s styled */\n .uktdropdown.is-open .uktdropdown-trigger {\n box-shadow: inset 0 0 0 100vmax var(--uktdd-menubar-trigger-bg-color-active);\n }\n}\n\n.uktdropdown-content {\n box-sizing: border-box;\n min-block-size: 0;\n overflow: auto;\n overscroll-behavior: contain;\n padding: var(--uktdd-body-pad-top) var(--uktdd-body-pad-right)\n var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);\n}\n\n@position-try --uktdd-top-left {\n position-area: top span-right;\n}\n\n@position-try --uktdd-bottom-left {\n position-area: bottom span-right;\n}\n\n@position-try --uktdd-bottom-right {\n position-area: bottom span-left;\n}\n\n@position-try --uktdd-top-right {\n position-area: top span-left;\n}\n\n@position-try --uktdd-submenu-inline-start {\n position-area: inline-start span-block-end;\n}\n","import { getBestMatch } from '@acusti/matchmaking';\nimport { type SyntheticEvent } from 'react';\n\nimport { type Item } from './Dropdown.js';\n\nexport const ITEM_SELECTOR = '[data-ukt-item], [data-ukt-value]';\nexport const SUBMENU_SELECTOR = '[data-ukt-submenu]';\n\nconst DISABLED_ITEM_SELECTOR = '[aria-disabled=\"true\"]';\n\nexport type OnToggleSubmenu = (item: HTMLElement, isExpanded: boolean) => void;\n\ntype MaybeHTMLElement = HTMLElement | null;\n\nconst getBodyElement = (dropdownElement: MaybeHTMLElement) =>\n (dropdownElement?.querySelector('.uktdropdown-body') ?? null) as MaybeHTMLElement;\n\n// The level root that owns an item: the closest [data-ukt-submenu] ancestor,\n// or null for items at the top level of the dropdown body\nexport const getLevelRoot = (element: HTMLElement) =>\n element.closest(SUBMENU_SELECTOR) as MaybeHTMLElement;\n\n// An item’s own submenu (a parent item), excluding submenus of descendant items\nexport const getSubmenuOfItem = (item: HTMLElement): MaybeHTMLElement => {\n const submenu = item.querySelector(SUBMENU_SELECTOR) as MaybeHTMLElement;\n if (!submenu) return null;\n const owner = submenu.parentElement?.closest(ITEM_SELECTOR);\n return owner === item ? submenu : null;\n};\n\n// The parent item that owns a submenu level\nexport const getParentItem = (levelRoot: HTMLElement) =>\n (levelRoot.parentElement?.closest(ITEM_SELECTOR) ?? null) as MaybeHTMLElement;\n\n// A parent item’s label is its text content excluding the submenu subtree\nexport const getItemLabel = (item: HTMLElement): string => {\n if (!getSubmenuOfItem(item)) return item.innerText ?? '';\n const clone = item.cloneNode(true) as HTMLElement;\n for (const submenu of Array.from(clone.querySelectorAll(SUBMENU_SELECTOR))) {\n submenu.remove();\n }\n return (clone.textContent ?? '').trim();\n};\n\n// Ancestor parent items from the root level down to the element’s immediate parent\nexport const getItemPath = (element: MaybeHTMLElement): Item['path'] => {\n const path: Item['path'] = [];\n if (!element) return path;\n let levelRoot = getLevelRoot(element);\n while (levelRoot) {\n const parentItem = getParentItem(levelRoot);\n if (!parentItem) break;\n const label = getItemLabel(parentItem);\n path.unshift({ label, value: parentItem.dataset.uktValue ?? label });\n levelRoot = getLevelRoot(parentItem);\n }\n return path;\n};\n\nexport const getItemElements = (\n dropdownElement: MaybeHTMLElement,\n levelRoot?: MaybeHTMLElement,\n): Array<HTMLElement> | null => {\n const bodyElement = getBodyElement(dropdownElement);\n if (!bodyElement) return null;\n\n const root = levelRoot ?? bodyElement;\n const candidates = Array.from(\n root.querySelectorAll(ITEM_SELECTOR),\n ) as Array<HTMLElement>;\n\n if (candidates.length) {\n return candidates.filter((item) => {\n if (item.matches(DISABLED_ITEM_SELECTOR)) return false;\n return getLevelRoot(item) === (levelRoot ?? null);\n });\n }\n\n // If no items found via [data-ukt-item] or [data-ukt-value] selector,\n // use first instance of multiple children found — flat bodies and flat\n // submenu levels alike\n let items: HTMLCollection = root.children;\n while (items.length === 1) {\n if (items[0].children == null) break;\n items = items[0].children;\n }\n // If unable to find an element with more than one child, treat direct child as items\n if (items.length === 1) {\n items = root.children;\n }\n return (Array.from(items) as Array<HTMLElement>).filter(\n (item) => !item.matches(DISABLED_ITEM_SELECTOR),\n );\n};\n\n// The item an event target belongs to within its own level: the closest\n// marked item, or — when the target sits in a level with no marked items\n// (a heuristically-detected level) — the target itself if it’s one of that\n// level’s detected items. Misses (body padding, separators) and disabled\n// items resolve to null.\nexport const getItemForTarget = (\n dropdownElement: HTMLElement,\n target: HTMLElement,\n): MaybeHTMLElement => {\n let item = target.closest(ITEM_SELECTOR) as MaybeHTMLElement;\n // If nothing matched, or the target sits in a deeper level than the\n // matched item (an unmarked, heuristically-detected submenu level),\n // resolve the item within the target’s own level instead\n const targetLevelRoot = getLevelRoot(target);\n if (!item || (targetLevelRoot && item.contains(targetLevelRoot))) {\n const itemElements = getItemElements(dropdownElement, targetLevelRoot);\n item = itemElements?.find((itemElement) => itemElement === target) ?? item;\n }\n if (!item || !dropdownElement.contains(item)) return null;\n if (item.matches(DISABLED_ITEM_SELECTOR)) return null;\n return item;\n};\n\n// All active items, in document order (ancestors before descendants)\nexport const getActiveItemElements = (dropdownElement: MaybeHTMLElement) => {\n if (!dropdownElement) return null;\n const actives = dropdownElement.querySelectorAll('[data-ukt-active]');\n return actives.length ? (Array.from(actives) as Array<HTMLElement>) : null;\n};\n\n// The deepest active item — the one keyboard input operates on\nexport const getActiveItemElement = (dropdownElement: MaybeHTMLElement) => {\n const actives = getActiveItemElements(dropdownElement);\n return actives ? actives[actives.length - 1] : null;\n};\n\n// The deepest expanded parent item — the one whose submenu is the innermost\n// open one — in document order\nexport const getDeepestExpandedItem = (\n dropdownElement: MaybeHTMLElement,\n): MaybeHTMLElement => {\n if (!dropdownElement) return null;\n const expanded = (\n Array.from(\n dropdownElement.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((element) => element.matches(ITEM_SELECTOR));\n return expanded.length ? expanded[expanded.length - 1] : null;\n};\n\nexport const isItemExpanded = (item: HTMLElement) =>\n item.getAttribute('aria-expanded') === 'true';\n\nlet submenuIdCounter = 0;\n\nconst ensureSubmenuAria = (item: HTMLElement, submenu: HTMLElement) => {\n if (!submenu.hasAttribute('role')) submenu.setAttribute('role', 'menu');\n if (!submenu.id) submenu.id = `uktdd-submenu-${++submenuIdCounter}`;\n if (!item.hasAttribute('aria-haspopup')) item.setAttribute('aria-haspopup', 'menu');\n if (!item.hasAttribute('aria-expanded')) item.setAttribute('aria-expanded', 'false');\n if (!item.hasAttribute('aria-controls')) {\n item.setAttribute('aria-controls', submenu.id);\n }\n};\n\n// Fill in submenu/parent-item ARIA (only what the consumer hasn’t set)\nexport const annotateParentItems = (bodyElement: MaybeHTMLElement) => {\n if (!bodyElement) return;\n for (const submenu of Array.from(bodyElement.querySelectorAll(SUBMENU_SELECTOR))) {\n const item = getParentItem(submenu as HTMLElement);\n if (item) ensureSubmenuAria(item, submenu as HTMLElement);\n }\n};\n\nexport const expandItem = (item: HTMLElement, onToggleSubmenu?: OnToggleSubmenu) => {\n const submenu = getSubmenuOfItem(item);\n if (!submenu) return;\n ensureSubmenuAria(item, submenu);\n if (isItemExpanded(item)) return;\n item.setAttribute('aria-expanded', 'true');\n onToggleSubmenu?.(item, true);\n};\n\nexport const collapseItem = (item: HTMLElement, onToggleSubmenu?: OnToggleSubmenu) => {\n if (!isItemExpanded(item)) return;\n const submenu = getSubmenuOfItem(item);\n if (submenu) {\n // Collapse any expanded descendants first so their state can’t leak\n // into the next disclosure and their onClose callbacks fire\n // (recursion makes the collapse order deepest-first)\n const expandedDescendants = (\n Array.from(\n submenu.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((descendant) => descendant.matches(ITEM_SELECTOR));\n for (const descendant of expandedDescendants) {\n collapseItem(descendant, onToggleSubmenu);\n }\n for (const active of Array.from(submenu.querySelectorAll('[data-ukt-active]'))) {\n delete (active as HTMLElement).dataset.uktActive;\n }\n }\n item.setAttribute('aria-expanded', 'false');\n onToggleSubmenu?.(item, false);\n};\n\n// Collapse every expanded parent item that isn’t an ancestor of element\n// (element == null collapses all), deepest-first\nexport const collapseItemsOutsidePath = (\n dropdownElement: MaybeHTMLElement,\n element: MaybeHTMLElement,\n onToggleSubmenu?: OnToggleSubmenu,\n) => {\n const bodyElement = getBodyElement(dropdownElement);\n if (!bodyElement) return;\n const expandedItems = (\n Array.from(\n bodyElement.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((item) => item.matches(ITEM_SELECTOR));\n for (const item of expandedItems.reverse()) {\n if (element && item.contains(element)) continue;\n collapseItem(item, onToggleSubmenu);\n }\n};\n\nconst clearItemElementsState = (itemElements: Array<HTMLElement>) => {\n itemElements.forEach((itemElement) => {\n if (itemElement.hasAttribute('data-ukt-active')) {\n delete itemElement.dataset.uktActive;\n }\n // Also clear active state in any deeper levels within this item\n for (const active of Array.from(\n itemElement.querySelectorAll('[data-ukt-active]'),\n )) {\n delete (active as HTMLElement).dataset.uktActive;\n }\n });\n};\n\n// Make the active set exactly the chain of element + its ancestor parent items\nconst setActiveChain = (dropdownElement: HTMLElement, element: HTMLElement) => {\n const chain = new Set<HTMLElement>([element]);\n let levelRoot = getLevelRoot(element);\n while (levelRoot) {\n const parentItem = getParentItem(levelRoot);\n if (!parentItem) break;\n chain.add(parentItem);\n levelRoot = getLevelRoot(parentItem);\n }\n for (const active of getActiveItemElements(dropdownElement) ?? []) {\n if (!chain.has(active)) delete active.dataset.uktActive;\n }\n for (const item of chain) {\n item.setAttribute('data-ukt-active', '');\n }\n};\n\ntype BaseSetActiveItemPayload = {\n dropdownElement: HTMLElement;\n element?: null;\n event: Event | SyntheticEvent<HTMLElement>;\n index?: null;\n indexAddend?: null;\n isExactMatch?: null;\n onActiveItem?: (payload: Item) => void;\n text?: null;\n};\n\nexport const setActiveItem = ({\n dropdownElement,\n element,\n event,\n index,\n indexAddend,\n isExactMatch,\n onActiveItem,\n text,\n}:\n | ({\n element: HTMLElement;\n } & Omit<BaseSetActiveItemPayload, 'element'>)\n | ({\n index: number;\n } & Omit<BaseSetActiveItemPayload, 'index'>)\n | ({\n indexAddend: number;\n } & Omit<BaseSetActiveItemPayload, 'indexAddend'>)\n | ({\n isExactMatch?: boolean;\n text: string;\n } & Omit<BaseSetActiveItemPayload, 'isExactMatch' | 'text'>)): MaybeHTMLElement => {\n const currentDeepest = getActiveItemElement(dropdownElement);\n // Keys and text operate on the current level (the level of the deepest\n // active item); activating an element directly targets its own level\n const levelRoot = element\n ? getLevelRoot(element)\n : currentDeepest\n ? getLevelRoot(currentDeepest)\n : null;\n\n const itemElements = getItemElements(dropdownElement, levelRoot);\n if (!itemElements || itemElements.length === 0) return currentDeepest;\n\n const lastIndex = itemElements.length - 1;\n const currentActiveIndex = itemElements.findIndex(\n (itemElement) => itemElement === currentDeepest,\n );\n\n let nextActiveIndex = currentActiveIndex;\n if (typeof index === 'number') {\n // Negative index means count back from the end\n nextActiveIndex = index < 0 ? itemElements.length + index : index;\n }\n\n if (element) {\n nextActiveIndex = itemElements.findIndex(\n (itemElement) => itemElement === element,\n );\n if (nextActiveIndex === -1) return currentDeepest;\n } else if (typeof indexAddend === 'number') {\n // If there’s no currentActiveIndex and we are handling -1, start at lastIndex\n if (currentActiveIndex === -1 && indexAddend === -1) {\n nextActiveIndex = lastIndex;\n } else {\n nextActiveIndex += indexAddend;\n }\n // Keep it within the bounds of the items list\n nextActiveIndex = Math.max(0, Math.min(nextActiveIndex, lastIndex));\n } else if (typeof text === 'string') {\n // If text is empty, clear existing active items and early return\n if (!text) {\n clearItemElementsState(itemElements);\n return null;\n }\n\n const itemTexts = itemElements.map(getItemLabel);\n if (isExactMatch) {\n const textToCompare = text.toLowerCase();\n nextActiveIndex = itemTexts.findIndex((itemText) =>\n itemText.toLowerCase().startsWith(textToCompare),\n );\n // If isExactMatch is required and no exact match was found, clear active items\n if (nextActiveIndex === -1) {\n clearItemElementsState(itemElements);\n }\n } else {\n const bestMatch = getBestMatch({ items: itemTexts, text });\n nextActiveIndex = itemTexts.findIndex((itemText) => itemText === bestMatch);\n }\n }\n\n const nextActiveItem = itemElements[nextActiveIndex] as MaybeHTMLElement;\n if (nextActiveItem == null || nextActiveItem === currentDeepest) {\n return currentDeepest;\n }\n\n setActiveChain(dropdownElement, nextActiveItem);\n const label = getItemLabel(nextActiveItem);\n const value = nextActiveItem.dataset.uktValue ?? label;\n onActiveItem?.({\n element: nextActiveItem,\n event,\n label,\n path: getItemPath(nextActiveItem),\n value,\n });\n // Find closest scrollable parent and ensure that next active item is visible\n let { parentElement } = nextActiveItem;\n let scrollableParent = null;\n while (!scrollableParent && parentElement && parentElement !== dropdownElement) {\n const isScrollable = parentElement.scrollHeight > parentElement.clientHeight + 15;\n if (isScrollable) {\n scrollableParent = parentElement;\n } else {\n parentElement = parentElement.parentElement;\n }\n }\n\n if (scrollableParent) {\n const parentRect = scrollableParent.getBoundingClientRect();\n const itemRect = nextActiveItem.getBoundingClientRect();\n const isAboveTop = itemRect.top < parentRect.top;\n const isBelowBottom = itemRect.bottom > parentRect.bottom;\n if (isAboveTop || isBelowBottom) {\n let { scrollTop } = scrollableParent;\n // Item isn’t fully visible; adjust scrollTop to put item within closest edge\n if (isAboveTop) {\n scrollTop -= parentRect.top - itemRect.top;\n } else {\n scrollTop += itemRect.bottom - parentRect.bottom;\n }\n scrollableParent.scrollTop = scrollTop;\n }\n }\n\n return nextActiveItem;\n};\n\nexport type Point = { x: number; y: number };\n\n// Whether a point is inside (or on an edge of) triangle a-b-c, from the sign\n// of the cross product for each edge: all the same sign ⇒ inside\nexport const isPointInTriangle = (p: Point, a: Point, b: Point, c: Point): boolean => {\n const cross = (u: Point, v: Point, w: Point) =>\n (u.x - w.x) * (v.y - w.y) - (v.x - w.x) * (u.y - w.y);\n const d1 = cross(p, a, b);\n const d2 = cross(p, b, c);\n const d3 = cross(p, c, a);\n const hasNegative = d1 < 0 || d2 < 0 || d3 < 0;\n const hasPositive = d1 > 0 || d2 > 0 || d3 > 0;\n return !(hasNegative && hasPositive);\n};\n","import clsx from 'clsx';\nimport {\n type CSSProperties,\n type FocusEvent as ReactFocusEvent,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n useMemo,\n useRef,\n} from 'react';\n\nimport {\n MenubarContext,\n type MenubarContextValue,\n type MenubarMember,\n} from './context.js';\n\nexport type MenubarProps = {\n children: ReactNode;\n className?: string;\n style?: CSSProperties;\n};\n\nconst compareDocumentOrder = (a: MenubarMember, b: MenubarMember) => {\n if (a.element === b.element) return 0;\n const position = a.element.compareDocumentPosition(b.element);\n if ((position & Node.DOCUMENT_POSITION_FOLLOWING) !== 0) return -1;\n if ((position & Node.DOCUMENT_POSITION_PRECEDING) !== 0) return 1;\n return 0;\n};\n\n// Matches interactive controls that live in the menubar without being dropdown\n// triggers (e.g. a plain button). Hovering one clears the open menu without\n// disengaging the menubar.\nconst NON_MENU_CONTROL_SELECTOR = 'a[href], button, input, select, textarea, [tabindex]';\n\n// Combines sibling Dropdowns into a single menu, like the system menu in the\n// top toolbar of macOS: one menu open at a time, ←/→ move between menus, and\n// once any menu is open, hovering or focusing another trigger switches to it.\nexport default function Menubar({ children, className, style }: MenubarProps) {\n const membersRef = useRef<Set<MenubarMember>>(new Set());\n // The member that engaged the bar (menu-mode). It keeps pointing at that\n // member even if that member’s menu was closed by hovering a non-menu\n // control, which allows the bar to stay engaged even with nothing open.\n const engagedMemberRef = useRef<HTMLElement | null>(null);\n\n const getOrderedMembersRef = useRef(() =>\n Array.from(membersRef.current).sort(compareDocumentOrder),\n );\n const getOrderedMembers = getOrderedMembersRef.current;\n\n const contextValue: MenubarContextValue = useMemo(\n () => ({\n moveOpen(fromElement: HTMLElement, direction: -1 | 1) {\n const members = getOrderedMembersRef.current();\n if (members.length < 2) return;\n const index = members.findIndex(\n (member) => member.element === fromElement,\n );\n if (index === -1) return;\n const nextIndex = (index + direction + members.length) % members.length;\n members[index].close();\n members[nextIndex].open();\n members[nextIndex].focusTrigger();\n },\n notifyClosed(element: HTMLElement) {\n // Only a dismissal of the member that engaged the bar ends\n // menu-mode. Outside-click handling closes every mounted\n // dropdown, so ignore the closes reported for the rest.\n if (engagedMemberRef.current === element) {\n engagedMemberRef.current = null;\n }\n },\n notifyOpened(element: HTMLElement) {\n engagedMemberRef.current = element;\n for (const member of membersRef.current) {\n if (member.element !== element && member.isOpen()) {\n member.close();\n }\n }\n },\n registerMember(member: MenubarMember) {\n membersRef.current.add(member);\n return () => {\n membersRef.current.delete(member);\n };\n },\n }),\n [],\n );\n\n // Rove focus between triggers with ←/→ while no menu is open (the open\n // dropdown’s own key handling slides the open menu between triggers)\n const handleKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n const { key } = event;\n if (key !== 'ArrowLeft' && key !== 'ArrowRight') return;\n const members = getOrderedMembers();\n if (members.length < 2) return;\n if (members.some((member) => member.isOpen())) return;\n const eventTarget = event.target as HTMLElement;\n const index = members.findIndex((member) => member.element.contains(eventTarget));\n if (index === -1) return;\n event.preventDefault();\n event.stopPropagation();\n const direction = key === 'ArrowRight' ? 1 : -1;\n members[(index + direction + members.length) % members.length].focusTrigger();\n };\n\n // Once the bar is engaged, moving hover or focus onto another member’s\n // trigger switches to it (opening notifies the menubar, which closes the\n // other open member), while moving onto a non-menu control clears the open\n // menu but keeps the bar engaged.\n const switchToMemberAt = (eventTarget: HTMLElement) => {\n if (engagedMemberRef.current == null) return;\n const members = getOrderedMembers();\n // If the member that engaged the bar is gone (e.g. it unmounted while\n // engaged) the bar is no longer engaged, so hover can’t reopen menus\n if (!members.some((m) => m.element === engagedMemberRef.current)) {\n engagedMemberRef.current = null;\n return;\n }\n const member = members.find((m) => m.element.contains(eventTarget));\n if (member) {\n if (!member.isOpen()) member.open();\n return;\n }\n // Not over a menu trigger: only a real non-menu control (not the bar’s\n // padding or the gaps between triggers) clears the open menu — this is\n // a menubar-driven close, so the members stay engaged.\n if (!eventTarget.closest(NON_MENU_CONTROL_SELECTOR)) return;\n for (const openMember of members) {\n if (openMember.isOpen()) openMember.close();\n }\n };\n\n const handleFocus = (event: ReactFocusEvent<HTMLDivElement>) => {\n switchToMemberAt(event.target as HTMLElement);\n };\n\n const handleMouseOver = (event: ReactMouseEvent<HTMLDivElement>) => {\n switchToMemberAt(event.target as HTMLElement);\n };\n\n return (\n <div\n className={clsx('uktmenubar', className)}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onMouseOver={handleMouseOver}\n role=\"menubar\"\n style={style}\n >\n <MenubarContext.Provider value={contextValue}>\n {children}\n </MenubarContext.Provider>\n </div>\n );\n}\n","/* eslint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/mouse-events-have-key-events, jsx-a11y/no-static-element-interactions */\nimport useKeyboardEvents, {\n isEventTargetUsingKeyEvent,\n} from '@acusti/use-keyboard-events';\nimport clsx from 'clsx';\nimport {\n Children,\n cloneElement,\n type CSSProperties,\n Fragment,\n isValidElement,\n type MouseEvent as ReactMouseEvent,\n type ReactElement,\n type ReactNode,\n type SyntheticEvent,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport {\n DropdownContext,\n type DropdownContextValue,\n MenubarContext,\n type SubmenuRegistration,\n} from './context.js';\nimport styles from './Dropdown.css?inline';\nimport {\n annotateParentItems,\n collapseItem,\n collapseItemsOutsidePath,\n expandItem,\n getActiveItemElement,\n getDeepestExpandedItem,\n getItemElements,\n getItemForTarget,\n getItemPath,\n getLevelRoot,\n getParentItem,\n getSubmenuOfItem,\n isItemExpanded,\n isPointInTriangle,\n type Point,\n setActiveItem,\n} from './helpers.js';\n\nexport type Item = {\n element: MaybeHTMLElement;\n event: Event | SyntheticEvent<HTMLElement>;\n label: string;\n /**\n * Ancestor parent items from the root level down to the item’s\n * immediate parent. Empty for top-level items.\n */\n path: Array<ItemPathEntry>;\n value: string;\n};\n\nexport type ItemPathEntry = { label: string; value: string };\n\nexport type Props = {\n /**\n * Boolean indicating if the user can submit a value not already in the\n * dropdown.\n */\n allowCreate?: boolean;\n /**\n * Boolean indicating if submitting with no item active emits an empty\n * value (i.e. clears the value). Only has an effect when the dropdown has a\n * text input to source that value from — a searchable dropdown’s search\n * input, or a text input inside a custom trigger. With no such input there\n * is no value to submit, so submitting with nothing selected is a no-op\n * regardless; clear such a dropdown with an explicit empty-valued item\n * instead. Defaults to true.\n */\n allowEmpty?: boolean;\n /**\n * Can take a single React element or exactly two renderable children.\n */\n children: ChildrenTuple | ReactElement;\n className?: string;\n disabled?: boolean;\n hasItems?: boolean;\n isOpenOnMount?: boolean;\n isSearchable?: boolean;\n keepOpenOnSubmit?: boolean;\n /**\n * Label content for the trigger button (when using single child syntax).\n * For a nested (submenu) Dropdown, this is the parent item’s content.\n */\n label?: ReactNode;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s name.\n */\n name?: string;\n onActiveItem?: (payload: Item) => void;\n onClick?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onClose?: () => unknown;\n onMouseDown?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onMouseUp?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onOpen?: () => unknown;\n onSubmitItem?: (payload: Item) => void;\n /**\n * Opens the dropdown when the pointer hovers the trigger, and closes it a\n * short moment after the pointer leaves the trigger and body entirely (the\n * close is delayed so crossing the gap between them, or pausing over\n * either, doesn’t flicker-close it). Click and keyboard opening keep\n * working as usual alongside it.\n */\n openOnHover?: boolean;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s placeholder.\n */\n placeholder?: string;\n /**\n * Applied to the dropdown root element. Also accepts the component’s CSS\n * custom properties (e.g. `--uktdd-body-min-width`) for per-instance\n * placement and sizing, which plain `CSSProperties` rejects.\n */\n style?: CSSProperties & Record<`--${string}`, string | number | undefined>;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s tabIndex.\n */\n tabIndex?: number;\n /**\n * Used as search input’s value if props.isSearchable === true\n * Used to determine if value has changed to avoid triggering onSubmitItem if not\n */\n value?: string;\n};\n\ntype ChildrenTuple = [ReactNode, ReactNode] | readonly [ReactNode, ReactNode];\n\ntype MaybeHTMLElement = HTMLElement | null;\n\ntype MousePosition = { clientX: number; clientY: number };\n\ntype TimeoutID = ReturnType<typeof setTimeout>;\n\nconst CHILDREN_ERROR =\n '@acusti/dropdown requires either 1 child (the dropdown body) or 2 children: the dropdown trigger and the dropdown body.';\nconst CLICKABLE_SELECTOR = 'button, a[href], input[type=\"button\"], input[type=\"submit\"]';\nconst FOCUSABLE_SELECTOR = 'a[href], button, input, select, textarea, [tabindex]';\nconst TEXT_INPUT_SELECTOR =\n 'input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea';\n\n// Matches macOS: quick, natural arrowing past parent items never flashes\n// their submenus, but a brief pause discloses. Frame-stepping macOS menus\n// puts its delay around 200–250ms; anything much shorter flashes\nconst SUBMENU_DISCLOSURE_DELAY = 200;\n\n// How long the pointer can dwell inside the safe area (heading toward an open\n// submenu) before we give up and switch to whatever it’s actually over. Reset\n// on every move, so it only fires on a pause — motion keeps the submenu open\nconst SAFE_AREA_TIMEOUT = 300;\n\n// props.openOnHover opens immediately on hover, but closing waits a beat so\n// that crossing the trigger/body gap (or a placement fallback moving the body\n// somewhere the pointer briefly leaves) doesn’t flicker-close it\nconst HOVER_CLOSE_DELAY = 150;\n\nexport default function Dropdown(props: Props) {\n const parentDropdown = useContext(DropdownContext);\n // A Dropdown nested inside a menu dropdown’s body renders as a submenu\n // (a parent item delegating to the root engine). A hasItems={false}\n // dropdown provides no submenu context, so a Dropdown nested inside one —\n // or a hasItems={false} Dropdown anywhere — renders independently instead.\n if (parentDropdown && props.hasItems !== false) {\n return <SubmenuDropdown {...props} parentDropdown={parentDropdown} />;\n }\n return <RootDropdown {...props} />;\n}\n\nfunction RootDropdown({\n allowCreate,\n allowEmpty = true,\n children,\n className,\n disabled,\n hasItems = true,\n isOpenOnMount,\n isSearchable,\n keepOpenOnSubmit = !hasItems,\n label,\n name,\n onActiveItem,\n onClick,\n onClose,\n onMouseDown,\n onMouseUp,\n onOpen,\n onSubmitItem,\n openOnHover,\n placeholder,\n style: styleFromProps,\n tabIndex,\n value,\n}: Props) {\n const childrenCount = Children.count(children);\n if (childrenCount !== 1 && childrenCount !== 2) {\n if (childrenCount === 0) {\n throw new Error(CHILDREN_ERROR + ' Received no children.');\n }\n console.error(`${CHILDREN_ERROR} Received ${childrenCount} children.`);\n }\n\n let trigger: React.ReactNode;\n if (childrenCount > 1) {\n trigger = (children as ChildrenTuple)[0];\n }\n\n const [isOpen, setIsOpen] = useState<boolean>(isOpenOnMount ?? false);\n const [isOpening, setIsOpening] = useState<boolean>(!isOpenOnMount);\n const [dropdownElement, setDropdownElement] = useState<MaybeHTMLElement>(null);\n const bodyId = useId();\n const popupRole = isSearchable ? 'listbox' : hasItems ? 'menu' : 'dialog';\n const menubar = useContext(MenubarContext);\n const inputElementRef = useRef<HTMLInputElement | null>(null);\n const closingTimerRef = useRef<null | TimeoutID>(null);\n const isOpeningTimerRef = useRef<null | TimeoutID>(null);\n const currentInputMethodRef = useRef<'keyboard' | 'mouse'>('mouse');\n const clearEnteredCharactersTimerRef = useRef<null | TimeoutID>(null);\n const enteredCharactersRef = useRef<string>('');\n const mouseDownPositionRef = useRef<MousePosition | null>(null);\n const disclosureTimerRef = useRef<null | TimeoutID>(null);\n const pendingDisclosureItemRef = useRef<MaybeHTMLElement>(null);\n const submenuRegistrationsRef = useRef<Set<SubmenuRegistration>>(new Set());\n const pointerRef = useRef<Point | null>(null);\n const lastMouseEventRef = useRef<MouseEvent | null>(null);\n const safeAreaRef = useRef<{ apex: Point; parent: HTMLElement } | null>(null);\n const safeAreaTimerRef = useRef<null | TimeoutID>(null);\n const wasInSafeAreaRef = useRef<boolean>(false);\n const hoverCloseTimerRef = useRef<null | TimeoutID>(null);\n\n const allowCreateRef = useRef(allowCreate);\n const allowEmptyRef = useRef(allowEmpty);\n const hasItemsRef = useRef(hasItems);\n const isOpenRef = useRef(isOpen);\n const isOpeningRef = useRef(isOpening);\n const keepOpenOnSubmitRef = useRef(keepOpenOnSubmit);\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n const onSubmitItemRef = useRef(onSubmitItem);\n const valueRef = useRef(value);\n\n useEffect(() => {\n allowCreateRef.current = allowCreate;\n allowEmptyRef.current = allowEmpty;\n hasItemsRef.current = hasItems;\n isOpenRef.current = isOpen;\n isOpeningRef.current = isOpening;\n keepOpenOnSubmitRef.current = keepOpenOnSubmit;\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n onSubmitItemRef.current = onSubmitItem;\n valueRef.current = value;\n }, [\n allowCreate,\n allowEmpty,\n hasItems,\n isOpen,\n isOpening,\n keepOpenOnSubmit,\n onClose,\n onOpen,\n onSubmitItem,\n value,\n ]);\n\n const isMountedRef = useRef(false);\n\n useEffect(() => {\n if (!isMountedRef.current) {\n isMountedRef.current = true;\n // If isOpenOnMount, trigger onOpen right away\n if (isOpenRef.current && onOpenRef.current) {\n onOpenRef.current();\n }\n return;\n }\n\n if (isOpen && onOpenRef.current) {\n onOpenRef.current();\n } else if (!isOpen && onCloseRef.current) {\n onCloseRef.current();\n }\n }, [isOpen]);\n\n // Nested (submenu) Dropdowns register here so their scoped callbacks\n // (onActiveItem/onOpen/onClose/onSubmitItem) can be dispatched to them\n const dropdownContextValue: DropdownContextValue = useMemo(\n () => ({\n registerSubmenu(registration: SubmenuRegistration) {\n submenuRegistrationsRef.current.add(registration);\n return () => {\n submenuRegistrationsRef.current.delete(registration);\n };\n },\n }),\n [],\n );\n\n const dispatchToSubmenus = (key: 'onActiveItem' | 'onSubmitItem', payload: Item) => {\n if (!payload.element) return;\n for (const registration of submenuRegistrationsRef.current) {\n if (registration.element.contains(payload.element)) {\n registration[key]?.(payload);\n }\n }\n };\n\n const handleActiveItem = (payload: Item) => {\n onActiveItem?.(payload);\n dispatchToSubmenus('onActiveItem', payload);\n };\n\n const handleToggleSubmenu = (item: HTMLElement, isExpanded: boolean) => {\n for (const registration of submenuRegistrationsRef.current) {\n if (registration.element === item) {\n (isExpanded ? registration.onOpen : registration.onClose)?.();\n }\n }\n };\n\n const clearDisclosureTimer = () => {\n if (disclosureTimerRef.current != null) {\n clearTimeout(disclosureTimerRef.current);\n disclosureTimerRef.current = null;\n }\n pendingDisclosureItemRef.current = null;\n };\n\n // Clear the disclosure intent timer on unmount so it can’t fire against\n // unmounted DOM or dispatch submenu callbacks after teardown\n useEffect(() => clearDisclosureTimer, []);\n\n // A parent item discloses its submenu after a short intent delay whenever\n // it becomes (and stays) the deepest active item, for pointer and keyboard\n // alike; submenus off the active path collapse immediately\n const syncSubmenuDisclosure = () => {\n if (!dropdownElement) return;\n const activeElement = getActiveItemElement(dropdownElement);\n collapseItemsOutsidePath(dropdownElement, activeElement, handleToggleSubmenu);\n const submenu = activeElement ? getSubmenuOfItem(activeElement) : null;\n if (activeElement && submenu && !isItemExpanded(activeElement)) {\n // A timer already pending for this item keeps its original start time\n if (pendingDisclosureItemRef.current === activeElement) return;\n clearDisclosureTimer();\n pendingDisclosureItemRef.current = activeElement;\n disclosureTimerRef.current = setTimeout(() => {\n disclosureTimerRef.current = null;\n pendingDisclosureItemRef.current = null;\n if (!activeElement.hasAttribute('data-ukt-active')) return;\n expandItem(activeElement, handleToggleSubmenu);\n }, SUBMENU_DISCLOSURE_DELAY);\n return;\n }\n clearDisclosureTimer();\n };\n\n const clearSafeAreaTimer = () => {\n if (safeAreaTimerRef.current != null) {\n clearTimeout(safeAreaTimerRef.current);\n safeAreaTimerRef.current = null;\n }\n };\n\n // Clear the safe-area give-up timer on unmount so it can’t fire against\n // unmounted DOM\n useEffect(() => clearSafeAreaTimer, []);\n\n // The safe area is the triangle from where the pointer last sat on the\n // open submenu’s parent (the apex) to that submenu’s two near corners.\n // While the pointer is inside it, it’s traveling toward the submenu, so the\n // submenu stays open even as the pointer crosses sibling items — the macOS\n // diagonal behavior\n const isPointerInSafeArea = (x: number, y: number): boolean => {\n const safeArea = safeAreaRef.current;\n if (!safeArea || !isItemExpanded(safeArea.parent)) return false;\n const submenu = getSubmenuOfItem(safeArea.parent);\n if (!submenu) return false;\n const submenuRect = submenu.getBoundingClientRect();\n const parentRect = safeArea.parent.getBoundingClientRect();\n // Submenus can open to either side; the near edge is the one facing\n // the parent item\n const nearX =\n submenuRect.left >= parentRect.right - 1\n ? submenuRect.left\n : submenuRect.right;\n return isPointInTriangle(\n { x, y },\n safeArea.apex,\n { x: nearX, y: submenuRect.top },\n { x: nearX, y: submenuRect.bottom },\n );\n };\n\n // The pointer left the safe area (or paused in it without reaching the\n // submenu): stop protecting the submenu and switch to whatever the pointer\n // is over now. Passing the target avoids an elementFromPoint read; the\n // give-up timer has no event, so it falls back to hit-testing the pointer\n const commitPointerTarget = (targetElement?: MaybeHTMLElement) => {\n clearSafeAreaTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n const pointer = pointerRef.current;\n const target =\n targetElement ??\n (pointer\n ? (dropdownElement?.ownerDocument.elementFromPoint(\n pointer.x,\n pointer.y,\n ) as MaybeHTMLElement)\n : null);\n if (!dropdownElement || !target || !dropdownElement.contains(target)) return;\n const item = getItemForTarget(dropdownElement, target);\n const event = lastMouseEventRef.current;\n // Only reachable via mouse events, so a real mouse event is on hand\n if (item && event) {\n setActiveItem({\n dropdownElement,\n element: item,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n };\n\n // Track the pointer against the open submenu’s safe area: anchor the apex\n // while over the parent item, and (re)arm the give-up timer while traveling\n // toward the submenu so only a pause — not motion — ends the protection\n const trackSafeArea = (event: ReactMouseEvent<HTMLElement>) => {\n // Safe-area intent only applies to an open menu with items; skip the\n // per-move DOM query otherwise (mousemove is a hot path)\n if (!dropdownElement || !isOpenRef.current || !hasItemsRef.current) return;\n const pointer = { x: event.clientX, y: event.clientY };\n pointerRef.current = pointer;\n lastMouseEventRef.current = event.nativeEvent;\n const parent = getDeepestExpandedItem(dropdownElement);\n if (!parent) {\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n clearSafeAreaTimer();\n return;\n }\n const target = event.target as HTMLElement;\n const submenu = getSubmenuOfItem(parent);\n const isOverParent =\n parent.contains(target) && !(submenu?.contains(target) ?? false);\n if (isOverParent) {\n safeAreaRef.current = { apex: pointer, parent };\n wasInSafeAreaRef.current = false;\n clearSafeAreaTimer();\n return;\n }\n // A newly-open submenu we haven’t anchored an apex for yet\n if (safeAreaRef.current?.parent !== parent) {\n safeAreaRef.current = null;\n }\n clearSafeAreaTimer();\n if (isPointerInSafeArea(pointer.x, pointer.y)) {\n wasInSafeAreaRef.current = true;\n safeAreaTimerRef.current = setTimeout(commitPointerTarget, SAFE_AREA_TIMEOUT);\n } else if (wasInSafeAreaRef.current) {\n // Just crossed out of the triangle. The pointer may still be over\n // the same sibling it entered while protected, so no mouseover will\n // fire — re-evaluate and activate whatever it’s on now\n commitPointerTarget(target);\n }\n };\n\n const clearHoverCloseTimer = () => {\n if (hoverCloseTimerRef.current != null) {\n clearTimeout(hoverCloseTimerRef.current);\n hoverCloseTimerRef.current = null;\n }\n };\n\n // Clear props.openOnHover’s close timer on unmount so it can’t fire against\n // unmounted DOM\n useEffect(() => clearHoverCloseTimer, []);\n\n const closeDropdown = (options?: { keepMenubarEngaged?: boolean }) => {\n setIsOpen(false);\n setIsOpening(false);\n mouseDownPositionRef.current = null;\n clearDisclosureTimer();\n clearSafeAreaTimer();\n clearHoverCloseTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n if (closingTimerRef.current != null) {\n clearTimeout(closingTimerRef.current);\n closingTimerRef.current = null;\n }\n // A self-dismissal — Escape, an outside click, or an item selection —\n // takes an enclosing menubar out of menu-mode. Switching menus,\n // clearing the open menu on hover, and focus changes pass\n // keepMenubarEngaged to stay in menu-mode.\n if (menubar && dropdownElement && !options?.keepMenubarEngaged) {\n menubar.notifyClosed(dropdownElement);\n }\n };\n\n // The pointer entered the trigger or (if open) the body: cancel any\n // pending close and, if props.openOnHover and not already open, open now\n const handleDropdownMouseEnter = () => {\n clearHoverCloseTimer();\n if (!openOnHover || isOpenRef.current) return;\n setIsOpen(true);\n setIsOpening(false);\n };\n\n // The pointer left the trigger and body entirely: if open, arm the\n // close-intent timer (a re-entry before it fires cancels it above, so\n // crossing the trigger/body gap doesn’t flicker)\n const handleDropdownMouseLeave = () => {\n if (!openOnHover || !isOpenRef.current || hoverCloseTimerRef.current != null) {\n return;\n }\n hoverCloseTimerRef.current = setTimeout(() => {\n hoverCloseTimerRef.current = null;\n closeDropdown();\n }, HOVER_CLOSE_DELAY);\n };\n\n const focusTrigger = () => {\n const firstChild = dropdownElement?.firstElementChild as MaybeHTMLElement;\n if (!firstChild) return;\n const focusable = firstChild.matches(FOCUSABLE_SELECTOR)\n ? firstChild\n : (firstChild.querySelector(FOCUSABLE_SELECTOR) as MaybeHTMLElement);\n focusable?.focus();\n };\n\n // Register with an enclosing Menubar (one open menu at a time, ←/→\n // moves between menus, hover-to-switch once any menu is open). Closing\n // goes through closeDropdown so pending timers (submenu disclosure,\n // close delay) can’t fire against a menu the menubar already closed.\n useEffect(() => {\n if (!menubar || !dropdownElement) return;\n return menubar.registerMember({\n close: () => closeDropdown({ keepMenubarEngaged: true }),\n element: dropdownElement,\n focusTrigger,\n isOpen: () => isOpenRef.current,\n open: () => setIsOpen(true),\n });\n });\n\n useEffect(() => {\n if (isOpen && menubar && dropdownElement) {\n menubar.notifyOpened(dropdownElement);\n }\n }, [dropdownElement, isOpen, menubar]);\n\n const handleSubmitItem = (event: Event | React.SyntheticEvent<HTMLElement>) => {\n const element = hasItemsRef.current\n ? getActiveItemElement(dropdownElement)\n : null;\n\n const submenuOfActive = element ? getSubmenuOfItem(element) : null;\n if (element && submenuOfActive) {\n // Parent items disclose; they never submit\n clearDisclosureTimer();\n expandItem(element, handleToggleSubmenu);\n if (currentInputMethodRef.current === 'keyboard' && dropdownElement) {\n const firstItem = getItemElements(dropdownElement, submenuOfActive)?.[0];\n if (firstItem) {\n setActiveItem({\n dropdownElement,\n element: firstItem,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n }\n return;\n }\n\n if (isOpenRef.current && !keepOpenOnSubmitRef.current) {\n // A short timeout before closing is better UX when user selects an item so dropdown\n // doesn’t close before expected. It also enables using <Link />s in the dropdown body.\n closingTimerRef.current = setTimeout(closeDropdown, 90);\n }\n\n if (!hasItemsRef.current) return;\n\n if (!element) {\n // With nothing selected, the only possible value comes from a text\n // input (a searchable dropdown’s input, or one inside a custom\n // trigger). No input means there’s no value to submit at all, so\n // bail regardless of allowCreate/allowEmpty instead of firing an\n // empty-valued onSubmitItem consumers have to defend against. (To\n // let such a dropdown clear its value, give it an explicit\n // empty-valued item, which submits as a normal active selection.)\n if (!inputElementRef.current) return;\n if (inputElementRef.current.value) {\n // Non-empty text matching no item is a created value\n if (!allowCreateRef.current) return;\n } else if (!allowEmptyRef.current) {\n // A cleared input is an empty (clearing) submit, which\n // allowEmpty gates even when allowCreate is set — “creating”\n // an empty value is clearing, not creating\n return;\n }\n }\n\n let itemLabel = element?.innerText ?? '';\n if (inputElementRef.current) {\n if (!element) {\n itemLabel = inputElementRef.current.value;\n } else {\n inputElementRef.current.value = itemLabel;\n }\n\n if (\n inputElementRef.current ===\n inputElementRef.current.ownerDocument.activeElement\n ) {\n inputElementRef.current.blur();\n }\n }\n\n const nextValue = element?.dataset.uktValue ?? itemLabel;\n // If parent is controlling Dropdown via props.value and nextValue is the same, do nothing\n if (valueRef.current && valueRef.current === nextValue) return;\n\n // If the item is clickable or contains exactly one clickable element, invoke it\n // (but only if the event didn’t already originate from that element)\n if (element) {\n const eventTarget = event.target as HTMLElement;\n\n if (element.matches(CLICKABLE_SELECTOR)) {\n // The item element itself is clickable (e.g., <button data-ukt-value=\"…\">)\n if (element !== eventTarget && !element.contains(eventTarget)) {\n element.click();\n }\n } else {\n // Check if item contains exactly one clickable child element\n const clickableElements = element.querySelectorAll(CLICKABLE_SELECTOR);\n if (clickableElements.length === 1) {\n const clickableElement = clickableElements[0] as HTMLElement;\n if (\n clickableElement !== eventTarget &&\n !clickableElement.contains(eventTarget)\n ) {\n clickableElement.click();\n }\n }\n }\n }\n\n const payload: Item = {\n element,\n event,\n label: itemLabel,\n path: getItemPath(element),\n value: nextValue,\n };\n onSubmitItemRef.current?.(payload);\n dispatchToSubmenus('onSubmitItem', payload);\n };\n\n const handleMouseMove = (event: ReactMouseEvent<HTMLElement>) => {\n const { clientX, clientY } = event;\n currentInputMethodRef.current = 'mouse';\n trackSafeArea(event);\n const initialPosition = mouseDownPositionRef.current;\n if (!initialPosition) return;\n if (\n Math.abs(initialPosition.clientX - clientX) < 12 &&\n Math.abs(initialPosition.clientY - clientY) < 12\n ) {\n return;\n }\n setIsOpening(false);\n };\n\n const handleMouseOver = (event: ReactMouseEvent<HTMLElement>) => {\n if (!hasItemsRef.current) return;\n\n // If user isn’t currently using the mouse to navigate the dropdown, do nothing\n if (currentInputMethodRef.current !== 'mouse') return;\n\n // Ensure we have the dropdown root HTMLElement\n if (!dropdownElement) return;\n\n const eventTarget = event.target as HTMLElement;\n if (!eventTarget.closest('.uktdropdown-body')) return;\n\n // Hover inside an open nested dropdown belongs to that dropdown\n const hoveredRoot = eventTarget.closest('.uktdropdown');\n if (\n hoveredRoot !== dropdownElement &&\n hoveredRoot?.classList.contains('is-open')\n ) {\n return;\n }\n\n // Heading toward an open submenu: keep it open even over sibling items\n if (isPointerInSafeArea(event.clientX, event.clientY)) return;\n\n const item = getItemForTarget(dropdownElement, eventTarget);\n if (!item) return;\n\n setActiveItem({\n dropdownElement,\n element: item,\n event,\n onActiveItem: handleActiveItem,\n });\n syncSubmenuDisclosure();\n };\n\n const handleMouseOut = (event: ReactMouseEvent<HTMLElement>) => {\n if (!hasItemsRef.current) return;\n // The pointer left the dropdown entirely: drop the safe area so its\n // give-up timer can’t later fire on a stale position, and fall through\n // to the normal collapse (mousemove has stopped, so nothing else will)\n const relatedTarget = event.relatedTarget as Node | null;\n const isLeavingDropdown = !dropdownElement?.contains(relatedTarget);\n if (isLeavingDropdown) {\n clearSafeAreaTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n }\n // Heading toward an open submenu: don’t clear the active item / collapse\n if (isPointerInSafeArea(event.clientX, event.clientY)) return;\n const activeItem = getActiveItemElement(dropdownElement);\n if (!activeItem) return;\n const eventRelatedTarget = event.relatedTarget as HTMLElement;\n if (activeItem !== event.target || activeItem.contains(eventRelatedTarget)) {\n return;\n }\n // If user moused out of activeItem (not into a descendant), it’s no longer active\n delete activeItem.dataset.uktActive;\n syncSubmenuDisclosure();\n };\n\n const handleMouseDown = (event: ReactMouseEvent<HTMLElement>) => {\n if (onMouseDown) onMouseDown(event);\n if (isOpenRef.current) return;\n\n setIsOpen(true);\n setIsOpening(true);\n mouseDownPositionRef.current = {\n clientX: event.clientX,\n clientY: event.clientY,\n };\n isOpeningTimerRef.current = setTimeout(() => {\n setIsOpening(false);\n isOpeningTimerRef.current = null;\n }, 1000);\n };\n\n const handleMouseUp = (event: ReactMouseEvent<HTMLElement>) => {\n if (onMouseUp) onMouseUp(event);\n // If dropdown is still opening or isn’t open or is closing, do nothing\n if (\n isOpeningRef.current ||\n !isOpenRef.current ||\n closingTimerRef.current != null\n ) {\n return;\n }\n\n const eventTarget = event.target as HTMLElement;\n\n // Clicks inside an open nested dropdown belong to that dropdown\n const clickedRoot = eventTarget.closest('.uktdropdown');\n if (\n clickedRoot !== dropdownElement &&\n clickedRoot?.classList.contains('is-open') &&\n dropdownElement?.contains(clickedRoot)\n ) {\n return;\n }\n\n // A click only counts as inside the body if the closest body element\n // belongs to this dropdown (a nested dropdown’s trigger sits inside\n // the outer body, but the outer body isn’t the nested one’s own)\n const targetBody = eventTarget.closest('.uktdropdown-body');\n const isInOwnBody = Boolean(\n targetBody && targetBody.closest('.uktdropdown') === dropdownElement,\n );\n // If click was outside dropdown body, don’t trigger submit\n if (!isInOwnBody) {\n // Don’t close dropdown if isOpening or search input is focused\n if (\n !isOpeningRef.current &&\n inputElementRef.current !== eventTarget.ownerDocument.activeElement\n ) {\n closeDropdown();\n }\n return;\n }\n\n // If dropdown has no items and click was within dropdown body, do nothing\n if (!hasItemsRef.current) return;\n\n if (dropdownElement) {\n const clickedItem = getItemForTarget(dropdownElement, eventTarget);\n if (clickedItem) {\n // Submit the item the click actually landed on: sync the\n // active item to it in case they diverge (e.g. active was\n // set via keyboard, then user clicked elsewhere)\n setActiveItem({\n dropdownElement,\n element: clickedItem,\n event,\n onActiveItem: handleActiveItem,\n });\n } else if (getActiveItemElement(dropdownElement)) {\n // A click that doesn’t land on an item — body padding, a\n // separator, or a disabled item (pointer-events: none\n // retargets its clicks to the container) — must not submit\n // the previously active item: like macOS, it does nothing.\n // With no active item it falls through, so a body click\n // can still submit an input-sourced value\n return;\n }\n }\n\n handleSubmitItem(event);\n };\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const { altKey, ctrlKey, key, metaKey } = event;\n const eventTarget = event.target as HTMLElement;\n if (!dropdownElement) return;\n\n const onEventHandled = () => {\n event.stopPropagation();\n event.preventDefault();\n currentInputMethodRef.current = 'keyboard';\n };\n\n const isEventTargetingDropdown = dropdownElement.contains(eventTarget);\n\n // Key events originating inside an open nested dropdown are that\n // dropdown’s business (e.g. an info popover nested in this body)\n const nestedRoot = eventTarget.closest?.('.uktdropdown');\n if (\n nestedRoot &&\n nestedRoot !== dropdownElement &&\n dropdownElement.contains(nestedRoot) &&\n nestedRoot.classList.contains('is-open')\n ) {\n return;\n }\n\n if (!isOpenRef.current) {\n // If dropdown is closed, don’t handle key events if event target isn’t within dropdown\n if (!isEventTargetingDropdown) return;\n // Open the dropdown on spacebar, enter, or if isSearchable and user hits the ↑/↓ arrows\n if (\n key === ' ' ||\n key === 'Enter' ||\n (hasItemsRef.current && (key === 'ArrowUp' || key === 'ArrowDown'))\n ) {\n onEventHandled();\n setIsOpen(true);\n }\n return;\n }\n\n const isTargetUsingKeyEvents = isEventTargetUsingKeyEvent(event);\n\n // If dropdown isOpen + hasItems & eventTargetNotUsingKeyEvents, handle characters\n if (hasItemsRef.current && !isTargetUsingKeyEvents) {\n let isEditingCharacters = !ctrlKey && !metaKey && /^[A-Za-z0-9]$/.test(key);\n // User could also be editing characters if there are already characters entered\n // and they are hitting delete or spacebar\n if (!isEditingCharacters && enteredCharactersRef.current) {\n isEditingCharacters = key === ' ' || key === 'Backspace';\n }\n\n if (isEditingCharacters) {\n onEventHandled();\n if (key === 'Backspace') {\n enteredCharactersRef.current = enteredCharactersRef.current.slice(\n 0,\n -1,\n );\n } else {\n enteredCharactersRef.current += key;\n }\n\n setActiveItem({\n dropdownElement,\n event,\n // If props.allowCreate, only override the input’s value with an\n // exact text match so user can enter a value not in items\n isExactMatch: allowCreateRef.current,\n onActiveItem: handleActiveItem,\n text: enteredCharactersRef.current,\n });\n syncSubmenuDisclosure();\n\n if (clearEnteredCharactersTimerRef.current != null) {\n clearTimeout(clearEnteredCharactersTimerRef.current);\n }\n\n clearEnteredCharactersTimerRef.current = setTimeout(() => {\n enteredCharactersRef.current = '';\n clearEnteredCharactersTimerRef.current = null;\n }, 1500);\n\n return;\n }\n }\n\n // If dropdown isOpen, handle submitting the value\n if (key === 'Enter' || (key === ' ' && !inputElementRef.current)) {\n onEventHandled();\n handleSubmitItem(event);\n return;\n }\n\n // If dropdown isOpen, handle closing it on escape or spacebar if !hasItems\n if (\n key === 'Escape' ||\n (isEventTargetingDropdown && key === ' ' && !hasItemsRef.current)\n ) {\n // Close dropdown if hasItems or event target not using key events\n if (hasItemsRef.current || !isTargetUsingKeyEvents) {\n // Escape closes the whole menu — submenus included — and\n // returns focus to the element that opened it. Focus before\n // closing: a searchable trigger input opens the dropdown on\n // focus, so its synchronous onFocus must land before the\n // close state update for the close to win the batch\n focusTrigger();\n closeDropdown();\n }\n return;\n }\n\n // Handle arrow keys\n if (hasItemsRef.current) {\n if (key === 'ArrowUp') {\n onEventHandled();\n if (altKey || metaKey) {\n setActiveItem({\n dropdownElement,\n event,\n index: 0,\n onActiveItem: handleActiveItem,\n });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: -1,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n return;\n }\n if (key === 'ArrowDown') {\n onEventHandled();\n if (altKey || metaKey) {\n // Using a negative index counts back from the end\n setActiveItem({\n dropdownElement,\n event,\n index: -1,\n onActiveItem: handleActiveItem,\n });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: 1,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n return;\n }\n // ←/→ dive into and surface out of submenus (and move between\n // menus in a menubar); leave them alone when a text input has focus\n if (!isTargetUsingKeyEvents) {\n if (key === 'ArrowRight') {\n const activeElement = getActiveItemElement(dropdownElement);\n const submenu = activeElement\n ? getSubmenuOfItem(activeElement)\n : null;\n if (activeElement && submenu) {\n onEventHandled();\n clearDisclosureTimer();\n expandItem(activeElement, handleToggleSubmenu);\n const firstItem = getItemElements(dropdownElement, submenu)?.[0];\n if (firstItem) {\n setActiveItem({\n dropdownElement,\n element: firstItem,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n return;\n }\n if (menubar) {\n onEventHandled();\n menubar.moveOpen(dropdownElement, 1);\n }\n return;\n }\n if (key === 'ArrowLeft') {\n const activeElement = getActiveItemElement(dropdownElement);\n const levelRoot = activeElement ? getLevelRoot(activeElement) : null;\n if (levelRoot) {\n onEventHandled();\n clearDisclosureTimer();\n const parentItem = getParentItem(levelRoot);\n if (parentItem) {\n collapseItem(parentItem, handleToggleSubmenu);\n }\n return;\n }\n if (menubar) {\n onEventHandled();\n menubar.moveOpen(dropdownElement, -1);\n }\n return;\n }\n }\n }\n };\n\n useKeyboardEvents({ ignoreUsedKeyboardEvents: false, onKeyDown: handleKeyDown });\n\n const handleRef = (ref: HTMLDivElement | null): (() => void) | void => {\n setDropdownElement(ref);\n if (!ref) return;\n\n const { ownerDocument } = ref;\n let inputElement = inputElementRef.current;\n // Check if trigger is a textual input or textarea element\n if (!inputElement && ref.firstElementChild) {\n if (ref.firstElementChild.matches(TEXT_INPUT_SELECTOR)) {\n inputElement = ref.firstElementChild as HTMLInputElement;\n } else {\n inputElement = ref.firstElementChild.querySelector(TEXT_INPUT_SELECTOR);\n }\n inputElementRef.current = inputElement;\n }\n\n const handleGlobalMouseDown = ({ target }: MouseEvent) => {\n const eventTarget = target as HTMLElement;\n if (!ref.contains(eventTarget)) {\n // Close dropdown on an outside click\n closeDropdown();\n }\n };\n\n const handleGlobalMouseUp = ({ target }: MouseEvent) => {\n if (!isOpenRef.current || closingTimerRef.current != null) return;\n\n // If still isOpening (gets set false 1s after open triggers), set it to false onMouseUp\n if (isOpeningRef.current) {\n setIsOpening(false);\n if (isOpeningTimerRef.current != null) {\n clearTimeout(isOpeningTimerRef.current);\n isOpeningTimerRef.current = null;\n }\n return;\n }\n\n const eventTarget = target as HTMLElement;\n // Only handle mouseup events from outside the dropdown here\n if (!ref.contains(eventTarget)) {\n closeDropdown();\n }\n };\n\n // Close dropdown if any element is focused outside of this dropdown\n const handleGlobalFocusIn = ({ target }: Event) => {\n if (!isOpenRef.current) return;\n\n const eventTarget = target as HTMLElement;\n // If focused element is a descendant or a parent of the dropdown, do nothing\n if (ref.contains(eventTarget) || eventTarget.contains(ref)) {\n return;\n }\n\n // Losing focus — including the focus shift when the body unmounts\n // on close — doesn’t end a menubar’s menu-mode; that takes a\n // deliberate dismissal (Escape, outside click, item select).\n closeDropdown({ keepMenubarEngaged: true });\n };\n\n document.addEventListener('focusin', handleGlobalFocusIn);\n document.addEventListener('mousedown', handleGlobalMouseDown);\n document.addEventListener('mouseup', handleGlobalMouseUp);\n\n if (ownerDocument !== document) {\n ownerDocument.addEventListener('focusin', handleGlobalFocusIn);\n ownerDocument.addEventListener('mousedown', handleGlobalMouseDown);\n ownerDocument.addEventListener('mouseup', handleGlobalMouseUp);\n }\n\n // If dropdown should be open on mount, focus it\n if (isOpenOnMount) {\n ref.focus();\n }\n\n const handleInput = (event: Event) => {\n if (!isOpenRef.current) setIsOpen(true);\n\n const input = event.target as HTMLInputElement;\n const isDeleting = enteredCharactersRef.current.length > input.value.length;\n enteredCharactersRef.current = input.value;\n // When deleting text, if there’s already an active item and\n // input isn’t empty, preserve the active item, else update it\n if (isDeleting && input.value.length && getActiveItemElement(ref)) {\n return;\n }\n\n setActiveItem({\n dropdownElement: ref,\n event,\n // If props.allowCreate, only override the input’s value with an\n // exact text match so user can enter a value not in items\n isExactMatch: allowCreateRef.current,\n onActiveItem: handleActiveItem,\n text: enteredCharactersRef.current,\n });\n };\n\n if (inputElement) {\n inputElement.addEventListener('input', handleInput);\n }\n\n return () => {\n document.removeEventListener('focusin', handleGlobalFocusIn);\n document.removeEventListener('mousedown', handleGlobalMouseDown);\n document.removeEventListener('mouseup', handleGlobalMouseUp);\n\n if (ownerDocument !== document) {\n ownerDocument.removeEventListener('focusin', handleGlobalFocusIn);\n ownerDocument.removeEventListener('mousedown', handleGlobalMouseDown);\n ownerDocument.removeEventListener('mouseup', handleGlobalMouseUp);\n }\n\n if (inputElement) {\n inputElement.removeEventListener('input', handleInput);\n }\n };\n };\n\n // When the body mounts (open): fill in parent-item/submenu ARIA, and\n // render it in the top layer via popover so an ancestor’s transform /\n // filter / contain can’t become the containing block for the fixed body\n // and break its anchor positioning + fallbacks. popover=\"manual\" keeps\n // dismissal under this component’s own listeners (see handleRef), which\n // preserves iframe support and searchable/text-input triggers that native\n // light-dismiss would close on any outside pointerdown.\n const handleBodyRef = (ref: HTMLDivElement | null) => {\n if (!ref) return;\n annotateParentItems(ref);\n // The Popover API is Baseline 2024, so showPopover() needs no feature\n // detection; the body is mounted only while open, so this runs once\n // per open and won’t throw on an already-open body.\n ref.showPopover();\n };\n\n if (!isValidElement(trigger)) {\n if (isSearchable) {\n trigger = (\n <input\n aria-controls={bodyId}\n aria-expanded={isOpen}\n aria-haspopup={popupRole}\n autoComplete=\"off\"\n className=\"uktdropdown-trigger\"\n defaultValue={value ?? ''}\n disabled={disabled}\n name={name}\n onFocus={() => setIsOpen(true)}\n placeholder={placeholder}\n ref={inputElementRef}\n tabIndex={tabIndex}\n type=\"text\"\n />\n );\n } else {\n trigger = (\n <button\n aria-controls={bodyId}\n aria-expanded={isOpen}\n aria-haspopup={popupRole}\n className=\"uktdropdown-trigger\"\n tabIndex={0}\n type=\"button\"\n >\n {trigger}\n </button>\n );\n }\n } else {\n // For a consumer-provided trigger, add ARIA props (letting the consumer\n // override by specifying their own).\n const triggerProps = trigger.props as Record<string, unknown>;\n trigger = cloneElement(trigger as ReactElement<Record<string, unknown>>, {\n 'aria-controls': triggerProps['aria-controls'] ?? bodyId,\n 'aria-expanded': triggerProps['aria-expanded'] ?? isOpen,\n 'aria-haspopup': triggerProps['aria-haspopup'] ?? popupRole,\n });\n }\n\n if (label != null) {\n trigger = (\n <label className=\"uktdropdown-label\">\n <div className=\"uktdropdown-label-text\">{label}</div>\n {trigger}\n </label>\n );\n }\n\n return (\n <Fragment>\n <style href=\"@acusti/dropdown/Dropdown\" precedence=\"medium\">\n {styles}\n </style>\n <div\n className={clsx('uktdropdown', className, {\n disabled,\n 'is-open': isOpen,\n 'is-searchable': isSearchable,\n })}\n onClick={onClick}\n onMouseDown={handleMouseDown}\n onMouseEnter={handleDropdownMouseEnter}\n onMouseLeave={handleDropdownMouseLeave}\n onMouseMove={handleMouseMove}\n onMouseOut={handleMouseOut}\n onMouseOver={handleMouseOver}\n onMouseUp={handleMouseUp}\n ref={handleRef}\n style={styleFromProps}\n >\n {trigger}\n {/* TODO next version of Dropdown should use <Activity> for body https://react.dev/reference/react/Activity */}\n {isOpen ? (\n <div\n className={clsx('uktdropdown-body', {\n 'has-items': hasItems,\n })}\n id={bodyId}\n popover=\"manual\"\n ref={handleBodyRef}\n role={popupRole}\n >\n <div className=\"uktdropdown-content\">\n <DropdownContext.Provider\n value={hasItems ? dropdownContextValue : null}\n >\n {childrenCount > 1\n ? (children as ChildrenTuple)[1]\n : children}\n </DropdownContext.Provider>\n </div>\n </div>\n ) : null}\n </div>\n </Fragment>\n );\n}\n\nconst INERT_SUBMENU_PROPS = [\n 'allowCreate',\n 'allowEmpty',\n 'isOpenOnMount',\n 'isSearchable',\n 'keepOpenOnSubmit',\n 'name',\n 'openOnHover',\n 'placeholder',\n 'tabIndex',\n 'value',\n] as const;\n\n// The nested (submenu) rendering of Dropdown: a parent item that discloses a\n// child menu. It renders the data-ukt-submenu protocol and registers with the\n// root dropdown, whose engine handles all interaction.\nfunction SubmenuDropdown(props: Props & { parentDropdown: DropdownContextValue }) {\n const {\n children,\n className,\n disabled,\n label,\n onActiveItem,\n onClose,\n onOpen,\n onSubmitItem,\n parentDropdown,\n style,\n } = props;\n\n const itemRef = useRef<HTMLLIElement | null>(null);\n\n useEffect(() => {\n const element = itemRef.current;\n if (!element) return;\n return parentDropdown.registerSubmenu({\n element,\n onActiveItem,\n onClose,\n onOpen,\n onSubmitItem,\n });\n }, [onActiveItem, onClose, onOpen, onSubmitItem, parentDropdown]);\n\n // Misuse feedback is unconditional, like the children-count error above\n const warnedRef = useRef(false);\n useEffect(() => {\n if (warnedRef.current) return;\n const inertProps = INERT_SUBMENU_PROPS.filter(\n (propName) => props[propName] !== undefined,\n );\n if (!inertProps.length) return;\n warnedRef.current = true;\n console.error(\n `@acusti/dropdown: ${inertProps.join(', ')} only apply to a top-level Dropdown and are ignored on a nested (submenu) Dropdown.`,\n );\n });\n\n const childrenCount = Children.count(children);\n let labelContent: ReactNode = label;\n let body: ReactNode = children;\n if (childrenCount > 1) {\n labelContent = (children as ChildrenTuple)[0];\n body = (children as ChildrenTuple)[1];\n }\n\n const submenu = isValidElement(body) ? (\n cloneElement(body as ReactElement<Record<string, unknown>>, {\n 'data-ukt-submenu': '',\n })\n ) : (\n <div data-ukt-submenu=\"\">{body}</div>\n );\n\n return (\n <li\n aria-disabled={disabled || undefined}\n className={className}\n data-ukt-item=\"\"\n ref={itemRef}\n style={style}\n >\n {labelContent}\n {submenu}\n </li>\n );\n}\n\nexport { default as Menubar, type MenubarProps } from './Menubar.js';\n"],"mappings":";;;;;;;AAkBA,IAAaa,kBAAkBb,cAA2C,IAAI;AAiB9E,IAAa2B,iBAAiB3B,cAA0C,IAAI;;;;;;AE9B5E,IAAa+B,gBAAgB;AAC7B,IAAaC,mBAAmB;AAEhC,IAAMC,yBAAyB;AAM/B,IAAMM,kBAAkBC,oBACnBA,iBAAiBC,cAAc,mBAAmB,KAAK;AAI5D,IAAaC,gBAAgBC,YACzBA,QAAQC,QAAQZ,gBAAgB;AAGpC,IAAaa,oBAAoBV,SAAwC;CACrE,MAAMW,UAAUX,KAAKM,cAAcT,gBAAgB;CACnD,IAAI,CAACc,SAAS,OAAO;CAErB,OADcA,QAAQE,eAAeJ,QAAAA,mCAAqB,MACzCT,OAAOW,UAAU;AACtC;AAGA,IAAaG,iBAAiBC,cACzBA,UAAUF,eAAeJ,QAAAA,mCAAqB,KAAK;AAGxD,IAAaO,gBAAgBhB,SAA8B;CACvD,IAAI,CAACU,iBAAiBV,IAAI,GAAG,OAAOA,KAAKiB,aAAa;CACtD,MAAMC,QAAQlB,KAAKmB,UAAU,IAAI;CACjC,KAAK,MAAMR,WAAWS,MAAMC,KAAKH,MAAMI,iBAAiBzB,gBAAgB,CAAC,GACrEc,QAAQY,OAAO;CAEnB,QAAQL,MAAMM,eAAe,GAAA,CAAIC,KAAK;AAC1C;AAGA,IAAaC,eAAelB,YAA4C;CACpE,MAAMmB,OAAqB,CAAA;CAC3B,IAAI,CAACnB,SAAS,OAAOmB;CACrB,IAAIZ,YAAYR,aAAaC,OAAO;CACpC,OAAOO,WAAW;EACd,MAAMa,aAAad,cAAcC,SAAS;EAC1C,IAAI,CAACa,YA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AA8BnU;CAC9B,IAAAoU,OAAsB5T;CACtB,IAAI+C,gBAAgB,GAAC;EACjB4Q,eAAgB3T,SAAyB;EACzC4T,OAAQ5T,SAAyB;CAA7B;CACP,IAAA4C;CAAA,IAAAP,EAAA,OAAAuR,MAAA;EAEehR,KAAA3F,eAAe2W,IAM/B,IALI9W,aAAa8W,MAA+C,EAAA,oBACpC,GACxB,CAGJ,IADI,oBAAA,OAAA;GAAsB,oBAAA;aAAIA;EAAW,CAAA;EACxCvR,EAAA,KAAAuR;EAAAvR,EAAA,MAAAO;CAAA,OAAAA,KAAAP,EAAA;CAND,MAAAuF,UAAgBhF;CAUO,MAAA2B,KAAApE,YAAA2C,KAAAA;CAAqB,IAAA8C;CAAA,IAAAvD,EAAA,QAAAnC,aAAAmC,EAAA,QAAAsR,gBAAAtR,EAAA,QAAAlB,SAAAkB,EAAA,QAAAuF,WAAAvF,EAAA,QAAAkC,IAAA;EADxCqB,KAAA,qBAAA,MAAA;GACmB,iBAAArB;GACJrE;GACG,iBAAA;GACTmT,KAAAA;GACElS;aALX,CAOKwS,cACA/L,OACA;;EAAAvF,EAAA,MAAAnC;EAAAmC,EAAA,MAAAsR;EAAAtR,EAAA,MAAAlB;EAAAkB,EAAA,MAAAuF;EAAAvF,EAAA,MAAAkC;EAAAlC,EAAA,MAAAuD;CAAA,OAAAA,KAAAvD,EAAA;CAAA,OATLuD;AASK"}
1
+ {"version":3,"file":"Dropdown.js","names":["createContext","Item","DropdownContextValue","registerSubmenu","registration","SubmenuRegistration","element","HTMLElement","onActiveItem","payload","onClose","onOpen","onSubmitItem","DropdownContext","MenubarContextValue","moveOpen","fromElement","direction","notifyClosed","notifyOpened","registerMember","member","MenubarMember","close","focusTrigger","isOpen","open","MenubarContext","getBestMatch","Children","isValidElement","ReactNode","SyntheticEvent","Item","ITEM_SELECTOR","SUBMENU_SELECTOR","DISABLED_ITEM_SELECTOR","OnToggleSubmenu","item","HTMLElement","isExpanded","MaybeHTMLElement","getBodyElement","dropdownElement","querySelector","getLevelRoot","element","closest","getSubmenuOfItem","submenu","owner","parentElement","getParentItem","levelRoot","getItemLabel","innerText","clone","cloneNode","Array","from","querySelectorAll","remove","textContent","trim","getNodeText","node","text","forEach","child","childProps","props","children","undefined","getLabelFromChildren","value","label","visit","uktValue","String","replace","getItemPath","path","parentItem","unshift","dataset","getItemElements","bodyElement","root","candidates","length","filter","matches","items","HTMLCollection","getItemForTarget","target","targetLevelRoot","contains","itemElements","find","itemElement","getActiveItemElements","actives","getActiveItemElement","getDeepestExpandedItem","expanded","isItemExpanded","getAttribute","submenuIdCounter","ensureSubmenuARIA","hasAttribute","setAttribute","id","annotateParentItems","annotateItemRoles","popupRole","list","isMenuItem","expandItem","onToggleSubmenu","collapseItem","expandedDescendants","descendant","active","uktActive","collapseItemsOutsidePath","expandedItems","reverse","clearItemElementsState","setActiveChain","chain","Set","add","has","BaseSetActiveItemPayload","event","Event","index","indexAddend","isExactMatch","onActiveItem","payload","setActiveItem","Omit","currentDeepest","lastIndex","currentActiveIndex","findIndex","nextActiveIndex","Math","max","min","itemTexts","map","textToCompare","toLowerCase","itemText","startsWith","bestMatch","nextActiveItem","scrollableParent","isScrollable","scrollHeight","clientHeight","parentRect","getBoundingClientRect","itemRect","isAboveTop","top","isBelowBottom","bottom","scrollTop","Point","x","y","isPointInTriangle","p","a","b","c","cross","u","v","w","d1","d2","d3","hasNegative","hasPositive","clsx","CSSProperties","FocusEvent","ReactFocusEvent","KeyboardEvent","ReactKeyboardEvent","MouseEvent","ReactMouseEvent","ReactNode","useMemo","useRef","MenubarContext","MenubarContextValue","MenubarMember","MenubarProps","children","className","style","compareDocumentOrder","a","b","element","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","NON_MENU_CONTROL_SELECTOR","Menubar","t0","$","_c","t1","Symbol","for","Set","membersRef","engagedMemberRef","t2","Array","from","current","sort","getOrderedMembersRef","getOrderedMembers","t3","moveOpen","fromElement","direction","members","length","index","findIndex","member","nextIndex","close","open","focusTrigger","notifyClosed","notifyOpened","element_0","member_0","isOpen","registerMember","member_1","add","delete","contextValue","t4","event","key","members_0","some","_temp","eventTarget","target","HTMLElement","index_0","member_3","contains","preventDefault","stopPropagation","direction_0","handleKeyDown","t5","eventTarget_0","members_1","m","member_4","find","m_0","closest","openMember","switchToMemberAt","t6","event_0","handleFocus","t7","event_1","handleMouseOver","t8","t9","t10","member_2","useKeyboardEvents","isEventTargetUsingKeyEvent","clsx","Children","cloneElement","CSSProperties","Fragment","isValidElement","MouseEvent","ReactMouseEvent","ReactElement","ReactNode","SyntheticEvent","useContext","useEffect","useId","useMemo","useRef","useState","DropdownContext","DropdownContextValue","MenubarContext","SubmenuRegistration","styles","annotateItemRoles","annotateParentItems","collapseItem","collapseItemsOutsidePath","expandItem","getActiveItemElement","getDeepestExpandedItem","getItemElements","getItemForTarget","getItemPath","getLabelFromChildren","getLevelRoot","getParentItem","getSubmenuOfItem","isItemExpanded","isPointInTriangle","Point","setActiveItem","Item","element","MaybeHTMLElement","event","Event","HTMLElement","label","path","Array","ItemValue","value","Props","allowCreate","allowEmpty","children","ChildrenTuple","className","disabled","hasItems","isOpenOnMount","isSearchable","keepOpenOnSubmit","name","onActiveItem","payload","onClick","onClose","onMouseDown","onMouseUp","onOpen","onSubmitItem","openOnHover","placeholder","style","Record","tabIndex","MousePosition","clientX","clientY","TimeoutID","ReturnType","setTimeout","CHILDREN_ERROR","CLICKABLE_SELECTOR","FOCUSABLE_SELECTOR","TEXT_INPUT_SELECTOR","SUBMENU_DISCLOSURE_DELAY","SAFE_AREA_TIMEOUT","HOVER_CLOSE_DELAY","Dropdown","props","$","_c","parentDropdown","t0","RootDropdown","t1","t2","t3","styleFromProps","undefined","childrenCount","count","Error","console","error","trigger","body","valueIdentity","t4","valueLabel","isOpen","setIsOpen","isOpening","setIsOpening","dropdownElement","setDropdownElement","bodyId","popupRole","menubar","inputElementRef","consumerOwnsARIASelectedRef","t5","Symbol","for","WeakSet","annotatedBodiesRef","closingTimerRef","isOpeningTimerRef","currentInputMethodRef","clearEnteredCharactersTimerRef","enteredCharactersRef","mouseDownPositionRef","disclosureTimerRef","pendingDisclosureItemRef","t6","Set","submenuRegistrationsRef","pointerRef","lastMouseEventRef","safeAreaRef","safeAreaTimerRef","wasInSafeAreaRef","hoverCloseTimerRef","allowCreateRef","allowEmptyRef","hasItemsRef","isOpenRef","isOpeningRef","keepOpenOnSubmitRef","onCloseRef","onOpenRef","onSubmitItemRef","valueRef","t7","t8","current","isMountedRef","t10","t9","t11","registerSubmenu","registration","add","delete","dropdownContextValue","t12","key","registration_0","contains","dispatchToSubmenus","t13","payload_0","handleActiveItem","t14","item","isExpanded","submenu","isShown","matches","showPopover","hidePopover","registration_1","handleToggleSubmenu","t15","clearTimeout","clearDisclosureTimer","t16","t17","t18","activeElement","submenu_0","hasAttribute","syncSubmenuDisclosure","t19","clearSafeAreaTimer","t20","t21","t22","x","y","safeArea","parent","submenu_1","submenuRect","getBoundingClientRect","parentRect","nearX","left","right","apex","top","bottom","isPointerInSafeArea","t23","targetElement","pointer","target","ownerDocument","elementFromPoint","item_0","commitPointerTarget","t24","event_0","pointer_0","nativeEvent","target_0","submenu_2","isOverParent","trackSafeArea","t25","clearHoverCloseTimer","t26","t27","t28","options","keepMenubarEngaged","notifyClosed","closeDropdown","t29","handleDropdownMouseEnter","t30","handleDropdownMouseLeave","t31","firstElementChild","firstChild","focusable","querySelector","focus","focusTrigger","t32","registerMember","close","open","t33","t34","notifyOpened","t35","event_1","submenuOfActive","firstItem","itemLabel","innerText","blur","nextValue","dataset","uktValue","bodyElement","closest","selected","from","querySelectorAll","removeAttribute","setAttribute","eventTarget","click","clickableElements","length","clickableElement","payload_1","handleSubmitItem","t36","event_2","initialPosition","Math","abs","handleMouseMove","t37","event_3","eventTarget_0","hoveredRoot","classList","item_1","handleMouseOver","t38","event_4","relatedTarget","Node","isLeavingDropdown","activeItem","eventRelatedTarget","uktActive","handleMouseOut","t39","event_5","handleMouseDown","t40","event_6","eventTarget_1","clickedRoot","targetBody","isInOwnBody","Boolean","clickedItem","handleMouseUp","t41","event_7","altKey","ctrlKey","key_0","metaKey","eventTarget_2","onEventHandled","stopPropagation","preventDefault","isEventTargetingDropdown","nestedRoot","isTargetUsingKeyEvents","isEditingCharacters","test","slice","isExactMatch","text","index","indexAddend","activeElement_0","submenu_3","firstItem_0","moveOpen","activeElement_1","levelRoot","parentItem","handleKeyDown","t42","ignoreUsedKeyboardEvents","onKeyDown","t43","ref","inputElement","HTMLInputElement","handleGlobalMouseDown","t44","target_1","eventTarget_3","handleGlobalMouseUp","t45","target_2","eventTarget_4","handleGlobalFocusIn","t46","target_3","eventTarget_5","document","addEventListener","handleInput","event_8","input","isDeleting","removeEventListener","handleRef","ref_0","has","selectedItem","find","item_2","handleBodyRef","t47","triggerProps","t48","t49","INERT_SUBMENU_PROPS","const","SubmenuDropdown","itemRef","warnedRef","inertProps","filter","propName","join","labelContent","popover","default","Menubar","MenubarProps"],"sources":["../src/context.ts","../src/Dropdown.css?inline","../src/helpers.ts","../src/Menubar.tsx","../src/Dropdown.tsx"],"sourcesContent":["import { createContext } from 'react';\n\nimport { type Item } from './Dropdown.js';\n\nexport type DropdownContextValue = {\n registerSubmenu: (registration: SubmenuRegistration) => () => void;\n};\n\nexport type SubmenuRegistration = {\n element: HTMLElement;\n onActiveItem?: (payload: Item) => void;\n onClose?: () => unknown;\n onOpen?: () => unknown;\n onSubmitItem?: (payload: Item) => void;\n};\n\n// Provided by a menu Dropdown; a Dropdown that finds this context renders as a\n// submenu (parent item + data-ukt-submenu) instead of a root dropdown.\nexport const DropdownContext = createContext<DropdownContextValue | null>(null);\n\nexport type MenubarContextValue = {\n moveOpen: (fromElement: HTMLElement, direction: -1 | 1) => void;\n notifyClosed: (element: HTMLElement) => void;\n notifyOpened: (element: HTMLElement) => void;\n registerMember: (member: MenubarMember) => () => void;\n};\n\nexport type MenubarMember = {\n close: () => void;\n element: HTMLElement;\n focusTrigger: () => void;\n isOpen: () => boolean;\n open: () => void;\n};\n\nexport const MenubarContext = createContext<MenubarContextValue | null>(null);\n",":root {\n --uktdd-font-family:\n system-ui, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue,\n Helvetica, Arial, sans-serif;\n --uktdd-body-bg-color: #fff;\n --uktdd-body-bg-color-hover: rgb(105, 162, 249);\n --uktdd-body-color-hover: #fff;\n /* the persistent tint on the item matching props.value (the current\n selection), shown even after the active/hover highlight moves off it */\n --uktdd-body-bg-color-selected: rgba(0, 0, 0, 0.06);\n --uktdd-body-buffer: 10px;\n --uktdd-body-max-height: calc(100dvh - var(--uktdd-body-buffer));\n --uktdd-body-max-width: calc(100dvw - var(--uktdd-body-buffer));\n --uktdd-body-min-height: 30px;\n --uktdd-body-pad-bottom: 0.5em;\n --uktdd-body-pad-left: 0.6875em;\n --uktdd-body-pad-right: 0.6875em;\n --uktdd-body-pad-top: 0.5em;\n --uktdd-body-min-width: min(50px, 100%);\n --uktdd-body-position-area: block-end span-inline-end;\n --uktdd-body-position-try-fallbacks:\n --uktdd-top-start, --uktdd-bottom-end, --uktdd-top-end;\n /* gap between the trigger and the body, applied as a symmetric\n margin-block so it lands on whichever side the body attaches to and\n auto-reverses when position-try flips it above/below the trigger. A\n margin establishes no containing block, so it’s safe on dropdowns with\n submenus */\n --uktdd-body-gap: 0px;\n --uktdd-body-color: canvastext;\n --uktdd-body-bg-color-path: #dcdcdc;\n --uktdd-body-color-path: currentColor;\n --uktdd-label-pad-right: 0.625em;\n --uktdd-submenu-position-area: inline-end span-block-end;\n --uktdd-submenu-position-try-fallbacks: --uktdd-submenu-inline-start;\n /* like --uktdd-body-gap but on the inline axis, since submenus open to\n the side; auto-reverses when they flip to the opposite inline edge */\n --uktdd-submenu-gap: 0px;\n --uktdd-menubar-trigger-bg-color-active: rgba(0, 0, 0, 0.12);\n}\n\n.uktdropdown,\n.uktdropdown-trigger {\n font-family: var(--uktdd-font-family);\n}\n\n.uktdropdown {\n width: max-content;\n anchor-scope: --uktdd-anchor;\n\n &.disabled {\n pointer-events: none;\n }\n\n > * {\n cursor: default;\n }\n\n > :first-child {\n anchor-name: --uktdd-anchor;\n }\n}\n\n.uktdropdown-label {\n display: flex;\n align-items: center;\n}\n\n.uktdropdown-label-text {\n padding-right: var(--uktdd-label-pad-right);\n}\n\n.uktdropdown-body {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n position: fixed;\n position-anchor: --uktdd-anchor;\n position-area: var(--uktdd-body-position-area);\n /* the primary placement wins whenever the body fits there, then the\n author’s fallbacks are tried in order (no position-try-order:\n most-height, which would override a fitting primary with whichever\n side of the viewport happens to be taller). The trailing --uktdd-fill\n options are the last resort when the body fits at its natural size in\n none of the author’s placements: --uktdd-fill sizes the body to the\n block-axis space it has and lets the content region scroll, so a body\n taller than the space never overflows or covers the trigger. The four\n ordered variants keep the body as close to the primary placement as\n possible — same side first, flipping inline alignment only to escape a\n horizontal-overflow rejection, and flipping to the opposite block side\n only when the preferred side is under --uktdd-body-min-height. Since\n --uktdd-fill clamps the block size, it can only be rejected for\n horizontal overflow (→ flip-inline) or a too-short side (→ flip-block),\n and these four cover every combination */\n position-try-fallbacks:\n var(--uktdd-body-position-try-fallbacks),\n --uktdd-fill,\n --uktdd-fill flip-inline,\n --uktdd-fill flip-block,\n --uktdd-fill flip-block flip-inline;\n min-block-size: min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));\n /* no 100% clamp: a placement is only accepted when the body’s natural\n size fits it, so squeezing is reserved for the --uktdd-fill options */\n max-block-size: var(--uktdd-body-max-height);\n min-inline-size: min(var(--uktdd-body-min-width), var(--uktdd-body-max-width));\n max-inline-size: var(--uktdd-body-max-width);\n inline-size: max-content;\n overflow: hidden;\n /* the body renders in the top layer via popover=\"manual\" so an ancestor’s\n transform / filter / contain can’t become its containing block, and the\n top layer handles stacking (no z-index). The UA-popover box resets that\n must beat a consumer’s global [popover] styles live in the\n div.uktdropdown-body rule below; these cosmetics stay overridable */\n color: inherit;\n background-color: var(--uktdd-body-bg-color);\n box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);\n\n &.has-items {\n user-select: none;\n }\n\n [aria-selected=\"true\"] {\n background-color: var(--uktdd-body-bg-color-selected);\n }\n\n [data-ukt-active] {\n background-color: var(--uktdd-body-bg-color-hover);\n color: var(--uktdd-body-color-hover);\n }\n\n /* an active item is on the path — not deepest — while a deeper highlight\n exists or the pointer is inside its submenu; macOS mutes the parent\n even when the pointer is over a separator or disabled submenu item */\n [data-ukt-active]:has([data-ukt-submenu] [data-ukt-active]),\n [data-ukt-active]:has([data-ukt-submenu]:hover) {\n background-color: var(--uktdd-body-bg-color-path);\n color: var(--uktdd-body-color-path);\n }\n\n [data-ukt-item][aria-disabled=\"true\"] {\n opacity: 0.5;\n pointer-events: none;\n }\n\n /* the expanded parent item anchors its submenu; anchor-scope keeps each\n level’s submenu bound to its own parent item */\n [data-ukt-item] {\n anchor-scope: --uktdd-submenu-anchor;\n }\n\n /* parent items get a macOS-style disclosure chevron, right-aligned */\n :is([data-ukt-item], [data-ukt-value])[aria-haspopup=\"menu\"] {\n position: relative;\n padding-inline-end: 2em;\n\n &::after {\n content: \"\";\n position: absolute;\n inset-inline-end: 0.9em;\n inset-block-start: 50%;\n inline-size: 0.3em;\n block-size: 0.3em;\n border-block-start: 0.14em solid currentColor;\n border-inline-end: 0.14em solid currentColor;\n translate: 0 -50%;\n rotate: 45deg;\n }\n\n &:dir(rtl)::after {\n rotate: -45deg;\n }\n }\n\n /* the expanded item anchors its submenu; its disclosure is driven by the\n submenu’s popover open state (showPopover on expand), not a display\n toggle here */\n [data-ukt-item][aria-expanded=\"true\"] {\n anchor-name: --uktdd-submenu-anchor;\n }\n\n /* the submenu renders in the top layer via popover=\"manual\", like the\n body, so no ancestor — including the body’s own popover box — can\n become the containing block for the fixed submenu and clip or shift its\n anchor placement. (Safari shifts a position-area box back inside its\n containing block on both axes, which pulled the submenu in over its\n parent menu when the body was that containing block.) The popover\n attribute plus its UA `:not(:popover-open)` rule handle hide-when-\n collapsed, so there’s no display toggle; showPopover/hidePopover track\n the item’s expanded state. The UA-popover box reset (inset/border) lives\n here — the selector already outweighs a bare [popover] on specificity —\n while the cosmetics stay overridable. */\n\n /* Until popover=\"manual\" is applied — SubmenuDropdown sets it on render,\n ensureSubmenuARIA adds it when the body opens — a submenu has no UA\n :not(:popover-open) rule to hide it. Keep it hidden here so raw\n data-ukt-submenu markup inserted into an already-open body (annotated\n only on the next open) doesn’t flash visible and uncontrolled. Once the\n attribute is present this stops matching, leaving visibility to the\n popover open state (no author display to fight :popover-open). */\n [data-ukt-submenu]:not([popover]) {\n display: none;\n }\n\n [data-ukt-submenu] {\n box-sizing: border-box;\n inset: auto;\n border: 0;\n block-size: auto;\n /* an explicit color so items don’t inherit the white highlight color\n from their active parent item (the submenu is its DOM child) */\n color: var(--uktdd-body-color);\n position: fixed;\n position-anchor: --uktdd-submenu-anchor;\n position-area: var(--uktdd-submenu-position-area);\n /* same strict-fit + fill-last-resort model as the body (see the\n .uktdropdown-body rule): a too-tall submenu sizes to its block-axis\n space and scrolls instead of clipping past the viewport edge, and\n the four --uktdd-fill variants keep it as near the primary\n placement as possible before flipping inline or block */\n position-try-fallbacks:\n var(--uktdd-submenu-position-try-fallbacks),\n --uktdd-fill,\n --uktdd-fill flip-inline,\n --uktdd-fill flip-block,\n --uktdd-fill flip-block flip-inline;\n z-index: 2;\n margin-block: 0;\n margin-inline: var(--uktdd-submenu-gap);\n /* the shared --uktdd-fill subtracts --uktdd-body-gap to keep the body’s\n block-axis margins inside the fill region; a submenu’s block margins\n are 0 (its gap is inline), so zero it here to avoid shortening a\n filled submenu when a consumer sets a body gap */\n --uktdd-body-gap: 0;\n padding: var(--uktdd-body-pad-top) var(--uktdd-body-pad-right)\n var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);\n inline-size: max-content;\n max-inline-size: var(--uktdd-body-max-width);\n min-block-size: min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));\n max-block-size: var(--uktdd-body-max-height);\n overflow: auto;\n overscroll-behavior: contain;\n list-style: none;\n background-color: var(--uktdd-body-bg-color);\n box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);\n }\n}\n\n/* The body is a popover, so a consumer’s global [popover] rules match it and\n tie .uktdropdown-body on specificity (both 0,1,0), letting source order\n decide — which can clobber the body’s box geometry. Reset the UA-popover box\n at div.uktdropdown-body (0,1,1): the lightest bump that still beats a bare\n [popover] (0,1,0), so the layout holds regardless of a consumer’s popover\n styles, while the body’s cosmetics stay overridable at 0,1,0. */\ndiv.uktdropdown-body {\n inset: auto;\n block-size: auto;\n margin-block: var(--uktdd-body-gap);\n margin-inline: 0;\n border: 0;\n padding: 0;\n}\n\n.uktmenubar {\n display: flex;\n align-items: stretch;\n width: max-content;\n font-family: var(--uktdd-font-family);\n\n /* the open menu’s trigger reads as active, like the highlighted item in\n the macOS menu bar; the default tints over whatever background the\n trigger already has, so it works regardless of how it’s styled */\n .uktdropdown.is-open .uktdropdown-trigger {\n box-shadow: inset 0 0 0 100vmax var(--uktdd-menubar-trigger-bg-color-active);\n }\n}\n\n.uktdropdown-content {\n box-sizing: border-box;\n min-block-size: 0;\n overflow: auto;\n overscroll-behavior: contain;\n padding: var(--uktdd-body-pad-top) var(--uktdd-body-pad-right)\n var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);\n}\n\n/* Named for the aligned edge (start/end), not the direction the body\n extends toward — e.g. top-start opens above the trigger with their\n inline-start edges flush, and the body can extend past the trigger’s\n inline-end edge. Both axes use logical keywords (block-start/-end,\n span-inline-start/-end rather than top/bottom, span-left/-right):\n position-area doesn’t allow mixing a physical keyword on one axis with a\n logical one on the other, and logical keeps the alignment correct in\n RTL. block-start/block-end read as top/bottom in the near-universal\n horizontal-tb writing mode. */\n@position-try --uktdd-top-start {\n position-area: block-start span-inline-end;\n}\n\n@position-try --uktdd-bottom-start {\n position-area: block-end span-inline-end;\n}\n\n@position-try --uktdd-bottom-end {\n position-area: block-end span-inline-start;\n}\n\n@position-try --uktdd-top-end {\n position-area: block-start span-inline-start;\n}\n\n@position-try --uktdd-submenu-inline-start {\n position-area: inline-start span-block-end;\n}\n\n/* The last-resort option appended after the author’s fallback list (for\n both the body and submenus). It sets no position-area, so it inherits\n the element’s primary placement — or its block-flipped mirror when\n applied as `--uktdd-fill flip-block` — and sizes the element to that\n side’s available space so the content scrolls. block-size must be a\n definite length here, not a max-block-size clamp on the auto size:\n position-try only accepts an option when the box it lays out fits, and\n an auto-sized box is evaluated at its natural (unclamped) size, so a\n clamp that would make it fit still reads as overflowing and the option\n is never selected. 100% is the space on the attached side; subtracting\n the symmetric --uktdd-body-gap margins keeps the margin box inside it.\n The base max-block-size also still applies, capping the fill at\n --uktdd-body-max-height, as does min-block-size, so a side shorter than\n --uktdd-body-min-height is rejected as unusable and the flipped side is\n tried instead. (No max-content clamp against stretching past the natural\n size: intrinsic keywords hit the same natural-size evaluation quirk when\n set inside @position-try, which would reject the option outright. The\n stretch can only surface when the author’s fallbacks skip the flipped\n block placement entirely and the preferred side is under\n --uktdd-body-min-height — vanishingly rare with the recipes this\n package documents.) */\n@position-try --uktdd-fill {\n block-size: calc(100% - var(--uktdd-body-gap) * 2);\n}\n","import { getBestMatch } from '@acusti/matchmaking';\nimport { Children, isValidElement, type ReactNode, type SyntheticEvent } from 'react';\n\nimport { type Item } from './Dropdown.js';\n\nexport const ITEM_SELECTOR = '[data-ukt-item], [data-ukt-value]';\nexport const SUBMENU_SELECTOR = '[data-ukt-submenu]';\n\nconst DISABLED_ITEM_SELECTOR = '[aria-disabled=\"true\"]';\n\nexport type OnToggleSubmenu = (item: HTMLElement, isExpanded: boolean) => void;\n\ntype MaybeHTMLElement = HTMLElement | null;\n\nconst getBodyElement = (dropdownElement: MaybeHTMLElement) =>\n (dropdownElement?.querySelector('.uktdropdown-body') ?? null) as MaybeHTMLElement;\n\n// The level root that owns an item: the closest [data-ukt-submenu] ancestor,\n// or null for items at the top level of the dropdown body\nexport const getLevelRoot = (element: HTMLElement) =>\n element.closest(SUBMENU_SELECTOR) as MaybeHTMLElement;\n\n// An item’s own submenu (a parent item), excluding submenus of descendant items\nexport const getSubmenuOfItem = (item: HTMLElement): MaybeHTMLElement => {\n const submenu = item.querySelector(SUBMENU_SELECTOR) as MaybeHTMLElement;\n if (!submenu) return null;\n const owner = submenu.parentElement?.closest(ITEM_SELECTOR);\n return owner === item ? submenu : null;\n};\n\n// The parent item that owns a submenu level\nexport const getParentItem = (levelRoot: HTMLElement) =>\n (levelRoot.parentElement?.closest(ITEM_SELECTOR) ?? null) as MaybeHTMLElement;\n\n// A parent item’s label is its text content excluding the submenu subtree\nexport const getItemLabel = (item: HTMLElement): string => {\n if (!getSubmenuOfItem(item)) return item.innerText ?? '';\n const clone = item.cloneNode(true) as HTMLElement;\n for (const submenu of Array.from(clone.querySelectorAll(SUBMENU_SELECTOR))) {\n submenu.remove();\n }\n return (clone.textContent ?? '').trim();\n};\n\n// Concatenate the text (string/number leaves) of a React node, approximating\n// the rendered innerText the dropdown uses as an item’s label. Submenu\n// subtrees are excluded, matching getItemLabel (and innerText, which omits\n// the collapsed — hidden — submenu), so a parent item’s derived label agrees\n// with its select-time label.\nconst getNodeText = (node: ReactNode): string => {\n let text = '';\n Children.forEach(node, (child) => {\n if (typeof child === 'string' || typeof child === 'number') {\n text += child;\n } else if (isValidElement(child)) {\n const childProps = child.props as {\n children?: ReactNode;\n 'data-ukt-submenu'?: unknown;\n };\n if (childProps['data-ukt-submenu'] !== undefined) return;\n text += getNodeText(childProps.children);\n }\n });\n return text;\n};\n\n// Find the item in `children` whose data-ukt-value matches `value` and return\n// its text as the label, so a bare identifier value shows the matching item’s\n// label without a separate options/label lookup. Returns undefined if no item\n// matches (the caller then falls back to the identifier itself). A\n// { label, value } value overrides this when the derived text isn’t right.\nexport const getLabelFromChildren = (\n children: ReactNode,\n value: string,\n): string | undefined => {\n let label: string | undefined;\n const visit = (node: ReactNode) => {\n if (label != null) return;\n Children.forEach(node, (child) => {\n if (label != null || !isValidElement(child)) return;\n const childProps = child.props as {\n children?: ReactNode;\n 'data-ukt-value'?: unknown;\n };\n const uktValue = childProps['data-ukt-value'];\n // Compare as strings: the DOM stringifies dataset values, so\n // data-ukt-value={400} matches value=\"400\" when selected and\n // must also match here.\n if (uktValue != null && String(uktValue) === value) {\n label = getNodeText(childProps.children).replace(/\\s+/g, ' ').trim();\n return;\n }\n visit(childProps.children);\n });\n };\n visit(children);\n return label;\n};\n\n// Ancestor parent items from the root level down to the element’s immediate parent\nexport const getItemPath = (element: MaybeHTMLElement): Item['path'] => {\n const path: Item['path'] = [];\n if (!element) return path;\n let levelRoot = getLevelRoot(element);\n while (levelRoot) {\n const parentItem = getParentItem(levelRoot);\n if (!parentItem) break;\n const label = getItemLabel(parentItem);\n path.unshift({ label, value: parentItem.dataset.uktValue ?? label });\n levelRoot = getLevelRoot(parentItem);\n }\n return path;\n};\n\nexport const getItemElements = (\n dropdownElement: MaybeHTMLElement,\n levelRoot?: MaybeHTMLElement,\n): Array<HTMLElement> | null => {\n const bodyElement = getBodyElement(dropdownElement);\n if (!bodyElement) return null;\n\n const root = levelRoot ?? bodyElement;\n const candidates = Array.from(\n root.querySelectorAll(ITEM_SELECTOR),\n ) as Array<HTMLElement>;\n\n if (candidates.length) {\n return candidates.filter((item) => {\n if (item.matches(DISABLED_ITEM_SELECTOR)) return false;\n return getLevelRoot(item) === (levelRoot ?? null);\n });\n }\n\n // If no items found via [data-ukt-item] or [data-ukt-value] selector,\n // use first instance of multiple children found — flat bodies and flat\n // submenu levels alike\n let items: HTMLCollection = root.children;\n while (items.length === 1) {\n if (items[0].children == null) break;\n items = items[0].children;\n }\n // If unable to find an element with more than one child, treat direct child as items\n if (items.length === 1) {\n items = root.children;\n }\n return (Array.from(items) as Array<HTMLElement>).filter(\n (item) => !item.matches(DISABLED_ITEM_SELECTOR),\n );\n};\n\n// The item an event target belongs to within its own level: the closest\n// marked item, or — when the target sits in a level with no marked items\n// (a heuristically-detected level) — the target itself if it’s one of that\n// level’s detected items. Misses (body padding, separators) and disabled\n// items resolve to null.\nexport const getItemForTarget = (\n dropdownElement: HTMLElement,\n target: HTMLElement,\n): MaybeHTMLElement => {\n let item = target.closest(ITEM_SELECTOR) as MaybeHTMLElement;\n // If nothing matched, or the target sits in a deeper level than the\n // matched item (an unmarked, heuristically-detected submenu level),\n // resolve the item within the target’s own level instead\n const targetLevelRoot = getLevelRoot(target);\n if (!item || (targetLevelRoot && item.contains(targetLevelRoot))) {\n const itemElements = getItemElements(dropdownElement, targetLevelRoot);\n item = itemElements?.find((itemElement) => itemElement === target) ?? item;\n }\n if (!item || !dropdownElement.contains(item)) return null;\n if (item.matches(DISABLED_ITEM_SELECTOR)) return null;\n return item;\n};\n\n// All active items, in document order (ancestors before descendants)\nexport const getActiveItemElements = (dropdownElement: MaybeHTMLElement) => {\n if (!dropdownElement) return null;\n const actives = dropdownElement.querySelectorAll('[data-ukt-active]');\n return actives.length ? (Array.from(actives) as Array<HTMLElement>) : null;\n};\n\n// The deepest active item — the one keyboard input operates on\nexport const getActiveItemElement = (dropdownElement: MaybeHTMLElement) => {\n const actives = getActiveItemElements(dropdownElement);\n return actives ? actives[actives.length - 1] : null;\n};\n\n// The deepest expanded parent item — the one whose submenu is the innermost\n// open one — in document order\nexport const getDeepestExpandedItem = (\n dropdownElement: MaybeHTMLElement,\n): MaybeHTMLElement => {\n if (!dropdownElement) return null;\n const expanded = (\n Array.from(\n dropdownElement.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((element) => element.matches(ITEM_SELECTOR));\n return expanded.length ? expanded[expanded.length - 1] : null;\n};\n\nexport const isItemExpanded = (item: HTMLElement) =>\n item.getAttribute('aria-expanded') === 'true';\n\nlet submenuIdCounter = 0;\n\nconst ensureSubmenuARIA = (item: HTMLElement, submenu: HTMLElement) => {\n if (!submenu.hasAttribute('role')) submenu.setAttribute('role', 'menu');\n if (!submenu.id) submenu.id = `uktdd-submenu-${++submenuIdCounter}`;\n // Normalize the submenu to a manual popover for consumers who author raw\n // data-ukt-submenu markup (SubmenuDropdown already sets it); a bare or auto\n // popover would light-dismiss and desync from the engine’s show/hidePopover.\n if (submenu.getAttribute('popover') !== 'manual') {\n submenu.setAttribute('popover', 'manual');\n }\n if (!item.hasAttribute('aria-haspopup')) item.setAttribute('aria-haspopup', 'menu');\n if (!item.hasAttribute('aria-expanded')) item.setAttribute('aria-expanded', 'false');\n if (!item.hasAttribute('aria-controls')) {\n item.setAttribute('aria-controls', submenu.id);\n }\n};\n\n// Fill in submenu/parent-item ARIA (only what the consumer hasn’t set)\nexport const annotateParentItems = (bodyElement: MaybeHTMLElement) => {\n if (!bodyElement) return;\n for (const submenu of Array.from(bodyElement.querySelectorAll(SUBMENU_SELECTOR))) {\n const item = getParentItem(submenu as HTMLElement);\n if (item) ensureSubmenuARIA(item, submenu as HTMLElement);\n }\n};\n\n// Fill in the item roles the consumer hasn’t set: options in a searchable\n// (listbox) dropdown, menuitems in a menu — and always menuitems inside a\n// submenu, which is itself a menu (annotateParentItems gives it role=\"menu\").\n// The <ul>/<ol> wrappers around the items get role=\"presentation\" so their\n// implicit list role doesn’t sit between the listbox/menu and its items; a\n// submenu already carries role=\"menu\", so its own role is left intact.\nexport const annotateItemRoles = (\n bodyElement: MaybeHTMLElement,\n popupRole: 'listbox' | 'menu',\n) => {\n if (!bodyElement) return;\n for (const list of Array.from(bodyElement.querySelectorAll('ul, ol'))) {\n if (!list.hasAttribute('role') && list.querySelector(ITEM_SELECTOR)) {\n list.setAttribute('role', 'presentation');\n }\n }\n for (const item of Array.from(\n bodyElement.querySelectorAll(ITEM_SELECTOR),\n ) as Array<HTMLElement>) {\n // Leave a consumer-set role, and a natively interactive item’s own role\n // (a button/link/input item keeps its element semantics), alone.\n if (\n item.hasAttribute('role') ||\n item.matches('a[href], button, input, select, textarea')\n ) {\n continue;\n }\n const isMenuItem = popupRole === 'menu' || getLevelRoot(item) != null;\n // A top-level parent item in a listbox would pair role=\"option\" with\n // the aria-haspopup/aria-expanded that annotateParentItems gives it —\n // invalid ARIA (an option can’t disclose a popup), and no valid role\n // exists for a submenu parent inside a listbox, so leave its role to\n // the consumer. (In a menu, menuitem is correct for parents.)\n if (!isMenuItem && getSubmenuOfItem(item)) continue;\n item.setAttribute('role', isMenuItem ? 'menuitem' : 'option');\n }\n};\n\nexport const expandItem = (item: HTMLElement, onToggleSubmenu?: OnToggleSubmenu) => {\n const submenu = getSubmenuOfItem(item);\n if (!submenu) return;\n ensureSubmenuARIA(item, submenu);\n if (isItemExpanded(item)) return;\n item.setAttribute('aria-expanded', 'true');\n onToggleSubmenu?.(item, true);\n};\n\nexport const collapseItem = (item: HTMLElement, onToggleSubmenu?: OnToggleSubmenu) => {\n if (!isItemExpanded(item)) return;\n const submenu = getSubmenuOfItem(item);\n if (submenu) {\n // Collapse any expanded descendants first so their state can’t leak\n // into the next disclosure and their onClose callbacks fire\n // (recursion makes the collapse order deepest-first)\n const expandedDescendants = (\n Array.from(\n submenu.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((descendant) => descendant.matches(ITEM_SELECTOR));\n for (const descendant of expandedDescendants) {\n collapseItem(descendant, onToggleSubmenu);\n }\n for (const active of Array.from(submenu.querySelectorAll('[data-ukt-active]'))) {\n delete (active as HTMLElement).dataset.uktActive;\n }\n }\n item.setAttribute('aria-expanded', 'false');\n onToggleSubmenu?.(item, false);\n};\n\n// Collapse every expanded parent item that isn’t an ancestor of element\n// (element == null collapses all), deepest-first\nexport const collapseItemsOutsidePath = (\n dropdownElement: MaybeHTMLElement,\n element: MaybeHTMLElement,\n onToggleSubmenu?: OnToggleSubmenu,\n) => {\n const bodyElement = getBodyElement(dropdownElement);\n if (!bodyElement) return;\n const expandedItems = (\n Array.from(\n bodyElement.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((item) => item.matches(ITEM_SELECTOR));\n for (const item of expandedItems.reverse()) {\n if (element && item.contains(element)) continue;\n collapseItem(item, onToggleSubmenu);\n }\n};\n\nconst clearItemElementsState = (itemElements: Array<HTMLElement>) => {\n itemElements.forEach((itemElement) => {\n if (itemElement.hasAttribute('data-ukt-active')) {\n delete itemElement.dataset.uktActive;\n }\n // Also clear active state in any deeper levels within this item\n for (const active of Array.from(\n itemElement.querySelectorAll('[data-ukt-active]'),\n )) {\n delete (active as HTMLElement).dataset.uktActive;\n }\n });\n};\n\n// Make the active set exactly the chain of element + its ancestor parent items\nconst setActiveChain = (dropdownElement: HTMLElement, element: HTMLElement) => {\n const chain = new Set<HTMLElement>([element]);\n let levelRoot = getLevelRoot(element);\n while (levelRoot) {\n const parentItem = getParentItem(levelRoot);\n if (!parentItem) break;\n chain.add(parentItem);\n levelRoot = getLevelRoot(parentItem);\n }\n for (const active of getActiveItemElements(dropdownElement) ?? []) {\n if (!chain.has(active)) delete active.dataset.uktActive;\n }\n for (const item of chain) {\n item.setAttribute('data-ukt-active', '');\n }\n};\n\ntype BaseSetActiveItemPayload = {\n dropdownElement: HTMLElement;\n element?: null;\n // Optional so an item can be activated programmatically (e.g. revealing the\n // current value on open); it’s only used to build the onActiveItem payload,\n // which is skipped when there’s no event to report.\n event?: Event | SyntheticEvent<HTMLElement>;\n index?: null;\n indexAddend?: null;\n isExactMatch?: null;\n onActiveItem?: (payload: Item) => void;\n text?: null;\n};\n\nexport const setActiveItem = ({\n dropdownElement,\n element,\n event,\n index,\n indexAddend,\n isExactMatch,\n onActiveItem,\n text,\n}:\n | ({\n element: HTMLElement;\n } & Omit<BaseSetActiveItemPayload, 'element'>)\n | ({\n index: number;\n } & Omit<BaseSetActiveItemPayload, 'index'>)\n | ({\n indexAddend: number;\n } & Omit<BaseSetActiveItemPayload, 'indexAddend'>)\n | ({\n isExactMatch?: boolean;\n text: string;\n } & Omit<BaseSetActiveItemPayload, 'isExactMatch' | 'text'>)): MaybeHTMLElement => {\n const currentDeepest = getActiveItemElement(dropdownElement);\n // Keys and text operate on the current level (the level of the deepest\n // active item); activating an element directly targets its own level\n const levelRoot = element\n ? getLevelRoot(element)\n : currentDeepest\n ? getLevelRoot(currentDeepest)\n : null;\n\n const itemElements = getItemElements(dropdownElement, levelRoot);\n if (!itemElements || itemElements.length === 0) return currentDeepest;\n\n const lastIndex = itemElements.length - 1;\n const currentActiveIndex = itemElements.findIndex(\n (itemElement) => itemElement === currentDeepest,\n );\n\n let nextActiveIndex = currentActiveIndex;\n if (typeof index === 'number') {\n // Negative index means count back from the end\n nextActiveIndex = index < 0 ? itemElements.length + index : index;\n }\n\n if (element) {\n nextActiveIndex = itemElements.findIndex(\n (itemElement) => itemElement === element,\n );\n if (nextActiveIndex === -1) return currentDeepest;\n } else if (typeof indexAddend === 'number') {\n // If there’s no currentActiveIndex and we are handling -1, start at lastIndex\n if (currentActiveIndex === -1 && indexAddend === -1) {\n nextActiveIndex = lastIndex;\n } else {\n nextActiveIndex += indexAddend;\n }\n // Keep it within the bounds of the items list\n nextActiveIndex = Math.max(0, Math.min(nextActiveIndex, lastIndex));\n } else if (typeof text === 'string') {\n // If text is empty, clear existing active items and early return\n if (!text) {\n clearItemElementsState(itemElements);\n return null;\n }\n\n const itemTexts = itemElements.map(getItemLabel);\n if (isExactMatch) {\n const textToCompare = text.toLowerCase();\n nextActiveIndex = itemTexts.findIndex((itemText) =>\n itemText.toLowerCase().startsWith(textToCompare),\n );\n // If isExactMatch is required and no exact match was found, clear active items\n if (nextActiveIndex === -1) {\n clearItemElementsState(itemElements);\n }\n } else {\n const bestMatch = getBestMatch({ items: itemTexts, text });\n nextActiveIndex = itemTexts.findIndex((itemText) => itemText === bestMatch);\n }\n }\n\n const nextActiveItem = itemElements[nextActiveIndex] as MaybeHTMLElement;\n if (nextActiveItem == null || nextActiveItem === currentDeepest) {\n return currentDeepest;\n }\n\n setActiveChain(dropdownElement, nextActiveItem);\n // A programmatic activation (no event) still moves the highlight and scrolls\n // the item into view, but has no event to report to onActiveItem.\n if (event) {\n const label = getItemLabel(nextActiveItem);\n onActiveItem?.({\n element: nextActiveItem,\n event,\n label,\n path: getItemPath(nextActiveItem),\n value: nextActiveItem.dataset.uktValue ?? label,\n });\n }\n // Find closest scrollable parent and ensure that next active item is visible\n let { parentElement } = nextActiveItem;\n let scrollableParent = null;\n while (!scrollableParent && parentElement && parentElement !== dropdownElement) {\n const isScrollable = parentElement.scrollHeight > parentElement.clientHeight + 15;\n if (isScrollable) {\n scrollableParent = parentElement;\n } else {\n parentElement = parentElement.parentElement;\n }\n }\n\n if (scrollableParent) {\n const parentRect = scrollableParent.getBoundingClientRect();\n const itemRect = nextActiveItem.getBoundingClientRect();\n const isAboveTop = itemRect.top < parentRect.top;\n const isBelowBottom = itemRect.bottom > parentRect.bottom;\n if (isAboveTop || isBelowBottom) {\n let { scrollTop } = scrollableParent;\n // Item isn’t fully visible; adjust scrollTop to put item within closest edge\n if (isAboveTop) {\n scrollTop -= parentRect.top - itemRect.top;\n } else {\n scrollTop += itemRect.bottom - parentRect.bottom;\n }\n scrollableParent.scrollTop = scrollTop;\n }\n }\n\n return nextActiveItem;\n};\n\nexport type Point = { x: number; y: number };\n\n// Whether a point is inside (or on an edge of) triangle a-b-c, from the sign\n// of the cross product for each edge: all the same sign ⇒ inside\nexport const isPointInTriangle = (p: Point, a: Point, b: Point, c: Point): boolean => {\n const cross = (u: Point, v: Point, w: Point) =>\n (u.x - w.x) * (v.y - w.y) - (v.x - w.x) * (u.y - w.y);\n const d1 = cross(p, a, b);\n const d2 = cross(p, b, c);\n const d3 = cross(p, c, a);\n const hasNegative = d1 < 0 || d2 < 0 || d3 < 0;\n const hasPositive = d1 > 0 || d2 > 0 || d3 > 0;\n return !(hasNegative && hasPositive);\n};\n","import clsx from 'clsx';\nimport {\n type CSSProperties,\n type FocusEvent as ReactFocusEvent,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n useMemo,\n useRef,\n} from 'react';\n\nimport {\n MenubarContext,\n type MenubarContextValue,\n type MenubarMember,\n} from './context.js';\n\nexport type MenubarProps = {\n children: ReactNode;\n className?: string;\n style?: CSSProperties;\n};\n\nconst compareDocumentOrder = (a: MenubarMember, b: MenubarMember) => {\n if (a.element === b.element) return 0;\n const position = a.element.compareDocumentPosition(b.element);\n if ((position & Node.DOCUMENT_POSITION_FOLLOWING) !== 0) return -1;\n if ((position & Node.DOCUMENT_POSITION_PRECEDING) !== 0) return 1;\n return 0;\n};\n\n// Matches interactive controls that live in the menubar without being dropdown\n// triggers (e.g. a plain button). Hovering one clears the open menu without\n// disengaging the menubar.\nconst NON_MENU_CONTROL_SELECTOR = 'a[href], button, input, select, textarea, [tabindex]';\n\n// Combines sibling Dropdowns into a single menu, like the system menu in the\n// top toolbar of macOS: one menu open at a time, ←/→ move between menus, and\n// once any menu is open, hovering or focusing another trigger switches to it.\nexport default function Menubar({ children, className, style }: MenubarProps) {\n const membersRef = useRef<Set<MenubarMember>>(new Set());\n // The member that engaged the bar (menu-mode). It keeps pointing at that\n // member even if that member’s menu was closed by hovering a non-menu\n // control, which allows the bar to stay engaged even with nothing open.\n const engagedMemberRef = useRef<HTMLElement | null>(null);\n\n const getOrderedMembersRef = useRef(() =>\n Array.from(membersRef.current).sort(compareDocumentOrder),\n );\n const getOrderedMembers = getOrderedMembersRef.current;\n\n const contextValue: MenubarContextValue = useMemo(\n () => ({\n moveOpen(fromElement: HTMLElement, direction: -1 | 1) {\n const members = getOrderedMembersRef.current();\n if (members.length < 2) return;\n const index = members.findIndex(\n (member) => member.element === fromElement,\n );\n if (index === -1) return;\n const nextIndex = (index + direction + members.length) % members.length;\n members[index].close();\n members[nextIndex].open();\n members[nextIndex].focusTrigger();\n },\n notifyClosed(element: HTMLElement) {\n // Only a dismissal of the member that engaged the bar ends\n // menu-mode. Outside-click handling closes every mounted\n // dropdown, so ignore the closes reported for the rest.\n if (engagedMemberRef.current === element) {\n engagedMemberRef.current = null;\n }\n },\n notifyOpened(element: HTMLElement) {\n engagedMemberRef.current = element;\n for (const member of membersRef.current) {\n if (member.element !== element && member.isOpen()) {\n member.close();\n }\n }\n },\n registerMember(member: MenubarMember) {\n membersRef.current.add(member);\n return () => {\n membersRef.current.delete(member);\n };\n },\n }),\n [],\n );\n\n // Rove focus between triggers with ←/→ while no menu is open (the open\n // dropdown’s own key handling slides the open menu between triggers)\n const handleKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n const { key } = event;\n if (key !== 'ArrowLeft' && key !== 'ArrowRight') return;\n const members = getOrderedMembers();\n if (members.length < 2) return;\n if (members.some((member) => member.isOpen())) return;\n const eventTarget = event.target as HTMLElement;\n const index = members.findIndex((member) => member.element.contains(eventTarget));\n if (index === -1) return;\n event.preventDefault();\n event.stopPropagation();\n const direction = key === 'ArrowRight' ? 1 : -1;\n members[(index + direction + members.length) % members.length].focusTrigger();\n };\n\n // Once the bar is engaged, moving hover or focus onto another member’s\n // trigger switches to it (opening notifies the menubar, which closes the\n // other open member), while moving onto a non-menu control clears the open\n // menu but keeps the bar engaged.\n const switchToMemberAt = (eventTarget: HTMLElement) => {\n if (engagedMemberRef.current == null) return;\n const members = getOrderedMembers();\n // If the member that engaged the bar is gone (e.g. it unmounted while\n // engaged) the bar is no longer engaged, so hover can’t reopen menus\n if (!members.some((m) => m.element === engagedMemberRef.current)) {\n engagedMemberRef.current = null;\n return;\n }\n const member = members.find((m) => m.element.contains(eventTarget));\n if (member) {\n if (!member.isOpen()) member.open();\n return;\n }\n // Not over a menu trigger: only a real non-menu control (not the bar’s\n // padding or the gaps between triggers) clears the open menu — this is\n // a menubar-driven close, so the members stay engaged.\n if (!eventTarget.closest(NON_MENU_CONTROL_SELECTOR)) return;\n for (const openMember of members) {\n if (openMember.isOpen()) openMember.close();\n }\n };\n\n const handleFocus = (event: ReactFocusEvent<HTMLDivElement>) => {\n switchToMemberAt(event.target as HTMLElement);\n };\n\n const handleMouseOver = (event: ReactMouseEvent<HTMLDivElement>) => {\n switchToMemberAt(event.target as HTMLElement);\n };\n\n return (\n <div\n className={clsx('uktmenubar', className)}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onMouseOver={handleMouseOver}\n role=\"menubar\"\n style={style}\n >\n <MenubarContext.Provider value={contextValue}>\n {children}\n </MenubarContext.Provider>\n </div>\n );\n}\n","/* eslint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/mouse-events-have-key-events, jsx-a11y/no-static-element-interactions */\nimport useKeyboardEvents, {\n isEventTargetUsingKeyEvent,\n} from '@acusti/use-keyboard-events';\nimport clsx from 'clsx';\nimport {\n Children,\n cloneElement,\n type CSSProperties,\n Fragment,\n isValidElement,\n type MouseEvent as ReactMouseEvent,\n type ReactElement,\n type ReactNode,\n type SyntheticEvent,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport {\n DropdownContext,\n type DropdownContextValue,\n MenubarContext,\n type SubmenuRegistration,\n} from './context.js';\nimport styles from './Dropdown.css?inline';\nimport {\n annotateItemRoles,\n annotateParentItems,\n collapseItem,\n collapseItemsOutsidePath,\n expandItem,\n getActiveItemElement,\n getDeepestExpandedItem,\n getItemElements,\n getItemForTarget,\n getItemPath,\n getLabelFromChildren,\n getLevelRoot,\n getParentItem,\n getSubmenuOfItem,\n isItemExpanded,\n isPointInTriangle,\n type Point,\n setActiveItem,\n} from './helpers.js';\n\nexport type Item = {\n element: MaybeHTMLElement;\n event: Event | SyntheticEvent<HTMLElement>;\n label: string;\n /**\n * Ancestor parent items from the root level down to the item’s\n * immediate parent. Empty for top-level items.\n */\n path: Array<ItemValue>;\n value: string;\n};\n\n/**\n * A { label, value } pair naming an item: `value` is the stored value (the\n * item’s data-ukt-value) and `label` is its displayed text. Accepted by the\n * value prop when an item’s value and label differ; also the shape of an\n * Item’s path entries.\n */\nexport type ItemValue = { label: string; value: string };\n\nexport type Props = {\n /**\n * Boolean indicating if the user can submit a value not already in the\n * dropdown.\n */\n allowCreate?: boolean;\n /**\n * Boolean indicating if submitting with no item active emits an empty\n * value (i.e. clears the value). Only has an effect when the dropdown has a\n * text input to source that value from — a searchable dropdown’s search\n * input, or a text input inside a custom trigger. With no such input there\n * is no value to submit, so submitting with nothing selected is a no-op\n * regardless; clear such a dropdown with an explicit empty-valued item\n * instead. Defaults to true.\n */\n allowEmpty?: boolean;\n /**\n * Can take a single React element or exactly two renderable children.\n */\n children: ChildrenTuple | ReactElement;\n className?: string;\n disabled?: boolean;\n hasItems?: boolean;\n isOpenOnMount?: boolean;\n isSearchable?: boolean;\n keepOpenOnSubmit?: boolean;\n /**\n * Label content for the trigger button (when using single child syntax).\n * For a nested (submenu) Dropdown, this is the parent item’s content.\n */\n label?: ReactNode;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s name.\n */\n name?: string;\n onActiveItem?: (payload: Item) => void;\n onClick?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onClose?: () => unknown;\n onMouseDown?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onMouseUp?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onOpen?: () => unknown;\n onSubmitItem?: (payload: Item) => void;\n /**\n * Opens the dropdown when the pointer hovers the trigger, and closes it a\n * short moment after the pointer leaves the trigger and body entirely (the\n * close is delayed so crossing the gap between them, or pausing over\n * either, doesn’t flicker-close it). Click and keyboard opening keep\n * working as usual alongside it.\n */\n openOnHover?: boolean;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s placeholder.\n */\n placeholder?: string;\n /**\n * Applied to the dropdown root element. Also accepts the component’s CSS\n * custom properties (e.g. `--uktdd-body-min-width`) for per-instance\n * placement and sizing, which plain `CSSProperties` rejects.\n */\n style?: CSSProperties & Record<`--${string}`, string | number | undefined>;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s tabIndex.\n */\n tabIndex?: number;\n /**\n * The dropdown’s controlled value. Pass a bare identifier when an item’s\n * stored value and its displayed label are the same, or a { label, value }\n * pair when they differ (e.g. a human-readable label shown for a stored\n * id) — the same { label, value } shape onSubmitItem reports back. The\n * value determines whether the value has changed, to avoid triggering\n * onSubmitItem when the already-selected item is re-submitted; the label is\n * used as the search input’s value when props.isSearchable === true. A bare\n * identifier is resolved to its label from the matching child’s\n * data-ukt-value in the body — so children whose value and label differ\n * need no explicit label; a { label, value } pair states it.\n */\n value?: ItemValue | string;\n};\n\ntype ChildrenTuple = [ReactNode, ReactNode] | readonly [ReactNode, ReactNode];\n\ntype MaybeHTMLElement = HTMLElement | null;\n\ntype MousePosition = { clientX: number; clientY: number };\n\ntype TimeoutID = ReturnType<typeof setTimeout>;\n\nconst CHILDREN_ERROR =\n '@acusti/dropdown requires either 1 child (the dropdown body) or 2 children: the dropdown trigger and the dropdown body.';\nconst CLICKABLE_SELECTOR = 'button, a[href], input[type=\"button\"], input[type=\"submit\"]';\nconst FOCUSABLE_SELECTOR = 'a[href], button, input, select, textarea, [tabindex]';\nconst TEXT_INPUT_SELECTOR =\n 'input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea';\n\n// Matches macOS: quick, natural arrowing past parent items never flashes\n// their submenus, but a brief pause discloses. Frame-stepping macOS menus\n// puts its delay around 200–250ms; anything much shorter flashes\nconst SUBMENU_DISCLOSURE_DELAY = 200;\n\n// How long the pointer can dwell inside the safe area (heading toward an open\n// submenu) before we give up and switch to whatever it’s actually over. Reset\n// on every move, so it only fires on a pause — motion keeps the submenu open\nconst SAFE_AREA_TIMEOUT = 300;\n\n// props.openOnHover opens immediately on hover, but closing waits a beat so\n// that crossing the trigger/body gap (or a placement fallback moving the body\n// somewhere the pointer briefly leaves) doesn’t flicker-close it\nconst HOVER_CLOSE_DELAY = 150;\n\nexport default function Dropdown(props: Props) {\n const parentDropdown = useContext(DropdownContext);\n // A Dropdown nested inside a menu dropdown’s body renders as a submenu\n // (a parent item delegating to the root engine). A hasItems={false}\n // dropdown provides no submenu context, so a Dropdown nested inside one —\n // or a hasItems={false} Dropdown anywhere — renders independently instead.\n if (parentDropdown && props.hasItems !== false) {\n return <SubmenuDropdown {...props} parentDropdown={parentDropdown} />;\n }\n return <RootDropdown {...props} />;\n}\n\nfunction RootDropdown({\n allowCreate,\n allowEmpty = true,\n children,\n className,\n disabled,\n hasItems = true,\n isOpenOnMount,\n isSearchable,\n keepOpenOnSubmit = !hasItems,\n label,\n name,\n onActiveItem,\n onClick,\n onClose,\n onMouseDown,\n onMouseUp,\n onOpen,\n onSubmitItem,\n openOnHover,\n placeholder,\n style: styleFromProps,\n tabIndex,\n value,\n}: Props) {\n const childrenCount = Children.count(children);\n if (childrenCount !== 1 && childrenCount !== 2) {\n if (childrenCount === 0) {\n throw new Error(CHILDREN_ERROR + ' Received no children.');\n }\n console.error(`${CHILDREN_ERROR} Received ${childrenCount} children.`);\n }\n\n let trigger: React.ReactNode;\n if (childrenCount > 1) {\n trigger = (children as ChildrenTuple)[0];\n }\n // The body is the node rendered inside .uktdropdown-body: the second of\n // two children, or the only child.\n const body = childrenCount > 1 ? (children as ChildrenTuple)[1] : children;\n\n // The value prop is either a bare identifier (its stored value and its\n // displayed label are the same) or a { label, value } pair when they\n // differ. valueIdentity drives change detection / no-op matching against an\n // item’s data-ukt-value; valueLabel is what a searchable dropdown shows in\n // its input. For a bare identifier, the label is resolved from the matching\n // child (data-ukt-value in the body — derivation walks the same node the\n // body renders, so a data-ukt-value in a custom trigger can’t match), so\n // children with distinct values and labels need no separate label; a\n // { label, value } pair states it explicitly. Only a searchable dropdown\n // displays the label, so skip the per-render walk entirely for anything\n // else.\n const valueIdentity = typeof value === 'string' ? value : value?.value;\n const valueLabel = !isSearchable\n ? undefined\n : typeof value !== 'string'\n ? value?.label\n : (getLabelFromChildren(body, value) ?? value);\n\n const [isOpen, setIsOpen] = useState<boolean>(isOpenOnMount ?? false);\n const [isOpening, setIsOpening] = useState<boolean>(!isOpenOnMount);\n const [dropdownElement, setDropdownElement] = useState<MaybeHTMLElement>(null);\n const bodyId = useId();\n const popupRole = isSearchable ? 'listbox' : hasItems ? 'menu' : 'dialog';\n const menubar = useContext(MenubarContext);\n const inputElementRef = useRef<HTMLInputElement | null>(null);\n // Whether the consumer authors aria-selected in the body themselves, in\n // which case this component’s aria-selected fill-ins stand down (set per\n // open in handleBodyRef)\n const consumerOwnsARIASelectedRef = useRef(false);\n // Body elements already annotated this open (see handleBodyRef)\n const annotatedBodiesRef = useRef<WeakSet<HTMLElement>>(new WeakSet());\n const closingTimerRef = useRef<null | TimeoutID>(null);\n const isOpeningTimerRef = useRef<null | TimeoutID>(null);\n const currentInputMethodRef = useRef<'keyboard' | 'mouse'>('mouse');\n const clearEnteredCharactersTimerRef = useRef<null | TimeoutID>(null);\n const enteredCharactersRef = useRef<string>('');\n const mouseDownPositionRef = useRef<MousePosition | null>(null);\n const disclosureTimerRef = useRef<null | TimeoutID>(null);\n const pendingDisclosureItemRef = useRef<MaybeHTMLElement>(null);\n const submenuRegistrationsRef = useRef<Set<SubmenuRegistration>>(new Set());\n const pointerRef = useRef<Point | null>(null);\n const lastMouseEventRef = useRef<MouseEvent | null>(null);\n const safeAreaRef = useRef<{ apex: Point; parent: HTMLElement } | null>(null);\n const safeAreaTimerRef = useRef<null | TimeoutID>(null);\n const wasInSafeAreaRef = useRef<boolean>(false);\n const hoverCloseTimerRef = useRef<null | TimeoutID>(null);\n\n const allowCreateRef = useRef(allowCreate);\n const allowEmptyRef = useRef(allowEmpty);\n const hasItemsRef = useRef(hasItems);\n const isOpenRef = useRef(isOpen);\n const isOpeningRef = useRef(isOpening);\n const keepOpenOnSubmitRef = useRef(keepOpenOnSubmit);\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n const onSubmitItemRef = useRef(onSubmitItem);\n const valueRef = useRef(valueIdentity);\n\n useEffect(() => {\n allowCreateRef.current = allowCreate;\n allowEmptyRef.current = allowEmpty;\n hasItemsRef.current = hasItems;\n isOpenRef.current = isOpen;\n isOpeningRef.current = isOpening;\n keepOpenOnSubmitRef.current = keepOpenOnSubmit;\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n onSubmitItemRef.current = onSubmitItem;\n valueRef.current = valueIdentity;\n }, [\n allowCreate,\n allowEmpty,\n hasItems,\n isOpen,\n isOpening,\n keepOpenOnSubmit,\n onClose,\n onOpen,\n onSubmitItem,\n valueIdentity,\n ]);\n\n const isMountedRef = useRef(false);\n\n useEffect(() => {\n if (!isMountedRef.current) {\n isMountedRef.current = true;\n // If isOpenOnMount, trigger onOpen right away\n if (isOpenRef.current && onOpenRef.current) {\n onOpenRef.current();\n }\n return;\n }\n\n if (isOpen && onOpenRef.current) {\n onOpenRef.current();\n } else if (!isOpen && onCloseRef.current) {\n onCloseRef.current();\n }\n }, [isOpen]);\n\n // Nested (submenu) Dropdowns register here so their scoped callbacks\n // (onActiveItem/onOpen/onClose/onSubmitItem) can be dispatched to them\n const dropdownContextValue: DropdownContextValue = useMemo(\n () => ({\n registerSubmenu(registration: SubmenuRegistration) {\n submenuRegistrationsRef.current.add(registration);\n return () => {\n submenuRegistrationsRef.current.delete(registration);\n };\n },\n }),\n [],\n );\n\n const dispatchToSubmenus = (key: 'onActiveItem' | 'onSubmitItem', payload: Item) => {\n if (!payload.element) return;\n for (const registration of submenuRegistrationsRef.current) {\n if (registration.element.contains(payload.element)) {\n registration[key]?.(payload);\n }\n }\n };\n\n const handleActiveItem = (payload: Item) => {\n onActiveItem?.(payload);\n dispatchToSubmenus('onActiveItem', payload);\n };\n\n const handleToggleSubmenu = (item: HTMLElement, isExpanded: boolean) => {\n // Show/hide the submenu in the top layer (popover=\"manual\"), like the\n // body, so no ancestor can become its containing block and shift its\n // anchor placement. Gate on the current state so a redundant toggle is\n // a no-op instead of a showPopover/hidePopover that throws.\n const submenu = getSubmenuOfItem(item);\n if (submenu) {\n const isShown = submenu.matches(':popover-open');\n if (isExpanded && !isShown) submenu.showPopover();\n else if (!isExpanded && isShown) submenu.hidePopover();\n }\n for (const registration of submenuRegistrationsRef.current) {\n if (registration.element === item) {\n (isExpanded ? registration.onOpen : registration.onClose)?.();\n }\n }\n };\n\n const clearDisclosureTimer = () => {\n if (disclosureTimerRef.current != null) {\n clearTimeout(disclosureTimerRef.current);\n disclosureTimerRef.current = null;\n }\n pendingDisclosureItemRef.current = null;\n };\n\n // Clear the disclosure intent timer on unmount so it can’t fire against\n // unmounted DOM or dispatch submenu callbacks after teardown\n useEffect(() => clearDisclosureTimer, []);\n\n // A parent item discloses its submenu after a short intent delay whenever\n // it becomes (and stays) the deepest active item, for pointer and keyboard\n // alike; submenus off the active path collapse immediately\n const syncSubmenuDisclosure = () => {\n if (!dropdownElement) return;\n const activeElement = getActiveItemElement(dropdownElement);\n collapseItemsOutsidePath(dropdownElement, activeElement, handleToggleSubmenu);\n const submenu = activeElement ? getSubmenuOfItem(activeElement) : null;\n if (activeElement && submenu && !isItemExpanded(activeElement)) {\n // A timer already pending for this item keeps its original start time\n if (pendingDisclosureItemRef.current === activeElement) return;\n clearDisclosureTimer();\n pendingDisclosureItemRef.current = activeElement;\n disclosureTimerRef.current = setTimeout(() => {\n disclosureTimerRef.current = null;\n pendingDisclosureItemRef.current = null;\n if (!activeElement.hasAttribute('data-ukt-active')) return;\n expandItem(activeElement, handleToggleSubmenu);\n }, SUBMENU_DISCLOSURE_DELAY);\n return;\n }\n clearDisclosureTimer();\n };\n\n const clearSafeAreaTimer = () => {\n if (safeAreaTimerRef.current != null) {\n clearTimeout(safeAreaTimerRef.current);\n safeAreaTimerRef.current = null;\n }\n };\n\n // Clear the safe-area give-up timer on unmount so it can’t fire against\n // unmounted DOM\n useEffect(() => clearSafeAreaTimer, []);\n\n // The safe area is the triangle from where the pointer last sat on the\n // open submenu’s parent (the apex) to that submenu’s two near corners.\n // While the pointer is inside it, it’s traveling toward the submenu, so the\n // submenu stays open even as the pointer crosses sibling items — the macOS\n // diagonal behavior\n const isPointerInSafeArea = (x: number, y: number): boolean => {\n const safeArea = safeAreaRef.current;\n if (!safeArea || !isItemExpanded(safeArea.parent)) return false;\n const submenu = getSubmenuOfItem(safeArea.parent);\n if (!submenu) return false;\n const submenuRect = submenu.getBoundingClientRect();\n const parentRect = safeArea.parent.getBoundingClientRect();\n // Submenus can open to either side; the near edge is the one facing\n // the parent item\n const nearX =\n submenuRect.left >= parentRect.right - 1\n ? submenuRect.left\n : submenuRect.right;\n return isPointInTriangle(\n { x, y },\n safeArea.apex,\n { x: nearX, y: submenuRect.top },\n { x: nearX, y: submenuRect.bottom },\n );\n };\n\n // The pointer left the safe area (or paused in it without reaching the\n // submenu): stop protecting the submenu and switch to whatever the pointer\n // is over now. Passing the target avoids an elementFromPoint read; the\n // give-up timer has no event, so it falls back to hit-testing the pointer\n const commitPointerTarget = (targetElement?: MaybeHTMLElement) => {\n clearSafeAreaTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n const pointer = pointerRef.current;\n const target =\n targetElement ??\n (pointer\n ? (dropdownElement?.ownerDocument.elementFromPoint(\n pointer.x,\n pointer.y,\n ) as MaybeHTMLElement)\n : null);\n if (!dropdownElement || !target || !dropdownElement.contains(target)) return;\n const item = getItemForTarget(dropdownElement, target);\n const event = lastMouseEventRef.current;\n // Only reachable via mouse events, so a real mouse event is on hand\n if (item && event) {\n setActiveItem({\n dropdownElement,\n element: item,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n };\n\n // Track the pointer against the open submenu’s safe area: anchor the apex\n // while over the parent item, and (re)arm the give-up timer while traveling\n // toward the submenu so only a pause — not motion — ends the protection\n const trackSafeArea = (event: ReactMouseEvent<HTMLElement>) => {\n // Safe-area intent only applies to an open menu with items; skip the\n // per-move DOM query otherwise (mousemove is a hot path)\n if (!dropdownElement || !isOpenRef.current || !hasItemsRef.current) return;\n const pointer = { x: event.clientX, y: event.clientY };\n pointerRef.current = pointer;\n lastMouseEventRef.current = event.nativeEvent;\n const parent = getDeepestExpandedItem(dropdownElement);\n if (!parent) {\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n clearSafeAreaTimer();\n return;\n }\n const target = event.target as HTMLElement;\n const submenu = getSubmenuOfItem(parent);\n const isOverParent =\n parent.contains(target) && !(submenu?.contains(target) ?? false);\n if (isOverParent) {\n safeAreaRef.current = { apex: pointer, parent };\n wasInSafeAreaRef.current = false;\n clearSafeAreaTimer();\n return;\n }\n // A newly-open submenu we haven’t anchored an apex for yet\n if (safeAreaRef.current?.parent !== parent) {\n safeAreaRef.current = null;\n }\n clearSafeAreaTimer();\n if (isPointerInSafeArea(pointer.x, pointer.y)) {\n wasInSafeAreaRef.current = true;\n safeAreaTimerRef.current = setTimeout(commitPointerTarget, SAFE_AREA_TIMEOUT);\n } else if (wasInSafeAreaRef.current) {\n // Just crossed out of the triangle. The pointer may still be over\n // the same sibling it entered while protected, so no mouseover will\n // fire — re-evaluate and activate whatever it’s on now\n commitPointerTarget(target);\n }\n };\n\n const clearHoverCloseTimer = () => {\n if (hoverCloseTimerRef.current != null) {\n clearTimeout(hoverCloseTimerRef.current);\n hoverCloseTimerRef.current = null;\n }\n };\n\n // Clear props.openOnHover’s close timer on unmount so it can’t fire against\n // unmounted DOM\n useEffect(() => clearHoverCloseTimer, []);\n\n const closeDropdown = (options?: { keepMenubarEngaged?: boolean }) => {\n setIsOpen(false);\n setIsOpening(false);\n mouseDownPositionRef.current = null;\n clearDisclosureTimer();\n clearSafeAreaTimer();\n clearHoverCloseTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n if (closingTimerRef.current != null) {\n clearTimeout(closingTimerRef.current);\n closingTimerRef.current = null;\n }\n // A self-dismissal — Escape, an outside click, or an item selection —\n // takes an enclosing menubar out of menu-mode. Switching menus,\n // clearing the open menu on hover, and focus changes pass\n // keepMenubarEngaged to stay in menu-mode.\n if (menubar && dropdownElement && !options?.keepMenubarEngaged) {\n menubar.notifyClosed(dropdownElement);\n }\n };\n\n // The pointer entered the trigger or (if open) the body: cancel any\n // pending close and, if props.openOnHover and not already open, open now\n const handleDropdownMouseEnter = () => {\n clearHoverCloseTimer();\n if (!openOnHover || isOpenRef.current) return;\n setIsOpen(true);\n setIsOpening(false);\n };\n\n // The pointer left the trigger and body entirely: if open, arm the\n // close-intent timer (a re-entry before it fires cancels it above, so\n // crossing the trigger/body gap doesn’t flicker)\n const handleDropdownMouseLeave = () => {\n if (!openOnHover || !isOpenRef.current || hoverCloseTimerRef.current != null) {\n return;\n }\n hoverCloseTimerRef.current = setTimeout(() => {\n hoverCloseTimerRef.current = null;\n closeDropdown();\n }, HOVER_CLOSE_DELAY);\n };\n\n const focusTrigger = () => {\n const firstChild = dropdownElement?.firstElementChild as MaybeHTMLElement;\n if (!firstChild) return;\n const focusable = firstChild.matches(FOCUSABLE_SELECTOR)\n ? firstChild\n : (firstChild.querySelector(FOCUSABLE_SELECTOR) as MaybeHTMLElement);\n focusable?.focus();\n };\n\n // Register with an enclosing Menubar (one open menu at a time, ←/→\n // moves between menus, hover-to-switch once any menu is open). Closing\n // goes through closeDropdown so pending timers (submenu disclosure,\n // close delay) can’t fire against a menu the menubar already closed.\n useEffect(() => {\n if (!menubar || !dropdownElement) return;\n return menubar.registerMember({\n close: () => closeDropdown({ keepMenubarEngaged: true }),\n element: dropdownElement,\n focusTrigger,\n isOpen: () => isOpenRef.current,\n open: () => setIsOpen(true),\n });\n });\n\n useEffect(() => {\n if (isOpen && menubar && dropdownElement) {\n menubar.notifyOpened(dropdownElement);\n }\n }, [dropdownElement, isOpen, menubar]);\n\n const handleSubmitItem = (event: Event | React.SyntheticEvent<HTMLElement>) => {\n const element = hasItemsRef.current\n ? getActiveItemElement(dropdownElement)\n : null;\n\n const submenuOfActive = element ? getSubmenuOfItem(element) : null;\n if (element && submenuOfActive) {\n // Parent items disclose; they never submit\n clearDisclosureTimer();\n expandItem(element, handleToggleSubmenu);\n if (currentInputMethodRef.current === 'keyboard' && dropdownElement) {\n const firstItem = getItemElements(dropdownElement, submenuOfActive)?.[0];\n if (firstItem) {\n setActiveItem({\n dropdownElement,\n element: firstItem,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n }\n return;\n }\n\n if (isOpenRef.current && !keepOpenOnSubmitRef.current) {\n // A short timeout before closing is better UX when user selects an item so dropdown\n // doesn’t close before expected. It also enables using <Link />s in the dropdown body.\n closingTimerRef.current = setTimeout(closeDropdown, 90);\n }\n\n if (!hasItemsRef.current) return;\n\n if (!element) {\n // With nothing selected, the only possible value comes from a text\n // input (a searchable dropdown’s input, or one inside a custom\n // trigger). No input means there’s no value to submit at all, so\n // bail regardless of allowCreate/allowEmpty instead of firing an\n // empty-valued onSubmitItem consumers have to defend against. (To\n // let such a dropdown clear its value, give it an explicit\n // empty-valued item, which submits as a normal active selection.)\n if (!inputElementRef.current) return;\n if (inputElementRef.current.value) {\n // Non-empty text matching no item is a created value\n if (!allowCreateRef.current) return;\n } else if (!allowEmptyRef.current) {\n // A cleared input is an empty (clearing) submit, which\n // allowEmpty gates even when allowCreate is set — “creating”\n // an empty value is clearing, not creating\n return;\n }\n }\n\n let itemLabel = element?.innerText ?? '';\n if (inputElementRef.current) {\n if (!element) {\n itemLabel = inputElementRef.current.value;\n } else {\n inputElementRef.current.value = itemLabel;\n }\n\n if (\n inputElementRef.current ===\n inputElementRef.current.ownerDocument.activeElement\n ) {\n inputElementRef.current.blur();\n }\n }\n\n const nextValue = element?.dataset.uktValue ?? itemLabel;\n // If parent is controlling Dropdown via props.value and nextValue is the same, do nothing\n if (valueRef.current && valueRef.current === nextValue) return;\n\n // When the body stays open after submit (keepOpenOnSubmit), move\n // aria-selected to the submitted option so the open-time annotation\n // doesn’t go stale; a closing body unmounts, so reopening re-derives\n // it from props.value. Listbox only — aria-selected isn’t valid on a\n // menuitem — scoped to the popup body (never a custom trigger’s own\n // aria-selected), and skipped entirely when the consumer authors\n // aria-selected themselves.\n if (\n element &&\n keepOpenOnSubmitRef.current &&\n popupRole === 'listbox' &&\n !consumerOwnsARIASelectedRef.current\n ) {\n const bodyElement = element.closest('.uktdropdown-body');\n for (const selected of Array.from(\n bodyElement?.querySelectorAll('[aria-selected=\"true\"]') ?? [],\n )) {\n selected.removeAttribute('aria-selected');\n }\n element.setAttribute('aria-selected', 'true');\n }\n\n // If the item is clickable or contains exactly one clickable element, invoke it\n // (but only if the event didn’t already originate from that element)\n if (element) {\n const eventTarget = event.target as HTMLElement;\n\n if (element.matches(CLICKABLE_SELECTOR)) {\n // The item element itself is clickable (e.g., <button data-ukt-value=\"…\">)\n if (element !== eventTarget && !element.contains(eventTarget)) {\n element.click();\n }\n } else {\n // Check if item contains exactly one clickable child element\n const clickableElements = element.querySelectorAll(CLICKABLE_SELECTOR);\n if (clickableElements.length === 1) {\n const clickableElement = clickableElements[0] as HTMLElement;\n if (\n clickableElement !== eventTarget &&\n !clickableElement.contains(eventTarget)\n ) {\n clickableElement.click();\n }\n }\n }\n }\n\n const payload: Item = {\n element,\n event,\n label: itemLabel,\n path: getItemPath(element),\n value: nextValue,\n };\n onSubmitItemRef.current?.(payload);\n dispatchToSubmenus('onSubmitItem', payload);\n };\n\n const handleMouseMove = (event: ReactMouseEvent<HTMLElement>) => {\n const { clientX, clientY } = event;\n currentInputMethodRef.current = 'mouse';\n trackSafeArea(event);\n const initialPosition = mouseDownPositionRef.current;\n if (!initialPosition) return;\n if (\n Math.abs(initialPosition.clientX - clientX) < 12 &&\n Math.abs(initialPosition.clientY - clientY) < 12\n ) {\n return;\n }\n setIsOpening(false);\n };\n\n const handleMouseOver = (event: ReactMouseEvent<HTMLElement>) => {\n if (!hasItemsRef.current) return;\n\n // If user isn’t currently using the mouse to navigate the dropdown, do nothing\n if (currentInputMethodRef.current !== 'mouse') return;\n\n // Ensure we have the dropdown root HTMLElement\n if (!dropdownElement) return;\n\n const eventTarget = event.target as HTMLElement;\n if (!eventTarget.closest('.uktdropdown-body')) return;\n\n // Hover inside an open nested dropdown belongs to that dropdown\n const hoveredRoot = eventTarget.closest('.uktdropdown');\n if (\n hoveredRoot !== dropdownElement &&\n hoveredRoot?.classList.contains('is-open')\n ) {\n return;\n }\n\n // Heading toward an open submenu: keep it open even over sibling items\n if (isPointerInSafeArea(event.clientX, event.clientY)) return;\n\n const item = getItemForTarget(dropdownElement, eventTarget);\n if (!item) return;\n\n setActiveItem({\n dropdownElement,\n element: item,\n event,\n onActiveItem: handleActiveItem,\n });\n syncSubmenuDisclosure();\n };\n\n const handleMouseOut = (event: ReactMouseEvent<HTMLElement>) => {\n if (!hasItemsRef.current) return;\n // The pointer left the dropdown entirely: drop the safe area so its\n // give-up timer can’t later fire on a stale position, and fall through\n // to the normal collapse (mousemove has stopped, so nothing else will)\n const relatedTarget = event.relatedTarget as Node | null;\n const isLeavingDropdown = !dropdownElement?.contains(relatedTarget);\n if (isLeavingDropdown) {\n clearSafeAreaTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n }\n // Heading toward an open submenu: don’t clear the active item / collapse\n if (isPointerInSafeArea(event.clientX, event.clientY)) return;\n const activeItem = getActiveItemElement(dropdownElement);\n if (!activeItem) return;\n const eventRelatedTarget = event.relatedTarget as HTMLElement;\n if (activeItem !== event.target || activeItem.contains(eventRelatedTarget)) {\n return;\n }\n // If user moused out of activeItem (not into a descendant), it’s no longer active\n delete activeItem.dataset.uktActive;\n syncSubmenuDisclosure();\n };\n\n const handleMouseDown = (event: ReactMouseEvent<HTMLElement>) => {\n if (onMouseDown) onMouseDown(event);\n if (isOpenRef.current) return;\n\n setIsOpen(true);\n setIsOpening(true);\n mouseDownPositionRef.current = {\n clientX: event.clientX,\n clientY: event.clientY,\n };\n isOpeningTimerRef.current = setTimeout(() => {\n setIsOpening(false);\n isOpeningTimerRef.current = null;\n }, 1000);\n };\n\n const handleMouseUp = (event: ReactMouseEvent<HTMLElement>) => {\n if (onMouseUp) onMouseUp(event);\n // If dropdown is still opening or isn’t open or is closing, do nothing\n if (\n isOpeningRef.current ||\n !isOpenRef.current ||\n closingTimerRef.current != null\n ) {\n return;\n }\n\n const eventTarget = event.target as HTMLElement;\n\n // Clicks inside an open nested dropdown belong to that dropdown\n const clickedRoot = eventTarget.closest('.uktdropdown');\n if (\n clickedRoot !== dropdownElement &&\n clickedRoot?.classList.contains('is-open') &&\n dropdownElement?.contains(clickedRoot)\n ) {\n return;\n }\n\n // A click only counts as inside the body if the closest body element\n // belongs to this dropdown (a nested dropdown’s trigger sits inside\n // the outer body, but the outer body isn’t the nested one’s own)\n const targetBody = eventTarget.closest('.uktdropdown-body');\n const isInOwnBody = Boolean(\n targetBody && targetBody.closest('.uktdropdown') === dropdownElement,\n );\n // If click was outside dropdown body, don’t trigger submit\n if (!isInOwnBody) {\n // Don’t close dropdown if isOpening or search input is focused\n if (\n !isOpeningRef.current &&\n inputElementRef.current !== eventTarget.ownerDocument.activeElement\n ) {\n closeDropdown();\n }\n return;\n }\n\n // If dropdown has no items and click was within dropdown body, do nothing\n if (!hasItemsRef.current) return;\n\n if (dropdownElement) {\n const clickedItem = getItemForTarget(dropdownElement, eventTarget);\n if (clickedItem) {\n // Submit the item the click actually landed on: sync the\n // active item to it in case they diverge (e.g. active was\n // set via keyboard, then user clicked elsewhere)\n setActiveItem({\n dropdownElement,\n element: clickedItem,\n event,\n onActiveItem: handleActiveItem,\n });\n } else if (getActiveItemElement(dropdownElement)) {\n // A click that doesn’t land on an item — body padding, a\n // separator, or a disabled item (pointer-events: none\n // retargets its clicks to the container) — must not submit\n // the previously active item: like macOS, it does nothing.\n // With no active item it falls through, so a body click\n // can still submit an input-sourced value\n return;\n }\n }\n\n handleSubmitItem(event);\n };\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const { altKey, ctrlKey, key, metaKey } = event;\n const eventTarget = event.target as HTMLElement;\n if (!dropdownElement) return;\n\n const onEventHandled = () => {\n event.stopPropagation();\n event.preventDefault();\n currentInputMethodRef.current = 'keyboard';\n };\n\n const isEventTargetingDropdown = dropdownElement.contains(eventTarget);\n\n // Key events originating inside an open nested dropdown are that\n // dropdown’s business (e.g. an info popover nested in this body)\n const nestedRoot = eventTarget.closest?.('.uktdropdown');\n if (\n nestedRoot &&\n nestedRoot !== dropdownElement &&\n dropdownElement.contains(nestedRoot) &&\n nestedRoot.classList.contains('is-open')\n ) {\n return;\n }\n\n if (!isOpenRef.current) {\n // If dropdown is closed, don’t handle key events if event target isn’t within dropdown\n if (!isEventTargetingDropdown) return;\n // Open the dropdown on spacebar, enter, or if isSearchable and user hits the ↑/↓ arrows\n if (\n key === ' ' ||\n key === 'Enter' ||\n (hasItemsRef.current && (key === 'ArrowUp' || key === 'ArrowDown'))\n ) {\n onEventHandled();\n setIsOpen(true);\n }\n return;\n }\n\n const isTargetUsingKeyEvents = isEventTargetUsingKeyEvent(event);\n\n // If dropdown isOpen + hasItems & eventTargetNotUsingKeyEvents, handle characters\n if (hasItemsRef.current && !isTargetUsingKeyEvents) {\n let isEditingCharacters = !ctrlKey && !metaKey && /^[A-Za-z0-9]$/.test(key);\n // User could also be editing characters if there are already characters entered\n // and they are hitting delete or spacebar\n if (!isEditingCharacters && enteredCharactersRef.current) {\n isEditingCharacters = key === ' ' || key === 'Backspace';\n }\n\n if (isEditingCharacters) {\n onEventHandled();\n if (key === 'Backspace') {\n enteredCharactersRef.current = enteredCharactersRef.current.slice(\n 0,\n -1,\n );\n } else {\n enteredCharactersRef.current += key;\n }\n\n setActiveItem({\n dropdownElement,\n event,\n // If props.allowCreate, only override the input’s value with an\n // exact text match so user can enter a value not in items\n isExactMatch: allowCreateRef.current,\n onActiveItem: handleActiveItem,\n text: enteredCharactersRef.current,\n });\n syncSubmenuDisclosure();\n\n if (clearEnteredCharactersTimerRef.current != null) {\n clearTimeout(clearEnteredCharactersTimerRef.current);\n }\n\n clearEnteredCharactersTimerRef.current = setTimeout(() => {\n enteredCharactersRef.current = '';\n clearEnteredCharactersTimerRef.current = null;\n }, 1500);\n\n return;\n }\n }\n\n // If dropdown isOpen, handle submitting the value\n if (key === 'Enter' || (key === ' ' && !inputElementRef.current)) {\n onEventHandled();\n handleSubmitItem(event);\n return;\n }\n\n // If dropdown isOpen, handle closing it on escape or spacebar if !hasItems\n if (\n key === 'Escape' ||\n (isEventTargetingDropdown && key === ' ' && !hasItemsRef.current)\n ) {\n // Close dropdown if hasItems or event target not using key events\n if (hasItemsRef.current || !isTargetUsingKeyEvents) {\n // Escape closes the whole menu — submenus included — and\n // returns focus to the element that opened it. Focus before\n // closing: a searchable trigger input opens the dropdown on\n // focus, so its synchronous onFocus must land before the\n // close state update for the close to win the batch\n focusTrigger();\n closeDropdown();\n }\n return;\n }\n\n // Handle arrow keys\n if (hasItemsRef.current) {\n if (key === 'ArrowUp') {\n onEventHandled();\n if (altKey || metaKey) {\n setActiveItem({\n dropdownElement,\n event,\n index: 0,\n onActiveItem: handleActiveItem,\n });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: -1,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n return;\n }\n if (key === 'ArrowDown') {\n onEventHandled();\n if (altKey || metaKey) {\n // Using a negative index counts back from the end\n setActiveItem({\n dropdownElement,\n event,\n index: -1,\n onActiveItem: handleActiveItem,\n });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: 1,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n return;\n }\n // ←/→ dive into and surface out of submenus (and move between\n // menus in a menubar); leave them alone when a text input has focus\n if (!isTargetUsingKeyEvents) {\n if (key === 'ArrowRight') {\n const activeElement = getActiveItemElement(dropdownElement);\n const submenu = activeElement\n ? getSubmenuOfItem(activeElement)\n : null;\n if (activeElement && submenu) {\n onEventHandled();\n clearDisclosureTimer();\n expandItem(activeElement, handleToggleSubmenu);\n const firstItem = getItemElements(dropdownElement, submenu)?.[0];\n if (firstItem) {\n setActiveItem({\n dropdownElement,\n element: firstItem,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n return;\n }\n if (menubar) {\n onEventHandled();\n menubar.moveOpen(dropdownElement, 1);\n }\n return;\n }\n if (key === 'ArrowLeft') {\n const activeElement = getActiveItemElement(dropdownElement);\n const levelRoot = activeElement ? getLevelRoot(activeElement) : null;\n if (levelRoot) {\n onEventHandled();\n clearDisclosureTimer();\n const parentItem = getParentItem(levelRoot);\n if (parentItem) {\n collapseItem(parentItem, handleToggleSubmenu);\n }\n return;\n }\n if (menubar) {\n onEventHandled();\n menubar.moveOpen(dropdownElement, -1);\n }\n return;\n }\n }\n }\n };\n\n useKeyboardEvents({ ignoreUsedKeyboardEvents: false, onKeyDown: handleKeyDown });\n\n const handleRef = (ref: HTMLDivElement | null): (() => void) | void => {\n setDropdownElement(ref);\n if (!ref) return;\n\n const { ownerDocument } = ref;\n let inputElement = inputElementRef.current;\n // Check if trigger is a textual input or textarea element\n if (!inputElement && ref.firstElementChild) {\n if (ref.firstElementChild.matches(TEXT_INPUT_SELECTOR)) {\n inputElement = ref.firstElementChild as HTMLInputElement;\n } else {\n inputElement = ref.firstElementChild.querySelector(TEXT_INPUT_SELECTOR);\n }\n inputElementRef.current = inputElement;\n }\n\n const handleGlobalMouseDown = ({ target }: MouseEvent) => {\n const eventTarget = target as HTMLElement;\n if (!ref.contains(eventTarget)) {\n // Close dropdown on an outside click\n closeDropdown();\n }\n };\n\n const handleGlobalMouseUp = ({ target }: MouseEvent) => {\n if (!isOpenRef.current || closingTimerRef.current != null) return;\n\n // If still isOpening (gets set false 1s after open triggers), set it to false onMouseUp\n if (isOpeningRef.current) {\n setIsOpening(false);\n if (isOpeningTimerRef.current != null) {\n clearTimeout(isOpeningTimerRef.current);\n isOpeningTimerRef.current = null;\n }\n return;\n }\n\n const eventTarget = target as HTMLElement;\n // Only handle mouseup events from outside the dropdown here\n if (!ref.contains(eventTarget)) {\n closeDropdown();\n }\n };\n\n // Close dropdown if any element is focused outside of this dropdown\n const handleGlobalFocusIn = ({ target }: Event) => {\n if (!isOpenRef.current) return;\n\n const eventTarget = target as HTMLElement;\n // If focused element is a descendant or a parent of the dropdown, do nothing\n if (ref.contains(eventTarget) || eventTarget.contains(ref)) {\n return;\n }\n\n // Losing focus — including the focus shift when the body unmounts\n // on close — doesn’t end a menubar’s menu-mode; that takes a\n // deliberate dismissal (Escape, outside click, item select).\n closeDropdown({ keepMenubarEngaged: true });\n };\n\n document.addEventListener('focusin', handleGlobalFocusIn);\n document.addEventListener('mousedown', handleGlobalMouseDown);\n document.addEventListener('mouseup', handleGlobalMouseUp);\n\n if (ownerDocument !== document) {\n ownerDocument.addEventListener('focusin', handleGlobalFocusIn);\n ownerDocument.addEventListener('mousedown', handleGlobalMouseDown);\n ownerDocument.addEventListener('mouseup', handleGlobalMouseUp);\n }\n\n // If dropdown should be open on mount, focus it\n if (isOpenOnMount) {\n ref.focus();\n }\n\n const handleInput = (event: Event) => {\n if (!isOpenRef.current) setIsOpen(true);\n\n const input = event.target as HTMLInputElement;\n const isDeleting = enteredCharactersRef.current.length > input.value.length;\n enteredCharactersRef.current = input.value;\n // When deleting text, if there’s already an active item and\n // input isn’t empty, preserve the active item, else update it\n if (isDeleting && input.value.length && getActiveItemElement(ref)) {\n return;\n }\n\n setActiveItem({\n dropdownElement: ref,\n event,\n // If props.allowCreate, only override the input’s value with an\n // exact text match so user can enter a value not in items\n isExactMatch: allowCreateRef.current,\n onActiveItem: handleActiveItem,\n text: enteredCharactersRef.current,\n });\n };\n\n if (inputElement) {\n inputElement.addEventListener('input', handleInput);\n }\n\n return () => {\n document.removeEventListener('focusin', handleGlobalFocusIn);\n document.removeEventListener('mousedown', handleGlobalMouseDown);\n document.removeEventListener('mouseup', handleGlobalMouseUp);\n\n if (ownerDocument !== document) {\n ownerDocument.removeEventListener('focusin', handleGlobalFocusIn);\n ownerDocument.removeEventListener('mousedown', handleGlobalMouseDown);\n ownerDocument.removeEventListener('mouseup', handleGlobalMouseUp);\n }\n\n if (inputElement) {\n inputElement.removeEventListener('input', handleInput);\n }\n };\n };\n\n // When the body mounts (open): fill in parent-item/submenu ARIA, and\n // render it in the top layer via popover so an ancestor’s transform /\n // filter / contain can’t become the containing block for the fixed body\n // and break its anchor positioning + fallbacks. popover=\"manual\" keeps\n // dismissal under this component’s own listeners (see handleRef), which\n // preserves iframe support and searchable/text-input triggers that native\n // light-dismiss would close on any outside pointerdown.\n // These annotations run once per open (the body unmounts on close and is\n // annotated fresh each time); items rendered into an already-open body —\n // async-loaded or consumer-filtered — aren’t annotated until the next\n // open. Known limitation until it’s needed.\n const handleBodyRef = (ref: HTMLDivElement | null) => {\n if (!ref) return;\n // An inline ref callback re-attaches (and re-runs) on every re-render\n // while the body is open, but everything below must run exactly once\n // per open: showPopover() throws on an already-shown popover, and the\n // ownership check would read the reveal’s own aria-selected annotation\n // back as consumer-authored. Each open mounts a fresh body element, so\n // latch per element (a WeakSet, to hold no unmounted bodies alive).\n if (annotatedBodiesRef.current.has(ref)) return;\n annotatedBodiesRef.current.add(ref);\n // A consumer-authored aria-selected anywhere in the just-mounted body\n // (whether \"true\" or \"false\") means the consumer manages selection\n // ARIA themselves: the reveal below and the keepOpenOnSubmit move in\n // handleSubmitItem both stand down, so a single-select listbox never\n // ends up with two selected options (the usual your-values-win rule).\n consumerOwnsARIASelectedRef.current =\n ref.querySelector('[aria-selected]') != null;\n annotateParentItems(ref);\n if (popupRole !== 'dialog') annotateItemRoles(ref, popupRole);\n // The Popover API is Baseline 2024, so showPopover() needs no feature\n // detection; the body is mounted only while open, so this runs once\n // per open and won’t throw on an already-open body.\n ref.showPopover();\n // Reveal the current value on open: mark the matching option\n // aria-selected (listbox only — aria-selected isn’t valid on a\n // menuitem), make it the active item (so keyboard navigation starts\n // there), and scroll it into view — so a controlled dropdown opens\n // showing (and at) its current selection. The lookup is deliberately\n // top-level only (getItemElements filters to the root level):\n // search/typeahead also match per level, and no native menu opens\n // with submenus pre-expanded, so a value matching only a submenu\n // item is a graceful no-op, like a value matching nothing.\n if (valueIdentity != null && dropdownElement) {\n const selectedItem = getItemElements(dropdownElement)?.find(\n (item) => item.dataset.uktValue === valueIdentity,\n );\n if (selectedItem) {\n if (popupRole === 'listbox' && !consumerOwnsARIASelectedRef.current) {\n selectedItem.setAttribute('aria-selected', 'true');\n }\n setActiveItem({ dropdownElement, element: selectedItem });\n }\n }\n };\n\n if (!isValidElement(trigger)) {\n if (isSearchable) {\n trigger = (\n <input\n aria-controls={bodyId}\n aria-expanded={isOpen}\n aria-haspopup={popupRole}\n autoComplete=\"off\"\n className=\"uktdropdown-trigger\"\n defaultValue={valueLabel ?? ''}\n disabled={disabled}\n name={name}\n onFocus={() => setIsOpen(true)}\n placeholder={placeholder}\n ref={inputElementRef}\n tabIndex={tabIndex}\n type=\"text\"\n />\n );\n } else {\n trigger = (\n <button\n aria-controls={bodyId}\n aria-expanded={isOpen}\n aria-haspopup={popupRole}\n className=\"uktdropdown-trigger\"\n tabIndex={0}\n type=\"button\"\n >\n {trigger}\n </button>\n );\n }\n } else {\n // For a consumer-provided trigger, add ARIA props (letting the consumer\n // override by specifying their own).\n const triggerProps = trigger.props as Record<string, unknown>;\n trigger = cloneElement(trigger as ReactElement<Record<string, unknown>>, {\n 'aria-controls': triggerProps['aria-controls'] ?? bodyId,\n 'aria-expanded': triggerProps['aria-expanded'] ?? isOpen,\n 'aria-haspopup': triggerProps['aria-haspopup'] ?? popupRole,\n });\n }\n\n if (label != null) {\n trigger = (\n <label className=\"uktdropdown-label\">\n <div className=\"uktdropdown-label-text\">{label}</div>\n {trigger}\n </label>\n );\n }\n\n return (\n <Fragment>\n <style href=\"@acusti/dropdown/Dropdown\" precedence=\"medium\">\n {styles}\n </style>\n <div\n className={clsx('uktdropdown', className, {\n disabled,\n 'is-open': isOpen,\n 'is-searchable': isSearchable,\n })}\n onClick={onClick}\n onMouseDown={handleMouseDown}\n onMouseEnter={handleDropdownMouseEnter}\n onMouseLeave={handleDropdownMouseLeave}\n onMouseMove={handleMouseMove}\n onMouseOut={handleMouseOut}\n onMouseOver={handleMouseOver}\n onMouseUp={handleMouseUp}\n ref={handleRef}\n style={styleFromProps}\n >\n {trigger}\n {/* TODO next version of Dropdown should use <Activity> for body https://react.dev/reference/react/Activity */}\n {isOpen ? (\n <div\n className={clsx('uktdropdown-body', {\n 'has-items': hasItems,\n })}\n id={bodyId}\n popover=\"manual\"\n ref={handleBodyRef}\n role={popupRole}\n >\n <div className=\"uktdropdown-content\">\n <DropdownContext.Provider\n value={hasItems ? dropdownContextValue : null}\n >\n {body}\n </DropdownContext.Provider>\n </div>\n </div>\n ) : null}\n </div>\n </Fragment>\n );\n}\n\nconst INERT_SUBMENU_PROPS = [\n 'allowCreate',\n 'allowEmpty',\n 'isOpenOnMount',\n 'isSearchable',\n 'keepOpenOnSubmit',\n 'name',\n 'openOnHover',\n 'placeholder',\n 'tabIndex',\n 'value',\n] as const;\n\n// The nested (submenu) rendering of Dropdown: a parent item that discloses a\n// child menu. It renders the data-ukt-submenu protocol and registers with the\n// root dropdown, whose engine handles all interaction.\nfunction SubmenuDropdown(props: Props & { parentDropdown: DropdownContextValue }) {\n const {\n children,\n className,\n disabled,\n label,\n onActiveItem,\n onClose,\n onOpen,\n onSubmitItem,\n parentDropdown,\n style,\n } = props;\n\n const itemRef = useRef<HTMLLIElement | null>(null);\n\n useEffect(() => {\n const element = itemRef.current;\n if (!element) return;\n return parentDropdown.registerSubmenu({\n element,\n onActiveItem,\n onClose,\n onOpen,\n onSubmitItem,\n });\n }, [onActiveItem, onClose, onOpen, onSubmitItem, parentDropdown]);\n\n // Misuse feedback is unconditional, like the children-count error above\n const warnedRef = useRef(false);\n useEffect(() => {\n if (warnedRef.current) return;\n const inertProps = INERT_SUBMENU_PROPS.filter(\n (propName) => props[propName] !== undefined,\n );\n if (!inertProps.length) return;\n warnedRef.current = true;\n console.error(\n `@acusti/dropdown: ${inertProps.join(', ')} only apply to a top-level Dropdown and are ignored on a nested (submenu) Dropdown.`,\n );\n });\n\n const childrenCount = Children.count(children);\n let labelContent: ReactNode = label;\n let body: ReactNode = children;\n if (childrenCount > 1) {\n labelContent = (children as ChildrenTuple)[0];\n body = (children as ChildrenTuple)[1];\n }\n\n // popover=\"manual\" renders the submenu in the top layer (see the\n // [data-ukt-submenu] CSS and handleToggleSubmenu), escaping the body’s\n // containing block so its anchor placement is correct across browsers. The\n // root dropdown’s engine calls showPopover/hidePopover as the item toggles.\n const submenu = isValidElement(body) ? (\n cloneElement(body as ReactElement<Record<string, unknown>>, {\n 'data-ukt-submenu': '',\n popover: 'manual',\n })\n ) : (\n <div data-ukt-submenu=\"\" popover=\"manual\">\n {body}\n </div>\n );\n\n return (\n <li\n aria-disabled={disabled || undefined}\n className={className}\n data-ukt-item=\"\"\n ref={itemRef}\n style={style}\n >\n {labelContent}\n {submenu}\n </li>\n );\n}\n\nexport { default as Menubar, type MenubarProps } from './Menubar.js';\n"],"mappings":";;;;;;;AAkBA,IAAaa,kBAAkBb,cAA2C,IAAI;AAiB9E,IAAa2B,iBAAiB3B,cAA0C,IAAI;;;;;;AE9B5E,IAAakC,gBAAgB;AAC7B,IAAaC,mBAAmB;AAEhC,IAAMC,yBAAyB;AAM/B,IAAMM,kBAAkBC,oBACnBA,iBAAiBC,cAAc,mBAAmB,KAAK;AAI5D,IAAaC,gBAAgBC,YACzBA,QAAQC,QAAQZ,gBAAgB;AAGpC,IAAaa,oBAAoBV,SAAwC;CACrE,MAAMW,UAAUX,KAAKM,cAAcT,gBAAgB;CACnD,IAAI,CAACc,SAAS,OAAO;CAErB,OADcA,QAAQE,eAAeJ,QAAAA,mCAAqB,MACzCT,OAAOW,UAAU;AACtC;AAGA,IAAaG,iBAAiBC,cACzBA,UAAUF,eAAeJ,QAAAA,mCAAqB,KAAK;AAGxD,IAAaO,gBAAgBhB,SAA8B;CACvD,IAAI,CAACU,iBAAiBV,IAAI,GAAG,OAAOA,KAAKiB,aAAa;CACtD,MAAMC,QAAQlB,KAAKmB,UAAU,IAAI;CACjC,KAAK,MAAMR,WAAWS,MAAMC,KAAKH,MAAMI,iBAAiBzB,gBAAgB,CAAC,GACrEc,QAAQY,OAAO;CAEnB,QAAQL,MAAMM,eAAe,GAAA,CAAIC,KAAK;AAC1C;AAOA,IAAMC,eAAeC,SAA4B;CAC7C,IAAIC,OAAO;CACXrC,SAASsC,QAAQF,OAAOG,UAAU;EAC9B,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