@stokelp/ui 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,3 @@
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;
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"),ee=require("react-window"),p=require("@zag-js/utils");var{withProvider:m,withContext:h}=e.createStyleContext(l.combobox),g=m((0,c.styled)(s.Combobox.Root),`root`,{defaultProps:{loopFocus:!0}}),te=h((0,c.styled)(s.Combobox.ClearTrigger),`clearTrigger`),ne=h((0,c.styled)(s.Combobox.Content),`content`),_=h((0,c.styled)(s.Combobox.Input),`input`),v=h((0,c.styled)(s.Combobox.Control),`control`),y=h((0,c.styled)(s.Combobox.Item),`item`),b=h((0,c.styled)(s.Combobox.ItemText),`itemText`),re=h((0,c.styled)(s.Combobox.Positioner),`positioner`),x=h((0,c.styled)(s.Combobox.Trigger),`trigger`),S=()=>(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`})})]}),C=()=>(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 w({item:e,isMultiple:t,renderItem:n}){let r=(0,s.useComboboxItemContext)();return(0,d.jsxs)(d.Fragment,{children:[t?r.selected?(0,d.jsx)(C,{}):(0,d.jsx)(S,{}):null,n?n(e):(0,d.jsx)(b,{truncate:!0,children:e.label})]})}function ie({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)(y,{item:c,style:n,"aria-posinset":i[`aria-posinset`],"aria-setsize":i[`aria-setsize`],children:(0,d.jsx)(w,{renderItem:s,item:c,isMultiple:o})})})}var T=({items:e=[],initialItems:c,debounceMs:l=0,placeholder:f,emptyLabel:m,loadingLabel:h,usePortal:b=!0,withAutoFilter:S=!0,positioning:C,loadItems:T,renderItem:E,renderValue:D,onResetInitialItems:O,isLoading:k,value:A,defaultValue:j,openDropdownOnFocus:M=!0,clearValueWhenEmpty:ae=!0,virtualized:oe,rowHeight:N=34,returnItemsOnEmpty:P,multiple:F=!1,onInputValueChange:se,...I})=>{let L=i.useUiLabels(),[R,z]=(0,u.useState)(()=>e),[B,V]=(0,u.useState)(!1),[H,U]=(0,u.useState)(!1),[W,G]=(0,u.useState)(``),K=typeof T==`function`,q=(0,u.useMemo)(()=>T?(0,p.debounce)(async e=>{try{U(!0),V(!0);let t=await T(e);z(t)}catch(e){console.error(e),z([])}finally{V(!1)}},l):null,[T,l]),ce=(0,u.useMemo)(()=>{if(!S||W===``)return e;let t=W.toLowerCase(),n=e.filter(e=>e.label.toLowerCase().includes(t));return n.length===0&&P?e:n},[e,S,W,P]),J=K?R:ce,Y=(0,u.useMemo)(()=>[...J,...c??[]],[J,c]),X=A?.map(String).join(`
2
+ `),[Z,le]=(0,u.useState)(X);if(X!==Z){le(X);let e=new Set(Y.map(e=>String(e.value)));!K&&W!==``&&A?.some(t=>!e.has(String(t)))&&G(``)}let ue=e=>{c&&c.length>0&&!c.find(t=>t.label===e.inputValue)&&O?.(),q?q(e.inputValue):S&&G(e.inputValue),se?.(e)},de=(0,u.useMemo)(()=>(0,s.createListCollection)({items:Y}),[Y]),fe=k??B,Q=h??(0,d.jsx)(n.Text,{p:`space-8`,textAlign:`center`,children:L.loading}),$=m??(0,d.jsx)(n.Text,{p:`space-8`,textAlign:`center`,children:L.noResults});return(0,d.jsxs)(g,{lazyMount:!0,unmountOnExit:!0,collection:de,positioning:{sameWidth:!0,gutter:0,...C},"data-recipe":`combobox`,onInputValueChange:ue,value:A,defaultValue:j,...I,multiple:F,children:[F?(0,d.jsx)(s.Combobox.Context,{children:t=>(0,d.jsxs)(v,{"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:[D?D(r):(0,d.jsx)(o.ChipLabel,{children:r.label}),!I.readOnly&&!I.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)(_,{asChild:!0,"data-multiple":`true`,placeholder:t.hasSelectedItems?void 0:f,onFocus:()=>{M&&!K&&t.setOpen(!0)},children:(0,d.jsx)(a.Input,{})}),(0,d.jsx)(x,{asChild:!0,hidden:K&&(!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)(v,{children:[(0,d.jsx)(s.Combobox.Context,{children:e=>(0,d.jsx)(_,{asChild:!0,placeholder:f,onInput:t=>{let n=t.currentTarget.value;ae&&n===``&&e.clearValue()},onFocus:()=>{M&&!K&&e.setOpen(!0)},children:(0,d.jsx)(a.Input,{})})}),(0,d.jsx)(x,{asChild:!0,hidden:K&&(!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)(te,{disabled:I.readOnly,onClick:O,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:b,wrapper:e=>(0,d.jsx)(s.Portal,{children:e}),children:(0,d.jsx)(re,{children:(0,d.jsx)(ne,{children:fe?Q:Y.length===0?(0,d.jsx)(d.Fragment,{children:K?H?$:Q:$}):oe?(0,d.jsx)(ee.List,{role:`presentation`,rowComponent:ie,rowProps:{items:Y,isMultiple:F,renderItem:E},rowCount:Y.length,rowHeight:N,style:{height:Math.min(N*Y.length,180)}}):Y.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)(y,{item:e,children:(0,d.jsx)(w,{renderItem:E,item:e,isMultiple:F})},e.value)},e.value))})})})]})};exports.Combobox=T;
2
3
  //# sourceMappingURL=Combobox.cjs.map
@@ -1 +1 @@
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,E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B,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","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","loadedItems","setLoadedItems","isLoading","setIsLoading","firstQueryTriggered","setFirstQueryTriggered","filterText","setFilterText","asyncMode","loadItems","debouncedLoadItems","newItems","value","error","debounceMs","filteredItems","withAutoFilter","text","matching","returnItemsOnEmpty","sourceItems","allItems","initialItems","valueKey","valueKeyOfFilter","setValueKeyOfFilter","listed","v","handleInputChange","details","onResetInitialItems","onInputValueChange","collection","effectiveIsLoading","loadingContent","loadingLabel","emptyContent","emptyLabel","positioning","multiple","api","i","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, 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 onInputValueChange,\n ...props\n}: ComboboxProps<T>) => {\n const uiLabels = useUiLabels()\n // With `loadItems`, the list is what it returned last; the `items` prop only seeds it.\n const [loadedItems, setLoadedItems] = useState(() => itemsFromUsers)\n const [isLoading, setIsLoading] = useState(false)\n const [firstQueryTriggered, setFirstQueryTriggered] = useState(false)\n // Without `loadItems`, the text the list is filtered on: the input's, as zag reports it.\n const [filterText, setFilterText] = useState('')\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 setLoadedItems(newItems)\n } catch (error) {\n console.error(error)\n setLoadedItems([])\n } finally {\n setIsLoading(false)\n }\n }, debounceMs)\n : null,\n [loadItems, debounceMs],\n )\n\n // The list is derived from the `items` of this very render, never mirrored into state: zag\n // re-derives the input text from the collection as soon as `value` changes, so a value set in\n // the same render as the item that carries it must find that item in the collection already.\n // A mirror caught up one render late, and the input went blank.\n const filteredItems = useMemo(() => {\n if (!withAutoFilter || filterText === '') return itemsFromUsers\n const text = filterText.toLowerCase()\n const matching = itemsFromUsers.filter((item: ComboboxItem) => item.label.toLowerCase().includes(text))\n return matching.length === 0 && returnItemsOnEmpty ? itemsFromUsers : matching\n }, [itemsFromUsers, withAutoFilter, filterText, returnItemsOnEmpty])\n\n const sourceItems = asyncMode ? loadedItems : filteredItems\n const allItems = useMemo(() => [...sourceItems, ...(initialItems ?? [])], [sourceItems, initialItems])\n\n // A new `value` the typed text filters out (an item created from the empty state under\n // another name, a value the app sets) would still be stringified to nothing: drop the\n // filter for that render. zag then writes the label in the input, and the filter follows it.\n const valueKey = value?.map(String).join('\\n')\n const [valueKeyOfFilter, setValueKeyOfFilter] = useState(valueKey)\n if (valueKey !== valueKeyOfFilter) {\n setValueKeyOfFilter(valueKey)\n const listed = new Set(allItems.map(item => String(item.value)))\n if (!asyncMode && filterText !== '' && value?.some(v => !listed.has(String(v)))) {\n setFilterText('')\n }\n }\n\n // A caller's onInputValueChange runs as well: it no longer replaces the filter.\n const handleInputChange = (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\n if (debouncedLoadItems) {\n debouncedLoadItems(details.inputValue)\n } else if (withAutoFilter) {\n setFilterText(details.inputValue)\n }\n onInputValueChange?.(details)\n }\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} is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AAX,EAAA,IAAA,CAACiB,EAAD,CAA6B,aAAkB,OAAM,WAAYqD,CAAW,CAAA,CACxE,EAFKjD,EAAK,KAEV,CACY,EAPbA,EAAK,KAOQ,CACrB,CAEI,CAAA,CACC,CAAA,CACM,CAAA,CAChB,C,EAEV,E"}
@@ -35,4 +35,4 @@ export type ComboboxProps<T extends ComboboxItem> = Omit<ComboboxRootProps<T>, '
35
35
  rowHeight?: number;
36
36
  returnItemsOnEmpty?: boolean;
37
37
  } & Omit<HTMLStyledProps<'div'>, 'defaultValue'> & RecipeVariantProps<typeof combobox>;
38
- export declare const Combobox: <T extends ComboboxItem>({ items: itemsFromUsers, initialItems, debounceMs, placeholder, emptyLabel, loadingLabel, usePortal, withAutoFilter, positioning, loadItems, renderItem, renderValue, onResetInitialItems, isLoading: controlledIsLoading, value, defaultValue, openDropdownOnFocus, clearValueWhenEmpty, virtualized, rowHeight, returnItemsOnEmpty, multiple, ...props }: ComboboxProps<T>) => import('react').JSX.Element;
38
+ export declare const Combobox: <T extends ComboboxItem>({ items: itemsFromUsers, initialItems, debounceMs, placeholder, emptyLabel, loadingLabel, usePortal, withAutoFilter, positioning, loadItems, renderItem, renderValue, onResetInitialItems, isLoading: controlledIsLoading, value, defaultValue, openDropdownOnFocus, clearValueWhenEmpty, virtualized, rowHeight, returnItemsOnEmpty, multiple, onInputValueChange, ...props }: ComboboxProps<T>) => import('react').JSX.Element;
@@ -6,16 +6,16 @@ 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
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";
9
+ import { Combobox as l, Portal as u, createListCollection as ee, useComboboxItemContext as d } from "@ark-ui/react";
10
10
  import { styled as f } from "@stokelp/styled-system/jsx";
11
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";
12
+ import { useMemo as m, useState as h } from "react";
13
13
  import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
14
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";
15
+ import { List as te } from "react-window";
16
+ import { debounce as ne } from "@zag-js/utils";
17
17
  // src/components/combobox/Combobox.tsx
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", {
18
+ var { withProvider: b, withContext: x } = e(p), re = b(f(l.Root), "root", { defaultProps: { loopFocus: !0 } }), ie = x(f(l.ClearTrigger), "clearTrigger"), ae = x(f(l.Content), "content"), S = x(f(l.Input), "input"), C = x(f(l.Control), "control"), w = x(f(l.Item), "item"), T = x(f(l.ItemText), "itemText"), oe = x(f(l.Positioner), "positioner"), E = x(f(l.Trigger), "trigger"), D = () => /* @__PURE__ */ v("svg", {
19
19
  width: "16",
20
20
  height: "17",
21
21
  viewBox: "0 0 16 17",
@@ -36,7 +36,7 @@ var { withProvider: x, withContext: S } = e(p), C = x(f(l.Root), "root", { defau
36
36
  rx: "3.5",
37
37
  className: y({ stroke: "grey.100" })
38
38
  })]
39
- }), N = () => /* @__PURE__ */ v("svg", {
39
+ }), O = () => /* @__PURE__ */ v("svg", {
40
40
  width: "16",
41
41
  height: "17",
42
42
  viewBox: "0 0 16 17",
@@ -55,14 +55,14 @@ var { withProvider: x, withContext: S } = e(p), C = x(f(l.Root), "root", { defau
55
55
  fill: "white"
56
56
  })]
57
57
  });
58
- function P({ item: e, isMultiple: t, renderItem: n }) {
58
+ function k({ item: e, isMultiple: t, renderItem: n }) {
59
59
  let r = d();
60
- return /* @__PURE__ */ v(g, { children: [t ? r.selected ? /* @__PURE__ */ _(N, {}) : /* @__PURE__ */ _(M, {}) : null, n ? n(e) : /* @__PURE__ */ _(k, {
60
+ return /* @__PURE__ */ v(g, { children: [t ? r.selected ? /* @__PURE__ */ _(O, {}) : /* @__PURE__ */ _(D, {}) : null, n ? n(e) : /* @__PURE__ */ _(T, {
61
61
  truncate: !0,
62
62
  children: e.label
63
63
  })] });
64
64
  }
65
- function F({ index: e, style: n, ariaAttributes: i, items: a, isMultiple: o, renderItem: s }) {
65
+ function se({ index: e, style: n, ariaAttributes: i, items: a, isMultiple: o, renderItem: s }) {
66
66
  let c = a[e];
67
67
  return /* @__PURE__ */ _(r, {
68
68
  when: !!c.tooltip,
@@ -70,12 +70,12 @@ function F({ index: e, style: n, ariaAttributes: i, items: a, isMultiple: o, ren
70
70
  label: c.tooltip,
71
71
  children: e
72
72
  }),
73
- children: /* @__PURE__ */ _(O, {
73
+ children: /* @__PURE__ */ _(w, {
74
74
  item: c,
75
75
  style: n,
76
76
  "aria-posinset": i["aria-posinset"],
77
77
  "aria-setsize": i["aria-setsize"],
78
- children: /* @__PURE__ */ _(P, {
78
+ children: /* @__PURE__ */ _(k, {
79
79
  renderItem: s,
80
80
  item: c,
81
81
  isMultiple: o
@@ -83,59 +83,59 @@ function F({ index: e, style: n, ariaAttributes: i, items: a, isMultiple: o, ren
83
83
  })
84
84
  });
85
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) => {
86
+ var A = ({ items: e = [], initialItems: d, debounceMs: f = 0, placeholder: p, emptyLabel: y, loadingLabel: b, usePortal: x = !0, withAutoFilter: T = !0, positioning: D, loadItems: O, renderItem: A, renderValue: j, onResetInitialItems: M, isLoading: N, value: P, defaultValue: ce, openDropdownOnFocus: F = !0, clearValueWhenEmpty: le = !0, virtualized: ue, rowHeight: I = 34, returnItemsOnEmpty: L, multiple: R = !1, onInputValueChange: z, ...B }) => {
87
+ let V = i(), [H, U] = h(() => e), [de, W] = h(!1), [fe, pe] = h(!1), [G, K] = h(""), q = typeof O == "function", J = m(() => O ? ne(async (e) => {
88
88
  try {
89
- ue(!0), J(!0);
90
- let t = await N(e);
91
- q(t);
89
+ pe(!0), W(!0);
90
+ let t = await O(e);
91
+ U(t);
92
92
  } catch (e) {
93
- console.error(e), q([]);
93
+ console.error(e), U([]);
94
94
  } finally {
95
- J(!1);
96
- }
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?.();
99
- let { inputValue: n } = t;
100
- if (X) X(n);
101
- else {
102
- let t = k && n !== "" ? e.filter((e) => e.label.toLowerCase().includes(n.toLowerCase())) : e;
103
- if (t.length === 0 && U) return q(e);
104
- q(t);
95
+ W(!1);
105
96
  }
97
+ }, f) : null, [O, f]), me = m(() => {
98
+ if (!T || G === "") return e;
99
+ let t = G.toLowerCase(), n = e.filter((e) => e.label.toLowerCase().includes(t));
100
+ return n.length === 0 && L ? e : n;
106
101
  }, [
107
- X,
108
102
  e,
109
- k
110
- ]);
111
- ne(() => {
112
- X || q(e);
113
- }, [e, X]);
114
- let fe = m(() => u({ items: Z }), [Z]), pe = ie ?? ce, Q = x ?? /* @__PURE__ */ _(n, {
103
+ T,
104
+ G,
105
+ L
106
+ ]), Y = q ? H : me, X = m(() => [...Y, ...d ?? []], [Y, d]), Z = P?.map(String).join("\n"), [he, ge] = h(Z);
107
+ if (Z !== he) {
108
+ ge(Z);
109
+ let e = new Set(X.map((e) => String(e.value)));
110
+ !q && G !== "" && P?.some((t) => !e.has(String(t))) && K("");
111
+ }
112
+ let _e = (e) => {
113
+ d && d.length > 0 && !d.find((t) => t.label === e.inputValue) && M?.(), J ? J(e.inputValue) : T && K(e.inputValue), z?.(e);
114
+ }, ve = m(() => ee({ items: X }), [X]), ye = N ?? de, Q = b ?? /* @__PURE__ */ _(n, {
115
115
  p: "space-8",
116
116
  textAlign: "center",
117
- children: K.loading
117
+ children: V.loading
118
118
  }), $ = y ?? /* @__PURE__ */ _(n, {
119
119
  p: "space-8",
120
120
  textAlign: "center",
121
- children: K.noResults
121
+ children: V.noResults
122
122
  });
123
- return /* @__PURE__ */ v(C, {
123
+ return /* @__PURE__ */ v(re, {
124
124
  lazyMount: !0,
125
125
  unmountOnExit: !0,
126
- collection: fe,
126
+ collection: ve,
127
127
  positioning: {
128
128
  sameWidth: !0,
129
129
  gutter: 0,
130
- ...M
130
+ ...D
131
131
  },
132
132
  "data-recipe": "combobox",
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, {
133
+ onInputValueChange: _e,
134
+ value: P,
135
+ defaultValue: ce,
136
+ ...B,
137
+ multiple: R,
138
+ children: [R ? /* @__PURE__ */ _(l.Context, { children: (t) => /* @__PURE__ */ v(C, {
139
139
  "data-multiple": "true",
140
140
  "data-open": t.open || void 0,
141
141
  children: [
@@ -143,24 +143,24 @@ var I = ({ items: e = [], initialItems: d, debounceMs: f = 0, placeholder: p, em
143
143
  let r = e.find((e) => String(e.value) === String(n));
144
144
  return r ? /* @__PURE__ */ v(o, {
145
145
  size: "sm",
146
- children: [L ? L(r) : /* @__PURE__ */ _(c, { children: r.label }), !G.readOnly && !G.disabled && /* @__PURE__ */ _(s, {
146
+ children: [j ? j(r) : /* @__PURE__ */ _(c, { children: r.label }), !B.readOnly && !B.disabled && /* @__PURE__ */ _(s, {
147
147
  "aria-label": `Retirer ${r.label}`,
148
148
  onClick: () => t.setValue(t.value.filter((e) => String(e) !== String(n)))
149
149
  })]
150
150
  }, n) : null;
151
151
  }),
152
- /* @__PURE__ */ _(E, {
152
+ /* @__PURE__ */ _(S, {
153
153
  asChild: !0,
154
154
  "data-multiple": "true",
155
155
  placeholder: t.hasSelectedItems ? void 0 : p,
156
156
  onFocus: () => {
157
- z && !Y && t.setOpen(!0);
157
+ F && !q && t.setOpen(!0);
158
158
  },
159
159
  children: /* @__PURE__ */ _(a, {})
160
160
  }),
161
- /* @__PURE__ */ _(j, {
161
+ /* @__PURE__ */ _(E, {
162
162
  asChild: !0,
163
- hidden: Y && (!d || d.length === 0),
163
+ hidden: q && (!d || d.length === 0),
164
164
  children: /* @__PURE__ */ _("svg", {
165
165
  width: "24",
166
166
  height: "24",
@@ -176,22 +176,22 @@ var I = ({ items: e = [], initialItems: d, debounceMs: f = 0, placeholder: p, em
176
176
  })
177
177
  })
178
178
  ]
179
- }) }) : /* @__PURE__ */ v(D, { children: [
180
- /* @__PURE__ */ _(l.Context, { children: (e) => /* @__PURE__ */ _(E, {
179
+ }) }) : /* @__PURE__ */ v(C, { children: [
180
+ /* @__PURE__ */ _(l.Context, { children: (e) => /* @__PURE__ */ _(S, {
181
181
  asChild: !0,
182
182
  placeholder: p,
183
183
  onInput: (t) => {
184
184
  let n = t.currentTarget.value;
185
- B && n === "" && e.clearValue();
185
+ le && n === "" && e.clearValue();
186
186
  },
187
187
  onFocus: () => {
188
- z && !Y && e.setOpen(!0);
188
+ F && !q && e.setOpen(!0);
189
189
  },
190
190
  children: /* @__PURE__ */ _(a, {})
191
191
  }) }),
192
- /* @__PURE__ */ _(j, {
192
+ /* @__PURE__ */ _(E, {
193
193
  asChild: !0,
194
- hidden: Y && (!d || d.length === 0),
194
+ hidden: q && (!d || d.length === 0),
195
195
  children: /* @__PURE__ */ _("svg", {
196
196
  width: "24",
197
197
  height: "24",
@@ -206,9 +206,9 @@ var I = ({ items: e = [], initialItems: d, debounceMs: f = 0, placeholder: p, em
206
206
  })
207
207
  })
208
208
  }),
209
- /* @__PURE__ */ _(w, {
210
- disabled: G.readOnly,
211
- onClick: R,
209
+ /* @__PURE__ */ _(ie, {
210
+ disabled: B.readOnly,
211
+ onClick: M,
212
212
  asChild: !0,
213
213
  children: /* @__PURE__ */ _("button", { children: /* @__PURE__ */ _("svg", {
214
214
  width: "20",
@@ -225,37 +225,37 @@ var I = ({ items: e = [], initialItems: d, debounceMs: f = 0, placeholder: p, em
225
225
  }) })
226
226
  })
227
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, {
228
+ when: x,
229
+ wrapper: (e) => /* @__PURE__ */ _(u, { children: e }),
230
+ children: /* @__PURE__ */ _(oe, { children: /* @__PURE__ */ _(ae, { children: ye ? Q : X.length === 0 ? /* @__PURE__ */ _(g, { children: q ? fe ? $ : Q : $ }) : ue ? /* @__PURE__ */ _(te, {
231
231
  role: "presentation",
232
- rowComponent: F,
232
+ rowComponent: se,
233
233
  rowProps: {
234
- items: Z,
235
- isMultiple: W,
236
- renderItem: I
234
+ items: X,
235
+ isMultiple: R,
236
+ renderItem: A
237
237
  },
238
- rowCount: Z.length,
239
- rowHeight: H,
240
- style: { height: Math.min(H * Z.length, 180) }
241
- }) : Z.map((e) => /* @__PURE__ */ _(r, {
238
+ rowCount: X.length,
239
+ rowHeight: I,
240
+ style: { height: Math.min(I * X.length, 180) }
241
+ }) : X.map((e) => /* @__PURE__ */ _(r, {
242
242
  when: !!e.tooltip,
243
243
  wrapper: (n) => /* @__PURE__ */ _(t, {
244
244
  label: e.tooltip,
245
245
  children: n
246
246
  }),
247
- children: /* @__PURE__ */ _(O, {
247
+ children: /* @__PURE__ */ _(w, {
248
248
  item: e,
249
- children: /* @__PURE__ */ _(P, {
250
- renderItem: I,
249
+ children: /* @__PURE__ */ _(k, {
250
+ renderItem: A,
251
251
  item: e,
252
- isMultiple: W
252
+ isMultiple: R
253
253
  })
254
254
  }, e.value)
255
255
  }, e.value)) }) })
256
256
  })]
257
257
  });
258
258
  };
259
- export { I as Combobox };
259
+ export { A as Combobox };
260
260
 
261
261
  //# sourceMappingURL=Combobox.js.map
@@ -1 +1 @@
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"],"mapp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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
+ {"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","loadedItems","setLoadedItems","useState","isLoading","setIsLoading","firstQueryTriggered","setFirstQueryTriggered","filterText","setFilterText","asyncMode","loadItems","debouncedLoadItems","useMemo","debounce","newItems","value","error","debounceMs","filteredItems","withAutoFilter","text","matching","returnItemsOnEmpty","sourceItems","allItems","initialItems","valueKey","valueKeyOfFilter","setValueKeyOfFilter","listed","v","handleInputChange","details","onResetInitialItems","onInputValueChange","collection","createListCollection","effectiveIsLoading","loadingContent","loadingLabel","Text","emptyContent","emptyLabel","positioning","multiple","api","i","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, 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 onInputValueChange,\n ...props\n}: ComboboxProps<T>) => {\n const uiLabels = useUiLabels()\n // With `loadItems`, the list is what it returned last; the `items` prop only seeds it.\n const [loadedItems, setLoadedItems] = useState(() => itemsFromUsers)\n const [isLoading, setIsLoading] = useState(false)\n const [firstQueryTriggered, setFirstQueryTriggered] = useState(false)\n // Without `loadItems`, the text the list is filtered on: the input's, as zag reports it.\n const [filterText, setFilterText] = useState('')\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 setLoadedItems(newItems)\n } catch (error) {\n console.error(error)\n setLoadedItems([])\n } finally {\n setIsLoading(false)\n }\n }, debounceMs)\n : null,\n [loadItems, debounceMs],\n )\n\n // The list is derived from the `items` of this very render, never mirrored into state: zag\n // re-derives the input text from the collection as soon as `value` changes, so a value set in\n // the same render as the item that carries it must find that item in the collection already.\n // A mirror caught up one render late, and the input went blank.\n const filteredItems = useMemo(() => {\n if (!withAutoFilter || filterText === '') return itemsFromUsers\n const text = filterText.toLowerCase()\n const matching = itemsFromUsers.filter((item: ComboboxItem) => item.label.toLowerCase().includes(text))\n return matching.length === 0 && returnItemsOnEmpty ? itemsFromUsers : matching\n }, [itemsFromUsers, withAutoFilter, filterText, returnItemsOnEmpty])\n\n const sourceItems = asyncMode ? loadedItems : filteredItems\n const allItems = useMemo(() => [...sourceItems, ...(initialItems ?? [])], [sourceItems, initialItems])\n\n // A new `value` the typed text filters out (an item created from the empty state under\n // another name, a value the app sets) would still be stringified to nothing: drop the\n // filter for that render. zag then writes the label in the input, and the filter follows it.\n const valueKey = value?.map(String).join('\\n')\n const [valueKeyOfFilter, setValueKeyOfFilter] = useState(valueKey)\n if (valueKey !== valueKeyOfFilter) {\n setValueKeyOfFilter(valueKey)\n const listed = new Set(allItems.map(item => String(item.value)))\n if (!asyncMode && filterText !== '' && value?.some(v => !listed.has(String(v)))) {\n setFilterText('')\n }\n }\n\n // A caller's onInputValueChange runs as well: it no longer replaces the filter.\n const handleInputChange = (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\n if (debouncedLoadItems) {\n debouncedLoadItems(details.inputValue)\n } else if (withAutoFilter) {\n setFilterText(details.inputValue)\n }\n onInputValueChange?.(details)\n }\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,KAAOC,EAAaC,EAAOZ,EAAY,IAAS,GAAG,QAAQ,EAC/D,cAAc,EACZ,WAAW,GACb,EACF,CAAC,GAEKc,KAAeC,EAAYH,EAAOZ,EAAY,YAAY,GAAG,cAAc,GAC3EgB,KAAUD,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,KAAaN,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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ACb,UAAS,MAAY,kBAAC7B,GAAD;KAAS,OAAO6B,EAAK;KAAU;IAAkB,CAAA;IAEtE,UAAA,kBAACZ,GAAD;KAA6B;KAC3B,UAAA,kBAACO,GAAD;MAA6B;MAAkB;MAAM,YAAY6D;KAAW,CAAA;IACxE,GAFKxD,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({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;
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,isMultiple:o,renderItem:s}){let c=a[e];return(0,l.jsx)(r.ConditionalWrapper,{when:!!c.tooltip,wrapper:e=>(0,l.jsx)(t.Tooltip,{label:c.tooltip,children:e}),children:(0,l.jsx)(y,{item:c,style:n,"aria-posinset":i[`aria-posinset`],"aria-setsize":i[`aria-setsize`],children:(0,l.jsx)(A,{renderItem:s,item:c,isMultiple:o})})})}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,isMultiple:N.multiple,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","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,EAE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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 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 SelectItem>({\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\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, isMultiple: props.multiple, 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,EAAA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CAACV,EAAAA,KAAD,CACE,KAAK,eACL,aAAcwC,EACd,SAAU,CAAE,QAAO,WAAYO,EAAM,SAAU,YAAW,EAC1D,SAAUhB,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"}
@@ -88,22 +88,23 @@ function L({ item: e, isMultiple: t, renderItem: n }) {
88
88
  children: e.label
89
89
  })] });
90
90
  }
91
- function R({ index: e, style: n, ariaAttributes: i, items: a, renderItem: o }) {
92
- let s = a[e];
91
+ function R({ index: e, style: n, ariaAttributes: i, items: a, isMultiple: o, renderItem: s }) {
92
+ let c = a[e];
93
93
  return /* @__PURE__ */ h(r, {
94
- when: !!s.tooltip,
94
+ when: !!c.tooltip,
95
95
  wrapper: (e) => /* @__PURE__ */ h(t, {
96
- label: s.tooltip,
96
+ label: c.tooltip,
97
97
  children: e
98
98
  }),
99
99
  children: /* @__PURE__ */ h(E, {
100
- item: s,
100
+ item: c,
101
101
  style: n,
102
102
  "aria-posinset": i["aria-posinset"],
103
103
  "aria-setsize": i["aria-setsize"],
104
104
  children: /* @__PURE__ */ h(L, {
105
- renderItem: o,
106
- item: s
105
+ renderItem: s,
106
+ item: c,
107
+ isMultiple: o
107
108
  })
108
109
  })
109
110
  });
@@ -213,6 +214,7 @@ function B({ items: e, placeholder: c, emptyLabel: l, usePortal: u = !0, positio
213
214
  rowComponent: R,
214
215
  rowProps: {
215
216
  items: e,
217
+ isMultiple: M.multiple,
216
218
  renderItem: m
217
219
  },
218
220
  rowCount: e.length,
@@ -1 +1 @@
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 )}\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,WAAW,GACb,EACF,CAAC,GAEKY,IAAeC,EAAYH,EAAOV,EAAU,YAAY,GAAG,cAAc,GACzEc,IAAUD,EAAYH,EAAOV,EAAU,OAAO,GAAG,SAAS,GAC1De,IAAUF,EAAYH,EAAOV,EAAU,OAAO,GAAG,SAAS,GAC1DgB,IAAYH,EAAYH,EAAOV,EAAU,SAAS,GAAG,WAAW,GAChEiB,IAAOJ,EAAYH,EAAOV,EAAU,IAAI,GAAG,MAAM,GACjDkB,IAAYL,EAAYH,EAAOV,EAAU,SAAS,GAAG,WAAW,GAChEmB,IAAiBN,EAAYH,EAAOV,EAAU,cAAc,GAAG,gBAAgB,GAC/EoB,IAAWP,EAAYH,EAAOV,EAAU,QAAQ,GAAG,UAAU,GAC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AO,EAAE,QAAQ,KAAK,IAAImC,IAAYnC,EAAM,QAAQ,GAAG,EAAE;IAC1D,CAAA,IAEDc,EAAkBd,CAAK,CAAC,CAAC,KAAK,GAAK,MACjCoC,EAAI,UAAU,KAAA,IACZ,kBAACV,GAAD,EAAA,UAAqCU,EAAI,MAAM,IAAIX,CAAY,EAAY,GAA5D,SAASY,GAAmD,IAE3E,kBAACjD,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAiB+C,EAAI,MAAsB,CAAA,GAC1CA,EAAI,MAAM,IAAIX,CAAY,CAClB,EAAA,GAHK,SAASY,GAGd,CAEf,EAEK,CAAA,EACC,CAAA;GACM,CAAA;GACpB,kBAACnE,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 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 SelectItem>({\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\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, isMultiple: props.multiple, 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":";;;;;;;;;;;;;;AAsBA,IAAM,EAAE,iBAAc,mBAAgBM,EAAmBC,CAAM,GAGzDC,IAAOC,EAAaC,EAAOV,EAAU,IAAS,GAAG,QAAQ,EAC7D,cAAc,EACZ,WAAW,GACb,EACF,CAAC,GAEKY,IAAeC,EAAYH,EAAOV,EAAU,YAAY,GAAG,cAAc,GACzEc,IAAUD,EAAYH,EAAOV,EAAU,OAAO,GAAG,SAAS,GAC1De,IAAUF,EAAYH,EAAOV,EAAU,OAAO,GAAG,SAAS,GAC1DgB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B;IAAiB,CAAA;IAC7G,UAAA,kBAAChC,GAAD,EAAA,UACE,kBAACP,GAAD,EAAA,UACGgB,EAAM,WAAW,IAChB,kBAAC+B,GAAD;KAAM,IAAG;KAAU,WAAU;KAC1B,UAAAC,KAAcb,EAAS;IACpB,CAAA,IACJc,IAGF,kBAACC,GAAD;KACE,MAAK;KACL,cAAcxB;KACd,UAAU;MAAE;MAAO,YAAYQ,EAAM;MAAU;KAAW;KAC1D,UAAUlB,EAAM;KACL;KACX,OAAO,EAAE,QAAQ,KAAK,IAAImC,IAAYnC,EAAM,QAAQ,GAAG,EAAE;IAC1D,CAAA,IAEDc,EAAkBd,CAAK,CAAC,CAAC,KAAK,GAAK,MACjCoC,EAAI,UAAU,KAAA,IACZ,kBAACV,GAAD,EAAA,UAAqCU,EAAI,MAAM,IAAIX,CAAY,EAAY,GAA5D,SAASY,GAAmD,IAE3E,kBAACjD,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAiB+C,EAAI,MAAsB,CAAA,GAC1CA,EAAI,MAAM,IAAIX,CAAY,CAClB,EAAA,GAHK,SAASY,GAGd,CAEf,EAEK,CAAA,EACC,CAAA;GACM,CAAA;GACpB,kBAACnE,EAAU,cAAX,CAAyB,CAAA;EACrB;;AAEV"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokelp/ui",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Stokelp UI React",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -60,6 +60,8 @@
60
60
  "build": "npm-run-all panda:codegen build:vite panda:lib",
61
61
  "preview": "vite preview",
62
62
  "typecheck": "tsc --noEmit --skipLibCheck --pretty",
63
+ "test": "panda codegen && vitest run",
64
+ "test:watch": "panda codegen && vitest",
63
65
  "check:dist": "node scripts/check-dist.mjs",
64
66
  "release": "semantic-release -e semantic-release-monorepo",
65
67
  "release:dry": "semantic-release -e semantic-release-monorepo --dry-run",
@@ -83,10 +85,12 @@
83
85
  "@storybook/addon-links": "^10.6.0",
84
86
  "@storybook/addon-mcp": "^10.6.0",
85
87
  "@storybook/react-vite": "^10.6.0",
88
+ "@testing-library/user-event": "^14.6.8",
86
89
  "@types/react": "^19.2.14",
87
90
  "@types/react-is": "^19.2.0",
88
91
  "@vitejs/plugin-react": "^6.0.2",
89
92
  "deepmerge": "^4.3.1",
93
+ "jsdom": "^30.1.3",
90
94
  "prop-types": "^15.8.1",
91
95
  "storybook": "^10.6.0",
92
96
  "storybook-addon-data-theme-switcher": "^3.2.0",