@brightlocal/ui-components 2.0.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/component-meta.json +2 -1
- package/dist/combobox.cjs +4 -1
- package/dist/combobox.d.ts +96 -3
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +498 -193
- package/dist/index.cjs +1 -1
- package/dist/index.js +378 -376
- package/dist/resizable.d.ts +1 -1
- package/dist/split-layout.cjs +1 -1
- package/dist/split-layout.d.ts +52 -1
- package/dist/split-layout.d.ts.map +1 -1
- package/dist/split-layout.js +82 -55
- package/package.json +1 -1
- package/src/components/combobox.tsx +695 -30
- package/src/components/split-layout.tsx +96 -2
package/component-meta.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightlocal/ui-components",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Machine-readable registry of all components in the BrightLocal Design System",
|
|
5
5
|
"components": [
|
|
6
6
|
{
|
|
@@ -374,6 +374,7 @@
|
|
|
374
374
|
"ComboboxContent",
|
|
375
375
|
"ComboboxInput",
|
|
376
376
|
"ComboboxList",
|
|
377
|
+
"ComboboxVirtualList",
|
|
377
378
|
"ComboboxEmpty",
|
|
378
379
|
"ComboboxGroup",
|
|
379
380
|
"ComboboxItem",
|
package/dist/combobox.cjs
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),re=require("react"),H=require("@brightlocal/icons"),ne=require("@tanstack/react-virtual"),se=require("class-variance-authority"),W=require("cmdk"),L=require("@brightlocal/ui-components/lib/utils"),Y=require("@brightlocal/ui-components/lib/use-dev-warning"),B=require("@brightlocal/ui-components/popover"),_=require("@brightlocal/ui-components/command");function ae(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return o.default=e,Object.freeze(o)}const t=ae(re),J=t.createContext(null),K=t.createContext(null);function $(){const e=t.useContext(J);if(!e)throw new Error("Combobox components must be used within a <Combobox>");return e}function ie({value:e,onValueChange:o,open:r,onOpenChange:n,shouldFilter:u=!0,disabled:b=!1,itemToStringValue:l,children:g}){const[v,C]=t.useState(""),[F,I]=t.useState(!1),[j,R]=t.useState(()=>new Map),[w,y]=t.useState(""),[h,m]=t.useState(void 0),E=e!==void 0,D=r!==void 0,k=E?e:v,d=D?r:F,x=t.useCallback(p=>{p||y(""),D||I(p),n?.(p)},[D,n]),N=t.useCallback(p=>{E||C(p),o?.(p)},[E,o]),s=t.useRef(new Map),S=t.useRef(!1),T=t.useRef(!0);t.useEffect(()=>()=>{T.current=!1},[]);const q=t.useCallback(()=>{S.current||(S.current=!0,queueMicrotask(()=>{S.current=!1,T.current&&R(new Map(s.current))}))},[]),M=t.useCallback((p,O)=>{s.current.get(p)!==O&&(s.current.set(p,O),q())},[q]),A=t.useRef(k);t.useLayoutEffect(()=>{A.current=k},[k]);const z=t.useCallback(p=>{p!==A.current&&s.current.has(p)&&(s.current.delete(p),q())},[q]),G=t.useMemo(()=>l?(p,O,i)=>W.defaultFilter(l(p),O,i):W.defaultFilter,[l]),U=t.useMemo(()=>({open:d,setOpen:x,value:k,onValueChange:N,shouldFilter:u,disabled:b,itemLabels:j,registerItem:M,unregisterItem:z,itemToStringValue:l,filterFn:G,searchValue:w,setSearchValue:y,activeDescendantId:h,setActiveDescendantId:m}),[d,x,k,N,u,b,j,M,z,l,G,w,h,m]);return a.jsx(J.Provider,{value:U,children:a.jsx(B.Popover,{open:d,onOpenChange:x,children:g})})}const ce=se.cva(["relative flex w-full items-center justify-between gap-2","px-4 py-2 h-9","border border-input rounded-md outline-none","bg-neutral-50 shadow-xs","dark:bg-white/5 dark:border-white/15","text-sm font-normal font-sans text-foreground","data-[placeholder=true]:text-muted-foreground","focus-visible:outline-none focus-visible:border-ring dark:focus-visible:border-neutral-500 focus-visible:bg-background","focus-visible:shadow-default","data-[state=open]:border-ring","disabled:cursor-not-allowed disabled:opacity-50","transition-[background-color,border-color,box-shadow] duration-200 ease-out","[&_svg]:pointer-events-none [&_svg]:shrink-0"]),Q=t.forwardRef(({className:e,dataHook:o,error:r,trackingEl:n,trackingLabel:u,children:b,...l},g)=>{const{open:v,disabled:C,value:F}=$(),I=t.useId(),j=!F,R=r||l["aria-invalid"]===!0||l["aria-invalid"]==="true";return a.jsx(B.PopoverTrigger,{asChild:!0,children:a.jsxs("button",{ref:g,"aria-controls":v?I:void 0,"aria-expanded":v,"aria-haspopup":"listbox","aria-invalid":R?"true":void 0,className:L.cn(ce(),R&&"border-destructive-40 dark:border-destructive-40 focus-visible:border-destructive-40 dark:focus-visible:border-destructive-40 focus-visible:shadow-destructive data-[state=open]:border-destructive-40 dark:data-[state=open]:border-destructive-40 data-[state=open]:shadow-destructive",e),"data-hook":o,"data-placeholder":j,"data-slot":"combobox-trigger","data-state":v?"open":"closed","data-tracking-el":n||"combobox-trigger","data-tracking-label":u,disabled:C||l.disabled,role:"combobox",type:"button",...l,children:[b,a.jsx(H.ChevronsUpDown,{"aria-hidden":"true",className:"text-muted-foreground ml-auto shrink-0"})]})})});Q.displayName="ComboboxTrigger";function ue({placeholder:e,className:o,displayValue:r}){const{value:n,itemLabels:u}=$(),b=n?u.get(n)||r?.(n)||n:e;return a.jsx("span",{className:L.cn("text-foreground overflow-hidden text-sm leading-normal font-medium text-ellipsis whitespace-nowrap",o),"data-slot":"combobox-value",children:b})}function le({dataHook:e,className:o,children:r,align:n="start",side:u="bottom",sideOffset:b,avoidCollisions:l,hideList:g=!1}){const{open:v,shouldFilter:C,filterFn:F,itemToStringValue:I}=$(),[j,R]=t.useState(null),w=t.useRef(null),y=t.useCallback(m=>{if(w.current?.(),w.current=null,!m)return;let E=!1;const D=N=>{E||(N==="top"||N==="bottom")&&(E=!0,k.disconnect(),R(N))},k=new MutationObserver(()=>{D(m.getAttribute("data-side"))});k.observe(m,{attributes:!0,attributeFilter:["data-side"]});let d=0,x=0;d=requestAnimationFrame(()=>{x=requestAnimationFrame(()=>{D(m.getAttribute("data-side"))})}),w.current=()=>{E=!0,k.disconnect(),cancelAnimationFrame(d),cancelAnimationFrame(x)}},[]);t.useEffect(()=>{if(!v){w.current?.(),w.current=null;const m=setTimeout(()=>R(null),150);return()=>clearTimeout(m)}},[v]);const h=I?F:void 0;return a.jsx(B.PopoverContent,{ref:y,align:n,"aria-label":"Options",avoidCollisions:l,className:L.cn("flex max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] flex-col overflow-hidden p-0",o),collisionPadding:4,"data-slot":"combobox-popover",side:j??u,sideOffset:b,children:a.jsx(_.Command,{className:L.cn("min-h-0 flex-1 border-0 shadow-none","[&_[data-slot='command-input-wrapper']]:shrink-0",g&&"[&_[data-slot='command-input-wrapper']]:border-b-0"),"data-slot":"combobox-command",dataHook:e||"combobox-command",filter:h,shouldFilter:C,children:r})})}const V=t.forwardRef(({debounceMs:e,onValueChange:o,...r},n)=>{const{setSearchValue:u,shouldFilter:b,activeDescendantId:l}=$(),g=t.useRef(void 0);Y.useDevWarning(()=>!!(e&&e>0&&b),`debounceMs is set on <ComboboxInput> but shouldFilter is true (default).
|
|
2
|
+
Debounce is designed for async/server-driven search where the consumer controls the items list.
|
|
3
|
+
Set shouldFilter={false} on <Combobox> for async search, or remove debounceMs for client-side filtering.`,[e,b]),Y.useDevWarning(()=>!!(e&&e>0&&r.value!==void 0),"debounceMs is set on <ComboboxInput> together with a controlled `value` prop.\nThe debounced onValueChange callback cannot update the controlled value synchronously, so the input will appear to lag behind typing.\nRemove `value` to let the input manage its own display, or remove debounceMs if you need a controlled input.",[e,r.value]),t.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const v=t.useCallback(C=>{u(C),e&&e>0?(clearTimeout(g.current),g.current=setTimeout(()=>{o?.(C)},e)):o?.(C)},[e,o,u]);return a.jsx(_.CommandInput,{ref:n,"aria-activedescendant":l,"data-slot":"combobox-input",onValueChange:v,...r})});V.displayName="ComboboxInput";const X=t.forwardRef(({className:e,...o},r)=>a.jsx(_.CommandList,{ref:r,className:L.cn("min-h-0 flex-1",e),"data-slot":"combobox-list",...o}));X.displayName="ComboboxList";function de({items:e,getItemValue:o,getItemLabel:r,getItemKeywords:n,estimateSize:u=36,overscan:b=5,children:l,renderEmpty:g,className:v,dataHook:C},F){const I=t.useRef(null),{value:j,onValueChange:R,setOpen:w,shouldFilter:y,searchValue:h,filterFn:m,setActiveDescendantId:E,registerItem:D,unregisterItem:k}=$(),[d,x]=t.useState(0),N=t.useId();t.useImperativeHandle(F,()=>I.current,[]),t.useEffect(()=>{const i=r??o;for(const c of e)D(o(c),i(c));return()=>{for(const c of e)k(o(c))}},[e,o,r,D,k]);const s=t.useMemo(()=>{if(!y||!h.trim())return e;const i=[];for(const c of e){let f=r?W.defaultFilter(r(c),h):m(o(c),h);if(n)for(const P of n(c))f=Math.max(f,W.defaultFilter(P,h));f>0&&i.push({item:c,score:f})}return i.sort((c,f)=>f.score-c.score),i.map(c=>c.item)},[e,y,h,o,r,n,m]),S=ne.useVirtualizer({count:s.length,getScrollElement:()=>I.current,estimateSize:()=>u,overscan:b}),T=d>=0&&d<s.length?o(s[d]):null;t.useEffect(()=>{x(0)},[h,s.length]);const q=t.useRef(!1);t.useEffect(()=>{if(q.current||!j)return;const i=s.findIndex(c=>o(c)===j);i>=0&&(x(i),S.scrollToIndex(i,{align:"center"}),q.current=!0)},[j,s,o,S]);const M=t.useRef(!1);t.useEffect(()=>{M.current&&d>=0&&d<s.length&&S.scrollToIndex(d,{align:"auto"}),M.current=!1},[d,s.length,S]),t.useEffect(()=>{const i=I.current?.closest('[data-slot="combobox-command"]');if(!i)return;const c=f=>{switch(f.key){case"ArrowDown":f.preventDefault(),f.stopPropagation(),M.current=!0,x(P=>P<s.length-1?P+1:P);break;case"ArrowUp":f.preventDefault(),f.stopPropagation(),M.current=!0,x(P=>P>0?P-1:P);break;case"Enter":if(f.preventDefault(),f.stopPropagation(),d>=0&&d<s.length){const P=o(s[d]);R(P===j?"":P),w(!1)}break;case"Home":f.preventDefault(),f.stopPropagation(),M.current=!0,x(0);break;case"End":f.preventDefault(),f.stopPropagation(),M.current=!0,x(s.length-1);break}};return i.addEventListener("keydown",c,{capture:!0}),()=>i.removeEventListener("keydown",c,{capture:!0})},[s,d,j,R,w,o]);const A=t.useMemo(()=>{const i=new Map;return s.forEach((c,f)=>{i.set(o(c),f)}),i},[s,o]),z=t.useCallback(i=>{const c=A.get(i);c!==void 0&&x(c)},[A]),G=t.useCallback(i=>(A.get(i)??0)+1,[A]),U=s.length,p=t.useMemo(()=>({activeValue:T,onItemPointerMove:z,idPrefix:N,filteredCount:U,getItemPosition:G}),[T,z,N,U,G]),O=T!=null?`${N}item-${T}`:void 0;return t.useEffect(()=>(E(O),()=>E(void 0)),[O,E]),s.length===0?a.jsx("div",{ref:I,className:L.cn("max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",v),"data-hook":C,"data-slot":"combobox-virtual-list",role:"listbox",children:g}):a.jsx(K.Provider,{value:p,children:a.jsx("div",{ref:I,className:L.cn("max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",v),"data-hook":C,"data-slot":"combobox-virtual-list",role:"listbox",children:a.jsx("div",{className:"relative w-full",style:{height:`${S.getTotalSize()}px`},children:S.getVirtualItems().map(i=>a.jsx("div",{ref:S.measureElement,className:"absolute top-0 left-0 w-full px-2","data-index":i.index,style:{transform:`translateY(${i.start}px)`},children:l(s[i.index],i.index,h)},i.key))})})})}const fe=t.forwardRef(de),Z=t.forwardRef((e,o)=>a.jsx(_.CommandEmpty,{ref:o,"data-slot":"combobox-empty",...e}));Z.displayName="ComboboxEmpty";const ee=t.forwardRef(({children:e,...o},r)=>{const n=t.useRef(null);return Y.useDevWarning(()=>n.current?n.current.querySelectorAll('[data-slot="combobox-item"]').length>=100:!1,`ComboboxGroup contains 100+ items. Use <ComboboxVirtualList> for large datasets to avoid DOM bloat and slow renders.
|
|
4
|
+
Import: import { ComboboxVirtualList } from "@brightlocal/ui-components/combobox"`,[e]),a.jsx(_.CommandGroup,{ref:u=>{n.current=u,typeof r=="function"?r(u):r&&(r.current=u)},"data-slot":"combobox-group",...o,children:e})});ee.displayName="ComboboxGroup";function be(e,o,r){if(!o||!o.trim())return e;const n=new RegExp(`(${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi"),u=e.split(n);return a.jsx("span",{children:u.map((b,l)=>l%2===1?a.jsx("span",{className:r,children:b},l):a.jsx(t.Fragment,{children:b},l))})}const te=t.forwardRef(({value:e,label:o,dataHook:r,children:n,className:u,highlight:b,highlightClassName:l,keywords:g,...v},C)=>{const{value:F,onValueChange:I,setOpen:j,registerItem:R,unregisterItem:w}=$(),y=t.useContext(K),h=F===e,m=t.useMemo(()=>o||(typeof n=="string"?n:typeof n=="number"?String(n):e),[o,n,e]),E=t.useRef(R),D=t.useRef(w);t.useEffect(()=>{E.current=R,D.current=w},[R,w]);const k=!!y;t.useEffect(()=>{if(!k)return E.current(e,m),()=>D.current(e)},[e,m,k]);const d=()=>{I(e===F?"":e),j(!1)},x=()=>b&&typeof n=="string"?be(n,b,l||"text-sm leading-normal font-semibold"):n;if(y){const N=y.activeValue===e,s=!!v.disabled;return a.jsxs("div",{ref:C,"aria-disabled":s||void 0,"aria-posinset":y.getItemPosition(e),"aria-selected":h,"aria-setsize":y.filteredCount,className:L.cn("data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground relative flex cursor-default items-center justify-between gap-2 rounded-sm px-2 py-3 text-sm outline-hidden select-none","[&_svg]:pointer-events-none [&_svg]:shrink-0",s&&"pointer-events-none opacity-50",u),"data-highlighted":N||void 0,"data-hook":r,"data-slot":"combobox-item",id:`${y.idPrefix}item-${e}`,role:"option",tabIndex:-1,onClick:s?void 0:d,onKeyDown:s?void 0:S=>{(S.key==="Enter"||S.key===" ")&&d()},onPointerMove:s?void 0:()=>y.onItemPointerMove(e),children:[x(),h&&a.jsx(H.Check,{"aria-hidden":"true",className:"text-muted-foreground shrink-0"})]})}return a.jsxs(_.CommandItem,{ref:C,className:L.cn("justify-between",u),"data-slot":"combobox-item",dataHook:r,keywords:g?[m,...g]:[m],value:e,onSelect:d,...v,children:[x(),h&&a.jsx(H.Check,{"aria-hidden":"true",className:"text-muted-foreground shrink-0"})]})});te.displayName="ComboboxItem";const oe=t.forwardRef((e,o)=>a.jsx(_.CommandSeparator,{ref:o,"data-slot":"combobox-separator",...e}));oe.displayName="ComboboxSeparator";function me({className:e,children:o}){return a.jsx("div",{"aria-live":"polite",className:L.cn("text-muted-foreground flex items-center justify-center gap-2 py-6 text-sm",e),"data-slot":"combobox-loading",role:"status",children:o||a.jsxs(a.Fragment,{children:[a.jsx("div",{"aria-hidden":"true",className:"size-4 animate-spin rounded-full border-2 border-current border-t-transparent [animation-duration:0.6s]"}),"Loading..."]})})}exports.Combobox=ie;exports.ComboboxContent=le;exports.ComboboxEmpty=Z;exports.ComboboxGroup=ee;exports.ComboboxInput=V;exports.ComboboxItem=te;exports.ComboboxList=X;exports.ComboboxLoading=me;exports.ComboboxSeparator=oe;exports.ComboboxTrigger=Q;exports.ComboboxValue=ue;exports.ComboboxVirtualList=fe;
|
package/dist/combobox.d.ts
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
import { CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator } from './command';
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Composable combobox supporting three usage modes:
|
|
5
|
+
*
|
|
6
|
+
* **1. Client-filtered (default)** — small/medium datasets with instant search.
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <Combobox>
|
|
9
|
+
* <ComboboxInput />
|
|
10
|
+
* <ComboboxList>
|
|
11
|
+
* <ComboboxGroup><ComboboxItem value="a">A</ComboboxItem></ComboboxGroup>
|
|
12
|
+
* </ComboboxList>
|
|
13
|
+
* </Combobox>
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* **2. Async / server-driven** — results fetched from an API.
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <Combobox shouldFilter={false}>
|
|
19
|
+
* <ComboboxInput debounceMs={300} onValueChange={fetchResults} />
|
|
20
|
+
* <ComboboxList>
|
|
21
|
+
* {results.map(r => <ComboboxItem key={r.id} value={r.id}>{r.name}</ComboboxItem>)}
|
|
22
|
+
* </ComboboxList>
|
|
23
|
+
* </Combobox>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* **3. Virtualised large list** — 100+ items rendered efficiently.
|
|
27
|
+
* Client-side filtering is on by default (`shouldFilter` omitted).
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <Combobox>
|
|
30
|
+
* <ComboboxInput />
|
|
31
|
+
* <ComboboxVirtualList items={items} getItemValue={i => i.id} estimateSize={36}>
|
|
32
|
+
* {(item) => <ComboboxItem value={item.id}>{item.name}</ComboboxItem>}
|
|
33
|
+
* </ComboboxVirtualList>
|
|
34
|
+
* </Combobox>
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
3
37
|
export interface ComboboxProps {
|
|
4
38
|
/** Controlled selected value */
|
|
5
39
|
value?: string;
|
|
@@ -9,7 +43,12 @@ export interface ComboboxProps {
|
|
|
9
43
|
open?: boolean;
|
|
10
44
|
/** Callback when open state changes */
|
|
11
45
|
onOpenChange?: (open: boolean) => void;
|
|
12
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Whether to use built-in client-side filtering. Defaults to `true`.
|
|
48
|
+
* Both `ComboboxList` (cmdk) and `ComboboxVirtualList` respect this flag.
|
|
49
|
+
* Set to `false` only for async/server-driven search where the consumer
|
|
50
|
+
* controls the items list.
|
|
51
|
+
*/
|
|
13
52
|
shouldFilter?: boolean;
|
|
14
53
|
/** Disabled state */
|
|
15
54
|
disabled?: boolean;
|
|
@@ -39,8 +78,22 @@ export interface ComboboxValueProps {
|
|
|
39
78
|
placeholder?: string;
|
|
40
79
|
/** Custom className */
|
|
41
80
|
className?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Resolve a display label for the selected value. Called when the internal
|
|
83
|
+
* label registry doesn't have a match (e.g. before the popover opens for
|
|
84
|
+
* the first time with a pre-selected value).
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```tsx
|
|
88
|
+
* <ComboboxValue
|
|
89
|
+
* placeholder="Select country..."
|
|
90
|
+
* displayValue={(v) => countriesMap.get(v)?.name}
|
|
91
|
+
* />
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
displayValue?: (value: string) => string | undefined;
|
|
42
95
|
}
|
|
43
|
-
declare function ComboboxValue({ placeholder, className }: ComboboxValueProps): import("react/jsx-runtime").JSX.Element;
|
|
96
|
+
declare function ComboboxValue({ placeholder, className, displayValue, }: ComboboxValueProps): import("react/jsx-runtime").JSX.Element;
|
|
44
97
|
export interface ComboboxContentProps {
|
|
45
98
|
/** Data hook for automated testing */
|
|
46
99
|
dataHook?: string;
|
|
@@ -73,10 +126,50 @@ export interface ComboboxInputProps extends React.ComponentProps<typeof CommandI
|
|
|
73
126
|
value?: string;
|
|
74
127
|
/** Called when input value changes. Use to trigger async search requests. */
|
|
75
128
|
onValueChange?: (value: string) => void;
|
|
129
|
+
/**
|
|
130
|
+
* Debounce delay in milliseconds for the `onValueChange` callback.
|
|
131
|
+
* The input display updates immediately; only the callback is debounced.
|
|
132
|
+
* Useful for async search to avoid firing API calls on every keystroke.
|
|
133
|
+
* @example 300
|
|
134
|
+
*/
|
|
135
|
+
debounceMs?: number;
|
|
76
136
|
}
|
|
77
137
|
declare const ComboboxInput: React.ForwardRefExoticComponent<Omit<ComboboxInputProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
78
138
|
export type ComboboxListProps = React.ComponentProps<typeof CommandList>;
|
|
79
139
|
declare const ComboboxList: React.ForwardRefExoticComponent<Omit<Omit<import('@brightlocal/ui-components/command').CommandListProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
140
|
+
export interface ComboboxVirtualListProps<T> {
|
|
141
|
+
/** Array of items to virtualise. Memoize with useMemo to avoid re-registering labels on every render. */
|
|
142
|
+
items: T[];
|
|
143
|
+
/** Extract the string value for each item (used for selection and keyboard navigation) */
|
|
144
|
+
getItemValue: (item: T) => string;
|
|
145
|
+
/**
|
|
146
|
+
* Extract a display label for filtering and trigger display. Defaults to `getItemValue`.
|
|
147
|
+
* Only used when `shouldFilter` is true on the parent Combobox.
|
|
148
|
+
*/
|
|
149
|
+
getItemLabel?: (item: T) => string;
|
|
150
|
+
/**
|
|
151
|
+
* Extract additional keywords to match against when filtering.
|
|
152
|
+
* The item label is always included automatically — these are extras
|
|
153
|
+
* (e.g. ISO codes, abbreviations) that should be searchable without
|
|
154
|
+
* appearing in the trigger display.
|
|
155
|
+
*/
|
|
156
|
+
getItemKeywords?: (item: T) => string[];
|
|
157
|
+
/** Estimated item height in pixels. @default 36 */
|
|
158
|
+
estimateSize?: number;
|
|
159
|
+
/** Number of items to render above and below the visible area. @default 5 */
|
|
160
|
+
overscan?: number;
|
|
161
|
+
/** Render function for each item. The third argument is the current search query, useful for highlighting matching text. */
|
|
162
|
+
children: (item: T, index: number, searchValue: string) => React.ReactNode;
|
|
163
|
+
/** Content to render when no items match the filter */
|
|
164
|
+
renderEmpty?: React.ReactNode;
|
|
165
|
+
/** Custom className for the scrollable container */
|
|
166
|
+
className?: string;
|
|
167
|
+
/** Data hook for automated testing */
|
|
168
|
+
dataHook?: string;
|
|
169
|
+
}
|
|
170
|
+
declare const ComboboxVirtualList: <T>(props: ComboboxVirtualListProps<T> & {
|
|
171
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
172
|
+
}) => React.ReactElement | null;
|
|
80
173
|
export type ComboboxEmptyProps = React.ComponentProps<typeof CommandEmpty>;
|
|
81
174
|
declare const ComboboxEmpty: React.ForwardRefExoticComponent<Omit<Omit<import('@brightlocal/ui-components/command').CommandEmptyProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
82
175
|
export type ComboboxGroupProps = React.ComponentProps<typeof CommandGroup>;
|
|
@@ -105,5 +198,5 @@ export interface ComboboxLoadingProps {
|
|
|
105
198
|
children?: React.ReactNode;
|
|
106
199
|
}
|
|
107
200
|
declare function ComboboxLoading({ className, children }: ComboboxLoadingProps): import("react/jsx-runtime").JSX.Element;
|
|
108
|
-
export { Combobox, ComboboxTrigger, ComboboxValue, ComboboxContent, ComboboxInput, ComboboxList, ComboboxEmpty, ComboboxGroup, ComboboxItem, ComboboxSeparator, ComboboxLoading, };
|
|
201
|
+
export { Combobox, ComboboxTrigger, ComboboxValue, ComboboxContent, ComboboxInput, ComboboxList, ComboboxVirtualList, ComboboxEmpty, ComboboxGroup, ComboboxItem, ComboboxSeparator, ComboboxLoading, };
|
|
109
202
|
//# sourceMappingURL=combobox.d.ts.map
|
package/dist/combobox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../src/components/combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../src/components/combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/B,OAAO,EAEL,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,gBAAgB,EACjB,MAAM,oCAAoC,CAAC;AAwE5C;;;;;;;;;;;;;;;;;;;;;;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