@brightlocal/ui-components 3.0.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 (235) hide show
  1. package/README.md +7 -1
  2. package/component-meta.json +749 -53
  3. package/deprecations.json +114 -4
  4. package/dist/accordion.cjs +1 -1
  5. package/dist/accordion.d.ts +36 -0
  6. package/dist/accordion.d.ts.map +1 -1
  7. package/dist/accordion.js +74 -61
  8. package/dist/alert-dialog.cjs +1 -1
  9. package/dist/alert-dialog.d.ts +32 -3
  10. package/dist/alert-dialog.d.ts.map +1 -1
  11. package/dist/alert-dialog.js +61 -58
  12. package/dist/alert.cjs +1 -1
  13. package/dist/alert.d.ts.map +1 -1
  14. package/dist/alert.js +58 -57
  15. package/dist/badge.cjs +1 -1
  16. package/dist/badge.d.ts +9 -0
  17. package/dist/badge.d.ts.map +1 -1
  18. package/dist/badge.js +50 -30
  19. package/dist/banner.cjs +1 -0
  20. package/dist/banner.d.ts +81 -0
  21. package/dist/banner.d.ts.map +1 -0
  22. package/dist/banner.js +176 -0
  23. package/dist/blocks/empty-state.cjs +1 -1
  24. package/dist/blocks/empty-state.d.ts +4 -3
  25. package/dist/blocks/empty-state.d.ts.map +1 -1
  26. package/dist/blocks/empty-state.js +50 -57
  27. package/dist/blocks/progress-state.d.ts +2 -2
  28. package/dist/blocks/sidebar.cjs +1 -1
  29. package/dist/blocks/sidebar.d.ts +17 -0
  30. package/dist/blocks/sidebar.d.ts.map +1 -1
  31. package/dist/blocks/sidebar.js +8 -2
  32. package/dist/brand-illustration-motif.d.ts +1 -1
  33. package/dist/button-group.cjs +1 -0
  34. package/dist/button-group.d.ts +36 -0
  35. package/dist/button-group.d.ts.map +1 -0
  36. package/dist/button-group.js +47 -0
  37. package/dist/button.cjs +1 -1
  38. package/dist/button.js +1 -1
  39. package/dist/card.cjs +1 -1
  40. package/dist/card.d.ts +105 -7
  41. package/dist/card.d.ts.map +1 -1
  42. package/dist/card.js +198 -101
  43. package/dist/chart.cjs +3 -3
  44. package/dist/chart.d.ts +270 -24
  45. package/dist/chart.d.ts.map +1 -1
  46. package/dist/chart.js +497 -322
  47. package/dist/checkbox.cjs +1 -1
  48. package/dist/checkbox.d.ts +1 -1
  49. package/dist/checkbox.d.ts.map +1 -1
  50. package/dist/checkbox.js +2 -1
  51. package/dist/chip.cjs +1 -1
  52. package/dist/chip.d.ts +38 -4
  53. package/dist/chip.d.ts.map +1 -1
  54. package/dist/chip.js +95 -81
  55. package/dist/combobox.cjs +1 -1
  56. package/dist/combobox.js +2 -2
  57. package/dist/command.cjs +1 -1
  58. package/dist/command.d.ts +23 -1
  59. package/dist/command.d.ts.map +1 -1
  60. package/dist/command.js +251 -225
  61. package/dist/data-table.cjs +1 -1
  62. package/dist/data-table.d.ts +201 -23
  63. package/dist/data-table.d.ts.map +1 -1
  64. package/dist/data-table.js +712 -568
  65. package/dist/date-picker.cjs +1 -1
  66. package/dist/date-picker.d.ts +13 -5
  67. package/dist/date-picker.d.ts.map +1 -1
  68. package/dist/date-picker.js +54 -53
  69. package/dist/field.cjs +1 -1
  70. package/dist/field.d.ts +8 -1
  71. package/dist/field.d.ts.map +1 -1
  72. package/dist/field.js +79 -52
  73. package/dist/global-layout.cjs +1 -1
  74. package/dist/global-layout.d.ts +105 -13
  75. package/dist/global-layout.d.ts.map +1 -1
  76. package/dist/global-layout.js +146 -129
  77. package/dist/grid.d.ts +26 -3
  78. package/dist/grid.d.ts.map +1 -1
  79. package/dist/hooks/use-breakpoint.cjs +1 -1
  80. package/dist/hooks/use-breakpoint.d.ts +1 -1
  81. package/dist/hooks/use-breakpoint.d.ts.map +1 -1
  82. package/dist/hooks/use-breakpoint.js +1 -0
  83. package/dist/hooks/use-mobile.cjs +1 -0
  84. package/dist/hooks/use-mobile.js +8 -0
  85. package/dist/index.cjs +1 -1
  86. package/dist/index.d.ts +6 -0
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +594 -553
  89. package/dist/info-tooltip.cjs +1 -0
  90. package/dist/info-tooltip.d.ts +39 -0
  91. package/dist/info-tooltip.d.ts.map +1 -0
  92. package/dist/info-tooltip.js +41 -0
  93. package/dist/input-chip.cjs +1 -1
  94. package/dist/input-chip.js +1 -1
  95. package/dist/input-group.cjs +1 -1
  96. package/dist/input-group.d.ts +33 -2
  97. package/dist/input-group.d.ts.map +1 -1
  98. package/dist/input-group.js +167 -54
  99. package/dist/input-otp.cjs +1 -1
  100. package/dist/input-otp.js +9 -9
  101. package/dist/input-password.cjs +1 -1
  102. package/dist/input-password.d.ts +45 -15
  103. package/dist/input-password.d.ts.map +1 -1
  104. package/dist/input-password.js +31 -30
  105. package/dist/input.cjs +1 -1
  106. package/dist/input.js +10 -10
  107. package/dist/lib/block-illustration.cjs +1 -1
  108. package/dist/lib/block-illustration.d.ts +4 -1
  109. package/dist/lib/block-illustration.d.ts.map +1 -1
  110. package/dist/lib/block-illustration.js +12 -11
  111. package/dist/lib/empty-chip.cjs +1 -0
  112. package/dist/lib/empty-chip.d.ts +4 -0
  113. package/dist/lib/empty-chip.d.ts.map +1 -0
  114. package/dist/lib/empty-chip.js +13 -0
  115. package/dist/lib/utils.cjs +1 -1
  116. package/dist/lib/utils.d.ts.map +1 -1
  117. package/dist/lib/utils.js +4 -3
  118. package/dist/list.cjs +1 -1
  119. package/dist/list.js +1 -1
  120. package/dist/multi-select-filter.cjs +1 -0
  121. package/dist/multi-select-filter.d.ts +178 -0
  122. package/dist/multi-select-filter.d.ts.map +1 -0
  123. package/dist/multi-select-filter.js +463 -0
  124. package/dist/pagination.cjs +1 -1
  125. package/dist/pagination.d.ts +3 -0
  126. package/dist/pagination.d.ts.map +1 -1
  127. package/dist/pagination.js +57 -57
  128. package/dist/progress.cjs +1 -1
  129. package/dist/progress.d.ts +123 -16
  130. package/dist/progress.d.ts.map +1 -1
  131. package/dist/progress.js +89 -75
  132. package/dist/rating.cjs +1 -1
  133. package/dist/rating.js +18 -18
  134. package/dist/relative-date.cjs +1 -0
  135. package/dist/relative-date.d.ts +65 -0
  136. package/dist/relative-date.d.ts.map +1 -0
  137. package/dist/relative-date.js +128 -0
  138. package/dist/scroll-area.cjs +1 -1
  139. package/dist/scroll-area.d.ts +15 -6
  140. package/dist/scroll-area.d.ts.map +1 -1
  141. package/dist/scroll-area.js +38 -36
  142. package/dist/select.cjs +2 -2
  143. package/dist/select.d.ts +24 -3
  144. package/dist/select.d.ts.map +1 -1
  145. package/dist/select.js +130 -110
  146. package/dist/sheet.cjs +1 -1
  147. package/dist/sheet.d.ts +78 -2
  148. package/dist/sheet.d.ts.map +1 -1
  149. package/dist/sheet.js +192 -85
  150. package/dist/single-select-filter.cjs +1 -0
  151. package/dist/single-select-filter.d.ts +81 -0
  152. package/dist/single-select-filter.d.ts.map +1 -0
  153. package/dist/single-select-filter.js +226 -0
  154. package/dist/sonner.cjs +1 -1
  155. package/dist/sonner.d.ts.map +1 -1
  156. package/dist/sonner.js +22 -22
  157. package/dist/split-layout.cjs +1 -1
  158. package/dist/split-layout.d.ts +1 -1
  159. package/dist/split-layout.js +13 -13
  160. package/dist/table.cjs +1 -1
  161. package/dist/table.d.ts +45 -4
  162. package/dist/table.d.ts.map +1 -1
  163. package/dist/table.js +90 -73
  164. package/dist/tabs.cjs +1 -1
  165. package/dist/tabs.d.ts +12 -1
  166. package/dist/tabs.d.ts.map +1 -1
  167. package/dist/tabs.js +148 -126
  168. package/dist/textarea.cjs +1 -1
  169. package/dist/textarea.js +1 -1
  170. package/dist/tooltip.cjs +1 -1
  171. package/dist/tooltip.d.ts +38 -36
  172. package/dist/tooltip.d.ts.map +1 -1
  173. package/dist/tooltip.js +262 -73
  174. package/dist/typography-heading.cjs +1 -1
  175. package/dist/typography-heading.d.ts +13 -0
  176. package/dist/typography-heading.d.ts.map +1 -1
  177. package/dist/typography-heading.js +32 -21
  178. package/dist/typography-text.cjs +1 -1
  179. package/dist/typography-text.d.ts +15 -2
  180. package/dist/typography-text.d.ts.map +1 -1
  181. package/dist/typography-text.js +35 -24
  182. package/dist/typography.d.ts +1 -1
  183. package/package.json +5 -6
  184. package/src/blocks/empty-state.tsx +17 -24
  185. package/src/blocks/progress-state.tsx +2 -2
  186. package/src/blocks/sidebar.tsx +26 -2
  187. package/src/components/accordion.tsx +82 -27
  188. package/src/components/alert-dialog.tsx +50 -5
  189. package/src/components/alert.tsx +16 -8
  190. package/src/components/badge.tsx +40 -3
  191. package/src/components/banner.tsx +288 -0
  192. package/src/components/brand-illustration-motif.tsx +1 -1
  193. package/src/components/button-group.tsx +112 -0
  194. package/src/components/button.tsx +1 -1
  195. package/src/components/card.tsx +249 -27
  196. package/src/components/chart.tsx +586 -53
  197. package/src/components/checkbox.tsx +1 -1
  198. package/src/components/chip.tsx +83 -10
  199. package/src/components/combobox.tsx +2 -2
  200. package/src/components/command.tsx +56 -4
  201. package/src/components/data-table.tsx +842 -199
  202. package/src/components/date-picker.tsx +18 -7
  203. package/src/components/field.tsx +81 -12
  204. package/src/components/global-layout.tsx +176 -38
  205. package/src/components/grid.tsx +34 -3
  206. package/src/components/info-tooltip.tsx +94 -0
  207. package/src/components/input-chip.tsx +1 -1
  208. package/src/components/input-group.tsx +246 -11
  209. package/src/components/input-otp.tsx +1 -1
  210. package/src/components/input-password.tsx +56 -22
  211. package/src/components/input.tsx +1 -1
  212. package/src/components/list.tsx +1 -1
  213. package/src/components/multi-select-filter.tsx +912 -0
  214. package/src/components/pagination.tsx +10 -3
  215. package/src/components/progress.tsx +190 -31
  216. package/src/components/rating.tsx +1 -1
  217. package/src/components/relative-date.tsx +230 -0
  218. package/src/components/scroll-area.tsx +23 -10
  219. package/src/components/select.tsx +65 -11
  220. package/src/components/sheet.tsx +240 -4
  221. package/src/components/single-select-filter.tsx +443 -0
  222. package/src/components/sonner.tsx +16 -5
  223. package/src/components/split-layout.tsx +2 -2
  224. package/src/components/table.tsx +71 -11
  225. package/src/components/tabs.tsx +93 -46
  226. package/src/components/textarea.tsx +1 -1
  227. package/src/components/tooltip.tsx +440 -68
  228. package/src/components/typography-heading.tsx +24 -0
  229. package/src/components/typography-text.tsx +27 -3
  230. package/src/components/typography.tsx +1 -1
  231. package/src/hooks/use-breakpoint.ts +2 -1
  232. package/src/index.ts +6 -0
  233. package/src/lib/block-illustration.tsx +5 -1
  234. package/src/lib/empty-chip.ts +24 -0
  235. package/src/lib/utils.ts +1 -0
