@bazza-ui/react 0.0.0 → 0.1.0-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ListboxStore-BtcTXpzi.d.cts +351 -0
- package/dist/ListboxStore-DPqpLlAL.d.ts +351 -0
- package/dist/adapters/index.cjs +2 -0
- package/dist/adapters/index.cjs.map +1 -0
- package/dist/adapters/index.d.cts +363 -0
- package/dist/adapters/index.d.ts +363 -0
- package/dist/adapters/index.js +2 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/chunk-4C666HHU.js +2 -0
- package/dist/chunk-4C666HHU.js.map +1 -0
- package/dist/chunk-AVZ64JQ3.js +2 -0
- package/dist/chunk-AVZ64JQ3.js.map +1 -0
- package/dist/chunk-BGJJC6GX.cjs +2 -0
- package/dist/chunk-BGJJC6GX.cjs.map +1 -0
- package/dist/chunk-FWWOE2SW.cjs +2 -0
- package/dist/chunk-FWWOE2SW.cjs.map +1 -0
- package/dist/chunk-JSPKF52O.cjs +2 -0
- package/dist/chunk-JSPKF52O.cjs.map +1 -0
- package/dist/chunk-KWGD24VS.js +2 -0
- package/dist/chunk-KWGD24VS.js.map +1 -0
- package/dist/chunk-M4G6J7DP.cjs +2 -0
- package/dist/chunk-M4G6J7DP.cjs.map +1 -0
- package/dist/chunk-WKAPAKUL.js +2 -0
- package/dist/chunk-WKAPAKUL.js.map +1 -0
- package/dist/combobox/index.cjs +2 -0
- package/dist/combobox/index.cjs.map +1 -0
- package/dist/combobox/index.d.cts +1039 -0
- package/dist/combobox/index.d.ts +1039 -0
- package/dist/combobox/index.js +2 -0
- package/dist/combobox/index.js.map +1 -0
- package/dist/command-score-Dgo3ZS3Z.d.ts +36 -0
- package/dist/command-score-YjNr3ZWi.d.cts +36 -0
- package/dist/context-menu/index.cjs +2 -0
- package/dist/context-menu/index.cjs.map +1 -0
- package/dist/context-menu/index.d.cts +658 -0
- package/dist/context-menu/index.d.ts +658 -0
- package/dist/context-menu/index.js +2 -0
- package/dist/context-menu/index.js.map +1 -0
- package/dist/data-surface-B-eIGTBi.d.cts +678 -0
- package/dist/data-surface-D1OilMDu.d.ts +678 -0
- package/dist/dropdown-menu/index.cjs +2 -0
- package/dist/dropdown-menu/index.cjs.map +1 -0
- package/dist/dropdown-menu/index.d.cts +700 -0
- package/dist/dropdown-menu/index.d.ts +700 -0
- package/dist/dropdown-menu/index.js +2 -0
- package/dist/dropdown-menu/index.js.map +1 -0
- package/dist/events-BPr8sRGH.d.cts +166 -0
- package/dist/events-BPr8sRGH.d.ts +166 -0
- package/dist/input-BoIK003I.d.cts +41 -0
- package/dist/input-DF7D8YzW.d.ts +41 -0
- package/dist/internal/listbox/index.cjs +2 -0
- package/dist/internal/listbox/index.cjs.map +1 -0
- package/dist/internal/listbox/index.d.cts +269 -0
- package/dist/internal/listbox/index.d.ts +269 -0
- package/dist/internal/listbox/index.js +2 -0
- package/dist/internal/listbox/index.js.map +1 -0
- package/dist/internal/popup-menu/index.cjs +2 -0
- package/dist/internal/popup-menu/index.cjs.map +1 -0
- package/dist/internal/popup-menu/index.d.cts +846 -0
- package/dist/internal/popup-menu/index.d.ts +846 -0
- package/dist/internal/popup-menu/index.js +2 -0
- package/dist/internal/popup-menu/index.js.map +1 -0
- package/dist/item-equality-B6TbXlBT.d.cts +7 -0
- package/dist/item-equality-B6TbXlBT.d.ts +7 -0
- package/dist/loading-DphSt8MY.d.cts +27 -0
- package/dist/loading-TsgH6v92.d.ts +27 -0
- package/dist/select/index.cjs +2 -0
- package/dist/select/index.cjs.map +1 -0
- package/dist/select/index.d.cts +927 -0
- package/dist/select/index.d.ts +927 -0
- package/dist/select/index.js +2 -0
- package/dist/select/index.js.map +1 -0
- package/dist/separator-B4Ot84B0.d.ts +748 -0
- package/dist/separator-BmbUeeaT.d.cts +748 -0
- package/dist/types-9vS1uLIK.d.cts +1557 -0
- package/dist/types-lQCIvWW8.d.ts +1557 -0
- package/dist/use-listbox-item-BIi4eRPI.d.cts +182 -0
- package/dist/use-listbox-item-BIi4eRPI.d.ts +182 -0
- package/package.json +50 -12
- package/dist/index.d.ts +0 -2
- 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 _chunkBGJJC6GXcjs = require('../chunk-BGJJC6GX.cjs');var _chunkJSPKF52Ocjs = require('../chunk-JSPKF52O.cjs');var _chunkFWWOE2SWcjs = require('../chunk-FWWOE2SW.cjs');var _chunkM4G6J7DPcjs = require('../chunk-M4G6J7DP.cjs');var Ho={};_chunkM4G6J7DPcjs.a.call(void 0, Ho,{Arrow:()=>_chunkJSPKF52Ocjs.N,Backdrop:()=>_chunkJSPKF52Ocjs.P,Clear:()=>ye,Empty:()=>_chunkJSPKF52Ocjs.oa,Group:()=>_chunkJSPKF52Ocjs.Qa,GroupLabel:()=>_chunkJSPKF52Ocjs.Ra,Icon:()=>_chunkJSPKF52Ocjs.ja,Input:()=>Ve,InputWrapper:()=>Me,Item:()=>Ee,ItemIndicator:()=>Le,ItemLabel:()=>we,List:()=>_chunkJSPKF52Ocjs.sa,Popup:()=>_chunkJSPKF52Ocjs._,Portal:()=>_chunkJSPKF52Ocjs.$,Positioner:()=>Te,Root:()=>ke,ScrollDownArrow:()=>_chunkJSPKF52Ocjs.xa,ScrollUpArrow:()=>_chunkJSPKF52Ocjs.wa,Separator:()=>_chunkJSPKF52Ocjs.Sa,Surface:()=>He,useComboboxPositionerContext:()=>Se});var _userender = require('@base-ui/react/use-render');var _react = require('react'); var X = _interopRequireWildcard(_react); var ce = _interopRequireWildcard(_react); var ee = _interopRequireWildcard(_react); var be = _interopRequireWildcard(_react); var re = _interopRequireWildcard(_react); var T = _interopRequireWildcard(_react); var oe = _interopRequireWildcard(_react); var w = _interopRequireWildcard(_react); var ae = _interopRequireWildcard(_react); var Ce = _interopRequireWildcard(_react); var Y = _interopRequireWildcard(_react); var U = _interopRequireWildcard(_react); var g = _interopRequireWildcard(_react); var Z = _interopRequireWildcard(_react);var Vo={slot:"bazzaui-combobox-clear"};var ye=X.forwardRef(function(e,t){let{keepMounted:a=!1,disabled:n,render:r,className:c,style:d,onClick:o,...i}=e,p=_chunkJSPKF52Ocjs.S.call(void 0, ),f=_nullishCoalesce(n, () => (p.disabled)),m=p.multiple?p.values.length>0:p.value!=="",y=X.useCallback(R=>{_optionalChain([o, 'optionalCall', _2 => _2(R)]),!R.defaultPrevented&&(p.multiple?p.onValuesChange([]):p.onValueChange(""),p.onInputValueChange(""))},[o,p]),u=X.useCallback(R=>{R.preventDefault()},[]),C=X.useMemo(()=>({hasValue:m,disabled:f}),[m,f]),b=_userender.useRender.call(void 0, {render:r,ref:t,state:C,props:{...i,[Vo.slot]:"",type:"button",tabIndex:-1,"aria-label":"Clear selection",disabled:f||!m,className:c,style:d,onClick:y,onPointerDown:u},enabled:a||m,defaultTagName:"button"});return!a&&!m?null:b});var me=ce.createContext(null);function Se(){return ce.useContext(me)}var ve=be.createContext(!1);function Mo(){return be.useContext(ve)}var Q={slot:"bazzaui-combobox-input",open:"data-open",closed:"data-closed",disabled:"data-disabled",placeholder:"data-placeholder"};function dt(l,e){if(!l)return;if(Array.isArray(l)){let n=_optionalChain([l, 'access', _3 => _3.find, 'call', _4 => _4(r=>r.value===e), 'optionalAccess', _5 => _5.label]);return typeof n=="string"?n:void 0}let t=l[e];return typeof t=="string"?t:void 0}function Eo(l){let{comboboxContext:e,open:t}=l,a=e.multiple?e.values.length>0:e.value!=null,n=re.useCallback(d=>{let o=_chunkJSPKF52Ocjs.ia.call(void 0, d,e.itemToStringValue),i=e.itemTextRegistry.get(o);if(i!==void 0)return i;let p=dt(e.items,o);if(p!==void 0)return p;let f=_chunkJSPKF52Ocjs.ha.call(void 0, d,e.itemToStringLabel);if(f&&f!==o)return f},[e.itemTextRegistry,e.items,e.itemToStringLabel,e.itemToStringValue]),r=re.useMemo(()=>{if(!a)return"";if(e.multiple){let i=e.values.map(p=>{let f=n(p);return f!==void 0?f:_chunkJSPKF52Ocjs.ha.call(void 0, p,e.itemToStringLabel)||_chunkJSPKF52Ocjs.ia.call(void 0, p,e.itemToStringValue)}).filter(Boolean);return i.length<=2?i.join(", "):`${i.length} selected`}let d=e.value;if(d==null)return"";let o=n(d);return o!==void 0?o:_chunkJSPKF52Ocjs.ha.call(void 0, d,e.itemToStringLabel)||_chunkJSPKF52Ocjs.ia.call(void 0, d,e.itemToStringValue)},[a,e.multiple,e.value,e.values,e.itemToStringLabel,e.itemToStringValue,n]),c=re.useMemo(()=>t?e.inputValue:r,[t,r,e.inputValue]);return{hasValue:a,displayValue:c,selectedLabel:r,getValueText:n}}function Lo(l){let{comboboxContext:e,store:t,focusOwnerStore:a,open:n,disabled:r,cursorBehavior:c,hasValue:d,getValueText:o,onFocus:i,onBlur:p,onClick:f,onKeyDown:m}=l,y=T.useRef(!1),u=T.useRef(!1),C=T.useRef(!1),b=T.useRef(null),R=T.useRef(null),I=T.useRef(null);T.useEffect(()=>{if(!n)return;let s=x=>{let E=e.inputRef.current,v=e.inputWrapperRef.current,L=document.getElementById(e.listId),A=x.target,P=_optionalChain([E, 'optionalAccess', _6 => _6.contains, 'call', _7 => _7(A)]),B=_optionalChain([v, 'optionalAccess', _8 => _8.contains, 'call', _9 => _9(A)]),G=_optionalChain([L, 'optionalAccess', _10 => _10.contains, 'call', _11 => _11(A)]);!P&&!B&&!G&&(I.current=x)};return document.addEventListener("pointerdown",s,!0),()=>{document.removeEventListener("pointerdown",s,!0),I.current=null}},[n,e.inputRef,e.inputWrapperRef,e.listId]),T.useLayoutEffect(()=>{let s=e.inputRef.current;if(s&&n&&R.current){let{start:x,end:E}=R.current,v=s.selectionStart,L=s.value.length;v===L&&x!==L&&s.setSelectionRange(x,E),R.current=null}});let S=T.useRef(n);T.useLayoutEffect(()=>{if(n&&!S.current){if(y.current){y.current=!1,S.current=n;return}if(C.current){C.current=!1,u.current=!1,b.current=null,S.current=n;return}if(u.current&&c==="none"){let x=e.inputRef.current,E=b.current;x&&E!==null&&requestAnimationFrame(()=>{let v=x.value.length,L=Math.min(E,v);x.setSelectionRange(L,L)}),u.current=!1,b.current=null,S.current=n;return}d&&e.multiple&&e.onInputValueChange("");let s=e.inputRef.current;if(s){let x=s.value.length;c==="select-all"&&x>0?requestAnimationFrame(()=>{s.setSelectionRange(0,s.value.length)}):c==="end"&&x>0&&requestAnimationFrame(()=>{s.setSelectionRange(s.value.length,s.value.length)})}}S.current=n},[n,e,d,c]);let V=T.useCallback(s=>{let x=s.target,E=x.value,v=x.selectionStart,L=x.selectionEnd;v!==null&&L!==null&&(R.current={start:v,end:L}),e.onInputValueChange(E),e.setFilterActive(),t.setSearch(E),t.state.open||(y.current=!0,e.openCombobox())},[e,t]),D=T.useCallback(s=>{if(_optionalChain([i, 'optionalCall', _12 => _12(s)]),s.defaultPrevented)return;let x=t.state.open;if(x&&(C.current=!0),e.openOnFocus&&!r&&!x){if(d&&!e.multiple){let E=_nullishCoalesce(o(e.value), () => (_chunkJSPKF52Ocjs.ha.call(void 0, e.value,e.itemToStringLabel)));e.onInputValueChange(E)}e.openCombobox()}},[i,e,r,t,d,o]),z=T.useCallback(s=>{_optionalChain([p, 'optionalCall', _13 => _13(s)]),!s.defaultPrevented&&requestAnimationFrame(()=>{let x=document.activeElement,v=_optionalChain([document, 'access', _14 => _14.getElementById, 'call', _15 => _15(e.listId), 'optionalAccess', _16 => _16.contains, 'call', _17 => _17(x)]),L=x===e.inputRef.current;if(!v&&!L){C.current=!1;let A=I.current,P=A?_chunkFWWOE2SWcjs.a.outsidePress:_chunkFWWOE2SWcjs.a.focusOut;I.current=null,e.closeCombobox(P,_nullishCoalesce(A, () => (void 0)))}})},[p,e]),H=T.useCallback(s=>{if(_optionalChain([f, 'optionalCall', _18 => _18(s)]),s.defaultPrevented)return;let x=t.state.open;if(!r&&!x){let E=s.target;if(c==="none"){let v=E.selectionStart;b.current=v,u.current=!0}if(d&&!e.multiple){let v=_nullishCoalesce(o(e.value), () => (_chunkJSPKF52Ocjs.ha.call(void 0, e.value,e.itemToStringLabel)));e.onInputValueChange(v)}e.openCombobox()}else x&&(C.current=!0)},[f,e,r,t,c,d,o]),N=T.useCallback(s=>{if(_optionalChain([m, 'optionalCall', _19 => _19(s)]),!s.defaultPrevented){if(n&&s.key==="Escape"){s.preventDefault(),e.closeCombobox(_chunkFWWOE2SWcjs.a.escapeKey);return}if(!n&&(s.key==="ArrowDown"||s.key==="ArrowUp"||s.key==="Enter")){if(s.preventDefault(),d&&!e.multiple){let x=_nullishCoalesce(o(e.value), () => (_chunkJSPKF52Ocjs.ha.call(void 0, e.value,e.itemToStringLabel)));e.onInputValueChange(x)}e.openCombobox();return}}},[n,e,m,d,o]),{handleKeyDown:M}=_chunkJSPKF52Ocjs.fa.call(void 0, {store:t,surfaceId:"combobox-input",focusOwnerStore:a,depth:0,submenuContext:null,subpageContext:null,enabled:n,enableTypeToSearch:!1,onKeyDown:N,closeAll:e.closeCombobox,skipFocusOwnerCheck:!0});return{handleChange:V,handleFocus:D,handleBlur:z,handleClick:H,handleKeyDown:M,selectionRef:R}}var Ve=ee.forwardRef(function(e,t){let{placeholder:a,disabled:n,cursorBehavior:r="none",render:c,className:d,style:o,onFocus:i,onBlur:p,onClick:f,onKeyDown:m,...y}=e,u=_chunkJSPKF52Ocjs.S.call(void 0, ),C=_chunkJSPKF52Ocjs.l.call(void 0, ),b=_chunkJSPKF52Ocjs.f.call(void 0, ),R=Mo(),I=(_nullishCoalesce(n, () => (u.disabled)))||C.disabled,S=_nullishCoalesce(a, () => (u.placeholder)),V=C.store.useState("open"),{hasValue:D,displayValue:z,getValueText:H}=Eo({comboboxContext:u,open:V}),{handleChange:N,handleFocus:M,handleBlur:s,handleClick:x,handleKeyDown:E}=Lo({comboboxContext:u,store:C.store,focusOwnerStore:b,open:V,disabled:I,cursorBehavior:r,hasValue:D,getValueText:H,onFocus:i,onBlur:p,onClick:f,onKeyDown:m}),v={[Q.slot]:""};V?v[Q.open]="":v[Q.closed]="",I&&(v[Q.disabled]=""),D||(v[Q.placeholder]=""),u.layout==="input-embedded"&&(v["data-input-embedded"]="");let L=ee.useCallback(G=>{u.setInputElement(G),typeof t=="function"?t(G):t&&(t.current=G)},[t,u]),A=ee.useMemo(()=>({open:V,disabled:I,placeholder:!D}),[V,I,D]),P=u.layout==="input-embedded"&&!R?{position:"relative",zIndex:1}:void 0;return _userender.useRender.call(void 0, {render:c,ref:L,state:A,props:{...y,...v,type:"text",role:"combobox","aria-autocomplete":"list","aria-expanded":V,"aria-controls":u.listId,"aria-haspopup":"listbox",autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:I,placeholder:D?void 0:S,className:d,style:{...P,...o},value:z,onChange:N,onFocus:M,onBlur:s,onClick:x,onKeyDown:E},defaultTagName:"input"})});var de={slot:"bazzaui-combobox-input-wrapper",open:"data-open"};var _jsxruntime = require('react/jsx-runtime');var Ct={open:l=>l?{[de.open]:""}:null},Me= exports.ComboboxInputWrapper =oe.forwardRef(function(e,t){let{render:a,className:n,style:r,children:c,...d}=e,{store:o}=_chunkJSPKF52Ocjs.l.call(void 0, ),i=_chunkJSPKF52Ocjs.S.call(void 0, ),p=o.useState("open"),f=oe.useMemo(()=>({open:p}),[p]),m=i.layout==="input-embedded"?{position:"relative",zIndex:1}:{position:"relative"},y=oe.useCallback(C=>{i.setInputWrapperElement(C),typeof t=="function"?t(C):t&&(t.current=C)},[t,i]),u=_userender.useRender.call(void 0, {render:a,ref:y,state:f,stateAttributesMapping:Ct,props:{...d,[de.slot]:"",className:n,style:{...m,...r},children:c},defaultTagName:"div"});return _jsxruntime.jsx.call(void 0, ve.Provider,{value:!0,children:u})});var te={slot:"bazzaui-combobox-item",highlighted:"data-highlighted",disabled:"data-disabled",selected:"data-selected"};var xe=ae.createContext(null);function se(){let l=ae.useContext(xe);if(!l)throw new Error("ComboboxItem child components must be used within a Combobox.Item");return l}function ht(){return ae.useContext(xe)}var Pt={highlighted:l=>l?{[te.highlighted]:""}:null,disabled:l=>l?{[te.disabled]:""}:null,selected:l=>l?{[te.selected]:""}:null};function It(l,e){if(l)return Array.isArray(l)?_optionalChain([l, 'access', _20 => _20.find, 'call', _21 => _21(a=>a.value===e), 'optionalAccess', _22 => _22.label]):l[e]}function yt(l,e){let{value:t,textValue:a,keywords:n,disabled:r=!1,onSelect:c,forceMount:d=!1,render:o,className:i,style:p,onClick:f,onPointerDown:m,onPointerMove:y,children:u,...C}=l,b=_chunkJSPKF52Ocjs.S.call(void 0, ),R=w.useMemo(()=>_chunkJSPKF52Ocjs.ia.call(void 0, t,b.itemToStringValue),[t,b.itemToStringValue]),I=w.useMemo(()=>It(b.items,R),[b.items,R]),S=w.useMemo(()=>_chunkJSPKF52Ocjs.ha.call(void 0, t,b.itemToStringLabel),[t,b.itemToStringLabel]),V=w.useMemo(()=>{if(a!==void 0)return a;if(typeof I=="string")return I;if(S&&S!==R)return S},[a,I,S,R]),D=w.useMemo(()=>{let P=typeof I=="string"?I:S&&S!==R?S:void 0;return P?n?n.includes(P)?n:[...n,P]:[P]:n},[n,I,S,R]),z=w.useRef(V),H=b.multiple?_chunkBGJJC6GXcjs.c.call(void 0, b.values,t,b.isItemEqualToValue):b.value!=null&&_chunkBGJJC6GXcjs.b.call(void 0, b.value,t,b.isItemEqualToValue),N=b.closeOnSelect,M=_chunkJSPKF52Ocjs.ea.call(void 0, {value:R,keywords:D,disabled:r,forceMount:d,closeOnClick:N,children:u});w.useEffect(()=>{let P=()=>{if(!r){if(b.multiple){let B=H?_chunkBGJJC6GXcjs.d.call(void 0, b.values,t,b.isItemEqualToValue):[...b.values,t];b.onValuesChange(B)}else b.onValueChange(t);_optionalChain([c, 'optionalCall', _23 => _23()])}};return M.registerSelect(P)},[r,b,t,H,c,M]),w.useEffect(()=>{let P=z.current;if(P)return b.registerItemText(R,P)},[R,b]),w.useEffect(()=>{!V&&typeof u=="string"&&(z.current=u,b.registerItemText(R,u))},[u,V,R,b]);let s=w.useMemo(()=>({highlighted:M.isHighlighted,disabled:r,selected:H}),[M.isHighlighted,r,H]),x=w.useMemo(()=>({id:M.id,value:t,textValue:V,highlighted:M.isHighlighted,disabled:r,selected:H}),[M.id,t,V,M.isHighlighted,r,H]),E=w.useCallback(P=>{_optionalChain([f, 'optionalCall', _24 => _24(P)]),P.defaultPrevented||M.handlers.onClick(P)},[f,M.handlers]),v=w.useCallback(P=>{M.handlers.onPointerDown(P),_optionalChain([m, 'optionalCall', _25 => _25(P)])},[M.handlers,m]),L=w.useCallback(P=>{_optionalChain([y, 'optionalCall', _26 => _26(P)]),P.defaultPrevented||M.handlers.onPointerMove(P)},[y,M.handlers]),A=_userender.useRender.call(void 0, {render:o,ref:[M.ref,e],state:s,stateAttributesMapping:Pt,props:{...C,[te.slot]:"",id:M.id,role:"option",tabIndex:-1,"aria-selected":H,"aria-disabled":r||void 0,className:i,style:p,onClick:E,onPointerMove:L,onPointerDown:v,children:u},enabled:M.isVisible,defaultTagName:"div"});return M.isVisible?_jsxruntime.jsx.call(void 0, xe.Provider,{value:x,children:A}):null}var Ee=w.forwardRef(yt);var fe={slot:"bazzaui-combobox-item-indicator",selected:"data-selected"};var Vt={selected:l=>l?{[fe.selected]:""}:null},Le= exports.ComboboxItemIndicator =Ce.forwardRef(function(e,t){let{keepMounted:a=!1,render:n,className:r,style:c,...d}=e,o=se(),i=Ce.useMemo(()=>({selected:o.selected}),[o.selected]),p=_userender.useRender.call(void 0, {render:n,ref:t,state:i,stateAttributesMapping:Vt,props:{...d,[fe.slot]:"","aria-hidden":!0,className:r,style:c},enabled:a||o.selected,defaultTagName:"span"});return!a&&!o.selected?null:p});var wo={slot:"bazzaui-combobox-item-label"};function Et(l,e){if(l)return Array.isArray(l)?_optionalChain([l, 'access', _27 => _27.find, 'call', _28 => _28(a=>a.value===e), 'optionalAccess', _29 => _29.label]):l[e]}var we=Y.forwardRef(function(e,t){let{render:a,className:n,style:r,children:c,...d}=e,o=_chunkJSPKF52Ocjs.S.call(void 0, ),i=se(),p=_chunkJSPKF52Ocjs.ia.call(void 0, i.value,o.itemToStringValue),f=Y.useMemo(()=>{if(c!==void 0)return c;let y=Et(o.items,p);return y!==void 0?y:i.textValue!==void 0?i.textValue:p},[c,o.items,p,i.textValue]),m=Y.useMemo(()=>({value:p,selected:i.selected,highlighted:i.highlighted,disabled:i.disabled}),[p,i.selected,i.highlighted,i.disabled]);return Y.useEffect(()=>{if(typeof f=="string")return o.registerItemText(p,f)},[f,o,p]),_userender.useRender.call(void 0, {render:a,ref:t,state:m,props:{...d,[wo.slot]:"",className:n,style:r,children:f},defaultTagName:"span"})});var _popover = require('@base-ui/react/popover');var ge={slot:"bazzaui-combobox-positioner"};function Lt(l,e,t,a){let n=t+a*2;if(l==="top"){let d=-(e+a),o=e+a;return{width:n,marginBottom:d,paddingTop:a,paddingLeft:a,paddingRight:a,paddingBottom:o}}let r=-(e+a),c=e+a;return{width:n,marginTop:r,paddingTop:c,paddingLeft:a,paddingRight:a,paddingBottom:a}}var Te=U.forwardRef(function(e,t){let{layout:a,popupPadding:n=8,side:r="bottom",align:c,sideOffset:d=4,anchor:o,className:i,style:p,children:f,...m}=e,y=_chunkJSPKF52Ocjs.S.call(void 0, ),u=_nullishCoalesce(a, () => (y.layout)),C=u==="input-embedded",b=_nullishCoalesce(o, () => (y.inputWrapperRef.current))?y.inputWrapperRef:y.inputRef,R=C?0:d,I=C?"center":_nullishCoalesce(c, () => ("start")),{inputHeight:S,inputWidth:V}=y,D=V+n*2,z={...p,...C?{zIndex:0}:{}};if(C)return _jsxruntime.jsx.call(void 0, _popover.Popover.Positioner,{ref:t,side:r,align:I,sideOffset:R,anchor:b,className:i,style:z,"data-input-embedded":"",[ge.slot]:"",...m,render:(s,x)=>{let E=x.side,v={layout:u,side:E,align:x.align,inputHeight:y.inputHeight},L={"--combobox-input-height":`${S}px`,"--combobox-input-width":`${V}px`,"--combobox-popup-padding":`${n}px`,"--combobox-popup-width":`${D}px`},A=Lt(E,S,V,n),P=U.Children.map(f,B=>U.isValidElement(B)?U.cloneElement(B,{style:{...A,...B.props.style},"data-side":E}):B);return _jsxruntime.jsx.call(void 0, me.Provider,{value:v,children:_jsxruntime.jsx.call(void 0, "div",{...s,style:{...s.style,...L},"data-side":E,children:P})})}});let H={layout:u,side:r,align:I,inputHeight:y.inputHeight},N={"--combobox-input-height":`${S}px`,"--combobox-input-width":`${V}px`},M={...z,...N};return _jsxruntime.jsx.call(void 0, me.Provider,{value:H,children:_jsxruntime.jsx.call(void 0, _popover.Popover.Positioner,{ref:t,side:r,align:I,sideOffset:R,anchor:b,className:i,style:M,[ge.slot]:"",...m,children:f})})});function ke(l){let{open:e,onOpenChange:t,actionsRef:a,defaultOpen:n=!1,value:r,defaultValue:c,onValueChange:d,multiple:o=!1,values:i,defaultValues:p,onValuesChange:f,isItemEqualToValue:m=_chunkBGJJC6GXcjs.a,itemToStringLabel:y,itemToStringValue:u,inputValue:C,defaultInputValue:b="",onInputValueChange:R,name:I,form:S,required:V,disabled:D=!1,placeholder:z="Search...",items:H,modal:N=!1,closeOnSelect:M,openOnFocus:s=!0,virtualized:x=!1,virtualItems:E,onHighlightChange:v,layout:L="floating",onOpenChangeComplete:A,debug:P,children:B,...G}=l,Ae=g.useId(),ie=g.useRef(null),he=g.useRef(null),[Oe,De]=g.useState(0),[Fe,ze]=g.useState(0),Be=g.useCallback(h=>{if(ie.current=h,h&&!he.current){let k=h.getBoundingClientRect();De(k.height),ze(k.width)}},[]),We=g.useCallback(h=>{if(he.current=h,h){let k=h.getBoundingClientRect();De(k.height),ze(k.width)}},[]),{store:W,focusOwnerStore:No,openChainStore:qo,registerSurface:Uo,closeAll:Go,virtualization:Ko,handleOpenChange:je,disabled:K,setDisabled:Ne}=_chunkJSPKF52Ocjs.L.call(void 0, {onOpenChange:t,defaultOpen:n,virtualized:x,items:E,onHighlightChange:v,disabled:D}),Re=g.useRef(null);g.useImperativeHandle(a,()=>({close:()=>{_optionalChain([Re, 'access', _30 => _30.current, 'optionalAccess', _31 => _31.close, 'call', _32 => _32()])},unmount:()=>{_optionalChain([Re, 'access', _33 => _33.current, 'optionalAccess', _34 => _34.unmount, 'call', _35 => _35()])},setDisabled:Ne}),[Ne]),W.useControlledProp("open",e,n);let $o=W.useState("open"),qe=g.useCallback((h,k,q)=>{K&&k!==_chunkFWWOE2SWcjs.a.imperativeAction||!h&&ie.current&&document.activeElement===ie.current||je(h,k,q)},[je,K]),Jo=g.useCallback(h=>{!h&&W.context.clearSearchOnClose==="after-exit"&&(W.clearSearch(),W.setInputActive(!1)),_optionalChain([A, 'optionalCall', _36 => _36(h)])},[W,A]),Xo=g.useCallback((h,k)=>{qe(h,k.reason,k.event)},[qe]),[Qo,Yo]=g.useState(c!==void 0?c:null),$=r!==void 0?r:Qo,Ue=g.useCallback(h=>{r===void 0&&Yo(h),_optionalChain([d, 'optionalCall', _37 => _37(h)])},[r,d]),[Zo,_o]=g.useState(_nullishCoalesce(p, () => ([]))),ne=i!==void 0?i:Zo,Ge=g.useCallback(h=>{i===void 0&&_o(h),_optionalChain([f, 'optionalCall', _38 => _38(h)])},[i,f]),[Pe,et]=g.useState(b),Ke=C!==void 0?C:Pe,$e=g.useCallback(h=>{C===void 0&&et(h),_optionalChain([R, 'optionalCall', _39 => _39(h)])},[C,R]),Je=g.useRef(new Map),Xe=g.useCallback((h,k)=>(Je.current.set(h,k),()=>{}),[]),Qe=_nullishCoalesce(M, () => (!o)),Ie=g.useRef({type:"active"}),[,ot]=g.useState({type:"active"}),J=g.useCallback(h=>{Ie.current=h,ot(h)},[]),Ye=Ie.current,Ze=g.useCallback(()=>{J({type:"active"})},[J]),_e=g.useCallback(()=>{K||(!o&&$!=null?J({type:"showAll"}):J({type:"active"}),W.setOpen(!0))},[K,W,o,$,J]),eo=g.useCallback((h,k)=>{let q=Ie.current,oo=q.type==="active"?Pe:q.type==="showAll"?"":q.search;J({type:"frozen",search:oo}),W.setOpen(!1,h,k)},[W,J,Pe]),tt=g.useMemo(()=>({multiple:o,value:$,values:ne,onValueChange:Ue,onValuesChange:Ge,isItemEqualToValue:m,itemToStringLabel:y,itemToStringValue:u,inputValue:Ke,onInputValueChange:$e,name:I,form:S,required:V,disabled:K,placeholder:z,items:H,itemTextRegistry:Je.current,registerItemText:Xe,listId:Ae,inputRef:ie,setInputElement:Be,inputWrapperRef:he,setInputWrapperElement:We,closeOnSelect:Qe,openOnFocus:s,openCombobox:_e,closeCombobox:eo,filterMode:Ye,setFilterActive:Ze,inputHeight:Oe,inputWidth:Fe,layout:L}),[o,$,ne,Ue,Ge,m,y,u,Ke,$e,I,S,V,K,z,H,Xe,Ae,Be,We,Qe,s,_e,eo,Ye,Ze,Oe,Fe,L]),nt=g.useMemo(()=>I?o?ne.length>0?ne.map((h,k)=>{let q=_chunkJSPKF52Ocjs.ia.call(void 0, h,u);return _jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:I,value:q,form:S,required:V&&k===0},q)}):_jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:I,value:"",form:S,required:V}):_jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:I,value:$!=null?_chunkJSPKF52Ocjs.ia.call(void 0, $,u):"",form:S,required:V}):null,[I,S,V,o,$,ne,u]);return _jsxruntime.jsx.call(void 0, _chunkJSPKF52Ocjs.R.Provider,{value:tt,children:_jsxruntime.jsxs.call(void 0, _chunkJSPKF52Ocjs.da,{store:W,focusOwnerStore:No,openChainStore:qo,disabled:K,depth:0,closeAll:Go,registerSurface:Uo,virtualization:Ko,menuType:"dropdown",componentName:"combobox",debug:P,children:[nt,_jsxruntime.jsx.call(void 0, _popover.Popover.Root,{...G,open:$o,onOpenChange:Xo,onOpenChangeComplete:Jo,modal:N,actionsRef:a?Re:void 0,children:B})]})})}var ko={slot:"bazzaui-combobox-surface"};var He=Z.forwardRef(function(e,t){let{autoHighlightFirst:a,search:n,onSearchChange:r,onPointerMove:c,...d}=e,o=_chunkJSPKF52Ocjs.S.call(void 0, ),i=Z.useCallback(u=>{_optionalChain([c, 'optionalCall', _40 => _40(u)]);let C=o.inputRef.current;C&&document.activeElement!==C&&C.focus()},[c,o.inputRef]),p=Z.useMemo(()=>{let u=_nullishCoalesce(a, () => (!0));if(u==="selected"){let C=o.multiple?o.values[0]:o.value;return C!=null?_chunkJSPKF52Ocjs.ia.call(void 0, C,o.itemToStringValue):!0}return u},[a,o.multiple,o.value,o.values,o.itemToStringValue]),{filterMode:f}=o,m=_nullishCoalesce(n, () => ((f.type==="active"?o.inputValue:f.type==="showAll"?"":f.search))),y=Z.useCallback(u=>{o.onInputValueChange(u),_optionalChain([r, 'optionalCall', _41 => _41(u)])},[o,r]);return _jsxruntime.jsx.call(void 0, _chunkJSPKF52Ocjs.ya,{ref:t,autoHighlightFirst:p,search:m,onSearchChange:y,onPointerMove:i,skipAutoFocus:!0,[ko.slot]:"",...d})});var Ao=(c=>(c.slot="bazzaui-combobox-arrow",c.open="data-open",c.closed="data-closed",c.side="data-side",c.align="data-align",c.uncentered="data-uncentered",c))(Ao||{});var Oo=(r=>(r.slot="bazzaui-combobox-backdrop",r.open="data-open",r.closed="data-closed",r.startingStyle="data-starting-style",r.endingStyle="data-ending-style",r))(Oo||{});var Do=(e=>(e.slot="bazzaui-combobox-empty",e))(Do||{});var Fo=(e=>(e.slot="bazzaui-combobox-group",e))(Fo||{});var zo=(e=>(e.slot="bazzaui-combobox-group-label",e))(zo||{});var Ht={slot:"bazzaui-combobox-icon",open:"data-popup-open"};var Bo=(t=>(t.slot="bazzaui-combobox-list",t.list="data-popup-menu-list",t))(Bo||{});var Wo=(m=>(m.slot="bazzaui-combobox-popup",m.open="data-open",m.closed="data-closed",m.side="data-side",m.align="data-align",m.startingStyle="data-starting-style",m.endingStyle="data-ending-style",m.instant="data-instant",m.focused="data-focused",m.hasOpenSubmenu="data-has-open-submenu",m.submenu="data-submenu",m.navigating="data-navigating",m))(Wo||{});var At={slotUp:"bazzaui-combobox-scroll-up-arrow",slotDown:"bazzaui-combobox-scroll-down-arrow",direction:"data-direction",side:"data-side"};var jo=(e=>(e.slot="bazzaui-combobox-separator",e))(jo||{});exports.Combobox = Ho; exports.ComboboxArrowDataAttributes = Ao; exports.ComboboxBackdropDataAttributes = Oo; exports.ComboboxClear = ye; exports.ComboboxEmptyDataAttributes = Do; exports.ComboboxGroupDataAttributes = Fo; exports.ComboboxGroupLabelDataAttributes = zo; exports.ComboboxIconDataAttributes = Ht; exports.ComboboxInput = Ve; exports.ComboboxInputDataAttributes = Q; exports.ComboboxInputWrapper = Me; exports.ComboboxInputWrapperDataAttributes = de; exports.ComboboxItem = Ee; exports.ComboboxItemDataAttributes = te; exports.ComboboxItemIndicator = Le; exports.ComboboxItemIndicatorDataAttributes = fe; exports.ComboboxItemLabel = we; exports.ComboboxListCssVars = _chunkJSPKF52Ocjs.qa; exports.ComboboxListDataAttributes = Bo; exports.ComboboxPopupDataAttributes = Wo; exports.ComboboxPositioner = Te; exports.ComboboxPositionerCssVars = _chunkJSPKF52Ocjs.aa; exports.ComboboxPositionerDataAttributes = ge; exports.ComboboxRoot = ke; exports.ComboboxScrollArrowDataAttributes = At; exports.ComboboxSeparatorDataAttributes = jo; exports.ComboboxStore = _chunkFWWOE2SWcjs.x; exports.ComboboxSurface = He; exports.commandScore = _chunkFWWOE2SWcjs.v; exports.defaultFilter = _chunkFWWOE2SWcjs.w; exports.useComboboxContext = _chunkJSPKF52Ocjs.S; exports.useComboboxItemContext = se; exports.useComboboxPositionerContext = Se; exports.useMaybeComboboxContext = _chunkJSPKF52Ocjs.T; exports.useMaybeComboboxItemContext = ht; exports.useMaybeSurfaceContext = _chunkFWWOE2SWcjs.p; exports.useSurfaceContext = _chunkFWWOE2SWcjs.o;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/ui/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","rest","comboboxContext","useComboboxContext","disabled","hasValue","handleClick","event","handlePointerDown","state","element","useRender","ComboboxPositionerContext","ComboboxInputWrapperContext","useIsInsideInputWrapper","ComboboxInputDataAttributes","resolveLabelFromItems","items","value","label","i","useComboboxDisplayValue","params","open","getValueText","serializedValue","stringifyAsValue","registryText","itemsLabel","resolvedLabel","resolveLabel","selectedLabel","texts","v","text"],"mappings":"AAAA,4/BAAkE,yDAAgQ,yDAAkF,yDAA2C,ICA/bA,EAAAA,CAAA,CAAA,C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M,CACxC,EAAA,CAAI,CAAC1B,CAAAA,CACH,MAAO,EAAA,CAET,EAAA,CAAIH,CAAAA,CAAgB,QAAA,CAAU,CAE5B,IAAM8B,CAAAA,CAAQ9B,CAAAA,CAAgB,MAAA,CAC3B,GAAA,CAAK+B,CAAAA,EAAM,CACV,IAAMC,CAAAA,CAAOV,CAAAA,CAAaS,CAAC,CAAA,CAC3B,OAAIC,CAAAA,GAAS,KAAA,CAAA,CAAkBA,CAAAA,CAG7BJ,kCAAAA,CAAaG,CAAG/B,CAAAA,CAAgB,iBAAiB,CAAA,EACjDwB,kCAAAA,CAAiBO,CAAG/B,CAAAA,CAAgB,iBAAiB,CAEzD,CAAC,CAAA,CACA,MAAA,CAAO,OAAO,CAAA,CACjB,OAAI8B,CAAAA,CAAM,MAAA,EAAU,CAAA,CACXA,CAAAA,CAAM,IAAA,CAAK,IAAI,CAAA,CAEjB,CAAA,EAAA","file":"/home/runner/work/ui/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 ...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 },\n [],\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 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 const placeholder = placeholderProp ?? 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 {\n resolveLabel,\n stringifyAsValue,\n} from '../../utils/resolve-value-label.js'\nimport type { ComboboxContextValue } from '../contexts/combobox-context.js'\n\n/**\n * Helper to resolve label from items prop\n */\nfunction resolveLabelFromItems(\n items:\n | Record<string, React.ReactNode>\n | Array<{ value: string; label: React.ReactNode }>\n | undefined,\n value: string,\n): string | undefined {\n if (!items) return undefined\n\n if (Array.isArray(items)) {\n const item = items.find((i) => i.value === value)\n const label = item?.label\n return typeof label === 'string' ? label : undefined\n }\n\n const label = items[value]\n return typeof label === 'string' ? label : undefined\n}\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 : comboboxContext.value != null\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 const itemsLabel = resolveLabelFromItems(\n comboboxContext.items,\n serializedValue,\n )\n if (itemsLabel !== undefined) {\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 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"]}
|