@acusti/dropdown 1.0.0-beta.0 → 1.0.0-beta.1

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
@@ -190,20 +190,33 @@ is the one you want.
190
190
  ## Color Scheme
191
191
 
192
192
  The default colors are drawn from CSS system colors (`Canvas`,
193
- `CanvasText`, `Highlight`, `HighlightText`) and `color-mix()` blends
194
- against `CanvasText`, rather than fixed light-mode values, so the dropdown
195
- looks native in whichever color scheme is in effect.
196
- `--uktdd-body-box-shadow` is the exception — a fixed `rgba(0, 0, 0, 0.25)`
197
- rather than a scheme-aware mix, since mixing in `CanvasText` turns it into
198
- a diffuse white glow in dark mode instead of a shadow. `color-scheme` (set
199
- via `--uktdd-color-scheme`, default `inherit`) is left to inherit from the
200
- host page rather than forced to `light dark`: the popover is page content,
201
- not OS chrome, so it matches whatever scheme the page itself has opted into
202
- — light, if the page hasn’t adopted dark mode — rather than following the
203
- OS/browser preference regardless of the page. Set `--uktdd-color-scheme` to
204
- `light dark` (or `light`/`dark`) to follow the user’s preference
205
- irrespective of the host page instead. Override any of the
206
- `--uktdd-body-bg-color*` / `--uktdd-body-color*` /
193
+ `CanvasText`, `Highlight`, `HighlightText`) rather than fixed light-mode
194
+ values, so the dropdown looks native in whichever color scheme is in
195
+ effect.
196
+
197
+ The tints layered over the body — `--uktdd-body-bg-color-selected`,
198
+ `--uktdd-body-border-color`, and `--uktdd-body-bg-color-path` — are
199
+ `color-mix()` blends that derive from the body’s own foreground and
200
+ background rather than from `CanvasText`/`Canvas` directly, so theming the
201
+ surface carries them with it: set `--uktdd-body-color` and
202
+ `--uktdd-body-bg-color` and the selected tint, hairline border, and
203
+ active-path step all re-derive from the pair you set. That matters because
204
+ a `var()` inside a custom property is substituted where that property is
205
+ declared, so a `:root` default blended against `CanvasText` would freeze to
206
+ the ambient color scheme before a consumer’s override could reach it — a
207
+ dark menu on a light page would keep a black hairline it can’t show. Each
208
+ one is still a plain custom property, so setting it directly overrides the
209
+ derived default outright. `--uktdd-body-box-shadow` is the exception — a
210
+ fixed `rgba(0, 0, 0, 0.25)` rather than a scheme-aware mix, since mixing in
211
+ `CanvasText` turns it into a diffuse white glow in dark mode instead of a
212
+ shadow. `color-scheme` (set via `--uktdd-color-scheme`, default `inherit`)
213
+ is left to inherit from the host page rather than forced to `light dark`:
214
+ the popover is page content, not OS chrome, so it matches whatever scheme
215
+ the page itself has opted into — light, if the page hasn’t adopted dark
216
+ mode — rather than following the OS/browser preference regardless of the
217
+ page. Set `--uktdd-color-scheme` to `light dark` (or `light`/`dark`) to
218
+ follow the user’s preference irrespective of the host page instead.
219
+ Override any of the `--uktdd-body-bg-color*` / `--uktdd-body-color*` /
207
220
  `--uktdd-body-box-shadow` custom properties to theme it further.
208
221
  `--uktdd-menubar-trigger-bg-color-active` blends against `currentColor`
