@brightlocal/ui-components 3.2.0 → 3.4.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 (434) hide show
  1. package/AI_USAGE.md +10 -0
  2. package/README.md +3 -1
  3. package/component-meta.json +1458 -380
  4. package/deprecations.json +44 -0
  5. package/dist/_virtual/_rolldown/runtime.cjs +1 -0
  6. package/dist/accordion.cjs +1 -1
  7. package/dist/accordion.js +73 -102
  8. package/dist/alert-dialog.cjs +1 -1
  9. package/dist/alert-dialog.d.ts +6 -4
  10. package/dist/alert-dialog.d.ts.map +1 -1
  11. package/dist/alert-dialog.js +85 -133
  12. package/dist/alert.cjs +1 -1
  13. package/dist/alert.d.ts +4 -4
  14. package/dist/alert.d.ts.map +1 -1
  15. package/dist/alert.js +106 -168
  16. package/dist/aspect-ratio.cjs +1 -1
  17. package/dist/aspect-ratio.js +13 -16
  18. package/dist/avatar.cjs +1 -1
  19. package/dist/avatar.js +30 -45
  20. package/dist/badge.cjs +1 -1
  21. package/dist/badge.d.ts +23 -1
  22. package/dist/badge.d.ts.map +1 -1
  23. package/dist/badge.js +90 -91
  24. package/dist/banner.cjs +1 -1
  25. package/dist/banner.js +102 -148
  26. package/dist/blocks/empty-state.cjs +1 -1
  27. package/dist/blocks/empty-state.d.ts +20 -3
  28. package/dist/blocks/empty-state.d.ts.map +1 -1
  29. package/dist/blocks/empty-state.js +73 -140
  30. package/dist/blocks/input-list.cjs +2 -2
  31. package/dist/blocks/input-list.d.ts +2 -2
  32. package/dist/blocks/input-list.d.ts.map +1 -1
  33. package/dist/blocks/input-list.js +138 -178
  34. package/dist/blocks/progress-state.cjs +1 -1
  35. package/dist/blocks/progress-state.js +223 -347
  36. package/dist/blocks/sidebar.cjs +1 -1
  37. package/dist/blocks/sidebar.d.ts +11 -6
  38. package/dist/blocks/sidebar.d.ts.map +1 -1
  39. package/dist/blocks/sidebar.js +763 -1092
  40. package/dist/brand-illustration-motif.cjs +1 -1
  41. package/dist/brand-illustration-motif.js +40 -61
  42. package/dist/breadcrumb.cjs +1 -1
  43. package/dist/breadcrumb.js +62 -102
  44. package/dist/button-group.cjs +1 -1
  45. package/dist/button-group.js +23 -31
  46. package/dist/button.cjs +1 -1
  47. package/dist/button.d.ts +4 -2
  48. package/dist/button.d.ts.map +1 -1
  49. package/dist/button.js +149 -189
  50. package/dist/calendar.cjs +1 -1
  51. package/dist/calendar.d.ts +87 -3
  52. package/dist/calendar.d.ts.map +1 -1
  53. package/dist/calendar.js +116 -173
  54. package/dist/callout.cjs +1 -1
  55. package/dist/callout.js +73 -96
  56. package/dist/card.cjs +1 -1
  57. package/dist/card.d.ts +10 -4
  58. package/dist/card.d.ts.map +1 -1
  59. package/dist/card.js +233 -316
  60. package/dist/carousel.cjs +1 -1
  61. package/dist/carousel.d.ts +3 -3
  62. package/dist/carousel.d.ts.map +1 -1
  63. package/dist/carousel.js +174 -268
  64. package/dist/centred-layout.cjs +1 -1
  65. package/dist/centred-layout.js +27 -48
  66. package/dist/chart-empty.cjs +1 -1
  67. package/dist/chart-empty.js +18 -27
  68. package/dist/chart.cjs +7 -7
  69. package/dist/chart.d.ts +23 -13
  70. package/dist/chart.d.ts.map +1 -1
  71. package/dist/chart.js +445 -651
  72. package/dist/checkbox.cjs +1 -1
  73. package/dist/checkbox.js +36 -69
  74. package/dist/chip.cjs +1 -1
  75. package/dist/chip.js +116 -173
  76. package/dist/collapsible.cjs +1 -1
  77. package/dist/collapsible.d.ts.map +1 -1
  78. package/dist/collapsible.js +35 -41
  79. package/dist/combobox.cjs +3 -3
  80. package/dist/combobox.d.ts +14 -4
  81. package/dist/combobox.d.ts.map +1 -1
  82. package/dist/combobox.js +439 -638
  83. package/dist/command.cjs +1 -1
  84. package/dist/command.d.ts.map +1 -1
  85. package/dist/command.js +273 -420
  86. package/dist/context-menu.cjs +1 -1
  87. package/dist/context-menu.d.ts +5 -5
  88. package/dist/context-menu.d.ts.map +1 -1
  89. package/dist/context-menu.js +121 -191
  90. package/dist/data-table.cjs +1 -1
  91. package/dist/data-table.d.ts +280 -129
  92. package/dist/data-table.d.ts.map +1 -1
  93. package/dist/data-table.js +687 -948
  94. package/dist/date-picker.cjs +1 -1
  95. package/dist/date-picker.d.ts +15 -4
  96. package/dist/date-picker.d.ts.map +1 -1
  97. package/dist/date-picker.js +156 -231
  98. package/dist/delta.cjs +1 -0
  99. package/dist/delta.d.ts +79 -0
  100. package/dist/delta.d.ts.map +1 -0
  101. package/dist/delta.js +62 -0
  102. package/dist/description-list.cjs +1 -0
  103. package/dist/description-list.d.ts +142 -0
  104. package/dist/description-list.d.ts.map +1 -0
  105. package/dist/description-list.js +173 -0
  106. package/dist/description.cjs +1 -1
  107. package/dist/description.js +11 -20
  108. package/dist/dialog.cjs +1 -1
  109. package/dist/dialog.d.ts +1 -1
  110. package/dist/dialog.d.ts.map +1 -1
  111. package/dist/dialog.js +76 -116
  112. package/dist/drawer.cjs +1 -1
  113. package/dist/drawer.d.ts +11 -11
  114. package/dist/drawer.d.ts.map +1 -1
  115. package/dist/drawer.js +76 -134
  116. package/dist/dropdown-menu.cjs +1 -1
  117. package/dist/dropdown-menu.d.ts +6 -6
  118. package/dist/dropdown-menu.d.ts.map +1 -1
  119. package/dist/dropdown-menu.js +179 -300
  120. package/dist/field.cjs +1 -1
  121. package/dist/field.d.ts +9 -9
  122. package/dist/field.d.ts.map +1 -1
  123. package/dist/field.js +166 -286
  124. package/dist/global-layout.cjs +1 -1
  125. package/dist/global-layout.js +203 -342
  126. package/dist/grid.cjs +1 -1
  127. package/dist/grid.js +16 -29
  128. package/dist/header.cjs +1 -1
  129. package/dist/header.js +21 -38
  130. package/dist/height-transition.cjs +1 -1
  131. package/dist/height-transition.js +38 -55
  132. package/dist/hooks/use-breakpoint.cjs +1 -1
  133. package/dist/hooks/use-breakpoint.js +9 -9
  134. package/dist/hooks/use-debounce.cjs +1 -1
  135. package/dist/hooks/use-debounce.js +12 -11
  136. package/dist/hooks/use-delayed-pending.cjs +1 -1
  137. package/dist/hooks/use-delayed-pending.js +8 -9
  138. package/dist/hooks/use-filter-search-params.cjs +1 -0
  139. package/dist/hooks/use-filter-search-params.d.ts +93 -0
  140. package/dist/hooks/use-filter-search-params.d.ts.map +1 -0
  141. package/dist/hooks/use-filter-search-params.js +122 -0
  142. package/dist/hooks/use-mobile.cjs +1 -1
  143. package/dist/hooks/use-mobile.js +6 -6
  144. package/dist/hooks/use-overlay-pointer-lock.cjs +1 -1
  145. package/dist/hooks/use-overlay-pointer-lock.js +8 -9
  146. package/dist/hooks/use-prefers-reduced-motion.cjs +1 -1
  147. package/dist/hooks/use-prefers-reduced-motion.js +5 -8
  148. package/dist/hover-card.cjs +1 -1
  149. package/dist/hover-card.d.ts +1 -1
  150. package/dist/hover-card.d.ts.map +1 -1
  151. package/dist/hover-card.js +30 -62
  152. package/dist/index.cjs +1 -1
  153. package/dist/index.d.ts +7 -0
  154. package/dist/index.d.ts.map +1 -1
  155. package/dist/index.js +658 -614
  156. package/dist/info-tooltip.cjs +1 -1
  157. package/dist/info-tooltip.js +22 -36
  158. package/dist/input-chip.cjs +1 -1
  159. package/dist/input-chip.d.ts +32 -3
  160. package/dist/input-chip.d.ts.map +1 -1
  161. package/dist/input-chip.js +181 -230
  162. package/dist/input-group.cjs +1 -1
  163. package/dist/input-group.js +174 -221
  164. package/dist/input-otp.cjs +1 -1
  165. package/dist/input-otp.d.ts +3 -3
  166. package/dist/input-otp.d.ts.map +1 -1
  167. package/dist/input-otp.js +102 -146
  168. package/dist/input-password.cjs +1 -1
  169. package/dist/input-password.d.ts +12 -16
  170. package/dist/input-password.d.ts.map +1 -1
  171. package/dist/input-password.js +139 -171
  172. package/dist/input.cjs +1 -1
  173. package/dist/input.d.ts.map +1 -1
  174. package/dist/input.js +51 -73
  175. package/dist/label.cjs +1 -1
  176. package/dist/label.js +20 -38
  177. package/dist/lib/block-illustration.cjs +1 -1
  178. package/dist/lib/block-illustration.d.ts +1 -1
  179. package/dist/lib/block-illustration.d.ts.map +1 -1
  180. package/dist/lib/block-illustration.js +16 -18
  181. package/dist/lib/compose-event-handlers.cjs +1 -0
  182. package/dist/lib/compose-event-handlers.d.ts +9 -0
  183. package/dist/lib/compose-event-handlers.d.ts.map +1 -0
  184. package/dist/lib/compose-event-handlers.js +8 -0
  185. package/dist/lib/download-file.cjs +1 -0
  186. package/dist/lib/download-file.d.ts +14 -0
  187. package/dist/lib/download-file.d.ts.map +1 -0
  188. package/dist/lib/download-file.js +40 -0
  189. package/dist/lib/empty-canvas.cjs +1 -1
  190. package/dist/lib/empty-canvas.js +28 -56
  191. package/dist/lib/empty-chip.cjs +1 -1
  192. package/dist/lib/empty-chip.d.ts +14 -3
  193. package/dist/lib/empty-chip.d.ts.map +1 -1
  194. package/dist/lib/empty-chip.js +15 -11
  195. package/dist/lib/field-aria.cjs +1 -0
  196. package/dist/lib/field-aria.d.ts +34 -0
  197. package/dist/lib/field-aria.d.ts.map +1 -0
  198. package/dist/lib/field-aria.js +52 -0
  199. package/dist/lib/image-file-info.cjs +1 -0
  200. package/dist/lib/image-file-info.d.ts +25 -0
  201. package/dist/lib/image-file-info.d.ts.map +1 -0
  202. package/dist/lib/image-file-info.js +67 -0
  203. package/dist/lib/media-viewer-content.cjs +1 -0
  204. package/dist/lib/media-viewer-content.d.ts +102 -0
  205. package/dist/lib/media-viewer-content.d.ts.map +1 -0
  206. package/dist/lib/media-viewer-content.js +650 -0
  207. package/dist/lib/media-viewer-internal.cjs +1 -0
  208. package/dist/lib/media-viewer-internal.d.ts +98 -0
  209. package/dist/lib/media-viewer-internal.d.ts.map +1 -0
  210. package/dist/lib/media-viewer-internal.js +61 -0
  211. package/dist/lib/media-viewer-motion.cjs +1 -0
  212. package/dist/lib/media-viewer-motion.d.ts +40 -0
  213. package/dist/lib/media-viewer-motion.d.ts.map +1 -0
  214. package/dist/lib/media-viewer-motion.js +37 -0
  215. package/dist/lib/motion.cjs +1 -1
  216. package/dist/lib/motion.d.ts +8 -0
  217. package/dist/lib/motion.d.ts.map +1 -1
  218. package/dist/lib/motion.js +14 -8
  219. package/dist/lib/optical-center.cjs +1 -1
  220. package/dist/lib/optical-center.d.ts +1 -1
  221. package/dist/lib/optical-center.d.ts.map +1 -1
  222. package/dist/lib/optical-center.js +12 -5
  223. package/dist/lib/spring-settle.cjs +1 -1
  224. package/dist/lib/spring-settle.js +1 -1
  225. package/dist/lib/table-internal.cjs +1 -0
  226. package/dist/lib/table-internal.d.ts +62 -0
  227. package/dist/lib/table-internal.d.ts.map +1 -0
  228. package/dist/lib/table-internal.js +18 -0
  229. package/dist/lib/use-controllable.cjs +1 -0
  230. package/dist/lib/use-controllable.d.ts +12 -0
  231. package/dist/lib/use-controllable.d.ts.map +1 -0
  232. package/dist/lib/use-controllable.js +15 -0
  233. package/dist/lib/use-dev-warning.cjs +1 -1
  234. package/dist/lib/utils.cjs +1 -1
  235. package/dist/lib/utils.js +26 -33
  236. package/dist/link.cjs +1 -1
  237. package/dist/link.d.ts +1 -1
  238. package/dist/link.js +78 -124
  239. package/dist/list.cjs +1 -1
  240. package/dist/list.d.ts +224 -39
  241. package/dist/list.d.ts.map +1 -1
  242. package/dist/list.js +323 -171
  243. package/dist/loading.cjs +1 -1
  244. package/dist/loading.js +124 -151
  245. package/dist/logo-mark.cjs +1 -0
  246. package/dist/logo-mark.d.ts +79 -0
  247. package/dist/logo-mark.d.ts.map +1 -0
  248. package/dist/logo-mark.js +219 -0
  249. package/dist/logo.cjs +1 -1
  250. package/dist/logo.d.ts +1 -1
  251. package/dist/logo.d.ts.map +1 -1
  252. package/dist/logo.js +51 -87
  253. package/dist/map.cjs +1 -1
  254. package/dist/map.d.ts.map +1 -1
  255. package/dist/map.js +390 -586
  256. package/dist/media-empty.cjs +1 -1
  257. package/dist/media-empty.js +27 -42
  258. package/dist/media-viewer.cjs +1 -0
  259. package/dist/media-viewer.d.ts +224 -0
  260. package/dist/media-viewer.d.ts.map +1 -0
  261. package/dist/media-viewer.js +295 -0
  262. package/dist/menubar.cjs +1 -1
  263. package/dist/menubar.d.ts +14 -14
  264. package/dist/menubar.d.ts.map +1 -1
  265. package/dist/menubar.js +130 -267
  266. package/dist/multi-select-filter.cjs +1 -1
  267. package/dist/multi-select-filter.d.ts +9 -1
  268. package/dist/multi-select-filter.d.ts.map +1 -1
  269. package/dist/multi-select-filter.js +357 -446
  270. package/dist/navigation-menu.cjs +1 -1
  271. package/dist/navigation-menu.js +108 -172
  272. package/dist/pagination.cjs +1 -1
  273. package/dist/pagination.d.ts +36 -12
  274. package/dist/pagination.d.ts.map +1 -1
  275. package/dist/pagination.js +208 -281
  276. package/dist/popover.cjs +1 -1
  277. package/dist/popover.d.ts +1 -1
  278. package/dist/popover.d.ts.map +1 -1
  279. package/dist/popover.js +34 -45
  280. package/dist/progress.cjs +1 -1
  281. package/dist/progress.d.ts +17 -2
  282. package/dist/progress.d.ts.map +1 -1
  283. package/dist/progress.js +116 -162
  284. package/dist/radio-group.cjs +1 -1
  285. package/dist/radio-group.js +90 -146
  286. package/dist/rating.cjs +1 -1
  287. package/dist/rating.d.ts +80 -13
  288. package/dist/rating.d.ts.map +1 -1
  289. package/dist/rating.js +70 -65
  290. package/dist/relative-date.cjs +1 -1
  291. package/dist/relative-date.d.ts.map +1 -1
  292. package/dist/relative-date.js +73 -89
  293. package/dist/resizable.cjs +1 -1
  294. package/dist/resizable.d.ts +39 -23
  295. package/dist/resizable.d.ts.map +1 -1
  296. package/dist/resizable.js +42 -44
  297. package/dist/result-count.cjs +1 -0
  298. package/dist/result-count.d.ts +110 -0
  299. package/dist/result-count.d.ts.map +1 -0
  300. package/dist/result-count.js +49 -0
  301. package/dist/route-progress.cjs +1 -1
  302. package/dist/route-progress.js +59 -102
  303. package/dist/scroll-area.cjs +1 -1
  304. package/dist/scroll-area.d.ts +9 -1
  305. package/dist/scroll-area.d.ts.map +1 -1
  306. package/dist/scroll-area.js +44 -79
  307. package/dist/select.cjs +2 -2
  308. package/dist/select.d.ts +10 -10
  309. package/dist/select.d.ts.map +1 -1
  310. package/dist/select.js +118 -238
  311. package/dist/separator.cjs +1 -1
  312. package/dist/separator.js +90 -78
  313. package/dist/sheet.cjs +1 -1
  314. package/dist/sheet.d.ts +8 -5
  315. package/dist/sheet.d.ts.map +1 -1
  316. package/dist/sheet.js +250 -317
  317. package/dist/single-select-filter.cjs +1 -1
  318. package/dist/single-select-filter.d.ts +32 -0
  319. package/dist/single-select-filter.d.ts.map +1 -1
  320. package/dist/single-select-filter.js +201 -203
  321. package/dist/skeleton.cjs +1 -1
  322. package/dist/skeleton.js +24 -38
  323. package/dist/slider.cjs +1 -1
  324. package/dist/slider.js +51 -81
  325. package/dist/sonner.cjs +1 -1
  326. package/dist/sonner.d.ts +1 -1
  327. package/dist/sonner.d.ts.map +1 -1
  328. package/dist/sonner.js +101 -125
  329. package/dist/spinner.cjs +1 -1
  330. package/dist/spinner.js +22 -31
  331. package/dist/split-layout.cjs +1 -1
  332. package/dist/split-layout.js +52 -101
  333. package/dist/status.cjs +1 -0
  334. package/dist/status.d.ts +51 -0
  335. package/dist/status.d.ts.map +1 -0
  336. package/dist/status.js +60 -0
  337. package/dist/stepper.cjs +1 -1
  338. package/dist/stepper.js +184 -316
  339. package/dist/switch.cjs +1 -1
  340. package/dist/switch.js +17 -32
  341. package/dist/table.cjs +1 -1
  342. package/dist/table.d.ts +103 -30
  343. package/dist/table.d.ts.map +1 -1
  344. package/dist/table.js +170 -209
  345. package/dist/tabs.cjs +1 -1
  346. package/dist/tabs.d.ts.map +1 -1
  347. package/dist/tabs.js +102 -147
  348. package/dist/text-reveal-motion.cjs +1 -1
  349. package/dist/text-reveal-motion.js +307 -363
  350. package/dist/textarea.cjs +1 -1
  351. package/dist/textarea.d.ts.map +1 -1
  352. package/dist/textarea.js +22 -35
  353. package/dist/toggle-group.cjs +1 -1
  354. package/dist/toggle-group.js +43 -62
  355. package/dist/toggle.cjs +1 -1
  356. package/dist/toggle.js +34 -46
  357. package/dist/tooltip.cjs +1 -1
  358. package/dist/tooltip.d.ts +2 -2
  359. package/dist/tooltip.d.ts.map +1 -1
  360. package/dist/tooltip.js +157 -249
  361. package/dist/typography-heading.cjs +1 -1
  362. package/dist/typography-heading.js +25 -61
  363. package/dist/typography-text.cjs +1 -1
  364. package/dist/typography-text.js +27 -57
  365. package/dist/typography.cjs +1 -1
  366. package/dist/typography.js +132 -340
  367. package/package.json +47 -47
  368. package/src/blocks/empty-state.tsx +34 -18
  369. package/src/blocks/input-list.tsx +14 -9
  370. package/src/blocks/sidebar.tsx +86 -31
  371. package/src/components/accordion.tsx +1 -1
  372. package/src/components/alert-dialog.tsx +4 -2
  373. package/src/components/badge.tsx +127 -15
  374. package/src/components/breadcrumb.tsx +1 -1
  375. package/src/components/button.tsx +8 -6
  376. package/src/components/calendar.tsx +155 -9
  377. package/src/components/card.tsx +63 -10
  378. package/src/components/carousel.tsx +4 -1
  379. package/src/components/chart.tsx +151 -17
  380. package/src/components/checkbox.tsx +1 -1
  381. package/src/components/collapsible.tsx +4 -1
  382. package/src/components/combobox.tsx +40 -7
  383. package/src/components/command.tsx +9 -10
  384. package/src/components/context-menu.tsx +4 -4
  385. package/src/components/data-table.tsx +619 -237
  386. package/src/components/date-picker.tsx +31 -4
  387. package/src/components/delta.tsx +217 -0
  388. package/src/components/description-list.tsx +445 -0
  389. package/src/components/drawer.tsx +5 -5
  390. package/src/components/dropdown-menu.tsx +4 -4
  391. package/src/components/field.tsx +36 -15
  392. package/src/components/global-layout.tsx +1 -1
  393. package/src/components/input-chip.tsx +51 -7
  394. package/src/components/input-group.tsx +1 -1
  395. package/src/components/input-password.tsx +15 -19
  396. package/src/components/input.tsx +10 -1
  397. package/src/components/list.tsx +695 -72
  398. package/src/components/logo-mark.tsx +345 -0
  399. package/src/components/map.tsx +18 -20
  400. package/src/components/media-viewer.tsx +908 -0
  401. package/src/components/multi-select-filter.tsx +255 -121
  402. package/src/components/navigation-menu.tsx +2 -2
  403. package/src/components/pagination.tsx +86 -26
  404. package/src/components/progress.tsx +91 -23
  405. package/src/components/rating.tsx +200 -74
  406. package/src/components/relative-date.tsx +19 -11
  407. package/src/components/resizable.tsx +86 -33
  408. package/src/components/result-count.tsx +253 -0
  409. package/src/components/scroll-area.tsx +31 -5
  410. package/src/components/select.tsx +2 -2
  411. package/src/components/sheet.tsx +14 -4
  412. package/src/components/single-select-filter.tsx +136 -41
  413. package/src/components/slider.tsx +2 -2
  414. package/src/components/status.tsx +162 -0
  415. package/src/components/switch.tsx +1 -1
  416. package/src/components/table.tsx +278 -106
  417. package/src/components/tabs.tsx +1 -0
  418. package/src/components/textarea.tsx +20 -2
  419. package/src/components/toggle.tsx +2 -2
  420. package/src/components/tooltip.tsx +11 -20
  421. package/src/hooks/use-filter-search-params.ts +302 -0
  422. package/src/index.ts +7 -0
  423. package/src/lib/compose-event-handlers.ts +14 -0
  424. package/src/lib/download-file.ts +61 -0
  425. package/src/lib/empty-chip.tsx +52 -0
  426. package/src/lib/field-aria.tsx +97 -0
  427. package/src/lib/image-file-info.ts +102 -0
  428. package/src/lib/media-viewer-content.tsx +1587 -0
  429. package/src/lib/media-viewer-internal.tsx +191 -0
  430. package/src/lib/media-viewer-motion.ts +120 -0
  431. package/src/lib/motion.ts +9 -0
  432. package/src/lib/table-internal.ts +74 -0
  433. package/src/lib/use-controllable.ts +43 -0
  434. package/src/lib/empty-chip.ts +0 -24
