@brightlocal/ui-components 3.2.0 → 3.3.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 (428) hide show
  1. package/AI_USAGE.md +10 -0
  2. package/README.md +3 -1
  3. package/component-meta.json +1271 -428
  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 +136 -176
  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.cjs +1 -1
  103. package/dist/description.js +11 -20
  104. package/dist/dialog.cjs +1 -1
  105. package/dist/dialog.d.ts +1 -1
  106. package/dist/dialog.d.ts.map +1 -1
  107. package/dist/dialog.js +76 -116
  108. package/dist/drawer.cjs +1 -1
  109. package/dist/drawer.d.ts +11 -11
  110. package/dist/drawer.d.ts.map +1 -1
  111. package/dist/drawer.js +76 -134
  112. package/dist/dropdown-menu.cjs +1 -1
  113. package/dist/dropdown-menu.d.ts +6 -6
  114. package/dist/dropdown-menu.d.ts.map +1 -1
  115. package/dist/dropdown-menu.js +179 -300
  116. package/dist/field.cjs +1 -1
  117. package/dist/field.d.ts +9 -9
  118. package/dist/field.d.ts.map +1 -1
  119. package/dist/field.js +166 -286
  120. package/dist/global-layout.cjs +1 -1
  121. package/dist/global-layout.js +203 -342
  122. package/dist/grid.cjs +1 -1
  123. package/dist/grid.js +16 -29
  124. package/dist/header.cjs +1 -1
  125. package/dist/header.js +21 -38
  126. package/dist/height-transition.cjs +1 -1
  127. package/dist/height-transition.js +38 -55
  128. package/dist/hooks/use-breakpoint.cjs +1 -1
  129. package/dist/hooks/use-breakpoint.js +9 -9
  130. package/dist/hooks/use-debounce.cjs +1 -1
  131. package/dist/hooks/use-debounce.js +12 -11
  132. package/dist/hooks/use-delayed-pending.cjs +1 -1
  133. package/dist/hooks/use-delayed-pending.js +8 -9
  134. package/dist/hooks/use-filter-search-params.cjs +1 -0
  135. package/dist/hooks/use-filter-search-params.d.ts +93 -0
  136. package/dist/hooks/use-filter-search-params.d.ts.map +1 -0
  137. package/dist/hooks/use-filter-search-params.js +122 -0
  138. package/dist/hooks/use-mobile.cjs +1 -1
  139. package/dist/hooks/use-mobile.js +6 -6
  140. package/dist/hooks/use-overlay-pointer-lock.cjs +1 -1
  141. package/dist/hooks/use-overlay-pointer-lock.js +8 -9
  142. package/dist/hooks/use-prefers-reduced-motion.cjs +1 -1
  143. package/dist/hooks/use-prefers-reduced-motion.js +5 -8
  144. package/dist/hover-card.cjs +1 -1
  145. package/dist/hover-card.d.ts +1 -1
  146. package/dist/hover-card.d.ts.map +1 -1
  147. package/dist/hover-card.js +30 -62
  148. package/dist/index.cjs +1 -1
  149. package/dist/index.d.ts +6 -0
  150. package/dist/index.d.ts.map +1 -1
  151. package/dist/index.js +630 -608
  152. package/dist/info-tooltip.cjs +1 -1
  153. package/dist/info-tooltip.js +22 -36
  154. package/dist/input-chip.cjs +1 -1
  155. package/dist/input-chip.d.ts +32 -3
  156. package/dist/input-chip.d.ts.map +1 -1
  157. package/dist/input-chip.js +181 -230
  158. package/dist/input-group.cjs +1 -1
  159. package/dist/input-group.js +174 -221
  160. package/dist/input-otp.cjs +1 -1
  161. package/dist/input-otp.d.ts +3 -3
  162. package/dist/input-otp.d.ts.map +1 -1
  163. package/dist/input-otp.js +102 -146
  164. package/dist/input-password.cjs +1 -1
  165. package/dist/input-password.d.ts +12 -16
  166. package/dist/input-password.d.ts.map +1 -1
  167. package/dist/input-password.js +139 -171
  168. package/dist/input.cjs +1 -1
  169. package/dist/input.d.ts.map +1 -1
  170. package/dist/input.js +51 -73
  171. package/dist/label.cjs +1 -1
  172. package/dist/label.js +20 -38
  173. package/dist/lib/block-illustration.cjs +1 -1
  174. package/dist/lib/block-illustration.d.ts +1 -1
  175. package/dist/lib/block-illustration.d.ts.map +1 -1
  176. package/dist/lib/block-illustration.js +16 -18
  177. package/dist/lib/compose-event-handlers.cjs +1 -0
  178. package/dist/lib/compose-event-handlers.d.ts +9 -0
  179. package/dist/lib/compose-event-handlers.d.ts.map +1 -0
  180. package/dist/lib/compose-event-handlers.js +8 -0
  181. package/dist/lib/download-file.cjs +1 -0
  182. package/dist/lib/download-file.d.ts +14 -0
  183. package/dist/lib/download-file.d.ts.map +1 -0
  184. package/dist/lib/download-file.js +40 -0
  185. package/dist/lib/empty-canvas.cjs +1 -1
  186. package/dist/lib/empty-canvas.js +28 -56
  187. package/dist/lib/empty-chip.cjs +1 -1
  188. package/dist/lib/empty-chip.d.ts +14 -3
  189. package/dist/lib/empty-chip.d.ts.map +1 -1
  190. package/dist/lib/empty-chip.js +15 -11
  191. package/dist/lib/field-aria.cjs +1 -0
  192. package/dist/lib/field-aria.d.ts +34 -0
  193. package/dist/lib/field-aria.d.ts.map +1 -0
  194. package/dist/lib/field-aria.js +52 -0
  195. package/dist/lib/image-file-info.cjs +1 -0
  196. package/dist/lib/image-file-info.d.ts +25 -0
  197. package/dist/lib/image-file-info.d.ts.map +1 -0
  198. package/dist/lib/image-file-info.js +67 -0
  199. package/dist/lib/media-viewer-content.cjs +1 -0
  200. package/dist/lib/media-viewer-content.d.ts +102 -0
  201. package/dist/lib/media-viewer-content.d.ts.map +1 -0
  202. package/dist/lib/media-viewer-content.js +650 -0
  203. package/dist/lib/media-viewer-internal.cjs +1 -0
  204. package/dist/lib/media-viewer-internal.d.ts +98 -0
  205. package/dist/lib/media-viewer-internal.d.ts.map +1 -0
  206. package/dist/lib/media-viewer-internal.js +61 -0
  207. package/dist/lib/media-viewer-motion.cjs +1 -0
  208. package/dist/lib/media-viewer-motion.d.ts +40 -0
  209. package/dist/lib/media-viewer-motion.d.ts.map +1 -0
  210. package/dist/lib/media-viewer-motion.js +37 -0
  211. package/dist/lib/motion.cjs +1 -1
  212. package/dist/lib/motion.d.ts +8 -0
  213. package/dist/lib/motion.d.ts.map +1 -1
  214. package/dist/lib/motion.js +11 -10
  215. package/dist/lib/optical-center.cjs +1 -1
  216. package/dist/lib/optical-center.d.ts +1 -1
  217. package/dist/lib/optical-center.d.ts.map +1 -1
  218. package/dist/lib/optical-center.js +12 -5
  219. package/dist/lib/spring-settle.cjs +1 -1
  220. package/dist/lib/spring-settle.js +1 -1
  221. package/dist/lib/table-internal.cjs +1 -0
  222. package/dist/lib/table-internal.d.ts +62 -0
  223. package/dist/lib/table-internal.d.ts.map +1 -0
  224. package/dist/lib/table-internal.js +18 -0
  225. package/dist/lib/use-controllable.cjs +1 -0
  226. package/dist/lib/use-controllable.d.ts +12 -0
  227. package/dist/lib/use-controllable.d.ts.map +1 -0
  228. package/dist/lib/use-controllable.js +15 -0
  229. package/dist/lib/use-dev-warning.cjs +1 -1
  230. package/dist/lib/utils.cjs +1 -1
  231. package/dist/lib/utils.js +26 -33
  232. package/dist/link.cjs +1 -1
  233. package/dist/link.d.ts +1 -1
  234. package/dist/link.js +78 -124
  235. package/dist/list.cjs +1 -1
  236. package/dist/list.d.ts +8 -0
  237. package/dist/list.d.ts.map +1 -1
  238. package/dist/list.js +94 -156
  239. package/dist/loading.cjs +1 -1
  240. package/dist/loading.js +124 -151
  241. package/dist/logo-mark.cjs +1 -0
  242. package/dist/logo-mark.d.ts +79 -0
  243. package/dist/logo-mark.d.ts.map +1 -0
  244. package/dist/logo-mark.js +219 -0
  245. package/dist/logo.cjs +1 -1
  246. package/dist/logo.d.ts +1 -1
  247. package/dist/logo.d.ts.map +1 -1
  248. package/dist/logo.js +51 -87
  249. package/dist/map.cjs +1 -1
  250. package/dist/map.d.ts.map +1 -1
  251. package/dist/map.js +390 -586
  252. package/dist/media-empty.cjs +1 -1
  253. package/dist/media-empty.js +27 -42
  254. package/dist/media-viewer.cjs +1 -0
  255. package/dist/media-viewer.d.ts +224 -0
  256. package/dist/media-viewer.d.ts.map +1 -0
  257. package/dist/media-viewer.js +295 -0
  258. package/dist/menubar.cjs +1 -1
  259. package/dist/menubar.d.ts +14 -14
  260. package/dist/menubar.d.ts.map +1 -1
  261. package/dist/menubar.js +130 -267
  262. package/dist/multi-select-filter.cjs +1 -1
  263. package/dist/multi-select-filter.d.ts +9 -1
  264. package/dist/multi-select-filter.d.ts.map +1 -1
  265. package/dist/multi-select-filter.js +357 -446
  266. package/dist/navigation-menu.cjs +1 -1
  267. package/dist/navigation-menu.js +108 -172
  268. package/dist/pagination.cjs +1 -1
  269. package/dist/pagination.d.ts +36 -12
  270. package/dist/pagination.d.ts.map +1 -1
  271. package/dist/pagination.js +208 -281
  272. package/dist/popover.cjs +1 -1
  273. package/dist/popover.d.ts +1 -1
  274. package/dist/popover.d.ts.map +1 -1
  275. package/dist/popover.js +34 -45
  276. package/dist/progress.cjs +1 -1
  277. package/dist/progress.d.ts +17 -2
  278. package/dist/progress.d.ts.map +1 -1
  279. package/dist/progress.js +116 -162
  280. package/dist/radio-group.cjs +1 -1
  281. package/dist/radio-group.js +90 -146
  282. package/dist/rating.cjs +1 -1
  283. package/dist/rating.d.ts +80 -13
  284. package/dist/rating.d.ts.map +1 -1
  285. package/dist/rating.js +70 -65
  286. package/dist/relative-date.cjs +1 -1
  287. package/dist/relative-date.d.ts.map +1 -1
  288. package/dist/relative-date.js +73 -89
  289. package/dist/resizable.cjs +1 -1
  290. package/dist/resizable.d.ts +39 -23
  291. package/dist/resizable.d.ts.map +1 -1
  292. package/dist/resizable.js +42 -44
  293. package/dist/result-count.cjs +1 -0
  294. package/dist/result-count.d.ts +110 -0
  295. package/dist/result-count.d.ts.map +1 -0
  296. package/dist/result-count.js +49 -0
  297. package/dist/route-progress.cjs +1 -1
  298. package/dist/route-progress.js +58 -102
  299. package/dist/scroll-area.cjs +1 -1
  300. package/dist/scroll-area.d.ts +9 -1
  301. package/dist/scroll-area.d.ts.map +1 -1
  302. package/dist/scroll-area.js +44 -79
  303. package/dist/select.cjs +2 -2
  304. package/dist/select.d.ts +10 -10
  305. package/dist/select.d.ts.map +1 -1
  306. package/dist/select.js +118 -238
  307. package/dist/separator.cjs +1 -1
  308. package/dist/separator.js +90 -78
  309. package/dist/sheet.cjs +1 -1
  310. package/dist/sheet.d.ts +8 -5
  311. package/dist/sheet.d.ts.map +1 -1
  312. package/dist/sheet.js +250 -317
  313. package/dist/single-select-filter.cjs +1 -1
  314. package/dist/single-select-filter.d.ts +32 -0
  315. package/dist/single-select-filter.d.ts.map +1 -1
  316. package/dist/single-select-filter.js +201 -203
  317. package/dist/skeleton.cjs +1 -1
  318. package/dist/skeleton.js +24 -38
  319. package/dist/slider.cjs +1 -1
  320. package/dist/slider.js +51 -81
  321. package/dist/sonner.cjs +1 -1
  322. package/dist/sonner.d.ts +1 -1
  323. package/dist/sonner.d.ts.map +1 -1
  324. package/dist/sonner.js +101 -125
  325. package/dist/spinner.cjs +1 -1
  326. package/dist/spinner.js +22 -31
  327. package/dist/split-layout.cjs +1 -1
  328. package/dist/split-layout.js +52 -101
  329. package/dist/status.cjs +1 -0
  330. package/dist/status.d.ts +51 -0
  331. package/dist/status.d.ts.map +1 -0
  332. package/dist/status.js +60 -0
  333. package/dist/stepper.cjs +1 -1
  334. package/dist/stepper.js +184 -316
  335. package/dist/switch.cjs +1 -1
  336. package/dist/switch.js +17 -32
  337. package/dist/table.cjs +1 -1
  338. package/dist/table.d.ts +103 -30
  339. package/dist/table.d.ts.map +1 -1
  340. package/dist/table.js +170 -209
  341. package/dist/tabs.cjs +1 -1
  342. package/dist/tabs.d.ts.map +1 -1
  343. package/dist/tabs.js +102 -147
  344. package/dist/text-reveal-motion.cjs +1 -1
  345. package/dist/text-reveal-motion.js +307 -363
  346. package/dist/textarea.cjs +1 -1
  347. package/dist/textarea.d.ts.map +1 -1
  348. package/dist/textarea.js +22 -35
  349. package/dist/toggle-group.cjs +1 -1
  350. package/dist/toggle-group.js +43 -62
  351. package/dist/toggle.cjs +1 -1
  352. package/dist/toggle.js +34 -46
  353. package/dist/tooltip.cjs +1 -1
  354. package/dist/tooltip.d.ts +2 -2
  355. package/dist/tooltip.d.ts.map +1 -1
  356. package/dist/tooltip.js +157 -249
  357. package/dist/typography-heading.cjs +1 -1
  358. package/dist/typography-heading.js +25 -61
  359. package/dist/typography-text.cjs +1 -1
  360. package/dist/typography-text.js +27 -57
  361. package/dist/typography.cjs +1 -1
  362. package/dist/typography.js +132 -340
  363. package/package.json +46 -46
  364. package/src/blocks/empty-state.tsx +34 -18
  365. package/src/blocks/sidebar.tsx +86 -31
  366. package/src/components/accordion.tsx +1 -1
  367. package/src/components/alert-dialog.tsx +4 -2
  368. package/src/components/badge.tsx +127 -15
  369. package/src/components/breadcrumb.tsx +1 -1
  370. package/src/components/button.tsx +8 -6
  371. package/src/components/calendar.tsx +155 -9
  372. package/src/components/card.tsx +63 -10
  373. package/src/components/carousel.tsx +4 -1
  374. package/src/components/chart.tsx +151 -17
  375. package/src/components/checkbox.tsx +1 -1
  376. package/src/components/collapsible.tsx +4 -1
  377. package/src/components/combobox.tsx +40 -7
  378. package/src/components/command.tsx +9 -10
  379. package/src/components/context-menu.tsx +4 -4
  380. package/src/components/data-table.tsx +619 -237
  381. package/src/components/date-picker.tsx +31 -4
  382. package/src/components/delta.tsx +217 -0
  383. package/src/components/drawer.tsx +5 -5
  384. package/src/components/dropdown-menu.tsx +4 -4
  385. package/src/components/field.tsx +36 -15
  386. package/src/components/global-layout.tsx +1 -1
  387. package/src/components/input-chip.tsx +51 -7
  388. package/src/components/input-group.tsx +1 -1
  389. package/src/components/input-password.tsx +15 -19
  390. package/src/components/input.tsx +10 -1
  391. package/src/components/list.tsx +14 -2
  392. package/src/components/logo-mark.tsx +345 -0
  393. package/src/components/map.tsx +18 -20
  394. package/src/components/media-viewer.tsx +908 -0
  395. package/src/components/multi-select-filter.tsx +255 -121
  396. package/src/components/navigation-menu.tsx +2 -2
  397. package/src/components/pagination.tsx +86 -26
  398. package/src/components/progress.tsx +91 -23
  399. package/src/components/rating.tsx +200 -74
  400. package/src/components/relative-date.tsx +19 -11
  401. package/src/components/resizable.tsx +86 -33
  402. package/src/components/result-count.tsx +253 -0
  403. package/src/components/scroll-area.tsx +31 -5
  404. package/src/components/select.tsx +2 -2
  405. package/src/components/sheet.tsx +14 -4
  406. package/src/components/single-select-filter.tsx +136 -41
  407. package/src/components/slider.tsx +2 -2
  408. package/src/components/status.tsx +162 -0
  409. package/src/components/switch.tsx +1 -1
  410. package/src/components/table.tsx +278 -106
  411. package/src/components/tabs.tsx +1 -0
  412. package/src/components/textarea.tsx +20 -2
  413. package/src/components/toggle.tsx +2 -2
  414. package/src/components/tooltip.tsx +11 -20
  415. package/src/hooks/use-filter-search-params.ts +302 -0
  416. package/src/index.ts +6 -0
  417. package/src/lib/compose-event-handlers.ts +14 -0
  418. package/src/lib/download-file.ts +61 -0
  419. package/src/lib/empty-chip.tsx +52 -0
  420. package/src/lib/field-aria.tsx +97 -0
  421. package/src/lib/image-file-info.ts +102 -0
  422. package/src/lib/media-viewer-content.tsx +1587 -0
  423. package/src/lib/media-viewer-internal.tsx +191 -0
  424. package/src/lib/media-viewer-motion.ts +120 -0
  425. package/src/lib/motion.ts +9 -0
  426. package/src/lib/table-internal.ts +74 -0
  427. package/src/lib/use-controllable.ts +43 -0
  428. package/src/lib/empty-chip.ts +0 -24
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { StarRating } from "@brightlocal/icons";
2
+ import { StarRating, ThumbsDown, ThumbsUp } from "@brightlocal/icons";
3
3
 
