@brightlocal/ui-components 3.4.0 → 3.5.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/AI_USAGE.md +22 -3
- package/README.md +177 -109
- package/component-meta.json +1061 -102
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.d.ts +13 -2
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +4 -3
- package/dist/banner.cjs +1 -1
- package/dist/banner.d.ts +47 -11
- package/dist/banner.d.ts.map +1 -1
- package/dist/banner.js +156 -79
- package/dist/blocks/empty-state.cjs +1 -1
- package/dist/blocks/empty-state.d.ts +40 -5
- package/dist/blocks/empty-state.d.ts.map +1 -1
- package/dist/blocks/empty-state.js +59 -52
- package/dist/blocks/input-list.d.ts +1 -0
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +12 -6
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +64 -63
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +47 -43
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +12 -0
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +115 -97
- package/dist/chart.cjs +6 -6
- package/dist/chart.d.ts +6 -10
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +281 -296
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +430 -343
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts +23 -2
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +212 -207
- package/dist/count-indicator.cjs +1 -0
- package/dist/count-indicator.d.ts +85 -0
- package/dist/count-indicator.d.ts.map +1 -0
- package/dist/count-indicator.js +72 -0
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +101 -11
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +593 -523
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts +26 -3
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +62 -47
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.d.ts +8 -4
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +37 -38
- package/dist/file-upload.cjs +1 -0
- package/dist/file-upload.d.ts +546 -0
- package/dist/file-upload.d.ts.map +1 -0
- package/dist/file-upload.js +1103 -0
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +7 -2
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +52 -52
- package/dist/hooks/use-file-dropzone.cjs +1 -0
- package/dist/hooks/use-file-dropzone.d.ts +75 -0
- package/dist/hooks/use-file-dropzone.d.ts.map +1 -0
- package/dist/hooks/use-file-dropzone.js +133 -0
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.d.ts +29 -16
- package/dist/hover-card.d.ts.map +1 -1
- package/dist/hover-card.js +153 -36
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +676 -640
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.d.ts +30 -1
- package/dist/input-chip.d.ts.map +1 -1
- package/dist/input-chip.js +131 -115
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +37 -2
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +131 -114
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.js +6 -6
- package/dist/lib/empty-canvas.cjs +1 -1
- package/dist/lib/empty-canvas.d.ts +27 -1
- package/dist/lib/empty-canvas.d.ts.map +1 -1
- package/dist/lib/empty-canvas.js +27 -23
- package/dist/lib/empty-chip.cjs +1 -1
- package/dist/lib/empty-chip.d.ts +19 -2
- package/dist/lib/empty-chip.d.ts.map +1 -1
- package/dist/lib/empty-chip.js +14 -9
- package/dist/lib/field-aria.cjs +1 -1
- package/dist/lib/field-aria.d.ts +4 -4
- package/dist/lib/field-aria.d.ts.map +1 -1
- package/dist/lib/field-aria.js +7 -5
- package/dist/lib/media-viewer-content.cjs +1 -1
- package/dist/lib/media-viewer-content.js +1 -1
- package/dist/lib/table-internal.cjs +1 -1
- package/dist/lib/table-internal.d.ts +19 -0
- package/dist/lib/table-internal.d.ts.map +1 -1
- package/dist/lib/table-internal.js +22 -7
- package/dist/list.cjs +1 -1
- package/dist/list.d.ts +13 -0
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +103 -82
- package/dist/logo-mark.cjs +1 -1
- package/dist/logo-mark.d.ts +18 -2
- package/dist/logo-mark.d.ts.map +1 -1
- package/dist/logo-mark.js +159 -79
- package/dist/media-empty.cjs +1 -1
- package/dist/media-empty.d.ts +50 -7
- package/dist/media-empty.d.ts.map +1 -1
- package/dist/media-empty.js +14 -13
- package/dist/media-viewer.cjs +1 -1
- package/dist/media-viewer.js +6 -6
- package/dist/multi-select-filter.cjs +1 -1
- package/dist/multi-select-filter.d.ts.map +1 -1
- package/dist/multi-select-filter.js +92 -101
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +11 -0
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +17 -17
- package/dist/relative-date.d.ts +6 -0
- package/dist/relative-date.d.ts.map +1 -1
- package/dist/resizable.d.ts +1 -1
- package/dist/result-count.cjs +1 -1
- package/dist/result-count.d.ts +13 -16
- package/dist/result-count.d.ts.map +1 -1
- package/dist/result-count.js +24 -33
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +22 -3
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +152 -125
- package/dist/single-select-filter.cjs +1 -1
- package/dist/single-select-filter.d.ts.map +1 -1
- package/dist/single-select-filter.js +67 -76
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +77 -76
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.d.ts +39 -3
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +127 -76
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.d.ts +34 -0
- package/dist/textarea.d.ts.map +1 -1
- package/dist/textarea.js +115 -19
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +137 -131
- package/dist/typography-text.cjs +1 -1
- package/dist/typography-text.d.ts +6 -2
- package/dist/typography-text.d.ts.map +1 -1
- package/dist/typography-text.js +14 -13
- package/package.json +3 -4
- package/src/blocks/empty-state.tsx +108 -48
- package/src/blocks/input-list.tsx +1 -0
- package/src/blocks/sidebar.tsx +39 -16
- package/src/components/alert-dialog.tsx +18 -2
- package/src/components/banner.tsx +247 -68
- package/src/components/button.tsx +27 -10
- package/src/components/card.tsx +89 -7
- package/src/components/chart.tsx +47 -67
- package/src/components/combobox.tsx +221 -12
- package/src/components/command.tsx +83 -37
- package/src/components/count-indicator.tsx +188 -0
- package/src/components/data-table.tsx +506 -159
- package/src/components/dialog.tsx +74 -5
- package/src/components/drawer.tsx +52 -32
- package/src/components/file-upload.tsx +2574 -0
- package/src/components/global-layout.tsx +18 -5
- package/src/components/hover-card.tsx +395 -65
- package/src/components/input-chip.tsx +67 -2
- package/src/components/input-group.tsx +89 -6
- package/src/components/list.tsx +40 -3
- package/src/components/logo-mark.tsx +109 -25
- package/src/components/media-empty.tsx +62 -7
- package/src/components/multi-select-filter.tsx +9 -16
- package/src/components/pagination.tsx +15 -2
- package/src/components/relative-date.tsx +6 -0
- package/src/components/result-count.tsx +27 -54
- package/src/components/sheet.tsx +86 -8
- package/src/components/single-select-filter.tsx +9 -16
- package/src/components/table.tsx +16 -1
- package/src/components/tabs.tsx +223 -41
- package/src/components/textarea.tsx +271 -4
- package/src/components/tooltip.tsx +29 -2
- package/src/components/typography-text.tsx +7 -2
- package/src/hooks/use-file-dropzone.ts +325 -0
- package/src/index.ts +3 -0
- package/src/lib/empty-canvas.tsx +47 -20
- package/src/lib/empty-chip.tsx +38 -3
- package/src/lib/field-aria.tsx +11 -6
- package/src/lib/table-internal.ts +38 -0
package/dist/command.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";const Z=require("./_virtual/_rolldown/runtime.cjs"),ee=require("./lib/empty-chip.cjs");let e=require("react");e=Z.__toESM(e,1);let V=require("@brightlocal/icons"),w=require("@brightlocal/ui-components/lib/utils"),a=require("react/jsx-runtime"),te=require("@brightlocal/ui-components/button"),ae=require("@brightlocal/ui-components/lib/use-dev-warning"),oe=require("@tanstack/react-virtual"),_=require("cmdk");var M=e.createContext({searchValue:"",setSearchValue:()=>{},activeDescendantId:void 0,setActiveDescendantId:()=>{},listboxId:void 0,setListboxId:()=>{}}),H=e.forwardRef(({className:t,dataHook:o,trackingEl:s,trackingLabel:n,...c},r)=>{const[p,m]=e.useState(""),[k,j]=e.useState(void 0),[y,b]=e.useState(void 0),g=e.useMemo(()=>({searchValue:p,setSearchValue:m,activeDescendantId:k,setActiveDescendantId:j,listboxId:y,setListboxId:b}),[p,k,y]);return(0,a.jsx)(M.Provider,{value:g,children:(0,a.jsx)(_.Command,{ref:r,className:(0,w.cn)("bg-popover text-popover-foreground flex w-full flex-col overflow-hidden rounded-lg border shadow-md",t),"data-hook":o,"data-slot":"command","data-tracking-el":s,"data-tracking-label":n,...c})})});H.displayName="Command";var B=e.forwardRef(({className:t,dataHook:o,trackingEl:s,trackingLabel:n,value:c,onValueChange:r,onClear:p,debounceMs:m,clearSearchAriaLabel:k,...j},y)=>{const b=e.useRef(null),[g,C]=e.useState(""),l=e.useRef(void 0),{setSearchValue:N,activeDescendantId:v,listboxId:u}=e.useContext(M);e.useImperativeHandle(y,()=>b.current,[]),(0,ae.useDevWarning)(()=>!!(m&&m>0&&c!==void 0),"debounceMs is set on <CommandInput> 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.",[m,c]),e.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]),e.useEffect(()=>{const x=b.current;x&&(u&&x.setAttribute("aria-controls",u),v?x.setAttribute("aria-activedescendant",v):x.removeAttribute("aria-activedescendant"))});const E=c!==void 0,R=E?c:g,P=String(R).length>0,L=x=>{E||C(x),N(x),m&&m>0?(clearTimeout(l.current),l.current=setTimeout(()=>{r?.(x)},m)):r?.(x)},f=()=>{E||C(""),N(""),clearTimeout(l.current),r?.(""),p?.(),b.current?.focus()};return(0,a.jsxs)("div",{className:"border-base-border flex h-12 items-center gap-2 self-stretch border-b px-3","data-hook":o,"data-slot":"command-input-wrapper",children:[(0,a.jsx)(V.Search,{className:"shrink-0 opacity-50"}),(0,a.jsx)(_.Command.Input,{ref:b,className:(0,w.cn)("placeholder:text-muted-foreground text-field flex w-full bg-transparent outline-hidden disabled:cursor-not-allowed disabled:opacity-50",t),"data-slot":"command-input","data-tracking-el":s,"data-tracking-label":n,value:R,onValueChange:L,...j}),P&&(0,a.jsx)(te.Button,{"aria-label":k??"Clear search",className:"text-muted-foreground hover:text-foreground size-6 p-0",dataHook:"command-input-clear",variant:"ghost",onClick:f,children:(0,a.jsx)(V.X,{})})]})});B.displayName="CommandInput";var F=e.forwardRef(({className:t,dataHook:o,...s},n)=>(0,a.jsx)(_.Command.List,{ref:n,className:(0,w.cn)("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),"data-hook":o,"data-slot":"command-list",...s}));F.displayName="CommandList";var K=e.forwardRef(({children:t,dataHook:o,description:s,icon:n,...c},r)=>{const p=e.useCallback(m=>{m?.setAttribute("role","option"),typeof r=="function"?r(m):r&&(r.current=m)},[r]);return(0,a.jsx)(_.Command.Empty,{ref:p,"aria-disabled":"true","aria-selected":"false",className:"text-body-sm py-6 text-center","data-hook":o,"data-slot":"command-empty",...c,children:n||s?(0,a.jsxs)("div",{className:"flex flex-col items-center gap-1 px-4",children:[n?(0,a.jsx)(ee.EmptyChip,{className:"mb-1",dataHook:`${o}-icon`,icon:n,slot:"command-empty-icon"}):null,(0,a.jsx)("p",{"data-slot":"command-empty-message",children:t}),s?(0,a.jsx)("p",{className:"text-muted-foreground","data-slot":"command-empty-description",children:s}):null]}):t})});K.displayName="CommandEmpty";var O=e.forwardRef(({className:t,dataHook:o,...s},n)=>(0,a.jsx)(_.Command.Group,{ref:n,className:(0,w.cn)("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:text-label-sm overflow-hidden px-2 py-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5",t),"data-hook":o,"data-slot":"command-group",...s}));O.displayName="CommandGroup";var U=e.forwardRef(({className:t,dataHook:o,...s},n)=>(0,a.jsx)(_.Command.Separator,{ref:n,className:(0,w.cn)("bg-border -mx-1 h-px",t),"data-hook":o,"data-slot":"command-separator",...s}));U.displayName="CommandSeparator";var W=e.forwardRef(({className:t,dataHook:o,trackingEl:s,trackingLabel:n,selected:c,children:r,...p},m)=>(0,a.jsxs)(_.Command.Item,{ref:m,className:(0,w.cn)("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:text-muted-foreground text-label relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-3 outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",t),"data-hook":o,"data-selected-item":c||void 0,"data-slot":"command-item","data-tracking-el":s,"data-tracking-label":n,...p,children:[r,c&&(0,a.jsx)(V.Check,{className:"text-foreground ml-auto"})]}));W.displayName="CommandItem";var X=e.forwardRef(({className:t,dataHook:o,trackingEl:s,trackingLabel:n,...c},r)=>(0,a.jsx)("span",{ref:r,className:(0,w.cn)("text-muted-foreground text-body-xs ml-auto",t),"data-hook":o,"data-slot":"command-shortcut","data-tracking-el":s,"data-tracking-label":n,...c}));X.displayName="CommandShortcut";var Y=e.createContext(null);function ne({items:t,getItemValue:o,getItemLabel:s,getItemKeywords:n,estimateSize:c=44,overscan:r=5,children:p,renderEmpty:m,"aria-label":k,className:j,dataHook:y},b){const g=e.useRef(null),{searchValue:C,setActiveDescendantId:l,setListboxId:N}=e.useContext(M),[v,u]=e.useState(0),E=e.useId(),R=e.useId(),P=e.useRef(new Map);e.useImperativeHandle(b,()=>g.current,[]);const L=e.useMemo(()=>s??o,[s,o]),f=e.useMemo(()=>{if(!C.trim())return t;const i=[];for(const h of t){let d=(0,_.defaultFilter)(L(h),C);if(n)for(const I of n(h))d=Math.max(d,(0,_.defaultFilter)(I,C));d>0&&i.push({item:h,score:d})}return i.sort((h,d)=>d.score-h.score),i.map(h=>h.item)},[t,C,L,n]),x=(0,oe.useVirtualizer)({count:f.length,getScrollElement:()=>g.current,estimateSize:()=>c,overscan:r}),S=v>=0&&v<f.length?o(f[v]):null;e.useEffect(()=>{u(0)},[C,f.length]);const D=e.useRef(!1);e.useEffect(()=>{D.current&&v>=0&&v<f.length&&x.scrollToIndex(v,{align:"auto"}),D.current=!1},[v,f.length,x]),e.useEffect(()=>{const i=g.current?.closest('[data-slot="command"]');if(!i)return;const h=d=>{switch(d.key){case"ArrowDown":d.preventDefault(),d.stopPropagation(),D.current=!0,u(I=>I<f.length-1?I+1:I);break;case"ArrowUp":d.preventDefault(),d.stopPropagation(),D.current=!0,u(I=>I>0?I-1:I);break;case"Enter":d.preventDefault(),d.stopPropagation(),S!=null&&P.current.get(S)?.();break;case"Home":d.preventDefault(),d.stopPropagation(),D.current=!0,u(0);break;case"End":d.preventDefault(),d.stopPropagation(),D.current=!0,u(f.length-1)}};return i.addEventListener("keydown",h,{capture:!0}),()=>i.removeEventListener("keydown",h,{capture:!0})},[f,S]);const q=e.useMemo(()=>{const i=new Map;return f.forEach((h,d)=>{i.set(o(h),d)}),i},[f,o]),A=e.useCallback(i=>{const h=q.get(i);h!==void 0&&u(h)},[q]),T=e.useCallback(i=>(q.get(i)??0)+1,[q]),$=f.length,Q=e.useMemo(()=>({activeValue:S,onItemPointerMove:A,idPrefix:E,filteredCount:$,getItemPosition:T,onSelectCallbacks:P}),[S,A,E,$,T]),z=S!=null?`${E}item-${S}`:void 0;e.useEffect(()=>(l(z),()=>l(void 0)),[z,l]),e.useEffect(()=>(N(R),()=>N(void 0)),[R,N]);const G=(0,w.cn)("scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",j);return f.length===0?(0,a.jsx)("div",{ref:g,"aria-label":k,className:G,"data-hook":y,"data-slot":"command-virtual-list",id:R,role:"listbox",tabIndex:-1,children:m}):(0,a.jsx)(Y.Provider,{value:Q,children:(0,a.jsx)("div",{ref:g,"aria-label":k,className:G,"data-hook":y,"data-slot":"command-virtual-list",id:R,role:"listbox",tabIndex:-1,children:(0,a.jsx)("div",{className:"relative w-full",style:{height:`${x.getTotalSize()}px`},children:x.getVirtualItems().map(i=>(0,a.jsx)("div",{ref:x.measureElement,className:"absolute top-0 left-0 w-full px-2","data-index":i.index,style:{transform:`translateY(${i.start}px)`},children:p(f[i.index],i.index,C)},i.key))})})})}var re=e.forwardRef(ne),J=e.forwardRef(({value:t,dataHook:o,trackingEl:s,trackingLabel:n,selected:c,disabled:r,onSelect:p,children:m,className:k,onClick:j,onKeyDown:y,onPointerMove:b,...g},C)=>{const l=e.useContext(Y),N=l?.activeValue===t,v=e.useRef(p);return e.useEffect(()=>{v.current=p}),e.useEffect(()=>{if(l)return l.onSelectCallbacks.current.set(t,()=>v.current?.()),()=>{l.onSelectCallbacks.current.delete(t)}},[t,l]),(0,a.jsxs)("div",{ref:C,...g,"aria-disabled":r||void 0,"aria-posinset":l?.getItemPosition(t),"aria-selected":c||void 0,"aria-setsize":l?.filteredCount,className:(0,w.cn)("data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground text-label relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-3 outline-hidden select-none","[&_svg]:pointer-events-none [&_svg]:shrink-0",r&&"pointer-events-none opacity-50",k),"data-highlighted":N||void 0,"data-hook":o,"data-selected-item":c||void 0,"data-slot":"command-virtual-item","data-tracking-el":s,"data-tracking-label":n,id:l?`${l.idPrefix}item-${t}`:void 0,role:"option",tabIndex:-1,onClick:r?void 0:u=>{p?.(),j?.(u)},onKeyDown:r?void 0:u=>{(u.key==="Enter"||u.key===" ")&&p?.(),y?.(u)},onPointerMove:r?void 0:u=>{l?.onItemPointerMove(t),b?.(u)},children:[m,c&&(0,a.jsx)(V.Check,{className:"text-foreground ml-auto"})]})});J.displayName="CommandVirtualItem";exports.Command=H;exports.CommandEmpty=K;exports.CommandGroup=O;exports.CommandInput=B;exports.CommandItem=W;exports.CommandList=F;exports.CommandSeparator=U;exports.CommandShortcut=X;exports.CommandVirtualItem=J;exports.CommandVirtualList=re;
|
|
1
|
+
"use client";const Z=require("./_virtual/_rolldown/runtime.cjs"),ee=require("./lib/empty-chip.cjs"),te=require("./blocks/empty-state.cjs");let e=require("react");e=Z.__toESM(e,1);let L=require("@brightlocal/icons"),N=require("@brightlocal/ui-components/lib/utils"),n=require("react/jsx-runtime"),ae=require("@brightlocal/ui-components/button"),oe=require("@brightlocal/ui-components/lib/use-dev-warning"),re=require("@tanstack/react-virtual"),w=require("cmdk");var V=e.createContext({searchValue:"",setSearchValue:()=>{},activeDescendantId:void 0,setActiveDescendantId:()=>{},listboxId:void 0,setListboxId:()=>{}}),H=e.forwardRef(({className:t,dataHook:a,trackingEl:s,trackingLabel:o,...r},u)=>{const[m,p]=e.useState(""),[h,I]=e.useState(void 0),[k,i]=e.useState(void 0),x=e.useMemo(()=>({searchValue:m,setSearchValue:p,activeDescendantId:h,setActiveDescendantId:I,listboxId:k,setListboxId:i}),[m,h,k]);return(0,n.jsx)(V.Provider,{value:x,children:(0,n.jsx)(w.Command,{ref:u,className:(0,N.cn)("bg-popover text-popover-foreground flex w-full flex-col overflow-hidden rounded-lg border shadow-md",t),"data-hook":a,"data-slot":"command","data-tracking-el":s,"data-tracking-label":o,...r})})});H.displayName="Command";var B=e.forwardRef(({className:t,dataHook:a,trackingEl:s,trackingLabel:o,value:r,onValueChange:u,onClear:m,debounceMs:p,clearSearchAriaLabel:h,...I},k)=>{const i=e.useRef(null),[x,y]=e.useState(""),l=e.useRef(void 0),{setSearchValue:E,activeDescendantId:C,listboxId:f}=e.useContext(V);e.useImperativeHandle(k,()=>i.current,[]),(0,oe.useDevWarning)(()=>!!(p&&p>0&&r!==void 0),"debounceMs is set on <CommandInput> 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.",[p,r]),e.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]),e.useEffect(()=>{const g=i.current;!g||!f||(g.setAttribute("aria-controls",f),C?g.setAttribute("aria-activedescendant",C):g.removeAttribute("aria-activedescendant"))});const S=r!==void 0,j=S?r:x,q=String(j).length>0,P=g=>{S||y(g),E(g),p&&p>0?(clearTimeout(l.current),l.current=setTimeout(()=>{u?.(g)},p)):u?.(g)},v=()=>{S||y(""),E(""),clearTimeout(l.current),u?.(""),m?.(),i.current?.focus()};return(0,n.jsxs)("div",{className:"border-base-border flex h-12 items-center gap-2 self-stretch border-b px-3","data-hook":a,"data-slot":"command-input-wrapper",children:[(0,n.jsx)(L.Search,{className:"shrink-0 opacity-50"}),(0,n.jsx)(w.Command.Input,{ref:i,className:(0,N.cn)("placeholder:text-muted-foreground text-field flex w-full bg-transparent outline-hidden disabled:cursor-not-allowed disabled:opacity-50",t),"data-slot":"command-input","data-tracking-el":s,"data-tracking-label":o,value:j,onValueChange:P,...I}),q&&(0,n.jsx)(ae.Button,{"aria-label":h??"Clear search",className:"text-muted-foreground hover:text-foreground size-6 p-0",dataHook:"command-input-clear",variant:"ghost",onClick:v,children:(0,n.jsx)(L.X,{})})]})});B.displayName="CommandInput";var F=e.forwardRef(({className:t,dataHook:a,...s},o)=>(0,n.jsx)(w.Command.List,{ref:o,className:(0,N.cn)("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),"data-hook":a,"data-slot":"command-list",...s}));F.displayName="CommandList";var K=e.forwardRef(({children:t,dataHook:a,description:s,icon:o,title:r,...u},m)=>{const p=!!(o||s)||r!==void 0,h=r!==void 0&&ee.hasEmptyActions(t),I=e.useId(),k=e.useCallback(i=>{if(i){i.setAttribute("role",h?"group":"option");const x=h?i.querySelector('[data-slot="empty-state-title"]'):null;x?(x.id||(x.id=I),i.setAttribute("aria-labelledby",x.id)):i.removeAttribute("aria-labelledby")}typeof m=="function"?m(i):m&&(m.current=i)},[m,h,I]);return(0,n.jsx)(w.Command.Empty,{ref:k,...h?{}:{"aria-disabled":"true","aria-selected":"false"},className:"text-body-sm py-6 text-center","data-hook":a,"data-slot":"command-empty",onKeyDown:h?i=>{i.key==="Enter"&&i.stopPropagation()}:void 0,...u,children:p?(0,n.jsx)(te.EmptyState,{className:"px-4","data-hook":void 0,dataHook:a??"command-empty",description:s,icon:o,size:"sm",title:r===void 0?t:r,children:h?t:null}):t})});K.displayName="CommandEmpty";var O=e.forwardRef(({className:t,dataHook:a,...s},o)=>(0,n.jsx)(w.Command.Group,{ref:o,className:(0,N.cn)("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:text-label-sm overflow-hidden px-2 py-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5",t),"data-hook":a,"data-slot":"command-group",...s}));O.displayName="CommandGroup";var U=e.forwardRef(({className:t,dataHook:a,...s},o)=>(0,n.jsx)(w.Command.Separator,{ref:o,className:(0,N.cn)("bg-border -mx-1 h-px",t),"data-hook":a,"data-slot":"command-separator",...s}));U.displayName="CommandSeparator";var W=e.forwardRef(({className:t,dataHook:a,trackingEl:s,trackingLabel:o,selected:r,children:u,...m},p)=>(0,n.jsxs)(w.Command.Item,{ref:p,className:(0,N.cn)("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:text-muted-foreground text-label relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-3 outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",t),"data-hook":a,"data-selected-item":r||void 0,"data-slot":"command-item","data-tracking-el":s,"data-tracking-label":o,...m,children:[u,r&&(0,n.jsx)(L.Check,{className:"text-foreground ml-auto"})]}));W.displayName="CommandItem";var X=e.forwardRef(({className:t,dataHook:a,trackingEl:s,trackingLabel:o,...r},u)=>(0,n.jsx)("span",{ref:u,className:(0,N.cn)("text-muted-foreground text-body-xs ml-auto",t),"data-hook":a,"data-slot":"command-shortcut","data-tracking-el":s,"data-tracking-label":o,...r}));X.displayName="CommandShortcut";var Y=e.createContext(null);function ne({items:t,getItemValue:a,getItemLabel:s,getItemKeywords:o,estimateSize:r=44,overscan:u=5,children:m,renderEmpty:p,"aria-label":h,className:I,dataHook:k},i){const x=e.useRef(null),{searchValue:y,setActiveDescendantId:l,setListboxId:E}=e.useContext(V),[C,f]=e.useState(0),S=e.useId(),j=e.useId(),q=e.useRef(new Map);e.useImperativeHandle(i,()=>x.current,[]);const P=e.useMemo(()=>s??a,[s,a]),v=e.useMemo(()=>{if(!y.trim())return t;const d=[];for(const b of t){let c=(0,w.defaultFilter)(P(b),y);if(o)for(const _ of o(b))c=Math.max(c,(0,w.defaultFilter)(_,y));c>0&&d.push({item:b,score:c})}return d.sort((b,c)=>c.score-b.score),d.map(b=>b.item)},[t,y,P,o]),g=(0,re.useVirtualizer)({count:v.length,getScrollElement:()=>x.current,estimateSize:()=>r,overscan:u}),R=C>=0&&C<v.length?a(v[C]):null;e.useEffect(()=>{f(0)},[y,v.length]);const D=e.useRef(!1);e.useEffect(()=>{D.current&&C>=0&&C<v.length&&g.scrollToIndex(C,{align:"auto"}),D.current=!1},[C,v.length,g]),e.useEffect(()=>{const d=x.current?.closest('[data-slot="command"]');if(!d)return;const b=c=>{switch(c.key){case"ArrowDown":c.preventDefault(),c.stopPropagation(),D.current=!0,f(_=>_<v.length-1?_+1:_);break;case"ArrowUp":c.preventDefault(),c.stopPropagation(),D.current=!0,f(_=>_>0?_-1:_);break;case"Enter":c.preventDefault(),c.stopPropagation(),R!=null&&q.current.get(R)?.();break;case"Home":c.preventDefault(),c.stopPropagation(),D.current=!0,f(0);break;case"End":c.preventDefault(),c.stopPropagation(),D.current=!0,f(v.length-1)}};return d.addEventListener("keydown",b,{capture:!0}),()=>d.removeEventListener("keydown",b,{capture:!0})},[v,R]);const A=e.useMemo(()=>{const d=new Map;return v.forEach((b,c)=>{d.set(a(b),c)}),d},[v,a]),M=e.useCallback(d=>{const b=A.get(d);b!==void 0&&f(b)},[A]),T=e.useCallback(d=>(A.get(d)??0)+1,[A]),z=v.length,Q=e.useMemo(()=>({activeValue:R,onItemPointerMove:M,idPrefix:S,filteredCount:z,getItemPosition:T,onSelectCallbacks:q}),[R,M,S,z,T]),$=R!=null?`${S}item-${R}`:void 0;e.useEffect(()=>(l($),()=>l(void 0)),[$,l]),e.useEffect(()=>(E(j),()=>E(void 0)),[j,E]);const G=(0,N.cn)("scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",I);return v.length===0?(0,n.jsx)("div",{ref:x,"aria-label":h,className:G,"data-hook":k,"data-slot":"command-virtual-list",id:j,role:"listbox",tabIndex:-1,children:p}):(0,n.jsx)(Y.Provider,{value:Q,children:(0,n.jsx)("div",{ref:x,"aria-label":h,className:G,"data-hook":k,"data-slot":"command-virtual-list",id:j,role:"listbox",tabIndex:-1,children:(0,n.jsx)("div",{className:"relative w-full",style:{height:`${g.getTotalSize()}px`},children:g.getVirtualItems().map(d=>(0,n.jsx)("div",{ref:g.measureElement,className:"absolute top-0 left-0 w-full px-2","data-index":d.index,style:{transform:`translateY(${d.start}px)`},children:m(v[d.index],d.index,y)},d.key))})})})}var se=e.forwardRef(ne),J=e.forwardRef(({value:t,dataHook:a,trackingEl:s,trackingLabel:o,selected:r,disabled:u,onSelect:m,children:p,className:h,onClick:I,onKeyDown:k,onPointerMove:i,...x},y)=>{const l=e.useContext(Y),E=l?.activeValue===t,C=e.useRef(m);return e.useEffect(()=>{C.current=m}),e.useEffect(()=>{if(l)return l.onSelectCallbacks.current.set(t,()=>C.current?.()),()=>{l.onSelectCallbacks.current.delete(t)}},[t,l]),(0,n.jsxs)("div",{ref:y,...x,"aria-disabled":u||void 0,"aria-posinset":l?.getItemPosition(t),"aria-selected":r||void 0,"aria-setsize":l?.filteredCount,className:(0,N.cn)("data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground text-label relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-3 outline-hidden select-none","[&_svg]:pointer-events-none [&_svg]:shrink-0",u&&"pointer-events-none opacity-50",h),"data-highlighted":E||void 0,"data-hook":a,"data-selected-item":r||void 0,"data-slot":"command-virtual-item","data-tracking-el":s,"data-tracking-label":o,id:l?`${l.idPrefix}item-${t}`:void 0,role:"option",tabIndex:-1,onClick:u?void 0:f=>{m?.(),I?.(f)},onKeyDown:u?void 0:f=>{(f.key==="Enter"||f.key===" ")&&m?.(),k?.(f)},onPointerMove:u?void 0:f=>{l?.onItemPointerMove(t),i?.(f)},children:[p,r&&(0,n.jsx)(L.Check,{className:"text-foreground ml-auto"})]})});J.displayName="CommandVirtualItem";exports.Command=H;exports.CommandEmpty=K;exports.CommandGroup=O;exports.CommandInput=B;exports.CommandItem=W;exports.CommandList=F;exports.CommandSeparator=U;exports.CommandShortcut=X;exports.CommandVirtualItem=J;exports.CommandVirtualList=se;
|
package/dist/command.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ declare const CommandList: React.ForwardRefExoticComponent<Omit<CommandListProps
|
|
|
76
76
|
/**
|
|
77
77
|
* Props for the CommandEmpty component
|
|
78
78
|
*/
|
|
79
|
-
export interface CommandEmptyProps extends React.ComponentProps<typeof CommandPrimitive.Empty> {
|
|
79
|
+
export interface CommandEmptyProps extends Omit<React.ComponentProps<typeof CommandPrimitive.Empty>, "title"> {
|
|
80
80
|
/**
|
|
81
81
|
* Data hook for automated testing
|
|
82
82
|
*/
|
|
@@ -87,6 +87,14 @@ export interface CommandEmptyProps extends React.ComponentProps<typeof CommandPr
|
|
|
87
87
|
* (Patterns/Empty States). Decorative; the message carries the state.
|
|
88
88
|
*/
|
|
89
89
|
icon?: React.ReactNode;
|
|
90
|
+
/**
|
|
91
|
+
* The message, e.g. “No locations match “{search}””. Pass it here when the
|
|
92
|
+
* empty state carries actions: `children` then become the actions row under
|
|
93
|
+
* the description, the same split as EmptyState. The line keeps the compact
|
|
94
|
+
* body-sm size; it is never a heading. Without `title`, `children` are the
|
|
95
|
+
* message.
|
|
96
|
+
*/
|
|
97
|
+
title?: React.ReactNode;
|
|
90
98
|
/**
|
|
91
99
|
* One quiet muted line under the message, e.g. "Try a different search."
|
|
92
100
|
*/
|
|
@@ -95,7 +103,9 @@ export interface CommandEmptyProps extends React.ComponentProps<typeof CommandPr
|
|
|
95
103
|
/**
|
|
96
104
|
* Empty state displayed when no results are found. Plain `children` render
|
|
97
105
|
* the one-line form; pass `icon` and/or `description` for the compact form
|
|
98
|
-
* the Empty States pattern uses at popover scope — never hand-roll it.
|
|
106
|
+
* the Empty States pattern uses at popover scope — never hand-roll it. To
|
|
107
|
+
* offer an action (Add location), pass the message as `title` and the
|
|
108
|
+
* buttons as `children`, as in EmptyState.
|
|
99
109
|
*
|
|
100
110
|
* @example
|
|
101
111
|
* ```tsx
|
|
@@ -105,6 +115,17 @@ export interface CommandEmptyProps extends React.ComponentProps<typeof CommandPr
|
|
|
105
115
|
* >
|
|
106
116
|
* No locations match “{search}”
|
|
107
117
|
* </CommandEmpty>
|
|
118
|
+
*
|
|
119
|
+
* <CommandEmpty
|
|
120
|
+
* description="Check the spelling, or add it as a new location."
|
|
121
|
+
* icon={<SearchX />}
|
|
122
|
+
* title={`No locations match “${search}”`}
|
|
123
|
+
* >
|
|
124
|
+
* <Button dataHook="add-location" size="sm" variant="secondary">
|
|
125
|
+
* <Plus />
|
|
126
|
+
* Add location
|
|
127
|
+
* </Button>
|
|
128
|
+
* </CommandEmpty>
|
|
108
129
|
* ```
|
|
109
130
|
*/
|
|
110
131
|
declare const CommandEmpty: React.ForwardRefExoticComponent<Omit<CommandEmptyProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
package/dist/command.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/components/command.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/components/command.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAwCnD;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,KAAK,CAAC,cAAc,CACxD,OAAO,gBAAgB,CACxB;IACC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,QAAA,MAAM,OAAO,kGAuCX,CAAC;AAOH;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,KAAK,CAAC,cAAc,CAC7D,OAAO,gBAAgB,CAAC,KAAK,CAC9B;IACC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;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