@@ -4,19 +4,28 @@ import * as React from "react";
4
4
  import { cva, type VariantProps } from "class-variance-authority";
5
5
 
6
6
  import { cn } from "@brightlocal/ui-components/lib/utils";
7
+ import { useDevWarning } from "@brightlocal/ui-components/lib/use-dev-warning";
8
+ import {
9
+ TABLE_CONTAINER_INSET,
10
+ TableSizeContext,
11
+ scrollRegionProps,
12
+ type TableFrame,
13
+ type TableSize,
14
+ } from "../lib/table-internal";
7
15
 
8
16
  /* -------------------------------------------------------------------------------------------------
9
17
  * CVA Variants
10
18
  * -----------------------------------------------------------------------------------------------*/
11
19
 
12
20
  const tableCellVariants = cva(
13
- "align-middle bg-transparent text-body-sm text-foreground break-words",
21
+ // `h-*` on a table cell is a min-height: the row still grows with
22
+ // multi-line content, so the size axis is the floor, never a clamp.
23
+ "align-middle bg-transparent p-2 text-body-sm text-foreground break-words",
14
24
  {
15
25
  variants: {
16
26
  size: {
17
- default: "h-12 p-2",
18
- md: "h-16 p-2",
19
- lg: "h-24 p-2",
27
+ default: "h-12",
28
+ sm: "h-10",
20
29
  },
21
30
  align: {
22
31
  left: "text-left",
@@ -34,9 +43,15 @@ const tableCellVariants = cva(
34
43
  const tableHeadVariants = cva(
35
44
  // bg-muted only for column headers inside <thead> — a <TableHead
36
45
  // scope="row"> in the body must not paint over its row's state tint.
37
- "[thead_&]:bg-muted h-12 p-2 align-middle text-muted-foreground text-label font-semibold break-words outline-none focus-visible:shadow-default transition-[background-color,box-shadow] duration-fast ease-out",
46
+ // No focus ring here: a <th> is never focusable — the sort control inside
47
+ // it (DataTableColumnHeader's Button) carries its own.
48
+ "[thead_&]:bg-muted p-2 align-middle text-muted-foreground text-label font-semibold break-words transition-colors duration-fast ease-out",
38
49
  {
39
50
  variants: {
51
+ size: {
52
+ default: "h-12",
53
+ sm: "h-9",
54
+ },
40
55
  align: {
41
56
  left: "text-left",
42
57
  right: "text-right",
@@ -44,43 +59,19 @@ const tableHeadVariants = cva(
44
59
  },
45
60
  },
46
61
  defaultVariants: {
62
+ size: "default",
47
63
  align: "left",
48
64
  },
49
65
  }
50
66
  );
51
67
 
52
- /* -------------------------------------------------------------------------------------------------
53
- * Scroll-region semantics (shared)
54
- * -----------------------------------------------------------------------------------------------*/
55
-
56
- /**
57
- * Focusable scroll-region semantics for a table's scroll container:
58
- * `role="region"` with an accessible name plus `tabIndex={0}`, so keyboard
59
- * users can focus the container and scroll it (axe:
60
- * scrollable-region-focusable).
61
- *
62
- * Single source of the contract and its "Scrollable table" default.
63
- * `Table` applies it to its own wrapper (`scrollOwner="self"` + `minWidth`);
64
- * `DataTable` / `VirtualizedDataTable` apply it to their outer wrapper,
65
- * which owns scrolling instead. The caller decides *when* the container is
66
- * a scroll region; this helper only says *what* that means.
67
- *
68
- * @internal Exported only so the DataTable module shares one copy — not a
69
- * public contract; its shape may change without a major release.
70
- */
71
- function scrollRegionProps(scrollRegionLabel: string | undefined) {
72
- return {
73
- role: "region",
74
- "aria-label": scrollRegionLabel ?? "Scrollable table",
75
- tabIndex: 0,
76
- } as const;
77
- }
78
-
79
68
  /* -------------------------------------------------------------------------------------------------
80
69
  * Table
81
70
  * -----------------------------------------------------------------------------------------------*/
82
71
 
83
- interface TableProps extends React.ComponentProps<"table"> {
72
+ // `frame` shadows the legacy HTML `<table frame>` attribute (typed boolean in
73
+ // React); the DS prop replaces it and never reaches the DOM.
74
+ interface TableProps extends Omit<React.ComponentProps<"table">, "frame"> {
84
75
  /**
85
76
  * Data hook for automated testing (REQUIRED)
86
77
  */
@@ -93,6 +84,15 @@ interface TableProps extends React.ComponentProps<"table"> {
93
84
  * Tracking label for analytics context
94
85
  */
95
86
  trackingLabel?: string;
87
+ /**
88
+ * Row density for the whole table. Sets the min-height of every `TableCell`
89
+ * (`default` = `h-12` 48px, `sm` = `h-10` 40px) and `TableHead`
90
+ * (`default` = `h-12` 48px, `sm` = `h-9` 36px) beneath it. Rows still grow
91
+ * with multi-line content. Use `sm` for dense, scan-heavy tables inside
92
+ * cards, dialogs and side panels; keep `default` for page-level lists.
93
+ * @default "default"
94
+ */
95
+ size?: TableSize;
96
96
  /**
97
97
  * Table layout algorithm.
98
98
  * - `"auto"` (default) — browser sizes columns based on content.
@@ -139,6 +139,31 @@ interface TableProps extends React.ComponentProps<"table"> {
139
139
  * @default "self"
140
140
  */
141
141
  scrollOwner?: "self" | "parent";
142
+ /**
143
+ * Where the frame comes from (DS-1103).
144
+ * - `"own"` — the table draws its own 1px `border-border`, `rounded-md`
145
+ * frame; cells keep `p-2`. The standalone table.
146
+ * - `"container"` — no border, square corners, and the first/last cell of
147
+ * every row (head, body, footer, empty, skeleton) pads to the container's
148
+ * gutter, `var(--content-inset)` — `Card` publishes it per density (24px
149
+ * for `data`); 24px outside any container. Use inside `CardContent flush`,
150
+ * a Sheet or a dialog body so the page shows one box and the columns line
151
+ * up with the title.
152
+ * With `scrollOwner="parent"` the scrolling ancestor draws the frame
153
+ * (`DataTable` has the same prop); the cell rule still applies.
154
+ * @default "own"
155
+ */
156
+ frame?: TableFrame;
157
+ /**
158
+ * Draw a faint `border-border` rule under every body row except the last
159
+ * (DS-1195), so a reader can follow one row across many columns. No zebra
160
+ * striping. Use it on long, dense tables with many numeric or grouped
161
+ * columns and on wide, horizontally scrolling tables; leave it off for
162
+ * short or simple tables, where the row height already separates rows.
163
+ * The header band and footer keep their own surfaces.
164
+ * @default false
165
+ */
166
+ rowDividers?: boolean;
142
167
  }
143
168
 
144
169
  const Table = React.forwardRef<HTMLTableElement, TableProps>(
@@ -148,55 +173,75 @@ const Table = React.forwardRef<HTMLTableElement, TableProps>(
148
173
  dataHook,
149
174
  trackingEl,
150
175
  trackingLabel,
176
+ size = "default",
151
177
  layout = "auto",
152
178
  minWidth,
153
179
  scrollRegionLabel,
154
180
  scrollOwner = "self",
181
+ frame = "own",
182
+ rowDividers = false,
155
183
  style,
156
184
  ...props
157
185
  },
158
186
  ref
159
187
  ) => {
160
188
  const ownsScroll = scrollOwner === "self";
189
+ const ownFrame = frame === "own";
161
190
  return (
162
- <div
163
- className={cn(
164
- "relative w-full",
165
- // `overflow-x-auto` makes the wrapper a scroll container in BOTH
166
- // axes (an `auto` axis forces the other out of `visible`), which
167
- // would confine a sticky <thead> here. With a parent scroll owner
168
- // the wrapper must stay overflow-visible so sticky positioning
169
- // and height bounds resolve against that ancestor (DS-912).
170
- // `scrollbar` themes the native scrollbar with DS colors — the
171
- // Command/Combobox treatment for bounded scroll containers.
172
- ownsScroll && "scrollbar overflow-x-auto",
173
- ownsScroll &&
174
- minWidth &&
175
- "focus-visible:shadow-default rounded-md outline-none"
176
- )}
177
- data-slot="table-container"
178
- {...(ownsScroll && minWidth
179
- ? scrollRegionProps(scrollRegionLabel)
180
- : undefined)}
181
- >
182
- <table
183
- ref={ref}
191
+ <TableSizeContext.Provider value={size}>
192
+ <div
184
193
  className={cn(
185
- // tabular-nums inherits into every cell (and into DataTable, which
186
- // renders this root), so numeric columns align by default; a
187
- // prose-heavy column can opt out with proportional-nums.
188
- "text-body-sm w-full caption-bottom tabular-nums",
189
- layout === "fixed" && "table-fixed",
190
- className
194
+ "relative w-full",
195
+ // `overflow-x-auto` makes the wrapper a scroll container in BOTH
196
+ // axes (an `auto` axis forces the other out of `visible`), which
197
+ // would confine a sticky <thead> here. With a parent scroll owner
198
+ // the wrapper must stay overflow-visible so sticky positioning
199
+ // and height bounds resolve against that ancestor (DS-912).
200
+ // `scrollbar` themes the native scrollbar with DS colors — the
201
+ // Command/Combobox treatment for bounded scroll containers.
202
+ ownsScroll && "scrollbar overflow-x-auto",
203
+ // `own`: the 1px frame and the rounded clip (header corners, focus
204
+ // ring). `container`: square and frameless — the container is the
205
+ // frame (DS-1103).
206
+ ownsScroll && ownFrame && "border-border rounded-md border",
207
+ ownsScroll &&
208
+ minWidth &&
209
+ "focus-visible:shadow-default outline-none"
191
210
  )}
192
- data-hook={dataHook}
193
- data-slot="table"
194
- data-tracking-el={trackingEl}
195
- data-tracking-label={trackingLabel}
196
- style={{ minWidth, ...style }}
197
- {...props}
198
- />
199
- </div>
211
+ data-frame={ownsScroll ? frame : undefined}
212
+ data-slot="table-container"
213
+ {...(ownsScroll && minWidth
214
+ ? scrollRegionProps(scrollRegionLabel)
215
+ : undefined)}
216
+ >
217
+ <table
218
+ ref={ref}
219
+ className={cn(
220
+ // tabular-nums inherits into every cell (and into DataTable, which
221
+ // renders this root), so numeric columns align by default; a
222
+ // prose-heavy column can opt out with proportional-nums.
223
+ "text-body-sm w-full caption-bottom tabular-nums",
224
+ layout === "fixed" && "table-fixed",
225
+ // Edge cells pad to the container's gutter in both scroll modes.
226
+ !ownFrame && TABLE_CONTAINER_INSET,
227
+ // Rule under each body row but the last — the frame (or the
228
+ // container) closes the table, so the last row needs none.
229
+ rowDividers &&
230
+ "[&_[data-slot=table-body]>tr:not(:last-child)]:border-border [&_[data-slot=table-body]>tr:not(:last-child)]:border-b",
231
+ className
232
+ )}
233
+ data-frame={frame}
234
+ data-hook={dataHook}
235
+ data-row-dividers={rowDividers ? "true" : undefined}
236
+ data-size={size}
237
+ data-slot="table"
238
+ data-tracking-el={trackingEl}
239
+ data-tracking-label={trackingLabel}
240
+ style={{ minWidth, ...style }}
241
+ {...props}
242
+ />
243
+ </div>
244
+ </TableSizeContext.Provider>
200
245
  );
201
246
  }
202
247
  );
@@ -289,16 +334,16 @@ interface TableRowProps extends React.ComponentProps<"tr"> {
289
334
  dataHook?: string;
290
335
  }
291
336
 
337
+ // Selected rows share the table head's surface (bg-muted). Shared with
338
+ // TableEmpty, which renders its own <tr>.
339
+ const tableRowStyles =
340
+ "data-[state=selected]:bg-muted duration-fast transition-colors ease-out";
341
+
292
342
  const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(
293
343
  ({ className, dataHook, ...props }, ref) => (
294
344
  <tr
295
345
  ref={ref}
296
- className={cn(
297
- // Selected rows share the table head's surface (bg-muted).
298
- "data-[state=selected]:bg-muted",
299
- "duration-fast transition-colors ease-out",
300
- className
301
- )}
346
+ className={cn(tableRowStyles, className)}
302
347
  data-hook={dataHook}
303
348
  data-slot="table-row"
304
349
  {...props}
@@ -315,7 +360,7 @@ TableRow.displayName = "TableRow";
315
360
  interface TableHeadProps
316
361
  extends
317
362
  Omit<React.ComponentProps<"th">, "align">,
318
- VariantProps<typeof tableHeadVariants> {
363
+ Omit<VariantProps<typeof tableHeadVariants>, "size"> {
319
364
  /**
320
365
  * Data hook for automated testing
321
366
  */
@@ -348,17 +393,20 @@ const TableHead = React.forwardRef<HTMLTableCellElement, TableHeadProps>(
348
393
  ...props
349
394
  },
350
395
  ref
351
- ) => (
352
- <th
353
- ref={ref}
354
- className={cn(tableHeadVariants({ align }), className)}
355
- data-hook={dataHook}
356
- data-slot="table-head"
357
- scope={scope}
358
- style={{ width, minWidth, ...style }}
359
- {...props}
360
- />
361
- )
396
+ ) => {
397
+ const size = React.useContext(TableSizeContext);
398
+ return (
399
+ <th
400
+ ref={ref}
401
+ className={cn(tableHeadVariants({ size, align }), className)}
402
+ data-hook={dataHook}
403
+ data-slot="table-head"
404
+ scope={scope}
405
+ style={{ width, minWidth, ...style }}
406
+ {...props}
407
+ />
408
+ );
409
+ }
362
410
  );
363
411
 
364
412
  TableHead.displayName = "TableHead";
@@ -370,7 +418,7 @@ TableHead.displayName = "TableHead";
370
418
  interface TableCellProps
371
419
  extends
372
420
  Omit<React.ComponentProps<"td">, "align">,
373
- VariantProps<typeof tableCellVariants> {
421
+ Omit<VariantProps<typeof tableCellVariants>, "size"> {
374
422
  /**
375
423
  * Data hook for automated testing
376
424
  */
@@ -385,8 +433,10 @@ interface TableCellProps
385
433
  */
386
434
  minWidth?: string;
387
435
  /**
388
- * Size variant for cell height/padding
389
- * @default "default"
436
+ * @deprecated Since 3.3.0 — ignored. Row height is set once on the parent
437
+ * `Table` (`size="default" | "sm"`, DS-556); a per-cell size let one row
438
+ * disagree with its table and duplicated what sized content already does.
439
+ * Accepted so existing markup keeps compiling; removed in the next major.
390
440
  */
391
441
  size?: "default" | "md" | "lg";
392
442
  /**
@@ -394,26 +444,144 @@ interface TableCellProps
394
444
  * @default "left"
395
445
  */
396
446
  align?: "left" | "right" | "center";
447
+ /**
448
+ * Marks the cell as the first of a column group (DS-1195): draws a 1px
449
+ * `border-border` separator on its start edge. Set it on every body cell of
450
+ * the column that starts a group; the header band stays clean, so
451
+ * `TableHead` has no such prop. In `DataTable`, set `meta.groupStart` on the
452
+ * column instead.
453
+ * @default false
454
+ */
455
+ groupStart?: boolean;
397
456
  }
398
457
 
399
458
  const TableCell = React.forwardRef<HTMLTableCellElement, TableCellProps>(
400
459
  (
401
- { className, dataHook, size, align, width, minWidth, style, ...props },
460
+ {
461
+ className,
462
+ dataHook,
463
+ // Deprecated no-op — destructured so it never reaches the DOM; only
464
+ // the dev warning below reads it (DS-556).
465
+ size: _deprecatedSize,
466
+ align,
467
+ groupStart = false,
468
+ width,
469
+ minWidth,
470
+ style,
471
+ ...props
472
+ },
402
473
  ref
403
- ) => (
404
- <td
405
- ref={ref}
406
- className={cn(tableCellVariants({ size, align }), className)}
407
- data-hook={dataHook}
408
- data-slot="table-cell"
409
- style={{ width, minWidth, ...style }}
410
- {...props}
411
- />
412
- )
474
+ ) => {
475
+ const size = React.useContext(TableSizeContext);
476
+ useDevWarning(
477
+ () => _deprecatedSize !== undefined,
478
+ 'TableCell: the "size" prop is deprecated since 3.3.0 and ignored — set size="default" | "sm" on the Table root instead (DS-556).',
479
+ [_deprecatedSize]
480
+ );
481
+ return (
482
+ <td
483
+ ref={ref}
484
+ className={cn(
485
+ tableCellVariants({ size, align }),
486
+ groupStart && "border-border border-l",
487
+ className
488
+ )}
489
+ data-group-start={groupStart ? "true" : undefined}
490
+ data-hook={dataHook}
491
+ data-slot="table-cell"
492
+ style={{ width, minWidth, ...style }}
493
+ {...props}
494
+ />
495
+ );
496
+ }
413
497
  );
414
498
 
415
499
  TableCell.displayName = "TableCell";
416
500
 
501
+ /* -------------------------------------------------------------------------------------------------
502
+ * TableEmpty
503
+ * -----------------------------------------------------------------------------------------------*/
504
+
505
+ /**
506
+ * Props for the TableEmpty component.
507
+ */
508
+ interface TableEmptyProps extends Omit<React.ComponentProps<"tr">, "children"> {
509
+ /**
510
+ * Number of columns the empty row spans — the table's column count, so the
511
+ * message centres across the whole table.
512
+ * @example 5
513
+ */
514
+ colSpan: number;
515
+ /**
516
+ * What the table shows in place of rows.
517
+ *
518
+ * A string is a one-line message in an ordinary row at the table's `size`
519
+ * min-height — the bare fallback, announced politely.
520
+ *
521
+ * Pass an `<EmptyState size="md">` for the two designed states. A filtered
522
+ * or searched collection with nothing left (the Figma `No results` state):
523
+ * the `SearchX` icon, the echoed query as the title and one line of
524
+ * description — no action, the reader wants the outcome of their own query,
525
+ * not a CTA. An empty collection (the `Empty` state): a title, one line and
526
+ * the setup CTA. The row brings the block's breathing room (`py-6`) with
527
+ * it, so do not wrap it in a padding element; keep it to the standard
528
+ * anatomy — it sits in the same polite live region. Any non-string child is
529
+ * treated as a block and gets that padding.
530
+ * @default "No results."
531
+ */
532
+ children?: React.ReactNode;
533
+ /**
534
+ * Data hook for automated testing
535
+ */
536
+ dataHook?: string;
537
+ }
538
+
539
+ /**
540
+ * The single full-width row a table shows when it has no rows — the same row
541
+ * `DataTable` renders for `noResultsMessage`. Place it inside `TableBody`.
542
+ *
543
+ * ```tsx
544
+ * <TableBody>
545
+ * {rows.length > 0 ? rows.map(renderRow) : (
546
+ * <TableEmpty colSpan={columns.length}>No results.</TableEmpty>
547
+ * )}
548
+ * </TableBody>
549
+ * ```
550
+ */
551
+ const TableEmpty = React.forwardRef<HTMLTableRowElement, TableEmptyProps>(
552
+ ({ colSpan, children, dataHook, className, ...props }, ref) => {
553
+ const content = children ?? "No results.";
554
+ // A plain line sits in an ordinary row; a block gets 24 on top of the
555
+ // cell's own 8 — the 32 an EmptyState has anywhere else. A translated
556
+ // node (a fragment, <Trans>) counts as a block — pass a resolved string
557
+ // for the one-line row.
558
+ const isLine = typeof content === "string" || typeof content === "number";
559
+ return (
560
+ <tr
561
+ ref={ref}
562
+ className={cn(tableRowStyles, className)}
563
+ data-hook={dataHook}
564
+ data-slot="table-empty"
565
+ {...props}
566
+ >
567
+ <TableCell align="center" colSpan={colSpan}>
568
+ {/* Polite live region: the outcome of the reader's own query. */}
569
+ <div
570
+ aria-live="polite"
571
+ className={cn(!isLine && "py-6")}
572
+ data-slot="table-empty-message"
573
+ role="status"
574
+ >
575
+ {content}
576
+ </div>
577
+ </TableCell>
578
+ </tr>
579
+ );
580
+ }
581
+ );
582
+
583
+ TableEmpty.displayName = "TableEmpty";
584
+
417
585
  /* -------------------------------------------------------------------------------------------------
418
586
  * TableCaption
419
587
  * -----------------------------------------------------------------------------------------------*/
@@ -446,9 +614,9 @@ interface TableCaptionProps extends React.ComponentProps<"caption"> {
446
614
  * </Table>
447
615
  *
448
616
  * // After
449
- * <TypographyH3 dataHook="transactions-heading" id="transactions-heading">
617
+ * <TypographyHeading level={3} dataHook="transactions-heading" id="transactions-heading">
450
618
  * Recent transactions
451
- * </TypographyH3>
619
+ * </TypographyHeading>
452
620
  * <Table aria-labelledby="transactions-heading" dataHook="transactions">
453
621
  * ...
454
622
  * </Table>
@@ -481,14 +649,17 @@ export {
481
649
  TableHead,
482
650
  TableRow,
483
651
  TableCell,
652
+ TableEmpty,
484
653
  TableCaption,
485
- // Shared scroll-region contract — consumed by DataTable/VirtualizedDataTable
486
- // for their outer scroll container. Not a component (lowercase, so it stays
487
- // out of the component registry).
654
+ // Kept only because it shipped from this entry in 3.1 (DS-912). It is an
655
+ // internal helper (now in lib/table-internal) and leaves the public entry
656
+ // in the next major — see deprecations.json.
488
657
  scrollRegionProps,
489
658
  };
490
659
 
491
660
  export type {
661
+ TableFrame,
662
+ TableSize,
492
663
  TableProps,
493
664
  TableHeaderProps,
494
665
  TableBodyProps,
@@ -496,5 +667,6 @@ export type {
496
667
  TableRowProps,
497
668
  TableHeadProps,
498
669
  TableCellProps,
670
+ TableEmptyProps,
499
671
  TableCaptionProps,
500
672
  };
@@ -45,6 +45,7 @@ const tabsTriggerVariants = cva(
45
45
  [
46
46
  "inline-flex items-center justify-center gap-2",
47
47
  "text-label whitespace-nowrap",
48
+ "cursor-pointer",
48
49
  "focus-visible:outline-none",
49
50
  "disabled:pointer-events-none disabled:opacity-50",
50
51
  ],
@@ -1,7 +1,10 @@
1
+ "use client";
2
+
1
3
  import * as React from "react";
2
4
  import { cva } from "class-variance-authority";
3
5
 
4
6
  import { cn } from "@brightlocal/ui-components/lib/utils";
7
+ import { useFieldDescribedBy } from "../lib/field-aria";
5
8
 
6
9
  const textareaVariants = cva([
7
10
  // Layout & Size
@@ -51,7 +54,15 @@ interface TextareaProps extends Omit<
51
54
 
52
55
  const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
53
56
  (
54
- { className, dataHook, error, trackingEl, trackingLabel, ...props },
57
+ {
58
+ className,
59
+ dataHook,
60
+ error,
61
+ trackingEl,
62
+ trackingLabel,
63
+ "aria-describedby": ariaDescribedBy,
64
+ ...props
65
+ },
55
66
  ref
56
67
  ) => {
57
68
  // Support both error prop and aria-invalid for backwards compatibility
@@ -60,14 +71,21 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
60
71
  props["aria-invalid"] === true ||
61
72
  props["aria-invalid"] === "true";
62
73
 
74
+ // Inside a Field, point aria-describedby at the FieldError and
75
+ // FieldDescription automatically; a hand-wired value is kept and merged.
76
+ const describedBy = useFieldDescribedBy(ariaDescribedBy);
77
+
63
78
  return (
64
79
  <textarea
65
80
  ref={ref}
81
+ aria-describedby={describedBy}
66
82
  aria-invalid={hasError ? "true" : undefined}
67
83
  className={cn(
68
84
  textareaVariants(),
85
+ // scroll-mb-16 reserves room for a two-line error message under the
86
+ // field, so a phone keyboard scrolls the message into view with it
69
87
  hasError &&
70
- "border-destructive-40 focus-visible:border-destructive-40 focus-visible:shadow-destructive",
88
+ "border-destructive-40 focus-visible:border-destructive-40 focus-visible:shadow-destructive scroll-mb-16",
71
89
  className
72
90
  )}
73
91
  data-hook={dataHook}
@@ -7,13 +7,13 @@ import { cva, type VariantProps } from "class-variance-authority";
7
7
  import { cn } from "@brightlocal/ui-components/lib/utils";
8
8
 
9
9
  const toggleVariants = cva(
10
- "inline-flex items-center justify-center gap-2 rounded-md text-label hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 focus-visible:border-ring focus-visible:shadow-default outline-none transition-[color,box-shadow] duration-fast ease-out whitespace-nowrap",
10
+ "inline-flex cursor-pointer items-center justify-center gap-2 rounded-md text-label hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-secondary data-[state=on]:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 focus-visible:border-ring focus-visible:shadow-default outline-none transition-[color,box-shadow] duration-fast ease-out whitespace-nowrap",
11
11
  {
12
12
  variants: {
13
13
  variant: {
14
14
  simple: "bg-transparent",
15
15
  outline:
16
- "border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground",
16
+ "border border-input bg-background shadow-xs hover:text-accent-foreground",
17
17
  },
18
18
  size: {
19
19
  default: "h-9 px-2 min-w-9",
@@ -4,6 +4,7 @@ import * as React from "react";
4
4
  import * as PopoverPrimitive from "@radix-ui/react-popover";
5
5
  import { Slot } from "@radix-ui/react-slot";
6
6
 
7
+ import { composeEventHandlers } from "../lib/compose-event-handlers";
7
8
  import {
8
9
  cn,
9
10
  FLOATING_CONTENT_ANIMATION,
@@ -71,21 +72,6 @@ function TooltipProvider({
71
72
 
72
73
  /* -------------------------------- Helpers --------------------------------- */
73
74
 
74
- /**
75
- * Calls the consumer's handler first, then ours — unless the consumer called
76
- * `preventDefault()`. Mirrors Radix's `composeEventHandlers` without adding
77
- * `@radix-ui/primitive` as a direct dependency.
78
- */
79
- function composeEventHandlers<E extends { defaultPrevented: boolean }>(
80
- theirs: ((event: E) => void) | undefined,
81
- ours: (event: E) => void
82
- ) {
83
- return (event: E) => {
84
- theirs?.(event);
85
- if (!event.defaultPrevented) ours(event);
86
- };
87
- }
88
-
89
75
  /** Grace period (ms) before a hover-opened tooltip closes after the pointer leaves. */
90
76
  const HOVER_CLOSE_GRACE_MS = 200;
91
77
 
@@ -211,23 +197,28 @@ function Tooltip({
211
197
 
212
198
  const openFromHover = React.useCallback(() => {
213
199
  clearTimers();
214
- // A tap already owns this tooltip; hover/focus must not restart its timers.
215
- if (mode.current === "touch") return;
200
+ if (mode.current === "touch") {
201
+ // A tap already owns this tooltip; hover/focus must not restart its timers.
202
+ if (open) return;
203
+ // A tap that never opened it (a controlled `open` held it shut) leaves no
204
+ // owner behind — hover/focus take over again.
205
+ mode.current = "hover";
206
+ }
216
207
  if (delayDuration > 0) {
217
208
  delayTimer.current = setTimeout(() => setOpen(true), delayDuration);
218
209
  } else {
219
210
  setOpen(true);
220
211
  }
221
- }, [clearTimers, delayDuration, setOpen]);
212
+ }, [clearTimers, delayDuration, open, setOpen]);
222
213
 
223
214
  const closeFromHover = React.useCallback(() => {
224
215
  clearTimers();
225
- if (mode.current === "touch") return;
216
+ if (mode.current === "touch" && open) return;
226
217
  hoverTimeout.current = setTimeout(
227
218
  () => setOpen(false),
228
219
  HOVER_CLOSE_GRACE_MS
229
220
  );
230
- }, [clearTimers, setOpen]);
221
+ }, [clearTimers, open, setOpen]);
231
222
 
232
223
  const onTriggerPointerEnter = React.useCallback(
233
224
  (e: React.PointerEvent) => {