@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
@@ -0,0 +1,191 @@
1
+ "use client";
2
+
3
+ /* Internal to the MediaViewer family: the item type, the root's context and
4
+ the item's More actions menu — shared by the parts in
5
+ components/media-viewer.tsx and the view in lib/media-viewer-content.tsx,
6
+ kept apart so a page without the view does not bundle it. */
7
+
8
+ import * as React from "react";
9
+ import { Ellipsis } from "@brightlocal/icons";
10
+ import { Button } from "../components/button";
11
+ import { Tooltip, TooltipContent, TooltipTrigger } from "../components/tooltip";
12
+ import {
13
+ DropdownMenu,
14
+ DropdownMenuContent,
15
+ DropdownMenuTrigger,
16
+ } from "../components/dropdown-menu";
17
+
18
+ /**
19
+ * One image in the set.
20
+ */
21
+ export interface MediaViewerItem {
22
+ /**
23
+ * The image URL.
24
+ */
25
+ src: string;
26
+ /**
27
+ * The image's description — alternative text for screen readers and
28
+ * search engines. It also names the trigger that previews it, and the
29
+ * view shows it under the title while the image is open.
30
+ */
31
+ alt: string;
32
+ /**
33
+ * A smaller image for the trigger's preview. Falls back to `src`.
34
+ */
35
+ thumbnailSrc?: string;
36
+ /**
37
+ * The file Download saves — say, the original at full size. Falls back to
38
+ * `src`.
39
+ */
40
+ downloadSrc?: string;
41
+ /**
42
+ * When the image was taken or added, shown under the title while it is
43
+ * open. An ISO 8601 timestamp or a Date; a plain `YYYY-MM-DD` string for a
44
+ * calendar date with no time of day.
45
+ */
46
+ date?: string | Date;
47
+ /**
48
+ * Marks a capture that is no longer available. The frame shows the
49
+ * unavailable message instead of requesting the image. An image that fails to
50
+ * load is treated the same way.
51
+ * @default false
52
+ */
53
+ expired?: boolean;
54
+ }
55
+
56
+ /* Inside MediaViewerContent: the built-in controls (Zoom in, Zoom out,
57
+ Download ahead of the consumer's actions; the item's menu after them),
58
+ and the registry that tells the view a MediaViewerActions is rendering
59
+ them. */
60
+ export const MediaViewerControlsContext = React.createContext<{
61
+ lead: React.ReactNode;
62
+ more: React.ReactNode;
63
+ }>({ lead: null, more: null });
64
+ export const MediaViewerActionsRegistry = React.createContext<
65
+ (() => () => void) | null
66
+ >(null);
67
+
68
+ export interface MediaViewerContextValue {
69
+ items: MediaViewerItem[];
70
+ index: number;
71
+ setIndex: (index: number) => void;
72
+ /** The trigger that last opened the view, for focus return. */
73
+ openerRef: React.MutableRefObject<HTMLButtonElement | null>;
74
+ open: boolean;
75
+ setOpen: (open: boolean) => void;
76
+ /** Counts openings; per-opening state in the view is keyed by it, as the
77
+ view's component stays mounted while closed. */
78
+ openCount: number;
79
+ /** When the opening press happened (event time), for the zoom's cutoff. */
80
+ openedAtRef: React.MutableRefObject<number>;
81
+ /** Whether the view's image has appeared this opening (its zoom has
82
+ started, or the reader has stepped) — only then does the preview step
83
+ aside, so there is never a frame with neither on screen. */
84
+ revealed: boolean;
85
+ reveal: () => void;
86
+ /** Mounted triggers by item index — where the image zooms from and to. */
87
+ triggersRef: React.MutableRefObject<Map<number, HTMLButtonElement>>;
88
+ /** Where the pointer last was while the view was open — the preview
89
+ under it when the view closes holds off its hover zoom. */
90
+ pointerRef: React.MutableRefObject<{ x: number; y: number } | null>;
91
+ /** The item's menu, as the root's `actions` builds it, or null. */
92
+ renderActions:
93
+ ((item: MediaViewerItem, index: number) => React.ReactNode) | null;
94
+ actionsLabel: (item: MediaViewerItem, index: number) => string;
95
+ /** Whether the set has a full view; without one the previews only show. */
96
+ viewable: boolean;
97
+ }
98
+
99
+ export const MediaViewerContext =
100
+ React.createContext<MediaViewerContextValue | null>(null);
101
+
102
+ export function useMediaViewerContext(part: string) {
103
+ const context = React.useContext(MediaViewerContext);
104
+ if (!context) {
105
+ throw new Error(`${part} must be used within <MediaViewer>`);
106
+ }
107
+ return context;
108
+ }
109
+
110
+ export const defaultActionsLabel = (item: MediaViewerItem, index: number) =>
111
+ `More actions for ${item.alt || `image ${index + 1}`}`;
112
+
113
+ export const defaultTriggerLabel = (
114
+ item: MediaViewerItem,
115
+ index: number,
116
+ total: number
117
+ ) => item.alt || `Image ${index + 1} of ${total}`;
118
+
119
+ /* The item's More actions button and its menu — on a preview and in the
120
+ view's bar. */
121
+ export function ItemActionsMenu({
122
+ dataHook,
123
+ label,
124
+ variant,
125
+ children,
126
+ }: {
127
+ dataHook: string;
128
+ label: string;
129
+ variant: "secondary" | "ghost";
130
+ children: React.ReactNode;
131
+ }) {
132
+ return (
133
+ <DropdownMenu>
134
+ <DropdownMenuTrigger asChild>
135
+ <Button
136
+ iconOnly
137
+ ariaLabel={label}
138
+ dataHook={dataHook}
139
+ size={variant === "secondary" ? "sm" : undefined}
140
+ variant={variant}
141
+ >
142
+ <Ellipsis aria-hidden />
143
+ </Button>
144
+ </DropdownMenuTrigger>
145
+ <DropdownMenuContent align="end" dataHook={`${dataHook}-content`}>
146
+ {children}
147
+ </DropdownMenuContent>
148
+ </DropdownMenu>
149
+ );
150
+ }
151
+
152
+ /**
153
+ * Renders `render(ref)` — an element that truncates to one line — inside a
154
+ * tooltip with the full text, which opens only when the text is actually
155
+ * cut at the moment the pointer or focus arrives.
156
+ */
157
+ export function TruncatedText<T extends HTMLElement>({
158
+ dataHook,
159
+ forwardRef,
160
+ full,
161
+ render,
162
+ }: {
163
+ dataHook: string;
164
+ /** A ref of the caller's to set to the same element. Keep it stable. */
165
+ forwardRef?: (node: T | null) => void;
166
+ full: React.ReactNode;
167
+ render: (ref: (node: T | null) => void) => React.ReactElement;
168
+ }) {
169
+ const [node, setNode] = React.useState<T | null>(null);
170
+ const [open, setOpen] = React.useState(false);
171
+ const measure = React.useCallback(
172
+ (next: T | null) => {
173
+ setNode(next);
174
+ forwardRef?.(next);
175
+ },
176
+ [forwardRef]
177
+ );
178
+ return (
179
+ <Tooltip
180
+ open={open}
181
+ onOpenChange={(next) =>
182
+ setOpen(next && !!node && node.scrollWidth > node.clientWidth)
183
+ }
184
+ >
185
+ <TooltipTrigger asChild>{render(measure)}</TooltipTrigger>
186
+ <TooltipContent dataHook={`${dataHook}-full`} side="top">
187
+ {full}
188
+ </TooltipContent>
189
+ </Tooltip>
190
+ );
191
+ }
@@ -0,0 +1,120 @@
1
+ import { MOTION_EASE_DECELERATE } from "@brightlocal/ui-components/lib/motion";
2
+
3
+ /*
4
+ * Motion and gesture values for MediaViewer's lightbox: the zoom between a
5
+ * preview and the view, the glide after a swipe, the rubber band past the
6
+ * ends, and the trackpad swipe thresholds. Private to MediaViewer.
7
+ */
8
+
9
+ /** The image at its resting place, unclipped. */
10
+ export const ZOOM_REST: Keyframe = {
11
+ transform: "none",
12
+ transformOrigin: "0 0",
13
+ clipPath: "inset(0px 0px 0px 0px round 0px)",
14
+ };
15
+
16
+ /* The keyframe that lays the image over its preview: scaled to cover it,
17
+ cropped the way the preview crops (object-cover, object-top), with the
18
+ preview's corner radius. Measured with no transform applied. A preview
19
+ zoomed in on hover (its image scaled about its centre — mid-transition
20
+ too) is matched as it stands, so the open starts from what the reader
21
+ sees. */
22
+ export function zoomKeyframe(
23
+ preview: HTMLElement,
24
+ image: HTMLImageElement
25
+ ): Keyframe | null {
26
+ const p = preview.getBoundingClientRect();
27
+ const i = image.getBoundingClientRect();
28
+ if (!p.width || !p.height || !i.width || !i.height) return null;
29
+ /* A preview scrolled out of sight has nowhere to zoom to: fade instead. */
30
+ if (
31
+ p.bottom <= 0 ||
32
+ p.right <= 0 ||
33
+ p.top >= window.innerHeight ||
34
+ p.left >= window.innerWidth
35
+ )
36
+ return null;
37
+ const cover = Math.max(p.width / i.width, p.height / i.height);
38
+ const thumb = preview.querySelector("img");
39
+ const hover = thumb ? parseFloat(getComputedStyle(thumb).scale) || 1 : 1;
40
+ const scale = cover * hover;
41
+ /* Where the image's top-left corner lands: the cover crop (centred
42
+ across, from the top), then the hover zoom about the preview's centre. */
43
+ const cx = p.left + p.width / 2;
44
+ const cy = p.top + p.height / 2;
45
+ const coverCrop = ((i.width - p.width / cover) / 2) * cover;
46
+ const originX = cx + hover * (p.left - coverCrop - cx);
47
+ const originY = cy + hover * (p.top - cy);
48
+ /* The preview's box, in the image's own pixels. */
49
+ const left = (p.left - originX) / scale;
50
+ const top = (p.top - originY) / scale;
51
+ const right = i.width - left - p.width / scale;
52
+ const bottom = i.height - top - p.height / scale;
53
+ const radius =
54
+ (parseFloat(getComputedStyle(preview).borderTopLeftRadius) || 0) / scale;
55
+ return {
56
+ transform: `translate(${originX - i.left}px, ${originY - i.top}px) scale(${scale})`,
57
+ transformOrigin: "0 0",
58
+ clipPath: `inset(${top}px ${right}px ${bottom}px ${left}px round ${radius}px)`,
59
+ };
60
+ }
61
+
62
+ /** Share of the stage width a drag must cover to step on release… */
63
+ export const DRAG_STEP_SHARE = 0.2;
64
+
65
+ /** …capped, in px, so a wide screen does not ask for a long pull. */
66
+ export const DRAG_STEP_MAX = 160;
67
+
68
+ /** Release speed, in px/ms, that steps however short the drag. */
69
+ export const DRAG_STEP_SPEED = 0.5;
70
+
71
+ /* After a drag, the track glides the rest of the way at the speed it was
72
+ let go, decelerating — so the motion carries on rather than restarting.
73
+ A slow release still finishes promptly; a fast one never snaps. */
74
+ export const glideTiming = (distance: number, speed: number) => ({
75
+ duration: Math.min(
76
+ 320,
77
+ Math.max(120, Math.abs(distance) / Math.max(Math.abs(speed), 0.6))
78
+ ),
79
+ easing: MOTION_EASE_DECELERATE,
80
+ });
81
+
82
+ /* Trackpad swipes follow the approach of yet-another-react-lightbox's
83
+ wheel swipe, a widely used, well-tried one. */
84
+
85
+ /** Rubber band past the first or last image: the most it gives, as a share
86
+ of the stage, and how stiffly (Apple's scroll-view constant). */
87
+ export const RUBBER_BAND_SHARE = 0.1;
88
+ export const RUBBER_BAND_STIFFNESS = 0.55;
89
+
90
+ /** Horizontal travel, in px, before a trackpad swipe starts moving the
91
+ image — a resting hand's drift does nothing. */
92
+ export const WHEEL_INTENT = 30;
93
+
94
+ /** Share of the stage width a trackpad swipe must pull to step. */
95
+ export const WHEEL_STEP_SHARE = 0.2;
96
+
97
+ /** Quiet time, in ms, after which a swipe short of a step springs back —
98
+ long enough that a pause in the fingers is not a let-go. */
99
+ export const WHEEL_CANCEL_DELAY = 600;
100
+
101
+ /** After a step, the inertia that follows is recognised by size: a delta
102
+ no more than this many times the last one is inertia, not new fingers.
103
+ The record fades after WHEEL_INERTIA_TTL ms of quiet. */
104
+ export const WHEEL_INERTIA_RISE = 1.2;
105
+ export const WHEEL_INERTIA_TTL = 300;
106
+
107
+ /** Inertia only fades: once it has, a delta this many times its faintest is
108
+ new fingers — the next swipe, without waiting for the inertia to die. */
109
+ export const WHEEL_FRESH_RISE = 2;
110
+
111
+ /**
112
+ * Where a track pulled `offset` px past the first or last image stands: it
113
+ * gives like a rubber band, ever stiffer, approaching but never reaching
114
+ * `limit`.
115
+ */
116
+ export function rubberBand(offset: number, limit: number): number {
117
+ if (!limit) return 0;
118
+ const give = 1 - 1 / ((Math.abs(offset) * RUBBER_BAND_STIFFNESS) / limit + 1);
119
+ return Math.sign(offset) * give * limit;
120
+ }
package/src/lib/motion.ts CHANGED
@@ -28,6 +28,15 @@ export const MOTION_DURATION_FAST_MS = 150;
28
28
  export const MOTION_DURATION_BASE_MS = 200;
