@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/textarea.js CHANGED
@@ -9,7 +9,7 @@ const b = u([
9
9
  "border border-input bg-background rounded-md",
10
10
  "outline-none transition-[border-color,background-color,box-shadow] duration-fast ease-out",
11
11
  // Typography
12
- "text-body",
12
+ "text-field",
13
13
  "text-foreground",
14
14
  // Spacing
15
15
  "px-3 py-2",
package/dist/tooltip.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),m=require("react"),x=require("@radix-ui/react-tooltip"),l=require("@brightlocal/ui-components/lib/utils");function s(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(o,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}return o.default=t,Object.freeze(o)}const c=s(m),i=s(x);function y({delayDuration:t=0,skipDelayDuration:o=0,...e}){return a.jsx(i.Provider,{delayDuration:t,skipDelayDuration:o,...e})}function b({...t}){return a.jsx(i.Root,{...t})}const d=c.forwardRef(({dataHook:t,trackingEl:o,trackingLabel:e,...r},n)=>a.jsx(i.Trigger,{ref:n,"data-hook":t,"data-slot":"tooltip-trigger","data-tracking-el":o,"data-tracking-label":e,...r}));d.displayName="TooltipTrigger";const p=c.forwardRef(({className:t,sideOffset:o=0,dataHook:e,trackingEl:r,trackingLabel:n,hideArrow:u=!1,children:g,...T},f)=>a.jsx(i.Portal,{children:a.jsxs(i.Content,{ref:f,className:l.cn("bg-secondary text-secondary-foreground text-body-xs z-50 w-max max-w-sm rounded-md px-3 py-1.5",l.FLOATING_CONTENT_ANIMATION,"**:data-[slot=tooltip-arrow]:-translate-y-px",t),"data-hook":e,"data-slot":"tooltip-content","data-tracking-el":r,"data-tracking-label":n,sideOffset:o,...T,children:[g,!u&&a.jsx(i.Arrow,{className:"fill-secondary","data-slot":"tooltip-arrow",height:7,width:14})]})}));p.displayName="TooltipContent";exports.Tooltip=b;exports.TooltipContent=p;exports.TooltipProvider=y;exports.TooltipTrigger=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),V=require("react"),U=require("@radix-ui/react-popover"),J=require("@radix-ui/react-slot"),A=require("@brightlocal/ui-components/lib/utils");function F(t){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const l=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(i,n,l.get?l:{enumerable:!0,get:()=>t[n]})}}return i.default=t,Object.freeze(i)}const e=F(V),y=F(U),L=e.createContext({delayDuration:0,skipDelayDuration:0});function K({delayDuration:t=0,skipDelayDuration:i=0,children:n}){const l=e.useMemo(()=>({delayDuration:t,skipDelayDuration:i}),[t,i]);return p.jsx(L.Provider,{value:l,children:n})}function a(t,i){return n=>{t?.(n),n.defaultPrevented||i(n)}}const Q=200,M=e.createContext(null);function q(){const t=e.useContext(M);if(!t)throw new Error("Tooltip components must be used within <Tooltip>");return t}function W({open:t,defaultOpen:i=!1,onOpenChange:n,children:l}){const{delayDuration:v}=e.useContext(L),[k,x]=e.useState(i??!1),m=t!==void 0,d=m?t:k,f=e.useRef(void 0),g=e.useRef(void 0),P=e.useRef(null),T=e.useRef("hover"),c=e.useRef(null),b=e.useId(),s=e.useCallback(o=>{o||(T.current="hover"),m||x(o),n?.(o)},[m,n]),r=e.useCallback(()=>{f.current!==void 0&&(clearTimeout(f.current),f.current=void 0),g.current!==void 0&&(clearTimeout(g.current),g.current=void 0)},[]);e.useEffect(()=>r,[r]);const u=e.useCallback(()=>{r(),T.current!=="touch"&&(v>0?g.current=setTimeout(()=>s(!0),v):s(!0))},[r,v,s]),C=e.useCallback(()=>{r(),T.current!=="touch"&&(f.current=setTimeout(()=>s(!1),Q))},[r,s]),O=e.useCallback(o=>{o.pointerType!=="touch"&&u()},[u]),R=e.useCallback(o=>{o.pointerType!=="touch"&&(c.current=null,C())},[C]),j=e.useCallback(o=>{c.current=o.pointerType==="touch"?"touch":"mouse"},[]),w=e.useCallback(()=>{c.current=null},[]),E=e.useCallback(()=>{const o=c.current;c.current=null,o==="touch"&&(r(),d?s(!1):(T.current="touch",s(!0)))},[r,d,s]),N=e.useCallback(()=>{c.current||u()},[u]),I=e.useCallback(()=>{C()},[C]),h=e.useCallback(()=>{r()},[r]),_=e.useCallback(o=>{o.pointerType!=="touch"&&C()},[C]),D=e.useCallback(o=>{const S=o.target;S instanceof Node&&P.current?.contains(S)&&o.preventDefault()},[]),z=e.useCallback(o=>{o||(r(),s(!1))},[r,s]),G=e.useMemo(()=>({open:d,tooltipId:b,triggerRef:P,onTriggerPointerEnter:O,onTriggerPointerLeave:R,onTriggerPointerDown:j,onTriggerPointerCancel:w,onTriggerClick:E,onTriggerFocus:N,onTriggerBlur:I,onContentPointerEnter:h,onContentPointerLeave:_,onContentInteractOutside:D}),[d,b,O,R,j,w,E,N,I,h,_,D]);return p.jsx(M.Provider,{value:G,children:p.jsx(y.Root,{open:d,onOpenChange:z,children:l})})}const H=e.forwardRef(({dataHook:t,trackingEl:i,trackingLabel:n,asChild:l,children:v,onBlur:k,onClick:x,onFocus:m,onPointerCancel:d,onPointerDown:f,onPointerEnter:g,onPointerLeave:P,...T},c)=>{const{open:b,tooltipId:s,triggerRef:r,onTriggerPointerEnter:u,onTriggerPointerLeave:C,onTriggerPointerDown:O,onTriggerPointerCancel:R,onTriggerClick:j,onTriggerFocus:w,onTriggerBlur:E}=q(),N=e.useCallback(h=>{r.current=h,typeof c=="function"?c(h):c&&(c.current=h)},[c,r]),I=l?J.Slot:"button";return p.jsx(y.Anchor,{asChild:!0,children:p.jsx(I,{ref:N,"data-slot":"tooltip-trigger",...T,"aria-describedby":b?s:void 0,"data-hook":t,"data-tracking-el":i,"data-tracking-label":n,type:l?void 0:"button",onBlur:a(k,E),onClick:a(x,j),onFocus:a(m,w),onPointerCancel:a(d,R),onPointerDown:a(f,O),onPointerEnter:a(g,u),onPointerLeave:a(P,C),children:v})})});H.displayName="TooltipTrigger";const B=e.forwardRef(({className:t,side:i="top",sideOffset:n=0,dataHook:l,trackingEl:v,trackingLabel:k,hideArrow:x=!1,children:m,onInteractOutside:d,onPointerEnter:f,onPointerLeave:g,...P},T)=>{const{tooltipId:c,onContentPointerEnter:b,onContentPointerLeave:s,onContentInteractOutside:r}=q();return p.jsx(y.Portal,{children:p.jsxs(y.Content,{ref:T,className:A.cn("bg-secondary text-secondary-foreground text-body-xs z-50 w-max max-w-sm rounded-md px-3 py-1.5",A.FLOATING_CONTENT_ANIMATION,"**:data-[slot=tooltip-arrow]:-translate-y-px",t),"data-hook":l,"data-slot":"tooltip-content","data-tracking-el":v,"data-tracking-label":k,side:i,sideOffset:n,onCloseAutoFocus:u=>u.preventDefault(),onOpenAutoFocus:u=>u.preventDefault(),...P,role:"none",onInteractOutside:a(d,r),onPointerEnter:a(f,b),onPointerLeave:a(g,s),children:[p.jsx("span",{id:c,role:"tooltip",children:m}),!x&&p.jsx(y.Arrow,{className:"fill-secondary","data-slot":"tooltip-arrow",height:7,width:14})]})})});B.displayName="TooltipContent";exports.Tooltip=W;exports.TooltipContent=B;exports.TooltipProvider=K;exports.TooltipTrigger=H;
package/dist/tooltip.d.ts CHANGED
@@ -1,8 +1,17 @@
1
1
  import * as React from "react";