package/dist/sheet.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),R=require("react"),O=require("@radix-ui/react-dialog"),C=require("class-variance-authority"),P=require("@brightlocal/icons"),n=require("@brightlocal/ui-components/lib/utils"),T=require("@brightlocal/ui-components/scroll-area"),q=require("@brightlocal/ui-components/hooks/use-overlay-pointer-lock");function f(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const o=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,o.get?o:{enumerable:!0,get:()=>e[a]})}}return t.default=e,Object.freeze(t)}const i=f(R),r=f(O),z=C.cva(["bg-background","data-[state=open]:animate-in","data-[state=closed]:animate-out","fixed","z-50","flex","flex-col","gap-4","p-6","shadow-lg","ease-out","data-[state=closed]:ease-in","data-[state=open]:duration-slow","data-[state=closed]:duration-250"],{variants:{side:{top:["data-[state=closed]:slide-out-to-top","data-[state=open]:slide-in-from-top","inset-x-0","top-0","h-auto","border-b"],right:["data-[state=closed]:slide-out-to-right","data-[state=open]:slide-in-from-right","inset-y-0","right-0","h-full","border-l"],bottom:["data-[state=closed]:slide-out-to-bottom","data-[state=open]:slide-in-from-bottom","inset-x-0","bottom-0","h-auto","border-t"],left:["data-[state=closed]:slide-out-to-left","data-[state=open]:slide-in-from-left","inset-y-0","left-0","h-full","border-r"]},size:{default:[],sm:[]}},compoundVariants:[{side:["left","right"],size:"default",className:["w-3/4","sm:max-w-sm"]},{side:["left","right"],size:"sm",className:["w-fit","min-w-(--ds-container-2xs)","max-w-(--ds-container-xs)"]}],defaultVariants:{side:"right",size:"default"}});function u({...e}){return s.jsx(r.Root,{"data-slot":"sheet",modal:!0,...e})}u.displayName="Sheet";const m=i.forwardRef(({dataHook:e,...t},a)=>s.jsx(r.Trigger,{ref:a,"data-slot":"sheet-trigger",...e!=null&&{"data-hook":e},...t}));m.displayName="SheetTrigger";const p=i.forwardRef(({...e},t)=>s.jsx(r.Close,{ref:t,"data-slot":"sheet-close",...e}));p.displayName="SheetClose";function c({...e}){return s.jsx(r.Portal,{"data-slot":"sheet-portal",...e})}c.displayName="SheetPortal";const h=i.forwardRef(({className:e,...t},a)=>s.jsx(r.Overlay,{ref:a,className:n.cn("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),"data-slot":"sheet-overlay",...t}));h.displayName="SheetOverlay";const g=i.forwardRef(({className:e,children:t,side:a,size:o,dataHook:l,trackingEl:d,trackingLabel:v,closeLabel:N,...w},k)=>(q.useOverlayPointerLock(),s.jsxs(c,{children:[s.jsx(h,{}),s.jsxs(r.Content,{ref:k,className:n.cn(z({side:a,size:o}),e),"data-hook":l,"data-slot":"sheet-content","data-tracking-el":d,"data-tracking-label":v,...w,children:[t,s.jsxs(r.Close,{className:"ring-offset-background focus-visible:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground duration-fast absolute top-4 right-4 rounded-xs opacity-70 outline-hidden transition-opacity ease-out hover:opacity-100 focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0",children:[s.jsx(P.X,{}),s.jsx("span",{className:"sr-only",children:N??"Close"})]})]})]})));g.displayName="SheetContent";const x=i.forwardRef(({className:e,...t},a)=>s.jsx("div",{ref:a,className:n.cn("flex flex-col gap-2 text-center sm:text-left",e),"data-slot":"sheet-header",...t}));x.displayName="SheetHeader";const y=i.forwardRef(({className:e,children:t,dataHook:a,...o},l)=>s.jsx(T.ScrollArea,{ref:l,className:n.cn("-mx-6 min-h-0 flex-1",e),"data-slot":"sheet-body",dataHook:a??"sheet-body",...o,children:s.jsx("div",{className:"px-5","data-slot":"sheet-body-content",children:t})}));y.displayName="SheetBody";const S=i.forwardRef(({className:e,...t},a)=>s.jsx("div",{ref:a,className:n.cn("mt-auto flex flex-col gap-2 sm:flex-row sm:justify-end",e),"data-slot":"sheet-footer",...t}));S.displayName="SheetFooter";const b=i.forwardRef(({className:e,icon:t,children:a,dataHook:o,...l},d)=>s.jsxs(r.Title,{ref:d,className:n.cn("text-foreground text-heading-section",t&&"flex items-center gap-2",e),"data-hook":o,"data-slot":"sheet-title",...l,children:[t&&s.jsx("span",{className:"shrink-0 [&_svg]:size-5","data-slot":"sheet-title-icon",children:t}),a]}));b.displayName="SheetTitle";const j=i.forwardRef(({className:e,dataHook:t,...a},o)=>s.jsx(r.Description,{ref:o,className:n.cn("text-body-sm text-muted-foreground",e),"data-hook":t,"data-slot":"sheet-description",...a}));j.displayName="SheetDescription";exports.Sheet=u;exports.SheetBody=y;exports.SheetClose=p;exports.SheetContent=g;exports.SheetDescription=j;exports.SheetFooter=S;exports.SheetHeader=x;exports.SheetOverlay=h;exports.SheetPortal=c;exports.SheetTitle=b;exports.SheetTrigger=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),I=require("react"),X=require("@radix-ui/react-dialog"),G=require("class-variance-authority"),w=require("@brightlocal/icons"),c=require("@brightlocal/ui-components/lib/utils"),k=require("@brightlocal/ui-components/button"),J=require("@brightlocal/ui-components/scroll-area"),Q=require("@brightlocal/ui-components/hooks/use-overlay-pointer-lock");function P(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const n=P(I),d=P(X),W=G.cva(["bg-background","data-[state=open]:animate-in","data-[state=closed]:animate-out","fixed","z-50","flex","flex-col","gap-4","p-6","shadow-lg","ease-out","data-[state=closed]:ease-in","data-[state=open]:duration-slow","data-[state=closed]:duration-250"],{variants:{side:{top:["data-[state=closed]:slide-out-to-top","data-[state=open]:slide-in-from-top","inset-x-0","top-0","h-auto","border-b"],right:["data-[state=closed]:slide-out-to-right","data-[state=open]:slide-in-from-right","inset-y-0","right-0","h-full","border-l"],bottom:["data-[state=closed]:slide-out-to-bottom","data-[state=open]:slide-in-from-bottom","inset-x-0","bottom-0","h-auto","border-t"],left:["data-[state=closed]:slide-out-to-left","data-[state=open]:slide-in-from-left","inset-y-0","left-0","h-full","border-r"]},size:{default:[],sm:[]}},compoundVariants:[{side:["left","right"],size:"default",className:["w-3/4","sm:max-w-sm"]},{side:["left","right"],size:"sm",className:["w-fit","min-w-(--ds-container-2xs)","max-w-(--ds-container-xs)"]}],defaultVariants:{side:"right",size:"default"}});function O({...e}){return a.jsx(d.Root,{"data-slot":"sheet",modal:!0,...e})}O.displayName="Sheet";const q=n.forwardRef(({dataHook:e,...t},s)=>a.jsx(d.Trigger,{ref:s,"data-slot":"sheet-trigger",...e!=null&&{"data-hook":e},...t}));q.displayName="SheetTrigger";const B=n.forwardRef(({...e},t)=>a.jsx(d.Close,{ref:t,"data-slot":"sheet-close",...e}));B.displayName="SheetClose";function R({...e}){return a.jsx(d.Portal,{"data-slot":"sheet-portal",...e})}R.displayName="SheetPortal";const C=n.forwardRef(({className:e,...t},s)=>a.jsx(d.Overlay,{ref:s,className:c.cn("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),"data-slot":"sheet-overlay",...t}));C.displayName="SheetOverlay";const z=n.forwardRef(({className:e,children:t,side:s,size:r,dataHook:l,trackingEl:u,trackingLabel:S,closeLabel:h,...b},j)=>(Q.useOverlayPointerLock(),a.jsxs(R,{children:[a.jsx(C,{}),a.jsxs(d.Content,{ref:j,className:c.cn(W({side:s,size:r}),e),"data-hook":l,"data-slot":"sheet-content","data-tracking-el":u,"data-tracking-label":S,...b,children:[t,a.jsx(d.Close,{asChild:!0,children:a.jsxs(k.Button,{iconOnly:!0,className:"absolute top-6 right-4",dataHook:"sheet-close",variant:"ghost",children:[a.jsx(w.X,{}),a.jsx("span",{className:"sr-only",children:h??"Close"})]})})]})]})));z.displayName="SheetContent";const A=n.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:c.cn("flex flex-col gap-2 text-center sm:text-left",e),"data-slot":"sheet-header",...t}));A.displayName="SheetHeader";const _=n.forwardRef(({className:e,onPrevious:t,onNext:s,current:r,total:l,hasPrevious:u,hasNext:S,renderPosition:h,ariaLabel:b,prevAriaLabel:j,nextAriaLabel:F,dataHook:N,trackingEl:K,trackingLabel:E,...M},U)=>{const m=u??(r==null||r>1),p=S??(r==null||l==null||r<l),g=n.useRef(null),x=n.useRef(null),f=n.useRef(null);n.useEffect(()=>{const o=f.current;if(f.current=null,!o)return;const i=document.activeElement;i!==o&&i!==document.body||(!m&&o===g.current&&p?x.current?.focus():!p&&o===x.current&&m&&g.current?.focus())});const D=o=>{const i=o.relatedTarget;i&&i!==g.current&&i!==x.current&&(f.current=null)},y=(o,i)=>{if(o==="previous"){if(!m)return;f.current=i,t()}else{if(!p)return;f.current=i,s()}},T=o=>{o.key==="ArrowUp"||o.key==="ArrowLeft"?(o.preventDefault(),y("previous",o.currentTarget)):(o.key==="ArrowDown"||o.key==="ArrowRight")&&(o.preventDefault(),y("next",o.currentTarget))};let v=null;return h!==null&&r!=null&&l!=null&&(v=h?h({current:r,total:l}):`${r} of ${l}`),a.jsxs("div",{ref:U,"aria-label":b??"Item navigation",className:c.cn("mb-2 flex items-center gap-1",e),"data-hook":N,"data-slot":"sheet-pagination","data-tracking-el":K,"data-tracking-label":E,role:"group",...M,children:[a.jsx(k.Button,{ref:g,ariaLabel:j??"Previous item",dataHook:`${N}-previous`,disabled:!m,variant:"ghost",onBlur:D,onClick:o=>y("previous",o.currentTarget),onKeyDown:T,children:a.jsx(w.ChevronUp,{})}),a.jsx(k.Button,{ref:x,ariaLabel:F??"Next item",dataHook:`${N}-next`,disabled:!p,variant:"ghost",onBlur:D,onClick:o=>y("next",o.currentTarget),onKeyDown:T,children:a.jsx(w.ChevronDown,{})}),v!=null&&a.jsx("span",{"aria-live":"polite",className:"text-body-sm text-muted-foreground","data-slot":"sheet-pagination-position",children:v})]})});_.displayName="SheetPagination";const L=n.forwardRef(({className:e,children:t,dataHook:s,...r},l)=>a.jsx(J.ScrollArea,{ref:l,className:c.cn("-mx-6 min-h-0 flex-1",e),"data-slot":"sheet-body",dataHook:s??"sheet-body",...r,children:a.jsx("div",{className:"px-5","data-slot":"sheet-body-content",children:t})}));L.displayName="SheetBody";const H=n.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:c.cn("mt-auto flex flex-col gap-2 sm:flex-row sm:justify-end",e),"data-slot":"sheet-footer",...t}));H.displayName="SheetFooter";const V=n.forwardRef(({className:e,icon:t,children:s,dataHook:r,...l},u)=>a.jsxs(d.Title,{ref:u,className:c.cn("text-foreground text-heading-section",t&&"flex items-center gap-2",e),"data-hook":r,"data-slot":"sheet-title",...l,children:[t&&a.jsx("span",{className:"shrink-0 [&_svg]:size-5","data-slot":"sheet-title-icon",children:t}),s]}));V.displayName="SheetTitle";const $=n.forwardRef(({className:e,dataHook:t,...s},r)=>a.jsx(d.Description,{ref:r,className:c.cn("text-body-sm text-muted-foreground",e),"data-hook":t,"data-slot":"sheet-description",...s}));$.displayName="SheetDescription";exports.Sheet=O;exports.SheetBody=L;exports.SheetClose=B;exports.SheetContent=z;exports.SheetDescription=$;exports.SheetFooter=H;exports.SheetHeader=A;exports.SheetOverlay=C;exports.SheetPagination=_;exports.SheetPortal=R;exports.SheetTitle=V;exports.SheetTrigger=q;
package/dist/sheet.d.ts CHANGED
@@ -105,6 +105,82 @@ declare const SheetContent: React.ForwardRefExoticComponent<Omit<SheetContentPro
105
105
  * Centers text on mobile, left-aligns on larger screens.
