@stokelp/ui 3.0.1 → 4.0.0

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.
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../utils/slots.cjs"),t=require("../tooltip/Tooltip.cjs"),n=require("../text/Text.cjs"),r=require("../../shared/ConditionalWrapper.cjs"),i=require("../ui-labels/UiLabelsProvider.cjs"),a=require("../input/Input.cjs"),o=require("../chip/Chip.cjs");let s=require("@ark-ui/react"),c=require("@stokelp/styled-system/jsx"),l=require("@stokelp/styled-system/recipes"),u=require("react"),d=require("react/jsx-runtime"),f=require("@stokelp/styled-system/css"),p=require("react-window"),m=require("@zag-js/utils");var{withProvider:h,withContext:g}=e.createStyleContext(l.combobox),_=h((0,c.styled)(s.Combobox.Root),`root`,{defaultProps:{loopFocus:!0}}),v=g((0,c.styled)(s.Combobox.ClearTrigger),`clearTrigger`),y=g((0,c.styled)(s.Combobox.Content),`content`),b=g((0,c.styled)(s.Combobox.Input),`input`),x=g((0,c.styled)(s.Combobox.Control),`control`),S=g((0,c.styled)(s.Combobox.Item),`item`),C=g((0,c.styled)(s.Combobox.ItemText),`itemText`),w=g((0,c.styled)(s.Combobox.Positioner),`positioner`),T=g((0,c.styled)(s.Combobox.Trigger),`trigger`),E=()=>(0,d.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,d.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,fill:`white`}),(0,d.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,className:(0,f.css)({stroke:`grey.100`})})]}),D=()=>(0,d.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,d.jsx)(`rect`,{y:`0.5`,width:`16`,height:`16`,rx:`4`,className:(0,f.css)({fill:`primary.500`})}),(0,d.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z`,fill:`white`})]});function O({item:e,isMultiple:t,renderItem:n}){let r=(0,s.useComboboxItemContext)();return(0,d.jsxs)(d.Fragment,{children:[t?r.selected?(0,d.jsx)(D,{}):(0,d.jsx)(E,{}):null,n?n(e):(0,d.jsx)(C,{truncate:!0,children:e.label})]})}var k=({items:e=[],initialItems:c,debounceMs:l=0,placeholder:f,emptyLabel:h,loadingLabel:g,usePortal:C=!0,withAutoFilter:E=!0,positioning:D,loadItems:k,renderItem:A,renderValue:j,onResetInitialItems:M,isLoading:N,value:P,defaultValue:F,openDropdownOnFocus:I=!0,clearValueWhenEmpty:ee=!0,virtualized:te,rowHeight:L=34,returnItemsOnEmpty:R,multiple:z=!1,...B})=>{let V=i.useUiLabels(),[H,U]=(0,u.useState)(()=>e),[W,G]=(0,u.useState)(!1),[K,q]=(0,u.useState)(!1),J=typeof k==`function`,Y=(0,u.useMemo)(()=>k?(0,m.debounce)(async e=>{try{q(!0),G(!0);let t=await k(e);U(t)}catch(e){console.error(e),U([])}finally{G(!1)}},l):null,[k,l]),X=[...!J&&!E?e:H,...c??[]],Z=(0,u.useCallback)(async t=>{c&&c.length>0&&!c.find(e=>e.label===t.inputValue)&&M?.();let{inputValue:n}=t;if(Y)Y(n);else{let t=E&&n!==``?e.filter(e=>e.label.toLowerCase().includes(n.toLowerCase())):e;if(t.length===0&&R)return U(e);U(t)}},[Y,e,E]);(0,u.useEffect)(()=>{Y||U(e)},[e,Y]);let ne=(0,u.useMemo)(()=>(0,s.createListCollection)({items:X}),[X]),re=N??W,Q=g??(0,d.jsx)(n.Text,{p:`space-8`,textAlign:`center`,children:V.loading}),$=h??(0,d.jsx)(n.Text,{p:`space-8`,textAlign:`center`,children:V.noResults});return(0,d.jsxs)(_,{lazyMount:!0,unmountOnExit:!0,collection:ne,positioning:{sameWidth:!0,gutter:0,...D},"data-recipe":`combobox`,onInputValueChange:Z,value:P,defaultValue:F,...B,multiple:z,children:[z?(0,d.jsx)(s.Combobox.Context,{children:t=>(0,d.jsxs)(x,{"data-multiple":`true`,"data-open":t.open||void 0,children:[t.value.map(n=>{let r=e.find(e=>String(e.value)===String(n));return r?(0,d.jsxs)(o.Chip,{size:`sm`,children:[j?j(r):(0,d.jsx)(o.ChipLabel,{children:r.label}),!B.readOnly&&!B.disabled&&(0,d.jsx)(o.ChipClearTrigger,{"aria-label":`Retirer ${r.label}`,onClick:()=>t.setValue(t.value.filter(e=>String(e)!==String(n)))})]},n):null}),(0,d.jsx)(b,{asChild:!0,"data-multiple":`true`,placeholder:t.hasSelectedItems?void 0:f,onFocus:()=>{I&&!J&&t.setOpen(!0)},children:(0,d.jsx)(a.Input,{})}),(0,d.jsx)(T,{asChild:!0,hidden:J&&(!c||c.length===0),children:(0,d.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,d.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z`,fill:`currentColor`})})})]})}):(0,d.jsxs)(x,{children:[(0,d.jsx)(s.Combobox.Context,{children:e=>(0,d.jsx)(b,{asChild:!0,placeholder:f,onInput:t=>{let n=t.currentTarget.value;ee&&n===``&&e.clearValue()},onFocus:()=>{I&&!J&&e.setOpen(!0)},children:(0,d.jsx)(a.Input,{})})}),(0,d.jsx)(T,{asChild:!0,hidden:J&&(!c||c.length===0),children:(0,d.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,d.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z`,fill:`currentColor`})})}),(0,d.jsx)(v,{disabled:B.readOnly,onClick:M,asChild:!0,children:(0,d.jsx)(`button`,{children:(0,d.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,d.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z`,fill:`currentColor`})})})})]}),(0,d.jsx)(r.ConditionalWrapper,{when:C,wrapper:e=>(0,d.jsx)(s.Portal,{children:e}),children:(0,d.jsx)(w,{children:(0,d.jsx)(y,{children:re?Q:X.length===0?(0,d.jsx)(d.Fragment,{children:J?K?$:Q:$}):te?(0,d.jsx)(d.Fragment,{children:(0,d.jsx)(p.FixedSizeList,{height:Math.min(L*X.length,180),itemCount:X.length,itemSize:L,width:`100%`,children:({index:e,style:n})=>(0,d.jsx)(r.ConditionalWrapper,{when:!!X[e].tooltip,wrapper:n=>(0,d.jsx)(t.Tooltip,{label:X[e].tooltip,children:n}),children:(0,d.jsx)(S,{item:X[e],style:n,children:(0,d.jsx)(O,{renderItem:A,item:X[e],isMultiple:z})},X[e].value)},X[e].value)})}):X.map(e=>(0,d.jsx)(r.ConditionalWrapper,{when:!!e.tooltip,wrapper:n=>(0,d.jsx)(t.Tooltip,{label:e.tooltip,children:n}),children:(0,d.jsx)(S,{item:e,children:(0,d.jsx)(O,{renderItem:A,item:e,isMultiple:z})},e.value)},e.value))})})})]})};exports.Combobox=k;
1
+ "use client";const e=require("../../utils/slots.cjs"),t=require("../tooltip/Tooltip.cjs"),n=require("../text/Text.cjs"),r=require("../../shared/ConditionalWrapper.cjs"),i=require("../ui-labels/UiLabelsProvider.cjs"),a=require("../input/Input.cjs"),o=require("../chip/Chip.cjs");let s=require("@ark-ui/react"),c=require("@stokelp/styled-system/jsx"),l=require("@stokelp/styled-system/recipes"),u=require("react"),d=require("react/jsx-runtime"),f=require("@stokelp/styled-system/css"),p=require("react-window"),m=require("@zag-js/utils");var{withProvider:h,withContext:g}=e.createStyleContext(l.combobox),_=h((0,c.styled)(s.Combobox.Root),`root`,{defaultProps:{loopFocus:!0}}),v=g((0,c.styled)(s.Combobox.ClearTrigger),`clearTrigger`),y=g((0,c.styled)(s.Combobox.Content),`content`),b=g((0,c.styled)(s.Combobox.Input),`input`),x=g((0,c.styled)(s.Combobox.Control),`control`),S=g((0,c.styled)(s.Combobox.Item),`item`),C=g((0,c.styled)(s.Combobox.ItemText),`itemText`),w=g((0,c.styled)(s.Combobox.Positioner),`positioner`),T=g((0,c.styled)(s.Combobox.Trigger),`trigger`),E=()=>(0,d.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,d.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,fill:`white`}),(0,d.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,className:(0,f.css)({stroke:`grey.100`})})]}),D=()=>(0,d.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,d.jsx)(`rect`,{y:`0.5`,width:`16`,height:`16`,rx:`4`,className:(0,f.css)({fill:`primary.500`})}),(0,d.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z`,fill:`white`})]});function O({item:e,isMultiple:t,renderItem:n}){let r=(0,s.useComboboxItemContext)();return(0,d.jsxs)(d.Fragment,{children:[t?r.selected?(0,d.jsx)(D,{}):(0,d.jsx)(E,{}):null,n?n(e):(0,d.jsx)(C,{truncate:!0,children:e.label})]})}function k({index:e,style:n,ariaAttributes:i,items:a,isMultiple:o,renderItem:s}){let c=a[e];return(0,d.jsx)(r.ConditionalWrapper,{when:!!c.tooltip,wrapper:e=>(0,d.jsx)(t.Tooltip,{label:c.tooltip,children:e}),children:(0,d.jsx)(S,{item:c,style:n,"aria-posinset":i[`aria-posinset`],"aria-setsize":i[`aria-setsize`],children:(0,d.jsx)(O,{renderItem:s,item:c,isMultiple:o})})})}var A=({items:e=[],initialItems:c,debounceMs:l=0,placeholder:f,emptyLabel:h,loadingLabel:g,usePortal:C=!0,withAutoFilter:E=!0,positioning:D,loadItems:A,renderItem:j,renderValue:M,onResetInitialItems:N,isLoading:P,value:F,defaultValue:I,openDropdownOnFocus:L=!0,clearValueWhenEmpty:ee=!0,virtualized:te,rowHeight:R=34,returnItemsOnEmpty:z,multiple:B=!1,...V})=>{let H=i.useUiLabels(),[U,W]=(0,u.useState)(()=>e),[G,K]=(0,u.useState)(!1),[q,J]=(0,u.useState)(!1),Y=typeof A==`function`,X=(0,u.useMemo)(()=>A?(0,m.debounce)(async e=>{try{J(!0),K(!0);let t=await A(e);W(t)}catch(e){console.error(e),W([])}finally{K(!1)}},l):null,[A,l]),Z=[...!Y&&!E?e:U,...c??[]],ne=(0,u.useCallback)(async t=>{c&&c.length>0&&!c.find(e=>e.label===t.inputValue)&&N?.();let{inputValue:n}=t;if(X)X(n);else{let t=E&&n!==``?e.filter(e=>e.label.toLowerCase().includes(n.toLowerCase())):e;if(t.length===0&&z)return W(e);W(t)}},[X,e,E]);(0,u.useEffect)(()=>{X||W(e)},[e,X]);let re=(0,u.useMemo)(()=>(0,s.createListCollection)({items:Z}),[Z]),ie=P??G,Q=g??(0,d.jsx)(n.Text,{p:`space-8`,textAlign:`center`,children:H.loading}),$=h??(0,d.jsx)(n.Text,{p:`space-8`,textAlign:`center`,children:H.noResults});return(0,d.jsxs)(_,{lazyMount:!0,unmountOnExit:!0,collection:re,positioning:{sameWidth:!0,gutter:0,...D},"data-recipe":`combobox`,onInputValueChange:ne,value:F,defaultValue:I,...V,multiple:B,children:[B?(0,d.jsx)(s.Combobox.Context,{children:t=>(0,d.jsxs)(x,{"data-multiple":`true`,"data-open":t.open||void 0,children:[t.value.map(n=>{let r=e.find(e=>String(e.value)===String(n));return r?(0,d.jsxs)(o.Chip,{size:`sm`,children:[M?M(r):(0,d.jsx)(o.ChipLabel,{children:r.label}),!V.readOnly&&!V.disabled&&(0,d.jsx)(o.ChipClearTrigger,{"aria-label":`Retirer ${r.label}`,onClick:()=>t.setValue(t.value.filter(e=>String(e)!==String(n)))})]},n):null}),(0,d.jsx)(b,{asChild:!0,"data-multiple":`true`,placeholder:t.hasSelectedItems?void 0:f,onFocus:()=>{L&&!Y&&t.setOpen(!0)},children:(0,d.jsx)(a.Input,{})}),(0,d.jsx)(T,{asChild:!0,hidden:Y&&(!c||c.length===0),children:(0,d.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,d.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z`,fill:`currentColor`})})})]})}):(0,d.jsxs)(x,{children:[(0,d.jsx)(s.Combobox.Context,{children:e=>(0,d.jsx)(b,{asChild:!0,placeholder:f,onInput:t=>{let n=t.currentTarget.value;ee&&n===``&&e.clearValue()},onFocus:()=>{L&&!Y&&e.setOpen(!0)},children:(0,d.jsx)(a.Input,{})})}),(0,d.jsx)(T,{asChild:!0,hidden:Y&&(!c||c.length===0),children:(0,d.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,d.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z`,fill:`currentColor`})})}),(0,d.jsx)(v,{disabled:V.readOnly,onClick:N,asChild:!0,children:(0,d.jsx)(`button`,{children:(0,d.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,d.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z`,fill:`currentColor`})})})})]}),(0,d.jsx)(r.ConditionalWrapper,{when:C,wrapper:e=>(0,d.jsx)(s.Portal,{children:e}),children:(0,d.jsx)(w,{children:(0,d.jsx)(y,{children:ie?Q:Z.length===0?(0,d.jsx)(d.Fragment,{children:Y?q?$:Q:$}):te?(0,d.jsx)(p.List,{role:`presentation`,rowComponent:k,rowProps:{items:Z,isMultiple:B,renderItem:j},rowCount:Z.length,rowHeight:R,style:{height:Math.min(R*Z.length,180)}}):Z.map(e=>(0,d.jsx)(r.ConditionalWrapper,{when:!!e.tooltip,wrapper:n=>(0,d.jsx)(t.Tooltip,{label:e.tooltip,children:n}),children:(0,d.jsx)(S,{item:e,children:(0,d.jsx)(O,{renderItem:j,item:e,isMultiple:B})},e.value)},e.value))})})})]})};exports.Combobox=A;
2
2
  //# sourceMappingURL=Combobox.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.cjs","names":["createStyleContext","combobox","styled","ArkCombobox","css","useComboboxItemContext","_Fragment","useUiLabels","useState","useMemo","debounce","useCallback","createListCollection","Text","Chip","ChipLabel","ChipClearTrigger","UIInput","ConditionalWrapper","Portal","FixedSizeList","Tooltip","require_slots","require_Tooltip","require_Text","require_ConditionalWrapper","require_UiLabelsProvider","require_Input","require_Chip","_ark_ui_react","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","_stokelp_styled_system_css","react_window","_zag_js_utils","Root","withProvider","ClearTrigger","withContext","Content","Input","Control","Item","ItemText","Positioner","Trigger","MultipleUncheckedIndicator","MultipleCheckedIndicator","CustomInnerItem","context","isMultiple","renderItem","item","Combobox","itemsFromUsers","controlledIsLoading","props","uiLabels","items","setItems","isLoading","setIsLoading","firstQueryTriggered","setFirstQueryTriggered","asyncMode","loadItems","debouncedLoadItems","newItems","value","error","debounceMs","allItems","withAutoFilter","initialItems","handleInputChange","details","onResetInitialItems","inputValue","returnItemsOnEmpty","collection","effectiveIsLoading","loadingContent","loadingLabel","emptyContent","emptyLabel","positioning","multiple","api","i","v","renderValue","x","placeholder","openDropdownOnFocus","e","clearValueWhenEmpty","usePortal","virtualized","rowHeight","index"],"sources":["../../../src/components/combobox/Combobox.tsx"],"sourcesContent":["import {\n Combobox as ArkCombobox,\n type ComboboxRootProps,\n createListCollection,\n Portal,\n useComboboxItemContext,\n} from '@ark-ui/react'\nimport { FC, ReactNode, useCallback, useEffect, useMemo, useState } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { debounce } from '@zag-js/utils'\n\nimport { combobox } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { Input as UIInput } from '~/components/input'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport { Chip, ChipClearTrigger, ChipLabel } from '~/components/chip'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { FixedSizeList } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(combobox)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkCombobox.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkCombobox.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkCombobox.Content), 'content')\nconst Input = withContext(styled(ArkCombobox.Input), 'input')\nconst Control = withContext(styled(ArkCombobox.Control), 'control')\nconst Item = withContext(styled(ArkCombobox.Item), 'item')\nconst ItemText = withContext(styled(ArkCombobox.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkCombobox.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkCombobox.Trigger), 'trigger')\n\nexport type ComboboxItem = {\n value: string | number\n label: string\n disabled?: boolean\n tooltip?: ReactNode\n}\n\nexport type ComboboxProps<T extends ComboboxItem> = Omit<\n ComboboxRootProps<T>,\n 'collection' | 'value' | 'defaultValue'\n> & {\n // Item values may be numbers: the chips compare them as strings.\n value?: Array<string | number>\n defaultValue?: Array<string | number>\n items?: T[]\n initialItems?: T[]\n renderItem?: (item: T) => ReactNode\n /**\n * Renders the inner content of each selected chip in `multiple` mode.\n * Receives the selected item and should return the chip body (the removable\n * clear button is appended automatically). Defaults to the item label.\n */\n renderValue?: (item: T) => ReactNode\n loadItems?: (inputValue: string) => Promise<T[]>\n debounceMs?: number\n emptyLabel?: ReactNode\n loadingLabel?: ReactNode\n placeholder?: string\n usePortal?: boolean\n isLoading?: boolean\n withAutoFilter?: boolean\n onResetInitialItems?: () => void\n openDropdownOnFocus?: boolean\n clearValueWhenEmpty?: boolean\n virtualized?: boolean\n rowHeight?: number\n returnItemsOnEmpty?: boolean\n} & Omit<HTMLStyledProps<'div'>, 'defaultValue'> &\n RecipeVariantProps<typeof combobox>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends ComboboxItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\nfunction CustomInnerItem<Item extends ComboboxItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useComboboxItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\nexport const Combobox = <T extends ComboboxItem>({\n items: itemsFromUsers = [],\n initialItems,\n debounceMs = 0,\n placeholder,\n emptyLabel,\n loadingLabel,\n usePortal = true,\n withAutoFilter = true,\n positioning,\n loadItems,\n renderItem,\n renderValue,\n onResetInitialItems,\n isLoading: controlledIsLoading,\n value,\n defaultValue,\n openDropdownOnFocus = true,\n clearValueWhenEmpty = true,\n virtualized,\n rowHeight = 34,\n returnItemsOnEmpty,\n multiple = false,\n ...props\n}: ComboboxProps<T>) => {\n const uiLabels = useUiLabels()\n const [items, setItems] = useState(() => itemsFromUsers)\n const [isLoading, setIsLoading] = useState(false)\n const [firstQueryTriggered, setFirstQueryTriggered] = useState(false)\n const asyncMode = typeof loadItems === 'function'\n\n const debouncedLoadItems = useMemo(\n () =>\n loadItems\n ? debounce(async (value: string) => {\n try {\n setFirstQueryTriggered(true)\n setIsLoading(true)\n const newItems = await loadItems(value)\n setItems(newItems)\n } catch (error) {\n console.error(error)\n setItems([])\n } finally {\n setIsLoading(false)\n }\n }, debounceMs)\n : null,\n [loadItems, debounceMs],\n )\n\n // A sync, unfiltered list has nothing to derive: read the prop itself. The mirrored\n // `items` state only catches up in an effect, one render late, and zag re-derives the\n // input text from the collection the moment `value` changes: a value set in the same\n // render as the item that carries it was stringified against a list without it, and\n // the input went blank.\n const sourceItems = !asyncMode && !withAutoFilter ? itemsFromUsers : items\n const allItems = [...sourceItems, ...(initialItems ?? [])]\n\n const handleInputChange = useCallback(\n async (details: ArkCombobox.InputValueChangeDetails) => {\n if (\n initialItems &&\n initialItems.length > 0 &&\n !initialItems.find((item: ComboboxItem) => item.label === details.inputValue)\n ) {\n onResetInitialItems?.()\n }\n const { inputValue } = details\n\n if (debouncedLoadItems) {\n debouncedLoadItems(inputValue)\n } else {\n const items =\n withAutoFilter && inputValue !== ''\n ? itemsFromUsers.filter((item: ComboboxItem) => item.label.toLowerCase().includes(inputValue.toLowerCase()))\n : itemsFromUsers\n\n if (items.length === 0 && returnItemsOnEmpty) {\n return setItems(itemsFromUsers)\n }\n setItems(items)\n }\n },\n [debouncedLoadItems, itemsFromUsers, withAutoFilter],\n )\n\n // Keep the visible items in sync with the source list whenever it changes\n // (e.g. options that load asynchronously after mount). Without this, an empty\n // input shows a stale/empty list (the no-results label) until the user types.\n // Consumers memoize `items`, so this only fires on real data changes, not on\n // every keystroke.\n useEffect(() => {\n if (!debouncedLoadItems) {\n setItems(itemsFromUsers)\n }\n }, [itemsFromUsers, debouncedLoadItems])\n\n const collection = useMemo(() => createListCollection({ items: allItems }), [allItems])\n\n const effectiveIsLoading = controlledIsLoading ?? isLoading\n\n const loadingContent = loadingLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n {uiLabels.loading}\n </Text>\n )\n const emptyContent = emptyLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n {uiLabels.noResults}\n </Text>\n )\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"combobox\"\n onInputValueChange={handleInputChange}\n value={value as string[] | undefined}\n defaultValue={defaultValue as string[] | undefined}\n {...props}\n multiple={multiple}\n >\n {multiple ? (\n // Tags-input layout: the control (styled via the recipe's `&[data-multiple]`\n // selectors) is the bordered box holding the selected chips and a\n // borderless growing input.\n <ArkCombobox.Context>\n {api => (\n <Control data-multiple=\"true\" data-open={api.open || undefined}>\n {/* Resolve chips from the current value against the full source\n list rather than ark's cached `selectedItems`: the cache is only\n re-derived on value changes, so async-loaded defaults would show\n 0 chips until the user selects something. Looking up in\n itemsFromUsers (never the filtered list) also keeps chips visible\n while the user is typing to filter. */}\n {api.value.map(v => {\n const item = itemsFromUsers.find((i: T) => String(i.value) === String(v))\n if (!item) return null\n return (\n <Chip key={v} size=\"sm\">\n {renderValue ? renderValue(item) : <ChipLabel>{item.label}</ChipLabel>}\n {!props.readOnly && !props.disabled && (\n <ChipClearTrigger\n aria-label={`Retirer ${item.label}`}\n // Remove by strict-equality-safe filter: stored values may\n // be numbers while item.value is compared as a string.\n onClick={() => api.setValue(api.value.filter(x => String(x) !== String(v)))}\n />\n )}\n </Chip>\n )\n })}\n <Input\n asChild\n data-multiple=\"true\"\n placeholder={api.hasSelectedItems ? undefined : placeholder}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n </Control>\n )}\n </ArkCombobox.Context>\n ) : (\n <Control>\n <ArkCombobox.Context>\n {api => (\n <Input\n asChild\n placeholder={placeholder}\n onInput={(e: React.FormEvent<HTMLInputElement>) => {\n const value = e.currentTarget.value\n\n if (clearValueWhenEmpty && value === '') {\n api.clearValue()\n }\n }}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n )}\n </ArkCombobox.Context>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} onClick={onResetInitialItems} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n )}\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal>{children}</Portal>}>\n <Positioner>\n <Content>\n {effectiveIsLoading ? (\n loadingContent\n ) : allItems.length === 0 ? (\n <>{asyncMode ? (firstQueryTriggered ? emptyContent : loadingContent) : emptyContent}</>\n ) : virtualized ? (\n <>\n <FixedSizeList\n height={Math.min(rowHeight * allItems.length, 180)}\n itemCount={allItems.length}\n itemSize={rowHeight}\n width=\"100%\"\n >\n {({ index, style }) => (\n <ConditionalWrapper\n key={allItems[index].value}\n when={!!allItems[index].tooltip}\n wrapper={children => <Tooltip label={allItems[index].tooltip}>{children}</Tooltip>}\n >\n <Item key={allItems[index].value} item={allItems[index]} style={style}>\n <CustomInnerItem renderItem={renderItem} item={allItems[index]} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n )}\n </FixedSizeList>\n </>\n ) : (\n allItems.map(item => (\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={item}>\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n ))\n )}\n </Content>\n </Positioner>\n </ConditionalWrapper>\n </Root>\n )\n}\n"],"mappings":"A,whBAwBA,GAAM,CAAE,eAAc,eAAgBA,EAAAA,mBAAmBC,EAAAA,QAAQ,EAG3DoC,EAAOC,GAAA,EAAapC,EAAAA,OAAAA,CAAOC,EAAAA,SAAY,IAAS,EAAG,OAAQ,CAC/D,aAAc,CACZ,UAAW,EACb,CACF,CAAC,EAEKoC,EAAeC,GAAA,EAAYtC,EAAAA,OAA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B,aAAY,KAAMuB,EAAS4B,GAAQ,WAAYb,CAAW,CAAA,CACnF,EAFKf,EAAS4B,EAAM,CAAC,KAErB,CACY,EAPb5B,EAAS4B,EAAM,CAAC,KAOH,CAET,CAAA,CACf,CAAA,EAEF5B,EAAS,IAAI,IACX,EAAAxC,EAAA,IAAA,CAACf,EAAAA,mBAAD,CAEE,KAAM,CAAC,CAACoC,EAAK,QACb,QAAS,IAAY,EAAArB,EAAA,IAAA,CAACZ,EAAAA,QAAD,CAAS,MAAOiC,EAAK,QAAU,UAAkB,CAAA,EAEtE,UAAA,EAAArB,EAAA,IAAA,CAACW,EAAD,CAA6B,OAC3B,UAAA,EAAAX,EAAA,IAAA,CAACiB,EAAD,CAA6B,aAAkB,OAAM,WAAYsC,CAAW,CAAA,CACxE,EAFKlC,EAAK,KAEV,CACY,EAPbA,EAAK,KAOQ,CACrB,CAEI,CAAA,CACC,CAAA,CACM,CAAA,CAChB,C,EAEV,E"}
