@brightlocal/ui-components 3.1.0 → 3.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.
Files changed (176) hide show
  1. package/README.md +6 -1
  2. package/component-meta.json +663 -38
  3. package/deprecations.json +1 -1
  4. package/dist/alert-dialog.cjs +1 -1
  5. package/dist/alert-dialog.d.ts +32 -3
  6. package/dist/alert-dialog.d.ts.map +1 -1
  7. package/dist/alert-dialog.js +61 -58
  8. package/dist/alert.cjs +1 -1
  9. package/dist/alert.d.ts.map +1 -1
  10. package/dist/alert.js +58 -57
  11. package/dist/badge.cjs +1 -1
  12. package/dist/badge.d.ts +9 -0
  13. package/dist/badge.d.ts.map +1 -1
  14. package/dist/badge.js +50 -30
  15. package/dist/banner.cjs +1 -0
  16. package/dist/banner.d.ts +81 -0
  17. package/dist/banner.d.ts.map +1 -0
  18. package/dist/banner.js +176 -0
  19. package/dist/blocks/empty-state.cjs +1 -1
  20. package/dist/blocks/empty-state.d.ts +4 -3
  21. package/dist/blocks/empty-state.d.ts.map +1 -1
  22. package/dist/blocks/empty-state.js +21 -20
  23. package/dist/blocks/progress-state.d.ts +2 -2
  24. package/dist/blocks/sidebar.cjs +1 -1
  25. package/dist/blocks/sidebar.d.ts +17 -0
  26. package/dist/blocks/sidebar.d.ts.map +1 -1
  27. package/dist/blocks/sidebar.js +8 -2
  28. package/dist/brand-illustration-motif.d.ts +1 -1
  29. package/dist/card.cjs +1 -1
  30. package/dist/card.d.ts +86 -6
  31. package/dist/card.d.ts.map +1 -1
  32. package/dist/card.js +185 -96
  33. package/dist/chart.cjs +3 -3
  34. package/dist/chart.d.ts +231 -13
  35. package/dist/chart.d.ts.map +1 -1
  36. package/dist/chart.js +466 -306
  37. package/dist/checkbox.cjs +1 -1
  38. package/dist/checkbox.d.ts +1 -1
  39. package/dist/checkbox.d.ts.map +1 -1
  40. package/dist/checkbox.js +2 -1
  41. package/dist/combobox.cjs +1 -1
  42. package/dist/combobox.js +2 -2
  43. package/dist/command.cjs +1 -1
  44. package/dist/command.js +1 -1
  45. package/dist/data-table.cjs +1 -1
  46. package/dist/data-table.d.ts +169 -22
  47. package/dist/data-table.d.ts.map +1 -1
  48. package/dist/data-table.js +695 -561
  49. package/dist/grid.d.ts +24 -1
  50. package/dist/grid.d.ts.map +1 -1
  51. package/dist/hooks/use-breakpoint.cjs +1 -1
  52. package/dist/hooks/use-breakpoint.d.ts +1 -1
  53. package/dist/hooks/use-breakpoint.d.ts.map +1 -1
  54. package/dist/hooks/use-breakpoint.js +1 -0
  55. package/dist/index.cjs +1 -1
  56. package/dist/index.d.ts +5 -0
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +593 -561
  59. package/dist/info-tooltip.cjs +1 -0
  60. package/dist/info-tooltip.d.ts +39 -0
  61. package/dist/info-tooltip.d.ts.map +1 -0
  62. package/dist/info-tooltip.js +41 -0
  63. package/dist/input-chip.cjs +1 -1
  64. package/dist/input-chip.js +1 -1
  65. package/dist/input-group.cjs +1 -1
  66. package/dist/input-group.d.ts +33 -2
  67. package/dist/input-group.d.ts.map +1 -1
  68. package/dist/input-group.js +167 -54
  69. package/dist/input-otp.cjs +1 -1
  70. package/dist/input-otp.js +9 -9
  71. package/dist/input-password.cjs +1 -1
  72. package/dist/input-password.d.ts +28 -6
  73. package/dist/input-password.d.ts.map +1 -1
  74. package/dist/input-password.js +5 -5
  75. package/dist/input.cjs +1 -1
  76. package/dist/input.js +10 -10
  77. package/dist/lib/block-illustration.cjs +1 -1
  78. package/dist/lib/block-illustration.d.ts +4 -1
  79. package/dist/lib/block-illustration.d.ts.map +1 -1
  80. package/dist/lib/block-illustration.js +12 -11
  81. package/dist/lib/utils.cjs +1 -1
  82. package/dist/lib/utils.d.ts.map +1 -1
  83. package/dist/lib/utils.js +4 -3
  84. package/dist/list.cjs +1 -1
  85. package/dist/list.js +1 -1
  86. package/dist/multi-select-filter.cjs +1 -0
  87. package/dist/multi-select-filter.d.ts +178 -0
  88. package/dist/multi-select-filter.d.ts.map +1 -0
  89. package/dist/multi-select-filter.js +463 -0
  90. package/dist/progress.cjs +1 -1
  91. package/dist/progress.d.ts +123 -16
  92. package/dist/progress.d.ts.map +1 -1
  93. package/dist/progress.js +89 -75
  94. package/dist/rating.cjs +1 -1
  95. package/dist/rating.js +18 -18
  96. package/dist/relative-date.cjs +1 -0
  97. package/dist/relative-date.d.ts +65 -0
  98. package/dist/relative-date.d.ts.map +1 -0
  99. package/dist/relative-date.js +128 -0
  100. package/dist/select.cjs +2 -2
  101. package/dist/select.d.ts +11 -1
  102. package/dist/select.d.ts.map +1 -1
  103. package/dist/select.js +97 -81
  104. package/dist/sheet.cjs +1 -1
  105. package/dist/sheet.d.ts +78 -2
  106. package/dist/sheet.d.ts.map +1 -1
  107. package/dist/sheet.js +192 -85
  108. package/dist/single-select-filter.cjs +1 -0
  109. package/dist/single-select-filter.d.ts +81 -0
  110. package/dist/single-select-filter.d.ts.map +1 -0
  111. package/dist/single-select-filter.js +226 -0
  112. package/dist/sonner.cjs +1 -1
  113. package/dist/sonner.d.ts.map +1 -1
  114. package/dist/sonner.js +22 -22
  115. package/dist/split-layout.cjs +1 -1
  116. package/dist/split-layout.d.ts +1 -1
  117. package/dist/split-layout.js +13 -13
  118. package/dist/table.cjs +1 -1
  119. package/dist/table.d.ts +45 -4
  120. package/dist/table.d.ts.map +1 -1
  121. package/dist/table.js +90 -73
  122. package/dist/tabs.cjs +1 -1
  123. package/dist/tabs.d.ts +12 -1
  124. package/dist/tabs.d.ts.map +1 -1
  125. package/dist/tabs.js +148 -126
  126. package/dist/textarea.cjs +1 -1
  127. package/dist/textarea.js +1 -1
  128. package/dist/tooltip.cjs +1 -1
  129. package/dist/tooltip.d.ts +38 -36
  130. package/dist/tooltip.d.ts.map +1 -1
  131. package/dist/tooltip.js +262 -73
  132. package/dist/typography-text.d.ts +1 -2
  133. package/dist/typography-text.d.ts.map +1 -1
  134. package/dist/typography.d.ts +1 -1
  135. package/package.json +5 -6
  136. package/src/blocks/empty-state.tsx +8 -3
  137. package/src/blocks/progress-state.tsx +2 -2
  138. package/src/blocks/sidebar.tsx +26 -2
  139. package/src/components/alert-dialog.tsx +50 -5
  140. package/src/components/alert.tsx +16 -8
  141. package/src/components/badge.tsx +40 -3
  142. package/src/components/banner.tsx +288 -0
  143. package/src/components/brand-illustration-motif.tsx +1 -1
  144. package/src/components/card.tsx +211 -24
  145. package/src/components/chart.tsx +523 -35
  146. package/src/components/checkbox.tsx +1 -1
  147. package/src/components/combobox.tsx +2 -2
  148. package/src/components/command.tsx +1 -1
  149. package/src/components/data-table.tsx +778 -195
  150. package/src/components/grid.tsx +32 -1
  151. package/src/components/info-tooltip.tsx +94 -0
  152. package/src/components/input-chip.tsx +1 -1
  153. package/src/components/input-group.tsx +246 -11
  154. package/src/components/input-otp.tsx +1 -1
  155. package/src/components/input-password.tsx +33 -11
  156. package/src/components/input.tsx +1 -1
  157. package/src/components/list.tsx +1 -1
  158. package/src/components/multi-select-filter.tsx +912 -0
  159. package/src/components/progress.tsx +190 -31
  160. package/src/components/rating.tsx +1 -1
  161. package/src/components/relative-date.tsx +230 -0
  162. package/src/components/select.tsx +35 -5
  163. package/src/components/sheet.tsx +240 -4
  164. package/src/components/single-select-filter.tsx +443 -0
  165. package/src/components/sonner.tsx +16 -5
  166. package/src/components/split-layout.tsx +2 -2
  167. package/src/components/table.tsx +71 -11
  168. package/src/components/tabs.tsx +93 -46
  169. package/src/components/textarea.tsx +1 -1
  170. package/src/components/tooltip.tsx +440 -68
  171. package/src/components/typography-text.tsx +1 -2
  172. package/src/components/typography.tsx +1 -1
  173. package/src/hooks/use-breakpoint.ts +2 -1
  174. package/src/index.ts +5 -0
  175. package/src/lib/block-illustration.tsx +5 -1
  176. package/src/lib/utils.ts +1 -0
package/dist/checkbox.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),g=require("react"),m=require("@radix-ui/react-checkbox"),x=require("@brightlocal/icons"),p=require("class-variance-authority"),v=require("@brightlocal/ui-components/lib/utils");function s(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const c=s(g),i=s(m),y=p.cva(["size-[18px] shrink-0 self-start mt-0.5","bg-background peer border border-ring dark:bg-input/30 rounded-xs transition-colors duration-fast ease-out outline-none","data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary","focus-visible:border-ring focus-visible:shadow-default","disabled:cursor-not-allowed disabled:opacity-50"],{variants:{error:{true:["border-destructive-40","focus-visible:border-destructive-40 focus-visible:shadow-destructive"]}},defaultVariants:{error:!1}}),n=c.forwardRef(({className:e,disabled:r=!1,error:t,dataHook:a,trackingEl:d,trackingLabel:u,id:l,...b},f)=>{const k=c.useId(),h=l||k;return o.jsx(i.Root,{ref:f,"aria-invalid":t?"true":void 0,className:v.cn(y({error:t}),e),"data-hook":a,"data-slot":"checkbox","data-tracking-el":d,"data-tracking-label":u,disabled:r,id:h,...b,children:o.jsx(i.Indicator,{className:"flex items-center justify-center text-current transition-none","data-slot":"checkbox-indicator",children:o.jsx(x.Check,{})})})});n.displayName="Checkbox";exports.Checkbox=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),g=require("react"),m=require("@radix-ui/react-checkbox"),p=require("@brightlocal/icons"),v=require("class-variance-authority"),y=require("@brightlocal/ui-components/lib/utils");function s(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const o=s(g),i=s(m),n=v.cva(["size-[18px] shrink-0 self-start mt-0.5","bg-background peer border border-ring dark:bg-input/30 rounded-xs transition-colors duration-fast ease-out outline-none","data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary","focus-visible:border-ring focus-visible:shadow-default","disabled:cursor-not-allowed disabled:opacity-50"],{variants:{error:{true:["border-destructive-40","focus-visible:border-destructive-40 focus-visible:shadow-destructive"]}},defaultVariants:{error:!1}}),d=o.forwardRef(({className:e,disabled:r=!1,error:t,dataHook:a,trackingEl:u,trackingLabel:l,id:b,...f},k)=>{const h=o.useId(),x=b||h;return c.jsx(i.Root,{ref:k,"aria-invalid":t?"true":void 0,className:y.cn(n({error:t}),e),"data-hook":a,"data-slot":"checkbox","data-tracking-el":u,"data-tracking-label":l,disabled:r,id:x,...f,children:c.jsx(i.Indicator,{className:"flex items-center justify-center text-current transition-none","data-slot":"checkbox-indicator",children:c.jsx(p.Check,{})})})});d.displayName="Checkbox";exports.Checkbox=d;exports.checkboxVariants=n;
@@ -15,5 +15,5 @@ export interface CheckboxProps extends Omit<React.ComponentProps<typeof Checkbox
15
15
  trackingLabel?: string;
16
16
  }
17
17
  declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
18
- export { Checkbox };
18
+ export { Checkbox, checkboxVariants };
19
19
  //# sourceMappingURL=checkbox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../src/components/checkbox.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,iBAAiB,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGlE,QAAA,MAAM,gBAAgB;;8EA0BrB,CAAC;AAEF,MAAM,WAAW,aACf,SACE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,iBAAiB,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,EACrE,YAAY,CAAC,OAAO,gBAAgB,CAAC;IACvC,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,QAAQ,sGAuCb,CAAC;AAIF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../src/components/checkbox.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,iBAAiB,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGlE,QAAA,MAAM,gBAAgB;;8EA0BrB,CAAC;AAEF,MAAM,WAAW,aACf,SACE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,iBAAiB,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,EACrE,YAAY,CAAC,OAAO,gBAAgB,CAAC;IACvC,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,QAAQ,sGAuCb,CAAC;AAIF,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC"}
package/dist/checkbox.js CHANGED
@@ -69,5 +69,6 @@ const p = k(
69
69
  );
70
70
  x.displayName = "Checkbox";
71
71
  export {
72
- x as Checkbox
72
+ x as Checkbox,
73
+ p as checkboxVariants
73
74
  };