106
106
  */
107
107
  declare const SheetHeader: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
108
+ /**
109
+ * Numbers a `SheetPagination` position indicator is built from.
110
+ */
111
+ interface SheetPaginationPositionInfo {
112
+ /** 1-based position of the item shown in the sheet. */
113
+ current: number;
114
+ /** Total number of items in the list being stepped through. */
115
+ total: number;
116
+ }
117
+ /**
118
+ * Props for the SheetPagination component
119
+ */
120
+ interface SheetPaginationProps extends Omit<React.ComponentProps<"div">, "children"> {
121
+ /** Called when the user steps to the previous item. */
122
+ onPrevious: () => void;
123
+ /** Called when the user steps to the next item. */
124
+ onNext: () => void;
125
+ /**
126
+ * 1-based position of the item shown in the sheet. Together with `total`,
127
+ * drives the position indicator and the default boundary state.
128
+ */
129
+ current?: number;
130
+ /** Total number of items in the list being stepped through. */
131
+ total?: number;
132
+ /**
133
+ * Whether a previous item exists. Disables the previous button when false.
134
+ * @default current > 1 (true when `current` is not set)
135
+ */
136
+ hasPrevious?: boolean;
137
+ /**
138
+ * Whether a next item exists. Disables the next button when false.
139
+ * @default current < total (true when either is not set)
140
+ */
141
+ hasNext?: boolean;
142
+ /**
143
+ * Render the position indicator. Receives the current position and total;
144
+ * you own the wording. Return `null` to hide it.
145
+ * @default Renders "{current} of {total}", or nothing when either is unset.
146
+ */
147
+ renderPosition?: ((info: SheetPaginationPositionInfo) => React.ReactNode) | null;
148
+ /**
149
+ * Accessible label for the item navigation group.
150
+ * @default "Item navigation"
151
+ */
152
+ ariaLabel?: string;
153
+ /**
154
+ * Accessible label for the previous button.
155
+ * @default "Previous item"
156
+ */
157
+ prevAriaLabel?: string;
158
+ /**
159
+ * Accessible label for the next button.
160
+ * @default "Next item"
161
+ */
162
+ nextAriaLabel?: string;
163
+ /**
164
+ * Data hook for automated testing. The buttons get `{dataHook}-previous`
165
+ * and `{dataHook}-next`.
166
+ */
167
+ dataHook: string;
168
+ /**
169
+ * Tracking element identifier for analytics
170
+ */
171
+ trackingEl?: string;
172
+ /**
173
+ * Tracking label for analytics context
174
+ */
175
+ trackingLabel?: string;
176
+ }
177
+ /**
178
+ * Previous/next controls for stepping through a list of items without
179
+ * closing the sheet — e.g. a detail sheet drilled into from a table row.
180
+ * Place it as the first child of SheetContent, above SheetHeader; it shares
181
+ * the close button's row. The arrow keys step while focus is on the controls.
182
+ */
183
+ declare const SheetPagination: React.ForwardRefExoticComponent<Omit<SheetPaginationProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
108
184
  /**
109
185
  * Props for the SheetBody component
110
186
  */