1
+ {"version":3,"file":"Combobox.cjs","names":["createStyleContext","combobox","styled","ArkCombobox","css","useComboboxItemContext","_Fragment","ConditionalWrapper","Tooltip","useUiLabels","useState","useMemo","debounce","useCallback","createListCollection","Text","Chip","ChipLabel","ChipClearTrigger","UIInput","Portal","List","require_slots","require_Tooltip","require_Text","require_ConditionalWrapper","require_UiLabelsProvider","require_Input","require_Chip","_ark_ui_react","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","_stokelp_styled_system_css","react_window","_zag_js_utils","Root","withProvider","ClearTrigger","withContext","Content","Input","Control","Item","ItemText","Positioner","Trigger","MultipleUncheckedIndicator","MultipleCheckedIndicator","CustomInnerItem","context","isMultiple","renderItem","item","VirtualRow","items","index","ariaAttributes","Combobox","itemsFromUsers","controlledIsLoading","props","uiLabels","setItems","isLoading","setIsLoading","firstQueryTriggered","setFirstQueryTriggered","asyncMode","loadItems","debouncedLoadItems","newItems","value","error","debounceMs","allItems","withAutoFilter","initialItems","handleInputChange","details","onResetInitialItems","inputValue","returnItemsOnEmpty","collection","effectiveIsLoading","loadingContent","loadingLabel","emptyContent","emptyLabel","positioning","multiple","api","i","v","renderValue","x","placeholder","openDropdownOnFocus","e","clearValueWhenEmpty","usePortal","virtualized","rowHeight"],"sources":["../../../src/components/combobox/Combobox.tsx"],"sourcesContent":["import {\n Combobox as ArkCombobox,\n type ComboboxRootProps,\n createListCollection,\n Portal,\n useComboboxItemContext,\n} from '@ark-ui/react'\nimport { FC, ReactNode, useCallback, useEffect, useMemo, useState } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { debounce } from '@zag-js/utils'\n\nimport { combobox } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { Input as UIInput } from '~/components/input'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport { Chip, ChipClearTrigger, ChipLabel } from '~/components/chip'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { List, type RowComponentProps } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(combobox)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkCombobox.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkCombobox.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkCombobox.Content), 'content')\nconst Input = withContext(styled(ArkCombobox.Input), 'input')\nconst Control = withContext(styled(ArkCombobox.Control), 'control')\nconst Item = withContext(styled(ArkCombobox.Item), 'item')\nconst ItemText = withContext(styled(ArkCombobox.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkCombobox.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkCombobox.Trigger), 'trigger')\n\nexport type ComboboxItem = {\n value: string | number\n label: string\n disabled?: boolean\n tooltip?: ReactNode\n}\n\nexport type ComboboxProps<T extends ComboboxItem> = Omit<\n ComboboxRootProps<T>,\n 'collection' | 'value' | 'defaultValue'\n> & {\n // Item values may be numbers: the chips compare them as strings.\n value?: Array<string | number>\n defaultValue?: Array<string | number>\n items?: T[]\n initialItems?: T[]\n renderItem?: (item: T) => ReactNode\n /**\n * Renders the inner content of each selected chip in `multiple` mode.\n * Receives the selected item and should return the chip body (the removable\n * clear button is appended automatically). Defaults to the item label.\n */\n renderValue?: (item: T) => ReactNode\n loadItems?: (inputValue: string) => Promise<T[]>\n debounceMs?: number\n emptyLabel?: ReactNode\n loadingLabel?: ReactNode\n placeholder?: string\n usePortal?: boolean\n isLoading?: boolean\n withAutoFilter?: boolean\n onResetInitialItems?: () => void\n openDropdownOnFocus?: boolean\n clearValueWhenEmpty?: boolean\n virtualized?: boolean\n rowHeight?: number\n returnItemsOnEmpty?: boolean\n} & Omit<HTMLStyledProps<'div'>, 'defaultValue'> &\n RecipeVariantProps<typeof combobox>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends ComboboxItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\nfunction CustomInnerItem<Item extends ComboboxItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useComboboxItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\ninterface VirtualRowProps<Item extends ComboboxItem> {\n items: Item[]\n isMultiple: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\n// Declared at module level: react-window memoizes the row component by identity, so a\n// component created during render would remount every visible row on each render.\nfunction VirtualRow<Item extends ComboboxItem>({\n index,\n style,\n ariaAttributes,\n items,\n isMultiple,\n renderItem,\n}: RowComponentProps<VirtualRowProps<Item>>) {\n const item = items[index]\n\n return (\n <ConditionalWrapper when={!!item.tooltip} wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}>\n {/* Only the position attributes: the option keeps its role from Ark, not react-window's listitem. */}\n <Item\n item={item}\n style={style}\n aria-posinset={ariaAttributes['aria-posinset']}\n aria-setsize={ariaAttributes['aria-setsize']}\n >\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={isMultiple} />\n </Item>\n </ConditionalWrapper>\n )\n}\n\nexport const Combobox = <T extends ComboboxItem>({\n items: itemsFromUsers = [],\n initialItems,\n debounceMs = 0,\n placeholder,\n emptyLabel,\n loadingLabel,\n usePortal = true,\n withAutoFilter = true,\n positioning,\n loadItems,\n renderItem,\n renderValue,\n onResetInitialItems,\n isLoading: controlledIsLoading,\n value,\n defaultValue,\n openDropdownOnFocus = true,\n clearValueWhenEmpty = true,\n virtualized,\n rowHeight = 34,\n returnItemsOnEmpty,\n multiple = false,\n ...props\n}: ComboboxProps<T>) => {\n const uiLabels = useUiLabels()\n const [items, setItems] = useState(() => itemsFromUsers)\n const [isLoading, setIsLoading] = useState(false)\n const [firstQueryTriggered, setFirstQueryTriggered] = useState(false)\n const asyncMode = typeof loadItems === 'function'\n\n const debouncedLoadItems = useMemo(\n () =>\n loadItems\n ? debounce(async (value: string) => {\n try {\n setFirstQueryTriggered(true)\n setIsLoading(true)\n const newItems = await loadItems(value)\n setItems(newItems)\n } catch (error) {\n console.error(error)\n setItems([])\n } finally {\n setIsLoading(false)\n }\n }, debounceMs)\n : null,\n [loadItems, debounceMs],\n )\n\n // A sync, unfiltered list has nothing to derive: read the prop itself. The mirrored\n // `items` state only catches up in an effect, one render late, and zag re-derives the\n // input text from the collection the moment `value` changes: a value set in the same\n // render as the item that carries it was stringified against a list without it, and\n // the input went blank.\n const sourceItems = !asyncMode && !withAutoFilter ? itemsFromUsers : items\n const allItems = [...sourceItems, ...(initialItems ?? [])]\n\n const handleInputChange = useCallback(\n async (details: ArkCombobox.InputValueChangeDetails) => {\n if (\n initialItems &&\n initialItems.length > 0 &&\n !initialItems.find((item: ComboboxItem) => item.label === details.inputValue)\n ) {\n onResetInitialItems?.()\n }\n const { inputValue } = details\n\n if (debouncedLoadItems) {\n debouncedLoadItems(inputValue)\n } else {\n const items =\n withAutoFilter && inputValue !== ''\n ? itemsFromUsers.filter((item: ComboboxItem) => item.label.toLowerCase().includes(inputValue.toLowerCase()))\n : itemsFromUsers\n\n if (items.length === 0 && returnItemsOnEmpty) {\n return setItems(itemsFromUsers)\n }\n setItems(items)\n }\n },\n [debouncedLoadItems, itemsFromUsers, withAutoFilter],\n )\n\n // Keep the visible items in sync with the source list whenever it changes\n // (e.g. options that load asynchronously after mount). Without this, an empty\n // input shows a stale/empty list (the no-results label) until the user types.\n // Consumers memoize `items`, so this only fires on real data changes, not on\n // every keystroke.\n useEffect(() => {\n if (!debouncedLoadItems) {\n setItems(itemsFromUsers)\n }\n }, [itemsFromUsers, debouncedLoadItems])\n\n const collection = useMemo(() => createListCollection({ items: allItems }), [allItems])\n\n const effectiveIsLoading = controlledIsLoading ?? isLoading\n\n const loadingContent = loadingLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n {uiLabels.loading}\n </Text>\n )\n const emptyContent = emptyLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n {uiLabels.noResults}\n </Text>\n )\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"combobox\"\n onInputValueChange={handleInputChange}\n value={value as string[] | undefined}\n defaultValue={defaultValue as string[] | undefined}\n {...props}\n multiple={multiple}\n >\n {multiple ? (\n // Tags-input layout: the control (styled via the recipe's `&[data-multiple]`\n // selectors) is the bordered box holding the selected chips and a\n // borderless growing input.\n <ArkCombobox.Context>\n {api => (\n <Control data-multiple=\"true\" data-open={api.open || undefined}>\n {/* Resolve chips from the current value against the full source\n list rather than ark's cached `selectedItems`: the cache is only\n re-derived on value changes, so async-loaded defaults would show\n 0 chips until the user selects something. Looking up in\n itemsFromUsers (never the filtered list) also keeps chips visible\n while the user is typing to filter. */}\n {api.value.map(v => {\n const item = itemsFromUsers.find((i: T) => String(i.value) === String(v))\n if (!item) return null\n return (\n <Chip key={v} size=\"sm\">\n {renderValue ? renderValue(item) : <ChipLabel>{item.label}</ChipLabel>}\n {!props.readOnly && !props.disabled && (\n <ChipClearTrigger\n aria-label={`Retirer ${item.label}`}\n // Remove by strict-equality-safe filter: stored values may\n // be numbers while item.value is compared as a string.\n onClick={() => api.setValue(api.value.filter(x => String(x) !== String(v)))}\n />\n )}\n </Chip>\n )\n })}\n <Input\n asChild\n data-multiple=\"true\"\n placeholder={api.hasSelectedItems ? undefined : placeholder}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n </Control>\n )}\n </ArkCombobox.Context>\n ) : (\n <Control>\n <ArkCombobox.Context>\n {api => (\n <Input\n asChild\n placeholder={placeholder}\n onInput={(e: React.FormEvent<HTMLInputElement>) => {\n const value = e.currentTarget.value\n\n if (clearValueWhenEmpty && value === '') {\n api.clearValue()\n }\n }}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n )}\n </ArkCombobox.Context>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} onClick={onResetInitialItems} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n )}\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal>{children}</Portal>}>\n <Positioner>\n <Content>\n {effectiveIsLoading ? (\n loadingContent\n ) : allItems.length === 0 ? (\n <>{asyncMode ? (firstQueryTriggered ? emptyContent : loadingContent) : emptyContent}</>\n ) : virtualized ? (\n // role=\"presentation\" overrides the list's own role=\"list\": the options must stay\n // owned by the listbox.\n <List\n role=\"presentation\"\n rowComponent={VirtualRow<T>}\n rowProps={{ items: allItems, isMultiple: multiple, renderItem }}\n rowCount={allItems.length}\n rowHeight={rowHeight}\n style={{ height: Math.min(rowHeight * allItems.length, 180) }}\n />\n ) : (\n allItems.map(item => (\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={item}>\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n ))\n )}\n </Content>\n </Positioner>\n </ConditionalWrapper>\n </Root>\n )\n}\n"],"mappings":"A,whBAwBA,GAAM,CAAE,eAAc,eAAgBA,EAAAA,mBAAmBC,EAAAA,QAAQ,EAG3DoC,EAAOC,GAAA,EAAapC,EAAAA,OAAAA,CAAOC,EAAAA,SAAY,IAAS,EAAG,OAAQ,CAC/D,aAAc,CACZ,UAAW,EACb,CACF,CAAC,EAEKoC,EAAeC,GAAA,EAAYtC,EAAAA,OAAAA,CAAOC,EAAAA,SAAY,YAAY,EAAG,cAAc,EAC3EsC,EAAUD,GAAA,EAAYtC,EAAAA,OAAAA,CAAOC,EAAAA,SAAY,OAAO,EAAG,SAAS,EAC5DuC,EAAQF,GAAA,EAAYtC,EAAAA,OAAAA,CAAOC,EAAAA,SAAY,KAAK,EAAG,OAAO,EACtDwC,EAAUH,GAAA,EAAYtC,EAAAA,OAAAA,CAAOC,EAAAA,SAAY,OAAO,EAAG,SAAS,EAC5DyC,EAAOJ,GAAA,EAAYtC,EAAAA,OAAAA,CAAOC,EAAAA,SAAY,IAAI,EAAG,MAAM,EACnD0C,EAAWL,GAAA,EAAYtC,EAAAA,OAAAA,CAAOC,EAAAA,SAAY,QAAQ,EAAG,UAAU,EAC/D2C,EAAaN,GAAA,EAAYtC,EAAAA,OAAAA,CAAOC,EAAAA,SAAY,UAAU,EAAG,YAAY,EACrE4C,EAAUP,GAAA,EAAYtC,EAAAA,OAAAA,CAAOC,EAAAA,SAAY,OAAO,EAAG,SAAS,EA0C5D6C,OACJ,EAAAf,EAAA,KAAA,CAAC,MAAD,CAAK,MAAM,KAAK,OAAO,KAAK,QAA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EAAE,4zBACF,KAAK,cACN,CAAA,CACE,CAAA,CACC,CAAA,CACI,CAAA,CACP,CAAA,CAAA,GAEX,EAAAA,EAAA,IAAA,CAAC1B,EAAAA,mBAAD,CAAoB,KAAM8F,EAAW,QAAS,IAAY,EAAApE,EAAA,IAAA,CAACb,EAAAA,OAAD,CAAS,UAAiB,CAAA,EAClF,UAAA,EAAAa,EAAA,IAAA,CAACa,EAAD,CAAA,UACE,EAAAb,EAAA,IAAA,CAACQ,EAAD,CAAA,SACG4C,GACCC,EACEV,EAAS,SAAW,GACtB,EAAA3C,EAAA,IAAA,CAAA3B,EAAAA,SAAA,CAAA,SAAG+D,EAAaF,EAAsBqB,EAAeF,EAAkBE,CAAe,CAAA,EACpFc,IAGF,EAAArE,EAAA,IAAA,CAACZ,EAAAA,KAAD,CACE,KAAK,eACL,aAAckC,EACd,SAAU,CAAE,MAAOqB,EAAU,WAAYe,EAAU,YAAW,EAC9D,SAAUf,EAAS,OACR,YACX,MAAO,CAAE,OAAQ,KAAK,IAAI2B,EAAY3B,EAAS,OAAQ,GAAG,CAAE,CAC7D,CAAA,EAEDA,EAAS,IAAI,IACX,EAAA3C,EAAA,IAAA,CAAC1B,EAAAA,mBAAD,CAEE,KAAM,CAAC,CAAC+C,EAAK,QACb,QAAS,IAAY,EAAArB,EAAA,IAAA,CAACzB,EAAAA,QAAD,CAAS,MAAO8C,EAAK,QAAU,UAAkB,CAAA,EAEtE,UAAA,EAAArB,EAAA,IAAA,CAACW,EAAD,CAA6B,OAC3B,UAAA,EAAAX,EAAA,IAAA,CAACiB,EAAD,CAA6B,aAAkB,OAAM,WAAYyC,CAAW,CAAA,CACxE,EAFKrC,EAAK,KAEV,CACY,EAPbA,EAAK,KAOQ,CACrB,CAEI,CAAA,CACC,CAAA,CACM,CAAA,CAChB,C,EAEV,E"}
@@ -5,148 +5,169 @@ import { Text as n } from "../text/Text.js";
5
5
  import { ConditionalWrapper as r } from "../../shared/ConditionalWrapper.js";