29
29
  export const MOTION_DURATION_SLOW_MS = 300;
30
30
 
31
+ /**
32
+ * Easing curves — mirror --ds-motion-ease-decelerate / -emphasized, for
33
+ * JS-driven animation (WAAPI `easing`) that cannot read the CSS tokens.
34
+ * decelerate: motion that carries on from a gesture and settles
35
+ * emphasized: entrances that land with a soft finish
36
+ */
37
+ export const MOTION_EASE_DECELERATE = "cubic-bezier(0, 0, 0.2, 1)";
38
+ export const MOTION_EASE_EMPHASIZED = "cubic-bezier(0.22, 1, 0.36, 1)";
39
+
31
40
  /**
32
41
  * Quick and controlled, no overshoot — list reorders and other
33
42
  * small-element layout moves.
@@ -0,0 +1,74 @@
1
+ import * as React from "react";
2
+
3
+ /**
4
+ * Internals shared by `Table` and `DataTable` / `VirtualizedDataTable`.
5
+ * This module is not in the package `exports` map, so nothing here is public
6
+ * API — `components/table.tsx` re-exports only what consumers need
7
+ * (`TableSize`).
8
+ */
9
+
10
+ /**
11
+ * Table density. One axis on the root (DS-556): the Table sets the row
12
+ * min-height for every cell and head beneath it, so a table reads as one
13
+ * density and sized content (Input, Button, Checkbox) never fights a per-cell
14
+ * size.
15
+ * - `default` — rows `h-12` (48px), column headers `h-12` (48px). The
16
+ * physical default height is unchanged from before DS-556.
17
+ * - `sm` — rows `h-10` (40px), column headers `h-9` (36px).
18
+ */
19
+ export type TableSize = "default" | "sm";
20
+
21
+ /**
22
+ * Where a table's frame comes from (DS-1103).
23
+ * - `own` — the table draws its own 1px `border-border` frame with `rounded-md`
24
+ * corners; every cell keeps its `p-2`.
25
+ * - `container` — no border, square corners; the first and last cell of every
26
+ * row (head, body, footer, empty and skeleton rows alike) pad to the
27
+ * surrounding container's gutter, `var(--content-inset)`, which `Card`
28
+ * publishes per density (24px for `data`); the `content` spacing token (24px)
29
+ * is the fallback outside any container. Use it inside `CardContent flush`,
30
+ * a Sheet or a dialog body so the page shows one box, not two.
31
+ */
32
+ export type TableFrame = "own" | "container";
33
+
34
+ /**
35
+ * Edge-cell padding for `frame="container"` — applied on the `<table>` so it
36
+ * reaches `TableHead`, `TableCell`, `TableEmpty`, footer and skeleton cells in
37
+ * both scroll-owner modes. The compound selector outranks the cells' own
38
+ * `p-2` / `px-2`.
39
+ */
40
+ export const TABLE_CONTAINER_INSET =
41
+ "[&_tr>*:first-child]:pl-[var(--content-inset,24px)] [&_tr>*:last-child]:pr-[var(--content-inset,24px)]";
42
+
43
+ /**
44
+ * Row min-height per Table `size`, in px — the `h-12` / `h-10` the cells
45
+ * carry in `tableCellVariants`. Keep the two in step: DataTable's virtualizer
46
+ * uses this as its default row estimate.
47
+ */
48
+ export const TABLE_ROW_MIN_HEIGHT: Record<TableSize, number> = {
49
+ default: 48,
50
+ sm: 40,
51
+ };
52
+
53
+ /** Density of the enclosing `Table`; cells and heads read it. */
54
+ export const TableSizeContext = React.createContext<TableSize>("default");
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
+ export function scrollRegionProps(scrollRegionLabel: string | undefined) {
69
+ return {
70
+ role: "region",
71
+ "aria-label": scrollRegionLabel ?? "Scrollable table",
72
+ tabIndex: 0,
73
+ } as const;
74
+ }
@@ -0,0 +1,43 @@
1
+ import * as React from "react";
2
+
3
+ /**
4
+ * Controlled/uncontrolled state helper.
5
+ *
6
+ * Resolves a "controlled or internal" value and returns a setter that takes
7
+ * a value or an updater (`SetStateAction<T>`, as TanStack Table expects).
8
+ * When the `controlled` value is defined, the parent owns state and
9
+ * `onChange` is called with the next value. When undefined, state is kept
10
+ * internally and `onChange` is still invoked (the common "notify but
11
+ * self-manage" pattern). Shared by DataTable and MediaViewer.
12
+ */
13
+ export function useControllable<T>(
14
+ controlled: T | undefined,
15
+ initialValue: T,
16
+ onChange?: (next: T) => void
17
+ ): [T, (updater: T | ((prev: T) => T)) => void] {
18
+ const [internal, setInternal] = React.useState<T>(initialValue);
19
+ const value = controlled !== undefined ? controlled : internal;
20
+
21
+ const valueRef = React.useRef(value);
22
+ React.useEffect(() => {
23
+ valueRef.current = value;
24
+ });
25
+
26
+ const isControlled = controlled !== undefined;
27
+
28
+ const setValue = React.useCallback(
29
+ (updater: T | ((prev: T) => T)) => {
30
+ const next =
31
+ typeof updater === "function"
32
+ ? (updater as (prev: T) => T)(valueRef.current)
33
+ : updater;
34
+ if (!isControlled) {
35
+ setInternal(next);
36
+ }
37
+ onChange?.(next);
38
+ },
39
+ [isControlled, onChange]
40
+ );
41
+
42
+ return [value, setValue];
43
+ }
@@ -1,24 +0,0 @@
1
- import { cva } from "class-variance-authority";
2
-
3
- /* -------------------------------------------------------------------------------------------------
4
- * Empty chip (internal)
5
- *
6
- * The icon chip every "nothing here" moment shares — EmptyState at card
7
- * scope, and CommandEmpty / ComboboxEmpty at popover scope. 40px of
8
- * `bg-muted` around a 16px glyph. It lives once so the two cannot drift: the
9
- * popover form used to be hand-rolled in consumer code with these classes
10
- * copied in.
11
- *
12
- * A canvas drops the chip — but a canvas is a different component, so there
13
- * is no variant for that here.
14
- * -----------------------------------------------------------------------------------------------*/
15
-
16
- export const emptyChipStyles = cva(
17
- "bg-muted text-muted-foreground flex size-10 items-center justify-center rounded-full",
18
- {
19
- variants: {
20
- align: { center: "", left: "shrink-0" },
21
- },
22
- defaultVariants: { align: "center" },
23
- }
24
- );