@@ -163,6 +239,6 @@ interface SheetDescriptionProps extends React.ComponentProps<typeof SheetPrimiti
163
239
  * Should be used within SheetHeader below SheetTitle.
164
240
  */
165
241
  declare const SheetDescription: React.ForwardRefExoticComponent<Omit<SheetDescriptionProps, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
166
- export { Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, };
167
- export type { SheetBodyProps, SheetContentProps, SheetDescriptionProps, SheetTitleProps, SheetTriggerProps, };
242
+ export { Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPagination, SheetPortal, SheetTitle, SheetTrigger, };
243
+ export type { SheetBodyProps, SheetContentProps, SheetDescriptionProps, SheetPaginationPositionInfo, SheetPaginationProps, SheetTitleProps, SheetTriggerProps, };
168
244
  //# sourceMappingURL=sheet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../src/components/sheet.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,cAAc,MAAM,wBAAwB,CAAC;AACzD,OAAO,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ACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,QAAA,MAAM,eAAe,0GA0IpB,CAAC;AAGF;;GAEG;AACH,UAAU,cAAe,SAAQ,IAAI,CACnC,KAAK,CAAC,cAAc,CAAC,OAAO,UAAU,CAAC,EACvC,UAAU,CACX;IACC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,QAAA,MAAM,SAAS,oGAkBb,CAAC;AAGH;;;GAGG;AACH,QAAA,MAAM,WAAW,mKAaf,CAAC;AAGH;;GAEG;AACH,UAAU,eAAgB,SAAQ,KAAK,CAAC,cAAc,CACpD,OAAO,cAAc,CAAC,KAAK,CAC5B;IACC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACxB;AAED;;;GAGG;AACH,QAAA,MAAM,UAAU,yGAsBd,CAAC;AAGH;;GAEG;AACH,UAAU,qBAAsB,SAAQ,KAAK,CAAC,cAAc,CAC1D,OAAO,cAAc,CAAC,WAAW,CAClC;IACC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,QAAA,MAAM,gBAAgB,iHAWpB,CAAC;AAGH,OAAO,EACL,KAAK,EACL,SAAS,EACT,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,WAAW,EACX,UAAU,EACV,YAAY,GACb,CAAC;AAEF,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,eAAe,EACf,iBAAiB,GAClB,CAAC"}