6
6
  import { useUiLabels as i } from "../ui-labels/UiLabelsProvider.js";
7
7
  import { Input as a } from "../input/Input.js";
8
- import { Chip as ee, ChipClearTrigger as o, ChipLabel as s } from "../chip/Chip.js";
9
- import { Combobox as c, Portal as te, createListCollection as ne, useComboboxItemContext as l } from "@ark-ui/react";
10
- import { styled as u } from "@stokelp/styled-system/jsx";
11
- import { combobox as d } from "@stokelp/styled-system/recipes";
12
- import { useCallback as f, useEffect as re, useMemo as p, useState as m } from "react";
13
- import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
14
- import { css as v } from "@stokelp/styled-system/css";
15
- import { FixedSizeList as ie } from "react-window";
16
- import { debounce as y } from "@zag-js/utils";
8
+ import { Chip as o, ChipClearTrigger as s, ChipLabel as c } from "../chip/Chip.js";
9
+ import { Combobox as l, Portal as ee, createListCollection as u, useComboboxItemContext as d } from "@ark-ui/react";
10
+ import { styled as f } from "@stokelp/styled-system/jsx";
11
+ import { combobox as p } from "@stokelp/styled-system/recipes";
12
+ import { useCallback as te, useEffect as ne, useMemo as m, useState as h } from "react";
13
+ import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
14
+ import { css as y } from "@stokelp/styled-system/css";
15
+ import { List as re } from "react-window";
16
+ import { debounce as b } from "@zag-js/utils";
17
17
  // src/components/combobox/Combobox.tsx