package/dist/combobox.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),ie=require("react"),Y=require("@brightlocal/icons"),ce=require("@tanstack/react-virtual"),le=require("class-variance-authority"),B=require("cmdk"),q=require("@brightlocal/ui-components/lib/utils"),H=require("@brightlocal/ui-components/lib/use-dev-warning"),J=require("@brightlocal/ui-components/popover"),$=require("@brightlocal/ui-components/command"),ue=require("@brightlocal/ui-components/spinner");function de(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const t=de(ie),Q=t.createContext(null),X=t.createContext(null);function z(){const e=t.useContext(Q);if(!e)throw new Error("Combobox components must be used within a <Combobox>");return e}function fe({value:e,onValueChange:r,open:n,onOpenChange:o,onClose:i,shouldFilter:f=!0,disabled:l=!1,itemToStringValue:d,children:m}){const[v,E]=t.useState(""),[x,b]=t.useState(!1),[S,R]=t.useState(()=>new Map),[C,L]=t.useState(""),[V,w]=t.useState(void 0),y=e!==void 0,D=n!==void 0,j=y?e:v,k=D?n:x,M=t.useCallback(g=>{g||L(""),D||b(g),o?.(g)},[D,o]),p=t.useCallback(g=>{y||E(g),r?.(g)},[y,r]),I=t.useRef(i);t.useEffect(()=>{I.current=i},[i]);const F=t.useRef(k);t.useEffect(()=>{F.current&&!k&&I.current?.(),F.current=k},[k]),t.useEffect(()=>()=>{F.current&&I.current?.()},[]);const u=t.useRef(new Map),P=t.useRef(!1),A=t.useRef(!0);t.useEffect(()=>()=>{A.current=!1},[]);const O=t.useCallback(()=>{P.current||(P.current=!0,queueMicrotask(()=>{P.current=!1,A.current&&R(new Map(u.current))}))},[]),T=t.useCallback((g,s)=>{u.current.get(g)!==s&&(u.current.set(g,s),O())},[O]),_=t.useCallback(g=>{for(const[s,c]of g)u.current.set(s,c);R(new Map(u.current))},[]),W=t.useRef(j);t.useLayoutEffect(()=>{W.current=j},[j]);const G=t.useCallback(g=>{g!==W.current&&u.current.has(g)&&(u.current.delete(g),O())},[O]),U=t.useMemo(()=>d?(g,s,c)=>B.defaultFilter(d(g),s,c):B.defaultFilter,[d]),K=t.useMemo(()=>({open:k,setOpen:M,value:j,onValueChange:p,shouldFilter:f,disabled:l,itemLabels:S,registerItem:T,registerItemsSync:_,unregisterItem:G,itemToStringValue:d,filterFn:U,searchValue:C,setSearchValue:L,activeDescendantId:V,setActiveDescendantId:w}),[k,M,j,p,f,l,S,T,_,G,d,U,C,V,w]);return a.jsx(Q.Provider,{value:K,children:a.jsx(J.Popover,{open:k,onOpenChange:M,children:m})})}const be=le.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-body 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-fast ease-out","[&_svg]:pointer-events-none [&_svg]:shrink-0"]),Z=t.forwardRef(({className:e,dataHook:r,error:n,trackingEl:o,trackingLabel:i,children:f,...l},d)=>{const{open:m,disabled:v,value:E}=z(),x=t.useId(),b=!E,S=n||l["aria-invalid"]===!0||l["aria-invalid"]==="true";return a.jsx(J.PopoverTrigger,{asChild:!0,children:a.jsxs("button",{ref:d,"aria-controls":m?x:void 0,"aria-expanded":m,"aria-haspopup":"listbox","aria-invalid":S?"true":void 0,className:q.cn(be(),S&&"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":r,"data-placeholder":b,"data-slot":"combobox-trigger","data-state":m?"open":"closed","data-tracking-el":o||"combobox-trigger","data-tracking-label":i,disabled:v||l.disabled,role:"combobox",type:"button",...l,children:[f,a.jsx(Y.ChevronsUpDown,{"aria-hidden":"true",className:"text-muted-foreground ml-auto shrink-0"})]})})});Z.displayName="ComboboxTrigger";function me(e){return e!=null&&typeof e=="object"&&"value"in e&&typeof e.value=="string"}function ee(e,r,n){if(r)return{getValue:r,getLabel:n??r,hasDistinctLabel:!!n};const o=e[0];if(!me(o))return null;const i=d=>d.value,f="label"in o&&typeof o.label=="string";return{getValue:i,getLabel:n??(f?d=>String(d.label):i),hasDistinctLabel:f||!!n}}function pe({placeholder:e,className:r,displayValue:n,items:o,getItemValue:i,getItemLabel:f}){const{value:l,itemLabels:d}=z(),m=t.useMemo(()=>o?ee(o,i,f):null,[o,i,f]);H.useDevWarning(()=>!!o&&o.length>0&&!m,"ComboboxValue: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.",[o,m]);const v=t.useMemo(()=>!o||!m?null:new Map(o.map(x=>[m.getValue(x),m.getLabel(x)])),[o,m]),E=l?v?.get(l)||d.get(l)||n?.(l)||l:e;return a.jsx("span",{className:q.cn("text-body overflow-hidden text-ellipsis whitespace-nowrap",r),"data-slot":"combobox-value",children:E})}function xe({dataHook:e,className:r,children:n,align:o="start",side:i="bottom",sideOffset:f,avoidCollisions:l,hideList:d=!1,ariaLabel:m}){const{open:v,shouldFilter:E,filterFn:x,itemToStringValue:b}=z(),[S,R]=t.useState(null),C=t.useRef(null),L=t.useCallback(w=>{if(C.current?.(),C.current=null,!w)return;let y=!1;const D=p=>{y||(p==="top"||p==="bottom")&&(y=!0,j.disconnect(),R(p))},j=new MutationObserver(()=>{D(w.getAttribute("data-side"))});j.observe(w,{attributes:!0,attributeFilter:["data-side"]});let k=0,M=0;k=requestAnimationFrame(()=>{M=requestAnimationFrame(()=>{D(w.getAttribute("data-side"))})}),C.current=()=>{y=!0,j.disconnect(),cancelAnimationFrame(k),cancelAnimationFrame(M)}},[]);t.useEffect(()=>{if(!v){C.current?.(),C.current=null;const w=setTimeout(()=>R(null),150);return()=>clearTimeout(w)}},[v]);const V=b?x:void 0;return a.jsx(J.PopoverContent,{ref:L,align:o,"aria-label":m??"Options",avoidCollisions:l,className:q.cn("flex max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] flex-col overflow-hidden p-0",r),collisionPadding:4,"data-slot":"combobox-popover",side:S??i,sideOffset:f,children:a.jsx($.Command,{className:q.cn("min-h-0 flex-1 border-0 shadow-none","[&_[data-slot='command-input-wrapper']]:shrink-0",d&&"[&_[data-slot='command-input-wrapper']]:border-b-0"),"data-slot":"combobox-command",dataHook:e||"combobox-command",filter:V,shouldFilter:E,children:n})})}const te=t.forwardRef(({debounceMs:e,onValueChange:r,...n},o)=>{const{setSearchValue:i,shouldFilter:f,activeDescendantId:l}=z(),d=t.useRef(void 0);H.useDevWarning(()=>!!(e&&e>0&&f),`debounceMs is set on <ComboboxInput> but shouldFilter is true (default).
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),ie=require("react"),Y=require("@brightlocal/icons"),ce=require("@tanstack/react-virtual"),le=require("class-variance-authority"),B=require("cmdk"),q=require("@brightlocal/ui-components/lib/utils"),H=require("@brightlocal/ui-components/lib/use-dev-warning"),J=require("@brightlocal/ui-components/popover"),$=require("@brightlocal/ui-components/command"),ue=require("@brightlocal/ui-components/spinner");function de(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const t=de(ie),Q=t.createContext(null),X=t.createContext(null);function z(){const e=t.useContext(Q);if(!e)throw new Error("Combobox components must be used within a <Combobox>");return e}function fe({value:e,onValueChange:r,open:n,onOpenChange:o,onClose:i,shouldFilter:f=!0,disabled:l=!1,itemToStringValue:d,children:m}){const[v,E]=t.useState(""),[x,b]=t.useState(!1),[S,R]=t.useState(()=>new Map),[C,L]=t.useState(""),[V,w]=t.useState(void 0),y=e!==void 0,D=n!==void 0,j=y?e:v,k=D?n:x,M=t.useCallback(g=>{g||L(""),D||b(g),o?.(g)},[D,o]),p=t.useCallback(g=>{y||E(g),r?.(g)},[y,r]),I=t.useRef(i);t.useEffect(()=>{I.current=i},[i]);const F=t.useRef(k);t.useEffect(()=>{F.current&&!k&&I.current?.(),F.current=k},[k]),t.useEffect(()=>()=>{F.current&&I.current?.()},[]);const u=t.useRef(new Map),P=t.useRef(!1),A=t.useRef(!0);t.useEffect(()=>()=>{A.current=!1},[]);const O=t.useCallback(()=>{P.current||(P.current=!0,queueMicrotask(()=>{P.current=!1,A.current&&R(new Map(u.current))}))},[]),T=t.useCallback((g,s)=>{u.current.get(g)!==s&&(u.current.set(g,s),O())},[O]),_=t.useCallback(g=>{for(const[s,c]of g)u.current.set(s,c);R(new Map(u.current))},[]),W=t.useRef(j);t.useLayoutEffect(()=>{W.current=j},[j]);const G=t.useCallback(g=>{g!==W.current&&u.current.has(g)&&(u.current.delete(g),O())},[O]),U=t.useMemo(()=>d?(g,s,c)=>B.defaultFilter(d(g),s,c):B.defaultFilter,[d]),K=t.useMemo(()=>({open:k,setOpen:M,value:j,onValueChange:p,shouldFilter:f,disabled:l,itemLabels:S,registerItem:T,registerItemsSync:_,unregisterItem:G,itemToStringValue:d,filterFn:U,searchValue:C,setSearchValue:L,activeDescendantId:V,setActiveDescendantId:w}),[k,M,j,p,f,l,S,T,_,G,d,U,C,V,w]);return a.jsx(Q.Provider,{value:K,children:a.jsx(J.Popover,{open:k,onOpenChange:M,children:m})})}const be=le.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-field 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-fast ease-out","[&_svg]:pointer-events-none [&_svg]:shrink-0"]),Z=t.forwardRef(({className:e,dataHook:r,error:n,trackingEl:o,trackingLabel:i,children:f,...l},d)=>{const{open:m,disabled:v,value:E}=z(),x=t.useId(),b=!E,S=n||l["aria-invalid"]===!0||l["aria-invalid"]==="true";return a.jsx(J.PopoverTrigger,{asChild:!0,children:a.jsxs("button",{ref:d,"aria-controls":m?x:void 0,"aria-expanded":m,"aria-haspopup":"listbox","aria-invalid":S?"true":void 0,className:q.cn(be(),S&&"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":r,"data-placeholder":b,"data-slot":"combobox-trigger","data-state":m?"open":"closed","data-tracking-el":o||"combobox-trigger","data-tracking-label":i,disabled:v||l.disabled,role:"combobox",type:"button",...l,children:[f,a.jsx(Y.ChevronsUpDown,{"aria-hidden":"true",className:"text-muted-foreground ml-auto shrink-0"})]})})});Z.displayName="ComboboxTrigger";function me(e){return e!=null&&typeof e=="object"&&"value"in e&&typeof e.value=="string"}function ee(e,r,n){if(r)return{getValue:r,getLabel:n??r,hasDistinctLabel:!!n};const o=e[0];if(!me(o))return null;const i=d=>d.value,f="label"in o&&typeof o.label=="string";return{getValue:i,getLabel:n??(f?d=>String(d.label):i),hasDistinctLabel:f||!!n}}function pe({placeholder:e,className:r,displayValue:n,items:o,getItemValue:i,getItemLabel:f}){const{value:l,itemLabels:d}=z(),m=t.useMemo(()=>o?ee(o,i,f):null,[o,i,f]);H.useDevWarning(()=>!!o&&o.length>0&&!m,"ComboboxValue: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.",[o,m]);const v=t.useMemo(()=>!o||!m?null:new Map(o.map(x=>[m.getValue(x),m.getLabel(x)])),[o,m]),E=l?v?.get(l)||d.get(l)||n?.(l)||l:e;return a.jsx("span",{className:q.cn("text-field overflow-hidden text-ellipsis whitespace-nowrap",r),"data-slot":"combobox-value",children:E})}function xe({dataHook:e,className:r,children:n,align:o="start",side:i="bottom",sideOffset:f,avoidCollisions:l,hideList:d=!1,ariaLabel:m}){const{open:v,shouldFilter:E,filterFn:x,itemToStringValue:b}=z(),[S,R]=t.useState(null),C=t.useRef(null),L=t.useCallback(w=>{if(C.current?.(),C.current=null,!w)return;let y=!1;const D=p=>{y||(p==="top"||p==="bottom")&&(y=!0,j.disconnect(),R(p))},j=new MutationObserver(()=>{D(w.getAttribute("data-side"))});j.observe(w,{attributes:!0,attributeFilter:["data-side"]});let k=0,M=0;k=requestAnimationFrame(()=>{M=requestAnimationFrame(()=>{D(w.getAttribute("data-side"))})}),C.current=()=>{y=!0,j.disconnect(),cancelAnimationFrame(k),cancelAnimationFrame(M)}},[]);t.useEffect(()=>{if(!v){C.current?.(),C.current=null;const w=setTimeout(()=>R(null),150);return()=>clearTimeout(w)}},[v]);const V=b?x:void 0;return a.jsx(J.PopoverContent,{ref:L,align:o,"aria-label":m??"Options",avoidCollisions:l,className:q.cn("flex max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] flex-col overflow-hidden p-0",r),collisionPadding:4,"data-slot":"combobox-popover",side:S??i,sideOffset:f,children:a.jsx($.Command,{className:q.cn("min-h-0 flex-1 border-0 shadow-none","[&_[data-slot='command-input-wrapper']]:shrink-0",d&&"[&_[data-slot='command-input-wrapper']]:border-b-0"),"data-slot":"combobox-command",dataHook:e||"combobox-command",filter:V,shouldFilter:E,children:n})})}const te=t.forwardRef(({debounceMs:e,onValueChange:r,...n},o)=>{const{setSearchValue:i,shouldFilter:f,activeDescendantId:l}=z(),d=t.useRef(void 0);H.useDevWarning(()=>!!(e&&e>0&&f),`debounceMs is set on <ComboboxInput> but shouldFilter is true (default).
2
2
  Debounce is designed for async/server-driven search where the consumer controls the items list.