2
- import * as TooltipPrimitive from "@radix-ui/react-tooltip";
3
- interface TooltipProviderProps extends React.ComponentProps<typeof TooltipPrimitive.Provider> {
2
+ import * as PopoverPrimitive from "@radix-ui/react-popover";
3
+ interface TooltipProviderProps {
4
+ /**
5
+ * The duration in ms to wait before showing the tooltip.
6
+ * @default 0
7
+ */
4
8
  delayDuration?: number;
9
+ /**
10
+ * The duration in ms to skip the delay when moving between tooltips.
11
+ * @default 0
12
+ */
5
13
  skipDelayDuration?: number;
14
+ children: React.ReactNode;
6
15
  }
7
16
  /**
8
17
  * TooltipProvider - Wraps your application or a section of it to provide shared tooltip configuration.
@@ -20,12 +29,19 @@ interface TooltipProviderProps extends React.ComponentProps<typeof TooltipPrimit
20
29
  * @param delayDuration - The duration in ms to wait before showing the tooltip (default: 0)
21
30
  * @param skipDelayDuration - The duration in ms to skip the delay when moving between tooltips (default: 0)
22
31
  */
23
- declare function TooltipProvider({ delayDuration, skipDelayDuration, ...props }: TooltipProviderProps): import("react/jsx-runtime").JSX.Element;
32
+ declare function TooltipProvider({ delayDuration, skipDelayDuration, children, }: TooltipProviderProps): import("react/jsx-runtime").JSX.Element;
24
33
  /**
25
- * Tooltip - Displays a popup with additional information when hovering over an element.
34
+ * Tooltip - Displays a popup with additional information.
35
+ *
36
+ * Toggletip behaviour by input type:
37
+ * - **Mouse / pen / keyboard**: opens on hover or focus, closes when the pointer
38
+ * leaves (after a short grace period so the pointer can move onto the content)
39
+ * or focus moves away.
40
+ * - **Touch**: a tap toggles it. While open it ignores hover/blur signals so the
41
+ * text can be long-pressed and copied; it closes on a second tap of the
42
+ * trigger, a tap outside, or Escape.
26
43
  *
27
44
  * @example
28
- * // Basic usage (requires TooltipProvider wrapper):
29
45
  * <Tooltip>
30
46
  * <TooltipTrigger asChild>
31
47
  * <Button>Hover me</Button>
@@ -36,50 +52,36 @@ declare function TooltipProvider({ delayDuration, skipDelayDuration, ...props }:
36
52
  * </Tooltip>
37
53
  *
38
54
  * @remarks
39
- * This component must be used within a TooltipProvider. Wrap your app or component tree
40
- * with TooltipProvider once at the top level for optimal performance and UX when using
41
- * multiple tooltips.
55
+ * Wrap your app once in a TooltipProvider to share `delayDuration` across all
56
+ * tooltips. Without one the provider defaults (no delay) apply.
42
57
  */
43
- declare function Tooltip({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
44
- interface TooltipTriggerProps extends React.ComponentProps<typeof TooltipPrimitive.Trigger> {
58
+ declare function Tooltip({ open: controlledOpen, defaultOpen, onOpenChange, children, }: React.ComponentProps<typeof PopoverPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
59
+ interface TooltipTriggerProps extends React.ComponentPropsWithoutRef<"button"> {
45
60
  /**
46
- * Data hook for automated testing, rendered as the `data-hook` attribute
47
- * (the platform test-selector contract).
48
- *
61
+ * Data hook for automated testing, rendered as the `data-hook` attribute.
49
62
  * Optional because `TooltipTrigger` is commonly used with `asChild`, where the
50
- * child element (e.g. a `Button`) already carries its own `dataHook`. When
51
- * `asChild` is set, the child's `data-hook` wins over this one.
63
+ * child element already carries its own `dataHook`.
52
64
  */
53
65
  dataHook?: string;
54
- /**
55
- * Optional analytics element identifier
56
- */
66
+ /** Optional analytics element identifier */
57
67
  trackingEl?: string;
58
- /**
59
- * Optional analytics label context
60
- */
68
+ /** Optional analytics label context */
61
69
  trackingLabel?: string;
70
+ /** Render as child element using Radix Slot */
71
+ asChild?: boolean;
62
72
  }
63
- declare const TooltipTrigger: React.ForwardRefExoticComponent<Omit<TooltipTriggerProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
64
- interface TooltipContentProps extends React.ComponentProps<typeof TooltipPrimitive.Content> {
65
- /**
66
- * Required data-hook attribute for testing and analytics
67
- */
73
+ declare const TooltipTrigger: React.ForwardRefExoticComponent<TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
74
+ interface TooltipContentProps extends Omit<React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>, "onOpenAutoFocus" | "onCloseAutoFocus"> {
75
+ /** Required data-hook attribute for testing and analytics */
68
76
  dataHook: string;
69
- /**
70
- * Optional analytics element identifier
71
- */
77
+ /** Optional analytics element identifier */
72
78
  trackingEl?: string;
73
- /**
74
- * Optional analytics label context
75
- */
79
+ /** Optional analytics label context */
76
80
  trackingLabel?: string;
77
- /**
78
- * Hide the tooltip arrow
79
- */
81
+ /** Hide the tooltip arrow */
80
82
  hideArrow?: boolean;
81
83
  }
82
- declare const TooltipContent: React.ForwardRefExoticComponent<Omit<TooltipContentProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
84
+ declare const TooltipContent: React.ForwardRefExoticComponent<TooltipContentProps & React.RefAttributes<HTMLDivElement>>;
83
85
  export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
84
86
  export type { TooltipContentProps, TooltipProviderProps, TooltipTriggerProps };
85
87
  //# sourceMappingURL=tooltip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../src/components/tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAC;AAO5D,UAAU,oBAAqB,SAAQ,KAAK,CAAC,cAAc,CACzD,OAAO,gBAAgB,CAAC,QAAQ,CACjC;IACC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,eAAe,CAAC,EACvB,aAAiB,EACjB,iBAAqB,EACrB,GAAG,KAAK,EACT,EAAE,oBAAoB,2CAQtB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,iBAAS,OAAO,CAAC,EACf,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,IAAI,CAAC,2CAEpD;AAED,UAAU,mBAAoB,SAAQ,KAAK,CAAC,cAAc,CACxD,OAAO,gBAAgB,CAAC,OAAO,CAChC;IACC;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,cAAc,4GAclB,CAAC;AAIH,UAAU,mBAAoB,SAAQ,KAAK,CAAC,cAAc,CACxD,OAAO,gBAAgB,CAAC,OAAO,CAChC;IACC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,QAAA,MAAM,cAAc,yGA+CnB,CAAC;AAIF,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC;AACpE,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,CAAC"}
1
+ {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../src/components/tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAC;AAU5D,UAAU,oBAAoB;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAcD;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,eAAe,CAAC,EACvB,aAAiB,EACjB,iBAAqB,EACrB,QAAQ,GACT,EAAE,oBAAoB,2CAUtB;AAqED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,iBAAS,OAAO,CAAC,EACf,IAAI,EAAE,cAAc,EACpB,WAAmB,EACnB,YAAY,EACZ,QAAQ,GACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,IAAI,CAAC,2CA8LpD;AAID,UAAU,mBAAoB,SAAQ,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC;IAC5E;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,QAAA,MAAM,cAAc,+FA+EnB,CAAC;AAMF,UAAU,mBAAoB,SAAQ,IAAI,CACxC,KAAK,CAAC,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,EAC/D,iBAAiB,GAAG,kBAAkB,CACvC;IACC,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,QAAA,MAAM,cAAc,4FA4EnB,CAAC;AAIF,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC;AACpE,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,CAAC"}
package/dist/tooltip.js CHANGED
@@ -1,83 +1,272 @@
1
- import { jsx as e, jsxs as m } from "react/jsx-runtime";
2
- import * as n from "react";
3
- import * as o from "@radix-ui/react-tooltip";
4
- import { cn as g, FLOATING_CONTENT_ANIMATION as T } from "@brightlocal/ui-components/lib/utils";
5
- function w({
6
- delayDuration: t = 0,
7
- skipDelayDuration: r = 0,
8
- ...a
1
+ import { jsx as T, jsxs as j } from "react/jsx-runtime";
2
+ import * as e from "react";
3
+ import * as y from "@radix-ui/react-popover";
4
+ import { Slot as G } from "@radix-ui/react-slot";
5
+ import { cn as V, FLOATING_CONTENT_ANIMATION as z } from "@brightlocal/ui-components/lib/utils";
6
+ const _ = e.createContext(
7
+ {
8
+ delayDuration: 0,
9
+ skipDelayDuration: 0
10
+ }
11
+ );
12
+ function X({
13
+ delayDuration: n = 0,
14
+ skipDelayDuration: s = 0,
15
+ children: c
9
16
  }) {
10
- return /* @__PURE__ */ e(
11
- o.Provider,
12
- {
13
- delayDuration: t,
14
- skipDelayDuration: r,
15
- ...a
16
- }
17
+ const d = e.useMemo(
18
+ () => ({ delayDuration: n, skipDelayDuration: s }),
19
+ [n, s]
17
20
  );
21
+ return /* @__PURE__ */ T(_.Provider, { value: d, children: c });
22
+ }
23
+ function a(n, s) {
24
+ return (c) => {
25
+ n?.(c), c.defaultPrevented || s(c);
26
+ };
27
+ }
28
+ const U = 200, H = e.createContext(null);
29
+ function M() {
30
+ const n = e.useContext(H);
31
+ if (!n)
32
+ throw new Error("Tooltip components must be used within <Tooltip>");
33
+ return n;
18
34
  }
19
- function y({
20
- ...t
35
+ function Y({
36
+ open: n,
37
+ defaultOpen: s = !1,
38
+ onOpenChange: c,
39
+ children: d
21
40
  }) {
22
- return /* @__PURE__ */ e(o.Root, { ...t });
41
+ const { delayDuration: m } = e.useContext(_), [k, x] = e.useState(
42
+ s ?? !1
43
+ ), v = n !== void 0, u = v ? n : k, p = e.useRef(void 0), f = e.useRef(void 0), P = e.useRef(null), g = e.useRef("hover"), r = e.useRef(null), h = e.useId(), i = e.useCallback(
44
+ (t) => {
45
+ t || (g.current = "hover"), v || x(t), c?.(t);
46
+ },
47
+ [v, c]
48
+ ), o = e.useCallback(() => {
49
+ p.current !== void 0 && (clearTimeout(p.current), p.current = void 0), f.current !== void 0 && (clearTimeout(f.current), f.current = void 0);
50
+ }, []);
51
+ e.useEffect(() => o, [o]);
52
+ const l = e.useCallback(() => {
53
+ o(), g.current !== "touch" && (m > 0 ? f.current = setTimeout(() => i(!0), m) : i(!0));
54
+ }, [o, m, i]), C = e.useCallback(() => {
55
+ o(), g.current !== "touch" && (p.current = setTimeout(
56
+ () => i(!1),
57
+ U
58
+ ));
59
+ }, [o, i]), w = e.useCallback(
60
+ (t) => {
61
+ t.pointerType !== "touch" && l();
62
+ },
63
+ [l]
64
+ ), R = e.useCallback(
65
+ (t) => {
66
+ t.pointerType !== "touch" && (r.current = null, C());
67
+ },
68
+ [C]
69
+ ), E = e.useCallback((t) => {
70
+ r.current = t.pointerType === "touch" ? "touch" : "mouse";
71
+ }, []), O = e.useCallback(() => {
72
+ r.current = null;
73
+ }, []), I = e.useCallback(() => {
74
+ const t = r.current;
75
+ r.current = null, t === "touch" && (o(), u ? i(!1) : (g.current = "touch", i(!0)));
76
+ }, [o, u, i]), N = e.useCallback(() => {
77
+ r.current || l();
78
+ }, [l]), A = e.useCallback(() => {
79
+ C();
80
+ }, [C]), b = e.useCallback(() => {
81
+ o();
82
+ }, [o]), F = e.useCallback(
83
+ (t) => {
84
+ t.pointerType !== "touch" && C();
85
+ },
86
+ [C]
87
+ ), L = e.useCallback((t) => {
88
+ const D = t.target;
89
+ D instanceof Node && P.current?.contains(D) && t.preventDefault();
90
+ }, []), S = e.useCallback(
91
+ (t) => {
92
+ t || (o(), i(!1));
93
+ },
94
+ [o, i]
95
+ ), B = e.useMemo(
96
+ () => ({
97
+ open: u,
98
+ tooltipId: h,
99
+ triggerRef: P,
100
+ onTriggerPointerEnter: w,
101
+ onTriggerPointerLeave: R,
102
+ onTriggerPointerDown: E,
103
+ onTriggerPointerCancel: O,
104
+ onTriggerClick: I,
105
+ onTriggerFocus: N,
106
+ onTriggerBlur: A,
107
+ onContentPointerEnter: b,
108
+ onContentPointerLeave: F,
109
+ onContentInteractOutside: L
110
+ }),
111
+ [
112
+ u,
113
+ h,
114
+ w,
115
+ R,
116
+ E,
117
+ O,
118
+ I,
119
+ N,
120
+ A,
121
+ b,
122
+ F,
123
+ L
124
+ ]
125
+ );
126
+ return /* @__PURE__ */ T(H.Provider, { value: B, children: /* @__PURE__ */ T(y.Root, { open: u, onOpenChange: S, children: d }) });
23
127
  }
24
- const f = n.forwardRef(({ dataHook: t, trackingEl: r, trackingLabel: a, ...i }, l) => /* @__PURE__ */ e(
25
- o.Trigger,
26
- {
27
- ref: l,
28
- "data-hook": t,
29
- "data-slot": "tooltip-trigger",
30
- "data-tracking-el": r,
31
- "data-tracking-label": a,
32
- ...i
128
+ const q = e.forwardRef(
129
+ ({
130
+ dataHook: n,
131
+ trackingEl: s,
132
+ trackingLabel: c,
133
+ asChild: d,
134
+ children: m,
135
+ onBlur: k,
136
+ onClick: x,
137
+ onFocus: v,
138
+ onPointerCancel: u,
139
+ onPointerDown: p,
140
+ onPointerEnter: f,
141
+ onPointerLeave: P,
142
+ ...g
143
+ }, r) => {
144
+ const {
145
+ open: h,
146
+ tooltipId: i,
147
+ triggerRef: o,
148
+ onTriggerPointerEnter: l,
149
+ onTriggerPointerLeave: C,
150
+ onTriggerPointerDown: w,
151
+ onTriggerPointerCancel: R,
152
+ onTriggerClick: E,
153
+ onTriggerFocus: O,
154
+ onTriggerBlur: I
155
+ } = M(), N = e.useCallback(
156
+ (b) => {
157
+ o.current = b, typeof r == "function" ? r(b) : r && (r.current = b);
158
+ },
159
+ [r, o]
160
+ ), A = d ? G : "button";
161
+ return /* @__PURE__ */ T(y.Anchor, { asChild: !0, children: /* @__PURE__ */ T(
162
+ A,
163
+ {
164
+ ref: N,
165
+ "data-slot": "tooltip-trigger",
166
+ ...g,
167
+ "aria-describedby": h ? i : void 0,
168
+ "data-hook": n,
169
+ "data-tracking-el": s,
170
+ "data-tracking-label": c,
171
+ type: d ? void 0 : "button",
172
+ onBlur: a(k, I),
173
+ onClick: a(x, E),
174
+ onFocus: a(v, O),
175
+ onPointerCancel: a(
176
+ u,
177
+ R
178
+ ),
179
+ onPointerDown: a(
180
+ p,
181
+ w
182
+ ),
183
+ onPointerEnter: a(
184
+ f,
185
+ l
186
+ ),
187
+ onPointerLeave: a(
188
+ P,
189
+ C
190
+ ),
191
+ children: m
192
+ }
193
+ ) });
33
194
  }
34
- ));
35
- f.displayName = "TooltipTrigger";
36
- const x = n.forwardRef(
195
+ );
196
+ q.displayName = "TooltipTrigger";
197
+ const J = e.forwardRef(
37
198
  ({
38
- className: t,
39
- sideOffset: r = 0,
40
- dataHook: a,
41
- trackingEl: i,
42
- trackingLabel: l,
43
- hideArrow: d = !1,
44
- children: s,
45
- ...p
46
- }, c) => /* @__PURE__ */ e(o.Portal, { children: /* @__PURE__ */ m(
47
- o.Content,
48
- {
49
- ref: c,
50
- className: g(
51
- "bg-secondary text-secondary-foreground text-body-xs z-50 w-max max-w-sm rounded-md px-3 py-1.5",
52
- T,
53
- "**:data-[slot=tooltip-arrow]:-translate-y-px",
54
- t
55
- ),
56
- "data-hook": a,
57
- "data-slot": "tooltip-content",
58
- "data-tracking-el": i,
59
- "data-tracking-label": l,
60
- sideOffset: r,
61
- ...p,
62
- children: [
63
- s,
64
- !d && /* @__PURE__ */ e(
65
- o.Arrow,
66
- {
67
- className: "fill-secondary",
68
- "data-slot": "tooltip-arrow",
69
- height: 7,
70
- width: 14
71
- }
72
- )
73
- ]
74
- }
75
- ) })
199
+ className: n,
200
+ side: s = "top",
201
+ sideOffset: c = 0,
202
+ dataHook: d,
203
+ trackingEl: m,
204
+ trackingLabel: k,
205
+ hideArrow: x = !1,
206
+ children: v,
207
+ onInteractOutside: u,
208
+ onPointerEnter: p,
209
+ onPointerLeave: f,
210
+ ...P
211
+ }, g) => {
212
+ const {
213
+ tooltipId: r,
214
+ onContentPointerEnter: h,
215
+ onContentPointerLeave: i,
216
+ onContentInteractOutside: o
217
+ } = M();
218
+ return /* @__PURE__ */ T(y.Portal, { children: /* @__PURE__ */ j(
219
+ y.Content,
220
+ {
221
+ ref: g,
222
+ className: V(
223
+ "bg-secondary text-secondary-foreground text-body-xs z-50 w-max max-w-sm rounded-md px-3 py-1.5",
224
+ z,
225
+ "**:data-[slot=tooltip-arrow]:-translate-y-px",
226
+ n
227
+ ),
228
+ "data-hook": d,
229
+ "data-slot": "tooltip-content",
230
+ "data-tracking-el": m,
231
+ "data-tracking-label": k,
232
+ side: s,
233
+ sideOffset: c,
234
+ onCloseAutoFocus: (l) => l.preventDefault(),
235
+ onOpenAutoFocus: (l) => l.preventDefault(),
236
+ ...P,
237
+ role: "none",
238
+ onInteractOutside: a(
239
+ u,
240
+ o
241
+ ),
242
+ onPointerEnter: a(
243
+ p,
244
+ h
245
+ ),
246
+ onPointerLeave: a(
247
+ f,
248
+ i
249
+ ),
250
+ children: [
251
+ /* @__PURE__ */ T("span", { id: r, role: "tooltip", children: v }),
252
+ !x && /* @__PURE__ */ T(
253
+ y.Arrow,
254
+ {
255
+ className: "fill-secondary",
256
+ "data-slot": "tooltip-arrow",
257
+ height: 7,
258
+ width: 14
259
+ }
260
+ )
261
+ ]
262
+ }
263
+ ) });
264
+ }
76
265
  );
77
- x.displayName = "TooltipContent";
266
+ J.displayName = "TooltipContent";
78
267
  export {
79
- y as Tooltip,
80
- x as TooltipContent,
81
- w as TooltipProvider,
82
- f as TooltipTrigger
268
+ Y as Tooltip,
269
+ J as TooltipContent,
270
+ X as TooltipProvider,
271
+ q as TooltipTrigger
83
272
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),b=require("react"),h=require("@radix-ui/react-slot"),m=require("class-variance-authority"),x=require("@brightlocal/ui-components/lib/utils");function j(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const n=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(e,a,n.get?n:{enumerable:!0,get:()=>t[a]})}}return e.default=t,Object.freeze(e)}const v=j(b),O=m.cva("",{variants:{variant:{display:"text-display",page:"text-heading-page",section:"text-heading-section",subsection:"text-heading-subsection",compact:"text-heading-compact"},color:{default:"text-foreground",muted:"text-muted-foreground"},align:{left:"text-left",center:"text-center",right:"text-right"},tabular:{true:"tabular-nums",false:"proportional-nums"}},defaultVariants:{color:"default"}}),S={1:"page",2:"section",3:"subsection",4:"subsection",5:"subsection",6:"subsection"},o=v.forwardRef(({className:t,level:e,variant:a,color:n="default",align:i,tabular:s,asChild:c=!1,dataHook:u,trackingEl:l,trackingLabel:d,...g},p)=>{const r=a??S[e],f=c?h.Slot:`h${e}`;return y.jsx(f,{ref:p,className:x.cn(O({variant:r,color:n,align:i,tabular:s}),t),"data-hook":u,"data-slot":"typography-heading","data-tracking-el":l||`typography-heading-${r}`,"data-tracking-label":d,...g})});o.displayName="TypographyHeading";exports.TypographyHeading=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),h=require("react"),m=require("@radix-ui/react-slot"),x=require("class-variance-authority"),j=require("@brightlocal/ui-components/lib/utils");function v(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(e,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return e.default=t,Object.freeze(e)}const O=v(h),S=x.cva("",{variants:{variant:{display:"text-display",page:"text-heading-page",section:"text-heading-section",subsection:"text-heading-subsection",compact:"text-heading-compact"},color:{default:"text-foreground",muted:"text-muted-foreground"},align:{left:"text-left",center:"text-center",right:"text-right"},tabular:{true:"tabular-nums",false:"proportional-nums"},truncate:{true:"block truncate"}},defaultVariants:{color:"default"}}),k={1:"page",2:"section",3:"subsection",4:"subsection",5:"subsection",6:"subsection"},o=O.forwardRef(({className:t,level:e,variant:a,color:r="default",align:c,tabular:i,truncate:s=!1,asChild:u=!1,dataHook:l,trackingEl:d,trackingLabel:g,...p},f)=>{const n=a??k[e],y=u?m.Slot:`h${e}`;return b.jsx(y,{ref:f,className:j.cn(S({variant:n,color:r,align:c,tabular:i,truncate:s}),t),"data-hook":l,"data-slot":"typography-heading","data-tracking-el":d||`typography-heading-${n}`,"data-tracking-label":g,...p})});o.displayName="TypographyHeading";exports.TypographyHeading=o;
@@ -77,6 +77,19 @@ interface TypographyHeadingProps extends React.ComponentProps<"h1"> {
77
77
  * TypographyText `metric` (plus `tabular` if it must align), not a heading.
78
78
  */
79
79
  tabular?: boolean;
80
+ /**
81
+ * Clip overflowing text to a single line with an ellipsis — card titles in
82
+ * a fixed-width grid, panel headers beside actions; anywhere a title can
83
+ * outgrow its container. The surrounding layout must still allow the
84
+ * element to shrink: inside a flex row the element (or its wrapper) needs
85
+ * `min-w-0`, and in a grid column `minmax(0, …)` — otherwise the box grows
86
+ * instead of clipping. Forces `display: block` (an inline box cannot
87
+ * clip), so an inline `asChild` child becomes a block while truncating —
88
+ * a no-op on the default h1–h6. Single-line only by design; a multi-line
89
+ * clamp can follow if demand appears.
90
+ * @default false
91
+ */
92
+ truncate?: boolean;
80
93
  /**
81
94
  * Render as a different element using Radix Slot pattern.
82
95
  * When true, merges props onto the child element.
@@ -1 +1 @@
1
- {"version":3,"file":"typography-heading.d.ts","sourceRoot":"","sources":["../../src/components/typography-heading.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B;;;;GAIG;AACH,KAAK,sBAAsB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEpD;;;;;;;;;;;;;;GAcG;AACH,KAAK,wBAAwB,GACzB,SAAS,GACT,MAAM,GACN,SAAS,GACT,YAAY,GACZ,SAAS,CAAC;AAEd;;GAEG;AACH,KAAK,sBAAsB,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE1D;;;;;;GAMG;AACH,KAAK,sBAAsB,GAAG,SAAS,GAAG,OAAO,CAAC;AAmDlD;;;GAGG;AACH,UAAU,sBAAuB,SAAQ,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC;IACjE;;;;OAIG;IACH,KAAK,EAAE,sBAAsB,CAAC;IAC9B;;;;OAIG;IACH,OAAO,CAAC,EAAE,wBAAwB,CAAC;IACnC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B;;;;OAIG;IACH,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;GAUG;AACH,QAAA,MAAM,iBAAiB,gHA0CtB,CAAC;AAGF,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC7B,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,GACvB,CAAC"}
1
+ {"version":3,"file":"typography-heading.d.ts","sourceRoot":"","sources":["../../src/components/typography-heading.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B;;;;GAIG;AACH,KAAK,sBAAsB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEpD;;;;;;;;;;;;;;GAcG;AACH,KAAK,wBAAwB,GACzB,SAAS,GACT,MAAM,GACN,SAAS,GACT,YAAY,GACZ,SAAS,CAAC;AAEd;;GAEG;AACH,KAAK,sBAAsB,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE1D;;;;;;GAMG;AACH,KAAK,sBAAsB,GAAG,SAAS,GAAG,OAAO,CAAC;AA4DlD;;;GAGG;AACH,UAAU,sBAAuB,SAAQ,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC;IACjE;;;;OAIG;IACH,KAAK,EAAE,sBAAsB,CAAC;IAC9B;;;;OAIG;IACH,OAAO,CAAC,EAAE,wBAAwB,CAAC;IACnC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B;;;;OAIG;IACH,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;GAUG;AACH,QAAA,MAAM,iBAAiB,gHA4CtB,CAAC;AAGF,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC7B,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,GACvB,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import { jsx as m } from "react/jsx-runtime";
2
- import * as f from "react";
3
- import { Slot as h } from "@radix-ui/react-slot";
4
- import { cva as y } from "class-variance-authority";
5
- import { cn as x } from "@brightlocal/ui-components/lib/utils";
6
- const b = y("", {
2
+ import * as h from "react";
3
+ import { Slot as y } from "@radix-ui/react-slot";
4
+ import { cva as x } from "class-variance-authority";
5
+ import { cn as b } from "@brightlocal/ui-components/lib/utils";
6
+ const v = x("", {
7
7
  variants: {
8
8
  variant: {
9
9
  display: "text-display",
@@ -29,19 +29,28 @@ const b = y("", {
29
29
  tabular: {
30
30
  true: "tabular-nums",
31
31
  false: "proportional-nums"
32
+ },
33
+ // Boolean on purpose (no `false` class): unlike tabular there is no
34
+ // inherited context to undo — either the element clips or it doesn't.
35
+ // `block` is load-bearing: an inline asChild child (e.g. a `span`) cannot
36
+ // clip — overflow does not apply to non-replaced inlines — so the variant
37
+ // forces a block container. A no-op on the default h1–h6 (already block)
38
+ // and on flex/grid items (blockified by the layout).
39
+ truncate: {
40
+ true: "block truncate"
32
41
  }
33
42
  },
34
43
  defaultVariants: {
35
44
  color: "default"
36
45
  }
37
- }), v = {
46
+ }), k = {
38
47
  1: "page",
39
48
  2: "section",
40
49
  3: "subsection",
41
50
  4: "subsection",
42
51
  5: "subsection",
43
52
  6: "subsection"
44
- }, V = f.forwardRef(
53
+ }, V = h.forwardRef(
45
54
  ({
46
55
  className: e,
47
56
  level: t,
@@ -49,30 +58,32 @@ const b = y("", {
49
58
  color: r = "default",
50
59
  align: n,
51
60
  tabular: i,
52
- asChild: s = !1,
53
- dataHook: c,
54
- trackingEl: d,
55
- trackingLabel: p,
61
+ truncate: s = !1,
62
+ asChild: c = !1,
63
+ dataHook: d,
64
+ trackingEl: p,
65
+ trackingLabel: l,
56
66
  ...g
57
- }, l) => {
58
- const a = o ?? v[t], u = s ? h : `h${t}`;
67
+ }, u) => {
68
+ const a = o ?? k[t], f = c ? y : `h${t}`;
59
69
  return /* @__PURE__ */ m(
60
- u,
70
+ f,
61
71
  {
62
- ref: l,
63
- className: x(
64
- b({
72
+ ref: u,
73
+ className: b(
74
+ v({
65
75
  variant: a,
66
76
  color: r,
67
77
  align: n,
68
- tabular: i
78
+ tabular: i,
79
+ truncate: s
69
80
  }),
70
81
  e
71
82
  ),
72
- "data-hook": c,
83
+ "data-hook": d,
73
84
  "data-slot": "typography-heading",
74
- "data-tracking-el": d || `typography-heading-${a}`,
75
- "data-tracking-label": p,
85
+ "data-tracking-el": p || `typography-heading-${a}`,
86
+ "data-tracking-label": l,
76
87
  ...g
77
88
  }
78
89
  );
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),f=require("react"),b=require("@radix-ui/react-slot"),x=require("class-variance-authority"),g=require("@brightlocal/ui-components/lib/utils");function m(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const h=m(f),T=x.cva("",{variants:{variant:{body:"text-body","body-sm":"text-body-sm","body-xs":"text-body-xs",metric:"text-metric",code:"text-code"},color:{default:"text-foreground",muted:"text-muted-foreground",destructive:"text-destructive-foreground"},tabular:{true:"tabular-nums",false:"proportional-nums"},align:{left:"text-left",center:"text-center",right:"text-right"}},defaultVariants:{variant:"body",color:"default"}}),j={body:"p","body-sm":"p","body-xs":"p",metric:"span",code:"code"},a=h.forwardRef(({className:t,variant:e="body",color:r="default",tabular:o,align:n,asChild:c=!1,dataHook:s,trackingEl:d,trackingLabel:u,...l},i)=>{const y=c?b.Slot:j[e];return p.jsx(y,{ref:i,className:g.cn(T({variant:e,color:r,tabular:o,align:n}),t),"data-hook":s,"data-slot":"typography-text","data-tracking-el":d||`typography-text-${e}`,"data-tracking-label":u,...l})});a.displayName="TypographyText";exports.TypographyText=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),b=require("react"),x=require("@radix-ui/react-slot"),g=require("class-variance-authority"),m=require("@brightlocal/ui-components/lib/utils");function h(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const T=h(b),j=g.cva("",{variants:{variant:{body:"text-body","body-sm":"text-body-sm","body-xs":"text-body-xs",metric:"text-metric",code:"text-code"},color:{default:"text-foreground",muted:"text-muted-foreground",destructive:"text-destructive-foreground"},tabular:{true:"tabular-nums",false:"proportional-nums"},align:{left:"text-left",center:"text-center",right:"text-right"},truncate:{true:"block truncate"}},defaultVariants:{variant:"body",color:"default"}}),v={body:"p","body-sm":"p","body-xs":"p",metric:"span",code:"code"},a=T.forwardRef(({className:t,variant:e="body",color:r="default",tabular:o,align:c,truncate:n=!1,asChild:s=!1,dataHook:u,trackingEl:d,trackingLabel:l,...i},y)=>{const p=s?x.Slot:v[e];return f.jsx(p,{ref:y,className:m.cn(j({variant:e,color:r,tabular:o,align:c,truncate:n}),t),"data-hook":u,"data-slot":"typography-text","data-tracking-el":d||`typography-text-${e}`,"data-tracking-label":l,...i})});a.displayName="TypographyText";exports.TypographyText=a;