18
- var { withProvider: b, withContext: x } = e(d), ae = b(u(c.Root), "root", { defaultProps: { loopFocus: !0 } }), oe = x(u(c.ClearTrigger), "clearTrigger"), S = x(u(c.Content), "content"), C = x(u(c.Input), "input"), w = x(u(c.Control), "control"), T = x(u(c.Item), "item"), E = x(u(c.ItemText), "itemText"), D = x(u(c.Positioner), "positioner"), O = x(u(c.Trigger), "trigger"), k = () => /* @__PURE__ */ _("svg", {
18
+ var { withProvider: x, withContext: S } = e(p), C = x(f(l.Root), "root", { defaultProps: { loopFocus: !0 } }), w = S(f(l.ClearTrigger), "clearTrigger"), T = S(f(l.Content), "content"), E = S(f(l.Input), "input"), D = S(f(l.Control), "control"), O = S(f(l.Item), "item"), k = S(f(l.ItemText), "itemText"), A = S(f(l.Positioner), "positioner"), j = S(f(l.Trigger), "trigger"), M = () => /* @__PURE__ */ v("svg", {
19
19
  width: "16",
20
20
  height: "17",
21
21
  viewBox: "0 0 16 17",
22
22
  fill: "none",
23
23
  xmlns: "http://www.w3.org/2000/svg",
24
- children: [/* @__PURE__ */ g("rect", {
24
+ children: [/* @__PURE__ */ _("rect", {
25
25
  x: "0.5",
26
26
  y: "1",
27
27
  width: "15",
28
28
  height: "15",
29
29
  rx: "3.5",
30
30
  fill: "white"
31
- }), /* @__PURE__ */ g("rect", {
31
+ }), /* @__PURE__ */ _("rect", {
32
32
  x: "0.5",
33
33
  y: "1",
34
34
  width: "15",
35
35
  height: "15",
36
36
  rx: "3.5",
37
- className: v({ stroke: "grey.100" })
37
+ className: y({ stroke: "grey.100" })
38
38
  })]
39
- }), A = () => /* @__PURE__ */ _("svg", {
39
+ }), N = () => /* @__PURE__ */ v("svg", {
40
40
  width: "16",
41
41
  height: "17",
42
42
  viewBox: "0 0 16 17",
43
43
  fill: "none",
44
44
  xmlns: "http://www.w3.org/2000/svg",
45
- children: [/* @__PURE__ */ g("rect", {
45
+ children: [/* @__PURE__ */ _("rect", {
46
46
  y: "0.5",
47
47
  width: "16",
48
48
  height: "16",
49
49
  rx: "4",
50
- className: v({ fill: "primary.500" })
51
- }), /* @__PURE__ */ g("path", {
50
+ className: y({ fill: "primary.500" })
51
+ }), /* @__PURE__ */ _("path", {
52
52
  fillRule: "evenodd",
53
53
  clipRule: "evenodd",
54
54
  d: "M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z",
55
55
  fill: "white"
56
56
  })]
57
57
  });
58
- function j({ item: e, isMultiple: t, renderItem: n }) {
59
- let r = l();
60
- return /* @__PURE__ */ _(h, { children: [t ? r.selected ? /* @__PURE__ */ g(A, {}) : /* @__PURE__ */ g(k, {}) : null, n ? n(e) : /* @__PURE__ */ g(E, {
58
+ function P({ item: e, isMultiple: t, renderItem: n }) {
59
+ let r = d();
60
+ return /* @__PURE__ */ v(g, { children: [t ? r.selected ? /* @__PURE__ */ _(N, {}) : /* @__PURE__ */ _(M, {}) : null, n ? n(e) : /* @__PURE__ */ _(k, {
61
61
  truncate: !0,
62
62
  children: e.label
63
63
  })] });
64
64
  }
65
- var M = ({ items: e = [], initialItems: l, debounceMs: u = 0, placeholder: d, emptyLabel: v, loadingLabel: b, usePortal: x = !0, withAutoFilter: E = !0, positioning: k, loadItems: A, renderItem: M, renderValue: N, onResetInitialItems: P, isLoading: F, value: I, defaultValue: L, openDropdownOnFocus: R = !0, clearValueWhenEmpty: z = !0, virtualized: B, rowHeight: V = 34, returnItemsOnEmpty: H, multiple: U = !1, ...W }) => {
66
- let G = i(), [K, q] = m(() => e), [se, J] = m(!1), [ce, le] = m(!1), Y = typeof A == "function", X = p(() => A ? y(async (e) => {
65
+ function F({ index: e, style: n, ariaAttributes: i, items: a, isMultiple: o, renderItem: s }) {
66
+ let c = a[e];
67
+ return /* @__PURE__ */ _(r, {
68
+ when: !!c.tooltip,
69
+ wrapper: (e) => /* @__PURE__ */ _(t, {
70
+ label: c.tooltip,
71
+ children: e
72
+ }),
73
+ children: /* @__PURE__ */ _(O, {
74
+ item: c,
75
+ style: n,
76
+ "aria-posinset": i["aria-posinset"],
77
+ "aria-setsize": i["aria-setsize"],
78
+ children: /* @__PURE__ */ _(P, {
79
+ renderItem: s,
80
+ item: c,
81
+ isMultiple: o
82
+ })
83
+ })
84
+ });
85
+ }
86
+ var I = ({ items: e = [], initialItems: d, debounceMs: f = 0, placeholder: p, emptyLabel: y, loadingLabel: x, usePortal: S = !0, withAutoFilter: k = !0, positioning: M, loadItems: N, renderItem: I, renderValue: L, onResetInitialItems: R, isLoading: ie, value: ae, defaultValue: oe, openDropdownOnFocus: z = !0, clearValueWhenEmpty: B = !0, virtualized: V, rowHeight: H = 34, returnItemsOnEmpty: U, multiple: W = !1, ...G }) => {
87
+ let K = i(), [se, q] = h(() => e), [ce, J] = h(!1), [le, ue] = h(!1), Y = typeof N == "function", X = m(() => N ? b(async (e) => {
67
88
  try {
68
- le(!0), J(!0);
69
- let t = await A(e);
89
+ ue(!0), J(!0);
90
+ let t = await N(e);
70
91
  q(t);
71
92
  } catch (e) {
72
93
  console.error(e), q([]);
73
94
  } finally {
74
95
  J(!1);
75
96
  }
76
- }, u) : null, [A, u]), Z = [...!Y && !E ? e : K, ...l ?? []], ue = f(async (t) => {
77
- l && l.length > 0 && !l.find((e) => e.label === t.inputValue) && P?.();
97
+ }, f) : null, [N, f]), Z = [...!Y && !k ? e : se, ...d ?? []], de = te(async (t) => {
98
+ d && d.length > 0 && !d.find((e) => e.label === t.inputValue) && R?.();
78
99
  let { inputValue: n } = t;
79
100
  if (X) X(n);
80
101
  else {
81
- let t = E && n !== "" ? e.filter((e) => e.label.toLowerCase().includes(n.toLowerCase())) : e;
82
- if (t.length === 0 && H) return q(e);
102
+ let t = k && n !== "" ? e.filter((e) => e.label.toLowerCase().includes(n.toLowerCase())) : e;
103
+ if (t.length === 0 && U) return q(e);
83
104
  q(t);
84
105
  }
85
106
  }, [
86
107
  X,
87
108
  e,
88
- E
109
+ k
89
110
  ]);
90
- re(() => {
111
+ ne(() => {
91
112
  X || q(e);
92
113
  }, [e, X]);
93
- let de = p(() => ne({ items: Z }), [Z]), fe = F ?? se, Q = b ?? /* @__PURE__ */ g(n, {
114
+ let fe = m(() => u({ items: Z }), [Z]), pe = ie ?? ce, Q = x ?? /* @__PURE__ */ _(n, {
94
115
  p: "space-8",
95
116
  textAlign: "center",
96
- children: G.loading
97
- }), $ = v ?? /* @__PURE__ */ g(n, {
117
+ children: K.loading
118
+ }), $ = y ?? /* @__PURE__ */ _(n, {
98
119
  p: "space-8",
99
120
  textAlign: "center",
100
- children: G.noResults
121
+ children: K.noResults
101
122
  });
102
- return /* @__PURE__ */ _(ae, {
123
+ return /* @__PURE__ */ v(C, {
103
124
  lazyMount: !0,
104
125
  unmountOnExit: !0,
105
- collection: de,
126
+ collection: fe,
106
127
  positioning: {
107
128
  sameWidth: !0,
108
129
  gutter: 0,
109
- ...k
130
+ ...M
110
131
  },
111
132
  "data-recipe": "combobox",
112
- onInputValueChange: ue,
113
- value: I,
114
- defaultValue: L,
115
- ...W,
116
- multiple: U,
117
- children: [U ? /* @__PURE__ */ g(c.Context, { children: (t) => /* @__PURE__ */ _(w, {
133
+ onInputValueChange: de,
134
+ value: ae,
135
+ defaultValue: oe,
136
+ ...G,
137
+ multiple: W,
138
+ children: [W ? /* @__PURE__ */ _(l.Context, { children: (t) => /* @__PURE__ */ v(D, {
118
139
  "data-multiple": "true",
119
140
  "data-open": t.open || void 0,
120
141
  children: [
121
142
  t.value.map((n) => {
122
143
  let r = e.find((e) => String(e.value) === String(n));
123
- return r ? /* @__PURE__ */ _(ee, {
144
+ return r ? /* @__PURE__ */ v(o, {
124
145
  size: "sm",
125
- children: [N ? N(r) : /* @__PURE__ */ g(s, { children: r.label }), !W.readOnly && !W.disabled && /* @__PURE__ */ g(o, {
146
+ children: [L ? L(r) : /* @__PURE__ */ _(c, { children: r.label }), !G.readOnly && !G.disabled && /* @__PURE__ */ _(s, {
126
147
  "aria-label": `Retirer ${r.label}`,
127
148
  onClick: () => t.setValue(t.value.filter((e) => String(e) !== String(n)))
128
149
  })]
129
150
  }, n) : null;
130
151
  }),
131
- /* @__PURE__ */ g(C, {
152
+ /* @__PURE__ */ _(E, {
132
153
  asChild: !0,
133
154
  "data-multiple": "true",
134
- placeholder: t.hasSelectedItems ? void 0 : d,
155
+ placeholder: t.hasSelectedItems ? void 0 : p,
135
156
  onFocus: () => {
136
- R && !Y && t.setOpen(!0);
157
+ z && !Y && t.setOpen(!0);
137
158
  },
138
- children: /* @__PURE__ */ g(a, {})
159
+ children: /* @__PURE__ */ _(a, {})
139
160
  }),
140
- /* @__PURE__ */ g(O, {
161
+ /* @__PURE__ */ _(j, {
141
162
  asChild: !0,
142
- hidden: Y && (!l || l.length === 0),
143
- children: /* @__PURE__ */ g("svg", {
163
+ hidden: Y && (!d || d.length === 0),
164
+ children: /* @__PURE__ */ _("svg", {
144
165
  width: "24",
145
166
  height: "24",
146
167
  viewBox: "0 0 24 24",
147
168
  fill: "none",
148
169
  xmlns: "http://www.w3.org/2000/svg",
149
- children: /* @__PURE__ */ g("path", {
170
+ children: /* @__PURE__ */ _("path", {
150
171
  fillRule: "evenodd",
151
172
  clipRule: "evenodd",
152
173
  d: "M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z",
@@ -155,29 +176,29 @@ var M = ({ items: e = [], initialItems: l, debounceMs: u = 0, placeholder: d, em
155
176
  })
156
177
  })
157
178
  ]
158
- }) }) : /* @__PURE__ */ _(w, { children: [
159
- /* @__PURE__ */ g(c.Context, { children: (e) => /* @__PURE__ */ g(C, {
179
+ }) }) : /* @__PURE__ */ v(D, { children: [
180
+ /* @__PURE__ */ _(l.Context, { children: (e) => /* @__PURE__ */ _(E, {
160
181
  asChild: !0,
161
- placeholder: d,
182
+ placeholder: p,
162
183
  onInput: (t) => {
163
184
  let n = t.currentTarget.value;
164
- z && n === "" && e.clearValue();
185
+ B && n === "" && e.clearValue();
165
186
  },
166
187
  onFocus: () => {
167
- R && !Y && e.setOpen(!0);
188
+ z && !Y && e.setOpen(!0);
168
189
  },
169
- children: /* @__PURE__ */ g(a, {})
190
+ children: /* @__PURE__ */ _(a, {})
170
191
  }) }),
171
- /* @__PURE__ */ g(O, {
192
+ /* @__PURE__ */ _(j, {
172
193
  asChild: !0,
173
- hidden: Y && (!l || l.length === 0),
174
- children: /* @__PURE__ */ g("svg", {
194
+ hidden: Y && (!d || d.length === 0),
195
+ children: /* @__PURE__ */ _("svg", {
175
196
  width: "24",
176
197
  height: "24",
177
198
  viewBox: "0 0 24 24",
178
199
  fill: "none",
179
200
  xmlns: "http://www.w3.org/2000/svg",
180
- children: /* @__PURE__ */ g("path", {
201
+ children: /* @__PURE__ */ _("path", {
181
202
  fillRule: "evenodd",
182
203
  clipRule: "evenodd",
183
204
  d: "M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z",
@@ -185,17 +206,17 @@ var M = ({ items: e = [], initialItems: l, debounceMs: u = 0, placeholder: d, em
185
206
  })
186
207
  })
187
208
  }),
188
- /* @__PURE__ */ g(oe, {
189
- disabled: W.readOnly,
190
- onClick: P,
209
+ /* @__PURE__ */ _(w, {
210
+ disabled: G.readOnly,
211
+ onClick: R,
191
212
  asChild: !0,
192
- children: /* @__PURE__ */ g("button", { children: /* @__PURE__ */ g("svg", {
213
+ children: /* @__PURE__ */ _("button", { children: /* @__PURE__ */ _("svg", {
193
214
  width: "20",
194
215
  height: "20",
195
216
  viewBox: "0 0 20 20",
196
217
  fill: "none",
197
218
  xmlns: "http://www.w3.org/2000/svg",
198
- children: /* @__PURE__ */ g("path", {
219
+ children: /* @__PURE__ */ _("path", {
199
220
  fillRule: "evenodd",
200
221
  clipRule: "evenodd",
201
222
  d: "M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z",
@@ -203,48 +224,38 @@ var M = ({ items: e = [], initialItems: l, debounceMs: u = 0, placeholder: d, em
203
224
  })
204
225
  }) })
205
226
  })
206
- ] }), /* @__PURE__ */ g(r, {
207
- when: x,
208
- wrapper: (e) => /* @__PURE__ */ g(te, { children: e }),
209
- children: /* @__PURE__ */ g(D, { children: /* @__PURE__ */ g(S, { children: fe ? Q : Z.length === 0 ? /* @__PURE__ */ g(h, { children: Y ? ce ? $ : Q : $ }) : B ? /* @__PURE__ */ g(h, { children: /* @__PURE__ */ g(ie, {
210
- height: Math.min(V * Z.length, 180),
211
- itemCount: Z.length,
212
- itemSize: V,
213
- width: "100%",
214
- children: ({ index: e, style: n }) => /* @__PURE__ */ g(r, {
215
- when: !!Z[e].tooltip,
216
- wrapper: (n) => /* @__PURE__ */ g(t, {
217
- label: Z[e].tooltip,
218
- children: n
219
- }),
220
- children: /* @__PURE__ */ g(T, {
221
- item: Z[e],
222
- style: n,
223
- children: /* @__PURE__ */ g(j, {
224
- renderItem: M,
225
- item: Z[e],
226
- isMultiple: U
227
- })
228
- }, Z[e].value)
229
- }, Z[e].value)
230
- }) }) : Z.map((e) => /* @__PURE__ */ g(r, {
227
+ ] }), /* @__PURE__ */ _(r, {
228
+ when: S,
229
+ wrapper: (e) => /* @__PURE__ */ _(ee, { children: e }),
230
+ children: /* @__PURE__ */ _(A, { children: /* @__PURE__ */ _(T, { children: pe ? Q : Z.length === 0 ? /* @__PURE__ */ _(g, { children: Y ? le ? $ : Q : $ }) : V ? /* @__PURE__ */ _(re, {
231
+ role: "presentation",
232
+ rowComponent: F,
233
+ rowProps: {
234
+ items: Z,
235
+ isMultiple: W,
236
+ renderItem: I
237
+ },
238
+ rowCount: Z.length,
239
+ rowHeight: H,
240
+ style: { height: Math.min(H * Z.length, 180) }
241
+ }) : Z.map((e) => /* @__PURE__ */ _(r, {
231
242
  when: !!e.tooltip,
232
- wrapper: (n) => /* @__PURE__ */ g(t, {
243
+ wrapper: (n) => /* @__PURE__ */ _(t, {
233
244
  label: e.tooltip,
234
245
  children: n
235
246
  }),
236
- children: /* @__PURE__ */ g(T, {
247
+ children: /* @__PURE__ */ _(O, {
237
248
  item: e,
238
- children: /* @__PURE__ */ g(j, {
239
- renderItem: M,
249
+ children: /* @__PURE__ */ _(P, {
250
+ renderItem: I,
240
251
  item: e,
241
- isMultiple: U
252
+ isMultiple: W
242
253
  })
243
254
  }, e.value)
244
255
  }, e.value)) }) })
245
256
  })]
246
257
  });
247
258
  };
248
- export { M as Combobox };
259
+ export { I as Combobox };
249
260
 
250
261
  //# sourceMappingURL=Combobox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.js","names":["ArkCombobox","_Fragment","Combobox","UIInput","Tooltip","Tooltip$1","Input$1","Fragment$1","createStyleContext","combobox","Root","withProvider","styled","Combobox","ClearTrigger","withContext","Content","Input","Control","Item","ItemText","Positioner","Trigger","MultipleUncheckedIndicator","css","MultipleCheckedIndicator","CustomInnerItem","context","useComboboxItemContext","isMultiple","renderItem","item","Combobox$1","itemsFromUsers","controlledIsLoading","props","uiLabels","useUiLabels","items","setItems","useState","isLoading","setIsLoading","firstQueryTriggered","setFirstQueryTriggered","asyncMode","loadItems","debouncedLoadItems","useMemo","debounce","newItems","value","error","debounceMs","allItems","withAutoFilter","initialItems","handleInputChange","useCallback","details","onResetInitialItems","inputValue","returnItemsOnEmpty","collection","createListCollection","effectiveIsLoading","loadingContent","loadingLabel","Text","emptyContent","emptyLabel","positioning","multiple","api","i","v","Chip","renderValue","ChipLabel","ChipClearTrigger","x","placeholder","openDropdownOnFocus","e","clearValueWhenEmpty","ConditionalWrapper","usePortal","Portal","virtualized","FixedSizeList","rowHeight","index"],"sources":["../../../src/components/combobox/Combobox.tsx"],"sourcesContent":["import {\n Combobox as ArkCombobox,\n type ComboboxRootProps,\n createListCollection,\n Portal,\n useComboboxItemContext,\n} from '@ark-ui/react'\nimport { FC, ReactNode, useCallback, useEffect, useMemo, useState } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { debounce } from '@zag-js/utils'\n\nimport { combobox } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { Input as UIInput } from '~/components/input'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport { Chip, ChipClearTrigger, ChipLabel } from '~/components/chip'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { FixedSizeList } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(combobox)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkCombobox.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkCombobox.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkCombobox.Content), 'content')\nconst Input = withContext(styled(ArkCombobox.Input), 'input')\nconst Control = withContext(styled(ArkCombobox.Control), 'control')\nconst Item = withContext(styled(ArkCombobox.Item), 'item')\nconst ItemText = withContext(styled(ArkCombobox.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkCombobox.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkCombobox.Trigger), 'trigger')\n\nexport type ComboboxItem = {\n value: string | number\n label: string\n disabled?: boolean\n tooltip?: ReactNode\n}\n\nexport type ComboboxProps<T extends ComboboxItem> = Omit<\n ComboboxRootProps<T>,\n 'collection' | 'value' | 'defaultValue'\n> & {\n // Item values may be numbers: the chips compare them as strings.\n value?: Array<string | number>\n defaultValue?: Array<string | number>\n items?: T[]\n initialItems?: T[]\n renderItem?: (item: T) => ReactNode\n /**\n * Renders the inner content of each selected chip in `multiple` mode.\n * Receives the selected item and should return the chip body (the removable\n * clear button is appended automatically). Defaults to the item label.\n */\n renderValue?: (item: T) => ReactNode\n loadItems?: (inputValue: string) => Promise<T[]>\n debounceMs?: number\n emptyLabel?: ReactNode\n loadingLabel?: ReactNode\n placeholder?: string\n usePortal?: boolean\n isLoading?: boolean\n withAutoFilter?: boolean\n onResetInitialItems?: () => void\n openDropdownOnFocus?: boolean\n clearValueWhenEmpty?: boolean\n virtualized?: boolean\n rowHeight?: number\n returnItemsOnEmpty?: boolean\n} & Omit<HTMLStyledProps<'div'>, 'defaultValue'> &\n RecipeVariantProps<typeof combobox>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends ComboboxItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\nfunction CustomInnerItem<Item extends ComboboxItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useComboboxItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\nexport const Combobox = <T extends ComboboxItem>({\n items: itemsFromUsers = [],\n initialItems,\n debounceMs = 0,\n placeholder,\n emptyLabel,\n loadingLabel,\n usePortal = true,\n withAutoFilter = true,\n positioning,\n loadItems,\n renderItem,\n renderValue,\n onResetInitialItems,\n isLoading: controlledIsLoading,\n value,\n defaultValue,\n openDropdownOnFocus = true,\n clearValueWhenEmpty = true,\n virtualized,\n rowHeight = 34,\n returnItemsOnEmpty,\n multiple = false,\n ...props\n}: ComboboxProps<T>) => {\n const uiLabels = useUiLabels()\n const [items, setItems] = useState(() => itemsFromUsers)\n const [isLoading, setIsLoading] = useState(false)\n const [firstQueryTriggered, setFirstQueryTriggered] = useState(false)\n const asyncMode = typeof loadItems === 'function'\n\n const debouncedLoadItems = useMemo(\n () =>\n loadItems\n ? debounce(async (value: string) => {\n try {\n setFirstQueryTriggered(true)\n setIsLoading(true)\n const newItems = await loadItems(value)\n setItems(newItems)\n } catch (error) {\n console.error(error)\n setItems([])\n } finally {\n setIsLoading(false)\n }\n }, debounceMs)\n : null,\n [loadItems, debounceMs],\n )\n\n // A sync, unfiltered list has nothing to derive: read the prop itself. The mirrored\n // `items` state only catches up in an effect, one render late, and zag re-derives the\n // input text from the collection the moment `value` changes: a value set in the same\n // render as the item that carries it was stringified against a list without it, and\n // the input went blank.\n const sourceItems = !asyncMode && !withAutoFilter ? itemsFromUsers : items\n const allItems = [...sourceItems, ...(initialItems ?? [])]\n\n const handleInputChange = useCallback(\n async (details: ArkCombobox.InputValueChangeDetails) => {\n if (\n initialItems &&\n initialItems.length > 0 &&\n !initialItems.find((item: ComboboxItem) => item.label === details.inputValue)\n ) {\n onResetInitialItems?.()\n }\n const { inputValue } = details\n\n if (debouncedLoadItems) {\n debouncedLoadItems(inputValue)\n } else {\n const items =\n withAutoFilter && inputValue !== ''\n ? itemsFromUsers.filter((item: ComboboxItem) => item.label.toLowerCase().includes(inputValue.toLowerCase()))\n : itemsFromUsers\n\n if (items.length === 0 && returnItemsOnEmpty) {\n return setItems(itemsFromUsers)\n }\n setItems(items)\n }\n },\n [debouncedLoadItems, itemsFromUsers, withAutoFilter],\n )\n\n // Keep the visible items in sync with the source list whenever it changes\n // (e.g. options that load asynchronously after mount). Without this, an empty\n // input shows a stale/empty list (the no-results label) until the user types.\n // Consumers memoize `items`, so this only fires on real data changes, not on\n // every keystroke.\n useEffect(() => {\n if (!debouncedLoadItems) {\n setItems(itemsFromUsers)\n }\n }, [itemsFromUsers, debouncedLoadItems])\n\n const collection = useMemo(() => createListCollection({ items: allItems }), [allItems])\n\n const effectiveIsLoading = controlledIsLoading ?? isLoading\n\n const loadingContent = loadingLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n {uiLabels.loading}\n </Text>\n )\n const emptyContent = emptyLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n {uiLabels.noResults}\n </Text>\n )\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"combobox\"\n onInputValueChange={handleInputChange}\n value={value as string[] | undefined}\n defaultValue={defaultValue as string[] | undefined}\n {...props}\n multiple={multiple}\n >\n {multiple ? (\n // Tags-input layout: the control (styled via the recipe's `&[data-multiple]`\n // selectors) is the bordered box holding the selected chips and a\n // borderless growing input.\n <ArkCombobox.Context>\n {api => (\n <Control data-multiple=\"true\" data-open={api.open || undefined}>\n {/* Resolve chips from the current value against the full source\n list rather than ark's cached `selectedItems`: the cache is only\n re-derived on value changes, so async-loaded defaults would show\n 0 chips until the user selects something. Looking up in\n itemsFromUsers (never the filtered list) also keeps chips visible\n while the user is typing to filter. */}\n {api.value.map(v => {\n const item = itemsFromUsers.find((i: T) => String(i.value) === String(v))\n if (!item) return null\n return (\n <Chip key={v} size=\"sm\">\n {renderValue ? renderValue(item) : <ChipLabel>{item.label}</ChipLabel>}\n {!props.readOnly && !props.disabled && (\n <ChipClearTrigger\n aria-label={`Retirer ${item.label}`}\n // Remove by strict-equality-safe filter: stored values may\n // be numbers while item.value is compared as a string.\n onClick={() => api.setValue(api.value.filter(x => String(x) !== String(v)))}\n />\n )}\n </Chip>\n )\n })}\n <Input\n asChild\n data-multiple=\"true\"\n placeholder={api.hasSelectedItems ? undefined : placeholder}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n </Control>\n )}\n </ArkCombobox.Context>\n ) : (\n <Control>\n <ArkCombobox.Context>\n {api => (\n <Input\n asChild\n placeholder={placeholder}\n onInput={(e: React.FormEvent<HTMLInputElement>) => {\n const value = e.currentTarget.value\n\n if (clearValueWhenEmpty && value === '') {\n api.clearValue()\n }\n }}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n )}\n </ArkCombobox.Context>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} onClick={onResetInitialItems} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n )}\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal>{children}</Portal>}>\n <Positioner>\n <Content>\n {effectiveIsLoading ? (\n loadingContent\n ) : allItems.length === 0 ? (\n <>{asyncMode ? (firstQueryTriggered ? emptyContent : loadingContent) : emptyContent}</>\n ) : virtualized ? (\n <>\n <FixedSizeList\n height={Math.min(rowHeight * allItems.length, 180)}\n itemCount={allItems.length}\n itemSize={rowHeight}\n width=\"100%\"\n >\n {({ index, style }) => (\n <ConditionalWrapper\n key={allItems[index].value}\n when={!!allItems[index].tooltip}\n wrapper={children => <Tooltip label={allItems[index].tooltip}>{children}</Tooltip>}\n >\n <Item key={allItems[index].value} item={allItems[index]} style={style}>\n <CustomInnerItem renderItem={renderItem} item={allItems[index]} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n )}\n </FixedSizeList>\n </>\n ) : (\n allItems.map(item => (\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={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,MAAY,kBAACvF,GAAD;MAAS,OAAOkD,EAASqC,EAAM,CAAC;MAAU;KAAkB,CAAA;KAEjF,UAAA,kBAACxE,GAAD;MAAkC,MAAMmC,EAASqC;MAAe;MAC9D,UAAA,kBAACjE,GAAD;OAA6B;OAAY,MAAM4B,EAASqC;OAAQ,YAAYnB;MAAW,CAAA;KACnF,GAFKlB,EAASqC,EAAM,CAAC,KAErB;IACY,GAPbrC,EAASqC,EAAM,CAAC,KAOH;GAET,CAAA,EACf,CAAA,IAEFrC,EAAS,KAAI,MACX,kBAAC+B,GAAD;IAEE,MAAM,CAAC,CAACtD,EAAK;IACb,UAAS,MAAY,kBAAC3B,GAAD;KAAS,OAAO2B,EAAK;KAAU;IAAkB,CAAA;IAEtE,UAAA,kBAACZ,GAAD;KAA6B;KAC3B,UAAA,kBAACO,GAAD;MAA6B;MAAkB;MAAM,YAAY8C;KAAW,CAAA;IACxE,GAFKzC,EAAK,KAEV;GACY,GAPbA,EAAK,KAOQ,CACrB,EAEI,CAAA,EACC,CAAA;EACM,CAAA,CAChB;;AAEV"}
1
+ {"version":3,"file":"Combobox.js","names":["ArkCombobox","_Fragment","Tooltip","Combobox","UIInput","Tooltip$1","Input$1","Fragment$1","createStyleContext","combobox","Root","withProvider","styled","Combobox","ClearTrigger","withContext","Content","Input","Control","Item","ItemText","Positioner","Trigger","MultipleUncheckedIndicator","css","MultipleCheckedIndicator","CustomInnerItem","context","useComboboxItemContext","isMultiple","renderItem","item","VirtualRow","items","index","ConditionalWrapper","ariaAttributes","Combobox$1","itemsFromUsers","controlledIsLoading","props","uiLabels","useUiLabels","setItems","useState","isLoading","setIsLoading","firstQueryTriggered","setFirstQueryTriggered","asyncMode","loadItems","debouncedLoadItems","useMemo","debounce","newItems","value","error","debounceMs","allItems","withAutoFilter","initialItems","handleInputChange","useCallback","details","onResetInitialItems","inputValue","returnItemsOnEmpty","collection","createListCollection","effectiveIsLoading","loadingContent","loadingLabel","Text","emptyContent","emptyLabel","positioning","multiple","api","i","v","Chip","renderValue","ChipLabel","ChipClearTrigger","x","placeholder","openDropdownOnFocus","e","clearValueWhenEmpty","usePortal","Portal","virtualized","List","rowHeight"],"sources":["../../../src/components/combobox/Combobox.tsx"],"sourcesContent":["import {\n Combobox as ArkCombobox,\n type ComboboxRootProps,\n createListCollection,\n Portal,\n useComboboxItemContext,\n} from '@ark-ui/react'\nimport { FC, ReactNode, useCallback, useEffect, useMemo, useState } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { debounce } from '@zag-js/utils'\n\nimport { combobox } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { Input as UIInput } from '~/components/input'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport { Chip, ChipClearTrigger, ChipLabel } from '~/components/chip'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { List, type RowComponentProps } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(combobox)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkCombobox.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkCombobox.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkCombobox.Content), 'content')\nconst Input = withContext(styled(ArkCombobox.Input), 'input')\nconst Control = withContext(styled(ArkCombobox.Control), 'control')\nconst Item = withContext(styled(ArkCombobox.Item), 'item')\nconst ItemText = withContext(styled(ArkCombobox.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkCombobox.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkCombobox.Trigger), 'trigger')\n\nexport type ComboboxItem = {\n value: string | number\n label: string\n disabled?: boolean\n tooltip?: ReactNode\n}\n\nexport type ComboboxProps<T extends ComboboxItem> = Omit<\n ComboboxRootProps<T>,\n 'collection' | 'value' | 'defaultValue'\n> & {\n // Item values may be numbers: the chips compare them as strings.\n value?: Array<string | number>\n defaultValue?: Array<string | number>\n items?: T[]\n initialItems?: T[]\n renderItem?: (item: T) => ReactNode\n /**\n * Renders the inner content of each selected chip in `multiple` mode.\n * Receives the selected item and should return the chip body (the removable\n * clear button is appended automatically). Defaults to the item label.\n */\n renderValue?: (item: T) => ReactNode\n loadItems?: (inputValue: string) => Promise<T[]>\n debounceMs?: number\n emptyLabel?: ReactNode\n loadingLabel?: ReactNode\n placeholder?: string\n usePortal?: boolean\n isLoading?: boolean\n withAutoFilter?: boolean\n onResetInitialItems?: () => void\n openDropdownOnFocus?: boolean\n clearValueWhenEmpty?: boolean\n virtualized?: boolean\n rowHeight?: number\n returnItemsOnEmpty?: boolean\n} & Omit<HTMLStyledProps<'div'>, 'defaultValue'> &\n RecipeVariantProps<typeof combobox>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends ComboboxItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\nfunction CustomInnerItem<Item extends ComboboxItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useComboboxItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\ninterface VirtualRowProps<Item extends ComboboxItem> {\n items: Item[]\n isMultiple: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\n// Declared at module level: react-window memoizes the row component by identity, so a\n// component created during render would remount every visible row on each render.\nfunction VirtualRow<Item extends ComboboxItem>({\n index,\n style,\n ariaAttributes,\n items,\n isMultiple,\n renderItem,\n}: RowComponentProps<VirtualRowProps<Item>>) {\n const item = items[index]\n\n return (\n <ConditionalWrapper when={!!item.tooltip} wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}>\n {/* Only the position attributes: the option keeps its role from Ark, not react-window's listitem. */}\n <Item\n item={item}\n style={style}\n aria-posinset={ariaAttributes['aria-posinset']}\n aria-setsize={ariaAttributes['aria-setsize']}\n >\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={isMultiple} />\n </Item>\n </ConditionalWrapper>\n )\n}\n\nexport const Combobox = <T extends ComboboxItem>({\n items: itemsFromUsers = [],\n initialItems,\n debounceMs = 0,\n placeholder,\n emptyLabel,\n loadingLabel,\n usePortal = true,\n withAutoFilter = true,\n positioning,\n loadItems,\n renderItem,\n renderValue,\n onResetInitialItems,\n isLoading: controlledIsLoading,\n value,\n defaultValue,\n openDropdownOnFocus = true,\n clearValueWhenEmpty = true,\n virtualized,\n rowHeight = 34,\n returnItemsOnEmpty,\n multiple = false,\n ...props\n}: ComboboxProps<T>) => {\n const uiLabels = useUiLabels()\n const [items, setItems] = useState(() => itemsFromUsers)\n const [isLoading, setIsLoading] = useState(false)\n const [firstQueryTriggered, setFirstQueryTriggered] = useState(false)\n const asyncMode = typeof loadItems === 'function'\n\n const debouncedLoadItems = useMemo(\n () =>\n loadItems\n ? debounce(async (value: string) => {\n try {\n setFirstQueryTriggered(true)\n setIsLoading(true)\n const newItems = await loadItems(value)\n setItems(newItems)\n } catch (error) {\n console.error(error)\n setItems([])\n } finally {\n setIsLoading(false)\n }\n }, debounceMs)\n : null,\n [loadItems, debounceMs],\n )\n\n // A sync, unfiltered list has nothing to derive: read the prop itself. The mirrored\n // `items` state only catches up in an effect, one render late, and zag re-derives the\n // input text from the collection the moment `value` changes: a value set in the same\n // render as the item that carries it was stringified against a list without it, and\n // the input went blank.\n const sourceItems = !asyncMode && !withAutoFilter ? itemsFromUsers : items\n const allItems = [...sourceItems, ...(initialItems ?? [])]\n\n const handleInputChange = useCallback(\n async (details: ArkCombobox.InputValueChangeDetails) => {\n if (\n initialItems &&\n initialItems.length > 0 &&\n !initialItems.find((item: ComboboxItem) => item.label === details.inputValue)\n ) {\n onResetInitialItems?.()\n }\n const { inputValue } = details\n\n if (debouncedLoadItems) {\n debouncedLoadItems(inputValue)\n } else {\n const items =\n withAutoFilter && inputValue !== ''\n ? itemsFromUsers.filter((item: ComboboxItem) => item.label.toLowerCase().includes(inputValue.toLowerCase()))\n : itemsFromUsers\n\n if (items.length === 0 && returnItemsOnEmpty) {\n return setItems(itemsFromUsers)\n }\n setItems(items)\n }\n },\n [debouncedLoadItems, itemsFromUsers, withAutoFilter],\n )\n\n // Keep the visible items in sync with the source list whenever it changes\n // (e.g. options that load asynchronously after mount). Without this, an empty\n // input shows a stale/empty list (the no-results label) until the user types.\n // Consumers memoize `items`, so this only fires on real data changes, not on\n // every keystroke.\n useEffect(() => {\n if (!debouncedLoadItems) {\n setItems(itemsFromUsers)\n }\n }, [itemsFromUsers, debouncedLoadItems])\n\n const collection = useMemo(() => createListCollection({ items: allItems }), [allItems])\n\n const effectiveIsLoading = controlledIsLoading ?? isLoading\n\n const loadingContent = loadingLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n {uiLabels.loading}\n </Text>\n )\n const emptyContent = emptyLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n {uiLabels.noResults}\n </Text>\n )\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"combobox\"\n onInputValueChange={handleInputChange}\n value={value as string[] | undefined}\n defaultValue={defaultValue as string[] | undefined}\n {...props}\n multiple={multiple}\n >\n {multiple ? (\n // Tags-input layout: the control (styled via the recipe's `&[data-multiple]`\n // selectors) is the bordered box holding the selected chips and a\n // borderless growing input.\n <ArkCombobox.Context>\n {api => (\n <Control data-multiple=\"true\" data-open={api.open || undefined}>\n {/* Resolve chips from the current value against the full source\n list rather than ark's cached `selectedItems`: the cache is only\n re-derived on value changes, so async-loaded defaults would show\n 0 chips until the user selects something. Looking up in\n itemsFromUsers (never the filtered list) also keeps chips visible\n while the user is typing to filter. */}\n {api.value.map(v => {\n const item = itemsFromUsers.find((i: T) => String(i.value) === String(v))\n if (!item) return null\n return (\n <Chip key={v} size=\"sm\">\n {renderValue ? renderValue(item) : <ChipLabel>{item.label}</ChipLabel>}\n {!props.readOnly && !props.disabled && (\n <ChipClearTrigger\n aria-label={`Retirer ${item.label}`}\n // Remove by strict-equality-safe filter: stored values may\n // be numbers while item.value is compared as a string.\n onClick={() => api.setValue(api.value.filter(x => String(x) !== String(v)))}\n />\n )}\n </Chip>\n )\n })}\n <Input\n asChild\n data-multiple=\"true\"\n placeholder={api.hasSelectedItems ? undefined : placeholder}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n </Control>\n )}\n </ArkCombobox.Context>\n ) : (\n <Control>\n <ArkCombobox.Context>\n {api => (\n <Input\n asChild\n placeholder={placeholder}\n onInput={(e: React.FormEvent<HTMLInputElement>) => {\n const value = e.currentTarget.value\n\n if (clearValueWhenEmpty && value === '') {\n api.clearValue()\n }\n }}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n )}\n </ArkCombobox.Context>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} onClick={onResetInitialItems} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n )}\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal>{children}</Portal>}>\n <Positioner>\n <Content>\n {effectiveIsLoading ? (\n loadingContent\n ) : allItems.length === 0 ? (\n <>{asyncMode ? (firstQueryTriggered ? emptyContent : loadingContent) : emptyContent}</>\n ) : virtualized ? (\n // role=\"presentation\" overrides the list's own role=\"list\": the options must stay\n // owned by the listbox.\n <List\n role=\"presentation\"\n rowComponent={VirtualRow<T>}\n rowProps={{ items: allItems, isMultiple: multiple, renderItem }}\n rowCount={allItems.length}\n rowHeight={rowHeight}\n style={{ height: Math.min(rowHeight * allItems.length, 180) }}\n />\n ) : (\n allItems.map(item => (\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={item}>\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n ))\n )}\n </Content>\n </Positioner>\n </ConditionalWrapper>\n </Root>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,IAAM,EAAE,iBAAc,mBAAgBQ,EAAmBC,CAAQ,GAG3DC,IAAOC,EAAaC,EAAOZ,EAAY,IAAS,GAAG,QAAQ,EAC/D,cAAc,EACZ,WAAW,GACb,EACF,CAAC,GAEKc,IAAeC,EAAYH,EAAOZ,EAAY,YAAY,GAAG,cAAc,GAC3EgB,IAAUD,EAAYH,EAAOZ,EAAY,OAAO,GAAG,SAAS,GAC5DiB,IAAQF,EAAYH,EAAOZ,EAAY,KAAK,GAAG,OAAO,GACtDkB,IAAUH,EAAYH,EAAOZ,EAAY,OAAO,GAAG,SAAS,GAC5DmB,IAAOJ,EAAYH,EAAOZ,EAAY,IAAI,GAAG,MAAM,GACnDoB,IAAWL,EAAYH,EAAOZ,EAAY,QAAQ,GAAG,UAAU,GAC/DqB,IAAaN,EAAYH,EAAOZ,EAAY,UAAU,GAAG,YAAY,GACrEsB,IAAUP,EAAYH,EAAOZ,EAAY,OAAO,GAAG,SAAS,GA0C5DuB,UACJ,kBAAC,OAAD;CAAK,OAAM;CAAK,QAAO;CAAK,SAAQ;CAAY,MAAK;CAAO,OAAM;CAAlE,UAAA,CACE,kBAAC,QAAD;EAAM,GAAE;EAAM,GAAE;EAAI,OAAM;EAAK,QAAO;EAAK,IAAG;EAAM,MAAK;CAAS,CAAA,GAClE,kBAAC,QAAD;EAAM,GAAE;EAAM,GAAE;EAAI,OAAM;EAAK,QAAO;EAAK,IAAG;EAAM,WAAWC,EAAI,EAAE,QAAQ,WAAW,CAAC;CAAI,CAAA,CAC1F;A,IAGDC,UACJ,kBAAC,OA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C7B,GAAD;GAAoB,MAAMsD;GAAW,UAAS,MAAY,kBAACC,IAAD,EAAS,YAAiB,CAAA;GAClF,UAAA,kBAACrE,GAAD,EAAA,UACE,kBAACL,GAAD,EAAA,UACGqD,KACCC,IACEZ,EAAS,WAAW,IACtB,kBAAAzD,GAAA,EAAA,UAAGgD,IAAaF,KAAsB0B,IAAeH,IAAkBG,EAAe,CAAA,IACpFkB,IAGF,kBAACC,IAAD;IACE,MAAK;IACL,cAAc5D;IACd,UAAU;KAAE,OAAO0B;KAAU,YAAYkB;KAAU;IAAW;IAC9D,UAAUlB,EAAS;IACR;IACX,OAAO,EAAE,QAAQ,KAAK,IAAImC,IAAYnC,EAAS,QAAQ,GAAG,EAAE;GAC7D,CAAA,IAEDA,EAAS,KAAI,MACX,kBAACvB,GAAD;IAEE,MAAM,CAAC,CAACJ,EAAK;IACb,UAAS,MAAY,kBAAC7B,GAAD;KAAS,OAAO6B,EAAK;KAAU;IAAkB,CAAA;IAEtE,UAAA,kBAACZ,GAAD;KAA6B;KAC3B,UAAA,kBAACO,GAAD;MAA6B;MAAkB;MAAM,YAAYkD;KAAW,CAAA;IACxE,GAFK7C,EAAK,KAEV;GACY,GAPbA,EAAK,KAOQ,CACrB,EAEI,CAAA,EACC,CAAA;EACM,CAAA,CAChB;;AAEV"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../utils/slots.cjs"),t=require("../tooltip/Tooltip.cjs"),n=require("../text/Text.cjs"),r=require("../../shared/ConditionalWrapper.cjs"),i=require("../ui-labels/UiLabelsProvider.cjs");let a=require("@ark-ui/react"),o=require("@stokelp/styled-system/jsx"),s=require("@stokelp/styled-system/recipes"),c=require("react"),l=require("react/jsx-runtime"),u=require("@stokelp/styled-system/css"),d=require("react-window");var{withProvider:f,withContext:p}=e.createStyleContext(s.select),m=f((0,o.styled)(a.Select.Root),`root`,{defaultProps:{loopFocus:!0}}),h=p((0,o.styled)(a.Select.ClearTrigger),`clearTrigger`),g=p((0,o.styled)(a.Select.Content),`content`),_=p((0,o.styled)(a.Select.Control),`control`),v=p((0,o.styled)(a.Select.Indicator),`indicator`),y=p((0,o.styled)(a.Select.Item),`item`),b=p((0,o.styled)(a.Select.ItemGroup),`itemGroup`),x=p((0,o.styled)(a.Select.ItemGroupLabel),`itemGroupLabel`),S=p((0,o.styled)(a.Select.ItemText),`itemText`),C=p((0,o.styled)(a.Select.Positioner),`positioner`),w=p((0,o.styled)(a.Select.Trigger),`trigger`),T=p((0,o.styled)(a.Select.ValueText),`valueText`),E=()=>(0,l.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,l.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,fill:`white`}),(0,l.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,className:(0,u.css)({stroke:`grey.100`})})]}),D=()=>(0,l.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,l.jsx)(`rect`,{y:`0.5`,width:`16`,height:`16`,rx:`4`,className:(0,u.css)({fill:`primary.500`})}),(0,l.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z`,fill:`white`})]});function O({placeholder:e,allSelectedLabel:t}){let n=(0,a.useSelectContext)(),r=n.collection.items,i=n.selectedItems;return n.multiple&&i.filter(e=>!e.disabled).length>=r.filter(e=>!e.disabled).length&&t?(0,l.jsx)(T,{className:`custom`,truncate:!0,children:t}):(0,l.jsx)(T,{truncate:!0,placeholder:e})}function k({renderTrigger:e,placeholder:t,allSelectedLabel:n}){let r=(0,a.useSelectContext)(),i=r.value&&r.value.length>0?r.collection.findMany(r.value):[];if(i.length===0)return(0,l.jsx)(T,{className:`custom`,truncate:!0,placeholder:t});let o=r.selectedItems;return r.multiple&&o.filter(e=>!e.disabled).length>=r.collection.items.filter(e=>!e.disabled).length&&n?(0,l.jsx)(T,{className:`custom`,truncate:!0,children:n}):(0,l.jsx)(T,{className:`custom`,placeholder:t,children:i.map(t=>(0,l.jsx)(`span`,{children:e(t)},t.value))})}function A({item:e,isMultiple:t,renderItem:n}){let r=(0,a.useSelectItemContext)();return(0,l.jsxs)(l.Fragment,{children:[t?r.selected?(0,l.jsx)(D,{}):(0,l.jsx)(E,{}):null,n?n(e):(0,l.jsx)(S,{truncate:!0,children:e.label})]})}function j(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.label===n.groupLabel?e.items.push(n):t.push({label:n.groupLabel,items:[n]})}return t}function M({items:e,placeholder:o,emptyLabel:s,usePortal:f=!0,positioning:p,renderItem:S,renderTrigger:T,virtualized:E,rowHeight:D=34,...M}){let N=i.useUiLabels(),P=(0,a.createListCollection)({items:e}),F=(0,c.useRef)(null),I=e=>(0,l.jsxs)(c.Fragment,{children:[(0,l.jsx)(r.ConditionalWrapper,{when:!!e.tooltip,wrapper:n=>(0,l.jsx)(t.Tooltip,{label:e.tooltip,children:n}),children:(0,l.jsx)(y,{item:e,children:(0,l.jsx)(A,{renderItem:S,item:e,isMultiple:M.multiple})},e.value)},e.value),e.separatorAfter&&(0,l.jsx)(`div`,{role:`separator`,className:(0,u.css)({height:`1px`,flexShrink:0,backgroundColor:`grey.100`,marginY:`space-4`,marginX:`space-8`})})]},e.value);return(0,l.jsxs)(m,{lazyMount:!0,unmountOnExit:!0,collection:P,positioning:{sameWidth:!0,gutter:0,...p},"data-recipe":`select`,...M,ref:e=>{e&&(F.current=e.closest(`[role="dialog"]`))},children:[(0,l.jsxs)(_,{children:[(0,l.jsxs)(w,{children:[T?(0,l.jsx)(k,{renderTrigger:T,placeholder:o,allSelectedLabel:M.allSelectedLabel}):(0,l.jsx)(O,{placeholder:o,allSelectedLabel:M.allSelectedLabel}),(0,l.jsx)(v,{asChild:!0,children:(0,l.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,l.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z`,fill:`currentColor`})})})]}),(0,l.jsx)(h,{disabled:M.readOnly,asChild:!0,children:(0,l.jsx)(`button`,{children:(0,l.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,l.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z`,fill:`currentColor`})})})})]}),(0,l.jsx)(r.ConditionalWrapper,{when:f,wrapper:e=>(0,l.jsx)(a.Portal,{container:F,children:e}),children:(0,l.jsx)(C,{children:(0,l.jsx)(g,{children:e.length===0?(0,l.jsx)(n.Text,{px:`space-8`,textAlign:`center`,children:s??N.noResults}):E?(0,l.jsx)(l.Fragment,{children:(0,l.jsx)(d.FixedSizeList,{height:Math.min(D*e.length,180),itemCount:e.length,itemSize:D,width:`100%`,children:({index:n,style:i})=>(0,l.jsx)(r.ConditionalWrapper,{when:!!e[n].tooltip,wrapper:r=>(0,l.jsx)(t.Tooltip,{label:e[n].tooltip,children:r}),children:(0,l.jsx)(y,{item:e[n],style:i,children:(0,l.jsx)(A,{renderItem:S,item:e[n]})},e[n].value)},e[n].value)})}):j(e).map((e,t)=>e.label===void 0?(0,l.jsx)(c.Fragment,{children:e.items.map(I)},`group-${t}`):(0,l.jsxs)(b,{children:[(0,l.jsx)(x,{children:e.label}),e.items.map(I)]},`group-${t}`))})})}),(0,l.jsx)(a.Select.HiddenSelect,{})]})}exports.Select=M;
1
+ "use client";const e=require("../../utils/slots.cjs"),t=require("../tooltip/Tooltip.cjs"),n=require("../text/Text.cjs"),r=require("../../shared/ConditionalWrapper.cjs"),i=require("../ui-labels/UiLabelsProvider.cjs");let a=require("@ark-ui/react"),o=require("@stokelp/styled-system/jsx"),s=require("@stokelp/styled-system/recipes"),c=require("react"),l=require("react/jsx-runtime"),u=require("@stokelp/styled-system/css"),d=require("react-window");var{withProvider:f,withContext:p}=e.createStyleContext(s.select),m=f((0,o.styled)(a.Select.Root),`root`,{defaultProps:{loopFocus:!0}}),h=p((0,o.styled)(a.Select.ClearTrigger),`clearTrigger`),g=p((0,o.styled)(a.Select.Content),`content`),_=p((0,o.styled)(a.Select.Control),`control`),v=p((0,o.styled)(a.Select.Indicator),`indicator`),y=p((0,o.styled)(a.Select.Item),`item`),b=p((0,o.styled)(a.Select.ItemGroup),`itemGroup`),x=p((0,o.styled)(a.Select.ItemGroupLabel),`itemGroupLabel`),S=p((0,o.styled)(a.Select.ItemText),`itemText`),C=p((0,o.styled)(a.Select.Positioner),`positioner`),w=p((0,o.styled)(a.Select.Trigger),`trigger`),T=p((0,o.styled)(a.Select.ValueText),`valueText`),E=()=>(0,l.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,l.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,fill:`white`}),(0,l.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,className:(0,u.css)({stroke:`grey.100`})})]}),D=()=>(0,l.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,l.jsx)(`rect`,{y:`0.5`,width:`16`,height:`16`,rx:`4`,className:(0,u.css)({fill:`primary.500`})}),(0,l.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z`,fill:`white`})]});function O({placeholder:e,allSelectedLabel:t}){let n=(0,a.useSelectContext)(),r=n.collection.items,i=n.selectedItems;return n.multiple&&i.filter(e=>!e.disabled).length>=r.filter(e=>!e.disabled).length&&t?(0,l.jsx)(T,{className:`custom`,truncate:!0,children:t}):(0,l.jsx)(T,{truncate:!0,placeholder:e})}function k({renderTrigger:e,placeholder:t,allSelectedLabel:n}){let r=(0,a.useSelectContext)(),i=r.value&&r.value.length>0?r.collection.findMany(r.value):[];if(i.length===0)return(0,l.jsx)(T,{className:`custom`,truncate:!0,placeholder:t});let o=r.selectedItems;return r.multiple&&o.filter(e=>!e.disabled).length>=r.collection.items.filter(e=>!e.disabled).length&&n?(0,l.jsx)(T,{className:`custom`,truncate:!0,children:n}):(0,l.jsx)(T,{className:`custom`,placeholder:t,children:i.map(t=>(0,l.jsx)(`span`,{children:e(t)},t.value))})}function A({item:e,isMultiple:t,renderItem:n}){let r=(0,a.useSelectItemContext)();return(0,l.jsxs)(l.Fragment,{children:[t?r.selected?(0,l.jsx)(D,{}):(0,l.jsx)(E,{}):null,n?n(e):(0,l.jsx)(S,{truncate:!0,children:e.label})]})}function j({index:e,style:n,ariaAttributes:i,items:a,renderItem:o}){let s=a[e];return(0,l.jsx)(r.ConditionalWrapper,{when:!!s.tooltip,wrapper:e=>(0,l.jsx)(t.Tooltip,{label:s.tooltip,children:e}),children:(0,l.jsx)(y,{item:s,style:n,"aria-posinset":i[`aria-posinset`],"aria-setsize":i[`aria-setsize`],children:(0,l.jsx)(A,{renderItem:o,item:s})})})}function M(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.label===n.groupLabel?e.items.push(n):t.push({label:n.groupLabel,items:[n]})}return t}function N({items:e,placeholder:o,emptyLabel:s,usePortal:f=!0,positioning:p,renderItem:S,renderTrigger:T,virtualized:E,rowHeight:D=34,...N}){let P=i.useUiLabels(),F=(0,a.createListCollection)({items:e}),I=(0,c.useRef)(null),L=e=>(0,l.jsxs)(c.Fragment,{children:[(0,l.jsx)(r.ConditionalWrapper,{when:!!e.tooltip,wrapper:n=>(0,l.jsx)(t.Tooltip,{label:e.tooltip,children:n}),children:(0,l.jsx)(y,{item:e,children:(0,l.jsx)(A,{renderItem:S,item:e,isMultiple:N.multiple})},e.value)},e.value),e.separatorAfter&&(0,l.jsx)(`div`,{role:`separator`,className:(0,u.css)({height:`1px`,flexShrink:0,backgroundColor:`grey.100`,marginY:`space-4`,marginX:`space-8`})})]},e.value);return(0,l.jsxs)(m,{lazyMount:!0,unmountOnExit:!0,collection:F,positioning:{sameWidth:!0,gutter:0,...p},"data-recipe":`select`,...N,ref:e=>{e&&(I.current=e.closest(`[role="dialog"]`))},children:[(0,l.jsxs)(_,{children:[(0,l.jsxs)(w,{children:[T?(0,l.jsx)(k,{renderTrigger:T,placeholder:o,allSelectedLabel:N.allSelectedLabel}):(0,l.jsx)(O,{placeholder:o,allSelectedLabel:N.allSelectedLabel}),(0,l.jsx)(v,{asChild:!0,children:(0,l.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,l.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z`,fill:`currentColor`})})})]}),(0,l.jsx)(h,{disabled:N.readOnly,asChild:!0,children:(0,l.jsx)(`button`,{children:(0,l.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,l.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z`,fill:`currentColor`})})})})]}),(0,l.jsx)(r.ConditionalWrapper,{when:f,wrapper:e=>(0,l.jsx)(a.Portal,{container:I,children:e}),children:(0,l.jsx)(C,{children:(0,l.jsx)(g,{children:e.length===0?(0,l.jsx)(n.Text,{px:`space-8`,textAlign:`center`,children:s??P.noResults}):E?(0,l.jsx)(d.List,{role:`presentation`,rowComponent:j,rowProps:{items:e,renderItem:S},rowCount:e.length,rowHeight:D,style:{height:Math.min(D*e.length,180)}}):M(e).map((e,t)=>e.label===void 0?(0,l.jsx)(c.Fragment,{children:e.items.map(L)},`group-${t}`):(0,l.jsxs)(b,{children:[(0,l.jsx)(x,{children:e.label}),e.items.map(L)]},`group-${t}`))})})}),(0,l.jsx)(a.Select.HiddenSelect,{})]})}exports.Select=N;
2
2
  //# sourceMappingURL=Select.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Select.cjs","names":["createStyleContext","select","styled","ArkSelect","css","useSelectContext","useSelectItemContext","_Fragment","useUiLabels","createListCollection","useRef","Fragment","ConditionalWrapper","Tooltip","Portal","Text","FixedSizeList","require_slots","require_Tooltip","require_Text","require_ConditionalWrapper","require_UiLabelsProvider","_ark_ui_react","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","_stokelp_styled_system_css","react_window","Root","withProvider","ClearTrigger","withContext","Content","Control","Indicator","Item","ItemGroup","ItemGroupLabel","ItemText","Positioner","Trigger","ValueText","MultipleUncheckedIndicator","MultipleCheckedIndicator","DefaultInnerTrigger","context","items","selectedItems","item","allSelectedLabel","CustomInnerTrigger","renderTrigger","CustomInnerItem","isMultiple","renderItem","toGroupRuns","runs","current","Select","props","uiLabels","collection","$dialogContent","renderOption","positioning","node","usePortal","emptyLabel","virtualized","rowHeight","index","run","runIndex"],"sources":["../../../src/components/select/Select.tsx"],"sourcesContent":["import {\n createListCollection,\n Portal,\n Select as ArkSelect,\n type SelectRootProps,\n useSelectItemContext,\n useSelectContext,\n} from '@ark-ui/react'\nimport { FC, Fragment, ReactNode, useRef } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\n\nimport { select } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { FixedSizeList } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(select)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkSelect.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkSelect.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkSelect.Content), 'content')\nconst Control = withContext(styled(ArkSelect.Control), 'control')\nconst Indicator = withContext(styled(ArkSelect.Indicator), 'indicator')\nconst Item = withContext(styled(ArkSelect.Item), 'item')\nconst ItemGroup = withContext(styled(ArkSelect.ItemGroup), 'itemGroup')\nconst ItemGroupLabel = withContext(styled(ArkSelect.ItemGroupLabel), 'itemGroupLabel')\nconst ItemText = withContext(styled(ArkSelect.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkSelect.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkSelect.Trigger), 'trigger')\nconst ValueText = withContext(styled(ArkSelect.ValueText), 'valueText')\n\nexport interface SelectItem {\n value: string | number\n label: string\n tooltip?: ReactNode\n disabled?: boolean\n /**\n * Renders a thin divider line after this item, separating option groups.\n * Ignored by the virtualized list (fixed row heights).\n */\n separatorAfter?: boolean\n /**\n * Heading for the group this item belongs to. Consecutive items sharing a label are\n * wrapped in one labelled group, so the heading is announced by screen readers instead\n * of being faked with a decorative row inside `renderItem`. Items without a label stay\n * ungrouped. Ignored by the virtualized list (fixed row heights).\n */\n groupLabel?: string\n}\n\nexport type SelectProps<Item extends SelectItem> = Omit<SelectRootProps<Item>, 'collection'> & {\n items: Item[] | readonly Item[]\n renderItem?: (item: Item) => ReactNode\n renderTrigger?: (item: Item) => ReactNode\n emptyLabel?: string\n placeholder?: string\n allSelectedLabel?: string\n usePortal?: boolean\n virtualized?: boolean\n rowHeight?: number\n} & HTMLStyledProps<'div'> &\n RecipeVariantProps<typeof select>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends SelectItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\ninterface InnerTriggerProps<Item extends SelectItem> {\n renderTrigger: (item: Item) => ReactNode\n placeholder?: string\n allSelectedLabel?: string\n}\n\ninterface DefaultInnerTriggerProps {\n placeholder?: string\n allSelectedLabel?: string\n}\n\nfunction DefaultInnerTrigger({ placeholder, allSelectedLabel }: DefaultInnerTriggerProps) {\n const context = useSelectContext()\n const items = context.collection.items\n const selectedItems = context.selectedItems\n\n if (\n context.multiple &&\n selectedItems.filter(item => !item.disabled).length >= items.filter(item => !item.disabled).length &&\n allSelectedLabel\n ) {\n return (\n <ValueText className=\"custom\" truncate>\n {allSelectedLabel}\n </ValueText>\n )\n }\n\n return <ValueText truncate placeholder={placeholder} />\n}\n\nfunction CustomInnerTrigger<Item extends SelectItem>({\n renderTrigger,\n placeholder,\n allSelectedLabel,\n}: InnerTriggerProps<Item>) {\n const context = useSelectContext()\n const items = context.value && context.value.length > 0 ? context.collection.findMany(context.value) : []\n\n if (items.length === 0) {\n return <ValueText className=\"custom\" truncate placeholder={placeholder} />\n }\n\n const selectedItems = context.selectedItems\n\n if (\n context.multiple &&\n selectedItems.filter(item => !item.disabled).length >=\n context.collection.items.filter(item => !item.disabled).length &&\n allSelectedLabel\n ) {\n return (\n <ValueText className=\"custom\" truncate>\n {allSelectedLabel}\n </ValueText>\n )\n }\n\n return (\n <ValueText className=\"custom\" placeholder={placeholder}>\n {items.map(item => (\n <span key={item.value}>{renderTrigger(item)}</span>\n ))}\n </ValueText>\n )\n}\n\nfunction CustomInnerItem<Item extends SelectItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useSelectItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\n/**\n * Splits the flat item list into consecutive runs sharing a `groupLabel`. Runs are built\n * from adjacency rather than by collecting every item with the same label, so the caller\n * keeps full control of the order: sorting is the caller's business, grouping is ours.\n */\nfunction toGroupRuns<Item extends SelectItem>(items: readonly Item[]) {\n const runs: Array<{ label?: string; items: Item[] }> = []\n\n for (const item of items) {\n const current = runs[runs.length - 1]\n if (current && current.label === item.groupLabel) {\n current.items.push(item)\n continue\n }\n runs.push({ label: item.groupLabel, items: [item] })\n }\n\n return runs\n}\n\nexport function Select<Item extends SelectItem>({\n items,\n placeholder,\n emptyLabel,\n usePortal = true,\n positioning,\n renderItem,\n renderTrigger,\n virtualized,\n rowHeight = 34,\n ...props\n}: SelectProps<Item>) {\n const uiLabels = useUiLabels()\n const collection = createListCollection({\n items,\n })\n const $dialogContent = useRef<HTMLDivElement | null>(null)\n\n const renderOption = (item: Item) => (\n <Fragment key={item.value}>\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={item}>\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={props.multiple} />\n </Item>\n </ConditionalWrapper>\n {item.separatorAfter && (\n <div\n role=\"separator\"\n className={css({\n height: '1px',\n flexShrink: 0,\n backgroundColor: 'grey.100',\n marginY: 'space-4',\n marginX: 'space-8',\n })}\n />\n )}\n </Fragment>\n )\n\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"select\"\n {...props}\n ref={(node: HTMLDivElement | null) => {\n if (node) {\n $dialogContent.current = node.closest('[role=\"dialog\"]') as HTMLDivElement | null\n }\n }}\n >\n <Control>\n <Trigger>\n {renderTrigger ? (\n <CustomInnerTrigger\n renderTrigger={renderTrigger}\n placeholder={placeholder}\n allSelectedLabel={props.allSelectedLabel}\n />\n ) : (\n <DefaultInnerTrigger placeholder={placeholder} allSelectedLabel={props.allSelectedLabel} />\n )}\n <Indicator asChild>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Indicator>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal container={$dialogContent}>{children}</Portal>}>\n <Positioner>\n <Content>\n {items.length === 0 ? (\n <Text px=\"space-8\" textAlign=\"center\">\n {emptyLabel ?? uiLabels.noResults}\n </Text>\n ) : virtualized ? (\n <>\n <FixedSizeList\n height={Math.min(rowHeight * items.length, 180)}\n itemCount={items.length}\n itemSize={rowHeight}\n width=\"100%\"\n >\n {({ index, style }) => (\n <ConditionalWrapper\n key={items[index].value}\n when={!!items[index].tooltip}\n wrapper={children => <Tooltip label={items[index].tooltip}>{children}</Tooltip>}\n >\n <Item key={items[index].value} item={items[index]} style={style}>\n <CustomInnerItem renderItem={renderItem} item={items[index]} />\n </Item>\n </ConditionalWrapper>\n )}\n </FixedSizeList>\n </>\n ) : (\n toGroupRuns<Item>(items).map((run, runIndex) =>\n run.label === undefined ? (\n <Fragment key={`group-${runIndex}`}>{run.items.map(renderOption)}</Fragment>\n ) : (\n <ItemGroup key={`group-${runIndex}`}>\n <ItemGroupLabel>{run.label}</ItemGroupLabel>\n {run.items.map(renderOption)}\n </ItemGroup>\n ),\n )\n )}\n </Content>\n </Positioner>\n </ConditionalWrapper>\n <ArkSelect.HiddenSelect />\n </Root>\n )\n}\n"],"mappings":"A,+bAsBA,GAAM,CAAE,eAAc,eAAgBA,EAAAA,mBAAmBC,EAAAA,MAAM,EAGzD4B,EAAOC,GAAA,EAAa5B,EAAAA,OAAAA,CAAOC,EAAAA,OAAU,IAAS,EAAG,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AyB,CAAA,CACrB,C,EAEV,C"}
1
+ {"version":3,"file":"Select.cjs","names":["createStyleContext","select","styled","ArkSelect","css","useSelectContext","useSelectItemContext","_Fragment","ConditionalWrapper","Tooltip","useUiLabels","createListCollection","useRef","Fragment","Portal","Text","List","require_slots","require_Tooltip","require_Text","require_ConditionalWrapper","require_UiLabelsProvider","_ark_ui_react","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","_stokelp_styled_system_css","react_window","Root","withProvider","ClearTrigger","withContext","Content","Control","Indicator","Item","ItemGroup","ItemGroupLabel","ItemText","Positioner","Trigger","ValueText","MultipleUncheckedIndicator","MultipleCheckedIndicator","DefaultInnerTrigger","context","items","selectedItems","item","allSelectedLabel","CustomInnerTrigger","renderTrigger","CustomInnerItem","isMultiple","renderItem","VirtualRow","index","ariaAttributes","toGroupRuns","runs","current","Select","props","uiLabels","collection","$dialogContent","renderOption","positioning","node","usePortal","emptyLabel","virtualized","rowHeight","run","runIndex"],"sources":["../../../src/components/select/Select.tsx"],"sourcesContent":["import {\n createListCollection,\n Portal,\n Select as ArkSelect,\n type SelectRootProps,\n useSelectItemContext,\n useSelectContext,\n} from '@ark-ui/react'\nimport { FC, Fragment, ReactNode, useRef } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\n\nimport { select } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { List, type RowComponentProps } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(select)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkSelect.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkSelect.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkSelect.Content), 'content')\nconst Control = withContext(styled(ArkSelect.Control), 'control')\nconst Indicator = withContext(styled(ArkSelect.Indicator), 'indicator')\nconst Item = withContext(styled(ArkSelect.Item), 'item')\nconst ItemGroup = withContext(styled(ArkSelect.ItemGroup), 'itemGroup')\nconst ItemGroupLabel = withContext(styled(ArkSelect.ItemGroupLabel), 'itemGroupLabel')\nconst ItemText = withContext(styled(ArkSelect.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkSelect.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkSelect.Trigger), 'trigger')\nconst ValueText = withContext(styled(ArkSelect.ValueText), 'valueText')\n\nexport interface SelectItem {\n value: string | number\n label: string\n tooltip?: ReactNode\n disabled?: boolean\n /**\n * Renders a thin divider line after this item, separating option groups.\n * Ignored by the virtualized list (fixed row heights).\n */\n separatorAfter?: boolean\n /**\n * Heading for the group this item belongs to. Consecutive items sharing a label are\n * wrapped in one labelled group, so the heading is announced by screen readers instead\n * of being faked with a decorative row inside `renderItem`. Items without a label stay\n * ungrouped. Ignored by the virtualized list (fixed row heights).\n */\n groupLabel?: string\n}\n\nexport type SelectProps<Item extends SelectItem> = Omit<SelectRootProps<Item>, 'collection'> & {\n items: Item[] | readonly Item[]\n renderItem?: (item: Item) => ReactNode\n renderTrigger?: (item: Item) => ReactNode\n emptyLabel?: string\n placeholder?: string\n allSelectedLabel?: string\n usePortal?: boolean\n virtualized?: boolean\n rowHeight?: number\n} & HTMLStyledProps<'div'> &\n RecipeVariantProps<typeof select>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends SelectItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\ninterface InnerTriggerProps<Item extends SelectItem> {\n renderTrigger: (item: Item) => ReactNode\n placeholder?: string\n allSelectedLabel?: string\n}\n\ninterface DefaultInnerTriggerProps {\n placeholder?: string\n allSelectedLabel?: string\n}\n\nfunction DefaultInnerTrigger({ placeholder, allSelectedLabel }: DefaultInnerTriggerProps) {\n const context = useSelectContext()\n const items = context.collection.items\n const selectedItems = context.selectedItems\n\n if (\n context.multiple &&\n selectedItems.filter(item => !item.disabled).length >= items.filter(item => !item.disabled).length &&\n allSelectedLabel\n ) {\n return (\n <ValueText className=\"custom\" truncate>\n {allSelectedLabel}\n </ValueText>\n )\n }\n\n return <ValueText truncate placeholder={placeholder} />\n}\n\nfunction CustomInnerTrigger<Item extends SelectItem>({\n renderTrigger,\n placeholder,\n allSelectedLabel,\n}: InnerTriggerProps<Item>) {\n const context = useSelectContext()\n const items = context.value && context.value.length > 0 ? context.collection.findMany(context.value) : []\n\n if (items.length === 0) {\n return <ValueText className=\"custom\" truncate placeholder={placeholder} />\n }\n\n const selectedItems = context.selectedItems\n\n if (\n context.multiple &&\n selectedItems.filter(item => !item.disabled).length >=\n context.collection.items.filter(item => !item.disabled).length &&\n allSelectedLabel\n ) {\n return (\n <ValueText className=\"custom\" truncate>\n {allSelectedLabel}\n </ValueText>\n )\n }\n\n return (\n <ValueText className=\"custom\" placeholder={placeholder}>\n {items.map(item => (\n <span key={item.value}>{renderTrigger(item)}</span>\n ))}\n </ValueText>\n )\n}\n\nfunction CustomInnerItem<Item extends SelectItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useSelectItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\ninterface VirtualRowProps<Item extends SelectItem> {\n items: readonly Item[]\n renderItem?: (item: Item) => ReactNode\n}\n\n// Declared at module level: react-window memoizes the row component by identity, so a\n// component created during render would remount every visible row on each render.\nfunction VirtualRow<Item extends SelectItem>({\n index,\n style,\n ariaAttributes,\n items,\n renderItem,\n}: RowComponentProps<VirtualRowProps<Item>>) {\n const item = items[index]\n\n return (\n <ConditionalWrapper when={!!item.tooltip} wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}>\n {/* Only the position attributes: the option keeps its role from Ark, not react-window's listitem. */}\n <Item\n item={item}\n style={style}\n aria-posinset={ariaAttributes['aria-posinset']}\n aria-setsize={ariaAttributes['aria-setsize']}\n >\n <CustomInnerItem renderItem={renderItem} item={item} />\n </Item>\n </ConditionalWrapper>\n )\n}\n\n/**\n * Splits the flat item list into consecutive runs sharing a `groupLabel`. Runs are built\n * from adjacency rather than by collecting every item with the same label, so the caller\n * keeps full control of the order: sorting is the caller's business, grouping is ours.\n */\nfunction toGroupRuns<Item extends SelectItem>(items: readonly Item[]) {\n const runs: Array<{ label?: string; items: Item[] }> = []\n\n for (const item of items) {\n const current = runs[runs.length - 1]\n if (current && current.label === item.groupLabel) {\n current.items.push(item)\n continue\n }\n runs.push({ label: item.groupLabel, items: [item] })\n }\n\n return runs\n}\n\nexport function Select<Item extends SelectItem>({\n items,\n placeholder,\n emptyLabel,\n usePortal = true,\n positioning,\n renderItem,\n renderTrigger,\n virtualized,\n rowHeight = 34,\n ...props\n}: SelectProps<Item>) {\n const uiLabels = useUiLabels()\n const collection = createListCollection({\n items,\n })\n const $dialogContent = useRef<HTMLDivElement | null>(null)\n\n const renderOption = (item: Item) => (\n <Fragment key={item.value}>\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={item}>\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={props.multiple} />\n </Item>\n </ConditionalWrapper>\n {item.separatorAfter && (\n <div\n role=\"separator\"\n className={css({\n height: '1px',\n flexShrink: 0,\n backgroundColor: 'grey.100',\n marginY: 'space-4',\n marginX: 'space-8',\n })}\n />\n )}\n </Fragment>\n )\n\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"select\"\n {...props}\n ref={(node: HTMLDivElement | null) => {\n if (node) {\n $dialogContent.current = node.closest('[role=\"dialog\"]') as HTMLDivElement | null\n }\n }}\n >\n <Control>\n <Trigger>\n {renderTrigger ? (\n <CustomInnerTrigger\n renderTrigger={renderTrigger}\n placeholder={placeholder}\n allSelectedLabel={props.allSelectedLabel}\n />\n ) : (\n <DefaultInnerTrigger placeholder={placeholder} allSelectedLabel={props.allSelectedLabel} />\n )}\n <Indicator asChild>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Indicator>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal container={$dialogContent}>{children}</Portal>}>\n <Positioner>\n <Content>\n {items.length === 0 ? (\n <Text px=\"space-8\" textAlign=\"center\">\n {emptyLabel ?? uiLabels.noResults}\n </Text>\n ) : virtualized ? (\n // role=\"presentation\" overrides the list's own role=\"list\": the options must stay\n // owned by the listbox.\n <List\n role=\"presentation\"\n rowComponent={VirtualRow<Item>}\n rowProps={{ items, renderItem }}\n rowCount={items.length}\n rowHeight={rowHeight}\n style={{ height: Math.min(rowHeight * items.length, 180) }}\n />\n ) : (\n toGroupRuns<Item>(items).map((run, runIndex) =>\n run.label === undefined ? (\n <Fragment key={`group-${runIndex}`}>{run.items.map(renderOption)}</Fragment>\n ) : (\n <ItemGroup key={`group-${runIndex}`}>\n <ItemGroupLabel>{run.label}</ItemGroupLabel>\n {run.items.map(renderOption)}\n </ItemGroup>\n ),\n )\n )}\n </Content>\n </Positioner>\n </ConditionalWrapper>\n <ArkSelect.HiddenSelect />\n </Root>\n )\n}\n"],"mappings":"A,+bAsBA,GAAM,CAAE,eAAc,eAAgBA,EAAAA,mBAAmBC,EAAAA,MAAM,EAGzD4B,EAAOC,GAAA,EAAa5B,EAAAA,OAAAA,CAAOC,EAAAA,OAAU,IAAS,EAAG,OAAQ,CAC7D,aAAc,CACZ,UAAW,EACb,CACF,CAAC,EAEK4B,EAAeC,GAAA,EAAY9B,EAAAA,OAAAA,CAAOC,EAAAA,OAAU,YAAY,EAAG,cAAc,EACzE8B,EAAUD,GAAA,EAAY9B,EAAAA,OAAAA,CAAOC,EAAAA,OAAU,OAAO,EAAG,SAAS,EAC1D+B,EAAUF,GAAA,EAAY9B,EAAAA,OAAAA,CAAOC,EAAAA,OAAU,OAAO,EAAG,SAAS,EAC1DgC,EAAYH,GAAA,EAAY9B,EAAAA,OAAAA,CAAOC,EAAAA,OAAU,SAAS,EAAG,WAAW,EAChEiC,EAAOJ,GAAA,EAAY9B,EAAAA,OAAAA,CAAOC,EAAAA,OAAU,IAAI,EAAG,MAAM,EACjDkC,EAAYL,GAAA,EAAY9B,EAAAA,OAAAA,CAAOC,EAAAA,OAAU,SAAS,EAAG,WAAW,EAChEmC,EAAiBN,GAAA,EAAY9B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AAA,KAAD,CACE,KAAK,eACL,aAAcwC,EACd,SAAU,CAAE,QAAO,YAAW,EAC9B,SAAUT,EAAM,OACL,YACX,MAAO,CAAE,OAAQ,KAAK,IAAI0B,EAAY1B,EAAM,OAAQ,GAAG,CAAE,CAC1D,CAAA,EAEDY,EAAkBZ,CAAK,CAAC,CAAC,KAAK,EAAK,IACjC2B,EAAI,QAAU,IAAA,IACZ,EAAAhD,EAAA,IAAA,CAACb,EAAAA,SAAD,CAAA,SAAqC6D,EAAI,MAAM,IAAIP,CAAY,CAAY,EAA5D,SAASQ,GAAmD,GAE3E,EAAAjD,EAAA,KAAA,CAACW,EAAD,CAAA,SAAA,EACE,EAAAX,EAAA,IAAA,CAACY,EAAD,CAAA,SAAiBoC,EAAI,KAAsB,CAAA,EAC1CA,EAAI,MAAM,IAAIP,CAAY,CAClB,CAAA,EAHK,SAASQ,GAGd,CAEf,CAEK,CAAA,CACC,CAAA,CACM,CAAA,GACpB,EAAAjD,EAAA,IAAA,CAACvB,EAAAA,OAAU,aAAX,CAAyB,CAAA,CACrB,C,EAEV,C"}
@@ -10,7 +10,7 @@ import { select as d } from "@stokelp/styled-system/recipes";
10
10
  import { Fragment as f, useRef as p } from "react";
11
11
  import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
12
12
  import { css as _ } from "@stokelp/styled-system/css";
13
- import { FixedSizeList as v } from "react-window";
13
+ import { List as v } from "react-window";
14
14
  // src/components/select/Select.tsx
15
15
  var { withProvider: y, withContext: b } = e(d), x = y(u(o.Root), "root", { defaultProps: { loopFocus: !0 } }), S = b(u(o.ClearTrigger), "clearTrigger"), C = b(u(o.Content), "content"), w = b(u(o.Control), "control"), T = b(u(o.Indicator), "indicator"), E = b(u(o.Item), "item"), D = b(u(o.ItemGroup), "itemGroup"), O = b(u(o.ItemGroupLabel), "itemGroupLabel"), k = b(u(o.ItemText), "itemText"), A = b(u(o.Positioner), "positioner"), j = b(u(o.Trigger), "trigger"), M = b(u(o.ValueText), "valueText"), N = () => /* @__PURE__ */ g("svg", {
16
16
  width: "16",
@@ -88,7 +88,27 @@ function L({ item: e, isMultiple: t, renderItem: n }) {
88
88
  children: e.label
89
89
  })] });
90
90
  }
91
- function R(e) {
91
+ function R({ index: e, style: n, ariaAttributes: i, items: a, renderItem: o }) {
92
+ let s = a[e];
93
+ return /* @__PURE__ */ h(r, {
94
+ when: !!s.tooltip,
95
+ wrapper: (e) => /* @__PURE__ */ h(t, {
96
+ label: s.tooltip,
97
+ children: e
98
+ }),
99
+ children: /* @__PURE__ */ h(E, {
100
+ item: s,
101
+ style: n,
102
+ "aria-posinset": i["aria-posinset"],
103
+ "aria-setsize": i["aria-setsize"],
104
+ children: /* @__PURE__ */ h(L, {
105
+ renderItem: o,
106
+ item: s
107
+ })
108
+ })
109
+ });
110
+ }
111
+ function z(e) {
92
112
  let t = [];
93
113
  for (let n of e) {
94
114
  let e = t[t.length - 1];
@@ -99,8 +119,8 @@ function R(e) {
99
119
  }
100
120
  return t;
101
121
  }
102
- function z({ items: e, placeholder: c, emptyLabel: l, usePortal: u = !0, positioning: d, renderItem: y, renderTrigger: b, virtualized: k, rowHeight: M = 34, ...N }) {
103
- let P = i(), z = s({ items: e }), B = p(null), V = (e) => /* @__PURE__ */ g(f, { children: [/* @__PURE__ */ h(r, {
122
+ function B({ items: e, placeholder: c, emptyLabel: l, usePortal: u = !0, positioning: d, renderItem: m, renderTrigger: y, virtualized: b, rowHeight: k = 34, ...M }) {
123
+ let N = i(), P = s({ items: e }), B = p(null), V = (e) => /* @__PURE__ */ g(f, { children: [/* @__PURE__ */ h(r, {
104
124
  when: !!e.tooltip,
105
125
  wrapper: (n) => /* @__PURE__ */ h(t, {
106
126
  label: e.tooltip,
@@ -109,9 +129,9 @@ function z({ items: e, placeholder: c, emptyLabel: l, usePortal: u = !0, positio
109
129
  children: /* @__PURE__ */ h(E, {
110
130
  item: e,
111
131
  children: /* @__PURE__ */ h(L, {
112
- renderItem: y,
132
+ renderItem: m,
113
133
  item: e,
114
- isMultiple: N.multiple
134
+ isMultiple: M.multiple
115
135
  })
116
136
  }, e.value)
117
137
  }, e.value), e.separatorAfter && /* @__PURE__ */ h("div", {
@@ -127,25 +147,25 @@ function z({ items: e, placeholder: c, emptyLabel: l, usePortal: u = !0, positio
127
147
  return /* @__PURE__ */ g(x, {
128
148
  lazyMount: !0,
129
149
  unmountOnExit: !0,
130
- collection: z,
150
+ collection: P,
131
151
  positioning: {
132
152
  sameWidth: !0,
133
153
  gutter: 0,
134
154
  ...d
135
155
  },
136
156
  "data-recipe": "select",
137
- ...N,
157
+ ...M,
138
158
  ref: (e) => {
139
159
  e && (B.current = e.closest("[role=\"dialog\"]"));
140
160
  },
141
161
  children: [
142
- /* @__PURE__ */ g(w, { children: [/* @__PURE__ */ g(j, { children: [b ? /* @__PURE__ */ h(I, {
143
- renderTrigger: b,
162
+ /* @__PURE__ */ g(w, { children: [/* @__PURE__ */ g(j, { children: [y ? /* @__PURE__ */ h(I, {
163
+ renderTrigger: y,
144
164
  placeholder: c,
145
- allSelectedLabel: N.allSelectedLabel
165
+ allSelectedLabel: M.allSelectedLabel
146
166
  }) : /* @__PURE__ */ h(F, {
147
167
  placeholder: c,
148
- allSelectedLabel: N.allSelectedLabel
168
+ allSelectedLabel: M.allSelectedLabel
149
169
  }), /* @__PURE__ */ h(T, {
150
170
  asChild: !0,
151
171
  children: /* @__PURE__ */ h("svg", {
@@ -162,7 +182,7 @@ function z({ items: e, placeholder: c, emptyLabel: l, usePortal: u = !0, positio
162
182
  })
163
183
  })
164
184
  })] }), /* @__PURE__ */ h(S, {
165
- disabled: N.readOnly,
185
+ disabled: M.readOnly,
166
186
  asChild: !0,
167
187
  children: /* @__PURE__ */ h("button", { children: /* @__PURE__ */ h("svg", {
168
188
  width: "20",
@@ -187,33 +207,23 @@ function z({ items: e, placeholder: c, emptyLabel: l, usePortal: u = !0, positio
187
207
  children: /* @__PURE__ */ h(A, { children: /* @__PURE__ */ h(C, { children: e.length === 0 ? /* @__PURE__ */ h(n, {
188
208
  px: "space-8",
189
209
  textAlign: "center",
190
- children: l ?? P.noResults
191
- }) : k ? /* @__PURE__ */ h(m, { children: /* @__PURE__ */ h(v, {
192
- height: Math.min(M * e.length, 180),
193
- itemCount: e.length,
194
- itemSize: M,
195
- width: "100%",
196
- children: ({ index: n, style: i }) => /* @__PURE__ */ h(r, {
197
- when: !!e[n].tooltip,
198
- wrapper: (r) => /* @__PURE__ */ h(t, {
199
- label: e[n].tooltip,
200
- children: r
201
- }),
202
- children: /* @__PURE__ */ h(E, {
203
- item: e[n],
204
- style: i,
205
- children: /* @__PURE__ */ h(L, {
206
- renderItem: y,
207
- item: e[n]
208
- })
209
- }, e[n].value)
210
- }, e[n].value)
211
- }) }) : R(e).map((e, t) => e.label === void 0 ? /* @__PURE__ */ h(f, { children: e.items.map(V) }, `group-${t}`) : /* @__PURE__ */ g(D, { children: [/* @__PURE__ */ h(O, { children: e.label }), e.items.map(V)] }, `group-${t}`)) }) })
210
+ children: l ?? N.noResults
211
+ }) : b ? /* @__PURE__ */ h(v, {
212
+ role: "presentation",
213
+ rowComponent: R,
214
+ rowProps: {
215
+ items: e,
216
+ renderItem: m
217
+ },
218
+ rowCount: e.length,
219
+ rowHeight: k,
220
+ style: { height: Math.min(k * e.length, 180) }
221
+ }) : z(e).map((e, t) => e.label === void 0 ? /* @__PURE__ */ h(f, { children: e.items.map(V) }, `group-${t}`) : /* @__PURE__ */ g(D, { children: [/* @__PURE__ */ h(O, { children: e.label }), e.items.map(V)] }, `group-${t}`)) }) })
212
222
  }),
213
223
  /* @__PURE__ */ h(o.HiddenSelect, {})
214
224
  ]
215
225
  });
216
226
  }
217
- export { z as Select };
227
+ export { B as Select };
218
228
 
219
229
  //# sourceMappingURL=Select.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Select.js","names":["ArkSelect","_Fragment","Select","Tooltip","Tooltip$1","Fragment$1","createStyleContext","select","Root","withProvider","styled","Select","ClearTrigger","withContext","Content","Control","Indicator","Item","ItemGroup","ItemGroupLabel","ItemText","Positioner","Trigger","ValueText","MultipleUncheckedIndicator","css","MultipleCheckedIndicator","DefaultInnerTrigger","context","useSelectContext","items","selectedItems","item","allSelectedLabel","CustomInnerTrigger","renderTrigger","CustomInnerItem","useSelectItemContext","isMultiple","renderItem","toGroupRuns","runs","current","Select$1","props","uiLabels","useUiLabels","collection","createListCollection","$dialogContent","useRef","renderOption","Fragment","ConditionalWrapper","positioning","node","usePortal","Portal","Text","emptyLabel","virtualized","FixedSizeList","rowHeight","index","run","runIndex"],"sources":["../../../src/components/select/Select.tsx"],"sourcesContent":["import {\n createListCollection,\n Portal,\n Select as ArkSelect,\n type SelectRootProps,\n useSelectItemContext,\n useSelectContext,\n} from '@ark-ui/react'\nimport { FC, Fragment, ReactNode, useRef } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\n\nimport { select } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { FixedSizeList } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(select)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkSelect.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkSelect.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkSelect.Content), 'content')\nconst Control = withContext(styled(ArkSelect.Control), 'control')\nconst Indicator = withContext(styled(ArkSelect.Indicator), 'indicator')\nconst Item = withContext(styled(ArkSelect.Item), 'item')\nconst ItemGroup = withContext(styled(ArkSelect.ItemGroup), 'itemGroup')\nconst ItemGroupLabel = withContext(styled(ArkSelect.ItemGroupLabel), 'itemGroupLabel')\nconst ItemText = withContext(styled(ArkSelect.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkSelect.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkSelect.Trigger), 'trigger')\nconst ValueText = withContext(styled(ArkSelect.ValueText), 'valueText')\n\nexport interface SelectItem {\n value: string | number\n label: string\n tooltip?: ReactNode\n disabled?: boolean\n /**\n * Renders a thin divider line after this item, separating option groups.\n * Ignored by the virtualized list (fixed row heights).\n */\n separatorAfter?: boolean\n /**\n * Heading for the group this item belongs to. Consecutive items sharing a label are\n * wrapped in one labelled group, so the heading is announced by screen readers instead\n * of being faked with a decorative row inside `renderItem`. Items without a label stay\n * ungrouped. Ignored by the virtualized list (fixed row heights).\n */\n groupLabel?: string\n}\n\nexport type SelectProps<Item extends SelectItem> = Omit<SelectRootProps<Item>, 'collection'> & {\n items: Item[] | readonly Item[]\n renderItem?: (item: Item) => ReactNode\n renderTrigger?: (item: Item) => ReactNode\n emptyLabel?: string\n placeholder?: string\n allSelectedLabel?: string\n usePortal?: boolean\n virtualized?: boolean\n rowHeight?: number\n} & HTMLStyledProps<'div'> &\n RecipeVariantProps<typeof select>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends SelectItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\ninterface InnerTriggerProps<Item extends SelectItem> {\n renderTrigger: (item: Item) => ReactNode\n placeholder?: string\n allSelectedLabel?: string\n}\n\ninterface DefaultInnerTriggerProps {\n placeholder?: string\n allSelectedLabel?: string\n}\n\nfunction DefaultInnerTrigger({ placeholder, allSelectedLabel }: DefaultInnerTriggerProps) {\n const context = useSelectContext()\n const items = context.collection.items\n const selectedItems = context.selectedItems\n\n if (\n context.multiple &&\n selectedItems.filter(item => !item.disabled).length >= items.filter(item => !item.disabled).length &&\n allSelectedLabel\n ) {\n return (\n <ValueText className=\"custom\" truncate>\n {allSelectedLabel}\n </ValueText>\n )\n }\n\n return <ValueText truncate placeholder={placeholder} />\n}\n\nfunction CustomInnerTrigger<Item extends SelectItem>({\n renderTrigger,\n placeholder,\n allSelectedLabel,\n}: InnerTriggerProps<Item>) {\n const context = useSelectContext()\n const items = context.value && context.value.length > 0 ? context.collection.findMany(context.value) : []\n\n if (items.length === 0) {\n return <ValueText className=\"custom\" truncate placeholder={placeholder} />\n }\n\n const selectedItems = context.selectedItems\n\n if (\n context.multiple &&\n selectedItems.filter(item => !item.disabled).length >=\n context.collection.items.filter(item => !item.disabled).length &&\n allSelectedLabel\n ) {\n return (\n <ValueText className=\"custom\" truncate>\n {allSelectedLabel}\n </ValueText>\n )\n }\n\n return (\n <ValueText className=\"custom\" placeholder={placeholder}>\n {items.map(item => (\n <span key={item.value}>{renderTrigger(item)}</span>\n ))}\n </ValueText>\n )\n}\n\nfunction CustomInnerItem<Item extends SelectItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useSelectItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\n/**\n * Splits the flat item list into consecutive runs sharing a `groupLabel`. Runs are built\n * from adjacency rather than by collecting every item with the same label, so the caller\n * keeps full control of the order: sorting is the caller's business, grouping is ours.\n */\nfunction toGroupRuns<Item extends SelectItem>(items: readonly Item[]) {\n const runs: Array<{ label?: string; items: Item[] }> = []\n\n for (const item of items) {\n const current = runs[runs.length - 1]\n if (current && current.label === item.groupLabel) {\n current.items.push(item)\n continue\n }\n runs.push({ label: item.groupLabel, items: [item] })\n }\n\n return runs\n}\n\nexport function Select<Item extends SelectItem>({\n items,\n placeholder,\n emptyLabel,\n usePortal = true,\n positioning,\n renderItem,\n renderTrigger,\n virtualized,\n rowHeight = 34,\n ...props\n}: SelectProps<Item>) {\n const uiLabels = useUiLabels()\n const collection = createListCollection({\n items,\n })\n const $dialogContent = useRef<HTMLDivElement | null>(null)\n\n const renderOption = (item: Item) => (\n <Fragment key={item.value}>\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={item}>\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={props.multiple} />\n </Item>\n </ConditionalWrapper>\n {item.separatorAfter && (\n <div\n role=\"separator\"\n className={css({\n height: '1px',\n flexShrink: 0,\n backgroundColor: 'grey.100',\n marginY: 'space-4',\n marginX: 'space-8',\n })}\n />\n )}\n </Fragment>\n )\n\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"select\"\n {...props}\n ref={(node: HTMLDivElement | null) => {\n if (node) {\n $dialogContent.current = node.closest('[role=\"dialog\"]') as HTMLDivElement | null\n }\n }}\n >\n <Control>\n <Trigger>\n {renderTrigger ? (\n <CustomInnerTrigger\n renderTrigger={renderTrigger}\n placeholder={placeholder}\n allSelectedLabel={props.allSelectedLabel}\n />\n ) : (\n <DefaultInnerTrigger placeholder={placeholder} allSelectedLabel={props.allSelectedLabel} />\n )}\n <Indicator asChild>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Indicator>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal container={$dialogContent}>{children}</Portal>}>\n <Positioner>\n <Content>\n {items.length === 0 ? (\n <Text px=\"space-8\" textAlign=\"center\">\n {emptyLabel ?? uiLabels.noResults}\n </Text>\n ) : virtualized ? (\n <>\n <FixedSizeList\n height={Math.min(rowHeight * items.length, 180)}\n itemCount={items.length}\n itemSize={rowHeight}\n width=\"100%\"\n >\n {({ index, style }) => (\n <ConditionalWrapper\n key={items[index].value}\n when={!!items[index].tooltip}\n wrapper={children => <Tooltip label={items[index].tooltip}>{children}</Tooltip>}\n >\n <Item key={items[index].value} item={items[index]} style={style}>\n <CustomInnerItem renderItem={renderItem} item={items[index]} />\n </Item>\n </ConditionalWrapper>\n )}\n </FixedSizeList>\n </>\n ) : (\n toGroupRuns<Item>(items).map((run, runIndex) =>\n run.label === undefined ? (\n <Fragment key={`group-${runIndex}`}>{run.items.map(renderOption)}</Fragment>\n ) : (\n <ItemGroup key={`group-${runIndex}`}>\n <ItemGroupLabel>{run.label}</ItemGroupLabel>\n {run.items.map(renderOption)}\n </ItemGroup>\n ),\n )\n )}\n </Content>\n </Positioner>\n </ConditionalWrapper>\n <ArkSelect.HiddenSelect />\n </Root>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,IAAM,EAAE,iBAAc,mBAAgBM,EAAmBC,CAAM,GAGzDC,IAAOC,EAAaC,EAAOV,EAAU,IAAS,GAAG,QAAQ,EAC7D,cAAc,EACZ,W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AA,EAAA,UACE,kBAAC4D,GAAD;KACE,QAAQ,KAAK,IAAIC,IAAYhC,EAAM,QAAQ,GAAG;KAC9C,WAAWA,EAAM;KACjB,UAAUgC;KACV,OAAM;KAEJ,WAAA,EAAE,UAAO,eACT,kBAACT,GAAD;MAEE,MAAM,CAAC,CAACvB,EAAMiC,EAAM,CAAC;MACrB,UAAS,MAAY,kBAAC5D,GAAD;OAAS,OAAO2B,EAAMiC,EAAM,CAAC;OAAU;MAAkB,CAAA;MAE9E,UAAA,kBAAC9C,GAAD;OAA+B,MAAMa,EAAMiC;OAAe;OACxD,UAAA,kBAAC3B,GAAD;QAA6B;QAAY,MAAMN,EAAMiC;OAAS,CAAA;MAC1D,GAFKjC,EAAMiC,EAAM,CAAC,KAElB;KACY,GAPbjC,EAAMiC,EAAM,CAAC,KAOA;IAET,CAAA,EACf,CAAA,IAEFvB,EAAkBV,CAAK,CAAC,CAAC,KAAK,GAAK,MACjCkC,EAAI,UAAU,KAAA,IACZ,kBAACZ,GAAD,EAAA,UAAqCY,EAAI,MAAM,IAAIb,CAAY,EAAY,GAA5D,SAASc,GAAmD,IAE3E,kBAAC/C,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAiB6C,EAAI,MAAsB,CAAA,GAC1CA,EAAI,MAAM,IAAIb,CAAY,CAClB,EAAA,GAHK,SAASc,GAGd,CAEf,EAEK,CAAA,EACC,CAAA;GACM,CAAA;GACpB,kBAACjE,EAAU,cAAX,CAAyB,CAAA;EACrB;;AAEV"}
1
+ {"version":3,"file":"Select.js","names":["ArkSelect","_Fragment","Tooltip","Select","Tooltip$1","Fragment$1","createStyleContext","select","Root","withProvider","styled","Select","ClearTrigger","withContext","Content","Control","Indicator","Item","ItemGroup","ItemGroupLabel","ItemText","Positioner","Trigger","ValueText","MultipleUncheckedIndicator","css","MultipleCheckedIndicator","DefaultInnerTrigger","context","useSelectContext","items","selectedItems","item","allSelectedLabel","CustomInnerTrigger","renderTrigger","CustomInnerItem","useSelectItemContext","isMultiple","renderItem","VirtualRow","index","ConditionalWrapper","ariaAttributes","toGroupRuns","runs","current","Select$1","props","uiLabels","useUiLabels","collection","createListCollection","$dialogContent","useRef","renderOption","Fragment","positioning","node","usePortal","Portal","Text","emptyLabel","virtualized","List","rowHeight","run","runIndex"],"sources":["../../../src/components/select/Select.tsx"],"sourcesContent":["import {\n createListCollection,\n Portal,\n Select as ArkSelect,\n type SelectRootProps,\n useSelectItemContext,\n useSelectContext,\n} from '@ark-ui/react'\nimport { FC, Fragment, ReactNode, useRef } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\n\nimport { select } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { List, type RowComponentProps } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(select)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkSelect.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkSelect.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkSelect.Content), 'content')\nconst Control = withContext(styled(ArkSelect.Control), 'control')\nconst Indicator = withContext(styled(ArkSelect.Indicator), 'indicator')\nconst Item = withContext(styled(ArkSelect.Item), 'item')\nconst ItemGroup = withContext(styled(ArkSelect.ItemGroup), 'itemGroup')\nconst ItemGroupLabel = withContext(styled(ArkSelect.ItemGroupLabel), 'itemGroupLabel')\nconst ItemText = withContext(styled(ArkSelect.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkSelect.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkSelect.Trigger), 'trigger')\nconst ValueText = withContext(styled(ArkSelect.ValueText), 'valueText')\n\nexport interface SelectItem {\n value: string | number\n label: string\n tooltip?: ReactNode\n disabled?: boolean\n /**\n * Renders a thin divider line after this item, separating option groups.\n * Ignored by the virtualized list (fixed row heights).\n */\n separatorAfter?: boolean\n /**\n * Heading for the group this item belongs to. Consecutive items sharing a label are\n * wrapped in one labelled group, so the heading is announced by screen readers instead\n * of being faked with a decorative row inside `renderItem`. Items without a label stay\n * ungrouped. Ignored by the virtualized list (fixed row heights).\n */\n groupLabel?: string\n}\n\nexport type SelectProps<Item extends SelectItem> = Omit<SelectRootProps<Item>, 'collection'> & {\n items: Item[] | readonly Item[]\n renderItem?: (item: Item) => ReactNode\n renderTrigger?: (item: Item) => ReactNode\n emptyLabel?: string\n placeholder?: string\n allSelectedLabel?: string\n usePortal?: boolean\n virtualized?: boolean\n rowHeight?: number\n} & HTMLStyledProps<'div'> &\n RecipeVariantProps<typeof select>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends SelectItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\ninterface InnerTriggerProps<Item extends SelectItem> {\n renderTrigger: (item: Item) => ReactNode\n placeholder?: string\n allSelectedLabel?: string\n}\n\ninterface DefaultInnerTriggerProps {\n placeholder?: string\n allSelectedLabel?: string\n}\n\nfunction DefaultInnerTrigger({ placeholder, allSelectedLabel }: DefaultInnerTriggerProps) {\n const context = useSelectContext()\n const items = context.collection.items\n const selectedItems = context.selectedItems\n\n if (\n context.multiple &&\n selectedItems.filter(item => !item.disabled).length >= items.filter(item => !item.disabled).length &&\n allSelectedLabel\n ) {\n return (\n <ValueText className=\"custom\" truncate>\n {allSelectedLabel}\n </ValueText>\n )\n }\n\n return <ValueText truncate placeholder={placeholder} />\n}\n\nfunction CustomInnerTrigger<Item extends SelectItem>({\n renderTrigger,\n placeholder,\n allSelectedLabel,\n}: InnerTriggerProps<Item>) {\n const context = useSelectContext()\n const items = context.value && context.value.length > 0 ? context.collection.findMany(context.value) : []\n\n if (items.length === 0) {\n return <ValueText className=\"custom\" truncate placeholder={placeholder} />\n }\n\n const selectedItems = context.selectedItems\n\n if (\n context.multiple &&\n selectedItems.filter(item => !item.disabled).length >=\n context.collection.items.filter(item => !item.disabled).length &&\n allSelectedLabel\n ) {\n return (\n <ValueText className=\"custom\" truncate>\n {allSelectedLabel}\n </ValueText>\n )\n }\n\n return (\n <ValueText className=\"custom\" placeholder={placeholder}>\n {items.map(item => (\n <span key={item.value}>{renderTrigger(item)}</span>\n ))}\n </ValueText>\n )\n}\n\nfunction CustomInnerItem<Item extends SelectItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useSelectItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\ninterface VirtualRowProps<Item extends SelectItem> {\n items: readonly Item[]\n renderItem?: (item: Item) => ReactNode\n}\n\n// Declared at module level: react-window memoizes the row component by identity, so a\n// component created during render would remount every visible row on each render.\nfunction VirtualRow<Item extends SelectItem>({\n index,\n style,\n ariaAttributes,\n items,\n renderItem,\n}: RowComponentProps<VirtualRowProps<Item>>) {\n const item = items[index]\n\n return (\n <ConditionalWrapper when={!!item.tooltip} wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}>\n {/* Only the position attributes: the option keeps its role from Ark, not react-window's listitem. */}\n <Item\n item={item}\n style={style}\n aria-posinset={ariaAttributes['aria-posinset']}\n aria-setsize={ariaAttributes['aria-setsize']}\n >\n <CustomInnerItem renderItem={renderItem} item={item} />\n </Item>\n </ConditionalWrapper>\n )\n}\n\n/**\n * Splits the flat item list into consecutive runs sharing a `groupLabel`. Runs are built\n * from adjacency rather than by collecting every item with the same label, so the caller\n * keeps full control of the order: sorting is the caller's business, grouping is ours.\n */\nfunction toGroupRuns<Item extends SelectItem>(items: readonly Item[]) {\n const runs: Array<{ label?: string; items: Item[] }> = []\n\n for (const item of items) {\n const current = runs[runs.length - 1]\n if (current && current.label === item.groupLabel) {\n current.items.push(item)\n continue\n }\n runs.push({ label: item.groupLabel, items: [item] })\n }\n\n return runs\n}\n\nexport function Select<Item extends SelectItem>({\n items,\n placeholder,\n emptyLabel,\n usePortal = true,\n positioning,\n renderItem,\n renderTrigger,\n virtualized,\n rowHeight = 34,\n ...props\n}: SelectProps<Item>) {\n const uiLabels = useUiLabels()\n const collection = createListCollection({\n items,\n })\n const $dialogContent = useRef<HTMLDivElement | null>(null)\n\n const renderOption = (item: Item) => (\n <Fragment key={item.value}>\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={item}>\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={props.multiple} />\n </Item>\n </ConditionalWrapper>\n {item.separatorAfter && (\n <div\n role=\"separator\"\n className={css({\n height: '1px',\n flexShrink: 0,\n backgroundColor: 'grey.100',\n marginY: 'space-4',\n marginX: 'space-8',\n })}\n />\n )}\n </Fragment>\n )\n\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"select\"\n {...props}\n ref={(node: HTMLDivElement | null) => {\n if (node) {\n $dialogContent.current = node.closest('[role=\"dialog\"]') as HTMLDivElement | null\n }\n }}\n >\n <Control>\n <Trigger>\n {renderTrigger ? (\n <CustomInnerTrigger\n renderTrigger={renderTrigger}\n placeholder={placeholder}\n allSelectedLabel={props.allSelectedLabel}\n />\n ) : (\n <DefaultInnerTrigger placeholder={placeholder} allSelectedLabel={props.allSelectedLabel} />\n )}\n <Indicator asChild>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Indicator>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal container={$dialogContent}>{children}</Portal>}>\n <Positioner>\n <Content>\n {items.length === 0 ? (\n <Text px=\"space-8\" textAlign=\"center\">\n {emptyLabel ?? uiLabels.noResults}\n </Text>\n ) : virtualized ? (\n // role=\"presentation\" overrides the list's own role=\"list\": the options must stay\n // owned by the listbox.\n <List\n role=\"presentation\"\n rowComponent={VirtualRow<Item>}\n rowProps={{ items, renderItem }}\n rowCount={items.length}\n rowHeight={rowHeight}\n style={{ height: Math.min(rowHeight * items.length, 180) }}\n />\n ) : (\n toGroupRuns<Item>(items).map((run, runIndex) =>\n run.label === undefined ? (\n <Fragment key={`group-${runIndex}`}>{run.items.map(renderOption)}</Fragment>\n ) : (\n <ItemGroup key={`group-${runIndex}`}>\n <ItemGroupLabel>{run.label}</ItemGroupLabel>\n {run.items.map(renderOption)}\n </ItemGroup>\n ),\n )\n )}\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version": "3.0.1",
3
+ "version": "4.0.0",
4
4
  "description": "Stokelp UI React",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -73,7 +73,7 @@
73
73
  "@heroicons/react": "^2.2.0",
74
74
  "@pandacss/dev": "^2.0.0",
75
75
  "react": "^19.2.0",
76
- "react-window": "^1.8.11"
76
+ "react-window": "^2.5.1"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@chromatic-com/storybook": "^5.3.1",
@@ -85,7 +85,6 @@
85
85
  "@storybook/react-vite": "^10.6.0",
86
86
  "@types/react": "^19.2.14",
87
87
  "@types/react-is": "^19.2.0",
88
- "@types/react-window": "^1.8.8",
89
88
  "@vitejs/plugin-react": "^6.0.2",
90
89
  "deepmerge": "^4.3.1",
91
90
  "prop-types": "^15.8.1",