4
4
  import { cn } from "@brightlocal/ui-components/lib/utils";
5
5
 
@@ -8,123 +8,249 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
8
8
  */
9
9
  type RatingSize = "sm" | "md";
10
10
 
11
- const starSizeMap: Record<RatingSize, number> = {
11
+ /**
12
+ * Shape of the review score the Rating renders.
13
+ * - `stars` — a 0–5 star value (Google, Yelp, Tripadvisor, …)
14
+ * - `recommendation` — Facebook's binary Recommended / Not recommended verdict
15
+ */
16
+ type RatingVariant = "stars" | "recommendation";
17
+
18
+ const iconSizeMap: Record<RatingSize, number> = {
12
19
  sm: 16,
13
20
  md: 24,
14
21
  };
15
22
 
23
+ const recommendationStyles: Record<RatingSize, string> = {
24
+ sm: "gap-1.5 text-body-sm",
25
+ md: "gap-2 text-body",
26
+ };
27
+
16
28
  /**
17
- * Rating component displays a star-based rating indicator.
18
- * Supports full and half-star values for precise rating display.
29
+ * Props shared by every Rating variant.
19
30
  */
20
- export interface RatingProps extends React.HTMLAttributes<HTMLDivElement> {
21
- /**
22
- * The rating value (0-5, supports 0.5 increments)
23
- */
24
- value: number;
31
+ interface RatingBaseProps extends React.HTMLAttributes<HTMLDivElement> {
25
32
  /**
26
33
  * Data hook for testing
27
34
  */
28
35
  dataHook: string;
29
36
  /**
30
- * Size of the star icons.
37
+ * Size of the glyphs (stars or thumbs).
31
38
  * @default "sm"
32
39
  */
33
40
  size?: RatingSize;
41
+ /**
42
+ * Optional tracking element identifier
43
+ */
44
+ trackingEl?: string;
45
+ /**
46
+ * Optional tracking label
47
+ */
48
+ trackingLabel?: string;
49
+ }
50
+
51
+ /**
52
+ * Star-based score (the default variant).
53
+ */
54
+ export interface RatingStarsProps extends RatingBaseProps {
55
+ /**
56
+ * Shape of the score.
57
+ * @default "stars"
58
+ */
59
+ variant?: Extract<RatingVariant, "stars">;
60
+ /**
61
+ * The rating value (0-5, supports 0.5 increments)
62
+ */
63
+ value: number;
34
64
  /**
35
65
  * Accessible label for the rating.
36
66
  * Supports `{value}` placeholder for interpolation.
37
67
  * @default "Rating: {value} out of 5 stars"
38
68
  */
39
69
  ariaLabel?: string;
70
+ /** Recommendation-only — never combined with a star `value`. */
71
+ recommended?: never;
72
+ /** Recommendation-only. */
73
+ showLabel?: never;
74
+ /** Recommendation-only. */
75
+ recommendedLabel?: never;
76
+ /** Recommendation-only. */
77
+ notRecommendedLabel?: never;
78
+ }
79
+
80
+ /**
81
+ * Facebook-style binary verdict: thumbs-up "Recommended" or thumbs-down
82
+ * "Not recommended".
83
+ */
84
+ export interface RatingRecommendationProps extends RatingBaseProps {
40
85
  /**
41
- * Optional tracking element identifier
86
+ * Shape of the score.
42
87
  */
43
- trackingEl?: string;
88
+ variant: Extract<RatingVariant, "recommendation">;
44
89
  /**
45
- * Optional tracking label
90
+ * Whether the reviewer recommended the business.
46
91
  */
47
- trackingLabel?: string;
92
+ recommended: boolean;
93
+ /**
94
+ * Render the verdict text beside the thumb. When `false` the thumb stands
95
+ * alone and the text becomes the accessible name instead.
96
+ * @default true
97
+ */
98
+ showLabel?: boolean;
99
+ /**
100
+ * Label for the positive verdict (visible text, or accessible name when
101
+ * `showLabel` is `false`).
102
+ * @default "Recommended"
103
+ */
104
+ recommendedLabel?: string;
105
+ /**
106
+ * Label for the negative verdict (visible text, or accessible name when
107
+ * `showLabel` is `false`).
108
+ * @default "Not recommended"
109
+ */
110
+ notRecommendedLabel?: string;
111
+ /** Stars-only — never combined with a `recommended` verdict. */
112
+ value?: never;
113
+ /** Stars-only. */
114
+ ariaLabel?: never;
48
115
  }
49
116
 
50
- const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
51
- (
52
- {
53
- value,
117
+ /**
118
+ * Rating displays a review score: a star-based value (full and half stars) or
119
+ * Facebook's binary Recommended / Not recommended verdict. The two shapes are a
120
+ * discriminated union on `variant`; each arm types the other arm's props as
121
+ * `never`, so a star `value` can never be combined with a `recommended`
122
+ * flag — not even through a spread of a non-literal object.
123
+ */
124
+ export type RatingProps = RatingStarsProps | RatingRecommendationProps;
125
+
126
+ const Rating = React.forwardRef<HTMLDivElement, RatingProps>((props, ref) => {
127
+ if (props.variant === "recommendation") {
128
+ const {
129
+ variant,
130
+ recommended,
131
+ showLabel = true,
132
+ recommendedLabel,
133
+ notRecommendedLabel,
54
134
  dataHook,
55
135
  size = "sm",
56
- ariaLabel,
57
136
  trackingEl,
58
137
  trackingLabel,
59
138
  className,
60
- ...props
61
- },
62
- ref
63
- ) => {
64
- // Clamp value between 0 and 5
65
- const clampedValue = Math.max(0, Math.min(5, value));
66
- const starSize = starSizeMap[size];
139
+ ...rest
140
+ } = props;
141
+ const label = recommended
142
+ ? (recommendedLabel ?? "Recommended")
143
+ : (notRecommendedLabel ?? "Not recommended");
144
+ const Icon = recommended ? ThumbsUp : ThumbsDown;
67
145
 
68
146
  return (
69
147
  <div
70
148
  ref={ref}
71
- aria-label={
72
- ariaLabel
73
- ? ariaLabel.replace("{value}", String(clampedValue))
74
- : `Rating: ${clampedValue} out of 5 stars`
75
- }
76
- className={cn("flex items-center gap-0.5", className)}
149
+ aria-label={showLabel ? undefined : label}
150
+ className={cn(
151
+ "flex items-center",
152
+ recommendationStyles[size],
153
+ className
154
+ )}
77
155
  data-hook={dataHook}
156
+ data-recommended={recommended}
78
157
  data-slot="rating"
79
158
  data-tracking-el={trackingEl}
80
159
  data-tracking-label={trackingLabel}
81
- role="img"
82
- {...props}
160
+ data-variant={variant}
161
+ role={showLabel ? undefined : "img"}
162
+ {...rest}
83
163
  >
84
- {[...Array(5)].map((_, index) => {
85
- const starValue = index + 1;
86
- const isFilled = clampedValue >= starValue;
87
- const isPartiallyFilled = !isFilled && clampedValue > index;
88
- const fillPercentage = isPartiallyFilled
89
- ? ((clampedValue - index) * 100).toFixed(0)
90
- : isFilled
91
- ? "100"
92
- : "0";
93
-
94
- return (
95
- <div key={index} className="relative" data-slot="rating-star">
96
- {/* Base star (empty/outline) */}
97
- <StarRating
98
- className="fill-muted stroke-muted"
99
- data-slot="rating-star-base"
100
- size={starSize}
101
- />
102
-
103
- {/* Filled overlay */}
104
- {(isFilled || isPartiallyFilled) && (
105
- <div
106
- aria-hidden="true"
107
- className="absolute inset-0 overflow-hidden"
108
- data-slot="rating-star-fill"
109
- style={{
110
- width: `${fillPercentage}%`,
111
- }}
112
- >
113
- <StarRating
114
- className="fill-rating stroke-rating"
115
- size={starSize}
116
- />
117
- </div>
118
- )}
119
- </div>
120
- );
121
- })}
164
+ <Icon
165
+ aria-hidden="true"
166
+ // Outline lucide glyph in muted-foreground, like decorative icons
167
+ // elsewhere in the DS; the thumb direction carries the meaning.
168
+ className="text-muted-foreground shrink-0"
169
+ data-slot="rating-recommendation-icon"
170
+ size={iconSizeMap[size]}
171
+ />
172
+ {showLabel && (
173
+ <span data-slot="rating-recommendation-label">{label}</span>
174
+ )}
122
175
  </div>
123
176
  );
124
177
  }
125
- );
178
+
179
+ const {
180
+ variant,
181
+ value,
182
+ dataHook,
183
+ size = "sm",
184
+ ariaLabel,
185
+ trackingEl,
186
+ trackingLabel,
187
+ className,
188
+ ...rest
189
+ } = props;
190
+ // Clamp value between 0 and 5
191
+ const clampedValue = Math.max(0, Math.min(5, value));
192
+ const starSize = iconSizeMap[size];
193
+
194
+ return (
195
+ <div
196
+ ref={ref}
197
+ aria-label={
198
+ ariaLabel
199
+ ? ariaLabel.replace(/\{value\}/g, String(clampedValue))
200
+ : `Rating: ${clampedValue} out of 5 stars`
201
+ }
202
+ className={cn("flex items-center gap-0.5", className)}
203
+ data-hook={dataHook}
204
+ data-slot="rating"
205
+ data-tracking-el={trackingEl}
206
+ data-tracking-label={trackingLabel}
207
+ data-variant={variant ?? "stars"}
208
+ role="img"
209
+ {...rest}
210
+ >
211
+ {[...Array(5)].map((_, index) => {
212
+ const starValue = index + 1;
213
+ const isFilled = clampedValue >= starValue;
214
+ const isPartiallyFilled = !isFilled && clampedValue > index;
215
+ const fillPercentage = isPartiallyFilled
216
+ ? ((clampedValue - index) * 100).toFixed(0)
217
+ : isFilled
218
+ ? "100"
219
+ : "0";
220
+
221
+ return (
222
+ <div key={index} className="relative" data-slot="rating-star">
223
+ {/* Base star (empty/outline) */}
224
+ <StarRating
225
+ className="fill-muted stroke-muted"
226
+ data-slot="rating-star-base"
227
+ size={starSize}
228
+ />
229
+
230
+ {/* Filled overlay */}
231
+ {(isFilled || isPartiallyFilled) && (
232
+ <div
233
+ aria-hidden="true"
234
+ className="absolute inset-0 overflow-hidden"
235
+ data-slot="rating-star-fill"
236
+ style={{
237
+ width: `${fillPercentage}%`,
238
+ }}
239
+ >
240
+ <StarRating
241
+ className="fill-rating stroke-rating"
242
+ size={starSize}
243
+ />
244
+ </div>
245
+ )}
246
+ </div>
247
+ );
248
+ })}
249
+ </div>
250
+ );
251
+ });
126
252
 
127
253
  Rating.displayName = "Rating";
128
254
 
129
255
  export { Rating };
130
- export type { RatingSize };
256
+ export type { RatingSize, RatingVariant };
@@ -202,6 +202,8 @@ export const RelativeDate = forwardRef<HTMLElement, RelativeDateProps>(
202
202
  const iso = dateOnly
203
203
  ? `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`
204
204
  : date.toISOString();
205
+ const shown = relativeWords(value, now, words);
206
+ const exact = exactText(date, dateOnly);
205
207
 
206
208
  return (
207
209
  <span
@@ -213,17 +215,23 @@ export const RelativeDate = forwardRef<HTMLElement, RelativeDateProps>(
213
215
  data-tracking-label={trackingLabel}
214
216
  >
215
217
  {label && <>{label} </>}
216
- <Tooltip>
217
- <TooltipTrigger
218
- className="focus-visible:shadow-default cursor-default rounded-xs underline decoration-dotted decoration-1 underline-offset-4 focus-visible:outline-none"
219
- dataHook={`${dataHook}-trigger`}
220
- >
221
- <time dateTime={iso}>{relativeWords(value, now, words)}</time>
222
- </TooltipTrigger>
223
- <TooltipContent dataHook={`${dataHook}-tooltip`} side="bottom">
224
- {exactText(date, dateOnly)}
225
- </TooltipContent>
226
- </Tooltip>
218
+ {/* When the words already are the exact date (an older calendar
219
+ date), a tooltip would only repeat them: plain text then. */}
220
+ {shown === exact ? (
221
+ <time dateTime={iso}>{shown}</time>
222
+ ) : (
223
+ <Tooltip>
224
+ <TooltipTrigger
225
+ className="focus-visible:shadow-default cursor-help rounded-xs underline decoration-dotted decoration-1 underline-offset-4 focus-visible:outline-none"
226
+ dataHook={`${dataHook}-trigger`}
227
+ >
228
+ <time dateTime={iso}>{shown}</time>
229
+ </TooltipTrigger>
230
+ <TooltipContent dataHook={`${dataHook}-tooltip`} side="bottom">
231
+ {exact}
232
+ </TooltipContent>
233
+ </Tooltip>
234
+ )}
227
235
  </span>
228
236
  );
229
237
  }
@@ -1,16 +1,28 @@
1
1
  "use client";
2
2
  import * as React from "react";
3
3
  import { GripVertical } from "@brightlocal/icons";
4
- import * as ResizablePrimitive from "react-resizable-panels";
4
+ import {
5
+ Group,
6
+ Panel,
7
+ Separator,
8
+ type PanelProps,
9
+ } from "react-resizable-panels";
5
10
 
6
11
  import { cn } from "@brightlocal/ui-components/lib/utils";
7
12
 
8
13
  /**
9
14
  * Props for the ResizablePanelGroup component.
10
15
  */
11
- interface ResizablePanelGroupProps extends React.ComponentProps<
12
- typeof ResizablePrimitive.PanelGroup
16
+ interface ResizablePanelGroupProps extends Omit<
17
+ React.ComponentProps<typeof Group>,
18
+ "orientation" | "elementRef"
13
19
  > {
20
+ /**
21
+ * Layout direction of the panels. Maps to `orientation` in
22
+ * react-resizable-panels 4.
23
+ * @default "horizontal"
24
+ */
25
+ direction?: "horizontal" | "vertical";
14
26
  /**
15
27
  * Data hook for automated testing
16
28
  */
@@ -27,52 +39,91 @@ interface ResizablePanelGroupProps extends React.ComponentProps<
27
39
 
28
40
  /**
29
41
  * Container for resizable panels. Manages layout direction and panel sizing.
42
+ * `ref` is the root element; use the `groupRef` prop for the imperative handle.
30
43
  */
31
44
  const ResizablePanelGroup = React.forwardRef<
32
- React.ComponentRef<typeof ResizablePrimitive.PanelGroup>,
45
+ HTMLDivElement,
33
46
  ResizablePanelGroupProps
34
- >(({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => (
35
- <ResizablePrimitive.PanelGroup
36
- ref={ref}
37
- className={cn(
38
- "flex h-full w-full data-[panel-group-direction=vertical]:flex-col",
39
- className
40
- )}
41
- data-hook={dataHook}
42
- data-slot="resizable-panel-group"
43
- data-tracking-el={trackingEl}
44
- data-tracking-label={trackingLabel}
45
- {...props}
46
- />
47
- ));
47
+ >(
48
+ (
49
+ {
50
+ className,
51
+ direction = "horizontal",
52
+ dataHook,
53
+ trackingEl,
54
+ trackingLabel,
55
+ ...props
56
+ },
57
+ ref
58
+ ) => (
59
+ <Group
60
+ className={cn("h-full w-full", className)}
61
+ data-hook={dataHook}
62
+ // v3 stamped this attribute; consumer selectors may still key off it.
63
+ data-panel-group-direction={direction}
64
+ data-slot="resizable-panel-group"
65
+ data-tracking-el={trackingEl}
66
+ data-tracking-label={trackingLabel}
67
+ elementRef={ref}
68
+ orientation={direction}
69
+ {...props}
70
+ />
71
+ )
72
+ );
48
73
 
49
74
  ResizablePanelGroup.displayName = "ResizablePanelGroup";
50
75
 
76
+ /**
77
+ * react-resizable-panels 4 reads a bare number as pixels. The DS keeps the
78
+ * previous contract: a number is a percentage of the group, a string passes
79
+ * through with its own unit ("240px", "20rem").
80
+ */
81
+ type PanelSize = number | string;
82
+
83
+ const toPercent = (size: PanelSize | undefined) =>
84
+ typeof size === "number" ? `${size}%` : size;
85
+
51
86
  /**
52
87
  * Props for the ResizablePanel component.
53
88
  */
54
- type ResizablePanelProps = React.ComponentProps<
55
- typeof ResizablePrimitive.Panel
56
- >;
89
+ type ResizablePanelProps = Omit<
90
+ PanelProps,
91
+ "defaultSize" | "minSize" | "maxSize" | "collapsedSize" | "elementRef"
92
+ > & {
93
+ /** Initial size. A number is a percentage of the group. */
94
+ defaultSize?: PanelSize;
95
+ /** Minimum size. A number is a percentage of the group. */
96
+ minSize?: PanelSize;
97
+ /** Maximum size. A number is a percentage of the group. */
98
+ maxSize?: PanelSize;
99
+ /** Size when collapsed. A number is a percentage of the group. */
100
+ collapsedSize?: PanelSize;
101
+ };
57
102
 
58
103
  /**
59
104
  * Individual resizable panel within a panel group.
105
+ * `ref` is the root element; use the `panelRef` prop for the imperative handle.
60
106
  */
61
- const ResizablePanel = React.forwardRef<
62
- React.ComponentRef<typeof ResizablePrimitive.Panel>,
63
- ResizablePanelProps
64
- >(({ ...props }, ref) => (
65
- <ResizablePrimitive.Panel ref={ref} data-slot="resizable-panel" {...props} />
66
- ));
107
+ const ResizablePanel = React.forwardRef<HTMLDivElement, ResizablePanelProps>(
108
+ ({ defaultSize, minSize, maxSize, collapsedSize, ...props }, ref) => (
109
+ <Panel
110
+ collapsedSize={toPercent(collapsedSize)}
111
+ data-slot="resizable-panel"
112
+ defaultSize={toPercent(defaultSize)}
113
+ elementRef={ref}
114
+ maxSize={toPercent(maxSize)}
115
+ minSize={toPercent(minSize)}
116
+ {...props}
117
+ />
118
+ )
119
+ );
67
120
 
68
121
  ResizablePanel.displayName = "ResizablePanel";
69
122
 
70
123
  /**
71
124
  * Props for the ResizableHandle component.
72
125
  */
73
- interface ResizableHandleProps extends React.ComponentProps<
74
- typeof ResizablePrimitive.PanelResizeHandle
75
- > {
126
+ interface ResizableHandleProps extends React.ComponentProps<typeof Separator> {
76
127
  /**
77
128
  * Show a visible drag handle indicator
78
129
  */
@@ -88,9 +139,11 @@ function ResizableHandle({
88
139
  ...props
89
140
  }: ResizableHandleProps) {
90
141
  return (
91
- <ResizablePrimitive.PanelResizeHandle
142
+ // A separator reports the axis it divides: aria-orientation="horizontal"
143
+ // is a bar across a vertical group.
144
+ <Separator
92
145
  className={cn(
93
- "bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-none data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",
146
+ "bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-none aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 aria-[orientation=horizontal]:[&>div]:rotate-90",
94
147
  className
95
148
  )}
96
149
  data-slot="resizable-handle"
@@ -101,7 +154,7 @@ function ResizableHandle({
101
154
  <GripVertical size={10} />
102
155
  </div>
103
156
  )}
104
- </ResizablePrimitive.PanelResizeHandle>
157
+ </Separator>
105
158
  );
106
159
  }
107
160