@docyrus/shadcn 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (767) hide show
  1. package/README.md +12 -3
  2. package/dist/base-lyra/accordion.js.map +1 -1
  3. package/dist/base-lyra/alert-dialog.js.map +1 -1
  4. package/dist/base-lyra/alert.js.map +1 -1
  5. package/dist/base-lyra/aspect-ratio.js.map +1 -1
  6. package/dist/base-lyra/avatar.js.map +1 -1
  7. package/dist/base-lyra/badge.js.map +1 -1
  8. package/dist/base-lyra/breadcrumb.js.map +1 -1
  9. package/dist/base-lyra/button-group.js.map +1 -1
  10. package/dist/base-lyra/button.js.map +1 -1
  11. package/dist/base-lyra/calendar.js.map +1 -1
  12. package/dist/base-lyra/card.js.map +1 -1
  13. package/dist/base-lyra/carousel.js.map +1 -1
  14. package/dist/base-lyra/chart.js.map +1 -1
  15. package/dist/base-lyra/checkbox.js.map +1 -1
  16. package/dist/base-lyra/combobox.js.map +1 -1
  17. package/dist/base-lyra/command.js.map +1 -1
  18. package/dist/base-lyra/context-menu.js.map +1 -1
  19. package/dist/base-lyra/dialog.js.map +1 -1
  20. package/dist/base-lyra/drawer.js.map +1 -1
  21. package/dist/base-lyra/dropdown-menu.js.map +1 -1
  22. package/dist/base-lyra/empty.js.map +1 -1
  23. package/dist/base-lyra/field.js.map +1 -1
  24. package/dist/base-lyra/hover-card.js.map +1 -1
  25. package/dist/base-lyra/index.js +8 -6
  26. package/dist/base-lyra/index.js.map +1 -1
  27. package/dist/base-lyra/input-group.js.map +1 -1
  28. package/dist/base-lyra/input-otp.js.map +1 -1
  29. package/dist/base-lyra/input.js.map +1 -1
  30. package/dist/base-lyra/item.js.map +1 -1
  31. package/dist/base-lyra/kbd.js.map +1 -1
  32. package/dist/base-lyra/label.js.map +1 -1
  33. package/dist/base-lyra/menubar.js.map +1 -1
  34. package/dist/base-lyra/native-select.js.map +1 -1
  35. package/dist/base-lyra/navigation-menu.js.map +1 -1
  36. package/dist/base-lyra/pagination.js.map +1 -1
  37. package/dist/base-lyra/popover.js.map +1 -1
  38. package/dist/base-lyra/progress.js.map +1 -1
  39. package/dist/base-lyra/radio-group.js.map +1 -1
  40. package/dist/base-lyra/resizable.js.map +1 -1
  41. package/dist/base-lyra/scroll-area.js.map +1 -1
  42. package/dist/base-lyra/select.js.map +1 -1
  43. package/dist/base-lyra/separator.js.map +1 -1
  44. package/dist/base-lyra/sheet.js.map +1 -1
  45. package/dist/base-lyra/sidebar.js +8 -6
  46. package/dist/base-lyra/sidebar.js.map +1 -1
  47. package/dist/base-lyra/skeleton.js.map +1 -1
  48. package/dist/base-lyra/slider.js.map +1 -1
  49. package/dist/base-lyra/spinner.js.map +1 -1
  50. package/dist/base-lyra/switch.js.map +1 -1
  51. package/dist/base-lyra/table.js.map +1 -1
  52. package/dist/base-lyra/tabs.js.map +1 -1
  53. package/dist/base-lyra/textarea.js.map +1 -1
  54. package/dist/base-lyra/toggle-group.js.map +1 -1
  55. package/dist/base-lyra/toggle.js.map +1 -1
  56. package/dist/base-lyra/tooltip.js.map +1 -1
  57. package/dist/base-maia/accordion.js.map +1 -1
  58. package/dist/base-maia/alert-dialog.js.map +1 -1
  59. package/dist/base-maia/alert.js.map +1 -1
  60. package/dist/base-maia/aspect-ratio.js.map +1 -1
  61. package/dist/base-maia/avatar.js.map +1 -1
  62. package/dist/base-maia/badge.js.map +1 -1
  63. package/dist/base-maia/breadcrumb.js.map +1 -1
  64. package/dist/base-maia/button-group.js.map +1 -1
  65. package/dist/base-maia/button.js.map +1 -1
  66. package/dist/base-maia/calendar.js.map +1 -1
  67. package/dist/base-maia/card.js.map +1 -1
  68. package/dist/base-maia/carousel.js.map +1 -1
  69. package/dist/base-maia/chart.js.map +1 -1
  70. package/dist/base-maia/checkbox.js.map +1 -1
  71. package/dist/base-maia/combobox.js.map +1 -1
  72. package/dist/base-maia/command.js.map +1 -1
  73. package/dist/base-maia/context-menu.js.map +1 -1
  74. package/dist/base-maia/dialog.js.map +1 -1
  75. package/dist/base-maia/drawer.js.map +1 -1
  76. package/dist/base-maia/dropdown-menu.js.map +1 -1
  77. package/dist/base-maia/empty.js.map +1 -1
  78. package/dist/base-maia/field.js.map +1 -1
  79. package/dist/base-maia/hover-card.js.map +1 -1
  80. package/dist/base-maia/index.js +8 -6
  81. package/dist/base-maia/index.js.map +1 -1
  82. package/dist/base-maia/input-group.js.map +1 -1
  83. package/dist/base-maia/input-otp.js.map +1 -1
  84. package/dist/base-maia/input.js.map +1 -1
  85. package/dist/base-maia/item.js.map +1 -1
  86. package/dist/base-maia/kbd.js.map +1 -1
  87. package/dist/base-maia/label.js.map +1 -1
  88. package/dist/base-maia/menubar.js.map +1 -1
  89. package/dist/base-maia/native-select.js.map +1 -1
  90. package/dist/base-maia/navigation-menu.js.map +1 -1
  91. package/dist/base-maia/pagination.js.map +1 -1
  92. package/dist/base-maia/popover.js.map +1 -1
  93. package/dist/base-maia/progress.js.map +1 -1
  94. package/dist/base-maia/radio-group.js.map +1 -1
  95. package/dist/base-maia/resizable.js.map +1 -1
  96. package/dist/base-maia/scroll-area.js.map +1 -1
  97. package/dist/base-maia/select.js.map +1 -1
  98. package/dist/base-maia/separator.js.map +1 -1
  99. package/dist/base-maia/sheet.js.map +1 -1
  100. package/dist/base-maia/sidebar.js +8 -6
  101. package/dist/base-maia/sidebar.js.map +1 -1
  102. package/dist/base-maia/skeleton.js.map +1 -1
  103. package/dist/base-maia/slider.js.map +1 -1
  104. package/dist/base-maia/spinner.js.map +1 -1
  105. package/dist/base-maia/switch.js.map +1 -1
  106. package/dist/base-maia/table.js.map +1 -1
  107. package/dist/base-maia/tabs.js.map +1 -1
  108. package/dist/base-maia/textarea.js.map +1 -1
  109. package/dist/base-maia/toggle-group.js.map +1 -1
  110. package/dist/base-maia/toggle.js.map +1 -1
  111. package/dist/base-maia/tooltip.js.map +1 -1
  112. package/dist/base-mira/accordion.js.map +1 -1
  113. package/dist/base-mira/alert-dialog.js.map +1 -1
  114. package/dist/base-mira/alert.js.map +1 -1
  115. package/dist/base-mira/aspect-ratio.js.map +1 -1
  116. package/dist/base-mira/avatar.js.map +1 -1
  117. package/dist/base-mira/badge.js.map +1 -1
  118. package/dist/base-mira/breadcrumb.js.map +1 -1
  119. package/dist/base-mira/button-group.js.map +1 -1
  120. package/dist/base-mira/button.js.map +1 -1
  121. package/dist/base-mira/calendar.js.map +1 -1
  122. package/dist/base-mira/card.js.map +1 -1
  123. package/dist/base-mira/carousel.js.map +1 -1
  124. package/dist/base-mira/chart.js.map +1 -1
  125. package/dist/base-mira/checkbox.js.map +1 -1
  126. package/dist/base-mira/combobox.js.map +1 -1
  127. package/dist/base-mira/command.js.map +1 -1
  128. package/dist/base-mira/context-menu.js.map +1 -1
  129. package/dist/base-mira/dialog.js.map +1 -1
  130. package/dist/base-mira/drawer.js.map +1 -1
  131. package/dist/base-mira/dropdown-menu.js.map +1 -1
  132. package/dist/base-mira/empty.js.map +1 -1
  133. package/dist/base-mira/field.js.map +1 -1
  134. package/dist/base-mira/hover-card.js.map +1 -1
  135. package/dist/base-mira/index.js +8 -6
  136. package/dist/base-mira/index.js.map +1 -1
  137. package/dist/base-mira/input-group.js.map +1 -1
  138. package/dist/base-mira/input-otp.js.map +1 -1
  139. package/dist/base-mira/input.js.map +1 -1
  140. package/dist/base-mira/item.js.map +1 -1
  141. package/dist/base-mira/kbd.js.map +1 -1
  142. package/dist/base-mira/label.js.map +1 -1
  143. package/dist/base-mira/menubar.js.map +1 -1
  144. package/dist/base-mira/native-select.js.map +1 -1
  145. package/dist/base-mira/navigation-menu.js.map +1 -1
  146. package/dist/base-mira/pagination.js.map +1 -1
  147. package/dist/base-mira/popover.js.map +1 -1
  148. package/dist/base-mira/progress.js.map +1 -1
  149. package/dist/base-mira/radio-group.js.map +1 -1
  150. package/dist/base-mira/resizable.js.map +1 -1
  151. package/dist/base-mira/scroll-area.js.map +1 -1
  152. package/dist/base-mira/select.js.map +1 -1
  153. package/dist/base-mira/separator.js.map +1 -1
  154. package/dist/base-mira/sheet.js.map +1 -1
  155. package/dist/base-mira/sidebar.js +8 -6
  156. package/dist/base-mira/sidebar.js.map +1 -1
  157. package/dist/base-mira/skeleton.js.map +1 -1
  158. package/dist/base-mira/slider.js.map +1 -1
  159. package/dist/base-mira/spinner.js.map +1 -1
  160. package/dist/base-mira/switch.js.map +1 -1
  161. package/dist/base-mira/table.js.map +1 -1
  162. package/dist/base-mira/tabs.js.map +1 -1
  163. package/dist/base-mira/textarea.js.map +1 -1
  164. package/dist/base-mira/toggle-group.js.map +1 -1
  165. package/dist/base-mira/toggle.js.map +1 -1
  166. package/dist/base-mira/tooltip.js.map +1 -1
  167. package/dist/base-nova/accordion.js.map +1 -1
  168. package/dist/base-nova/alert-dialog.js.map +1 -1
  169. package/dist/base-nova/alert.js.map +1 -1
  170. package/dist/base-nova/aspect-ratio.js.map +1 -1
  171. package/dist/base-nova/avatar.js.map +1 -1
  172. package/dist/base-nova/badge.js.map +1 -1
  173. package/dist/base-nova/breadcrumb.js.map +1 -1
  174. package/dist/base-nova/button-group.js.map +1 -1
  175. package/dist/base-nova/button.js.map +1 -1
  176. package/dist/base-nova/calendar.js.map +1 -1
  177. package/dist/base-nova/card.js.map +1 -1
  178. package/dist/base-nova/carousel.js.map +1 -1
  179. package/dist/base-nova/chart.js.map +1 -1
  180. package/dist/base-nova/checkbox.js.map +1 -1
  181. package/dist/base-nova/combobox.js.map +1 -1
  182. package/dist/base-nova/command.js.map +1 -1
  183. package/dist/base-nova/context-menu.js.map +1 -1
  184. package/dist/base-nova/dialog.js.map +1 -1
  185. package/dist/base-nova/drawer.js.map +1 -1
  186. package/dist/base-nova/dropdown-menu.js.map +1 -1
  187. package/dist/base-nova/empty.js.map +1 -1
  188. package/dist/base-nova/field.js.map +1 -1
  189. package/dist/base-nova/hover-card.js.map +1 -1
  190. package/dist/base-nova/index.js +8 -6
  191. package/dist/base-nova/index.js.map +1 -1
  192. package/dist/base-nova/input-group.js.map +1 -1
  193. package/dist/base-nova/input-otp.js.map +1 -1
  194. package/dist/base-nova/input.js.map +1 -1
  195. package/dist/base-nova/item.js.map +1 -1
  196. package/dist/base-nova/kbd.js.map +1 -1
  197. package/dist/base-nova/label.js.map +1 -1
  198. package/dist/base-nova/menubar.js.map +1 -1
  199. package/dist/base-nova/native-select.js.map +1 -1
  200. package/dist/base-nova/navigation-menu.js.map +1 -1
  201. package/dist/base-nova/pagination.js.map +1 -1
  202. package/dist/base-nova/popover.js.map +1 -1
  203. package/dist/base-nova/progress.js.map +1 -1
  204. package/dist/base-nova/radio-group.js.map +1 -1
  205. package/dist/base-nova/resizable.js.map +1 -1
  206. package/dist/base-nova/scroll-area.js.map +1 -1
  207. package/dist/base-nova/select.js.map +1 -1
  208. package/dist/base-nova/separator.js.map +1 -1
  209. package/dist/base-nova/sheet.js.map +1 -1
  210. package/dist/base-nova/sidebar.js +8 -6
  211. package/dist/base-nova/sidebar.js.map +1 -1
  212. package/dist/base-nova/skeleton.js.map +1 -1
  213. package/dist/base-nova/slider.js.map +1 -1
  214. package/dist/base-nova/spinner.js.map +1 -1
  215. package/dist/base-nova/switch.js.map +1 -1
  216. package/dist/base-nova/table.js.map +1 -1
  217. package/dist/base-nova/tabs.js.map +1 -1
  218. package/dist/base-nova/textarea.js.map +1 -1
  219. package/dist/base-nova/toggle-group.js.map +1 -1
  220. package/dist/base-nova/toggle.js.map +1 -1
  221. package/dist/base-nova/tooltip.js.map +1 -1
  222. package/dist/base-vega/accordion.js.map +1 -1
  223. package/dist/base-vega/alert-dialog.js.map +1 -1
  224. package/dist/base-vega/alert.js.map +1 -1
  225. package/dist/base-vega/aspect-ratio.js.map +1 -1
  226. package/dist/base-vega/avatar.js.map +1 -1
  227. package/dist/base-vega/badge.js.map +1 -1
  228. package/dist/base-vega/breadcrumb.js.map +1 -1
  229. package/dist/base-vega/button-group.js.map +1 -1
  230. package/dist/base-vega/button.js.map +1 -1
  231. package/dist/base-vega/calendar.js.map +1 -1
  232. package/dist/base-vega/card.js.map +1 -1
  233. package/dist/base-vega/carousel.js.map +1 -1
  234. package/dist/base-vega/chart.js.map +1 -1
  235. package/dist/base-vega/checkbox.js.map +1 -1
  236. package/dist/base-vega/combobox.js.map +1 -1
  237. package/dist/base-vega/command.js.map +1 -1
  238. package/dist/base-vega/context-menu.js.map +1 -1
  239. package/dist/base-vega/dialog.js.map +1 -1
  240. package/dist/base-vega/drawer.js.map +1 -1
  241. package/dist/base-vega/dropdown-menu.js.map +1 -1
  242. package/dist/base-vega/empty.js.map +1 -1
  243. package/dist/base-vega/field.js.map +1 -1
  244. package/dist/base-vega/hover-card.js.map +1 -1
  245. package/dist/base-vega/index.js +8 -6
  246. package/dist/base-vega/index.js.map +1 -1
  247. package/dist/base-vega/input-group.js.map +1 -1
  248. package/dist/base-vega/input-otp.js.map +1 -1
  249. package/dist/base-vega/input.js.map +1 -1
  250. package/dist/base-vega/item.js.map +1 -1
  251. package/dist/base-vega/kbd.js.map +1 -1
  252. package/dist/base-vega/label.js.map +1 -1
  253. package/dist/base-vega/menubar.js.map +1 -1
  254. package/dist/base-vega/native-select.js.map +1 -1
  255. package/dist/base-vega/navigation-menu.js.map +1 -1
  256. package/dist/base-vega/pagination.js.map +1 -1
  257. package/dist/base-vega/popover.js.map +1 -1
  258. package/dist/base-vega/progress.js.map +1 -1
  259. package/dist/base-vega/radio-group.js.map +1 -1
  260. package/dist/base-vega/resizable.js.map +1 -1
  261. package/dist/base-vega/scroll-area.js.map +1 -1
  262. package/dist/base-vega/select.js.map +1 -1
  263. package/dist/base-vega/separator.js.map +1 -1
  264. package/dist/base-vega/sheet.js.map +1 -1
  265. package/dist/base-vega/sidebar.js +8 -6
  266. package/dist/base-vega/sidebar.js.map +1 -1
  267. package/dist/base-vega/skeleton.js.map +1 -1
  268. package/dist/base-vega/slider.js.map +1 -1
  269. package/dist/base-vega/spinner.js.map +1 -1
  270. package/dist/base-vega/switch.js.map +1 -1
  271. package/dist/base-vega/table.js.map +1 -1
  272. package/dist/base-vega/tabs.js.map +1 -1
  273. package/dist/base-vega/textarea.js.map +1 -1
  274. package/dist/base-vega/toggle-group.js.map +1 -1
  275. package/dist/base-vega/toggle.js.map +1 -1
  276. package/dist/base-vega/tooltip.js.map +1 -1
  277. package/dist/hooks/index.d.ts +7 -0
  278. package/dist/hooks/index.js +181 -10
  279. package/dist/hooks/index.js.map +1 -1
  280. package/dist/hooks/use-as-ref.d.ts +5 -0
  281. package/dist/hooks/use-as-ref.js +17 -0
  282. package/dist/hooks/use-as-ref.js.map +1 -0
  283. package/dist/hooks/use-badge-overflow.d.ts +24 -0
  284. package/dist/hooks/use-badge-overflow.js +130 -0
  285. package/dist/hooks/use-badge-overflow.js.map +1 -0
  286. package/dist/hooks/use-callback-ref.d.ts +10 -0
  287. package/dist/hooks/use-callback-ref.js +17 -0
  288. package/dist/hooks/use-callback-ref.js.map +1 -0
  289. package/dist/hooks/use-debounced-callback.d.ts +3 -0
  290. package/dist/hooks/use-debounced-callback.js +38 -0
  291. package/dist/hooks/use-debounced-callback.js.map +1 -0
  292. package/dist/hooks/use-file-upload.d.ts +48 -0
  293. package/dist/hooks/use-file-upload.js +279 -0
  294. package/dist/hooks/use-file-upload.js.map +1 -0
  295. package/dist/hooks/use-isomorphic-layout-effect.d.ts +5 -0
  296. package/dist/hooks/use-isomorphic-layout-effect.js +8 -0
  297. package/dist/hooks/use-isomorphic-layout-effect.js.map +1 -0
  298. package/dist/hooks/use-lazy-ref.d.ts +5 -0
  299. package/dist/hooks/use-lazy-ref.js +14 -0
  300. package/dist/hooks/use-lazy-ref.js.map +1 -0
  301. package/dist/hooks/use-mobile.d.ts +1 -1
  302. package/dist/hooks/use-mobile.js +8 -6
  303. package/dist/hooks/use-mobile.js.map +1 -1
  304. package/dist/index.d.ts +1622 -106
  305. package/dist/index.js +23260 -2932
  306. package/dist/index.js.map +1 -1
  307. package/dist/lib/compose-refs.d.ts +15 -0
  308. package/dist/lib/compose-refs.js +42 -0
  309. package/dist/lib/compose-refs.js.map +1 -0
  310. package/dist/lib/format.d.ts +3 -0
  311. package/dist/lib/format.js +18 -0
  312. package/dist/lib/format.js.map +1 -0
  313. package/dist/lib/index.d.ts +3 -0
  314. package/dist/lib/index.js +53 -2
  315. package/dist/lib/index.js.map +1 -1
  316. package/dist/lib/utils.d.ts +6 -0
  317. package/dist/lib/utils.js.map +1 -1
  318. package/dist/new-york/accordion.js.map +1 -1
  319. package/dist/new-york/alert-dialog.js.map +1 -1
  320. package/dist/new-york/alert.js.map +1 -1
  321. package/dist/new-york/avatar.js.map +1 -1
  322. package/dist/new-york/badge.js.map +1 -1
  323. package/dist/new-york/breadcrumb.js.map +1 -1
  324. package/dist/new-york/button-group.js.map +1 -1
  325. package/dist/new-york/button.js.map +1 -1
  326. package/dist/new-york/calendar.js.map +1 -1
  327. package/dist/new-york/card.js.map +1 -1
  328. package/dist/new-york/carousel.js.map +1 -1
  329. package/dist/new-york/chart.js.map +1 -1
  330. package/dist/new-york/checkbox.js.map +1 -1
  331. package/dist/new-york/combobox.js.map +1 -1
  332. package/dist/new-york/command.js.map +1 -1
  333. package/dist/new-york/context-menu.js.map +1 -1
  334. package/dist/new-york/dialog.js.map +1 -1
  335. package/dist/new-york/drawer.js.map +1 -1
  336. package/dist/new-york/dropdown-menu.js.map +1 -1
  337. package/dist/new-york/empty.js.map +1 -1
  338. package/dist/new-york/field.js.map +1 -1
  339. package/dist/new-york/form.js.map +1 -1
  340. package/dist/new-york/hover-card.js.map +1 -1
  341. package/dist/new-york/index.js +8 -6
  342. package/dist/new-york/index.js.map +1 -1
  343. package/dist/new-york/input-group.js.map +1 -1
  344. package/dist/new-york/input-otp.js.map +1 -1
  345. package/dist/new-york/input.js.map +1 -1
  346. package/dist/new-york/item.js.map +1 -1
  347. package/dist/new-york/kbd.js.map +1 -1
  348. package/dist/new-york/label.js.map +1 -1
  349. package/dist/new-york/menubar.js.map +1 -1
  350. package/dist/new-york/native-select.js.map +1 -1
  351. package/dist/new-york/navigation-menu.js.map +1 -1
  352. package/dist/new-york/pagination.js.map +1 -1
  353. package/dist/new-york/popover.js.map +1 -1
  354. package/dist/new-york/progress.js.map +1 -1
  355. package/dist/new-york/radio-group.js.map +1 -1
  356. package/dist/new-york/resizable.js.map +1 -1
  357. package/dist/new-york/scroll-area.js.map +1 -1
  358. package/dist/new-york/select.js.map +1 -1
  359. package/dist/new-york/separator.js.map +1 -1
  360. package/dist/new-york/sheet.js.map +1 -1
  361. package/dist/new-york/sidebar.js +8 -6
  362. package/dist/new-york/sidebar.js.map +1 -1
  363. package/dist/new-york/skeleton.js.map +1 -1
  364. package/dist/new-york/slider.js.map +1 -1
  365. package/dist/new-york/spinner.js.map +1 -1
  366. package/dist/new-york/switch.js.map +1 -1
  367. package/dist/new-york/table.js.map +1 -1
  368. package/dist/new-york/tabs.js.map +1 -1
  369. package/dist/new-york/textarea.js.map +1 -1
  370. package/dist/new-york/toggle-group.js.map +1 -1
  371. package/dist/new-york/toggle.js.map +1 -1
  372. package/dist/new-york/tooltip.js.map +1 -1
  373. package/dist/radix-lyra/accordion.js.map +1 -1
  374. package/dist/radix-lyra/alert-dialog.js.map +1 -1
  375. package/dist/radix-lyra/alert.js.map +1 -1
  376. package/dist/radix-lyra/avatar.js.map +1 -1
  377. package/dist/radix-lyra/badge.js.map +1 -1
  378. package/dist/radix-lyra/breadcrumb.js.map +1 -1
  379. package/dist/radix-lyra/button-group.js.map +1 -1
  380. package/dist/radix-lyra/button.js.map +1 -1
  381. package/dist/radix-lyra/calendar.js.map +1 -1
  382. package/dist/radix-lyra/card.js.map +1 -1
  383. package/dist/radix-lyra/carousel.js.map +1 -1
  384. package/dist/radix-lyra/chart.js.map +1 -1
  385. package/dist/radix-lyra/checkbox.js.map +1 -1
  386. package/dist/radix-lyra/combobox.js.map +1 -1
  387. package/dist/radix-lyra/command.js.map +1 -1
  388. package/dist/radix-lyra/context-menu.js.map +1 -1
  389. package/dist/radix-lyra/dialog.js.map +1 -1
  390. package/dist/radix-lyra/drawer.js.map +1 -1
  391. package/dist/radix-lyra/dropdown-menu.js.map +1 -1
  392. package/dist/radix-lyra/empty.js.map +1 -1
  393. package/dist/radix-lyra/field.js.map +1 -1
  394. package/dist/radix-lyra/hover-card.js.map +1 -1
  395. package/dist/radix-lyra/index.js +8 -6
  396. package/dist/radix-lyra/index.js.map +1 -1
  397. package/dist/radix-lyra/input-group.js.map +1 -1
  398. package/dist/radix-lyra/input-otp.js.map +1 -1
  399. package/dist/radix-lyra/input.js.map +1 -1
  400. package/dist/radix-lyra/item.js.map +1 -1
  401. package/dist/radix-lyra/kbd.js.map +1 -1
  402. package/dist/radix-lyra/label.js.map +1 -1
  403. package/dist/radix-lyra/menubar.js.map +1 -1
  404. package/dist/radix-lyra/native-select.js.map +1 -1
  405. package/dist/radix-lyra/navigation-menu.js.map +1 -1
  406. package/dist/radix-lyra/pagination.js.map +1 -1
  407. package/dist/radix-lyra/popover.js.map +1 -1
  408. package/dist/radix-lyra/progress.js.map +1 -1
  409. package/dist/radix-lyra/radio-group.js.map +1 -1
  410. package/dist/radix-lyra/resizable.js.map +1 -1
  411. package/dist/radix-lyra/scroll-area.js.map +1 -1
  412. package/dist/radix-lyra/select.js.map +1 -1
  413. package/dist/radix-lyra/separator.js.map +1 -1
  414. package/dist/radix-lyra/sheet.js.map +1 -1
  415. package/dist/radix-lyra/sidebar.js +8 -6
  416. package/dist/radix-lyra/sidebar.js.map +1 -1
  417. package/dist/radix-lyra/skeleton.js.map +1 -1
  418. package/dist/radix-lyra/slider.js.map +1 -1
  419. package/dist/radix-lyra/spinner.js.map +1 -1
  420. package/dist/radix-lyra/switch.js.map +1 -1
  421. package/dist/radix-lyra/table.js.map +1 -1
  422. package/dist/radix-lyra/tabs.js.map +1 -1
  423. package/dist/radix-lyra/textarea.js.map +1 -1
  424. package/dist/radix-lyra/toggle-group.js.map +1 -1
  425. package/dist/radix-lyra/toggle.js.map +1 -1
  426. package/dist/radix-lyra/tooltip.js.map +1 -1
  427. package/dist/radix-maia/accordion.js.map +1 -1
  428. package/dist/radix-maia/alert-dialog.js.map +1 -1
  429. package/dist/radix-maia/alert.js.map +1 -1
  430. package/dist/radix-maia/avatar.js.map +1 -1
  431. package/dist/radix-maia/badge.js.map +1 -1
  432. package/dist/radix-maia/breadcrumb.js.map +1 -1
  433. package/dist/radix-maia/button-group.js.map +1 -1
  434. package/dist/radix-maia/button.js.map +1 -1
  435. package/dist/radix-maia/calendar.js.map +1 -1
  436. package/dist/radix-maia/card.js.map +1 -1
  437. package/dist/radix-maia/carousel.js.map +1 -1
  438. package/dist/radix-maia/chart.js.map +1 -1
  439. package/dist/radix-maia/checkbox.js.map +1 -1
  440. package/dist/radix-maia/combobox.js.map +1 -1
  441. package/dist/radix-maia/command.js.map +1 -1
  442. package/dist/radix-maia/context-menu.js.map +1 -1
  443. package/dist/radix-maia/dialog.js.map +1 -1
  444. package/dist/radix-maia/drawer.js.map +1 -1
  445. package/dist/radix-maia/dropdown-menu.js.map +1 -1
  446. package/dist/radix-maia/empty.js.map +1 -1
  447. package/dist/radix-maia/field.js.map +1 -1
  448. package/dist/radix-maia/hover-card.js.map +1 -1
  449. package/dist/radix-maia/index.js +8 -6
  450. package/dist/radix-maia/index.js.map +1 -1
  451. package/dist/radix-maia/input-group.js.map +1 -1
  452. package/dist/radix-maia/input-otp.js.map +1 -1
  453. package/dist/radix-maia/input.js.map +1 -1
  454. package/dist/radix-maia/item.js.map +1 -1
  455. package/dist/radix-maia/kbd.js.map +1 -1
  456. package/dist/radix-maia/label.js.map +1 -1
  457. package/dist/radix-maia/menubar.js.map +1 -1
  458. package/dist/radix-maia/native-select.js.map +1 -1
  459. package/dist/radix-maia/navigation-menu.js.map +1 -1
  460. package/dist/radix-maia/pagination.js.map +1 -1
  461. package/dist/radix-maia/popover.js.map +1 -1
  462. package/dist/radix-maia/progress.js.map +1 -1
  463. package/dist/radix-maia/radio-group.js.map +1 -1
  464. package/dist/radix-maia/resizable.js.map +1 -1
  465. package/dist/radix-maia/scroll-area.js.map +1 -1
  466. package/dist/radix-maia/select.js.map +1 -1
  467. package/dist/radix-maia/separator.js.map +1 -1
  468. package/dist/radix-maia/sheet.js.map +1 -1
  469. package/dist/radix-maia/sidebar.js +8 -6
  470. package/dist/radix-maia/sidebar.js.map +1 -1
  471. package/dist/radix-maia/skeleton.js.map +1 -1
  472. package/dist/radix-maia/slider.js.map +1 -1
  473. package/dist/radix-maia/spinner.js.map +1 -1
  474. package/dist/radix-maia/switch.js.map +1 -1
  475. package/dist/radix-maia/table.js.map +1 -1
  476. package/dist/radix-maia/tabs.js.map +1 -1
  477. package/dist/radix-maia/textarea.js.map +1 -1
  478. package/dist/radix-maia/toggle-group.js.map +1 -1
  479. package/dist/radix-maia/toggle.js.map +1 -1
  480. package/dist/radix-maia/tooltip.js.map +1 -1
  481. package/dist/radix-mira/accordion.js.map +1 -1
  482. package/dist/radix-mira/alert-dialog.js.map +1 -1
  483. package/dist/radix-mira/alert.js.map +1 -1
  484. package/dist/radix-mira/avatar.js.map +1 -1
  485. package/dist/radix-mira/badge.js.map +1 -1
  486. package/dist/radix-mira/breadcrumb.js.map +1 -1
  487. package/dist/radix-mira/button-group.js.map +1 -1
  488. package/dist/radix-mira/button.js.map +1 -1
  489. package/dist/radix-mira/calendar.js.map +1 -1
  490. package/dist/radix-mira/card.js.map +1 -1
  491. package/dist/radix-mira/carousel.js.map +1 -1
  492. package/dist/radix-mira/chart.js.map +1 -1
  493. package/dist/radix-mira/checkbox.js.map +1 -1
  494. package/dist/radix-mira/combobox.js.map +1 -1
  495. package/dist/radix-mira/command.js.map +1 -1
  496. package/dist/radix-mira/context-menu.js.map +1 -1
  497. package/dist/radix-mira/dialog.js.map +1 -1
  498. package/dist/radix-mira/drawer.js.map +1 -1
  499. package/dist/radix-mira/dropdown-menu.js.map +1 -1
  500. package/dist/radix-mira/empty.js.map +1 -1
  501. package/dist/radix-mira/field.js.map +1 -1
  502. package/dist/radix-mira/hover-card.js.map +1 -1
  503. package/dist/radix-mira/index.js +8 -6
  504. package/dist/radix-mira/index.js.map +1 -1
  505. package/dist/radix-mira/input-group.js.map +1 -1
  506. package/dist/radix-mira/input-otp.js.map +1 -1
  507. package/dist/radix-mira/input.js.map +1 -1
  508. package/dist/radix-mira/item.js.map +1 -1
  509. package/dist/radix-mira/kbd.js.map +1 -1
  510. package/dist/radix-mira/label.js.map +1 -1
  511. package/dist/radix-mira/menubar.js.map +1 -1
  512. package/dist/radix-mira/native-select.js.map +1 -1
  513. package/dist/radix-mira/navigation-menu.js.map +1 -1
  514. package/dist/radix-mira/pagination.js.map +1 -1
  515. package/dist/radix-mira/popover.js.map +1 -1
  516. package/dist/radix-mira/progress.js.map +1 -1
  517. package/dist/radix-mira/radio-group.js.map +1 -1
  518. package/dist/radix-mira/resizable.js.map +1 -1
  519. package/dist/radix-mira/scroll-area.js.map +1 -1
  520. package/dist/radix-mira/select.js.map +1 -1
  521. package/dist/radix-mira/separator.js.map +1 -1
  522. package/dist/radix-mira/sheet.js.map +1 -1
  523. package/dist/radix-mira/sidebar.js +8 -6
  524. package/dist/radix-mira/sidebar.js.map +1 -1
  525. package/dist/radix-mira/skeleton.js.map +1 -1
  526. package/dist/radix-mira/slider.js.map +1 -1
  527. package/dist/radix-mira/spinner.js.map +1 -1
  528. package/dist/radix-mira/switch.js.map +1 -1
  529. package/dist/radix-mira/table.js.map +1 -1
  530. package/dist/radix-mira/tabs.js.map +1 -1
  531. package/dist/radix-mira/textarea.js.map +1 -1
  532. package/dist/radix-mira/toggle-group.js.map +1 -1
  533. package/dist/radix-mira/toggle.js.map +1 -1
  534. package/dist/radix-mira/tooltip.js.map +1 -1
  535. package/dist/radix-nova/accordion.js.map +1 -1
  536. package/dist/radix-nova/alert-dialog.js.map +1 -1
  537. package/dist/radix-nova/alert.js.map +1 -1
  538. package/dist/radix-nova/avatar.js.map +1 -1
  539. package/dist/radix-nova/badge.js.map +1 -1
  540. package/dist/radix-nova/breadcrumb.js.map +1 -1
  541. package/dist/radix-nova/button-group.js.map +1 -1
  542. package/dist/radix-nova/button.js.map +1 -1
  543. package/dist/radix-nova/calendar.js.map +1 -1
  544. package/dist/radix-nova/card.js.map +1 -1
  545. package/dist/radix-nova/carousel.js.map +1 -1
  546. package/dist/radix-nova/chart.js.map +1 -1
  547. package/dist/radix-nova/checkbox.js.map +1 -1
  548. package/dist/radix-nova/combobox.js.map +1 -1
  549. package/dist/radix-nova/command.js.map +1 -1
  550. package/dist/radix-nova/context-menu.js.map +1 -1
  551. package/dist/radix-nova/dialog.js.map +1 -1
  552. package/dist/radix-nova/drawer.js.map +1 -1
  553. package/dist/radix-nova/dropdown-menu.js.map +1 -1
  554. package/dist/radix-nova/empty.js.map +1 -1
  555. package/dist/radix-nova/field.js.map +1 -1
  556. package/dist/radix-nova/hover-card.js.map +1 -1
  557. package/dist/radix-nova/index.js +8 -6
  558. package/dist/radix-nova/index.js.map +1 -1
  559. package/dist/radix-nova/input-group.js.map +1 -1
  560. package/dist/radix-nova/input-otp.js.map +1 -1
  561. package/dist/radix-nova/input.js.map +1 -1
  562. package/dist/radix-nova/item.js.map +1 -1
  563. package/dist/radix-nova/kbd.js.map +1 -1
  564. package/dist/radix-nova/label.js.map +1 -1
  565. package/dist/radix-nova/menubar.js.map +1 -1
  566. package/dist/radix-nova/native-select.js.map +1 -1
  567. package/dist/radix-nova/navigation-menu.js.map +1 -1
  568. package/dist/radix-nova/pagination.js.map +1 -1
  569. package/dist/radix-nova/popover.js.map +1 -1
  570. package/dist/radix-nova/progress.js.map +1 -1
  571. package/dist/radix-nova/radio-group.js.map +1 -1
  572. package/dist/radix-nova/resizable.js.map +1 -1
  573. package/dist/radix-nova/scroll-area.js.map +1 -1
  574. package/dist/radix-nova/select.js.map +1 -1
  575. package/dist/radix-nova/separator.js.map +1 -1
  576. package/dist/radix-nova/sheet.js.map +1 -1
  577. package/dist/radix-nova/sidebar.js +8 -6
  578. package/dist/radix-nova/sidebar.js.map +1 -1
  579. package/dist/radix-nova/skeleton.js.map +1 -1
  580. package/dist/radix-nova/slider.js.map +1 -1
  581. package/dist/radix-nova/spinner.js.map +1 -1
  582. package/dist/radix-nova/switch.js.map +1 -1
  583. package/dist/radix-nova/table.js.map +1 -1
  584. package/dist/radix-nova/tabs.js.map +1 -1
  585. package/dist/radix-nova/textarea.js.map +1 -1
  586. package/dist/radix-nova/toggle-group.js.map +1 -1
  587. package/dist/radix-nova/toggle.js.map +1 -1
  588. package/dist/radix-nova/tooltip.js.map +1 -1
  589. package/dist/radix-vega/accordion.js.map +1 -1
  590. package/dist/radix-vega/action-bar.d.ts +41 -0
  591. package/dist/radix-vega/action-bar.js +589 -0
  592. package/dist/radix-vega/action-bar.js.map +1 -0
  593. package/dist/radix-vega/alert-dialog.js.map +1 -1
  594. package/dist/radix-vega/alert.js.map +1 -1
  595. package/dist/radix-vega/avatar-group.d.ts +19 -0
  596. package/dist/radix-vega/avatar-group.js +193 -0
  597. package/dist/radix-vega/avatar-group.js.map +1 -0
  598. package/dist/radix-vega/avatar.d.ts +1 -3
  599. package/dist/radix-vega/avatar.js +1 -27
  600. package/dist/radix-vega/avatar.js.map +1 -1
  601. package/dist/radix-vega/badge-overflow.d.ts +21 -0
  602. package/dist/radix-vega/badge-overflow.js +223 -0
  603. package/dist/radix-vega/badge-overflow.js.map +1 -0
  604. package/dist/radix-vega/badge.d.ts +1 -1
  605. package/dist/radix-vega/badge.js.map +1 -1
  606. package/dist/radix-vega/breadcrumb.js.map +1 -1
  607. package/dist/radix-vega/button-group.js.map +1 -1
  608. package/dist/radix-vega/button.d.ts +2 -2
  609. package/dist/radix-vega/button.js.map +1 -1
  610. package/dist/radix-vega/calendar.js.map +1 -1
  611. package/dist/radix-vega/card.js.map +1 -1
  612. package/dist/radix-vega/carousel.js.map +1 -1
  613. package/dist/radix-vega/chart.js.map +1 -1
  614. package/dist/radix-vega/checkbox-group.d.ts +12 -0
  615. package/dist/radix-vega/checkbox-group.js +119 -0
  616. package/dist/radix-vega/checkbox-group.js.map +1 -0
  617. package/dist/radix-vega/checkbox.js.map +1 -1
  618. package/dist/radix-vega/circular-progress.d.ts +27 -0
  619. package/dist/radix-vega/circular-progress.js +252 -0
  620. package/dist/radix-vega/circular-progress.js.map +1 -0
  621. package/dist/radix-vega/color-picker.d.ts +85 -0
  622. package/dist/radix-vega/color-picker.js +1683 -0
  623. package/dist/radix-vega/color-picker.js.map +1 -0
  624. package/dist/radix-vega/color-swatch.d.ts +17 -0
  625. package/dist/radix-vega/color-swatch.js +95 -0
  626. package/dist/radix-vega/color-swatch.js.map +1 -0
  627. package/dist/radix-vega/combobox.d.ts +18 -22
  628. package/dist/radix-vega/combobox.js +118 -276
  629. package/dist/radix-vega/combobox.js.map +1 -1
  630. package/dist/radix-vega/command.js.map +1 -1
  631. package/dist/radix-vega/compare-slider.d.ts +32 -0
  632. package/dist/radix-vega/compare-slider.js +393 -0
  633. package/dist/radix-vega/compare-slider.js.map +1 -0
  634. package/dist/radix-vega/context-menu.js.map +1 -1
  635. package/dist/radix-vega/cropper.d.ts +89 -0
  636. package/dist/radix-vega/cropper.js +1396 -0
  637. package/dist/radix-vega/cropper.js.map +1 -0
  638. package/dist/radix-vega/dialog.js.map +1 -1
  639. package/dist/radix-vega/drawer.js.map +1 -1
  640. package/dist/radix-vega/dropdown-menu.js.map +1 -1
  641. package/dist/radix-vega/editable.d.ts +100 -0
  642. package/dist/radix-vega/editable.js +684 -0
  643. package/dist/radix-vega/editable.js.map +1 -0
  644. package/dist/radix-vega/empty.js.map +1 -1
  645. package/dist/radix-vega/field.js.map +1 -1
  646. package/dist/radix-vega/file-upload.d.ts +89 -0
  647. package/dist/radix-vega/file-upload.js +1089 -0
  648. package/dist/radix-vega/file-upload.js.map +1 -0
  649. package/dist/radix-vega/gauge.d.ts +27 -0
  650. package/dist/radix-vega/gauge.js +359 -0
  651. package/dist/radix-vega/gauge.js.map +1 -0
  652. package/dist/radix-vega/hover-card.js.map +1 -1
  653. package/dist/radix-vega/index.d.ts +50 -3
  654. package/dist/radix-vega/index.js +23001 -2667
  655. package/dist/radix-vega/index.js.map +1 -1
  656. package/dist/radix-vega/input-group.d.ts +1 -1
  657. package/dist/radix-vega/input-group.js.map +1 -1
  658. package/dist/radix-vega/input-otp.js.map +1 -1
  659. package/dist/radix-vega/input.js.map +1 -1
  660. package/dist/radix-vega/item.d.ts +2 -2
  661. package/dist/radix-vega/item.js.map +1 -1
  662. package/dist/radix-vega/kanban.d.ts +62 -0
  663. package/dist/radix-vega/kanban.js +831 -0
  664. package/dist/radix-vega/kanban.js.map +1 -0
  665. package/dist/radix-vega/kbd.js.map +1 -1
  666. package/dist/radix-vega/key-value.d.ts +82 -0
  667. package/dist/radix-vega/key-value.js +765 -0
  668. package/dist/radix-vega/key-value.js.map +1 -0
  669. package/dist/radix-vega/label.js.map +1 -1
  670. package/dist/radix-vega/listbox.d.ts +11 -0
  671. package/dist/radix-vega/listbox.js +90 -0
  672. package/dist/radix-vega/listbox.js.map +1 -0
  673. package/dist/radix-vega/mask-input.d.ts +64 -0
  674. package/dist/radix-vega/mask-input.js +1186 -0
  675. package/dist/radix-vega/mask-input.js.map +1 -0
  676. package/dist/radix-vega/media-player.d.ts +127 -0
  677. package/dist/radix-vega/media-player.js +2696 -0
  678. package/dist/radix-vega/media-player.js.map +1 -0
  679. package/dist/radix-vega/mention.d.ts +11 -0
  680. package/dist/radix-vega/mention.js +94 -0
  681. package/dist/radix-vega/mention.js.map +1 -0
  682. package/dist/radix-vega/menubar.js.map +1 -1
  683. package/dist/radix-vega/native-select.js.map +1 -1
  684. package/dist/radix-vega/navigation-menu.js.map +1 -1
  685. package/dist/radix-vega/pagination.js.map +1 -1
  686. package/dist/radix-vega/phone-input.d.ts +48 -0
  687. package/dist/radix-vega/phone-input.js +957 -0
  688. package/dist/radix-vega/phone-input.js.map +1 -0
  689. package/dist/radix-vega/popover.js.map +1 -1
  690. package/dist/radix-vega/progress.js.map +1 -1
  691. package/dist/radix-vega/qr-code.d.ts +53 -0
  692. package/dist/radix-vega/qr-code.js +396 -0
  693. package/dist/radix-vega/qr-code.js.map +1 -0
  694. package/dist/radix-vega/radio-group.js.map +1 -1
  695. package/dist/radix-vega/rating.d.ts +47 -0
  696. package/dist/radix-vega/rating.js +749 -0
  697. package/dist/radix-vega/rating.js.map +1 -0
  698. package/dist/radix-vega/relative-time-card.d.ts +22 -0
  699. package/dist/radix-vega/relative-time-card.js +236 -0
  700. package/dist/radix-vega/relative-time-card.js.map +1 -0
  701. package/dist/radix-vega/resizable.js.map +1 -1
  702. package/dist/radix-vega/responsive-dialog.d.ts +20 -0
  703. package/dist/radix-vega/responsive-dialog.js +483 -0
  704. package/dist/radix-vega/responsive-dialog.js.map +1 -0
  705. package/dist/radix-vega/scroll-area.js.map +1 -1
  706. package/dist/radix-vega/scroll-spy.d.ts +39 -0
  707. package/dist/radix-vega/scroll-spy.js +372 -0
  708. package/dist/radix-vega/scroll-spy.js.map +1 -0
  709. package/dist/radix-vega/scroller.d.ts +20 -0
  710. package/dist/radix-vega/scroller.js +352 -0
  711. package/dist/radix-vega/scroller.js.map +1 -0
  712. package/dist/radix-vega/segmented-input.d.ts +29 -0
  713. package/dist/radix-vega/segmented-input.js +178 -0
  714. package/dist/radix-vega/segmented-input.js.map +1 -0
  715. package/dist/radix-vega/select.js.map +1 -1
  716. package/dist/radix-vega/separator.js.map +1 -1
  717. package/dist/radix-vega/sheet.js.map +1 -1
  718. package/dist/radix-vega/sidebar.js +8 -6
  719. package/dist/radix-vega/sidebar.js.map +1 -1
  720. package/dist/radix-vega/skeleton.js.map +1 -1
  721. package/dist/radix-vega/slider.js.map +1 -1
  722. package/dist/radix-vega/sortable.d.ts +51 -0
  723. package/dist/radix-vega/sortable.js +444 -0
  724. package/dist/radix-vega/sortable.js.map +1 -0
  725. package/dist/radix-vega/speed-dial.d.ts +46 -0
  726. package/dist/radix-vega/speed-dial.js +898 -0
  727. package/dist/radix-vega/speed-dial.js.map +1 -0
  728. package/dist/radix-vega/spinner.js.map +1 -1
  729. package/dist/radix-vega/stack.d.ts +21 -0
  730. package/dist/radix-vega/stack.js +268 -0
  731. package/dist/radix-vega/stack.js.map +1 -0
  732. package/dist/radix-vega/stat.d.ts +24 -0
  733. package/dist/radix-vega/stat.js +147 -0
  734. package/dist/radix-vega/stat.js.map +1 -0
  735. package/dist/radix-vega/status.d.ts +18 -0
  736. package/dist/radix-vega/status.js +71 -0
  737. package/dist/radix-vega/status.js.map +1 -0
  738. package/dist/radix-vega/stepper.d.ts +73 -0
  739. package/dist/radix-vega/stepper.js +973 -0
  740. package/dist/radix-vega/stepper.js.map +1 -0
  741. package/dist/radix-vega/swap.d.ts +29 -0
  742. package/dist/radix-vega/swap.js +214 -0
  743. package/dist/radix-vega/swap.js.map +1 -0
  744. package/dist/radix-vega/switch.js.map +1 -1
  745. package/dist/radix-vega/table.js.map +1 -1
  746. package/dist/radix-vega/tabs.d.ts +1 -1
  747. package/dist/radix-vega/tabs.js.map +1 -1
  748. package/dist/radix-vega/tags-input.d.ts +12 -0
  749. package/dist/radix-vega/tags-input.js +98 -0
  750. package/dist/radix-vega/tags-input.js.map +1 -0
  751. package/dist/radix-vega/textarea.js.map +1 -1
  752. package/dist/radix-vega/time-picker.d.ts +88 -0
  753. package/dist/radix-vega/time-picker.js +1750 -0
  754. package/dist/radix-vega/time-picker.js.map +1 -0
  755. package/dist/radix-vega/timeline.d.ts +32 -0
  756. package/dist/radix-vega/timeline.js +611 -0
  757. package/dist/radix-vega/timeline.js.map +1 -0
  758. package/dist/radix-vega/toggle-group.js.map +1 -1
  759. package/dist/radix-vega/toggle.js.map +1 -1
  760. package/dist/radix-vega/tooltip.js.map +1 -1
  761. package/dist/radix-vega/tour.d.ts +109 -0
  762. package/dist/radix-vega/tour.js +1314 -0
  763. package/dist/radix-vega/tour.js.map +1 -0
  764. package/dist/radix-vega/visually-hidden-input.d.ts +8 -0
  765. package/dist/radix-vega/visually-hidden-input.js +33 -0
  766. package/dist/radix-vega/visually-hidden-input.js.map +1 -0
  767. package/package.json +53 -14
