@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
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var _chunkM4G6J7DPcjs = require('./chunk-M4G6J7DP.cjs');var _react = require('react'); var G = _interopRequireWildcard(_react); var H = _interopRequireWildcard(_react); var T = _interopRequireWildcard(_react); var A = _interopRequireWildcard(_react); var D = _interopRequireWildcard(_react); var b = _interopRequireWildcard(_react); var ge = _interopRequireWildcard(_react); var C = _interopRequireWildcard(_react);var he=G.createContext(null);function B(){return G.useContext(he)}var q=H.createContext(null);function ze(){let n=H.useContext(q);if(!n)throw new Error("Item child components must be used within an Item");return n}function Ne(){return H.useContext(q)}var $=T.createContext(null);function Y(){let n=T.useContext($);if(!n)throw new Error("Listbox components must be used within a Listbox provider");return n}function Fe(){return T.useContext($)}var W=A.createContext(null);process.env.NODE_ENV!=="production"&&(W.displayName="RowWidthContext");function Ge(){let n=A.useContext(W);if(!n)throw new Error("useRowWidthContext must be used within a List with measureRowWidth enabled");return n}function X(){return A.useContext(W)}var J=D.createContext(null);function Q(){let n=D.useContext(J);if(!n)throw new Error("Listbox components must be used within a Surface provider");return n}function We(){return D.useContext(J)}function P(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _2 => _2.trim, 'call', _3 => _3()]), () => (""))}function fe(n){return n.normalize("NFD").replace(/\p{Diacritic}/gu,"")}function Ke(n){return n?n.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,""):""}function _e(n){let{id:e,value:t,keywords:r,disabled:s=!1,activatable:o=!0,forceMount:a=!1,shortcut:l,forceOrder:d,forceScore:c,isSubmenuTrigger:h=!1,onSelect:g,closeOnClick:v=!0,onAfterSelect:R,children:m,aimGuard:E}=n,{store:i}=Q(),u=B(),{depth:x}=Y(),f=b.useRef(null),I=b.useId(),[O,z]=b.useState(null);b.useLayoutEffect(()=>{if(O)return i.registerRow(I,O,{kind:"item",groupId:_optionalChain([u, 'optionalAccess', _4 => _4.groupId])})},[O,I,_optionalChain([u, 'optionalAccess', _5 => _5.groupId]),i]);let[M,N]=b.useState("");b.useLayoutEffect(()=>{if(e===void 0&&t===void 0&&f.current){let y=_nullishCoalesce(_optionalChain([f, 'access', _6 => _6.current, 'access', _7 => _7.textContent, 'optionalAccess', _8 => _8.trim, 'call', _9 => _9()]), () => (""));N(y)}},[e,t,m]);let p=_nullishCoalesce(e, () => ((P(t)||M))),F=b.useId(),K=_nullishCoalesce(e, () => (`item-${F}`)),_=_optionalChain([r, 'optionalAccess', _10 => _10.map, 'call', _11 => _11(y=>P(y)), 'access', _12 => _12.filter, 'call', _13 => _13(Boolean)]),ye=_?JSON.stringify(_):void 0;b.useEffect(()=>!p&&!a?void 0:i.registerItem(p,{value:p,keywords:_,groupId:_optionalChain([u, 'optionalAccess', _14 => _14.groupId]),disabled:s,activatable:o,isSubmenuTrigger:h,shortcut:l,forceOrder:d,forceScore:c,closeOnClick:v}),[p,ye,_optionalChain([u, 'optionalAccess', _15 => _15.groupId]),s,o,h,l,d,c,v,i,a]),b.useEffect(()=>{if(p)return i.registerItemRef(p,f)},[p,i]);let U=X();b.useLayoutEffect(()=>{U&&f.current&&p&&U.queueMeasurement(f.current,p)},[U,p]),b.useEffect(()=>{if(!(!g||!p))return i.registerItemSelect(p,g)},[p,g,i]);let we=i.useState("normalizedSearch"),j=i.useState("isHighlighted",p),ie=i.useState("isFirstRow",I),se=i.useState("isLastRow",I),oe=i.useState("isFirstInGroup",I),ae=i.useState("isLastInGroup",I),Oe=i.useState("getItemScore",p),Me=i.isFilterDisabled(),Le=we.length>0,Pe=a||Me||!Le||Oe>0,le=b.useCallback(y=>{if(y.defaultPrevented||s||o===!1||!p)return;y.preventDefault(),_optionalChain([i, 'access', _16 => _16.context, 'access', _17 => _17.itemSelects, 'access', _18 => _18.get, 'call', _19 => _19(p), 'optionalCall', _20 => _20()]),_optionalChain([R, 'optionalCall', _21 => _21(p)])},[s,o,i,p,R]),ce=b.useCallback(y=>{y.preventDefault()},[]),ue=b.useCallback(y=>{if(!y.defaultPrevented&&!s&&p){if(E){let{aimGuardActiveRef:de,guardedDepthRef:De}=E;if(de.current&&De.current===x)return}i.shouldAllowPointerHighlight(y.clientX,y.clientY)&&i.setHighlightedId(p)}},[s,E,x,i,p]),ke=b.useMemo(()=>({id:K,highlighted:j,disabled:s,shortcut:l}),[K,j,s,l]),He=b.useCallback(y=>p?i.registerItemSelect(p,y):()=>{},[i,p]),Te=b.useMemo(()=>({onClick:le,onPointerMove:ue,onPointerDown:ce}),[le,ue,ce]),k=_optionalChain([u, 'optionalAccess', _22 => _22.positional]),Ae=b.useMemo(()=>({first:_nullishCoalesce(_optionalChain([k, 'optionalAccess', _23 => _23.first]), () => (ie)),last:_nullishCoalesce(_optionalChain([k, 'optionalAccess', _24 => _24.last]), () => (se)),firstInGroup:_nullishCoalesce(_optionalChain([k, 'optionalAccess', _25 => _25.firstInGroup]), () => (oe)),lastInGroup:_nullishCoalesce(_optionalChain([k, 'optionalAccess', _26 => _26.lastInGroup]), () => (ae))}),[k,ie,se,oe,ae]);return{id:K,storeId:p,ref:f,rowRef:z,positional:Ae,isHighlighted:j,isVisible:Pe,contextValue:ke,handlers:Te,registerSelect:He}}function Ue(n){let{store:e,surfaceId:t,enabled:r,onKeyDown:s,onSelect:o,closeAll:a,focusOwner:l,depth:d=0,submenuContext:c,subpageContext:h,enableTypeToSearch:g=!1,skipFocusOwnerCheck:v=!1}=n,R=_nullishCoalesce(_optionalChain([l, 'optionalAccess', _27 => _27.useState, 'call', _28 => _28("isOwner",t)]), () => (!0)),m=v?!0:R;return{handleKeyDown:ge.useCallback(i=>{if(_optionalChain([s, 'optionalCall', _29 => _29(i)]),!i.defaultPrevented&&r&&m&&!(i.nativeEvent.isComposing||i.keyCode===229)){if(g){let u=e.context.hideUntilActive,x=e.state.inputActive;if(u&&!x&&i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey){let I=e.context.shortcuts.get(i.key.toLowerCase());if(I&&e.selectByShortcut(i.key)){i.preventDefault();let O=e.context.items.get(I);_optionalChain([o, 'optionalCall', _30 => _30({itemId:I,closeOnClick:_nullishCoalesce(_optionalChain([O, 'optionalAccess', _31 => _31.closeOnClick]), () => (!0))})]);return}i.preventDefault(),e.setPendingSearch(i.key),e.setInputActive(!0);return}}switch(i.key){case"ArrowDown":{i.preventDefault(),e.highlightNext();break}case"ArrowUp":{i.preventDefault(),e.highlightPrev();break}case"n":{i.ctrlKey&&(i.preventDefault(),e.highlightNext());break}case"p":{i.ctrlKey&&(i.preventDefault(),e.highlightPrev());break}case"ArrowRight":{e.isHighlightedSubmenuTrigger()&&(i.preventDefault(),e.openSubmenuForHighlighted());break}case"l":{i.ctrlKey&&e.isHighlightedSubmenuTrigger()&&(i.preventDefault(),e.openSubmenuForHighlighted());break}case"ArrowLeft":{if(_optionalChain([h, 'optionalAccess', _32 => _32.goBack, 'call', _33 => _33()])){i.preventDefault(),l&&h.parentSurfaceId&&l.setOwnerId(h.parentSurfaceId);break}d>0&&c&&l&&(i.preventDefault(),c.setOpen(!1),l.setOwnerId(c.parentSurfaceId));break}case"h":{if(i.ctrlKey&&_optionalChain([h, 'optionalAccess', _34 => _34.goBack, 'call', _35 => _35()])){i.preventDefault(),l&&h.parentSurfaceId&&l.setOwnerId(h.parentSurfaceId);break}i.ctrlKey&&d>0&&c&&l&&(i.preventDefault(),c.setOpen(!1),l.setOwnerId(c.parentSurfaceId));break}case"Enter":{i.preventDefault();let u=e.state.highlightedId,x=e.getHighlightedItem();if(_optionalChain([x, 'optionalAccess', _36 => _36.activatable])===!1)break;e.selectHighlighted(),_optionalChain([o, 'optionalCall', _37 => _37({itemId:u,closeOnClick:_nullishCoalesce(_optionalChain([x, 'optionalAccess', _38 => _38.closeOnClick]), () => (!0))})]);break}case"Home":{i.preventDefault(),e.setHighlightedId(null),e.highlightNext();break}case"End":{i.preventDefault(),e.setHighlightedId(null),e.highlightPrev();break}case"Escape":{if(h){i.preventDefault(),i.stopPropagation(),h.closeRootOnEsc?a():h.goBack()&&l&&h.parentSurfaceId?l.setOwnerId(h.parentSurfaceId):d>0&&c&&(c.setOpen(!1),l&&l.setOwnerId(c.parentSurfaceId));break}if(d===0)break;i.preventDefault(),i.stopPropagation(),_optionalChain([c, 'optionalAccess', _39 => _39.closeRootOnEsc])!==!1?a():(c.setOpen(!1),l&&l.setOwnerId(c.parentSurfaceId));break}default:{let u=e.state.normalizedSearch.length>0;if(i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey&&!u){let f=e.context.shortcuts.get(i.key.toLowerCase());if(f&&e.selectByShortcut(i.key)){i.preventDefault();let I=e.context.items.get(f);_optionalChain([o, 'optionalCall', _40 => _40({itemId:f,closeOnClick:_nullishCoalesce(_optionalChain([I, 'optionalAccess', _41 => _41.closeOnClick]), () => (!0))})])}}break}}}},[s,r,m,g,e,d,c,h,l,o,a])}}var je=!1,Be=!1;function w(...n){je&&console.log("[useStickyRowWidth]",...n)}function pe(n){return`${Math.ceil(n)}px`}function qe(n){let e=Number.parseFloat(n);return Number.isFinite(e)?e:null}function $e(n){let{listRef:e,targetRef:t,maxWidth:r,enabled:s=!0}=n,o=C.useCallback(()=>_nullishCoalesce(_optionalChain([t, 'optionalAccess', _42 => _42.current]), () => (e.current)),[t,e]),a=C.useRef(0);C.useLayoutEffect(()=>{if(!s)return;let i=o();if(!i)return;let u=qe(i.style.getPropertyValue("--row-width").trim());!u||u<=a.current||(a.current=u,w("Hydrated max width from existing --row-width:",{hydratedWidth:u}))},[s,o]);let l=C.useRef([]),d=C.useRef([]),c=C.useRef(!1),h=C.useRef(new Set),g=C.useCallback(i=>{let u=o();if(!u)return;let x=r!==void 0?Math.min(i,r):i;w("--row-width updated:",{rawWidth:i,cappedWidth:x,cssValue:pe(x),maxWidthCap:r,targetElement:u.tagName+(u.className?`.${u.className.split(" ").join(".")}`:"")}),u.style.setProperty("--row-width",pe(x))},[o,r]),v=C.useCallback(()=>{c.current||(c.current=!0,requestAnimationFrame(()=>{let i=l.current,u=a.current,x=!1;if(i.length>0){w("Measuring batch of",i.length,"rows");for(let{element:f,id:I}of i){if(h.current.has(I))continue;if(!f.isConnected){w("Row skipped (unmounted):",{id:I});continue}let O=f.style.width,z=f.style.maxWidth;f.setAttribute("data-measuring",""),f.style.maxWidth="none",f.style.width="max-content";let M=Math.max(f.scrollWidth,f.offsetWidth)+1,N=getComputedStyle(f);if(w("Row measurement details:",{id:I,measuredWidth:M,scrollWidth:f.scrollWidth,offsetWidth:f.offsetWidth,computedWidth:N.width,computedMaxWidth:N.maxWidth,inlineMaxWidth:z,textContent:_optionalChain([f, 'access', _43 => _43.textContent, 'optionalAccess', _44 => _44.slice, 'call', _45 => _45(0,50)])}),Be||(f.style.width=O,f.style.maxWidth=z,f.removeAttribute("data-measuring")),M<=1){let p=f.getBoundingClientRect(),F=getComputedStyle(f);w("Row skipped (0-width, will retry):",{id:I,width:M,scrollWidth:f.scrollWidth,offsetWidth:f.offsetWidth,boundingRect:{width:p.width,height:p.height},display:F.display,visibility:F.visibility,innerHTML:f.innerHTML.slice(0,100),isConnected:f.isConnected,parentElement:_optionalChain([f, 'access', _46 => _46.parentElement, 'optionalAccess', _47 => _47.tagName])});continue}w("Row measured:",{id:I,width:M,currentMax:u,isNewMax:M>u}),M>u&&(u=M,x=!0),h.current.add(I)}l.current=[]}x&&(w("New max width found:",{previousMax:a.current,newMax:u,totalMeasured:h.current.size}),a.current=u,d.current.push(()=>g(u)));for(let f of d.current)f();d.current=[],c.current=!1}))},[g]),R=C.useCallback((i,u)=>{if(!s){w("queueMeasurement skipped (disabled):",u);return}if(h.current.has(u)){w("queueMeasurement skipped (already measured):",u);return}w("queueMeasurement:",{id:u,queueSize:l.current.length+1,element:i.tagName}),l.current.push({element:i,id:u}),v()},[s,v]),m=C.useCallback(()=>{let i=a.current,u=h.current.size;h.current.clear(),a.current=0;let x=o();x&&x.style.removeProperty("--row-width"),w("Measurements reset:",{previousMaxWidth:i,previousMeasuredCount:u,targetElement:_optionalChain([x, 'optionalAccess', _48 => _48.tagName])})},[o]),E=C.useCallback(()=>{let i=h.current.size;h.current.clear(),w("Measured IDs cleared (sticky width kept):",{previousMeasuredCount:i,currentMaxWidth:a.current})},[]);return C.useEffect(()=>{if(!s)return;let i=o();if(!i||typeof ResizeObserver>"u")return;let u=null,x=new ResizeObserver(f=>{u!==null&&cancelAnimationFrame(u),u=requestAnimationFrame(()=>{u=null,a.current>0&&(w("ResizeObserver triggered re-apply:",{currentMax:a.current,containerSize:_optionalChain([f, 'access', _49 => _49[0], 'optionalAccess', _50 => _50.contentRect])}),g(a.current))})});return x.observe(i),()=>{u!==null&&cancelAnimationFrame(u),x.disconnect()}},[o,s,g]),{queueMeasurement:R,resetMeasurements:m,clearMeasuredIds:E}}var _store = require('@base-ui/utils/store');var _useRefWithInit = require('@base-ui/utils/useRefWithInit');var L={};_chunkM4G6J7DPcjs.a.call(void 0, L,{auto:()=>ft,clearPress:()=>at,closePress:()=>it,escapeKey:()=>Ze,focusOut:()=>tt,imperativeAction:()=>gt,inputChange:()=>st,inputClear:()=>ot,itemKeyboardSelect:()=>rt,itemPress:()=>nt,keyboard:()=>ht,listNavigation:()=>lt,none:()=>pt,outsidePress:()=>et,pointer:()=>dt,siblingOpen:()=>ut,submenuTrigger:()=>ct,triggerContextMenu:()=>Qe,triggerFocus:()=>Je,triggerHover:()=>Xe,triggerPress:()=>Ye});var Ye="trigger-press",Xe="trigger-hover",Je="trigger-focus",Qe="trigger-context-menu",Ze="escape-key",et="outside-press",tt="focus-out",nt="item-press",rt="item-keyboard-select",it="close-press",st="input-change",ot="input-clear",at="clear-press",lt="list-navigation",ct="submenu-trigger",ut="sibling-open",dt="pointer",ht="keyboard",ft="auto",gt="imperative-action",pt="none";function me(n,e,t,r){let s=!1,o=!1;return{reason:n,event:_nullishCoalesce(e, () => (new Event("ui-event"))),cancel(){s=!0},allowPropagation(){o=!0},get isCanceled(){return s},get isPropagationAllowed(){return o},trigger:t,...r}}function xe(n,e,t){return{reason:n,event:_nullishCoalesce(e, () => (new Event("ui-event"))),...t}}var Z=null,be=!1;function mt(n){Z=n.pointerType||"mouse"}function xt(){Z=null}function Zt(){be||typeof document>"u"||(be=!0,document.addEventListener("pointerdown",mt,{capture:!0,passive:!0}),document.addEventListener("keydown",xt,{capture:!0,passive:!0}))}function Se(n){switch(n){case"touch":return"touch";case"pen":return"pen";case"mouse":return"mouse";default:return null}}function Ie(n){let e=Se(_optionalChain([n, 'optionalAccess', _51 => _51.pointerType]));return e||(n&&typeof KeyboardEvent<"u"&&n instanceof KeyboardEvent?"keyboard":_nullishCoalesce(Se(Z), () => ("keyboard")))}var Re=1,bt=.9,St=.8,It=.17,ee=.1,te=.999,Rt=.9999;var vt=.99,Ct=/[\\/_+.#"@[({&]/,Et=/[\\/_+.#"@[({&]/g,yt=/[\s-]/,Ce=/[\s-]/g;function ne(n,e,t,r,s,o,a){if(o===e.length)return s===n.length?Re:vt;let l=`${s},${o}`;if(a[l]!==void 0)return a[l];let d=r.charAt(o),c=t.indexOf(d,s),h=0,g,v,R,m;for(;c>=0;)g=ne(n,e,t,r,c+1,o+1,a),g>h&&(c===s?g*=Re:Ct.test(n.charAt(c-1))?(g*=St,R=n.slice(s,c-1).match(Et),R&&s>0&&(g*=te**R.length)):yt.test(n.charAt(c-1))?(g*=bt,m=n.slice(s,c-1).match(Ce),m&&s>0&&(g*=te**m.length)):(g*=It,s>0&&(g*=te**(c-s))),n.charAt(c)!==e.charAt(o)&&(g*=Rt)),(g<ee&&t.charAt(c-1)===r.charAt(o+1)||r.charAt(o+1)===r.charAt(o)&&t.charAt(c-1)!==r.charAt(o))&&(v=ne(n,e,t,r,c+1,o+2,a),v*ee>g&&(g=v*ee)),g>h&&(h=g),c=t.indexOf(d,c+1);return a[l]=h,h}function ve(n){return fe(n.toLowerCase()).replace(Ce," ")}function V(n,e,t){if(!e)return 1;if(!n)return 0;let r=t&&t.length>0?`${n} ${t.join(" ")}`:n;return ne(r,e,ve(r),ve(e),0,0,{})}var wt=V;var Lt={open:_store.createSelector.call(void 0, n=>_nullishCoalesce(n.openProp, () => (n.open))),openMethod:_store.createSelector.call(void 0, n=>n.openMethod),search:_store.createSelector.call(void 0, n=>_nullishCoalesce(n.searchProp, () => (n.search))),normalizedSearch:_store.createSelector.call(void 0, n=>n.normalizedSearch),highlightedId:_store.createSelector.call(void 0, n=>n.highlightedId),highlightSource:_store.createSelector.call(void 0, n=>n.highlightSource),hasInput:_store.createSelector.call(void 0, n=>n.hasInput),inputActive:_store.createSelector.call(void 0, n=>n.inputActive),pendingSearch:_store.createSelector.call(void 0, n=>n.pendingSearch),filteredCount:_store.createSelector.call(void 0, n=>n.filteredCount),filteredItems:_store.createSelector.call(void 0, n=>n.filteredItems),visibleGroups:_store.createSelector.call(void 0, n=>n.visibleGroups),virtualized:_store.createSelector.call(void 0, n=>n.virtualized),isHighlighted:_store.createSelector.call(void 0, (n,e)=>n.highlightedId===e),isGroupVisible:_store.createSelector.call(void 0, (n,e)=>n.normalizedSearch.length===0||n.visibleGroups.has(e)),isFirstRow:_store.createSelector.call(void 0, (n,e)=>n.virtualized?!1:_optionalChain([n, 'access', _52 => _52.orderedRows, 'access', _53 => _53.filter, 'call', _54 => _54(r=>r.groupId===void 0), 'access', _55 => _55[0], 'optionalAccess', _56 => _56.id])===e),isLastRow:_store.createSelector.call(void 0, (n,e)=>n.virtualized?!1:_optionalChain([n, 'access', _57 => _57.orderedRows, 'access', _58 => _58.filter, 'call', _59 => _59(r=>r.groupId===void 0), 'access', _60 => _60.at, 'call', _61 => _61(-1), 'optionalAccess', _62 => _62.id])===e),isFirstGroup:_store.createSelector.call(void 0, (n,e)=>n.virtualized?!1:_optionalChain([n, 'access', _63 => _63.orderedRows, 'access', _64 => _64.filter, 'call', _65 => _65(r=>r.kind==="group"), 'access', _66 => _66[0], 'optionalAccess', _67 => _67.id])===e),isLastGroup:_store.createSelector.call(void 0, (n,e)=>n.virtualized?!1:_optionalChain([n, 'access', _68 => _68.orderedRows, 'access', _69 => _69.filter, 'call', _70 => _70(r=>r.kind==="group"), 'access', _71 => _71.at, 'call', _72 => _72(-1), 'optionalAccess', _73 => _73.id])===e),isFirstInGroup:_store.createSelector.call(void 0, (n,e)=>{if(n.virtualized)return!1;let t=n.orderedRows.find(s=>s.id===e);return _optionalChain([t, 'optionalAccess', _74 => _74.groupId])?_optionalChain([n, 'access', _75 => _75.orderedRows, 'access', _76 => _76.filter, 'call', _77 => _77(s=>s.groupId===t.groupId), 'access', _78 => _78[0], 'optionalAccess', _79 => _79.id])===e:!1}),isLastInGroup:_store.createSelector.call(void 0, (n,e)=>{if(n.virtualized)return!1;let t=n.orderedRows.find(s=>s.id===e);return _optionalChain([t, 'optionalAccess', _80 => _80.groupId])?_optionalChain([n, 'access', _81 => _81.orderedRows, 'access', _82 => _82.filter, 'call', _83 => _83(s=>s.groupId===t.groupId), 'access', _84 => _84.at, 'call', _85 => _85(-1), 'optionalAccess', _86 => _86.id])===e:!1}),getItemScore:_store.createSelector.call(void 0, (n,e)=>n.normalizedSearch.length===0?1:_nullishCoalesce(n.filteredItems.get(e), () => (0))),hasSearchWithNoResults:_store.createSelector.call(void 0, n=>n.normalizedSearch.length===0?!1:n.virtualized&&n.virtualItemsCount>=0?n.virtualItemsCount===0:n.filteredCount===0)};function Ee(n,e){return n.element===null||e.element===null||!n.element.isConnected||!e.element.isConnected?n.index-e.index:n.element.compareDocumentPosition(e.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var Pt=n=>P(n),re= exports.y = (_class =class n extends _store.ReactStore{constructor(e,t){let s={...{filter:V,normalizeSearch:Pt,loop:!0,autoHighlightFirst:!0,clearSearchOnClose:!0,resetScrollOnSearch:!0,hideUntilActive:!1,listId:"",inputId:"",items:new Map,groups:new Map,itemSelects:new Map,submenuOpens:new Map,submenuCloses:new Map,shortcuts:new Map,rowElements:new Map,onOpenChange:()=>{},onSearchChange:void 0,virtualItems:[],orderedItems:[],onHighlightChange:void 0,refs:{listRef:{current:null},listScrollContainerRef:{current:null},popupRef:{current:null},itemRefs:new Map,groupRefs:new Map},onCloseComplete:void 0,onPopupCloseComplete:void 0,lastPointerPosition:null},...t},o={...kt(),...e};o.normalizedSearch=s.normalizeSearch(o.search),super(o,s,Lt);_class.prototype.__init.call(this);,this.observe("open",(a,l)=>{if(a!==l)if(a)this.resetPointerPosition(),this.context.autoHighlightFirst===!0&&this.highlightFirstItem();else{this.context.clearSearchOnClose===!0&&this.setSearch("");let d=this.context.clearSearchOnClose==="after-exit";this.update({inputActive:d?this.state.inputActive:!1,pendingSearch:""})}}),this.observe("search",(a,l)=>{a!==l&&this.syncNormalizedSearch()}),this.observe(a=>a.searchProp,(a,l)=>{a!==l&&this.syncNormalizedSearch()}),this.observe("normalizedSearch",(a,l)=>{a!==l&&(this.resetPointerPosition(),this.recomputeFilteredItems(l),this.context.resetScrollOnSearch&&!this.state.virtualized&&this.scrollListToTop())})}setOpen(e,t=L.none,r){let s=me(t,r);this.context.onOpenChange(e,s),!s.isCanceled&&(e&&this.set("openMethod",Ie(r)),this.set("open",e))}setSearch(e){let t=_nullishCoalesce(this.state.searchProp, () => (e));this.update({search:e,normalizedSearch:this.context.normalizeSearch(t)}),_optionalChain([this, 'access', _87 => _87.context, 'access', _88 => _88.onSearchChange, 'optionalCall', _89 => _89(e)])}setSearchNormalizer(e){this.context.normalizeSearch=e;let t=_nullishCoalesce(this.state.searchProp, () => (this.state.search)),r=e(t);r!==this.state.normalizedSearch&&this.set("normalizedSearch",r)}syncNormalizedSearch(){let e=_nullishCoalesce(this.state.searchProp, () => (this.state.search)),t=this.context.normalizeSearch(e);t!==this.state.normalizedSearch&&this.set("normalizedSearch",t)}__init() {this.defaultSearchInitialized=!1}initializeDefaultSearch(e){this.defaultSearchInitialized||(this.defaultSearchInitialized=!0,this.state.searchProp===void 0&&e!==this.state.search&&this.setSearch(e))}setHighlightedId(e,t="pointer"){this.state.highlightedId!==e&&(this.closeSiblingSubmenus(e),this.update({highlightedId:e,highlightSource:t}),this.notifyHighlightChange(e,t),t==="keyboard"&&e!==null&&this.scrollItemIntoView(e))}notifyHighlightChange(e,t){let{onHighlightChange:r}=this.context;if(!r)return;let s=t==="keyboard"?L.keyboard:t==="pointer"?L.pointer:L.auto,o=e===null?-1:this.state.virtualized?this.getVirtualItemIndex(e):this.getVisibleItemIndex(e),a=xe(s,void 0,{index:o});r(e,o,a)}scrollItemIntoView(e){let{refs:t}=this.context,r=t.listRef.current,o=_optionalChain([t, 'access', _90 => _90.itemRefs, 'access', _91 => _91.get, 'call', _92 => _92(e), 'optionalAccess', _93 => _93.current]);if(o&&r)try{r.contains(o)&&(o.scrollIntoView({block:"nearest"}),this.maybeRevealGroupTop(e,r))}catch (e2){}}maybeRevealGroupTop(e,t){let r=_optionalChain([this, 'access', _94 => _94.context, 'access', _95 => _95.items, 'access', _96 => _96.get, 'call', _97 => _97(e), 'optionalAccess', _98 => _98.groupId]);if(!r||this.getVisibleItemIds().find(c=>_optionalChain([this, 'access', _99 => _99.context, 'access', _100 => _100.items, 'access', _101 => _101.get, 'call', _102 => _102(c), 'optionalAccess', _103 => _103.groupId])===r)!==e)return;let a=_optionalChain([this, 'access', _104 => _104.context, 'access', _105 => _105.refs, 'access', _106 => _106.groupRefs, 'access', _107 => _107.get, 'call', _108 => _108(r), 'optionalAccess', _109 => _109.current]);if(!a||!t.contains(a))return;let l=_nullishCoalesce(this.context.refs.listScrollContainerRef.current, () => (this.getScrollResetElement(t))),d=l.getBoundingClientRect().top-a.getBoundingClientRect().top;d>0&&(l.scrollTop-=d)}scrollListToTop(){let e=this.context.refs.listRef.current,t=_nullishCoalesce(this.context.refs.listScrollContainerRef.current, () => ((e?this.getScrollResetElement(e):null)));if(t){if(typeof t.scrollTo=="function"){t.scrollTo({top:0});return}t.scrollTop=0}}getScrollResetElement(e){let t=e;for(;t;){if(this.isScrollableElement(t))return t;t=t.parentElement}return e}isScrollableElement(e){let r=_optionalChain([e, 'access', _110 => _110.ownerDocument, 'optionalAccess', _111 => _111.defaultView, 'optionalAccess', _112 => _112.getComputedStyle, 'call', _113 => _113(e), 'access', _114 => _114.overflowY]),s=r==="auto"||r==="scroll"||r==="overlay";return e.scrollTop>0||s&&e.scrollHeight>e.clientHeight}setHasInput(e){this.set("hasInput",e)}setInputActive(e){this.set("inputActive",e)}setPendingSearch(e){this.set("pendingSearch",e)}setHideUntilActive(e){this.context.hideUntilActive=e,e&&this.state.normalizedSearch.length>0&&this.setInputActive(!0)}setVirtualized(e){this.set("virtualized",e)}setVirtualItems(e){let t=this.context.virtualItems;if(this.context.virtualItems=e,this.set("virtualItemsCount",e.length),this.preRegisterVirtualItems(),e===t)return;if(t.length===e.length){let a=!0;for(let l=0;l<t.length;l++){let d=t[l],c=e[l];if(!d||!c||d.value!==c.value||d.disabled!==c.disabled){a=!1;break}}if(a)return}if(!this.state.virtualized||!this.state.open||e.length===0)return;let r=t.find(a=>!a.disabled),s=e.find(a=>!a.disabled),o=r!==void 0&&_optionalChain([s, 'optionalAccess', _115 => _115.value])!==r.value;this.validateHighlight({forceFirst:o})}setOrderedItems(e,t){let r=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _116 => _116.reason]), () => ("replace")),s=this.context.orderedItems;if(this.context.orderedItems=e,e!==s&&this.state.open){if(r==="append"&&this.state.highlightedId!==null){let o=this.state.highlightedId,a=this.context.items.get(o),l=e.includes(o),d=a?!a.disabled:!1;if(l&&d)return}if(e.length>0){let o=e.find(a=>this.context.items.has(a));o!==void 0?this.setHighlightedId(o,"auto"):this.setHighlightedId(null)}else this.setHighlightedId(null)}}maybeAutoHighlightOnRegister(e){if(this.context.filter!==!1||!this.state.open||this.state.highlightedId!==null||!this.context.autoHighlightFirst)return;let t=this.context.orderedItems;if(t.length===0)return;t.find(s=>this.context.items.has(s))===e&&this.setHighlightedId(e,"auto")}setOnHighlightChange(e){this.context.onHighlightChange=e}setListRef(e){this.context.refs.listRef=e}setListScrollContainerRef(e){this.context.refs.listScrollContainerRef=e}setPopupRef(e){this.context.refs.popupRef=e}registerItemRef(e,t){return this.context.refs.itemRefs.set(e,t),()=>{this.context.refs.itemRefs.delete(e)}}shouldAllowPointerHighlight(e,t){let r=this.context.lastPointerPosition;if(r===null)return this.context.lastPointerPosition={x:e,y:t},!0;let s=Math.abs(e-r.x),o=Math.abs(t-r.y);return s>1||o>1?(this.context.lastPointerPosition={x:e,y:t},!0):!1}resetPointerPosition(){this.context.lastPointerPosition=null}preRegisterVirtualItems(){let e=this.context.virtualItems;if(e.length!==0){for(let t of e)this.context.items.has(t.value)||this.context.items.set(t.value,{value:t.value,keywords:t.keywords,disabled:t.disabled});this.recomputeFilteredItems()}}registerItem(e,t){let r=this.context.items.get(e);if(r&&r.value===t.value&&r.disabled===t.disabled&&r.forceOrder===t.forceOrder&&r.forceScore===t.forceScore&&r.groupId===t.groupId&&r.shortcut===t.shortcut&&r.activatable===t.activatable)return()=>{this.context.items.get(e)===r&&(this.context.items.delete(e),this.context.itemSelects.delete(e),t.groupId&&_optionalChain([this, 'access', _117 => _117.context, 'access', _118 => _118.groups, 'access', _119 => _119.get, 'call', _120 => _120(t.groupId), 'optionalAccess', _121 => _121.delete, 'call', _122 => _122(e)]),t.shortcut&&this.context.shortcuts.delete(t.shortcut.toLowerCase()),this.recomputeFilteredItems())};if(this.context.items.set(e,t),t.groupId){let o=this.context.groups.get(t.groupId);o&&o.add(e)}if(t.shortcut){let o=t.shortcut.toLowerCase();this.context.shortcuts.set(o,e)}return this.recomputeFilteredItems(),this.maybeAutoHighlightOnRegister(e),()=>{if(this.context.items.delete(e),this.context.itemSelects.delete(e),t.groupId){let o=this.context.groups.get(t.groupId);o&&o.delete(e)}if(t.shortcut){let o=t.shortcut.toLowerCase();this.context.shortcuts.delete(o)}this.recomputeFilteredItems()}}registerGroup(e,t){return this.context.groups.set(e,new Set),t&&this.context.refs.groupRefs.set(e,t),()=>{this.context.groups.delete(e),this.context.refs.groupRefs.delete(e)}}registerRow(e,t,r){this.context.rowElements.set(e,t);let o=[...this.state.orderedRows.filter(a=>a.id!==e),{id:e,kind:r.kind,groupId:r.groupId}];return o.sort((a,l)=>this.compareRowOrder(a,l)),this.set("orderedRows",o),()=>{this.context.rowElements.get(e)===t&&(this.context.rowElements.delete(e),this.set("orderedRows",this.state.orderedRows.filter(a=>a.id!==e)))}}compareRowOrder(e,t){let r=this.context.rowElements.get(e.id),s=this.context.rowElements.get(t.id);if(!r||!s||!r.isConnected||!s.isConnected)return 0;let o=r.compareDocumentPosition(s);return o&Node.DOCUMENT_POSITION_FOLLOWING?-1:o&Node.DOCUMENT_POSITION_PRECEDING?1:0}registerItemSelect(e,t){return t&&this.context.itemSelects.set(e,t),()=>{this.context.itemSelects.delete(e)}}registerSubmenuOpen(e,t){return t&&this.context.submenuOpens.set(e,t),()=>{this.context.submenuOpens.delete(e)}}registerSubmenuClose(e,t){return t&&this.context.submenuCloses.set(e,t),()=>{this.context.submenuCloses.delete(e)}}closeSiblingSubmenus(e){for(let[t,r]of this.context.submenuCloses)if(t!==e)try{r()}catch (e3){}}highlightNext(){let e=this.getVisibleItemIds();if(e.length===0)return;let r=(this.state.highlightedId?e.indexOf(this.state.highlightedId):-1)+1;r>=e.length&&(r=this.context.loop?0:e.length-1);let s=e[r];s&&this.setHighlightedId(s,"keyboard")}highlightPrev(){let e=this.getVisibleItemIds();if(e.length===0)return;let r=(this.state.highlightedId?e.indexOf(this.state.highlightedId):e.length)-1;r<0&&(r=this.context.loop?e.length-1:0);let s=e[r];s&&this.setHighlightedId(s,"keyboard")}selectHighlighted(){if(this.state.highlightedId){if(_optionalChain([this, 'access', _123 => _123.context, 'access', _124 => _124.items, 'access', _125 => _125.get, 'call', _126 => _126(this.state.highlightedId), 'optionalAccess', _127 => _127.activatable])===!1)return;_optionalChain([this, 'access', _128 => _128.context, 'access', _129 => _129.itemSelects, 'access', _130 => _130.get, 'call', _131 => _131(this.state.highlightedId), 'optionalCall', _132 => _132()])}}selectByShortcut(e){let t=this.context.shortcuts.get(e.toLowerCase());if(!t)return!1;let r=this.context.items.get(t);if(!r||r.disabled)return!1;let s=_nullishCoalesce(this.state.filteredItems.get(t), () => (0));return this.state.normalizedSearch.length===0||s>0?(_optionalChain([this, 'access', _133 => _133.context, 'access', _134 => _134.itemSelects, 'access', _135 => _135.get, 'call', _136 => _136(t), 'optionalCall', _137 => _137()]),!0):!1}openSubmenuForHighlighted(){this.state.highlightedId&&_optionalChain([this, 'access', _138 => _138.context, 'access', _139 => _139.submenuOpens, 'access', _140 => _140.get, 'call', _141 => _141(this.state.highlightedId), 'optionalCall', _142 => _142()])}isHighlightedSubmenuTrigger(){return this.state.highlightedId?_nullishCoalesce(_optionalChain([this, 'access', _143 => _143.context, 'access', _144 => _144.items, 'access', _145 => _145.get, 'call', _146 => _146(this.state.highlightedId), 'optionalAccess', _147 => _147.isSubmenuTrigger]), () => (!1)):!1}getHighlightedItem(){if(this.state.highlightedId)return this.context.items.get(this.state.highlightedId)}clearSearch(){this.setSearch("")}clearHighlight(){this.update({highlightedId:null,highlightSource:null})}highlightFirstItem(){let e=this.getVisibleItemIds();e.length>0&&e[0]?this.update({highlightedId:e[0],highlightSource:null}):this.update({highlightedId:null,highlightSource:null})}applyAutoHighlight(){if(!this.state.open)return;let e=this.context.autoHighlightFirst;e===!0?this.highlightFirstItem():typeof e=="string"&&this.highlightItemByValue(e)}highlightItemByValue(e){let t=this.getVisibleItemIds(),r=null;t.includes(e)?r=e:t.length>0&&t[0]&&(r=t[0]),this.update({highlightedId:r,highlightSource:null}),r&&requestAnimationFrame(()=>{this.scrollItemIntoView(r)})}isFilterDisabled(){return this.context.filter===!1}getVisibleItemIds(){let e=[],t=this.state.normalizedSearch,r=this.state.filteredItems,s=this.context.virtualItems,o=this.context.orderedItems;if(this.state.virtualized&&s.length>0){for(let d of s){let c=_nullishCoalesce(r.get(d.value), () => (0));(t.length===0||c>0)&&!d.disabled&&e.push(d.value)}return e}if(this.context.filter===!1&&o.length>0){let d=[];for(let c of o){let h=this.context.items.get(c);h&&!h.disabled?e.push(c):h||d.push(c)}if(process.env.NODE_ENV!=="production"&&d.length>0&&e.length>0)for(let c of d)console.warn(`[ListboxStore] Item "${c}" is in orderedItems but not registered. This may cause keyboard navigation to skip this item. Make sure the render function passes the \`id\` prop: <Item {...props}>...</Item>`);return e}let a=[],l=0;this.context.items.forEach((d,c)=>{let h=l++,g=_nullishCoalesce(r.get(c), () => (0));(t.length===0||g>0)&&!d.disabled&&a.push({id:c,element:_nullishCoalesce(_optionalChain([this, 'access', _148 => _148.context, 'access', _149 => _149.refs, 'access', _150 => _150.itemRefs, 'access', _151 => _151.get, 'call', _152 => _152(c), 'optionalAccess', _153 => _153.current]), () => (null)),index:h})}),a.sort(Ee);for(let{id:d}of a)e.push(d);return e}getVisibleItemIndex(e){return this.getVisibleItemIds().indexOf(e)}getVirtualItemIndex(e){return this.state.virtualized?this.context.virtualItems.findIndex(t=>t.value===e):-1}validateHighlight(e={}){let{forceFirst:t=!1,filteredItems:r=this.state.filteredItems,newSearch:s,prevSearch:o}=e,a=o!==void 0?o:this.state.normalizedSearch,l=s!==void 0?s:a,d=s!==void 0&&s!==a;if(!this.state.open||!this.context.autoHighlightFirst)return this.state.highlightedId;let c=this.state.highlightedId,{filter:h}=this.context,g=t||d,v=!1;if(c&&!g){let m=_nullishCoalesce(r.get(c), () => (0)),E=l.length===0||h===!1||m>0,i=this.context.items.get(c),u=this.context.virtualItems.find(O=>O.value===c),x=_nullishCoalesce(_nullishCoalesce(_optionalChain([i, 'optionalAccess', _154 => _154.disabled]), () => (_optionalChain([u, 'optionalAccess', _155 => _155.disabled]))), () => (!1)),f=this.state.virtualized||i!==void 0,I=!this.state.virtualized||this.context.virtualItems.length===0||u!==void 0;v=E&&!x&&f&&I}if(v)return c;let R=null;if(this.state.virtualized&&this.context.virtualItems.length>0)for(let m of this.context.virtualItems){let E=_nullishCoalesce(r.get(m.value), () => (0));if((l.length===0||h===!1||E>0)&&!m.disabled){R=m.value;break}}else if(h===!1&&this.context.orderedItems.length>0)for(let m of this.context.orderedItems){let E=this.context.items.get(m);if(E&&!E.disabled){R=m;break}}else{let m=null,E=0;for(let[i,u]of this.context.items){let x=E++,f=_nullishCoalesce(r.get(i), () => (0));if((l.length===0||f>0)&&!u.disabled){let O={id:i,element:_nullishCoalesce(_optionalChain([this, 'access', _156 => _156.context, 'access', _157 => _157.refs, 'access', _158 => _158.itemRefs, 'access', _159 => _159.get, 'call', _160 => _160(i), 'optionalAccess', _161 => _161.current]), () => (null)),index:x};(m===null||Ee(O,m)<0)&&(m=O)}}R=_nullishCoalesce(_optionalChain([m, 'optionalAccess', _162 => _162.id]), () => (null))}return R!==c&&this.update({highlightedId:R,highlightSource:null}),R}recomputeFilteredItems(e){let{filter:t}=this.context,r=this.state.normalizedSearch,s=this.context.items,o=this.context.groups,a=new Map,l=new Set,d=0;if(!r||t===!1){if(this.state.virtualized&&this.context.virtualItems.length>0)for(let h of this.context.virtualItems)a.set(h.value,1),d++;else s.forEach((h,g)=>{a.set(g,1),d++});o.forEach((h,g)=>{l.add(g)})}else{let h=t||V;s.forEach((g,v)=>{let R=h(g.value,r,g.keywords),m=_nullishCoalesce(g.forceScore, () => (R));a.set(v,m),m>0&&(d++,g.groupId&&l.add(g.groupId))})}if(t===!1){this.update({filteredItems:a,visibleGroups:l,filteredCount:d,filterTrigger:this.state.filterTrigger+1});return}let c=this.validateHighlight({filteredItems:a,newSearch:r,prevSearch:e});this.update({filteredItems:a,visibleGroups:l,filteredCount:d,filterTrigger:this.state.filterTrigger+1,highlightedId:c,highlightSource:null})}static useStore(e,t,r){return _useRefWithInit.useRefWithInit.call(void 0, ()=>_nullishCoalesce(e, () => (new n(t,r)))).current}}, _class);function kt(){return{open:!1,openProp:void 0,openMethod:null,search:"",searchProp:void 0,normalizedSearch:"",highlightedId:null,highlightSource:null,hasInput:!1,inputActive:!1,pendingSearch:"",filteredItems:new Map,visibleGroups:new Set,filteredCount:0,filterTrigger:0,virtualized:!1,virtualItemsCount:0,orderedRows:[]}}exports.a = L; exports.b = me; exports.c = Zt; exports.d = he; exports.e = B; exports.f = q; exports.g = ze; exports.h = Ne; exports.i = $; exports.j = Y; exports.k = Fe; exports.l = W; exports.m = Ge; exports.n = X; exports.o = J; exports.p = Q; exports.q = We; exports.r = P; exports.s = Ke; exports.t = _e; exports.u = Ue; exports.v = $e; exports.w = V; exports.x = wt; exports.y = re;
2
+ //# sourceMappingURL=chunk-XMZZ62VJ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-XMZZ62VJ.cjs","../src/internal/listbox/contexts/group-context.ts","../src/internal/listbox/contexts/item-context.ts","../src/internal/listbox/contexts/listbox-context.ts","../src/internal/listbox/contexts/row-width-context.ts","../src/internal/listbox/contexts/surface-context.ts","../src/internal/listbox/hooks/use-listbox-item.ts","../src/internal/listbox/utils/normalize.ts"],"names":["GroupContext","useGroupContext","ItemContext","useItemContext","context","useMaybeItemContext","ListboxContext","useListboxContext","useMaybeListboxContext","RowWidthContext","useRowWidthContext","useMaybeRowWidthContext","SurfaceContext","useSurfaceContext","useMaybeSurfaceContext","normalizeValue","value","deburr","slugify","useListboxItem","params","idProp","valueProp","keywords","disabled","activatable","forceMount","shortcut","forceOrder","forceScore","isSubmenuTrigger","onSelect","closeOnClick","onAfterSelect","children","aimGuard","store","groupContext","depth","ref","rowId","rowElement","setRowElement","inferredValue","setInferredValue","textContent","registrationId","generatedDomId","domId"],"mappings":"AAAA,ugCAAyC,uWCElB,IAoBjBA,EAAAA,CAAqB,CAAA,CAAA,aAAA,CAAwC,IAAI,CAAA,CAEhE,SAASC,CAAAA,CAAAA,CAA4C,CAC1D,OAAa,CAAA,CAAA,UAAA,CAAWD,EAAY,CACtC,CCxBA,IAiBME,CAAAA,CAAoB,CAAA,CAAA,aAAA,CAAuC,IAAI,CAAA,CAE9D,SAASC,EAAAA,CAAAA,CAAmC,CACjD,IAAMC,CAAAA,CAAgB,CAAA,CAAA,UAAA,CAAWF,CAAW,CAAA,CAC5C,EAAA,CAAI,CAACE,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,mDAAmD,CAAA,CAErE,OAAOA,CACT,CAEO,SAASC,EAAAA,CAAAA,CAA+C,CAC7D,OAAa,CAAA,CAAA,UAAA,CAAWH,CAAW,CACrC,CC7BA,IAuCMI,CAAAA,CAAuB,CAAA,CAAA,aAAA,CAA0C,IAAI,CAAA,CAEpE,SAASC,CAAAA,CAAAA,CAAyC,CACvD,IAAMH,CAAAA,CAAgB,CAAA,CAAA,UAAA,CAAWE,CAAc,CAAA,CAC/C,EAAA,CAAI,CAACF,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,2DAA2D,CAAA,CAE7E,OAAOA,CACT,CAEO,SAASI,EAAAA,CAAAA,CAAqD,CACnE,OAAa,CAAA,CAAA,UAAA,CAAWF,CAAc,CACxC,CCnDA,IAqBaG,CAAAA,CAAwB,CAAA,CAAA,aAAA,CACnC,IACF,CAAA,CAEI,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,YAAA,EAAA,CAC3BA,CAAAA,CAAgB,WAAA,CAAc,iBAAA,CAAA,CAOzB,SAASC,EAAAA,CAAAA,CAA2C,CACzD,IAAMN,CAAAA,CAAgB,CAAA,CAAA,UAAA,CAAWK,CAAe,CAAA,CAChD,EAAA,CAAI,CAACL,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,4EACF,CAAA,CAEF,OAAOA,CACT,CAOO,SAASO,CAAAA,CAAAA,CAAuD,CACrE,OAAa,CAAA,CAAA,UAAA,CAAWF,CAAe,CACzC,CClDA,IAoBMG,CAAAA,CAAuB,CAAA,CAAA,aAAA,CAA0C,IAAI,CAAA,CAEpE,SAASC,CAAAA,CAAAA,CAAyC,CACvD,IAAMT,CAAAA,CAAgB,CAAA,CAAA,UAAA,CAAWQ,CAAc,CAAA,CAC/C,EAAA,CAAI,CAACR,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,2DAA2D,CAAA,CAE7E,OAAOA,CACT,CAEO,SAASU,EAAAA,CAAAA,CAAqD,CACnE,OAAa,CAAA,CAAA,UAAA,CAAWF,CAAc,CACxC,CChCA,SCKgBG,CAAAA,CAAeC,CAAAA,CAA0C,CACvE,wCAAOA,CAAAA,6BAAO,IAAA,mBAAK,GAAA,SAAK,IAC1B,CAaO,SAASC,EAAAA,CAAOD,CAAAA,CAAuB,CAC5C,OAAOA,CAAAA,CAAM,SAAA,CAAU,KAAK,CAAA,CAAE,OAAA,CAAQ,iBAAA,CAAmB,EAAE,CAC7D,CAmBO,SAASE,EAAAA,CAAQF,CAAAA,CAA0C,CAChE,OAAKA,CAAAA,CAGHA,CAAAA,CACG,IAAA,CAAK,CAAA,CACL,WAAA,CAAY,CAAA,CAEZ,OAAA,CAAQ,MAAA,CAAQ,GAAG,CAAA,CAEnB,OAAA,CAAQ,aAAA,CAAe,EAAE,CAAA,CAEzB,OAAA,CAAQ,KAAA,CAAO,GAAG,CAAA,CAElB,OAAA,CAAQ,QAAA,CAAU,EAAE,CAAA,CAbN,EAerB,CD2JO,SAASG,EAAAA,CACdC,CAAAA,CACsB,CACtB,GAAM,CACJ,EAAA,CAAIC,CAAAA,CACJ,KAAA,CAAOC,CAAAA,CACP,QAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CAAW,CAAA,CAAA,CACX,WAAA,CAAAC,CAAAA,CAAc,CAAA,CAAA,CACd,UAAA,CAAAC,CAAAA,CAAa,CAAA,CAAA,CACb,QAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CAAAA,CACA,gBAAA,CAAAC,CAAAA,CAAmB,CAAA,CAAA,CACnB,QAAA,CAAAC,CAAAA,CACA,YAAA,CAAAC,CAAAA,CAAe,CAAA,CAAA,CACf,aAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CACF,CAAA,CAAIf,CAAAA,CAEE,CAAE,KAAA,CAAAgB,CAAM,CAAA,CAAIvB,CAAAA,CAAkB,CAAA,CAC9BwB,CAAAA,CAAepC,CAAAA,CAAgB,CAAA,CAC/B,CAAE,KAAA,CAAAqC,CAAM,CAAA,CAAI/B,CAAAA,CAAkB,CAAA,CAE9BgC,CAAAA,CAAY,CAAA,CAAA,MAAA,CAAuB,IAAI,CAAA,CAGvCC,CAAAA,CAAc,CAAA,CAAA,KAAA,CAAM,CAAA,CACpB,CAACC,CAAAA,CAAYC,CAAa,CAAA,CAAU,CAAA,CAAA,QAAA,CAA6B,IAAI,CAAA,CAErE,CAAA,CAAA,eAAA,CAAgB,CAAA,CAAA,EAAM,CAC1B,EAAA,CAAKD,CAAAA,CACL,OAAOL,CAAAA,CAAM,WAAA,CAAYI,CAAAA,CAAOC,CAAAA,CAAY,CAC1C,IAAA,CAAM,MAAA,CACN,OAAA,iBAASJ,CAAAA,6BAAc,SACzB,CAAC,CACH,CAAA,CAAG,CAACI,CAAAA,CAAYD,CAAAA,iBAAOH,CAAAA,6BAAc,SAAA,CAASD,CAAK,CAAC,CAAA,CAGpD,GAAM,CAACO,CAAAA,CAAeC,CAAgB,CAAA,CAAU,CAAA,CAAA,QAAA,CAAiB,EAAE,CAAA,CAG7D,CAAA,CAAA,eAAA,CAAgB,CAAA,CAAA,EAAM,CAC1B,EAAA,CAAIvB,CAAAA,GAAW,KAAA,CAAA,EAAaC,CAAAA,GAAc,KAAA,CAAA,EAAaiB,CAAAA,CAAI,OAAA,CAAS,CAClE,IAAMM,CAAAA,kCAAcN,CAAAA,qBAAI,OAAA,qBAAQ,WAAA,6BAAa,IAAA,mBAAK,GAAA,SAAK,IAAA,CACvDK,CAAAA,CAAiBC,CAAW,CAC9B,CACF,CAAA,CAAG,CAACxB,CAAAA,CAAQC,CAAAA,CAAWY,CAAQ,CAAC,CAAA,CAKhC,IAAMY,CAAAA,kBAAiBzB,CAAAA,SAAAA,CAAWN,CAAAA,CAAeO,CAAS,CAAA,EAAKqB,CAAAA,GAAAA,CAKzDI,CAAAA,CAAuB,CAAA,CAAA,KAAA,CAAM,CAAA,CAC7BC,CAAAA,kBAAQ3B,CAAAA,SAAU,CAAA,KAAA,EAAQ0B,CAAc,CAAA,GAAA","file":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-XMZZ62VJ.cjs","sourcesContent":[null,"'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Group Context (for items to know their parent group)\n// ============================================================================\n\nexport interface GroupPositional {\n first?: boolean\n last?: boolean\n firstInGroup?: boolean\n lastInGroup?: boolean\n firstGroup?: boolean\n lastGroup?: boolean\n}\n\nexport interface GroupContextValue {\n groupId?: string\n positional?: GroupPositional\n}\n\nconst GroupContext = React.createContext<GroupContextValue | null>(null)\n\nexport function useGroupContext(): GroupContextValue | null {\n return React.useContext(GroupContext)\n}\n\nexport { GroupContext }\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Item Context (for child components like indicators to access item state)\n// ============================================================================\n\nexport interface ItemContextValue {\n /** Unique ID for this item (for DOM id attribute) */\n id: string\n /** Whether the item is highlighted */\n highlighted: boolean\n /** Whether the item is disabled */\n disabled: boolean\n /** Keyboard shortcut for this item */\n shortcut?: string\n}\n\nconst ItemContext = React.createContext<ItemContextValue | null>(null)\n\nexport function useItemContext(): ItemContextValue {\n const context = React.useContext(ItemContext)\n if (!context) {\n throw new Error('Item child components must be used within an Item')\n }\n return context\n}\n\nexport function useMaybeItemContext(): ItemContextValue | null {\n return React.useContext(ItemContext)\n}\n\nexport { ItemContext }\n","'use client'\n\nimport * as React from 'react'\nimport type { HighlightChangeEventDetails } from '../../popup-menu/events.js'\nimport type { ListboxStore, VirtualItem } from '../store/ListboxStore.js'\n\n/**\n * Virtualization configuration passed from Root/Submenu to Surface.\n */\nexport interface VirtualizationConfig {\n /** Whether virtualization mode is enabled */\n virtualized: boolean\n /** Pre-registered items for virtualization */\n items: VirtualItem[]\n /**\n * Callback when highlighted item changes (for scroll sync).\n * The third parameter contains event details including the reason for the change.\n */\n onHighlightChange?: (\n id: string | null,\n index: number,\n eventDetails: HighlightChangeEventDetails,\n ) => void\n}\n\nexport interface ListboxContextValue {\n /** The Listbox store instance */\n store: ListboxStore\n /** Nesting depth: 0 = root menu, 1+ = submenu */\n depth: number\n /** Close the entire menu tree (deepest submenu to root, sequentially) */\n closeAll: () => void\n /** Register a surface (submenu) for closeAll tracking. Returns unregister function. */\n registerSurface: (\n depth: number,\n setOpen: (open: boolean) => void,\n ) => () => void\n /** Virtualization configuration (if enabled) */\n virtualization?: VirtualizationConfig\n}\n\nconst ListboxContext = React.createContext<ListboxContextValue | null>(null)\n\nexport function useListboxContext(): ListboxContextValue {\n const context = React.useContext(ListboxContext)\n if (!context) {\n throw new Error('Listbox components must be used within a Listbox provider')\n }\n return context\n}\n\nexport function useMaybeListboxContext(): ListboxContextValue | null {\n return React.useContext(ListboxContext)\n}\n\nexport { ListboxContext }\n","'use client'\n\nimport * as React from 'react'\n\n/**\n * Context value for row width measurement.\n * Provided by List when `measureRowWidth` is enabled.\n */\nexport interface RowWidthContextValue {\n /**\n * Queue a row element for width measurement.\n * Call this when a row mounts or becomes visible.\n *\n * @param element - The DOM element to measure\n * @param id - Unique identifier for this row (used to avoid re-measuring)\n */\n queueMeasurement: (element: HTMLElement, id: string) => void\n}\n\n/**\n * Context for row width measurement.\n * Items use this to self-register for measurement.\n */\nexport const RowWidthContext = React.createContext<RowWidthContextValue | null>(\n null,\n)\n\nif (process.env.NODE_ENV !== 'production') {\n RowWidthContext.displayName = 'RowWidthContext'\n}\n\n/**\n * Hook to get the row width context.\n * Throws an error if used outside of a List with `measureRowWidth` enabled.\n */\nexport function useRowWidthContext(): RowWidthContextValue {\n const context = React.useContext(RowWidthContext)\n if (!context) {\n throw new Error(\n 'useRowWidthContext must be used within a List with measureRowWidth enabled',\n )\n }\n return context\n}\n\n/**\n * Hook to optionally get the row width context.\n * Returns null if not within a List with `measureRowWidth` enabled.\n * This is the preferred hook for items that should work both with and without measurement.\n */\nexport function useMaybeRowWidthContext(): RowWidthContextValue | null {\n return React.useContext(RowWidthContext)\n}\n","'use client'\n\nimport * as React from 'react'\nimport type { ListboxStore } from '../store/ListboxStore.js'\n\n// Re-export types from the store for convenience\nexport type {\n FilterFn,\n ItemRegistration,\n} from '../store/ListboxStore.js'\n\n// ============================================================================\n// Surface Context\n// ============================================================================\n\nexport interface SurfaceContextValue {\n /** The Listbox store instance */\n store: ListboxStore\n /** Unique identifier for this surface */\n surfaceId: string\n}\n\nconst SurfaceContext = React.createContext<SurfaceContextValue | null>(null)\n\nexport function useSurfaceContext(): SurfaceContextValue {\n const context = React.useContext(SurfaceContext)\n if (!context) {\n throw new Error('Listbox components must be used within a Surface provider')\n }\n return context\n}\n\nexport function useMaybeSurfaceContext(): SurfaceContextValue | null {\n return React.useContext(SurfaceContext)\n}\n\nexport { SurfaceContext }\n","'use client'\n\nimport * as React from 'react'\nimport { useGroupContext } from '../contexts/group-context.js'\nimport type { ItemContextValue } from '../contexts/item-context.js'\nimport { useListboxContext } from '../contexts/listbox-context.js'\nimport { useMaybeRowWidthContext } from '../contexts/row-width-context.js'\nimport { useSurfaceContext } from '../contexts/surface-context.js'\nimport { normalizeValue } from '../utils/normalize.js'\n\n/**\n * Aim guard refs for submenu navigation.\n * Optional - only needed for popup menus with submenus.\n */\nexport interface AimGuardRefs {\n /** Whether aim guard is currently active */\n aimGuardActiveRef: React.RefObject<boolean>\n /** The depth at which aim guard is active (null when not guarding) */\n guardedDepthRef: React.RefObject<number | null>\n}\n\n/**\n * Parameters for the useListboxItem hook.\n */\nexport interface UseListboxItemParams {\n /**\n * Explicit unique identifier for this item in the store.\n * Takes highest priority for item registration.\n * Used by data-first APIs to ensure consistent IDs.\n */\n id?: string\n\n /**\n * Unique value for this item used as identifier and for filtering.\n * If not provided, will be inferred from textContent.\n * Used for registration when `id` is not provided.\n */\n value?: string\n\n /**\n * Additional keywords to match against when filtering.\n * Useful for aliases or synonyms.\n */\n keywords?: string[]\n\n /**\n * Whether this item is disabled.\n * Disabled items are not selectable and are skipped during keyboard navigation.\n */\n disabled?: boolean\n\n /**\n * Whether this item can be activated via Enter or click.\n * Non-activatable items remain highlightable.\n * @default true\n */\n activatable?: boolean\n\n /**\n * Whether to force render this item regardless of filter results.\n * @default false\n */\n forceMount?: boolean\n\n /**\n * Keyboard shortcut to trigger this item.\n * When the menu is focused and the user presses this key, the item will be selected.\n * Should be a single character (e.g., \"1\", \"a\", etc.).\n */\n shortcut?: string\n\n /**\n * Forces this row's relative order during score-based sorting.\n * Lower values appear earlier.\n * @default 0\n */\n forceOrder?: number\n\n /**\n * Overrides this row's computed fuzzy-match score.\n * Useful for pinning or manually ranking rows in score-based views.\n */\n forceScore?: number\n\n /**\n * Whether this item is a submenu trigger (for store registration).\n * @default false\n */\n isSubmenuTrigger?: boolean\n\n /**\n * Callback when this item is selected (via click or Enter key).\n * For simple items, pass this directly. For checkbox/radio items,\n * use registerSelect() to register a dynamic handler.\n */\n onSelect?: () => void\n\n /**\n * Whether selecting this item should close the menu.\n * @default true\n */\n closeOnClick?: boolean\n\n /**\n * Callback invoked after selection occurs (via click).\n * Called with the item's ID. The consumer handles any\n * post-selection behavior like closing menus.\n */\n onAfterSelect?: (itemId: string) => void\n\n /**\n * Children (used for text content inference when value is not provided).\n */\n children?: React.ReactNode\n\n /**\n * Optional aim guard refs for popup menu navigation.\n * When provided, pointer move events will respect the aim guard.\n */\n aimGuard?: AimGuardRefs\n}\n\n/**\n * Return value from the useListboxItem hook.\n */\nexport interface UseListboxItemReturn {\n /** Unique ID for this item (DOM ID for aria-activedescendant) */\n id: string\n\n /**\n * Store identifier for this item.\n * Use this when calling store methods like setHighlightedId, registerSubmenuOpen, etc.\n * This is the `value` prop (or inferred from textContent).\n */\n storeId: string\n\n /** Ref to attach to the item element */\n ref: React.RefObject<HTMLDivElement | null>\n\n /** Callback ref that tracks the mounted row element for positional attributes. Merge into the rendered element's ref. */\n rowRef: (element: HTMLElement | null) => void\n\n /** Positional state among visible rows (all false in virtualized mode). */\n positional: {\n first: boolean\n last: boolean\n firstInGroup: boolean\n lastInGroup: boolean\n }\n\n /** Whether item is currently highlighted */\n isHighlighted: boolean\n\n /** Whether item should be rendered (passes filter) */\n isVisible: boolean\n\n /** Context value to provide to children via ItemContext.Provider */\n contextValue: ItemContextValue\n\n /**\n * Event handlers to spread on the element.\n * These handle click, pointer move, and pointer down events.\n */\n handlers: {\n onClick: React.MouseEventHandler<HTMLDivElement>\n onPointerMove: React.PointerEventHandler<HTMLDivElement>\n onPointerDown: React.PointerEventHandler<HTMLDivElement>\n }\n\n /**\n * Register a custom onSelect handler.\n * This is useful for checkbox/radio items where the select behavior\n * needs to be customized (e.g., toggle checked state).\n * Returns an unregister function.\n */\n registerSelect: (handler: (() => void) | undefined) => () => void\n}\n\n/**\n * Hook that provides all shared logic for navigatable/highlightable listbox items.\n *\n * This hook handles:\n * - Item registration with the listbox store\n * - Highlight state management (keyboard and pointer)\n * - Filter/search visibility\n * - Scroll into view on keyboard navigation\n * - Click, pointer move, and pointer down event handlers\n * - Optional aim guard integration (for submenu navigation)\n *\n * @example\n * ```tsx\n * function CustomItem(props) {\n * const item = useListboxItem({\n * value: props.value,\n * disabled: props.disabled,\n * onSelect: props.onSelect,\n * })\n *\n * if (!item.isVisible) return null\n *\n * return (\n * <ItemContext.Provider value={item.contextValue}>\n * <div\n * ref={item.ref}\n * {...item.handlers}\n * data-highlighted={item.isHighlighted || undefined}\n * >\n * {props.children}\n * </div>\n * </ItemContext.Provider>\n * )\n * }\n * ```\n */\nexport function useListboxItem(\n params: UseListboxItemParams,\n): UseListboxItemReturn {\n const {\n id: idProp,\n value: valueProp,\n keywords,\n disabled = false,\n activatable = true,\n forceMount = false,\n shortcut,\n forceOrder,\n forceScore,\n isSubmenuTrigger = false,\n onSelect,\n closeOnClick = true,\n onAfterSelect,\n children,\n aimGuard,\n } = params\n\n const { store } = useSurfaceContext()\n const groupContext = useGroupContext()\n const { depth } = useListboxContext()\n\n const ref = React.useRef<HTMLDivElement>(null)\n\n // Positional row registry: stable per-instance row id + mounted element\n const rowId = React.useId()\n const [rowElement, setRowElement] = React.useState<HTMLElement | null>(null)\n\n React.useLayoutEffect(() => {\n if (!rowElement) return undefined\n return store.registerRow(rowId, rowElement, {\n kind: 'item',\n groupId: groupContext?.groupId,\n })\n }, [rowElement, rowId, groupContext?.groupId, store])\n\n // Infer value from textContent if not provided\n const [inferredValue, setInferredValue] = React.useState<string>('')\n\n // biome-ignore lint/correctness/useExhaustiveDependencies(children): children is an intentional trigger dep — re-infer the value from textContent when content changes\n React.useLayoutEffect(() => {\n if (idProp === undefined && valueProp === undefined && ref.current) {\n const textContent = ref.current.textContent?.trim() ?? ''\n setInferredValue(textContent)\n }\n }, [idProp, valueProp, children])\n\n // Registration ID priority: id prop > value prop > textContent inference\n // This ensures data-first APIs can provide explicit IDs that match their internal tracking\n // Note: valueProp is normalized (trimmed) to match cmdk's behavior\n const registrationId = idProp ?? (normalizeValue(valueProp) || inferredValue)\n\n // Generate a stable ID for DOM id attribute (aria-activedescendant, etc.)\n // When id prop is provided (data-first APIs), use it directly for DOM ID\n // This ensures aria-activedescendant works correctly with composite IDs\n const generatedDomId = React.useId()\n const domId = idProp ?? `item-${generatedDomId}`\n\n // Stabilize keywords to prevent infinite loops when passed as inline arrays\n // We use JSON.stringify to compare by value rather than reference\n // Keywords are also normalized (trimmed) to match cmdk's behavior\n const normalizedKeywords = keywords\n ?.map((k) => normalizeValue(k))\n .filter(Boolean)\n const keywordsKey = normalizedKeywords\n ? JSON.stringify(normalizedKeywords)\n : undefined\n\n // Register item with store (using registrationId as the unique identifier)\n // biome-ignore lint/correctness/useExhaustiveDependencies: keywordsKey is a stable by-value stand-in for normalizedKeywords — depending on the array itself (new identity every render) causes an infinite register/recompute loop\n React.useEffect(() => {\n if (!registrationId && !forceMount) return\n\n const unregister = store.registerItem(registrationId, {\n value: registrationId,\n keywords: normalizedKeywords,\n groupId: groupContext?.groupId,\n disabled,\n activatable,\n isSubmenuTrigger,\n shortcut,\n forceOrder,\n forceScore,\n closeOnClick,\n })\n\n return unregister\n }, [\n registrationId,\n keywordsKey,\n groupContext?.groupId,\n disabled,\n activatable,\n isSubmenuTrigger,\n shortcut,\n forceOrder,\n forceScore,\n closeOnClick,\n store,\n forceMount,\n ])\n\n // Register DOM ref with store for scroll behavior\n React.useEffect(() => {\n if (!registrationId) return\n return store.registerItemRef(registrationId, ref)\n }, [registrationId, store])\n\n // Register for row width measurement if enabled\n const rowWidthContext = useMaybeRowWidthContext()\n\n React.useLayoutEffect(() => {\n if (rowWidthContext && ref.current && registrationId) {\n rowWidthContext.queueMeasurement(ref.current, registrationId)\n }\n }, [rowWidthContext, registrationId])\n\n // Register onSelect handler if provided directly\n React.useEffect(() => {\n if (!onSelect || !registrationId) return\n return store.registerItemSelect(registrationId, onSelect)\n }, [registrationId, onSelect, store])\n\n // Use selectors to get derived state (using registrationId as identifier)\n const normalizedSearch = store.useState('normalizedSearch')\n const isHighlighted = store.useState('isHighlighted', registrationId)\n const isFirstRow = store.useState('isFirstRow', rowId)\n const isLastRow = store.useState('isLastRow', rowId)\n const isFirstInGroup = store.useState('isFirstInGroup', rowId)\n const isLastInGroup = store.useState('isLastInGroup', rowId)\n const score = store.useState('getItemScore', registrationId)\n\n // Check if filtering is disabled (consumer handles filtering externally)\n const filterDisabled = store.isFilterDisabled()\n\n // Determine visibility based on filter score\n // When filterDisabled, consumer handles filtering so all items are visible\n const hasSearch = normalizedSearch.length > 0\n const isVisible = forceMount || filterDisabled || !hasSearch || score > 0\n\n // Note: Scroll behavior is now handled by the store's setHighlightedId method.\n // It uses the registered DOM refs to call scrollIntoView when the element exists,\n // or falls back to onHighlightChange for virtualizer sync.\n\n // Event handlers\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return\n if (disabled) return\n if (activatable === false) return\n if (!registrationId) return\n\n event.preventDefault()\n\n // Call the registered onSelect handler via store\n const registeredHandler = store.context.itemSelects.get(registrationId)\n registeredHandler?.()\n\n // Notify consumer that selection occurred (for closing menus, etc.)\n onAfterSelect?.(registrationId)\n },\n [disabled, activatable, store, registrationId, onAfterSelect],\n )\n\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n event.preventDefault()\n },\n [],\n )\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return\n if (disabled) return\n if (!registrationId) return\n\n // Don't highlight if aim guard is active at this depth (user is moving toward submenu)\n // Only block highlighting in the same menu where the trigger is located\n if (aimGuard) {\n const { aimGuardActiveRef, guardedDepthRef } = aimGuard\n if (aimGuardActiveRef.current && guardedDepthRef.current === depth)\n return\n }\n\n // Check if pointer has actually moved - prevents phantom highlights when\n // content shifts under a stationary pointer (e.g., search results changing)\n if (!store.shouldAllowPointerHighlight(event.clientX, event.clientY)) {\n return\n }\n\n // Highlight on hover (using registrationId as identifier)\n store.setHighlightedId(registrationId)\n },\n [disabled, aimGuard, depth, store, registrationId],\n )\n\n // Context value for child components\n const contextValue: ItemContextValue = React.useMemo(\n () => ({\n id: domId,\n highlighted: isHighlighted,\n disabled,\n shortcut,\n }),\n [domId, isHighlighted, disabled, shortcut],\n )\n\n // Register a custom select handler (for checkbox/radio items)\n const registerSelect = React.useCallback(\n (handler: (() => void) | undefined) => {\n if (!registrationId) return () => {}\n return store.registerItemSelect(registrationId, handler)\n },\n [store, registrationId],\n )\n\n const handlers = React.useMemo(\n () => ({\n onClick: handleClick,\n onPointerMove: handlePointerMove,\n onPointerDown: handlePointerDown,\n }),\n [handleClick, handlePointerMove, handlePointerDown],\n )\n\n const contextPositional = groupContext?.positional\n const positional = React.useMemo(\n () => ({\n first: contextPositional?.first ?? isFirstRow,\n last: contextPositional?.last ?? isLastRow,\n firstInGroup: contextPositional?.firstInGroup ?? isFirstInGroup,\n lastInGroup: contextPositional?.lastInGroup ?? isLastInGroup,\n }),\n [contextPositional, isFirstRow, isLastRow, isFirstInGroup, isLastInGroup],\n )\n\n return {\n id: domId,\n storeId: registrationId,\n ref,\n rowRef: setRowElement,\n positional,\n isHighlighted,\n isVisible,\n contextValue,\n handlers,\n registerSelect,\n }\n}\n","/**\n * Normalizes a value string for use in filtering and identification.\n * Trims leading/trailing whitespace to match cmdk's behavior.\n *\n * @param value - The value to normalize\n * @returns The trimmed value, or empty string if value is nullish\n */\nexport function normalizeValue(value: string | undefined | null): string {\n return value?.trim() ?? ''\n}\n\n/**\n * Remove diacritics/accents from a string so unaccented queries match accented\n * content (e.g. \"cafe\" matches \"café\", \"municao\" matches \"munição\").\n *\n * Uses Unicode NFD decomposition and strips combining marks. Characters that\n * do not decompose into a base letter plus a combining mark (e.g. \"ø\", \"ł\")\n * are intentionally left unchanged.\n *\n * @param value - The value to fold\n * @returns The value with combining diacritical marks removed\n */\nexport function deburr(value: string): string {\n return value.normalize('NFD').replace(/\\p{Diacritic}/gu, '')\n}\n\n/**\n * Converts a value string to a URL-safe slug for use in IDs.\n * - Trims whitespace\n * - Converts to lowercase\n * - Replaces spaces with hyphens\n * - Removes non-alphanumeric characters (except hyphens)\n * - Collapses multiple hyphens into one\n * - Removes leading/trailing hyphens\n *\n * @example\n * slugify(\"User Settings\") // \"user-settings\"\n * slugify(\" Hello World! \") // \"hello-world\"\n * slugify(\"Café & Co.\") // \"caf-co\"\n *\n * @param value - The value to slugify\n * @returns The slugified value, or empty string if value is nullish\n */\nexport function slugify(value: string | undefined | null): string {\n if (!value) return ''\n\n return (\n value\n .trim()\n .toLowerCase()\n // Replace spaces with hyphens\n .replace(/\\s+/g, '-')\n // Remove non-alphanumeric characters (except hyphens)\n .replace(/[^a-z0-9-]/g, '')\n // Collapse multiple hyphens into one\n .replace(/-+/g, '-')\n // Remove leading/trailing hyphens\n .replace(/^-|-$/g, '')\n )\n}\n"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk5T5B5SPRcjs = require('../chunk-5T5B5SPR.cjs');var _chunkW4ACKMIZcjs = require('../chunk-W4ACKMIZ.cjs');var _chunkXMZZ62VJcjs = require('../chunk-XMZZ62VJ.cjs');var _chunkM4G6J7DPcjs = require('../chunk-M4G6J7DP.cjs');var zo={};_chunkM4G6J7DPcjs.a.call(void 0, zo,{Arrow:()=>_chunkW4ACKMIZcjs.s,Backdrop:()=>_chunkW4ACKMIZcjs.t,Clear:()=>Me,Empty:()=>_chunkW4ACKMIZcjs.U,Group:()=>_chunkW4ACKMIZcjs.pa,GroupLabel:()=>_chunkW4ACKMIZcjs.W,Icon:()=>_chunkW4ACKMIZcjs.T,Input:()=>we,InputWrapper:()=>ke,Item:()=>Te,ItemIndicator:()=>He,ItemLabel:()=>Oe,List:()=>_chunkW4ACKMIZcjs.ba,Popup:()=>_chunkW4ACKMIZcjs.J,Portal:()=>_chunkW4ACKMIZcjs.K,Positioner:()=>De,Root:()=>Ae,ScrollDownArrow:()=>_chunkW4ACKMIZcjs.ea,ScrollUpArrow:()=>_chunkW4ACKMIZcjs.da,Separator:()=>_chunkW4ACKMIZcjs.sa,Surface:()=>Fe,useComboboxPositionerContext:()=>Ee});var _userender = require('@base-ui/react/use-render');var _react = require('react'); var _ = _interopRequireWildcard(_react); var xe = _interopRequireWildcard(_react); var ne = _interopRequireWildcard(_react); var Ce = _interopRequireWildcard(_react); var se = _interopRequireWildcard(_react); var T = _interopRequireWildcard(_react); var re = _interopRequireWildcard(_react); var E = _interopRequireWildcard(_react); var le = _interopRequireWildcard(_react); var Ie = _interopRequireWildcard(_react); var Y = _interopRequireWildcard(_react); var U = _interopRequireWildcard(_react); var h = _interopRequireWildcard(_react); var Z = _interopRequireWildcard(_react);var ko={slot:"bazzaui-combobox-clear"};var Me=_.forwardRef(function(e,o){let{keepMounted:i=!1,disabled:u,render:s,className:p,style:c,onClick:a,onPointerDown:t,...P}=e,m=_chunkW4ACKMIZcjs.w.call(void 0, ),b=_nullishCoalesce(u, () => (m.disabled)),I=m.multiple?m.values.length>0:m.value!=="",d=_.useCallback(R=>{_optionalChain([a, 'optionalCall', _2 => _2(R)]),!R.defaultPrevented&&(m.multiple?m.onValuesChange([]):m.onValueChange(""),m.onInputValueChange(""))},[a,m]),g=_.useCallback(R=>{R.preventDefault(),_optionalChain([t, 'optionalCall', _3 => _3(R)])},[t]),l=_.useMemo(()=>({hasValue:I,disabled:b}),[I,b]),S=_userender.useRender.call(void 0, {render:s,ref:o,state:l,props:{...P,[ko.slot]:"",type:"button",tabIndex:-1,"aria-label":"Clear selection",disabled:b||!I,className:p,style:c,onClick:d,onPointerDown:g},enabled:i||I,defaultTagName:"button"});return!i&&!I?null:S});var fe=xe.createContext(null);function Ee(){return xe.useContext(fe)}var Le=Ce.createContext(!1);function To(){return Ce.useContext(Le)}var Q={slot:"bazzaui-combobox-input",open:"data-open",closed:"data-closed",disabled:"data-disabled",placeholder:"data-placeholder"};function Ho(x){let{comboboxContext:e,open:o}=x,i=e.multiple?e.values.length>0:!_chunkW4ACKMIZcjs.Q.call(void 0, e.value),u=se.useCallback(c=>{let a=_chunkW4ACKMIZcjs.S.call(void 0, c,e.itemToStringValue),t=e.itemTextRegistry.get(a);if(t!==void 0)return t;let P=_chunk5T5B5SPRcjs.f.call(void 0, e.items,a);if(typeof P=="string")return P;let m=_chunkW4ACKMIZcjs.R.call(void 0, c,e.itemToStringLabel);if(m&&m!==a)return m},[e.itemTextRegistry,e.items,e.itemToStringLabel,e.itemToStringValue]),s=se.useMemo(()=>{if(!i)return"";if(e.multiple){let t=e.values.map(P=>{let m=u(P);return m!==void 0?m:_chunkW4ACKMIZcjs.R.call(void 0, P,e.itemToStringLabel)||_chunkW4ACKMIZcjs.S.call(void 0, P,e.itemToStringValue)}).filter(Boolean);return t.length<=2?t.join(", "):`${t.length} selected`}let c=e.value;if(c==null)return"";let a=u(c);return a!==void 0?a:_chunkW4ACKMIZcjs.R.call(void 0, c,e.itemToStringLabel)||_chunkW4ACKMIZcjs.S.call(void 0, c,e.itemToStringValue)},[i,e.multiple,e.value,e.values,e.itemToStringLabel,e.itemToStringValue,u]),p=se.useMemo(()=>o?e.inputValue:s,[o,s,e.inputValue]);return{hasValue:i,displayValue:p,selectedLabel:s,getValueText:u}}function Oo(x){let{comboboxContext:e,store:o,focusOwnerStore:i,open:u,disabled:s,cursorBehavior:p,hasValue:c,getValueText:a,onFocus:t,onBlur:P,onClick:m,onKeyDown:b}=x,I=T.useRef(!1),d=T.useRef(!1),g=T.useRef(!1),l=T.useRef(null),S=T.useRef(null),R=T.useRef(null);T.useEffect(()=>{if(!u)return;let n=f=>{let r=e.inputRef.current,v=e.inputWrapperRef.current,y=document.getElementById(e.listId),O=f.target,W=_optionalChain([r, 'optionalAccess', _4 => _4.contains, 'call', _5 => _5(O)]),z=_optionalChain([v, 'optionalAccess', _6 => _6.contains, 'call', _7 => _7(O)]),ee=_optionalChain([y, 'optionalAccess', _8 => _8.contains, 'call', _9 => _9(O)]);!W&&!z&&!ee&&(R.current=f)};return document.addEventListener("pointerdown",n,!0),()=>{document.removeEventListener("pointerdown",n,!0),R.current=null}},[u,e.inputRef,e.inputWrapperRef,e.listId]),T.useLayoutEffect(()=>{let n=e.inputRef.current;if(n&&u&&S.current){let{start:f,end:r}=S.current,v=n.selectionStart,y=n.value.length;v===y&&f!==y&&n.setSelectionRange(f,r),S.current=null}});let L=T.useRef(u);T.useLayoutEffect(()=>{if(u&&!L.current){if(I.current){I.current=!1,L.current=u;return}if(g.current){g.current=!1,d.current=!1,l.current=null,L.current=u;return}if(d.current&&p==="none"){let f=e.inputRef.current,r=l.current;f&&r!==null&&requestAnimationFrame(()=>{let v=f.value.length,y=Math.min(r,v);f.setSelectionRange(y,y)}),d.current=!1,l.current=null,L.current=u;return}c&&e.multiple&&e.onInputValueChange("");let n=e.inputRef.current;if(n){let f=n.value.length;p==="select-all"&&f>0?requestAnimationFrame(()=>{n.setSelectionRange(0,n.value.length)}):p==="end"&&f>0&&requestAnimationFrame(()=>{n.setSelectionRange(n.value.length,n.value.length)})}}L.current=u},[u,e,c,p]);let w=T.useCallback(n=>{let f=n.target,r=f.value,v=f.selectionStart,y=f.selectionEnd;v!==null&&y!==null&&(S.current={start:v,end:y}),e.onInputValueChange(r),e.setFilterActive(),o.setSearch(r),o.state.open||(I.current=!0,e.openCombobox())},[e,o]),k=T.useCallback(n=>{if(_optionalChain([t, 'optionalCall', _10 => _10(n)]),n.defaultPrevented)return;let f=o.state.open;if(f&&(g.current=!0),e.openOnFocus&&!s&&!f){if(c&&!e.multiple){let r=_nullishCoalesce(a(e.value), () => (_chunkW4ACKMIZcjs.R.call(void 0, e.value,e.itemToStringLabel)));e.onInputValueChange(r)}e.openCombobox()}},[t,e,s,o,c,a]),V=T.useCallback(n=>{_optionalChain([P, 'optionalCall', _11 => _11(n)]),!n.defaultPrevented&&requestAnimationFrame(()=>{let f=document.activeElement,v=_optionalChain([document, 'access', _12 => _12.getElementById, 'call', _13 => _13(e.listId), 'optionalAccess', _14 => _14.contains, 'call', _15 => _15(f)]),y=f===e.inputRef.current;if(!v&&!y){g.current=!1;let O=R.current,W=O?_chunkXMZZ62VJcjs.a.outsidePress:_chunkXMZZ62VJcjs.a.focusOut;R.current=null,e.closeCombobox(W,_nullishCoalesce(O, () => (void 0)))}})},[P,e]),A=T.useCallback(n=>{if(_optionalChain([m, 'optionalCall', _16 => _16(n)]),n.defaultPrevented)return;let f=o.state.open;if(!s&&!f){let r=n.target;if(p==="none"){let v=r.selectionStart;l.current=v,d.current=!0}if(c&&!e.multiple){let v=_nullishCoalesce(a(e.value), () => (_chunkW4ACKMIZcjs.R.call(void 0, e.value,e.itemToStringLabel)));e.onInputValueChange(v)}e.openCombobox()}else f&&(g.current=!0)},[m,e,s,o,p,c,a]),K=T.useCallback(n=>{if(_optionalChain([b, 'optionalCall', _17 => _17(n)]),!n.defaultPrevented){if(u&&n.key==="Escape"){n.preventDefault(),e.closeCombobox(_chunkXMZZ62VJcjs.a.escapeKey);return}if(!u&&(n.key==="ArrowDown"||n.key==="ArrowUp"||n.key==="Enter")){if(n.preventDefault(),c&&!e.multiple){let f=_nullishCoalesce(a(e.value), () => (_chunkW4ACKMIZcjs.R.call(void 0, e.value,e.itemToStringLabel)));e.onInputValueChange(f)}e.openCombobox();return}}},[u,e,b,c,a]),{handleKeyDown:j}=_chunkW4ACKMIZcjs.P.call(void 0, {store:o,surfaceId:"combobox-input",focusOwnerStore:i,depth:0,submenuContext:null,subpageContext:null,enabled:u,enableTypeToSearch:!1,onKeyDown:K,closeAll:e.closeCombobox,skipFocusOwnerCheck:!0});return{handleChange:w,handleFocus:k,handleBlur:V,handleClick:A,handleKeyDown:j,selectionRef:S}}var we=ne.forwardRef(function(e,o){let{placeholder:i,disabled:u,cursorBehavior:s="none",render:p,className:c,style:a,onFocus:t,onBlur:P,onClick:m,onKeyDown:b,...I}=e,d=_chunkW4ACKMIZcjs.w.call(void 0, ),g=_chunkW4ACKMIZcjs.d.call(void 0, ),l=_chunkW4ACKMIZcjs.a.call(void 0, ),S=To(),R=(_nullishCoalesce(u, () => (d.disabled)))||g.disabled,L=_chunk5T5B5SPRcjs.f.call(void 0, d.items,""),w=_nullishCoalesce(_nullishCoalesce(i, () => ((typeof L=="string"?L:void 0))), () => (d.placeholder)),k=g.store.useState("open"),{hasValue:V,displayValue:A,getValueText:K}=Ho({comboboxContext:d,open:k}),{handleChange:j,handleFocus:n,handleBlur:f,handleClick:r,handleKeyDown:v}=Oo({comboboxContext:d,store:g.store,focusOwnerStore:l,open:k,disabled:R,cursorBehavior:s,hasValue:V,getValueText:K,onFocus:t,onBlur:P,onClick:m,onKeyDown:b}),y={[Q.slot]:""};k?y[Q.open]="":y[Q.closed]="",R&&(y[Q.disabled]=""),V||(y[Q.placeholder]=""),d.layout==="input-embedded"&&(y["data-input-embedded"]="");let O=ne.useCallback(M=>{d.setInputElement(M),typeof o=="function"?o(M):o&&(o.current=M)},[o,d]),W=ne.useMemo(()=>({open:k,disabled:R,placeholder:!V}),[k,R,V]),z=d.layout==="input-embedded"&&!S?{position:"relative",zIndex:1}:void 0;return _userender.useRender.call(void 0, {render:p,ref:O,state:W,props:{...I,...y,type:"text",role:"combobox","aria-autocomplete":"list","aria-expanded":k,"aria-controls":d.listId,"aria-haspopup":"listbox",autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:R,placeholder:V?void 0:w,className:c,style:{...z,...a},value:A,onChange:j,onFocus:n,onBlur:f,onClick:r,onKeyDown:v},defaultTagName:"input"})});var ge={slot:"bazzaui-combobox-input-wrapper",open:"data-open"};var _jsxruntime = require('react/jsx-runtime');var Rt={open:x=>x?{[ge.open]:""}:null},ke= exports.ComboboxInputWrapper =re.forwardRef(function(e,o){let{render:i,className:u,style:s,children:p,...c}=e,{store:a}=_chunkW4ACKMIZcjs.d.call(void 0, ),t=_chunkW4ACKMIZcjs.w.call(void 0, ),P=a.useState("open"),m=re.useMemo(()=>({open:P}),[P]),b=t.layout==="input-embedded"?{position:"relative",zIndex:1}:{position:"relative"},I=re.useCallback(g=>{t.setInputWrapperElement(g),typeof o=="function"?o(g):o&&(o.current=g)},[o,t]),d=_userender.useRender.call(void 0, {render:i,ref:I,state:m,stateAttributesMapping:Rt,props:{...c,[ge.slot]:"",className:u,style:{...b,...s},children:p},defaultTagName:"div"});return _jsxruntime.jsx.call(void 0, Le.Provider,{value:!0,children:d})});var q={slot:"bazzaui-combobox-item",highlighted:"data-highlighted",disabled:"data-disabled",selected:"data-selected",first:"data-first",last:"data-last",firstInGroup:"data-first-in-group",lastInGroup:"data-last-in-group"};var he=le.createContext(null);function ue(){let x=le.useContext(he);if(!x)throw new Error("ComboboxItem child components must be used within a Combobox.Item");return x}function yt(){return le.useContext(he)}var Vt={highlighted:x=>x?{[q.highlighted]:""}:null,disabled:x=>x?{[q.disabled]:""}:null,selected:x=>x?{[q.selected]:""}:null,first:x=>x?{[q.first]:""}:null,last:x=>x?{[q.last]:""}:null,firstInGroup:x=>x?{[q.firstInGroup]:""}:null,lastInGroup:x=>x?{[q.lastInGroup]:""}:null};function Mt(x,e){let{value:o,textValue:i,keywords:u,disabled:s=!1,onSelect:p,forceMount:c=!1,render:a,className:t,style:P,onClick:m,onPointerDown:b,onPointerMove:I,children:d,...g}=x,l=_chunkW4ACKMIZcjs.w.call(void 0, ),S=E.useMemo(()=>_chunkW4ACKMIZcjs.S.call(void 0, o,l.itemToStringValue),[o,l.itemToStringValue]),R=E.useId(),L=o===null?`combobox-clear-${R}`:void 0,w=E.useMemo(()=>_chunk5T5B5SPRcjs.e.call(void 0, l.items,S),[l.items,S]),k=_optionalChain([w, 'optionalAccess', _18 => _18.label]),V=E.useMemo(()=>_chunkW4ACKMIZcjs.R.call(void 0, o,l.itemToStringLabel),[o,l.itemToStringLabel]),A=E.useMemo(()=>{if(i!==void 0)return i;if(typeof k=="string")return k;if(V&&V!==S)return V},[i,k,V,S]),K=E.useMemo(()=>_chunk5T5B5SPRcjs.g.call(void 0, u,[typeof k=="string"?k:V&&V!==S?V:void 0,..._nullishCoalesce(_optionalChain([w, 'optionalAccess', _19 => _19.keywords]), () => ([]))]),[u,k,V,S,w]),j=E.useRef(A),n=l.multiple?_chunk5T5B5SPRcjs.c.call(void 0, l.values,o,l.isItemEqualToValue):l.value!==""&&_chunk5T5B5SPRcjs.b.call(void 0, l.value,o,l.isItemEqualToValue),f=l.closeOnSelect,r=_chunkW4ACKMIZcjs.O.call(void 0, {id:L,value:S,keywords:K,disabled:s,forceMount:c,closeOnClick:f,children:d});E.useEffect(()=>{let M=()=>{if(!s){if(l.multiple)if(o==null)l.onValuesChange([]);else{let me=n?_chunk5T5B5SPRcjs.d.call(void 0, l.values,o,l.isItemEqualToValue):[...l.values,o];l.onValuesChange(me)}else l.onValueChange(o);_optionalChain([p, 'optionalCall', _20 => _20()])}};return r.registerSelect(M)},[s,l,o,n,p,r]),E.useEffect(()=>{let M=j.current;if(M)return l.registerItemText(S,M)},[S,l]),E.useEffect(()=>{!A&&typeof d=="string"&&(j.current=d,l.registerItemText(S,d))},[d,A,S,l]);let v=E.useMemo(()=>({highlighted:r.isHighlighted,disabled:s,selected:n,first:r.positional.first,last:r.positional.last,firstInGroup:r.positional.firstInGroup,lastInGroup:r.positional.lastInGroup}),[r.isHighlighted,s,n,r.positional]),y=E.useMemo(()=>({id:r.id,value:o,textValue:A,highlighted:r.isHighlighted,disabled:s,selected:n}),[r.id,o,A,r.isHighlighted,s,n]),O=E.useCallback(M=>{_optionalChain([m, 'optionalCall', _21 => _21(M)]),M.defaultPrevented||r.handlers.onClick(M)},[m,r.handlers]),W=E.useCallback(M=>{r.handlers.onPointerDown(M),_optionalChain([b, 'optionalCall', _22 => _22(M)])},[r.handlers,b]),z=E.useCallback(M=>{_optionalChain([I, 'optionalCall', _23 => _23(M)]),M.defaultPrevented||r.handlers.onPointerMove(M)},[I,r.handlers]),ee=_userender.useRender.call(void 0, {render:a,ref:[r.ref,r.rowRef,e],state:v,stateAttributesMapping:Vt,props:{...g,[q.slot]:"",id:r.id,role:"option",tabIndex:-1,"aria-selected":n,"aria-disabled":s||void 0,className:t,style:P,onClick:O,onPointerMove:z,onPointerDown:W,children:d},enabled:r.isVisible,defaultTagName:"div"});return r.isVisible?_jsxruntime.jsx.call(void 0, he.Provider,{value:y,children:ee}):null}var Te=E.forwardRef(Mt);var Pe={slot:"bazzaui-combobox-item-indicator",selected:"data-selected"};var wt={selected:x=>x?{[Pe.selected]:""}:null},He= exports.ComboboxItemIndicator =Ie.forwardRef(function(e,o){let{keepMounted:i=!1,render:u,className:s,style:p,...c}=e,a=ue(),t=Ie.useMemo(()=>({selected:a.selected}),[a.selected]),P=_userender.useRender.call(void 0, {render:u,ref:o,state:t,stateAttributesMapping:wt,props:{...c,[Pe.slot]:"","aria-hidden":!0,className:s,style:p},enabled:i||a.selected,defaultTagName:"span"});return!i&&!a.selected?null:P});var Do={slot:"bazzaui-combobox-item-label"};var Oe=Y.forwardRef(function(e,o){let{render:i,className:u,style:s,children:p,...c}=e,a=_chunkW4ACKMIZcjs.w.call(void 0, ),t=ue(),P=_chunkW4ACKMIZcjs.S.call(void 0, t.value,a.itemToStringValue),m=Y.useMemo(()=>{if(p!==void 0)return p;let I=_chunk5T5B5SPRcjs.f.call(void 0, a.items,P);return I!==void 0?I:t.textValue!==void 0?t.textValue:P},[p,a.items,P,t.textValue]),b=Y.useMemo(()=>({value:P,selected:t.selected,highlighted:t.highlighted,disabled:t.disabled}),[P,t.selected,t.highlighted,t.disabled]);return Y.useEffect(()=>{if(typeof m=="string")return a.registerItemText(P,m)},[m,a,P]),_userender.useRender.call(void 0, {render:i,ref:o,state:b,props:{...c,[Do.slot]:"",className:u,style:s,children:m},defaultTagName:"span"})});var _popover = require('@base-ui/react/popover');var Re={slot:"bazzaui-combobox-positioner"};function Tt(x,e,o,i){let u=o+i*2;if(x==="top"){let c=-(e+i),a=e+i;return{width:u,marginBottom:c,paddingTop:i,paddingLeft:i,paddingRight:i,paddingBottom:a}}let s=-(e+i),p=e+i;return{width:u,marginTop:s,paddingTop:p,paddingLeft:i,paddingRight:i,paddingBottom:i}}var De=U.forwardRef(function(e,o){let{layout:i,popupPadding:u=8,side:s="bottom",align:p,sideOffset:c=4,anchor:a,className:t,style:P,children:m,...b}=e,I=_chunkW4ACKMIZcjs.w.call(void 0, ),d=_nullishCoalesce(i, () => (I.layout)),g=d==="input-embedded",l=_nullishCoalesce(a, () => (I.inputWrapperRef.current))?I.inputWrapperRef:I.inputRef,S=g?0:c,R=g?"center":_nullishCoalesce(p, () => ("start")),{inputHeight:L,inputWidth:w}=I,k=w+u*2,V={...P,...g?{zIndex:0}:{}};if(g)return _jsxruntime.jsx.call(void 0, _popover.Popover.Positioner,{ref:o,side:s,align:R,sideOffset:S,anchor:l,className:t,style:V,"data-input-embedded":"",[Re.slot]:"",...b,render:(n,f)=>{let r=f.side,v={layout:d,side:r,align:f.align,inputHeight:I.inputHeight},y={"--combobox-input-height":`${L}px`,"--combobox-input-width":`${w}px`,"--combobox-popup-padding":`${u}px`,"--combobox-popup-width":`${k}px`},O=Tt(r,L,w,u),W=U.Children.map(m,z=>U.isValidElement(z)?U.cloneElement(z,{style:{...O,...z.props.style},"data-side":r}):z);return _jsxruntime.jsx.call(void 0, fe.Provider,{value:v,children:_jsxruntime.jsx.call(void 0, "div",{...n,style:{...n.style,...y},"data-side":r,children:W})})}});let A={layout:d,side:s,align:R,inputHeight:I.inputHeight},K={"--combobox-input-height":`${L}px`,"--combobox-input-width":`${w}px`},j={...V,...K};return _jsxruntime.jsx.call(void 0, fe.Provider,{value:A,children:_jsxruntime.jsx.call(void 0, _popover.Popover.Positioner,{ref:o,side:s,align:R,sideOffset:S,anchor:l,className:t,style:j,[Re.slot]:"",...b,children:m})})});function Ae(x){let{open:e,onOpenChange:o,actionsRef:i,defaultOpen:u=!1,value:s,defaultValue:p,onValueChange:c,multiple:a=!1,values:t,defaultValues:P,onValuesChange:m,isItemEqualToValue:b=_chunk5T5B5SPRcjs.a,itemToStringLabel:I,itemToStringValue:d,inputValue:g,defaultInputValue:l="",onInputValueChange:S,name:R,form:L,required:w,disabled:k=!1,placeholder:V="Search...",items:A,modal:K=!1,closeOnSelect:j,openOnFocus:n=!0,virtualized:f=!1,virtualItems:r,onHighlightChange:v,layout:y="floating",onOpenChangeComplete:O,debug:W,children:z,...ee}=x,M=h.useCallback((C,H,G,be)=>_optionalChain([v, 'optionalCall', _24 => _24(C,G,be)]),[v]),me=h.useId(),ce=h.useRef(null),Se=h.useRef(null),[ze,Be]=h.useState(0),[We,je]=h.useState(0),Ge=h.useCallback(C=>{if(ce.current=C,C&&!Se.current){let H=C.getBoundingClientRect();Be(H.height),je(H.width)}},[]),Ne=h.useCallback(C=>{if(Se.current=C,C){let H=C.getBoundingClientRect();Be(H.height),je(H.width)}},[]),{store:B,focusOwnerStore:$o,openChainStore:Jo,registerSurface:Xo,closeAll:_o,virtualization:Qo,handleOpenChange:qe,disabled:$,setDisabled:Ke,menuTreeResolver:Yo}=_chunkW4ACKMIZcjs.q.call(void 0, {onOpenChange:o,defaultOpen:u,virtualized:f,items:r,onHighlightChange:M,disabled:k}),ye=h.useRef(null);h.useImperativeHandle(i,()=>({close:()=>{_optionalChain([ye, 'access', _25 => _25.current, 'optionalAccess', _26 => _26.close, 'call', _27 => _27()])},unmount:()=>{_optionalChain([ye, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.unmount, 'call', _30 => _30()])},setDisabled:Ke}),[Ke]),B.useControlledProp("openProp",e);let Zo=B.useState("open"),Ue=h.useCallback((C,H,G)=>{$&&H!==_chunkXMZZ62VJcjs.a.imperativeAction||!C&&ce.current&&document.activeElement===ce.current||qe(C,H,G)},[qe,$]),et=h.useCallback(C=>{!C&&B.context.clearSearchOnClose==="after-exit"&&(B.clearSearch(),B.setInputActive(!1)),C||B.clearHighlight(),_optionalChain([O, 'optionalCall', _31 => _31(C)])},[B,O]),ot=h.useCallback((C,H)=>{Ue(C,H.reason,H.event)},[Ue]),[tt,nt]=h.useState(p!==void 0?p:null),J=s!==void 0?s:tt,$e=h.useCallback(C=>{s===void 0&&nt(C),_optionalChain([c, 'optionalCall', _32 => _32(C)])},[s,c]),[rt,at]=h.useState(_nullishCoalesce(P, () => ([]))),ae=t!==void 0?t:rt,Je=h.useCallback(C=>{t===void 0&&at(C),_optionalChain([m, 'optionalCall', _33 => _33(C)])},[t,m]),[ve,st]=h.useState(l),Xe=g!==void 0?g:ve,_e=h.useCallback(C=>{g===void 0&&st(C),_optionalChain([S, 'optionalCall', _34 => _34(C)])},[g,S]),Qe=h.useRef(new Map),Ye=h.useCallback((C,H)=>(Qe.current.set(C,H),()=>{}),[]),Ze=_nullishCoalesce(j, () => (!a)),Ve=h.useRef({type:"active"}),[,lt]=h.useState({type:"active"}),X=h.useCallback(C=>{Ve.current=C,lt(C)},[]),eo=Ve.current,oo=h.useCallback(()=>{X({type:"active"})},[X]),to=h.useCallback(()=>{$||(!a&&J!=null?X({type:"showAll"}):X({type:"active"}),B.setOpen(!0))},[$,B,a,J,X]),no=h.useCallback((C,H)=>{let G=Ve.current,be=G.type==="active"?ve:G.type==="showAll"?"":G.search;X({type:"frozen",search:be}),B.setOpen(!1,C,H)},[B,X,ve]),ut=h.useMemo(()=>({multiple:a,value:J,values:ae,onValueChange:$e,onValuesChange:Je,isItemEqualToValue:b,itemToStringLabel:I,itemToStringValue:d,inputValue:Xe,onInputValueChange:_e,name:R,form:L,required:w,disabled:$,placeholder:V,items:A,itemTextRegistry:Qe.current,registerItemText:Ye,listId:me,inputRef:ce,setInputElement:Ge,inputWrapperRef:Se,setInputWrapperElement:Ne,closeOnSelect:Ze,openOnFocus:n,openCombobox:to,closeCombobox:no,filterMode:eo,setFilterActive:oo,inputHeight:ze,inputWidth:We,layout:y}),[a,J,ae,$e,Je,b,I,d,Xe,_e,R,L,w,$,V,A,Ye,me,Ge,Ne,Ze,n,to,no,eo,oo,ze,We,y]),it=h.useMemo(()=>R?a?ae.length>0?ae.map((C,H)=>{let G=_chunkW4ACKMIZcjs.S.call(void 0, C,d);return _jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:R,value:G,form:L,required:w&&H===0},G)}):_jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:R,value:"",form:L,required:w}):_jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:R,value:J!=null?_chunkW4ACKMIZcjs.S.call(void 0, J,d):"",form:L,required:w}):null,[R,L,w,a,J,ae,d]);return _jsxruntime.jsx.call(void 0, _chunkW4ACKMIZcjs.v.Provider,{value:ut,children:_jsxruntime.jsxs.call(void 0, _chunkW4ACKMIZcjs.N,{menuTreeResolver:Yo,store:B,focusOwnerStore:$o,openChainStore:Jo,disabled:$,depth:0,closeAll:_o,registerSurface:Xo,virtualization:Qo,menuType:"dropdown",componentName:"combobox",debug:W,children:[it,_jsxruntime.jsx.call(void 0, _popover.Popover.Root,{...ee,open:Zo,onOpenChange:ot,onOpenChangeComplete:et,modal:K,actionsRef:i?ye:void 0,children:z})]})})}var Fo={slot:"bazzaui-combobox-surface"};var Fe=Z.forwardRef(function(e,o){let{autoHighlightFirst:i,clearSearchOnClose:u=!0,search:s,onSearchChange:p,onPointerMove:c,...a}=e,t=_chunkW4ACKMIZcjs.w.call(void 0, ),P=Z.useCallback(g=>{_optionalChain([c, 'optionalCall', _35 => _35(g)]);let l=t.inputRef.current;l&&document.activeElement!==l&&l.focus()},[c,t.inputRef]),m=Z.useMemo(()=>{let g=_nullishCoalesce(i, () => (!0));if(g==="selected"){let l=t.multiple?t.values[0]:t.value;return l!=null?_chunkW4ACKMIZcjs.S.call(void 0, l,t.itemToStringValue):!0}return g},[i,t.multiple,t.value,t.values,t.itemToStringValue]),{filterMode:b}=t,I=_nullishCoalesce(s, () => ((b.type==="active"?t.inputValue:b.type==="showAll"?"":b.search))),d=Z.useCallback(g=>{t.onInputValueChange(g),_optionalChain([p, 'optionalCall', _36 => _36(g)])},[t,p]);return _jsxruntime.jsx.call(void 0, _chunkW4ACKMIZcjs.fa,{ref:o,autoHighlightFirst:m,clearSearchOnClose:u,search:I,onSearchChange:d,onPointerMove:P,skipAutoFocus:!0,[Fo.slot]:"",...a})});var Bo=(p=>(p.slot="bazzaui-combobox-arrow",p.open="data-open",p.closed="data-closed",p.side="data-side",p.align="data-align",p.uncentered="data-uncentered",p))(Bo||{});var Wo=(s=>(s.slot="bazzaui-combobox-backdrop",s.open="data-open",s.closed="data-closed",s.startingStyle="data-starting-style",s.endingStyle="data-ending-style",s))(Wo||{});var jo=(e=>(e.slot="bazzaui-combobox-empty",e))(jo||{});var Go=(e=>(e.slot="bazzaui-combobox-group",e))(Go||{});var No=(e=>(e.slot="bazzaui-combobox-group-label",e))(No||{});var At={slot:"bazzaui-combobox-icon",open:"data-popup-open"};var qo=(o=>(o.slot="bazzaui-combobox-list",o.list="data-popup-menu-list",o))(qo||{});var Ko=(b=>(b.slot="bazzaui-combobox-popup",b.open="data-open",b.closed="data-closed",b.side="data-side",b.align="data-align",b.startingStyle="data-starting-style",b.endingStyle="data-ending-style",b.instant="data-instant",b.focused="data-focused",b.hasOpenSubmenu="data-has-open-submenu",b.submenu="data-submenu",b.navigating="data-navigating",b))(Ko||{});var Ft={slotUp:"bazzaui-combobox-scroll-up-arrow",slotDown:"bazzaui-combobox-scroll-down-arrow",direction:"data-direction",side:"data-side"};var Uo=(e=>(e.slot="bazzaui-combobox-separator",e))(Uo||{});exports.Combobox = zo; exports.ComboboxArrowDataAttributes = Bo; exports.ComboboxBackdropDataAttributes = Wo; exports.ComboboxClear = Me; exports.ComboboxEmptyDataAttributes = jo; exports.ComboboxGroupDataAttributes = Go; exports.ComboboxGroupLabelDataAttributes = No; exports.ComboboxIconDataAttributes = At; exports.ComboboxInput = we; exports.ComboboxInputDataAttributes = Q; exports.ComboboxInputWrapper = ke; exports.ComboboxInputWrapperDataAttributes = ge; exports.ComboboxItem = Te; exports.ComboboxItemDataAttributes = q; exports.ComboboxItemIndicator = He; exports.ComboboxItemIndicatorDataAttributes = Pe; exports.ComboboxItemLabel = Oe; exports.ComboboxListCssVars = _chunkW4ACKMIZcjs.aa; exports.ComboboxListDataAttributes = qo; exports.ComboboxPopupDataAttributes = Ko; exports.ComboboxPositioner = De; exports.ComboboxPositionerCssVars = _chunkW4ACKMIZcjs.L; exports.ComboboxPositionerDataAttributes = Re; exports.ComboboxRoot = Ae; exports.ComboboxScrollArrowDataAttributes = Ft; exports.ComboboxSeparatorDataAttributes = Uo; exports.ComboboxStore = _chunkXMZZ62VJcjs.y; exports.ComboboxSurface = Fe; exports.commandScore = _chunkXMZZ62VJcjs.w; exports.defaultFilter = _chunkXMZZ62VJcjs.x; exports.useComboboxContext = _chunkW4ACKMIZcjs.w; exports.useComboboxItemContext = ue; exports.useComboboxPositionerContext = Ee; exports.useMaybeComboboxContext = _chunkW4ACKMIZcjs.x; exports.useMaybeComboboxItemContext = yt; exports.useMaybeSurfaceContext = _chunkXMZZ62VJcjs.q; exports.useSurfaceContext = _chunkXMZZ62VJcjs.p;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/combobox/index.cjs","../../src/combobox/index.parts.ts","../../src/combobox/clear/clear.tsx","../../src/combobox/clear/clear.data-attrs.ts","../../src/combobox/contexts/combobox-positioner-context.ts","../../src/combobox/input/input.tsx","../../src/combobox/input-wrapper/input-wrapper-context.ts","../../src/combobox/input/input.data-attrs.ts","../../src/combobox/input/use-combobox-display-value.ts"],"names":["index_parts_exports","__export","PopupMenuArrow","PopupMenuBackdrop","ComboboxClear","PopupMenuEmpty","PopupMenuGroup","PopupMenuGroupLabel","PopupMenuIcon","ComboboxInput","ComboboxInputWrapper","ComboboxItem","ComboboxItemIndicator","ComboboxItemLabel","PopupMenuList","PopupMenuPopup","PopupMenuPortal","ComboboxPositioner","ComboboxRoot","PopupMenuScrollDownArrow","PopupMenuScrollUpArrow","PopupMenuSeparator","ComboboxSurface","useComboboxPositionerContext","ComboboxClearDataAttributes","props","forwardedRef","keepMounted","disabledProp","render","className","style","onClick","onPointerDown","rest","comboboxContext","useComboboxContext","disabled","hasValue","handleClick","event","handlePointerDown","state","element","useRender","ComboboxPositionerContext","ComboboxInputWrapperContext","useIsInsideInputWrapper","ComboboxInputDataAttributes","useComboboxDisplayValue","params","open","isValueEmpty","getValueText","value","serializedValue","stringifyAsValue","registryText","itemsLabel","resolveLabelFromItems","resolvedLabel","resolveLabel","selectedLabel","texts","v","text"],"mappings":"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","file":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/combobox/index.cjs","sourcesContent":[null,"// ============================================================================\n// Combobox Parts\n// ============================================================================\n// Re-exports shared components from internal/popup-menu with Combobox-specific\n// Root, Input, 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 // Icon\n PopupMenuIcon as Icon,\n PopupMenuList as List,\n PopupMenuPopup as Popup,\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 { ComboboxClear as Clear } from './clear/clear.js'\nexport { useComboboxPositionerContext } from './contexts/combobox-positioner-context.js'\nexport { ComboboxInput as Input } from './input/input.js'\nexport { ComboboxInputWrapper as InputWrapper } from './input-wrapper/input-wrapper.js'\nexport { ComboboxItem as Item } from './item/item.js'\nexport { ComboboxItemIndicator as ItemIndicator } from './item-indicator/item-indicator.js'\nexport { ComboboxItemLabel as ItemLabel } from './item-label/item-label.js'\nexport { ComboboxPositioner as Positioner } from './positioner/positioner.js'\n// Combobox-specific components\nexport { ComboboxRoot as Root } from './root/root.js'\nexport { ComboboxSurface as Surface } from './surface/surface.js'\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 { useComboboxContext } from '../contexts/combobox-context.js'\nimport { ComboboxClearDataAttributes } from './clear.data-attrs.js'\n\nexport { ComboboxClearDataAttributes }\n\nexport interface ComboboxClearState extends Record<string, unknown> {\n /**\n * Whether the combobox has a value (clear button is actionable).\n */\n hasValue: boolean\n /**\n * Whether the combobox is disabled.\n */\n disabled: boolean\n}\n\nexport interface ComboboxClearProps\n extends ComponentProps<'button', ComboboxClear.State> {\n /**\n * Whether to render the button even when there's no value to clear.\n * @default false\n */\n keepMounted?: boolean\n}\n\n/**\n * A button that clears the selected value(s) when clicked.\n * Renders a `<button>` element.\n */\nexport const ComboboxClear = React.forwardRef<\n HTMLButtonElement,\n ComboboxClear.Props\n>(function ComboboxClear(props, forwardedRef) {\n const {\n keepMounted = false,\n disabled: disabledProp,\n render,\n className,\n style,\n onClick,\n onPointerDown,\n ...rest\n } = props\n\n const comboboxContext = useComboboxContext()\n\n const disabled = disabledProp ?? comboboxContext.disabled\n\n const hasValue = comboboxContext.multiple\n ? comboboxContext.values.length > 0\n : comboboxContext.value !== ''\n\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented) return\n\n if (comboboxContext.multiple) {\n comboboxContext.onValuesChange([])\n } else {\n comboboxContext.onValueChange('')\n }\n\n // Also clear the input value\n comboboxContext.onInputValueChange('')\n },\n [onClick, comboboxContext],\n )\n\n // Prevent pointer down from stealing focus from the input\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLButtonElement>) => {\n event.preventDefault()\n onPointerDown?.(event)\n },\n [onPointerDown],\n )\n\n const state: ComboboxClear.State = React.useMemo(\n () => ({\n hasValue,\n disabled,\n }),\n [hasValue, disabled],\n )\n\n const element = useRender({\n render,\n ref: forwardedRef,\n state,\n props: {\n ...rest,\n [ComboboxClearDataAttributes.slot]: '',\n type: 'button',\n tabIndex: -1, // Not tabbable - use keyboard shortcuts instead\n 'aria-label': 'Clear selection',\n disabled: disabled || !hasValue,\n className,\n style,\n onClick: handleClick,\n onPointerDown: handlePointerDown,\n },\n enabled: keepMounted || hasValue,\n defaultTagName: 'button',\n })\n\n // Don't render if no value and not keepMounted\n if (!keepMounted && !hasValue) {\n return null\n }\n\n return element\n})\n\nexport namespace ComboboxClear {\n export type State = ComboboxClearState\n export interface Props extends ComboboxClearProps {}\n}\n","/**\n * Data attributes for ComboboxClear component.\n */\nexport const ComboboxClearDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-combobox-clear'}\n */\n slot: 'bazzaui-combobox-clear',\n} as const\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Types\n// ============================================================================\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 * Layout mode for the combobox popup.\n * - `'floating'` - Standard dropdown positioning below/above the input\n * - `'input-embedded'` - Popup wraps around the input (macOS-style)\n */\nexport type ComboboxLayout = 'floating' | 'input-embedded'\n\n/**\n * Context value for Combobox Positioner.\n * Provides alignment state for coordinating positioning behavior.\n */\nexport interface ComboboxPositionerContextValue {\n /**\n * The layout mode being used.\n * - `'floating'` - Standard dropdown positioning\n * - `'input-embedded'` - Popup wraps around the input\n */\n layout: ComboboxLayout\n\n /**\n * The side of the popup relative to the input.\n */\n side: Side\n\n /**\n * The alignment of the popup.\n */\n align: Align\n\n /**\n * Height of the input element in pixels.\n * Use this to add appropriate padding to the popup.\n */\n inputHeight: number\n}\n\n// ============================================================================\n// Context\n// ============================================================================\n\nconst ComboboxPositionerContext =\n React.createContext<ComboboxPositionerContextValue | null>(null)\n\n/**\n * Hook to access the Combobox Positioner context.\n * Returns null if used outside a ComboboxPositioner.\n */\nexport function useComboboxPositionerContext(): ComboboxPositionerContextValue | null {\n return React.useContext(ComboboxPositionerContext)\n}\n\nexport { ComboboxPositionerContext }\n","'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { useFocusOwner } from '../../internal/popup-menu/contexts/focus-owner-context.js'\nimport { usePopupMenuContext } from '../../internal/popup-menu/contexts/popup-menu-context.js'\nimport { resolveLabelFromItems } from '../../utils/items.js'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useComboboxContext } from '../contexts/combobox-context.js'\nimport { useIsInsideInputWrapper } from '../input-wrapper/input-wrapper-context.js'\nimport { ComboboxInputDataAttributes } from './input.data-attrs.js'\nimport { useComboboxDisplayValue } from './use-combobox-display-value.js'\nimport { useComboboxInputBehavior } from './use-combobox-input-behavior.js'\n\nexport { ComboboxInputDataAttributes }\n\nexport interface ComboboxInputState extends Record<string, unknown> {\n /**\n * Whether the combobox popup is open.\n */\n open: boolean\n /**\n * Whether the input is disabled.\n */\n disabled: boolean\n /**\n * Whether the input currently shows placeholder (no value selected).\n */\n placeholder: boolean\n}\n\n/**\n * Cursor behavior when the combobox popup opens.\n * - `'none'` - Don't move the cursor (cursor appears where clicked)\n * - `'end'` - Move cursor to the end of the input\n * - `'select-all'` - Move cursor to the end and select all text\n */\nexport type ComboboxInputCursorBehavior = 'none' | 'end' | 'select-all'\n\nexport interface ComboboxInputProps\n extends Omit<\n ComponentProps<'input', ComboboxInput.State>,\n 'value' | 'onChange' | 'type'\n > {\n /**\n * Placeholder text shown when no value is selected and input is empty.\n * Overrides the placeholder set on Combobox.Root.\n */\n placeholder?: string\n\n /**\n * Cursor behavior when the combobox popup opens.\n * - `'none'` - Don't move the cursor (cursor appears where clicked)\n * - `'end'` - Move cursor to the end of the input\n * - `'select-all'` - Move cursor to the end and select all text\n *\n * @default 'none'\n */\n cursorBehavior?: ComboboxInputCursorBehavior\n}\n\n/**\n * An input that acts as both the trigger and search field for the combobox.\n * Renders an `<input>` element with combobox ARIA semantics.\n */\nexport const ComboboxInput = React.forwardRef<\n HTMLInputElement,\n ComboboxInput.Props\n>(function ComboboxInput(props, forwardedRef) {\n const {\n placeholder: placeholderProp,\n disabled: disabledProp,\n cursorBehavior = 'none',\n render,\n className,\n style,\n onFocus,\n onBlur,\n onClick,\n onKeyDown,\n ...rest\n } = props\n\n const comboboxContext = useComboboxContext()\n const popupMenuContext = usePopupMenuContext()\n const focusOwnerStore = useFocusOwner()\n const isInsideInputWrapper = useIsInsideInputWrapper()\n\n const disabled =\n (disabledProp ?? comboboxContext.disabled) || popupMenuContext.disabled\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 the input.\n const nullItemLabel = resolveLabelFromItems(comboboxContext.items, '')\n const placeholder =\n placeholderProp ??\n (typeof nullItemLabel === 'string' ? nullItemLabel : undefined) ??\n comboboxContext.placeholder\n\n // Get open state\n const open = popupMenuContext.store.useState('open')\n\n // Use display value hook\n const { hasValue, displayValue, getValueText } = useComboboxDisplayValue({\n comboboxContext,\n open,\n })\n\n // Use input behavior hook\n const { handleChange, handleFocus, handleBlur, handleClick, handleKeyDown } =\n useComboboxInputBehavior({\n comboboxContext,\n store: popupMenuContext.store,\n focusOwnerStore,\n open,\n disabled,\n cursorBehavior,\n hasValue,\n getValueText,\n onFocus,\n onBlur,\n onClick,\n onKeyDown,\n })\n\n // Build data attributes\n const dataAttrs: Record<string, string> = {\n [ComboboxInputDataAttributes.slot]: '',\n }\n if (open) {\n dataAttrs[ComboboxInputDataAttributes.open] = ''\n } else {\n dataAttrs[ComboboxInputDataAttributes.closed] = ''\n }\n if (disabled) {\n dataAttrs[ComboboxInputDataAttributes.disabled] = ''\n }\n if (!hasValue) {\n dataAttrs[ComboboxInputDataAttributes.placeholder] = ''\n }\n // Add input-embedded data attribute when layout is input-embedded\n if (comboboxContext.layout === 'input-embedded') {\n dataAttrs['data-input-embedded'] = ''\n }\n\n // Register input element for positioning\n const mergedRef = React.useCallback(\n (node: HTMLInputElement | null) => {\n comboboxContext.setInputElement(node)\n if (typeof forwardedRef === 'function') {\n forwardedRef(node)\n } else if (forwardedRef) {\n forwardedRef.current = node\n }\n },\n [forwardedRef, comboboxContext],\n )\n\n const state: ComboboxInput.State = React.useMemo(\n () => ({\n open,\n disabled,\n placeholder: !hasValue,\n }),\n [open, disabled, hasValue],\n )\n\n // When input-embedded layout, apply styles to position input above the popup\n // Skip z-index if inside an InputWrapper (the wrapper handles z-index)\n const inputEmbeddedStyles: React.CSSProperties | undefined =\n comboboxContext.layout === 'input-embedded' && !isInsideInputWrapper\n ? { position: 'relative', zIndex: 1 }\n : undefined\n\n const element = useRender({\n render,\n ref: mergedRef,\n state,\n props: {\n ...rest,\n ...dataAttrs,\n type: 'text',\n role: 'combobox',\n 'aria-autocomplete': 'list',\n 'aria-expanded': open,\n 'aria-controls': comboboxContext.listId,\n 'aria-haspopup': 'listbox',\n autoComplete: 'off',\n autoCorrect: 'off',\n spellCheck: false,\n disabled,\n placeholder: !hasValue ? placeholder : undefined,\n className,\n style: { ...inputEmbeddedStyles, ...style },\n value: displayValue,\n onChange: handleChange,\n onFocus: handleFocus,\n onBlur: handleBlur,\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n },\n defaultTagName: 'input',\n })\n\n return element\n})\n\nexport namespace ComboboxInput {\n export interface Props extends ComboboxInputProps {}\n export type State = ComboboxInputState\n}\n","import * as React from 'react'\n\n/**\n * Context to indicate that children are inside an InputWrapper.\n * When true, Input should not apply its own z-index styles for input-embedded layout.\n */\nexport const ComboboxInputWrapperContext = React.createContext<boolean>(false)\n\n/**\n * Hook to check if component is inside a ComboboxInputWrapper.\n */\nexport function useIsInsideInputWrapper(): boolean {\n return React.useContext(ComboboxInputWrapperContext)\n}\n","/**\n * Data attributes for ComboboxInput component.\n */\nexport const ComboboxInputDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-combobox-input'}\n */\n slot: 'bazzaui-combobox-input',\n /** Present when the combobox popup is open. */\n open: 'data-open',\n /** Present when the combobox popup is closed. */\n closed: 'data-closed',\n /** Present when the input is disabled. */\n disabled: 'data-disabled',\n /** Present when no value is selected (showing placeholder). */\n placeholder: 'data-placeholder',\n} as const\n","'use client'\n\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 { ComboboxContextValue } from '../contexts/combobox-context.js'\n\nexport interface UseComboboxDisplayValueParams<Value = unknown> {\n comboboxContext: ComboboxContextValue<Value>\n open: boolean\n}\n\nexport interface UseComboboxDisplayValueReturn<Value = unknown> {\n /** Whether a value is selected */\n hasValue: boolean\n /** The value to display in the input */\n displayValue: string\n /** The label of the selected value(s) */\n selectedLabel: string\n /** Get the display text for a value */\n getValueText: (value: Value) => string | undefined\n}\n\n/**\n * Hook to compute the display value for the combobox input.\n *\n * Handles:\n * - Determining if a value is selected (single or multi-select)\n * - Computing the display label for selected values\n * - Switching between selected label (closed) and input value (open)\n */\nexport function useComboboxDisplayValue<Value = unknown>(\n params: UseComboboxDisplayValueParams<Value>,\n): UseComboboxDisplayValueReturn<Value> {\n const { comboboxContext, open } = params\n\n // Determine if showing placeholder (no value selected)\n const hasValue = comboboxContext.multiple\n ? comboboxContext.values.length > 0\n : !isValueEmpty(comboboxContext.value)\n\n // Get the display text for selected value\n const getValueText = React.useCallback(\n (value: Value): string | undefined => {\n // Serialize for registry lookup\n const serializedValue = stringifyAsValue(\n value,\n comboboxContext.itemToStringValue,\n )\n\n // First try the registry (populated when items mount)\n const registryText = comboboxContext.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 // The input can only display strings, so ignore non-string labels here.\n const itemsLabel = resolveLabelFromItems(\n comboboxContext.items,\n serializedValue,\n )\n if (typeof itemsLabel === 'string') {\n return itemsLabel\n }\n\n // Fall back to itemToStringLabel for object values\n const resolvedLabel = resolveLabel(\n value,\n comboboxContext.itemToStringLabel,\n )\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 comboboxContext.itemTextRegistry,\n comboboxContext.items,\n comboboxContext.itemToStringLabel,\n comboboxContext.itemToStringValue,\n ],\n )\n\n // Get the label for the selected value (used when closed or just opened)\n const selectedLabel = React.useMemo(() => {\n if (!hasValue) {\n return ''\n }\n if (comboboxContext.multiple) {\n // For multi-select, show comma-separated values or count\n const texts = comboboxContext.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, comboboxContext.itemToStringLabel) ||\n stringifyAsValue(v, comboboxContext.itemToStringValue)\n )\n })\n .filter(Boolean)\n if (texts.length <= 2) {\n return texts.join(', ')\n }\n return `${texts.length} selected`\n }\n // Single-select: show the value's text.\n // Empty-string values are already handled by the `!hasValue` guard above;\n // this null check also narrows `Value | null` down to `Value`.\n const value = comboboxContext.value\n if (value == null) return ''\n\n const text = getValueText(value)\n if (text !== undefined) return text\n // Fall back to resolved label or serialized value\n return (\n resolveLabel(value, comboboxContext.itemToStringLabel) ||\n stringifyAsValue(value, comboboxContext.itemToStringValue)\n )\n }, [\n hasValue,\n comboboxContext.multiple,\n comboboxContext.value,\n comboboxContext.values,\n comboboxContext.itemToStringLabel,\n comboboxContext.itemToStringValue,\n getValueText,\n ])\n\n // Determine the display value for the input\n // When closed: show selected value's text\n // When open: show the search/filter text (inputValue)\n const displayValue = React.useMemo(() => {\n if (!open) {\n // When closed, show the selected value's label\n return selectedLabel\n }\n // When open, use the input value for filtering\n return comboboxContext.inputValue\n }, [open, selectedLabel, comboboxContext.inputValue])\n\n return {\n hasValue,\n displayValue,\n selectedLabel,\n getValueText,\n }\n}\n"]}