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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/ListboxStore-BYBpGrOz.d.ts +453 -0
  2. package/dist/ListboxStore-nmorsoqX.d.cts +453 -0
  3. package/dist/chunk-4C666HHU.js +2 -0
  4. package/dist/chunk-4C666HHU.js.map +1 -0
  5. package/dist/chunk-5T5B5SPR.cjs +2 -0
  6. package/dist/chunk-5T5B5SPR.cjs.map +1 -0
  7. package/dist/chunk-A4Z5BY7H.js +2 -0
  8. package/dist/chunk-A4Z5BY7H.js.map +1 -0
  9. package/dist/chunk-BFOY762U.js +2 -0
  10. package/dist/chunk-BFOY762U.js.map +1 -0
  11. package/dist/chunk-IT372NHF.js +2 -0
  12. package/dist/chunk-IT372NHF.js.map +1 -0
  13. package/dist/chunk-JFEVUUPC.cjs +2 -0
  14. package/dist/chunk-JFEVUUPC.cjs.map +1 -0
  15. package/dist/chunk-KO3DXT3Y.js +2 -0
  16. package/dist/chunk-KO3DXT3Y.js.map +1 -0
  17. package/dist/chunk-LXXK4S4Q.js +2 -0
  18. package/dist/chunk-LXXK4S4Q.js.map +1 -0
  19. package/dist/chunk-M4G6J7DP.cjs +2 -0
  20. package/dist/chunk-M4G6J7DP.cjs.map +1 -0
  21. package/dist/chunk-SCDHQZFI.cjs +2 -0
  22. package/dist/chunk-SCDHQZFI.cjs.map +1 -0
  23. package/dist/chunk-W4ACKMIZ.cjs +2 -0
  24. package/dist/chunk-W4ACKMIZ.cjs.map +1 -0
  25. package/dist/chunk-XMZZ62VJ.cjs +2 -0
  26. package/dist/chunk-XMZZ62VJ.cjs.map +1 -0
  27. package/dist/combobox/index.cjs +2 -0
  28. package/dist/combobox/index.cjs.map +1 -0
  29. package/dist/combobox/index.d.cts +1066 -0
  30. package/dist/combobox/index.d.ts +1066 -0
  31. package/dist/combobox/index.js +2 -0
  32. package/dist/combobox/index.js.map +1 -0
  33. package/dist/command-menu/index.cjs +2 -0
  34. package/dist/command-menu/index.cjs.map +1 -0
  35. package/dist/command-menu/index.d.cts +154 -0
  36. package/dist/command-menu/index.d.ts +154 -0
  37. package/dist/command-menu/index.js +2 -0
  38. package/dist/command-menu/index.js.map +1 -0
  39. package/dist/command-score-CTJ9NV6n.d.cts +23 -0
  40. package/dist/command-score-CTJ9NV6n.d.ts +23 -0
  41. package/dist/context-menu/index.cjs +2 -0
  42. package/dist/context-menu/index.cjs.map +1 -0
  43. package/dist/context-menu/index.d.cts +672 -0
  44. package/dist/context-menu/index.d.ts +672 -0
  45. package/dist/context-menu/index.js +2 -0
  46. package/dist/context-menu/index.js.map +1 -0
  47. package/dist/dropdown-menu/index.cjs +2 -0
  48. package/dist/dropdown-menu/index.cjs.map +1 -0
  49. package/dist/dropdown-menu/index.d.cts +699 -0
  50. package/dist/dropdown-menu/index.d.ts +699 -0
  51. package/dist/dropdown-menu/index.js +2 -0
  52. package/dist/dropdown-menu/index.js.map +1 -0
  53. package/dist/events-DOGItflK.d.ts +1776 -0
  54. package/dist/events-DPsuhBln.d.cts +1776 -0
  55. package/dist/input-C95v6jB0.d.cts +46 -0
  56. package/dist/input-CYweYB_i.d.ts +46 -0
  57. package/dist/internal/listbox/index.cjs +2 -0
  58. package/dist/internal/listbox/index.cjs.map +1 -0
  59. package/dist/internal/listbox/index.d.cts +272 -0
  60. package/dist/internal/listbox/index.d.ts +272 -0
  61. package/dist/internal/listbox/index.js +2 -0
  62. package/dist/internal/listbox/index.js.map +1 -0
  63. package/dist/internal/popup-menu/index.cjs +2 -0
  64. package/dist/internal/popup-menu/index.cjs.map +1 -0
  65. package/dist/internal/popup-menu/index.d.cts +238 -0
  66. package/dist/internal/popup-menu/index.d.ts +238 -0
  67. package/dist/internal/popup-menu/index.js +2 -0
  68. package/dist/internal/popup-menu/index.js.map +1 -0
  69. package/dist/items-B6HeFO_8.d.cts +37 -0
  70. package/dist/items-B6HeFO_8.d.ts +37 -0
  71. package/dist/kbd/index.cjs +2 -0
  72. package/dist/kbd/index.cjs.map +1 -0
  73. package/dist/kbd/index.d.cts +61 -0
  74. package/dist/kbd/index.d.ts +61 -0
  75. package/dist/kbd/index.js +2 -0
  76. package/dist/kbd/index.js.map +1 -0
  77. package/dist/loaders/index.cjs +2 -0
  78. package/dist/loaders/index.cjs.map +1 -0
  79. package/dist/loaders/index.d.cts +363 -0
  80. package/dist/loaders/index.d.ts +363 -0
  81. package/dist/loaders/index.js +2 -0
  82. package/dist/loaders/index.js.map +1 -0
  83. package/dist/loading-C6WZGUc3.d.cts +29 -0
  84. package/dist/loading-CC4n55sR.d.ts +29 -0
  85. package/dist/resolve-BYm41YfG.d.ts +406 -0
  86. package/dist/resolve-Dk_fAKb2.d.cts +406 -0
  87. package/dist/scroll-arrow-B81wZTZ2.d.cts +544 -0
  88. package/dist/scroll-arrow-CNd0tgME.d.ts +544 -0
  89. package/dist/select/index.cjs +2 -0
  90. package/dist/select/index.cjs.map +1 -0
  91. package/dist/select/index.d.cts +985 -0
  92. package/dist/select/index.d.ts +985 -0
  93. package/dist/select/index.js +2 -0
  94. package/dist/select/index.js.map +1 -0
  95. package/dist/separator-BiySI623.d.cts +275 -0
  96. package/dist/separator-De8l8DKO.d.ts +275 -0
  97. package/dist/surface-context-ClmxshBW.d.ts +14 -0
  98. package/dist/surface-context-DF-L-30G.d.cts +14 -0
  99. package/dist/type-guards-BC2B6bVi.d.cts +350 -0
  100. package/dist/type-guards-ybcHBB3C.d.ts +350 -0
  101. package/dist/types-DT4FOOa2.d.cts +51 -0
  102. package/dist/types-DT4FOOa2.d.ts +51 -0
  103. package/dist/use-listbox-item-NzZuY34-.d.cts +212 -0
  104. package/dist/use-listbox-item-NzZuY34-.d.ts +212 -0
  105. package/dist/video-player/index.cjs +3 -0
  106. package/dist/video-player/index.cjs.map +1 -0
  107. package/dist/video-player/index.d.cts +1391 -0
  108. package/dist/video-player/index.d.ts +1391 -0
  109. package/dist/video-player/index.js +3 -0
  110. package/dist/video-player/index.js.map +1 -0
  111. package/package.json +66 -12
  112. package/dist/index.d.ts +0 -2
  113. package/dist/index.js +0 -2
