@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
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),p=require("react"),i=require("@brightlocal/icons"),g=require("@brightlocal/ui-components/lib/utils"),f=require("./lib/empty-canvas.cjs");function y(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(a,e,o.get?o:{enumerable:!0,get:()=>t[e]})}}return a.default=t,Object.freeze(a)}const b=y(p),n={image:{icon:s.jsx(i.Image,{strokeWidth:2}),message:"No photo available"},video:{icon:s.jsx(i.Video,{strokeWidth:2}),message:"No video available"}},r=b.forwardRef(({className:t,dataHook:a,variant:e="image",icon:o,message:c,trackingEl:l,trackingLabel:m,...u},d)=>s.jsx(f.EmptyCanvas,{ref:d,className:g.cn("size-full",t),"data-variant":e,dataHook:a,icon:o??n[e].icon,message:c??n[e].message,slot:"media-empty",trackingEl:l,trackingLabel:m,...u}));r.displayName="MediaEmpty";exports.MediaEmpty=r;
1
+ const g=require("./_virtual/_rolldown/runtime.cjs"),p=require("./lib/empty-canvas.cjs");let i=require("react");i=g.__toESM(i,1);let r=require("@brightlocal/icons"),q=require("@brightlocal/ui-components/lib/utils"),a=require("react/jsx-runtime");var t={image:{icon:(0,a.jsx)(r.Image,{strokeWidth:2}),message:"No photo available"},video:{icon:(0,a.jsx)(r.Video,{strokeWidth:2}),message:"No video available"}},s=i.forwardRef(({className:o,dataHook:l,variant:e="image",icon:m,message:c,trackingEl:_,trackingLabel:n,...u},d)=>(0,a.jsx)(p.EmptyCanvas,{ref:d,className:(0,q.cn)("size-full",o),"data-variant":e,dataHook:l,icon:m??t[e].icon,message:c??t[e].message,slot:"media-empty",trackingEl:_,trackingLabel:n,...u}));s.displayName="MediaEmpty";exports.MediaEmpty=s;
@@ -1,45 +1,30 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import * as l from "react";
3
- import { Video as f, Image as g } from "@brightlocal/icons";
1
+ import { EmptyCanvas as f } from "./lib/empty-canvas.js";
2
+ import * as c from "react";
3
+ import { Image as g, Video as v } from "@brightlocal/icons";
4
4
  import { cn as n } from "@brightlocal/ui-components/lib/utils";
5
- import { EmptyCanvas as y } from "./lib/empty-canvas.js";
6
- const a = {
7
- image: { icon: /* @__PURE__ */ o(g, { strokeWidth: 2 }), message: "No photo available" },
8
- video: { icon: /* @__PURE__ */ o(f, { strokeWidth: 2 }), message: "No video available" }
9
- }, N = l.forwardRef(
10
- ({
11
- className: m,
12
- dataHook: i,
13
- variant: e = "image",
14
- icon: s,
15
- message: t,
16
- trackingEl: r,
17
- trackingLabel: p,
18
- ...d
19
- }, c) => (
20
- /* `size-full`, unlike the chart and map placeholders: a media slot's frame
21
- already has both dimensions — that is what reserving an aspect ratio
22
- means — so this one fills rather than asking for a height. No radius
23
- either: the frame clips, and a radius here would draw a second, smaller
24
- corner inside the card's own. */
25
- /* @__PURE__ */ o(
26
- y,
27
- {
28
- ref: c,
29
- className: n("size-full", m),
30
- "data-variant": e,
31
- dataHook: i,
32
- icon: s ?? a[e].icon,
33
- message: t ?? a[e].message,
34
- slot: "media-empty",
35
- trackingEl: r,
36
- trackingLabel: p,
37
- ...d
38
- }
39
- )
40
- )
41
- );
42
- N.displayName = "MediaEmpty";
5
+ import { jsx as a } from "react/jsx-runtime";
6
+ var o = {
7
+ image: {
8
+ icon: /* @__PURE__ */ a(g, { strokeWidth: 2 }),
9
+ message: "No photo available"
10
+ },
11
+ video: {
12
+ icon: /* @__PURE__ */ a(v, { strokeWidth: 2 }),
13
+ message: "No video available"
14
+ }
15
+ }, y = c.forwardRef(({ className: m, dataHook: i, variant: e = "image", icon: s, message: t, trackingEl: r, trackingLabel: p, ...d }, l) => /* @__PURE__ */ a(f, {
16
+ ref: l,
17
+ className: n("size-full", m),
18
+ "data-variant": e,
19
+ dataHook: i,
20
+ icon: s ?? o[e].icon,
21
+ message: t ?? o[e].message,
22
+ slot: "media-empty",
23
+ trackingEl: r,
24
+ trackingLabel: p,
25
+ ...d
26
+ }));
27
+ y.displayName = "MediaEmpty";
43
28
  export {
44
- N as MediaEmpty
29
+ y as MediaEmpty
45
30
  };
