@stokelp/ui 4.0.1 → 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"),
|
|
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,EAAA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EV,EAAS,SAAW,GACtB,EAAA3C,EAAA,IAAA,CAAA3B,EAAAA,SAAA,CAAA,SAAG+D,EAAaF,EAAsBqB,EAAeF,EAAkBE,CAAe,CAAA,EACpFc,IAGF,EAAArE,EAAA,IAAA,CAACZ,EAAAA,KAAD,CACE,KAAK,eACL,aAAckC,EACd,SAAU,CAAE,MAAOqB,EAAU,WAAYe,EAAU,YAAW,EAC9D,SAAUf,EAAS,OACR,YACX,MAAO,CAAE,OAAQ,KAAK,IAAI2B,EAAY3B,EAAS,OAAQ,GAAG,CAAE,CAC7D,CAAA,EAEDA,EAAS,IAAI,IACX,EAAA3C,EAAA,IAAA,CAAC1B,EAAAA,mBAAD,CAEE,KAAM,CAAC,CAAC+C,EAAK,QACb,QAAS,IAAY,EAAArB,EAAA,IAAA,CAACzB,EAAAA,QAAD,CAAS,MAAO8C,EAAK,QAAU,UAAkB,CAAA,EAEtE,UAAA,EAAArB,EAAA,IAAA,CAACW,EAAD,CAA6B,OAC3B,UAAA,EAAAX,EAAA,IAAA,CAACiB,EAAD,CAA6B,aAAkB,OAAM,WAAYyC,CAAW,CAAA,CACxE,EAFKrC,EAAK,KAEV,CACY,EAPbA,EAAK,KAOQ,CACrB,CAEI,CAAA,CACC,CAAA,CACM,CAAA,CAChB,C,EAEV,E"}
|
|
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} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n ))\n )}\n </Content>\n </Positioner>\n </ConditionalWrapper>\n </Root>\n )\n}\n"],"mappings":"A,yhBAwBA,GAAM,CAAE,eAAc,eAAgBA,EAAAA,mBAAmBC,EAAAA,QAAQ,EAG3DmC,EAAOC,GAAA,EAAanC,EAAAA,OAAAA,CAAOC,EAAAA,SAAY,IAAS,EAAG,OAAQ,CAC/D,aAAc,CACZ,UAAW,EACb,CACF,CAAC,EAEKmC,GAAeC,GAAA,EAAYrC,EAAAA,OAAAA,CAAOC,EAAAA,SAAY,YAAY,EAAG,cAAc,EAC3EqC,GAAUD,GAAA,EAAYrC,EAAAA,OAAAA,CAAOC,EAAAA,SAAY,OAAO,EAAG,SAAS,EAC5DsC,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AAD,CAAS,UAAiB,CAAA,EAClF,UAAA,EAAAa,EAAA,IAAA,CAACa,GAAD,CAAA,UACE,EAAAb,EAAA,IAAA,CAACQ,GAAD,CAAA,SACGwD,GACCC,EACEb,EAAS,SAAW,GACtB,EAAApD,EAAA,IAAA,CAAA1B,EAAAA,SAAA,CAAA,SAAGiE,EAAaJ,EAAsBgC,EAAeF,EAAkBE,CAAe,CAAA,EACpFa,IAGF,EAAAhF,EAAA,IAAA,CAACZ,GAAAA,KAAD,CACE,KAAK,eACL,aAAckC,GACd,SAAU,CAAE,MAAO8B,EAAU,WAAYkB,EAAU,YAAW,EAC9D,SAAUlB,EAAS,OACR,YACX,MAAO,CAAE,OAAQ,KAAK,IAAI6B,EAAY7B,EAAS,OAAQ,GAAG,CAAE,CAC7D,CAAA,EAEDA,EAAS,IAAI,IACX,EAAApD,EAAA,IAAA,CAACzB,EAAAA,mBAAD,CAEE,KAAM,CAAC,CAAC8C,EAAK,QACb,QAAS,IAAY,EAAArB,EAAA,IAAA,CAACxB,EAAAA,QAAD,CAAS,MAAO6C,EAAK,QAAU,UAAkB,CAAA,EAEtE,UAAA,EAAArB,EAAA,IAAA,CAACW,EAAD,CAA6B,OAC3B,UAAA,EAAAX,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
|
|
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 {
|
|
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
|
|
16
|
-
import { debounce as
|
|
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:
|
|
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
|
-
}),
|
|
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
|
|
58
|
+
function k({ item: e, isMultiple: t, renderItem: n }) {
|
|
59
59
|
let r = d();
|
|
60
|
-
return /* @__PURE__ */ v(g, { children: [t ? r.selected ? /* @__PURE__ */ _(
|
|
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
|
|
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__ */ _(
|
|
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__ */ _(
|
|
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
|
|
87
|
-
let
|
|
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
|
-
|
|
90
|
-
let t = await
|
|
91
|
-
|
|
89
|
+
pe(!0), W(!0);
|
|
90
|
+
let t = await O(e);
|
|
91
|
+
U(t);
|
|
92
92
|
} catch (e) {
|
|
93
|
-
console.error(e),
|
|
93
|
+
console.error(e), U([]);
|
|
94
94
|
} finally {
|
|
95
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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:
|
|
117
|
+
children: V.loading
|
|
118
118
|
}), $ = y ?? /* @__PURE__ */ _(n, {
|
|
119
119
|
p: "space-8",
|
|
120
120
|
textAlign: "center",
|
|
121
|
-
children:
|
|
121
|
+
children: V.noResults
|
|
122
122
|
});
|
|
123
|
-
return /* @__PURE__ */ v(
|
|
123
|
+
return /* @__PURE__ */ v(re, {
|
|
124
124
|
lazyMount: !0,
|
|
125
125
|
unmountOnExit: !0,
|
|
126
|
-
collection:
|
|
126
|
+
collection: ve,
|
|
127
127
|
positioning: {
|
|
128
128
|
sameWidth: !0,
|
|
129
129
|
gutter: 0,
|
|
130
|
-
...
|
|
130
|
+
...D
|
|
131
131
|
},
|
|
132
132
|
"data-recipe": "combobox",
|
|
133
|
-
onInputValueChange:
|
|
134
|
-
value:
|
|
135
|
-
defaultValue:
|
|
136
|
-
...
|
|
137
|
-
multiple:
|
|
138
|
-
children: [
|
|
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: [
|
|
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__ */ _(
|
|
152
|
+
/* @__PURE__ */ _(S, {
|
|
153
153
|
asChild: !0,
|
|
154
154
|
"data-multiple": "true",
|
|
155
155
|
placeholder: t.hasSelectedItems ? void 0 : p,
|
|
156
156
|
onFocus: () => {
|
|
157
|
-
|
|
157
|
+
F && !q && t.setOpen(!0);
|
|
158
158
|
},
|
|
159
159
|
children: /* @__PURE__ */ _(a, {})
|
|
160
160
|
}),
|
|
161
|
-
/* @__PURE__ */ _(
|
|
161
|
+
/* @__PURE__ */ _(E, {
|
|
162
162
|
asChild: !0,
|
|
163
|
-
hidden:
|
|
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(
|
|
180
|
-
/* @__PURE__ */ _(l.Context, { children: (e) => /* @__PURE__ */ _(
|
|
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
|
-
|
|
185
|
+
le && n === "" && e.clearValue();
|
|
186
186
|
},
|
|
187
187
|
onFocus: () => {
|
|
188
|
-
|
|
188
|
+
F && !q && e.setOpen(!0);
|
|
189
189
|
},
|
|
190
190
|
children: /* @__PURE__ */ _(a, {})
|
|
191
191
|
}) }),
|
|
192
|
-
/* @__PURE__ */ _(
|
|
192
|
+
/* @__PURE__ */ _(E, {
|
|
193
193
|
asChild: !0,
|
|
194
|
-
hidden:
|
|
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__ */ _(
|
|
210
|
-
disabled:
|
|
211
|
-
onClick:
|
|
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:
|
|
229
|
-
wrapper: (e) => /* @__PURE__ */ _(
|
|
230
|
-
children: /* @__PURE__ */ _(
|
|
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:
|
|
232
|
+
rowComponent: se,
|
|
233
233
|
rowProps: {
|
|
234
|
-
items:
|
|
235
|
-
isMultiple:
|
|
236
|
-
renderItem:
|
|
234
|
+
items: X,
|
|
235
|
+
isMultiple: R,
|
|
236
|
+
renderItem: A
|
|
237
237
|
},
|
|
238
|
-
rowCount:
|
|
239
|
-
rowHeight:
|
|
240
|
-
style: { height: Math.min(
|
|
241
|
-
}) :
|
|
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__ */ _(
|
|
247
|
+
children: /* @__PURE__ */ _(w, {
|
|
248
248
|
item: e,
|
|
249
|
-
children: /* @__PURE__ */ _(
|
|
250
|
-
renderItem:
|
|
249
|
+
children: /* @__PURE__ */ _(k, {
|
|
250
|
+
renderItem: A,
|
|
251
251
|
item: e,
|
|
252
|
-
isMultiple:
|
|
252
|
+
isMultiple: R
|
|
253
253
|
})
|
|
254
254
|
}, e.value)
|
|
255
255
|
}, e.value)) }) })
|
|
256
256
|
})]
|
|
257
257
|
});
|
|
258
258
|
};
|
|
259
|
-
export {
|
|
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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A,EAAA,UAAGgD,IAAaF,KAAsB0B,IAAeH,IAAkBG,EAAe,CAAA,IACpFkB,IAGF,kBAACC,IAAD;IACE,MAAK;IACL,cAAc5D;IACd,UAAU;KAAE,OAAO0B;KAAU,YAAYkB;KAAU;IAAW;IAC9D,UAAUlB,EAAS;IACR;IACX,OAAO,EAAE,QAAQ,KAAK,IAAImC,IAAYnC,EAAS,QAAQ,GAAG,EAAE;GAC7D,CAAA,IAEDA,EAAS,KAAI,MACX,kBAACvB,GAAD;IAEE,MAAM,CAAC,CAACJ,EAAK;IACb,UAAS,MAAY,kBAAC7B,GAAD;KAAS,OAAO6B,EAAK;KAAU;IAAkB,CAAA;IAEtE,UAAA,kBAACZ,GAAD;KAA6B;KAC3B,UAAA,kBAACO,GAAD;MAA6B;MAAkB;MAAM,YAAYkD;KAAW,CAAA;IACxE,GAFK7C,EAAK,KAEV;GACY,GAPbA,EAAK,KAOQ,CACrB,EAEI,CAAA,EACC,CAAA;EACM,CAAA,CAChB;;AAEV"}
|
|
1
|
+
{"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,QAA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AAI,MACX,kBAAChC,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,YAAY6D;KAAW,CAAA;IACxE,GAFKxD,EAAK,KAEV;GACY,GAPbA,EAAK,KAOQ,CACrB,EAEI,CAAA,EACC,CAAA;EACM,CAAA,CAChB;;AAEV"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stokelp/ui",
|
|
3
|
-
"version": "4.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",
|