3
3
  Set shouldFilter={false} on <Combobox> for async search, or remove debounceMs for client-side filtering.`,[e,f]),H.useDevWarning(()=>!!(e&&e>0&&n.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,n.value]),t.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);const m=t.useCallback(v=>{i(v),e&&e>0?(clearTimeout(d.current),d.current=setTimeout(()=>{r?.(v)},e)):r?.(v)},[e,r,i]);return a.jsx($.CommandInput,{ref:o,"aria-activedescendant":l,"data-slot":"combobox-input",onValueChange:m,...n})});te.displayName="ComboboxInput";const oe=t.forwardRef(({className:e,...r},n)=>a.jsx($.CommandList,{ref:n,className:q.cn("scrollbar min-h-0 flex-1",e),"data-slot":"combobox-list",...r}));oe.displayName="ComboboxList";function ge({items:e,getItemValue:r,getItemLabel:n,getItemKeywords:o,estimateSize:i=36,overscan:f=5,children:l,renderEmpty:d,className:m,dataHook:v},E){const x=t.useMemo(()=>ee(e,r,n),[e,r,n]),b=t.useMemo(()=>x?.getValue??(s=>{if(typeof s=="string"||typeof s=="number")return String(s);throw new Error("[BrightLocal DS] ComboboxVirtualList: `getItemValue` is required for non-primitive items without a `value` property.")}),[x]),S=t.useMemo(()=>x?.getLabel??b,[x,b]);H.useDevWarning(()=>!x&&e.length>0,"ComboboxVirtualList: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.",[x,e.length]);const R=t.useRef(null),{value:C,onValueChange:L,setOpen:V,shouldFilter:w,searchValue:y,filterFn:D,setActiveDescendantId:j,registerItemsSync:k,unregisterItem:M}=z(),[p,I]=t.useState(0),F=t.useId();t.useImperativeHandle(E,()=>R.current,[]),t.useLayoutEffect(()=>{const s=e.map(c=>[b(c),S(c)]);return k(s),()=>{for(const c of e)M(b(c))}},[e,b,S,k,M]);const u=t.useMemo(()=>{if(!w||!y.trim())return e;const s=[];for(const c of e){let h=x?.hasDistinctLabel?B.defaultFilter(S(c),y):D(b(c),y);if(o)for(const N of o(c))h=Math.max(h,B.defaultFilter(N,y));h>0&&s.push({item:c,score:h})}return s.sort((c,h)=>h.score-c.score),s.map(c=>c.item)},[e,w,y,b,S,o,D,x?.hasDistinctLabel]),P=ce.useVirtualizer({count:u.length,getScrollElement:()=>R.current,estimateSize:()=>i,overscan:f}),A=p>=0&&p<u.length?b(u[p]):null;t.useEffect(()=>{I(0)},[y,u.length]);const O=t.useRef(!1);t.useEffect(()=>{if(O.current||!C)return;const s=u.findIndex(c=>b(c)===C);s>=0&&(I(s),P.scrollToIndex(s,{align:"center"}),O.current=!0)},[C,u,b,P]);const T=t.useRef(!1);t.useEffect(()=>{T.current&&p>=0&&p<u.length&&P.scrollToIndex(p,{align:"auto"}),T.current=!1},[p,u.length,P]),t.useEffect(()=>{const s=R.current?.closest('[data-slot="combobox-command"]');if(!s)return;const c=h=>{switch(h.key){case"ArrowDown":h.preventDefault(),h.stopPropagation(),T.current=!0,I(N=>N<u.length-1?N+1:N);break;case"ArrowUp":h.preventDefault(),h.stopPropagation(),T.current=!0,I(N=>N>0?N-1:N);break;case"Enter":if(h.preventDefault(),h.stopPropagation(),p>=0&&p<u.length){const N=b(u[p]);L(N===C?"":N),V(!1)}break;case"Home":h.preventDefault(),h.stopPropagation(),T.current=!0,I(0);break;case"End":h.preventDefault(),h.stopPropagation(),T.current=!0,I(u.length-1);break}};return s.addEventListener("keydown",c,{capture:!0}),()=>s.removeEventListener("keydown",c,{capture:!0})},[u,p,C,L,V,b]);const _=t.useMemo(()=>{const s=new Map;return u.forEach((c,h)=>{s.set(b(c),h)}),s},[u,b]),W=t.useCallback(s=>{const c=_.get(s);c!==void 0&&I(c)},[_]),G=t.useCallback(s=>(_.get(s)??0)+1,[_]),U=u.length,K=t.useMemo(()=>({activeValue:A,onItemPointerMove:W,idPrefix:F,filteredCount:U,getItemPosition:G}),[A,W,F,U,G]),g=A!=null?`${F}item-${A}`:void 0;return t.useEffect(()=>(j(g),()=>j(void 0)),[g,j]),u.length===0?a.jsx("div",{ref:R,className:q.cn("scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",m),"data-hook":v,"data-slot":"combobox-virtual-list",role:"listbox",children:d}):a.jsx(X.Provider,{value:K,children:a.jsx("div",{ref:R,className:q.cn("scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",m),"data-hook":v,"data-slot":"combobox-virtual-list",role:"listbox",children:a.jsx("div",{className:"relative w-full",style:{height:`${P.getTotalSize()}px`},children:P.getVirtualItems().map(s=>a.jsx("div",{ref:P.measureElement,className:"absolute top-0 left-0 w-full px-2","data-index":s.index,style:{transform:`translateY(${s.start}px)`},children:l(u[s.index],s.index,y)},s.key))})})})}const he=t.forwardRef(ge),re=t.forwardRef((e,r)=>a.jsx($.CommandEmpty,{ref:r,"data-slot":"combobox-empty",...e}));re.displayName="ComboboxEmpty";const ne=t.forwardRef(({children:e,...r},n)=>{const o=t.useRef(null);return H.useDevWarning(()=>o.current?o.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
4
  Import: import { ComboboxVirtualList } from "@brightlocal/ui-components/combobox"`,[e]),a.jsx($.CommandGroup,{ref:i=>{o.current=i,typeof n=="function"?n(i):n&&(n.current=i)},"data-slot":"combobox-group",...r,children:e})});ne.displayName="ComboboxGroup";function ve(e,r,n){if(!r||!r.trim())return e;const o=new RegExp(`(${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi"),i=e.split(o);return a.jsx("span",{children:i.map((f,l)=>l%2===1?a.jsx("span",{className:n,children:f},l):a.jsx(t.Fragment,{children:f},l))})}const se=t.forwardRef(({value:e,label:r,dataHook:n,children:o,className:i,highlight:f,highlightClassName:l,keywords:d,onSelect:m,...v},E)=>{const{value:x,onValueChange:b,setOpen:S,registerItem:R,unregisterItem:C}=z(),L=t.useContext(X),V=x===e,w=t.useMemo(()=>r||(typeof o=="string"?o:typeof o=="number"?String(o):e),[r,o,e]),y=t.useRef(R),D=t.useRef(C);t.useEffect(()=>{y.current=R,D.current=C},[R,C]);const j=!!L;t.useEffect(()=>{if(!j)return y.current(e,w),()=>D.current(e)},[e,w,j]);const k=()=>{b(e===x?"":e),S(!1),m?.(e)},M=()=>f&&typeof o=="string"?ve(o,f,l||"text-label font-semibold"):o;if(L){const p=L.activeValue===e,I=!!v.disabled;return a.jsxs("div",{ref:E,"aria-disabled":I||void 0,"aria-posinset":L.getItemPosition(e),"aria-selected":V,"aria-setsize":L.filteredCount,className:q.cn("data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground text-label relative flex cursor-default items-center justify-between gap-2 rounded-sm px-2 py-3 outline-hidden select-none","[&_svg]:pointer-events-none [&_svg]:shrink-0",I&&"pointer-events-none opacity-50",i),"data-highlighted":p||void 0,"data-hook":n,"data-slot":"combobox-item",id:`${L.idPrefix}item-${e}`,role:"option",tabIndex:-1,onClick:I?void 0:k,onKeyDown:I?void 0:F=>{(F.key==="Enter"||F.key===" ")&&k()},onPointerMove:I?void 0:()=>L.onItemPointerMove(e),children:[M(),V&&a.jsx(Y.Check,{"aria-hidden":"true",className:"text-muted-foreground shrink-0"})]})}return a.jsxs($.CommandItem,{ref:E,className:q.cn("justify-between",i),"data-slot":"combobox-item",dataHook:n,keywords:d?[w,...d]:[w],value:e,onSelect:k,...v,children:[M(),V&&a.jsx(Y.Check,{"aria-hidden":"true",className:"text-muted-foreground shrink-0"})]})});se.displayName="ComboboxItem";const ae=t.forwardRef((e,r)=>a.jsx($.CommandSeparator,{ref:r,"data-slot":"combobox-separator",...e}));ae.displayName="ComboboxSeparator";function Ce({className:e,children:r,loadingText:n}){return a.jsx("div",{"aria-live":"polite",className:q.cn("text-body-sm text-muted-foreground relative flex items-center justify-center gap-2 py-6","animate-entrance-fade flash-delay",e),"data-slot":"combobox-loading",role:"status",children:r||a.jsxs(a.Fragment,{children:[a.jsx(ue.Spinner,{size:"md"}),a.jsx("span",{className:"sr-only",children:n??"Loading suggestions"})]})})}exports.Combobox=fe;exports.ComboboxContent=xe;exports.ComboboxEmpty=re;exports.ComboboxGroup=ne;exports.ComboboxInput=te;exports.ComboboxItem=se;exports.ComboboxList=oe;exports.ComboboxLoading=Ce;exports.ComboboxSeparator=ae;exports.ComboboxTrigger=Z;exports.ComboboxValue=pe;exports.ComboboxVirtualList=he;
package/dist/combobox.js CHANGED
@@ -129,7 +129,7 @@ const me = oe([
129
129
  "bg-neutral-50 shadow-xs",
130
130
  "dark:bg-white/5 dark:border-white/15",
131
131
  // Typography
132
- "text-body text-foreground",
132
+ "text-field text-foreground",
133
133
  // Placeholder state
134
134
  "data-[placeholder=true]:text-muted-foreground",
135
135
  // Focus state
@@ -235,7 +235,7 @@ function $e({
235
235
  "span",
236
236
  {
237
237
  className: T(
238
- "text-body overflow-hidden text-ellipsis whitespace-nowrap",
238
+ "text-field overflow-hidden text-ellipsis whitespace-nowrap",
239
239
  r
240
240
  ),
241
241
  "data-slot": "combobox-value",
package/dist/command.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),Z=require("react"),N=require("cmdk"),ee=require("@tanstack/react-virtual"),_=require("@brightlocal/icons"),te=require("@brightlocal/ui-components/button"),y=require("@brightlocal/ui-components/lib/utils"),ae=require("@brightlocal/ui-components/lib/use-dev-warning"),oe=require("./lib/empty-chip.cjs");function ne(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(a,o,n.get?n:{enumerable:!0,get:()=>t[o]})}}return a.default=t,Object.freeze(a)}const e=ne(Z),A=e.createContext({searchValue:"",setSearchValue:()=>{},activeDescendantId:void 0,setActiveDescendantId:()=>{},listboxId:void 0,setListboxId:()=>{}}),G=e.forwardRef(({className:t,dataHook:a,trackingEl:o,trackingLabel:n,...i},s)=>{const[p,u]=e.useState(""),[I,S]=e.useState(void 0),[w,C]=e.useState(void 0),v=e.useMemo(()=>({searchValue:p,setSearchValue:u,activeDescendantId:I,setActiveDescendantId:S,listboxId:w,setListboxId:C}),[p,I,w]);return r.jsx(A.Provider,{value:v,children:r.jsx(N.Command,{ref:s,className:y.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":o,"data-tracking-label":n,...i})})});G.displayName="Command";const H=e.forwardRef(({className:t,dataHook:a,trackingEl:o,trackingLabel:n,value:i,onValueChange:s,onClear:p,debounceMs:u,clearSearchAriaLabel:I,...S},w)=>{const C=e.useRef(null),[v,b]=e.useState(""),d=e.useRef(void 0),{setSearchValue:j,activeDescendantId:g,listboxId:m}=e.useContext(A);e.useImperativeHandle(w,()=>C.current,[]),ae.useDevWarning(()=>!!(u&&u>0&&i!==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.",[u,i]),e.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]),e.useEffect(()=>{const x=C.current;x&&(m&&x.setAttribute("aria-controls",m),g?x.setAttribute("aria-activedescendant",g):x.removeAttribute("aria-activedescendant"))});const R=i!==void 0,E=R?i:v,L=String(E).length>0,V=x=>{R||b(x),j(x),u&&u>0?(clearTimeout(d.current),d.current=setTimeout(()=>{s?.(x)},u)):s?.(x)},f=()=>{R||b(""),j(""),clearTimeout(d.current),s?.(""),p?.(),C.current?.focus()};return r.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:[r.jsx(_.Search,{className:"shrink-0 opacity-50"}),r.jsx(N.Command.Input,{ref:C,className:y.cn("placeholder:text-muted-foreground text-body flex w-full bg-transparent outline-hidden disabled:cursor-not-allowed disabled:opacity-50",t),"data-slot":"command-input","data-tracking-el":o,"data-tracking-label":n,value:E,onValueChange:V,...S}),L&&r.jsx(te.Button,{"aria-label":I??"Clear search",className:"text-muted-foreground hover:text-foreground size-6 p-0",dataHook:"command-input-clear",variant:"ghost",onClick:f,children:r.jsx(_.X,{})})]})});H.displayName="CommandInput";const B=e.forwardRef(({className:t,dataHook:a,...o},n)=>r.jsx(N.Command.List,{ref:n,className:y.cn("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),"data-hook":a,"data-slot":"command-list",...o}));B.displayName="CommandList";const F=e.forwardRef(({children:t,dataHook:a,description:o,icon:n,...i},s)=>{const p=e.useCallback(u=>{u?.setAttribute("role","option"),typeof s=="function"?s(u):s&&(s.current=u)},[s]);return r.jsx(N.Command.Empty,{ref:p,"aria-disabled":"true","aria-selected":"false",className:"text-body-sm py-6 text-center","data-hook":a,"data-slot":"command-empty",...i,children:n||o?r.jsxs("div",{className:"flex flex-col items-center gap-1 px-4",children:[n?r.jsx("span",{"aria-hidden":"true",className:y.cn(oe.emptyChipStyles(),"mb-1"),"data-slot":"command-empty-icon",children:n}):null,r.jsx("p",{"data-slot":"command-empty-message",children:t}),o?r.jsx("p",{className:"text-muted-foreground","data-slot":"command-empty-description",children:o}):null]}):t})});F.displayName="CommandEmpty";const W=e.forwardRef(({className:t,dataHook:a,...o},n)=>r.jsx(N.Command.Group,{ref:n,className:y.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",...o}));W.displayName="CommandGroup";const K=e.forwardRef(({className:t,dataHook:a,...o},n)=>r.jsx(N.Command.Separator,{ref:n,className:y.cn("bg-border -mx-1 h-px",t),"data-hook":a,"data-slot":"command-separator",...o}));K.displayName="CommandSeparator";const U=e.forwardRef(({className:t,dataHook:a,trackingEl:o,trackingLabel:n,selected:i,children:s,...p},u)=>r.jsxs(N.Command.Item,{ref:u,className:y.cn("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:text-muted-foreground text-label relative flex cursor-default 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":i||void 0,"data-slot":"command-item","data-tracking-el":o,"data-tracking-label":n,...p,children:[s,i&&r.jsx(_.Check,{className:"text-foreground ml-auto"})]}));U.displayName="CommandItem";const X=e.forwardRef(({className:t,dataHook:a,trackingEl:o,trackingLabel:n,...i},s)=>r.jsx("span",{ref:s,className:y.cn("text-muted-foreground text-body-xs ml-auto",t),"data-hook":a,"data-slot":"command-shortcut","data-tracking-el":o,"data-tracking-label":n,...i}));X.displayName="CommandShortcut";const Y=e.createContext(null);function re({items:t,getItemValue:a,getItemLabel:o,getItemKeywords:n,estimateSize:i=44,overscan:s=5,children:p,renderEmpty:u,"aria-label":I,className:S,dataHook:w},C){const v=e.useRef(null),{searchValue:b,setActiveDescendantId:d,setListboxId:j}=e.useContext(A),[g,m]=e.useState(0),R=e.useId(),E=e.useId(),L=e.useRef(new Map);e.useImperativeHandle(C,()=>v.current,[]);const V=e.useMemo(()=>o??a,[o,a]),f=e.useMemo(()=>{if(!b.trim())return t;const c=[];for(const h of t){let l=N.defaultFilter(V(h),b);if(n)for(const k of n(h))l=Math.max(l,N.defaultFilter(k,b));l>0&&c.push({item:h,score:l})}return c.sort((h,l)=>l.score-h.score),c.map(h=>h.item)},[t,b,V,n]),x=ee.useVirtualizer({count:f.length,getScrollElement:()=>v.current,estimateSize:()=>i,overscan:s}),D=g>=0&&g<f.length?a(f[g]):null;e.useEffect(()=>{m(0)},[b,f.length]);const P=e.useRef(!1);e.useEffect(()=>{P.current&&g>=0&&g<f.length&&x.scrollToIndex(g,{align:"auto"}),P.current=!1},[g,f.length,x]),e.useEffect(()=>{const c=v.current?.closest('[data-slot="command"]');if(!c)return;const h=l=>{switch(l.key){case"ArrowDown":l.preventDefault(),l.stopPropagation(),P.current=!0,m(k=>k<f.length-1?k+1:k);break;case"ArrowUp":l.preventDefault(),l.stopPropagation(),P.current=!0,m(k=>k>0?k-1:k);break;case"Enter":{l.preventDefault(),l.stopPropagation(),D!=null&&L.current.get(D)?.();break}case"Home":l.preventDefault(),l.stopPropagation(),P.current=!0,m(0);break;case"End":l.preventDefault(),l.stopPropagation(),P.current=!0,m(f.length-1);break}};return c.addEventListener("keydown",h,{capture:!0}),()=>c.removeEventListener("keydown",h,{capture:!0})},[f,D]);const M=e.useMemo(()=>{const c=new Map;return f.forEach((h,l)=>{c.set(a(h),l)}),c},[f,a]),q=e.useCallback(c=>{const h=M.get(c);h!==void 0&&m(h)},[M]),T=e.useCallback(c=>(M.get(c)??0)+1,[M]),z=f.length,Q=e.useMemo(()=>({activeValue:D,onItemPointerMove:q,idPrefix:R,filteredCount:z,getItemPosition:T,onSelectCallbacks:L}),[D,q,R,z,T]),O=D!=null?`${R}item-${D}`:void 0;e.useEffect(()=>(d(O),()=>d(void 0)),[O,d]),e.useEffect(()=>(j(E),()=>j(void 0)),[E,j]);const $=y.cn("scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",S);return f.length===0?r.jsx("div",{ref:v,"aria-label":I,className:$,"data-hook":w,"data-slot":"command-virtual-list",id:E,role:"listbox",tabIndex:-1,children:u}):r.jsx(Y.Provider,{value:Q,children:r.jsx("div",{ref:v,"aria-label":I,className:$,"data-hook":w,"data-slot":"command-virtual-list",id:E,role:"listbox",tabIndex:-1,children:r.jsx("div",{className:"relative w-full",style:{height:`${x.getTotalSize()}px`},children:x.getVirtualItems().map(c=>r.jsx("div",{ref:x.measureElement,className:"absolute top-0 left-0 w-full px-2","data-index":c.index,style:{transform:`translateY(${c.start}px)`},children:p(f[c.index],c.index,b)},c.key))})})})}const se=e.forwardRef(re),J=e.forwardRef(({value:t,dataHook:a,trackingEl:o,trackingLabel:n,selected:i,disabled:s,onSelect:p,children:u,className:I,onClick:S,onKeyDown:w,onPointerMove:C,...v},b)=>{const d=e.useContext(Y),j=d?.activeValue===t,g=e.useRef(p);return e.useEffect(()=>{g.current=p}),e.useEffect(()=>{if(d)return d.onSelectCallbacks.current.set(t,()=>g.current?.()),()=>{d.onSelectCallbacks.current.delete(t)}},[t,d]),r.jsxs("div",{ref:b,...v,"aria-disabled":s||void 0,"aria-posinset":d?.getItemPosition(t),"aria-selected":i||void 0,"aria-setsize":d?.filteredCount,className:y.cn("data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground text-label relative flex cursor-default items-center gap-2 rounded-sm px-2 py-3 outline-hidden select-none","[&_svg]:pointer-events-none [&_svg]:shrink-0",s&&"pointer-events-none opacity-50",I),"data-highlighted":j||void 0,"data-hook":a,"data-selected-item":i||void 0,"data-slot":"command-virtual-item","data-tracking-el":o,"data-tracking-label":n,id:d?`${d.idPrefix}item-${t}`:void 0,role:"option",tabIndex:-1,onClick:s?void 0:m=>{p?.(),S?.(m)},onKeyDown:s?void 0:m=>{(m.key==="Enter"||m.key===" ")&&p?.(),w?.(m)},onPointerMove:s?void 0:m=>{d?.onItemPointerMove(t),C?.(m)},children:[u,i&&r.jsx(_.Check,{className:"text-foreground ml-auto"})]})});J.displayName="CommandVirtualItem";exports.Command=G;exports.CommandEmpty=F;exports.CommandGroup=W;exports.CommandInput=H;exports.CommandItem=U;exports.CommandList=B;exports.CommandSeparator=K;exports.CommandShortcut=X;exports.CommandVirtualItem=J;exports.CommandVirtualList=se;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),Z=require("react"),N=require("cmdk"),ee=require("@tanstack/react-virtual"),_=require("@brightlocal/icons"),te=require("@brightlocal/ui-components/button"),y=require("@brightlocal/ui-components/lib/utils"),ae=require("@brightlocal/ui-components/lib/use-dev-warning"),oe=require("./lib/empty-chip.cjs");function ne(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(a,o,n.get?n:{enumerable:!0,get:()=>t[o]})}}return a.default=t,Object.freeze(a)}const e=ne(Z),A=e.createContext({searchValue:"",setSearchValue:()=>{},activeDescendantId:void 0,setActiveDescendantId:()=>{},listboxId:void 0,setListboxId:()=>{}}),G=e.forwardRef(({className:t,dataHook:a,trackingEl:o,trackingLabel:n,...i},s)=>{const[p,u]=e.useState(""),[I,S]=e.useState(void 0),[w,b]=e.useState(void 0),v=e.useMemo(()=>({searchValue:p,setSearchValue:u,activeDescendantId:I,setActiveDescendantId:S,listboxId:w,setListboxId:b}),[p,I,w]);return r.jsx(A.Provider,{value:v,children:r.jsx(N.Command,{ref:s,className:y.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":o,"data-tracking-label":n,...i})})});G.displayName="Command";const H=e.forwardRef(({className:t,dataHook:a,trackingEl:o,trackingLabel:n,value:i,onValueChange:s,onClear:p,debounceMs:u,clearSearchAriaLabel:I,...S},w)=>{const b=e.useRef(null),[v,C]=e.useState(""),d=e.useRef(void 0),{setSearchValue:j,activeDescendantId:g,listboxId:m}=e.useContext(A);e.useImperativeHandle(w,()=>b.current,[]),ae.useDevWarning(()=>!!(u&&u>0&&i!==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.",[u,i]),e.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]),e.useEffect(()=>{const x=b.current;x&&(m&&x.setAttribute("aria-controls",m),g?x.setAttribute("aria-activedescendant",g):x.removeAttribute("aria-activedescendant"))});const R=i!==void 0,E=R?i:v,L=String(E).length>0,V=x=>{R||C(x),j(x),u&&u>0?(clearTimeout(d.current),d.current=setTimeout(()=>{s?.(x)},u)):s?.(x)},f=()=>{R||C(""),j(""),clearTimeout(d.current),s?.(""),p?.(),b.current?.focus()};return r.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:[r.jsx(_.Search,{className:"shrink-0 opacity-50"}),r.jsx(N.Command.Input,{ref:b,className:y.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":o,"data-tracking-label":n,value:E,onValueChange:V,...S}),L&&r.jsx(te.Button,{"aria-label":I??"Clear search",className:"text-muted-foreground hover:text-foreground size-6 p-0",dataHook:"command-input-clear",variant:"ghost",onClick:f,children:r.jsx(_.X,{})})]})});H.displayName="CommandInput";const B=e.forwardRef(({className:t,dataHook:a,...o},n)=>r.jsx(N.Command.List,{ref:n,className:y.cn("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),"data-hook":a,"data-slot":"command-list",...o}));B.displayName="CommandList";const F=e.forwardRef(({children:t,dataHook:a,description:o,icon:n,...i},s)=>{const p=e.useCallback(u=>{u?.setAttribute("role","option"),typeof s=="function"?s(u):s&&(s.current=u)},[s]);return r.jsx(N.Command.Empty,{ref:p,"aria-disabled":"true","aria-selected":"false",className:"text-body-sm py-6 text-center","data-hook":a,"data-slot":"command-empty",...i,children:n||o?r.jsxs("div",{className:"flex flex-col items-center gap-1 px-4",children:[n?r.jsx("span",{"aria-hidden":"true",className:y.cn(oe.emptyChipStyles(),"mb-1"),"data-slot":"command-empty-icon",children:n}):null,r.jsx("p",{"data-slot":"command-empty-message",children:t}),o?r.jsx("p",{className:"text-muted-foreground","data-slot":"command-empty-description",children:o}):null]}):t})});F.displayName="CommandEmpty";const W=e.forwardRef(({className:t,dataHook:a,...o},n)=>r.jsx(N.Command.Group,{ref:n,className:y.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",...o}));W.displayName="CommandGroup";const K=e.forwardRef(({className:t,dataHook:a,...o},n)=>r.jsx(N.Command.Separator,{ref:n,className:y.cn("bg-border -mx-1 h-px",t),"data-hook":a,"data-slot":"command-separator",...o}));K.displayName="CommandSeparator";const U=e.forwardRef(({className:t,dataHook:a,trackingEl:o,trackingLabel:n,selected:i,children:s,...p},u)=>r.jsxs(N.Command.Item,{ref:u,className:y.cn("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:text-muted-foreground text-label relative flex cursor-default 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":i||void 0,"data-slot":"command-item","data-tracking-el":o,"data-tracking-label":n,...p,children:[s,i&&r.jsx(_.Check,{className:"text-foreground ml-auto"})]}));U.displayName="CommandItem";const X=e.forwardRef(({className:t,dataHook:a,trackingEl:o,trackingLabel:n,...i},s)=>r.jsx("span",{ref:s,className:y.cn("text-muted-foreground text-body-xs ml-auto",t),"data-hook":a,"data-slot":"command-shortcut","data-tracking-el":o,"data-tracking-label":n,...i}));X.displayName="CommandShortcut";const Y=e.createContext(null);function re({items:t,getItemValue:a,getItemLabel:o,getItemKeywords:n,estimateSize:i=44,overscan:s=5,children:p,renderEmpty:u,"aria-label":I,className:S,dataHook:w},b){const v=e.useRef(null),{searchValue:C,setActiveDescendantId:d,setListboxId:j}=e.useContext(A),[g,m]=e.useState(0),R=e.useId(),E=e.useId(),L=e.useRef(new Map);e.useImperativeHandle(b,()=>v.current,[]);const V=e.useMemo(()=>o??a,[o,a]),f=e.useMemo(()=>{if(!C.trim())return t;const c=[];for(const h of t){let l=N.defaultFilter(V(h),C);if(n)for(const k of n(h))l=Math.max(l,N.defaultFilter(k,C));l>0&&c.push({item:h,score:l})}return c.sort((h,l)=>l.score-h.score),c.map(h=>h.item)},[t,C,V,n]),x=ee.useVirtualizer({count:f.length,getScrollElement:()=>v.current,estimateSize:()=>i,overscan:s}),D=g>=0&&g<f.length?a(f[g]):null;e.useEffect(()=>{m(0)},[C,f.length]);const P=e.useRef(!1);e.useEffect(()=>{P.current&&g>=0&&g<f.length&&x.scrollToIndex(g,{align:"auto"}),P.current=!1},[g,f.length,x]),e.useEffect(()=>{const c=v.current?.closest('[data-slot="command"]');if(!c)return;const h=l=>{switch(l.key){case"ArrowDown":l.preventDefault(),l.stopPropagation(),P.current=!0,m(k=>k<f.length-1?k+1:k);break;case"ArrowUp":l.preventDefault(),l.stopPropagation(),P.current=!0,m(k=>k>0?k-1:k);break;case"Enter":{l.preventDefault(),l.stopPropagation(),D!=null&&L.current.get(D)?.();break}case"Home":l.preventDefault(),l.stopPropagation(),P.current=!0,m(0);break;case"End":l.preventDefault(),l.stopPropagation(),P.current=!0,m(f.length-1);break}};return c.addEventListener("keydown",h,{capture:!0}),()=>c.removeEventListener("keydown",h,{capture:!0})},[f,D]);const M=e.useMemo(()=>{const c=new Map;return f.forEach((h,l)=>{c.set(a(h),l)}),c},[f,a]),q=e.useCallback(c=>{const h=M.get(c);h!==void 0&&m(h)},[M]),T=e.useCallback(c=>(M.get(c)??0)+1,[M]),z=f.length,Q=e.useMemo(()=>({activeValue:D,onItemPointerMove:q,idPrefix:R,filteredCount:z,getItemPosition:T,onSelectCallbacks:L}),[D,q,R,z,T]),O=D!=null?`${R}item-${D}`:void 0;e.useEffect(()=>(d(O),()=>d(void 0)),[O,d]),e.useEffect(()=>(j(E),()=>j(void 0)),[E,j]);const $=y.cn("scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",S);return f.length===0?r.jsx("div",{ref:v,"aria-label":I,className:$,"data-hook":w,"data-slot":"command-virtual-list",id:E,role:"listbox",tabIndex:-1,children:u}):r.jsx(Y.Provider,{value:Q,children:r.jsx("div",{ref:v,"aria-label":I,className:$,"data-hook":w,"data-slot":"command-virtual-list",id:E,role:"listbox",tabIndex:-1,children:r.jsx("div",{className:"relative w-full",style:{height:`${x.getTotalSize()}px`},children:x.getVirtualItems().map(c=>r.jsx("div",{ref:x.measureElement,className:"absolute top-0 left-0 w-full px-2","data-index":c.index,style:{transform:`translateY(${c.start}px)`},children:p(f[c.index],c.index,C)},c.key))})})})}const se=e.forwardRef(re),J=e.forwardRef(({value:t,dataHook:a,trackingEl:o,trackingLabel:n,selected:i,disabled:s,onSelect:p,children:u,className:I,onClick:S,onKeyDown:w,onPointerMove:b,...v},C)=>{const d=e.useContext(Y),j=d?.activeValue===t,g=e.useRef(p);return e.useEffect(()=>{g.current=p}),e.useEffect(()=>{if(d)return d.onSelectCallbacks.current.set(t,()=>g.current?.()),()=>{d.onSelectCallbacks.current.delete(t)}},[t,d]),r.jsxs("div",{ref:C,...v,"aria-disabled":s||void 0,"aria-posinset":d?.getItemPosition(t),"aria-selected":i||void 0,"aria-setsize":d?.filteredCount,className:y.cn("data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground text-label relative flex cursor-default items-center gap-2 rounded-sm px-2 py-3 outline-hidden select-none","[&_svg]:pointer-events-none [&_svg]:shrink-0",s&&"pointer-events-none opacity-50",I),"data-highlighted":j||void 0,"data-hook":a,"data-selected-item":i||void 0,"data-slot":"command-virtual-item","data-tracking-el":o,"data-tracking-label":n,id:d?`${d.idPrefix}item-${t}`:void 0,role:"option",tabIndex:-1,onClick:s?void 0:m=>{p?.(),S?.(m)},onKeyDown:s?void 0:m=>{(m.key==="Enter"||m.key===" ")&&p?.(),w?.(m)},onPointerMove:s?void 0:m=>{d?.onItemPointerMove(t),b?.(m)},children:[u,i&&r.jsx(_.Check,{className:"text-foreground ml-auto"})]})});J.displayName="CommandVirtualItem";exports.Command=G;exports.CommandEmpty=F;exports.CommandGroup=W;exports.CommandInput=H;exports.CommandItem=U;exports.CommandList=B;exports.CommandSeparator=K;exports.CommandShortcut=X;exports.CommandVirtualItem=J;exports.CommandVirtualList=se;
package/dist/command.js CHANGED
@@ -94,7 +94,7 @@ const Z = e.forwardRef(
94
94
  {
95
95
  ref: C,
96
96
  className: y(
97
- "placeholder:text-muted-foreground text-body flex w-full bg-transparent outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
97
+ "placeholder:text-muted-foreground text-field flex w-full bg-transparent outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
98
98
  t
99
99
  ),
100
100
  "data-slot": "command-input",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),Te=require("react"),C=require("@tanstack/react-table"),Se=require("@tanstack/react-virtual"),k=require("@brightlocal/icons"),b=require("@brightlocal/ui-components/lib/utils"),q=require("@brightlocal/ui-components/hooks/use-breakpoint"),H=require("./button.cjs"),G=require("./checkbox.cjs"),B=require("./input-group.cjs"),w=require("./pagination.cjs"),M=require("./skeleton.cjs"),g=require("./table.cjs"),Ce=require("./typography.cjs");function ke(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const l in e)if(l!=="default"){const t=Object.getOwnPropertyDescriptor(e,l);Object.defineProperty(n,l,t.get?t:{enumerable:!0,get:()=>e[l]})}}return n.default=e,Object.freeze(n)}const x=ke(Te);function v(e,n,l){const[t,i]=x.useState(n),o=e!==void 0?e:t,s=x.useRef(o);x.useEffect(()=>{s.current=o});const r=e!==void 0,d=x.useCallback(c=>{const u=typeof c=="function"?c(s.current):c;r||i(u),l?.(u)},[r,l]);return[o,d]}function De(e){const{columns:n,data:l,enableSorting:t=!0,enableGlobalFiltering:i=!1,enableRowSelection:o=!1,enablePagination:s=!1,pageSize:r=10,manualSorting:d=!1,manualFiltering:c=!1,manualPagination:u=!1,rowCount:h,pageCount:m,enableExpanding:p=!1,getSubRows:j,getRowCanExpand:T,paginateExpandedRows:D=!1,getRowId:f,pagination:I,onPaginationChange:P,sorting:R,onSortingChange:y,globalFilter:S,onGlobalFilterChange:E,rowSelection:N,onRowSelectionChange:A,expanded:F,onExpandedChange:z}=e,[ue,ge]=v(I,{pageIndex:0,pageSize:r},P),[be,xe]=v(R,[],y),[pe,he]=v(S,"",E),[me,fe]=v(N,{},A),[we,je]=v(F,{},z);return C.useReactTable({data:l,columns:n,getCoreRowModel:C.getCoreRowModel(),...f&&{getRowId:f},...(s||u)&&{onPaginationChange:ge},...s&&{...!u&&{getPaginationRowModel:C.getPaginationRowModel()}},...u&&{manualPagination:!0,...h!=null&&{rowCount:h},...m!=null&&{pageCount:m}},enableSorting:t,...t&&{...!d&&{getSortedRowModel:C.getSortedRowModel()},onSortingChange:xe,...d&&{manualSorting:!0}},...i&&{...!c&&{getFilteredRowModel:C.getFilteredRowModel()},...c&&{manualFiltering:!0},onGlobalFilterChange:he,globalFilterFn:"includesString"},enableRowSelection:o,...o!==!1&&{onRowSelectionChange:fe},enableExpanding:p,...p&&{getExpandedRowModel:C.getExpandedRowModel(),onExpandedChange:je,getSubRows:j,...T&&{getRowCanExpand:T},...s&&!u&&{paginateExpandedRows:D}},state:{pagination:ue,sorting:be,globalFilter:pe,rowSelection:me,expanded:we}})}function _({table:e,dataHook:n,trackingEl:l,trackingLabel:t,isLoading:i=!1,skeletonRowCount:o,noResultsMessage:s="No results.",stickyHeader:r=!1,className:d,layout:c,minWidth:u,scrollRegionLabel:h,footer:m,getRowClassName:p,renderExpandedContent:j}){const T=e.getVisibleLeafColumns().length,D=o??e.getState().pagination.pageSize??10;return a.jsx("div",{"aria-busy":i||void 0,className:b.cn("border-border overflow-auto rounded-md border",d),"data-hook":n,"data-slot":"data-table-view","data-tracking-el":l,"data-tracking-label":t,children:a.jsxs(g.Table,{dataHook:`${n}-table`,layout:c,minWidth:u,scrollRegionLabel:h,children:[a.jsx(L,{stickyHeader:r,table:e}),a.jsx(g.TableBody,{children:i?a.jsxs(a.Fragment,{children:[a.jsx(U,{colCount:T,rowCount:D}),a.jsx(g.TableRow,{className:"sr-only",children:a.jsx(g.TableCell,{colSpan:T,children:a.jsx("div",{"aria-live":"polite",role:"status",children:"Loading data…"})})})]}):a.jsx(a.Fragment,{children:e.getRowModel().rows.length>0?e.getRowModel().rows.map(f=>a.jsx(O,{columnCount:T,getRowClassName:p,renderExpandedContent:j,row:f},f.id)):a.jsx(g.TableRow,{children:a.jsx(g.TableCell,{align:"center",colSpan:T,size:"lg",children:a.jsx("div",{"aria-live":"polite",className:"py-6",role:"status",children:s})})})})}),m]})})}_.displayName="DataTable";function L({table:e,stickyHeader:n}){return a.jsx(g.TableHeader,{className:b.cn(n&&"sticky top-0 z-10"),children:e.getHeaderGroups().map(l=>a.jsx(g.TableRow,{children:l.headers.map(t=>{const i=t.column.getCanSort()?t.column.getIsSorted():!1,o=i==="asc"?"ascending":i==="desc"?"descending":t.column.getCanSort()?"none":void 0,s=t.column.columnDef.meta;return a.jsx(g.TableHead,{"aria-sort":o,colSpan:t.colSpan,minWidth:s?.minWidth,width:s?.width,children:t.isPlaceholder?null:C.flexRender(t.column.columnDef.header,t.getContext())},t.id)})},l.id))})}function O({row:e,columnCount:n,getRowClassName:l,renderExpandedContent:t}){const i=e.getCanExpand(),o=e.getIsExpanded(),s=t&&i&&o?t(e):null;return a.jsxs(a.Fragment,{children:[a.jsx(g.TableRow,{className:b.cn("[&_[data-slot=button].bg-transparent:hover]:bg-secondary",i&&o?"bg-muted":e.depth>0&&"bg-accent/50",l?.(e)),"data-depth":e.depth,"data-expanded":i?String(o):void 0,"data-state":e.getIsSelected()?"selected":void 0,children:e.getVisibleCells().map(r=>a.jsx(g.TableCell,{children:C.flexRender(r.column.columnDef.cell,r.getContext())},r.id))}),s!=null&&a.jsx(g.TableRow,{className:"bg-accent/50 [&_[data-slot=button].bg-transparent:hover]:bg-secondary","data-slot":"data-table-expanded-row",children:a.jsx(g.TableCell,{colSpan:n,children:s})})]})}function U({rowCount:e,colCount:n}){return a.jsx(a.Fragment,{children:Array.from({length:e}).map((l,t)=>a.jsx(g.TableRow,{children:Array.from({length:n}).map((i,o)=>a.jsx(g.TableCell,{children:a.jsx(M.Skeleton,{className:"h-4 w-full"})},`skeleton-${t}-${o}`))},`skeleton-${t}`))})}function W({table:e,dataHook:n,trackingEl:l,trackingLabel:t,isLoading:i=!1,skeletonRowCount:o,noResultsMessage:s="No results.",stickyHeader:r=!1,className:d,layout:c,minWidth:u,scrollRegionLabel:h,footer:m,getRowClassName:p,height:j,estimateSize:T=48,overscan:D=5}){const f=e.getVisibleLeafColumns().length,I=o??e.getState().pagination.pageSize??10,P=x.useRef(null),R=e.getRowModel().rows,y=Se.useVirtualizer({count:R.length,getScrollElement:()=>P.current,estimateSize:()=>T,overscan:D}),S=y.getVirtualItems(),E=y.getTotalSize(),N=S.length>0?S[0].start:0,A=S.length>0?E-S[S.length-1].end:0;return a.jsx("div",{ref:P,"aria-busy":i||void 0,className:b.cn("border-border overflow-auto rounded-md border",d),"data-hook":n,"data-slot":"data-table-view","data-tracking-el":l,"data-tracking-label":t,style:j!=null?{height:j}:void 0,children:a.jsxs(g.Table,{dataHook:`${n}-table`,layout:c,minWidth:u,scrollRegionLabel:h,children:[a.jsx(L,{stickyHeader:r,table:e}),a.jsx(g.TableBody,{children:i?a.jsxs(a.Fragment,{children:[a.jsx(U,{colCount:f,rowCount:I}),a.jsx(g.TableRow,{className:"sr-only",children:a.jsx(g.TableCell,{colSpan:f,children:a.jsx("div",{"aria-live":"polite",role:"status",children:"Loading data…"})})})]}):R.length>0?a.jsxs(a.Fragment,{children:[N>0&&a.jsx("tr",{"aria-hidden":"true",children:a.jsx("td",{colSpan:f,style:{height:N}})}),S.map(F=>{const z=R[F.index];return a.jsx(O,{columnCount:f,getRowClassName:p,row:z},z.id)}),A>0&&a.jsx("tr",{"aria-hidden":"true",children:a.jsx("td",{colSpan:f,style:{height:A}})})]}):a.jsx(g.TableRow,{children:a.jsx(g.TableCell,{align:"center",colSpan:f,size:"lg",children:a.jsx("div",{"aria-live":"polite",className:"py-6",role:"status",children:s})})})}),m]})})}W.displayName="VirtualizedDataTable";function X({column:e,title:n,className:l,dataHook:t,trackingEl:i,trackingLabel:o,align:s="left",getSortLabel:r}){if(!e.getCanSort())return a.jsx("div",{className:b.cn("text-muted-foreground text-label text-left font-semibold",s==="right"&&"text-right",s==="center"&&"text-center",l),"data-hook":t,"data-slot":"data-table-column-header","data-tracking-el":i,"data-tracking-label":o,children:n});const d=e.getIsSorted(),c=d===!1?e.columnDef.sortDescFirst===!0:d==="asc",u=r?r(n,d):d==="desc"?`Sort by ${n}, currently descending`:d==="asc"?`Sort by ${n}, currently ascending`:`Sort by ${n}`;return a.jsx("div",{className:b.cn("flex items-center",s==="right"&&"justify-end",s==="center"&&"justify-center",l),"data-slot":"data-table-column-header","data-tracking-el":i,"data-tracking-label":o,children:a.jsxs(H.Button,{"aria-label":u,className:"text-muted-foreground text-label h-auto p-0 font-semibold",dataHook:t||`column-header-${e.id}`,size:"sm",variant:"ghost",onClick:()=>e.toggleSorting(c),children:[a.jsx("span",{"aria-hidden":"true",children:n}),a.jsx("span",{"aria-hidden":"true",className:"flex size-3 items-center justify-center",children:d==="desc"?a.jsx(k.ArrowDown,{size:12}):d==="asc"?a.jsx(k.ArrowUp,{size:12}):a.jsx(k.ArrowUpDown,{size:12})})]})})}X.displayName="DataTableColumnHeader";function J({table:e,ariaLabel:n,placeholder:l,clearSearchAriaLabel:t,...i}){const o=e.getState().globalFilter??"",s=r=>{e.setGlobalFilter(r)};return a.jsxs(B.InputGroup,{"data-slot":"data-table-search",...i,children:[a.jsx(B.InputGroupAddon,{className:"pl-3",children:a.jsx(k.Search,{})}),a.jsx(B.InputGroupInput,{"aria-label":n??"Search table",placeholder:l??"Search...",type:"text",value:o,onChange:r=>s(r.target.value)}),o&&a.jsx(B.InputGroupAddon,{className:"pr-1",children:a.jsx(H.Button,{"aria-label":t??"Clear search",className:"size-6 p-0","data-slot":"data-table-search-clear",dataHook:`${i.dataHook}-clear`,variant:"ghost",onClick:()=>s(""),children:a.jsx(k.X,{size:14})})})]})}J.displayName="DataTableSearch";function Re(e){const{pageIndex:n,pageSize:l}=e.getState().pagination,t=e.getRowCount(),i=e.getPageCount(),o=e.getCanPreviousPage(),s=e.getCanNextPage(),r=n+1,d=t===0?0:n*l+1,c=Math.min(r*l,t),u=x.useCallback(j=>e.setPageIndex(j-1),[e]),h=x.useCallback(()=>e.nextPage(),[e]),m=x.useCallback(()=>e.previousPage(),[e]),p=x.useCallback(j=>e.setPageSize(j),[e]);return x.useMemo(()=>({pageIndex:n,pageSize:l,totalRows:t,totalPages:i,startRow:d,endRow:c,currentPage:r,canPrev:o,canNext:s,goToPage:u,nextPage:h,previousPage:m,setPageSize:p}),[n,l,t,i,d,c,r,o,s,u,h,m,p])}const $=x.createContext(null);function K(){const e=x.useContext($);if(!e)throw new Error("DataTablePagination sub-components must be used within <DataTablePagination>");return e}function Q({renderText:e,className:n}){const{info:l}=K(),t=q.useIsBelowBreakpoint("sm"),{startRow:i,endRow:o,totalRows:s,pageIndex:r,pageSize:d}=l;if(t)return null;const c=e?e({startRow:i,endRow:o,totalRows:s,pageIndex:r,pageSize:d}):s===0?null:`${i}-${o} of ${s}`;return c==null?null:a.jsx("span",{className:b.cn("text-body-sm text-muted-foreground whitespace-nowrap",n),"data-slot":"data-table-pagination-row-count",children:c})}Q.displayName="DataTablePaginationRowCount";function V({ariaLabel:e="Table pagination",dataHook:n,className:l}){const{info:t}=K(),i=q.useIsBelowBreakpoint("sm"),o=w.usePagination({page:t.currentPage,totalPages:t.totalPages});return t.totalPages<=1?null:a.jsx(w.Pagination,{ariaLabel:e,className:b.cn(!i&&"mx-0 w-auto justify-end",l),dataHook:n??"pagination-nav",children:a.jsx(w.PaginationContent,{children:o.map((s,r)=>s==="previous"?a.jsx(w.PaginationItem,{children:a.jsx(w.PaginationPrevious,{disabled:!t.canPrev,onClick:()=>t.previousPage()})},"previous"):s==="next"?a.jsx(w.PaginationItem,{children:a.jsx(w.PaginationNext,{disabled:!t.canNext,onClick:()=>t.nextPage()})},"next"):s==="ellipsis"?a.jsx(w.PaginationItem,{children:a.jsx(w.PaginationEllipsis,{})},`ellipsis-${r}`):a.jsx(w.PaginationItem,{children:a.jsx(w.PaginationLink,{isActive:s===t.currentPage,page:s,onClick:()=>t.goToPage(s)})},s))})})}V.displayName="DataTablePaginationNav";function Y({table:e,dataHook:n,showRowCount:l=!0,renderRowCount:t,trackingEl:i,trackingLabel:o,className:s,ariaLabel:r="Table pagination",children:d}){const c=Re(e),u=q.useIsBelowBreakpoint("sm"),h=x.useMemo(()=>({info:c}),[c]),m={"data-hook":n,"data-slot":"data-table-pagination","data-tracking-el":i,"data-tracking-label":o};if(d)return a.jsx($.Provider,{value:h,children:a.jsx("div",{className:b.cn("flex w-full flex-wrap items-center gap-x-4 gap-y-2",s),...m,children:d})});const p=u||!l||t===null?null:t?t({startRow:c.startRow,endRow:c.endRow,totalRows:c.totalRows,pageIndex:c.pageIndex,pageSize:c.pageSize}):c.totalRows===0?null:`${c.startRow}-${c.endRow} of ${c.totalRows}`;return p==null&&c.totalPages<=1?null:a.jsx($.Provider,{value:h,children:a.jsxs("div",{className:b.cn("flex min-h-9 w-full flex-wrap items-center gap-x-4 gap-y-2",p!=null?"justify-between":"justify-end",s),...m,children:[p!=null&&a.jsx("span",{className:"text-body-sm text-muted-foreground whitespace-nowrap",children:p}),a.jsx(V,{ariaLabel:r,className:"grow",dataHook:`${n}-nav`})]})})}Y.displayName="DataTablePagination";function Z({table:e,dataHook:n,trackingEl:l,trackingLabel:t,selectAllAriaLabel:i}){return a.jsx(G.Checkbox,{"aria-label":i??"Select all",checked:e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()&&"indeterminate",dataHook:n||"select-all-checkbox",trackingEl:l,trackingLabel:t,onCheckedChange:o=>e.toggleAllPageRowsSelected(!!o)})}Z.displayName="DataTableSelectAllCheckbox";function ee({row:e,dataHook:n,trackingEl:l,trackingLabel:t,selectRowAriaLabel:i}){return a.jsx(G.Checkbox,{"aria-label":i??"Select row",checked:e.getIsSelected(),dataHook:n||`select-row-${e.id}`,disabled:!e.getCanSelect(),trackingEl:l,trackingLabel:t,onCheckedChange:o=>e.toggleSelected(!!o)})}ee.displayName="DataTableSelectRowCheckbox";function ae({row:e,rowName:n,dataHook:l,trackingEl:t,trackingLabel:i,expandLabel:o,collapseLabel:s,className:r}){if(!e.getCanExpand())return a.jsx("span",{"aria-hidden":"true",className:b.cn("inline-block size-9",r),"data-slot":"data-table-expand-row-spacer"});const d=e.getIsExpanded(),c=d?s:o;let u;return c&&(n!==void 0||!c.includes("{name}"))?u=c.replaceAll("{name}",n??""):n!==void 0?u=d?`Collapse details for ${n}`:`Expand details for ${n}`:u=d?"Collapse row":"Expand row",a.jsx(H.Button,{iconOnly:!0,"aria-expanded":d,"aria-label":u,className:r,"data-state":d?"open":"closed",dataHook:l||`expand-row-${e.id}`,size:"sm",trackingEl:t,trackingLabel:i,variant:"ghost",onClick:e.getToggleExpandedHandler(),children:a.jsx(k.ChevronRight,{"aria-hidden":"true",className:b.cn("duration-base transition-transform ease-in-out",d&&"rotate-90")})})}ae.displayName="DataTableExpandRowButton";function te({fields:e=3,loadingLabel:n,dataHook:l,className:t}){return a.jsxs("div",{className:b.cn("relative flex flex-col gap-2 py-1",t),"data-hook":l||"data-table-expanded-skeleton","data-slot":"data-table-expanded-skeleton",role:"status",children:[a.jsx("span",{className:"sr-only",children:n??"Loading details"}),Array.from({length:e},(i,o)=>a.jsxs("div",{"aria-hidden":"true",className:"flex items-center gap-4",children:[a.jsx(M.Skeleton,{className:"h-4 w-24 shrink-0"}),a.jsx(M.Skeleton,{className:"h-4 w-48 max-w-full"})]},o))]})}te.displayName="DataTableExpandedSkeleton";const ne=x.createContext(null);function le(){const e=x.useContext(ne);if(!e)throw new Error("DataTableBulkActions components must be used within <DataTableBulkActions>");return e}function oe({table:e,dataHook:n,trackingEl:l,trackingLabel:t,className:i,children:o}){const s=e.getFilteredSelectedRowModel().rows.length,r=e.getRowCount(),d=x.useMemo(()=>({selectedCount:s,totalCount:r}),[s,r]);return s===0?null:a.jsx(ne.Provider,{value:d,children:a.jsx("div",{className:b.cn("flex items-center gap-2.5",i),"data-hook":n,"data-slot":"data-table-bulk-actions","data-tracking-el":l??"data-table-bulk-actions","data-tracking-label":t,children:o})})}oe.displayName="DataTableBulkActions";function se({dataHook:e="data-table-bulk-actions-summary",className:n,children:l}){const{selectedCount:t,totalCount:i}=le();let o;return typeof l=="function"?o=l({selectedCount:t,totalCount:i}):l!=null?o=l:o=`${t} of ${i} row(s) selected.`,a.jsx(Ce.TypographyMuted,{asChild:!0,className:b.cn("min-w-0",n),dataHook:e,children:a.jsx("span",{"data-slot":"data-table-bulk-actions-summary",role:"status",children:o})})}se.displayName="DataTableBulkActionsSummary";function ie({dataHook:e="data-table-bulk-actions-actions",className:n,children:l}){return a.jsx("div",{className:b.cn("flex shrink-0 items-center gap-2",n),"data-hook":e,"data-slot":"data-table-bulk-actions-actions",children:l})}ie.displayName="DataTableBulkActionsActions";function re({dataHook:e,className:n,children:l}){return a.jsx("div",{className:b.cn("flex flex-col gap-3 py-4 sm:flex-row sm:items-center",n),"data-hook":e,"data-slot":"data-table-toolbar",children:l})}re.displayName="DataTableToolbar";function ce({className:e,children:n}){return a.jsx("div",{className:b.cn("flex w-full min-w-0 items-center gap-2 sm:w-auto sm:flex-1",e),"data-slot":"data-table-toolbar-left",children:n})}ce.displayName="DataTableToolbarLeft";function de({className:e,children:n}){return a.jsx("div",{className:b.cn("flex w-full items-center justify-end gap-2 sm:w-auto",e),"data-slot":"data-table-toolbar-right",children:n})}de.displayName="DataTableToolbarRight";exports.DataTable=_;exports.DataTableBulkActions=oe;exports.DataTableBulkActionsActions=ie;exports.DataTableBulkActionsSummary=se;exports.DataTableColumnHeader=X;exports.DataTableExpandRowButton=ae;exports.DataTableExpandedSkeleton=te;exports.DataTablePagination=Y;exports.DataTablePaginationNav=V;exports.DataTablePaginationRowCount=Q;exports.DataTableSearch=J;exports.DataTableSelectAllCheckbox=Z;exports.DataTableSelectRowCheckbox=ee;exports.DataTableToolbar=re;exports.DataTableToolbarLeft=ce;exports.DataTableToolbarRight=de;exports.VirtualizedDataTable=W;exports.useDataTable=De;exports.useDataTableBulkActionsContext=le;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),ke=require("react"),R=require("@tanstack/react-table"),ye=require("@tanstack/react-virtual"),A=require("@brightlocal/icons"),m=require("@brightlocal/ui-components/lib/utils"),L=require("@brightlocal/ui-components/hooks/use-breakpoint"),W=require("./button.cjs"),J=require("./checkbox.cjs"),F=require("./input-group.cjs"),v=require("./pagination.cjs"),V=require("./skeleton.cjs"),K=require("./spinner.cjs"),x=require("./table.cjs"),Re=require("./typography.cjs");function De(e){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(a,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return a.default=e,Object.freeze(a)}const g=De(ke);function N(e,a,o){const[n,s]=g.useState(a),i=e!==void 0?e:n,l=g.useRef(i);g.useEffect(()=>{l.current=i});const c=e!==void 0,u=g.useCallback(r=>{const d=typeof r=="function"?r(l.current):r;c||s(d),o?.(d)},[c,o]);return[i,u]}function Pe(e){const{columns:a,data:o,enableSorting:n=!0,enableGlobalFiltering:s=!1,enableRowSelection:i=!1,enablePagination:l=!1,pageSize:c=10,manualSorting:u=!1,manualFiltering:r=!1,manualPagination:d=!1,rowCount:f,pageCount:p,enableExpanding:h=!1,getSubRows:j,getRowCanExpand:S,paginateExpandedRows:T=!1,getRowId:C,pagination:k,onPaginationChange:b,sorting:w,onSortingChange:D,globalFilter:P,onGlobalFilterChange:E,rowSelection:y,onRowSelectionChange:H,expanded:I,onExpandedChange:B}=e,[$,z]=N(k,{pageIndex:0,pageSize:c},b),[he,me]=N(w,[],D),[Se,we]=N(P,"",E),[je,Te]=N(y,{},H),[Ce,ve]=N(I,{},B);return R.useReactTable({data:o,columns:a,getCoreRowModel:R.getCoreRowModel(),...C&&{getRowId:C},...(l||d)&&{onPaginationChange:z},...l&&{...!d&&{getPaginationRowModel:R.getPaginationRowModel()}},...d&&{manualPagination:!0,...f!=null&&{rowCount:f},...p!=null&&{pageCount:p}},enableSorting:n,...n&&{...!u&&{getSortedRowModel:R.getSortedRowModel()},onSortingChange:me,...u&&{manualSorting:!0}},...s&&{...!r&&{getFilteredRowModel:R.getFilteredRowModel()},...r&&{manualFiltering:!0},onGlobalFilterChange:we,globalFilterFn:"includesString"},enableRowSelection:i,...i!==!1&&{onRowSelectionChange:Te},enableExpanding:h,...h&&{getExpandedRowModel:R.getExpandedRowModel(),onExpandedChange:ve,getSubRows:j,...S&&{getRowCanExpand:S},...l&&!d&&{paginateExpandedRows:T}},state:{pagination:$,sorting:he,globalFilter:Se,rowSelection:je,expanded:Ce}})}const M=g.createContext(!1);function Q({table:e,dataHook:a,trackingEl:o,trackingLabel:n,isLoading:s=!1,refetching:i=!1,refetchingLabel:l,skeletonRowCount:c,noResultsMessage:u="No results.",stickyHeader:r=!1,className:d,layout:f,minWidth:p,scrollRegionLabel:h,footer:j,getRowClassName:S,renderExpandedContent:T}){const C=e.getVisibleLeafColumns().length,k=c??e.getState().pagination.pageSize??10,b=!!p||r||h!==void 0;return t.jsxs("div",{className:m.cn("border-border scrollbar relative overflow-auto rounded-md border",b&&"focus-visible:shadow-default outline-none",d),"data-hook":a,"data-slot":"data-table-view","data-tracking-el":o,"data-tracking-label":n,...b?x.scrollRegionProps(h):void 0,children:[t.jsx("div",{"aria-live":"polite",className:"sr-only",role:"status",children:i?l??"Loading results…":null}),t.jsx(M.Provider,{value:i,children:t.jsxs(x.Table,{"aria-busy":s||i||void 0,dataHook:`${a}-table`,layout:f,minWidth:p,scrollOwner:"parent",children:[t.jsx(X,{stickyHeader:r,table:e}),t.jsx(x.TableBody,{children:s?t.jsxs(t.Fragment,{children:[t.jsx(Z,{colCount:C,rowCount:k}),t.jsx(x.TableRow,{className:"sr-only",children:t.jsx(x.TableCell,{colSpan:C,children:t.jsx("div",{"aria-live":"polite",role:"status",children:"Loading data…"})})})]}):t.jsx(t.Fragment,{children:e.getRowModel().rows.length>0?e.getRowModel().rows.map(w=>t.jsx(Y,{columnCount:C,getRowClassName:S,renderExpandedContent:T,row:w},w.id)):t.jsx(x.TableRow,{children:t.jsx(x.TableCell,{align:"center",colSpan:C,size:"lg",children:t.jsx("div",{"aria-live":"polite",className:"py-6",role:"status",children:u})})})})}),j]})})]})}Q.displayName="DataTable";const G=g.createContext(null),q=()=>()=>{};function Ne(){const[e]=g.useState(()=>{const a=new Map,o=new Set,n=s=>a.get(s)??null;return{set:(s,i)=>{const l=n(s);l===i||l!==null&&i!==null&&l.displayed===i.displayed&&l.live===i.live||(i===null?a.delete(s):a.set(s,i),o.forEach(c=>c()))},get:n,anyHeld:()=>{for(const s of a.values())if(s.displayed!==s.live)return!0;return!1},subscribe:s=>(o.add(s),()=>{o.delete(s)})}});return e}function X({table:e,stickyHeader:a}){const o=Ne();return t.jsx(G.Provider,{value:o,children:t.jsx(x.TableHeader,{className:m.cn(a&&"sticky top-0 z-10"),children:e.getHeaderGroups().map(n=>t.jsx(x.TableRow,{children:n.headers.map(s=>t.jsx(Ae,{header:s},s.id))},n.id))})})}function Ae({header:e}){const a=g.useContext(G),o=g.useSyncExternalStore(a?a.subscribe:q,()=>a?a.get(e.column.id)?.displayed??null:null,()=>null),n=e.column.getCanSort(),s=n?o??e.column.getIsSorted():!1,i=s==="asc"?"ascending":s==="desc"?"descending":n?"none":void 0,l=e.column.columnDef.meta;return t.jsx(x.TableHead,{"aria-sort":i,colSpan:e.colSpan,minWidth:l?.minWidth,width:l?.width,children:e.isPlaceholder?null:R.flexRender(e.column.columnDef.header,e.getContext())})}function Y({row:e,columnCount:a,getRowClassName:o,renderExpandedContent:n}){const s=e.getCanExpand(),i=e.getIsExpanded(),l=n&&s&&i?n(e):null;return t.jsxs(t.Fragment,{children:[t.jsx(x.TableRow,{className:m.cn("[&_[data-slot=button].bg-transparent:hover]:bg-secondary",s&&i?"bg-muted":e.depth>0&&"bg-accent/50",o?.(e)),"data-depth":e.depth,"data-expanded":s?String(i):void 0,"data-state":e.getIsSelected()?"selected":void 0,children:e.getVisibleCells().map(c=>t.jsx(x.TableCell,{children:R.flexRender(c.column.columnDef.cell,c.getContext())},c.id))}),l!=null&&t.jsx(x.TableRow,{className:"bg-accent/50 [&_[data-slot=button].bg-transparent:hover]:bg-secondary","data-slot":"data-table-expanded-row",children:t.jsx(x.TableCell,{colSpan:a,children:l})})]})}function Z({rowCount:e,colCount:a}){return t.jsx(t.Fragment,{children:Array.from({length:e}).map((o,n)=>t.jsx(x.TableRow,{children:Array.from({length:a}).map((s,i)=>t.jsx(x.TableCell,{children:t.jsx(V.Skeleton,{className:"h-4 w-full"})},`skeleton-${n}-${i}`))},`skeleton-${n}`))})}function ee({table:e,dataHook:a,trackingEl:o,trackingLabel:n,isLoading:s=!1,refetching:i=!1,refetchingLabel:l,skeletonRowCount:c,noResultsMessage:u="No results.",stickyHeader:r=!1,className:d,layout:f,minWidth:p,scrollRegionLabel:h,footer:j,getRowClassName:S,height:T,estimateSize:C=48,overscan:k=5}){const b=e.getVisibleLeafColumns().length,w=c??e.getState().pagination.pageSize??10,D=g.useRef(null),P=e.getRowModel().rows,E=ye.useVirtualizer({count:P.length,getScrollElement:()=>D.current,estimateSize:()=>C,overscan:k}),y=E.getVirtualItems(),H=E.getTotalSize(),I=y.length>0?y[0].start:0,B=y.length>0?H-y[y.length-1].end:0;return t.jsxs("div",{ref:D,className:m.cn("border-border scrollbar relative overflow-auto rounded-md border","focus-visible:shadow-default outline-none",d),"data-hook":a,"data-slot":"data-table-view","data-tracking-el":o,"data-tracking-label":n,style:T!=null?{height:T}:void 0,...x.scrollRegionProps(h),children:[t.jsx("div",{"aria-live":"polite",className:"sr-only",role:"status",children:i?l??"Loading results…":null}),t.jsx(M.Provider,{value:i,children:t.jsxs(x.Table,{"aria-busy":s||i||void 0,dataHook:`${a}-table`,layout:f,minWidth:p,scrollOwner:"parent",children:[t.jsx(X,{stickyHeader:r,table:e}),t.jsx(x.TableBody,{children:s?t.jsxs(t.Fragment,{children:[t.jsx(Z,{colCount:b,rowCount:w}),t.jsx(x.TableRow,{className:"sr-only",children:t.jsx(x.TableCell,{colSpan:b,children:t.jsx("div",{"aria-live":"polite",role:"status",children:"Loading data…"})})})]}):P.length>0?t.jsxs(t.Fragment,{children:[I>0&&t.jsx("tr",{"aria-hidden":"true",children:t.jsx("td",{colSpan:b,style:{height:I}})}),y.map($=>{const z=P[$.index];return t.jsx(Y,{columnCount:b,getRowClassName:S,row:z},z.id)}),B>0&&t.jsx("tr",{"aria-hidden":"true",children:t.jsx("td",{colSpan:b,style:{height:B}})})]}):t.jsx(x.TableRow,{children:t.jsx(x.TableCell,{align:"center",colSpan:b,size:"lg",children:t.jsx("div",{"aria-live":"polite",className:"py-6",role:"status",children:u})})})}),j]})})]})}ee.displayName="VirtualizedDataTable";function te({column:e,title:a,className:o,dataHook:n,trackingEl:s,trackingLabel:i,align:l="left",getSortLabel:c,loading:u=!1}){const r=e.getIsSorted(),d=g.useContext(G),f=g.useSyncExternalStore(d?d.subscribe:q,()=>d?d.get(e.id)?.displayed??null:null,()=>null),[p,h]=g.useState(r);!d&&!u&&p!==r&&h(r);const S=u?d?f??r:p:r,T=S!==r,C=g.useSyncExternalStore(d?d.subscribe:q,()=>d?d.anyHeld():!1,()=>!1),b=u&&(T||!(d?C:T)&&r!==!1);if(g.useLayoutEffect(()=>{if(d)return d.set(e.id,{displayed:S,live:r}),()=>{d.set(e.id,null)}},[d,e.id,S,r]),!e.getCanSort())return t.jsx("div",{className:m.cn("text-muted-foreground text-label text-left font-semibold",l==="right"&&"text-right",l==="center"&&"text-center",o),"data-hook":n,"data-slot":"data-table-column-header","data-tracking-el":s,"data-tracking-label":i,children:a});const w=r===!1?e.columnDef.sortDescFirst===!0:r==="asc",D=c?c(a,S):S==="desc"?`Sort by ${a}, currently descending`:S==="asc"?`Sort by ${a}, currently ascending`:`Sort by ${a}`;return t.jsx("div",{className:m.cn("flex items-center",l==="right"&&"justify-end",l==="center"&&"justify-center",o),"data-slot":"data-table-column-header","data-tracking-el":s,"data-tracking-label":i,children:t.jsxs(W.Button,{"aria-busy":u?"true":void 0,"aria-label":D,className:"text-muted-foreground text-label h-auto p-0 font-semibold",dataHook:n||`column-header-${e.id}`,size:"sm",variant:"ghost",onClick:()=>{u||e.toggleSorting(w)},children:[t.jsx("span",{"aria-hidden":"true",children:a}),t.jsx("span",{"aria-hidden":"true",className:"flex size-3 items-center justify-center",children:b?t.jsx(K.Spinner,{size:"sm"}):S==="desc"?t.jsx(A.ArrowDown,{size:12}):S==="asc"?t.jsx(A.ArrowUp,{size:12}):t.jsx(A.ArrowUpDown,{size:12})})]})})}te.displayName="DataTableColumnHeader";function ae({table:e,ariaLabel:a,placeholder:o,clearSearchAriaLabel:n,loading:s=!1,debounceMs:i,...l}){const c=e.getState().globalFilter??"",[u,r]=g.useState(c),d=i??(e.options.manualFiltering===!0?300:0),f=g.useRef(null),p=g.useCallback(()=>{f.current!==null&&(clearTimeout(f.current),f.current=null)},[]);g.useEffect(()=>p,[p]);const h=g.useRef(u);g.useEffect(()=>{h.current=u});const[j,S]=g.useState({filter:c,pushed:[]}),T=b=>{(e.getState().globalFilter??"")!==b&&(S(w=>({filter:w.filter,pushed:[...w.pushed,b].slice(-10)})),e.setGlobalFilter(b))},C=b=>{p(),d>0?f.current=setTimeout(()=>{f.current=null,h.current===b&&T(b)},d):T(b)};if(c!==j.filter){const b=j.pushed.lastIndexOf(c),w=b!==-1;S({filter:c,pushed:w?j.pushed.slice(b+1):j.pushed}),!w&&c!==u&&r(c)}const k=()=>{p(),r(""),T("")};return t.jsxs(F.InputGroup,{"aria-busy":s?"true":void 0,"data-slot":"data-table-search",...l,children:[t.jsx(F.InputGroupAddon,{className:"pl-3",children:s?t.jsx(K.Spinner,{dataHook:`${l.dataHook}-loading`}):t.jsx(A.Search,{})}),t.jsx(F.InputGroupInput,{"aria-label":a??"Search table",placeholder:o??"Search...",type:"text",value:u,onChange:b=>{const w=b.target.value;r(w),C(w)}}),t.jsx(F.InputGroupClear,{clearSearchAriaLabel:n,"data-slot":"data-table-search-clear",dataHook:`${l.dataHook}-clear`,onClear:d>0?k:void 0})]})}ae.displayName="DataTableSearch";function Ee(e){const{pageIndex:a,pageSize:o}=e.getState().pagination,n=e.getRowCount(),s=e.getPageCount(),i=e.getCanPreviousPage(),l=e.getCanNextPage(),c=a+1,u=n===0?0:a*o+1,r=Math.min(c*o,n),d=g.useCallback(j=>e.setPageIndex(j-1),[e]),f=g.useCallback(()=>e.nextPage(),[e]),p=g.useCallback(()=>e.previousPage(),[e]),h=g.useCallback(j=>e.setPageSize(j),[e]);return g.useMemo(()=>({pageIndex:a,pageSize:o,totalRows:n,totalPages:s,startRow:u,endRow:r,currentPage:c,canPrev:i,canNext:l,goToPage:d,nextPage:f,previousPage:p,setPageSize:h}),[a,o,n,s,u,r,c,i,l,d,f,p,h])}const O=g.createContext(null);function ne(){const e=g.useContext(O);if(!e)throw new Error("DataTablePagination sub-components must be used within <DataTablePagination>");return e}function le({renderText:e,className:a}){const{info:o}=ne(),n=L.useIsBelowBreakpoint("sm"),{startRow:s,endRow:i,totalRows:l,pageIndex:c,pageSize:u}=o;if(n)return null;const r=e?e({startRow:s,endRow:i,totalRows:l,pageIndex:c,pageSize:u}):l===0?null:`${s}-${i} of ${l}`;return r==null?null:t.jsx("span",{className:m.cn("text-body-sm text-muted-foreground whitespace-nowrap",a),"data-slot":"data-table-pagination-row-count",children:r})}le.displayName="DataTablePaginationRowCount";function _({ariaLabel:e="Table pagination",dataHook:a,className:o}){const{info:n}=ne(),s=L.useIsBelowBreakpoint("sm"),i=v.usePagination({page:n.currentPage,totalPages:n.totalPages});return n.totalPages<=1?null:t.jsx(v.Pagination,{ariaLabel:e,className:m.cn(!s&&"mx-0 w-auto justify-end",o),dataHook:a??"pagination-nav",children:t.jsx(v.PaginationContent,{children:i.map((l,c)=>l==="previous"?t.jsx(v.PaginationItem,{children:t.jsx(v.PaginationPrevious,{disabled:!n.canPrev,onClick:()=>n.previousPage()})},"previous"):l==="next"?t.jsx(v.PaginationItem,{children:t.jsx(v.PaginationNext,{disabled:!n.canNext,onClick:()=>n.nextPage()})},"next"):l==="ellipsis"?t.jsx(v.PaginationItem,{children:t.jsx(v.PaginationEllipsis,{})},`ellipsis-${c}`):t.jsx(v.PaginationItem,{children:t.jsx(v.PaginationLink,{isActive:l===n.currentPage,page:l,onClick:()=>n.goToPage(l)})},l))})})}_.displayName="DataTablePaginationNav";function oe({table:e,dataHook:a,showRowCount:o=!0,renderRowCount:n,trackingEl:s,trackingLabel:i,className:l,ariaLabel:c="Table pagination",children:u}){const r=Ee(e),d=L.useIsBelowBreakpoint("sm"),f=g.useMemo(()=>({info:r}),[r]),p={"data-hook":a,"data-slot":"data-table-pagination","data-tracking-el":s,"data-tracking-label":i};if(u)return t.jsx(O.Provider,{value:f,children:t.jsx("div",{className:m.cn("flex w-full flex-wrap items-center gap-x-4 gap-y-2",l),...p,children:u})});const h=d||!o||n===null?null:n?n({startRow:r.startRow,endRow:r.endRow,totalRows:r.totalRows,pageIndex:r.pageIndex,pageSize:r.pageSize}):r.totalRows===0?null:`${r.startRow}-${r.endRow} of ${r.totalRows}`;return h==null&&r.totalPages<=1?null:t.jsx(O.Provider,{value:f,children:t.jsxs("div",{className:m.cn("flex min-h-9 w-full flex-wrap items-center gap-x-4 gap-y-2",h!=null?"justify-between":"justify-end",l),...p,children:[h!=null&&t.jsx("span",{className:"text-body-sm text-muted-foreground whitespace-nowrap",children:h}),t.jsx(_,{ariaLabel:c,className:"grow",dataHook:`${a}-nav`})]})})}oe.displayName="DataTablePagination";function se({table:e,dataHook:a,trackingEl:o,trackingLabel:n,selectAllAriaLabel:s}){const i=g.useContext(M);return t.jsx(J.Checkbox,{"aria-disabled":i||void 0,"aria-label":s??"Select all",checked:e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()&&"indeterminate",dataHook:a||"select-all-checkbox",trackingEl:o,trackingLabel:n,onCheckedChange:l=>{i||e.toggleAllPageRowsSelected(!!l)}})}se.displayName="DataTableSelectAllCheckbox";function ie({row:e,dataHook:a,trackingEl:o,trackingLabel:n,selectRowAriaLabel:s}){const i=g.useContext(M);return t.jsx(J.Checkbox,{"aria-disabled":i||void 0,"aria-label":s??"Select row",checked:e.getIsSelected(),dataHook:a||`select-row-${e.id}`,disabled:!e.getCanSelect(),trackingEl:o,trackingLabel:n,onCheckedChange:l=>{i||e.toggleSelected(!!l)}})}ie.displayName="DataTableSelectRowCheckbox";function re({row:e,rowName:a,dataHook:o,trackingEl:n,trackingLabel:s,expandLabel:i,collapseLabel:l,className:c}){if(!e.getCanExpand())return t.jsx("span",{"aria-hidden":"true",className:m.cn("inline-block size-9",c),"data-slot":"data-table-expand-row-spacer"});const u=e.getIsExpanded(),r=u?l:i;let d;return r&&(a!==void 0||!r.includes("{name}"))?d=r.replaceAll("{name}",a??""):a!==void 0?d=u?`Collapse details for ${a}`:`Expand details for ${a}`:d=u?"Collapse row":"Expand row",t.jsx(W.Button,{iconOnly:!0,"aria-expanded":u,"aria-label":d,className:c,"data-state":u?"open":"closed",dataHook:o||`expand-row-${e.id}`,size:"sm",trackingEl:n,trackingLabel:s,variant:"ghost",onClick:e.getToggleExpandedHandler(),children:t.jsx(A.ChevronRight,{"aria-hidden":"true",className:m.cn("duration-base transition-transform ease-in-out",u&&"rotate-90")})})}re.displayName="DataTableExpandRowButton";function ce({fields:e=3,loadingLabel:a,dataHook:o,className:n}){return t.jsxs("div",{className:m.cn("relative flex flex-col gap-2 py-1",n),"data-hook":o||"data-table-expanded-skeleton","data-slot":"data-table-expanded-skeleton",role:"status",children:[t.jsx("span",{className:"sr-only",children:a??"Loading details"}),Array.from({length:e},(s,i)=>t.jsxs("div",{"aria-hidden":"true",className:"flex items-center gap-4",children:[t.jsx(V.Skeleton,{className:"h-4 w-24 shrink-0"}),t.jsx(V.Skeleton,{className:"h-4 w-48 max-w-full"})]},i))]})}ce.displayName="DataTableExpandedSkeleton";const U=g.createContext(null);function de(){const e=g.useContext(U);if(!e)throw new Error("DataTableBulkActions components must be used within <DataTableBulkActions>");return e}function ue({table:e,dataHook:a,trackingEl:o,trackingLabel:n,className:s,children:i,refetching:l=!1}){const c=e.getFilteredSelectedRowModel().rows.length,u=e.getRowCount(),r=g.useMemo(()=>({selectedCount:c,totalCount:u,refetching:l}),[c,u,l]);return c===0?null:t.jsx(U.Provider,{value:r,children:t.jsx("div",{"aria-busy":l||void 0,className:m.cn("flex items-center gap-2.5",s),"data-hook":a,"data-slot":"data-table-bulk-actions","data-tracking-el":o??"data-table-bulk-actions","data-tracking-label":n,children:i})})}ue.displayName="DataTableBulkActions";function ge({dataHook:e="data-table-bulk-actions-summary",className:a,children:o}){const n=de(),{selectedCount:s,totalCount:i}=n;let l;return typeof o=="function"?l=o(n):o!=null?l=o:l=`${s} of ${i} row(s) selected.`,t.jsx(Re.TypographyMuted,{asChild:!0,className:m.cn("min-w-0",a),dataHook:e,children:t.jsx("span",{"data-slot":"data-table-bulk-actions-summary",role:"status",children:l})})}ge.displayName="DataTableBulkActionsSummary";function be({dataHook:e="data-table-bulk-actions-actions",className:a,children:o}){const n=g.useContext(U)?.refetching??!1;return t.jsx("div",{className:m.cn("flex shrink-0 items-center gap-2",a),"data-hook":e,"data-slot":"data-table-bulk-actions-actions",inert:n||void 0,children:o})}be.displayName="DataTableBulkActionsActions";function xe({dataHook:e,className:a,children:o}){return t.jsx("div",{className:m.cn("flex flex-col gap-3 py-4 sm:flex-row sm:items-center",a),"data-hook":e,"data-slot":"data-table-toolbar",children:o})}xe.displayName="DataTableToolbar";function pe({className:e,children:a}){return t.jsx("div",{className:m.cn("flex w-full min-w-0 items-center gap-2 sm:w-auto sm:flex-1",e),"data-slot":"data-table-toolbar-left",children:a})}pe.displayName="DataTableToolbarLeft";function fe({className:e,children:a}){return t.jsx("div",{className:m.cn("flex w-full items-center justify-end gap-2 sm:w-auto",e),"data-slot":"data-table-toolbar-right",children:a})}fe.displayName="DataTableToolbarRight";exports.DataTable=Q;exports.DataTableBulkActions=ue;exports.DataTableBulkActionsActions=be;exports.DataTableBulkActionsSummary=ge;exports.DataTableColumnHeader=te;exports.DataTableExpandRowButton=re;exports.DataTableExpandedSkeleton=ce;exports.DataTablePagination=oe;exports.DataTablePaginationNav=_;exports.DataTablePaginationRowCount=le;exports.DataTableSearch=ae;exports.DataTableSelectAllCheckbox=se;exports.DataTableSelectRowCheckbox=ie;exports.DataTableToolbar=xe;exports.DataTableToolbarLeft=pe;exports.DataTableToolbarRight=fe;exports.VirtualizedDataTable=ee;exports.useDataTable=Pe;exports.useDataTableBulkActionsContext=de;
@@ -200,15 +200,6 @@ export interface UseDataTableOptions<TData> {
200
200
  * return <DataTable table={table} dataHook="locations-table" />;
201
201
  */
202
202
  export declare function useDataTable<TData>(options: UseDataTableOptions<TData>): TanStackTable<TData>;
203
- /**
204
- * Props for `DataTable`.
205
- *
206
- * `DataTable` is the generic rendering layer for a DataTable. It takes an
207
- * already-constructed TanStack Table instance (typically from
208
- * `useDataTable`) and renders the primitives. It is purposefully
209
- * rendering-focused — wire toolbars, pagination, and search components
210
- * outside of it via composition.
211
- */
212
203
  export interface DataTableProps<TData> {
213
204
  /** TanStack Table instance (usually returned from `useDataTable`). */
214
205
  table: TanStackTable<TData>;
@@ -220,6 +211,32 @@ export interface DataTableProps<TData> {
220
211
  trackingLabel?: string;
221
212
  /** Show skeleton rows instead of data while loading async data. */
222
213
  isLoading?: boolean;
214
+ /**
215
+ * Marks a server-side refetch (page, sort, filter or search change) as in
216
+ * flight. Unlike `isLoading` — the initial load, which swaps rows for
217
+ * skeletons — `refetching` never touches the rows: they stay rendered at
218
+ * full contrast (keep the stale data with TanStack Query's
219
+ * `placeholderData: keepPreviousData` or `useTransition`). The table sets
220
+ * `aria-busy` (never the wrapper — the live region must stay outside the
221
+ * busy subtree to be announced), a polite live region announces
222
+ * `refetchingLabel`, and the
223
+ * selection checkboxes (`DataTableSelectAllCheckbox`,
224
+ * `DataTableSelectRowCheckbox`) set `aria-disabled` and ignore toggles —
225
+ * selecting rows that are about to be replaced acts on stale data. The busy *visual* belongs to the
226
+ * control that requested the refetch (the pagination button, the sort
227
+ * header's or search field's `loading`), not to the body.
228
+ *
229
+ * Wrap a raw `isFetching` in `useDelayedPending` before passing it, so a
230
+ * refetch that resolves inside the flash threshold shows nothing at all.
231
+ * @default false
232
+ */
233
+ refetching?: boolean;
234
+ /**
235
+ * What the polite live region announces to screen readers while
236
+ * `refetching` is set.
237
+ * @default "Loading results…"
238
+ */
239
+ refetchingLabel?: string;
223
240
  /** Number of skeleton rows when loading. Falls back to the table's page size, then 10. */
224
241
  skeletonRowCount?: number;
225
242
  /**
@@ -239,13 +256,38 @@ export interface DataTableProps<TData> {
239
256
  */
240
257
  noResultsMessage?: React.ReactNode;
241
258
  /**
242
- * Pin the `<thead>` to the top of the scroll container so column headers
243
- * remain visible while scrolling. The header keeps its opaque `bg-muted`
244
- * background to separate it from body rows.
259
+ * Pin the `<thead>` to the top of the component's own scroll container
260
+ * (the outer wrapper) so column headers remain visible while the rows
261
+ * scroll. Bound the height through `className` — a fixed cap
262
+ * (`max-h-96`) or flex sizing inside a height-capped parent
263
+ * (`min-h-0 flex-1`) — and the header sticks while rows scroll beneath
264
+ * it (DS-912). The header keeps its opaque `bg-muted` background to
265
+ * separate it from body rows.
266
+ *
267
+ * Setting this also makes the outer wrapper a focusable scroll region
268
+ * (`role="region"` + `tabIndex`, labelled by `scrollRegionLabel`), so
269
+ * keyboard users can focus and scroll the rows — the height bound lives
270
+ * in `className`, which the component cannot inspect, so the sticky
271
+ * intent is the signal. For the same reason, don't set it on a table
272
+ * with no height bound: the wrapper never scrolls, and the region
273
+ * becomes an inert tab stop.
245
274
  * @default false
246
275
  */
247
276
  stickyHeader?: boolean;
248
- /** Additional class name for the outer wrapper. */
277
+ /**
278
+ * Additional class name for the outer wrapper — the component's single
279
+ * scroll container for both axes. Height bounds belong here: `max-h-*`
280
+ * for a fixed cap, or `min-h-0 flex-1` to fill a height-capped parent
281
+ * such as a dialog body.
282
+ *
283
+ * A height bound almost always wants `stickyHeader` with it — that also
284
+ * grants the keyboard-focusable scroll-region semantics. If you cap the
285
+ * height and deliberately let the header scroll away, pass
286
+ * `scrollRegionLabel` instead: it opts the wrapper into the same
287
+ * focusable scroll-region semantics without pinning the header, so the
288
+ * region semantics sit on the element that actually scrolls — keyboard
289
+ * arrow keys only scroll the focused element itself or an ancestor.
290
+ */
249
291
  className?: string;
250
292
  /**
251
293
  * Table layout algorithm.
@@ -266,8 +308,23 @@ export interface DataTableProps<TData> {
266
308
  */
267
309
  minWidth?: string;
268
310
  /**
269
- * Accessible label for the scroll container region.
270
- * Used when `minWidth` is set to provide context for keyboard users.
311
+ * Accessible label for the scroll container region (the outer wrapper).
312
+ * Applied whenever the wrapper is a focusable scroll region: `minWidth`
313
+ * is set (horizontal scrolling), `stickyHeader` is set (vertical
314
+ * scrolling under a pinned header), or always on `VirtualizedDataTable`
315
+ * (its viewport is bounded by definition).
316
+ *
317
+ * Passing it is also itself the opt-in for tables that scroll without
318
+ * either signal — a `className` height cap with the header deliberately
319
+ * left unpinned. The height bound lives in `className`, which the
320
+ * component cannot inspect, so the supplied label tells it the rows
321
+ * scroll and the wrapper becomes a focusable region. Don't pass it on a
322
+ * table that never scrolls: the region would be an inert tab stop.
323
+ *
324
+ * Give each table on a page a distinct label ("Invoices", "Team
325
+ * members") — several region landmarks sharing the default name violate
326
+ * axe's landmark-unique rule and are indistinguishable to screen-reader
327
+ * users.
271
328
  * @default "Scrollable table"
272
329
  */
273
330
  scrollRegionLabel?: string;
@@ -322,20 +379,22 @@ export interface DataTableProps<TData> {
322
379
  *
323
380
  * @example
324
381
  * // One slot inside a gapped parent (dialog, card, page section).
325
- * // min-h-0/flex-1 keep the table scrollable in height-capped parents.
382
+ * // min-h-0/flex-1 keep the table scrollable in height-capped parents;
383
+ * // the outer wrapper is the scroll container, so stickyHeader keeps the
384
+ * // column headers visible while the rows scroll (DS-912).
326
385
  * <div className="flex min-h-0 flex-1 flex-col">
327
386
  * <DataTableToolbar dataHook="toolbar-top">
328
387
  * <DataTableToolbarLeft>{heading or search}</DataTableToolbarLeft>
329
388
  * <DataTableToolbarRight>{filters}</DataTableToolbarRight>
330
389
  * </DataTableToolbar>
331
- * <DataTable table={table} dataHook="my-table" className="min-h-0 flex-1 overflow-y-auto" />
390
+ * <DataTable table={table} dataHook="my-table" stickyHeader className="min-h-0 flex-1" />
332
391
  * <DataTableToolbar dataHook="toolbar-bottom">
333
392
  * <DataTableToolbarLeft>{selection counter}</DataTableToolbarLeft>
334
393
  * <DataTableToolbarRight>{pagination}</DataTableToolbarRight>
335
394
  * </DataTableToolbar>
336
395
  * </div>
337
396
  */
338
- export declare function DataTable<TData>({ table, dataHook, trackingEl, trackingLabel, isLoading, skeletonRowCount, noResultsMessage, stickyHeader, className, layout, minWidth, scrollRegionLabel, footer, getRowClassName, renderExpandedContent, }: DataTableProps<TData>): import("react/jsx-runtime").JSX.Element;
397
+ export declare function DataTable<TData>({ table, dataHook, trackingEl, trackingLabel, isLoading, refetching, refetchingLabel, skeletonRowCount, noResultsMessage, stickyHeader, className, layout, minWidth, scrollRegionLabel, footer, getRowClassName, renderExpandedContent, }: DataTableProps<TData>): import("react/jsx-runtime").JSX.Element;
339
398
  export declare namespace DataTable {
340
399
  var displayName: string;
341
400
  }
@@ -397,7 +456,7 @@ export interface VirtualizedDataTableProps<TData> extends Omit<DataTableProps<TD
397
456
  * />
398
457
  * );
399
458
  */
400
- export declare function VirtualizedDataTable<TData>({ table, dataHook, trackingEl, trackingLabel, isLoading, skeletonRowCount, noResultsMessage, stickyHeader, className, layout, minWidth, scrollRegionLabel, footer, getRowClassName, height, estimateSize, overscan, }: VirtualizedDataTableProps<TData>): import("react/jsx-runtime").JSX.Element;
459
+ export declare function VirtualizedDataTable<TData>({ table, dataHook, trackingEl, trackingLabel, isLoading, refetching, refetchingLabel, skeletonRowCount, noResultsMessage, stickyHeader, className, layout, minWidth, scrollRegionLabel, footer, getRowClassName, height, estimateSize, overscan, }: VirtualizedDataTableProps<TData>): import("react/jsx-runtime").JSX.Element;
401
460
  export declare namespace VirtualizedDataTable {
402
461
  var displayName: string;
403
462
  }
@@ -421,9 +480,35 @@ export interface DataTableColumnHeaderProps<TData, TValue> extends React.HTMLAtt
421
480
  /**
422
481
  * Builds the accessible label for the sort button.
423
482
  * Receives the column title and current sort direction (`"asc"`, `"desc"`, or `false`).
483
+ * While `loading` is true the direction passed is the settled one — the
484
+ * order the visible rows still reflect, not the one just requested.
424
485
  * @default (title, dir) => `Sort by ${title}${dir ? `, currently ${dir === "asc" ? "ascending" : "descending"}` : ""}`
425
486
  */
426
487
  getSortLabel?: (title: string, direction: "asc" | "desc" | false) => string;
488
+ /**
489
+ * Marks a server-side sort refetch as in flight. Pass the same fetching
490
+ * flag to every column's header: every sort button sets `aria-busy` and
491
+ * becomes inert — clicks are ignored to prevent a double-fetch — without a
492
+ * disabled look, and the column whose click requested the refetch (the one
493
+ * whose requested order differs from the settled one it still shows) swaps
494
+ * its sort icon for a spinner. Icons, labels and the `<th>`'s `aria-sort`
495
+ * keep describing the settled sort order — the order the visible rows still
496
+ * reflect — until the flag clears.
497
+ *
498
+ * The settled order is captured when the sort change and this flag land in
499
+ * the same render commit: a click handler that sets both, or React Query's
500
+ * `isFetching` in the same batch — the normal wirings. It is tracked at the
501
+ * table level, so it survives the columns array being rebuilt (and every
502
+ * header remounting) when the flag flips. A flag that only flips on a later
503
+ * render (e.g. wrapped in `useDelayedPending`) degrades gracefully to
504
+ * announcing the requested order (the standard behavior of sortable
505
+ * tables), with the spinner on the sorted column or columns — the
506
+ * requesting one can no longer be told apart; button and `<th>` stay
507
+ * consistent with each other either way. Rendered standalone (outside a
508
+ * DataTable), the settled order is held in header-local state instead.
509
+ * @default false
510
+ */
511
+ loading?: boolean;
427
512
  }
428
513
  /**
429
514
  * Sortable column header with sort indicator icons.
@@ -446,7 +531,7 @@ export interface DataTableColumnHeaderProps<TData, TValue> extends React.HTMLAtt
446
531
  * so tables that do not opt in keep first-click-ascending. Once a column is
447
532
  * sorted, clicking again reverses the direction as before.
448
533
  */
449
- export declare function DataTableColumnHeader<TData, TValue>({ column, title, className, dataHook, trackingEl, trackingLabel, align, getSortLabel, }: DataTableColumnHeaderProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
534
+ export declare function DataTableColumnHeader<TData, TValue>({ column, title, className, dataHook, trackingEl, trackingLabel, align, getSortLabel, loading, }: DataTableColumnHeaderProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
450
535
  export declare namespace DataTableColumnHeader {
451
536
  var displayName: string;
452
537
  }
@@ -466,6 +551,27 @@ export interface DataTableSearchProps<TData> extends Omit<React.ComponentPropsWi
466
551
  placeholder?: string;
467
552
  /** Accessible label for the clear button. @default "Clear search" */
468
553
  clearSearchAriaLabel?: string;
554
+ /**
555
+ * Search refetch in flight — the leading search icon swaps to a spinner
556
+ * and the group sets `aria-busy`. The input stays fully editable, and the
557
+ * clear button keeps its place in the trailing slot whenever there is a
558
+ * value: the way out of a slow search never disappears.
559
+ * @default false
560
+ */
561
+ loading?: boolean;
562
+ /**
563
+ * Debounce between keystrokes and the table's global filter, in
564
+ * milliseconds. The input echoes instantly; the filter (and any server
565
+ * refetch keyed off it) only updates after the pause. Clearing via the
566
+ * clear button skips the debounce.
567
+ *
568
+ * The default is derived from the table's filtering mode: `300` when the
569
+ * table uses `manualFiltering` (server-side — one refetch per pause,
570
+ * "debounce the request"), `0` for client-side filtering (rows keep
571
+ * narrowing per keystroke, as before). Pass a value to override either mode.
572
+ * @default table.options.manualFiltering ? 300 : 0
573
+ */
574
+ debounceMs?: number;
469
575
  }
470
576
  /**
471
577
  * Search input for filtering DataTable rows.
@@ -475,8 +581,14 @@ export interface DataTableSearchProps<TData> extends Omit<React.ComponentPropsWi
475
581
  * customize width or shape.
476
582
  *
477
583
  * Uses the table's global filter (requires `enableGlobalFiltering` on the hook).
584
+ *
585
+ * With `manualFiltering` (server-side search) keystrokes echo in the input
586
+ * instantly while the global filter — and any server refetch keyed off it —
587
+ * only updates after `debounceMs` of inactivity. Client-side filtering stays
588
+ * synchronous: rows narrow per keystroke, exactly as the Filtering pattern
589
+ * promises ("debounce the request, never the input").
478
590
  */
479
- export declare function DataTableSearch<TData>({ table, ariaLabel, placeholder, clearSearchAriaLabel, ...inputGroupProps }: DataTableSearchProps<TData>): import("react/jsx-runtime").JSX.Element;
591
+ export declare function DataTableSearch<TData>({ table, ariaLabel, placeholder, clearSearchAriaLabel, loading, debounceMs, ...inputGroupProps }: DataTableSearchProps<TData>): import("react/jsx-runtime").JSX.Element;
480
592
  export declare namespace DataTableSearch {
481
593
  var displayName: string;
482
594
  }
@@ -658,6 +770,11 @@ export interface DataTableSelectAllCheckboxProps<TData> {
658
770
  /**
659
771
  * Header checkbox for selecting all visible page rows. Renders as
660
772
  * indeterminate when some (but not all) rows are selected.
773
+ *
774
+ * While the surrounding `DataTable` is `refetching`, the checkbox is
775
+ * `aria-disabled` and toggles are ignored (visually unchanged, still exposed
776
+ * to screen readers so the select-all `<th>` never reads as empty): the rows
777
+ * it would select are stale and about to be replaced (DS-916).
661
778
  */
662
779
  export declare function DataTableSelectAllCheckbox<TData>({ table, dataHook, trackingEl, trackingLabel, selectAllAriaLabel, }: DataTableSelectAllCheckboxProps<TData>): import("react/jsx-runtime").JSX.Element;
663
780
  export declare namespace DataTableSelectAllCheckbox {
@@ -680,6 +797,11 @@ export interface DataTableSelectRowCheckboxProps<TData> {
680
797
  }
681
798
  /**
682
799
  * Row-level selection checkbox. Disabled when the row cannot be selected.
800
+ *
801
+ * While the surrounding `DataTable` is `refetching`, the checkbox is
802
+ * `aria-disabled` and toggles are ignored (visually unchanged, still exposed
803
+ * to screen readers): the row it would select is stale and about to be
804
+ * replaced (DS-916).
683
805
  */
684
806
  export declare function DataTableSelectRowCheckbox<TData>({ row, dataHook, trackingEl, trackingLabel, selectRowAriaLabel, }: DataTableSelectRowCheckboxProps<TData>): import("react/jsx-runtime").JSX.Element;
685
807
  export declare namespace DataTableSelectRowCheckbox {
@@ -788,6 +910,13 @@ export interface DataTableBulkActionsContextValue {
788
910
  * `useDataTable` — the same option `DataTablePagination` relies on.
789
911
  */
790
912
  totalCount: number;
913
+ /**
914
+ * Whether a server-side refetch is in flight (the bar's `refetching` prop).
915
+ * `DataTableBulkActionsActions` goes inert on it; custom action parts built
916
+ * on this context should do the same — the selection they would act on is
917
+ * stale (DS-916).
918
+ */
919
+ refetching: boolean;
791
920
  }
792
921
  /**
793
922
  * Read the selection counts from the surrounding `DataTableBulkActions`.
@@ -821,6 +950,16 @@ export interface DataTableBulkActionsProps<TData> {
821
950
  * `DataTableBulkActionsActions`, and any custom parts in any order.
822
951
  */
823
952
  children?: React.ReactNode;
953
+ /**
954
+ * Marks a server-side refetch as in flight — pass the same flag given to
955
+ * the `DataTable`'s `refetching`. The bar sets `aria-busy` and
956
+ * `DataTableBulkActionsActions` becomes inert (unfocusable and unclickable,
957
+ * visually unchanged): bulk actions would act on stale rows about to be
958
+ * replaced. The bar lives outside the table's subtree, so it cannot inherit
959
+ * the flag from `DataTable` — it must be passed here too (DS-916).
960
+ * @default false
961
+ */
962
+ refetching?: boolean;
824
963
  }
825
964
  /**
826
965
  * Bulk-actions bar for a DataTable with row selection.
@@ -851,7 +990,7 @@ export interface DataTableBulkActionsProps<TData> {
851
990
  * </DataTableToolbarRight>
852
991
  * </DataTableToolbar>
853
992
  */
854
- export declare function DataTableBulkActions<TData>({ table, dataHook, trackingEl, trackingLabel, className, children, }: DataTableBulkActionsProps<TData>): import("react/jsx-runtime").JSX.Element | null;
993
+ export declare function DataTableBulkActions<TData>({ table, dataHook, trackingEl, trackingLabel, className, children, refetching, }: DataTableBulkActionsProps<TData>): import("react/jsx-runtime").JSX.Element | null;
855
994
  export declare namespace DataTableBulkActions {
856
995
  var displayName: string;
857
996
  }
@@ -922,6 +1061,10 @@ export interface DataTableBulkActionsActionsProps {
922
1061
  * Optional: a single action can sit directly inside
923
1062
  * `DataTableBulkActions`. Use this when you have several, or need them
924
1063
  * grouped and protected from shrinking.
1064
+ *
1065
+ * While the bar's `refetching` flag is set, the slot is `inert` — its buttons
1066
+ * cannot be clicked or focused (without a disabled look), because the
1067
+ * selection they would act on is stale (DS-916).
925
1068
  */
926
1069
  export declare function DataTableBulkActionsActions({ dataHook, className, children, }: DataTableBulkActionsActionsProps): import("react/jsx-runtime").JSX.Element;
927
1070
  export declare namespace DataTableBulkActionsActions {
@@ -951,6 +1094,10 @@ export interface DataTableToolbarProps {
951
1094
  * note on `DataTable`. The built-in vertical padding provides the spacing
952
1095
  * between a toolbar and its table; don't add custom margins or padding.
953
1096
  *
1097
+ * Inside a Card with a header, filters that narrow what the card shows
1098
+ * (`DataTableSearch` included) go in the header's `CardToolbar`; this toolbar
1099
+ * keeps pagination beside the table. A report card uses both.
1100
+ *
954
1101
  * @example
955
1102
  * <DataTableToolbar dataHook="locations-toolbar">
956
1103
  * <DataTableToolbarLeft>