@@ -0,0 +1 @@
1
+ "use client";const be=require("./_virtual/_rolldown/runtime.cjs"),xe=require("./aspect-ratio.cjs"),Z=require("./lib/use-controllable.cjs"),F=require("./dialog.cjs"),ee=require("./media-empty.cjs"),te=require("./lib/compose-event-handlers.cjs"),S=require("./lib/media-viewer-internal.cjs"),ye=require("./lib/media-viewer-content.cjs");let e=require("react");e=be.__toESM(e,1);let q=require("@brightlocal/ui-components/lib/utils"),l=require("react/jsx-runtime"),Me=require("class-variance-authority");var re=30,Re=250,_e=2,W=5;function ne({items:s,index:r,defaultIndex:c=0,onIndexChange:f,open:i,defaultOpen:R=!1,onOpenChange:m,actions:_,formatActionsLabel:a,viewable:d=!0,children:h}){const[x,y]=Z.useControllable(r,c,f),[n,b]=Z.useControllable(i,R,m),T=e.useRef(null),p=e.useRef(new Map),o=e.useRef(null);e.useEffect(()=>{if(!n)return;o.current=null;const V=j=>{o.current={x:j.clientX,y:j.clientY}};return window.addEventListener("pointermove",V,{passive:!0}),window.addEventListener("pointerdown",V,{passive:!0}),()=>{window.removeEventListener("pointermove",V),window.removeEventListener("pointerdown",V)}},[n]);const g=e.useRef(0),[E,A]=e.useState({open:n,count:n?1:0});E.open!==n&&A({open:n,count:n?E.count+1:E.count});const u=E.count,[z,O]=e.useState(0),L=z===u,N=e.useCallback(()=>O(u),[u]),P=s.length===0;e.useEffect(()=>{n&&P&&b(!1)},[n,P,b]);const H=e.useMemo(()=>({items:s,index:x,setIndex:y,openerRef:T,open:n,setOpen:b,openCount:u,openedAtRef:g,revealed:L,reveal:N,triggersRef:p,pointerRef:o,renderActions:_??null,actionsLabel:a??S.defaultActionsLabel,viewable:d}),[_,a,d,s,x,y,n,b,u,L,N]);return(0,l.jsx)(S.MediaViewerContext.Provider,{value:H,children:d?(0,l.jsx)(F.Dialog,{open:n,onOpenChange:b,children:h}):h})}ne.displayName="MediaViewer";function Ee(s,r){const c=e.useRef(r);e.useLayoutEffect(()=>{c.current=r});const f=e.useRef(null),i=e.useRef(!1),R=a=>{i.current=!1,f.current=s&&a.pointerType!=="mouse"?{x:a.clientX,y:a.clientY}:null},m=a=>{const d=f.current;if(f.current=null,!d)return;const h=a.clientX-d.x,x=a.clientY-d.y;Math.abs(h)<re||Math.abs(h)<Math.abs(x)||(i.current=!0,c.current(h<0?1:-1))},_=()=>{const a=i.current;return i.current=!1,a};return e.useEffect(()=>{if(!s)return;let a=0,d=!1,h=0,x=0,y=1/0,n=!1,b=0;const T=p=>{if(p.ctrlKey||Math.abs(p.deltaY)>=Math.abs(p.deltaX))return;p.preventDefault(),window.clearTimeout(b),b=window.setTimeout(()=>{a=0,d=!1},Re);const o=p.deltaX,g=Math.abs(o);if(d){g<x&&(n||(y=g),n=!0),n&&(y=Math.min(y,g)),x=g;const E=Math.sign(o)!==h,A=n&&g>=y*_e;if(!E&&!A)return;d=!1,a=0}a+=o,!(Math.abs(a)<re)&&(d=!0,h=Math.sign(o),x=g,y=g,n=!1,a=0,c.current(o>0?1:-1))};return s.addEventListener("wheel",T,{passive:!1}),()=>{s.removeEventListener("wheel",T),window.clearTimeout(b)}},[s]),{onPointerDown:R,onPointerUp:m,consumeSwipe:_}}var ie=e.forwardRef(({className:s,dataHook:r,index:c=0,ratio:f=4/3,indicator:i=!1,emptyMessage:R,unavailableMessage:m,formatLabel:_=S.defaultTriggerLabel,children:a,trackingEl:d,trackingLabel:h,onClick:x,onKeyDown:y,onPointerDown:n,onPointerUp:b,...T},p)=>{const{items:o,index:g,setIndex:E,openerRef:A,open:u,openedAtRef:z,revealed:O,triggersRef:L,pointerRef:N,renderActions:P,actionsLabel:H,viewable:V}=S.useMediaViewerContext("MediaViewerTrigger"),j=V&&i&&o.length>1,[le,U]=e.useState(c),[Y,B]=e.useState(!1),K=e.useRef(null),[Q,G]=e.useState(!1);e.useLayoutEffect(()=>{if(u)return;const t=N.current,M=K.current;if(!t||!M)return;const C=M.getBoundingClientRect();t.x>=C.left&&t.x<=C.right&&t.y>=C.top&&t.y<=C.bottom&&G(!0)},[u,N]);const[ce,de]=e.useState(u);u!==ce&&(de(u),!u&&Y&&(B(!1),j&&U(g)));const w=j?Y&&u?g:Math.min(Math.max(le,0),o.length-1):c,$=t=>{const M=w+t;M>=0&&M<o.length&&U(M)},ue=u&&O&&g===w,v=o[w],D=v?.thumbnailSrc??v?.src,[fe,pe]=e.useState(null),ge=!!(v&&(v.expired||fe===D)),I=Math.min(Math.max(w-Math.floor(W/2),0),Math.max(o.length-W,0)),[k,we]=e.useState(null),me=e.useCallback(t=>{we(t),typeof p=="function"?p(t):p&&(p.current=t)},[p]);e.useLayoutEffect(()=>{if(!k)return;const t=L.current;return t.set(w,k),()=>{t.get(w)===k&&t.delete(w)}},[k,w,L]);const X=Ee(j?k:null,$),J=(0,l.jsxs)(xe.AspectRatio,{dataHook:`${r}-frame`,ratio:f,children:[ge?(0,l.jsx)(ee.MediaEmpty,{dataHook:`${r}-empty`,message:m??"Image no longer available"}):v&&D?(0,l.jsx)("img",{alt:v.alt,className:(0,q.cn)("duration-slow size-full object-cover object-top transition-transform ease-in-out motion-reduce:transition-none",V&&!Q&&"group-hover/tile:scale-110 motion-reduce:group-hover/tile:scale-100"),decoding:"async",draggable:!1,loading:"lazy",src:D,onError:()=>pe(D)}):(0,l.jsx)(ee.MediaEmpty,{dataHook:`${r}-empty`,message:R}),i&&o.length>1?(0,l.jsx)("div",{"aria-hidden":!0,className:"absolute inset-x-0 bottom-3 flex items-center justify-center gap-1.5","data-hook":`${r}-indicator`,"data-slot":"media-viewer-trigger-indicator",children:o.slice(I,I+W).map((t,M)=>{const C=I+M,he=M===0&&I>0||M===4&&I+W<o.length;return(0,l.jsx)("span",{className:(0,q.cn)("rounded-full shadow-sm",he?"size-1":"size-1.5",C===w?"bg-background":"bg-background/50")},t.src)})}):null]}),ve=V?(0,l.jsx)(F.DialogTrigger,{ref:me,"aria-label":v?_(v,w,o.length):void 0,className:(0,q.cn)("border-border relative block w-full overflow-hidden rounded-lg border text-left outline-none","duration-fast focus-visible:shadow-default transition-shadow ease-out",!Q&&"group-hover/tile:shadow-md","disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",j&&"touch-pan-y"),"data-slot":"media-viewer-trigger","data-tracking-el":d??"media-viewer-trigger","data-tracking-label":h,dataHook:r,disabled:!v,type:"button",onClick:t=>{if(X.consumeSwipe()){t.preventDefault();return}x?.(t),!t.defaultPrevented&&(A.current=t.currentTarget,z.current=t.timeStamp,B(!0),E(w))},onKeyDown:t=>{y?.(t),!(t.defaultPrevented||!j)&&(t.key==="ArrowLeft"?(t.preventDefault(),$(-1)):t.key==="ArrowRight"&&(t.preventDefault(),$(1)))},onPointerDown:t=>te.composeEventHandlers(n,X.onPointerDown)(t),onPointerUp:t=>te.composeEventHandlers(b,X.onPointerUp)(t),...T,children:J}):(0,l.jsx)("div",{className:"border-border relative block w-full overflow-hidden rounded-lg border","data-hook":r,"data-slot":"media-viewer-trigger",children:J});return(0,l.jsxs)("div",{ref:K,className:(0,q.cn)("group/tile relative isolate",ue&&"invisible",s),"data-hook":`${r}-tile`,"data-slot":"media-viewer-trigger-tile",onPointerLeave:()=>G(!1),children:[ve,a,v&&P?(0,l.jsx)("div",{className:(0,q.cn)("absolute top-3 right-3 z-10 flex","duration-fast opacity-0 transition-opacity ease-out","group-focus-within/tile:opacity-100 group-hover/tile:opacity-100 has-data-[state=open]:opacity-100 pointer-coarse:opacity-100"),"data-slot":"media-viewer-trigger-actions",children:(0,l.jsx)(S.ItemActionsMenu,{dataHook:`${r}-actions`,label:H(v,w),variant:"secondary",children:P(v,w)})}):null]})});ie.displayName="MediaViewerTrigger";var Ve=(0,Me.cva)("pointer-events-none absolute z-10 flex items-center gap-1 [&_:is(a,button,input,select,textarea,[tabindex])]:pointer-events-auto",{variants:{align:{"top-start":"top-3 left-3","top-end":"top-3 right-3","bottom-start":"bottom-3 left-3","bottom-end":"bottom-3 right-3"}},defaultVariants:{align:"top-start"}}),ae=e.forwardRef(({className:s,align:r,dataHook:c,...f},i)=>(0,l.jsx)("div",{ref:i,className:(0,q.cn)(Ve({align:r}),s),"data-hook":c,"data-slot":"media-viewer-addon",...f}));ae.displayName="MediaViewerAddon";var oe=e.forwardRef(({className:s,dataHook:r,children:c,...f},i)=>{const R=e.useCallback(m=>{typeof i=="function"?i(m):i&&(i.current=m)},[i]);return(0,l.jsx)(S.TruncatedText,{dataHook:r??"media-viewer-title",forwardRef:R,full:c,render:m=>(0,l.jsx)(F.DialogTitle,{ref:m,className:(0,q.cn)("text-label truncate [grid-area:title]",s),"data-slot":"media-viewer-title",dataHook:r,...f,children:c})})});oe.displayName="MediaViewerTitle";var se=e.forwardRef(({className:s,dataHook:r,children:c,...f},i)=>{const{lead:R,more:m}=e.useContext(S.MediaViewerControlsContext),_=e.useContext(S.MediaViewerActionsRegistry);return e.useLayoutEffect(()=>_?.(),[_]),(0,l.jsxs)("div",{ref:i,className:(0,q.cn)("flex items-center justify-end gap-1 [grid-area:actions]",s),"data-hook":r,"data-slot":"media-viewer-actions",...f,children:[R,c,m]})});se.displayName="MediaViewerActions";exports.MediaViewer=ne;exports.MediaViewerActions=se;exports.MediaViewerAddon=ae;exports.MediaViewerContent=ye.MediaViewerContent;exports.MediaViewerTitle=oe;exports.MediaViewerTrigger=ie;
@@ -0,0 +1,224 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ import { DialogTitle } from './dialog';
3
+ import { MediaViewerItem } from '../lib/media-viewer-internal';
4
+ import { MediaViewerContent } from '../lib/media-viewer-content';
5
+ import * as React from "react";
6
+ export type { MediaViewerItem } from '../lib/media-viewer-internal';
7
+ export type { MediaViewerContentProps } from '../lib/media-viewer-content';
8
+ /**
9
+ * Props for the MediaViewer root.
10
+ */
11
+ export interface MediaViewerProps {
12
+ /**
13
+ * The set of images. Triggers preview them and the view steps through them.
14
+ */
15
+ items: MediaViewerItem[];
16
+ /**
17
+ * Zero-based index of the open item (controlled).
18
+ */
19
+ index?: number;
20
+ /**
21
+ * Index of the open item when uncontrolled.
22
+ * @default 0
23
+ */
24
+ defaultIndex?: number;
25
+ /**
26
+ * Called with the new index when a trigger opens the view or the reader
27
+ * steps through the set.
28
+ */
29
+ onIndexChange?: (index: number) => void;
30
+ /**
31
+ * Whether the view is open (controlled).
32
+ */
33
+ open?: boolean;
34
+ /**
35
+ * Whether the view is open when uncontrolled.
36
+ * @default false
37
+ */
38
+ defaultOpen?: boolean;
39
+ /**
40
+ * Called when the view opens or closes.
41
+ */
42
+ onOpenChange?: (open: boolean) => void;
43
+ /**
44
+ * Actions on one item — DropdownMenuItems (Edit description, Replace,
45
+ * Remove) for the item and its index. The family puts them behind a More
46
+ * actions button in two places: the top-right corner of each preview
47
+ * (shown on hover, keyboard focus and while open; always on touch
48
+ * screens) and the view's bottom bar, after the built-in controls.
49
+ */
50
+ actions?: (item: MediaViewerItem, index: number) => React.ReactNode;
51
+ /**
52
+ * Accessible label for the More actions button, per item — it names the
53
+ * item, as a grid shows one per preview.
54
+ * @default (item) => `More actions for ${item.alt}`
55
+ */
56
+ formatActionsLabel?: (item: MediaViewerItem, index: number) => string;
57
+ /**
58
+ * Whether the previews open a full view. Off, a preview is only a picture
59
+ * — not a button, no hover zoom — that still carries its addons and the
60
+ * item's More actions: an editing grid, say. Leave `MediaViewerContent`
61
+ * out then; nothing of the view runs, and a bundler drops its code.
62
+ * @default true
63
+ */
64
+ viewable?: boolean;
65
+ /**
66
+ * The family's parts: one or more `MediaViewerTrigger`s and the
67
+ * `MediaViewerContent`, anywhere inside — the root renders no DOM.
68
+ */
69
+ children: React.ReactNode;
70
+ }
71
+ /**
72
+ * Root of the family: owns the image set, which item is open and whether the
73
+ * view is. Renders no DOM of its own.
74
+ *
75
+ * @example
76
+ * ```tsx
77
+ * <MediaViewer items={photos}>
78
+ * <MediaViewerTrigger dataHook="photo-tile" />
79
+ * <MediaViewerContent dataHook="photo-viewer">
80
+ * <MediaViewerTitle>Business photos</MediaViewerTitle>
81
+ * </MediaViewerContent>
82
+ * </MediaViewer>
83
+ * ```
84
+ */
85
+ declare function MediaViewer({ items, index: indexProp, defaultIndex, onIndexChange, open: openProp, defaultOpen, onOpenChange, actions, formatActionsLabel, viewable, children, }: MediaViewerProps): React.JSX.Element;
86
+ declare namespace MediaViewer {
87
+ var displayName: string;
88
+ }
89
+ /**
90
+ * Props for MediaViewerTrigger.
91
+ */
92
+ export interface MediaViewerTriggerProps extends Omit<React.ComponentPropsWithoutRef<"button">, "type"> {
93
+ /**
94
+ * Required data-hook attribute for automated testing. The parts derive
95
+ * theirs from it: `-tile`, `-frame`, `-empty`, `-indicator`, `-actions`.
96
+ * @example "photo-tile"
97
+ */
98
+ dataHook: string;
99
+ /**
100
+ * The item this trigger previews and opens the view at.
101
+ * @default 0
102
+ */
103
+ index?: number;
104
+ /**
105
+ * Width over height of the frame.
106
+ * @default 4 / 3
107
+ */
108
+ ratio?: number;
109
+ /**
110
+ * Dots along the bottom of the preview, the shown item marked — for a
111
+ * single preview that stands for the whole set. Such a preview can also be
112
+ * browsed in place: a swipe (touch or trackpad) or the arrow keys show the
113
+ * next or previous image before it is opened, and after the view closes it
114
+ * shows the image the reader stopped on. Leave it off for a grid, where
115
+ * every item has its own trigger.
116
+ * @default false
117
+ */
118
+ indicator?: boolean;
119
+ /**
120
+ * The line shown when the set has no item at `index`.
121
+ * @default "No photo available"
122
+ */
123
+ emptyMessage?: string;
124
+ /**
125
+ * The line shown when the item has expired or its image cannot be loaded.
126
+ * @default "Image no longer available"
127
+ */
128
+ unavailableMessage?: string;
129
+ /**
130
+ * The button's name — set on the button itself, so it holds whether the
131
+ * image loads, has expired or has no `alt`. An `aria-label` passed to the
132
+ * trigger wins over it.
133
+ * @default (item, index, total) => item.alt || `Image ${index + 1} of ${total}`
134
+ */
135
+ formatLabel?: (item: MediaViewerItem, index: number, total: number) => string;
136
+ /**
137
+ * `MediaViewerAddon`s laid over the preview — a Badge with the position,
138
+ * a status. They sit beside the button, not inside it.
139
+ */
140
+ children?: React.ReactNode;
141
+ /**
142
+ * Tracking element identifier for analytics.
143
+ * @default "media-viewer-trigger"
144
+ */
145
+ trackingEl?: string;
146
+ /**
147
+ * Tracking label for analytics context.
148
+ */
149
+ trackingLabel?: string;
150
+ }
151
+ /**
152
+ * A pressable, fixed-ratio preview of one item that opens the view at it —
153
+ * hover and focus-visible states, optional dots for the set, addons over its
154
+ * corners, the item's More actions when the root has `actions`, and
155
+ * `MediaEmpty` when there is no item. The tile wraps the button: `className`
156
+ * sizes the tile, the other props go to the button.
157
+ *
158
+ * @example
159
+ * ```tsx
160
+ * <MediaViewerTrigger dataHook="photo-tile" indicator />
161
+ * ```
162
+ */
163
+ declare const MediaViewerTrigger: React.ForwardRefExoticComponent<MediaViewerTriggerProps & React.RefAttributes<HTMLButtonElement>>;
164
+ declare const mediaViewerAddonVariants: (props?: ({
165
+ align?: "top-start" | "top-end" | "bottom-start" | "bottom-end" | null | undefined;
166
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
167
+ /**
168
+ * Props for MediaViewerAddon.
169
+ */
170
+ export interface MediaViewerAddonProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof mediaViewerAddonVariants> {
171
+ /**
172
+ * Data hook for automated testing.
173
+ */
174
+ dataHook?: string;
175
+ }
176
+ /**
177
+ * Content laid over a corner of a `MediaViewerTrigger` — a Badge with the
178
+ * position, a status. Always shown. It sits beside the preview's button, so
179
+ * it is not part of its name, and a click on plain content still opens the
180
+ * view. The top-right corner holds the item's More actions when the root
181
+ * has `actions`.
182
+ *
183
+ * @example
184
+ * ```tsx
185
+ * <MediaViewerTrigger dataHook="photo-1" index={0}>
186
+ * <MediaViewerAddon align="top-start">
187
+ * <Badge dataHook="photo-1-position" variant="secondary">1</Badge>
188
+ * </MediaViewerAddon>
189
+ * </MediaViewerTrigger>
190
+ * ```
191
+ */
192
+ declare const MediaViewerAddon: React.ForwardRefExoticComponent<MediaViewerAddonProps & React.RefAttributes<HTMLDivElement>>;
193
+ /**
194
+ * Props for MediaViewerTitle.
195
+ */
196
+ export interface MediaViewerTitleProps extends React.ComponentPropsWithoutRef<typeof DialogTitle> {
197
+ /**
198
+ * Data hook for automated testing.
199
+ */
200
+ dataHook?: string;
201
+ }
202
+ /**
203
+ * The view's title — names the dialog (`aria-labelledby`). Sits at the left of
204
+ * the bottom bar: who or what the images belong to.
205
+ */
206
+ declare const MediaViewerTitle: React.ForwardRefExoticComponent<MediaViewerTitleProps & React.RefAttributes<HTMLHeadingElement>>;
207
+ /**
208
+ * Props for MediaViewerActions.
209
+ */
210
+ export interface MediaViewerActionsProps extends React.ComponentPropsWithoutRef<"div"> {
211
+ /**
212
+ * Data hook for automated testing.
213
+ */
214
+ dataHook?: string;
215
+ }
216
+ /**
217
+ * Your own actions for the open image — share, say — at the right of the
218
+ * bottom bar, after the built-in Download, Zoom in and Zoom out, and before
219
+ * the item's More actions (the root's `actions`). Use ghost icon Buttons.
220
+ * Leave it out when the built-in controls are enough.
221
+ */
222
+ declare const MediaViewerActions: React.ForwardRefExoticComponent<MediaViewerActionsProps & React.RefAttributes<HTMLDivElement>>;
223
+ export { MediaViewer, MediaViewerActions, MediaViewerAddon, MediaViewerContent, MediaViewerTitle, MediaViewerTrigger, };
224
+ //# sourceMappingURL=media-viewer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-viewer.d.ts","sourceRoot":"","sources":["../../src/components/media-viewer.tsx"],"names":[],"mappings":"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"}
@@ -0,0 +1,295 @@
1
+ "use client";
2
+ import { AspectRatio as pe } from "./aspect-ratio.js";
3
+ import { useControllable as J } from "./lib/use-controllable.js";
4
+ import { Dialog as me, DialogTitle as ge, DialogTrigger as we } from "./dialog.js";
5
+ import { MediaEmpty as Z } from "./media-empty.js";
6
+ import { composeEventHandlers as ee } from "./lib/compose-event-handlers.js";
7
+ import { ItemActionsMenu as he, MediaViewerActionsRegistry as ve, MediaViewerContext as be, MediaViewerControlsContext as ye, TruncatedText as Re, defaultActionsLabel as xe, defaultTriggerLabel as Me, useMediaViewerContext as Ee } from "./lib/media-viewer-internal.js";
8
+ import { MediaViewerContent as He } from "./lib/media-viewer-content.js";
9
+ import * as t from "react";
10
+ import { cn as L } from "@brightlocal/ui-components/lib/utils";
11
+ import { jsx as u, jsxs as F } from "react/jsx-runtime";
12
+ import { cva as Ve } from "class-variance-authority";
13
+ var te = 30, Se = 250, Te = 2, O = 5;
14
+ function Le({ items: s, index: r, defaultIndex: l = 0, onIndexChange: f, open: n, defaultOpen: M = !1, onOpenChange: w, actions: E, formatActionsLabel: a, viewable: c = !0, children: v }) {
15
+ const [y, R] = J(r, l, f), [o, b] = J(n, M, w), N = t.useRef(null), p = t.useRef(/* @__PURE__ */ new Map()), i = t.useRef(null);
16
+ t.useEffect(() => {
17
+ if (!o) return;
18
+ i.current = null;
19
+ const S = (T) => {
20
+ i.current = {
21
+ x: T.clientX,
22
+ y: T.clientY
23
+ };
24
+ };
25
+ return window.addEventListener("pointermove", S, { passive: !0 }), window.addEventListener("pointerdown", S, { passive: !0 }), () => {
26
+ window.removeEventListener("pointermove", S), window.removeEventListener("pointerdown", S);
27
+ };
28
+ }, [o]);
29
+ const m = t.useRef(0), [V, A] = t.useState({
30
+ open: o,
31
+ count: o ? 1 : 0
32
+ });
33
+ V.open !== o && A({
34
+ open: o,
35
+ count: o ? V.count + 1 : V.count
36
+ });
37
+ const d = V.count, [_, j] = t.useState(0), P = _ === d, I = t.useCallback(() => j(d), [d]), k = s.length === 0;
38
+ t.useEffect(() => {
39
+ o && k && b(!1);
40
+ }, [
41
+ o,
42
+ k,
43
+ b
44
+ ]);
45
+ const $ = t.useMemo(() => ({
46
+ items: s,
47
+ index: y,
48
+ setIndex: R,
49
+ openerRef: N,
50
+ open: o,
51
+ setOpen: b,
52
+ openCount: d,
53
+ openedAtRef: m,
54
+ revealed: P,
55
+ reveal: I,
56
+ triggersRef: p,
57
+ pointerRef: i,
58
+ renderActions: E ?? null,
59
+ actionsLabel: a ?? xe,
60
+ viewable: c
61
+ }), [
62
+ E,
63
+ a,
64
+ c,
65
+ s,
66
+ y,
67
+ R,
68
+ o,
69
+ b,
70
+ d,
71
+ P,
72
+ I
73
+ ]);
74
+ return /* @__PURE__ */ u(be.Provider, {
75
+ value: $,
76
+ children: c ? /* @__PURE__ */ u(me, {
77
+ open: o,
78
+ onOpenChange: b,
79
+ children: v
80
+ }) : v
81
+ });
82
+ }
83
+ Le.displayName = "MediaViewer";
84
+ function Ne(s, r) {
85
+ const l = t.useRef(r);
86
+ t.useLayoutEffect(() => {
87
+ l.current = r;
88
+ });
89
+ const f = t.useRef(null), n = t.useRef(!1), M = (a) => {
90
+ n.current = !1, f.current = s && a.pointerType !== "mouse" ? {
91
+ x: a.clientX,
92
+ y: a.clientY
93
+ } : null;
94
+ }, w = (a) => {
95
+ const c = f.current;
96
+ if (f.current = null, !c) return;
97
+ const v = a.clientX - c.x, y = a.clientY - c.y;
98
+ Math.abs(v) < te || Math.abs(v) < Math.abs(y) || (n.current = !0, l.current(v < 0 ? 1 : -1));
99
+ }, E = () => {
100
+ const a = n.current;
101
+ return n.current = !1, a;
102
+ };
103
+ return t.useEffect(() => {
104
+ if (!s) return;
105
+ let a = 0, c = !1, v = 0, y = 0, R = 1 / 0, o = !1, b = 0;
106
+ const N = (p) => {
107
+ if (p.ctrlKey || Math.abs(p.deltaY) >= Math.abs(p.deltaX)) return;
108
+ p.preventDefault(), window.clearTimeout(b), b = window.setTimeout(() => {
109
+ a = 0, c = !1;
110
+ }, Se);
111
+ const i = p.deltaX, m = Math.abs(i);
112
+ if (c) {
113
+ m < y && (o || (R = m), o = !0), o && (R = Math.min(R, m)), y = m;
114
+ const V = Math.sign(i) !== v, A = o && m >= R * Te;
115
+ if (!V && !A) return;
116
+ c = !1, a = 0;
117
+ }
118
+ a += i, !(Math.abs(a) < te) && (c = !0, v = Math.sign(i), y = m, R = m, o = !1, a = 0, l.current(i > 0 ? 1 : -1));
119
+ };
120
+ return s.addEventListener("wheel", N, { passive: !1 }), () => {
121
+ s.removeEventListener("wheel", N), window.clearTimeout(b);
122
+ };
123
+ }, [s]), {
124
+ onPointerDown: M,
125
+ onPointerUp: w,
126
+ consumeSwipe: E
127
+ };
128
+ }
129
+ var Ce = t.forwardRef(({ className: s, dataHook: r, index: l = 0, ratio: f = 4 / 3, indicator: n = !1, emptyMessage: M, unavailableMessage: w, formatLabel: E = Me, children: a, trackingEl: c, trackingLabel: v, onClick: y, onKeyDown: R, onPointerDown: o, onPointerUp: b, ...N }, p) => {
130
+ const { items: i, index: m, setIndex: V, openerRef: A, open: d, openedAtRef: _, revealed: j, triggersRef: P, pointerRef: I, renderActions: k, actionsLabel: $, viewable: S } = Ee("MediaViewerTrigger"), T = S && n && i.length > 1, [re, U] = t.useState(l), [Y, B] = t.useState(!1), K = t.useRef(null), [q, Q] = t.useState(!1);
131
+ t.useLayoutEffect(() => {
132
+ if (d) return;
133
+ const e = I.current, x = K.current;
134
+ if (!e || !x) return;
135
+ const C = x.getBoundingClientRect();
136
+ e.x >= C.left && e.x <= C.right && e.y >= C.top && e.y <= C.bottom && Q(!0);
137
+ }, [d, I]);
138
+ const [oe, ne] = t.useState(d);
139
+ d !== oe && (ne(d), !d && Y && (B(!1), T && U(m)));
140
+ const g = T ? Y && d ? m : Math.min(Math.max(re, 0), i.length - 1) : l, H = (e) => {
141
+ const x = g + e;
142
+ x >= 0 && x < i.length && U(x);
143
+ }, ae = d && j && m === g, h = i[g], z = h?.thumbnailSrc ?? h?.src, [ie, se] = t.useState(null), le = !!(h && (h.expired || ie === z)), D = Math.min(Math.max(g - Math.floor(O / 2), 0), Math.max(i.length - O, 0)), [W, ce] = t.useState(null), de = t.useCallback((e) => {
144
+ ce(e), typeof p == "function" ? p(e) : p && (p.current = e);
145
+ }, [p]);
146
+ t.useLayoutEffect(() => {
147
+ if (!W) return;
148
+ const e = P.current;
149
+ return e.set(g, W), () => {
150
+ e.get(g) === W && e.delete(g);
151
+ };
152
+ }, [
153
+ W,
154
+ g,
155
+ P
156
+ ]);
157
+ const X = Ne(T ? W : null, H), G = /* @__PURE__ */ F(pe, {
158
+ dataHook: `${r}-frame`,
159
+ ratio: f,
160
+ children: [le ? /* @__PURE__ */ u(Z, {
161
+ dataHook: `${r}-empty`,
162
+ message: w ?? "Image no longer available"
163
+ }) : h && z ? /* @__PURE__ */ u("img", {
164
+ alt: h.alt,
165
+ className: L("duration-slow size-full object-cover object-top transition-transform ease-in-out motion-reduce:transition-none", S && !q && "group-hover/tile:scale-110 motion-reduce:group-hover/tile:scale-100"),
166
+ decoding: "async",
167
+ draggable: !1,
168
+ loading: "lazy",
169
+ src: z,
170
+ onError: () => se(z)
171
+ }) : /* @__PURE__ */ u(Z, {
172
+ dataHook: `${r}-empty`,
173
+ message: M
174
+ }), n && i.length > 1 ? /* @__PURE__ */ u("div", {
175
+ "aria-hidden": !0,
176
+ className: "absolute inset-x-0 bottom-3 flex items-center justify-center gap-1.5",
177
+ "data-hook": `${r}-indicator`,
178
+ "data-slot": "media-viewer-trigger-indicator",
179
+ children: i.slice(D, D + O).map((e, x) => {
180
+ const C = D + x, fe = x === 0 && D > 0 || x === 4 && D + O < i.length;
181
+ return /* @__PURE__ */ u("span", { className: L("rounded-full shadow-sm", fe ? "size-1" : "size-1.5", C === g ? "bg-background" : "bg-background/50") }, e.src);
182
+ })
183
+ }) : null]
184
+ }), ue = S ? /* @__PURE__ */ u(we, {
185
+ ref: de,
186
+ "aria-label": h ? E(h, g, i.length) : void 0,
187
+ className: L("border-border relative block w-full overflow-hidden rounded-lg border text-left outline-none", "duration-fast focus-visible:shadow-default transition-shadow ease-out", !q && "group-hover/tile:shadow-md", "disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50", T && "touch-pan-y"),
188
+ "data-slot": "media-viewer-trigger",
189
+ "data-tracking-el": c ?? "media-viewer-trigger",
190
+ "data-tracking-label": v,
191
+ dataHook: r,
192
+ disabled: !h,
193
+ type: "button",
194
+ onClick: (e) => {
195
+ if (X.consumeSwipe()) {
196
+ e.preventDefault();
197
+ return;
198
+ }
199
+ y?.(e), !e.defaultPrevented && (A.current = e.currentTarget, _.current = e.timeStamp, B(!0), V(g));
200
+ },
201
+ onKeyDown: (e) => {
202
+ R?.(e), !(e.defaultPrevented || !T) && (e.key === "ArrowLeft" ? (e.preventDefault(), H(-1)) : e.key === "ArrowRight" && (e.preventDefault(), H(1)));
203
+ },
204
+ onPointerDown: (e) => ee(o, X.onPointerDown)(e),
205
+ onPointerUp: (e) => ee(b, X.onPointerUp)(e),
206
+ ...N,
207
+ children: G
208
+ }) : /* @__PURE__ */ u("div", {
209
+ className: "border-border relative block w-full overflow-hidden rounded-lg border",
210
+ "data-hook": r,
211
+ "data-slot": "media-viewer-trigger",
212
+ children: G
213
+ });
214
+ return /* @__PURE__ */ F("div", {
215
+ ref: K,
216
+ className: L("group/tile relative isolate", ae && "invisible", s),
217
+ "data-hook": `${r}-tile`,
218
+ "data-slot": "media-viewer-trigger-tile",
219
+ onPointerLeave: () => Q(!1),
220
+ children: [
221
+ ue,
222
+ a,
223
+ h && k ? /* @__PURE__ */ u("div", {
224
+ className: L("absolute top-3 right-3 z-10 flex", "duration-fast opacity-0 transition-opacity ease-out", "group-focus-within/tile:opacity-100 group-hover/tile:opacity-100 has-data-[state=open]:opacity-100 pointer-coarse:opacity-100"),
225
+ "data-slot": "media-viewer-trigger-actions",
226
+ children: /* @__PURE__ */ u(he, {
227
+ dataHook: `${r}-actions`,
228
+ label: $(h, g),
229
+ variant: "secondary",
230
+ children: k(h, g)
231
+ })
232
+ }) : null
233
+ ]
234
+ });
235
+ });
236
+ Ce.displayName = "MediaViewerTrigger";
237
+ var Ae = Ve("pointer-events-none absolute z-10 flex items-center gap-1 [&_:is(a,button,input,select,textarea,[tabindex])]:pointer-events-auto", {
238
+ variants: { align: {
239
+ "top-start": "top-3 left-3",
240
+ "top-end": "top-3 right-3",
241
+ "bottom-start": "bottom-3 left-3",
242
+ "bottom-end": "bottom-3 right-3"
243
+ } },
244
+ defaultVariants: { align: "top-start" }
245
+ }), Pe = t.forwardRef(({ className: s, align: r, dataHook: l, ...f }, n) => /* @__PURE__ */ u("div", {
246
+ ref: n,
247
+ className: L(Ae({ align: r }), s),
248
+ "data-hook": l,
249
+ "data-slot": "media-viewer-addon",
250
+ ...f
251
+ }));
252
+ Pe.displayName = "MediaViewerAddon";
253
+ var Ie = t.forwardRef(({ className: s, dataHook: r, children: l, ...f }, n) => {
254
+ const M = t.useCallback((w) => {
255
+ typeof n == "function" ? n(w) : n && (n.current = w);
256
+ }, [n]);
257
+ return /* @__PURE__ */ u(Re, {
258
+ dataHook: r ?? "media-viewer-title",
259
+ forwardRef: M,
260
+ full: l,
261
+ render: (w) => /* @__PURE__ */ u(ge, {
262
+ ref: w,
263
+ className: L("text-label truncate [grid-area:title]", s),
264
+ "data-slot": "media-viewer-title",
265
+ dataHook: r,
266
+ ...f,
267
+ children: l
268
+ })
269
+ });
270
+ });
271
+ Ie.displayName = "MediaViewerTitle";
272
+ var ke = t.forwardRef(({ className: s, dataHook: r, children: l, ...f }, n) => {
273
+ const { lead: M, more: w } = t.useContext(ye), E = t.useContext(ve);
274
+ return t.useLayoutEffect(() => E?.(), [E]), /* @__PURE__ */ F("div", {
275
+ ref: n,
276
+ className: L("flex items-center justify-end gap-1 [grid-area:actions]", s),
277
+ "data-hook": r,
278
+ "data-slot": "media-viewer-actions",
279
+ ...f,
280
+ children: [
281
+ M,
282
+ l,
283
+ w
284
+ ]
285
+ });
286
+ });
287
+ ke.displayName = "MediaViewerActions";
288
+ export {
289
+ Le as MediaViewer,
290
+ ke as MediaViewerActions,
291
+ Pe as MediaViewerAddon,
292
+ He as MediaViewerContent,
293
+ Ie as MediaViewerTitle,
294
+ Ce as MediaViewerTrigger
295
+ };