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

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.
package/README.md CHANGED
@@ -514,9 +514,9 @@ Example:
514
514
 
515
515
  ```css
516
516
  .settings-dropdown {
517
- --uktdd-body-position-area: bottom span-left;
517
+ --uktdd-body-position-area: block-end span-inline-start;
518
518
  --uktdd-body-position-try-fallbacks:
519
- --uktdd-top-right, --uktdd-bottom-left, --uktdd-top-left;
519
+ --uktdd-top-end, --uktdd-bottom-start, --uktdd-top-start;
520
520
  --uktdd-body-gap: 8px;
521
521
  }
522
522
 
@@ -528,6 +528,54 @@ Example:
528
528
  This approach keeps the public React API small while still allowing precise
529
529
  placement and sizing control when a product surface needs it.
530
530
 
531
+ ### Changing the Default Direction
532
+
533
+ `--uktdd-body-position-area` and `--uktdd-body-position-try-fallbacks`
534
+ always change together. `--uktdd-body-position-area` is the primary
535
+ placement, used whenever it fits in the viewport — that’s what actually
536
+ determines the direction a dropdown opens by default. The fallbacks list is
537
+ only consulted when the primary placement doesn’t fit, so overriding it
538
+ alone changes nothing in the common case where the primary already fits.
539
+ Overriding the primary alone works, but leaves behind a fallback cascade
540
+ tuned for the old primary — in a cramped viewport, the dropdown can fall
541
+ back toward the direction you just moved away from.
542
+
543
+ The four `@position-try` blocks the component ships (`--uktdd-top-start`,
544
+ `--uktdd-top-end`, `--uktdd-bottom-start`, `--uktdd-bottom-end`) are named
545
+ for the aligned edge, not the direction the body extends toward: `start`
546
+ opens with the body’s inline-start edge flush with the trigger’s
547
+ inline-start edge (extending toward inline-end), and `end` is the mirror
548
+ image. This also means they’re RTL-safe — `start`/`end` follow the
549
+ document’s writing direction the way `left`/`right` wouldn’t. The values
550
+ pair `block-start`/`block-end` with `span-inline-start`/`span-inline-end`
551
+ rather than `top`/`bottom` — `position-area` doesn’t allow mixing a
552
+ physical keyword on one axis with a logical one on the other — though
553
+ `block-start`/`block-end` read as `top`/`bottom` in the near-universal
554
+ horizontal-tb writing mode.
555
+
556
+ Pick the row matching the direction you want, and set both variables to its
557
+ pair:
558
+
559
+ | Direction | `--uktdd-body-position-area` | `--uktdd-body-position-try-fallbacks` |
560
+ | ----------------------------------- | ------------------------------- | ------------------------------------------------------------- |
561
+ | Bottom, start-aligned (the default) | `block-end span-inline-end` | `--uktdd-top-start, --uktdd-bottom-end, --uktdd-top-end` |
562
+ | Bottom, end-aligned | `block-end span-inline-start` | `--uktdd-top-end, --uktdd-bottom-start, --uktdd-top-start` |
563
+ | Top, start-aligned | `block-start span-inline-end` | `--uktdd-bottom-start, --uktdd-top-end, --uktdd-bottom-end` |
564
+ | Top, end-aligned | `block-start span-inline-start` | `--uktdd-bottom-end, --uktdd-top-start, --uktdd-bottom-start` |
565
+
566
+ For example, to make a dropdown open upward and end-aligned (useful for a
567
+ trigger pinned to the bottom of the viewport, near the inline-end edge):
568
+
569
+ ```css
570
+ .bottom-toolbar-dropdown {
571
+ --uktdd-body-position-area: block-start span-inline-start;
572
+ --uktdd-body-position-try-fallbacks:
573
+ --uktdd-bottom-end, --uktdd-top-start, --uktdd-bottom-start;
574
+ }
575
+ ```
576
+
577
+ See the `DirectionRecipes` story for a live demo of all four.
578
+
531
579
  Use `--uktdd-body-gap` for the space between the trigger and the body. It
532
580
  is applied as a symmetric `margin-block`, so the gap lands on whichever
533
581
  side the body attaches to and auto-reverses when `position-try` flips the
@@ -548,9 +596,9 @@ the menu size itself from its contents.
548
596
 
549
597
  ```css