@@ -0,0 +1,2 @@
1
+ import{a as xt}from"../chunk-IT372NHF.js";import{a as bt,b as Pt,c as Rt,d as It,e as Ct,f as Re,g as Tt}from"../chunk-KO3DXT3Y.js";import{J as rt,K as lt,L as ao,N as at,O as it,Q as de,R as fe,S as z,T as st,U as ut,V as ct,W as pt,aa as io,ba as mt,d as we,da as dt,ea as ft,fa as gt,pa as St,q as tt,s as ot,sa as ht,t as nt}from"../chunk-BFOY762U.js";import{a as He,p as to,q as oo,w as no,x as ro,y as lo}from"../chunk-A4Z5BY7H.js";import{a as eo}from"../chunk-4C666HHU.js";var Nt={};eo(Nt,{Arrow:()=>ot,Backdrop:()=>nt,Empty:()=>ut,Group:()=>St,GroupLabel:()=>pt,Icon:()=>st,Input:()=>ct,Item:()=>ze,ItemIndicator:()=>Ge,ItemLabel:()=>Fe,List:()=>mt,Popup:()=>je,Portal:()=>lt,Positioner:()=>Ye,Root:()=>Xe,ScrollDownArrow:()=>ft,ScrollUpArrow:()=>dt,Separator:()=>ht,Surface:()=>$e,Trigger:()=>Ke,Value:()=>Je});import{useRender as co}from"@base-ui/react/use-render";import*as E from"react";import*as Ie from"react";var Le=Ie.createContext(null);function O(){let e=Ie.useContext(Le);if(!e)throw new Error("Select components must be used within a Select.Root");return e}function so(){return Ie.useContext(Le)}var $={slot:"bazzaui-select-item",highlighted:"data-highlighted",disabled:"data-disabled",selected:"data-selected",first:"data-first",last:"data-last",firstInGroup:"data-first-in-group",lastInGroup:"data-last-in-group"};import*as Ce from"react";var ke=Ce.createContext(null);function Te(){let e=Ce.useContext(ke);if(!e)throw new Error("Select.Item child components must be used within a Select.Item");return e}function uo(){return Ce.useContext(ke)}import{jsx as fo}from"react/jsx-runtime";var po={highlighted:e=>e?{[$.highlighted]:""}:null,disabled:e=>e?{[$.disabled]:""}:null,selected:e=>e?{[$.selected]:""}:null,first:e=>e?{[$.first]:""}:null,last:e=>e?{[$.last]:""}:null,firstInGroup:e=>e?{[$.firstInGroup]:""}:null,lastInGroup:e=>e?{[$.lastInGroup]:""}:null};function mo(e,n){let{value:t,textValue:l,keywords:s,disabled:r=!1,onSelect:c,forceMount:b=!1,render:o,className:a,style:P,onClick:d,onPointerDown:m,onPointerMove:R,children:u,...i}=e,p=O(),g=E.useMemo(()=>z(t,p.itemToStringValue),[t,p.itemToStringValue]),M=E.useId(),L=t===null?`select-clear-${M}`:void 0,h=E.useMemo(()=>Ct(p.items,g),[p.items,g]),V=h?.label,w=E.useMemo(()=>fe(t,p.itemToStringLabel),[t,p.itemToStringLabel]),v=E.useMemo(()=>{if(l!==void 0)return l;if(typeof V=="string")return V;if(w&&w!==g)return w},[l,V,w,g]),ee=E.useMemo(()=>Tt(s,[typeof V=="string"?V:w&&w!==g?w:void 0,...h?.keywords??[]]),[s,V,w,g,h]),k=E.useRef(v),A=p.multiple?Rt(p.values,t,p.isItemEqualToValue):p.value!==""&&Pt(p.value,t,p.isItemEqualToValue),ie=!p.multiple,S=it({id:L,value:g,keywords:ee,disabled:r,forceMount:b,closeOnClick:ie,children:u});E.useEffect(()=>{let T=()=>{if(!r){if(p.multiple)if(t==null)p.onValuesChange([]);else{let te=A?It(p.values,t,p.isItemEqualToValue):[...p.values,t];p.onValuesChange(te)}else p.onValueChange(t);c?.()}};return S.registerSelect(T)},[r,p,t,A,c,S]),E.useEffect(()=>{let T=k.current;if(T)return p.registerItemText(g,T)},[g,p]),E.useEffect(()=>{!v&&typeof u=="string"&&(k.current=u,p.registerItemText(g,u))},[u,v,g,p]);let F=E.useMemo(()=>({highlighted:S.isHighlighted,disabled:r,selected:A,first:S.positional.first,last:S.positional.last,firstInGroup:S.positional.firstInGroup,lastInGroup:S.positional.lastInGroup}),[S.isHighlighted,r,A,S.positional]),J=E.useMemo(()=>({id:S.id,value:t,textValue:v,highlighted:S.isHighlighted,disabled:r,selected:A}),[S.id,t,v,S.isHighlighted,r,A]),B=E.useCallback(T=>{d?.(T),T.defaultPrevented||S.handlers.onClick(T)},[d,S.handlers]),W=E.useCallback(T=>{S.handlers.onPointerDown(T),m?.(T)},[S.handlers,m]),_=E.useCallback(T=>{R?.(T),T.defaultPrevented||S.handlers.onPointerMove(T)},[R,S.handlers]),q=co({render:o,ref:[S.ref,S.rowRef,n],state:F,stateAttributesMapping:po,props:{...i,[$.slot]:"",id:S.id,role:"option",tabIndex:-1,"aria-selected":A,"aria-disabled":r||void 0,className:a,style:P,onClick:B,onPointerMove:_,onPointerDown:W,children:u},enabled:S.isVisible,defaultTagName:"div"});return S.isVisible?fo(ke.Provider,{value:J,children:q}):null}var ze=E.forwardRef(mo);import{useRender as go}from"@base-ui/react/use-render";import*as Ae from"react";var Me={slot:"bazzaui-select-item-indicator",selected:"data-selected",highlighted:"data-highlighted"};var So={selected:e=>e?{[Me.selected]:""}:null,highlighted:e=>e?{[Me.highlighted]:""}:null},Ge=Ae.forwardRef(function(n,t){let{render:l,className:s,style:r,forceMount:c=!1,keepMounted:b=!1,children:o,...a}=n,P=Te(),d=P.selected,m=P.highlighted,R=Ae.useMemo(()=>({selected:d,highlighted:m}),[d,m]),u=c||b||d,i=typeof o=="function"?o(R):b&&!d?null:o,p=go({render:l,ref:t,state:R,stateAttributesMapping:So,props:{...a,[Me.slot]:"","aria-hidden":!0,className:s,style:r,children:i},defaultTagName:"span"});return u?p:null});import{useRender as ho}from"@base-ui/react/use-render";import*as j from"react";var Mt={slot:"bazzaui-select-item-label"};var Fe=j.forwardRef(function(n,t){let{render:l,className:s,style:r,children:c,...b}=n,o=O(),a=Te(),P=j.useRef(null),d=z(a.value,o.itemToStringValue),m=j.useMemo(()=>{if(c!==void 0)return c;let i=Re(o.items,d);return i!==void 0?i:a.textValue!==void 0?a.textValue:d},[c,o.items,d,a.textValue]),R=j.useMemo(()=>({value:d,selected:a.selected,highlighted:a.highlighted,disabled:a.disabled}),[d,a.selected,a.highlighted,a.disabled]);j.useEffect(()=>{if(typeof m=="string")return o.registerItemText(d,m)},[m,o,d]);let u=j.useCallback(i=>{P.current=i,a.selected&&i&&(o.selectedItemTextRef.current=i),i&&!a.disabled&&(o.firstItemTextRef.current||(o.firstItemTextRef.current=i))},[a.selected,a.disabled,o]);return ho({render:l,ref:t,state:R,props:{...b,[Mt.slot]:"",ref:u,className:s,style:r,children:m},defaultTagName:"span"})});import*as ce from"react";import*as Oe from"react";var Be=Oe.createContext(null);function Ve(){return Oe.useContext(Be)}import{jsx as xo}from"react/jsx-runtime";var je=ce.forwardRef(function(n,t){let{className:l,render:s,...r}=n,c=Ve(),b=c?.alignItemWithTriggerActive??!1,o=c?.align,a=ce.useCallback(m=>({...m,side:b?"none":m.side,alignItemWithTriggerActive:b}),[b]),P=ce.useMemo(()=>typeof l=="function"?m=>l(a(m)):l,[l,a]),d=ce.useMemo(()=>typeof s=="function"?(m,R)=>s(m,a(R)):s,[s,a]);return xo(rt,{ref:t,className:P,render:d,"data-align-item-with-trigger":b?"":void 0,...b?{"data-side":"none","data-align":o}:{},...r})});import{useDirection as bo}from"@base-ui/react/internals/direction-context";import{Popover as Po}from"@base-ui/react/popover";import*as C from"react";function pe(e,n,t){return e<n?n:e>t?t:e}function We(e){let n=e.getBoundingClientRect(),{offsetWidth:t,offsetHeight:l}=e,s=t>0?Math.round(n.width)/t:1,r=l>0?Math.round(n.height)/l:1;return(!Number.isFinite(s)||s===0)&&(s=1),(!Number.isFinite(r)||r===0)&&(r=1),{x:s,y:r}}function Vt(e,n,t){return e/t[n]}function ve(e,n){let t=e.x/n.x,l=e.y/n.y,s=e.width/n.x,r=e.height/n.y;return{x:t,y:l,width:s,height:r,top:l,left:t,right:t+s,bottom:l+r}}var K=1;function ge(e,n){return Math.max(0,e-n)}var vt=5,yt=20,_e=10,Et=100;function wt(e){let{triggerRect:n,positionerRect:t,valueRect:l,textRect:s,scrollHeight:r,documentClientHeight:c,documentClientWidth:b,marginTop:o,marginBottom:a,minHeight:P,maxPopupHeight:d,borderBottom:m,direction:R}=e,u=()=>({fallback:!0,left:0,isTopPositioned:!1,top:0,height:0,scrollTop:0,marginTop:o,marginBottom:a,reachedMaxHeight:!1,transformOrigin:null}),i=c-o-a,p=b,g=n.height,M=i-n.bottom+g,L=R==="rtl"?n.right-t.width:n.left,h=0,V=null;if(s&&l){L=t.left+(R==="rtl"?l.right-s.right:l.left-s.left);let U=l.top-n.top+l.height/2;h=s.top-t.top+s.height/2-U,V=s.top+s.height/2}let w=M+h+a+m,v=Math.min(i,w),ee=i-o-a,k=w-v,A=p-vt,ie=pe(L,vt,A-t.width),S=ge(r,v),F=k>=S-K;if(F&&(v=Math.min(i,t.height)-(k-S)),n.top<yt||n.bottom>i-yt||Math.ceil(v)+K<Math.min(r,P))return u();let B=Math.max(P,v),W=a+m-o,_=0,q=k;if(F){let U=Math.max(0,i-w);_=t.height>=ee?0:Math.max(0,U+W),q=S}else q=Math.max(0,k-W);let T=null;if(V!=null){let U=t.top,Z=t.height,f=Z>0?(V-U)/Z*100:50;T=`50% ${pe(f,0,100)}%`}let te=B===i||v>=d;return{fallback:!1,left:ie,isTopPositioned:F,top:_,height:v,scrollTop:q,marginTop:o,marginBottom:a,reachedMaxHeight:te,transformOrigin:T}}function Ht(e){let{isTopPositioned:n,currentHeight:t,scrollTop:l,maxScrollTop:s,maxAvailableHeight:r}=e,c=n?s-l:l;if(c<=K){let d=pe(c,0,r-t),m=t+d;return{height:d>0?m:null,scroll:{kind:"set",value:n?s:0},reachedMaxHeight:r-m<=K}}let b=Math.min(t+c,r),o={kind:"none"},a=!1;if(r-b>K)o=n?{kind:"max"}:{kind:"clamp",value:0};else if(a=!0,!n&&l<s){let d=t+c-r;o={kind:"clamp",value:l-(c-d)}}let P=Math.ceil(b);return{height:P,scroll:o,reachedMaxHeight:a||P>=r-K}}var qe={slot:"bazzaui-select-positioner"};import{jsx as At}from"react/jsx-runtime";var Ye=C.forwardRef(function(n,t){let{alignItemWithTrigger:l=!0,side:s="bottom",align:r="start",sideOffset:c=0,className:b,style:o,children:a,...P}=n,d=we(),m=O(),R=bo()==="rtl"?"rtl":"ltr",u=d.store,i=u.useState("open"),p=u.useState("openMethod"),g=u.useState("hasInput"),[M,L]=C.useState(l),h=M&&p!=="touch"&&!g,[V,w]=C.useState(!1),[v,ee]=C.useState(null),k=C.useRef(null),A=C.useRef(null),ie=C.useRef(null),S=C.useRef(!1),F=C.useRef(!1),J=C.useCallback(()=>{let f=k.current,x=u.context.refs.popupRef.current;f&&(f.style.height=""),x&&(x.style.height="",x.style.removeProperty("--transform-origin")),S.current=!1,F.current=!1},[u]),B=C.useCallback(()=>{J(),L(l),w(!1),ee(null)},[l,J]);C.useEffect(()=>m.registerResetPositioningCallback(B),[m,B]);let W=C.useCallback(()=>{if(u.state.hasInput)return;let f=k.current,x=m.triggerRef.current,D=u.context.refs.popupRef.current,Y=u.context.refs.listRef.current;if(!f||!x||!D||!Y)return;let oe=m.selectedItemTextRef.current;if(!oe?.isConnected){let N=m.firstItemTextRef.current;oe=N?.isConnected?N:null}let se=m.valueRef.current,he=Io(D),H;try{let N=Ue(f),ne=f.ownerDocument,re=We(x),Q=N.getComputedStyle(f),me=N.getComputedStyle(D);H=wt({triggerRect:ve(x.getBoundingClientRect(),re),positionerRect:ve(f.getBoundingClientRect(),re),valueRect:se?ve(se.getBoundingClientRect(),re):null,textRect:oe?ve(oe.getBoundingClientRect(),re):null,scrollHeight:Y.scrollHeight,documentClientHeight:ne.documentElement.clientHeight,documentClientWidth:ne.documentElement.clientWidth,marginTop:Number.parseFloat(Q.marginTop)||_e,marginBottom:Number.parseFloat(Q.marginBottom)||_e,minHeight:Number.parseFloat(Q.minHeight)||Et,maxPopupHeight:Lt(me),borderBottom:Number.parseFloat(me.borderBottomWidth)||0,direction:R});let xe=(N.visualViewport?.scale??1)!==1&&Ro(N);if(H.fallback||xe){L(!1),w(!0);return}f.style.height=`${H.height}px`,D.style.height="100%",H.transformOrigin&&D.style.setProperty("--transform-origin",H.transformOrigin),Y.scrollTop=H.scrollTop,S.current=H.reachedMaxHeight,F.current=!0}finally{he()}ee({left:H.left,top:H.isTopPositioned?H.top:null,bottom:H.isTopPositioned?null:0,marginTop:H.marginTop,marginBottom:H.marginBottom}),w(!0)},[u,m,R]);C.useEffect(()=>{!i||!h||V||W()},[i,h,V,W]),C.useEffect(()=>{i&&!h&&J()},[i,h,J]),C.useEffect(()=>{if(!i||!h)return;let f=k.current,x=f?Ue(f):window,D=Y=>{u.setOpen(!1,He.none,Y)};return x.addEventListener("resize",D),()=>{x.removeEventListener("resize",D)}},[i,h,u]);let _=C.useCallback(f=>{let x=k.current,D=u.context.refs.popupRef.current;if(!x||!D||!F.current||S.current||!h)return;let Y=x.style.top==="0px",oe=x.style.bottom==="0px";if(!Y&&!oe)return;let se=Ue(x),he=x.ownerDocument,H=We(x),N=Vt(x.getBoundingClientRect().height,"y",H),ne=se.getComputedStyle(x),re=Number.parseFloat(ne.marginTop)||0,Q=Number.parseFloat(ne.marginBottom)||0,me=Lt(se.getComputedStyle(D)),xe=Math.min(he.documentElement.clientHeight-re-Q,me),le=Ht({isTopPositioned:Y,currentHeight:N,scrollTop:f.scrollTop,maxScrollTop:ge(f.scrollHeight,f.clientHeight),maxAvailableHeight:xe});switch(le.height!=null&&(x.style.height=`${le.height}px`),le.scroll.kind){case"set":f.scrollTop=le.scroll.value;break;case"max":{let X=ge(f.scrollHeight,f.clientHeight);Math.abs(f.scrollTop-X)>K&&(f.scrollTop=X);break}case"clamp":{let X=ge(f.scrollHeight,f.clientHeight),be=pe(le.scroll.value,0,X);Math.abs(f.scrollTop-be)>K&&(f.scrollTop=be);break}default:break}le.reachedMaxHeight&&(S.current=!0)},[u,h]);C.useEffect(()=>{if(!i||!h||!V)return;let f=u.context.refs.listRef.current;if(!f)return;let x=()=>_(f);return f.addEventListener("scroll",x,{passive:!0}),()=>{f.removeEventListener("scroll",x)}},[i,h,V,_,u]);let q=h?"none":s,T=C.useMemo(()=>({alignItemWithTriggerActive:h,side:q,align:r,scrollUpArrowRef:A,scrollDownArrowRef:ie,setAlignItemWithTriggerActive:L,resetPositioningState:B}),[h,q,r,B]),te=C.useCallback(f=>{k.current=f,typeof t=="function"?t(f):t&&(t.current=f)},[t]),U=i&&h&&!V,Z=h&&v?{position:"fixed",transform:"none",left:v.left,top:v.top??"auto",bottom:v.bottom??"auto",marginTop:v.marginTop,marginBottom:v.marginBottom,maxHeight:"none"}:{};return At(Be.Provider,{value:T,children:At(Po.Positioner,{ref:te,side:h?void 0:s,align:h?void 0:r,sideOffset:h?0:c,disableAnchorTracking:h||void 0,className:b,style:{...o,...Z,...U?{visibility:"hidden"}:{}},...h?{"data-side":"none","data-align":r}:{},[qe.slot]:"",...P,children:a})})});function Ue(e){return e.ownerDocument?.defaultView??window}function Lt(e){let n=e.maxHeight||"";return n.endsWith("px")&&Number.parseFloat(n)||Number.POSITIVE_INFINITY}function Ro(e){let n=e.navigator;return n?/AppleWebKit/.test(n.userAgent)&&!/Chrome|Chromium|Edg|OPR/.test(n.userAgent):!1}var kt=[["transform","none"],["scale","1"],["translate","0 0"]];function Io(e){let{style:n}=e,t={};for(let[l,s]of kt)t[l]=n.getPropertyValue(l),n.setProperty(l,s,"important");return()=>{for(let[l]of kt){let s=t[l];s?n.setProperty(l,s):n.removeProperty(l)}}}import{Popover as Co}from"@base-ui/react/popover";import*as I from"react";import{jsx as ye,jsxs as To}from"react/jsx-runtime";function Xe(e){let{open:n,onOpenChange:t,onOpenChangeComplete:l,actionsRef:s,defaultOpen:r=!1,value:c,defaultValue:b,onValueChange:o,multiple:a=!1,values:P,defaultValues:d,onValuesChange:m,isItemEqualToValue:R=bt,itemToStringLabel:u,itemToStringValue:i,name:p,form:g,required:M,disabled:L=!1,placeholder:h="Select...",items:V,modal:w=!0,closeOnOutsidePress:v="pointerdown",virtualized:ee=!1,virtualItems:k,onHighlightChange:A,debug:ie,children:S,...F}=e,J=I.useCallback((y,ue,Ee,Qt)=>A?.(y,Ee,Qt),[A]),B=I.useId(),W=I.useRef(null),_=I.useRef(null),q=I.useRef(null),T=I.useRef(null),te=I.useCallback(y=>{W.current=y},[]),U=I.useCallback(y=>{_.current=y},[]),Z=I.useRef(null),f=I.useCallback(y=>(Z.current=y,()=>{Z.current=null}),[]),{store:x,focusOwnerStore:D,openChainStore:Y,registerSurface:oe,closeAll:se,virtualization:he,handleOpenChange:H,disabled:N,setDisabled:ne,menuTreeResolver:re}=tt({onOpenChange:t,defaultOpen:r,virtualized:ee,items:k,onHighlightChange:J,closeOnOutsidePress:v,disabled:L}),Q=I.useRef(null);I.useImperativeHandle(s,()=>({close:()=>{Q.current?.close()},unmount:()=>{Q.current?.unmount()},setDisabled:ne}),[ne]),x.useControlledProp("openProp",n);let me=x.useState("open"),[xe,le]=I.useState(b!==void 0?b:null),X=c!==void 0?c:xe,be=I.useCallback(y=>{c===void 0&&le(y),o?.(y)},[c,o]),[Yt,Xt]=I.useState(d??[]),Pe=P!==void 0?P:Yt,Ze=I.useCallback(y=>{P===void 0&&Xt(y),m?.(y)},[P,m]),Qe=I.useRef(new Map),et=I.useCallback((y,ue)=>(Qe.current.set(y,ue),()=>{}),[]),$t=I.useMemo(()=>({multiple:a,value:X,values:Pe,onValueChange:be,onValuesChange:Ze,isItemEqualToValue:R,itemToStringLabel:u,itemToStringValue:i,name:p,form:g,required:M,disabled:N,placeholder:h,items:V,itemTextRegistry:Qe.current,registerItemText:et,listId:B,triggerRef:W,valueRef:_,selectedItemTextRef:q,firstItemTextRef:T,setTriggerElement:te,setValueElement:U,registerResetPositioningCallback:f}),[a,X,Pe,be,Ze,R,u,i,p,g,M,N,h,V,et,B,te,U,f]),Kt=I.useMemo(()=>p?a?Pe.length>0?Pe.map((y,ue)=>{let Ee=z(y,i);return ye("input",{type:"hidden",name:p,value:Ee,form:g,required:M&&ue===0},Ee)}):ye("input",{type:"hidden",name:p,value:"",form:g,required:M}):ye("input",{type:"hidden",name:p,value:X!=null?z(X,i):"",form:g,required:M}):null,[p,g,M,a,X,Pe,i]),Jt=I.useCallback((y,ue)=>{H(y,ue.reason,ue.event)},[H]),Zt=I.useCallback(y=>{!y&&x.context.clearSearchOnClose==="after-exit"&&(x.clearSearch(),x.setInputActive(!1)),y||(x.clearHighlight(),Z.current?.(),T.current=null),l?.(y)},[x,l]);return ye(Le.Provider,{value:$t,children:To(at,{menuTreeResolver:re,store:x,focusOwnerStore:D,openChainStore:Y,disabled:N,depth:0,closeAll:se,registerSurface:oe,virtualization:he,menuType:"dropdown",closeOnOutsidePress:v,componentName:"select",debug:ie,children:[Kt,ye(Co.Root,{...F,open:me,onOpenChange:Jt,onOpenChangeComplete:Zt,modal:w,actionsRef:s?Q:void 0,children:S})]})})}import*as De from"react";var Ot={slot:"bazzaui-select-surface"};import{jsx as Mo}from"react/jsx-runtime";var $e=De.forwardRef(function(n,t){let{autoHighlightFirst:l,...s}=n,r=O(),c=Ve(),b=De.useMemo(()=>{let o=a=>de(a)?!0:z(a,r.itemToStringValue);if(l==="selected"){let a=r.multiple?r.values[0]:r.value;return o(a)}if(l!==void 0)return l;if(c?.alignItemWithTriggerActive){let a=r.multiple?r.values[0]:r.value;return o(a)}return!0},[l,c?.alignItemWithTriggerActive,r.multiple,r.value,r.values,r.itemToStringValue]);return Mo(gt,{ref:t,autoHighlightFirst:b,[Ot.slot]:"",...s})});import{Popover as Vo}from"@base-ui/react/popover";import{useRender as vo}from"@base-ui/react/use-render";import*as G from"react";var Se={slot:"bazzaui-select-trigger",open:"data-open",closed:"data-closed",disabled:"data-disabled",placeholder:"data-placeholder"};import{jsx as Dt}from"react/jsx-runtime";var yo={open:e=>e?{[Se.open]:""}:null,disabled:e=>e?{[Se.disabled]:""}:null,placeholder:e=>e?{[Se.placeholder]:""}:null},Eo=G.forwardRef(function(n,t){let{render:l,children:s,disabled:r,className:c,style:b,triggerProps:o,triggerState:a,...P}=n,d=O(),m=r??d.disabled,R=d.multiple?d.values.length>0:!de(d.value),u=G.useMemo(()=>({open:a.open,disabled:m,placeholder:!R}),[a.open,m,R]),i=G.useCallback(p=>{d.setTriggerElement(p)},[d]);return vo({render:l,ref:t,state:u,stateAttributesMapping:yo,props:{...xt(o,{...P,className:c,style:b,children:s}),[Se.slot]:"",ref:i,role:"combobox","aria-haspopup":"listbox","aria-controls":d.listId},defaultTagName:"button"})}),Ke=G.forwardRef(function(n,t){let{disabled:l,...s}=n,r=O(),c=we(),{store:b,closeAll:o,closeOnOutsidePress:a}=c,P=(l??r.disabled)||c.disabled,d=b.useState("open"),m=G.useRef(null),R=G.useCallback(u=>{m.current=u,typeof t=="function"?t(u):t&&(t.current=u)},[t]);return G.useEffect(()=>{let u=m.current;if(!u||a!=="pointerdown")return;let i=p=>{d&&(o(He.triggerPress,p),u.addEventListener("click",g=>{g.stopPropagation(),g.preventDefault()},{once:!0,capture:!0}))};return u.addEventListener("pointerdown",i,!0),()=>{u.removeEventListener("pointerdown",i,!0)}},[d,o,a]),Dt(Vo.Trigger,{ref:R,disabled:P,render:(u,i)=>Dt(Eo,{...s,disabled:P,triggerProps:u,triggerState:i,ref:u.ref})})});import{useRender as wo}from"@base-ui/react/use-render";import*as ae from"react";var Ne={slot:"bazzaui-select-value",placeholder:"data-placeholder",multiple:"data-multiple"};var Ho={hasValue:e=>e?null:{[Ne.placeholder]:""},multiple:e=>e?{[Ne.multiple]:""}:null,getValueText:()=>null};function Lo(e,n){let{render:t,className:l,style:s,placeholder:r,children:c,...b}=e,o=O(),a=r??o.placeholder,P=ae.useMemo(()=>Re(o.items,""),[o.items]),d=r??P??a,m=o.multiple?o.values.length>0:!de(o.value),R=ae.useCallback(g=>{let M=z(g,o.itemToStringValue),L=o.itemTextRegistry.get(M);if(L!==void 0)return L;let h=Re(o.items,M);if(h!==void 0)return h;let V=fe(g,o.itemToStringLabel);if(V&&V!==M)return V},[o.itemTextRegistry,o.items,o.itemToStringLabel,o.itemToStringValue]),u=ae.useMemo(()=>({value:o.value,values:o.values,multiple:o.multiple,hasValue:m,placeholder:a,getValueText:R}),[o.value,o.values,o.multiple,m,a,R]),i;if(typeof c=="function")i=c(u);else if(c!==void 0)i=c;else if(!m)i=d;else if(o.multiple){let g=o.values.map(M=>{let L=R(M);return L!==void 0?L:fe(M,o.itemToStringLabel)||z(M,o.itemToStringValue)}).filter(Boolean);i=g.length>2?`${g.length} selected`:g.join(", ")}else{let g=o.value;if(g!=null){let M=R(g);M!==void 0?i=M:i=fe(g,o.itemToStringLabel)||z(g,o.itemToStringValue)}}let p=ae.useCallback(g=>{o.setValueElement(g)},[o]);return wo({render:t,ref:n,state:u,stateAttributesMapping:Ho,props:{...b,[Ne.slot]:"",ref:p,className:l,style:s,children:i},defaultTagName:"span"})}var Je=ae.forwardRef(Lo);var zt=(c=>(c.slot="bazzaui-select-arrow",c.open="data-open",c.closed="data-closed",c.side="data-side",c.align="data-align",c.uncentered="data-uncentered",c))(zt||{});var Gt=(r=>(r.slot="bazzaui-select-backdrop",r.open="data-open",r.closed="data-closed",r.startingStyle="data-starting-style",r.endingStyle="data-ending-style",r))(Gt||{});var Ft=(n=>(n.slot="bazzaui-select-empty",n))(Ft||{});var Bt=(n=>(n.slot="bazzaui-select-group",n))(Bt||{});var jt=(n=>(n.slot="bazzaui-select-group-label",n))(jt||{});var ko={slot:"bazzaui-select-icon",open:"data-popup-open"};var Wt=(l=>(l.slot="bazzaui-select-input",l.open="data-open",l.closed="data-closed",l))(Wt||{});var _t=(t=>(t.slot="bazzaui-select-list",t.list="data-popup-menu-list",t))(_t||{});var qt=(n=>(n.alignItemWithTrigger="data-align-item-with-trigger",n))(qt||{});var Ao={slotUp:"bazzaui-select-scroll-up-arrow",slotDown:"bazzaui-select-scroll-down-arrow",direction:"data-direction",side:"data-side"};var Ut=(n=>(n.slot="bazzaui-select-separator",n))(Ut||{});export{Nt as Select,zt as SelectArrowDataAttributes,Gt as SelectBackdropDataAttributes,Ft as SelectEmptyDataAttributes,Bt as SelectGroupDataAttributes,jt as SelectGroupLabelDataAttributes,ko as SelectIconDataAttributes,Wt as SelectInputDataAttributes,ze as SelectItem,$ as SelectItemDataAttributes,Ge as SelectItemIndicator,Me as SelectItemIndicatorDataAttributes,Fe as SelectItemLabel,io as SelectListCssVars,_t as SelectListDataAttributes,je as SelectPopup,qt as SelectPopupDataAttributes,Ye as SelectPositioner,ao as SelectPositionerCssVars,qe as SelectPositionerDataAttributes,Xe as SelectRoot,Ao as SelectScrollArrowDataAttributes,Ut as SelectSeparatorDataAttributes,lo as SelectStore,$e as SelectSurface,Ke as SelectTrigger,Se as SelectTriggerDataAttributes,Je as SelectValue,no as commandScore,ro as defaultFilter,so as useMaybeSelectContext,uo as useMaybeSelectItemContext,oo as useMaybeSurfaceContext,O as useSelectContext,Te as useSelectItemContext,Ve as useSelectPositionerContext,to as useSurfaceContext};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/select/index.parts.ts","../../src/select/item/item.tsx","../../src/select/contexts/select-context.ts","../../src/select/item/item.data-attrs.ts","../../src/select/item/item-context.ts","../../src/select/item-indicator/item-indicator.tsx","../../src/select/item-indicator/item-indicator.data-attrs.ts","../../src/select/item-label/item-label.tsx","../../src/select/item-label/item-label.data-attrs.ts","../../src/select/popup/popup.tsx","../../src/select/contexts/select-positioner-context.ts","../../src/select/positioner/positioner.tsx","../../src/utils/clamp.ts","../../src/utils/scale.ts","../../src/utils/scroll-edges.ts","../../src/select/positioner/alignment.ts","../../src/select/positioner/positioner.data-attrs.ts","../../src/select/root/root.tsx","../../src/select/surface/surface.tsx","../../src/select/surface/surface.data-attrs.ts","../../src/select/trigger/trigger.tsx","../../src/select/trigger/trigger.data-attrs.ts","../../src/select/value/value.tsx","../../src/select/value/value.data-attrs.ts","../../src/select/arrow/arrow.data-attrs.ts","../../src/select/backdrop/backdrop.data-attrs.ts","../../src/select/empty/empty.data-attrs.ts","../../src/select/group/group.data-attrs.ts","../../src/select/group-label/group-label.data-attrs.ts","../../src/select/icon/icon.data-attrs.ts","../../src/select/input/input.data-attrs.ts","../../src/select/list/list.data-attrs.ts","../../src/select/popup/popup.data-attrs.ts","../../src/select/scroll-arrow/scroll-arrow.data-attrs.ts","../../src/select/separator/separator.data-attrs.ts"],"sourcesContent":["// ============================================================================\n// Select Parts\n// ============================================================================\n// Re-exports shared components from internal/popup-menu with Select-specific\n// Root, Trigger, Value, Item, ItemLabel, and ItemIndicator components.\n\n// Re-export VirtualItem type from internal/listbox\nexport type { VirtualItem } from '../internal/listbox/index.js'\n\n// Re-export shared components from internal/popup-menu\nexport {\n PopupMenuArrow as Arrow,\n PopupMenuBackdrop as Backdrop,\n PopupMenuEmpty as Empty,\n // Structure\n PopupMenuGroup as Group,\n PopupMenuGroupLabel as GroupLabel,\n // Trigger components\n PopupMenuIcon as Icon,\n PopupMenuInput as Input,\n PopupMenuList as List,\n // Positioning & Container\n PopupMenuPortal as Portal,\n // Scroll indicators\n PopupMenuScrollDownArrow as ScrollDownArrow,\n PopupMenuScrollUpArrow as ScrollUpArrow,\n PopupMenuSeparator as Separator,\n} from '../internal/popup-menu/index.js'\nexport { SelectItem as Item } from './item/item.js'\nexport { SelectItemIndicator as ItemIndicator } from './item-indicator/item-indicator.js'\nexport { SelectItemLabel as ItemLabel } from './item-label/item-label.js'\n// Select-specific Popup with alignItemWithTriggerActive state\nexport type { SelectPopupProps, SelectPopupState } from './popup/popup.js'\nexport { SelectPopup as Popup } from './popup/popup.js'\n// Custom Select Positioner with alignItemWithTrigger support\nexport { SelectPositioner as Positioner } from './positioner/positioner.js'\n// Select-specific components\nexport { SelectRoot as Root } from './root/root.js'\n// Select-specific Surface with alignItemWithTrigger auto-highlight support\nexport { SelectSurface as Surface } from './surface/surface.js'\nexport { SelectTrigger as Trigger } from './trigger/trigger.js'\nexport { SelectValue as Value } from './value/value.js'\n","'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { usePopupMenuItem } from '../../internal/popup-menu/index.js'\nimport {\n compareItemEquality,\n itemIncludes,\n removeItem,\n} from '../../utils/item-equality.js'\nimport { mergeKeywords, resolveItemFromItems } from '../../utils/items.js'\nimport {\n resolveLabel,\n stringifyAsValue,\n} from '../../utils/resolve-value-label.js'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useSelectContext } from '../contexts/select-context.js'\nimport { SelectItemDataAttributes } from './item.data-attrs.js'\nimport {\n SelectItemContext,\n type SelectItemContextValue,\n} from './item-context.js'\n\nexport { SelectItemDataAttributes }\n\nexport interface SelectItemState extends Record<string, unknown> {\n /**\n * Whether the item is highlighted (via keyboard or pointer).\n */\n highlighted: boolean\n /**\n * Whether the item is disabled.\n */\n disabled: boolean\n /**\n * Whether the item is currently selected.\n */\n selected: boolean\n first: boolean\n last: boolean\n firstInGroup: boolean\n lastInGroup: boolean\n}\n\nexport interface SelectItemProps<Value = unknown>\n extends ComponentProps<'div', SelectItem.State> {\n /**\n * The value of this item. Required and must be unique within the Select.\n * Can be a primitive or an object.\n *\n * Pass `null` to render a clearable item: selecting it clears the selection\n * and its label is used as the trigger placeholder (Base UI parity).\n */\n value: Value | null\n\n /**\n * Text value to use for display in Select.Value when this item is selected.\n * If not provided, the text content of the item will be used.\n * For object values, this can be auto-detected from `{ label }` shape.\n */\n textValue?: string\n\n /**\n * Additional keywords to match against when filtering.\n * Useful for aliases or synonyms.\n */\n keywords?: string[]\n\n /**\n * Whether this item is disabled.\n * Disabled items are not selectable and are skipped during keyboard navigation.\n */\n disabled?: boolean\n\n /**\n * Callback when this item is selected.\n */\n onSelect?: () => void\n\n /**\n * Whether to force render this item regardless of filter results.\n * @default false\n */\n forceMount?: boolean\n}\n\nconst stateAttributesMapping = {\n highlighted: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.highlighted]: '' } : null,\n disabled: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.disabled]: '' } : null,\n selected: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.selected]: '' } : null,\n first: (value: unknown) =>\n value ? { [SelectItemDataAttributes.first]: '' } : null,\n last: (value: unknown) =>\n value ? { [SelectItemDataAttributes.last]: '' } : null,\n firstInGroup: (value: unknown) =>\n value ? { [SelectItemDataAttributes.firstInGroup]: '' } : null,\n lastInGroup: (value: unknown) =>\n value ? { [SelectItemDataAttributes.lastInGroup]: '' } : null,\n}\n\n/**\n * A selectable item in the select dropdown.\n * Renders a `<div>` element with role=\"option\".\n *\n * @template Value - The type of the item value (can be a primitive or object)\n */\nfunction SelectItemImpl<Value = unknown>(\n props: SelectItemProps<Value>,\n forwardedRef: React.ForwardedRef<HTMLDivElement>,\n) {\n const {\n value,\n textValue: textValueProp,\n keywords: keywordsProp,\n disabled = false,\n onSelect,\n forceMount = false,\n render,\n className,\n style,\n onClick,\n onPointerDown,\n onPointerMove,\n children,\n ...rest\n } = props\n\n const selectContext = useSelectContext<Value>()\n\n // Serialize value for registry key and internal lookups\n const serializedValue = React.useMemo(\n () => stringifyAsValue(value, selectContext.itemToStringValue),\n [value, selectContext.itemToStringValue],\n )\n\n // A null value serializes to '' which the listbox treats as \"no id\" and skips\n // registration. Give a clearable (null) item an explicit id so it still\n // registers and is selectable; its label still feeds filtering via keywords.\n const generatedItemId = React.useId()\n const listboxId =\n value === null ? `select-clear-${generatedItemId}` : undefined\n\n // Resolve the item entry (label + keywords) from the items prop, for\n // auto-populating textValue and filter keywords.\n const itemFromItems = React.useMemo(\n () => resolveItemFromItems(selectContext.items, serializedValue),\n [selectContext.items, serializedValue],\n )\n const labelFromItems = itemFromItems?.label\n\n // Auto-resolve label from object value shape { label }\n const labelFromObjectValue = React.useMemo(\n () => resolveLabel(value, selectContext.itemToStringLabel),\n [value, selectContext.itemToStringLabel],\n )\n\n // Auto-populate textValue: explicit prop > label from items (if string) > label from object > undefined\n const textValue = React.useMemo(() => {\n if (textValueProp !== undefined) return textValueProp\n if (typeof labelFromItems === 'string') return labelFromItems\n // For object values, use the resolved label\n if (labelFromObjectValue && labelFromObjectValue !== serializedValue) {\n return labelFromObjectValue\n }\n return undefined\n }, [textValueProp, labelFromItems, labelFromObjectValue, serializedValue])\n\n // Auto-add the label plus any items[].keywords to the filter keywords.\n const keywords = React.useMemo(() => {\n const labelStr =\n typeof labelFromItems === 'string'\n ? labelFromItems\n : labelFromObjectValue && labelFromObjectValue !== serializedValue\n ? labelFromObjectValue\n : undefined\n return mergeKeywords(keywordsProp, [\n labelStr,\n ...(itemFromItems?.keywords ?? []),\n ])\n }, [\n keywordsProp,\n labelFromItems,\n labelFromObjectValue,\n serializedValue,\n itemFromItems,\n ])\n\n const textRef = React.useRef<string | undefined>(textValue)\n\n // Track if this item is selected using custom equality.\n // A `null` item is selected when there is no selection; an empty string is\n // still treated as \"no selection\" and never matches an item.\n const selected = selectContext.multiple\n ? itemIncludes(\n selectContext.values,\n value,\n selectContext.isItemEqualToValue,\n )\n : selectContext.value !== '' &&\n compareItemEquality(\n selectContext.value,\n value,\n selectContext.isItemEqualToValue,\n )\n\n // Determine close behavior: single-select closes, multi-select stays open\n const closeOnClick = !selectContext.multiple\n\n const item = usePopupMenuItem({\n id: listboxId,\n value: serializedValue,\n keywords,\n disabled,\n forceMount,\n closeOnClick,\n children,\n })\n\n // Register the select handler that updates the value\n React.useEffect(() => {\n const handleSelect = () => {\n if (disabled) return\n\n if (selectContext.multiple) {\n // A null item clears all selections in multi-select mode.\n if (value == null) {\n selectContext.onValuesChange([])\n } else {\n // Toggle value in array using custom equality\n const newValues = selected\n ? removeItem(\n selectContext.values,\n value,\n selectContext.isItemEqualToValue,\n )\n : [...selectContext.values, value]\n selectContext.onValuesChange(newValues)\n }\n } else {\n // Set single value (null clears the selection)\n selectContext.onValueChange(value)\n }\n\n onSelect?.()\n }\n return item.registerSelect(handleSelect)\n }, [disabled, selectContext, value, selected, onSelect, item])\n\n // Register item text for Select.Value display\n React.useEffect(() => {\n // Use textValue if provided, otherwise extract from children\n const text = textRef.current\n if (text) {\n return selectContext.registerItemText(serializedValue, text)\n }\n }, [serializedValue, selectContext])\n\n // Update text ref when children might have changed (for extraction)\n React.useEffect(() => {\n if (!textValue && typeof children === 'string') {\n textRef.current = children\n selectContext.registerItemText(serializedValue, children)\n }\n }, [children, textValue, serializedValue, selectContext])\n\n const state: SelectItem.State = React.useMemo(\n () => ({\n highlighted: item.isHighlighted,\n disabled,\n selected,\n first: item.positional.first,\n last: item.positional.last,\n firstInGroup: item.positional.firstInGroup,\n lastInGroup: item.positional.lastInGroup,\n }),\n [item.isHighlighted, disabled, selected, item.positional],\n )\n\n const itemContextValue: SelectItemContextValue<Value> = React.useMemo(\n () => ({\n id: item.id,\n value,\n textValue,\n highlighted: item.isHighlighted,\n disabled,\n selected,\n }),\n [item.id, value, textValue, item.isHighlighted, disabled, selected],\n )\n\n // Merge user-provided handlers with item handlers\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n item.handlers.onClick(event)\n }\n },\n [onClick, item.handlers],\n )\n\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n item.handlers.onPointerDown(event)\n onPointerDown?.(event)\n },\n [item.handlers, onPointerDown],\n )\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n onPointerMove?.(event)\n if (!event.defaultPrevented) {\n item.handlers.onPointerMove(event)\n }\n },\n [onPointerMove, item.handlers],\n )\n\n const element = useRender({\n render,\n ref: [item.ref, item.rowRef, forwardedRef],\n state,\n stateAttributesMapping,\n props: {\n ...rest,\n [SelectItemDataAttributes.slot]: '',\n id: item.id,\n role: 'option',\n tabIndex: -1,\n 'aria-selected': selected,\n 'aria-disabled': disabled || undefined,\n className,\n style,\n onClick: handleClick,\n onPointerMove: handlePointerMove,\n onPointerDown: handlePointerDown,\n children,\n },\n enabled: item.isVisible,\n defaultTagName: 'div',\n })\n\n if (!item.isVisible) {\n return null\n }\n\n return (\n <SelectItemContext.Provider\n value={itemContextValue as SelectItemContextValue}\n >\n {element}\n </SelectItemContext.Provider>\n )\n}\n\nexport const SelectItem = React.forwardRef(SelectItemImpl) as <Value = unknown>(\n props: SelectItemProps<Value> & React.RefAttributes<HTMLDivElement>,\n) => React.ReactElement | null\n\nexport namespace SelectItem {\n export type State = SelectItemState\n export interface Props<Value = unknown> extends SelectItemProps<Value> {}\n}\n","'use client'\n\nimport * as React from 'react'\nimport type { ItemEqualityComparer } from '../../utils/item-equality.js'\nimport type { Items } from '../../utils/items.js'\n\n// ============================================================================\n// Select Context\n// ============================================================================\n// Provides value management and form integration for Select components.\n// Separate from PopupMenuContext to handle Select-specific concerns.\n\n/**\n * Item text registry for displaying selected values.\n * Maps serialized item value to its text content.\n */\nexport type ItemTextRegistry = Map<string, string>\n\n/**\n * Context value for Select components.\n * Provides value state, callbacks, and form integration.\n *\n * @template Value - The type of the select value (can be a primitive or object)\n */\nexport interface SelectContextValue<Value = unknown> {\n // ===== Selection State =====\n /** Whether multi-select mode is enabled */\n multiple: boolean\n /** Current selected value (single-select mode) */\n value: Value | null\n /** Current selected values (multi-select mode) */\n values: Value[]\n /** Callback when value changes (single-select mode; `null` clears it) */\n onValueChange: (value: Value | null) => void\n /** Callback when values change (multi-select mode) */\n onValuesChange: (values: Value[]) => void\n\n // ===== Object Value Support =====\n /**\n * Custom comparison logic used to determine if a select item value\n * matches the current selected value.\n * Useful when item values are objects without matching referentially.\n * Defaults to Object.is comparison.\n */\n isItemEqualToValue: ItemEqualityComparer<Value>\n /**\n * When the item values are objects, this function converts the object\n * value to a string representation for display in the trigger.\n * If the shape of the object is { value, label }, the label will be\n * used automatically without needing to specify this prop.\n */\n itemToStringLabel?: (itemValue: Value) => string\n /**\n * When the item values are objects, this function converts the object\n * value to a string representation for form submission.\n * If the shape of the object is { value, label }, the value will be\n * used automatically without needing to specify this prop.\n */\n itemToStringValue?: (itemValue: Value) => string\n\n // ===== Form Integration =====\n /** Form field name for submission */\n name?: string\n /** Associate with a form by ID */\n form?: string\n /** Whether this field is required */\n required?: boolean\n /** Whether the select is disabled */\n disabled: boolean\n /** Placeholder text when no value selected */\n placeholder: string\n\n // ===== Item Text Registry =====\n /** Registry of item values to their text content */\n itemTextRegistry: ItemTextRegistry\n /** Register an item's text content */\n registerItemText: (value: string, text: string) => () => void\n /**\n * Data structure of the items for label resolution.\n * Used to display labels before items mount (e.g., on initial render with defaultValue).\n * Can be a record mapping values to labels, or an array of\n * `{ value, label, keywords? }` objects.\n */\n items?: Items\n\n // ===== List ID for ARIA =====\n /** ID for the listbox element */\n listId: string\n\n // ===== Element Refs for Positioning =====\n /** Ref to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>\n /** Ref to the value display element (text in trigger) */\n valueRef: React.RefObject<HTMLElement | null>\n /** Ref to the selected item's text element */\n selectedItemTextRef: React.MutableRefObject<HTMLElement | null>\n /** Ref to the first item's text element (used when no selection for alignItemWithTrigger) */\n firstItemTextRef: React.MutableRefObject<HTMLElement | null>\n /** Callback to set the trigger element */\n setTriggerElement: (element: HTMLElement | null) => void\n /** Callback to set the value element */\n setValueElement: (element: HTMLElement | null) => void\n\n // ===== Positioner Callback Registration =====\n /** Register a callback to reset positioning state after close animation */\n registerResetPositioningCallback: (\n callback: (() => void) | null,\n ) => () => void\n}\n\nconst SelectContext = React.createContext<SelectContextValue<unknown> | null>(\n null,\n)\n\n/**\n * Hook to access the Select context.\n * Throws if used outside a Select.Root.\n */\nexport function useSelectContext<Value = unknown>(): SelectContextValue<Value> {\n const context = React.useContext(SelectContext)\n if (!context) {\n throw new Error('Select components must be used within a Select.Root')\n }\n return context as SelectContextValue<Value>\n}\n\n/**\n * Hook to optionally access the Select context.\n * Returns null if used outside a Select.Root.\n */\nexport function useMaybeSelectContext<\n Value = unknown,\n>(): SelectContextValue<Value> | null {\n return React.useContext(SelectContext) as SelectContextValue<Value> | null\n}\n\nexport { SelectContext }\n","export const SelectItemDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-item'}\n */\n slot: 'bazzaui-select-item',\n /**\n * Present when the item is highlighted via keyboard or pointer.\n */\n highlighted: 'data-highlighted',\n /**\n * Present when the item is disabled.\n */\n disabled: 'data-disabled',\n /**\n * Present when the item is currently selected.\n */\n selected: 'data-selected',\n /** Present when this row is the first visible list-level row (not inside a group). */\n first: 'data-first',\n /** Present when this row is the last visible list-level row (not inside a group). */\n last: 'data-last',\n /** Present when this row is the first visible row within its group. */\n firstInGroup: 'data-first-in-group',\n /** Present when this row is the last visible row within its group. */\n lastInGroup: 'data-last-in-group',\n} as const\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Select Item Context\n// ============================================================================\n// Provides select-specific item state to child components.\n\nexport interface SelectItemContextValue<Value = unknown> {\n /** Unique ID for this item (for DOM id attribute) */\n id: string\n /** The value of this item (`null` for a clearable item) */\n value: Value | null\n /** The text value/label for this item */\n textValue: string | undefined\n /** Whether the item is highlighted */\n highlighted: boolean\n /** Whether the item is disabled */\n disabled: boolean\n /** Whether the item is selected */\n selected: boolean\n}\n\nconst SelectItemContext = React.createContext<SelectItemContextValue | null>(\n null,\n)\n\nexport function useSelectItemContext<\n Value = unknown,\n>(): SelectItemContextValue<Value> {\n const context = React.useContext(SelectItemContext)\n if (!context) {\n throw new Error(\n 'Select.Item child components must be used within a Select.Item',\n )\n }\n return context as SelectItemContextValue<Value>\n}\n\nexport function useMaybeSelectItemContext<\n Value = unknown,\n>(): SelectItemContextValue<Value> | null {\n return React.useContext(\n SelectItemContext,\n ) as SelectItemContextValue<Value> | null\n}\n\nexport { SelectItemContext }\n","'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useSelectItemContext } from '../item/item-context.js'\nimport { SelectItemIndicatorDataAttributes } from './item-indicator.data-attrs.js'\n\nexport { SelectItemIndicatorDataAttributes }\n\nexport interface SelectItemIndicatorState extends Record<string, unknown> {\n /**\n * Whether the item is selected.\n */\n selected: boolean\n /**\n * Whether the item is highlighted (via keyboard or pointer).\n */\n highlighted: boolean\n}\n\nexport interface SelectItemIndicatorProps\n extends Omit<ComponentProps<'span', SelectItemIndicator.State>, 'children'> {\n /**\n * Whether to force render even when the item is not selected.\n * @default false\n */\n forceMount?: boolean\n\n /**\n * Whether to keep the element mounted even when not selected.\n * Unlike forceMount, this still conditionally renders children.\n * Useful for checkbox-style indicators where the container is always visible.\n * @default false\n */\n keepMounted?: boolean\n\n /**\n * Content to render. Can be a ReactNode or a function that receives state.\n */\n children?:\n | React.ReactNode\n | ((state: SelectItemIndicator.State) => React.ReactNode)\n}\n\nconst stateAttributesMapping = {\n selected: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemIndicatorDataAttributes.selected]: '' } : null,\n highlighted: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemIndicatorDataAttributes.highlighted]: '' } : null,\n}\n\n/**\n * Indicator that shows when the item is selected.\n * Typically renders a checkmark icon.\n * Only renders when the item is selected (unless forceMount or keepMounted is true).\n * Renders a `<span>` element.\n */\nexport const SelectItemIndicator = React.forwardRef<\n HTMLSpanElement,\n SelectItemIndicator.Props\n>(function SelectItemIndicator(props, forwardedRef) {\n const {\n render,\n className,\n style,\n forceMount = false,\n keepMounted = false,\n children,\n ...rest\n } = props\n\n const itemContext = useSelectItemContext()\n const selected = itemContext.selected\n const highlighted = itemContext.highlighted\n\n const state: SelectItemIndicator.State = React.useMemo(\n () => ({ selected, highlighted }),\n [selected, highlighted],\n )\n\n // Determine if we should render\n const shouldRender = forceMount || keepMounted || selected\n\n // For keepMounted, only render children when selected\n const content =\n typeof children === 'function'\n ? children(state)\n : keepMounted && !selected\n ? null\n : children\n\n const element = useRender({\n render,\n ref: forwardedRef,\n state,\n stateAttributesMapping,\n props: {\n ...rest,\n [SelectItemIndicatorDataAttributes.slot]: '',\n 'aria-hidden': true,\n className,\n style,\n children: content,\n },\n defaultTagName: 'span',\n })\n\n if (!shouldRender) {\n return null\n }\n\n return element\n})\n\nexport namespace SelectItemIndicator {\n export interface Props extends SelectItemIndicatorProps {}\n export type State = SelectItemIndicatorState\n}\n","export const SelectItemIndicatorDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-item-indicator'}\n */\n slot: 'bazzaui-select-item-indicator',\n /**\n * Present when the parent item is selected.\n */\n selected: 'data-selected',\n /**\n * Present when the parent item is highlighted via keyboard or pointer.\n */\n highlighted: 'data-highlighted',\n} as const\n","'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { resolveLabelFromItems } from '../../utils/items.js'\nimport { stringifyAsValue } from '../../utils/resolve-value-label.js'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useSelectContext } from '../contexts/select-context.js'\nimport { useSelectItemContext } from '../item/item-context.js'\nimport { SelectItemLabelDataAttributes } from './item-label.data-attrs.js'\n\nexport { SelectItemLabelDataAttributes }\n\nexport interface SelectItemLabelState extends Record<string, unknown> {\n /**\n * The serialized string key for the parent item's value.\n * For object values, this is the result of `itemToStringValue` or the auto-detected `.value` property.\n */\n value: string\n /**\n * Whether the parent item is selected.\n */\n selected: boolean\n /**\n * Whether the parent item is highlighted.\n */\n highlighted: boolean\n /**\n * Whether the parent item is disabled.\n */\n disabled: boolean\n}\n\nexport interface SelectItemLabelProps\n extends ComponentProps<'span', SelectItemLabel.State> {}\n\n/**\n * The label/text content of a Select.Item.\n *\n * When no children are provided, automatically renders the label from the\n * `items` prop passed to `Select.Root`. If children are provided, they\n * override the automatic label.\n *\n * Also captures the text for display in `Select.Value` when the item is selected,\n * and provides the text element reference for `alignItemWithTrigger` positioning.\n *\n * Renders a `<span>` element.\n */\nexport const SelectItemLabel = React.forwardRef<\n HTMLSpanElement,\n SelectItemLabel.Props\n>(function SelectItemLabel(props, forwardedRef) {\n const { render, className, style, children, ...rest } = props\n\n const selectContext = useSelectContext()\n const itemContext = useSelectItemContext()\n const textRef = React.useRef<HTMLSpanElement | null>(null)\n\n // Serialize the item value to a string key for registry lookups\n const valueKey = stringifyAsValue(\n itemContext.value,\n selectContext.itemToStringValue,\n )\n\n // Resolve label content:\n // 1. Explicit children (override)\n // 2. Label from items prop lookup\n // 3. textValue from item context\n // 4. Fall back to the serialized value key\n const resolvedLabel = React.useMemo(() => {\n if (children !== undefined) {\n return children\n }\n\n const labelFromItems = resolveLabelFromItems(selectContext.items, valueKey)\n if (labelFromItems !== undefined) {\n return labelFromItems\n }\n\n if (itemContext.textValue !== undefined) {\n return itemContext.textValue\n }\n\n return valueKey\n }, [children, selectContext.items, valueKey, itemContext.textValue])\n\n // Build state for render prop and className/style functions\n const state: SelectItemLabel.State = React.useMemo(\n () => ({\n value: valueKey,\n selected: itemContext.selected,\n highlighted: itemContext.highlighted,\n disabled: itemContext.disabled,\n }),\n [\n valueKey,\n itemContext.selected,\n itemContext.highlighted,\n itemContext.disabled,\n ],\n )\n\n // Register the text content when mounted (for Select.Value display)\n React.useEffect(() => {\n if (typeof resolvedLabel === 'string') {\n return selectContext.registerItemText(valueKey, resolvedLabel)\n }\n }, [resolvedLabel, selectContext, valueKey])\n\n // Merge refs - need to track for positioning AND pass to useRender\n const mergedRef = React.useCallback(\n (node: HTMLSpanElement | null) => {\n textRef.current = node\n\n // Register this element as the selected item text for alignItemWithTrigger positioning\n if (itemContext.selected && node) {\n selectContext.selectedItemTextRef.current = node\n }\n\n // Register as the first item text for alignment fallback\n // Only set if not already set - first non-disabled item to render wins\n // The positioner will prefer selectedItemTextRef over firstItemTextRef\n if (node && !itemContext.disabled) {\n if (!selectContext.firstItemTextRef.current) {\n selectContext.firstItemTextRef.current = node\n }\n }\n },\n [itemContext.selected, itemContext.disabled, selectContext],\n )\n\n return useRender({\n render,\n ref: forwardedRef,\n state,\n props: {\n ...rest,\n [SelectItemLabelDataAttributes.slot]: '',\n ref: mergedRef,\n className,\n style,\n children: resolvedLabel,\n },\n defaultTagName: 'span',\n })\n})\n\nexport namespace SelectItemLabel {\n export interface Props extends SelectItemLabelProps {}\n export type State = SelectItemLabelState\n}\n","export const SelectItemLabelDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-item-label'}\n */\n slot: 'bazzaui-select-item-label',\n} as const\n","'use client'\n\nimport * as React from 'react'\nimport {\n PopupMenuPopup,\n type PopupMenuPopupState,\n} from '../../internal/popup-menu/components/popup/popup.js'\nimport type { ComponentRenderFn } from '../../utils/types.js'\nimport { useSelectPositionerContext } from '../contexts/select-positioner-context.js'\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface SelectPopupState extends Omit<PopupMenuPopupState, 'side'> {\n /**\n * Side the popup is placed on relative to the trigger.\n *\n * Reports `'none'` while `alignItemWithTrigger` positioning is active, because\n * the popup overlaps the trigger and therefore has no physical side. This\n * mirrors Base UI's behavior instead of leaking the `'bottom'` fallback that\n * the underlying Popover computes when no side is provided.\n */\n side: PopupMenuPopupState['side'] | 'none'\n\n /**\n * Whether the popup is currently using align-item-with-trigger positioning.\n * This reflects the actual state, not just the prop value - it will be false\n * if alignment couldn't be applied (e.g., not enough space, no selected item).\n */\n alignItemWithTriggerActive: boolean\n}\n\nexport interface SelectPopupProps\n extends Omit<PopupMenuPopup.Props, 'className' | 'render'> {\n /**\n * CSS class applied to the element, or a function that\n * returns a class based on the component's state.\n */\n className?: string | ((state: SelectPopupState) => string)\n\n /**\n * Allows replacing the popup element with a custom element.\n * The render state includes Select-specific alignment state.\n */\n render?:\n | React.ReactElement\n | ComponentRenderFn<React.HTMLAttributes<HTMLElement>, SelectPopupState>\n}\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * A container for the select popup contents.\n * Extends PopupMenuPopup with Select-specific state including alignItemWithTriggerActive.\n *\n * Renders a `<div>` element.\n */\nexport const SelectPopup = React.forwardRef<HTMLDivElement, SelectPopup.Props>(\n function SelectPopup(props, forwardedRef) {\n const { className: classNameProp, render: renderProp, ...rest } = props\n\n // Get positioner context for alignItemWithTriggerActive\n const positionerContext = useSelectPositionerContext()\n const alignItemWithTriggerActive =\n positionerContext?.alignItemWithTriggerActive ?? false\n const align = positionerContext?.align\n\n // Extend the base popup state with Select-specific fields. While alignment\n // is active the popup overlaps the trigger, so there is no physical side -\n // surface `'none'` instead of the Popover's `'bottom'` fallback.\n const extendState = React.useCallback(\n (baseState: PopupMenuPopupState): SelectPopupState => ({\n ...baseState,\n side: alignItemWithTriggerActive ? 'none' : baseState.side,\n alignItemWithTriggerActive,\n }),\n [alignItemWithTriggerActive],\n )\n\n // Wrap className to expose the extended Select state\n const className = React.useMemo(() => {\n if (typeof classNameProp === 'function') {\n return (baseState: PopupMenuPopupState) =>\n classNameProp(extendState(baseState))\n }\n return classNameProp\n }, [classNameProp, extendState])\n\n // Wrap render to expose the extended Select state\n const render = React.useMemo(() => {\n if (typeof renderProp === 'function') {\n return (\n renderProps: React.HTMLAttributes<HTMLElement>,\n baseState: PopupMenuPopupState,\n ) => renderProp(renderProps, extendState(baseState))\n }\n return renderProp\n }, [renderProp, extendState])\n\n return (\n <PopupMenuPopup\n ref={forwardedRef}\n className={className}\n render={render}\n data-align-item-with-trigger={\n alignItemWithTriggerActive ? '' : undefined\n }\n // When alignment is active, override the side/align data attributes the\n // underlying Popover derives from its state so the DOM matches the\n // `'none'` side we report. The key is omitted entirely when inactive to\n // avoid clobbering Popover's own `data-side`/`data-align` with\n // `undefined` (Base UI's prop merge does not skip undefined values).\n {...(alignItemWithTriggerActive\n ? { 'data-side': 'none', 'data-align': align }\n : {})}\n {...rest}\n />\n )\n },\n)\n\nexport namespace SelectPopup {\n export type Props = SelectPopupProps\n export type State = SelectPopupState\n}\n","'use client'\n\nimport * as React from 'react'\n\n// Types matching Base UI's positioning types\nexport type Side = 'top' | 'bottom' | 'left' | 'right'\nexport type Align = 'start' | 'center' | 'end'\n\n/**\n * Context value for Select Positioner.\n * Provides alignment state for coordinating positioning behavior.\n */\nexport interface SelectPositionerContextValue {\n /**\n * Whether alignItemWithTrigger is actively being used.\n * This may be false even if the prop is true (e.g., fallback scenarios).\n */\n alignItemWithTriggerActive: boolean\n\n /**\n * The rendered side of the popup (or 'none' when using align-item-with-trigger).\n */\n side: Side | 'none'\n\n /**\n * The rendered alignment of the popup.\n */\n align: Align\n\n /**\n * Ref for the scroll up arrow element.\n */\n scrollUpArrowRef: React.RefObject<HTMLDivElement | null>\n\n /**\n * Ref for the scroll down arrow element.\n */\n scrollDownArrowRef: React.RefObject<HTMLDivElement | null>\n\n /**\n * Callback to disable alignItemWithTrigger (fallback to normal positioning).\n */\n setAlignItemWithTriggerActive: (active: boolean) => void\n\n /**\n * Callback to reset positioning state after close animation completes.\n * This preserves positioning during exit animations.\n */\n resetPositioningState: () => void\n}\n\nconst SelectPositionerContext =\n React.createContext<SelectPositionerContextValue | null>(null)\n\n/**\n * Hook to access the Select Positioner context.\n * Returns null if used outside a SelectPositioner.\n */\nexport function useSelectPositionerContext(): SelectPositionerContextValue | null {\n return React.useContext(SelectPositionerContext)\n}\n\nexport { SelectPositionerContext }\n","'use client'\n\nimport { useDirection } from '@base-ui/react/internals/direction-context'\nimport { Popover, type PopoverPositionerProps } from '@base-ui/react/popover'\nimport * as React from 'react'\nimport { usePopupMenuContext } from '../../internal/popup-menu/contexts/popup-menu-context.js'\nimport { clamp } from '../../utils/clamp.js'\nimport { REASONS } from '../../utils/events/index.js'\nimport { getScale, normalizeRect, normalizeSize } from '../../utils/scale.js'\nimport {\n getMaxScrollOffset,\n SCROLL_EDGE_TOLERANCE_PX,\n} from '../../utils/scroll-edges.js'\nimport { useSelectContext } from '../contexts/select-context.js'\nimport {\n type Align,\n SelectPositionerContext,\n type SelectPositionerContextValue,\n type Side,\n} from '../contexts/select-positioner-context.js'\nimport {\n type AlignmentResult,\n computeAlignment,\n computeScrollGrowth,\n DEFAULT_MARGIN,\n DEFAULT_MIN_HEIGHT,\n} from './alignment.js'\nimport { SelectPositionerDataAttributes } from './positioner.data-attrs.js'\n\nexport { SelectPositionerDataAttributes }\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface SelectPositionerProps extends PopoverPositionerProps {\n /**\n * Whether the positioner overlaps the trigger so the selected item's text is\n * aligned with the trigger's value text (a native-select feel).\n *\n * Only applies to mouse/pen/keyboard input. When disabled, the popup falls\n * back to standard anchored positioning on the configured `side`. It is\n * automatically disabled when:\n * - the select is searchable — a `Select.Input` is present (a `hideUntilActive`\n * input counts once it activates), so the filtered list anchors to the\n * trigger like a combobox;\n * - the select was opened by touch (the full list is shown instead);\n * - the trigger is too close to a viewport edge; or\n * - there isn't enough room for a reasonably sized popup.\n *\n * @default true\n */\n alignItemWithTrigger?: boolean\n}\n\ninterface AlignmentPlacement {\n left: number\n top: number | null\n bottom: number | null\n marginTop: number\n marginBottom: number\n}\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * Positions the select popup against its trigger.\n *\n * When `alignItemWithTrigger` is active, the popup overlaps the trigger so the\n * selected item's text lines up with the trigger's value, the list is\n * pre-scrolled to that item, and the popup is sized/anchored to fit the\n * viewport (Base UI parity). Otherwise it delegates to the standard anchored\n * positioning of `Popover.Positioner`.\n *\n * Renders a `<div>` element.\n */\nexport const SelectPositioner = React.forwardRef<\n HTMLDivElement,\n SelectPositioner.Props\n>(function SelectPositioner(props, forwardedRef) {\n const {\n alignItemWithTrigger = true,\n side: sideProp = 'bottom',\n align: alignProp = 'start',\n sideOffset = 0,\n className,\n style,\n children,\n ...rest\n } = props\n\n const popupMenuContext = usePopupMenuContext()\n const selectContext = useSelectContext()\n const direction = useDirection() === 'rtl' ? 'rtl' : 'ltr'\n\n const store = popupMenuContext.store\n const open = store.useState('open')\n const openMethod = store.useState('openMethod')\n // True whenever a search input is actually rendered in the Surface (an\n // always-visible input, or a `hideUntilActive` input once it activates).\n const hasInput = store.useState('hasInput')\n\n // `controlled*` reflects the prop plus any runtime fallback to standard\n // positioning. Alignment additionally requires a non-touch open and no search\n // input present: once the list is searchable, the \"align selected item with\n // the trigger\" premise breaks down (the selection can be filtered out), so we\n // defer to standard anchored positioning (Base UI parity: Select aligns,\n // Combobox anchors).\n const [controlledAlignItemWithTrigger, setControlledAlignItemWithTrigger] =\n React.useState(alignItemWithTrigger)\n const alignItemWithTriggerActive =\n controlledAlignItemWithTrigger && openMethod !== 'touch' && !hasInput\n\n const [positioned, setPositioned] = React.useState(false)\n const [placement, setPlacement] = React.useState<AlignmentPlacement | null>(\n null,\n )\n\n const positionerRef = React.useRef<HTMLDivElement | null>(null)\n const scrollUpArrowRef = React.useRef<HTMLDivElement | null>(null)\n const scrollDownArrowRef = React.useRef<HTMLDivElement | null>(null)\n const reachedMaxHeightRef = React.useRef(false)\n const initialPlacedRef = React.useRef(false)\n\n // Remove the imperative styles we apply during alignment so the element can\n // return to standard positioning (on fallback or after close).\n const clearImperativeStyles = React.useCallback(() => {\n const positioner = positionerRef.current\n const popup = store.context.refs.popupRef.current\n if (positioner) {\n positioner.style.height = ''\n }\n if (popup) {\n popup.style.height = ''\n popup.style.removeProperty('--transform-origin')\n }\n reachedMaxHeightRef.current = false\n initialPlacedRef.current = false\n }, [store])\n\n // Reset after the close animation completes so positioning is preserved\n // during the exit transition.\n const resetPositioningState = React.useCallback(() => {\n clearImperativeStyles()\n setControlledAlignItemWithTrigger(alignItemWithTrigger)\n setPositioned(false)\n setPlacement(null)\n }, [alignItemWithTrigger, clearImperativeStyles])\n\n React.useEffect(() => {\n const cleanup = selectContext.registerResetPositioningCallback(\n resetPositioningState,\n )\n return cleanup\n }, [selectContext, resetPositioningState])\n\n // Measure, compute, and apply the aligned placement.\n const runAlignment = React.useCallback(() => {\n // A search input registered after this pass was scheduled (e.g. an\n // always-visible input mounting on open): skip aligning and let the bail\n // effect hand off to anchored positioning.\n if (store.state.hasInput) {\n return\n }\n\n const positioner = positionerRef.current\n const trigger = selectContext.triggerRef.current\n const popup = store.context.refs.popupRef.current\n const scroller = store.context.refs.listRef.current\n\n if (!positioner || !trigger || !popup || !scroller) {\n return\n }\n\n // Prefer the selected item's text; fall back to the first item when there\n // is no selection. Re-validate connectedness (items may have remounted).\n let textElement = selectContext.selectedItemTextRef.current\n if (!textElement?.isConnected) {\n const firstItemText = selectContext.firstItemTextRef.current\n textElement = firstItemText?.isConnected ? firstItemText : null\n }\n const valueElement = selectContext.valueRef.current\n\n // Neutralize any popup transform (entry animation / starting-style) so\n // measured geometry isn't skewed.\n const restoreTransforms = unsetTransformStyles(popup)\n\n let result: AlignmentResult\n try {\n const win = ownerWindow(positioner)\n const doc = positioner.ownerDocument\n const scale = getScale(trigger)\n\n const positionerStyles = win.getComputedStyle(positioner)\n const popupStyles = win.getComputedStyle(popup)\n\n result = computeAlignment({\n triggerRect: normalizeRect(trigger.getBoundingClientRect(), scale),\n positionerRect: normalizeRect(\n positioner.getBoundingClientRect(),\n scale,\n ),\n valueRect: valueElement\n ? normalizeRect(valueElement.getBoundingClientRect(), scale)\n : null,\n textRect: textElement\n ? normalizeRect(textElement.getBoundingClientRect(), scale)\n : null,\n scrollHeight: scroller.scrollHeight,\n documentClientHeight: doc.documentElement.clientHeight,\n documentClientWidth: doc.documentElement.clientWidth,\n marginTop:\n Number.parseFloat(positionerStyles.marginTop) || DEFAULT_MARGIN,\n marginBottom:\n Number.parseFloat(positionerStyles.marginBottom) || DEFAULT_MARGIN,\n minHeight:\n Number.parseFloat(positionerStyles.minHeight) || DEFAULT_MIN_HEIGHT,\n maxPopupHeight: getMaxPopupHeight(popupStyles),\n borderBottom: Number.parseFloat(popupStyles.borderBottomWidth) || 0,\n direction,\n })\n\n // Safari mispositions fixed popups while pinch-zoomed; fall back.\n const isPinchZoomed =\n (win.visualViewport?.scale ?? 1) !== 1 && isWebkit(win)\n\n if (result.fallback || isPinchZoomed) {\n setControlledAlignItemWithTrigger(false)\n setPositioned(true)\n return\n }\n\n // Imperative styles: height/scroll are mutated here (and, later, on\n // scroll) and must not be owned by React's style reconciliation.\n positioner.style.height = `${result.height}px`\n popup.style.height = '100%'\n if (result.transformOrigin) {\n popup.style.setProperty('--transform-origin', result.transformOrigin)\n }\n scroller.scrollTop = result.scrollTop\n reachedMaxHeightRef.current = result.reachedMaxHeight\n initialPlacedRef.current = true\n } finally {\n restoreTransforms()\n }\n\n setPlacement({\n left: result.left,\n top: result.isTopPositioned ? result.top : null,\n bottom: result.isTopPositioned ? null : 0,\n marginTop: result.marginTop,\n marginBottom: result.marginBottom,\n })\n setPositioned(true)\n }, [store, selectContext, direction])\n\n // Initial alignment once the popup is open. We use a passive effect (not\n // layout) because the popup/list elements register with the store in their\n // own effects, which run before this parent effect; `visibility: hidden`\n // keeps the measuring pass from flashing.\n React.useEffect(() => {\n if (!open || !alignItemWithTriggerActive || positioned) {\n return\n }\n runAlignment()\n }, [open, alignItemWithTriggerActive, positioned, runAlignment])\n\n // When a search input appears while open (always-visible on open, or a\n // `hideUntilActive` input activating), alignment switches off. Clear the\n // imperative styles from any aligned pass so the handoff to standard anchored\n // positioning is clean.\n React.useEffect(() => {\n if (open && !alignItemWithTriggerActive) {\n clearImperativeStyles()\n }\n }, [open, alignItemWithTriggerActive, clearImperativeStyles])\n\n // Aligned, fixed-position popups don't track the anchor; a viewport resize\n // would leave them stale, so close instead (Base UI parity).\n React.useEffect(() => {\n if (!open || !alignItemWithTriggerActive) {\n return\n }\n const positioner = positionerRef.current\n const win = positioner ? ownerWindow(positioner) : window\n const handleResize = (event: UIEvent) => {\n store.setOpen(false, REASONS.none, event)\n }\n win.addEventListener('resize', handleResize)\n return () => {\n win.removeEventListener('resize', handleResize)\n }\n }, [open, alignItemWithTriggerActive, store])\n\n // Grow the popup toward the viewport edge as the user scrolls (native-select\n // feel): scroll input first expands the popup until it reaches the maximum\n // available height, after which it scrolls normally. Mutates height/scrollTop\n // imperatively so there's no re-render per scroll frame.\n const handleScroll = React.useCallback(\n (scroller: HTMLElement) => {\n const positioner = positionerRef.current\n const popup = store.context.refs.popupRef.current\n if (!positioner || !popup || !initialPlacedRef.current) {\n return\n }\n // Once fully grown (or no longer aligned), the list scrolls normally.\n if (reachedMaxHeightRef.current || !alignItemWithTriggerActive) {\n return\n }\n\n const isTopPositioned = positioner.style.top === '0px'\n const isBottomPositioned = positioner.style.bottom === '0px'\n if (!isTopPositioned && !isBottomPositioned) {\n return\n }\n\n const win = ownerWindow(positioner)\n const doc = positioner.ownerDocument\n const scale = getScale(positioner)\n const currentHeight = normalizeSize(\n positioner.getBoundingClientRect().height,\n 'y',\n scale,\n )\n const positionerStyles = win.getComputedStyle(positioner)\n const marginTop = Number.parseFloat(positionerStyles.marginTop) || 0\n const marginBottom = Number.parseFloat(positionerStyles.marginBottom) || 0\n const maxPopupHeight = getMaxPopupHeight(win.getComputedStyle(popup))\n const maxAvailableHeight = Math.min(\n doc.documentElement.clientHeight - marginTop - marginBottom,\n maxPopupHeight,\n )\n\n const result = computeScrollGrowth({\n isTopPositioned,\n currentHeight,\n scrollTop: scroller.scrollTop,\n maxScrollTop: getMaxScrollOffset(\n scroller.scrollHeight,\n scroller.clientHeight,\n ),\n maxAvailableHeight,\n })\n\n if (result.height != null) {\n positioner.style.height = `${result.height}px`\n }\n\n switch (result.scroll.kind) {\n case 'set':\n scroller.scrollTop = result.scroll.value\n break\n case 'max': {\n const nextMax = getMaxScrollOffset(\n scroller.scrollHeight,\n scroller.clientHeight,\n )\n if (\n Math.abs(scroller.scrollTop - nextMax) > SCROLL_EDGE_TOLERANCE_PX\n ) {\n scroller.scrollTop = nextMax\n }\n break\n }\n case 'clamp': {\n const nextMax = getMaxScrollOffset(\n scroller.scrollHeight,\n scroller.clientHeight,\n )\n const target = clamp(result.scroll.value, 0, nextMax)\n if (\n Math.abs(scroller.scrollTop - target) > SCROLL_EDGE_TOLERANCE_PX\n ) {\n scroller.scrollTop = target\n }\n break\n }\n default:\n break\n }\n\n if (result.reachedMaxHeight) {\n reachedMaxHeightRef.current = true\n }\n },\n [store, alignItemWithTriggerActive],\n )\n\n // Drive the grow-on-scroll handler from the scroller's scroll events. The\n // existing scroll arrows nudge `scrollTop`, so they feed growth for free.\n React.useEffect(() => {\n if (!open || !alignItemWithTriggerActive || !positioned) {\n return\n }\n const scroller = store.context.refs.listRef.current\n if (!scroller) {\n return\n }\n const onScroll = () => handleScroll(scroller)\n scroller.addEventListener('scroll', onScroll, { passive: true })\n return () => {\n scroller.removeEventListener('scroll', onScroll)\n }\n }, [open, alignItemWithTriggerActive, positioned, handleScroll, store])\n\n const renderedSide: Side | 'none' = alignItemWithTriggerActive\n ? 'none'\n : (sideProp as Side)\n\n const contextValue: SelectPositionerContextValue = React.useMemo(\n () => ({\n alignItemWithTriggerActive,\n side: renderedSide,\n align: alignProp as Align,\n scrollUpArrowRef,\n scrollDownArrowRef,\n setAlignItemWithTriggerActive: setControlledAlignItemWithTrigger,\n resetPositioningState,\n }),\n [\n alignItemWithTriggerActive,\n renderedSide,\n alignProp,\n resetPositioningState,\n ],\n )\n\n const mergedRef = React.useCallback(\n (node: HTMLDivElement | null) => {\n positionerRef.current = node\n if (typeof forwardedRef === 'function') {\n forwardedRef(node)\n } else if (forwardedRef) {\n forwardedRef.current = node\n }\n },\n [forwardedRef],\n )\n\n // Hidden (but laid out) while measuring so the pass doesn't flash.\n const shouldHide = open && alignItemWithTriggerActive && !positioned\n\n // React-owned styles in alignment mode. These explicitly override the\n // anchored styles `Popover.Positioner` applies (position/transform/inset) so\n // there's no conflict; `height` is intentionally omitted (managed\n // imperatively above and on scroll).\n const alignmentStyles: React.CSSProperties =\n alignItemWithTriggerActive && placement\n ? {\n position: 'fixed',\n transform: 'none',\n left: placement.left,\n top: placement.top ?? 'auto',\n bottom: placement.bottom ?? 'auto',\n marginTop: placement.marginTop,\n marginBottom: placement.marginBottom,\n maxHeight: 'none',\n }\n : {}\n\n return (\n <SelectPositionerContext.Provider value={contextValue}>\n <Popover.Positioner\n ref={mergedRef}\n side={alignItemWithTriggerActive ? undefined : sideProp}\n align={alignItemWithTriggerActive ? undefined : alignProp}\n sideOffset={alignItemWithTriggerActive ? 0 : sideOffset}\n disableAnchorTracking={alignItemWithTriggerActive || undefined}\n className={className}\n style={{\n ...style,\n ...alignmentStyles,\n ...(shouldHide ? { visibility: 'hidden' } : {}),\n }}\n {...(alignItemWithTriggerActive\n ? { 'data-side': 'none', 'data-align': alignProp }\n : {})}\n {...{ [SelectPositionerDataAttributes.slot]: '' }}\n {...rest}\n >\n {children}\n </Popover.Positioner>\n </SelectPositionerContext.Provider>\n )\n})\n\nexport namespace SelectPositioner {\n export type Props = SelectPositionerProps\n export type State = Popover.Positioner.State\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\nfunction ownerWindow(node: Element): Window {\n return node.ownerDocument?.defaultView ?? window\n}\n\nfunction getMaxPopupHeight(popupStyles: CSSStyleDeclaration): number {\n const maxHeight = popupStyles.maxHeight || ''\n return maxHeight.endsWith('px')\n ? Number.parseFloat(maxHeight) || Number.POSITIVE_INFINITY\n : Number.POSITIVE_INFINITY\n}\n\nfunction isWebkit(win: Window): boolean {\n const nav = win.navigator\n if (!nav) {\n return false\n }\n return (\n /AppleWebKit/.test(nav.userAgent) &&\n !/Chrome|Chromium|Edg|OPR/.test(nav.userAgent)\n )\n}\n\nconst TRANSFORM_STYLE_RESETS = [\n ['transform', 'none'],\n ['scale', '1'],\n ['translate', '0 0'],\n] as const\n\n/**\n * Temporarily clear transform-related styles on an element so geometry reads\n * aren't affected by an in-flight transform. Returns a restore function.\n */\nfunction unsetTransformStyles(element: HTMLElement): () => void {\n const { style } = element\n const original: Record<string, string> = {}\n\n for (const [property, value] of TRANSFORM_STYLE_RESETS) {\n original[property] = style.getPropertyValue(property)\n style.setProperty(property, value, 'important')\n }\n\n return () => {\n for (const [property] of TRANSFORM_STYLE_RESETS) {\n const value = original[property]\n if (value) {\n style.setProperty(property, value)\n } else {\n style.removeProperty(property)\n }\n }\n }\n}\n","/**\n * Clamp a number to the inclusive range `[min, max]`.\n */\nexport function clamp(value: number, min: number, max: number): number {\n if (value < min) {\n return min\n }\n if (value > max) {\n return max\n }\n return value\n}\n","/**\n * The visual scale applied to an element by CSS `zoom` or a transformed\n * ancestor. Used to convert `getBoundingClientRect()` values (which are in\n * scaled, visual pixels) back into layout pixels so geometry math is correct\n * under zoom/transform.\n */\nexport interface Scale {\n x: number\n y: number\n}\n\n/**\n * A plain, fully-resolved rectangle (all of `x/y/width/height` plus the\n * derived edges), independent of the live `DOMRect`.\n */\nexport interface NormalizedRect {\n x: number\n y: number\n width: number\n height: number\n top: number\n right: number\n bottom: number\n left: number\n}\n\n/**\n * Compute an element's visual scale by comparing its rendered rect against its\n * layout `offsetWidth`/`offsetHeight`. Returns `{ x: 1, y: 1 }` when the\n * element has no layout box (so callers can divide safely).\n *\n * Mirrors Floating UI's `platform.getScale`, but dependency-free.\n */\nexport function getScale(element: HTMLElement): Scale {\n const rect = element.getBoundingClientRect()\n const { offsetWidth, offsetHeight } = element\n\n let x = offsetWidth > 0 ? Math.round(rect.width) / offsetWidth : 1\n let y = offsetHeight > 0 ? Math.round(rect.height) / offsetHeight : 1\n\n if (!Number.isFinite(x) || x === 0) {\n x = 1\n }\n if (!Number.isFinite(y) || y === 0) {\n y = 1\n }\n\n return { x, y }\n}\n\n/**\n * Convert a scaled size into layout pixels for the given axis.\n */\nexport function normalizeSize(\n size: number,\n axis: 'x' | 'y',\n scale: Scale,\n): number {\n return size / scale[axis]\n}\n\n/**\n * Convert a (possibly scaled) `DOMRect` into a {@link NormalizedRect} in layout\n * pixels using the supplied {@link Scale}.\n */\nexport function normalizeRect(\n rect: DOMRect | DOMRectReadOnly,\n scale: Scale,\n): NormalizedRect {\n const x = rect.x / scale.x\n const y = rect.y / scale.y\n const width = rect.width / scale.x\n const height = rect.height / scale.y\n\n return {\n x,\n y,\n width,\n height,\n top: y,\n left: x,\n right: x + width,\n bottom: y + height,\n }\n}\n","import { clamp } from './clamp.js'\n\n/**\n * Pixel tolerance used when comparing scroll offsets against their edges.\n * Sub-pixel rounding (zoom, fractional DPR) can leave a scroller a fraction\n * of a pixel away from a true edge; treat anything within this distance as\n * \"at the edge\".\n */\nexport const SCROLL_EDGE_TOLERANCE_PX = 1\n\n/**\n * The maximum scroll offset for a scroller, i.e. how far it can scroll on a\n * given axis. Never negative (content shorter than the viewport yields `0`).\n */\nexport function getMaxScrollOffset(\n scrollSize: number,\n clientSize: number,\n): number {\n return Math.max(0, scrollSize - clientSize)\n}\n\n/**\n * Normalize a scroll offset into `[0, max]`, snapping to an edge when within\n * {@link SCROLL_EDGE_TOLERANCE_PX} of it. When both edges are within tolerance\n * (a barely-scrollable scroller), snaps to whichever edge is closer.\n */\nexport function normalizeScrollOffset(value: number, max: number): number {\n if (max <= 0) {\n return 0\n }\n\n const clamped = clamp(value, 0, max)\n const startDistance = clamped\n const endDistance = max - clamped\n const withinStartTolerance = startDistance <= SCROLL_EDGE_TOLERANCE_PX\n const withinEndTolerance = endDistance <= SCROLL_EDGE_TOLERANCE_PX\n\n if (withinStartTolerance && withinEndTolerance) {\n return startDistance <= endDistance ? 0 : max\n }\n\n if (withinStartTolerance) {\n return 0\n }\n\n if (withinEndTolerance) {\n return max\n }\n\n return clamped\n}\n","import { clamp } from '../../utils/clamp.js'\nimport type { NormalizedRect } from '../../utils/scale.js'\nimport {\n getMaxScrollOffset,\n SCROLL_EDGE_TOLERANCE_PX,\n} from '../../utils/scroll-edges.js'\n\n// ============================================================================\n// Constants (Base UI parity)\n// ============================================================================\n\n/** Horizontal viewport padding kept between the popup and the viewport edges. */\nexport const ALIGNMENT_PADDING_X = 5\n/** Distance from a viewport edge within which we abandon alignment. */\nexport const TRIGGER_COLLISION_THRESHOLD = 20\n/** Default outer margins when the positioner has no explicit margin CSS. */\nexport const DEFAULT_MARGIN = 10\n/** Default minimum popup height before falling back to trigger alignment. */\nexport const DEFAULT_MIN_HEIGHT = 100\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface AlignmentInput {\n /** Scale-normalized rect of the trigger. */\n triggerRect: NormalizedRect\n /** Scale-normalized rect of the positioner (natural, pre-alignment). */\n positionerRect: NormalizedRect\n /** Scale-normalized rect of the trigger's value text, if available. */\n valueRect: NormalizedRect | null\n /** Scale-normalized rect of the item text to align (selected or first). */\n textRect: NormalizedRect | null\n /** Natural scroll height of the scroller (content height). */\n scrollHeight: number\n /** `document.documentElement.clientHeight`. */\n documentClientHeight: number\n /** `document.documentElement.clientWidth`. */\n documentClientWidth: number\n /** Resolved top margin (px). */\n marginTop: number\n /** Resolved bottom margin (px). */\n marginBottom: number\n /** Resolved minimum popup height (px). */\n minHeight: number\n /** Popup `max-height` in px, or `Infinity` when unconstrained. */\n maxPopupHeight: number\n /** Popup bottom border width (px). */\n borderBottom: number\n /** Writing direction. */\n direction: 'ltr' | 'rtl'\n}\n\nexport interface AlignmentResult {\n /** When true, alignment is not viable; fall back to trigger-anchored placement. */\n fallback: boolean\n /** Final clamped left in viewport pixels. */\n left: number\n /** Pin via `top` (true) or via `bottom: 0` (false). */\n isTopPositioned: boolean\n /** Top offset in px when {@link isTopPositioned}. */\n top: number\n /** Final popup height in px. */\n height: number\n /** Scroll offset to apply to the scroller so the item aligns with the trigger. */\n scrollTop: number\n /** Resolved top margin (px). */\n marginTop: number\n /** Resolved bottom margin (px). */\n marginBottom: number\n /** Whether the popup opened at its maximum height (no room to grow on scroll). */\n reachedMaxHeight: boolean\n /** Value for the popup `--transform-origin`, or `null` when not computed. */\n transformOrigin: string | null\n}\n\n// ============================================================================\n// Core computation (pure)\n// ============================================================================\n\n/**\n * Compute the overlap (\"align item with trigger\") placement for a select popup,\n * porting Base UI's `SelectPopup` geometry.\n *\n * Pure and deterministic: the scroller's client height is modeled as the\n * computed popup `height`, so no live DOM reads are required. The caller applies\n * the result and may refine `scrollTop` against the live scroller.\n */\nexport function computeAlignment(input: AlignmentInput): AlignmentResult {\n const {\n triggerRect,\n positionerRect,\n valueRect,\n textRect,\n scrollHeight,\n documentClientHeight,\n documentClientWidth,\n marginTop,\n marginBottom,\n minHeight,\n maxPopupHeight,\n borderBottom,\n direction,\n } = input\n\n const fallback = (): AlignmentResult => ({\n fallback: true,\n left: 0,\n isTopPositioned: false,\n top: 0,\n height: 0,\n scrollTop: 0,\n marginTop,\n marginBottom,\n reachedMaxHeight: false,\n transformOrigin: null,\n })\n\n const viewportHeight = documentClientHeight - marginTop - marginBottom\n const viewportWidth = documentClientWidth\n const triggerHeight = triggerRect.height\n const availableSpaceBeneathTrigger =\n viewportHeight - triggerRect.bottom + triggerHeight\n\n let alignedLeft =\n direction === 'rtl'\n ? triggerRect.right - positionerRect.width\n : triggerRect.left\n let offsetY = 0\n let textCenterY: number | null = null\n\n if (textRect && valueRect) {\n alignedLeft =\n positionerRect.left +\n (direction === 'rtl'\n ? valueRect.right - textRect.right\n : valueRect.left - textRect.left)\n\n const valueCenterFromTriggerTop =\n valueRect.top - triggerRect.top + valueRect.height / 2\n const textCenterFromPositionerTop =\n textRect.top - positionerRect.top + textRect.height / 2\n\n offsetY = textCenterFromPositionerTop - valueCenterFromTriggerTop\n textCenterY = textRect.top + textRect.height / 2\n }\n\n const idealHeight =\n availableSpaceBeneathTrigger + offsetY + marginBottom + borderBottom\n let height = Math.min(viewportHeight, idealHeight)\n // Faithful to Base UI: margins are subtracted again here (used only by the\n // top-positioned `top` heuristic below).\n const maxHeight = viewportHeight - marginTop - marginBottom\n const scrollTop = idealHeight - height\n\n const maxRight = viewportWidth - ALIGNMENT_PADDING_X\n const left = clamp(\n alignedLeft,\n ALIGNMENT_PADDING_X,\n maxRight - positionerRect.width,\n )\n\n // Model the scroller's client height as the applied popup height.\n const maxScrollTop = getMaxScrollOffset(scrollHeight, height)\n const isTopPositioned = scrollTop >= maxScrollTop - SCROLL_EDGE_TOLERANCE_PX\n\n if (isTopPositioned) {\n height =\n Math.min(viewportHeight, positionerRect.height) -\n (scrollTop - maxScrollTop)\n }\n\n // Bail to trigger-anchored placement when the trigger hugs a viewport edge or\n // the aligned popup would be shorter than the (content-capped) minimum.\n const triggerEdgeFallback =\n triggerRect.top < TRIGGER_COLLISION_THRESHOLD ||\n triggerRect.bottom > viewportHeight - TRIGGER_COLLISION_THRESHOLD ||\n Math.ceil(height) + SCROLL_EDGE_TOLERANCE_PX <\n Math.min(scrollHeight, minHeight)\n\n if (triggerEdgeFallback) {\n return fallback()\n }\n\n const initialHeight = Math.max(minHeight, height)\n\n // Base UI folds the bottom margin and the popup's bottom border into\n // `idealHeight`, which then drives the placement (`topOffset`/`scrollTop`).\n // That leaks into the vertical position: the aligned item lands off the\n // trigger value by exactly `marginTop - marginBottom - borderBottom` (e.g. 1px\n // too high for a popup with a 1px border and symmetric margins). Cancel that\n // here so the selected item's text lines up with the value pixel-for-pixel.\n // This is a no-op in the default case (no border, equal margins).\n const alignmentCorrection = marginBottom + borderBottom - marginTop\n\n let top = 0\n let finalScrollTop = scrollTop\n if (isTopPositioned) {\n const topOffset = Math.max(0, viewportHeight - idealHeight)\n top =\n positionerRect.height >= maxHeight\n ? 0\n : Math.max(0, topOffset + alignmentCorrection)\n finalScrollTop = maxScrollTop\n } else {\n finalScrollTop = Math.max(0, scrollTop - alignmentCorrection)\n }\n\n let transformOrigin: string | null = null\n if (textCenterY != null) {\n const popupTop = positionerRect.top\n const popupHeight = positionerRect.height\n const transformOriginY =\n popupHeight > 0 ? ((textCenterY - popupTop) / popupHeight) * 100 : 50\n transformOrigin = `50% ${clamp(transformOriginY, 0, 100)}%`\n }\n\n const reachedMaxHeight =\n initialHeight === viewportHeight || height >= maxPopupHeight\n\n return {\n fallback: false,\n left,\n isTopPositioned,\n top,\n height,\n scrollTop: finalScrollTop,\n marginTop,\n marginBottom,\n reachedMaxHeight,\n transformOrigin,\n }\n}\n\n// ============================================================================\n// Grow-on-scroll (pure)\n// ============================================================================\n\nexport interface ScrollGrowthInput {\n /** Whether the popup is pinned to the top edge (`top: 0`). */\n isTopPositioned: boolean\n /** Current popup height in px. */\n currentHeight: number\n /** Current scroller scroll offset. */\n scrollTop: number\n /** Current maximum scroll offset of the scroller. */\n maxScrollTop: number\n /** Maximum height the popup may grow to (viewport- and max-height-bound). */\n maxAvailableHeight: number\n}\n\n/** How the caller should adjust the scroller after resizing. */\nexport type ScrollGrowthIntent =\n | { kind: 'none' }\n /** Set `scrollTop` directly to `value`. */\n | { kind: 'set'; value: number }\n /** Set `scrollTop` to the scroller's (recomputed) maximum. */\n | { kind: 'max' }\n /** Set `scrollTop` to `clamp(value, 0, recomputedMax)`. */\n | { kind: 'clamp'; value: number }\n\nexport interface ScrollGrowthResult {\n /** New popup height in px, or `null` to leave it unchanged. */\n height: number | null\n /** Scroller adjustment to apply after resizing. */\n scroll: ScrollGrowthIntent\n /** Whether the popup has now reached its maximum height (latches scrolling). */\n reachedMaxHeight: boolean\n}\n\n/**\n * Decide how a scroll gesture should be split between *growing* the popup and\n * actually *scrolling* its content, while the popup is pinned to a viewport\n * edge and hasn't yet reached its maximum height. Ported from Base UI's\n * `SelectPopup` scroll handler.\n *\n * The caller must ensure the popup is edge-pinned (top or bottom) and that\n * {@link ScrollGrowthResult.reachedMaxHeight} hasn't already latched.\n */\nexport function computeScrollGrowth(\n input: ScrollGrowthInput,\n): ScrollGrowthResult {\n const {\n isTopPositioned,\n currentHeight,\n scrollTop,\n maxScrollTop,\n maxAvailableHeight,\n } = input\n\n const diff = isTopPositioned ? maxScrollTop - scrollTop : scrollTop\n\n // Tiny remaining gap: consume it as a final bit of growth and snap to the edge.\n if (diff <= SCROLL_EDGE_TOLERANCE_PX) {\n const heightDelta = clamp(diff, 0, maxAvailableHeight - currentHeight)\n const newHeight = currentHeight + heightDelta\n return {\n height: heightDelta > 0 ? newHeight : null,\n scroll: { kind: 'set', value: isTopPositioned ? maxScrollTop : 0 },\n reachedMaxHeight:\n maxAvailableHeight - newHeight <= SCROLL_EDGE_TOLERANCE_PX,\n }\n }\n\n const nextHeight = Math.min(currentHeight + diff, maxAvailableHeight)\n let scroll: ScrollGrowthIntent = { kind: 'none' }\n let reachedMax = false\n\n if (maxAvailableHeight - nextHeight > SCROLL_EDGE_TOLERANCE_PX) {\n // Still room to grow: keep the content anchored to the pinned edge.\n scroll = isTopPositioned ? { kind: 'max' } : { kind: 'clamp', value: 0 }\n } else {\n reachedMax = true\n if (!isTopPositioned && scrollTop < maxScrollTop) {\n // Consume the overshoot beyond max as real scrolling.\n const overshoot = currentHeight + diff - maxAvailableHeight\n scroll = { kind: 'clamp', value: scrollTop - (diff - overshoot) }\n }\n }\n\n const height = Math.ceil(nextHeight)\n\n return {\n height,\n scroll,\n reachedMaxHeight:\n reachedMax || height >= maxAvailableHeight - SCROLL_EDGE_TOLERANCE_PX,\n }\n}\n","export const SelectPositionerDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-positioner'}\n */\n slot: 'bazzaui-select-positioner',\n} as const\n","'use client'\n\nimport { Popover, type PopoverRootProps } from '@base-ui/react/popover'\nimport * as React from 'react'\nimport type { VirtualItem } from '../../internal/listbox/index.js'\nimport {\n type PopupMenuDebugOptions,\n type PopupMenuHighlightChangeHandler,\n PopupMenuProviders,\n type PopupMenuRootActions,\n type UsePopupMenuRootParams,\n usePopupMenuRoot,\n} from '../../internal/popup-menu/index.js'\nimport {\n defaultItemEquality,\n type ItemEqualityComparer,\n} from '../../utils/item-equality.js'\nimport type { Items } from '../../utils/items.js'\nimport { stringifyAsValue } from '../../utils/resolve-value-label.js'\nimport {\n type ItemTextRegistry,\n SelectContext,\n type SelectContextValue,\n} from '../contexts/select-context.js'\nimport type {\n SelectHighlightChangeEventDetails,\n SelectOpenChangeEventDetails,\n} from '../events.js'\n\n/**\n * Helper type to determine the value type based on the multiple flag.\n */\ntype SelectValue<\n Value,\n Multiple extends boolean | undefined,\n> = Multiple extends true ? Value[] : Value | null\n\nexport interface SelectRootProps<\n Value = unknown,\n Multiple extends boolean | undefined = false,\n> extends Omit<\n PopoverRootProps,\n 'open' | 'onOpenChange' | 'defaultOpen' | 'actionsRef'\n > {\n // ===== Open State =====\n /**\n * Whether the select is open.\n * Use for controlled mode.\n */\n open?: boolean\n\n /**\n * Callback when the open state changes.\n * The second parameter contains event details including the reason for the change.\n */\n onOpenChange?: (\n open: boolean,\n eventDetails: SelectOpenChangeEventDetails,\n ) => void\n\n /**\n * Callback called after any animations complete when the select opens or closes.\n * Useful for resetting state after exit animations finish.\n */\n onOpenChangeComplete?: (open: boolean) => void\n\n /**\n * A ref to imperative actions.\n * - `close`: closes the menu imperatively.\n * - `unmount`: unmounts the popup imperatively (when keep-mounted mode is enabled).\n * - `setDisabled`: enables/disables the menu imperatively.\n */\n actionsRef?: React.RefObject<SelectRoot.Actions | null>\n\n /**\n * Whether the select is initially open.\n * Use for uncontrolled mode.\n * @default false\n */\n defaultOpen?: boolean\n\n // ===== Single Selection =====\n /**\n * Current selected value (single-select mode).\n * Use for controlled mode.\n * Can be a primitive or an object.\n */\n value?: SelectValue<Value, Multiple>\n\n /**\n * Default selected value (single-select mode).\n * Use for uncontrolled mode.\n */\n defaultValue?: SelectValue<Value, Multiple>\n\n /**\n * Callback when the selected value changes (single-select mode).\n *\n * Note: when a clearable (`null`) item is selected, this is called with\n * `null` at runtime. If you use `null` items, handle that case.\n */\n onValueChange?: (value: Value) => void\n\n // ===== Multi Selection =====\n /**\n * Whether multi-select mode is enabled.\n * @default false\n */\n multiple?: Multiple\n\n /**\n * Current selected values (multi-select mode).\n * Use for controlled mode.\n */\n values?: Value[]\n\n /**\n * Default selected values (multi-select mode).\n * Use for uncontrolled mode.\n */\n defaultValues?: Value[]\n\n /**\n * Callback when the selected values change (multi-select mode).\n */\n onValuesChange?: (values: Value[]) => void\n\n // ===== Object Value Support =====\n /**\n * Custom comparison logic used to determine if a select item value\n * matches the current selected value.\n * Useful when item values are objects without matching referentially.\n * Defaults to Object.is comparison.\n */\n isItemEqualToValue?: ItemEqualityComparer<Value>\n\n /**\n * When the item values are objects (`<Select.Item value={object}>`),\n * this function converts the object value to a string representation\n * for display in the trigger.\n * If the shape of the object is `{ value, label }`, the label will be\n * used automatically without needing to specify this prop.\n */\n itemToStringLabel?: (itemValue: Value) => string\n\n /**\n * When the item values are objects (`<Select.Item value={object}>`),\n * this function converts the object value to a string representation\n * for form submission.\n * If the shape of the object is `{ value, label }`, the value will be\n * used automatically without needing to specify this prop.\n */\n itemToStringValue?: (itemValue: Value) => string\n\n // ===== Form Integration =====\n /**\n * Form field name for submission.\n * When set, hidden input(s) will be rendered for form submission.\n */\n name?: string\n\n /**\n * Associate with a form by ID.\n */\n form?: string\n\n /**\n * Whether this field is required.\n */\n required?: boolean\n\n /**\n * Whether the select is disabled.\n * @default false\n */\n disabled?: boolean\n\n /**\n * Placeholder text when no value is selected.\n * @default \"Select...\"\n */\n placeholder?: string\n\n /**\n * Data structure of the items rendered in the select popup.\n * When specified, `<Select.Value>` renders the label of the selected item\n * instead of the raw value.\n *\n * Can be a record mapping values to labels, or an array of\n * `{ value, label, keywords? }` objects. Only the array form can express\n * `keywords` (extra filter terms) or a `null` (clearable) value.\n * @example\n * ```tsx\n * // Record format\n * <Select.Root items={{ us: 'United States', uk: 'United Kingdom' }}>\n *\n * // Array format (supports keywords and a null clearable item)\n * <Select.Root items={[\n * { value: null, label: 'Select a country' },\n * { value: 'us', label: 'United States', keywords: ['america', 'usa'] },\n * { value: 'uk', label: 'United Kingdom' },\n * ]}>\n * ```\n */\n items?: Items\n\n // ===== Behavior =====\n /**\n * Determines if the select enters a modal state when open.\n *\n * - `true`: user interaction is limited to the select: document page scroll\n * is locked, and pointer interactions on outside elements are disabled.\n * - `false`: user interaction with the rest of the document is allowed.\n * - `'trap-focus'`: focus is trapped inside the select, but document page\n * scroll is not locked and pointer interactions outside of it remain enabled.\n *\n * @default true\n */\n modal?: boolean | 'trap-focus'\n\n /**\n * When to close the select on outside interactions.\n * - 'pointerdown': Close immediately when pointer is pressed outside (default)\n * - 'click': Close when a full click (pointerdown + pointerup) occurs outside\n * @default 'pointerdown'\n */\n closeOnOutsidePress?: 'click' | 'pointerdown'\n\n // ===== Virtualization =====\n /**\n * Whether virtualization mode is enabled.\n * When true, items should provide an explicit `index` prop and\n * the `virtualItems` prop should be provided for navigation to work correctly.\n * @default false\n */\n virtualized?: boolean\n\n /**\n * Pre-registered items for virtualization.\n * When provided with `virtualized={true}`, this allows navigation to work\n * for items that aren't currently mounted in the DOM.\n */\n virtualItems?: VirtualItem[]\n\n /**\n * Callback when the highlighted item changes.\n * Useful for synchronizing with a virtualizer (e.g., scrollToIndex) or other UI state.\n * The third parameter contains event details including the reason for the change.\n */\n onHighlightChange?: (\n id: string | null,\n index: number,\n eventDetails: SelectHighlightChangeEventDetails,\n ) => void\n\n /**\n * Debug visualization options for submenu interaction heuristics.\n */\n debug?: PopupMenuDebugOptions\n\n children: React.ReactNode\n}\n\n/**\n * Groups all parts of the select.\n * Manages open state, selection state, and provides context to children.\n * Doesn't render its own HTML element.\n *\n * @template Value - The type of the select value (can be a primitive or object)\n * @template Multiple - Whether multiple selection is enabled\n */\nexport function SelectRoot<\n Value = unknown,\n Multiple extends boolean | undefined = false,\n>(props: SelectRootProps<Value, Multiple>): React.JSX.Element {\n const {\n // Open state\n open: openProp,\n onOpenChange,\n onOpenChangeComplete,\n actionsRef,\n defaultOpen = false,\n // Single selection\n value: valueProp,\n defaultValue,\n onValueChange,\n // Multi selection\n multiple = false as Multiple,\n values: valuesProp,\n defaultValues,\n onValuesChange,\n // Object value support\n isItemEqualToValue = defaultItemEquality as ItemEqualityComparer<Value>,\n itemToStringLabel,\n itemToStringValue,\n // Form integration\n name,\n form,\n required,\n disabled: disabledProp = false,\n placeholder = 'Select...',\n items,\n // Behavior\n modal = true,\n closeOnOutsidePress = 'pointerdown',\n // Virtualization\n virtualized = false,\n virtualItems,\n onHighlightChange,\n debug,\n children,\n ...rest\n } = props\n\n const handleHighlightChange =\n React.useCallback<PopupMenuHighlightChangeHandler>(\n (id, _node, index, details) =>\n onHighlightChange?.(\n id,\n index,\n details as SelectHighlightChangeEventDetails,\n ),\n [onHighlightChange],\n )\n\n // Generate a unique ID for the listbox\n const listId = React.useId()\n\n // ===== Element Refs for Positioning =====\n const triggerRef = React.useRef<HTMLElement | null>(null)\n const valueRef = React.useRef<HTMLElement | null>(null)\n const selectedItemTextRef = React.useRef<HTMLElement | null>(null)\n const firstItemTextRef = React.useRef<HTMLElement | null>(null)\n\n const setTriggerElement = React.useCallback((element: HTMLElement | null) => {\n triggerRef.current = element\n }, [])\n\n const setValueElement = React.useCallback((element: HTMLElement | null) => {\n valueRef.current = element\n }, [])\n\n // ===== Positioner Reset Callback =====\n // Store callback to reset positioning state after close animation\n const resetPositioningCallbackRef = React.useRef<(() => void) | null>(null)\n\n const registerResetPositioningCallback = React.useCallback(\n (callback: (() => void) | null) => {\n resetPositioningCallbackRef.current = callback\n // Return cleanup function\n return () => {\n resetPositioningCallbackRef.current = null\n }\n },\n [],\n )\n\n // ===== Open State =====\n // Use shared hook to create stores and utilities\n const {\n store,\n focusOwnerStore,\n openChainStore,\n registerSurface,\n closeAll,\n virtualization,\n handleOpenChange,\n disabled: menuDisabled,\n setDisabled,\n menuTreeResolver,\n } = usePopupMenuRoot({\n // Cast to generic type - component handles type safety via narrowed types\n onOpenChange:\n onOpenChange as unknown as UsePopupMenuRootParams['onOpenChange'],\n defaultOpen,\n virtualized,\n items: virtualItems,\n onHighlightChange: handleHighlightChange,\n closeOnOutsidePress,\n disabled: disabledProp,\n })\n\n const popoverActionsRef = React.useRef<Popover.Root.Actions | null>(null)\n\n React.useImperativeHandle(\n actionsRef,\n () => ({\n close: () => {\n popoverActionsRef.current?.close()\n },\n unmount: () => {\n popoverActionsRef.current?.unmount()\n },\n setDisabled,\n }),\n [setDisabled],\n )\n\n // Sync controlled open prop to store\n store.useControlledProp('openProp', openProp)\n\n // Get open state from store for Popover\n const open = store.useState('open')\n\n // ===== Single Selection State =====\n const [internalValue, setInternalValue] = React.useState<Value | null>(\n defaultValue !== undefined ? (defaultValue as Value | null) : null,\n )\n const value: Value | null =\n valueProp !== undefined ? (valueProp as Value | null) : internalValue\n\n const handleValueChange = React.useCallback(\n (newValue: Value | null) => {\n if (valueProp === undefined) {\n setInternalValue(newValue)\n }\n // `null` is only produced by a clearable item; the public onValueChange\n // type stays `(value: Value) => void` to keep `onValueChange={setState}`\n // ergonomic, so the null is forwarded through a cast at this boundary.\n onValueChange?.(newValue as Value)\n },\n [valueProp, onValueChange],\n )\n\n // ===== Multi Selection State =====\n const [internalValues, setInternalValues] = React.useState<Value[]>(\n defaultValues ?? [],\n )\n const values: Value[] = valuesProp !== undefined ? valuesProp : internalValues\n\n const handleValuesChange = React.useCallback(\n (newValues: Value[]) => {\n if (valuesProp === undefined) {\n setInternalValues(newValues)\n }\n onValuesChange?.(newValues)\n },\n [valuesProp, onValuesChange],\n )\n\n // ===== Item Text Registry =====\n // The registry persists item text even after items unmount (popup closes).\n // This ensures SelectValue can display the correct label for selected values.\n // Text is only overwritten when items re-mount with new text, never deleted.\n const itemTextRegistryRef = React.useRef<ItemTextRegistry>(new Map())\n\n const registerItemText = React.useCallback(\n (itemValue: string, text: string) => {\n itemTextRegistryRef.current.set(itemValue, text)\n // No cleanup - text should persist even when items unmount\n return () => {}\n },\n [],\n )\n\n // ===== Select Context =====\n const selectContextValue: SelectContextValue<Value> = React.useMemo(\n () => ({\n multiple: multiple as boolean,\n value,\n values,\n onValueChange: handleValueChange,\n onValuesChange: handleValuesChange,\n isItemEqualToValue,\n itemToStringLabel,\n itemToStringValue,\n name,\n form,\n required,\n disabled: menuDisabled,\n placeholder,\n items,\n itemTextRegistry: itemTextRegistryRef.current,\n registerItemText,\n listId,\n triggerRef,\n valueRef,\n selectedItemTextRef,\n firstItemTextRef,\n setTriggerElement,\n setValueElement,\n registerResetPositioningCallback,\n }),\n [\n multiple,\n value,\n values,\n handleValueChange,\n handleValuesChange,\n isItemEqualToValue,\n itemToStringLabel,\n itemToStringValue,\n name,\n form,\n required,\n menuDisabled,\n placeholder,\n items,\n registerItemText,\n listId,\n setTriggerElement,\n setValueElement,\n registerResetPositioningCallback,\n ],\n )\n\n // ===== Hidden Inputs for Form Submission =====\n const hiddenInputs = React.useMemo(() => {\n if (!name) return null\n\n if (multiple) {\n // Multiple hidden inputs for array submission\n if (values.length > 0) {\n return values.map((v, index) => {\n const serializedValue = stringifyAsValue(v, itemToStringValue)\n return (\n <input\n key={serializedValue}\n type=\"hidden\"\n name={name}\n value={serializedValue}\n form={form}\n required={required && index === 0}\n />\n )\n })\n }\n // Empty hidden input to ensure field is submitted even when empty\n return (\n <input\n type=\"hidden\"\n name={name}\n value=\"\"\n form={form}\n required={required}\n />\n )\n }\n\n // Single hidden input\n return (\n <input\n type=\"hidden\"\n name={name}\n value={value != null ? stringifyAsValue(value, itemToStringValue) : ''}\n form={form}\n required={required}\n />\n )\n }, [name, form, required, multiple, value, values, itemToStringValue])\n\n // Wrapper to adapt Popover's event details to our handleOpenChange\n const handlePopoverOpenChange = React.useCallback(\n (nextOpen: boolean, popoverDetails: Popover.Root.ChangeEventDetails) => {\n // Forward to our internal handler with the reason and event\n handleOpenChange(\n nextOpen,\n popoverDetails.reason as SelectOpenChangeEventDetails['reason'],\n popoverDetails.event,\n )\n },\n [handleOpenChange],\n )\n\n // Handle animation complete - reset positioning state after close animation\n const handleOpenChangeComplete = React.useCallback(\n (nextOpen: boolean) => {\n // Clear search and deactivate the input after the exit animation\n // completes, matching the other menu roots. `clearSearchOnClose=\"after-exit\"`\n // defers this cleanup from the store's close handler to here; without it a\n // `hideUntilActive` input stays activated (visible) on reopen.\n if (!nextOpen && store.context.clearSearchOnClose === 'after-exit') {\n store.clearSearch()\n store.setInputActive(false)\n }\n // Reset positioning state after close animation completes\n // This preserves the aligned position during the exit animation\n if (!nextOpen) {\n store.clearHighlight()\n resetPositioningCallbackRef.current?.()\n // Clear first item text ref so it can be set fresh on next open\n firstItemTextRef.current = null\n }\n // Call user's callback\n onOpenChangeComplete?.(nextOpen)\n },\n [store, onOpenChangeComplete],\n )\n\n return (\n <SelectContext.Provider\n value={selectContextValue as SelectContextValue<unknown>}\n >\n <PopupMenuProviders\n menuTreeResolver={menuTreeResolver}\n store={store}\n focusOwnerStore={focusOwnerStore}\n openChainStore={openChainStore}\n disabled={menuDisabled}\n depth={0}\n closeAll={closeAll}\n registerSurface={registerSurface}\n virtualization={virtualization}\n menuType=\"dropdown\"\n closeOnOutsidePress={closeOnOutsidePress}\n componentName=\"select\"\n debug={debug}\n >\n {hiddenInputs}\n <Popover.Root\n {...rest}\n open={open}\n onOpenChange={handlePopoverOpenChange}\n onOpenChangeComplete={handleOpenChangeComplete}\n modal={modal}\n actionsRef={actionsRef ? popoverActionsRef : undefined}\n >\n {children}\n </Popover.Root>\n </PopupMenuProviders>\n </SelectContext.Provider>\n )\n}\n\nexport namespace SelectRoot {\n export interface Props<\n Value = unknown,\n Multiple extends boolean | undefined = false,\n > extends SelectRootProps<Value, Multiple> {}\n export type OpenChangeEventDetails = SelectOpenChangeEventDetails\n export type HighlightChangeEventDetails = SelectHighlightChangeEventDetails\n export type Actions = PopupMenuRootActions\n}\n","'use client'\n\nimport * as React from 'react'\nimport {\n PopupMenuSurface,\n type PopupMenuSurfaceProps,\n} from '../../internal/popup-menu/index.js'\nimport {\n isValueEmpty,\n stringifyAsValue,\n} from '../../utils/resolve-value-label.js'\nimport { useSelectContext } from '../contexts/select-context.js'\nimport { useSelectPositionerContext } from '../contexts/select-positioner-context.js'\nimport { SelectSurfaceDataAttributes } from './surface.data-attrs.js'\n\nexport { SelectSurfaceDataAttributes }\n\nexport interface SelectSurfaceProps\n extends Omit<PopupMenuSurfaceProps, 'autoHighlightFirst'> {\n /**\n * Controls auto-highlighting behavior when the select opens.\n * - `true`: highlight the first item (default when alignItemWithTrigger is inactive)\n * - `false`: don't auto-highlight any item\n * - `'selected'`: highlight the currently selected item, or first item if none selected\n * - `string`: highlight the item with this specific value\n *\n * Note: When the Positioner's `alignItemWithTrigger` is active and this prop\n * is not explicitly set, the selected item is automatically highlighted.\n *\n * @default true (or selected value when alignItemWithTrigger is active)\n */\n autoHighlightFirst?: boolean | 'selected' | string\n}\n\n/**\n * Provides search context and manages item registration for Select.\n * Automatically configures `autoHighlightFirst` based on the Positioner's\n * `alignItemWithTrigger` prop - when active, highlights the selected item\n * instead of the first item.\n *\n * Place inside Select.Popup to enable search functionality.\n * Renders a `<div>` element.\n */\nexport const SelectSurface = React.forwardRef<\n HTMLDivElement,\n SelectSurface.Props\n>(function SelectSurface(props, forwardedRef) {\n const { autoHighlightFirst: autoHighlightFirstProp, ...rest } = props\n\n const selectContext = useSelectContext()\n const positionerContext = useSelectPositionerContext()\n\n // Determine autoHighlightFirst value:\n // - 'selected': use the current selected value (falls back to true if no selection)\n // - If alignItemWithTrigger is active and prop is not set, highlight the selected item\n // - Otherwise, use the prop value (defaulting to true)\n const autoHighlightFirst = React.useMemo(() => {\n // Helper to serialize a value to a string for highlighting\n // Returns true (highlight first) when there's no meaningful value\n const serializeValue = (value: unknown): string | true => {\n if (isValueEmpty(value)) return true\n return stringifyAsValue(value, selectContext.itemToStringValue)\n }\n\n // Handle 'selected' shorthand - resolve to actual selected value\n if (autoHighlightFirstProp === 'selected') {\n // For single-select, use the selected value\n // For multi-select, use the first selected value\n const selectedValue = selectContext.multiple\n ? selectContext.values[0]\n : selectContext.value\n\n // If there's a selected value, serialize and use for highlighting\n return serializeValue(selectedValue)\n }\n\n // If user explicitly passed a value (other than 'selected'), respect it\n if (autoHighlightFirstProp !== undefined) {\n return autoHighlightFirstProp\n }\n\n // If alignItemWithTrigger is active and we have a selected value,\n // auto-highlight the selected item\n if (positionerContext?.alignItemWithTriggerActive) {\n // For single-select, use the value\n // For multi-select, use the first selected value (or fall back to true)\n const selectedValue = selectContext.multiple\n ? selectContext.values[0]\n : selectContext.value\n return serializeValue(selectedValue)\n }\n\n // Default behavior\n return true\n }, [\n autoHighlightFirstProp,\n positionerContext?.alignItemWithTriggerActive,\n selectContext.multiple,\n selectContext.value,\n selectContext.values,\n selectContext.itemToStringValue,\n ])\n\n return (\n <PopupMenuSurface\n ref={forwardedRef}\n autoHighlightFirst={autoHighlightFirst}\n {...{ [SelectSurfaceDataAttributes.slot]: '' }}\n {...rest}\n />\n )\n})\n\nexport namespace SelectSurface {\n export type State = PopupMenuSurface.State\n export interface Props extends SelectSurfaceProps {}\n}\n","export const SelectSurfaceDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-surface'}\n */\n slot: 'bazzaui-select-surface',\n} as const\n","'use client'\n\nimport { Popover } from '@base-ui/react/popover'\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { usePopupMenuContext } from '../../internal/popup-menu/contexts/popup-menu-context.js'\nimport { REASONS } from '../../utils/events/index.js'\nimport { mergeElementProps } from '../../utils/merge-element-props.js'\nimport { isValueEmpty } from '../../utils/resolve-value-label.js'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useSelectContext } from '../contexts/select-context.js'\nimport { SelectTriggerDataAttributes } from './trigger.data-attrs.js'\n\nexport { SelectTriggerDataAttributes }\n\nexport interface SelectTriggerState extends Record<string, unknown> {\n /**\n * Whether the select is open.\n */\n open: boolean\n /**\n * Whether the select is disabled.\n */\n disabled: boolean\n /**\n * Whether the select currently shows placeholder (no value selected).\n */\n placeholder: boolean\n}\n\nexport interface SelectTriggerProps\n extends ComponentProps<'button', SelectTrigger.State> {\n /**\n * Whether the trigger is disabled.\n */\n disabled?: boolean\n}\n\nconst stateAttributesMapping = {\n open: (value: unknown): Record<string, string> | null =>\n value ? { [SelectTriggerDataAttributes.open]: '' } : null,\n disabled: (value: unknown): Record<string, string> | null =>\n value ? { [SelectTriggerDataAttributes.disabled]: '' } : null,\n placeholder: (value: unknown): Record<string, string> | null =>\n value ? { [SelectTriggerDataAttributes.placeholder]: '' } : null,\n}\n\n/**\n * Inner component that renders using useRender.\n * This allows us to use hooks while being called from Popover.Trigger's render prop.\n */\nconst SelectTriggerInner = React.forwardRef<\n HTMLButtonElement,\n SelectTriggerProps & {\n triggerProps: React.ComponentPropsWithRef<'button'>\n triggerState: { open: boolean }\n }\n>(function SelectTriggerInner(props, forwardedRef) {\n const {\n render,\n children,\n disabled: disabledProp,\n className,\n style,\n triggerProps,\n triggerState,\n ...rest\n } = props\n\n const selectContext = useSelectContext()\n const disabled = disabledProp ?? selectContext.disabled\n\n // Determine if showing placeholder\n // Match Base UI: null, undefined, or empty string = no selection\n const hasValue = selectContext.multiple\n ? selectContext.values.length > 0\n : !isValueEmpty(selectContext.value)\n\n const state: SelectTrigger.State = React.useMemo(\n () => ({\n open: triggerState.open,\n disabled,\n placeholder: !hasValue,\n }),\n [triggerState.open, disabled, hasValue],\n )\n\n // Register trigger element for positioning\n const internalRef = React.useCallback(\n (node: HTMLButtonElement | null) => {\n selectContext.setTriggerElement(node)\n },\n [selectContext],\n )\n\n return useRender({\n render,\n ref: forwardedRef,\n state,\n stateAttributesMapping,\n props: {\n ...mergeElementProps<'button'>(triggerProps, {\n ...rest,\n className,\n style,\n children,\n } as Partial<React.ComponentPropsWithRef<'button'>>),\n [SelectTriggerDataAttributes.slot]: '',\n ref: internalRef,\n role: 'combobox' as const,\n 'aria-haspopup': 'listbox' as const,\n 'aria-controls': selectContext.listId,\n },\n defaultTagName: 'button',\n })\n})\n\n/**\n * A button that opens the select dropdown.\n * Renders a `<button>` element with combobox ARIA semantics.\n */\nexport const SelectTrigger = React.forwardRef<\n HTMLButtonElement,\n SelectTrigger.Props\n>(function SelectTrigger(props, forwardedRef) {\n const { disabled: disabledProp, ...rest } = props\n const selectContext = useSelectContext()\n const popupMenuContext = usePopupMenuContext()\n const { store, closeAll, closeOnOutsidePress } = popupMenuContext\n const disabled =\n (disabledProp ?? selectContext.disabled) || popupMenuContext.disabled\n const isOpen = store.useState('open')\n\n // We need to intercept pointerdown before it reaches Popover.Trigger.\n // This ref tracks the element so we can add a one-time click blocker.\n const triggerRef = React.useRef<HTMLButtonElement | null>(null)\n\n // Combine refs\n const setRef = React.useCallback(\n (element: HTMLButtonElement | null) => {\n triggerRef.current = element\n if (typeof forwardedRef === 'function') {\n forwardedRef(element)\n } else if (forwardedRef) {\n forwardedRef.current = element\n }\n },\n [forwardedRef],\n )\n\n // Handle pointerdown to close on press when open\n React.useEffect(() => {\n const trigger = triggerRef.current\n if (!trigger || closeOnOutsidePress !== 'pointerdown') return\n\n const handlePointerDown = (event: PointerEvent) => {\n // If the select is open, close it immediately and block the click\n if (isOpen) {\n closeAll(REASONS.triggerPress, event)\n\n // Block the upcoming click from reaching Popover.Trigger\n // This prevents the toggle behavior from reopening the popup\n trigger.addEventListener(\n 'click',\n (clickEvent) => {\n clickEvent.stopPropagation()\n clickEvent.preventDefault()\n },\n { once: true, capture: true },\n )\n }\n }\n\n // Use capture phase to see the event before Popover.Trigger\n trigger.addEventListener('pointerdown', handlePointerDown, true)\n return () => {\n trigger.removeEventListener('pointerdown', handlePointerDown, true)\n }\n }, [isOpen, closeAll, closeOnOutsidePress])\n\n return (\n <Popover.Trigger\n ref={setRef}\n disabled={disabled}\n render={(triggerProps, triggerState) => (\n <SelectTriggerInner\n {...rest}\n disabled={disabled}\n triggerProps={triggerProps}\n triggerState={triggerState}\n ref={triggerProps.ref as React.Ref<HTMLButtonElement>}\n />\n )}\n />\n )\n})\n\nexport namespace SelectTrigger {\n export interface Props extends SelectTriggerProps {}\n export type State = SelectTriggerState\n}\n","export const SelectTriggerDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-trigger'}\n */\n slot: 'bazzaui-select-trigger',\n /**\n * Present when the select dropdown is open.\n */\n open: 'data-open',\n /**\n * Present when the select dropdown is closed.\n */\n closed: 'data-closed',\n /**\n * Present when the trigger is disabled.\n */\n disabled: 'data-disabled',\n /**\n * Present when no value is selected (showing placeholder).\n */\n placeholder: 'data-placeholder',\n} as const\n","'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { resolveLabelFromItems } from '../../utils/items.js'\nimport {\n isValueEmpty,\n resolveLabel,\n stringifyAsValue,\n} from '../../utils/resolve-value-label.js'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useSelectContext } from '../contexts/select-context.js'\nimport { SelectValueDataAttributes } from './value.data-attrs.js'\n\nexport { SelectValueDataAttributes }\n\nexport interface SelectValueState<Value = unknown>\n extends Record<string, unknown> {\n /**\n * The currently selected value (single-select mode).\n */\n value: Value | null\n /**\n * The currently selected values (multi-select mode).\n */\n values: Value[]\n /**\n * Whether the select is in multi-select mode.\n */\n multiple: boolean\n /**\n * Whether a value is currently selected.\n */\n hasValue: boolean\n /**\n * The placeholder text.\n */\n placeholder: string\n /**\n * Get the display content for a value.\n * First checks the item text registry (populated when items mount),\n * then falls back to the `items` prop passed to SelectRoot,\n * then falls back to `itemToStringLabel` for object values.\n */\n getValueText: (value: Value) => React.ReactNode | undefined\n}\n\nexport interface SelectValueProps<Value = unknown>\n extends Omit<ComponentProps<'span', SelectValueState<Value>>, 'children'> {\n /**\n * Placeholder text when no value is selected.\n * Overrides the placeholder set on Select.Root.\n */\n placeholder?: string\n\n /**\n * Custom render function for the selected value content.\n * Receives the current state and should return the content to render.\n * This is different from the `render` prop which replaces the element.\n */\n children?:\n | React.ReactNode\n | ((state: SelectValueState<Value>) => React.ReactNode)\n}\n\nconst stateAttributesMapping = {\n hasValue: (value: unknown): Record<string, string> | null =>\n !value ? { [SelectValueDataAttributes.placeholder]: '' } : null,\n multiple: (value: unknown): Record<string, string> | null =>\n value ? { [SelectValueDataAttributes.multiple]: '' } : null,\n // Exclude function from data attributes to avoid hydration mismatch\n getValueText: () => null,\n}\n\n/**\n * Displays the currently selected value(s) or placeholder.\n * Typically placed inside Select.Trigger.\n * Renders a `<span>` element.\n */\nfunction SelectValueImpl<Value = unknown>(\n props: SelectValueProps<Value>,\n forwardedRef: React.ForwardedRef<HTMLSpanElement>,\n) {\n const {\n render,\n className,\n style,\n placeholder: placeholderProp,\n children,\n ...rest\n } = props\n\n const selectContext = useSelectContext<Value>()\n\n const placeholder = placeholderProp ?? selectContext.placeholder\n\n // A `null` item's label (looked up under the empty-string key) acts as the\n // placeholder, taking precedence over the Root placeholder but not an\n // explicit `placeholder` prop on Select.Value (Base UI parity).\n const nullItemLabel = React.useMemo(\n () => resolveLabelFromItems(selectContext.items, ''),\n [selectContext.items],\n )\n const placeholderContent = placeholderProp ?? nullItemLabel ?? placeholder\n\n const hasValue = selectContext.multiple\n ? selectContext.values.length > 0\n : !isValueEmpty(selectContext.value)\n\n // Helper to get text for a value\n // First check the item text registry (populated when items mount),\n // then fall back to the items prop (available immediately for initial render),\n // then fall back to itemToStringLabel for object values\n const getValueText = React.useCallback(\n (value: Value): React.ReactNode | undefined => {\n // Serialize for registry lookup\n const serializedValue = stringifyAsValue(\n value,\n selectContext.itemToStringValue,\n )\n\n // First try the registry (populated when items mount)\n const registryText = selectContext.itemTextRegistry.get(serializedValue)\n if (registryText !== undefined) {\n return registryText\n }\n\n // Fall back to the items prop (for initial render before popup opens)\n const labelFromItems = resolveLabelFromItems(\n selectContext.items,\n serializedValue,\n )\n if (labelFromItems !== undefined) {\n return labelFromItems\n }\n\n // Fall back to itemToStringLabel for object values\n const resolvedLabel = resolveLabel(value, selectContext.itemToStringLabel)\n // Only return if it's different from the serialized value (meaning we got a real label)\n if (resolvedLabel && resolvedLabel !== serializedValue) {\n return resolvedLabel\n }\n\n return undefined\n },\n [\n selectContext.itemTextRegistry,\n selectContext.items,\n selectContext.itemToStringLabel,\n selectContext.itemToStringValue,\n ],\n )\n\n const state: SelectValueState<Value> = React.useMemo(\n () => ({\n value: selectContext.value,\n values: selectContext.values,\n multiple: selectContext.multiple,\n hasValue,\n placeholder,\n getValueText,\n }),\n [\n selectContext.value,\n selectContext.values,\n selectContext.multiple,\n hasValue,\n placeholder,\n getValueText,\n ],\n )\n\n // Determine what to render as content\n let content: React.ReactNode\n\n if (typeof children === 'function') {\n // Custom render function\n content = children(state)\n } else if (children !== undefined) {\n // Static children\n content = children\n } else if (!hasValue) {\n // Show placeholder when no value (a null item's label, if present)\n content = placeholderContent\n } else if (selectContext.multiple) {\n // Multi-select: show count or comma-separated values\n const texts = selectContext.values\n .map((v) => {\n const text = getValueText(v)\n if (text !== undefined) return text\n // Fall back to resolved label or serialized value\n return (\n resolveLabel(v, selectContext.itemToStringLabel) ||\n stringifyAsValue(v, selectContext.itemToStringValue)\n )\n })\n .filter(Boolean)\n content = texts.length > 2 ? `${texts.length} selected` : texts.join(', ')\n } else {\n // Single-select: show value text\n const value = selectContext.value\n if (value != null) {\n const text = getValueText(value)\n if (text !== undefined) {\n content = text\n } else {\n // Fall back to resolved label or serialized value\n content =\n resolveLabel(value, selectContext.itemToStringLabel) ||\n stringifyAsValue(value, selectContext.itemToStringValue)\n }\n }\n }\n\n // Register value element for positioning\n const internalRef = React.useCallback(\n (node: HTMLSpanElement | null) => {\n selectContext.setValueElement(node)\n },\n [selectContext],\n )\n\n return useRender({\n render,\n ref: forwardedRef,\n state,\n stateAttributesMapping,\n props: {\n ...rest,\n [SelectValueDataAttributes.slot]: '',\n ref: internalRef,\n className,\n style,\n children: content,\n },\n defaultTagName: 'span',\n })\n}\n\nexport const SelectValue = React.forwardRef(SelectValueImpl) as <\n Value = unknown,\n>(\n props: SelectValueProps<Value> & React.RefAttributes<HTMLSpanElement>,\n) => React.ReactElement\n\nexport namespace SelectValue {\n // Props uses unknown default for simpler usage when type doesn't matter\n export interface Props extends SelectValueProps<unknown> {}\n export type State = SelectValueState<unknown>\n}\n","export const SelectValueDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-value'}\n */\n slot: 'bazzaui-select-value',\n /**\n * Present when showing placeholder (no value selected).\n */\n placeholder: 'data-placeholder',\n /**\n * Present when in multi-select mode.\n */\n multiple: 'data-multiple',\n} as const\n","export enum SelectArrowDataAttributes {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-arrow'}\n */\n slot = 'bazzaui-select-arrow',\n /**\n * Present when the popup menu is open.\n */\n open = 'data-open',\n /**\n * Present when the popup menu is closed.\n */\n closed = 'data-closed',\n /**\n * Indicates which side the popup is positioned relative to the trigger.\n * @type {'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'}\n */\n side = 'data-side',\n /**\n * Indicates how the popup is aligned relative to specified side.\n * @type {'start' | 'center' | 'end'}\n */\n align = 'data-align',\n /**\n * Present when the arrow is not centered due to collision avoidance.\n */\n uncentered = 'data-uncentered',\n}\n","export enum SelectBackdropDataAttributes {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-backdrop'}\n */\n slot = 'bazzaui-select-backdrop',\n /**\n * Present when the popup menu is open.\n */\n open = 'data-open',\n /**\n * Present when the popup menu is closed.\n */\n closed = 'data-closed',\n /**\n * Present when the popup menu is animating in.\n */\n startingStyle = 'data-starting-style',\n /**\n * Present when the popup menu is animating out.\n */\n endingStyle = 'data-ending-style',\n}\n","/**\n * Data attributes applied to Select.Empty for styling.\n * Displayed when no items match the current search filter.\n *\n * @example\n * ```css\n * [data-bazzaui-select-empty] {\n * padding: 8px 16px;\n * color: var(--muted);\n * text-align: center;\n * }\n * ```\n */\nexport enum SelectEmptyDataAttributes {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-empty'}\n */\n slot = 'bazzaui-select-empty',\n}\n","export enum SelectGroupDataAttributes {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-group'}\n */\n slot = 'bazzaui-select-group',\n}\n","export enum SelectGroupLabelDataAttributes {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-group-label'}\n */\n slot = 'bazzaui-select-group-label',\n}\n","export const SelectIconDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-icon'}\n */\n slot: 'bazzaui-select-icon',\n /** Present when the popup is open. */\n open: 'data-popup-open',\n} as const\n","export enum SelectInputDataAttributes {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-input'}\n */\n slot = 'bazzaui-select-input',\n /**\n * Present when the popup menu is open.\n */\n open = 'data-open',\n /**\n * Present when the popup menu is closed.\n */\n closed = 'data-closed',\n}\n","/**\n * Data attributes applied to Select.List for styling.\n * Container for select items with role=\"listbox\".\n *\n * @example\n * ```css\n * [data-bazzaui-select-list] {\n * max-height: 300px;\n * overflow-y: auto;\n * }\n * ```\n */\nexport enum SelectListDataAttributes {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-list'}\n */\n slot = 'bazzaui-select-list',\n /**\n * Always present on the list element.\n * Used for styling and by useStickyRowWidth to find the list container.\n */\n list = 'data-popup-menu-list',\n}\n","// Re-export all base popup data attributes\nexport { PopupMenuPopupDataAttributes } from '../../internal/popup-menu/components/popup/popup.data-attrs.js'\n\n/**\n * Select-specific popup data attributes (in addition to PopupMenuPopupDataAttributes).\n */\nexport enum SelectPopupDataAttributes {\n /**\n * Present when the popup is using align-item-with-trigger positioning.\n * This reflects the actual state, not just the prop value.\n */\n alignItemWithTrigger = 'data-align-item-with-trigger',\n}\n","export const SelectScrollArrowDataAttributes = {\n /**\n * Identifies the component part for scroll up arrow.\n * @type {'bazzaui-select-scroll-up-arrow'}\n */\n slotUp: 'bazzaui-select-scroll-up-arrow',\n /**\n * Identifies the component part for scroll down arrow.\n * @type {'bazzaui-select-scroll-down-arrow'}\n */\n slotDown: 'bazzaui-select-scroll-down-arrow',\n /**\n * Direction of the scroll arrow.\n * @type {'up' | 'down'}\n */\n direction: 'data-direction',\n /**\n * Side of the popup.\n * @type {'top' | 'bottom' | 'left' | 'right'}\n */\n side: 'data-side',\n} as const\n","export enum SelectSeparatorDataAttributes {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-separator'}\n */\n slot = 'bazzaui-select-separator',\n}\n"],"mappings":"geAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,WAAAE,GAAA,aAAAC,GAAA,UAAAC,GAAA,UAAAC,GAAA,eAAAC,GAAA,SAAAC,GAAA,UAAAC,GAAA,SAAAC,GAAA,kBAAAC,GAAA,cAAAC,GAAA,SAAAC,GAAA,UAAAC,GAAA,WAAAC,GAAA,eAAAC,GAAA,SAAAC,GAAA,oBAAAC,GAAA,kBAAAC,GAAA,cAAAC,GAAA,YAAAC,GAAA,YAAAC,GAAA,UAAAC,KCEA,OAAS,aAAAC,OAAiB,4BAC1B,UAAYC,MAAW,QCDvB,UAAYC,OAAW,QA4GvB,IAAMC,GAAsB,iBAC1B,IACF,EAMO,SAASC,GAA+D,CAC7E,IAAMC,EAAgB,cAAWF,EAAa,EAC9C,GAAI,CAACE,EACH,MAAM,IAAI,MA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IAAMC,GAAkC,CAK7C,OAAQ,iCAKR,SAAU,mCAKV,UAAW,iBAKX,KAAM,WACR,ECrBO,IAAKC,QAKVA,EAAA,KAAO,2BALGA,QAAA","names":["index_parts_exports","__export","PopupMenuArrow","PopupMenuBackdrop","PopupMenuEmpty","PopupMenuGroup","PopupMenuGroupLabel","PopupMenuIcon","PopupMenuInput","SelectItem","SelectItemIndicator","SelectItemLabel","PopupMenuList","SelectPopup","PopupMenuPortal","SelectPositioner","SelectRoot","PopupMenuScrollDownArrow","PopupMenuScrollUpArrow","PopupMenuSeparator","SelectSurface","SelectTrigger","SelectValue","useRender","React","React","SelectContext","useSelectContext","context","useMaybeSelectContext","SelectItemDataAttributes","React","SelectItemContext","useSelectItemContext","context","useMaybeSelectItemContext","jsx","stateAttributesMapping","value","SelectItemDataAttributes","SelectItemImpl","props","forwardedRef","textValueProp","keywordsProp","disabled","onSelect","forceMount","render","className","style","onClick","onPointerDown","onPointerMove","children","rest","selectContext","useSelectContext","serializedValue","stringifyAsValue","generatedItemId","listboxId","itemFromItems","resolveItemFromItems","labelFromItems","labelFromObjectValue","resolveLabel","textValue","keywords","mergeKeywords","textRef","selected","itemIncludes","compareItemEquality","closeOnClick","item","usePopupMenuItem","handleSelect","newValues","removeItem","text","state","itemContextValue","handleClick","event","handlePointerDown","handlePointerMove","element","useRender","jsx","SelectItemContext","SelectItem","useRender","React","SelectItemIndicatorDataAttributes","stateAttributesMapping","value","SelectItemIndicatorDataAttributes","SelectItemIndicator","props","forwardedRef","render","className","style","forceMount","keepMounted","children","rest","itemContext","useSelectItemContext","selected","highlighted","state","shouldRender","content","element","useRender","useRender","React","SelectItemLabelDataAttributes","SelectItemLabel","props","forwardedRef","render","className","style","children","rest","selectContext","useSelectContext","itemContext","useSelectItemContext","textRef","valueKey","stringifyAsValue","resolvedLabel","labelFromItems","resolveLabelFromItems","state","mergedRef","node","useRender","SelectItemLabelDataAttributes","React","React","SelectPositionerContext","useSelectPositionerContext","jsx","SelectPopup","props","forwardedRef","classNameProp","renderProp","rest","positionerContext","useSelectPositionerContext","alignItemWithTriggerActive","align","extendState","baseState","className","render","renderProps","PopupMenuPopup","useDirection","Popover","React","clamp","value","min","max","getScale","element","rect","offsetWidth","offsetHeight","x","y","normalizeSize","size","axis","scale","normalizeRect","width","height","SCROLL_EDGE_TOLERANCE_PX","getMaxScrollOffset","scrollSize","clientSize","ALIGNMENT_PADDING_X","TRIGGER_COLLISION_THRESHOLD","DEFAULT_MARGIN","DEFAULT_MIN_HEIGHT","computeAlignment","input","triggerRect","positionerRect","valueRect","textRect","scrollHeight","documentClientHeight","documentClientWidth","marginTop","marginBottom","minHeight","maxPopupHeight","borderBottom","direction","fallback","viewportHeight","viewportWidth","triggerHeight","availableSpaceBeneathTrigger","alignedLeft","offsetY","textCenterY","valueCenterFromTriggerTop","idealHeight","height","maxHeight","scrollTop","maxRight","left","clamp","maxScrollTop","getMaxScrollOffset","isTopPositioned","SCROLL_EDGE_TOLERANCE_PX","initialHeight","alignmentCorrection","top","finalScrollTop","topOffset","transformOrigin","popupTop","popupHeight","transformOriginY","reachedMaxHeight","computeScrollGrowth","currentHeight","maxAvailableHeight","diff","heightDelta","newHeight","nextHeight","scroll","reachedMax","overshoot","SelectPositionerDataAttributes","jsx","SelectPositioner","props","forwardedRef","alignItemWithTrigger","sideProp","alignProp","sideOffset","className","style","children","rest","popupMenuContext","usePopupMenuContext","selectContext","useSelectContext","direction","useDirection","store","open","openMethod","hasInput","controlledAlignItemWithTrigger","setControlledAlignItemWithTrigger","alignItemWithTriggerActive","positioned","setPositioned","placement","setPlacement","positionerRef","scrollUpArrowRef","scrollDownArrowRef","reachedMaxHeightRef","initialPlacedRef","clearImperativeStyles","positioner","popup","resetPositioningState","runAlignment","trigger","scroller","textElement","firstItemText","valueElement","restoreTransforms","unsetTransformStyles","result","win","ownerWindow","doc","scale","getScale","positionerStyles","popupStyles","computeAlignment","normalizeRect","DEFAULT_MARGIN","DEFAULT_MIN_HEIGHT","getMaxPopupHeight","isPinchZoomed","isWebkit","handleResize","event","reason_parts_exports","handleScroll","isTopPositioned","isBottomPositioned","currentHeight","normalizeSize","marginTop","marginBottom","maxPopupHeight","maxAvailableHeight","computeScrollGrowth","getMaxScrollOffset","nextMax","SCROLL_EDGE_TOLERANCE_PX","target","clamp","onScroll","renderedSide","contextValue","mergedRef","node","shouldHide","alignmentStyles","jsx","SelectPositionerContext","Popover","SelectPositionerDataAttributes","maxHeight","nav","TRANSFORM_STYLE_RESETS","element","original","property","value","Popover","React","jsx","jsxs","SelectRoot","props","openProp","onOpenChange","onOpenChangeComplete","actionsRef","defaultOpen","valueProp","defaultValue","onValueChange","multiple","valuesProp","defaultValues","onValuesChange","isItemEqualToValue","defaultItemEquality","itemToStringLabel","itemToStringValue","name","form","required","disabledProp","placeholder","items","modal","closeOnOutsidePress","virtualized","virtualItems","onHighlightChange","debug","children","rest","handleHighlightChange","id","_node","index","details","listId","triggerRef","valueRef","selectedItemTextRef","firstItemTextRef","setTriggerElement","element","setValueElement","resetPositioningCallbackRef","registerResetPositioningCallback","callback","store","focusOwnerStore","openChainStore","registerSurface","closeAll","virtualization","handleOpenChange","menuDisabled","setDisabled","menuTreeResolver","usePopupMenuRoot","popoverActionsRef","open","internalValue","setInternalValue","value","handleValueChange","newValue","internalValues","setInternalValues","values","handleValuesChange","newValues","itemTextRegistryRef","registerItemText","itemValue","text","selectContextValue","hiddenInputs","v","serializedValue","stringifyAsValue","handlePopoverOpenChange","nextOpen","popoverDetails","handleOpenChangeComplete","SelectContext","PopupMenuProviders","Popover","React","SelectSurfaceDataAttributes","jsx","SelectSurface","props","forwardedRef","autoHighlightFirstProp","rest","selectContext","useSelectContext","positionerContext","useSelectPositionerContext","autoHighlightFirst","serializeValue","value","isValueEmpty","stringifyAsValue","selectedValue","jsx","PopupMenuSurface","SelectSurfaceDataAttributes","Popover","useRender","React","SelectTriggerDataAttributes","jsx","stateAttributesMapping","value","SelectTriggerDataAttributes","SelectTriggerInner","props","forwardedRef","render","children","disabledProp","className","style","triggerProps","triggerState","rest","selectContext","useSelectContext","disabled","hasValue","isValueEmpty","state","internalRef","node","useRender","mergeElementProps","SelectTrigger","popupMenuContext","usePopupMenuContext","store","closeAll","closeOnOutsidePress","isOpen","triggerRef","setRef","element","trigger","handlePointerDown","event","reason_parts_exports","clickEvent","jsx","Popover","useRender","React","SelectValueDataAttributes","stateAttributesMapping","value","SelectValueDataAttributes","SelectValueImpl","props","forwardedRef","render","className","style","placeholderProp","children","rest","selectContext","useSelectContext","placeholder","nullItemLabel","resolveLabelFromItems","placeholderContent","hasValue","isValueEmpty","getValueText","serializedValue","stringifyAsValue","registryText","labelFromItems","resolvedLabel","resolveLabel","state","content","texts","v","text","internalRef","node","useRender","SelectValue","SelectArrowDataAttributes","SelectBackdropDataAttributes","SelectEmptyDataAttributes","SelectGroupDataAttributes","SelectGroupLabelDataAttributes","SelectIconDataAttributes","SelectInputDataAttributes","SelectListDataAttributes","SelectPopupDataAttributes","SelectScrollArrowDataAttributes","SelectSeparatorDataAttributes"]}