209
222
  instead, so it stays visible against a menubar trigger that the consumer
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-color-scheme:inherit;--uktdd-body-bg-color:Canvas;--uktdd-body-bg-color-hover:Highlight;--uktdd-body-color-hover:HighlightText;--uktdd-body-bg-color-selected:color-mix(in oklab, CanvasText 6%, transparent);--uktdd-body-box-shadow:0 8px 18px #00000040;--uktdd-body-border-color:color-mix(in oklab, CanvasText 15%, transparent);--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-fallback-1:--uktdd-top-start;--uktdd-body-position-try-fallback-2:--uktdd-bottom-end;--uktdd-body-fill-fallbacks:--uktdd-fill-bottom, --uktdd-fill-top;--uktdd-body-gap:0px;--uktdd-body-color:CanvasText;--uktdd-body-bg-color-path:color-mix(in oklab, CanvasText 12%, Canvas);--uktdd-body-color-path:currentColor;--uktdd-label-pad-right:.625em;--uktdd-submenu-position-area:inline-end span-block-end;--uktdd-submenu-position-try-fallback:--uktdd-submenu-inline-start;--uktdd-submenu-fill-fallbacks:--uktdd-submenu-fill, --uktdd-submenu-fill flip-inline;--uktdd-submenu-gap:0px;--uktdd-menubar-trigger-bg-color-active:color-mix(in oklab, currentColor 12%, transparent)}.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-fallbacks:var(--uktdd-body-position-try-fallback-1), var(--uktdd-body-position-try-fallback-2), var(--uktdd-body-fill-fallbacks);min-block-size:min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));max-block-size:var(--uktdd-body-max-height);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:var(--uktdd-body-color);color-scheme:var(--uktdd-color-scheme);background-color:var(--uktdd-body-bg-color);box-shadow:var(--uktdd-body-box-shadow);flex-direction:column;display:flex;position:fixed;overflow:hidden}.uktdropdown-body.has-items{-webkit-user-select:none;user-select:none}.uktdropdown-body [aria-selected=true]{background-color:var(--uktdd-body-bg-color-selected)}.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-submenu]:not([popover]){display:none}.uktdropdown-body [data-ukt-submenu]{box-sizing:border-box;border:1px solid var(--uktdd-body-border-color);block-size:auto;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-fallback), var(--uktdd-submenu-fill-fallbacks);z-index:2;margin-block:0;margin-inline:var(--uktdd-submenu-gap);--uktdd-body-gap:0px;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);min-block-size:min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));max-block-size:var(--uktdd-body-max-height);overscroll-behavior:contain;background-color:var(--uktdd-body-bg-color);box-shadow:var(--uktdd-body-box-shadow);list-style:none;position:fixed;inset:auto;overflow:auto}div.uktdropdown-body{block-size:auto;margin-block:var(--uktdd-body-gap);border:1px solid var(--uktdd-body-border-color);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-noop{ }@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;}@position-try --uktdd-fill-bottom{position-area: block-end; block-size: calc(100% - var(--uktdd-body-gap) * 2); min-block-size: min(var(--uktdd-body-min-height), var(--uktdd-body-max-height), calc((100dvb - anchor-size(block)) / 2 - var(--uktdd-body-gap) * 2)); justify-self: anchor-center;}@position-try --uktdd-fill-top{position-area: block-start; block-size: calc(100% - var(--uktdd-body-gap) * 2); min-block-size: min(var(--uktdd-body-min-height), var(--uktdd-body-max-height), calc((100dvb - anchor-size(block)) / 2 - var(--uktdd-body-gap) * 2)); justify-self: anchor-center;}@position-try --uktdd-fill{block-size: calc(100% - var(--uktdd-body-gap) * 2);}@position-try --uktdd-submenu-fill{position-area: inline-end; block-size: calc(100% - var(--uktdd-body-gap) * 2); align-self: anchor-center;}@position-try --uktdd-fill-cover{position-area: span-all span-inline-end; block-size: calc(100% - var(--uktdd-body-gap) * 2); align-self: anchor-center;}";
12
+ var Dropdown_default = ":root{--uktdd-font-family:system-ui, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, Helvetica, Arial, sans-serif;--uktdd-color-scheme:inherit;--uktdd-body-bg-color:Canvas;--uktdd-body-bg-color-hover:Highlight;--uktdd-body-color-hover:HighlightText;--uktdd-body-bg-color-selected:color-mix(in oklab, currentColor 6%, transparent);--uktdd-body-box-shadow:0 8px 18px #00000040;--uktdd-body-border-color:color-mix(in oklab, currentColor 15%, transparent);--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-fallback-1:--uktdd-top-start;--uktdd-body-position-try-fallback-2:--uktdd-bottom-end;--uktdd-body-fill-fallbacks:--uktdd-fill-bottom, --uktdd-fill-top;--uktdd-body-gap:0px;--uktdd-body-color:CanvasText;--uktdd-body-color-path:currentColor;--uktdd-label-pad-right:.625em;--uktdd-submenu-position-area:inline-end span-block-end;--uktdd-submenu-position-try-fallback:--uktdd-submenu-inline-start;--uktdd-submenu-fill-fallbacks:--uktdd-submenu-fill, --uktdd-submenu-fill flip-inline;--uktdd-submenu-gap:0px;--uktdd-menubar-trigger-bg-color-active:color-mix(in oklab, currentColor 12%, transparent)}.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-fallbacks:var(--uktdd-body-position-try-fallback-1), var(--uktdd-body-position-try-fallback-2), var(--uktdd-body-fill-fallbacks);min-block-size:min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));max-block-size:var(--uktdd-body-max-height);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:var(--uktdd-body-color);color-scheme:var(--uktdd-color-scheme);background-color:var(--uktdd-body-bg-color);box-shadow:var(--uktdd-body-box-shadow);flex-direction:column;display:flex;position:fixed;overflow:hidden}.uktdropdown-body.has-items{-webkit-user-select:none;user-select:none}.uktdropdown-body [aria-selected=true]{background-color:var(--uktdd-body-bg-color-selected)}.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-mix(in oklab, var(--uktdd-body-color) 12%, var(--uktdd-body-bg-color)));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-submenu]:not([popover]){display:none}.uktdropdown-body [data-ukt-submenu]{box-sizing:border-box;border:1px solid var(--uktdd-body-border-color);block-size:auto;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-fallback), var(--uktdd-submenu-fill-fallbacks);z-index:2;margin-block:0;margin-inline:var(--uktdd-submenu-gap);--uktdd-body-gap:0px;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);min-block-size:min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));max-block-size:var(--uktdd-body-max-height);overscroll-behavior:contain;background-color:var(--uktdd-body-bg-color);box-shadow:var(--uktdd-body-box-shadow);list-style:none;position:fixed;inset:auto;overflow:auto}div.uktdropdown-body{block-size:auto;margin-block:var(--uktdd-body-gap);border:1px solid var(--uktdd-body-border-color);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-noop{ }@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;}@position-try --uktdd-fill-bottom{position-area: block-end; block-size: calc(100% - var(--uktdd-body-gap) * 2); min-block-size: min(var(--uktdd-body-min-height), var(--uktdd-body-max-height), calc((100dvb - anchor-size(block)) / 2 - var(--uktdd-body-gap) * 2)); justify-self: anchor-center;}@position-try --uktdd-fill-top{position-area: block-start; block-size: calc(100% - var(--uktdd-body-gap) * 2); min-block-size: min(var(--uktdd-body-min-height), var(--uktdd-body-max-height), calc((100dvb - anchor-size(block)) / 2 - var(--uktdd-body-gap) * 2)); justify-self: anchor-center;}@position-try --uktdd-fill{block-size: calc(100% - var(--uktdd-body-gap) * 2);}@position-try --uktdd-submenu-fill{position-area: inline-end; block-size: calc(100% - var(--uktdd-body-gap) * 2); align-self: anchor-center;}@position-try --uktdd-fill-cover{position-area: span-all span-inline-end; block-size: calc(100% - var(--uktdd-body-gap) * 2); align-self: anchor-center;}";
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","Children","isValidElement","ReactNode","SyntheticEvent","Item","ITEM_SELECTOR","SUBMENU_SELECTOR","DISABLED_ITEM_SELECTOR","OnToggleSubmenu","item","HTMLElement","isExpanded","MaybeHTMLElement","getBodyElement","dropdownElement","querySelector","getLevelRoot","element","closest","getSubmenuOfItem","submenu","owner","parentElement","getParentItem","levelRoot","getItemLabel","innerText","clone","cloneNode","Array","from","querySelectorAll","remove","textContent","trim","getNodeText","node","text","forEach","child","childProps","props","children","undefined","getLabelFromChildren","value","label","visit","uktValue","String","replace","getItemPath","path","parentItem","unshift","dataset","getItemElements","bodyElement","root","candidates","length","filter","matches","items","HTMLCollection","getItemForTarget","target","targetLevelRoot","contains","itemElements","find","itemElement","getActiveItemElements","actives","getActiveItemElement","getDeepestExpandedItem","expanded","isItemExpanded","getAttribute","submenuIdCounter","ensureSubmenuARIA","hasAttribute","setAttribute","id","annotateParentItems","annotateItemRoles","popupRole","list","isMenuItem","expandItem","onToggleSubmenu","collapseItem","expandedDescendants","descendant","active","uktActive","collapseItemsOutsidePath","expandedItems","reverse","clearItemElementsState","setActiveChain","chain","Set","add","has","BaseSetActiveItemPayload","event","Event","index","indexAddend","isExactMatch","onActiveItem","payload","setActiveItem","Omit","currentDeepest","lastIndex","currentActiveIndex","findIndex","nextActiveIndex","Math","max","min","itemTexts","map","textToCompare","toLowerCase","itemText","startsWith","bestMatch","nextActiveItem","scrollableParent","isScrollable","scrollHeight","clientHeight","parentRect","getBoundingClientRect","itemRect","isAboveTop","top","isBelowBottom","bottom","scrollTop","Point","x","y","isPointInTriangle","p","a","b","c","cross","u","v","w","d1","d2","d3","hasNegative","hasPositive","clsx","CSSProperties","FocusEvent","ReactFocusEvent","KeyboardEvent","ReactKeyboardEvent","MouseEvent","ReactMouseEvent","ReactNode","useMemo","useRef","MenubarContext","MenubarContextValue","MenubarMember","MenubarProps","children","className","style","compareDocumentOrder","a","b","element","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","NON_MENU_CONTROL_SELECTOR","Menubar","t0","$","_c","t1","Symbol","for","Set","membersRef","engagedMemberRef","t2","Array","from","current","sort","getOrderedMembersRef","getOrderedMembers","t3","moveOpen","fromElement","direction","members","length","index","findIndex","member","nextIndex","close","open","focusTrigger","notifyClosed","notifyOpened","element_0","member_0","isOpen","registerMember","member_1","add","delete","contextValue","t4","event","key","members_0","some","_temp","eventTarget","target","HTMLElement","index_0","member_3","contains","preventDefault","stopPropagation","direction_0","handleKeyDown","t5","eventTarget_0","members_1","m","member_4","find","m_0","closest","openMember","switchToMemberAt","t6","event_0","handleFocus","t7","event_1","handleMouseOver","t8","t9","t10","member_2","useKeyboardEvents","isEventTargetUsingKeyEvent","clsx","Children","cloneElement","CSSProperties","Fragment","isValidElement","MouseEvent","ReactMouseEvent","ReactElement","ReactNode","SyntheticEvent","useContext","useEffect","useId","useMemo","useRef","useState","DropdownContext","DropdownContextValue","MenubarContext","SubmenuRegistration","styles","annotateItemRoles","annotateParentItems","collapseItem","collapseItemsOutsidePath","expandItem","getActiveItemElement","getDeepestExpandedItem","getItemElements","getItemForTarget","getItemPath","getLabelFromChildren","getLevelRoot","getParentItem","getSubmenuOfItem","isItemExpanded","isPointInTriangle","Point","setActiveItem","Item","element","MaybeHTMLElement","event","Event","HTMLElement","label","path","Array","ItemValue","value","Props","allowCreate","allowEmpty","children","ChildrenTuple","className","disabled","hasItems","isOpenOnMount","isSearchable","keepOpenOnSubmit","name","onActiveItem","payload","onClick","onClose","onMouseDown","onMouseUp","onOpen","onSubmitItem","openOnHover","placeholder","style","Record","tabIndex","MousePosition","clientX","clientY","TimeoutID","ReturnType","setTimeout","CHILDREN_ERROR","CLICKABLE_SELECTOR","FOCUSABLE_SELECTOR","TEXT_INPUT_SELECTOR","SUBMENU_DISCLOSURE_DELAY","SAFE_AREA_TIMEOUT","HOVER_CLOSE_DELAY","Dropdown","props","$","_c","parentDropdown","t0","RootDropdown","t1","t2","t3","styleFromProps","undefined","childrenCount","count","Error","console","error","trigger","body","valueIdentity","t4","valueLabel","isOpen","setIsOpen","isOpening","setIsOpening","dropdownElement","setDropdownElement","bodyId","popupRole","menubar","inputElementRef","consumerOwnsARIASelectedRef","t5","Symbol","for","WeakSet","annotatedBodiesRef","closingTimerRef","isOpeningTimerRef","currentInputMethodRef","clearEnteredCharactersTimerRef","enteredCharactersRef","mouseDownPositionRef","disclosureTimerRef","pendingDisclosureItemRef","t6","Set","submenuRegistrationsRef","pointerRef","lastMouseEventRef","safeAreaRef","safeAreaTimerRef","wasInSafeAreaRef","hoverCloseTimerRef","allowCreateRef","allowEmptyRef","hasItemsRef","isOpenRef","isOpeningRef","keepOpenOnSubmitRef","onCloseRef","onOpenRef","onSubmitItemRef","valueRef","t7","t8","current","isMountedRef","t10","t9","t11","registerSubmenu","registration","add","delete","dropdownContextValue","t12","key","registration_0","contains","dispatchToSubmenus","t13","payload_0","handleActiveItem","t14","item","isExpanded","submenu","isShown","matches","showPopover","hidePopover","registration_1","handleToggleSubmenu","t15","clearTimeout","clearDisclosureTimer","t16","t17","t18","activeElement","submenu_0","hasAttribute","syncSubmenuDisclosure","t19","clearSafeAreaTimer","t20","t21","t22","x","y","safeArea","parent","submenu_1","submenuRect","getBoundingClientRect","parentRect","nearX","left","right","apex","top","bottom","isPointerInSafeArea","t23","targetElement","pointer","target","ownerDocument","elementFromPoint","item_0","commitPointerTarget","t24","event_0","pointer_0","nativeEvent","target_0","submenu_2","isOverParent","trackSafeArea","t25","clearHoverCloseTimer","t26","t27","t28","options","keepMenubarEngaged","notifyClosed","closeDropdown","t29","handleDropdownMouseEnter","t30","handleDropdownMouseLeave","t31","firstElementChild","firstChild","focusable","querySelector","focus","focusTrigger","t32","registerMember","close","open","t33","t34","notifyOpened","t35","event_1","submenuOfActive","firstItem","itemLabel","innerText","blur","nextValue","dataset","uktValue","bodyElement","closest","selected","from","querySelectorAll","removeAttribute","setAttribute","eventTarget","click","clickableElements","length","clickableElement","payload_1","handleSubmitItem","t36","event_2","initialPosition","Math","abs","handleMouseMove","t37","event_3","eventTarget_0","hoveredRoot","classList","item_1","handleMouseOver","t38","event_4","relatedTarget","Node","isLeavingDropdown","activeItem","eventRelatedTarget","uktActive","handleMouseOut","t39","event_5","handleMouseDown","t40","event_6","eventTarget_1","clickedRoot","targetBody","isInOwnBody","Boolean","clickedItem","handleMouseUp","t41","event_7","altKey","ctrlKey","key_0","metaKey","eventTarget_2","onEventHandled","stopPropagation","preventDefault","isEventTargetingDropdown","nestedRoot","isTargetUsingKeyEvents","isEditingCharacters","test","slice","isExactMatch","text","index","indexAddend","activeElement_0","submenu_3","firstItem_0","moveOpen","activeElement_1","levelRoot","parentItem","handleKeyDown","t42","ignoreUsedKeyboardEvents","onKeyDown","t43","ref","inputElement","HTMLInputElement","handleGlobalMouseDown","t44","target_1","eventTarget_3","handleGlobalMouseUp","t45","target_2","eventTarget_4","handleGlobalFocusIn","t46","target_3","eventTarget_5","document","addEventListener","handleInput","event_8","input","isDeleting","removeEventListener","handleRef","ref_0","has","selectedItem","find","item_2","handleBodyRef","t47","triggerProps","t48","t49","INERT_SUBMENU_PROPS","const","SubmenuDropdown","itemRef","warnedRef","inertProps","filter","propName","join","labelContent","popover","default","Menubar","MenubarProps"],"sources":["../src/context.ts","../src/Dropdown.css?inline","../src/helpers.ts","../src/Menubar.tsx","../src/Dropdown.tsx"],"sourcesContent":["import { createContext } from 'react';\n\nimport { type Item } from './Dropdown.js';\n\nexport type DropdownContextValue = {\n registerSubmenu: (registration: SubmenuRegistration) => () => void;\n};\n\nexport type SubmenuRegistration = {\n element: HTMLElement;\n onActiveItem?: (payload: Item) => void;\n onClose?: () => unknown;\n onOpen?: () => unknown;\n onSubmitItem?: (payload: Item) => void;\n};\n\n// Provided by a menu Dropdown; a Dropdown that finds this context renders as a\n// submenu (parent item + data-ukt-submenu) instead of a root dropdown.\nexport const DropdownContext = createContext<DropdownContextValue | null>(null);\n\nexport type MenubarContextValue = {\n moveOpen: (fromElement: HTMLElement, direction: -1 | 1) => void;\n notifyClosed: (element: HTMLElement) => void;\n notifyOpened: (element: HTMLElement) => void;\n registerMember: (member: MenubarMember) => () => void;\n};\n\nexport type MenubarMember = {\n close: () => void;\n element: HTMLElement;\n focusTrigger: () => void;\n isOpen: () => boolean;\n open: () => void;\n};\n\nexport const MenubarContext = createContext<MenubarContextValue | null>(null);\n",":root {\n --uktdd-font-family:\n system-ui, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue,\n Helvetica, Arial, sans-serif;\n /* the popover is page content, not OS chrome — a native OS context menu\n always renders in the OS’s own scheme regardless of the host page,\n but this component should match whatever color-scheme the host page\n itself declares (light, if the page hasn’t opted into dark mode),\n so it inherits rather than forcing one. Override to `light dark` (or\n `light`/`dark`) to follow the user’s OS/browser preference instead,\n irrespective of the host page */\n --uktdd-color-scheme: inherit;\n /* Canvas(Text)/Highlight(Text) are UA system colors, so the color defaults\n below need no prefers-color-scheme query of their own to work in both\n schemes. The UA default is light-only regardless of OS/browser preference\n until something opts in, which is what --uktdd-color-scheme above is for */\n --uktdd-body-bg-color: Canvas;\n --uktdd-body-bg-color-hover: Highlight;\n --uktdd-body-color-hover: HighlightText;\n /* the persistent tint on the item matching props.value (the current\n selection), shown even after the active/hover highlight moves off it */\n --uktdd-body-bg-color-selected: color-mix(in oklab, CanvasText 6%, transparent);\n /* shared by the body & submenu (see their box-shadow declarations below).\n A fixed black rather than a CanvasText-based mix: CanvasText is\n near-white in dark mode, so mixing it in turns this into a diffuse\n glow around the body instead of a shadow. Black stays a\n conventional cast shadow in light mode and fades to barely-there in\n dark mode — safe in both, rather than wrong in one */\n --uktdd-body-box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);\n /* a hairline edge, shared by the body & submenu, that does the job the\n shadow can’t on a dark Canvas (a shadow alone is nearly invisible\n against a dark background, unlike on a light one). Unlike the\n shadow, a crisp 1px line has no blur radius to turn into a glow, so\n color-mix against CanvasText is safe here in both schemes */\n --uktdd-body-border-color: color-mix(in oklab, CanvasText 15%, transparent);\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 /* The two author fallbacks, tried in order after the primary placement\n and before the fills. The defaults are the primary’s single-axis\n flips: slot 1 the block flip, slot 2 the inline flip. Change direction\n by resetting --uktdd-body-position-area and both slots together (see\n the recipes in the README). The primary sets the direction, the\n slots are its flips */\n --uktdd-body-position-try-fallback-1: --uktdd-top-start;\n --uktdd-body-position-try-fallback-2: --uktdd-bottom-end;\n /* the last-resort fill placements appended after the fallbacks above\n (see the .uktdropdown-body rule). Overridable so a dropdown that\n prefers opening upward can flip the pair’s order to keep the fill\n on its preferred side: --uktdd-fill-top, --uktdd-fill-bottom */\n --uktdd-body-fill-fallbacks: --uktdd-fill-bottom, --uktdd-fill-top;\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 /* the muted highlight for an ancestor item on the active path (see the\n [data-ukt-active] rules below); mixed against Canvas instead of a\n fixed light gray so it reads as a gray step off the body background\n in both a light and a dark Canvas */\n --uktdd-body-bg-color-path: color-mix(in oklab, CanvasText 12%, Canvas);\n --uktdd-body-color-path: currentColor;\n --uktdd-label-pad-right: 0.625em;\n --uktdd-submenu-position-area: inline-end span-block-end;\n /* the submenu’s only author fallback (the natural opposite placement) */\n --uktdd-submenu-position-try-fallback: --uktdd-submenu-inline-start;\n /* the last-resort fills for a submenu too tall to open beside its parent\n at natural size (see the [data-ukt-submenu] rule). Unlike the body’s\n block-side fills, these keep the submenu beside the parent — macOS\n never covers a parent menu with its submenu — filling the block axis\n and scrolling: --uktdd-submenu-fill on the same side, its flip-inline\n mirror on the other. Each anchor-centers on the block axis, so a\n parent anywhere (including near the block-end edge, where the space\n below it is too short) still gets the full viewport height beside it.\n Overridable to flip the pair for a submenu that opens inline-start */\n --uktdd-submenu-fill-fallbacks:\n --uktdd-submenu-fill, --uktdd-submenu-fill flip-inline;\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 /* tints over whatever background the trigger already has, so a fixed\n black wouldn’t register against a trigger the consumer’s already\n styled dark; color-mix against currentColor (not CanvasText, which\n tracks the ambient color-scheme rather than the trigger’s own\n background) follows whatever foreground the trigger already uses for\n contrast against its own background, so the tint stays visible\n whether or not that matches the page’s color scheme */\n --uktdd-menubar-trigger-bg-color-active: color-mix(\n in oklab,\n currentColor 12%,\n transparent\n );\n}\n\n.uktdropdown,\n.uktdropdown-trigger {\n font-family: var(--uktdd-font-family);\n}\n\n.uktdropdown {\n width: max-content;\n anchor-scope: --uktdd-anchor;\n\n &.disabled {\n pointer-events: none;\n }\n\n > * {\n cursor: default;\n }\n\n > :first-child {\n anchor-name: --uktdd-anchor;\n }\n}\n\n.uktdropdown-label {\n display: flex;\n align-items: center;\n}\n\n.uktdropdown-label-text {\n padding-right: var(--uktdd-label-pad-right);\n}\n\n.uktdropdown-body {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n position: fixed;\n position-anchor: --uktdd-anchor;\n position-area: var(--uktdd-body-position-area);\n /* the primary placement wins whenever the body fits there, then the\n fallbacks are tried in order (no position-try-order: most-height,\n which would move the body to the viewport’s taller side even when\n the primary placement fits). The trailing fill options are the last\n resort when the body fits in none of the placements: each sizes the\n body to the block-axis space on one side of the trigger so the\n content region scrolls. Engines may cap the position options list\n at an implementation-defined length with a spec floor of five, and\n that list includes the base position — so four fallbacks past it\n are guaranteed on every conformant engine. This default budget —\n two named author fallbacks plus these two fills — is exactly four,\n within that floor with no reliance on any engine exceeding it. The\n two author fallbacks are the single-axis flips of the primary (a\n block flip and an inline flip); the both-axes diagonal is dropped\n so the fills stay within the floor, so a trigger crammed into the\n corner diagonal to the primary lands in a fill rather than a fourth\n natural placement (re-tune the primary for edge-pinned triggers).\n Each fill pins one block side, unrejectable on the inline axis\n (span-all can’t overflow horizontally, and anchor-center shifts the\n body as needed to keep it inside the viewport). A fill can only be\n rejected when its side is shorter than its min-block-size floor,\n and the fills cap that floor at the worst-case larger side (see\n their @position-try rules), so at least one of the pair always\n fits */\n position-try-fallbacks:\n var(--uktdd-body-position-try-fallback-1),\n var(--uktdd-body-position-try-fallback-2), var(--uktdd-body-fill-fallbacks);\n min-block-size: min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));\n /* no 100% clamp: a placement is only accepted when the body’s natural\n size fits it, so squeezing is reserved for the --uktdd-fill options */\n max-block-size: var(--uktdd-body-max-height);\n min-inline-size: min(var(--uktdd-body-min-width), var(--uktdd-body-max-width));\n max-inline-size: var(--uktdd-body-max-width);\n inline-size: max-content;\n overflow: hidden;\n /* the body renders in the top layer via popover=\"manual\" so an ancestor’s\n transform / filter / contain can’t become its containing block, and the\n top layer handles stacking (no z-index). The UA-popover box resets that\n must beat a consumer’s global [popover] styles live in the\n div.uktdropdown-body rule below; these cosmetics stay overridable */\n color: var(--uktdd-body-color);\n /* inherited by [data-ukt-submenu] too, since it’s a DOM descendant of\n the body (inheritance follows the DOM tree, not top-layer paint\n order) */\n color-scheme: var(--uktdd-color-scheme);\n background-color: var(--uktdd-body-bg-color);\n box-shadow: var(--uktdd-body-box-shadow);\n\n &.has-items {\n user-select: none;\n }\n\n [aria-selected=\"true\"] {\n background-color: var(--uktdd-body-bg-color-selected);\n }\n\n [data-ukt-active] {\n background-color: var(--uktdd-body-bg-color-hover);\n color: var(--uktdd-body-color-hover);\n }\n\n /* an active item is on the path — not deepest — while a deeper highlight\n exists or the pointer is inside its submenu; macOS mutes the parent\n even when the pointer is over a separator or disabled submenu item */\n [data-ukt-active]:has([data-ukt-submenu] [data-ukt-active]),\n [data-ukt-active]:has([data-ukt-submenu]:hover) {\n background-color: var(--uktdd-body-bg-color-path);\n color: var(--uktdd-body-color-path);\n }\n\n [data-ukt-item][aria-disabled=\"true\"] {\n opacity: 0.5;\n pointer-events: none;\n }\n\n /* the expanded parent item anchors its submenu; anchor-scope keeps each\n level’s submenu bound to its own parent item */\n [data-ukt-item] {\n anchor-scope: --uktdd-submenu-anchor;\n }\n\n /* parent items get a macOS-style disclosure chevron, right-aligned */\n :is([data-ukt-item], [data-ukt-value])[aria-haspopup=\"menu\"] {\n position: relative;\n padding-inline-end: 2em;\n\n &::after {\n content: \"\";\n position: absolute;\n inset-inline-end: 0.9em;\n inset-block-start: 50%;\n inline-size: 0.3em;\n block-size: 0.3em;\n border-block-start: 0.14em solid currentColor;\n border-inline-end: 0.14em solid currentColor;\n translate: 0 -50%;\n rotate: 45deg;\n }\n\n &:dir(rtl)::after {\n rotate: -45deg;\n }\n }\n\n /* the expanded item anchors its submenu; its disclosure is driven by the\n submenu’s popover open state (showPopover on expand), not a display\n toggle here */\n [data-ukt-item][aria-expanded=\"true\"] {\n anchor-name: --uktdd-submenu-anchor;\n }\n\n /* the submenu renders in the top layer via popover=\"manual\", like the\n body, so no ancestor — including the body’s own popover box — can\n become the containing block for the fixed submenu and clip or shift its\n anchor placement. (Safari shifts a position-area box back inside its\n containing block on both axes, which pulled the submenu in over its\n parent menu when the body was that containing block.) The popover\n attribute plus its UA `:not(:popover-open)` rule handle hide-when-\n collapsed, so there’s no display toggle; showPopover/hidePopover track\n the item’s expanded state. The UA-popover box reset (inset/border) lives\n here — the selector already outweighs a bare [popover] on specificity —\n while the cosmetics stay overridable. */\n\n /* Until popover=\"manual\" is applied — SubmenuDropdown sets it on render,\n ensureSubmenuARIA adds it when the body opens — a submenu has no UA\n :not(:popover-open) rule to hide it. Keep it hidden here so raw\n data-ukt-submenu markup inserted into an already-open body (annotated\n only on the next open) doesn’t flash visible and uncontrolled. Once the\n attribute is present this stops matching, leaving visibility to the\n popover open state (no author display to fight :popover-open). */\n [data-ukt-submenu]:not([popover]) {\n display: none;\n }\n\n [data-ukt-submenu] {\n box-sizing: border-box;\n inset: auto;\n border: 1px solid var(--uktdd-body-border-color);\n block-size: auto;\n /* an explicit color so items don’t inherit the white highlight color\n from their active parent item (the submenu is its DOM child) */\n color: var(--uktdd-body-color);\n position: fixed;\n position-anchor: --uktdd-submenu-anchor;\n position-area: var(--uktdd-submenu-position-area);\n /* like the body’s fill model, but a too-tall submenu stays beside\n its parent so that it can’t cover its parent menu.\n The list is the author fallback (the natural opposite placement),\n then --uktdd-submenu-fill-fallbacks: full-height anchor-centered\n fills, one per inline side. These fills are rejected only on the\n inline axis, so — unlike the body pair, whose two sides sum to the\n viewport — there’s no at-least-one-always-fits guarantee: a submenu\n too tall to open beside its parent and too wide for either side\n reverts to its (overflowing) primary. Normal submenus won’t hit\n that, but for extra wide menus, append the block-cover fills\n (--uktdd-fill-bottom, --uktdd-fill-top) to\n --uktdd-submenu-fill-fallbacks */\n position-try-fallbacks:\n var(--uktdd-submenu-position-try-fallback),\n var(--uktdd-submenu-fill-fallbacks);\n z-index: 2;\n margin-block: 0;\n margin-inline: var(--uktdd-submenu-gap);\n /* the fill options subtract --uktdd-body-gap to keep the body’s\n block-axis margins inside the fill region; a submenu’s block margins\n are 0 (its gap is inline), so zero it here to avoid shortening a\n filled submenu when a consumer sets a body gap. The unit is load-\n bearing: a bare 0 is a <number>, making the fills’\n calc(100% - <number>) invalid so the whole block-size declaration\n drops and every fill option is evaluated at natural size — and\n rejected */\n --uktdd-body-gap: 0px;\n padding: var(--uktdd-body-pad-top) var(--uktdd-body-pad-right)\n var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);\n inline-size: max-content;\n max-inline-size: var(--uktdd-body-max-width);\n min-block-size: min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));\n max-block-size: var(--uktdd-body-max-height);\n overflow: auto;\n overscroll-behavior: contain;\n list-style: none;\n background-color: var(--uktdd-body-bg-color);\n box-shadow: var(--uktdd-body-box-shadow);\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: 1px solid var(--uktdd-body-border-color);\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/* An empty option for a fallback slot a recipe doesn’t use — e.g. a\n centered menu (bottom/top span-all) has one meaningful author fallback,\n so it sets --uktdd-body-position-try-fallback-1 and leaves slot 2 as\n --uktdd-noop, which applies no overrides and evaluates identically to the\n primary placement, meaning it’s rejected in turn and skipped without\n breaking the declaration the way an empty var() would. */\n@position-try --uktdd-noop {\n}\n\n/* Named for the aligned edge (start/end), not the direction the body\n extends toward — e.g. top-start opens above the trigger with their\n inline-start edges flush, and the body can extend past the trigger’s\n inline-end edge. Both axes use logical keywords (block-start/-end,\n span-inline-start/-end rather than top/bottom, span-left/-right):\n position-area doesn’t allow mixing a physical keyword on one axis with a\n logical one on the other, and logical keeps the alignment correct in\n RTL. block-start/block-end read as top/bottom in the near-universal\n horizontal-tb writing mode. */\n@position-try --uktdd-top-start {\n position-area: block-start span-inline-end;\n}\n\n@position-try --uktdd-bottom-start {\n position-area: block-end span-inline-end;\n}\n\n@position-try --uktdd-bottom-end {\n position-area: block-end span-inline-start;\n}\n\n@position-try --uktdd-top-end {\n position-area: block-start span-inline-start;\n}\n\n@position-try --uktdd-submenu-inline-start {\n position-area: inline-start span-block-end;\n}\n\n/* The last-resort fills, each sizing the element to one block side’s space\n so the content scrolls. block-size must be a definite length:\n position-try evaluates an auto-sized box at its natural (unclamped) size,\n so a max-block-size clamp that would make it fit still reads as\n overflowing and is never selected (same quirk that rejects max-content\n here). 100% is the attached side’s space, less the symmetric\n --uktdd-body-gap margins.\n\n min-block-size still applies (a side shorter than --uktdd-body-min-height\n is rejected and the other tried), but is capped at the worst-case larger\n side, so a min above ~half the viewport can’t reject both sides and\n strand the body at the overflowing primary.\n\n The pair must be unrejectable on the inline axis so whichever block side\n fits can be accepted. A bare block keyword spans all inline tiles\n (viewport-wide containing block, no horizontal overflow), and justify-self:\n anchor-center shifts the trigger-centered element inward to stay on-screen\n (span-all’s default alignment wouldn’t, so a corner would overflow) */\n@position-try --uktdd-fill-bottom {\n position-area: block-end;\n block-size: calc(100% - var(--uktdd-body-gap) * 2);\n min-block-size: min(\n var(--uktdd-body-min-height),\n var(--uktdd-body-max-height),\n calc((100dvb - anchor-size(block)) / 2 - var(--uktdd-body-gap) * 2)\n );\n justify-self: anchor-center;\n}\n\n@position-try --uktdd-fill-top {\n position-area: block-start;\n block-size: calc(100% - var(--uktdd-body-gap) * 2);\n min-block-size: min(\n var(--uktdd-body-min-height),\n var(--uktdd-body-max-height),\n calc((100dvb - anchor-size(block)) / 2 - var(--uktdd-body-gap) * 2)\n );\n justify-self: anchor-center;\n}\n\n/* The same-side fill (used by submenus, and available to authors composing\n their own fallback lists, including tactic-flipped: `--uktdd-fill\n flip-inline`). It sets no position-area, so it inherits the element’s\n primary placement — or a tactic-transformed mirror of it — and only\n sizes the element to that placement’s block-axis space */\n@position-try --uktdd-fill {\n block-size: calc(100% - var(--uktdd-body-gap) * 2);\n}\n\n/* The submenu full-height fill (see --uktdd-submenu-fill-fallbacks): the\n block-axis mirror of --uktdd-fill-bottom. A bare inline keyword spans all\n block tiles, so the containing block is viewport-tall and the submenu\n fills the full block axis on the inline-end side (beside the parent, never\n over it), and align-self: anchor-center shifts it on the block axis to\n stay on-screen — the rescue for a parent near the block-end edge, where\n the top-aligned --uktdd-fill has too little room below it. Rejected only\n on the inline axis (no room for the submenu’s width on that side), so the\n flip-inline pair covers both sides. Compose `--uktdd-submenu-fill\n flip-inline` for the opposite side */\n@position-try --uktdd-submenu-fill {\n position-area: inline-end;\n block-size: calc(100% - var(--uktdd-body-gap) * 2);\n align-self: anchor-center;\n}\n\n/* The opt-in cover fill (in no default list): where the block-side fills\n loosen the inline axis and keep the body beside the trigger, this keeps\n the strict start-aligned inline edge (span-inline-end, like the -start\n placements; compose `--uktdd-fill-cover flip-inline` for end alignment)\n and loosens the block axis instead — span-all sizes the body to the\n viewport’s full block axis, covering the trigger, and anchor-center\n keeps a shorter body (an authored max-block-size) centered over the\n trigger and shifted on-screen. Overflowing the trigger-to-viewport-edge\n inline region rejects it, so it applies only when the body fits\n horizontally as aligned: list it before the guaranteed pair\n (--uktdd-fill-cover, --uktdd-fill-bottom, --uktdd-fill-top) with at\n most two author fallbacks, for six options total — the ceiling every\n current engine clears (Chromium evaluates six; Safari and Firefox go\n further). One author fallback keeps it within the spec floor of five\n (see the .uktdropdown-body rule). Avoid it on searchable dropdowns: the\n body overlays the trigger’s input */\n@position-try --uktdd-fill-cover {\n position-area: span-all span-inline-end;\n block-size: calc(100% - var(--uktdd-body-gap) * 2);\n align-self: anchor-center;\n}\n","import { getBestMatch } from '@acusti/matchmaking';\nimport { Children, isValidElement, type ReactNode, type SyntheticEvent } from 'react';\n\nimport { type Item } from './Dropdown.js';\n\nexport const ITEM_SELECTOR = '[data-ukt-item], [data-ukt-value]';\nexport const SUBMENU_SELECTOR = '[data-ukt-submenu]';\n\nconst DISABLED_ITEM_SELECTOR = '[aria-disabled=\"true\"]';\n\nexport type OnToggleSubmenu = (item: HTMLElement, isExpanded: boolean) => void;\n\ntype MaybeHTMLElement = HTMLElement | null;\n\nconst getBodyElement = (dropdownElement: MaybeHTMLElement) =>\n (dropdownElement?.querySelector('.uktdropdown-body') ?? null) as MaybeHTMLElement;\n\n// The level root that owns an item: the closest [data-ukt-submenu] ancestor,\n// or null for items at the top level of the dropdown body\nexport const getLevelRoot = (element: HTMLElement) =>\n element.closest(SUBMENU_SELECTOR) as MaybeHTMLElement;\n\n// An item’s own submenu (a parent item), excluding submenus of descendant items\nexport const getSubmenuOfItem = (item: HTMLElement): MaybeHTMLElement => {\n const submenu = item.querySelector(SUBMENU_SELECTOR) as MaybeHTMLElement;\n if (!submenu) return null;\n const owner = submenu.parentElement?.closest(ITEM_SELECTOR);\n return owner === item ? submenu : null;\n};\n\n// The parent item that owns a submenu level\nexport const getParentItem = (levelRoot: HTMLElement) =>\n (levelRoot.parentElement?.closest(ITEM_SELECTOR) ?? null) as MaybeHTMLElement;\n\n// A parent item’s label is its text content excluding the submenu subtree\nexport const getItemLabel = (item: HTMLElement): string => {\n if (!getSubmenuOfItem(item)) return item.innerText ?? '';\n const clone = item.cloneNode(true) as HTMLElement;\n for (const submenu of Array.from(clone.querySelectorAll(SUBMENU_SELECTOR))) {\n submenu.remove();\n }\n return (clone.textContent ?? '').trim();\n};\n\n// Concatenate the text (string/number leaves) of a React node, approximating\n// the rendered innerText the dropdown uses as an item’s label. Submenu\n// subtrees are excluded, matching getItemLabel (and innerText, which omits\n// the collapsed — hidden — submenu), so a parent item’s derived label agrees\n// with its select-time label.\nconst getNodeText = (node: ReactNode): string => {\n let text = '';\n Children.forEach(node, (child) => {\n if (typeof child === 'string' || typeof child === 'number') {\n text += child;\n } else if (isValidElement(child)) {\n const childProps = child.props as {\n children?: ReactNode;\n 'data-ukt-submenu'?: unknown;\n };\n if (childProps['data-ukt-submenu'] !== undefined) return;\n text += getNodeText(childProps.children);\n }\n });\n return text;\n};\n\n// Find the item in `children` whose data-ukt-value matches `value` and return\n// its text as the label, so a bare identifier value shows the matching item’s\n// label without a separate options/label lookup. Returns undefined if no item\n// matches (the caller then falls back to the identifier itself). A\n// { label, value } value overrides this when the derived text isn’t right.\nexport const getLabelFromChildren = (\n children: ReactNode,\n value: string,\n): string | undefined => {\n let label: string | undefined;\n const visit = (node: ReactNode) => {\n if (label != null) return;\n Children.forEach(node, (child) => {\n if (label != null || !isValidElement(child)) return;\n const childProps = child.props as {\n children?: ReactNode;\n 'data-ukt-value'?: unknown;\n };\n const uktValue = childProps['data-ukt-value'];\n // Compare as strings: the DOM stringifies dataset values, so\n // data-ukt-value={400} matches value=\"400\" when selected and\n // must also match here.\n if (uktValue != null && String(uktValue) === value) {\n label = getNodeText(childProps.children).replace(/\\s+/g, ' ').trim();\n return;\n }\n visit(childProps.children);\n });\n };\n visit(children);\n return label;\n};\n\n// Ancestor parent items from the root level down to the element’s immediate parent\nexport const getItemPath = (element: MaybeHTMLElement): Item['path'] => {\n const path: Item['path'] = [];\n if (!element) return path;\n let levelRoot = getLevelRoot(element);\n while (levelRoot) {\n const parentItem = getParentItem(levelRoot);\n if (!parentItem) break;\n const label = getItemLabel(parentItem);\n path.unshift({ label, value: parentItem.dataset.uktValue ?? label });\n levelRoot = getLevelRoot(parentItem);\n }\n return path;\n};\n\nexport const getItemElements = (\n dropdownElement: MaybeHTMLElement,\n levelRoot?: MaybeHTMLElement,\n): Array<HTMLElement> | null => {\n const bodyElement = getBodyElement(dropdownElement);\n if (!bodyElement) return null;\n\n const root = levelRoot ?? bodyElement;\n const candidates = Array.from(\n root.querySelectorAll(ITEM_SELECTOR),\n ) as Array<HTMLElement>;\n\n if (candidates.length) {\n return candidates.filter((item) => {\n if (item.matches(DISABLED_ITEM_SELECTOR)) return false;\n return getLevelRoot(item) === (levelRoot ?? null);\n });\n }\n\n // If no items found via [data-ukt-item] or [data-ukt-value] selector,\n // use first instance of multiple children found — flat bodies and flat\n // submenu levels alike\n let items: HTMLCollection = root.children;\n while (items.length === 1) {\n if (items[0].children == null) break;\n items = items[0].children;\n }\n // If unable to find an element with more than one child, treat direct child as items\n if (items.length === 1) {\n items = root.children;\n }\n return (Array.from(items) as Array<HTMLElement>).filter(\n (item) => !item.matches(DISABLED_ITEM_SELECTOR),\n );\n};\n\n// The item an event target belongs to within its own level: the closest\n// marked item, or — when the target sits in a level with no marked items\n// (a heuristically-detected level) — the target itself if it’s one of that\n// level’s detected items. Misses (body padding, separators) and disabled\n// items resolve to null.\nexport const getItemForTarget = (\n dropdownElement: HTMLElement,\n target: HTMLElement,\n): MaybeHTMLElement => {\n let item = target.closest(ITEM_SELECTOR) as MaybeHTMLElement;\n // If nothing matched, or the target sits in a deeper level than the\n // matched item (an unmarked, heuristically-detected submenu level),\n // resolve the item within the target’s own level instead\n const targetLevelRoot = getLevelRoot(target);\n if (!item || (targetLevelRoot && item.contains(targetLevelRoot))) {\n const itemElements = getItemElements(dropdownElement, targetLevelRoot);\n item = itemElements?.find((itemElement) => itemElement === target) ?? item;\n }\n if (!item || !dropdownElement.contains(item)) return null;\n if (item.matches(DISABLED_ITEM_SELECTOR)) return null;\n return item;\n};\n\n// All active items, in document order (ancestors before descendants)\nexport const getActiveItemElements = (dropdownElement: MaybeHTMLElement) => {\n if (!dropdownElement) return null;\n const actives = dropdownElement.querySelectorAll('[data-ukt-active]');\n return actives.length ? (Array.from(actives) as Array<HTMLElement>) : null;\n};\n\n// The deepest active item — the one keyboard input operates on\nexport const getActiveItemElement = (dropdownElement: MaybeHTMLElement) => {\n const actives = getActiveItemElements(dropdownElement);\n return actives ? actives[actives.length - 1] : null;\n};\n\n// The deepest expanded parent item — the one whose submenu is the innermost\n// open one — in document order\nexport const getDeepestExpandedItem = (\n dropdownElement: MaybeHTMLElement,\n): MaybeHTMLElement => {\n if (!dropdownElement) return null;\n const expanded = (\n Array.from(\n dropdownElement.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((element) => element.matches(ITEM_SELECTOR));\n return expanded.length ? expanded[expanded.length - 1] : null;\n};\n\nexport const isItemExpanded = (item: HTMLElement) =>\n item.getAttribute('aria-expanded') === 'true';\n\nlet submenuIdCounter = 0;\n\nconst ensureSubmenuARIA = (item: HTMLElement, submenu: HTMLElement) => {\n if (!submenu.hasAttribute('role')) submenu.setAttribute('role', 'menu');\n if (!submenu.id) submenu.id = `uktdd-submenu-${++submenuIdCounter}`;\n // Normalize the submenu to a manual popover for consumers who author raw\n // data-ukt-submenu markup (SubmenuDropdown already sets it); a bare or auto\n // popover would light-dismiss and desync from the engine’s show/hidePopover.\n if (submenu.getAttribute('popover') !== 'manual') {\n submenu.setAttribute('popover', 'manual');\n }\n if (!item.hasAttribute('aria-haspopup')) item.setAttribute('aria-haspopup', 'menu');\n if (!item.hasAttribute('aria-expanded')) item.setAttribute('aria-expanded', 'false');\n if (!item.hasAttribute('aria-controls')) {\n item.setAttribute('aria-controls', submenu.id);\n }\n};\n\n// Fill in submenu/parent-item ARIA (only what the consumer hasn’t set)\nexport const annotateParentItems = (bodyElement: MaybeHTMLElement) => {\n if (!bodyElement) return;\n for (const submenu of Array.from(bodyElement.querySelectorAll(SUBMENU_SELECTOR))) {\n const item = getParentItem(submenu as HTMLElement);\n if (item) ensureSubmenuARIA(item, submenu as HTMLElement);\n }\n};\n\n// Fill in the item roles the consumer hasn’t set: options in a searchable\n// (listbox) dropdown, menuitems in a menu — and always menuitems inside a\n// submenu, which is itself a menu (annotateParentItems gives it role=\"menu\").\n// The <ul>/<ol> wrappers around the items get role=\"presentation\" so their\n// implicit list role doesn’t sit between the listbox/menu and its items; a\n// submenu already carries role=\"menu\", so its own role is left intact.\nexport const annotateItemRoles = (\n bodyElement: MaybeHTMLElement,\n popupRole: 'listbox' | 'menu',\n) => {\n if (!bodyElement) return;\n for (const list of Array.from(bodyElement.querySelectorAll('ul, ol'))) {\n if (!list.hasAttribute('role') && list.querySelector(ITEM_SELECTOR)) {\n list.setAttribute('role', 'presentation');\n }\n }\n for (const item of Array.from(\n bodyElement.querySelectorAll(ITEM_SELECTOR),\n ) as Array<HTMLElement>) {\n // Leave a consumer-set role, and a natively interactive item’s own role\n // (a button/link/input item keeps its element semantics), alone.\n if (\n item.hasAttribute('role') ||\n item.matches('a[href], button, input, select, textarea')\n ) {\n continue;\n }\n const isMenuItem = popupRole === 'menu' || getLevelRoot(item) != null;\n // A top-level parent item in a listbox would pair role=\"option\" with\n // the aria-haspopup/aria-expanded that annotateParentItems gives it —\n // invalid ARIA (an option can’t disclose a popup), and no valid role\n // exists for a submenu parent inside a listbox, so leave its role to\n // the consumer. (In a menu, menuitem is correct for parents.)\n if (!isMenuItem && getSubmenuOfItem(item)) continue;\n item.setAttribute('role', isMenuItem ? 'menuitem' : 'option');\n }\n};\n\nexport const expandItem = (item: HTMLElement, onToggleSubmenu?: OnToggleSubmenu) => {\n const submenu = getSubmenuOfItem(item);\n if (!submenu) return;\n ensureSubmenuARIA(item, submenu);\n if (isItemExpanded(item)) return;\n item.setAttribute('aria-expanded', 'true');\n onToggleSubmenu?.(item, true);\n};\n\nexport const collapseItem = (item: HTMLElement, onToggleSubmenu?: OnToggleSubmenu) => {\n if (!isItemExpanded(item)) return;\n const submenu = getSubmenuOfItem(item);\n if (submenu) {\n // Collapse any expanded descendants first so their state can’t leak\n // into the next disclosure and their onClose callbacks fire\n // (recursion makes the collapse order deepest-first)\n const expandedDescendants = (\n Array.from(\n submenu.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((descendant) => descendant.matches(ITEM_SELECTOR));\n for (const descendant of expandedDescendants) {\n collapseItem(descendant, onToggleSubmenu);\n }\n for (const active of Array.from(submenu.querySelectorAll('[data-ukt-active]'))) {\n delete (active as HTMLElement).dataset.uktActive;\n }\n }\n item.setAttribute('aria-expanded', 'false');\n onToggleSubmenu?.(item, false);\n};\n\n// Collapse every expanded parent item that isn’t an ancestor of element\n// (element == null collapses all), deepest-first\nexport const collapseItemsOutsidePath = (\n dropdownElement: MaybeHTMLElement,\n element: MaybeHTMLElement,\n onToggleSubmenu?: OnToggleSubmenu,\n) => {\n const bodyElement = getBodyElement(dropdownElement);\n if (!bodyElement) return;\n const expandedItems = (\n Array.from(\n bodyElement.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((item) => item.matches(ITEM_SELECTOR));\n for (const item of expandedItems.reverse()) {\n if (element && item.contains(element)) continue;\n collapseItem(item, onToggleSubmenu);\n }\n};\n\nconst clearItemElementsState = (itemElements: Array<HTMLElement>) => {\n itemElements.forEach((itemElement) => {\n if (itemElement.hasAttribute('data-ukt-active')) {\n delete itemElement.dataset.uktActive;\n }\n // Also clear active state in any deeper levels within this item\n for (const active of Array.from(\n itemElement.querySelectorAll('[data-ukt-active]'),\n )) {\n delete (active as HTMLElement).dataset.uktActive;\n }\n });\n};\n\n// Make the active set exactly the chain of element + its ancestor parent items\nconst setActiveChain = (dropdownElement: HTMLElement, element: HTMLElement) => {\n const chain = new Set<HTMLElement>([element]);\n let levelRoot = getLevelRoot(element);\n while (levelRoot) {\n const parentItem = getParentItem(levelRoot);\n if (!parentItem) break;\n chain.add(parentItem);\n levelRoot = getLevelRoot(parentItem);\n }\n for (const active of getActiveItemElements(dropdownElement) ?? []) {\n if (!chain.has(active)) delete active.dataset.uktActive;\n }\n for (const item of chain) {\n item.setAttribute('data-ukt-active', '');\n }\n};\n\ntype BaseSetActiveItemPayload = {\n dropdownElement: HTMLElement;\n element?: null;\n // Optional so an item can be activated programmatically (e.g. revealing the\n // current value on open); it’s only used to build the onActiveItem payload,\n // which is skipped when there’s no event to report.\n event?: Event | SyntheticEvent<HTMLElement>;\n index?: null;\n indexAddend?: null;\n isExactMatch?: null;\n onActiveItem?: (payload: Item) => void;\n text?: null;\n};\n\nexport const setActiveItem = ({\n dropdownElement,\n element,\n event,\n index,\n indexAddend,\n isExactMatch,\n onActiveItem,\n text,\n}:\n | ({\n element: HTMLElement;\n } & Omit<BaseSetActiveItemPayload, 'element'>)\n | ({\n index: number;\n } & Omit<BaseSetActiveItemPayload, 'index'>)\n | ({\n indexAddend: number;\n } & Omit<BaseSetActiveItemPayload, 'indexAddend'>)\n | ({\n isExactMatch?: boolean;\n text: string;\n } & Omit<BaseSetActiveItemPayload, 'isExactMatch' | 'text'>)): MaybeHTMLElement => {\n const currentDeepest = getActiveItemElement(dropdownElement);\n // Keys and text operate on the current level (the level of the deepest\n // active item); activating an element directly targets its own level\n const levelRoot = element\n ? getLevelRoot(element)\n : currentDeepest\n ? getLevelRoot(currentDeepest)\n : null;\n\n const itemElements = getItemElements(dropdownElement, levelRoot);\n if (!itemElements || itemElements.length === 0) return currentDeepest;\n\n const lastIndex = itemElements.length - 1;\n const currentActiveIndex = itemElements.findIndex(\n (itemElement) => itemElement === currentDeepest,\n );\n\n let nextActiveIndex = currentActiveIndex;\n if (typeof index === 'number') {\n // Negative index means count back from the end\n nextActiveIndex = index < 0 ? itemElements.length + index : index;\n }\n\n if (element) {\n nextActiveIndex = itemElements.findIndex(\n (itemElement) => itemElement === element,\n );\n if (nextActiveIndex === -1) return currentDeepest;\n } else if (typeof indexAddend === 'number') {\n // If there’s no currentActiveIndex and we are handling -1, start at lastIndex\n if (currentActiveIndex === -1 && indexAddend === -1) {\n nextActiveIndex = lastIndex;\n } else {\n nextActiveIndex += indexAddend;\n }\n // Keep it within the bounds of the items list\n nextActiveIndex = Math.max(0, Math.min(nextActiveIndex, lastIndex));\n } else if (typeof text === 'string') {\n // If text is empty, clear existing active items and early return\n if (!text) {\n clearItemElementsState(itemElements);\n return null;\n }\n\n const itemTexts = itemElements.map(getItemLabel);\n if (isExactMatch) {\n const textToCompare = text.toLowerCase();\n nextActiveIndex = itemTexts.findIndex((itemText) =>\n itemText.toLowerCase().startsWith(textToCompare),\n );\n // If isExactMatch is required and no exact match was found, clear active items\n if (nextActiveIndex === -1) {\n clearItemElementsState(itemElements);\n }\n } else {\n const bestMatch = getBestMatch({ items: itemTexts, text });\n nextActiveIndex = itemTexts.findIndex((itemText) => itemText === bestMatch);\n }\n }\n\n const nextActiveItem = itemElements[nextActiveIndex] as MaybeHTMLElement;\n if (nextActiveItem == null || nextActiveItem === currentDeepest) {\n return currentDeepest;\n }\n\n setActiveChain(dropdownElement, nextActiveItem);\n // A programmatic activation (no event) still moves the highlight and scrolls\n // the item into view, but has no event to report to onActiveItem.\n if (event) {\n const label = getItemLabel(nextActiveItem);\n onActiveItem?.({\n element: nextActiveItem,\n event,\n label,\n path: getItemPath(nextActiveItem),\n value: nextActiveItem.dataset.uktValue ?? label,\n });\n }\n // Find closest scrollable parent and ensure that next active item is visible\n let { parentElement } = nextActiveItem;\n let scrollableParent = null;\n while (!scrollableParent && parentElement && parentElement !== dropdownElement) {\n const isScrollable = parentElement.scrollHeight > parentElement.clientHeight + 15;\n if (isScrollable) {\n scrollableParent = parentElement;\n } else {\n parentElement = parentElement.parentElement;\n }\n }\n\n if (scrollableParent) {\n const parentRect = scrollableParent.getBoundingClientRect();\n const itemRect = nextActiveItem.getBoundingClientRect();\n const isAboveTop = itemRect.top < parentRect.top;\n const isBelowBottom = itemRect.bottom > parentRect.bottom;\n if (isAboveTop || isBelowBottom) {\n let { scrollTop } = scrollableParent;\n // Item isn’t fully visible; adjust scrollTop to put item within closest edge\n if (isAboveTop) {\n scrollTop -= parentRect.top - itemRect.top;\n } else {\n scrollTop += itemRect.bottom - parentRect.bottom;\n }\n scrollableParent.scrollTop = scrollTop;\n }\n }\n\n return nextActiveItem;\n};\n\nexport type Point = { x: number; y: number };\n\n// Whether a point is inside (or on an edge of) triangle a-b-c, from the sign\n// of the cross product for each edge: all the same sign ⇒ inside\nexport const isPointInTriangle = (p: Point, a: Point, b: Point, c: Point): boolean => {\n const cross = (u: Point, v: Point, w: Point) =>\n (u.x - w.x) * (v.y - w.y) - (v.x - w.x) * (u.y - w.y);\n const d1 = cross(p, a, b);\n const d2 = cross(p, b, c);\n const d3 = cross(p, c, a);\n const hasNegative = d1 < 0 || d2 < 0 || d3 < 0;\n const hasPositive = d1 > 0 || d2 > 0 || d3 > 0;\n return !(hasNegative && hasPositive);\n};\n","import clsx from 'clsx';\nimport {\n type CSSProperties,\n type FocusEvent as ReactFocusEvent,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n useMemo,\n useRef,\n} from 'react';\n\nimport {\n MenubarContext,\n type MenubarContextValue,\n type MenubarMember,\n} from './context.js';\n\nexport type MenubarProps = {\n children: ReactNode;\n className?: string;\n style?: CSSProperties;\n};\n\nconst compareDocumentOrder = (a: MenubarMember, b: MenubarMember) => {\n if (a.element === b.element) return 0;\n const position = a.element.compareDocumentPosition(b.element);\n if ((position & Node.DOCUMENT_POSITION_FOLLOWING) !== 0) return -1;\n if ((position & Node.DOCUMENT_POSITION_PRECEDING) !== 0) return 1;\n return 0;\n};\n\n// Matches interactive controls that live in the menubar without being dropdown\n// triggers (e.g. a plain button). Hovering one clears the open menu without\n// disengaging the menubar.\nconst NON_MENU_CONTROL_SELECTOR = 'a[href], button, input, select, textarea, [tabindex]';\n\n// Combines sibling Dropdowns into a single menu, like the system menu in the\n// top toolbar of macOS: one menu open at a time, ←/→ move between menus, and\n// once any menu is open, hovering or focusing another trigger switches to it.\nexport default function Menubar({ children, className, style }: MenubarProps) {\n const membersRef = useRef<Set<MenubarMember>>(new Set());\n // The member that engaged the bar (menu-mode). It keeps pointing at that\n // member even if that member’s menu was closed by hovering a non-menu\n // control, which allows the bar to stay engaged even with nothing open.\n const engagedMemberRef = useRef<HTMLElement | null>(null);\n\n const getOrderedMembersRef = useRef(() =>\n Array.from(membersRef.current).sort(compareDocumentOrder),\n );\n const getOrderedMembers = getOrderedMembersRef.current;\n\n const contextValue: MenubarContextValue = useMemo(\n () => ({\n moveOpen(fromElement: HTMLElement, direction: -1 | 1) {\n const members = getOrderedMembersRef.current();\n if (members.length < 2) return;\n const index = members.findIndex(\n (member) => member.element === fromElement,\n );\n if (index === -1) return;\n const nextIndex = (index + direction + members.length) % members.length;\n members[index].close();\n members[nextIndex].open();\n members[nextIndex].focusTrigger();\n },\n notifyClosed(element: HTMLElement) {\n // Only a dismissal of the member that engaged the bar ends\n // menu-mode. Outside-click handling closes every mounted\n // dropdown, so ignore the closes reported for the rest.\n if (engagedMemberRef.current === element) {\n engagedMemberRef.current = null;\n }\n },\n notifyOpened(element: HTMLElement) {\n engagedMemberRef.current = element;\n for (const member of membersRef.current) {\n if (member.element !== element && member.isOpen()) {\n member.close();\n }\n }\n },\n registerMember(member: MenubarMember) {\n membersRef.current.add(member);\n return () => {\n membersRef.current.delete(member);\n };\n },\n }),\n [],\n );\n\n // Rove focus between triggers with ←/→ while no menu is open (the open\n // dropdown’s own key handling slides the open menu between triggers)\n const handleKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n const { key } = event;\n if (key !== 'ArrowLeft' && key !== 'ArrowRight') return;\n const members = getOrderedMembers();\n if (members.length < 2) return;\n if (members.some((member) => member.isOpen())) return;\n const eventTarget = event.target as HTMLElement;\n const index = members.findIndex((member) => member.element.contains(eventTarget));\n if (index === -1) return;\n event.preventDefault();\n event.stopPropagation();\n const direction = key === 'ArrowRight' ? 1 : -1;\n members[(index + direction + members.length) % members.length].focusTrigger();\n };\n\n // Once the bar is engaged, moving hover or focus onto another member’s\n // trigger switches to it (opening notifies the menubar, which closes the\n // other open member), while moving onto a non-menu control clears the open\n // menu but keeps the bar engaged.\n const switchToMemberAt = (eventTarget: HTMLElement) => {\n if (engagedMemberRef.current == null) return;\n const members = getOrderedMembers();\n // If the member that engaged the bar is gone (e.g. it unmounted while\n // engaged) the bar is no longer engaged, so hover can’t reopen menus\n if (!members.some((m) => m.element === engagedMemberRef.current)) {\n engagedMemberRef.current = null;\n return;\n }\n const member = members.find((m) => m.element.contains(eventTarget));\n if (member) {\n if (!member.isOpen()) member.open();\n return;\n }\n // Not over a menu trigger: only a real non-menu control (not the bar’s\n // padding or the gaps between triggers) clears the open menu — this is\n // a menubar-driven close, so the members stay engaged.\n if (!eventTarget.closest(NON_MENU_CONTROL_SELECTOR)) return;\n for (const openMember of members) {\n if (openMember.isOpen()) openMember.close();\n }\n };\n\n const handleFocus = (event: ReactFocusEvent<HTMLDivElement>) => {\n switchToMemberAt(event.target as HTMLElement);\n };\n\n const handleMouseOver = (event: ReactMouseEvent<HTMLDivElement>) => {\n switchToMemberAt(event.target as HTMLElement);\n };\n\n return (\n <div\n className={clsx('uktmenubar', className)}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onMouseOver={handleMouseOver}\n role=\"menubar\"\n style={style}\n >\n <MenubarContext.Provider value={contextValue}>\n {children}\n </MenubarContext.Provider>\n </div>\n );\n}\n","/* eslint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/mouse-events-have-key-events, jsx-a11y/no-static-element-interactions */\nimport useKeyboardEvents, {\n isEventTargetUsingKeyEvent,\n} from '@acusti/use-keyboard-events';\nimport clsx from 'clsx';\nimport {\n Children,\n cloneElement,\n type CSSProperties,\n Fragment,\n isValidElement,\n type MouseEvent as ReactMouseEvent,\n type ReactElement,\n type ReactNode,\n type SyntheticEvent,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport {\n DropdownContext,\n type DropdownContextValue,\n MenubarContext,\n type SubmenuRegistration,\n} from './context.js';\nimport styles from './Dropdown.css?inline';\nimport {\n annotateItemRoles,\n annotateParentItems,\n collapseItem,\n collapseItemsOutsidePath,\n expandItem,\n getActiveItemElement,\n getDeepestExpandedItem,\n getItemElements,\n getItemForTarget,\n getItemPath,\n getLabelFromChildren,\n getLevelRoot,\n getParentItem,\n getSubmenuOfItem,\n isItemExpanded,\n isPointInTriangle,\n type Point,\n setActiveItem,\n} from './helpers.js';\n\nexport type Item = {\n element: MaybeHTMLElement;\n event: Event | SyntheticEvent<HTMLElement>;\n label: string;\n /**\n * Ancestor parent items from the root level down to the item’s\n * immediate parent. Empty for top-level items.\n */\n path: Array<ItemValue>;\n value: string;\n};\n\n/**\n * A { label, value } pair naming an item: `value` is the stored value (the\n * item’s data-ukt-value) and `label` is its displayed text. Accepted by the\n * value prop when an item’s value and label differ; also the shape of an\n * Item’s path entries.\n */\nexport type ItemValue = { label: string; value: string };\n\nexport type Props = {\n /**\n * Boolean indicating if the user can submit a value not already in the\n * dropdown.\n */\n allowCreate?: boolean;\n /**\n * Boolean indicating if submitting with no item active emits an empty\n * value (i.e. clears the value). Only has an effect when the dropdown has a\n * text input to source that value from — a searchable dropdown’s search\n * input, or a text input inside a custom trigger. With no such input there\n * is no value to submit, so submitting with nothing selected is a no-op\n * regardless; clear such a dropdown with an explicit empty-valued item\n * instead. Defaults to true.\n */\n allowEmpty?: boolean;\n /**\n * Can take a single React element or exactly two renderable children.\n */\n children: ChildrenTuple | ReactElement;\n className?: string;\n disabled?: boolean;\n hasItems?: boolean;\n isOpenOnMount?: boolean;\n isSearchable?: boolean;\n keepOpenOnSubmit?: boolean;\n /**\n * Label content for the trigger button (when using single child syntax).\n * For a nested (submenu) Dropdown, this is the parent item’s content.\n */\n label?: ReactNode;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s name.\n */\n name?: string;\n onActiveItem?: (payload: Item) => void;\n onClick?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onClose?: () => unknown;\n onMouseDown?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onMouseUp?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onOpen?: () => unknown;\n onSubmitItem?: (payload: Item) => void;\n /**\n * Opens the dropdown when the pointer hovers the trigger, and closes it a\n * short moment after the pointer leaves the trigger and body entirely (the\n * close is delayed so crossing the gap between them, or pausing over\n * either, doesn’t flicker-close it). Click and keyboard opening keep\n * working as usual alongside it.\n */\n openOnHover?: boolean;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s placeholder.\n */\n placeholder?: string;\n /**\n * Applied to the dropdown root element. Also accepts the component’s CSS\n * custom properties (e.g. `--uktdd-body-min-width`) for per-instance\n * placement and sizing, which plain `CSSProperties` rejects.\n */\n style?: CSSProperties & Record<`--${string}`, string | number | undefined>;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s tabIndex.\n */\n tabIndex?: number;\n /**\n * The dropdown’s controlled value. Pass a bare identifier when an item’s\n * stored value and its displayed label are the same, or a { label, value }\n * pair when they differ (e.g. a human-readable label shown for a stored\n * id) — the same { label, value } shape onSubmitItem reports back. The\n * value determines whether the value has changed, to avoid triggering\n * onSubmitItem when the already-selected item is re-submitted; the label is\n * used as the search input’s value when props.isSearchable === true. A bare\n * identifier is resolved to its label from the matching child’s\n * data-ukt-value in the body — so children whose value and label differ\n * need no explicit label; a { label, value } pair states it.\n */\n value?: ItemValue | string;\n};\n\ntype ChildrenTuple = [ReactNode, ReactNode] | readonly [ReactNode, ReactNode];\n\ntype MaybeHTMLElement = HTMLElement | null;\n\ntype MousePosition = { clientX: number; clientY: number };\n\ntype TimeoutID = ReturnType<typeof setTimeout>;\n\nconst CHILDREN_ERROR =\n '@acusti/dropdown requires either 1 child (the dropdown body) or 2 children: the dropdown trigger and the dropdown body.';\nconst CLICKABLE_SELECTOR = 'button, a[href], input[type=\"button\"], input[type=\"submit\"]';\nconst FOCUSABLE_SELECTOR = 'a[href], button, input, select, textarea, [tabindex]';\nconst TEXT_INPUT_SELECTOR =\n 'input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea';\n\n// Matches macOS: quick, natural arrowing past parent items never flashes\n// their submenus, but a brief pause discloses. Frame-stepping macOS menus\n// puts its delay around 200–250ms; anything much shorter flashes\nconst SUBMENU_DISCLOSURE_DELAY = 200;\n\n// How long the pointer can dwell inside the safe area (heading toward an open\n// submenu) before we give up and switch to whatever it’s actually over. Reset\n// on every move, so it only fires on a pause — motion keeps the submenu open\nconst SAFE_AREA_TIMEOUT = 300;\n\n// props.openOnHover opens immediately on hover, but closing waits a beat so\n// that crossing the trigger/body gap (or a placement fallback moving the body\n// somewhere the pointer briefly leaves) doesn’t flicker-close it\nconst HOVER_CLOSE_DELAY = 150;\n\nexport default function Dropdown(props: Props) {\n const parentDropdown = useContext(DropdownContext);\n // A Dropdown nested inside a menu dropdown’s body renders as a submenu\n // (a parent item delegating to the root engine). A hasItems={false}\n // dropdown provides no submenu context, so a Dropdown nested inside one —\n // or a hasItems={false} Dropdown anywhere — renders independently instead.\n if (parentDropdown && props.hasItems !== false) {\n return <SubmenuDropdown {...props} parentDropdown={parentDropdown} />;\n }\n return <RootDropdown {...props} />;\n}\n\nfunction RootDropdown({\n allowCreate,\n allowEmpty = true,\n children,\n className,\n disabled,\n hasItems = true,\n isOpenOnMount,\n isSearchable,\n keepOpenOnSubmit = !hasItems,\n label,\n name,\n onActiveItem,\n onClick,\n onClose,\n onMouseDown,\n onMouseUp,\n onOpen,\n onSubmitItem,\n openOnHover,\n placeholder,\n style: styleFromProps,\n tabIndex,\n value,\n}: Props) {\n const childrenCount = Children.count(children);\n if (childrenCount !== 1 && childrenCount !== 2) {\n if (childrenCount === 0) {\n throw new Error(CHILDREN_ERROR + ' Received no children.');\n }\n console.error(`${CHILDREN_ERROR} Received ${childrenCount} children.`);\n }\n\n let trigger: React.ReactNode;\n if (childrenCount > 1) {\n trigger = (children as ChildrenTuple)[0];\n }\n // The body is the node rendered inside .uktdropdown-body: the second of\n // two children, or the only child.\n const body = childrenCount > 1 ? (children as ChildrenTuple)[1] : children;\n\n // The value prop is either a bare identifier (its stored value and its\n // displayed label are the same) or a { label, value } pair when they\n // differ. valueIdentity drives change detection / no-op matching against an\n // item’s data-ukt-value; valueLabel is what a searchable dropdown shows in\n // its input. For a bare identifier, the label is resolved from the matching\n // child (data-ukt-value in the body — derivation walks the same node the\n // body renders, so a data-ukt-value in a custom trigger can’t match), so\n // children with distinct values and labels need no separate label; a\n // { label, value } pair states it explicitly. A bare value that matches no\n // child has no known label — a value is an identity, not display text — so\n // it falls back to the placeholder (an empty input), not to the raw\n // identifier. The exception is allowCreate, where an unmatched value is an\n // entry the user created (a typed value not among the items) and must still\n // show as typed. Only a searchable dropdown displays the label, so skip the\n // per-render walk entirely for anything else.\n const valueIdentity = typeof value === 'string' ? value : value?.value;\n const valueLabel = !isSearchable\n ? undefined\n : typeof value !== 'string'\n ? value?.label\n : (getLabelFromChildren(body, value) ?? (allowCreate ? value : undefined));\n\n const [isOpen, setIsOpen] = useState<boolean>(isOpenOnMount ?? false);\n const [isOpening, setIsOpening] = useState<boolean>(!isOpenOnMount);\n const [dropdownElement, setDropdownElement] = useState<MaybeHTMLElement>(null);\n const bodyId = useId();\n const popupRole = isSearchable ? 'listbox' : hasItems ? 'menu' : 'dialog';\n const menubar = useContext(MenubarContext);\n const inputElementRef = useRef<HTMLInputElement | null>(null);\n // Whether the consumer authors aria-selected in the body themselves, in\n // which case this component’s aria-selected fill-ins stand down (set per\n // open in handleBodyRef)\n const consumerOwnsARIASelectedRef = useRef(false);\n // Body elements already annotated this open (see handleBodyRef)\n const annotatedBodiesRef = useRef<WeakSet<HTMLElement>>(new WeakSet());\n const closingTimerRef = useRef<null | TimeoutID>(null);\n const isOpeningTimerRef = useRef<null | TimeoutID>(null);\n const currentInputMethodRef = useRef<'keyboard' | 'mouse'>('mouse');\n const clearEnteredCharactersTimerRef = useRef<null | TimeoutID>(null);\n const enteredCharactersRef = useRef<string>('');\n const mouseDownPositionRef = useRef<MousePosition | null>(null);\n const disclosureTimerRef = useRef<null | TimeoutID>(null);\n const pendingDisclosureItemRef = useRef<MaybeHTMLElement>(null);\n const submenuRegistrationsRef = useRef<Set<SubmenuRegistration>>(new Set());\n const pointerRef = useRef<Point | null>(null);\n const lastMouseEventRef = useRef<MouseEvent | null>(null);\n const safeAreaRef = useRef<{ apex: Point; parent: HTMLElement } | null>(null);\n const safeAreaTimerRef = useRef<null | TimeoutID>(null);\n const wasInSafeAreaRef = useRef<boolean>(false);\n const hoverCloseTimerRef = useRef<null | TimeoutID>(null);\n\n const allowCreateRef = useRef(allowCreate);\n const allowEmptyRef = useRef(allowEmpty);\n const hasItemsRef = useRef(hasItems);\n const isOpenRef = useRef(isOpen);\n const isOpeningRef = useRef(isOpening);\n const keepOpenOnSubmitRef = useRef(keepOpenOnSubmit);\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n const onSubmitItemRef = useRef(onSubmitItem);\n const valueRef = useRef(valueIdentity);\n\n useEffect(() => {\n allowCreateRef.current = allowCreate;\n allowEmptyRef.current = allowEmpty;\n hasItemsRef.current = hasItems;\n isOpenRef.current = isOpen;\n isOpeningRef.current = isOpening;\n keepOpenOnSubmitRef.current = keepOpenOnSubmit;\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n onSubmitItemRef.current = onSubmitItem;\n valueRef.current = valueIdentity;\n }, [\n allowCreate,\n allowEmpty,\n hasItems,\n isOpen,\n isOpening,\n keepOpenOnSubmit,\n onClose,\n onOpen,\n onSubmitItem,\n valueIdentity,\n ]);\n\n const isMountedRef = useRef(false);\n\n useEffect(() => {\n if (!isMountedRef.current) {\n isMountedRef.current = true;\n // If isOpenOnMount, trigger onOpen right away\n if (isOpenRef.current && onOpenRef.current) {\n onOpenRef.current();\n }\n return;\n }\n\n if (isOpen && onOpenRef.current) {\n onOpenRef.current();\n } else if (!isOpen && onCloseRef.current) {\n onCloseRef.current();\n }\n }, [isOpen]);\n\n // Nested (submenu) Dropdowns register here so their scoped callbacks\n // (onActiveItem/onOpen/onClose/onSubmitItem) can be dispatched to them\n const dropdownContextValue: DropdownContextValue = useMemo(\n () => ({\n registerSubmenu(registration: SubmenuRegistration) {\n submenuRegistrationsRef.current.add(registration);\n return () => {\n submenuRegistrationsRef.current.delete(registration);\n };\n },\n }),\n [],\n );\n\n const dispatchToSubmenus = (key: 'onActiveItem' | 'onSubmitItem', payload: Item) => {\n if (!payload.element) return;\n for (const registration of submenuRegistrationsRef.current) {\n if (registration.element.contains(payload.element)) {\n registration[key]?.(payload);\n }\n }\n };\n\n const handleActiveItem = (payload: Item) => {\n onActiveItem?.(payload);\n dispatchToSubmenus('onActiveItem', payload);\n };\n\n const handleToggleSubmenu = (item: HTMLElement, isExpanded: boolean) => {\n // Show/hide the submenu in the top layer (popover=\"manual\"), like the\n // body, so no ancestor can become its containing block and shift its\n // anchor placement. Gate on the current state so a redundant toggle is\n // a no-op instead of a showPopover/hidePopover that throws.\n const submenu = getSubmenuOfItem(item);\n if (submenu) {\n const isShown = submenu.matches(':popover-open');\n if (isExpanded && !isShown) submenu.showPopover();\n else if (!isExpanded && isShown) submenu.hidePopover();\n }\n for (const registration of submenuRegistrationsRef.current) {\n if (registration.element === item) {\n (isExpanded ? registration.onOpen : registration.onClose)?.();\n }\n }\n };\n\n const clearDisclosureTimer = () => {\n if (disclosureTimerRef.current != null) {\n clearTimeout(disclosureTimerRef.current);\n disclosureTimerRef.current = null;\n }\n pendingDisclosureItemRef.current = null;\n };\n\n // Clear the disclosure intent timer on unmount so it can’t fire against\n // unmounted DOM or dispatch submenu callbacks after teardown\n useEffect(() => clearDisclosureTimer, []);\n\n // A parent item discloses its submenu after a short intent delay whenever\n // it becomes (and stays) the deepest active item, for pointer and keyboard\n // alike; submenus off the active path collapse immediately\n const syncSubmenuDisclosure = () => {\n if (!dropdownElement) return;\n const activeElement = getActiveItemElement(dropdownElement);\n collapseItemsOutsidePath(dropdownElement, activeElement, handleToggleSubmenu);\n const submenu = activeElement ? getSubmenuOfItem(activeElement) : null;\n if (activeElement && submenu && !isItemExpanded(activeElement)) {\n // A timer already pending for this item keeps its original start time\n if (pendingDisclosureItemRef.current === activeElement) return;\n clearDisclosureTimer();\n pendingDisclosureItemRef.current = activeElement;\n disclosureTimerRef.current = setTimeout(() => {\n disclosureTimerRef.current = null;\n pendingDisclosureItemRef.current = null;\n if (!activeElement.hasAttribute('data-ukt-active')) return;\n expandItem(activeElement, handleToggleSubmenu);\n }, SUBMENU_DISCLOSURE_DELAY);\n return;\n }\n clearDisclosureTimer();\n };\n\n const clearSafeAreaTimer = () => {\n if (safeAreaTimerRef.current != null) {\n clearTimeout(safeAreaTimerRef.current);\n safeAreaTimerRef.current = null;\n }\n };\n\n // Clear the safe-area give-up timer on unmount so it can’t fire against\n // unmounted DOM\n useEffect(() => clearSafeAreaTimer, []);\n\n // The safe area is the triangle from where the pointer last sat on the\n // open submenu’s parent (the apex) to that submenu’s two near corners.\n // While the pointer is inside it, it’s traveling toward the submenu, so the\n // submenu stays open even as the pointer crosses sibling items — the macOS\n // diagonal behavior\n const isPointerInSafeArea = (x: number, y: number): boolean => {\n const safeArea = safeAreaRef.current;\n if (!safeArea || !isItemExpanded(safeArea.parent)) return false;\n const submenu = getSubmenuOfItem(safeArea.parent);\n if (!submenu) return false;\n const submenuRect = submenu.getBoundingClientRect();\n const parentRect = safeArea.parent.getBoundingClientRect();\n // Submenus can open to either side; the near edge is the one facing\n // the parent item\n const nearX =\n submenuRect.left >= parentRect.right - 1\n ? submenuRect.left\n : submenuRect.right;\n return isPointInTriangle(\n { x, y },\n safeArea.apex,\n { x: nearX, y: submenuRect.top },\n { x: nearX, y: submenuRect.bottom },\n );\n };\n\n // The pointer left the safe area (or paused in it without reaching the\n // submenu): stop protecting the submenu and switch to whatever the pointer\n // is over now. Passing the target avoids an elementFromPoint read; the\n // give-up timer has no event, so it falls back to hit-testing the pointer\n const commitPointerTarget = (targetElement?: MaybeHTMLElement) => {\n clearSafeAreaTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n const pointer = pointerRef.current;\n const target =\n targetElement ??\n (pointer\n ? (dropdownElement?.ownerDocument.elementFromPoint(\n pointer.x,\n pointer.y,\n ) as MaybeHTMLElement)\n : null);\n if (!dropdownElement || !target || !dropdownElement.contains(target)) return;\n const item = getItemForTarget(dropdownElement, target);\n const event = lastMouseEventRef.current;\n // Only reachable via mouse events, so a real mouse event is on hand\n if (item && event) {\n setActiveItem({\n dropdownElement,\n element: item,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n };\n\n // Track the pointer against the open submenu’s safe area: anchor the apex\n // while over the parent item, and (re)arm the give-up timer while traveling\n // toward the submenu so only a pause — not motion — ends the protection\n const trackSafeArea = (event: ReactMouseEvent<HTMLElement>) => {\n // Safe-area intent only applies to an open menu with items; skip the\n // per-move DOM query otherwise (mousemove is a hot path)\n if (!dropdownElement || !isOpenRef.current || !hasItemsRef.current) return;\n const pointer = { x: event.clientX, y: event.clientY };\n pointerRef.current = pointer;\n lastMouseEventRef.current = event.nativeEvent;\n const parent = getDeepestExpandedItem(dropdownElement);\n if (!parent) {\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n clearSafeAreaTimer();\n return;\n }\n const target = event.target as HTMLElement;\n const submenu = getSubmenuOfItem(parent);\n const isOverParent =\n parent.contains(target) && !(submenu?.contains(target) ?? false);\n if (isOverParent) {\n safeAreaRef.current = { apex: pointer, parent };\n wasInSafeAreaRef.current = false;\n clearSafeAreaTimer();\n return;\n }\n // A newly-open submenu we haven’t anchored an apex for yet\n if (safeAreaRef.current?.parent !== parent) {\n safeAreaRef.current = null;\n }\n clearSafeAreaTimer();\n if (isPointerInSafeArea(pointer.x, pointer.y)) {\n wasInSafeAreaRef.current = true;\n safeAreaTimerRef.current = setTimeout(commitPointerTarget, SAFE_AREA_TIMEOUT);\n } else if (wasInSafeAreaRef.current) {\n // Just crossed out of the triangle. The pointer may still be over\n // the same sibling it entered while protected, so no mouseover will\n // fire — re-evaluate and activate whatever it’s on now\n commitPointerTarget(target);\n }\n };\n\n const clearHoverCloseTimer = () => {\n if (hoverCloseTimerRef.current != null) {\n clearTimeout(hoverCloseTimerRef.current);\n hoverCloseTimerRef.current = null;\n }\n };\n\n // Clear props.openOnHover’s close timer on unmount so it can’t fire against\n // unmounted DOM\n useEffect(() => clearHoverCloseTimer, []);\n\n const closeDropdown = (options?: { keepMenubarEngaged?: boolean }) => {\n setIsOpen(false);\n setIsOpening(false);\n mouseDownPositionRef.current = null;\n clearDisclosureTimer();\n clearSafeAreaTimer();\n clearHoverCloseTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n if (closingTimerRef.current != null) {\n clearTimeout(closingTimerRef.current);\n closingTimerRef.current = null;\n }\n // A self-dismissal — Escape, an outside click, or an item selection —\n // takes an enclosing menubar out of menu-mode. Switching menus,\n // clearing the open menu on hover, and focus changes pass\n // keepMenubarEngaged to stay in menu-mode.\n if (menubar && dropdownElement && !options?.keepMenubarEngaged) {\n menubar.notifyClosed(dropdownElement);\n }\n };\n\n // The pointer entered the trigger or (if open) the body: cancel any\n // pending close and, if props.openOnHover and not already open, open now\n const handleDropdownMouseEnter = () => {\n clearHoverCloseTimer();\n if (!openOnHover || isOpenRef.current) return;\n setIsOpen(true);\n setIsOpening(false);\n };\n\n // The pointer left the trigger and body entirely: if open, arm the\n // close-intent timer (a re-entry before it fires cancels it above, so\n // crossing the trigger/body gap doesn’t flicker)\n const handleDropdownMouseLeave = () => {\n if (!openOnHover || !isOpenRef.current || hoverCloseTimerRef.current != null) {\n return;\n }\n hoverCloseTimerRef.current = setTimeout(() => {\n hoverCloseTimerRef.current = null;\n closeDropdown();\n }, HOVER_CLOSE_DELAY);\n };\n\n const focusTrigger = () => {\n const firstChild = dropdownElement?.firstElementChild as MaybeHTMLElement;\n if (!firstChild) return;\n const focusable = firstChild.matches(FOCUSABLE_SELECTOR)\n ? firstChild\n : (firstChild.querySelector(FOCUSABLE_SELECTOR) as MaybeHTMLElement);\n focusable?.focus();\n };\n\n // Register with an enclosing Menubar (one open menu at a time, ←/→\n // moves between menus, hover-to-switch once any menu is open). Closing\n // goes through closeDropdown so pending timers (submenu disclosure,\n // close delay) can’t fire against a menu the menubar already closed.\n useEffect(() => {\n if (!menubar || !dropdownElement) return;\n return menubar.registerMember({\n close: () => closeDropdown({ keepMenubarEngaged: true }),\n element: dropdownElement,\n focusTrigger,\n isOpen: () => isOpenRef.current,\n open: () => setIsOpen(true),\n });\n });\n\n useEffect(() => {\n if (isOpen && menubar && dropdownElement) {\n menubar.notifyOpened(dropdownElement);\n }\n }, [dropdownElement, isOpen, menubar]);\n\n const handleSubmitItem = (event: Event | React.SyntheticEvent<HTMLElement>) => {\n const element = hasItemsRef.current\n ? getActiveItemElement(dropdownElement)\n : null;\n\n const submenuOfActive = element ? getSubmenuOfItem(element) : null;\n if (element && submenuOfActive) {\n // Parent items disclose; they never submit\n clearDisclosureTimer();\n expandItem(element, handleToggleSubmenu);\n if (currentInputMethodRef.current === 'keyboard' && dropdownElement) {\n const firstItem = getItemElements(dropdownElement, submenuOfActive)?.[0];\n if (firstItem) {\n setActiveItem({\n dropdownElement,\n element: firstItem,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n }\n return;\n }\n\n if (isOpenRef.current && !keepOpenOnSubmitRef.current) {\n // A short timeout before closing is better UX when user selects an item so dropdown\n // doesn’t close before expected. It also enables using <Link />s in the dropdown body.\n closingTimerRef.current = setTimeout(closeDropdown, 90);\n }\n\n if (!hasItemsRef.current) return;\n\n if (!element) {\n // With nothing selected, the only possible value comes from a text\n // input (a searchable dropdown’s input, or one inside a custom\n // trigger). No input means there’s no value to submit at all, so\n // bail regardless of allowCreate/allowEmpty instead of firing an\n // empty-valued onSubmitItem consumers have to defend against. (To\n // let such a dropdown clear its value, give it an explicit\n // empty-valued item, which submits as a normal active selection.)\n if (!inputElementRef.current) return;\n if (inputElementRef.current.value) {\n // Non-empty text matching no item is a created value\n if (!allowCreateRef.current) return;\n } else if (!allowEmptyRef.current) {\n // A cleared input is an empty (clearing) submit, which\n // allowEmpty gates even when allowCreate is set — “creating”\n // an empty value is clearing, not creating\n return;\n }\n }\n\n let itemLabel = element?.innerText ?? '';\n if (inputElementRef.current) {\n if (!element) {\n itemLabel = inputElementRef.current.value;\n } else {\n inputElementRef.current.value = itemLabel;\n }\n\n if (\n inputElementRef.current ===\n inputElementRef.current.ownerDocument.activeElement\n ) {\n inputElementRef.current.blur();\n }\n }\n\n const nextValue = element?.dataset.uktValue ?? itemLabel;\n // If parent is controlling Dropdown via props.value and nextValue is the same, do nothing\n if (valueRef.current && valueRef.current === nextValue) return;\n\n // When the body stays open after submit (keepOpenOnSubmit), move\n // aria-selected to the submitted option so the open-time annotation\n // doesn’t go stale; a closing body unmounts, so reopening re-derives\n // it from props.value. Listbox only — aria-selected isn’t valid on a\n // menuitem — scoped to the popup body (never a custom trigger’s own\n // aria-selected), and skipped entirely when the consumer authors\n // aria-selected themselves.\n if (\n element &&\n keepOpenOnSubmitRef.current &&\n popupRole === 'listbox' &&\n !consumerOwnsARIASelectedRef.current\n ) {\n const bodyElement = element.closest('.uktdropdown-body');\n for (const selected of Array.from(\n bodyElement?.querySelectorAll('[aria-selected=\"true\"]') ?? [],\n )) {\n selected.removeAttribute('aria-selected');\n }\n element.setAttribute('aria-selected', 'true');\n }\n\n // If the item is clickable or contains exactly one clickable element, invoke it\n // (but only if the event didn’t already originate from that element)\n if (element) {\n const eventTarget = event.target as HTMLElement;\n\n if (element.matches(CLICKABLE_SELECTOR)) {\n // The item element itself is clickable (e.g., <button data-ukt-value=\"…\">)\n if (element !== eventTarget && !element.contains(eventTarget)) {\n element.click();\n }\n } else {\n // Check if item contains exactly one clickable child element\n const clickableElements = element.querySelectorAll(CLICKABLE_SELECTOR);\n if (clickableElements.length === 1) {\n const clickableElement = clickableElements[0] as HTMLElement;\n if (\n clickableElement !== eventTarget &&\n !clickableElement.contains(eventTarget)\n ) {\n clickableElement.click();\n }\n }\n }\n }\n\n const payload: Item = {\n element,\n event,\n label: itemLabel,\n path: getItemPath(element),\n value: nextValue,\n };\n onSubmitItemRef.current?.(payload);\n dispatchToSubmenus('onSubmitItem', payload);\n };\n\n const handleMouseMove = (event: ReactMouseEvent<HTMLElement>) => {\n const { clientX, clientY } = event;\n currentInputMethodRef.current = 'mouse';\n trackSafeArea(event);\n const initialPosition = mouseDownPositionRef.current;\n if (!initialPosition) return;\n if (\n Math.abs(initialPosition.clientX - clientX) < 12 &&\n Math.abs(initialPosition.clientY - clientY) < 12\n ) {\n return;\n }\n setIsOpening(false);\n };\n\n const handleMouseOver = (event: ReactMouseEvent<HTMLElement>) => {\n if (!hasItemsRef.current) return;\n\n // If user isn’t currently using the mouse to navigate the dropdown, do nothing\n if (currentInputMethodRef.current !== 'mouse') return;\n\n // Ensure we have the dropdown root HTMLElement\n if (!dropdownElement) return;\n\n const eventTarget = event.target as HTMLElement;\n if (!eventTarget.closest('.uktdropdown-body')) return;\n\n // Hover inside an open nested dropdown belongs to that dropdown\n const hoveredRoot = eventTarget.closest('.uktdropdown');\n if (\n hoveredRoot !== dropdownElement &&\n hoveredRoot?.classList.contains('is-open')\n ) {\n return;\n }\n\n // Heading toward an open submenu: keep it open even over sibling items\n if (isPointerInSafeArea(event.clientX, event.clientY)) return;\n\n const item = getItemForTarget(dropdownElement, eventTarget);\n if (!item) return;\n\n setActiveItem({\n dropdownElement,\n element: item,\n event,\n onActiveItem: handleActiveItem,\n });\n syncSubmenuDisclosure();\n };\n\n const handleMouseOut = (event: ReactMouseEvent<HTMLElement>) => {\n if (!hasItemsRef.current) return;\n // The pointer left the dropdown entirely: drop the safe area so its\n // give-up timer can’t later fire on a stale position, and fall through\n // to the normal collapse (mousemove has stopped, so nothing else will)\n const relatedTarget = event.relatedTarget as Node | null;\n const isLeavingDropdown = !dropdownElement?.contains(relatedTarget);\n if (isLeavingDropdown) {\n clearSafeAreaTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n }\n // Heading toward an open submenu: don’t clear the active item / collapse\n if (isPointerInSafeArea(event.clientX, event.clientY)) return;\n const activeItem = getActiveItemElement(dropdownElement);\n if (!activeItem) return;\n const eventRelatedTarget = event.relatedTarget as HTMLElement;\n if (activeItem !== event.target || activeItem.contains(eventRelatedTarget)) {\n return;\n }\n // If user moused out of activeItem (not into a descendant), it’s no longer active\n delete activeItem.dataset.uktActive;\n syncSubmenuDisclosure();\n };\n\n const handleMouseDown = (event: ReactMouseEvent<HTMLElement>) => {\n if (onMouseDown) onMouseDown(event);\n if (isOpenRef.current) return;\n\n setIsOpen(true);\n setIsOpening(true);\n mouseDownPositionRef.current = {\n clientX: event.clientX,\n clientY: event.clientY,\n };\n isOpeningTimerRef.current = setTimeout(() => {\n setIsOpening(false);\n isOpeningTimerRef.current = null;\n }, 1000);\n };\n\n const handleMouseUp = (event: ReactMouseEvent<HTMLElement>) => {\n if (onMouseUp) onMouseUp(event);\n // If dropdown is still opening or isn’t open or is closing, do nothing\n if (\n isOpeningRef.current ||\n !isOpenRef.current ||\n closingTimerRef.current != null\n ) {\n return;\n }\n\n const eventTarget = event.target as HTMLElement;\n\n // Clicks inside an open nested dropdown belong to that dropdown\n const clickedRoot = eventTarget.closest('.uktdropdown');\n if (\n clickedRoot !== dropdownElement &&\n clickedRoot?.classList.contains('is-open') &&\n dropdownElement?.contains(clickedRoot)\n ) {\n return;\n }\n\n // A click only counts as inside the body if the closest body element\n // belongs to this dropdown (a nested dropdown’s trigger sits inside\n // the outer body, but the outer body isn’t the nested one’s own)\n const targetBody = eventTarget.closest('.uktdropdown-body');\n const isInOwnBody = Boolean(\n targetBody && targetBody.closest('.uktdropdown') === dropdownElement,\n );\n // If click was outside dropdown body, don’t trigger submit\n if (!isInOwnBody) {\n // Don’t close dropdown if isOpening or search input is focused\n if (\n !isOpeningRef.current &&\n inputElementRef.current !== eventTarget.ownerDocument.activeElement\n ) {\n closeDropdown();\n }\n return;\n }\n\n // If dropdown has no items and click was within dropdown body, do nothing\n if (!hasItemsRef.current) return;\n\n if (dropdownElement) {\n const clickedItem = getItemForTarget(dropdownElement, eventTarget);\n if (clickedItem) {\n // Submit the item the click actually landed on: sync the\n // active item to it in case they diverge (e.g. active was\n // set via keyboard, then user clicked elsewhere)\n setActiveItem({\n dropdownElement,\n element: clickedItem,\n event,\n onActiveItem: handleActiveItem,\n });\n } else if (getActiveItemElement(dropdownElement)) {\n // A click that doesn’t land on an item — body padding, a\n // separator, or a disabled item (pointer-events: none\n // retargets its clicks to the container) — must not submit\n // the previously active item: like macOS, it does nothing.\n // With no active item it falls through, so a body click\n // can still submit an input-sourced value\n return;\n }\n }\n\n handleSubmitItem(event);\n };\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const { altKey, ctrlKey, key, metaKey } = event;\n const eventTarget = event.target as HTMLElement;\n if (!dropdownElement) return;\n\n const onEventHandled = () => {\n event.stopPropagation();\n event.preventDefault();\n currentInputMethodRef.current = 'keyboard';\n };\n\n const isEventTargetingDropdown = dropdownElement.contains(eventTarget);\n\n // Key events originating inside an open nested dropdown are that\n // dropdown’s business (e.g. an info popover nested in this body)\n const nestedRoot = eventTarget.closest?.('.uktdropdown');\n if (\n nestedRoot &&\n nestedRoot !== dropdownElement &&\n dropdownElement.contains(nestedRoot) &&\n nestedRoot.classList.contains('is-open')\n ) {\n return;\n }\n\n if (!isOpenRef.current) {\n // If dropdown is closed, don’t handle key events if event target isn’t within dropdown\n if (!isEventTargetingDropdown) return;\n // Open the dropdown on spacebar, enter, or if isSearchable and user hits the ↑/↓ arrows\n if (\n key === ' ' ||\n key === 'Enter' ||\n (hasItemsRef.current && (key === 'ArrowUp' || key === 'ArrowDown'))\n ) {\n onEventHandled();\n setIsOpen(true);\n }\n return;\n }\n\n const isTargetUsingKeyEvents = isEventTargetUsingKeyEvent(event);\n\n // If dropdown isOpen + hasItems & eventTargetNotUsingKeyEvents, handle characters\n if (hasItemsRef.current && !isTargetUsingKeyEvents) {\n let isEditingCharacters = !ctrlKey && !metaKey && /^[A-Za-z0-9]$/.test(key);\n // User could also be editing characters if there are already characters entered\n // and they are hitting delete or spacebar\n if (!isEditingCharacters && enteredCharactersRef.current) {\n isEditingCharacters = key === ' ' || key === 'Backspace';\n }\n\n if (isEditingCharacters) {\n onEventHandled();\n if (key === 'Backspace') {\n enteredCharactersRef.current = enteredCharactersRef.current.slice(\n 0,\n -1,\n );\n } else {\n enteredCharactersRef.current += key;\n }\n\n setActiveItem({\n dropdownElement,\n event,\n // If props.allowCreate, only override the input’s value with an\n // exact text match so user can enter a value not in items\n isExactMatch: allowCreateRef.current,\n onActiveItem: handleActiveItem,\n text: enteredCharactersRef.current,\n });\n syncSubmenuDisclosure();\n\n if (clearEnteredCharactersTimerRef.current != null) {\n clearTimeout(clearEnteredCharactersTimerRef.current);\n }\n\n clearEnteredCharactersTimerRef.current = setTimeout(() => {\n enteredCharactersRef.current = '';\n clearEnteredCharactersTimerRef.current = null;\n }, 1500);\n\n return;\n }\n }\n\n // If dropdown isOpen, handle submitting the value\n if (key === 'Enter' || (key === ' ' && !inputElementRef.current)) {\n onEventHandled();\n handleSubmitItem(event);\n return;\n }\n\n // If dropdown isOpen, handle closing it on escape or spacebar if !hasItems\n if (\n key === 'Escape' ||\n (isEventTargetingDropdown && key === ' ' && !hasItemsRef.current)\n ) {\n // Close dropdown if hasItems or event target not using key events\n if (hasItemsRef.current || !isTargetUsingKeyEvents) {\n // Escape closes the whole menu — submenus included — and\n // returns focus to the element that opened it. Focus before\n // closing: a searchable trigger input opens the dropdown on\n // focus, so its synchronous onFocus must land before the\n // close state update for the close to win the batch\n focusTrigger();\n closeDropdown();\n }\n return;\n }\n\n // Handle arrow keys\n if (hasItemsRef.current) {\n if (key === 'ArrowUp') {\n onEventHandled();\n if (altKey || metaKey) {\n setActiveItem({\n dropdownElement,\n event,\n index: 0,\n onActiveItem: handleActiveItem,\n });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: -1,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n return;\n }\n if (key === 'ArrowDown') {\n onEventHandled();\n if (altKey || metaKey) {\n // Using a negative index counts back from the end\n setActiveItem({\n dropdownElement,\n event,\n index: -1,\n onActiveItem: handleActiveItem,\n });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: 1,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n return;\n }\n // ←/→ dive into and surface out of submenus (and move between\n // menus in a menubar); leave them alone when a text input has focus\n if (!isTargetUsingKeyEvents) {\n if (key === 'ArrowRight') {\n const activeElement = getActiveItemElement(dropdownElement);\n const submenu = activeElement\n ? getSubmenuOfItem(activeElement)\n : null;\n if (activeElement && submenu) {\n onEventHandled();\n clearDisclosureTimer();\n expandItem(activeElement, handleToggleSubmenu);\n const firstItem = getItemElements(dropdownElement, submenu)?.[0];\n if (firstItem) {\n setActiveItem({\n dropdownElement,\n element: firstItem,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n return;\n }\n if (menubar) {\n onEventHandled();\n menubar.moveOpen(dropdownElement, 1);\n }\n return;\n }\n if (key === 'ArrowLeft') {\n const activeElement = getActiveItemElement(dropdownElement);\n const levelRoot = activeElement ? getLevelRoot(activeElement) : null;\n if (levelRoot) {\n onEventHandled();\n clearDisclosureTimer();\n const parentItem = getParentItem(levelRoot);\n if (parentItem) {\n collapseItem(parentItem, handleToggleSubmenu);\n }\n return;\n }\n if (menubar) {\n onEventHandled();\n menubar.moveOpen(dropdownElement, -1);\n }\n return;\n }\n }\n }\n };\n\n useKeyboardEvents({ ignoreUsedKeyboardEvents: false, onKeyDown: handleKeyDown });\n\n const handleRef = (ref: HTMLDivElement | null): (() => void) | void => {\n setDropdownElement(ref);\n if (!ref) return;\n\n const { ownerDocument } = ref;\n let inputElement = inputElementRef.current;\n // Check if trigger is a textual input or textarea element\n if (!inputElement && ref.firstElementChild) {\n if (ref.firstElementChild.matches(TEXT_INPUT_SELECTOR)) {\n inputElement = ref.firstElementChild as HTMLInputElement;\n } else {\n inputElement = ref.firstElementChild.querySelector(TEXT_INPUT_SELECTOR);\n }\n inputElementRef.current = inputElement;\n }\n\n const handleGlobalMouseDown = ({ target }: MouseEvent) => {\n const eventTarget = target as HTMLElement;\n if (!ref.contains(eventTarget)) {\n // Close dropdown on an outside click\n closeDropdown();\n }\n };\n\n const handleGlobalMouseUp = ({ target }: MouseEvent) => {\n if (!isOpenRef.current || closingTimerRef.current != null) return;\n\n // If still isOpening (gets set false 1s after open triggers), set it to false onMouseUp\n if (isOpeningRef.current) {\n setIsOpening(false);\n if (isOpeningTimerRef.current != null) {\n clearTimeout(isOpeningTimerRef.current);\n isOpeningTimerRef.current = null;\n }\n return;\n }\n\n const eventTarget = target as HTMLElement;\n // Only handle mouseup events from outside the dropdown here\n if (!ref.contains(eventTarget)) {\n closeDropdown();\n }\n };\n\n // Close dropdown if any element is focused outside of this dropdown\n const handleGlobalFocusIn = ({ target }: Event) => {\n if (!isOpenRef.current) return;\n\n const eventTarget = target as HTMLElement;\n // If focused element is a descendant or a parent of the dropdown, do nothing\n if (ref.contains(eventTarget) || eventTarget.contains(ref)) {\n return;\n }\n\n // Losing focus — including the focus shift when the body unmounts\n // on close — doesn’t end a menubar’s menu-mode; that takes a\n // deliberate dismissal (Escape, outside click, item select).\n closeDropdown({ keepMenubarEngaged: true });\n };\n\n document.addEventListener('focusin', handleGlobalFocusIn);\n document.addEventListener('mousedown', handleGlobalMouseDown);\n document.addEventListener('mouseup', handleGlobalMouseUp);\n\n if (ownerDocument !== document) {\n ownerDocument.addEventListener('focusin', handleGlobalFocusIn);\n ownerDocument.addEventListener('mousedown', handleGlobalMouseDown);\n ownerDocument.addEventListener('mouseup', handleGlobalMouseUp);\n }\n\n // If dropdown should be open on mount, focus it\n if (isOpenOnMount) {\n ref.focus();\n }\n\n const handleInput = (event: Event) => {\n if (!isOpenRef.current) setIsOpen(true);\n\n const input = event.target as HTMLInputElement;\n const isDeleting = enteredCharactersRef.current.length > input.value.length;\n enteredCharactersRef.current = input.value;\n // When deleting text, if there’s already an active item and\n // input isn’t empty, preserve the active item, else update it\n if (isDeleting && input.value.length && getActiveItemElement(ref)) {\n return;\n }\n\n setActiveItem({\n dropdownElement: ref,\n event,\n // If props.allowCreate, only override the input’s value with an\n // exact text match so user can enter a value not in items\n isExactMatch: allowCreateRef.current,\n onActiveItem: handleActiveItem,\n text: enteredCharactersRef.current,\n });\n };\n\n if (inputElement) {\n inputElement.addEventListener('input', handleInput);\n }\n\n return () => {\n document.removeEventListener('focusin', handleGlobalFocusIn);\n document.removeEventListener('mousedown', handleGlobalMouseDown);\n document.removeEventListener('mouseup', handleGlobalMouseUp);\n\n if (ownerDocument !== document) {\n ownerDocument.removeEventListener('focusin', handleGlobalFocusIn);\n ownerDocument.removeEventListener('mousedown', handleGlobalMouseDown);\n ownerDocument.removeEventListener('mouseup', handleGlobalMouseUp);\n }\n\n if (inputElement) {\n inputElement.removeEventListener('input', handleInput);\n }\n };\n };\n\n // When the body mounts (open): fill in parent-item/submenu ARIA, and\n // render it in the top layer via popover so an ancestor’s transform /\n // filter / contain can’t become the containing block for the fixed body\n // and break its anchor positioning + fallbacks. popover=\"manual\" keeps\n // dismissal under this component’s own listeners (see handleRef), which\n // preserves iframe support and searchable/text-input triggers that native\n // light-dismiss would close on any outside pointerdown.\n // These annotations run once per open (the body unmounts on close and is\n // annotated fresh each time); items rendered into an already-open body —\n // async-loaded or consumer-filtered — aren’t annotated until the next\n // open. Known limitation until it’s needed.\n const handleBodyRef = (ref: HTMLDivElement | null) => {\n if (!ref) return;\n // An inline ref callback re-attaches (and re-runs) on every re-render\n // while the body is open, but everything below must run exactly once\n // per open: showPopover() throws on an already-shown popover, and the\n // ownership check would read the reveal’s own aria-selected annotation\n // back as consumer-authored. Each open mounts a fresh body element, so\n // latch per element (a WeakSet, to hold no unmounted bodies alive).\n if (annotatedBodiesRef.current.has(ref)) return;\n annotatedBodiesRef.current.add(ref);\n // A consumer-authored aria-selected anywhere in the just-mounted body\n // (whether \"true\" or \"false\") means the consumer manages selection\n // ARIA themselves: the reveal below and the keepOpenOnSubmit move in\n // handleSubmitItem both stand down, so a single-select listbox never\n // ends up with two selected options (the usual your-values-win rule).\n consumerOwnsARIASelectedRef.current =\n ref.querySelector('[aria-selected]') != null;\n annotateParentItems(ref);\n if (popupRole !== 'dialog') annotateItemRoles(ref, popupRole);\n // The Popover API is Baseline 2024, so showPopover() needs no feature\n // detection; the body is mounted only while open, so this runs once\n // per open and won’t throw on an already-open body.\n ref.showPopover();\n // Reveal the current value on open: mark the matching option\n // aria-selected (listbox only — aria-selected isn’t valid on a\n // menuitem), make it the active item (so keyboard navigation starts\n // there), and scroll it into view — so a controlled dropdown opens\n // showing (and at) its current selection. The lookup is deliberately\n // top-level only (getItemElements filters to the root level):\n // search/typeahead also match per level, and no native menu opens\n // with submenus pre-expanded, so a value matching only a submenu\n // item is a graceful no-op, like a value matching nothing.\n if (valueIdentity != null && dropdownElement) {\n const selectedItem = getItemElements(dropdownElement)?.find(\n (item) => item.dataset.uktValue === valueIdentity,\n );\n if (selectedItem) {\n if (popupRole === 'listbox' && !consumerOwnsARIASelectedRef.current) {\n selectedItem.setAttribute('aria-selected', 'true');\n }\n setActiveItem({ dropdownElement, element: selectedItem });\n }\n }\n };\n\n if (!isValidElement(trigger)) {\n if (isSearchable) {\n trigger = (\n <input\n aria-controls={bodyId}\n aria-expanded={isOpen}\n aria-haspopup={popupRole}\n autoComplete=\"off\"\n className=\"uktdropdown-trigger\"\n defaultValue={valueLabel ?? ''}\n disabled={disabled}\n name={name}\n onFocus={() => setIsOpen(true)}\n placeholder={placeholder}\n ref={inputElementRef}\n tabIndex={tabIndex}\n type=\"text\"\n />\n );\n } else {\n trigger = (\n <button\n aria-controls={bodyId}\n aria-expanded={isOpen}\n aria-haspopup={popupRole}\n className=\"uktdropdown-trigger\"\n tabIndex={0}\n type=\"button\"\n >\n {trigger}\n </button>\n );\n }\n } else {\n // For a consumer-provided trigger, add ARIA props (letting the consumer\n // override by specifying their own).\n const triggerProps = trigger.props as Record<string, unknown>;\n trigger = cloneElement(trigger as ReactElement<Record<string, unknown>>, {\n 'aria-controls': triggerProps['aria-controls'] ?? bodyId,\n 'aria-expanded': triggerProps['aria-expanded'] ?? isOpen,\n 'aria-haspopup': triggerProps['aria-haspopup'] ?? popupRole,\n });\n }\n\n if (label != null) {\n trigger = (\n <label className=\"uktdropdown-label\">\n <div className=\"uktdropdown-label-text\">{label}</div>\n {trigger}\n </label>\n );\n }\n\n return (\n <Fragment>\n <style href=\"@acusti/dropdown/Dropdown\" precedence=\"medium\">\n {styles}\n </style>\n <div\n className={clsx('uktdropdown', className, {\n disabled,\n 'is-open': isOpen,\n 'is-searchable': isSearchable,\n })}\n onClick={onClick}\n onMouseDown={handleMouseDown}\n onMouseEnter={handleDropdownMouseEnter}\n onMouseLeave={handleDropdownMouseLeave}\n onMouseMove={handleMouseMove}\n onMouseOut={handleMouseOut}\n onMouseOver={handleMouseOver}\n onMouseUp={handleMouseUp}\n ref={handleRef}\n style={styleFromProps}\n >\n {trigger}\n {/* TODO next version of Dropdown should use <Activity> for body https://react.dev/reference/react/Activity */}\n {isOpen ? (\n <div\n className={clsx('uktdropdown-body', {\n 'has-items': hasItems,\n })}\n id={bodyId}\n popover=\"manual\"\n ref={handleBodyRef}\n role={popupRole}\n >\n <div className=\"uktdropdown-content\">\n <DropdownContext.Provider\n value={hasItems ? dropdownContextValue : null}\n >\n {body}\n </DropdownContext.Provider>\n </div>\n </div>\n ) : null}\n </div>\n </Fragment>\n );\n}\n\nconst INERT_SUBMENU_PROPS = [\n 'allowCreate',\n 'allowEmpty',\n 'isOpenOnMount',\n 'isSearchable',\n 'keepOpenOnSubmit',\n 'name',\n 'openOnHover',\n 'placeholder',\n 'tabIndex',\n 'value',\n] as const;\n\n// The nested (submenu) rendering of Dropdown: a parent item that discloses a\n// child menu. It renders the data-ukt-submenu protocol and registers with the\n// root dropdown, whose engine handles all interaction.\nfunction SubmenuDropdown(props: Props & { parentDropdown: DropdownContextValue }) {\n const {\n children,\n className,\n disabled,\n label,\n onActiveItem,\n onClose,\n onOpen,\n onSubmitItem,\n parentDropdown,\n style,\n } = props;\n\n const itemRef = useRef<HTMLLIElement | null>(null);\n\n useEffect(() => {\n const element = itemRef.current;\n if (!element) return;\n return parentDropdown.registerSubmenu({\n element,\n onActiveItem,\n onClose,\n onOpen,\n onSubmitItem,\n });\n }, [onActiveItem, onClose, onOpen, onSubmitItem, parentDropdown]);\n\n // Misuse feedback is unconditional, like the children-count error above\n const warnedRef = useRef(false);\n useEffect(() => {\n if (warnedRef.current) return;\n const inertProps = INERT_SUBMENU_PROPS.filter(\n (propName) => props[propName] !== undefined,\n );\n if (!inertProps.length) return;\n warnedRef.current = true;\n console.error(\n `@acusti/dropdown: ${inertProps.join(', ')} only apply to a top-level Dropdown and are ignored on a nested (submenu) Dropdown.`,\n );\n });\n\n const childrenCount = Children.count(children);\n let labelContent: ReactNode = label;\n let body: ReactNode = children;\n if (childrenCount > 1) {\n labelContent = (children as ChildrenTuple)[0];\n body = (children as ChildrenTuple)[1];\n }\n\n // popover=\"manual\" renders the submenu in the top layer (see the\n // [data-ukt-submenu] CSS and handleToggleSubmenu), escaping the body’s\n // containing block so its anchor placement is correct across browsers. The\n // root dropdown’s engine calls showPopover/hidePopover as the item toggles.\n const submenu = isValidElement(body) ? (\n cloneElement(body as ReactElement<Record<string, unknown>>, {\n 'data-ukt-submenu': '',\n popover: 'manual',\n })\n ) : (\n <div data-ukt-submenu=\"\" popover=\"manual\">\n {body}\n </div>\n );\n\n return (\n <li\n aria-disabled={disabled || undefined}\n className={className}\n data-ukt-item=\"\"\n ref={itemRef}\n style={style}\n >\n {labelContent}\n {submenu}\n </li>\n );\n}\n\nexport { default as Menubar, type MenubarProps } from './Menubar.js';\n"],"mappings":";;;;;;;AAkBA,IAAaa,kBAAkBb,cAA2C,IAAI;AAiB9E,IAAa2B,iBAAiB3B,cAA0C,IAAI;;;;;;AE9B5E,IAAakC,gBAAgB;AAC7B,IAAaC,mBAAmB;AAEhC,IAAMC,yBAAyB;AAM/B,IAAMM,kBAAkBC,oBACnBA,iBAAiBC,cAAc,mBAAmB,KAAK;AAI5D,IAAaC,gBAAgBC,YACzBA,QAAQC,QAAQZ,gBAAgB;AAGpC,IAAaa,oBAAoBV,SAAwC;CACrE,MAAMW,UAAUX,KAAKM,cAAcT,gBAAgB;CACnD,IAAI,CAACc,SAAS,OAAO;CAErB,OADcA,QAAQE,eAAeJ,QAAAA,mCAAqB,MACzCT,OAAOW,UAAU;AACtC;AAGA,IAAaG,iBAAiBC,cACzBA,UAAUF,eAAeJ,QAAAA,mCAAqB,KAAK;AAGxD,IAAaO,gBAAgBhB,SAA8B;CACvD,IAAI,CAACU,iBAAiBV,IAAI,GAAG,OAAOA,KAAKiB,aAAa;CACtD,MAAMC,QAAQlB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AAC6R,WAAU5G,QAAO;GACtB2G,UAASpO,UAAW;GACpBpD,QAAOC,MACH,qBAAqBwR,WAAUG,KAAM,IAAI,EAAC,oFAC9C;EAAC;EACJzS,EAAA,KAAAD;EAAAC,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAVD/E,UAAUqF,EAUT;CAED,MAAAI,gBAAsBpG,SAAQqG,MAAOhD,QAAQ;CAC7C,IAAA+U,eAA8BvV;CAC9B,IAAA6D,OAAsBrD;CACtB,IAAI+C,gBAAgB,GAAC;EACjBgS,eAAgB/U,SAAyB;EACzCqD,OAAQrD,SAAyB;CAA7B;CACP,IAAA4C;CAAA,IAAAP,EAAA,OAAAgB,MAAA;EAMeT,KAAA7F,eAAesG,IAS/B,IARIzG,aAAayG,MAA+C;GAAA,oBACpC;GAAE2R,SACb;EACb,CAKJ,IAHI,oBAAA,OAAA;GAAsB,oBAAA;GAAW,SAAA;aAC5B3R;EACC,CAAA;EACThB,EAAA,KAAAgB;EAAAhB,EAAA,MAAAO;CAAA,OAAAA,KAAAP,EAAA;CATD,MAAAsF,UAAgB/E;CAaO,MAAAW,KAAApD,YAAA2C,KAAAA;CAAqB,IAAAsB;CAAA,IAAA/B,EAAA,QAAAnC,aAAAmC,EAAA,QAAA0S,gBAAA1S,EAAA,QAAAlB,SAAAkB,EAAA,QAAAsF,WAAAtF,EAAA,QAAAkB,IAAA;EADxCa,KAAA,qBAAA,MAAA;GACmB,iBAAAb;GACJrD;GACG,iBAAA;GACTuU,KAAAA;GACEtT;aALX,CAOK4T,cACApN,OACA;;EAAAtF,EAAA,MAAAnC;EAAAmC,EAAA,MAAA0S;EAAA1S,EAAA,MAAAlB;EAAAkB,EAAA,MAAAsF;EAAAtF,EAAA,MAAAkB;EAAAlB,EAAA,MAAA+B;CAAA,OAAAA,KAAA/B,EAAA;CAAA,OATL+B;AASK"}
1
+ {"version":3,"file":"Dropdown.js","names":["createContext","Item","DropdownContextValue","registerSubmenu","registration","SubmenuRegistration","element","HTMLElement","onActiveItem","payload","onClose","onOpen","onSubmitItem","DropdownContext","MenubarContextValue","moveOpen","fromElement","direction","notifyClosed","notifyOpened","registerMember","member","MenubarMember","close","focusTrigger","isOpen","open","MenubarContext","getBestMatch","Children","isValidElement","ReactNode","SyntheticEvent","Item","ITEM_SELECTOR","SUBMENU_SELECTOR","DISABLED_ITEM_SELECTOR","OnToggleSubmenu","item","HTMLElement","isExpanded","MaybeHTMLElement","getBodyElement","dropdownElement","querySelector","getLevelRoot","element","closest","getSubmenuOfItem","submenu","owner","parentElement","getParentItem","levelRoot","getItemLabel","innerText","clone","cloneNode","Array","from","querySelectorAll","remove","textContent","trim","getNodeText","node","text","forEach","child","childProps","props","children","undefined","getLabelFromChildren","value","label","visit","uktValue","String","replace","getItemPath","path","parentItem","unshift","dataset","getItemElements","bodyElement","root","candidates","length","filter","matches","items","HTMLCollection","getItemForTarget","target","targetLevelRoot","contains","itemElements","find","itemElement","getActiveItemElements","actives","getActiveItemElement","getDeepestExpandedItem","expanded","isItemExpanded","getAttribute","submenuIdCounter","ensureSubmenuARIA","hasAttribute","setAttribute","id","annotateParentItems","annotateItemRoles","popupRole","list","isMenuItem","expandItem","onToggleSubmenu","collapseItem","expandedDescendants","descendant","active","uktActive","collapseItemsOutsidePath","expandedItems","reverse","clearItemElementsState","setActiveChain","chain","Set","add","has","BaseSetActiveItemPayload","event","Event","index","indexAddend","isExactMatch","onActiveItem","payload","setActiveItem","Omit","currentDeepest","lastIndex","currentActiveIndex","findIndex","nextActiveIndex","Math","max","min","itemTexts","map","textToCompare","toLowerCase","itemText","startsWith","bestMatch","nextActiveItem","scrollableParent","isScrollable","scrollHeight","clientHeight","parentRect","getBoundingClientRect","itemRect","isAboveTop","top","isBelowBottom","bottom","scrollTop","Point","x","y","isPointInTriangle","p","a","b","c","cross","u","v","w","d1","d2","d3","hasNegative","hasPositive","clsx","CSSProperties","FocusEvent","ReactFocusEvent","KeyboardEvent","ReactKeyboardEvent","MouseEvent","ReactMouseEvent","ReactNode","useMemo","useRef","MenubarContext","MenubarContextValue","MenubarMember","MenubarProps","children","className","style","compareDocumentOrder","a","b","element","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","NON_MENU_CONTROL_SELECTOR","Menubar","t0","$","_c","t1","Symbol","for","Set","membersRef","engagedMemberRef","t2","Array","from","current","sort","getOrderedMembersRef","getOrderedMembers","t3","moveOpen","fromElement","direction","members","length","index","findIndex","member","nextIndex","close","open","focusTrigger","notifyClosed","notifyOpened","element_0","member_0","isOpen","registerMember","member_1","add","delete","contextValue","t4","event","key","members_0","some","_temp","eventTarget","target","HTMLElement","index_0","member_3","contains","preventDefault","stopPropagation","direction_0","handleKeyDown","t5","eventTarget_0","members_1","m","member_4","find","m_0","closest","openMember","switchToMemberAt","t6","event_0","handleFocus","t7","event_1","handleMouseOver","t8","t9","t10","member_2","useKeyboardEvents","isEventTargetUsingKeyEvent","clsx","Children","cloneElement","CSSProperties","Fragment","isValidElement","MouseEvent","ReactMouseEvent","ReactElement","ReactNode","SyntheticEvent","useContext","useEffect","useId","useMemo","useRef","useState","DropdownContext","DropdownContextValue","MenubarContext","SubmenuRegistration","styles","annotateItemRoles","annotateParentItems","collapseItem","collapseItemsOutsidePath","expandItem","getActiveItemElement","getDeepestExpandedItem","getItemElements","getItemForTarget","getItemPath","getLabelFromChildren","getLevelRoot","getParentItem","getSubmenuOfItem","isItemExpanded","isPointInTriangle","Point","setActiveItem","Item","element","MaybeHTMLElement","event","Event","HTMLElement","label","path","Array","ItemValue","value","Props","allowCreate","allowEmpty","children","ChildrenTuple","className","disabled","hasItems","isOpenOnMount","isSearchable","keepOpenOnSubmit","name","onActiveItem","payload","onClick","onClose","onMouseDown","onMouseUp","onOpen","onSubmitItem","openOnHover","placeholder","style","Record","tabIndex","MousePosition","clientX","clientY","TimeoutID","ReturnType","setTimeout","CHILDREN_ERROR","CLICKABLE_SELECTOR","FOCUSABLE_SELECTOR","TEXT_INPUT_SELECTOR","SUBMENU_DISCLOSURE_DELAY","SAFE_AREA_TIMEOUT","HOVER_CLOSE_DELAY","Dropdown","props","$","_c","parentDropdown","t0","RootDropdown","t1","t2","t3","styleFromProps","undefined","childrenCount","count","Error","console","error","trigger","body","valueIdentity","t4","valueLabel","isOpen","setIsOpen","isOpening","setIsOpening","dropdownElement","setDropdownElement","bodyId","popupRole","menubar","inputElementRef","consumerOwnsARIASelectedRef","t5","Symbol","for","WeakSet","annotatedBodiesRef","closingTimerRef","isOpeningTimerRef","currentInputMethodRef","clearEnteredCharactersTimerRef","enteredCharactersRef","mouseDownPositionRef","disclosureTimerRef","pendingDisclosureItemRef","t6","Set","submenuRegistrationsRef","pointerRef","lastMouseEventRef","safeAreaRef","safeAreaTimerRef","wasInSafeAreaRef","hoverCloseTimerRef","allowCreateRef","allowEmptyRef","hasItemsRef","isOpenRef","isOpeningRef","keepOpenOnSubmitRef","onCloseRef","onOpenRef","onSubmitItemRef","valueRef","t7","t8","current","isMountedRef","t10","t9","t11","registerSubmenu","registration","add","delete","dropdownContextValue","t12","key","registration_0","contains","dispatchToSubmenus","t13","payload_0","handleActiveItem","t14","item","isExpanded","submenu","isShown","matches","showPopover","hidePopover","registration_1","handleToggleSubmenu","t15","clearTimeout","clearDisclosureTimer","t16","t17","t18","activeElement","submenu_0","hasAttribute","syncSubmenuDisclosure","t19","clearSafeAreaTimer","t20","t21","t22","x","y","safeArea","parent","submenu_1","submenuRect","getBoundingClientRect","parentRect","nearX","left","right","apex","top","bottom","isPointerInSafeArea","t23","targetElement","pointer","target","ownerDocument","elementFromPoint","item_0","commitPointerTarget","t24","event_0","pointer_0","nativeEvent","target_0","submenu_2","isOverParent","trackSafeArea","t25","clearHoverCloseTimer","t26","t27","t28","options","keepMenubarEngaged","notifyClosed","closeDropdown","t29","handleDropdownMouseEnter","t30","handleDropdownMouseLeave","t31","firstElementChild","firstChild","focusable","querySelector","focus","focusTrigger","t32","registerMember","close","open","t33","t34","notifyOpened","t35","event_1","submenuOfActive","firstItem","itemLabel","innerText","blur","nextValue","dataset","uktValue","bodyElement","closest","selected","from","querySelectorAll","removeAttribute","setAttribute","eventTarget","click","clickableElements","length","clickableElement","payload_1","handleSubmitItem","t36","event_2","initialPosition","Math","abs","handleMouseMove","t37","event_3","eventTarget_0","hoveredRoot","classList","item_1","handleMouseOver","t38","event_4","relatedTarget","Node","isLeavingDropdown","activeItem","eventRelatedTarget","uktActive","handleMouseOut","t39","event_5","handleMouseDown","t40","event_6","eventTarget_1","clickedRoot","targetBody","isInOwnBody","Boolean","clickedItem","handleMouseUp","t41","event_7","altKey","ctrlKey","key_0","metaKey","eventTarget_2","onEventHandled","stopPropagation","preventDefault","isEventTargetingDropdown","nestedRoot","isTargetUsingKeyEvents","isEditingCharacters","test","slice","isExactMatch","text","index","indexAddend","activeElement_0","submenu_3","firstItem_0","moveOpen","activeElement_1","levelRoot","parentItem","handleKeyDown","t42","ignoreUsedKeyboardEvents","onKeyDown","t43","ref","inputElement","HTMLInputElement","handleGlobalMouseDown","t44","target_1","eventTarget_3","handleGlobalMouseUp","t45","target_2","eventTarget_4","handleGlobalFocusIn","t46","target_3","eventTarget_5","document","addEventListener","handleInput","event_8","input","isDeleting","removeEventListener","handleRef","ref_0","has","selectedItem","find","item_2","handleBodyRef","t47","triggerProps","t48","t49","INERT_SUBMENU_PROPS","const","SubmenuDropdown","itemRef","warnedRef","inertProps","filter","propName","join","labelContent","popover","default","Menubar","MenubarProps"],"sources":["../src/context.ts","../src/Dropdown.css?inline","../src/helpers.ts","../src/Menubar.tsx","../src/Dropdown.tsx"],"sourcesContent":["import { createContext } from 'react';\n\nimport { type Item } from './Dropdown.js';\n\nexport type DropdownContextValue = {\n registerSubmenu: (registration: SubmenuRegistration) => () => void;\n};\n\nexport type SubmenuRegistration = {\n element: HTMLElement;\n onActiveItem?: (payload: Item) => void;\n onClose?: () => unknown;\n onOpen?: () => unknown;\n onSubmitItem?: (payload: Item) => void;\n};\n\n// Provided by a menu Dropdown; a Dropdown that finds this context renders as a\n// submenu (parent item + data-ukt-submenu) instead of a root dropdown.\nexport const DropdownContext = createContext<DropdownContextValue | null>(null);\n\nexport type MenubarContextValue = {\n moveOpen: (fromElement: HTMLElement, direction: -1 | 1) => void;\n notifyClosed: (element: HTMLElement) => void;\n notifyOpened: (element: HTMLElement) => void;\n registerMember: (member: MenubarMember) => () => void;\n};\n\nexport type MenubarMember = {\n close: () => void;\n element: HTMLElement;\n focusTrigger: () => void;\n isOpen: () => boolean;\n open: () => void;\n};\n\nexport const MenubarContext = createContext<MenubarContextValue | null>(null);\n",":root {\n --uktdd-font-family:\n system-ui, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue,\n Helvetica, Arial, sans-serif;\n /* the popover is page content, not OS chrome — a native OS context menu\n always renders in the OS’s own scheme regardless of the host page,\n but this component should match whatever color-scheme the host page\n itself declares (light, if the page hasn’t opted into dark mode),\n so it inherits rather than forcing one. Override to `light dark` (or\n `light`/`dark`) to follow the user’s OS/browser preference instead,\n irrespective of the host page */\n --uktdd-color-scheme: inherit;\n /* Canvas(Text)/Highlight(Text) are UA system colors, so the color defaults\n below need no prefers-color-scheme query of their own to work in both\n schemes. The UA default is light-only regardless of OS/browser preference\n until something opts in, which is what --uktdd-color-scheme above is for */\n --uktdd-body-bg-color: Canvas;\n --uktdd-body-bg-color-hover: Highlight;\n --uktdd-body-color-hover: HighlightText;\n /* the persistent tint on the item matching props.value (the current\n selection), shown even after the active/hover highlight moves off it.\n Mixed against currentColor rather than CanvasText so that it tracks\n authored --uktdd-body-color values (CanvasText tracks color-scheme,\n while currentColor is the element’s own `color`) */\n --uktdd-body-bg-color-selected: color-mix(in oklab, currentColor 6%, transparent);\n /* shared by the body & submenu (see their box-shadow declarations below).\n A fixed black rather than a CanvasText-based mix: CanvasText is\n near-white in dark mode, so mixing it in turns this into a diffuse\n glow around the body instead of a shadow. Black stays a\n conventional cast shadow in light mode and fades to barely-there in\n dark mode — safe in both, rather than wrong in one */\n --uktdd-body-box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);\n /* a hairline edge, shared by the body & submenu, that does the job the\n shadow can’t on a dark Canvas (a shadow alone is nearly invisible\n against a dark background, unlike on a light one). Unlike the\n shadow, a crisp 1px line has no blur radius to turn into a glow, so\n a color-mix is safe here in both schemes. Mixed against currentColor\n for the same reason as --uktdd-body-bg-color-selected above (to track an\n authored --uktdd-body-color instead of just color-scheme) */\n --uktdd-body-border-color: color-mix(in oklab, currentColor 15%, transparent);\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 /* The two author fallbacks, tried in order after the primary placement\n and before the fills. The defaults are the primary’s single-axis\n flips: slot 1 the block flip, slot 2 the inline flip. Change direction\n by resetting --uktdd-body-position-area and both slots together (see\n the recipes in the README). The primary sets the direction, the\n slots are its flips */\n --uktdd-body-position-try-fallback-1: --uktdd-top-start;\n --uktdd-body-position-try-fallback-2: --uktdd-bottom-end;\n /* the last-resort fill placements appended after the fallbacks above\n (see the .uktdropdown-body rule). Overridable so a dropdown that\n prefers opening upward can flip the pair’s order to keep the fill\n on its preferred side: --uktdd-fill-top, --uktdd-fill-bottom */\n --uktdd-body-fill-fallbacks: --uktdd-fill-bottom, --uktdd-fill-top;\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 isn’t defaulted here — see the\n [data-ukt-active] path rule below; set this property directly to\n override it */\n --uktdd-body-color-path: currentColor;\n --uktdd-label-pad-right: 0.625em;\n --uktdd-submenu-position-area: inline-end span-block-end;\n /* the submenu’s only author fallback (the natural opposite placement) */\n --uktdd-submenu-position-try-fallback: --uktdd-submenu-inline-start;\n /* the last-resort fills for a submenu too tall to open beside its parent\n at natural size (see the [data-ukt-submenu] rule). Unlike the body’s\n block-side fills, these keep the submenu beside the parent — macOS\n never covers a parent menu with its submenu — filling the block axis\n and scrolling: --uktdd-submenu-fill on the same side, its flip-inline\n mirror on the other. Each anchor-centers on the block axis, so a\n parent anywhere (including near the block-end edge, where the space\n below it is too short) still gets the full viewport height beside it.\n Overridable to flip the pair for a submenu that opens inline-start */\n --uktdd-submenu-fill-fallbacks:\n --uktdd-submenu-fill, --uktdd-submenu-fill flip-inline;\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 /* tints over whatever background the trigger already has, so a fixed\n black wouldn’t register against a trigger the consumer’s already\n styled dark; color-mix against currentColor (not CanvasText, which\n tracks the ambient color-scheme rather than the trigger’s own\n background) follows whatever foreground the trigger already uses for\n contrast against its own background, so the tint stays visible\n whether or not that matches the page’s color scheme */\n --uktdd-menubar-trigger-bg-color-active: color-mix(\n in oklab,\n currentColor 12%,\n transparent\n );\n}\n\n.uktdropdown,\n.uktdropdown-trigger {\n font-family: var(--uktdd-font-family);\n}\n\n.uktdropdown {\n width: max-content;\n anchor-scope: --uktdd-anchor;\n\n &.disabled {\n pointer-events: none;\n }\n\n > * {\n cursor: default;\n }\n\n > :first-child {\n anchor-name: --uktdd-anchor;\n }\n}\n\n.uktdropdown-label {\n display: flex;\n align-items: center;\n}\n\n.uktdropdown-label-text {\n padding-right: var(--uktdd-label-pad-right);\n}\n\n.uktdropdown-body {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n position: fixed;\n position-anchor: --uktdd-anchor;\n position-area: var(--uktdd-body-position-area);\n /* the primary placement wins whenever the body fits there, then the\n fallbacks are tried in order (no position-try-order: most-height,\n which would move the body to the viewport’s taller side even when\n the primary placement fits). The trailing fill options are the last\n resort when the body fits in none of the placements: each sizes the\n body to the block-axis space on one side of the trigger so the\n content region scrolls. Engines may cap the position options list\n at an implementation-defined length with a spec floor of five, and\n that list includes the base position — so four fallbacks past it\n are guaranteed on every conformant engine. This default budget —\n two named author fallbacks plus these two fills — is exactly four,\n within that floor with no reliance on any engine exceeding it. The\n two author fallbacks are the single-axis flips of the primary (a\n block flip and an inline flip); the both-axes diagonal is dropped\n so the fills stay within the floor, so a trigger crammed into the\n corner diagonal to the primary lands in a fill rather than a fourth\n natural placement (re-tune the primary for edge-pinned triggers).\n Each fill pins one block side, unrejectable on the inline axis\n (span-all can’t overflow horizontally, and anchor-center shifts the\n body as needed to keep it inside the viewport). A fill can only be\n rejected when its side is shorter than its min-block-size floor,\n and the fills cap that floor at the worst-case larger side (see\n their @position-try rules), so at least one of the pair always\n fits */\n position-try-fallbacks:\n var(--uktdd-body-position-try-fallback-1),\n var(--uktdd-body-position-try-fallback-2), var(--uktdd-body-fill-fallbacks);\n min-block-size: min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));\n /* no 100% clamp: a placement is only accepted when the body’s natural\n size fits it, so squeezing is reserved for the --uktdd-fill options */\n max-block-size: var(--uktdd-body-max-height);\n min-inline-size: min(var(--uktdd-body-min-width), var(--uktdd-body-max-width));\n max-inline-size: var(--uktdd-body-max-width);\n inline-size: max-content;\n overflow: hidden;\n /* the body renders in the top layer via popover=\"manual\" so an ancestor’s\n transform / filter / contain can’t become its containing block, and the\n top layer handles stacking (no z-index). The UA-popover box resets that\n must beat a consumer’s global [popover] styles live in the\n div.uktdropdown-body rule below; these cosmetics stay overridable */\n color: var(--uktdd-body-color);\n /* inherited by [data-ukt-submenu] too, since it’s a DOM descendant of\n the body (inheritance follows the DOM tree, not top-layer paint\n order) */\n color-scheme: var(--uktdd-color-scheme);\n background-color: var(--uktdd-body-bg-color);\n box-shadow: var(--uktdd-body-box-shadow);\n\n &.has-items {\n user-select: none;\n }\n\n [aria-selected=\"true\"] {\n background-color: var(--uktdd-body-bg-color-selected);\n }\n\n [data-ukt-active] {\n background-color: var(--uktdd-body-bg-color-hover);\n color: var(--uktdd-body-color-hover);\n }\n\n /* an active item is on the path — not deepest — while a deeper highlight\n exists or the pointer is inside its submenu; macOS mutes the parent\n even when the pointer is over a separator or disabled submenu item */\n [data-ukt-active]:has([data-ukt-submenu] [data-ukt-active]),\n [data-ukt-active]:has([data-ukt-submenu]:hover) {\n /* --uktdd-body-bg-color-path has no :root default: it mixes the\n body’s foreground into its background, and a background has no\n use-time keyword like currentColor to carry that resolution\n down. So the fallback lives here, in the var() itself, where a\n consumer’s --uktdd-body-color/-bg-color override is in scope —\n not frozen to :root’s defaults. Matches a CanvasText/Canvas mix\n at those defaults */\n background-color: var(\n --uktdd-body-bg-color-path,\n color-mix(in oklab, var(--uktdd-body-color) 12%, var(--uktdd-body-bg-color))\n );\n color: var(--uktdd-body-color-path);\n }\n\n [data-ukt-item][aria-disabled=\"true\"] {\n opacity: 0.5;\n pointer-events: none;\n }\n\n /* the expanded parent item anchors its submenu; anchor-scope keeps each\n level’s submenu bound to its own parent item */\n [data-ukt-item] {\n anchor-scope: --uktdd-submenu-anchor;\n }\n\n /* parent items get a macOS-style disclosure chevron, right-aligned */\n :is([data-ukt-item], [data-ukt-value])[aria-haspopup=\"menu\"] {\n position: relative;\n padding-inline-end: 2em;\n\n &::after {\n content: \"\";\n position: absolute;\n inset-inline-end: 0.9em;\n inset-block-start: 50%;\n inline-size: 0.3em;\n block-size: 0.3em;\n border-block-start: 0.14em solid currentColor;\n border-inline-end: 0.14em solid currentColor;\n translate: 0 -50%;\n rotate: 45deg;\n }\n\n &:dir(rtl)::after {\n rotate: -45deg;\n }\n }\n\n /* the expanded item anchors its submenu; its disclosure is driven by the\n submenu’s popover open state (showPopover on expand), not a display\n toggle here */\n [data-ukt-item][aria-expanded=\"true\"] {\n anchor-name: --uktdd-submenu-anchor;\n }\n\n /* the submenu renders in the top layer via popover=\"manual\", like the\n body, so no ancestor — including the body’s own popover box — can\n become the containing block for the fixed submenu and clip or shift its\n anchor placement. (Safari shifts a position-area box back inside its\n containing block on both axes, which pulled the submenu in over its\n parent menu when the body was that containing block.) The popover\n attribute plus its UA `:not(:popover-open)` rule handle hide-when-\n collapsed, so there’s no display toggle; showPopover/hidePopover track\n the item’s expanded state. The UA-popover box reset (inset/border) lives\n here — the selector already outweighs a bare [popover] on specificity —\n while the cosmetics stay overridable. */\n\n /* Until popover=\"manual\" is applied — SubmenuDropdown sets it on render,\n ensureSubmenuARIA adds it when the body opens — a submenu has no UA\n :not(:popover-open) rule to hide it. Keep it hidden here so raw\n data-ukt-submenu markup inserted into an already-open body (annotated\n only on the next open) doesn’t flash visible and uncontrolled. Once the\n attribute is present this stops matching, leaving visibility to the\n popover open state (no author display to fight :popover-open). */\n [data-ukt-submenu]:not([popover]) {\n display: none;\n }\n\n [data-ukt-submenu] {\n box-sizing: border-box;\n inset: auto;\n border: 1px solid var(--uktdd-body-border-color);\n block-size: auto;\n /* an explicit color so items don’t inherit the white highlight color\n from their active parent item (the submenu is its DOM child) */\n color: var(--uktdd-body-color);\n position: fixed;\n position-anchor: --uktdd-submenu-anchor;\n position-area: var(--uktdd-submenu-position-area);\n /* like the body’s fill model, but a too-tall submenu stays beside\n its parent so that it can’t cover its parent menu.\n The list is the author fallback (the natural opposite placement),\n then --uktdd-submenu-fill-fallbacks: full-height anchor-centered\n fills, one per inline side. These fills are rejected only on the\n inline axis, so — unlike the body pair, whose two sides sum to the\n viewport — there’s no at-least-one-always-fits guarantee: a submenu\n too tall to open beside its parent and too wide for either side\n reverts to its (overflowing) primary. Normal submenus won’t hit\n that, but for extra wide menus, append the block-cover fills\n (--uktdd-fill-bottom, --uktdd-fill-top) to\n --uktdd-submenu-fill-fallbacks */\n position-try-fallbacks:\n var(--uktdd-submenu-position-try-fallback),\n var(--uktdd-submenu-fill-fallbacks);\n z-index: 2;\n margin-block: 0;\n margin-inline: var(--uktdd-submenu-gap);\n /* the fill options subtract --uktdd-body-gap to keep the body’s\n block-axis margins inside the fill region; a submenu’s block margins\n are 0 (its gap is inline), so zero it here to avoid shortening a\n filled submenu when a consumer sets a body gap. The unit is load-\n bearing: a bare 0 is a <number>, making the fills’\n calc(100% - <number>) invalid so the whole block-size declaration\n drops and every fill option is evaluated at natural size — and\n rejected */\n --uktdd-body-gap: 0px;\n padding: var(--uktdd-body-pad-top) var(--uktdd-body-pad-right)\n var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);\n inline-size: max-content;\n max-inline-size: var(--uktdd-body-max-width);\n min-block-size: min(var(--uktdd-body-min-height), var(--uktdd-body-max-height));\n max-block-size: var(--uktdd-body-max-height);\n overflow: auto;\n overscroll-behavior: contain;\n list-style: none;\n background-color: var(--uktdd-body-bg-color);\n box-shadow: var(--uktdd-body-box-shadow);\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: 1px solid var(--uktdd-body-border-color);\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/* An empty option for a fallback slot a recipe doesn’t use — e.g. a\n centered menu (bottom/top span-all) has one meaningful author fallback,\n so it sets --uktdd-body-position-try-fallback-1 and leaves slot 2 as\n --uktdd-noop, which applies no overrides and evaluates identically to the\n primary placement, meaning it’s rejected in turn and skipped without\n breaking the declaration the way an empty var() would. */\n@position-try --uktdd-noop {\n}\n\n/* Named for the aligned edge (start/end), not the direction the body\n extends toward — e.g. top-start opens above the trigger with their\n inline-start edges flush, and the body can extend past the trigger’s\n inline-end edge. Both axes use logical keywords (block-start/-end,\n span-inline-start/-end rather than top/bottom, span-left/-right):\n position-area doesn’t allow mixing a physical keyword on one axis with a\n logical one on the other, and logical keeps the alignment correct in\n RTL. block-start/block-end read as top/bottom in the near-universal\n horizontal-tb writing mode. */\n@position-try --uktdd-top-start {\n position-area: block-start span-inline-end;\n}\n\n@position-try --uktdd-bottom-start {\n position-area: block-end span-inline-end;\n}\n\n@position-try --uktdd-bottom-end {\n position-area: block-end span-inline-start;\n}\n\n@position-try --uktdd-top-end {\n position-area: block-start span-inline-start;\n}\n\n@position-try --uktdd-submenu-inline-start {\n position-area: inline-start span-block-end;\n}\n\n/* The last-resort fills, each sizing the element to one block side’s space\n so the content scrolls. block-size must be a definite length:\n position-try evaluates an auto-sized box at its natural (unclamped) size,\n so a max-block-size clamp that would make it fit still reads as\n overflowing and is never selected (same quirk that rejects max-content\n here). 100% is the attached side’s space, less the symmetric\n --uktdd-body-gap margins.\n\n min-block-size still applies (a side shorter than --uktdd-body-min-height\n is rejected and the other tried), but is capped at the worst-case larger\n side, so a min above ~half the viewport can’t reject both sides and\n strand the body at the overflowing primary.\n\n The pair must be unrejectable on the inline axis so whichever block side\n fits can be accepted. A bare block keyword spans all inline tiles\n (viewport-wide containing block, no horizontal overflow), and justify-self:\n anchor-center shifts the trigger-centered element inward to stay on-screen\n (span-all’s default alignment wouldn’t, so a corner would overflow) */\n@position-try --uktdd-fill-bottom {\n position-area: block-end;\n block-size: calc(100% - var(--uktdd-body-gap) * 2);\n min-block-size: min(\n var(--uktdd-body-min-height),\n var(--uktdd-body-max-height),\n calc((100dvb - anchor-size(block)) / 2 - var(--uktdd-body-gap) * 2)\n );\n justify-self: anchor-center;\n}\n\n@position-try --uktdd-fill-top {\n position-area: block-start;\n block-size: calc(100% - var(--uktdd-body-gap) * 2);\n min-block-size: min(\n var(--uktdd-body-min-height),\n var(--uktdd-body-max-height),\n calc((100dvb - anchor-size(block)) / 2 - var(--uktdd-body-gap) * 2)\n );\n justify-self: anchor-center;\n}\n\n/* The same-side fill (used by submenus, and available to authors composing\n their own fallback lists, including tactic-flipped: `--uktdd-fill\n flip-inline`). It sets no position-area, so it inherits the element’s\n primary placement — or a tactic-transformed mirror of it — and only\n sizes the element to that placement’s block-axis space */\n@position-try --uktdd-fill {\n block-size: calc(100% - var(--uktdd-body-gap) * 2);\n}\n\n/* The submenu full-height fill (see --uktdd-submenu-fill-fallbacks): the\n block-axis mirror of --uktdd-fill-bottom. A bare inline keyword spans all\n block tiles, so the containing block is viewport-tall and the submenu\n fills the full block axis on the inline-end side (beside the parent, never\n over it), and align-self: anchor-center shifts it on the block axis to\n stay on-screen — the rescue for a parent near the block-end edge, where\n the top-aligned --uktdd-fill has too little room below it. Rejected only\n on the inline axis (no room for the submenu’s width on that side), so the\n flip-inline pair covers both sides. Compose `--uktdd-submenu-fill\n flip-inline` for the opposite side */\n@position-try --uktdd-submenu-fill {\n position-area: inline-end;\n block-size: calc(100% - var(--uktdd-body-gap) * 2);\n align-self: anchor-center;\n}\n\n/* The opt-in cover fill (in no default list): where the block-side fills\n loosen the inline axis and keep the body beside the trigger, this keeps\n the strict start-aligned inline edge (span-inline-end, like the -start\n placements; compose `--uktdd-fill-cover flip-inline` for end alignment)\n and loosens the block axis instead — span-all sizes the body to the\n viewport’s full block axis, covering the trigger, and anchor-center\n keeps a shorter body (an authored max-block-size) centered over the\n trigger and shifted on-screen. Overflowing the trigger-to-viewport-edge\n inline region rejects it, so it applies only when the body fits\n horizontally as aligned: list it before the guaranteed pair\n (--uktdd-fill-cover, --uktdd-fill-bottom, --uktdd-fill-top) with at\n most two author fallbacks, for six options total — the ceiling every\n current engine clears (Chromium evaluates six; Safari and Firefox go\n further). One author fallback keeps it within the spec floor of five\n (see the .uktdropdown-body rule). Avoid it on searchable dropdowns: the\n body overlays the trigger’s input */\n@position-try --uktdd-fill-cover {\n position-area: span-all span-inline-end;\n block-size: calc(100% - var(--uktdd-body-gap) * 2);\n align-self: anchor-center;\n}\n","import { getBestMatch } from '@acusti/matchmaking';\nimport { Children, isValidElement, type ReactNode, type SyntheticEvent } from 'react';\n\nimport { type Item } from './Dropdown.js';\n\nexport const ITEM_SELECTOR = '[data-ukt-item], [data-ukt-value]';\nexport const SUBMENU_SELECTOR = '[data-ukt-submenu]';\n\nconst DISABLED_ITEM_SELECTOR = '[aria-disabled=\"true\"]';\n\nexport type OnToggleSubmenu = (item: HTMLElement, isExpanded: boolean) => void;\n\ntype MaybeHTMLElement = HTMLElement | null;\n\nconst getBodyElement = (dropdownElement: MaybeHTMLElement) =>\n (dropdownElement?.querySelector('.uktdropdown-body') ?? null) as MaybeHTMLElement;\n\n// The level root that owns an item: the closest [data-ukt-submenu] ancestor,\n// or null for items at the top level of the dropdown body\nexport const getLevelRoot = (element: HTMLElement) =>\n element.closest(SUBMENU_SELECTOR) as MaybeHTMLElement;\n\n// An item’s own submenu (a parent item), excluding submenus of descendant items\nexport const getSubmenuOfItem = (item: HTMLElement): MaybeHTMLElement => {\n const submenu = item.querySelector(SUBMENU_SELECTOR) as MaybeHTMLElement;\n if (!submenu) return null;\n const owner = submenu.parentElement?.closest(ITEM_SELECTOR);\n return owner === item ? submenu : null;\n};\n\n// The parent item that owns a submenu level\nexport const getParentItem = (levelRoot: HTMLElement) =>\n (levelRoot.parentElement?.closest(ITEM_SELECTOR) ?? null) as MaybeHTMLElement;\n\n// A parent item’s label is its text content excluding the submenu subtree\nexport const getItemLabel = (item: HTMLElement): string => {\n if (!getSubmenuOfItem(item)) return item.innerText ?? '';\n const clone = item.cloneNode(true) as HTMLElement;\n for (const submenu of Array.from(clone.querySelectorAll(SUBMENU_SELECTOR))) {\n submenu.remove();\n }\n return (clone.textContent ?? '').trim();\n};\n\n// Concatenate the text (string/number leaves) of a React node, approximating\n// the rendered innerText the dropdown uses as an item’s label. Submenu\n// subtrees are excluded, matching getItemLabel (and innerText, which omits\n// the collapsed — hidden — submenu), so a parent item’s derived label agrees\n// with its select-time label.\nconst getNodeText = (node: ReactNode): string => {\n let text = '';\n Children.forEach(node, (child) => {\n if (typeof child === 'string' || typeof child === 'number') {\n text += child;\n } else if (isValidElement(child)) {\n const childProps = child.props as {\n children?: ReactNode;\n 'data-ukt-submenu'?: unknown;\n };\n if (childProps['data-ukt-submenu'] !== undefined) return;\n text += getNodeText(childProps.children);\n }\n });\n return text;\n};\n\n// Find the item in `children` whose data-ukt-value matches `value` and return\n// its text as the label, so a bare identifier value shows the matching item’s\n// label without a separate options/label lookup. Returns undefined if no item\n// matches (the caller then falls back to the identifier itself). A\n// { label, value } value overrides this when the derived text isn’t right.\nexport const getLabelFromChildren = (\n children: ReactNode,\n value: string,\n): string | undefined => {\n let label: string | undefined;\n const visit = (node: ReactNode) => {\n if (label != null) return;\n Children.forEach(node, (child) => {\n if (label != null || !isValidElement(child)) return;\n const childProps = child.props as {\n children?: ReactNode;\n 'data-ukt-value'?: unknown;\n };\n const uktValue = childProps['data-ukt-value'];\n // Compare as strings: the DOM stringifies dataset values, so\n // data-ukt-value={400} matches value=\"400\" when selected and\n // must also match here.\n if (uktValue != null && String(uktValue) === value) {\n label = getNodeText(childProps.children).replace(/\\s+/g, ' ').trim();\n return;\n }\n visit(childProps.children);\n });\n };\n visit(children);\n return label;\n};\n\n// Ancestor parent items from the root level down to the element’s immediate parent\nexport const getItemPath = (element: MaybeHTMLElement): Item['path'] => {\n const path: Item['path'] = [];\n if (!element) return path;\n let levelRoot = getLevelRoot(element);\n while (levelRoot) {\n const parentItem = getParentItem(levelRoot);\n if (!parentItem) break;\n const label = getItemLabel(parentItem);\n path.unshift({ label, value: parentItem.dataset.uktValue ?? label });\n levelRoot = getLevelRoot(parentItem);\n }\n return path;\n};\n\nexport const getItemElements = (\n dropdownElement: MaybeHTMLElement,\n levelRoot?: MaybeHTMLElement,\n): Array<HTMLElement> | null => {\n const bodyElement = getBodyElement(dropdownElement);\n if (!bodyElement) return null;\n\n const root = levelRoot ?? bodyElement;\n const candidates = Array.from(\n root.querySelectorAll(ITEM_SELECTOR),\n ) as Array<HTMLElement>;\n\n if (candidates.length) {\n return candidates.filter((item) => {\n if (item.matches(DISABLED_ITEM_SELECTOR)) return false;\n return getLevelRoot(item) === (levelRoot ?? null);\n });\n }\n\n // If no items found via [data-ukt-item] or [data-ukt-value] selector,\n // use first instance of multiple children found — flat bodies and flat\n // submenu levels alike\n let items: HTMLCollection = root.children;\n while (items.length === 1) {\n if (items[0].children == null) break;\n items = items[0].children;\n }\n // If unable to find an element with more than one child, treat direct child as items\n if (items.length === 1) {\n items = root.children;\n }\n return (Array.from(items) as Array<HTMLElement>).filter(\n (item) => !item.matches(DISABLED_ITEM_SELECTOR),\n );\n};\n\n// The item an event target belongs to within its own level: the closest\n// marked item, or — when the target sits in a level with no marked items\n// (a heuristically-detected level) — the target itself if it’s one of that\n// level’s detected items. Misses (body padding, separators) and disabled\n// items resolve to null.\nexport const getItemForTarget = (\n dropdownElement: HTMLElement,\n target: HTMLElement,\n): MaybeHTMLElement => {\n let item = target.closest(ITEM_SELECTOR) as MaybeHTMLElement;\n // If nothing matched, or the target sits in a deeper level than the\n // matched item (an unmarked, heuristically-detected submenu level),\n // resolve the item within the target’s own level instead\n const targetLevelRoot = getLevelRoot(target);\n if (!item || (targetLevelRoot && item.contains(targetLevelRoot))) {\n const itemElements = getItemElements(dropdownElement, targetLevelRoot);\n item = itemElements?.find((itemElement) => itemElement === target) ?? item;\n }\n if (!item || !dropdownElement.contains(item)) return null;\n if (item.matches(DISABLED_ITEM_SELECTOR)) return null;\n return item;\n};\n\n// All active items, in document order (ancestors before descendants)\nexport const getActiveItemElements = (dropdownElement: MaybeHTMLElement) => {\n if (!dropdownElement) return null;\n const actives = dropdownElement.querySelectorAll('[data-ukt-active]');\n return actives.length ? (Array.from(actives) as Array<HTMLElement>) : null;\n};\n\n// The deepest active item — the one keyboard input operates on\nexport const getActiveItemElement = (dropdownElement: MaybeHTMLElement) => {\n const actives = getActiveItemElements(dropdownElement);\n return actives ? actives[actives.length - 1] : null;\n};\n\n// The deepest expanded parent item — the one whose submenu is the innermost\n// open one — in document order\nexport const getDeepestExpandedItem = (\n dropdownElement: MaybeHTMLElement,\n): MaybeHTMLElement => {\n if (!dropdownElement) return null;\n const expanded = (\n Array.from(\n dropdownElement.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((element) => element.matches(ITEM_SELECTOR));\n return expanded.length ? expanded[expanded.length - 1] : null;\n};\n\nexport const isItemExpanded = (item: HTMLElement) =>\n item.getAttribute('aria-expanded') === 'true';\n\nlet submenuIdCounter = 0;\n\nconst ensureSubmenuARIA = (item: HTMLElement, submenu: HTMLElement) => {\n if (!submenu.hasAttribute('role')) submenu.setAttribute('role', 'menu');\n if (!submenu.id) submenu.id = `uktdd-submenu-${++submenuIdCounter}`;\n // Normalize the submenu to a manual popover for consumers who author raw\n // data-ukt-submenu markup (SubmenuDropdown already sets it); a bare or auto\n // popover would light-dismiss and desync from the engine’s show/hidePopover.\n if (submenu.getAttribute('popover') !== 'manual') {\n submenu.setAttribute('popover', 'manual');\n }\n if (!item.hasAttribute('aria-haspopup')) item.setAttribute('aria-haspopup', 'menu');\n if (!item.hasAttribute('aria-expanded')) item.setAttribute('aria-expanded', 'false');\n if (!item.hasAttribute('aria-controls')) {\n item.setAttribute('aria-controls', submenu.id);\n }\n};\n\n// Fill in submenu/parent-item ARIA (only what the consumer hasn’t set)\nexport const annotateParentItems = (bodyElement: MaybeHTMLElement) => {\n if (!bodyElement) return;\n for (const submenu of Array.from(bodyElement.querySelectorAll(SUBMENU_SELECTOR))) {\n const item = getParentItem(submenu as HTMLElement);\n if (item) ensureSubmenuARIA(item, submenu as HTMLElement);\n }\n};\n\n// Fill in the item roles the consumer hasn’t set: options in a searchable\n// (listbox) dropdown, menuitems in a menu — and always menuitems inside a\n// submenu, which is itself a menu (annotateParentItems gives it role=\"menu\").\n// The <ul>/<ol> wrappers around the items get role=\"presentation\" so their\n// implicit list role doesn’t sit between the listbox/menu and its items; a\n// submenu already carries role=\"menu\", so its own role is left intact.\nexport const annotateItemRoles = (\n bodyElement: MaybeHTMLElement,\n popupRole: 'listbox' | 'menu',\n) => {\n if (!bodyElement) return;\n for (const list of Array.from(bodyElement.querySelectorAll('ul, ol'))) {\n if (!list.hasAttribute('role') && list.querySelector(ITEM_SELECTOR)) {\n list.setAttribute('role', 'presentation');\n }\n }\n for (const item of Array.from(\n bodyElement.querySelectorAll(ITEM_SELECTOR),\n ) as Array<HTMLElement>) {\n // Leave a consumer-set role, and a natively interactive item’s own role\n // (a button/link/input item keeps its element semantics), alone.\n if (\n item.hasAttribute('role') ||\n item.matches('a[href], button, input, select, textarea')\n ) {\n continue;\n }\n const isMenuItem = popupRole === 'menu' || getLevelRoot(item) != null;\n // A top-level parent item in a listbox would pair role=\"option\" with\n // the aria-haspopup/aria-expanded that annotateParentItems gives it —\n // invalid ARIA (an option can’t disclose a popup), and no valid role\n // exists for a submenu parent inside a listbox, so leave its role to\n // the consumer. (In a menu, menuitem is correct for parents.)\n if (!isMenuItem && getSubmenuOfItem(item)) continue;\n item.setAttribute('role', isMenuItem ? 'menuitem' : 'option');\n }\n};\n\nexport const expandItem = (item: HTMLElement, onToggleSubmenu?: OnToggleSubmenu) => {\n const submenu = getSubmenuOfItem(item);\n if (!submenu) return;\n ensureSubmenuARIA(item, submenu);\n if (isItemExpanded(item)) return;\n item.setAttribute('aria-expanded', 'true');\n onToggleSubmenu?.(item, true);\n};\n\nexport const collapseItem = (item: HTMLElement, onToggleSubmenu?: OnToggleSubmenu) => {\n if (!isItemExpanded(item)) return;\n const submenu = getSubmenuOfItem(item);\n if (submenu) {\n // Collapse any expanded descendants first so their state can’t leak\n // into the next disclosure and their onClose callbacks fire\n // (recursion makes the collapse order deepest-first)\n const expandedDescendants = (\n Array.from(\n submenu.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((descendant) => descendant.matches(ITEM_SELECTOR));\n for (const descendant of expandedDescendants) {\n collapseItem(descendant, onToggleSubmenu);\n }\n for (const active of Array.from(submenu.querySelectorAll('[data-ukt-active]'))) {\n delete (active as HTMLElement).dataset.uktActive;\n }\n }\n item.setAttribute('aria-expanded', 'false');\n onToggleSubmenu?.(item, false);\n};\n\n// Collapse every expanded parent item that isn’t an ancestor of element\n// (element == null collapses all), deepest-first\nexport const collapseItemsOutsidePath = (\n dropdownElement: MaybeHTMLElement,\n element: MaybeHTMLElement,\n onToggleSubmenu?: OnToggleSubmenu,\n) => {\n const bodyElement = getBodyElement(dropdownElement);\n if (!bodyElement) return;\n const expandedItems = (\n Array.from(\n bodyElement.querySelectorAll('[aria-expanded=\"true\"]'),\n ) as Array<HTMLElement>\n ).filter((item) => item.matches(ITEM_SELECTOR));\n for (const item of expandedItems.reverse()) {\n if (element && item.contains(element)) continue;\n collapseItem(item, onToggleSubmenu);\n }\n};\n\nconst clearItemElementsState = (itemElements: Array<HTMLElement>) => {\n itemElements.forEach((itemElement) => {\n if (itemElement.hasAttribute('data-ukt-active')) {\n delete itemElement.dataset.uktActive;\n }\n // Also clear active state in any deeper levels within this item\n for (const active of Array.from(\n itemElement.querySelectorAll('[data-ukt-active]'),\n )) {\n delete (active as HTMLElement).dataset.uktActive;\n }\n });\n};\n\n// Make the active set exactly the chain of element + its ancestor parent items\nconst setActiveChain = (dropdownElement: HTMLElement, element: HTMLElement) => {\n const chain = new Set<HTMLElement>([element]);\n let levelRoot = getLevelRoot(element);\n while (levelRoot) {\n const parentItem = getParentItem(levelRoot);\n if (!parentItem) break;\n chain.add(parentItem);\n levelRoot = getLevelRoot(parentItem);\n }\n for (const active of getActiveItemElements(dropdownElement) ?? []) {\n if (!chain.has(active)) delete active.dataset.uktActive;\n }\n for (const item of chain) {\n item.setAttribute('data-ukt-active', '');\n }\n};\n\ntype BaseSetActiveItemPayload = {\n dropdownElement: HTMLElement;\n element?: null;\n // Optional so an item can be activated programmatically (e.g. revealing the\n // current value on open); it’s only used to build the onActiveItem payload,\n // which is skipped when there’s no event to report.\n event?: Event | SyntheticEvent<HTMLElement>;\n index?: null;\n indexAddend?: null;\n isExactMatch?: null;\n onActiveItem?: (payload: Item) => void;\n text?: null;\n};\n\nexport const setActiveItem = ({\n dropdownElement,\n element,\n event,\n index,\n indexAddend,\n isExactMatch,\n onActiveItem,\n text,\n}:\n | ({\n element: HTMLElement;\n } & Omit<BaseSetActiveItemPayload, 'element'>)\n | ({\n index: number;\n } & Omit<BaseSetActiveItemPayload, 'index'>)\n | ({\n indexAddend: number;\n } & Omit<BaseSetActiveItemPayload, 'indexAddend'>)\n | ({\n isExactMatch?: boolean;\n text: string;\n } & Omit<BaseSetActiveItemPayload, 'isExactMatch' | 'text'>)): MaybeHTMLElement => {\n const currentDeepest = getActiveItemElement(dropdownElement);\n // Keys and text operate on the current level (the level of the deepest\n // active item); activating an element directly targets its own level\n const levelRoot = element\n ? getLevelRoot(element)\n : currentDeepest\n ? getLevelRoot(currentDeepest)\n : null;\n\n const itemElements = getItemElements(dropdownElement, levelRoot);\n if (!itemElements || itemElements.length === 0) return currentDeepest;\n\n const lastIndex = itemElements.length - 1;\n const currentActiveIndex = itemElements.findIndex(\n (itemElement) => itemElement === currentDeepest,\n );\n\n let nextActiveIndex = currentActiveIndex;\n if (typeof index === 'number') {\n // Negative index means count back from the end\n nextActiveIndex = index < 0 ? itemElements.length + index : index;\n }\n\n if (element) {\n nextActiveIndex = itemElements.findIndex(\n (itemElement) => itemElement === element,\n );\n if (nextActiveIndex === -1) return currentDeepest;\n } else if (typeof indexAddend === 'number') {\n // If there’s no currentActiveIndex and we are handling -1, start at lastIndex\n if (currentActiveIndex === -1 && indexAddend === -1) {\n nextActiveIndex = lastIndex;\n } else {\n nextActiveIndex += indexAddend;\n }\n // Keep it within the bounds of the items list\n nextActiveIndex = Math.max(0, Math.min(nextActiveIndex, lastIndex));\n } else if (typeof text === 'string') {\n // If text is empty, clear existing active items and early return\n if (!text) {\n clearItemElementsState(itemElements);\n return null;\n }\n\n const itemTexts = itemElements.map(getItemLabel);\n if (isExactMatch) {\n const textToCompare = text.toLowerCase();\n nextActiveIndex = itemTexts.findIndex((itemText) =>\n itemText.toLowerCase().startsWith(textToCompare),\n );\n // If isExactMatch is required and no exact match was found, clear active items\n if (nextActiveIndex === -1) {\n clearItemElementsState(itemElements);\n }\n } else {\n const bestMatch = getBestMatch({ items: itemTexts, text });\n nextActiveIndex = itemTexts.findIndex((itemText) => itemText === bestMatch);\n }\n }\n\n const nextActiveItem = itemElements[nextActiveIndex] as MaybeHTMLElement;\n if (nextActiveItem == null || nextActiveItem === currentDeepest) {\n return currentDeepest;\n }\n\n setActiveChain(dropdownElement, nextActiveItem);\n // A programmatic activation (no event) still moves the highlight and scrolls\n // the item into view, but has no event to report to onActiveItem.\n if (event) {\n const label = getItemLabel(nextActiveItem);\n onActiveItem?.({\n element: nextActiveItem,\n event,\n label,\n path: getItemPath(nextActiveItem),\n value: nextActiveItem.dataset.uktValue ?? label,\n });\n }\n // Find closest scrollable parent and ensure that next active item is visible\n let { parentElement } = nextActiveItem;\n let scrollableParent = null;\n while (!scrollableParent && parentElement && parentElement !== dropdownElement) {\n const isScrollable = parentElement.scrollHeight > parentElement.clientHeight + 15;\n if (isScrollable) {\n scrollableParent = parentElement;\n } else {\n parentElement = parentElement.parentElement;\n }\n }\n\n if (scrollableParent) {\n const parentRect = scrollableParent.getBoundingClientRect();\n const itemRect = nextActiveItem.getBoundingClientRect();\n const isAboveTop = itemRect.top < parentRect.top;\n const isBelowBottom = itemRect.bottom > parentRect.bottom;\n if (isAboveTop || isBelowBottom) {\n let { scrollTop } = scrollableParent;\n // Item isn’t fully visible; adjust scrollTop to put item within closest edge\n if (isAboveTop) {\n scrollTop -= parentRect.top - itemRect.top;\n } else {\n scrollTop += itemRect.bottom - parentRect.bottom;\n }\n scrollableParent.scrollTop = scrollTop;\n }\n }\n\n return nextActiveItem;\n};\n\nexport type Point = { x: number; y: number };\n\n// Whether a point is inside (or on an edge of) triangle a-b-c, from the sign\n// of the cross product for each edge: all the same sign ⇒ inside\nexport const isPointInTriangle = (p: Point, a: Point, b: Point, c: Point): boolean => {\n const cross = (u: Point, v: Point, w: Point) =>\n (u.x - w.x) * (v.y - w.y) - (v.x - w.x) * (u.y - w.y);\n const d1 = cross(p, a, b);\n const d2 = cross(p, b, c);\n const d3 = cross(p, c, a);\n const hasNegative = d1 < 0 || d2 < 0 || d3 < 0;\n const hasPositive = d1 > 0 || d2 > 0 || d3 > 0;\n return !(hasNegative && hasPositive);\n};\n","import clsx from 'clsx';\nimport {\n type CSSProperties,\n type FocusEvent as ReactFocusEvent,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n useMemo,\n useRef,\n} from 'react';\n\nimport {\n MenubarContext,\n type MenubarContextValue,\n type MenubarMember,\n} from './context.js';\n\nexport type MenubarProps = {\n children: ReactNode;\n className?: string;\n style?: CSSProperties;\n};\n\nconst compareDocumentOrder = (a: MenubarMember, b: MenubarMember) => {\n if (a.element === b.element) return 0;\n const position = a.element.compareDocumentPosition(b.element);\n if ((position & Node.DOCUMENT_POSITION_FOLLOWING) !== 0) return -1;\n if ((position & Node.DOCUMENT_POSITION_PRECEDING) !== 0) return 1;\n return 0;\n};\n\n// Matches interactive controls that live in the menubar without being dropdown\n// triggers (e.g. a plain button). Hovering one clears the open menu without\n// disengaging the menubar.\nconst NON_MENU_CONTROL_SELECTOR = 'a[href], button, input, select, textarea, [tabindex]';\n\n// Combines sibling Dropdowns into a single menu, like the system menu in the\n// top toolbar of macOS: one menu open at a time, ←/→ move between menus, and\n// once any menu is open, hovering or focusing another trigger switches to it.\nexport default function Menubar({ children, className, style }: MenubarProps) {\n const membersRef = useRef<Set<MenubarMember>>(new Set());\n // The member that engaged the bar (menu-mode). It keeps pointing at that\n // member even if that member’s menu was closed by hovering a non-menu\n // control, which allows the bar to stay engaged even with nothing open.\n const engagedMemberRef = useRef<HTMLElement | null>(null);\n\n const getOrderedMembersRef = useRef(() =>\n Array.from(membersRef.current).sort(compareDocumentOrder),\n );\n const getOrderedMembers = getOrderedMembersRef.current;\n\n const contextValue: MenubarContextValue = useMemo(\n () => ({\n moveOpen(fromElement: HTMLElement, direction: -1 | 1) {\n const members = getOrderedMembersRef.current();\n if (members.length < 2) return;\n const index = members.findIndex(\n (member) => member.element === fromElement,\n );\n if (index === -1) return;\n const nextIndex = (index + direction + members.length) % members.length;\n members[index].close();\n members[nextIndex].open();\n members[nextIndex].focusTrigger();\n },\n notifyClosed(element: HTMLElement) {\n // Only a dismissal of the member that engaged the bar ends\n // menu-mode. Outside-click handling closes every mounted\n // dropdown, so ignore the closes reported for the rest.\n if (engagedMemberRef.current === element) {\n engagedMemberRef.current = null;\n }\n },\n notifyOpened(element: HTMLElement) {\n engagedMemberRef.current = element;\n for (const member of membersRef.current) {\n if (member.element !== element && member.isOpen()) {\n member.close();\n }\n }\n },\n registerMember(member: MenubarMember) {\n membersRef.current.add(member);\n return () => {\n membersRef.current.delete(member);\n };\n },\n }),\n [],\n );\n\n // Rove focus between triggers with ←/→ while no menu is open (the open\n // dropdown’s own key handling slides the open menu between triggers)\n const handleKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n const { key } = event;\n if (key !== 'ArrowLeft' && key !== 'ArrowRight') return;\n const members = getOrderedMembers();\n if (members.length < 2) return;\n if (members.some((member) => member.isOpen())) return;\n const eventTarget = event.target as HTMLElement;\n const index = members.findIndex((member) => member.element.contains(eventTarget));\n if (index === -1) return;\n event.preventDefault();\n event.stopPropagation();\n const direction = key === 'ArrowRight' ? 1 : -1;\n members[(index + direction + members.length) % members.length].focusTrigger();\n };\n\n // Once the bar is engaged, moving hover or focus onto another member’s\n // trigger switches to it (opening notifies the menubar, which closes the\n // other open member), while moving onto a non-menu control clears the open\n // menu but keeps the bar engaged.\n const switchToMemberAt = (eventTarget: HTMLElement) => {\n if (engagedMemberRef.current == null) return;\n const members = getOrderedMembers();\n // If the member that engaged the bar is gone (e.g. it unmounted while\n // engaged) the bar is no longer engaged, so hover can’t reopen menus\n if (!members.some((m) => m.element === engagedMemberRef.current)) {\n engagedMemberRef.current = null;\n return;\n }\n const member = members.find((m) => m.element.contains(eventTarget));\n if (member) {\n if (!member.isOpen()) member.open();\n return;\n }\n // Not over a menu trigger: only a real non-menu control (not the bar’s\n // padding or the gaps between triggers) clears the open menu — this is\n // a menubar-driven close, so the members stay engaged.\n if (!eventTarget.closest(NON_MENU_CONTROL_SELECTOR)) return;\n for (const openMember of members) {\n if (openMember.isOpen()) openMember.close();\n }\n };\n\n const handleFocus = (event: ReactFocusEvent<HTMLDivElement>) => {\n switchToMemberAt(event.target as HTMLElement);\n };\n\n const handleMouseOver = (event: ReactMouseEvent<HTMLDivElement>) => {\n switchToMemberAt(event.target as HTMLElement);\n };\n\n return (\n <div\n className={clsx('uktmenubar', className)}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n onMouseOver={handleMouseOver}\n role=\"menubar\"\n style={style}\n >\n <MenubarContext.Provider value={contextValue}>\n {children}\n </MenubarContext.Provider>\n </div>\n );\n}\n","/* eslint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/mouse-events-have-key-events, jsx-a11y/no-static-element-interactions */\nimport useKeyboardEvents, {\n isEventTargetUsingKeyEvent,\n} from '@acusti/use-keyboard-events';\nimport clsx from 'clsx';\nimport {\n Children,\n cloneElement,\n type CSSProperties,\n Fragment,\n isValidElement,\n type MouseEvent as ReactMouseEvent,\n type ReactElement,\n type ReactNode,\n type SyntheticEvent,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport {\n DropdownContext,\n type DropdownContextValue,\n MenubarContext,\n type SubmenuRegistration,\n} from './context.js';\nimport styles from './Dropdown.css?inline';\nimport {\n annotateItemRoles,\n annotateParentItems,\n collapseItem,\n collapseItemsOutsidePath,\n expandItem,\n getActiveItemElement,\n getDeepestExpandedItem,\n getItemElements,\n getItemForTarget,\n getItemPath,\n getLabelFromChildren,\n getLevelRoot,\n getParentItem,\n getSubmenuOfItem,\n isItemExpanded,\n isPointInTriangle,\n type Point,\n setActiveItem,\n} from './helpers.js';\n\nexport type Item = {\n element: MaybeHTMLElement;\n event: Event | SyntheticEvent<HTMLElement>;\n label: string;\n /**\n * Ancestor parent items from the root level down to the item’s\n * immediate parent. Empty for top-level items.\n */\n path: Array<ItemValue>;\n value: string;\n};\n\n/**\n * A { label, value } pair naming an item: `value` is the stored value (the\n * item’s data-ukt-value) and `label` is its displayed text. Accepted by the\n * value prop when an item’s value and label differ; also the shape of an\n * Item’s path entries.\n */\nexport type ItemValue = { label: string; value: string };\n\nexport type Props = {\n /**\n * Boolean indicating if the user can submit a value not already in the\n * dropdown.\n */\n allowCreate?: boolean;\n /**\n * Boolean indicating if submitting with no item active emits an empty\n * value (i.e. clears the value). Only has an effect when the dropdown has a\n * text input to source that value from — a searchable dropdown’s search\n * input, or a text input inside a custom trigger. With no such input there\n * is no value to submit, so submitting with nothing selected is a no-op\n * regardless; clear such a dropdown with an explicit empty-valued item\n * instead. Defaults to true.\n */\n allowEmpty?: boolean;\n /**\n * Can take a single React element or exactly two renderable children.\n */\n children: ChildrenTuple | ReactElement;\n className?: string;\n disabled?: boolean;\n hasItems?: boolean;\n isOpenOnMount?: boolean;\n isSearchable?: boolean;\n keepOpenOnSubmit?: boolean;\n /**\n * Label content for the trigger button (when using single child syntax).\n * For a nested (submenu) Dropdown, this is the parent item’s content.\n */\n label?: ReactNode;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s name.\n */\n name?: string;\n onActiveItem?: (payload: Item) => void;\n onClick?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onClose?: () => unknown;\n onMouseDown?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onMouseUp?: (event: ReactMouseEvent<HTMLElement>) => unknown;\n onOpen?: () => unknown;\n onSubmitItem?: (payload: Item) => void;\n /**\n * Opens the dropdown when the pointer hovers the trigger, and closes it a\n * short moment after the pointer leaves the trigger and body entirely (the\n * close is delayed so crossing the gap between them, or pausing over\n * either, doesn’t flicker-close it). Click and keyboard opening keep\n * working as usual alongside it.\n */\n openOnHover?: boolean;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s placeholder.\n */\n placeholder?: string;\n /**\n * Applied to the dropdown root element. Also accepts the component’s CSS\n * custom properties (e.g. `--uktdd-body-min-width`) for per-instance\n * placement and sizing, which plain `CSSProperties` rejects.\n */\n style?: CSSProperties & Record<`--${string}`, string | number | undefined>;\n /**\n * Only usable in conjunction with {isSearchable: true}.\n * Used as search input’s tabIndex.\n */\n tabIndex?: number;\n /**\n * The dropdown’s controlled value. Pass a bare identifier when an item’s\n * stored value and its displayed label are the same, or a { label, value }\n * pair when they differ (e.g. a human-readable label shown for a stored\n * id) — the same { label, value } shape onSubmitItem reports back. The\n * value determines whether the value has changed, to avoid triggering\n * onSubmitItem when the already-selected item is re-submitted; the label is\n * used as the search input’s value when props.isSearchable === true. A bare\n * identifier is resolved to its label from the matching child’s\n * data-ukt-value in the body — so children whose value and label differ\n * need no explicit label; a { label, value } pair states it.\n */\n value?: ItemValue | string;\n};\n\ntype ChildrenTuple = [ReactNode, ReactNode] | readonly [ReactNode, ReactNode];\n\ntype MaybeHTMLElement = HTMLElement | null;\n\ntype MousePosition = { clientX: number; clientY: number };\n\ntype TimeoutID = ReturnType<typeof setTimeout>;\n\nconst CHILDREN_ERROR =\n '@acusti/dropdown requires either 1 child (the dropdown body) or 2 children: the dropdown trigger and the dropdown body.';\nconst CLICKABLE_SELECTOR = 'button, a[href], input[type=\"button\"], input[type=\"submit\"]';\nconst FOCUSABLE_SELECTOR = 'a[href], button, input, select, textarea, [tabindex]';\nconst TEXT_INPUT_SELECTOR =\n 'input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea';\n\n// Matches macOS: quick, natural arrowing past parent items never flashes\n// their submenus, but a brief pause discloses. Frame-stepping macOS menus\n// puts its delay around 200–250ms; anything much shorter flashes\nconst SUBMENU_DISCLOSURE_DELAY = 200;\n\n// How long the pointer can dwell inside the safe area (heading toward an open\n// submenu) before we give up and switch to whatever it’s actually over. Reset\n// on every move, so it only fires on a pause — motion keeps the submenu open\nconst SAFE_AREA_TIMEOUT = 300;\n\n// props.openOnHover opens immediately on hover, but closing waits a beat so\n// that crossing the trigger/body gap (or a placement fallback moving the body\n// somewhere the pointer briefly leaves) doesn’t flicker-close it\nconst HOVER_CLOSE_DELAY = 150;\n\nexport default function Dropdown(props: Props) {\n const parentDropdown = useContext(DropdownContext);\n // A Dropdown nested inside a menu dropdown’s body renders as a submenu\n // (a parent item delegating to the root engine). A hasItems={false}\n // dropdown provides no submenu context, so a Dropdown nested inside one —\n // or a hasItems={false} Dropdown anywhere — renders independently instead.\n if (parentDropdown && props.hasItems !== false) {\n return <SubmenuDropdown {...props} parentDropdown={parentDropdown} />;\n }\n return <RootDropdown {...props} />;\n}\n\nfunction RootDropdown({\n allowCreate,\n allowEmpty = true,\n children,\n className,\n disabled,\n hasItems = true,\n isOpenOnMount,\n isSearchable,\n keepOpenOnSubmit = !hasItems,\n label,\n name,\n onActiveItem,\n onClick,\n onClose,\n onMouseDown,\n onMouseUp,\n onOpen,\n onSubmitItem,\n openOnHover,\n placeholder,\n style: styleFromProps,\n tabIndex,\n value,\n}: Props) {\n const childrenCount = Children.count(children);\n if (childrenCount !== 1 && childrenCount !== 2) {\n if (childrenCount === 0) {\n throw new Error(CHILDREN_ERROR + ' Received no children.');\n }\n console.error(`${CHILDREN_ERROR} Received ${childrenCount} children.`);\n }\n\n let trigger: React.ReactNode;\n if (childrenCount > 1) {\n trigger = (children as ChildrenTuple)[0];\n }\n // The body is the node rendered inside .uktdropdown-body: the second of\n // two children, or the only child.\n const body = childrenCount > 1 ? (children as ChildrenTuple)[1] : children;\n\n // The value prop is either a bare identifier (its stored value and its\n // displayed label are the same) or a { label, value } pair when they\n // differ. valueIdentity drives change detection / no-op matching against an\n // item’s data-ukt-value; valueLabel is what a searchable dropdown shows in\n // its input. For a bare identifier, the label is resolved from the matching\n // child (data-ukt-value in the body — derivation walks the same node the\n // body renders, so a data-ukt-value in a custom trigger can’t match), so\n // children with distinct values and labels need no separate label; a\n // { label, value } pair states it explicitly. A bare value that matches no\n // child has no known label — a value is an identity, not display text — so\n // it falls back to the placeholder (an empty input), not to the raw\n // identifier. The exception is allowCreate, where an unmatched value is an\n // entry the user created (a typed value not among the items) and must still\n // show as typed. Only a searchable dropdown displays the label, so skip the\n // per-render walk entirely for anything else.\n const valueIdentity = typeof value === 'string' ? value : value?.value;\n const valueLabel = !isSearchable\n ? undefined\n : typeof value !== 'string'\n ? value?.label\n : (getLabelFromChildren(body, value) ?? (allowCreate ? value : undefined));\n\n const [isOpen, setIsOpen] = useState<boolean>(isOpenOnMount ?? false);\n const [isOpening, setIsOpening] = useState<boolean>(!isOpenOnMount);\n const [dropdownElement, setDropdownElement] = useState<MaybeHTMLElement>(null);\n const bodyId = useId();\n const popupRole = isSearchable ? 'listbox' : hasItems ? 'menu' : 'dialog';\n const menubar = useContext(MenubarContext);\n const inputElementRef = useRef<HTMLInputElement | null>(null);\n // Whether the consumer authors aria-selected in the body themselves, in\n // which case this component’s aria-selected fill-ins stand down (set per\n // open in handleBodyRef)\n const consumerOwnsARIASelectedRef = useRef(false);\n // Body elements already annotated this open (see handleBodyRef)\n const annotatedBodiesRef = useRef<WeakSet<HTMLElement>>(new WeakSet());\n const closingTimerRef = useRef<null | TimeoutID>(null);\n const isOpeningTimerRef = useRef<null | TimeoutID>(null);\n const currentInputMethodRef = useRef<'keyboard' | 'mouse'>('mouse');\n const clearEnteredCharactersTimerRef = useRef<null | TimeoutID>(null);\n const enteredCharactersRef = useRef<string>('');\n const mouseDownPositionRef = useRef<MousePosition | null>(null);\n const disclosureTimerRef = useRef<null | TimeoutID>(null);\n const pendingDisclosureItemRef = useRef<MaybeHTMLElement>(null);\n const submenuRegistrationsRef = useRef<Set<SubmenuRegistration>>(new Set());\n const pointerRef = useRef<Point | null>(null);\n const lastMouseEventRef = useRef<MouseEvent | null>(null);\n const safeAreaRef = useRef<{ apex: Point; parent: HTMLElement } | null>(null);\n const safeAreaTimerRef = useRef<null | TimeoutID>(null);\n const wasInSafeAreaRef = useRef<boolean>(false);\n const hoverCloseTimerRef = useRef<null | TimeoutID>(null);\n\n const allowCreateRef = useRef(allowCreate);\n const allowEmptyRef = useRef(allowEmpty);\n const hasItemsRef = useRef(hasItems);\n const isOpenRef = useRef(isOpen);\n const isOpeningRef = useRef(isOpening);\n const keepOpenOnSubmitRef = useRef(keepOpenOnSubmit);\n const onCloseRef = useRef(onClose);\n const onOpenRef = useRef(onOpen);\n const onSubmitItemRef = useRef(onSubmitItem);\n const valueRef = useRef(valueIdentity);\n\n useEffect(() => {\n allowCreateRef.current = allowCreate;\n allowEmptyRef.current = allowEmpty;\n hasItemsRef.current = hasItems;\n isOpenRef.current = isOpen;\n isOpeningRef.current = isOpening;\n keepOpenOnSubmitRef.current = keepOpenOnSubmit;\n onCloseRef.current = onClose;\n onOpenRef.current = onOpen;\n onSubmitItemRef.current = onSubmitItem;\n valueRef.current = valueIdentity;\n }, [\n allowCreate,\n allowEmpty,\n hasItems,\n isOpen,\n isOpening,\n keepOpenOnSubmit,\n onClose,\n onOpen,\n onSubmitItem,\n valueIdentity,\n ]);\n\n const isMountedRef = useRef(false);\n\n useEffect(() => {\n if (!isMountedRef.current) {\n isMountedRef.current = true;\n // If isOpenOnMount, trigger onOpen right away\n if (isOpenRef.current && onOpenRef.current) {\n onOpenRef.current();\n }\n return;\n }\n\n if (isOpen && onOpenRef.current) {\n onOpenRef.current();\n } else if (!isOpen && onCloseRef.current) {\n onCloseRef.current();\n }\n }, [isOpen]);\n\n // Nested (submenu) Dropdowns register here so their scoped callbacks\n // (onActiveItem/onOpen/onClose/onSubmitItem) can be dispatched to them\n const dropdownContextValue: DropdownContextValue = useMemo(\n () => ({\n registerSubmenu(registration: SubmenuRegistration) {\n submenuRegistrationsRef.current.add(registration);\n return () => {\n submenuRegistrationsRef.current.delete(registration);\n };\n },\n }),\n [],\n );\n\n const dispatchToSubmenus = (key: 'onActiveItem' | 'onSubmitItem', payload: Item) => {\n if (!payload.element) return;\n for (const registration of submenuRegistrationsRef.current) {\n if (registration.element.contains(payload.element)) {\n registration[key]?.(payload);\n }\n }\n };\n\n const handleActiveItem = (payload: Item) => {\n onActiveItem?.(payload);\n dispatchToSubmenus('onActiveItem', payload);\n };\n\n const handleToggleSubmenu = (item: HTMLElement, isExpanded: boolean) => {\n // Show/hide the submenu in the top layer (popover=\"manual\"), like the\n // body, so no ancestor can become its containing block and shift its\n // anchor placement. Gate on the current state so a redundant toggle is\n // a no-op instead of a showPopover/hidePopover that throws.\n const submenu = getSubmenuOfItem(item);\n if (submenu) {\n const isShown = submenu.matches(':popover-open');\n if (isExpanded && !isShown) submenu.showPopover();\n else if (!isExpanded && isShown) submenu.hidePopover();\n }\n for (const registration of submenuRegistrationsRef.current) {\n if (registration.element === item) {\n (isExpanded ? registration.onOpen : registration.onClose)?.();\n }\n }\n };\n\n const clearDisclosureTimer = () => {\n if (disclosureTimerRef.current != null) {\n clearTimeout(disclosureTimerRef.current);\n disclosureTimerRef.current = null;\n }\n pendingDisclosureItemRef.current = null;\n };\n\n // Clear the disclosure intent timer on unmount so it can’t fire against\n // unmounted DOM or dispatch submenu callbacks after teardown\n useEffect(() => clearDisclosureTimer, []);\n\n // A parent item discloses its submenu after a short intent delay whenever\n // it becomes (and stays) the deepest active item, for pointer and keyboard\n // alike; submenus off the active path collapse immediately\n const syncSubmenuDisclosure = () => {\n if (!dropdownElement) return;\n const activeElement = getActiveItemElement(dropdownElement);\n collapseItemsOutsidePath(dropdownElement, activeElement, handleToggleSubmenu);\n const submenu = activeElement ? getSubmenuOfItem(activeElement) : null;\n if (activeElement && submenu && !isItemExpanded(activeElement)) {\n // A timer already pending for this item keeps its original start time\n if (pendingDisclosureItemRef.current === activeElement) return;\n clearDisclosureTimer();\n pendingDisclosureItemRef.current = activeElement;\n disclosureTimerRef.current = setTimeout(() => {\n disclosureTimerRef.current = null;\n pendingDisclosureItemRef.current = null;\n if (!activeElement.hasAttribute('data-ukt-active')) return;\n expandItem(activeElement, handleToggleSubmenu);\n }, SUBMENU_DISCLOSURE_DELAY);\n return;\n }\n clearDisclosureTimer();\n };\n\n const clearSafeAreaTimer = () => {\n if (safeAreaTimerRef.current != null) {\n clearTimeout(safeAreaTimerRef.current);\n safeAreaTimerRef.current = null;\n }\n };\n\n // Clear the safe-area give-up timer on unmount so it can’t fire against\n // unmounted DOM\n useEffect(() => clearSafeAreaTimer, []);\n\n // The safe area is the triangle from where the pointer last sat on the\n // open submenu’s parent (the apex) to that submenu’s two near corners.\n // While the pointer is inside it, it’s traveling toward the submenu, so the\n // submenu stays open even as the pointer crosses sibling items — the macOS\n // diagonal behavior\n const isPointerInSafeArea = (x: number, y: number): boolean => {\n const safeArea = safeAreaRef.current;\n if (!safeArea || !isItemExpanded(safeArea.parent)) return false;\n const submenu = getSubmenuOfItem(safeArea.parent);\n if (!submenu) return false;\n const submenuRect = submenu.getBoundingClientRect();\n const parentRect = safeArea.parent.getBoundingClientRect();\n // Submenus can open to either side; the near edge is the one facing\n // the parent item\n const nearX =\n submenuRect.left >= parentRect.right - 1\n ? submenuRect.left\n : submenuRect.right;\n return isPointInTriangle(\n { x, y },\n safeArea.apex,\n { x: nearX, y: submenuRect.top },\n { x: nearX, y: submenuRect.bottom },\n );\n };\n\n // The pointer left the safe area (or paused in it without reaching the\n // submenu): stop protecting the submenu and switch to whatever the pointer\n // is over now. Passing the target avoids an elementFromPoint read; the\n // give-up timer has no event, so it falls back to hit-testing the pointer\n const commitPointerTarget = (targetElement?: MaybeHTMLElement) => {\n clearSafeAreaTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n const pointer = pointerRef.current;\n const target =\n targetElement ??\n (pointer\n ? (dropdownElement?.ownerDocument.elementFromPoint(\n pointer.x,\n pointer.y,\n ) as MaybeHTMLElement)\n : null);\n if (!dropdownElement || !target || !dropdownElement.contains(target)) return;\n const item = getItemForTarget(dropdownElement, target);\n const event = lastMouseEventRef.current;\n // Only reachable via mouse events, so a real mouse event is on hand\n if (item && event) {\n setActiveItem({\n dropdownElement,\n element: item,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n };\n\n // Track the pointer against the open submenu’s safe area: anchor the apex\n // while over the parent item, and (re)arm the give-up timer while traveling\n // toward the submenu so only a pause — not motion — ends the protection\n const trackSafeArea = (event: ReactMouseEvent<HTMLElement>) => {\n // Safe-area intent only applies to an open menu with items; skip the\n // per-move DOM query otherwise (mousemove is a hot path)\n if (!dropdownElement || !isOpenRef.current || !hasItemsRef.current) return;\n const pointer = { x: event.clientX, y: event.clientY };\n pointerRef.current = pointer;\n lastMouseEventRef.current = event.nativeEvent;\n const parent = getDeepestExpandedItem(dropdownElement);\n if (!parent) {\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n clearSafeAreaTimer();\n return;\n }\n const target = event.target as HTMLElement;\n const submenu = getSubmenuOfItem(parent);\n const isOverParent =\n parent.contains(target) && !(submenu?.contains(target) ?? false);\n if (isOverParent) {\n safeAreaRef.current = { apex: pointer, parent };\n wasInSafeAreaRef.current = false;\n clearSafeAreaTimer();\n return;\n }\n // A newly-open submenu we haven’t anchored an apex for yet\n if (safeAreaRef.current?.parent !== parent) {\n safeAreaRef.current = null;\n }\n clearSafeAreaTimer();\n if (isPointerInSafeArea(pointer.x, pointer.y)) {\n wasInSafeAreaRef.current = true;\n safeAreaTimerRef.current = setTimeout(commitPointerTarget, SAFE_AREA_TIMEOUT);\n } else if (wasInSafeAreaRef.current) {\n // Just crossed out of the triangle. The pointer may still be over\n // the same sibling it entered while protected, so no mouseover will\n // fire — re-evaluate and activate whatever it’s on now\n commitPointerTarget(target);\n }\n };\n\n const clearHoverCloseTimer = () => {\n if (hoverCloseTimerRef.current != null) {\n clearTimeout(hoverCloseTimerRef.current);\n hoverCloseTimerRef.current = null;\n }\n };\n\n // Clear props.openOnHover’s close timer on unmount so it can’t fire against\n // unmounted DOM\n useEffect(() => clearHoverCloseTimer, []);\n\n const closeDropdown = (options?: { keepMenubarEngaged?: boolean }) => {\n setIsOpen(false);\n setIsOpening(false);\n mouseDownPositionRef.current = null;\n clearDisclosureTimer();\n clearSafeAreaTimer();\n clearHoverCloseTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n if (closingTimerRef.current != null) {\n clearTimeout(closingTimerRef.current);\n closingTimerRef.current = null;\n }\n // A self-dismissal — Escape, an outside click, or an item selection —\n // takes an enclosing menubar out of menu-mode. Switching menus,\n // clearing the open menu on hover, and focus changes pass\n // keepMenubarEngaged to stay in menu-mode.\n if (menubar && dropdownElement && !options?.keepMenubarEngaged) {\n menubar.notifyClosed(dropdownElement);\n }\n };\n\n // The pointer entered the trigger or (if open) the body: cancel any\n // pending close and, if props.openOnHover and not already open, open now\n const handleDropdownMouseEnter = () => {\n clearHoverCloseTimer();\n if (!openOnHover || isOpenRef.current) return;\n setIsOpen(true);\n setIsOpening(false);\n };\n\n // The pointer left the trigger and body entirely: if open, arm the\n // close-intent timer (a re-entry before it fires cancels it above, so\n // crossing the trigger/body gap doesn’t flicker)\n const handleDropdownMouseLeave = () => {\n if (!openOnHover || !isOpenRef.current || hoverCloseTimerRef.current != null) {\n return;\n }\n hoverCloseTimerRef.current = setTimeout(() => {\n hoverCloseTimerRef.current = null;\n closeDropdown();\n }, HOVER_CLOSE_DELAY);\n };\n\n const focusTrigger = () => {\n const firstChild = dropdownElement?.firstElementChild as MaybeHTMLElement;\n if (!firstChild) return;\n const focusable = firstChild.matches(FOCUSABLE_SELECTOR)\n ? firstChild\n : (firstChild.querySelector(FOCUSABLE_SELECTOR) as MaybeHTMLElement);\n focusable?.focus();\n };\n\n // Register with an enclosing Menubar (one open menu at a time, ←/→\n // moves between menus, hover-to-switch once any menu is open). Closing\n // goes through closeDropdown so pending timers (submenu disclosure,\n // close delay) can’t fire against a menu the menubar already closed.\n useEffect(() => {\n if (!menubar || !dropdownElement) return;\n return menubar.registerMember({\n close: () => closeDropdown({ keepMenubarEngaged: true }),\n element: dropdownElement,\n focusTrigger,\n isOpen: () => isOpenRef.current,\n open: () => setIsOpen(true),\n });\n });\n\n useEffect(() => {\n if (isOpen && menubar && dropdownElement) {\n menubar.notifyOpened(dropdownElement);\n }\n }, [dropdownElement, isOpen, menubar]);\n\n const handleSubmitItem = (event: Event | React.SyntheticEvent<HTMLElement>) => {\n const element = hasItemsRef.current\n ? getActiveItemElement(dropdownElement)\n : null;\n\n const submenuOfActive = element ? getSubmenuOfItem(element) : null;\n if (element && submenuOfActive) {\n // Parent items disclose; they never submit\n clearDisclosureTimer();\n expandItem(element, handleToggleSubmenu);\n if (currentInputMethodRef.current === 'keyboard' && dropdownElement) {\n const firstItem = getItemElements(dropdownElement, submenuOfActive)?.[0];\n if (firstItem) {\n setActiveItem({\n dropdownElement,\n element: firstItem,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n }\n return;\n }\n\n if (isOpenRef.current && !keepOpenOnSubmitRef.current) {\n // A short timeout before closing is better UX when user selects an item so dropdown\n // doesn’t close before expected. It also enables using <Link />s in the dropdown body.\n closingTimerRef.current = setTimeout(closeDropdown, 90);\n }\n\n if (!hasItemsRef.current) return;\n\n if (!element) {\n // With nothing selected, the only possible value comes from a text\n // input (a searchable dropdown’s input, or one inside a custom\n // trigger). No input means there’s no value to submit at all, so\n // bail regardless of allowCreate/allowEmpty instead of firing an\n // empty-valued onSubmitItem consumers have to defend against. (To\n // let such a dropdown clear its value, give it an explicit\n // empty-valued item, which submits as a normal active selection.)\n if (!inputElementRef.current) return;\n if (inputElementRef.current.value) {\n // Non-empty text matching no item is a created value\n if (!allowCreateRef.current) return;\n } else if (!allowEmptyRef.current) {\n // A cleared input is an empty (clearing) submit, which\n // allowEmpty gates even when allowCreate is set — “creating”\n // an empty value is clearing, not creating\n return;\n }\n }\n\n let itemLabel = element?.innerText ?? '';\n if (inputElementRef.current) {\n if (!element) {\n itemLabel = inputElementRef.current.value;\n } else {\n inputElementRef.current.value = itemLabel;\n }\n\n if (\n inputElementRef.current ===\n inputElementRef.current.ownerDocument.activeElement\n ) {\n inputElementRef.current.blur();\n }\n }\n\n const nextValue = element?.dataset.uktValue ?? itemLabel;\n // If parent is controlling Dropdown via props.value and nextValue is the same, do nothing\n if (valueRef.current && valueRef.current === nextValue) return;\n\n // When the body stays open after submit (keepOpenOnSubmit), move\n // aria-selected to the submitted option so the open-time annotation\n // doesn’t go stale; a closing body unmounts, so reopening re-derives\n // it from props.value. Listbox only — aria-selected isn’t valid on a\n // menuitem — scoped to the popup body (never a custom trigger’s own\n // aria-selected), and skipped entirely when the consumer authors\n // aria-selected themselves.\n if (\n element &&\n keepOpenOnSubmitRef.current &&\n popupRole === 'listbox' &&\n !consumerOwnsARIASelectedRef.current\n ) {\n const bodyElement = element.closest('.uktdropdown-body');\n for (const selected of Array.from(\n bodyElement?.querySelectorAll('[aria-selected=\"true\"]') ?? [],\n )) {\n selected.removeAttribute('aria-selected');\n }\n element.setAttribute('aria-selected', 'true');\n }\n\n // If the item is clickable or contains exactly one clickable element, invoke it\n // (but only if the event didn’t already originate from that element)\n if (element) {\n const eventTarget = event.target as HTMLElement;\n\n if (element.matches(CLICKABLE_SELECTOR)) {\n // The item element itself is clickable (e.g., <button data-ukt-value=\"…\">)\n if (element !== eventTarget && !element.contains(eventTarget)) {\n element.click();\n }\n } else {\n // Check if item contains exactly one clickable child element\n const clickableElements = element.querySelectorAll(CLICKABLE_SELECTOR);\n if (clickableElements.length === 1) {\n const clickableElement = clickableElements[0] as HTMLElement;\n if (\n clickableElement !== eventTarget &&\n !clickableElement.contains(eventTarget)\n ) {\n clickableElement.click();\n }\n }\n }\n }\n\n const payload: Item = {\n element,\n event,\n label: itemLabel,\n path: getItemPath(element),\n value: nextValue,\n };\n onSubmitItemRef.current?.(payload);\n dispatchToSubmenus('onSubmitItem', payload);\n };\n\n const handleMouseMove = (event: ReactMouseEvent<HTMLElement>) => {\n const { clientX, clientY } = event;\n currentInputMethodRef.current = 'mouse';\n trackSafeArea(event);\n const initialPosition = mouseDownPositionRef.current;\n if (!initialPosition) return;\n if (\n Math.abs(initialPosition.clientX - clientX) < 12 &&\n Math.abs(initialPosition.clientY - clientY) < 12\n ) {\n return;\n }\n setIsOpening(false);\n };\n\n const handleMouseOver = (event: ReactMouseEvent<HTMLElement>) => {\n if (!hasItemsRef.current) return;\n\n // If user isn’t currently using the mouse to navigate the dropdown, do nothing\n if (currentInputMethodRef.current !== 'mouse') return;\n\n // Ensure we have the dropdown root HTMLElement\n if (!dropdownElement) return;\n\n const eventTarget = event.target as HTMLElement;\n if (!eventTarget.closest('.uktdropdown-body')) return;\n\n // Hover inside an open nested dropdown belongs to that dropdown\n const hoveredRoot = eventTarget.closest('.uktdropdown');\n if (\n hoveredRoot !== dropdownElement &&\n hoveredRoot?.classList.contains('is-open')\n ) {\n return;\n }\n\n // Heading toward an open submenu: keep it open even over sibling items\n if (isPointerInSafeArea(event.clientX, event.clientY)) return;\n\n const item = getItemForTarget(dropdownElement, eventTarget);\n if (!item) return;\n\n setActiveItem({\n dropdownElement,\n element: item,\n event,\n onActiveItem: handleActiveItem,\n });\n syncSubmenuDisclosure();\n };\n\n const handleMouseOut = (event: ReactMouseEvent<HTMLElement>) => {\n if (!hasItemsRef.current) return;\n // The pointer left the dropdown entirely: drop the safe area so its\n // give-up timer can’t later fire on a stale position, and fall through\n // to the normal collapse (mousemove has stopped, so nothing else will)\n const relatedTarget = event.relatedTarget as Node | null;\n const isLeavingDropdown = !dropdownElement?.contains(relatedTarget);\n if (isLeavingDropdown) {\n clearSafeAreaTimer();\n safeAreaRef.current = null;\n wasInSafeAreaRef.current = false;\n }\n // Heading toward an open submenu: don’t clear the active item / collapse\n if (isPointerInSafeArea(event.clientX, event.clientY)) return;\n const activeItem = getActiveItemElement(dropdownElement);\n if (!activeItem) return;\n const eventRelatedTarget = event.relatedTarget as HTMLElement;\n if (activeItem !== event.target || activeItem.contains(eventRelatedTarget)) {\n return;\n }\n // If user moused out of activeItem (not into a descendant), it’s no longer active\n delete activeItem.dataset.uktActive;\n syncSubmenuDisclosure();\n };\n\n const handleMouseDown = (event: ReactMouseEvent<HTMLElement>) => {\n if (onMouseDown) onMouseDown(event);\n if (isOpenRef.current) return;\n\n setIsOpen(true);\n setIsOpening(true);\n mouseDownPositionRef.current = {\n clientX: event.clientX,\n clientY: event.clientY,\n };\n isOpeningTimerRef.current = setTimeout(() => {\n setIsOpening(false);\n isOpeningTimerRef.current = null;\n }, 1000);\n };\n\n const handleMouseUp = (event: ReactMouseEvent<HTMLElement>) => {\n if (onMouseUp) onMouseUp(event);\n // If dropdown is still opening or isn’t open or is closing, do nothing\n if (\n isOpeningRef.current ||\n !isOpenRef.current ||\n closingTimerRef.current != null\n ) {\n return;\n }\n\n const eventTarget = event.target as HTMLElement;\n\n // Clicks inside an open nested dropdown belong to that dropdown\n const clickedRoot = eventTarget.closest('.uktdropdown');\n if (\n clickedRoot !== dropdownElement &&\n clickedRoot?.classList.contains('is-open') &&\n dropdownElement?.contains(clickedRoot)\n ) {\n return;\n }\n\n // A click only counts as inside the body if the closest body element\n // belongs to this dropdown (a nested dropdown’s trigger sits inside\n // the outer body, but the outer body isn’t the nested one’s own)\n const targetBody = eventTarget.closest('.uktdropdown-body');\n const isInOwnBody = Boolean(\n targetBody && targetBody.closest('.uktdropdown') === dropdownElement,\n );\n // If click was outside dropdown body, don’t trigger submit\n if (!isInOwnBody) {\n // Don’t close dropdown if isOpening or search input is focused\n if (\n !isOpeningRef.current &&\n inputElementRef.current !== eventTarget.ownerDocument.activeElement\n ) {\n closeDropdown();\n }\n return;\n }\n\n // If dropdown has no items and click was within dropdown body, do nothing\n if (!hasItemsRef.current) return;\n\n if (dropdownElement) {\n const clickedItem = getItemForTarget(dropdownElement, eventTarget);\n if (clickedItem) {\n // Submit the item the click actually landed on: sync the\n // active item to it in case they diverge (e.g. active was\n // set via keyboard, then user clicked elsewhere)\n setActiveItem({\n dropdownElement,\n element: clickedItem,\n event,\n onActiveItem: handleActiveItem,\n });\n } else if (getActiveItemElement(dropdownElement)) {\n // A click that doesn’t land on an item — body padding, a\n // separator, or a disabled item (pointer-events: none\n // retargets its clicks to the container) — must not submit\n // the previously active item: like macOS, it does nothing.\n // With no active item it falls through, so a body click\n // can still submit an input-sourced value\n return;\n }\n }\n\n handleSubmitItem(event);\n };\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const { altKey, ctrlKey, key, metaKey } = event;\n const eventTarget = event.target as HTMLElement;\n if (!dropdownElement) return;\n\n const onEventHandled = () => {\n event.stopPropagation();\n event.preventDefault();\n currentInputMethodRef.current = 'keyboard';\n };\n\n const isEventTargetingDropdown = dropdownElement.contains(eventTarget);\n\n // Key events originating inside an open nested dropdown are that\n // dropdown’s business (e.g. an info popover nested in this body)\n const nestedRoot = eventTarget.closest?.('.uktdropdown');\n if (\n nestedRoot &&\n nestedRoot !== dropdownElement &&\n dropdownElement.contains(nestedRoot) &&\n nestedRoot.classList.contains('is-open')\n ) {\n return;\n }\n\n if (!isOpenRef.current) {\n // If dropdown is closed, don’t handle key events if event target isn’t within dropdown\n if (!isEventTargetingDropdown) return;\n // Open the dropdown on spacebar, enter, or if isSearchable and user hits the ↑/↓ arrows\n if (\n key === ' ' ||\n key === 'Enter' ||\n (hasItemsRef.current && (key === 'ArrowUp' || key === 'ArrowDown'))\n ) {\n onEventHandled();\n setIsOpen(true);\n }\n return;\n }\n\n const isTargetUsingKeyEvents = isEventTargetUsingKeyEvent(event);\n\n // If dropdown isOpen + hasItems & eventTargetNotUsingKeyEvents, handle characters\n if (hasItemsRef.current && !isTargetUsingKeyEvents) {\n let isEditingCharacters = !ctrlKey && !metaKey && /^[A-Za-z0-9]$/.test(key);\n // User could also be editing characters if there are already characters entered\n // and they are hitting delete or spacebar\n if (!isEditingCharacters && enteredCharactersRef.current) {\n isEditingCharacters = key === ' ' || key === 'Backspace';\n }\n\n if (isEditingCharacters) {\n onEventHandled();\n if (key === 'Backspace') {\n enteredCharactersRef.current = enteredCharactersRef.current.slice(\n 0,\n -1,\n );\n } else {\n enteredCharactersRef.current += key;\n }\n\n setActiveItem({\n dropdownElement,\n event,\n // If props.allowCreate, only override the input’s value with an\n // exact text match so user can enter a value not in items\n isExactMatch: allowCreateRef.current,\n onActiveItem: handleActiveItem,\n text: enteredCharactersRef.current,\n });\n syncSubmenuDisclosure();\n\n if (clearEnteredCharactersTimerRef.current != null) {\n clearTimeout(clearEnteredCharactersTimerRef.current);\n }\n\n clearEnteredCharactersTimerRef.current = setTimeout(() => {\n enteredCharactersRef.current = '';\n clearEnteredCharactersTimerRef.current = null;\n }, 1500);\n\n return;\n }\n }\n\n // If dropdown isOpen, handle submitting the value\n if (key === 'Enter' || (key === ' ' && !inputElementRef.current)) {\n onEventHandled();\n handleSubmitItem(event);\n return;\n }\n\n // If dropdown isOpen, handle closing it on escape or spacebar if !hasItems\n if (\n key === 'Escape' ||\n (isEventTargetingDropdown && key === ' ' && !hasItemsRef.current)\n ) {\n // Close dropdown if hasItems or event target not using key events\n if (hasItemsRef.current || !isTargetUsingKeyEvents) {\n // Escape closes the whole menu — submenus included — and\n // returns focus to the element that opened it. Focus before\n // closing: a searchable trigger input opens the dropdown on\n // focus, so its synchronous onFocus must land before the\n // close state update for the close to win the batch\n focusTrigger();\n closeDropdown();\n }\n return;\n }\n\n // Handle arrow keys\n if (hasItemsRef.current) {\n if (key === 'ArrowUp') {\n onEventHandled();\n if (altKey || metaKey) {\n setActiveItem({\n dropdownElement,\n event,\n index: 0,\n onActiveItem: handleActiveItem,\n });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: -1,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n return;\n }\n if (key === 'ArrowDown') {\n onEventHandled();\n if (altKey || metaKey) {\n // Using a negative index counts back from the end\n setActiveItem({\n dropdownElement,\n event,\n index: -1,\n onActiveItem: handleActiveItem,\n });\n } else {\n setActiveItem({\n dropdownElement,\n event,\n indexAddend: 1,\n onActiveItem: handleActiveItem,\n });\n }\n syncSubmenuDisclosure();\n return;\n }\n // ←/→ dive into and surface out of submenus (and move between\n // menus in a menubar); leave them alone when a text input has focus\n if (!isTargetUsingKeyEvents) {\n if (key === 'ArrowRight') {\n const activeElement = getActiveItemElement(dropdownElement);\n const submenu = activeElement\n ? getSubmenuOfItem(activeElement)\n : null;\n if (activeElement && submenu) {\n onEventHandled();\n clearDisclosureTimer();\n expandItem(activeElement, handleToggleSubmenu);\n const firstItem = getItemElements(dropdownElement, submenu)?.[0];\n if (firstItem) {\n setActiveItem({\n dropdownElement,\n element: firstItem,\n event,\n onActiveItem: handleActiveItem,\n });\n }\n return;\n }\n if (menubar) {\n onEventHandled();\n menubar.moveOpen(dropdownElement, 1);\n }\n return;\n }\n if (key === 'ArrowLeft') {\n const activeElement = getActiveItemElement(dropdownElement);\n const levelRoot = activeElement ? getLevelRoot(activeElement) : null;\n if (levelRoot) {\n onEventHandled();\n clearDisclosureTimer();\n const parentItem = getParentItem(levelRoot);\n if (parentItem) {\n collapseItem(parentItem, handleToggleSubmenu);\n }\n return;\n }\n if (menubar) {\n onEventHandled();\n menubar.moveOpen(dropdownElement, -1);\n }\n return;\n }\n }\n }\n };\n\n useKeyboardEvents({ ignoreUsedKeyboardEvents: false, onKeyDown: handleKeyDown });\n\n const handleRef = (ref: HTMLDivElement | null): (() => void) | void => {\n setDropdownElement(ref);\n if (!ref) return;\n\n const { ownerDocument } = ref;\n let inputElement = inputElementRef.current;\n // Check if trigger is a textual input or textarea element\n if (!inputElement && ref.firstElementChild) {\n if (ref.firstElementChild.matches(TEXT_INPUT_SELECTOR)) {\n inputElement = ref.firstElementChild as HTMLInputElement;\n } else {\n inputElement = ref.firstElementChild.querySelector(TEXT_INPUT_SELECTOR);\n }\n inputElementRef.current = inputElement;\n }\n\n const handleGlobalMouseDown = ({ target }: MouseEvent) => {\n const eventTarget = target as HTMLElement;\n if (!ref.contains(eventTarget)) {\n // Close dropdown on an outside click\n closeDropdown();\n }\n };\n\n const handleGlobalMouseUp = ({ target }: MouseEvent) => {\n if (!isOpenRef.current || closingTimerRef.current != null) return;\n\n // If still isOpening (gets set false 1s after open triggers), set it to false onMouseUp\n if (isOpeningRef.current) {\n setIsOpening(false);\n if (isOpeningTimerRef.current != null) {\n clearTimeout(isOpeningTimerRef.current);\n isOpeningTimerRef.current = null;\n }\n return;\n }\n\n const eventTarget = target as HTMLElement;\n // Only handle mouseup events from outside the dropdown here\n if (!ref.contains(eventTarget)) {\n closeDropdown();\n }\n };\n\n // Close dropdown if any element is focused outside of this dropdown\n const handleGlobalFocusIn = ({ target }: Event) => {\n if (!isOpenRef.current) return;\n\n const eventTarget = target as HTMLElement;\n // If focused element is a descendant or a parent of the dropdown, do nothing\n if (ref.contains(eventTarget) || eventTarget.contains(ref)) {\n return;\n }\n\n // Losing focus — including the focus shift when the body unmounts\n // on close — doesn’t end a menubar’s menu-mode; that takes a\n // deliberate dismissal (Escape, outside click, item select).\n closeDropdown({ keepMenubarEngaged: true });\n };\n\n document.addEventListener('focusin', handleGlobalFocusIn);\n document.addEventListener('mousedown', handleGlobalMouseDown);\n document.addEventListener('mouseup', handleGlobalMouseUp);\n\n if (ownerDocument !== document) {\n ownerDocument.addEventListener('focusin', handleGlobalFocusIn);\n ownerDocument.addEventListener('mousedown', handleGlobalMouseDown);\n ownerDocument.addEventListener('mouseup', handleGlobalMouseUp);\n }\n\n // If dropdown should be open on mount, focus it\n if (isOpenOnMount) {\n ref.focus();\n }\n\n const handleInput = (event: Event) => {\n if (!isOpenRef.current) setIsOpen(true);\n\n const input = event.target as HTMLInputElement;\n const isDeleting = enteredCharactersRef.current.length > input.value.length;\n enteredCharactersRef.current = input.value;\n // When deleting text, if there’s already an active item and\n // input isn’t empty, preserve the active item, else update it\n if (isDeleting && input.value.length && getActiveItemElement(ref)) {\n return;\n }\n\n setActiveItem({\n dropdownElement: ref,\n event,\n // If props.allowCreate, only override the input’s value with an\n // exact text match so user can enter a value not in items\n isExactMatch: allowCreateRef.current,\n onActiveItem: handleActiveItem,\n text: enteredCharactersRef.current,\n });\n };\n\n if (inputElement) {\n inputElement.addEventListener('input', handleInput);\n }\n\n return () => {\n document.removeEventListener('focusin', handleGlobalFocusIn);\n document.removeEventListener('mousedown', handleGlobalMouseDown);\n document.removeEventListener('mouseup', handleGlobalMouseUp);\n\n if (ownerDocument !== document) {\n ownerDocument.removeEventListener('focusin', handleGlobalFocusIn);\n ownerDocument.removeEventListener('mousedown', handleGlobalMouseDown);\n ownerDocument.removeEventListener('mouseup', handleGlobalMouseUp);\n }\n\n if (inputElement) {\n inputElement.removeEventListener('input', handleInput);\n }\n };\n };\n\n // When the body mounts (open): fill in parent-item/submenu ARIA, and\n // render it in the top layer via popover so an ancestor’s transform /\n // filter / contain can’t become the containing block for the fixed body\n // and break its anchor positioning + fallbacks. popover=\"manual\" keeps\n // dismissal under this component’s own listeners (see handleRef), which\n // preserves iframe support and searchable/text-input triggers that native\n // light-dismiss would close on any outside pointerdown.\n // These annotations run once per open (the body unmounts on close and is\n // annotated fresh each time); items rendered into an already-open body —\n // async-loaded or consumer-filtered — aren’t annotated until the next\n // open. Known limitation until it’s needed.\n const handleBodyRef = (ref: HTMLDivElement | null) => {\n if (!ref) return;\n // An inline ref callback re-attaches (and re-runs) on every re-render\n // while the body is open, but everything below must run exactly once\n // per open: showPopover() throws on an already-shown popover, and the\n // ownership check would read the reveal’s own aria-selected annotation\n // back as consumer-authored. Each open mounts a fresh body element, so\n // latch per element (a WeakSet, to hold no unmounted bodies alive).\n if (annotatedBodiesRef.current.has(ref)) return;\n annotatedBodiesRef.current.add(ref);\n // A consumer-authored aria-selected anywhere in the just-mounted body\n // (whether \"true\" or \"false\") means the consumer manages selection\n // ARIA themselves: the reveal below and the keepOpenOnSubmit move in\n // handleSubmitItem both stand down, so a single-select listbox never\n // ends up with two selected options (the usual your-values-win rule).\n consumerOwnsARIASelectedRef.current =\n ref.querySelector('[aria-selected]') != null;\n annotateParentItems(ref);\n if (popupRole !== 'dialog') annotateItemRoles(ref, popupRole);\n // The Popover API is Baseline 2024, so showPopover() needs no feature\n // detection; the body is mounted only while open, so this runs once\n // per open and won’t throw on an already-open body.\n ref.showPopover();\n // Reveal the current value on open: mark the matching option\n // aria-selected (listbox only — aria-selected isn’t valid on a\n // menuitem), make it the active item (so keyboard navigation starts\n // there), and scroll it into view — so a controlled dropdown opens\n // showing (and at) its current selection. The lookup is deliberately\n // top-level only (getItemElements filters to the root level):\n // search/typeahead also match per level, and no native menu opens\n // with submenus pre-expanded, so a value matching only a submenu\n // item is a graceful no-op, like a value matching nothing.\n if (valueIdentity != null && dropdownElement) {\n const selectedItem = getItemElements(dropdownElement)?.find(\n (item) => item.dataset.uktValue === valueIdentity,\n );\n if (selectedItem) {\n if (popupRole === 'listbox' && !consumerOwnsARIASelectedRef.current) {\n selectedItem.setAttribute('aria-selected', 'true');\n }\n setActiveItem({ dropdownElement, element: selectedItem });\n }\n }\n };\n\n if (!isValidElement(trigger)) {\n if (isSearchable) {\n trigger = (\n <input\n aria-controls={bodyId}\n aria-expanded={isOpen}\n aria-haspopup={popupRole}\n autoComplete=\"off\"\n className=\"uktdropdown-trigger\"\n defaultValue={valueLabel ?? ''}\n disabled={disabled}\n name={name}\n onFocus={() => setIsOpen(true)}\n placeholder={placeholder}\n ref={inputElementRef}\n tabIndex={tabIndex}\n type=\"text\"\n />\n );\n } else {\n trigger = (\n <button\n aria-controls={bodyId}\n aria-expanded={isOpen}\n aria-haspopup={popupRole}\n className=\"uktdropdown-trigger\"\n tabIndex={0}\n type=\"button\"\n >\n {trigger}\n </button>\n );\n }\n } else {\n // For a consumer-provided trigger, add ARIA props (letting the consumer\n // override by specifying their own).\n const triggerProps = trigger.props as Record<string, unknown>;\n trigger = cloneElement(trigger as ReactElement<Record<string, unknown>>, {\n 'aria-controls': triggerProps['aria-controls'] ?? bodyId,\n 'aria-expanded': triggerProps['aria-expanded'] ?? isOpen,\n 'aria-haspopup': triggerProps['aria-haspopup'] ?? popupRole,\n });\n }\n\n if (label != null) {\n trigger = (\n <label className=\"uktdropdown-label\">\n <div className=\"uktdropdown-label-text\">{label}</div>\n {trigger}\n </label>\n );\n }\n\n return (\n <Fragment>\n <style href=\"@acusti/dropdown/Dropdown\" precedence=\"medium\">\n {styles}\n </style>\n <div\n className={clsx('uktdropdown', className, {\n disabled,\n 'is-open': isOpen,\n 'is-searchable': isSearchable,\n })}\n onClick={onClick}\n onMouseDown={handleMouseDown}\n onMouseEnter={handleDropdownMouseEnter}\n onMouseLeave={handleDropdownMouseLeave}\n onMouseMove={handleMouseMove}\n onMouseOut={handleMouseOut}\n onMouseOver={handleMouseOver}\n onMouseUp={handleMouseUp}\n ref={handleRef}\n style={styleFromProps}\n >\n {trigger}\n {/* TODO next version of Dropdown should use <Activity> for body https://react.dev/reference/react/Activity */}\n {isOpen ? (\n <div\n className={clsx('uktdropdown-body', {\n 'has-items': hasItems,\n })}\n id={bodyId}\n popover=\"manual\"\n ref={handleBodyRef}\n role={popupRole}\n >\n <div className=\"uktdropdown-content\">\n <DropdownContext.Provider\n value={hasItems ? dropdownContextValue : null}\n >\n {body}\n </DropdownContext.Provider>\n </div>\n </div>\n ) : null}\n </div>\n </Fragment>\n );\n}\n\nconst INERT_SUBMENU_PROPS = [\n 'allowCreate',\n 'allowEmpty',\n 'isOpenOnMount',\n 'isSearchable',\n 'keepOpenOnSubmit',\n 'name',\n 'openOnHover',\n 'placeholder',\n 'tabIndex',\n 'value',\n] as const;\n\n// The nested (submenu) rendering of Dropdown: a parent item that discloses a\n// child menu. It renders the data-ukt-submenu protocol and registers with the\n// root dropdown, whose engine handles all interaction.\nfunction SubmenuDropdown(props: Props & { parentDropdown: DropdownContextValue }) {\n const {\n children,\n className,\n disabled,\n label,\n onActiveItem,\n onClose,\n onOpen,\n onSubmitItem,\n parentDropdown,\n style,\n } = props;\n\n const itemRef = useRef<HTMLLIElement | null>(null);\n\n useEffect(() => {\n const element = itemRef.current;\n if (!element) return;\n return parentDropdown.registerSubmenu({\n element,\n onActiveItem,\n onClose,\n onOpen,\n onSubmitItem,\n });\n }, [onActiveItem, onClose, onOpen, onSubmitItem, parentDropdown]);\n\n // Misuse feedback is unconditional, like the children-count error above\n const warnedRef = useRef(false);\n useEffect(() => {\n if (warnedRef.current) return;\n const inertProps = INERT_SUBMENU_PROPS.filter(\n (propName) => props[propName] !== undefined,\n );\n if (!inertProps.length) return;\n warnedRef.current = true;\n console.error(\n `@acusti/dropdown: ${inertProps.join(', ')} only apply to a top-level Dropdown and are ignored on a nested (submenu) Dropdown.`,\n );\n });\n\n const childrenCount = Children.count(children);\n let labelContent: ReactNode = label;\n let body: ReactNode = children;\n if (childrenCount > 1) {\n labelContent = (children as ChildrenTuple)[0];\n body = (children as ChildrenTuple)[1];\n }\n\n // popover=\"manual\" renders the submenu in the top layer (see the\n // [data-ukt-submenu] CSS and handleToggleSubmenu), escaping the body’s\n // containing block so its anchor placement is correct across browsers. The\n // root dropdown’s engine calls showPopover/hidePopover as the item toggles.\n const submenu = isValidElement(body) ? (\n cloneElement(body as ReactElement<Record<string, unknown>>, {\n 'data-ukt-submenu': '',\n popover: 'manual',\n })\n ) : (\n <div data-ukt-submenu=\"\" popover=\"manual\">\n {body}\n </div>\n );\n\n return (\n <li\n aria-disabled={disabled || undefined}\n className={className}\n data-ukt-item=\"\"\n ref={itemRef}\n style={style}\n >\n {labelContent}\n {submenu}\n </li>\n );\n}\n\nexport { default as Menubar, type MenubarProps } from './Menubar.js';\n"],"mappings":";;;;;;;AAkBA,IAAaa,kBAAkBb,cAA2C,IAAI;AAiB9E,IAAa2B,iBAAiB3B,cAA0C,IAAI;;;;;;AE9B5E,IAAakC,gBAAgB;AAC7B,IAAaC,mBAAmB;AAEhC,IAAMC,yBAAyB;AAM/B,IAAMM,kBAAkBC,oBACnBA,iBAAiBC,cAAc,mBAAmB,KAAK;AAI5D,IAAaC,gBAAgBC,YACzBA,QAAQC,QAAQZ,gBAAgB;AAGpC,IAAaa,oBAAoBV,SAAwC;CACrE,MAAMW,UAAUX,KAAKM,cAAcT,gBAAgB;CACnD,IAAI,CAACc,SAAS,OAAO;CAErB,OADcA,QAAQE,eAAeJ,QAAAA,mCAAqB,MACzCT,OAAOW,UAAU;AACtC;AAGA,IAAaG,iBAAiBC,cACzBA,UAAUF,eAAeJ,QAAAA,mCAAqB,KAAK;AAGxD,IAAaO,gBAAgBhB,SAA8B;CACvD,IAAI,CAACU,iBAAiBV,IAAI,GAAG,OAAOA,KAAKiB,aAAa;CACtD,MAAMC,QAAQlB,KAAKmB,UAAU,IAAI;CACjC,KAAK,MAAMR,WAAWS,MAAMC,KAAKH,MAAMI,iBAAiBzB,gBAAgB,CAAC,GACrEc,QAAQY,OAAO;CAEnB,QAAQL,MAAMM,eAAe,GAAA,CAAIC,KAAK;AAC1C;AAOA,IAAMC,eAAeC,SAA4B;CAC7C,IAAIC,OAAO;CACXrC,SAASsC,QAAQF,OAAOG,UAAU;EAC9B,IAAI,OAAOA,UAAU,YAAY,OAAOA,UAAU,UAC9CF,QAAQE;OACL,IAAItC,eAAesC,KAAK,GAAG;GAC9B,MAAMC,aAAaD,MAAME;GAIzB,IAAID,WAAW,wBAAwBG,KAAAA,GAAW;GAClDN,QAAQF,YAAYK,WAAWE,QAAQ;EAC3C;CACJ,CAAC;CAC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AAayG,MAA+C;GAAA,oBACpC;GAAE2R,SACb;EACb,CAKJ,IAHI,oBAAA,OAAA;GAAsB,oBAAA;GAAW,SAAA;aAC5B3R;EACC,CAAA;EACThB,EAAA,KAAAgB;EAAAhB,EAAA,MAAAO;CAAA,OAAAA,KAAAP,EAAA;CATD,MAAAsF,UAAgB/E;CAaO,MAAAW,KAAApD,YAAA2C,KAAAA;CAAqB,IAAAsB;CAAA,IAAA/B,EAAA,QAAAnC,aAAAmC,EAAA,QAAA0S,gBAAA1S,EAAA,QAAAlB,SAAAkB,EAAA,QAAAsF,WAAAtF,EAAA,QAAAkB,IAAA;EADxCa,KAAA,qBAAA,MAAA;GACmB,iBAAAb;GACJrD;GACG,iBAAA;GACTuU,KAAAA;GACEtT;aALX,CAOK4T,cACApN,OACA;;EAAAtF,EAAA,MAAAnC;EAAAmC,EAAA,MAAA0S;EAAA1S,EAAA,MAAAlB;EAAAkB,EAAA,MAAAsF;EAAAtF,EAAA,MAAAkB;EAAAlB,EAAA,MAAA+B;CAAA,OAAAA,KAAA/B,EAAA;CAAA,OATL+B;AASK"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acusti/dropdown",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.1",
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",