550
598
  .avatar-menu {
551
- --uktdd-body-position-area: bottom span-left;
599
+ --uktdd-body-position-area: block-end span-inline-start;
552
600
  --uktdd-body-position-try-fallbacks:
553
- --uktdd-top-right, --uktdd-top-left, --uktdd-bottom-right;
601
+ --uktdd-top-end, --uktdd-top-start, --uktdd-bottom-end;
554
602
  }
555
603
  ```
556
604
 
package/dist/Dropdown.js CHANGED
@@ -9,7 +9,7 @@ var DropdownContext = createContext(null);
9
9
  var MenubarContext = createContext(null);
10
10
  //#endregion
11
11
  //#region src/Dropdown.css?inline
12
- var Dropdown_default = ":root{--uktdd-font-family:system-ui, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, Helvetica, Arial, sans-serif;--uktdd-body-bg-color:#fff;--uktdd-body-bg-color-hover:#69a2f9;--uktdd-body-color-hover:#fff;--uktdd-body-buffer:10px;--uktdd-body-max-height:calc(100dvh - var(--uktdd-body-buffer));--uktdd-body-max-width:calc(100dvw - var(--uktdd-body-buffer));--uktdd-body-min-height:30px;--uktdd-body-pad-bottom:.5em;--uktdd-body-pad-left:.6875em;--uktdd-body-pad-right:.6875em;--uktdd-body-pad-top:.5em;--uktdd-body-min-width:min(50px, 100%);--uktdd-body-position-area:bottom span-right;--uktdd-body-position-try-fallbacks:--uktdd-top-left, --uktdd-bottom-right, --uktdd-top-right;--uktdd-body-gap:0px;--uktdd-body-color:canvastext;--uktdd-body-bg-color-path:#dcdcdc;--uktdd-body-color-path:currentColor;--uktdd-label-pad-right:.625em;--uktdd-submenu-position-area:inline-end span-block-end;--uktdd-submenu-position-try-fallbacks:--uktdd-submenu-inline-start;--uktdd-submenu-gap:0px;--uktdd-menubar-trigger-bg-color-active:#0000001f}.uktdropdown,.uktdropdown-trigger{font-family:var(--uktdd-font-family)}.uktdropdown{anchor-scope:--uktdd-anchor;width:max-content}.uktdropdown.disabled{pointer-events:none}.uktdropdown>*{cursor:default}.uktdropdown>:first-child{anchor-name:--uktdd-anchor}.uktdropdown-label{align-items:center;display:flex}.uktdropdown-label-text{padding-right:var(--uktdd-label-pad-right)}.uktdropdown-body{box-sizing:border-box;position-anchor:--uktdd-anchor;position-area:var(--uktdd-body-position-area);position-try-order:most-height;position-try-fallbacks:var(--uktdd-body-position-try-fallbacks);min-block-size:min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));max-block-size:min(var(--uktdd-body-max-height), 100%);min-inline-size:min(var(--uktdd-body-min-width), var(--uktdd-body-max-width));max-inline-size:var(--uktdd-body-max-width);inline-size:max-content;color:inherit;background-color:var(--uktdd-body-bg-color);flex-direction:column;display:flex;position:fixed;overflow:hidden;box-shadow:0 8px 18px #00000040}.uktdropdown-body.has-items{-webkit-user-select:none;user-select:none}.uktdropdown-body [data-ukt-active]{background-color:var(--uktdd-body-bg-color-hover);color:var(--uktdd-body-color-hover)}:is(.uktdropdown-body [data-ukt-active]:has([data-ukt-submenu] [data-ukt-active]),.uktdropdown-body [data-ukt-active]:has([data-ukt-submenu]:hover)){background-color:var(--uktdd-body-bg-color-path);color:var(--uktdd-body-color-path)}.uktdropdown-body [data-ukt-item][aria-disabled=true]{opacity:.5;pointer-events:none}.uktdropdown-body [data-ukt-item]{anchor-scope:--uktdd-submenu-anchor}.uktdropdown-body :is([data-ukt-item],[data-ukt-value])[aria-haspopup=menu]{padding-inline-end:2em;position:relative}.uktdropdown-body :is([data-ukt-item],[data-ukt-value])[aria-haspopup=menu]:after{content:\"\";border-block-start:.14em solid;border-inline-end:.14em solid;block-size:.3em;inline-size:.3em;position:absolute;inset-block-start:50%;inset-inline-end:.9em;translate:0 -50%;rotate:45deg}.uktdropdown-body :is([data-ukt-item],[data-ukt-value])[aria-haspopup=menu]:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)):after{rotate:-45deg}.uktdropdown-body [data-ukt-item][aria-expanded=true]{anchor-name:--uktdd-submenu-anchor}.uktdropdown-body [data-ukt-item][aria-expanded=true]>[data-ukt-submenu]{display:block}.uktdropdown-body [data-ukt-submenu]{box-sizing:border-box;color:var(--uktdd-body-color);position-anchor:--uktdd-submenu-anchor;position-area:var(--uktdd-submenu-position-area);position-try-fallbacks:var(--uktdd-submenu-position-try-fallbacks);z-index:2;margin-block:0;margin-inline:var(--uktdd-submenu-gap);padding:var(--uktdd-body-pad-top) var(--uktdd-body-pad-right) var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);inline-size:max-content;max-inline-size:var(--uktdd-body-max-width);max-block-size:var(--uktdd-body-max-height);overscroll-behavior:contain;background-color:var(--uktdd-body-bg-color);list-style:none;display:none;position:fixed;overflow:auto;box-shadow:0 8px 18px #00000040}div.uktdropdown-body{block-size:auto;margin-block:var(--uktdd-body-gap);border:0;margin-inline:0;padding:0;inset:auto}.uktmenubar{width:max-content;font-family:var(--uktdd-font-family);align-items:stretch;display:flex}.uktmenubar .uktdropdown.is-open .uktdropdown-trigger{box-shadow:inset 0 0 0 100vmax var(--uktdd-menubar-trigger-bg-color-active)}.uktdropdown-content{box-sizing:border-box;overscroll-behavior:contain;min-block-size:0;padding:var(--uktdd-body-pad-top) var(--uktdd-body-pad-right) var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);overflow:auto}@position-try --uktdd-top-left{position-area: top span-right;}@position-try --uktdd-bottom-left{position-area: bottom span-right;}@position-try --uktdd-bottom-right{position-area: bottom span-left;}@position-try --uktdd-top-right{position-area: top span-left;}@position-try --uktdd-submenu-inline-start{position-area: inline-start span-block-end;}";
12
+ var Dropdown_default = ":root{--uktdd-font-family:system-ui, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, Helvetica, Arial, sans-serif;--uktdd-body-bg-color:#fff;--uktdd-body-bg-color-hover:#69a2f9;--uktdd-body-color-hover:#fff;--uktdd-body-buffer:10px;--uktdd-body-max-height:calc(100dvh - var(--uktdd-body-buffer));--uktdd-body-max-width:calc(100dvw - var(--uktdd-body-buffer));--uktdd-body-min-height:30px;--uktdd-body-pad-bottom:.5em;--uktdd-body-pad-left:.6875em;--uktdd-body-pad-right:.6875em;--uktdd-body-pad-top:.5em;--uktdd-body-min-width:min(50px, 100%);--uktdd-body-position-area:block-end span-inline-end;--uktdd-body-position-try-fallbacks:--uktdd-top-start, --uktdd-bottom-end, --uktdd-top-end;--uktdd-body-gap:0px;--uktdd-body-color:canvastext;--uktdd-body-bg-color-path:#dcdcdc;--uktdd-body-color-path:currentColor;--uktdd-label-pad-right:.625em;--uktdd-submenu-position-area:inline-end span-block-end;--uktdd-submenu-position-try-fallbacks:--uktdd-submenu-inline-start;--uktdd-submenu-gap:0px;--uktdd-menubar-trigger-bg-color-active:#0000001f}.uktdropdown,.uktdropdown-trigger{font-family:var(--uktdd-font-family)}.uktdropdown{anchor-scope:--uktdd-anchor;width:max-content}.uktdropdown.disabled{pointer-events:none}.uktdropdown>*{cursor:default}.uktdropdown>:first-child{anchor-name:--uktdd-anchor}.uktdropdown-label{align-items:center;display:flex}.uktdropdown-label-text{padding-right:var(--uktdd-label-pad-right)}.uktdropdown-body{box-sizing:border-box;position-anchor:--uktdd-anchor;position-area:var(--uktdd-body-position-area);position-try-order:most-height;position-try-fallbacks:var(--uktdd-body-position-try-fallbacks);min-block-size:min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));max-block-size:min(var(--uktdd-body-max-height), 100%);min-inline-size:min(var(--uktdd-body-min-width), var(--uktdd-body-max-width));max-inline-size:var(--uktdd-body-max-width);inline-size:max-content;color:inherit;background-color:var(--uktdd-body-bg-color);flex-direction:column;display:flex;position:fixed;overflow:hidden;box-shadow:0 8px 18px #00000040}.uktdropdown-body.has-items{-webkit-user-select:none;user-select:none}.uktdropdown-body [data-ukt-active]{background-color:var(--uktdd-body-bg-color-hover);color:var(--uktdd-body-color-hover)}:is(.uktdropdown-body [data-ukt-active]:has([data-ukt-submenu] [data-ukt-active]),.uktdropdown-body [data-ukt-active]:has([data-ukt-submenu]:hover)){background-color:var(--uktdd-body-bg-color-path);color:var(--uktdd-body-color-path)}.uktdropdown-body [data-ukt-item][aria-disabled=true]{opacity:.5;pointer-events:none}.uktdropdown-body [data-ukt-item]{anchor-scope:--uktdd-submenu-anchor}.uktdropdown-body :is([data-ukt-item],[data-ukt-value])[aria-haspopup=menu]{padding-inline-end:2em;position:relative}.uktdropdown-body :is([data-ukt-item],[data-ukt-value])[aria-haspopup=menu]:after{content:\"\";border-block-start:.14em solid;border-inline-end:.14em solid;block-size:.3em;inline-size:.3em;position:absolute;inset-block-start:50%;inset-inline-end:.9em;translate:0 -50%;rotate:45deg}.uktdropdown-body :is([data-ukt-item],[data-ukt-value])[aria-haspopup=menu]:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)):after{rotate:-45deg}.uktdropdown-body [data-ukt-item][aria-expanded=true]{anchor-name:--uktdd-submenu-anchor}.uktdropdown-body [data-ukt-item][aria-expanded=true]>[data-ukt-submenu]{display:block}.uktdropdown-body [data-ukt-submenu]{box-sizing:border-box;color:var(--uktdd-body-color);position-anchor:--uktdd-submenu-anchor;position-area:var(--uktdd-submenu-position-area);position-try-fallbacks:var(--uktdd-submenu-position-try-fallbacks);z-index:2;margin-block:0;margin-inline:var(--uktdd-submenu-gap);padding:var(--uktdd-body-pad-top) var(--uktdd-body-pad-right) var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);inline-size:max-content;max-inline-size:var(--uktdd-body-max-width);max-block-size:var(--uktdd-body-max-height);overscroll-behavior:contain;background-color:var(--uktdd-body-bg-color);list-style:none;display:none;position:fixed;overflow:auto;box-shadow:0 8px 18px #00000040}div.uktdropdown-body{block-size:auto;margin-block:var(--uktdd-body-gap);border:0;margin-inline:0;padding:0;inset:auto}.uktmenubar{width:max-content;font-family:var(--uktdd-font-family);align-items:stretch;display:flex}.uktmenubar .uktdropdown.is-open .uktdropdown-trigger{box-shadow:inset 0 0 0 100vmax var(--uktdd-menubar-trigger-bg-color-active)}.uktdropdown-content{box-sizing:border-box;overscroll-behavior:contain;min-block-size:0;padding:var(--uktdd-body-pad-top) var(--uktdd-body-pad-right) var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);overflow:auto}@position-try --uktdd-top-start{position-area: block-start span-inline-end;}@position-try --uktdd-bottom-start{position-area: block-end span-inline-end;}@position-try --uktdd-bottom-end{position-area: block-end span-inline-start;}@position-try --uktdd-top-end{position-area: block-start span-inline-start;}@position-try --uktdd-submenu-inline-start{position-area: inline-start span-block-end;}";
13
13
  //#endregion
14
14
  //#region src/helpers.ts
15
15
  var ITEM_SELECTOR = "[data-ukt-item], [data-ukt-value]";
@@ -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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C;EACJrR,EAAA,KAAAD;EAAAC,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAVD7E,UAAUmF,EAUT;CAED,MAAAI,gBAAsBlG,SAAQmG,MAAOhD,QAAQ;CAC7C,IAAA2T,eAA8BnU;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","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: 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 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/* 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","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,YAAY;EACjB,MAAMC,QAAQb,aAAaY,UAAU;EACrCD,KAAKG,QAAQ;GAAED;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jB4Q,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acusti/dropdown",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.4",
4
4
  "description": "React component that renders a dropdown with a trigger and supports searching, keyboard access, and more",
5
5
  "keywords": [
6
6
  "a11y",