package/dist/sheet.js CHANGED
@@ -1,12 +1,13 @@
1
- import { jsx as o, jsxs as n } from "react/jsx-runtime";
2
- import * as i from "react";
3
- import * as s from "@radix-ui/react-dialog";
4
- import { cva as x } from "class-variance-authority";
5
- import { X as y } from "@brightlocal/icons";
6
- import { cn as d } from "@brightlocal/ui-components/lib/utils";
7
- import { ScrollArea as b } from "@brightlocal/ui-components/scroll-area";
8
- import { useOverlayPointerLock as N } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
9
- const S = x(
1
+ import { jsx as o, jsxs as h } from "react/jsx-runtime";
2
+ import * as l from "react";
3
+ import * as d from "@radix-ui/react-dialog";
4
+ import { cva as $ } from "class-variance-authority";
5
+ import { X as j, ChevronUp as H, ChevronDown as K } from "@brightlocal/icons";
6
+ import { cn as c } from "@brightlocal/ui-components/lib/utils";
7
+ import { Button as R } from "@brightlocal/ui-components/button";
8
+ import { ScrollArea as V } from "@brightlocal/ui-components/scroll-area";
9
+ import { useOverlayPointerLock as E } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
10
+ const F = $(
10
11
  [
11
12
  "bg-background",
12
13
  "data-[state=open]:animate-in",
@@ -95,33 +96,33 @@ const S = x(
95
96
  }
96
97
  }
97
98
  );
98
- function v({ ...e }) {
99
- return /* @__PURE__ */ o(s.Root, { "data-slot": "sheet", modal: !0, ...e });
99
+ function U({ ...e }) {
100
+ return /* @__PURE__ */ o(d.Root, { "data-slot": "sheet", modal: !0, ...e });
100
101
  }
101
- v.displayName = "Sheet";
102
- const w = i.forwardRef(({ dataHook: e, ...t }, a) => /* @__PURE__ */ o(
103
- s.Trigger,
102
+ U.displayName = "Sheet";
103
+ const I = l.forwardRef(({ dataHook: e, ...t }, s) => /* @__PURE__ */ o(
104
+ d.Trigger,
104
105
  {
105
- ref: a,
106
+ ref: s,
106
107
  "data-slot": "sheet-trigger",
107
108
  ...e != null && { "data-hook": e },
108
109
  ...t
109
110
  }
110
111
  ));
111
- w.displayName = "SheetTrigger";
112
- const k = i.forwardRef(({ ...e }, t) => /* @__PURE__ */ o(s.Close, { ref: t, "data-slot": "sheet-close", ...e }));
113
- k.displayName = "SheetClose";
114
- function f({
112
+ I.displayName = "SheetTrigger";
113
+ const X = l.forwardRef(({ ...e }, t) => /* @__PURE__ */ o(d.Close, { ref: t, "data-slot": "sheet-close", ...e }));
114
+ X.displayName = "SheetClose";
115
+ function T({
115
116
  ...e
116
117
  }) {
117
- return /* @__PURE__ */ o(s.Portal, { "data-slot": "sheet-portal", ...e });
118
+ return /* @__PURE__ */ o(d.Portal, { "data-slot": "sheet-portal", ...e });
118
119
  }
119
- f.displayName = "SheetPortal";
120
- const m = i.forwardRef(({ className: e, ...t }, a) => /* @__PURE__ */ o(
121
- s.Overlay,
120
+ T.displayName = "SheetPortal";
121
+ const z = l.forwardRef(({ className: e, ...t }, s) => /* @__PURE__ */ o(
122
+ d.Overlay,
122
123
  {
123
- ref: a,
124
- className: d(
124
+ ref: s,
125
+ className: c(
125
126
  "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
126
127
  e
127
128
  ),
@@ -129,69 +130,174 @@ const m = i.forwardRef(({ className: e, ...t }, a) => /* @__PURE__ */ o(
129
130
  ...t
130
131
  }
131
132
  ));
132
- m.displayName = "SheetOverlay";
133
- const R = i.forwardRef(
133
+ z.displayName = "SheetOverlay";
134
+ const _ = l.forwardRef(
134
135
  ({
135
136
  className: e,
136
137
  children: t,
137
- side: a,
138
+ side: s,
138
139
  size: r,
139
- dataHook: l,
140
- trackingEl: c,
141
- trackingLabel: h,
142
- closeLabel: p,
143
- ...u
144
- }, g) => (N(), /* @__PURE__ */ n(f, { children: [
145
- /* @__PURE__ */ o(m, {}),
146
- /* @__PURE__ */ n(
147
- s.Content,
140
+ dataHook: n,
141
+ trackingEl: f,
142
+ trackingLabel: b,
143
+ closeLabel: m,
144
+ ...w
145
+ }, S) => (E(), /* @__PURE__ */ h(T, { children: [
146
+ /* @__PURE__ */ o(z, {}),
147
+ /* @__PURE__ */ h(
148
+ d.Content,
148
149
  {
149
- ref: g,
150
- className: d(S({ side: a, size: r }), e),
151
- "data-hook": l,
150
+ ref: S,
151
+ className: c(F({ side: s, size: r }), e),
152
+ "data-hook": n,
152
153
  "data-slot": "sheet-content",
153
- "data-tracking-el": c,
154
- "data-tracking-label": h,
155
- ...u,
154
+ "data-tracking-el": f,
155
+ "data-tracking-label": b,
156
+ ...w,
156
157
  children: [
157
158
  t,
158
- /* @__PURE__ */ n(s.Close, { className: "ring-offset-background focus-visible:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground duration-fast absolute top-4 right-4 rounded-xs opacity-70 outline-hidden transition-opacity ease-out hover:opacity-100 focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0", children: [
159
- /* @__PURE__ */ o(y, {}),
160
- /* @__PURE__ */ o("span", { className: "sr-only", children: p ?? "Close" })
161
- ] })
159
+ /* @__PURE__ */ o(d.Close, { asChild: !0, children: /* @__PURE__ */ h(
160
+ R,
161
+ {
162
+ iconOnly: !0,
163
+ className: "absolute top-6 right-4",
164
+ dataHook: "sheet-close",
165
+ variant: "ghost",
166
+ children: [
167
+ /* @__PURE__ */ o(j, {}),
168
+ /* @__PURE__ */ o("span", { className: "sr-only", children: m ?? "Close" })
169
+ ]
170
+ }
171
+ ) })
162
172
  ]
163
173
  }
164
174
  )
165
175
  ] }))
166
176
  );
167
- R.displayName = "SheetContent";
168
- const C = i.forwardRef(({ className: e, ...t }, a) => /* @__PURE__ */ o(
177
+ _.displayName = "SheetContent";
178
+ const q = l.forwardRef(({ className: e, ...t }, s) => /* @__PURE__ */ o(
169
179
  "div",
170
180
  {
171
- ref: a,
172
- className: d("flex flex-col gap-2 text-center sm:text-left", e),
181
+ ref: s,
182
+ className: c("flex flex-col gap-2 text-center sm:text-left", e),
173
183
  "data-slot": "sheet-header",
174
184
  ...t
175
185
  }
176
186
  ));
177
- C.displayName = "SheetHeader";
178
- const z = i.forwardRef(({ className: e, children: t, dataHook: a, ...r }, l) => /* @__PURE__ */ o(
179
- b,
187
+ q.displayName = "SheetHeader";
188
+ const G = l.forwardRef(
189
+ ({
190
+ className: e,
191
+ onPrevious: t,
192
+ onNext: s,
193
+ current: r,
194
+ total: n,
195
+ hasPrevious: f,
196
+ hasNext: b,
197
+ renderPosition: m,
198
+ ariaLabel: w,
199
+ prevAriaLabel: S,
200
+ nextAriaLabel: P,
201
+ dataHook: v,
202
+ trackingEl: B,
203
+ trackingLabel: A,
204
+ ...O
205
+ }, L) => {
206
+ const p = f ?? (r == null || r > 1), g = b ?? (r == null || n == null || r < n), x = l.useRef(null), y = l.useRef(null), u = l.useRef(null);
207
+ l.useEffect(() => {
208
+ const a = u.current;
209
+ if (u.current = null, !a) return;
210
+ const i = document.activeElement;
211
+ i !== a && i !== document.body || (!p && a === x.current && g ? y.current?.focus() : !g && a === y.current && p && x.current?.focus());
212
+ });
213
+ const C = (a) => {
214
+ const i = a.relatedTarget;
215
+ i && i !== x.current && i !== y.current && (u.current = null);
216
+ }, N = (a, i) => {
217
+ if (a === "previous") {
218
+ if (!p) return;
219
+ u.current = i, t();
220
+ } else {
221
+ if (!g) return;
222
+ u.current = i, s();
223
+ }
224
+ }, D = (a) => {
225
+ a.key === "ArrowUp" || a.key === "ArrowLeft" ? (a.preventDefault(), N("previous", a.currentTarget)) : (a.key === "ArrowDown" || a.key === "ArrowRight") && (a.preventDefault(), N("next", a.currentTarget));
226
+ };
227
+ let k = null;
228
+ return m !== null && r != null && n != null && (k = m ? m({ current: r, total: n }) : `${r} of ${n}`), /* @__PURE__ */ h(
229
+ "div",
230
+ {
231
+ ref: L,
232
+ "aria-label": w ?? "Item navigation",
233
+ className: c("mb-2 flex items-center gap-1", e),
234
+ "data-hook": v,
235
+ "data-slot": "sheet-pagination",
236
+ "data-tracking-el": B,
237
+ "data-tracking-label": A,
238
+ role: "group",
239
+ ...O,
240
+ children: [
241
+ /* @__PURE__ */ o(
242
+ R,
243
+ {
244
+ ref: x,
245
+ ariaLabel: S ?? "Previous item",
246
+ dataHook: `${v}-previous`,
247
+ disabled: !p,
248
+ variant: "ghost",
249
+ onBlur: C,
250
+ onClick: (a) => N("previous", a.currentTarget),
251
+ onKeyDown: D,
252
+ children: /* @__PURE__ */ o(H, {})
253
+ }
254
+ ),
255
+ /* @__PURE__ */ o(
256
+ R,
257
+ {
258
+ ref: y,
259
+ ariaLabel: P ?? "Next item",
260
+ dataHook: `${v}-next`,
261
+ disabled: !g,
262
+ variant: "ghost",
263
+ onBlur: C,
264
+ onClick: (a) => N("next", a.currentTarget),
265
+ onKeyDown: D,
266
+ children: /* @__PURE__ */ o(K, {})
267
+ }
268
+ ),
269
+ k != null && /* @__PURE__ */ o(
270
+ "span",
271
+ {
272
+ "aria-live": "polite",
273
+ className: "text-body-sm text-muted-foreground",
274
+ "data-slot": "sheet-pagination-position",
275
+ children: k
276
+ }
277
+ )
278
+ ]
279
+ }
280
+ );
281
+ }
282
+ );
283
+ G.displayName = "SheetPagination";
284
+ const J = l.forwardRef(({ className: e, children: t, dataHook: s, ...r }, n) => /* @__PURE__ */ o(
285
+ V,
180
286
  {
181
- ref: l,
182
- className: d("-mx-6 min-h-0 flex-1", e),
287
+ ref: n,
288
+ className: c("-mx-6 min-h-0 flex-1", e),
183
289
  "data-slot": "sheet-body",
184
- dataHook: a ?? "sheet-body",
290
+ dataHook: s ?? "sheet-body",
185
291
  ...r,
186
292
  children: /* @__PURE__ */ o("div", { className: "px-5", "data-slot": "sheet-body-content", children: t })
187
293
  }
188
294
  ));
189
- z.displayName = "SheetBody";
190
- const T = i.forwardRef(({ className: e, ...t }, a) => /* @__PURE__ */ o(
295
+ J.displayName = "SheetBody";
296
+ const M = l.forwardRef(({ className: e, ...t }, s) => /* @__PURE__ */ o(
191
297
  "div",
192
298
  {
193
- ref: a,
194
- className: d(
299
+ ref: s,
300
+ className: c(
195
301
  "mt-auto flex flex-col gap-2 sm:flex-row sm:justify-end",
196
302
  e
197
303
  ),
@@ -199,47 +305,48 @@ const T = i.forwardRef(({ className: e, ...t }, a) => /* @__PURE__ */ o(
199
305
  ...t
200
306
  }
201
307
  ));
202
- T.displayName = "SheetFooter";
203
- const P = i.forwardRef(({ className: e, icon: t, children: a, dataHook: r, ...l }, c) => /* @__PURE__ */ n(
204
- s.Title,
308
+ M.displayName = "SheetFooter";
309
+ const Q = l.forwardRef(({ className: e, icon: t, children: s, dataHook: r, ...n }, f) => /* @__PURE__ */ h(
310
+ d.Title,
205
311
  {
206
- ref: c,
207
- className: d(
312
+ ref: f,
313
+ className: c(
208
314
  "text-foreground text-heading-section",
209
315
  t && "flex items-center gap-2",
210
316
  e
211
317
  ),
212
318
  "data-hook": r,
213
319
  "data-slot": "sheet-title",
214
- ...l,
320
+ ...n,
215
321
  children: [
216
322
  t && /* @__PURE__ */ o("span", { className: "shrink-0 [&_svg]:size-5", "data-slot": "sheet-title-icon", children: t }),
217
- a
323
+ s
218
324
  ]
219
325
  }
220
326
  ));
221
- P.displayName = "SheetTitle";
222
- const D = i.forwardRef(({ className: e, dataHook: t, ...a }, r) => /* @__PURE__ */ o(
223
- s.Description,
327
+ Q.displayName = "SheetTitle";
328
+ const W = l.forwardRef(({ className: e, dataHook: t, ...s }, r) => /* @__PURE__ */ o(
329
+ d.Description,
224
330
  {
225
331
  ref: r,
226
- className: d("text-body-sm text-muted-foreground", e),
332
+ className: c("text-body-sm text-muted-foreground", e),
227
333
  "data-hook": t,
228
334
  "data-slot": "sheet-description",
229
- ...a
335
+ ...s
230
336
  }
231
337
  ));
232
- D.displayName = "SheetDescription";
338
+ W.displayName = "SheetDescription";
233
339
  export {
234
- v as Sheet,
235
- z as SheetBody,
236
- k as SheetClose,
237
- R as SheetContent,
238
- D as SheetDescription,
239
- T as SheetFooter,
240
- C as SheetHeader,
241
- m as SheetOverlay,
242
- f as SheetPortal,
243
- P as SheetTitle,
244
- w as SheetTrigger
340
+ U as Sheet,
341
+ J as SheetBody,
342
+ X as SheetClose,
343
+ _ as SheetContent,
344
+ W as SheetDescription,
345
+ M as SheetFooter,
346
+ q as SheetHeader,
347
+ z as SheetOverlay,
348
+ G as SheetPagination,
349
+ T as SheetPortal,
350
+ Q as SheetTitle,
351
+ I as SheetTrigger
245
352
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),Q=require("react"),W=require("@brightlocal/icons"),G=require("@brightlocal/ui-components/button"),i=require("@brightlocal/ui-components/drawer"),X=require("@brightlocal/ui-components/hooks/use-breakpoint"),Y=require("@brightlocal/ui-components/label"),R=require("@brightlocal/ui-components/radio-group"),g=require("@brightlocal/ui-components/select"),P=require("@brightlocal/ui-components/lib/utils"),_=require("@brightlocal/ui-components/multi-select-filter");function Z(n){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const a in n)if(a!=="default"){const c=Object.getOwnPropertyDescriptor(n,a);Object.defineProperty(l,a,c.get?c:{enumerable:!0,get:()=>n[a]})}}return l.default=n,Object.freeze(l)}const h=Z(Q);function E({value:n,defaultValue:l,onValueChange:a,open:c,onOpenChange:x}){const[m,p]=h.useState(l),d=n!==void 0,b=d?n:m,[j,S]=h.useState(!1),u=c!==void 0,v=u?c:j,f=h.useCallback(o=>{d||p(o),a?.(o)},[d,a]),w=h.useCallback(o=>{u||S(o),x?.(o)},[u,x]);return{clear:()=>f(l),onOpenChange:w,open:v,setValue:f,value:b}}function H({count:n}){return e.jsx("span",{className:"text-muted-foreground text-label-sm ml-auto tabular-nums",children:n})}function y({children:n,dataHook:l}){return e.jsx("span",{"aria-hidden":"true",className:"flex shrink-0 items-center [&_svg]:size-4","data-hook":l,children:n})}function M({className:n,dataHook:l,label:a,options:c,value:x,defaultValue:m="",onValueChange:p,open:d,onOpenChange:b,size:j="default",icon:S,presentation:u="menu",disabled:v=!1,clearLabel:f,doneLabel:w,drawerDescription:o,trackingEl:N,trackingLabel:O,"aria-label":k,ref:q,...F}){const s=E({defaultValue:m,onOpenChange:b,onValueChange:p,open:d,value:x}),L=X.useIsBelowBreakpoint("md"),U=u==="drawer"||u==="auto"&&L,z=h.useId(),C=s.value===""?void 0:c.find(t=>t.value===s.value),D=C?.label,$=C!==void 0,A=$?D:a,T=S??C?.icon,I=T?e.jsx(y,{dataHook:`${l}-icon`,children:T}):null,V=$?`${a}: ${D}`:a;if(U){const t=e.jsxs("button",{ref:q,"aria-label":k??V,className:P.cn(_.multiSelectFilterTriggerVariants({size:j}),n),"data-hook":l,"data-slot":"single-select-filter","data-tracking-el":N??"single-select-filter","data-tracking-label":O,disabled:v,type:"button",...F,children:[I,e.jsx("span",{"data-hook":`${l}-summary`,children:A}),e.jsx(W.ChevronDown,{"aria-hidden":"true",className:"text-muted-foreground"})]});return e.jsxs(i.Drawer,{open:s.open,onOpenChange:s.onOpenChange,children:[e.jsx(i.DrawerTrigger,{asChild:!0,children:t}),e.jsxs(i.DrawerContent,{dataHook:`${l}-drawer`,children:[e.jsxs(i.DrawerHeader,{children:[e.jsx(i.DrawerTitle,{children:a}),e.jsx(i.DrawerDescription,{className:"sr-only",children:o??"Pick one option."})]}),e.jsxs(i.DrawerBody,{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pb-2",children:[e.jsx(R.RadioGroup,{className:"grid grid-cols-2 gap-x-4 gap-y-3",dataHook:`${l}-radio-group`,value:s.value,onValueChange:r=>{s.setValue(r)},children:c.map((r,J)=>{const K=r.disabled||r.count===0,B=`${z}-${J}`;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R.RadioGroupItem,{"data-hook":`${l}-option-${r.value}`,disabled:K,id:B,value:r.value}),e.jsxs(Y.Label,{className:"flex-1 gap-2",htmlFor:B,children:[r.icon?e.jsx(y,{dataHook:`${l}-option-${r.value}-icon`,children:r.icon}):null,r.label]}),r.count!==void 0?e.jsx(H,{count:r.count}):null]},r.value)})}),$&&s.value!==m?e.jsx(G.Button,{dataHook:`${l}-clear`,variant:"ghost",onClick:()=>s.clear(),children:f??"Clear filters"}):null]}),e.jsx(i.DrawerFooter,{children:e.jsx(i.DrawerClose,{asChild:!0,children:e.jsx(G.Button,{dataHook:`${l}-done`,children:w??"Done"})})})]})]})}return e.jsx("span",{"data-hook":l,"data-slot":"single-select-filter","data-tracking-el":N??"single-select-filter","data-tracking-label":O,children:e.jsxs(g.Select,{disabled:v,open:s.open,value:s.value,onOpenChange:s.onOpenChange,onValueChange:t=>s.setValue(t),children:[e.jsxs(g.SelectTrigger,{ref:q,className:P.cn(_.multiSelectFilterTriggerVariants({size:j}),"data-[placeholder]:text-foreground w-auto",n),dataHook:`${l}-trigger`,selectLabel:k??V,...F,children:[I,e.jsx(g.SelectValue,{placeholder:a,children:D})]}),e.jsx(g.SelectContent,{align:"start",children:c.map(t=>{const r=t.disabled||t.count===0;return e.jsx(g.SelectItem,{"data-hook":`${l}-option-${t.value}`,disabled:r,hint:t.count!==void 0?e.jsx("span",{className:"tabular-nums",children:t.count}):void 0,value:t.value,children:e.jsxs("span",{className:"flex items-center gap-2",children:[t.icon?e.jsx(y,{dataHook:`${l}-option-${t.value}-icon`,children:t.icon}):null,t.label]})},t.value)})})]})})}const ee=M;M.displayName="SingleSelectFilter";exports.SingleSelectFilter=ee;
@@ -0,0 +1,81 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ import { multiSelectFilterTriggerVariants } from './multi-select-filter';
3
+ import * as React from "react";
4
+ interface SingleSelectFilterOption<Value extends string = string> {
5
+ value: Value;
6
+ label: string;
7
+ count?: number;
8
+ disabled?: boolean;
9
+ /**
10
+ * Glyph before the label in the menu and the drawer — the option's own
11
+ * mark (a source's logo, a period's clock), 16px. The trigger wears the
12
+ * picked option's glyph when no `icon` is set. Hidden from assistive tech.
13
+ */
14
+ icon?: React.ReactNode;
15
+ }
16
+ interface SingleSelectFilterProps<Value extends string = string> extends Omit<React.ComponentPropsWithoutRef<"button">, "value" | "defaultValue" | "onChange" | "children">, VariantProps<typeof multiSelectFilterTriggerVariants> {
17
+ /** Data hook for automated testing (REQUIRED). */
18
+ dataHook: string;
19
+ /**
20
+ * The dimension's name — drawer title, Select accessible label.
21
+ * Use the product's words ("Time period"), never an internal field name.
22
+ */
23
+ label: string;
24
+ /**
25
+ * The selectable options, in the dimension's own order. Values must be
26
+ * non-empty — `""` means "nothing picked", so make "All" an explicit value.
27
+ */
28
+ options: readonly SingleSelectFilterOption<Value>[];
29
+ /** Controlled selected value. */
30
+ value?: Value;
31
+ /**
32
+ * Initial value for uncontrolled mode.
33
+ * @default ""
34
+ */
35
+ defaultValue?: Value;
36
+ /** Callback on every pick. */
37
+ onValueChange?: (value: Value) => void;
38
+ /** Controlled open state. */
39
+ open?: boolean;
40
+ /** Callback when the surface opens or closes. */
41
+ onOpenChange?: (open: boolean) => void;
42
+ /**
43
+ * Fixed glyph leading the trigger — the dimension's own icon (a calendar,
44
+ * a funnel), 16px. Without it the trigger wears the picked option's
45
+ * `option.icon`. Hidden from assistive tech.
46
+ */
47
+ icon?: React.ReactNode;
48
+ /**
49
+ * How the options open: the DS Select `menu`, a bottom `drawer`, or `auto`
50
+ * — the menu from the md breakpoint up and the drawer below it.
51
+ * @default "menu"
52
+ */
53
+ presentation?: "menu" | "drawer" | "auto";
54
+ /** Disables the trigger. */
55
+ disabled?: boolean;
56
+ /**
57
+ * Label of the clear action inside the drawer.
58
+ * @default "Clear filters"
59
+ */
60
+ clearLabel?: string;
61
+ /**
62
+ * Label of the drawer's Done button.
63
+ * @default "Done"
64
+ */
65
+ doneLabel?: string;
66
+ /**
67
+ * Screen-reader description of the drawer.
68
+ * @default "Pick one option."
69
+ */
70
+ drawerDescription?: string;
71
+ /** Analytics element identifier. @default "single-select-filter" */
72
+ trackingEl?: string;
73
+ /** Analytics label */
74
+ trackingLabel?: string;
75
+ }
76
+ declare const SingleSelectFilter: <Value extends string = string>(props: SingleSelectFilterProps<Value> & {
77
+ ref?: React.Ref<HTMLButtonElement>;
78
+ }) => React.ReactElement | null;
79
+ export { SingleSelectFilter, type SingleSelectFilterOption };
80
+ export type { SingleSelectFilterProps };
81
+ //# sourceMappingURL=single-select-filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-select-filter.d.ts","sourceRoot":"","sources":["../../src/components/single-select-filter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AA6B7D,OAAO,EAAE,gCAAgC,EAAE,MAAM,gDAAgD,CAAC;AAwBlG,UAAU,wBAAwB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM;IAC9D,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACxB;AAED,UAAU,uBAAuB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,CAC7D,SACE,IAAI,CACF,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,EACxC,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,CACnD,EACD,YAAY,CAAC,OAAO,gCAAgC,CAAC;IACvD,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,EAAE,SAAS,wBAAwB,CAAC,KAAK,CAAC,EAAE,CAAC;IACpD,iCAAiC;IACjC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,8BAA8B;IAC9B,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvC,6BAA6B;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iDAAiD;IACjD,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;;OAIG;IACH,I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