@@ -0,0 +1,1396 @@
1
+ import { Slot } from '@radix-ui/react-slot';
2
+ import { cva } from 'class-variance-authority';
3
+ import * as React5 from 'react';
4
+ import { clsx } from 'clsx';
5
+ import { twMerge } from 'tailwind-merge';
6
+ import { jsx } from 'react/jsx-runtime';
7
+
8
+ function setRef(ref, value) {
9
+ if (typeof ref === "function") {
10
+ return ref(value);
11
+ }
12
+ if (ref !== null && ref !== void 0) {
13
+ ref.current = value;
14
+ }
15
+ }
16
+ function composeRefs(...refs) {
17
+ return (node) => {
18
+ let hasCleanup = false;
19
+ const cleanups = refs.map((ref) => {
20
+ const cleanup = setRef(ref, node);
21
+ if (!hasCleanup && typeof cleanup === "function") {
22
+ hasCleanup = true;
23
+ }
24
+ return cleanup;
25
+ });
26
+ if (hasCleanup) {
27
+ return () => {
28
+ for (let i = 0; i < cleanups.length; i++) {
29
+ const cleanup = cleanups[i];
30
+ if (typeof cleanup === "function") {
31
+ cleanup();
32
+ } else {
33
+ setRef(refs[i], null);
34
+ }
35
+ }
36
+ };
37
+ }
38
+ };
39
+ }
40
+ function useComposedRefs(...refs) {
41
+ return React5.useCallback(composeRefs(...refs), refs);
42
+ }
43
+ function cn(...inputs) {
44
+ return twMerge(clsx(inputs));
45
+ }
46
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React5.useLayoutEffect : React5.useEffect;
47
+
48
+ // src/hooks/use-as-ref.ts
49
+ function useAsRef(props) {
50
+ const ref = React5.useRef(props);
51
+ useIsomorphicLayoutEffect(() => {
52
+ ref.current = props;
53
+ });
54
+ return ref;
55
+ }
56
+ function useLazyRef(fn) {
57
+ const ref = React5.useRef(null);
58
+ if (ref.current === null) {
59
+ ref.current = fn();
60
+ }
61
+ return ref;
62
+ }
63
+ var ROOT_NAME = "Cropper";
64
+ var ROOT_IMPL_NAME = "CropperImpl";
65
+ var IMAGE_NAME = "CropperImage";
66
+ var VIDEO_NAME = "CropperVideo";
67
+ var AREA_NAME = "CropperArea";
68
+ var MAX_CACHE_SIZE = 200;
69
+ var DPR = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
70
+ var rotationSizeCache = /* @__PURE__ */ new Map();
71
+ var cropSizeCache = /* @__PURE__ */ new Map();
72
+ var croppedAreaCache = /* @__PURE__ */ new Map();
73
+ var onPositionClampCache = /* @__PURE__ */ new Map();
74
+ function clamp(value, min, max) {
75
+ return Math.min(Math.max(value, min), max);
76
+ }
77
+ function quantize(n, step = 2 / DPR) {
78
+ return Math.round(n / step) * step;
79
+ }
80
+ function quantizePosition(n, step = 4 / DPR) {
81
+ return Math.round(n / step) * step;
82
+ }
83
+ function quantizeZoom(n, step = 0.01) {
84
+ return Math.round(n / step) * step;
85
+ }
86
+ function quantizeRotation(n, step = 1) {
87
+ return Math.round(n / step) * step;
88
+ }
89
+ function snapToDevicePixel(n) {
90
+ return Math.round(n * DPR) / DPR;
91
+ }
92
+ function lruGet(map, key) {
93
+ const v = map.get(key);
94
+ if (v !== void 0) {
95
+ map.delete(key);
96
+ map.set(key, v);
97
+ }
98
+ return v;
99
+ }
100
+ function lruSet(map, key, val, max = MAX_CACHE_SIZE) {
101
+ if (map.has(key)) {
102
+ map.delete(key);
103
+ }
104
+ map.set(key, val);
105
+ if (map.size > max) {
106
+ const firstKey = map.keys().next().value;
107
+ if (firstKey !== void 0) {
108
+ map.delete(firstKey);
109
+ }
110
+ }
111
+ }
112
+ function getDistanceBetweenPoints(pointA, pointB) {
113
+ return Math.sqrt((pointA.y - pointB.y) ** 2 + (pointA.x - pointB.x) ** 2);
114
+ }
115
+ function getCenter(a, b) {
116
+ return {
117
+ x: (b.x + a.x) * 0.5,
118
+ y: (b.y + a.y) * 0.5
119
+ };
120
+ }
121
+ function getRotationBetweenPoints(pointA, pointB) {
122
+ return Math.atan2(pointB.y - pointA.y, pointB.x - pointA.x) * 180 / Math.PI;
123
+ }
124
+ function getRadianAngle(degreeValue) {
125
+ return degreeValue * Math.PI / 180;
126
+ }
127
+ function rotateSize(width, height, rotation) {
128
+ const cacheKey = `${quantize(width)}-${quantize(height)}-${quantizeRotation(rotation)}`;
129
+ const cached = lruGet(rotationSizeCache, cacheKey);
130
+ if (cached) {
131
+ return cached;
132
+ }
133
+ const rotRad = getRadianAngle(rotation);
134
+ const cosRot = Math.cos(rotRad);
135
+ const sinRot = Math.sin(rotRad);
136
+ const result = {
137
+ width: Math.abs(cosRot * width) + Math.abs(sinRot * height),
138
+ height: Math.abs(sinRot * width) + Math.abs(cosRot * height)
139
+ };
140
+ lruSet(rotationSizeCache, cacheKey, result, MAX_CACHE_SIZE);
141
+ return result;
142
+ }
143
+ function getCropSize(mediaWidth, mediaHeight, contentWidth, contentHeight, aspect, rotation = 0) {
144
+ const cacheKey = `${quantize(mediaWidth, 8)}-${quantize(mediaHeight, 8)}-${quantize(contentWidth, 8)}-${quantize(contentHeight, 8)}-${quantize(aspect, 0.01)}-${quantizeRotation(rotation)}`;
145
+ const cached = lruGet(cropSizeCache, cacheKey);
146
+ if (cached) {
147
+ return cached;
148
+ }
149
+ const { width, height } = rotateSize(mediaWidth, mediaHeight, rotation);
150
+ const fittingWidth = Math.min(width, contentWidth);
151
+ const fittingHeight = Math.min(height, contentHeight);
152
+ const result = fittingWidth > fittingHeight * aspect ? {
153
+ width: fittingHeight * aspect,
154
+ height: fittingHeight
155
+ } : {
156
+ width: fittingWidth,
157
+ height: fittingWidth / aspect
158
+ };
159
+ lruSet(cropSizeCache, cacheKey, result, MAX_CACHE_SIZE);
160
+ return result;
161
+ }
162
+ function onPositionClamp(position, mediaSize, cropSize, zoom, rotation = 0) {
163
+ const quantizedX = quantizePosition(position.x);
164
+ const quantizedY = quantizePosition(position.y);
165
+ const cacheKey = `${quantizedX}-${quantizedY}-${quantize(mediaSize.width)}-${quantize(mediaSize.height)}-${quantize(cropSize.width)}-${quantize(cropSize.height)}-${quantizeZoom(zoom)}-${quantizeRotation(rotation)}`;
166
+ const cached = lruGet(onPositionClampCache, cacheKey);
167
+ if (cached) {
168
+ return cached;
169
+ }
170
+ const { width, height } = rotateSize(
171
+ mediaSize.width,
172
+ mediaSize.height,
173
+ rotation
174
+ );
175
+ const maxPositionX = width * zoom * 0.5 - cropSize.width * 0.5;
176
+ const maxPositionY = height * zoom * 0.5 - cropSize.height * 0.5;
177
+ const result = {
178
+ x: clamp(position.x, -maxPositionX, maxPositionX),
179
+ y: clamp(position.y, -maxPositionY, maxPositionY)
180
+ };
181
+ lruSet(onPositionClampCache, cacheKey, result, MAX_CACHE_SIZE);
182
+ return result;
183
+ }
184
+ function getCroppedArea(crop, mediaSize, cropSize, aspect, zoom, rotation = 0, allowOverflow = false) {
185
+ const cacheKey = `${quantizePosition(crop.x)}-${quantizePosition(crop.y)}-${quantize(mediaSize.width)}-${quantize(mediaSize.height)}-${quantize(mediaSize.naturalWidth)}-${quantize(mediaSize.naturalHeight)}-${quantize(cropSize.width)}-${quantize(cropSize.height)}-${quantize(aspect, 0.01)}-${quantizeZoom(zoom)}-${quantizeRotation(rotation)}-${allowOverflow}`;
186
+ const cached = lruGet(croppedAreaCache, cacheKey);
187
+ if (cached) return cached;
188
+ const onAreaLimit = !allowOverflow ? (max, value) => Math.min(max, Math.max(0, value)) : (_max, value) => value;
189
+ const mediaBBoxSize = rotateSize(mediaSize.width, mediaSize.height, rotation);
190
+ const mediaNaturalBBoxSize = rotateSize(
191
+ mediaSize.naturalWidth,
192
+ mediaSize.naturalHeight,
193
+ rotation
194
+ );
195
+ const croppedAreaPercentages = {
196
+ x: onAreaLimit(
197
+ 100,
198
+ ((mediaBBoxSize.width - cropSize.width / zoom) / 2 - crop.x / zoom) / mediaBBoxSize.width * 100
199
+ ),
200
+ y: onAreaLimit(
201
+ 100,
202
+ ((mediaBBoxSize.height - cropSize.height / zoom) / 2 - crop.y / zoom) / mediaBBoxSize.height * 100
203
+ ),
204
+ width: onAreaLimit(
205
+ 100,
206
+ cropSize.width / mediaBBoxSize.width * 100 / zoom
207
+ ),
208
+ height: onAreaLimit(
209
+ 100,
210
+ cropSize.height / mediaBBoxSize.height * 100 / zoom
211
+ )
212
+ };
213
+ const widthInPixels = Math.round(
214
+ onAreaLimit(
215
+ mediaNaturalBBoxSize.width,
216
+ croppedAreaPercentages.width * mediaNaturalBBoxSize.width / 100
217
+ )
218
+ );
219
+ const heightInPixels = Math.round(
220
+ onAreaLimit(
221
+ mediaNaturalBBoxSize.height,
222
+ croppedAreaPercentages.height * mediaNaturalBBoxSize.height / 100
223
+ )
224
+ );
225
+ const isImageWiderThanHigh = mediaNaturalBBoxSize.width >= mediaNaturalBBoxSize.height * aspect;
226
+ const sizePixels = isImageWiderThanHigh ? {
227
+ width: Math.round(heightInPixels * aspect),
228
+ height: heightInPixels
229
+ } : {
230
+ width: widthInPixels,
231
+ height: Math.round(widthInPixels / aspect)
232
+ };
233
+ const croppedAreaPixels = {
234
+ ...sizePixels,
235
+ x: Math.round(
236
+ onAreaLimit(
237
+ mediaNaturalBBoxSize.width - sizePixels.width,
238
+ croppedAreaPercentages.x * mediaNaturalBBoxSize.width / 100
239
+ )
240
+ ),
241
+ y: Math.round(
242
+ onAreaLimit(
243
+ mediaNaturalBBoxSize.height - sizePixels.height,
244
+ croppedAreaPercentages.y * mediaNaturalBBoxSize.height / 100
245
+ )
246
+ )
247
+ };
248
+ const result = { croppedAreaPercentages, croppedAreaPixels };
249
+ lruSet(croppedAreaCache, cacheKey, result, MAX_CACHE_SIZE);
250
+ return result;
251
+ }
252
+ var StoreContext = React5.createContext(null);
253
+ function useStoreContext(consumerName) {
254
+ const context = React5.useContext(StoreContext);
255
+ if (!context) {
256
+ throw new Error(`\`${consumerName}\` must be used within \`${ROOT_NAME}\``);
257
+ }
258
+ return context;
259
+ }
260
+ function useStore(selector) {
261
+ const store = useStoreContext("useStore");
262
+ const getSnapshot = React5.useCallback(
263
+ () => selector(store.getState()),
264
+ [store, selector]
265
+ );
266
+ return React5.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
267
+ }
268
+ var CropperContext = React5.createContext(null);
269
+ function useCropperContext(consumerName) {
270
+ const context = React5.useContext(CropperContext);
271
+ if (!context) {
272
+ throw new Error(`\`${consumerName}\` must be used within \`${ROOT_NAME}\``);
273
+ }
274
+ return context;
275
+ }
276
+ function Cropper(props) {
277
+ const {
278
+ crop = { x: 0, y: 0 },
279
+ zoom = 1,
280
+ minZoom = 1,
281
+ maxZoom = 3,
282
+ zoomSpeed = 1,
283
+ rotation = 0,
284
+ keyboardStep = 1,
285
+ aspectRatio = 4 / 3,
286
+ shape = "rectangle",
287
+ objectFit = "contain",
288
+ allowOverflow = false,
289
+ preventScrollZoom = false,
290
+ withGrid = false,
291
+ onCropChange,
292
+ onCropSizeChange,
293
+ onCropAreaChange,
294
+ onCropComplete,
295
+ onZoomChange,
296
+ onRotationChange,
297
+ onMediaLoaded,
298
+ onInteractionStart,
299
+ onInteractionEnd,
300
+ className,
301
+ ...rootProps
302
+ } = props;
303
+ const listenersRef = useLazyRef(() => /* @__PURE__ */ new Set());
304
+ const stateRef = useLazyRef(() => ({
305
+ crop,
306
+ zoom,
307
+ rotation,
308
+ mediaSize: null,
309
+ cropSize: null,
310
+ isDragging: false,
311
+ isWheelZooming: false
312
+ }));
313
+ const propsRef = useAsRef({
314
+ onCropChange,
315
+ onCropSizeChange,
316
+ onCropAreaChange,
317
+ onCropComplete,
318
+ onZoomChange,
319
+ onRotationChange,
320
+ onMediaLoaded,
321
+ onInteractionStart,
322
+ onInteractionEnd
323
+ });
324
+ const rootRef = React5.useRef(null);
325
+ const store = React5.useMemo(() => {
326
+ let isBatching = false;
327
+ let raf = null;
328
+ function notifyCropAreaChange() {
329
+ if (raf != null) return;
330
+ raf = requestAnimationFrame(() => {
331
+ raf = null;
332
+ const s = stateRef.current;
333
+ if (s?.mediaSize && s.cropSize && propsRef.current.onCropAreaChange) {
334
+ const { croppedAreaPercentages, croppedAreaPixels } = getCroppedArea(
335
+ s.crop,
336
+ s.mediaSize,
337
+ s.cropSize,
338
+ aspectRatio,
339
+ s.zoom,
340
+ s.rotation
341
+ );
342
+ propsRef.current.onCropAreaChange(
343
+ croppedAreaPercentages,
344
+ croppedAreaPixels
345
+ );
346
+ }
347
+ });
348
+ }
349
+ return {
350
+ subscribe: (cb) => {
351
+ listenersRef.current.add(cb);
352
+ return () => listenersRef.current.delete(cb);
353
+ },
354
+ getState: () => stateRef.current,
355
+ setState: (key, value) => {
356
+ if (Object.is(stateRef.current[key], value)) return;
357
+ stateRef.current[key] = value;
358
+ if (key === "crop" && typeof value === "object" && value && "x" in value) {
359
+ propsRef.current.onCropChange?.(value);
360
+ } else if (key === "zoom" && typeof value === "number") {
361
+ propsRef.current.onZoomChange?.(value);
362
+ } else if (key === "rotation" && typeof value === "number") {
363
+ propsRef.current.onRotationChange?.(value);
364
+ } else if (key === "cropSize" && typeof value === "object" && value && "width" in value) {
365
+ propsRef.current.onCropSizeChange?.(value);
366
+ } else if (key === "mediaSize" && typeof value === "object" && value && "naturalWidth" in value) {
367
+ propsRef.current.onMediaLoaded?.(value);
368
+ } else if (key === "isDragging") {
369
+ if (value) {
370
+ propsRef.current.onInteractionStart?.();
371
+ } else {
372
+ propsRef.current.onInteractionEnd?.();
373
+ const currentState = stateRef.current;
374
+ if (currentState?.mediaSize && currentState.cropSize && propsRef.current.onCropComplete) {
375
+ const { croppedAreaPercentages, croppedAreaPixels } = getCroppedArea(
376
+ currentState.crop,
377
+ currentState.mediaSize,
378
+ currentState.cropSize,
379
+ aspectRatio,
380
+ currentState.zoom,
381
+ currentState.rotation
382
+ );
383
+ propsRef.current.onCropComplete(
384
+ croppedAreaPercentages,
385
+ croppedAreaPixels
386
+ );
387
+ }
388
+ }
389
+ }
390
+ if ((key === "crop" || key === "zoom" || key === "rotation" || key === "mediaSize" || key === "cropSize") && propsRef.current.onCropAreaChange) {
391
+ notifyCropAreaChange();
392
+ }
393
+ if (!isBatching) {
394
+ store.notify();
395
+ }
396
+ },
397
+ notify: () => {
398
+ for (const cb of listenersRef.current) {
399
+ cb();
400
+ }
401
+ },
402
+ batch: (fn) => {
403
+ if (isBatching) {
404
+ fn();
405
+ return;
406
+ }
407
+ isBatching = true;
408
+ try {
409
+ fn();
410
+ } finally {
411
+ isBatching = false;
412
+ store.notify();
413
+ }
414
+ }
415
+ };
416
+ }, [listenersRef, stateRef, propsRef, aspectRatio]);
417
+ useIsomorphicLayoutEffect(() => {
418
+ const updates = {};
419
+ let hasUpdates = false;
420
+ let shouldRecompute = false;
421
+ if (crop !== void 0) {
422
+ const currentState = store.getState();
423
+ if (!Object.is(currentState.crop, crop)) {
424
+ updates.crop = crop;
425
+ hasUpdates = true;
426
+ }
427
+ }
428
+ if (zoom !== void 0) {
429
+ const currentState = store.getState();
430
+ if (currentState.zoom !== zoom) {
431
+ updates.zoom = zoom;
432
+ hasUpdates = true;
433
+ shouldRecompute = true;
434
+ }
435
+ }
436
+ if (rotation !== void 0) {
437
+ const currentState = store.getState();
438
+ if (currentState.rotation !== rotation) {
439
+ updates.rotation = rotation;
440
+ hasUpdates = true;
441
+ shouldRecompute = true;
442
+ }
443
+ }
444
+ if (hasUpdates) {
445
+ store.batch(() => {
446
+ Object.entries(updates).forEach(([key, value]) => {
447
+ store.setState(key, value);
448
+ });
449
+ });
450
+ if (shouldRecompute && rootRef.current) {
451
+ requestAnimationFrame(() => {
452
+ const currentState = store.getState();
453
+ if (currentState.cropSize && currentState.mediaSize) {
454
+ const newPosition = !allowOverflow ? onPositionClamp(
455
+ currentState.crop,
456
+ currentState.mediaSize,
457
+ currentState.cropSize,
458
+ currentState.zoom,
459
+ currentState.rotation
460
+ ) : currentState.crop;
461
+ if (Math.abs(newPosition.x - currentState.crop.x) > 1e-3 || Math.abs(newPosition.y - currentState.crop.y) > 1e-3) {
462
+ store.setState("crop", newPosition);
463
+ }
464
+ }
465
+ });
466
+ }
467
+ }
468
+ }, [crop, zoom, rotation, store, allowOverflow]);
469
+ const contextValue = React5.useMemo(
470
+ () => ({
471
+ minZoom,
472
+ maxZoom,
473
+ zoomSpeed,
474
+ keyboardStep,
475
+ aspectRatio,
476
+ shape,
477
+ objectFit,
478
+ preventScrollZoom,
479
+ allowOverflow,
480
+ withGrid,
481
+ rootRef
482
+ }),
483
+ [
484
+ minZoom,
485
+ maxZoom,
486
+ zoomSpeed,
487
+ keyboardStep,
488
+ aspectRatio,
489
+ shape,
490
+ objectFit,
491
+ preventScrollZoom,
492
+ allowOverflow,
493
+ withGrid
494
+ ]
495
+ );
496
+ return /* @__PURE__ */ jsx(StoreContext.Provider, { value: store, children: /* @__PURE__ */ jsx(CropperContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
497
+ "div",
498
+ {
499
+ "data-slot": "cropper-wrapper",
500
+ className: cn("relative size-full overflow-hidden", className),
501
+ children: /* @__PURE__ */ jsx(CropperImpl, { ...rootProps })
502
+ }
503
+ ) }) });
504
+ }
505
+ function CropperImpl(props) {
506
+ const {
507
+ onWheelZoom: onWheelZoomProp,
508
+ onKeyUp: onKeyUpProp,
509
+ onKeyDown: onKeyDownProp,
510
+ onMouseDown: onMouseDownProp,
511
+ onTouchStart: onTouchStartProp,
512
+ asChild,
513
+ className,
514
+ ref,
515
+ ...rootImplProps
516
+ } = props;
517
+ const context = useCropperContext(ROOT_IMPL_NAME);
518
+ const store = useStoreContext(ROOT_IMPL_NAME);
519
+ const crop = useStore((state) => state.crop);
520
+ const zoom = useStore((state) => state.zoom);
521
+ const rotation = useStore((state) => state.rotation);
522
+ const mediaSize = useStore((state) => state.mediaSize);
523
+ const cropSize = useStore((state) => state.cropSize);
524
+ const propsRef = useAsRef({
525
+ onWheelZoom: onWheelZoomProp,
526
+ onKeyUp: onKeyUpProp,
527
+ onKeyDown: onKeyDownProp,
528
+ onMouseDown: onMouseDownProp,
529
+ onTouchStart: onTouchStartProp
530
+ });
531
+ const composedRef = useComposedRefs(ref, context.rootRef);
532
+ const dragStartPositionRef = React5.useRef({ x: 0, y: 0 });
533
+ const dragStartCropRef = React5.useRef({ x: 0, y: 0 });
534
+ const contentPositionRef = React5.useRef({ x: 0, y: 0 });
535
+ const lastPinchDistanceRef = React5.useRef(0);
536
+ const lastPinchRotationRef = React5.useRef(0);
537
+ const rafDragTimeoutRef = React5.useRef(null);
538
+ const rafPinchTimeoutRef = React5.useRef(null);
539
+ const wheelTimerRef = React5.useRef(null);
540
+ const isTouchingRef = React5.useRef(false);
541
+ const gestureZoomStartRef = React5.useRef(0);
542
+ const gestureRotationStartRef = React5.useRef(0);
543
+ const onRefsCleanup = React5.useCallback(() => {
544
+ if (rafDragTimeoutRef.current) {
545
+ cancelAnimationFrame(rafDragTimeoutRef.current);
546
+ rafDragTimeoutRef.current = null;
547
+ }
548
+ if (rafPinchTimeoutRef.current) {
549
+ cancelAnimationFrame(rafPinchTimeoutRef.current);
550
+ rafPinchTimeoutRef.current = null;
551
+ }
552
+ if (wheelTimerRef.current) {
553
+ clearTimeout(wheelTimerRef.current);
554
+ wheelTimerRef.current = null;
555
+ }
556
+ isTouchingRef.current = false;
557
+ }, []);
558
+ const onCacheCleanup = React5.useCallback(() => {
559
+ if (onPositionClampCache.size > MAX_CACHE_SIZE * 1.5) {
560
+ onPositionClampCache.clear();
561
+ }
562
+ if (croppedAreaCache.size > MAX_CACHE_SIZE * 1.5) {
563
+ croppedAreaCache.clear();
564
+ }
565
+ }, []);
566
+ const getMousePoint = React5.useCallback(
567
+ (event) => ({
568
+ x: Number(event.clientX),
569
+ y: Number(event.clientY)
570
+ }),
571
+ []
572
+ );
573
+ const getTouchPoint = React5.useCallback(
574
+ (touch) => ({
575
+ x: Number(touch.clientX),
576
+ y: Number(touch.clientY)
577
+ }),
578
+ []
579
+ );
580
+ const onContentPositionChange = React5.useCallback(() => {
581
+ if (context.rootRef?.current) {
582
+ const bounds = context.rootRef.current.getBoundingClientRect();
583
+ contentPositionRef.current = { x: bounds.left, y: bounds.top };
584
+ }
585
+ }, [context.rootRef]);
586
+ const getPointOnContent = React5.useCallback(
587
+ ({ x, y }, contentTopLeft) => {
588
+ if (!context.rootRef?.current) {
589
+ return { x: 0, y: 0 };
590
+ }
591
+ const contentRect = context.rootRef.current.getBoundingClientRect();
592
+ return {
593
+ x: contentRect.width / 2 - (x - contentTopLeft.x),
594
+ y: contentRect.height / 2 - (y - contentTopLeft.y)
595
+ };
596
+ },
597
+ [context.rootRef]
598
+ );
599
+ const getPointOnMedia = React5.useCallback(
600
+ ({ x, y }) => {
601
+ return {
602
+ x: (x + crop.x) / zoom,
603
+ y: (y + crop.y) / zoom
604
+ };
605
+ },
606
+ [crop, zoom]
607
+ );
608
+ const recomputeCropPosition = React5.useCallback(() => {
609
+ if (!cropSize || !mediaSize) return;
610
+ const newPosition = !context.allowOverflow ? onPositionClamp(crop, mediaSize, cropSize, zoom, rotation) : crop;
611
+ if (Math.abs(newPosition.x - crop.x) > 1e-3 || Math.abs(newPosition.y - crop.y) > 1e-3) {
612
+ store.setState("crop", newPosition);
613
+ }
614
+ }, [cropSize, mediaSize, context.allowOverflow, crop, zoom, rotation, store]);
615
+ const onZoomChange = React5.useCallback(
616
+ (newZoom, point, shouldUpdatePosition = true) => {
617
+ if (!cropSize || !mediaSize) return;
618
+ const clampedZoom = clamp(newZoom, context.minZoom, context.maxZoom);
619
+ store.batch(() => {
620
+ if (shouldUpdatePosition) {
621
+ const zoomPoint = getPointOnContent(
622
+ point,
623
+ contentPositionRef.current
624
+ );
625
+ const zoomTarget = getPointOnMedia(zoomPoint);
626
+ const requestedPosition = {
627
+ x: zoomTarget.x * clampedZoom - zoomPoint.x,
628
+ y: zoomTarget.y * clampedZoom - zoomPoint.y
629
+ };
630
+ const newPosition = !context.allowOverflow ? onPositionClamp(
631
+ requestedPosition,
632
+ mediaSize,
633
+ cropSize,
634
+ clampedZoom,
635
+ rotation
636
+ ) : requestedPosition;
637
+ store.setState("crop", newPosition);
638
+ }
639
+ store.setState("zoom", clampedZoom);
640
+ });
641
+ requestAnimationFrame(() => {
642
+ recomputeCropPosition();
643
+ });
644
+ },
645
+ [
646
+ cropSize,
647
+ mediaSize,
648
+ context.minZoom,
649
+ context.maxZoom,
650
+ context.allowOverflow,
651
+ getPointOnContent,
652
+ getPointOnMedia,
653
+ rotation,
654
+ store,
655
+ recomputeCropPosition
656
+ ]
657
+ );
658
+ const onDragStart = React5.useCallback(
659
+ ({ x, y }) => {
660
+ dragStartPositionRef.current = { x, y };
661
+ dragStartCropRef.current = { ...crop };
662
+ store.setState("isDragging", true);
663
+ },
664
+ [crop, store]
665
+ );
666
+ const onDrag = React5.useCallback(
667
+ ({ x, y }) => {
668
+ if (rafDragTimeoutRef.current) {
669
+ cancelAnimationFrame(rafDragTimeoutRef.current);
670
+ }
671
+ rafDragTimeoutRef.current = requestAnimationFrame(() => {
672
+ if (!cropSize || !mediaSize) return;
673
+ if (x === void 0 || y === void 0) return;
674
+ const offsetX = x - dragStartPositionRef.current.x;
675
+ const offsetY = y - dragStartPositionRef.current.y;
676
+ if (Math.abs(offsetX) < 2 && Math.abs(offsetY) < 2) {
677
+ return;
678
+ }
679
+ const requestedPosition = {
680
+ x: dragStartCropRef.current.x + offsetX,
681
+ y: dragStartCropRef.current.y + offsetY
682
+ };
683
+ const newPosition = !context.allowOverflow ? onPositionClamp(
684
+ requestedPosition,
685
+ mediaSize,
686
+ cropSize,
687
+ zoom,
688
+ rotation
689
+ ) : requestedPosition;
690
+ const currentCrop = store.getState().crop;
691
+ if (Math.abs(newPosition.x - currentCrop.x) > 1 || Math.abs(newPosition.y - currentCrop.y) > 1) {
692
+ store.setState("crop", newPosition);
693
+ }
694
+ });
695
+ },
696
+ [cropSize, mediaSize, context.allowOverflow, zoom, rotation, store]
697
+ );
698
+ const onMouseMove = React5.useCallback(
699
+ (event) => onDrag(getMousePoint(event)),
700
+ [getMousePoint, onDrag]
701
+ );
702
+ const onTouchMove = React5.useCallback(
703
+ (event) => {
704
+ event.preventDefault();
705
+ if (event.touches.length === 2) {
706
+ const [firstTouch, secondTouch] = event.touches ?? [];
707
+ if (firstTouch && secondTouch) {
708
+ const pointA = getTouchPoint(firstTouch);
709
+ const pointB = getTouchPoint(secondTouch);
710
+ const center = getCenter(pointA, pointB);
711
+ onDrag(center);
712
+ if (rafPinchTimeoutRef.current) {
713
+ cancelAnimationFrame(rafPinchTimeoutRef.current);
714
+ }
715
+ rafPinchTimeoutRef.current = requestAnimationFrame(() => {
716
+ const distance = getDistanceBetweenPoints(pointA, pointB);
717
+ const distanceRatio = distance / lastPinchDistanceRef.current;
718
+ if (Math.abs(distanceRatio - 1) > 0.01) {
719
+ const newZoom = zoom * distanceRatio;
720
+ onZoomChange(newZoom, center, false);
721
+ lastPinchDistanceRef.current = distance;
722
+ }
723
+ const rotationAngle = getRotationBetweenPoints(pointA, pointB);
724
+ const rotationDiff = rotationAngle - lastPinchRotationRef.current;
725
+ if (Math.abs(rotationDiff) > 0.5) {
726
+ const newRotation = rotation + rotationDiff;
727
+ store.setState("rotation", newRotation);
728
+ lastPinchRotationRef.current = rotationAngle;
729
+ }
730
+ });
731
+ }
732
+ } else if (event.touches.length === 1) {
733
+ const firstTouch = event.touches[0];
734
+ if (firstTouch) {
735
+ onDrag(getTouchPoint(firstTouch));
736
+ }
737
+ }
738
+ },
739
+ [getTouchPoint, onDrag, zoom, onZoomChange, rotation, store]
740
+ );
741
+ const onGestureChange = React5.useCallback(
742
+ (event) => {
743
+ event.preventDefault();
744
+ if (isTouchingRef.current) {
745
+ return;
746
+ }
747
+ const point = { x: Number(event.clientX), y: Number(event.clientY) };
748
+ const newZoom = gestureZoomStartRef.current - 1 + event.scale;
749
+ onZoomChange(newZoom, point, true);
750
+ const newRotation = gestureRotationStartRef.current + event.rotation;
751
+ store.setState("rotation", newRotation);
752
+ },
753
+ [onZoomChange, store]
754
+ );
755
+ const onGestureEnd = React5.useCallback(() => {
756
+ document.removeEventListener(
757
+ "gesturechange",
758
+ onGestureChange
759
+ );
760
+ document.removeEventListener("gestureend", onGestureEnd);
761
+ }, [onGestureChange]);
762
+ const onGestureStart = React5.useCallback(
763
+ (event) => {
764
+ event.preventDefault();
765
+ document.addEventListener(
766
+ "gesturechange",
767
+ onGestureChange
768
+ );
769
+ document.addEventListener("gestureend", onGestureEnd);
770
+ gestureZoomStartRef.current = zoom;
771
+ gestureRotationStartRef.current = rotation;
772
+ },
773
+ [zoom, rotation, onGestureChange, onGestureEnd]
774
+ );
775
+ const onSafariZoomPrevent = React5.useCallback(
776
+ (event) => event.preventDefault(),
777
+ []
778
+ );
779
+ const onEventsCleanup = React5.useCallback(() => {
780
+ document.removeEventListener("mousemove", onMouseMove);
781
+ document.removeEventListener("touchmove", onTouchMove);
782
+ document.removeEventListener(
783
+ "gesturechange",
784
+ onGestureChange
785
+ );
786
+ document.removeEventListener("gestureend", onGestureEnd);
787
+ }, [onMouseMove, onTouchMove, onGestureChange, onGestureEnd]);
788
+ const onDragStopped = React5.useCallback(() => {
789
+ isTouchingRef.current = false;
790
+ store.setState("isDragging", false);
791
+ onRefsCleanup();
792
+ document.removeEventListener("mouseup", onDragStopped);
793
+ document.removeEventListener("touchend", onDragStopped);
794
+ onEventsCleanup();
795
+ }, [store, onEventsCleanup, onRefsCleanup]);
796
+ const getWheelDelta = React5.useCallback((event) => {
797
+ let deltaX = event.deltaX;
798
+ let deltaY = event.deltaY;
799
+ let deltaZ = event.deltaZ;
800
+ if (event.deltaMode === 1) {
801
+ deltaX *= 16;
802
+ deltaY *= 16;
803
+ deltaZ *= 16;
804
+ } else if (event.deltaMode === 2) {
805
+ deltaX *= 400;
806
+ deltaY *= 400;
807
+ deltaZ *= 400;
808
+ }
809
+ return { deltaX, deltaY, deltaZ };
810
+ }, []);
811
+ const onWheelZoom = React5.useCallback(
812
+ (event) => {
813
+ propsRef.current.onWheelZoom?.(event);
814
+ if (event.defaultPrevented) return;
815
+ event.preventDefault();
816
+ const point = getMousePoint(event);
817
+ const { deltaY } = getWheelDelta(event);
818
+ const newZoom = zoom - deltaY * context.zoomSpeed / 200;
819
+ onZoomChange(newZoom, point, true);
820
+ store.batch(() => {
821
+ const currentState = store.getState();
822
+ if (!currentState.isWheelZooming) {
823
+ store.setState("isWheelZooming", true);
824
+ }
825
+ if (!currentState.isDragging) {
826
+ store.setState("isDragging", true);
827
+ }
828
+ });
829
+ if (wheelTimerRef.current) {
830
+ clearTimeout(wheelTimerRef.current);
831
+ }
832
+ wheelTimerRef.current = window.setTimeout(() => {
833
+ store.batch(() => {
834
+ store.setState("isWheelZooming", false);
835
+ store.setState("isDragging", false);
836
+ });
837
+ }, 250);
838
+ },
839
+ [
840
+ propsRef,
841
+ getMousePoint,
842
+ zoom,
843
+ context.zoomSpeed,
844
+ onZoomChange,
845
+ getWheelDelta,
846
+ store
847
+ ]
848
+ );
849
+ const onKeyUp = React5.useCallback(
850
+ (event) => {
851
+ propsRef.current.onKeyUp?.(event);
852
+ if (event.defaultPrevented) return;
853
+ const arrowKeys = /* @__PURE__ */ new Set([
854
+ "ArrowUp",
855
+ "ArrowDown",
856
+ "ArrowLeft",
857
+ "ArrowRight"
858
+ ]);
859
+ if (arrowKeys.has(event.key)) {
860
+ event.preventDefault();
861
+ store.setState("isDragging", false);
862
+ }
863
+ },
864
+ [propsRef, store]
865
+ );
866
+ const onKeyDown = React5.useCallback(
867
+ (event) => {
868
+ propsRef.current.onKeyDown?.(event);
869
+ if (event.defaultPrevented || !cropSize || !mediaSize) return;
870
+ let step = context.keyboardStep;
871
+ if (event.shiftKey) {
872
+ step *= 0.2;
873
+ }
874
+ const keyCallbacks = {
875
+ ArrowUp: () => ({ ...crop, y: crop.y - step }),
876
+ ArrowDown: () => ({ ...crop, y: crop.y + step }),
877
+ ArrowLeft: () => ({ ...crop, x: crop.x - step }),
878
+ ArrowRight: () => ({ ...crop, x: crop.x + step })
879
+ };
880
+ const callback = keyCallbacks[event.key];
881
+ if (!callback) return;
882
+ event.preventDefault();
883
+ let newCrop = callback();
884
+ if (!context.allowOverflow) {
885
+ newCrop = onPositionClamp(newCrop, mediaSize, cropSize, zoom, rotation);
886
+ }
887
+ if (!event.repeat) {
888
+ store.setState("isDragging", true);
889
+ }
890
+ store.setState("crop", newCrop);
891
+ },
892
+ [
893
+ propsRef,
894
+ cropSize,
895
+ mediaSize,
896
+ context.keyboardStep,
897
+ context.allowOverflow,
898
+ crop,
899
+ zoom,
900
+ rotation,
901
+ store
902
+ ]
903
+ );
904
+ const onMouseDown = React5.useCallback(
905
+ (event) => {
906
+ propsRef.current.onMouseDown?.(event);
907
+ if (event.defaultPrevented) return;
908
+ event.preventDefault();
909
+ document.addEventListener("mousemove", onMouseMove);
910
+ document.addEventListener("mouseup", onDragStopped);
911
+ onContentPositionChange();
912
+ onDragStart(getMousePoint(event));
913
+ },
914
+ [
915
+ propsRef,
916
+ getMousePoint,
917
+ onDragStart,
918
+ onDragStopped,
919
+ onMouseMove,
920
+ onContentPositionChange
921
+ ]
922
+ );
923
+ const onTouchStart = React5.useCallback(
924
+ (event) => {
925
+ propsRef.current.onTouchStart?.(event);
926
+ if (event.defaultPrevented) return;
927
+ isTouchingRef.current = true;
928
+ document.addEventListener("touchmove", onTouchMove, { passive: false });
929
+ document.addEventListener("touchend", onDragStopped);
930
+ onContentPositionChange();
931
+ if (event.touches.length === 2) {
932
+ const [firstTouch, secondTouch] = event.touches ? Array.from(event.touches) : [];
933
+ if (firstTouch && secondTouch) {
934
+ const pointA = getTouchPoint(firstTouch);
935
+ const pointB = getTouchPoint(secondTouch);
936
+ lastPinchDistanceRef.current = getDistanceBetweenPoints(
937
+ pointA,
938
+ pointB
939
+ );
940
+ lastPinchRotationRef.current = getRotationBetweenPoints(
941
+ pointA,
942
+ pointB
943
+ );
944
+ onDragStart(getCenter(pointA, pointB));
945
+ }
946
+ } else if (event.touches.length === 1) {
947
+ const firstTouch = event.touches[0];
948
+ if (firstTouch) {
949
+ onDragStart(getTouchPoint(firstTouch));
950
+ }
951
+ }
952
+ },
953
+ [
954
+ propsRef,
955
+ onDragStopped,
956
+ onTouchMove,
957
+ onContentPositionChange,
958
+ getTouchPoint,
959
+ onDragStart
960
+ ]
961
+ );
962
+ React5.useEffect(() => {
963
+ const content = context.rootRef?.current;
964
+ if (!content) return;
965
+ if (!context.preventScrollZoom) {
966
+ content.addEventListener("wheel", onWheelZoom, { passive: false });
967
+ }
968
+ content.addEventListener("gesturestart", onSafariZoomPrevent);
969
+ content.addEventListener("gesturestart", onGestureStart);
970
+ return () => {
971
+ if (!context.preventScrollZoom) {
972
+ content.removeEventListener("wheel", onWheelZoom);
973
+ }
974
+ content.removeEventListener("gesturestart", onSafariZoomPrevent);
975
+ content.removeEventListener(
976
+ "gesturestart",
977
+ onGestureStart
978
+ );
979
+ onRefsCleanup();
980
+ };
981
+ }, [
982
+ context.rootRef,
983
+ context.preventScrollZoom,
984
+ onWheelZoom,
985
+ onRefsCleanup,
986
+ onSafariZoomPrevent,
987
+ onGestureStart
988
+ ]);
989
+ React5.useEffect(() => {
990
+ return () => {
991
+ onRefsCleanup();
992
+ onCacheCleanup();
993
+ };
994
+ }, [onRefsCleanup, onCacheCleanup]);
995
+ const RootPrimitive = asChild ? Slot : "div";
996
+ return /* @__PURE__ */ jsx(
997
+ RootPrimitive,
998
+ {
999
+ "data-slot": "cropper",
1000
+ tabIndex: 0,
1001
+ ...rootImplProps,
1002
+ ref: composedRef,
1003
+ className: cn(
1004
+ "absolute inset-0 flex cursor-move touch-none select-none items-center justify-center overflow-hidden outline-none",
1005
+ className
1006
+ ),
1007
+ onKeyUp,
1008
+ onKeyDown,
1009
+ onMouseDown,
1010
+ onTouchStart
1011
+ }
1012
+ );
1013
+ }
1014
+ var cropperMediaVariants = cva("will-change-transform", {
1015
+ variants: {
1016
+ objectFit: {
1017
+ contain: "absolute inset-0 m-auto max-h-full max-w-full",
1018
+ cover: "h-auto w-full",
1019
+ "horizontal-cover": "h-auto w-full",
1020
+ "vertical-cover": "h-full w-auto"
1021
+ }
1022
+ },
1023
+ defaultVariants: {
1024
+ objectFit: "contain"
1025
+ }
1026
+ });
1027
+ function useMediaComputation({
1028
+ mediaRef,
1029
+ context,
1030
+ store,
1031
+ rotation,
1032
+ getNaturalDimensions
1033
+ }) {
1034
+ const computeSizes = React5.useCallback(() => {
1035
+ const media = mediaRef.current;
1036
+ const content = context.rootRef?.current;
1037
+ if (!media || !content) return;
1038
+ const contentRect = content.getBoundingClientRect();
1039
+ const containerAspect = contentRect.width / contentRect.height;
1040
+ const { width: naturalWidth, height: naturalHeight } = getNaturalDimensions(media);
1041
+ const isScaledDown = media.offsetWidth < naturalWidth || media.offsetHeight < naturalHeight;
1042
+ const mediaAspect = naturalWidth / naturalHeight;
1043
+ let renderedMediaSize;
1044
+ if (isScaledDown) {
1045
+ const objectFitCallbacks = {
1046
+ contain: () => containerAspect > mediaAspect ? {
1047
+ width: contentRect.height * mediaAspect,
1048
+ height: contentRect.height
1049
+ } : {
1050
+ width: contentRect.width,
1051
+ height: contentRect.width / mediaAspect
1052
+ },
1053
+ "horizontal-cover": () => ({
1054
+ width: contentRect.width,
1055
+ height: contentRect.width / mediaAspect
1056
+ }),
1057
+ "vertical-cover": () => ({
1058
+ width: contentRect.height * mediaAspect,
1059
+ height: contentRect.height
1060
+ }),
1061
+ cover: () => containerAspect < mediaAspect ? {
1062
+ width: contentRect.width,
1063
+ height: contentRect.width / mediaAspect
1064
+ } : {
1065
+ width: contentRect.height * mediaAspect,
1066
+ height: contentRect.height
1067
+ }
1068
+ };
1069
+ const callback = objectFitCallbacks[context.objectFit];
1070
+ renderedMediaSize = callback ? callback() : containerAspect > mediaAspect ? {
1071
+ width: contentRect.height * mediaAspect,
1072
+ height: contentRect.height
1073
+ } : {
1074
+ width: contentRect.width,
1075
+ height: contentRect.width / mediaAspect
1076
+ };
1077
+ } else {
1078
+ renderedMediaSize = {
1079
+ width: media.offsetWidth,
1080
+ height: media.offsetHeight
1081
+ };
1082
+ }
1083
+ const mediaSize = {
1084
+ ...renderedMediaSize,
1085
+ naturalWidth,
1086
+ naturalHeight
1087
+ };
1088
+ store.setState("mediaSize", mediaSize);
1089
+ const cropSize = getCropSize(
1090
+ mediaSize.width,
1091
+ mediaSize.height,
1092
+ contentRect.width,
1093
+ contentRect.height,
1094
+ context.aspectRatio,
1095
+ rotation
1096
+ );
1097
+ store.setState("cropSize", cropSize);
1098
+ requestAnimationFrame(() => {
1099
+ const currentState = store.getState();
1100
+ if (currentState.cropSize && currentState.mediaSize) {
1101
+ const newPosition = onPositionClamp(
1102
+ currentState.crop,
1103
+ currentState.mediaSize,
1104
+ currentState.cropSize,
1105
+ currentState.zoom,
1106
+ currentState.rotation
1107
+ );
1108
+ if (Math.abs(newPosition.x - currentState.crop.x) > 1e-3 || Math.abs(newPosition.y - currentState.crop.y) > 1e-3) {
1109
+ store.setState("crop", newPosition);
1110
+ }
1111
+ }
1112
+ });
1113
+ return { mediaSize, cropSize };
1114
+ }, [
1115
+ mediaRef,
1116
+ context.aspectRatio,
1117
+ context.rootRef,
1118
+ context.objectFit,
1119
+ store,
1120
+ rotation,
1121
+ getNaturalDimensions
1122
+ ]);
1123
+ return { computeSizes };
1124
+ }
1125
+ function CropperImage(props) {
1126
+ const {
1127
+ className,
1128
+ style,
1129
+ asChild,
1130
+ ref,
1131
+ onLoad,
1132
+ objectFit,
1133
+ snapPixels = false,
1134
+ ...imageProps
1135
+ } = props;
1136
+ const context = useCropperContext(IMAGE_NAME);
1137
+ const store = useStoreContext(IMAGE_NAME);
1138
+ const crop = useStore((state) => state.crop);
1139
+ const zoom = useStore((state) => state.zoom);
1140
+ const rotation = useStore((state) => state.rotation);
1141
+ const imageRef = React5.useRef(null);
1142
+ const composedRef = useComposedRefs(ref, imageRef);
1143
+ const getNaturalDimensions = React5.useCallback(
1144
+ (image) => ({
1145
+ width: image.naturalWidth,
1146
+ height: image.naturalHeight
1147
+ }),
1148
+ []
1149
+ );
1150
+ const { computeSizes } = useMediaComputation({
1151
+ mediaRef: imageRef,
1152
+ context,
1153
+ store,
1154
+ rotation,
1155
+ getNaturalDimensions
1156
+ });
1157
+ const onMediaLoad = React5.useCallback(() => {
1158
+ const image = imageRef.current;
1159
+ if (!image) return;
1160
+ computeSizes();
1161
+ onLoad?.(
1162
+ new Event("load")
1163
+ );
1164
+ }, [computeSizes, onLoad]);
1165
+ React5.useEffect(() => {
1166
+ const image = imageRef.current;
1167
+ if (image?.complete && image.naturalWidth > 0) {
1168
+ onMediaLoad();
1169
+ }
1170
+ }, [onMediaLoad]);
1171
+ React5.useEffect(() => {
1172
+ const content = context.rootRef?.current;
1173
+ if (!content) return;
1174
+ if (typeof ResizeObserver !== "undefined") {
1175
+ let isFirstResize = true;
1176
+ const resizeObserver = new ResizeObserver(() => {
1177
+ if (isFirstResize) {
1178
+ isFirstResize = false;
1179
+ return;
1180
+ }
1181
+ const callback = () => {
1182
+ const image = imageRef.current;
1183
+ if (image?.complete && image.naturalWidth > 0) {
1184
+ computeSizes();
1185
+ }
1186
+ };
1187
+ if ("requestIdleCallback" in window) {
1188
+ requestIdleCallback(callback);
1189
+ } else {
1190
+ setTimeout(callback, 16);
1191
+ }
1192
+ });
1193
+ resizeObserver.observe(content);
1194
+ return () => {
1195
+ resizeObserver.disconnect();
1196
+ };
1197
+ } else {
1198
+ const onWindowResize = () => {
1199
+ const image = imageRef.current;
1200
+ if (image?.complete && image.naturalWidth > 0) {
1201
+ computeSizes();
1202
+ }
1203
+ };
1204
+ window.addEventListener("resize", onWindowResize);
1205
+ return () => {
1206
+ window.removeEventListener("resize", onWindowResize);
1207
+ };
1208
+ }
1209
+ }, [context.rootRef, computeSizes]);
1210
+ const ImagePrimitive = asChild ? Slot : "img";
1211
+ return /* @__PURE__ */ jsx(
1212
+ ImagePrimitive,
1213
+ {
1214
+ "data-slot": "cropper-image",
1215
+ ...imageProps,
1216
+ ref: composedRef,
1217
+ className: cn(
1218
+ cropperMediaVariants({
1219
+ objectFit: objectFit ?? context.objectFit,
1220
+ className
1221
+ })
1222
+ ),
1223
+ style: {
1224
+ transform: snapPixels ? `translate(${snapToDevicePixel(crop.x)}px, ${snapToDevicePixel(crop.y)}px) rotate(${rotation}deg) scale(${zoom})` : `translate(${crop.x}px, ${crop.y}px) rotate(${rotation}deg) scale(${zoom})`,
1225
+ ...style
1226
+ },
1227
+ onLoad: onMediaLoad
1228
+ }
1229
+ );
1230
+ }
1231
+ function CropperVideo(props) {
1232
+ const {
1233
+ className,
1234
+ style,
1235
+ asChild,
1236
+ ref,
1237
+ onLoadedMetadata,
1238
+ objectFit,
1239
+ snapPixels = false,
1240
+ ...videoProps
1241
+ } = props;
1242
+ const context = useCropperContext(VIDEO_NAME);
1243
+ const store = useStoreContext(VIDEO_NAME);
1244
+ const crop = useStore((state) => state.crop);
1245
+ const zoom = useStore((state) => state.zoom);
1246
+ const rotation = useStore((state) => state.rotation);
1247
+ const videoRef = React5.useRef(null);
1248
+ const composedRef = useComposedRefs(ref, videoRef);
1249
+ const getNaturalDimensions = React5.useCallback(
1250
+ (video) => ({
1251
+ width: video.videoWidth,
1252
+ height: video.videoHeight
1253
+ }),
1254
+ []
1255
+ );
1256
+ const { computeSizes } = useMediaComputation({
1257
+ mediaRef: videoRef,
1258
+ context,
1259
+ store,
1260
+ rotation,
1261
+ getNaturalDimensions
1262
+ });
1263
+ const onMediaLoad = React5.useCallback(() => {
1264
+ const video = videoRef.current;
1265
+ if (!video) return;
1266
+ computeSizes();
1267
+ onLoadedMetadata?.(
1268
+ new Event(
1269
+ "loadedmetadata"
1270
+ )
1271
+ );
1272
+ }, [computeSizes, onLoadedMetadata]);
1273
+ React5.useEffect(() => {
1274
+ const content = context.rootRef?.current;
1275
+ if (!content) return;
1276
+ if (typeof ResizeObserver !== "undefined") {
1277
+ let isFirstResize = true;
1278
+ const resizeObserver = new ResizeObserver(() => {
1279
+ if (isFirstResize) {
1280
+ isFirstResize = false;
1281
+ return;
1282
+ }
1283
+ const callback = () => {
1284
+ const video = videoRef.current;
1285
+ if (video && video.videoWidth > 0 && video.videoHeight > 0) {
1286
+ computeSizes();
1287
+ }
1288
+ };
1289
+ if ("requestIdleCallback" in window) {
1290
+ requestIdleCallback(callback);
1291
+ } else {
1292
+ setTimeout(callback, 16);
1293
+ }
1294
+ });
1295
+ resizeObserver.observe(content);
1296
+ return () => {
1297
+ resizeObserver.disconnect();
1298
+ };
1299
+ } else {
1300
+ const onWindowResize = () => {
1301
+ const video = videoRef.current;
1302
+ if (video && video.videoWidth > 0 && video.videoHeight > 0) {
1303
+ computeSizes();
1304
+ }
1305
+ };
1306
+ window.addEventListener("resize", onWindowResize);
1307
+ return () => {
1308
+ window.removeEventListener("resize", onWindowResize);
1309
+ };
1310
+ }
1311
+ }, [context.rootRef, computeSizes]);
1312
+ const VideoPrimitive = asChild ? Slot : "video";
1313
+ return /* @__PURE__ */ jsx(
1314
+ VideoPrimitive,
1315
+ {
1316
+ "data-slot": "cropper-video",
1317
+ autoPlay: true,
1318
+ playsInline: true,
1319
+ loop: true,
1320
+ muted: true,
1321
+ controls: false,
1322
+ ...videoProps,
1323
+ ref: composedRef,
1324
+ className: cn(
1325
+ cropperMediaVariants({
1326
+ objectFit: objectFit ?? context.objectFit,
1327
+ className
1328
+ })
1329
+ ),
1330
+ style: {
1331
+ transform: snapPixels ? `translate(${snapToDevicePixel(crop.x)}px, ${snapToDevicePixel(crop.y)}px) rotate(${rotation}deg) scale(${zoom})` : `translate(${crop.x}px, ${crop.y}px) rotate(${rotation}deg) scale(${zoom})`,
1332
+ ...style
1333
+ },
1334
+ onLoadedMetadata: onMediaLoad
1335
+ }
1336
+ );
1337
+ }
1338
+ var cropperAreaVariants = cva(
1339
+ "absolute top-1/2 left-1/2 box-border -translate-x-1/2 -translate-y-1/2 overflow-hidden border border-[2.5px] border-white/90 shadow-[0_0_0_9999em_rgba(0,0,0,0.5)]",
1340
+ {
1341
+ variants: {
1342
+ shape: {
1343
+ rectangle: "",
1344
+ circle: "rounded-full"
1345
+ },
1346
+ withGrid: {
1347
+ true: "before:absolute before:top-0 before:right-1/3 before:bottom-0 before:left-1/3 before:box-border before:border before:border-white/50 before:border-t-0 before:border-b-0 before:content-[''] after:absolute after:top-1/3 after:right-0 after:bottom-1/3 after:left-0 after:box-border after:border after:border-white/50 after:border-r-0 after:border-l-0 after:content-['']",
1348
+ false: ""
1349
+ }
1350
+ },
1351
+ defaultVariants: {
1352
+ shape: "rectangle",
1353
+ withGrid: false
1354
+ }
1355
+ }
1356
+ );
1357
+ function CropperArea(props) {
1358
+ const {
1359
+ className,
1360
+ style,
1361
+ asChild,
1362
+ ref,
1363
+ snapPixels = false,
1364
+ shape,
1365
+ withGrid,
1366
+ ...areaProps
1367
+ } = props;
1368
+ const context = useCropperContext(AREA_NAME);
1369
+ const cropSize = useStore((state) => state.cropSize);
1370
+ if (!cropSize) return null;
1371
+ const AreaPrimitive = asChild ? Slot : "div";
1372
+ return /* @__PURE__ */ jsx(
1373
+ AreaPrimitive,
1374
+ {
1375
+ "data-slot": "cropper-area",
1376
+ ...areaProps,
1377
+ ref,
1378
+ className: cn(
1379
+ cropperAreaVariants({
1380
+ shape: shape ?? context.shape,
1381
+ withGrid: withGrid ?? context.withGrid,
1382
+ className
1383
+ })
1384
+ ),
1385
+ style: {
1386
+ width: snapPixels ? Math.round(cropSize.width) : cropSize.width,
1387
+ height: snapPixels ? Math.round(cropSize.height) : cropSize.height,
1388
+ ...style
1389
+ }
1390
+ }
1391
+ );
1392
+ }
1393
+
1394
+ export { Cropper, CropperArea, CropperImage, CropperVideo, useStore as useCropper };
1395
+ //# sourceMappingURL=cropper.js.map
1396
+ //# sourceMappingURL=cropper.js.map