@vritti/quantum-ui 0.2.10 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (939) hide show
  1. package/dist/Alert.js +4 -32
  2. package/dist/Alert.js.map +1 -1
  3. package/dist/AppSelector.js +37 -0
  4. package/dist/AppSelector.js.map +1 -0
  5. package/dist/Avatar.js +6 -6
  6. package/dist/Avatar.js.map +1 -1
  7. package/dist/Badge2.js +3 -3
  8. package/dist/Breadcrumb.js +125 -0
  9. package/dist/Breadcrumb.js.map +1 -0
  10. package/dist/Button.js +9 -5
  11. package/dist/Button.js.map +1 -1
  12. package/dist/Button2.js +4 -4
  13. package/dist/Button2.js.map +1 -1
  14. package/dist/Card.js +1 -1
  15. package/dist/CardSkeleton.js +17 -0
  16. package/dist/CardSkeleton.js.map +1 -0
  17. package/dist/Chart.js +6196 -6402
  18. package/dist/Chart.js.map +1 -1
  19. package/dist/Checkbox2.js +7 -6
  20. package/dist/Checkbox2.js.map +1 -1
  21. package/dist/CheckboxGroup.js +74 -0
  22. package/dist/CheckboxGroup.js.map +1 -0
  23. package/dist/CloudProviderSelector.js +37 -0
  24. package/dist/CloudProviderSelector.js.map +1 -0
  25. package/dist/Collapsible.js +8 -0
  26. package/dist/Collapsible.js.map +1 -0
  27. package/dist/Combination.js +10 -2509
  28. package/dist/Combination.js.map +1 -1
  29. package/dist/ConfirmContext.js +75 -0
  30. package/dist/ConfirmContext.js.map +1 -0
  31. package/dist/CurrencySelector.js +194 -0
  32. package/dist/CurrencySelector.js.map +1 -0
  33. package/dist/DangerZoneSkeleton.js +52 -0
  34. package/dist/DangerZoneSkeleton.js.map +1 -0
  35. package/dist/DatePicker.js +36 -18
  36. package/dist/DatePicker.js.map +1 -1
  37. package/dist/DeploymentSelector.js +37 -0
  38. package/dist/DeploymentSelector.js.map +1 -0
  39. package/dist/Dialog.js +159 -0
  40. package/dist/Dialog.js.map +1 -0
  41. package/dist/DropdownMenu.js +66 -1493
  42. package/dist/DropdownMenu.js.map +1 -1
  43. package/dist/Empty.js +49 -0
  44. package/dist/Empty.js.map +1 -0
  45. package/dist/ErrorBoundary.js +255 -0
  46. package/dist/ErrorBoundary.js.map +1 -0
  47. package/dist/FeatureSelector.js +37 -0
  48. package/dist/FeatureSelector.js.map +1 -0
  49. package/dist/FilePreview.js +194 -0
  50. package/dist/FilePreview.js.map +1 -0
  51. package/dist/Form.js +1922 -20
  52. package/dist/Form.js.map +1 -1
  53. package/dist/HierarchyGraph.js +10729 -0
  54. package/dist/HierarchyGraph.js.map +1 -0
  55. package/dist/IndustrySelector.js +37 -0
  56. package/dist/IndustrySelector.js.map +1 -0
  57. package/dist/Input.js +22 -0
  58. package/dist/Input.js.map +1 -0
  59. package/dist/Label.js +2 -22
  60. package/dist/Label.js.map +1 -1
  61. package/dist/LocaleSelector.js +111 -0
  62. package/dist/LocaleSelector.js.map +1 -0
  63. package/dist/MicrofrontendSelector.js +19 -0
  64. package/dist/MicrofrontendSelector.js.map +1 -0
  65. package/dist/OTPField.js +29 -27
  66. package/dist/OTPField.js.map +1 -1
  67. package/dist/PageHeaderSkeleton.js +35 -0
  68. package/dist/PageHeaderSkeleton.js.map +1 -0
  69. package/dist/PasswordField.js +2 -50
  70. package/dist/PasswordField.js.map +1 -1
  71. package/dist/PhoneField.js +9 -14
  72. package/dist/PhoneField.js.map +1 -1
  73. package/dist/PlanSelector.js +37 -0
  74. package/dist/PlanSelector.js.map +1 -0
  75. package/dist/Progress.js +5 -4
  76. package/dist/Progress.js.map +1 -1
  77. package/dist/RadioGroup.js +392 -0
  78. package/dist/RadioGroup.js.map +1 -0
  79. package/dist/RegionSelector.js +37 -0
  80. package/dist/RegionSelector.js.map +1 -0
  81. package/dist/Select.js +780 -0
  82. package/dist/Select.js.map +1 -0
  83. package/dist/SelectFilter.js +387 -0
  84. package/dist/SelectFilter.js.map +1 -0
  85. package/dist/Sidebar.js +616 -0
  86. package/dist/Sidebar.js.map +1 -0
  87. package/dist/SingleSelect.js +429 -0
  88. package/dist/SingleSelect.js.map +1 -0
  89. package/dist/Skeleton.js +1 -1
  90. package/dist/Sonner.js +2 -1134
  91. package/dist/Sonner.js.map +1 -1
  92. package/dist/Sortable.js +4517 -0
  93. package/dist/Sortable.js.map +1 -0
  94. package/dist/Spinner.js +1 -1
  95. package/dist/StepProgressIndicator.js +42 -0
  96. package/dist/StepProgressIndicator.js.map +1 -0
  97. package/dist/Switch.js +16 -16
  98. package/dist/Switch.js.map +1 -1
  99. package/dist/TabsSkeleton.js +188 -0
  100. package/dist/TabsSkeleton.js.map +1 -0
  101. package/dist/TextArea.js +17 -20
  102. package/dist/TextArea.js.map +1 -1
  103. package/dist/TextField.js +3 -19
  104. package/dist/TextField.js.map +1 -1
  105. package/dist/TimezoneSelector.js +144 -0
  106. package/dist/TimezoneSelector.js.map +1 -0
  107. package/dist/Toggle.js +3 -33
  108. package/dist/Toggle.js.map +1 -1
  109. package/dist/Typography.js +1 -1
  110. package/dist/UploadFile.js +232 -0
  111. package/dist/UploadFile.js.map +1 -0
  112. package/dist/ValueFilter.js +123 -0
  113. package/dist/ValueFilter.js.map +1 -0
  114. package/dist/ViewTabs.js +218 -0
  115. package/dist/ViewTabs.js.map +1 -0
  116. package/dist/_commonjsHelpers.js +3 -1
  117. package/dist/_commonjsHelpers.js.map +1 -1
  118. package/dist/assets/quantum-ui.css +808 -38
  119. package/dist/axios.js +4575 -0
  120. package/dist/axios.js.map +1 -0
  121. package/dist/circle-alert.js +19 -0
  122. package/dist/circle-alert.js.map +1 -0
  123. package/dist/circle-check.js +18 -0
  124. package/dist/circle-check.js.map +1 -0
  125. package/dist/collapsible2.js +154 -0
  126. package/dist/collapsible2.js.map +1 -0
  127. package/dist/components/Breadcrumb.js +2 -0
  128. package/dist/components/Breadcrumb.js.map +1 -0
  129. package/dist/components/Card.js +1 -0
  130. package/dist/components/Card.js.map +1 -1
  131. package/dist/components/CheckboxGroup.js +2 -0
  132. package/dist/components/CheckboxGroup.js.map +1 -0
  133. package/dist/components/Collapsible.js +2 -0
  134. package/dist/components/Collapsible.js.map +1 -0
  135. package/dist/components/DangerZone.js +2 -0
  136. package/dist/components/DangerZone.js.map +1 -0
  137. package/dist/components/DataTable.js +1 -1
  138. package/dist/components/Dialog.js +2 -0
  139. package/dist/components/Dialog.js.map +1 -0
  140. package/dist/components/DropdownMenu.js +1 -1
  141. package/dist/components/Empty.js +2 -0
  142. package/dist/components/Empty.js.map +1 -0
  143. package/dist/components/ErrorBoundary.js +2 -0
  144. package/dist/components/ErrorBoundary.js.map +1 -0
  145. package/dist/components/FilePreview.js +2 -0
  146. package/dist/components/FilePreview.js.map +1 -0
  147. package/dist/components/HierarchyGraph.js +2 -0
  148. package/dist/components/HierarchyGraph.js.map +1 -0
  149. package/dist/components/PageHeader.js +2 -0
  150. package/dist/components/PageHeader.js.map +1 -0
  151. package/dist/components/RadioGroup.js +2 -0
  152. package/dist/components/RadioGroup.js.map +1 -0
  153. package/dist/components/RichTextEditor.js +4 -0
  154. package/dist/components/RichTextEditor.js.map +1 -0
  155. package/dist/components/Select.js +6 -1356
  156. package/dist/components/Select.js.map +1 -1
  157. package/dist/components/Sidebar.js +2 -0
  158. package/dist/components/Sidebar.js.map +1 -0
  159. package/dist/components/Sortable.js +2 -0
  160. package/dist/components/Sortable.js.map +1 -0
  161. package/dist/components/StepProgressIndicator.js +2 -0
  162. package/dist/components/StepProgressIndicator.js.map +1 -0
  163. package/dist/components/Tabs.js +2 -0
  164. package/dist/components/Tabs.js.map +1 -0
  165. package/dist/components/UploadFile.js +2 -0
  166. package/dist/components/UploadFile.js.map +1 -0
  167. package/dist/components/ValueFilter.js +2 -0
  168. package/dist/components/ValueFilter.js.map +1 -0
  169. package/dist/components/ViewTabs.js +2 -0
  170. package/dist/components/ViewTabs.js.map +1 -0
  171. package/dist/context/index.js +1 -0
  172. package/dist/context/index.js.map +1 -1
  173. package/dist/dropdown-menu.js +1209 -0
  174. package/dist/dropdown-menu.js.map +1 -0
  175. package/dist/ellipsis.js +19 -0
  176. package/dist/ellipsis.js.map +1 -0
  177. package/dist/eye.js +52 -0
  178. package/dist/eye.js.map +1 -0
  179. package/dist/field.js +2 -2
  180. package/dist/file-text.js +27 -0
  181. package/dist/file-text.js.map +1 -0
  182. package/dist/grip-vertical.js +22 -0
  183. package/dist/grip-vertical.js.map +1 -0
  184. package/dist/hooks/index.js +3 -1
  185. package/dist/hooks/index.js.map +1 -1
  186. package/dist/image-component.js +614 -0
  187. package/dist/image-component.js.map +1 -0
  188. package/dist/index.js +48 -12
  189. package/dist/index.js.map +1 -1
  190. package/dist/index10.js +181 -11
  191. package/dist/index10.js.map +1 -1
  192. package/dist/index11.js +177 -4
  193. package/dist/index11.js.map +1 -1
  194. package/dist/index12.js +17 -38
  195. package/dist/index12.js.map +1 -1
  196. package/dist/index13.js +204 -188
  197. package/dist/index13.js.map +1 -1
  198. package/dist/index14.js +124 -192
  199. package/dist/index14.js.map +1 -1
  200. package/dist/index15.js +79 -0
  201. package/dist/index15.js.map +1 -0
  202. package/dist/index16.js +16 -0
  203. package/dist/index16.js.map +1 -0
  204. package/dist/index17.js +1137 -0
  205. package/dist/index17.js.map +1 -0
  206. package/dist/index18.js +41 -0
  207. package/dist/index18.js.map +1 -0
  208. package/dist/index19.js +314 -0
  209. package/dist/index19.js.map +1 -0
  210. package/dist/index2.js +54030 -59
  211. package/dist/index2.js.map +1 -1
  212. package/dist/index20.js +488 -0
  213. package/dist/index20.js.map +1 -0
  214. package/dist/index21.js +2540 -0
  215. package/dist/index21.js.map +1 -0
  216. package/dist/index22.js +36 -0
  217. package/dist/index22.js.map +1 -0
  218. package/dist/index23.js +13 -0
  219. package/dist/index23.js.map +1 -0
  220. package/dist/index24.js +8 -0
  221. package/dist/index24.js.map +1 -0
  222. package/dist/index25.js +35 -0
  223. package/dist/index25.js.map +1 -0
  224. package/dist/index26.js +65 -0
  225. package/dist/index26.js.map +1 -0
  226. package/dist/index27.js +16 -0
  227. package/dist/index27.js.map +1 -0
  228. package/dist/index28.js +41 -0
  229. package/dist/index28.js.map +1 -0
  230. package/dist/index29.js +84 -0
  231. package/dist/index29.js.map +1 -0
  232. package/dist/index3.js +41 -61
  233. package/dist/index3.js.map +1 -1
  234. package/dist/index30.js +199 -0
  235. package/dist/index30.js.map +1 -0
  236. package/dist/index4.js +290 -92
  237. package/dist/index4.js.map +1 -1
  238. package/dist/index5.js +102 -42
  239. package/dist/index5.js.map +1 -1
  240. package/dist/index6.js +35 -8
  241. package/dist/index6.js.map +1 -1
  242. package/dist/index7.js +1141 -110
  243. package/dist/index7.js.map +1 -1
  244. package/dist/index8.js +19 -34
  245. package/dist/index8.js.map +1 -1
  246. package/dist/index9.js +27 -4
  247. package/dist/index9.js.map +1 -1
  248. package/dist/lib/components/Breadcrumb/Breadcrumb.d.ts +17 -0
  249. package/dist/lib/components/Breadcrumb/Breadcrumb.d.ts.map +1 -0
  250. package/dist/lib/components/Breadcrumb/index.d.ts +4 -0
  251. package/dist/lib/components/Breadcrumb/index.d.ts.map +1 -0
  252. package/dist/lib/components/Button/Button.d.ts +3 -1
  253. package/dist/lib/components/Button/Button.d.ts.map +1 -1
  254. package/dist/lib/components/Card/CardSkeleton.d.ts +9 -0
  255. package/dist/lib/components/Card/CardSkeleton.d.ts.map +1 -0
  256. package/dist/lib/components/Card/index.d.ts +1 -0
  257. package/dist/lib/components/Card/index.d.ts.map +1 -1
  258. package/dist/lib/components/Chart/Chart.d.ts +1 -1
  259. package/dist/lib/components/Chart/Chart.d.ts.map +1 -1
  260. package/dist/lib/components/CheckboxGroup/CheckboxGroup.d.ts +24 -0
  261. package/dist/lib/components/CheckboxGroup/CheckboxGroup.d.ts.map +1 -0
  262. package/dist/lib/components/CheckboxGroup/index.d.ts +3 -0
  263. package/dist/lib/components/CheckboxGroup/index.d.ts.map +1 -0
  264. package/dist/lib/components/Collapsible/Collapsible.d.ts +5 -0
  265. package/dist/lib/components/Collapsible/Collapsible.d.ts.map +1 -0
  266. package/dist/lib/components/Collapsible/index.d.ts +2 -0
  267. package/dist/lib/components/Collapsible/index.d.ts.map +1 -0
  268. package/dist/lib/components/DangerZone/DangerZone.d.ts +13 -0
  269. package/dist/lib/components/DangerZone/DangerZone.d.ts.map +1 -0
  270. package/dist/lib/components/DangerZone/DangerZoneSkeleton.d.ts +9 -0
  271. package/dist/lib/components/DangerZone/DangerZoneSkeleton.d.ts.map +1 -0
  272. package/dist/lib/components/DangerZone/index.d.ts +4 -0
  273. package/dist/lib/components/DangerZone/index.d.ts.map +1 -0
  274. package/dist/lib/components/DataTable/DataTable.d.ts +2 -11
  275. package/dist/lib/components/DataTable/DataTable.d.ts.map +1 -1
  276. package/dist/lib/components/DataTable/components/DataTableColumnHeader.d.ts.map +1 -1
  277. package/dist/lib/components/DataTable/components/DataTableEmpty.d.ts.map +1 -1
  278. package/dist/lib/components/DataTable/components/DataTableFilters.d.ts +11 -0
  279. package/dist/lib/components/DataTable/components/DataTableFilters.d.ts.map +1 -0
  280. package/dist/lib/components/DataTable/components/DataTableImportDialog.d.ts +16 -0
  281. package/dist/lib/components/DataTable/components/DataTableImportDialog.d.ts.map +1 -0
  282. package/dist/lib/components/DataTable/components/DataTablePagination.d.ts +1 -2
  283. package/dist/lib/components/DataTable/components/DataTablePagination.d.ts.map +1 -1
  284. package/dist/lib/components/DataTable/components/DataTableRowDensity.d.ts +11 -0
  285. package/dist/lib/components/DataTable/components/DataTableRowDensity.d.ts.map +1 -0
  286. package/dist/lib/components/DataTable/components/DataTableSearch.d.ts +14 -0
  287. package/dist/lib/components/DataTable/components/DataTableSearch.d.ts.map +1 -0
  288. package/dist/lib/components/DataTable/components/DataTableSelectionBar.d.ts +14 -0
  289. package/dist/lib/components/DataTable/components/DataTableSelectionBar.d.ts.map +1 -0
  290. package/dist/lib/components/DataTable/components/DataTableViewOptions.d.ts.map +1 -1
  291. package/dist/lib/components/DataTable/components/DataTableViewTabs.d.ts +7 -0
  292. package/dist/lib/components/DataTable/components/DataTableViewTabs.d.ts.map +1 -0
  293. package/dist/lib/components/DataTable/components/DataTableViewsMenu.d.ts +14 -0
  294. package/dist/lib/components/DataTable/components/DataTableViewsMenu.d.ts.map +1 -0
  295. package/dist/lib/components/DataTable/components/FilterWrapper.d.ts +21 -0
  296. package/dist/lib/components/DataTable/components/FilterWrapper.d.ts.map +1 -0
  297. package/dist/lib/components/DataTable/components/RowActions.d.ts +20 -0
  298. package/dist/lib/components/DataTable/components/RowActions.d.ts.map +1 -0
  299. package/dist/lib/components/DataTable/hooks/useAutoUpsert.d.ts +3 -0
  300. package/dist/lib/components/DataTable/hooks/useAutoUpsert.d.ts.map +1 -0
  301. package/dist/lib/components/DataTable/hooks/useDataTable.d.ts +24 -2
  302. package/dist/lib/components/DataTable/hooks/useDataTable.d.ts.map +1 -1
  303. package/dist/lib/components/DataTable/index.d.ts +11 -3
  304. package/dist/lib/components/DataTable/index.d.ts.map +1 -1
  305. package/dist/lib/components/DataTable/store/store.d.ts +28 -0
  306. package/dist/lib/components/DataTable/store/store.d.ts.map +1 -0
  307. package/dist/lib/components/DataTable/store/useTableSlice.d.ts +18 -0
  308. package/dist/lib/components/DataTable/store/useTableSlice.d.ts.map +1 -0
  309. package/dist/lib/components/DataTable/types.d.ts +55 -56
  310. package/dist/lib/components/DataTable/types.d.ts.map +1 -1
  311. package/dist/lib/components/DataTable/utils.d.ts +8 -1
  312. package/dist/lib/components/DataTable/utils.d.ts.map +1 -1
  313. package/dist/lib/components/DatePicker/DatePicker.d.ts +1 -1
  314. package/dist/lib/components/DatePicker/DatePicker.d.ts.map +1 -1
  315. package/dist/lib/components/Dialog/Dialog.d.ts +31 -0
  316. package/dist/lib/components/Dialog/Dialog.d.ts.map +1 -0
  317. package/dist/lib/components/Dialog/index.d.ts +3 -0
  318. package/dist/lib/components/Dialog/index.d.ts.map +1 -0
  319. package/dist/lib/components/DropdownMenu/DropdownMenu.d.ts +1 -1
  320. package/dist/lib/components/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  321. package/dist/lib/components/DropdownMenu/types.d.ts +10 -1
  322. package/dist/lib/components/DropdownMenu/types.d.ts.map +1 -1
  323. package/dist/lib/components/Editor/context/editor-config-context.d.ts +9 -0
  324. package/dist/lib/components/Editor/context/editor-config-context.d.ts.map +1 -0
  325. package/dist/lib/components/Editor/context/toolbar-context.d.ts +18 -0
  326. package/dist/lib/components/Editor/context/toolbar-context.d.ts.map +1 -0
  327. package/dist/lib/components/Editor/editor-hooks/use-debounce.d.ts +2 -0
  328. package/dist/lib/components/Editor/editor-hooks/use-debounce.d.ts.map +1 -0
  329. package/dist/lib/components/Editor/editor-hooks/use-modal.d.ts +6 -0
  330. package/dist/lib/components/Editor/editor-hooks/use-modal.d.ts.map +1 -0
  331. package/dist/lib/components/Editor/editor-hooks/use-report.d.ts +2 -0
  332. package/dist/lib/components/Editor/editor-hooks/use-report.d.ts.map +1 -0
  333. package/dist/lib/components/Editor/editor-hooks/use-update-toolbar.d.ts +3 -0
  334. package/dist/lib/components/Editor/editor-hooks/use-update-toolbar.d.ts.map +1 -0
  335. package/dist/lib/components/Editor/editor-ui/button-group.d.ts +12 -0
  336. package/dist/lib/components/Editor/editor-ui/button-group.d.ts.map +1 -0
  337. package/dist/lib/components/Editor/editor-ui/button.d.ts +11 -0
  338. package/dist/lib/components/Editor/editor-ui/button.d.ts.map +1 -0
  339. package/dist/lib/components/Editor/editor-ui/code-button.d.ts +8 -0
  340. package/dist/lib/components/Editor/editor-ui/code-button.d.ts.map +1 -0
  341. package/dist/lib/components/Editor/editor-ui/color-picker.d.ts +92 -0
  342. package/dist/lib/components/Editor/editor-ui/color-picker.d.ts.map +1 -0
  343. package/dist/lib/components/Editor/editor-ui/command.d.ts +19 -0
  344. package/dist/lib/components/Editor/editor-ui/command.d.ts.map +1 -0
  345. package/dist/lib/components/Editor/editor-ui/content-editable.d.ts +9 -0
  346. package/dist/lib/components/Editor/editor-ui/content-editable.d.ts.map +1 -0
  347. package/dist/lib/components/Editor/editor-ui/dialog.d.ts +16 -0
  348. package/dist/lib/components/Editor/editor-ui/dialog.d.ts.map +1 -0
  349. package/dist/lib/components/Editor/editor-ui/image-component.d.ts +16 -0
  350. package/dist/lib/components/Editor/editor-ui/image-component.d.ts.map +1 -0
  351. package/dist/lib/components/Editor/editor-ui/image-resizer.d.ts +18 -0
  352. package/dist/lib/components/Editor/editor-ui/image-resizer.d.ts.map +1 -0
  353. package/dist/lib/components/Editor/editor-ui/input.d.ts +4 -0
  354. package/dist/lib/components/Editor/editor-ui/input.d.ts.map +1 -0
  355. package/dist/lib/components/Editor/editor-ui/label.d.ts +5 -0
  356. package/dist/lib/components/Editor/editor-ui/label.d.ts.map +1 -0
  357. package/dist/lib/components/Editor/editor-ui/popover.d.ts +8 -0
  358. package/dist/lib/components/Editor/editor-ui/popover.d.ts.map +1 -0
  359. package/dist/lib/components/Editor/editor-ui/scroll-area.d.ts +6 -0
  360. package/dist/lib/components/Editor/editor-ui/scroll-area.d.ts.map +1 -0
  361. package/dist/lib/components/Editor/editor-ui/select.d.ts +16 -0
  362. package/dist/lib/components/Editor/editor-ui/select.d.ts.map +1 -0
  363. package/dist/lib/components/Editor/editor-ui/separator.d.ts +5 -0
  364. package/dist/lib/components/Editor/editor-ui/separator.d.ts.map +1 -0
  365. package/dist/lib/components/Editor/editor-ui/tabs.d.ts +8 -0
  366. package/dist/lib/components/Editor/editor-ui/tabs.d.ts.map +1 -0
  367. package/dist/lib/components/Editor/editor-ui/toggle-group.d.ts +8 -0
  368. package/dist/lib/components/Editor/editor-ui/toggle-group.d.ts.map +1 -0
  369. package/dist/lib/components/Editor/editor-ui/toggle.d.ts +10 -0
  370. package/dist/lib/components/Editor/editor-ui/toggle.d.ts.map +1 -0
  371. package/dist/lib/components/Editor/editor-ui/tooltip.d.ts +8 -0
  372. package/dist/lib/components/Editor/editor-ui/tooltip.d.ts.map +1 -0
  373. package/dist/lib/components/Editor/index.d.ts +4 -0
  374. package/dist/lib/components/Editor/index.d.ts.map +1 -0
  375. package/dist/lib/components/Editor/nodes/autocomplete-node.d.ts +19 -0
  376. package/dist/lib/components/Editor/nodes/autocomplete-node.d.ts.map +1 -0
  377. package/dist/lib/components/Editor/nodes/embeds/tweet-node.d.ts +22 -0
  378. package/dist/lib/components/Editor/nodes/embeds/tweet-node.d.ts.map +1 -0
  379. package/dist/lib/components/Editor/nodes/embeds/youtube-node.d.ts +23 -0
  380. package/dist/lib/components/Editor/nodes/embeds/youtube-node.d.ts.map +1 -0
  381. package/dist/lib/components/Editor/nodes/emoji-node.d.ts +18 -0
  382. package/dist/lib/components/Editor/nodes/emoji-node.d.ts.map +1 -0
  383. package/dist/lib/components/Editor/nodes/image-node.d.ts +49 -0
  384. package/dist/lib/components/Editor/nodes/image-node.d.ts.map +1 -0
  385. package/dist/lib/components/Editor/nodes/keyword-node.d.ts +15 -0
  386. package/dist/lib/components/Editor/nodes/keyword-node.d.ts.map +1 -0
  387. package/dist/lib/components/Editor/nodes/layout-container-node.d.ts +23 -0
  388. package/dist/lib/components/Editor/nodes/layout-container-node.d.ts.map +1 -0
  389. package/dist/lib/components/Editor/nodes/layout-item-node.d.ts +15 -0
  390. package/dist/lib/components/Editor/nodes/layout-item-node.d.ts.map +1 -0
  391. package/dist/lib/components/Editor/nodes/mention-node.d.ts +21 -0
  392. package/dist/lib/components/Editor/nodes/mention-node.d.ts.map +1 -0
  393. package/dist/lib/components/Editor/nodes/nodes.d.ts +3 -0
  394. package/dist/lib/components/Editor/nodes/nodes.d.ts.map +1 -0
  395. package/dist/lib/components/Editor/nodes.d.ts +2 -0
  396. package/dist/lib/components/Editor/nodes.d.ts.map +1 -0
  397. package/dist/lib/components/Editor/plugins/actions/actions-plugin.d.ts +4 -0
  398. package/dist/lib/components/Editor/plugins/actions/actions-plugin.d.ts.map +1 -0
  399. package/dist/lib/components/Editor/plugins/actions/character-limit-plugin.d.ts +5 -0
  400. package/dist/lib/components/Editor/plugins/actions/character-limit-plugin.d.ts.map +1 -0
  401. package/dist/lib/components/Editor/plugins/actions/clear-editor-plugin.d.ts +2 -0
  402. package/dist/lib/components/Editor/plugins/actions/clear-editor-plugin.d.ts.map +1 -0
  403. package/dist/lib/components/Editor/plugins/actions/counter-character-plugin.d.ts +6 -0
  404. package/dist/lib/components/Editor/plugins/actions/counter-character-plugin.d.ts.map +1 -0
  405. package/dist/lib/components/Editor/plugins/actions/edit-mode-toggle-plugin.d.ts +2 -0
  406. package/dist/lib/components/Editor/plugins/actions/edit-mode-toggle-plugin.d.ts.map +1 -0
  407. package/dist/lib/components/Editor/plugins/actions/import-export-plugin.d.ts +2 -0
  408. package/dist/lib/components/Editor/plugins/actions/import-export-plugin.d.ts.map +1 -0
  409. package/dist/lib/components/Editor/plugins/actions/markdown-toggle-plugin.d.ts +6 -0
  410. package/dist/lib/components/Editor/plugins/actions/markdown-toggle-plugin.d.ts.map +1 -0
  411. package/dist/lib/components/Editor/plugins/actions/max-length-plugin.d.ts +4 -0
  412. package/dist/lib/components/Editor/plugins/actions/max-length-plugin.d.ts.map +1 -0
  413. package/dist/lib/components/Editor/plugins/actions/share-content-plugin.d.ts +2 -0
  414. package/dist/lib/components/Editor/plugins/actions/share-content-plugin.d.ts.map +1 -0
  415. package/dist/lib/components/Editor/plugins/actions/speech-to-text-plugin.d.ts +7 -0
  416. package/dist/lib/components/Editor/plugins/actions/speech-to-text-plugin.d.ts.map +1 -0
  417. package/dist/lib/components/Editor/plugins/actions/tree-view-plugin.d.ts +3 -0
  418. package/dist/lib/components/Editor/plugins/actions/tree-view-plugin.d.ts.map +1 -0
  419. package/dist/lib/components/Editor/plugins/auto-link-plugin.d.ts +3 -0
  420. package/dist/lib/components/Editor/plugins/auto-link-plugin.d.ts.map +1 -0
  421. package/dist/lib/components/Editor/plugins/autocomplete-plugin.d.ts +11 -0
  422. package/dist/lib/components/Editor/plugins/autocomplete-plugin.d.ts.map +1 -0
  423. package/dist/lib/components/Editor/plugins/code-action-menu-plugin.d.ts +4 -0
  424. package/dist/lib/components/Editor/plugins/code-action-menu-plugin.d.ts.map +1 -0
  425. package/dist/lib/components/Editor/plugins/code-highlight-plugin.d.ts +3 -0
  426. package/dist/lib/components/Editor/plugins/code-highlight-plugin.d.ts.map +1 -0
  427. package/dist/lib/components/Editor/plugins/component-picker-menu-plugin.d.ts +9 -0
  428. package/dist/lib/components/Editor/plugins/component-picker-menu-plugin.d.ts.map +1 -0
  429. package/dist/lib/components/Editor/plugins/context-menu-plugin.d.ts +3 -0
  430. package/dist/lib/components/Editor/plugins/context-menu-plugin.d.ts.map +1 -0
  431. package/dist/lib/components/Editor/plugins/drag-drop-paste-plugin.d.ts +2 -0
  432. package/dist/lib/components/Editor/plugins/drag-drop-paste-plugin.d.ts.map +1 -0
  433. package/dist/lib/components/Editor/plugins/draggable-block-plugin.d.ts +5 -0
  434. package/dist/lib/components/Editor/plugins/draggable-block-plugin.d.ts.map +1 -0
  435. package/dist/lib/components/Editor/plugins/embeds/auto-embed-plugin.d.ts +18 -0
  436. package/dist/lib/components/Editor/plugins/embeds/auto-embed-plugin.d.ts.map +1 -0
  437. package/dist/lib/components/Editor/plugins/embeds/twitter-plugin.d.ts +5 -0
  438. package/dist/lib/components/Editor/plugins/embeds/twitter-plugin.d.ts.map +1 -0
  439. package/dist/lib/components/Editor/plugins/embeds/youtube-plugin.d.ts +5 -0
  440. package/dist/lib/components/Editor/plugins/embeds/youtube-plugin.d.ts.map +1 -0
  441. package/dist/lib/components/Editor/plugins/emoji-picker-plugin.d.ts +2 -0
  442. package/dist/lib/components/Editor/plugins/emoji-picker-plugin.d.ts.map +1 -0
  443. package/dist/lib/components/Editor/plugins/emojis-plugin.d.ts +3 -0
  444. package/dist/lib/components/Editor/plugins/emojis-plugin.d.ts.map +1 -0
  445. package/dist/lib/components/Editor/plugins/floating-link-editor-plugin.d.ts +7 -0
  446. package/dist/lib/components/Editor/plugins/floating-link-editor-plugin.d.ts.map +1 -0
  447. package/dist/lib/components/Editor/plugins/floating-text-format-plugin.d.ts +7 -0
  448. package/dist/lib/components/Editor/plugins/floating-text-format-plugin.d.ts.map +1 -0
  449. package/dist/lib/components/Editor/plugins/images-plugin.d.ts +25 -0
  450. package/dist/lib/components/Editor/plugins/images-plugin.d.ts.map +1 -0
  451. package/dist/lib/components/Editor/plugins/keywords-plugin.d.ts +3 -0
  452. package/dist/lib/components/Editor/plugins/keywords-plugin.d.ts.map +1 -0
  453. package/dist/lib/components/Editor/plugins/layout-plugin.d.ts +13 -0
  454. package/dist/lib/components/Editor/plugins/layout-plugin.d.ts.map +1 -0
  455. package/dist/lib/components/Editor/plugins/link-plugin.d.ts +3 -0
  456. package/dist/lib/components/Editor/plugins/link-plugin.d.ts.map +1 -0
  457. package/dist/lib/components/Editor/plugins/list-max-indent-level-plugin.d.ts +4 -0
  458. package/dist/lib/components/Editor/plugins/list-max-indent-level-plugin.d.ts.map +1 -0
  459. package/dist/lib/components/Editor/plugins/mentions-plugin.d.ts +3 -0
  460. package/dist/lib/components/Editor/plugins/mentions-plugin.d.ts.map +1 -0
  461. package/dist/lib/components/Editor/plugins/picker/alignment-picker-plugin.d.ts +5 -0
  462. package/dist/lib/components/Editor/plugins/picker/alignment-picker-plugin.d.ts.map +1 -0
  463. package/dist/lib/components/Editor/plugins/picker/bulleted-list-picker-plugin.d.ts +3 -0
  464. package/dist/lib/components/Editor/plugins/picker/bulleted-list-picker-plugin.d.ts.map +1 -0
  465. package/dist/lib/components/Editor/plugins/picker/check-list-picker-plugin.d.ts +3 -0
  466. package/dist/lib/components/Editor/plugins/picker/check-list-picker-plugin.d.ts.map +1 -0
  467. package/dist/lib/components/Editor/plugins/picker/code-picker-plugin.d.ts +3 -0
  468. package/dist/lib/components/Editor/plugins/picker/code-picker-plugin.d.ts.map +1 -0
  469. package/dist/lib/components/Editor/plugins/picker/columns-layout-picker-plugin.d.ts +3 -0
  470. package/dist/lib/components/Editor/plugins/picker/columns-layout-picker-plugin.d.ts.map +1 -0
  471. package/dist/lib/components/Editor/plugins/picker/component-picker-menu-plugin.d.ts +2 -0
  472. package/dist/lib/components/Editor/plugins/picker/component-picker-menu-plugin.d.ts.map +1 -0
  473. package/dist/lib/components/Editor/plugins/picker/component-picker-option.d.ts +17 -0
  474. package/dist/lib/components/Editor/plugins/picker/component-picker-option.d.ts.map +1 -0
  475. package/dist/lib/components/Editor/plugins/picker/divider-picker-plugin.d.ts +3 -0
  476. package/dist/lib/components/Editor/plugins/picker/divider-picker-plugin.d.ts.map +1 -0
  477. package/dist/lib/components/Editor/plugins/picker/embeds-picker-plugin.d.ts +5 -0
  478. package/dist/lib/components/Editor/plugins/picker/embeds-picker-plugin.d.ts.map +1 -0
  479. package/dist/lib/components/Editor/plugins/picker/heading-picker-plugin.d.ts +5 -0
  480. package/dist/lib/components/Editor/plugins/picker/heading-picker-plugin.d.ts.map +1 -0
  481. package/dist/lib/components/Editor/plugins/picker/image-picker-plugin.d.ts +3 -0
  482. package/dist/lib/components/Editor/plugins/picker/image-picker-plugin.d.ts.map +1 -0
  483. package/dist/lib/components/Editor/plugins/picker/numbered-list-picker-plugin.d.ts +3 -0
  484. package/dist/lib/components/Editor/plugins/picker/numbered-list-picker-plugin.d.ts.map +1 -0
  485. package/dist/lib/components/Editor/plugins/picker/paragraph-picker-plugin.d.ts +3 -0
  486. package/dist/lib/components/Editor/plugins/picker/paragraph-picker-plugin.d.ts.map +1 -0
  487. package/dist/lib/components/Editor/plugins/picker/quote-picker-plugin.d.ts +3 -0
  488. package/dist/lib/components/Editor/plugins/picker/quote-picker-plugin.d.ts.map +1 -0
  489. package/dist/lib/components/Editor/plugins/picker/table-picker-plugin.d.ts +6 -0
  490. package/dist/lib/components/Editor/plugins/picker/table-picker-plugin.d.ts.map +1 -0
  491. package/dist/lib/components/Editor/plugins/plugins.d.ts +2 -0
  492. package/dist/lib/components/Editor/plugins/plugins.d.ts.map +1 -0
  493. package/dist/lib/components/Editor/plugins/tab-focus-plugin.d.ts +2 -0
  494. package/dist/lib/components/Editor/plugins/tab-focus-plugin.d.ts.map +1 -0
  495. package/dist/lib/components/Editor/plugins/table-plugin.d.ts +34 -0
  496. package/dist/lib/components/Editor/plugins/table-plugin.d.ts.map +1 -0
  497. package/dist/lib/components/Editor/plugins/toolbar/block-format/block-format-data.d.ts +5 -0
  498. package/dist/lib/components/Editor/plugins/toolbar/block-format/block-format-data.d.ts.map +1 -0
  499. package/dist/lib/components/Editor/plugins/toolbar/block-format/format-bulleted-list.d.ts +2 -0
  500. package/dist/lib/components/Editor/plugins/toolbar/block-format/format-bulleted-list.d.ts.map +1 -0
  501. package/dist/lib/components/Editor/plugins/toolbar/block-format/format-check-list.d.ts +2 -0
  502. package/dist/lib/components/Editor/plugins/toolbar/block-format/format-check-list.d.ts.map +1 -0
  503. package/dist/lib/components/Editor/plugins/toolbar/block-format/format-code-block.d.ts +2 -0
  504. package/dist/lib/components/Editor/plugins/toolbar/block-format/format-code-block.d.ts.map +1 -0
  505. package/dist/lib/components/Editor/plugins/toolbar/block-format/format-heading.d.ts +5 -0
  506. package/dist/lib/components/Editor/plugins/toolbar/block-format/format-heading.d.ts.map +1 -0
  507. package/dist/lib/components/Editor/plugins/toolbar/block-format/format-numbered-list.d.ts +2 -0
  508. package/dist/lib/components/Editor/plugins/toolbar/block-format/format-numbered-list.d.ts.map +1 -0
  509. package/dist/lib/components/Editor/plugins/toolbar/block-format/format-paragraph.d.ts +2 -0
  510. package/dist/lib/components/Editor/plugins/toolbar/block-format/format-paragraph.d.ts.map +1 -0
  511. package/dist/lib/components/Editor/plugins/toolbar/block-format/format-quote.d.ts +2 -0
  512. package/dist/lib/components/Editor/plugins/toolbar/block-format/format-quote.d.ts.map +1 -0
  513. package/dist/lib/components/Editor/plugins/toolbar/block-format-toolbar-plugin.d.ts +4 -0
  514. package/dist/lib/components/Editor/plugins/toolbar/block-format-toolbar-plugin.d.ts.map +1 -0
  515. package/dist/lib/components/Editor/plugins/toolbar/block-insert/insert-columns-layout.d.ts +2 -0
  516. package/dist/lib/components/Editor/plugins/toolbar/block-insert/insert-columns-layout.d.ts.map +1 -0
  517. package/dist/lib/components/Editor/plugins/toolbar/block-insert/insert-embeds.d.ts +2 -0
  518. package/dist/lib/components/Editor/plugins/toolbar/block-insert/insert-embeds.d.ts.map +1 -0
  519. package/dist/lib/components/Editor/plugins/toolbar/block-insert/insert-horizontal-rule.d.ts +2 -0
  520. package/dist/lib/components/Editor/plugins/toolbar/block-insert/insert-horizontal-rule.d.ts.map +1 -0
  521. package/dist/lib/components/Editor/plugins/toolbar/block-insert/insert-image.d.ts +2 -0
  522. package/dist/lib/components/Editor/plugins/toolbar/block-insert/insert-image.d.ts.map +1 -0
  523. package/dist/lib/components/Editor/plugins/toolbar/block-insert/insert-table.d.ts +2 -0
  524. package/dist/lib/components/Editor/plugins/toolbar/block-insert/insert-table.d.ts.map +1 -0
  525. package/dist/lib/components/Editor/plugins/toolbar/block-insert-plugin.d.ts +4 -0
  526. package/dist/lib/components/Editor/plugins/toolbar/block-insert-plugin.d.ts.map +1 -0
  527. package/dist/lib/components/Editor/plugins/toolbar/clear-formatting-toolbar-plugin.d.ts +2 -0
  528. package/dist/lib/components/Editor/plugins/toolbar/clear-formatting-toolbar-plugin.d.ts.map +1 -0
  529. package/dist/lib/components/Editor/plugins/toolbar/code-language-toolbar-plugin.d.ts +2 -0
  530. package/dist/lib/components/Editor/plugins/toolbar/code-language-toolbar-plugin.d.ts.map +1 -0
  531. package/dist/lib/components/Editor/plugins/toolbar/element-format-toolbar-plugin.d.ts +4 -0
  532. package/dist/lib/components/Editor/plugins/toolbar/element-format-toolbar-plugin.d.ts.map +1 -0
  533. package/dist/lib/components/Editor/plugins/toolbar/font-background-toolbar-plugin.d.ts +2 -0
  534. package/dist/lib/components/Editor/plugins/toolbar/font-background-toolbar-plugin.d.ts.map +1 -0
  535. package/dist/lib/components/Editor/plugins/toolbar/font-color-toolbar-plugin.d.ts +2 -0
  536. package/dist/lib/components/Editor/plugins/toolbar/font-color-toolbar-plugin.d.ts.map +1 -0
  537. package/dist/lib/components/Editor/plugins/toolbar/font-family-toolbar-plugin.d.ts +2 -0
  538. package/dist/lib/components/Editor/plugins/toolbar/font-family-toolbar-plugin.d.ts.map +1 -0
  539. package/dist/lib/components/Editor/plugins/toolbar/font-format-toolbar-plugin.d.ts +2 -0
  540. package/dist/lib/components/Editor/plugins/toolbar/font-format-toolbar-plugin.d.ts.map +1 -0
  541. package/dist/lib/components/Editor/plugins/toolbar/font-size-toolbar-plugin.d.ts +2 -0
  542. package/dist/lib/components/Editor/plugins/toolbar/font-size-toolbar-plugin.d.ts.map +1 -0
  543. package/dist/lib/components/Editor/plugins/toolbar/history-toolbar-plugin.d.ts +2 -0
  544. package/dist/lib/components/Editor/plugins/toolbar/history-toolbar-plugin.d.ts.map +1 -0
  545. package/dist/lib/components/Editor/plugins/toolbar/horizontal-rule-toolbar-plugin.d.ts +2 -0
  546. package/dist/lib/components/Editor/plugins/toolbar/horizontal-rule-toolbar-plugin.d.ts.map +1 -0
  547. package/dist/lib/components/Editor/plugins/toolbar/image-toolbar-plugin.d.ts +2 -0
  548. package/dist/lib/components/Editor/plugins/toolbar/image-toolbar-plugin.d.ts.map +1 -0
  549. package/dist/lib/components/Editor/plugins/toolbar/link-toolbar-plugin.d.ts +4 -0
  550. package/dist/lib/components/Editor/plugins/toolbar/link-toolbar-plugin.d.ts.map +1 -0
  551. package/dist/lib/components/Editor/plugins/toolbar/subsuper-toolbar-plugin.d.ts +2 -0
  552. package/dist/lib/components/Editor/plugins/toolbar/subsuper-toolbar-plugin.d.ts.map +1 -0
  553. package/dist/lib/components/Editor/plugins/toolbar/table-toolbar-plugin.d.ts +2 -0
  554. package/dist/lib/components/Editor/plugins/toolbar/table-toolbar-plugin.d.ts.map +1 -0
  555. package/dist/lib/components/Editor/plugins/toolbar/toolbar-plugin.d.ts +6 -0
  556. package/dist/lib/components/Editor/plugins/toolbar/toolbar-plugin.d.ts.map +1 -0
  557. package/dist/lib/components/Editor/plugins/typing-pref-plugin.d.ts +4 -0
  558. package/dist/lib/components/Editor/plugins/typing-pref-plugin.d.ts.map +1 -0
  559. package/dist/lib/components/Editor/plugins.d.ts +2 -0
  560. package/dist/lib/components/Editor/plugins.d.ts.map +1 -0
  561. package/dist/lib/components/Editor/shared/can-use-dom.d.ts +2 -0
  562. package/dist/lib/components/Editor/shared/can-use-dom.d.ts.map +1 -0
  563. package/dist/lib/components/Editor/shared/caret-from-point.d.ts +5 -0
  564. package/dist/lib/components/Editor/shared/caret-from-point.d.ts.map +1 -0
  565. package/dist/lib/components/Editor/shared/environment.d.ts +18 -0
  566. package/dist/lib/components/Editor/shared/environment.d.ts.map +1 -0
  567. package/dist/lib/components/Editor/shared/invariant.d.ts +2 -0
  568. package/dist/lib/components/Editor/shared/invariant.d.ts.map +1 -0
  569. package/dist/lib/components/Editor/shared/normalize-class-names.d.ts +2 -0
  570. package/dist/lib/components/Editor/shared/normalize-class-names.d.ts.map +1 -0
  571. package/dist/lib/components/Editor/shared/react-patches.d.ts +2 -0
  572. package/dist/lib/components/Editor/shared/react-patches.d.ts.map +1 -0
  573. package/dist/lib/components/Editor/shared/react-test-utils.d.ts +3 -0
  574. package/dist/lib/components/Editor/shared/react-test-utils.d.ts.map +1 -0
  575. package/dist/lib/components/Editor/shared/simple-diff-with-cursor.d.ts +6 -0
  576. package/dist/lib/components/Editor/shared/simple-diff-with-cursor.d.ts.map +1 -0
  577. package/dist/lib/components/Editor/shared/use-layout-effect.d.ts +4 -0
  578. package/dist/lib/components/Editor/shared/use-layout-effect.d.ts.map +1 -0
  579. package/dist/lib/components/Editor/shared/warn-only-once.d.ts +2 -0
  580. package/dist/lib/components/Editor/shared/warn-only-once.d.ts.map +1 -0
  581. package/dist/lib/components/Editor/themes/editor-theme.d.ts +3 -0
  582. package/dist/lib/components/Editor/themes/editor-theme.d.ts.map +1 -0
  583. package/dist/lib/components/Editor/transformers/index.d.ts +16 -0
  584. package/dist/lib/components/Editor/transformers/index.d.ts.map +1 -0
  585. package/dist/lib/components/Editor/transformers/markdown-emoji-transformer.d.ts +3 -0
  586. package/dist/lib/components/Editor/transformers/markdown-emoji-transformer.d.ts.map +1 -0
  587. package/dist/lib/components/Editor/transformers/markdown-hr-transformer.d.ts +3 -0
  588. package/dist/lib/components/Editor/transformers/markdown-hr-transformer.d.ts.map +1 -0
  589. package/dist/lib/components/Editor/transformers/markdown-image-transformer.d.ts +3 -0
  590. package/dist/lib/components/Editor/transformers/markdown-image-transformer.d.ts.map +1 -0
  591. package/dist/lib/components/Editor/transformers/markdown-table-transformer.d.ts +3 -0
  592. package/dist/lib/components/Editor/transformers/markdown-table-transformer.d.ts.map +1 -0
  593. package/dist/lib/components/Editor/transformers/markdown-tweet-transformer.d.ts +3 -0
  594. package/dist/lib/components/Editor/transformers/markdown-tweet-transformer.d.ts.map +1 -0
  595. package/dist/lib/components/Editor/types.d.ts +23 -0
  596. package/dist/lib/components/Editor/types.d.ts.map +1 -0
  597. package/dist/lib/components/Editor/utils/can-use-dom.d.ts +2 -0
  598. package/dist/lib/components/Editor/utils/can-use-dom.d.ts.map +1 -0
  599. package/dist/lib/components/Editor/utils/collapsible.d.ts +3 -0
  600. package/dist/lib/components/Editor/utils/collapsible.d.ts.map +1 -0
  601. package/dist/lib/components/Editor/utils/doc-serialization.d.ts +4 -0
  602. package/dist/lib/components/Editor/utils/doc-serialization.d.ts.map +1 -0
  603. package/dist/lib/components/Editor/utils/emoji-list.d.ts +21 -0
  604. package/dist/lib/components/Editor/utils/emoji-list.d.ts.map +1 -0
  605. package/dist/lib/components/Editor/utils/get-dom-range-rect.d.ts +2 -0
  606. package/dist/lib/components/Editor/utils/get-dom-range-rect.d.ts.map +1 -0
  607. package/dist/lib/components/Editor/utils/get-selected-node.d.ts +3 -0
  608. package/dist/lib/components/Editor/utils/get-selected-node.d.ts.map +1 -0
  609. package/dist/lib/components/Editor/utils/guard.d.ts +2 -0
  610. package/dist/lib/components/Editor/utils/guard.d.ts.map +1 -0
  611. package/dist/lib/components/Editor/utils/is-mobile-width.d.ts +2 -0
  612. package/dist/lib/components/Editor/utils/is-mobile-width.d.ts.map +1 -0
  613. package/dist/lib/components/Editor/utils/set-floating-elem-position-for-link-editor.d.ts +2 -0
  614. package/dist/lib/components/Editor/utils/set-floating-elem-position-for-link-editor.d.ts.map +1 -0
  615. package/dist/lib/components/Editor/utils/set-floating-elem-position.d.ts +2 -0
  616. package/dist/lib/components/Editor/utils/set-floating-elem-position.d.ts.map +1 -0
  617. package/dist/lib/components/Editor/utils/swipe.d.ts +5 -0
  618. package/dist/lib/components/Editor/utils/swipe.d.ts.map +1 -0
  619. package/dist/lib/components/Editor/utils/url.d.ts +3 -0
  620. package/dist/lib/components/Editor/utils/url.d.ts.map +1 -0
  621. package/dist/lib/components/Empty/Empty.d.ts +12 -0
  622. package/dist/lib/components/Empty/Empty.d.ts.map +1 -0
  623. package/dist/lib/components/Empty/index.d.ts +3 -0
  624. package/dist/lib/components/Empty/index.d.ts.map +1 -0
  625. package/dist/lib/components/ErrorBoundary/ErrorBoundary.d.ts +7 -0
  626. package/dist/lib/components/ErrorBoundary/ErrorBoundary.d.ts.map +1 -0
  627. package/dist/lib/components/ErrorBoundary/ErrorPage.d.ts +38 -0
  628. package/dist/lib/components/ErrorBoundary/ErrorPage.d.ts.map +1 -0
  629. package/dist/lib/components/ErrorBoundary/index.d.ts +3 -0
  630. package/dist/lib/components/ErrorBoundary/index.d.ts.map +1 -0
  631. package/dist/lib/components/FilePreview/FilePreview.d.ts +8 -0
  632. package/dist/lib/components/FilePreview/FilePreview.d.ts.map +1 -0
  633. package/dist/lib/components/FilePreview/index.d.ts +2 -0
  634. package/dist/lib/components/FilePreview/index.d.ts.map +1 -0
  635. package/dist/lib/components/Form/Form.d.ts +5 -3
  636. package/dist/lib/components/Form/Form.d.ts.map +1 -1
  637. package/dist/lib/components/HierarchyGraph/HierarchyGraph.d.ts +24 -0
  638. package/dist/lib/components/HierarchyGraph/HierarchyGraph.d.ts.map +1 -0
  639. package/dist/lib/components/HierarchyGraph/index.d.ts +5 -0
  640. package/dist/lib/components/HierarchyGraph/index.d.ts.map +1 -0
  641. package/dist/lib/components/PageHeader/PageHeader.d.ts +8 -0
  642. package/dist/lib/components/PageHeader/PageHeader.d.ts.map +1 -0
  643. package/dist/lib/components/PageHeader/PageHeaderSkeleton.d.ts +10 -0
  644. package/dist/lib/components/PageHeader/PageHeaderSkeleton.d.ts.map +1 -0
  645. package/dist/lib/components/PageHeader/index.d.ts +3 -0
  646. package/dist/lib/components/PageHeader/index.d.ts.map +1 -0
  647. package/dist/lib/components/PhoneField/PhoneField.d.ts.map +1 -1
  648. package/dist/lib/components/RadioGroup/RadioGroup.d.ts +23 -0
  649. package/dist/lib/components/RadioGroup/RadioGroup.d.ts.map +1 -0
  650. package/dist/lib/components/RadioGroup/index.d.ts +3 -0
  651. package/dist/lib/components/RadioGroup/index.d.ts.map +1 -0
  652. package/dist/lib/components/Select/Select.d.ts +8 -10
  653. package/dist/lib/components/Select/Select.d.ts.map +1 -1
  654. package/dist/lib/components/Select/SelectFilter.d.ts +20 -0
  655. package/dist/lib/components/Select/SelectFilter.d.ts.map +1 -0
  656. package/dist/lib/components/Select/components/MultiSelect/MultiSelect.d.ts +3 -1
  657. package/dist/lib/components/Select/components/MultiSelect/MultiSelect.d.ts.map +1 -1
  658. package/dist/lib/components/Select/components/MultiSelect/MultiSelectFilter.d.ts +13 -6
  659. package/dist/lib/components/Select/components/MultiSelect/MultiSelectFilter.d.ts.map +1 -1
  660. package/dist/lib/components/Select/components/SingleSelect/SingleSelect.d.ts +17 -1
  661. package/dist/lib/components/Select/components/SingleSelect/SingleSelect.d.ts.map +1 -1
  662. package/dist/lib/components/Select/components/SingleSelect/SingleSelectFilter.d.ts +9 -2
  663. package/dist/lib/components/Select/components/SingleSelect/SingleSelectFilter.d.ts.map +1 -1
  664. package/dist/lib/components/Select/hooks/useMultiSelect.d.ts +2 -1
  665. package/dist/lib/components/Select/hooks/useMultiSelect.d.ts.map +1 -1
  666. package/dist/lib/components/Select/hooks/useSelect.d.ts +3 -1
  667. package/dist/lib/components/Select/hooks/useSelect.d.ts.map +1 -1
  668. package/dist/lib/components/Select/hooks/useSingleSelect.d.ts +2 -1
  669. package/dist/lib/components/Select/hooks/useSingleSelect.d.ts.map +1 -1
  670. package/dist/lib/components/Select/index.d.ts +4 -2
  671. package/dist/lib/components/Select/index.d.ts.map +1 -1
  672. package/dist/lib/components/Select/types.d.ts +8 -1
  673. package/dist/lib/components/Select/types.d.ts.map +1 -1
  674. package/dist/lib/components/Sidebar/Sidebar.d.ts +24 -0
  675. package/dist/lib/components/Sidebar/Sidebar.d.ts.map +1 -0
  676. package/dist/lib/components/Sidebar/index.d.ts +2 -0
  677. package/dist/lib/components/Sidebar/index.d.ts.map +1 -0
  678. package/dist/lib/components/Sortable/Sortable.d.ts +39 -0
  679. package/dist/lib/components/Sortable/Sortable.d.ts.map +1 -0
  680. package/dist/lib/components/Sortable/index.d.ts +3 -0
  681. package/dist/lib/components/Sortable/index.d.ts.map +1 -0
  682. package/dist/lib/components/StepProgressIndicator/StepProgressIndicator.d.ts +12 -0
  683. package/dist/lib/components/StepProgressIndicator/StepProgressIndicator.d.ts.map +1 -0
  684. package/dist/lib/components/StepProgressIndicator/index.d.ts +3 -0
  685. package/dist/lib/components/StepProgressIndicator/index.d.ts.map +1 -0
  686. package/dist/lib/components/Switch/Switch.d.ts.map +1 -1
  687. package/dist/lib/components/Tabs/Tabs.d.ts +27 -0
  688. package/dist/lib/components/Tabs/Tabs.d.ts.map +1 -0
  689. package/dist/lib/components/Tabs/TabsSkeleton.d.ts +11 -0
  690. package/dist/lib/components/Tabs/TabsSkeleton.d.ts.map +1 -0
  691. package/dist/lib/components/Tabs/index.d.ts +3 -0
  692. package/dist/lib/components/Tabs/index.d.ts.map +1 -0
  693. package/dist/lib/components/TextArea/TextArea.d.ts.map +1 -1
  694. package/dist/lib/components/UploadFile/UploadFile.d.ts +26 -0
  695. package/dist/lib/components/UploadFile/UploadFile.d.ts.map +1 -0
  696. package/dist/lib/components/UploadFile/index.d.ts +2 -0
  697. package/dist/lib/components/UploadFile/index.d.ts.map +1 -0
  698. package/dist/lib/components/ValueFilter/ValueFilter.d.ts +11 -0
  699. package/dist/lib/components/ValueFilter/ValueFilter.d.ts.map +1 -0
  700. package/dist/lib/components/ValueFilter/index.d.ts +3 -0
  701. package/dist/lib/components/ValueFilter/index.d.ts.map +1 -0
  702. package/dist/lib/components/ViewTabs/ViewTabs.d.ts +23 -0
  703. package/dist/lib/components/ViewTabs/ViewTabs.d.ts.map +1 -0
  704. package/dist/lib/components/ViewTabs/index.d.ts +3 -0
  705. package/dist/lib/components/ViewTabs/index.d.ts.map +1 -0
  706. package/dist/lib/components/index.d.ts +19 -0
  707. package/dist/lib/components/index.d.ts.map +1 -1
  708. package/dist/lib/config/index.d.ts +6 -0
  709. package/dist/lib/config/index.d.ts.map +1 -1
  710. package/dist/lib/context/ConfirmContext.d.ts +21 -0
  711. package/dist/lib/context/ConfirmContext.d.ts.map +1 -0
  712. package/dist/lib/context/index.d.ts +1 -0
  713. package/dist/lib/context/index.d.ts.map +1 -1
  714. package/dist/lib/hooks/index.d.ts +5 -0
  715. package/dist/lib/hooks/index.d.ts.map +1 -1
  716. package/dist/lib/hooks/useConfirm.d.ts +4 -0
  717. package/dist/lib/hooks/useConfirm.d.ts.map +1 -0
  718. package/dist/lib/hooks/useDialog.d.ts +11 -0
  719. package/dist/lib/hooks/useDialog.d.ts.map +1 -0
  720. package/dist/lib/hooks/useIsMobile.d.ts +2 -0
  721. package/dist/lib/hooks/useIsMobile.d.ts.map +1 -0
  722. package/dist/lib/hooks/useSlugParams.d.ts +12 -0
  723. package/dist/lib/hooks/useSlugParams.d.ts.map +1 -0
  724. package/dist/lib/hooks/useTimer.d.ts +6 -0
  725. package/dist/lib/hooks/useTimer.d.ts.map +1 -0
  726. package/dist/lib/index.d.ts +1 -0
  727. package/dist/lib/index.d.ts.map +1 -1
  728. package/dist/lib/selects/app/AppFilter.d.ts +11 -0
  729. package/dist/lib/selects/app/AppFilter.d.ts.map +1 -0
  730. package/dist/lib/selects/app/AppSelector.d.ts +4 -0
  731. package/dist/lib/selects/app/AppSelector.d.ts.map +1 -0
  732. package/dist/lib/selects/app/index.d.ts +3 -0
  733. package/dist/lib/selects/app/index.d.ts.map +1 -0
  734. package/dist/lib/selects/app-code/AppCodeFilter.d.ts +11 -0
  735. package/dist/lib/selects/app-code/AppCodeFilter.d.ts.map +1 -0
  736. package/dist/lib/selects/app-code/AppCodeSelector.d.ts +4 -0
  737. package/dist/lib/selects/app-code/AppCodeSelector.d.ts.map +1 -0
  738. package/dist/lib/selects/app-code/index.d.ts +3 -0
  739. package/dist/lib/selects/app-code/index.d.ts.map +1 -0
  740. package/dist/lib/selects/cloud-provider/CloudProviderFilter.d.ts +11 -0
  741. package/dist/lib/selects/cloud-provider/CloudProviderFilter.d.ts.map +1 -0
  742. package/dist/lib/selects/cloud-provider/CloudProviderSelector.d.ts +4 -0
  743. package/dist/lib/selects/cloud-provider/CloudProviderSelector.d.ts.map +1 -0
  744. package/dist/lib/selects/cloud-provider/index.d.ts +3 -0
  745. package/dist/lib/selects/cloud-provider/index.d.ts.map +1 -0
  746. package/dist/lib/selects/currency/CurrencyFilter.d.ts +11 -0
  747. package/dist/lib/selects/currency/CurrencyFilter.d.ts.map +1 -0
  748. package/dist/lib/selects/currency/CurrencySelector.d.ts +4 -0
  749. package/dist/lib/selects/currency/CurrencySelector.d.ts.map +1 -0
  750. package/dist/lib/selects/currency/currencies.d.ts +3 -0
  751. package/dist/lib/selects/currency/currencies.d.ts.map +1 -0
  752. package/dist/lib/selects/currency/index.d.ts +3 -0
  753. package/dist/lib/selects/currency/index.d.ts.map +1 -0
  754. package/dist/lib/selects/deployment/DeploymentFilter.d.ts +11 -0
  755. package/dist/lib/selects/deployment/DeploymentFilter.d.ts.map +1 -0
  756. package/dist/lib/selects/deployment/DeploymentSelector.d.ts +4 -0
  757. package/dist/lib/selects/deployment/DeploymentSelector.d.ts.map +1 -0
  758. package/dist/lib/selects/deployment/index.d.ts +3 -0
  759. package/dist/lib/selects/deployment/index.d.ts.map +1 -0
  760. package/dist/lib/selects/feature/FeatureFilter.d.ts +11 -0
  761. package/dist/lib/selects/feature/FeatureFilter.d.ts.map +1 -0
  762. package/dist/lib/selects/feature/FeatureSelector.d.ts +4 -0
  763. package/dist/lib/selects/feature/FeatureSelector.d.ts.map +1 -0
  764. package/dist/lib/selects/feature/index.d.ts +3 -0
  765. package/dist/lib/selects/feature/index.d.ts.map +1 -0
  766. package/dist/lib/selects/index.d.ts +12 -0
  767. package/dist/lib/selects/index.d.ts.map +1 -0
  768. package/dist/lib/selects/industry/IndustryFilter.d.ts +11 -0
  769. package/dist/lib/selects/industry/IndustryFilter.d.ts.map +1 -0
  770. package/dist/lib/selects/industry/IndustrySelector.d.ts +4 -0
  771. package/dist/lib/selects/industry/IndustrySelector.d.ts.map +1 -0
  772. package/dist/lib/selects/industry/index.d.ts +3 -0
  773. package/dist/lib/selects/industry/index.d.ts.map +1 -0
  774. package/dist/lib/selects/locale/LocaleFilter.d.ts +11 -0
  775. package/dist/lib/selects/locale/LocaleFilter.d.ts.map +1 -0
  776. package/dist/lib/selects/locale/LocaleSelector.d.ts +4 -0
  777. package/dist/lib/selects/locale/LocaleSelector.d.ts.map +1 -0
  778. package/dist/lib/selects/locale/index.d.ts +3 -0
  779. package/dist/lib/selects/locale/index.d.ts.map +1 -0
  780. package/dist/lib/selects/locale/locales.d.ts +3 -0
  781. package/dist/lib/selects/locale/locales.d.ts.map +1 -0
  782. package/dist/lib/selects/microfrontend/MicrofrontendSelector.d.ts +4 -0
  783. package/dist/lib/selects/microfrontend/MicrofrontendSelector.d.ts.map +1 -0
  784. package/dist/lib/selects/microfrontend/index.d.ts +2 -0
  785. package/dist/lib/selects/microfrontend/index.d.ts.map +1 -0
  786. package/dist/lib/selects/plan/PlanFilter.d.ts +11 -0
  787. package/dist/lib/selects/plan/PlanFilter.d.ts.map +1 -0
  788. package/dist/lib/selects/plan/PlanSelector.d.ts +4 -0
  789. package/dist/lib/selects/plan/PlanSelector.d.ts.map +1 -0
  790. package/dist/lib/selects/plan/index.d.ts +3 -0
  791. package/dist/lib/selects/plan/index.d.ts.map +1 -0
  792. package/dist/lib/selects/region/RegionFilter.d.ts +11 -0
  793. package/dist/lib/selects/region/RegionFilter.d.ts.map +1 -0
  794. package/dist/lib/selects/region/RegionSelector.d.ts +4 -0
  795. package/dist/lib/selects/region/RegionSelector.d.ts.map +1 -0
  796. package/dist/lib/selects/region/index.d.ts +3 -0
  797. package/dist/lib/selects/region/index.d.ts.map +1 -0
  798. package/dist/lib/selects/timezone/TimezoneFilter.d.ts +11 -0
  799. package/dist/lib/selects/timezone/TimezoneFilter.d.ts.map +1 -0
  800. package/dist/lib/selects/timezone/TimezoneSelector.d.ts +4 -0
  801. package/dist/lib/selects/timezone/TimezoneSelector.d.ts.map +1 -0
  802. package/dist/lib/selects/timezone/index.d.ts +3 -0
  803. package/dist/lib/selects/timezone/index.d.ts.map +1 -0
  804. package/dist/lib/selects/timezone/timezones.d.ts +3 -0
  805. package/dist/lib/selects/timezone/timezones.d.ts.map +1 -0
  806. package/dist/lib/services/table-views.service.d.ts +25 -0
  807. package/dist/lib/services/table-views.service.d.ts.map +1 -0
  808. package/dist/lib/types/api-response.d.ts +21 -0
  809. package/dist/lib/types/api-response.d.ts.map +1 -0
  810. package/dist/lib/types/table-filter.d.ts +41 -0
  811. package/dist/lib/types/table-filter.d.ts.map +1 -0
  812. package/dist/lib/utils/axios.d.ts.map +1 -1
  813. package/dist/lib/utils/index.d.ts +1 -0
  814. package/dist/lib/utils/index.d.ts.map +1 -1
  815. package/dist/lib/utils/motion.d.ts +2 -0
  816. package/dist/lib/utils/motion.d.ts.map +1 -0
  817. package/dist/lib/utils/slug.d.ts +7 -0
  818. package/dist/lib/utils/slug.d.ts.map +1 -0
  819. package/dist/plus.js +18 -0
  820. package/dist/plus.js.map +1 -0
  821. package/dist/popover.js +3 -299
  822. package/dist/popover.js.map +1 -1
  823. package/dist/proxy.js +11392 -0
  824. package/dist/proxy.js.map +1 -0
  825. package/dist/react-error-boundary.js +67 -0
  826. package/dist/react-error-boundary.js.map +1 -0
  827. package/dist/select2.js +116 -0
  828. package/dist/select2.js.map +1 -0
  829. package/dist/selects/app-code.js +37 -0
  830. package/dist/selects/app-code.js.map +1 -0
  831. package/dist/selects/app.js +2 -0
  832. package/dist/selects/app.js.map +1 -0
  833. package/dist/selects/cloud-provider.js +2 -0
  834. package/dist/selects/cloud-provider.js.map +1 -0
  835. package/dist/selects/currency.js +2 -0
  836. package/dist/selects/currency.js.map +1 -0
  837. package/dist/selects/deployment.js +2 -0
  838. package/dist/selects/deployment.js.map +1 -0
  839. package/dist/selects/feature.js +2 -0
  840. package/dist/selects/feature.js.map +1 -0
  841. package/dist/selects/industry.js +2 -0
  842. package/dist/selects/industry.js.map +1 -0
  843. package/dist/selects/locale.js +2 -0
  844. package/dist/selects/locale.js.map +1 -0
  845. package/dist/selects/microfrontend.js +2 -0
  846. package/dist/selects/microfrontend.js.map +1 -0
  847. package/dist/selects/plan.js +2 -0
  848. package/dist/selects/plan.js.map +1 -0
  849. package/dist/selects/region.js +2 -0
  850. package/dist/selects/region.js.map +1 -0
  851. package/dist/selects/timezone.js +2 -0
  852. package/dist/selects/timezone.js.map +1 -0
  853. package/dist/separator2.js +2 -28
  854. package/dist/separator2.js.map +1 -1
  855. package/dist/shadcn/index.d.ts +2 -0
  856. package/dist/shadcn/index.d.ts.map +1 -1
  857. package/dist/shadcn/shadcnBreadcrumb/breadcrumb.d.ts +18 -0
  858. package/dist/shadcn/shadcnBreadcrumb/breadcrumb.d.ts.map +1 -0
  859. package/dist/shadcn/shadcnBreadcrumb/index.d.ts +2 -0
  860. package/dist/shadcn/shadcnBreadcrumb/index.d.ts.map +1 -0
  861. package/dist/shadcn/shadcnCalendar/calendar.d.ts +1 -1
  862. package/dist/shadcn/shadcnCalendar/calendar.d.ts.map +1 -1
  863. package/dist/shadcn/shadcnChart/Chart.d.ts +2 -2
  864. package/dist/shadcn/shadcnChart/Chart.d.ts.map +1 -1
  865. package/dist/shadcn/shadcnCollapsible/collapsible.d.ts +7 -0
  866. package/dist/shadcn/shadcnCollapsible/collapsible.d.ts.map +1 -0
  867. package/dist/shadcn/shadcnCollapsible/index.d.ts +2 -0
  868. package/dist/shadcn/shadcnCollapsible/index.d.ts.map +1 -0
  869. package/dist/shadcn/shadcnDialog/dialog.d.ts +20 -0
  870. package/dist/shadcn/shadcnDialog/dialog.d.ts.map +1 -0
  871. package/dist/shadcn/shadcnDialog/index.d.ts +2 -0
  872. package/dist/shadcn/shadcnDialog/index.d.ts.map +1 -0
  873. package/dist/shadcn/shadcnDropdownMenu/dropdown-menu.d.ts +1 -1
  874. package/dist/shadcn/shadcnDropdownMenu/dropdown-menu.d.ts.map +1 -1
  875. package/dist/shadcn/shadcnForm/form.d.ts +1 -1
  876. package/dist/shadcn/shadcnForm/form.d.ts.map +1 -1
  877. package/dist/shadcn/shadcnInputOTP/InputOTP.d.ts +1 -1
  878. package/dist/shadcn/shadcnInputOTP/InputOTP.d.ts.map +1 -1
  879. package/dist/shadcn/shadcnMultiSelect/multi-select.d.ts +1 -1
  880. package/dist/shadcn/shadcnMultiSelect/multi-select.d.ts.map +1 -1
  881. package/dist/shadcn/shadcnProgress/Progress.d.ts +1 -1
  882. package/dist/shadcn/shadcnProgress/Progress.d.ts.map +1 -1
  883. package/dist/shadcn/shadcnRadioGroup/RadioGroup.d.ts +6 -0
  884. package/dist/shadcn/shadcnRadioGroup/RadioGroup.d.ts.map +1 -0
  885. package/dist/shadcn/shadcnRadioGroup/index.d.ts +2 -0
  886. package/dist/shadcn/shadcnRadioGroup/index.d.ts.map +1 -0
  887. package/dist/shadcn/shadcnSheet/sheet.d.ts +1 -1
  888. package/dist/shadcn/shadcnSheet/sheet.d.ts.map +1 -1
  889. package/dist/shadcn/shadcnSidebar/index.d.ts +2 -0
  890. package/dist/shadcn/shadcnSidebar/index.d.ts.map +1 -0
  891. package/dist/shadcn/shadcnSidebar/sidebar.d.ts +86 -0
  892. package/dist/shadcn/shadcnSidebar/sidebar.d.ts.map +1 -0
  893. package/dist/shadcn/shadcnSingleSelect/single-select.d.ts +2 -1
  894. package/dist/shadcn/shadcnSingleSelect/single-select.d.ts.map +1 -1
  895. package/dist/shadcn/shadcnSwitch/Switch.d.ts.map +1 -1
  896. package/dist/shadcn/shadcnTable/table.d.ts +1 -1
  897. package/dist/shadcn/shadcnTable/table.d.ts.map +1 -1
  898. package/dist/shadcn/shadcnTabs/index.d.ts +2 -0
  899. package/dist/shadcn/shadcnTabs/index.d.ts.map +1 -0
  900. package/dist/shadcn/shadcnTabs/tabs.d.ts +8 -0
  901. package/dist/shadcn/shadcnTabs/tabs.d.ts.map +1 -0
  902. package/dist/shadcn/shadcnTooltip/tooltip.d.ts +1 -1
  903. package/dist/shadcn/shadcnTooltip/tooltip.d.ts.map +1 -1
  904. package/dist/share-2.js +42 -0
  905. package/dist/share-2.js.map +1 -0
  906. package/dist/text-align-justify.js +34 -0
  907. package/dist/text-align-justify.js.map +1 -0
  908. package/dist/trash-2.js +55 -0
  909. package/dist/trash-2.js.map +1 -0
  910. package/dist/types/api-response.js +2 -0
  911. package/dist/types/api-response.js.map +1 -0
  912. package/dist/types/table-filter.js +17 -0
  913. package/dist/types/table-filter.js.map +1 -0
  914. package/dist/upload.js +19 -0
  915. package/dist/upload.js.map +1 -0
  916. package/dist/useConfirm.js +37 -0
  917. package/dist/useConfirm.js.map +1 -0
  918. package/dist/useDataTable.js +26545 -0
  919. package/dist/useDataTable.js.map +1 -0
  920. package/dist/useIsMobile.js +19 -0
  921. package/dist/useIsMobile.js.map +1 -0
  922. package/dist/{useSSE.js → useTimer.js} +33 -3
  923. package/dist/useTimer.js.map +1 -0
  924. package/dist/utils/axios.js +2 -4167
  925. package/dist/utils/axios.js.map +1 -1
  926. package/dist/utils/motion.js +4425 -0
  927. package/dist/utils/motion.js.map +1 -0
  928. package/dist/utils/slug.js +15 -0
  929. package/dist/utils/slug.js.map +1 -0
  930. package/dist/utils.js +3137 -3750
  931. package/dist/utils.js.map +1 -1
  932. package/dist/value.js +820 -0
  933. package/dist/value.js.map +1 -0
  934. package/package.json +186 -3
  935. package/dist/lib/components/DataTable/components/DataTableToolbar.d.ts +0 -15
  936. package/dist/lib/components/DataTable/components/DataTableToolbar.d.ts.map +0 -1
  937. package/dist/useSSE.js.map +0 -1
  938. package/dist/utils2.js +0 -3042
  939. package/dist/utils2.js.map +0 -1
@@ -0,0 +1,4425 @@
1
+ import { c as clamp, i as isEasingArray, N as NativeAnimation, s as supportedWaapiEasing, a as supportsLinearEasing, b as isBezierDefinition, d as memo, r as resolveElements, g as getValueAsType, n as numberValueTypes, f as frame, e as cancelFrame, h as camelToDash, t as transformPropOrder, j as transformProps, k as isHTMLElement, M as MotionValue, l as isCSSVar, o as statsBuffer, p as frameData, q as activeAnimations, v as easingDefinitionToFunction, w as interpolate, x as isMotionValue, y as motionValue, J as JSAnimation, z as collectMotionValues, B as getValueTransition$1, C as secondsToMilliseconds, D as applyGeneratorOptions, E as mapEasingToNativeEasing, F as microtask, G as removeItem, H as noop$1, V as VisualElement, I as createBox, K as visualElementStore, O as copyBoxInto, P as HTMLVisualElement, Q as HTMLProjectionNode, R as stepsOrder, S as loadFeatures, T as LazyContext, U as MotionConfigContext, W as resolveTransition, X as useConstant, Y as loadExternalIsValidProp, Z as createMotionProxy, _ as gestureAnimations, $ as animations, a0 as createDomVisualElement, a1 as layout, a2 as drag, a3 as supportsViewTimeline, a4 as supportsScrollTimeline, a5 as progress, a6 as velocityPerSecond, a7 as defaultOffset$1, a8 as warnOnce, a9 as resize, u as useIsomorphicLayoutEffect, aa as invariant, ab as acceleratedValues, ac as hasReducedMotionListener, ad as initPrefersReducedMotion, ae as prefersReducedMotion, af as animateVisualElement, ag as setTarget, ah as mixNumber, ai as createGeneratorEasing, aj as fillOffset, ak as isGenerator, al as isSVGElement, am as isSVGSVGElement, an as SVGVisualElement, ao as animateSingleValue, ap as animateTarget, aq as spring, ar as fillWildcards, as as PresenceContext, at as addDomEvent, au as motionComponentSymbol, av as rootProjectionNode, aw as MotionGlobalConfig, ax as optimizedAppearDataId, ay as startWaapiAnimation, az as getOptimisedAppearId, aA as makeUseVisualState, aB as MotionContext, aC as warning, aD as moveItem, m as motion } from '../proxy.js';
2
+ export { A as AnimatePresence, aE as AsyncMotionValueAnimation, aF as DOMKeyframesResolver, aG as DOMVisualElement, aH as DocumentProjectionNode, aI as Feature, aJ as FlatTree, aK as KeyframeResolver, L as LayoutGroupContext, aL as NativeAnimationExtended, aM as NodeStack, aN as PopChild, aO as PresenceChild, aP as SubscriptionManager, aQ as SwitchLayoutGroupContext, aR as addPointerEvent, aS as addPointerInfo, aT as addScaleCorrector, aU as addUniqueItem, aV as addValueToWillChange, aW as alpha, aX as analyseComplexValue, aY as animateMotionValue, aZ as animateValue, a_ as animateVariant, a$ as anticipate, b0 as applyAxisDelta, b1 as applyBoxDelta, b2 as applyPointDelta, b3 as applyTreeDeltas, b4 as aspectRatio, b5 as axisDeltaEquals, b6 as axisEquals, b7 as axisEqualsRounded, b8 as backIn, b9 as backInOut, ba as backOut, bb as boxEquals, bc as boxEqualsRounded, bd as buildHTMLStyles, be as buildProjectionTransform, bf as buildSVGAttrs, bg as buildSVGPath, bh as buildTransform, bi as calcAxisDelta, bj as calcBoxDelta, bk as calcChildStagger, bl as calcGeneratorDuration, bm as calcLength, bn as calcRelativeAxis, bo as calcRelativeAxisPosition, bp as calcRelativeBox, bq as calcRelativePosition, br as camelCaseAttributes, bs as cancelMicrotask, bt as checkVariantsDidChange, bu as circIn, bv as circInOut, bw as circOut, bx as cleanDirtyNodes, by as color, bz as compareByDepth, bA as complex, bB as containsCSSVariable, bC as convertBoundingBoxToBox, bD as convertBoxToBoundingBox, bE as convertOffsetToTimes, bF as copyAxisDeltaInto, bG as copyAxisInto, bH as correctBorderRadius, bI as correctBoxShadow, bJ as createAnimationState, bK as createAxis, bL as createAxisDelta, bM as createDelta, bN as createProjectionNode, bO as createRenderBatcher, bP as cubicBezier, bQ as cubicBezierAsString, bR as defaultEasing, bS as defaultTransformValue, bT as defaultValueTypes, bU as degrees, bV as delay, bW as delayInSeconds, bX as dimensionValueTypes, bY as distance, bZ as distance2D, b_ as eachAxis, b$ as easeIn, c0 as easeInOut, c1 as easeOut, c2 as filterProps, c3 as findDimensionValueType, c4 as findValueType, c5 as flushKeyframeResolvers, c6 as frameSteps, c7 as generateLinearEasing, c8 as getAnimatableNone, c9 as getDefaultTransition, ca as getDefaultValueType, cb as getFeatureDefinitions, cc as getFinalKeyframe, cd as getMixer, ce as getVariableValue, cf as getVariantContext, cg as globalProjectionState, ch as has2DTranslate, ci as hasScale, cj as hasTransform, ck as hasWarned, cl as hex, cm as hover, cn as hsla, co as hslaToRgba, cp as inertia, cq as invisibleValues, cr as isAnimationControls, cs as isBrowser, ct as isCSSVariableName, cu as isCSSVariableToken, cv as isControllingVariants, cw as isDeltaZero, cx as isDragActive, cy as isDragging, cz as isElementKeyboardAccessible, cA as isElementTextInput, cB as isForcedMotionValue, cC as isKeyframesTarget, cD as isNear, cE as isNodeOrChild, cF as isNumericalString, cG as isObject, cH as isPrimaryPointer, cI as isSVGTag, cJ as isTransitionDefined, cK as isValidMotionProp, cL as isVariantLabel, cM as isVariantNode, cN as isWillChangeMotionValue, cO as isZeroValueString, cP as keyframes, cQ as makeAnimationInstant, cR as maxGeneratorDuration, cS as measurePageBox, cT as measureViewportBox, cU as millisecondsToSeconds, cV as mirrorEasing, cW as mix, cX as mixArray, cY as mixColor, cZ as mixComplex, c_ as mixImmediate, c$ as mixLinearColor, d0 as mixObject, d1 as mixValues, d2 as mixVisibility, d3 as number, d4 as optimizedAppearDataAttribute, d5 as parseCSSVariable, d6 as parseValueFromTransform, d7 as percent, d8 as pipe, d9 as pixelsToPercent, da as positionalKeys, db as press, dc as progressPercentage, dd as propagateDirtyNodes, de as px, df as readTransformValue, dg as removeAxisDelta, dh as removeAxisTransforms, di as removeBoxTransforms, dj as removePointDelta, dk as renderHTML, dl as renderSVG, dm as resolveMotionValue, dn as resolveVariant, dp as resolveVariantFromProps, dq as reverseEasing, dr as rgbUnit, ds as rgba, dt as scale, du as scaleCorrectors, dv as scalePoint, dw as scrapeHTMLMotionValuesFromProps, dx as scrapeSVGMotionValuesFromProps, dy as setDragLock, dz as setFeatureDefinitions, dA as setStyle, dB as supportsBrowserAnimation, dC as supportsFlags, dD as testValueType, dE as time, dF as transformAxis, dG as transformBox, dH as transformBoxPoints, dI as transformValueTypes, dJ as translateAxis, dK as updateMotionValuesFromProps, dL as useComposedRefs, dM as useIsPresent, dN as usePresence, dO as variantPriorityOrder, dP as variantProps, dQ as vh, dR as vw } from '../proxy.js';
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import * as React from 'react';
5
+ import { useState, useRef, useEffect, useContext, useMemo, useInsertionEffect, useCallback, useLayoutEffect, createContext, forwardRef } from 'react';
6
+ import { u as useForceUpdate, L as LayoutGroup } from '../index29.js';
7
+ export { D as DeprecatedLayoutGroupContext, n as nodeGroup } from '../index29.js';
8
+
9
+ const wrap = (min, max, v) => {
10
+ const rangeSize = max - min;
11
+ return ((((v - min) % rangeSize) + rangeSize) % rangeSize) + min;
12
+ };
13
+
14
+ function steps(numSteps, direction = "end") {
15
+ return (progress) => {
16
+ progress =
17
+ direction === "end"
18
+ ? Math.min(progress, 0.999)
19
+ : Math.max(progress, 0.001);
20
+ const expanded = progress * numSteps;
21
+ const rounded = direction === "end" ? Math.floor(expanded) : Math.ceil(expanded);
22
+ return clamp(0, 1, rounded / numSteps);
23
+ };
24
+ }
25
+
26
+ function getEasingForSegment(easing, i) {
27
+ return isEasingArray(easing) ? easing[wrap(0, easing.length, i)] : easing;
28
+ }
29
+
30
+ class GroupAnimation {
31
+ constructor(animations) {
32
+ // Bound to accomadate common `return animation.stop` pattern
33
+ this.stop = () => this.runAll("stop");
34
+ this.animations = animations.filter(Boolean);
35
+ }
36
+ get finished() {
37
+ return Promise.all(this.animations.map((animation) => animation.finished));
38
+ }
39
+ /**
40
+ * TODO: Filter out cancelled or stopped animations before returning
41
+ */
42
+ getAll(propName) {
43
+ return this.animations[0][propName];
44
+ }
45
+ setAll(propName, newValue) {
46
+ for (let i = 0; i < this.animations.length; i++) {
47
+ this.animations[i][propName] = newValue;
48
+ }
49
+ }
50
+ attachTimeline(timeline) {
51
+ const subscriptions = this.animations.map((animation) => animation.attachTimeline(timeline));
52
+ return () => {
53
+ subscriptions.forEach((cancel, i) => {
54
+ cancel && cancel();
55
+ this.animations[i].stop();
56
+ });
57
+ };
58
+ }
59
+ get time() {
60
+ return this.getAll("time");
61
+ }
62
+ set time(time) {
63
+ this.setAll("time", time);
64
+ }
65
+ get speed() {
66
+ return this.getAll("speed");
67
+ }
68
+ set speed(speed) {
69
+ this.setAll("speed", speed);
70
+ }
71
+ get state() {
72
+ return this.getAll("state");
73
+ }
74
+ get startTime() {
75
+ return this.getAll("startTime");
76
+ }
77
+ get duration() {
78
+ return getMax(this.animations, "duration");
79
+ }
80
+ get iterationDuration() {
81
+ return getMax(this.animations, "iterationDuration");
82
+ }
83
+ runAll(methodName) {
84
+ this.animations.forEach((controls) => controls[methodName]());
85
+ }
86
+ play() {
87
+ this.runAll("play");
88
+ }
89
+ pause() {
90
+ this.runAll("pause");
91
+ }
92
+ cancel() {
93
+ this.runAll("cancel");
94
+ }
95
+ complete() {
96
+ this.runAll("complete");
97
+ }
98
+ }
99
+ function getMax(animations, propName) {
100
+ let max = 0;
101
+ for (let i = 0; i < animations.length; i++) {
102
+ const value = animations[i][propName];
103
+ if (value !== null && value > max) {
104
+ max = value;
105
+ }
106
+ }
107
+ return max;
108
+ }
109
+
110
+ class GroupAnimationWithThen extends GroupAnimation {
111
+ then(onResolve, _onReject) {
112
+ return this.finished.finally(onResolve).then(() => { });
113
+ }
114
+ }
115
+
116
+ class NativeAnimationWrapper extends NativeAnimation {
117
+ constructor(animation) {
118
+ super();
119
+ this.animation = animation;
120
+ animation.onfinish = () => {
121
+ this.finishedTime = this.time;
122
+ this.notifyFinished();
123
+ };
124
+ }
125
+ }
126
+
127
+ const animationMaps = new WeakMap();
128
+ const animationMapKey = (name, pseudoElement = "") => `${name}:${pseudoElement}`;
129
+ function getAnimationMap(element) {
130
+ let map = animationMaps.get(element);
131
+ if (!map) {
132
+ map = new Map();
133
+ animationMaps.set(element, map);
134
+ }
135
+ return map;
136
+ }
137
+
138
+ const pxValues = new Set([
139
+ // Border props
140
+ "borderWidth",
141
+ "borderTopWidth",
142
+ "borderRightWidth",
143
+ "borderBottomWidth",
144
+ "borderLeftWidth",
145
+ "borderRadius",
146
+ "borderTopLeftRadius",
147
+ "borderTopRightRadius",
148
+ "borderBottomRightRadius",
149
+ "borderBottomLeftRadius",
150
+ // Positioning props
151
+ "width",
152
+ "maxWidth",
153
+ "height",
154
+ "maxHeight",
155
+ "top",
156
+ "right",
157
+ "bottom",
158
+ "left",
159
+ "inset",
160
+ "insetBlock",
161
+ "insetBlockStart",
162
+ "insetBlockEnd",
163
+ "insetInline",
164
+ "insetInlineStart",
165
+ "insetInlineEnd",
166
+ // Spacing props
167
+ "padding",
168
+ "paddingTop",
169
+ "paddingRight",
170
+ "paddingBottom",
171
+ "paddingLeft",
172
+ "paddingBlock",
173
+ "paddingBlockStart",
174
+ "paddingBlockEnd",
175
+ "paddingInline",
176
+ "paddingInlineStart",
177
+ "paddingInlineEnd",
178
+ "margin",
179
+ "marginTop",
180
+ "marginRight",
181
+ "marginBottom",
182
+ "marginLeft",
183
+ "marginBlock",
184
+ "marginBlockStart",
185
+ "marginBlockEnd",
186
+ "marginInline",
187
+ "marginInlineStart",
188
+ "marginInlineEnd",
189
+ // Typography
190
+ "fontSize",
191
+ // Misc
192
+ "backgroundPositionX",
193
+ "backgroundPositionY",
194
+ ]);
195
+
196
+ function applyPxDefaults(keyframes, name) {
197
+ for (let i = 0; i < keyframes.length; i++) {
198
+ if (typeof keyframes[i] === "number" && pxValues.has(name)) {
199
+ keyframes[i] = keyframes[i] + "px";
200
+ }
201
+ }
202
+ }
203
+
204
+ function isWaapiSupportedEasing(easing) {
205
+ return Boolean((typeof easing === "function" && supportsLinearEasing()) ||
206
+ !easing ||
207
+ (typeof easing === "string" &&
208
+ (easing in supportedWaapiEasing || supportsLinearEasing())) ||
209
+ isBezierDefinition(easing) ||
210
+ (Array.isArray(easing) && easing.every(isWaapiSupportedEasing)));
211
+ }
212
+
213
+ const supportsPartialKeyframes = /*@__PURE__*/ memo(() => {
214
+ try {
215
+ document.createElement("div").animate({ opacity: [1] });
216
+ }
217
+ catch (e) {
218
+ return false;
219
+ }
220
+ return true;
221
+ });
222
+
223
+ function createSelectorEffect(subjectEffect) {
224
+ return (subject, values) => {
225
+ const elements = resolveElements(subject);
226
+ const subscriptions = [];
227
+ for (const element of elements) {
228
+ const remove = subjectEffect(element, values);
229
+ subscriptions.push(remove);
230
+ }
231
+ return () => {
232
+ for (const remove of subscriptions)
233
+ remove();
234
+ };
235
+ };
236
+ }
237
+
238
+ class MotionValueState {
239
+ constructor() {
240
+ this.latest = {};
241
+ this.values = new Map();
242
+ }
243
+ set(name, value, render, computed, useDefaultValueType = true) {
244
+ const existingValue = this.values.get(name);
245
+ if (existingValue) {
246
+ existingValue.onRemove();
247
+ }
248
+ const onChange = () => {
249
+ const v = value.get();
250
+ if (useDefaultValueType) {
251
+ this.latest[name] = getValueAsType(v, numberValueTypes[name]);
252
+ }
253
+ else {
254
+ this.latest[name] = v;
255
+ }
256
+ render && frame.render(render);
257
+ };
258
+ onChange();
259
+ const cancelOnChange = value.on("change", onChange);
260
+ computed && value.addDependent(computed);
261
+ const remove = () => {
262
+ cancelOnChange();
263
+ render && cancelFrame(render);
264
+ this.values.delete(name);
265
+ computed && value.removeDependent(computed);
266
+ };
267
+ this.values.set(name, { value, onRemove: remove });
268
+ return remove;
269
+ }
270
+ get(name) {
271
+ return this.values.get(name)?.value;
272
+ }
273
+ }
274
+
275
+ function createEffect(addValue) {
276
+ const stateCache = new WeakMap();
277
+ return (subject, values) => {
278
+ const state = stateCache.get(subject) ?? new MotionValueState();
279
+ stateCache.set(subject, state);
280
+ const subscriptions = [];
281
+ for (const key in values) {
282
+ const value = values[key];
283
+ const remove = addValue(subject, state, key, value);
284
+ subscriptions.push(remove);
285
+ }
286
+ return () => {
287
+ for (const cancel of subscriptions)
288
+ cancel();
289
+ };
290
+ };
291
+ }
292
+
293
+ function canSetAsProperty(element, name) {
294
+ if (!(name in element))
295
+ return false;
296
+ const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(element), name) ||
297
+ Object.getOwnPropertyDescriptor(element, name);
298
+ // Check if it has a setter
299
+ return descriptor && typeof descriptor.set === "function";
300
+ }
301
+ const addAttrValue = (element, state, key, value) => {
302
+ const isProp = canSetAsProperty(element, key);
303
+ const name = isProp
304
+ ? key
305
+ : key.startsWith("data") || key.startsWith("aria")
306
+ ? camelToDash(key)
307
+ : key;
308
+ /**
309
+ * Set attribute directly via property if available
310
+ */
311
+ const render = isProp
312
+ ? () => {
313
+ element[name] = state.latest[key];
314
+ }
315
+ : () => {
316
+ const v = state.latest[key];
317
+ if (v === null || v === undefined) {
318
+ element.removeAttribute(name);
319
+ }
320
+ else {
321
+ element.setAttribute(name, String(v));
322
+ }
323
+ };
324
+ return state.set(key, value, render);
325
+ };
326
+ const attrEffect = /*@__PURE__*/ createSelectorEffect(
327
+ /*@__PURE__*/ createEffect(addAttrValue));
328
+
329
+ const propEffect = /*@__PURE__*/ createEffect((subject, state, key, value) => {
330
+ return state.set(key, value, () => {
331
+ subject[key] = state.latest[key];
332
+ }, undefined, false);
333
+ });
334
+
335
+ const translateAlias = {
336
+ x: "translateX",
337
+ y: "translateY",
338
+ z: "translateZ",
339
+ transformPerspective: "perspective",
340
+ };
341
+ function buildTransform(state) {
342
+ let transform = "";
343
+ let transformIsDefault = true;
344
+ /**
345
+ * Loop over all possible transforms in order, adding the ones that
346
+ * are present to the transform string.
347
+ */
348
+ for (let i = 0; i < transformPropOrder.length; i++) {
349
+ const key = transformPropOrder[i];
350
+ const value = state.latest[key];
351
+ if (value === undefined)
352
+ continue;
353
+ let valueIsDefault = true;
354
+ if (typeof value === "number") {
355
+ valueIsDefault = value === (key.startsWith("scale") ? 1 : 0);
356
+ }
357
+ else {
358
+ const parsed = parseFloat(value);
359
+ valueIsDefault = key.startsWith("scale") ? parsed === 1 : parsed === 0;
360
+ }
361
+ if (!valueIsDefault) {
362
+ transformIsDefault = false;
363
+ const transformName = translateAlias[key] || key;
364
+ transform += `${transformName}(${value}) `;
365
+ }
366
+ }
367
+ return transformIsDefault ? "none" : transform.trim();
368
+ }
369
+
370
+ const originProps = new Set(["originX", "originY", "originZ"]);
371
+ const addStyleValue = (element, state, key, value) => {
372
+ let render = undefined;
373
+ let computed = undefined;
374
+ if (transformProps.has(key)) {
375
+ if (!state.get("transform")) {
376
+ // If this is an HTML element, we need to set the transform-box to fill-box
377
+ // to normalise the transform relative to the element's bounding box
378
+ if (!isHTMLElement(element) && !state.get("transformBox")) {
379
+ addStyleValue(element, state, "transformBox", new MotionValue("fill-box"));
380
+ }
381
+ state.set("transform", new MotionValue("none"), () => {
382
+ element.style.transform = buildTransform(state);
383
+ });
384
+ }
385
+ computed = state.get("transform");
386
+ }
387
+ else if (originProps.has(key)) {
388
+ if (!state.get("transformOrigin")) {
389
+ state.set("transformOrigin", new MotionValue(""), () => {
390
+ const originX = state.latest.originX ?? "50%";
391
+ const originY = state.latest.originY ?? "50%";
392
+ const originZ = state.latest.originZ ?? 0;
393
+ element.style.transformOrigin = `${originX} ${originY} ${originZ}`;
394
+ });
395
+ }
396
+ computed = state.get("transformOrigin");
397
+ }
398
+ else if (isCSSVar(key)) {
399
+ render = () => {
400
+ element.style.setProperty(key, state.latest[key]);
401
+ };
402
+ }
403
+ else {
404
+ render = () => {
405
+ element.style[key] = state.latest[key];
406
+ };
407
+ }
408
+ return state.set(key, value, render, computed);
409
+ };
410
+ const styleEffect = /*@__PURE__*/ createSelectorEffect(
411
+ /*@__PURE__*/ createEffect(addStyleValue));
412
+
413
+ function addSVGPathValue(element, state, key, value) {
414
+ frame.render(() => element.setAttribute("pathLength", "1"));
415
+ if (key === "pathOffset") {
416
+ return state.set(key, value, () => {
417
+ // Use unitless value to avoid Safari zoom bug
418
+ const offset = state.latest[key];
419
+ element.setAttribute("stroke-dashoffset", `${-offset}`);
420
+ });
421
+ }
422
+ else {
423
+ if (!state.get("stroke-dasharray")) {
424
+ state.set("stroke-dasharray", new MotionValue("1 1"), () => {
425
+ const { pathLength = 1, pathSpacing } = state.latest;
426
+ // Use unitless values to avoid Safari zoom bug
427
+ element.setAttribute("stroke-dasharray", `${pathLength} ${pathSpacing ?? 1 - Number(pathLength)}`);
428
+ });
429
+ }
430
+ return state.set(key, value, undefined, state.get("stroke-dasharray"));
431
+ }
432
+ }
433
+ const addSVGValue = (element, state, key, value) => {
434
+ if (key.startsWith("path")) {
435
+ return addSVGPathValue(element, state, key, value);
436
+ }
437
+ else if (key.startsWith("attr")) {
438
+ return addAttrValue(element, state, convertAttrKey(key), value);
439
+ }
440
+ const handler = key in element.style ? addStyleValue : addAttrValue;
441
+ return handler(element, state, key, value);
442
+ };
443
+ const svgEffect = /*@__PURE__*/ createSelectorEffect(
444
+ /*@__PURE__*/ createEffect(addSVGValue));
445
+ function convertAttrKey(key) {
446
+ return key.replace(/^attr([A-Z])/, (_, firstChar) => firstChar.toLowerCase());
447
+ }
448
+
449
+ function getComputedStyle$1(element, name) {
450
+ const computedStyle = window.getComputedStyle(element);
451
+ return isCSSVar(name)
452
+ ? computedStyle.getPropertyValue(name)
453
+ : computedStyle[name];
454
+ }
455
+
456
+ function observeTimeline(update, timeline) {
457
+ let prevProgress;
458
+ const onFrame = () => {
459
+ const { currentTime } = timeline;
460
+ const percentage = currentTime === null ? 0 : currentTime.value;
461
+ const progress = percentage / 100;
462
+ if (prevProgress !== progress) {
463
+ update(progress);
464
+ }
465
+ prevProgress = progress;
466
+ };
467
+ frame.preUpdate(onFrame, true);
468
+ return () => cancelFrame(onFrame);
469
+ }
470
+
471
+ function record() {
472
+ const { value } = statsBuffer;
473
+ if (value === null) {
474
+ cancelFrame(record);
475
+ return;
476
+ }
477
+ value.frameloop.rate.push(frameData.delta);
478
+ value.animations.mainThread.push(activeAnimations.mainThread);
479
+ value.animations.waapi.push(activeAnimations.waapi);
480
+ value.animations.layout.push(activeAnimations.layout);
481
+ }
482
+ function mean(values) {
483
+ return values.reduce((acc, value) => acc + value, 0) / values.length;
484
+ }
485
+ function summarise(values, calcAverage = mean) {
486
+ if (values.length === 0) {
487
+ return {
488
+ min: 0,
489
+ max: 0,
490
+ avg: 0,
491
+ };
492
+ }
493
+ return {
494
+ min: Math.min(...values),
495
+ max: Math.max(...values),
496
+ avg: calcAverage(values),
497
+ };
498
+ }
499
+ const msToFps = (ms) => Math.round(1000 / ms);
500
+ function clearStatsBuffer() {
501
+ statsBuffer.value = null;
502
+ statsBuffer.addProjectionMetrics = null;
503
+ }
504
+ function reportStats() {
505
+ const { value } = statsBuffer;
506
+ if (!value) {
507
+ throw new Error("Stats are not being measured");
508
+ }
509
+ clearStatsBuffer();
510
+ cancelFrame(record);
511
+ const summary = {
512
+ frameloop: {
513
+ setup: summarise(value.frameloop.setup),
514
+ rate: summarise(value.frameloop.rate),
515
+ read: summarise(value.frameloop.read),
516
+ resolveKeyframes: summarise(value.frameloop.resolveKeyframes),
517
+ preUpdate: summarise(value.frameloop.preUpdate),
518
+ update: summarise(value.frameloop.update),
519
+ preRender: summarise(value.frameloop.preRender),
520
+ render: summarise(value.frameloop.render),
521
+ postRender: summarise(value.frameloop.postRender),
522
+ },
523
+ animations: {
524
+ mainThread: summarise(value.animations.mainThread),
525
+ waapi: summarise(value.animations.waapi),
526
+ layout: summarise(value.animations.layout),
527
+ },
528
+ layoutProjection: {
529
+ nodes: summarise(value.layoutProjection.nodes),
530
+ calculatedTargetDeltas: summarise(value.layoutProjection.calculatedTargetDeltas),
531
+ calculatedProjections: summarise(value.layoutProjection.calculatedProjections),
532
+ },
533
+ };
534
+ /**
535
+ * Convert the rate to FPS
536
+ */
537
+ const { rate } = summary.frameloop;
538
+ rate.min = msToFps(rate.min);
539
+ rate.max = msToFps(rate.max);
540
+ rate.avg = msToFps(rate.avg);
541
+ [rate.min, rate.max] = [rate.max, rate.min];
542
+ return summary;
543
+ }
544
+ function recordStats() {
545
+ if (statsBuffer.value) {
546
+ clearStatsBuffer();
547
+ throw new Error("Stats are already being measured");
548
+ }
549
+ const newStatsBuffer = statsBuffer;
550
+ newStatsBuffer.value = {
551
+ frameloop: {
552
+ setup: [],
553
+ rate: [],
554
+ read: [],
555
+ resolveKeyframes: [],
556
+ preUpdate: [],
557
+ update: [],
558
+ preRender: [],
559
+ render: [],
560
+ postRender: [],
561
+ },
562
+ animations: {
563
+ mainThread: [],
564
+ waapi: [],
565
+ layout: [],
566
+ },
567
+ layoutProjection: {
568
+ nodes: [],
569
+ calculatedTargetDeltas: [],
570
+ calculatedProjections: [],
571
+ },
572
+ };
573
+ newStatsBuffer.addProjectionMetrics = (metrics) => {
574
+ const { layoutProjection } = newStatsBuffer.value;
575
+ layoutProjection.nodes.push(metrics.nodes);
576
+ layoutProjection.calculatedTargetDeltas.push(metrics.calculatedTargetDeltas);
577
+ layoutProjection.calculatedProjections.push(metrics.calculatedProjections);
578
+ };
579
+ frame.postRender(record, true);
580
+ return reportStats;
581
+ }
582
+
583
+ function getOriginIndex(from, total) {
584
+ if (from === "first") {
585
+ return 0;
586
+ }
587
+ else {
588
+ const lastIndex = total - 1;
589
+ return from === "last" ? lastIndex : lastIndex / 2;
590
+ }
591
+ }
592
+ function stagger(duration = 0.1, { startDelay = 0, from = 0, ease } = {}) {
593
+ return (i, total) => {
594
+ const fromIndex = typeof from === "number" ? from : getOriginIndex(from, total);
595
+ const distance = Math.abs(fromIndex - i);
596
+ let delay = duration * distance;
597
+ if (ease) {
598
+ const maxDelay = total * duration;
599
+ const easingFunction = easingDefinitionToFunction(ease);
600
+ delay = easingFunction(delay / maxDelay) * maxDelay;
601
+ }
602
+ return startDelay + delay;
603
+ };
604
+ }
605
+
606
+ function transform(...args) {
607
+ const useImmediate = !Array.isArray(args[0]);
608
+ const argOffset = useImmediate ? 0 : -1;
609
+ const inputValue = args[0 + argOffset];
610
+ const inputRange = args[1 + argOffset];
611
+ const outputRange = args[2 + argOffset];
612
+ const options = args[3 + argOffset];
613
+ const interpolator = interpolate(inputRange, outputRange, options);
614
+ return useImmediate ? interpolator(inputValue) : interpolator;
615
+ }
616
+
617
+ /**
618
+ * Create a `MotionValue` that animates to its latest value using any transition type.
619
+ * Can either be a value or track another `MotionValue`.
620
+ *
621
+ * ```jsx
622
+ * const x = motionValue(0)
623
+ * const y = followValue(x, { type: "spring", stiffness: 300 })
624
+ * // or with tween
625
+ * const z = followValue(x, { type: "tween", duration: 0.5, ease: "easeOut" })
626
+ * ```
627
+ *
628
+ * @param source - Initial value or MotionValue to track
629
+ * @param options - Animation transition options
630
+ * @returns `MotionValue`
631
+ *
632
+ * @public
633
+ */
634
+ function followValue(source, options) {
635
+ const initialValue = isMotionValue(source) ? source.get() : source;
636
+ const value = motionValue(initialValue);
637
+ attachFollow(value, source, options);
638
+ return value;
639
+ }
640
+ /**
641
+ * Attach an animation to a MotionValue that will animate whenever the value changes.
642
+ * Similar to attachSpring but supports any transition type (spring, tween, inertia, etc.)
643
+ *
644
+ * @param value - The MotionValue to animate
645
+ * @param source - Initial value or MotionValue to track
646
+ * @param options - Animation transition options
647
+ * @returns Cleanup function
648
+ *
649
+ * @public
650
+ */
651
+ function attachFollow(value, source, options = {}) {
652
+ const initialValue = value.get();
653
+ let activeAnimation = null;
654
+ let latestValue = initialValue;
655
+ let latestSetter;
656
+ const unit = typeof initialValue === "string"
657
+ ? initialValue.replace(/[\d.-]/g, "")
658
+ : undefined;
659
+ const stopAnimation = () => {
660
+ if (activeAnimation) {
661
+ activeAnimation.stop();
662
+ activeAnimation = null;
663
+ }
664
+ value.animation = undefined;
665
+ };
666
+ const startAnimation = () => {
667
+ const currentValue = asNumber(value.get());
668
+ const targetValue = asNumber(latestValue);
669
+ // Don't animate if we're already at the target
670
+ if (currentValue === targetValue) {
671
+ stopAnimation();
672
+ return;
673
+ }
674
+ // Use the running animation's analytical velocity for accuracy,
675
+ // falling back to the MotionValue's velocity for the initial animation.
676
+ // This prevents systematic velocity loss at high frame rates (240hz+).
677
+ const velocity = activeAnimation
678
+ ? activeAnimation.getGeneratorVelocity()
679
+ : value.getVelocity();
680
+ stopAnimation();
681
+ activeAnimation = new JSAnimation({
682
+ keyframes: [currentValue, targetValue],
683
+ velocity,
684
+ // Default to spring if no type specified (matches useSpring behavior)
685
+ type: "spring",
686
+ restDelta: 0.001,
687
+ restSpeed: 0.01,
688
+ ...options,
689
+ onUpdate: latestSetter,
690
+ });
691
+ };
692
+ // Use a stable function reference so the frame loop Set deduplicates
693
+ // multiple calls within the same frame (e.g. rapid mouse events)
694
+ const scheduleAnimation = () => {
695
+ startAnimation();
696
+ value.animation = activeAnimation ?? undefined;
697
+ value["events"].animationStart?.notify();
698
+ activeAnimation?.then(() => {
699
+ value.animation = undefined;
700
+ value["events"].animationComplete?.notify();
701
+ });
702
+ };
703
+ value.attach((v, set) => {
704
+ latestValue = v;
705
+ latestSetter = (latest) => set(parseValue(latest, unit));
706
+ frame.postRender(scheduleAnimation);
707
+ }, stopAnimation);
708
+ if (isMotionValue(source)) {
709
+ let skipNextAnimation = options.skipInitialAnimation === true;
710
+ const removeSourceOnChange = source.on("change", (v) => {
711
+ if (skipNextAnimation) {
712
+ skipNextAnimation = false;
713
+ value.jump(parseValue(v, unit), false);
714
+ }
715
+ else {
716
+ value.set(parseValue(v, unit));
717
+ }
718
+ });
719
+ const removeValueOnDestroy = value.on("destroy", removeSourceOnChange);
720
+ return () => {
721
+ removeSourceOnChange();
722
+ removeValueOnDestroy();
723
+ };
724
+ }
725
+ return stopAnimation;
726
+ }
727
+ function parseValue(v, unit) {
728
+ return unit ? v + unit : v;
729
+ }
730
+ function asNumber(v) {
731
+ return typeof v === "number" ? v : parseFloat(v);
732
+ }
733
+
734
+ function subscribeValue(inputValues, outputValue, getLatest) {
735
+ const update = () => outputValue.set(getLatest());
736
+ const scheduleUpdate = () => frame.preRender(update, false, true);
737
+ const subscriptions = inputValues.map((v) => v.on("change", scheduleUpdate));
738
+ outputValue.on("destroy", () => {
739
+ subscriptions.forEach((unsubscribe) => unsubscribe());
740
+ cancelFrame(update);
741
+ });
742
+ }
743
+
744
+ /**
745
+ * Create a `MotionValue` that transforms the output of other `MotionValue`s by
746
+ * passing their latest values through a transform function.
747
+ *
748
+ * Whenever a `MotionValue` referred to in the provided function is updated,
749
+ * it will be re-evaluated.
750
+ *
751
+ * ```jsx
752
+ * const x = motionValue(0)
753
+ * const y = transformValue(() => x.get() * 2) // double x
754
+ * ```
755
+ *
756
+ * @param transformer - A transform function. This function must be pure with no side-effects or conditional statements.
757
+ * @returns `MotionValue`
758
+ *
759
+ * @public
760
+ */
761
+ function transformValue(transform) {
762
+ const collectedValues = [];
763
+ /**
764
+ * Open session of collectMotionValues. Any MotionValue that calls get()
765
+ * inside transform will be saved into this array.
766
+ */
767
+ collectMotionValues.current = collectedValues;
768
+ const initialValue = transform();
769
+ collectMotionValues.current = undefined;
770
+ const value = motionValue(initialValue);
771
+ subscribeValue(collectedValues, value, transform);
772
+ return value;
773
+ }
774
+
775
+ /**
776
+ * Create a `MotionValue` that maps the output of another `MotionValue` by
777
+ * mapping it from one range of values into another.
778
+ *
779
+ * @remarks
780
+ *
781
+ * Given an input range of `[-200, -100, 100, 200]` and an output range of
782
+ * `[0, 1, 1, 0]`, the returned `MotionValue` will:
783
+ *
784
+ * - When provided a value between `-200` and `-100`, will return a value between `0` and `1`.
785
+ * - When provided a value between `-100` and `100`, will return `1`.
786
+ * - When provided a value between `100` and `200`, will return a value between `1` and `0`
787
+ *
788
+ * The input range must be a linear series of numbers. The output range
789
+ * can be any value type supported by Motion: numbers, colors, shadows, etc.
790
+ *
791
+ * Every value in the output range must be of the same type and in the same format.
792
+ *
793
+ * ```jsx
794
+ * const x = motionValue(0)
795
+ * const xRange = [-200, -100, 100, 200]
796
+ * const opacityRange = [0, 1, 1, 0]
797
+ * const opacity = mapValue(x, xRange, opacityRange)
798
+ * ```
799
+ *
800
+ * @param inputValue - `MotionValue`
801
+ * @param inputRange - A linear series of numbers (either all increasing or decreasing)
802
+ * @param outputRange - A series of numbers, colors or strings. Must be the same length as `inputRange`.
803
+ * @param options -
804
+ *
805
+ * - clamp: boolean. Clamp values to within the given range. Defaults to `true`
806
+ * - ease: EasingFunction[]. Easing functions to use on the interpolations between each value in the input and output ranges. If provided as an array, the array must be one item shorter than the input and output ranges, as the easings apply to the transition between each.
807
+ *
808
+ * @returns `MotionValue`
809
+ *
810
+ * @public
811
+ */
812
+ function mapValue(inputValue, inputRange, outputRange, options) {
813
+ const map = transform(inputRange, outputRange, options);
814
+ return transformValue(() => map(inputValue.get()));
815
+ }
816
+
817
+ /**
818
+ * Create a `MotionValue` that animates to its latest value using a spring.
819
+ * Can either be a value or track another `MotionValue`.
820
+ *
821
+ * ```jsx
822
+ * const x = motionValue(0)
823
+ * const y = springValue(x, { stiffness: 300 })
824
+ * ```
825
+ *
826
+ * @param source - Initial value or MotionValue to track
827
+ * @param options - Spring configuration options
828
+ * @returns `MotionValue`
829
+ *
830
+ * @public
831
+ */
832
+ function springValue(source, options) {
833
+ return followValue(source, { type: "spring", ...options });
834
+ }
835
+ /**
836
+ * Attach a spring animation to a MotionValue that will animate whenever the value changes.
837
+ *
838
+ * @param value - The MotionValue to animate
839
+ * @param source - Initial value or MotionValue to track
840
+ * @param options - Spring configuration options
841
+ * @returns Cleanup function
842
+ *
843
+ * @public
844
+ */
845
+ function attachSpring(value, source, options) {
846
+ return attachFollow(value, source, { type: "spring", ...options });
847
+ }
848
+
849
+ function chooseLayerType(valueName) {
850
+ if (valueName === "layout")
851
+ return "group";
852
+ if (valueName === "enter" || valueName === "new")
853
+ return "new";
854
+ if (valueName === "exit" || valueName === "old")
855
+ return "old";
856
+ return "group";
857
+ }
858
+
859
+ let pendingRules = {};
860
+ let style = null;
861
+ const css = {
862
+ set: (selector, values) => {
863
+ pendingRules[selector] = values;
864
+ },
865
+ commit: () => {
866
+ if (!style) {
867
+ style = document.createElement("style");
868
+ style.id = "motion-view";
869
+ }
870
+ let cssText = "";
871
+ for (const selector in pendingRules) {
872
+ const rule = pendingRules[selector];
873
+ cssText += `${selector} {\n`;
874
+ for (const [property, value] of Object.entries(rule)) {
875
+ cssText += ` ${property}: ${value};\n`;
876
+ }
877
+ cssText += "}\n";
878
+ }
879
+ style.textContent = cssText;
880
+ document.head.appendChild(style);
881
+ pendingRules = {};
882
+ },
883
+ remove: () => {
884
+ if (style && style.parentElement) {
885
+ style.parentElement.removeChild(style);
886
+ }
887
+ },
888
+ };
889
+
890
+ function getViewAnimationLayerInfo(pseudoElement) {
891
+ const match = pseudoElement.match(/::view-transition-(old|new|group|image-pair)\((.*?)\)/);
892
+ if (!match)
893
+ return null;
894
+ return { layer: match[2], type: match[1] };
895
+ }
896
+
897
+ function filterViewAnimations(animation) {
898
+ const { effect } = animation;
899
+ if (!effect)
900
+ return false;
901
+ return (effect.target === document.documentElement &&
902
+ effect.pseudoElement?.startsWith("::view-transition"));
903
+ }
904
+ function getViewAnimations() {
905
+ return document.getAnimations().filter(filterViewAnimations);
906
+ }
907
+
908
+ function hasTarget(target, targets) {
909
+ return targets.has(target) && Object.keys(targets.get(target)).length > 0;
910
+ }
911
+
912
+ const definitionNames = ["layout", "enter", "exit", "new", "old"];
913
+ function startViewAnimation(builder) {
914
+ const { update, targets, options: defaultOptions } = builder;
915
+ if (!document.startViewTransition) {
916
+ return new Promise(async (resolve) => {
917
+ await update();
918
+ resolve(new GroupAnimation([]));
919
+ });
920
+ }
921
+ // TODO: Go over existing targets and ensure they all have ids
922
+ /**
923
+ * If we don't have any animations defined for the root target,
924
+ * remove it from being captured.
925
+ */
926
+ if (!hasTarget("root", targets)) {
927
+ css.set(":root", {
928
+ "view-transition-name": "none",
929
+ });
930
+ }
931
+ /**
932
+ * Set the timing curve to linear for all view transition layers.
933
+ * This gets baked into the keyframes, which can't be changed
934
+ * without breaking the generated animation.
935
+ *
936
+ * This allows us to set easing via updateTiming - which can be changed.
937
+ */
938
+ css.set("::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*)", { "animation-timing-function": "linear !important" });
939
+ css.commit(); // Write
940
+ const transition = document.startViewTransition(async () => {
941
+ await update();
942
+ // TODO: Go over new targets and ensure they all have ids
943
+ });
944
+ transition.finished.finally(() => {
945
+ css.remove(); // Write
946
+ });
947
+ return new Promise((resolve) => {
948
+ transition.ready.then(() => {
949
+ const generatedViewAnimations = getViewAnimations();
950
+ const animations = [];
951
+ /**
952
+ * Create animations for each of our explicitly-defined subjects.
953
+ */
954
+ targets.forEach((definition, target) => {
955
+ // TODO: If target is not "root", resolve elements
956
+ // and iterate over each
957
+ for (const key of definitionNames) {
958
+ if (!definition[key])
959
+ continue;
960
+ const { keyframes, options } = definition[key];
961
+ for (let [valueName, valueKeyframes] of Object.entries(keyframes)) {
962
+ if (!valueKeyframes)
963
+ continue;
964
+ const valueOptions = {
965
+ ...getValueTransition$1(defaultOptions, valueName),
966
+ ...getValueTransition$1(options, valueName),
967
+ };
968
+ const type = chooseLayerType(key);
969
+ /**
970
+ * If this is an opacity animation, and keyframes are not an array,
971
+ * we need to convert them into an array and set an initial value.
972
+ */
973
+ if (valueName === "opacity" &&
974
+ !Array.isArray(valueKeyframes)) {
975
+ const initialValue = type === "new" ? 0 : 1;
976
+ valueKeyframes = [initialValue, valueKeyframes];
977
+ }
978
+ /**
979
+ * Resolve stagger function if provided.
980
+ */
981
+ if (typeof valueOptions.delay === "function") {
982
+ valueOptions.delay = valueOptions.delay(0, 1);
983
+ }
984
+ valueOptions.duration && (valueOptions.duration = secondsToMilliseconds(valueOptions.duration));
985
+ valueOptions.delay && (valueOptions.delay = secondsToMilliseconds(valueOptions.delay));
986
+ const animation = new NativeAnimation({
987
+ ...valueOptions,
988
+ element: document.documentElement,
989
+ name: valueName,
990
+ pseudoElement: `::view-transition-${type}(${target})`,
991
+ keyframes: valueKeyframes,
992
+ });
993
+ animations.push(animation);
994
+ }
995
+ }
996
+ });
997
+ /**
998
+ * Handle browser generated animations
999
+ */
1000
+ for (const animation of generatedViewAnimations) {
1001
+ if (animation.playState === "finished")
1002
+ continue;
1003
+ const { effect } = animation;
1004
+ if (!effect || !(effect instanceof KeyframeEffect))
1005
+ continue;
1006
+ const { pseudoElement } = effect;
1007
+ if (!pseudoElement)
1008
+ continue;
1009
+ const name = getViewAnimationLayerInfo(pseudoElement);
1010
+ if (!name)
1011
+ continue;
1012
+ const targetDefinition = targets.get(name.layer);
1013
+ if (!targetDefinition) {
1014
+ /**
1015
+ * If transition name is group then update the timing of the animation
1016
+ * whereas if it's old or new then we could possibly replace it using
1017
+ * the above method.
1018
+ */
1019
+ const transitionName = name.type === "group" ? "layout" : "";
1020
+ let animationTransition = {
1021
+ ...getValueTransition$1(defaultOptions, transitionName),
1022
+ };
1023
+ animationTransition.duration && (animationTransition.duration = secondsToMilliseconds(animationTransition.duration));
1024
+ animationTransition =
1025
+ applyGeneratorOptions(animationTransition);
1026
+ const easing = mapEasingToNativeEasing(animationTransition.ease, animationTransition.duration);
1027
+ effect.updateTiming({
1028
+ delay: secondsToMilliseconds(animationTransition.delay ?? 0),
1029
+ duration: animationTransition.duration,
1030
+ easing,
1031
+ });
1032
+ animations.push(new NativeAnimationWrapper(animation));
1033
+ }
1034
+ else if (hasOpacity(targetDefinition, "enter") &&
1035
+ hasOpacity(targetDefinition, "exit") &&
1036
+ effect
1037
+ .getKeyframes()
1038
+ .some((keyframe) => keyframe.mixBlendMode)) {
1039
+ animations.push(new NativeAnimationWrapper(animation));
1040
+ }
1041
+ else {
1042
+ animation.cancel();
1043
+ }
1044
+ }
1045
+ resolve(new GroupAnimation(animations));
1046
+ });
1047
+ });
1048
+ }
1049
+ function hasOpacity(target, key) {
1050
+ return target?.[key]?.keyframes.opacity;
1051
+ }
1052
+
1053
+ let builders = [];
1054
+ let current = null;
1055
+ function next() {
1056
+ current = null;
1057
+ const [nextBuilder] = builders;
1058
+ if (nextBuilder)
1059
+ start(nextBuilder);
1060
+ }
1061
+ function start(builder) {
1062
+ removeItem(builders, builder);
1063
+ current = builder;
1064
+ startViewAnimation(builder).then((animation) => {
1065
+ builder.notifyReady(animation);
1066
+ animation.finished.finally(next);
1067
+ });
1068
+ }
1069
+ function processQueue() {
1070
+ /**
1071
+ * Iterate backwards over the builders array. We can ignore the
1072
+ * "wait" animations. If we have an interrupting animation in the
1073
+ * queue then we need to batch all preceeding animations into it.
1074
+ * Currently this only batches the update functions but will also
1075
+ * need to batch the targets.
1076
+ */
1077
+ for (let i = builders.length - 1; i >= 0; i--) {
1078
+ const builder = builders[i];
1079
+ const { interrupt } = builder.options;
1080
+ if (interrupt === "immediate") {
1081
+ const batchedUpdates = builders.slice(0, i + 1).map((b) => b.update);
1082
+ const remaining = builders.slice(i + 1);
1083
+ builder.update = () => {
1084
+ batchedUpdates.forEach((update) => update());
1085
+ };
1086
+ // Put the current builder at the front, followed by any "wait" builders
1087
+ builders = [builder, ...remaining];
1088
+ break;
1089
+ }
1090
+ }
1091
+ if (!current || builders[0]?.options.interrupt === "immediate") {
1092
+ next();
1093
+ }
1094
+ }
1095
+ function addToQueue(builder) {
1096
+ builders.push(builder);
1097
+ microtask.render(processQueue);
1098
+ }
1099
+
1100
+ class ViewTransitionBuilder {
1101
+ constructor(update, options = {}) {
1102
+ this.currentSubject = "root";
1103
+ this.targets = new Map();
1104
+ this.notifyReady = noop$1;
1105
+ this.readyPromise = new Promise((resolve) => {
1106
+ this.notifyReady = resolve;
1107
+ });
1108
+ this.update = update;
1109
+ this.options = {
1110
+ interrupt: "wait",
1111
+ ...options,
1112
+ };
1113
+ addToQueue(this);
1114
+ }
1115
+ get(subject) {
1116
+ this.currentSubject = subject;
1117
+ return this;
1118
+ }
1119
+ layout(keyframes, options) {
1120
+ this.updateTarget("layout", keyframes, options);
1121
+ return this;
1122
+ }
1123
+ new(keyframes, options) {
1124
+ this.updateTarget("new", keyframes, options);
1125
+ return this;
1126
+ }
1127
+ old(keyframes, options) {
1128
+ this.updateTarget("old", keyframes, options);
1129
+ return this;
1130
+ }
1131
+ enter(keyframes, options) {
1132
+ this.updateTarget("enter", keyframes, options);
1133
+ return this;
1134
+ }
1135
+ exit(keyframes, options) {
1136
+ this.updateTarget("exit", keyframes, options);
1137
+ return this;
1138
+ }
1139
+ crossfade(options) {
1140
+ this.updateTarget("enter", { opacity: 1 }, options);
1141
+ this.updateTarget("exit", { opacity: 0 }, options);
1142
+ return this;
1143
+ }
1144
+ updateTarget(target, keyframes, options = {}) {
1145
+ const { currentSubject, targets } = this;
1146
+ if (!targets.has(currentSubject)) {
1147
+ targets.set(currentSubject, {});
1148
+ }
1149
+ const targetData = targets.get(currentSubject);
1150
+ targetData[target] = { keyframes, options };
1151
+ }
1152
+ then(resolve, reject) {
1153
+ return this.readyPromise.then(resolve, reject);
1154
+ }
1155
+ }
1156
+ function animateView(update, defaultOptions = {}) {
1157
+ return new ViewTransitionBuilder(update, defaultOptions);
1158
+ }
1159
+
1160
+ function isObjectKey(key, object) {
1161
+ return key in object;
1162
+ }
1163
+ class ObjectVisualElement extends VisualElement {
1164
+ constructor() {
1165
+ super(...arguments);
1166
+ this.type = "object";
1167
+ }
1168
+ readValueFromInstance(instance, key) {
1169
+ if (isObjectKey(key, instance)) {
1170
+ const value = instance[key];
1171
+ if (typeof value === "string" || typeof value === "number") {
1172
+ return value;
1173
+ }
1174
+ }
1175
+ return undefined;
1176
+ }
1177
+ getBaseTargetFromProps() {
1178
+ return undefined;
1179
+ }
1180
+ removeValueFromRenderState(key, renderState) {
1181
+ delete renderState.output[key];
1182
+ }
1183
+ measureInstanceViewportBox() {
1184
+ return createBox();
1185
+ }
1186
+ build(renderState, latestValues) {
1187
+ Object.assign(renderState.output, latestValues);
1188
+ }
1189
+ renderInstance(instance, { output }) {
1190
+ Object.assign(instance, output);
1191
+ }
1192
+ sortInstanceNodePosition() {
1193
+ return 0;
1194
+ }
1195
+ }
1196
+
1197
+ const layoutSelector = "[data-layout], [data-layout-id]";
1198
+ const noop = () => { };
1199
+ function snapshotFromTarget(projection) {
1200
+ const target = projection.targetWithTransforms || projection.target;
1201
+ if (!target)
1202
+ return undefined;
1203
+ const measuredBox = createBox();
1204
+ const layoutBox = createBox();
1205
+ copyBoxInto(measuredBox, target);
1206
+ copyBoxInto(layoutBox, target);
1207
+ return {
1208
+ animationId: projection.root?.animationId ?? 0,
1209
+ measuredBox,
1210
+ layoutBox,
1211
+ latestValues: projection.animationValues || projection.latestValues || {},
1212
+ source: projection.id,
1213
+ };
1214
+ }
1215
+ class LayoutAnimationBuilder {
1216
+ constructor(scope, updateDom, defaultOptions) {
1217
+ this.sharedTransitions = new Map();
1218
+ this.notifyReady = noop;
1219
+ this.rejectReady = noop;
1220
+ this.scope = scope;
1221
+ this.updateDom = updateDom;
1222
+ this.defaultOptions = defaultOptions;
1223
+ this.readyPromise = new Promise((resolve, reject) => {
1224
+ this.notifyReady = resolve;
1225
+ this.rejectReady = reject;
1226
+ });
1227
+ frame.postRender(() => {
1228
+ this.start().then(this.notifyReady).catch(this.rejectReady);
1229
+ });
1230
+ }
1231
+ shared(id, transition) {
1232
+ this.sharedTransitions.set(id, transition);
1233
+ return this;
1234
+ }
1235
+ then(resolve, reject) {
1236
+ return this.readyPromise.then(resolve, reject);
1237
+ }
1238
+ async start() {
1239
+ const beforeElements = collectLayoutElements(this.scope);
1240
+ const beforeRecords = this.buildRecords(beforeElements);
1241
+ beforeRecords.forEach(({ projection }) => {
1242
+ const hasCurrentAnimation = Boolean(projection.currentAnimation);
1243
+ const isSharedLayout = Boolean(projection.options.layoutId);
1244
+ if (hasCurrentAnimation && isSharedLayout) {
1245
+ const snapshot = snapshotFromTarget(projection);
1246
+ if (snapshot) {
1247
+ projection.snapshot = snapshot;
1248
+ }
1249
+ else if (projection.snapshot) {
1250
+ projection.snapshot = undefined;
1251
+ }
1252
+ }
1253
+ else if (projection.snapshot &&
1254
+ (projection.currentAnimation || projection.isProjecting())) {
1255
+ projection.snapshot = undefined;
1256
+ }
1257
+ projection.isPresent = true;
1258
+ projection.willUpdate();
1259
+ });
1260
+ await this.updateDom();
1261
+ const afterElements = collectLayoutElements(this.scope);
1262
+ const afterRecords = this.buildRecords(afterElements);
1263
+ this.handleExitingElements(beforeRecords, afterRecords);
1264
+ afterRecords.forEach(({ projection }) => {
1265
+ const instance = projection.instance;
1266
+ const resumeFromInstance = projection.resumeFrom
1267
+ ?.instance;
1268
+ if (!instance || !resumeFromInstance)
1269
+ return;
1270
+ if (!("style" in instance))
1271
+ return;
1272
+ const currentTransform = instance.style.transform;
1273
+ const resumeFromTransform = resumeFromInstance.style.transform;
1274
+ if (currentTransform &&
1275
+ resumeFromTransform &&
1276
+ currentTransform === resumeFromTransform) {
1277
+ instance.style.transform = "";
1278
+ instance.style.transformOrigin = "";
1279
+ }
1280
+ });
1281
+ afterRecords.forEach(({ projection }) => {
1282
+ projection.isPresent = true;
1283
+ });
1284
+ const root = getProjectionRoot(afterRecords, beforeRecords);
1285
+ root?.didUpdate();
1286
+ await new Promise((resolve) => {
1287
+ frame.postRender(() => resolve());
1288
+ });
1289
+ const animations = collectAnimations(afterRecords);
1290
+ const animation = new GroupAnimation(animations);
1291
+ return animation;
1292
+ }
1293
+ buildRecords(elements) {
1294
+ const records = [];
1295
+ const recordMap = new Map();
1296
+ for (const element of elements) {
1297
+ const parentRecord = findParentRecord(element, recordMap, this.scope);
1298
+ const { layout, layoutId } = readLayoutAttributes(element);
1299
+ const override = layoutId
1300
+ ? this.sharedTransitions.get(layoutId)
1301
+ : undefined;
1302
+ const transition = override || this.defaultOptions;
1303
+ const record = getOrCreateRecord(element, parentRecord?.projection, {
1304
+ layout,
1305
+ layoutId,
1306
+ animationType: typeof layout === "string" ? layout : "both",
1307
+ transition: transition,
1308
+ });
1309
+ recordMap.set(element, record);
1310
+ records.push(record);
1311
+ }
1312
+ return records;
1313
+ }
1314
+ handleExitingElements(beforeRecords, afterRecords) {
1315
+ const afterElementsSet = new Set(afterRecords.map((record) => record.element));
1316
+ beforeRecords.forEach((record) => {
1317
+ if (afterElementsSet.has(record.element))
1318
+ return;
1319
+ // For shared layout elements, relegate to set up resumeFrom
1320
+ // so the remaining element animates from this position
1321
+ if (record.projection.options.layoutId) {
1322
+ record.projection.isPresent = false;
1323
+ record.projection.relegate();
1324
+ }
1325
+ record.visualElement.unmount();
1326
+ visualElementStore.delete(record.element);
1327
+ });
1328
+ // Clear resumeFrom on EXISTING nodes that point to unmounted projections
1329
+ // This prevents crossfade animation when the source element was removed entirely
1330
+ // But preserve resumeFrom for NEW nodes so they can animate from the old position
1331
+ // Also preserve resumeFrom for lead nodes that were just promoted via relegate
1332
+ const beforeElementsSet = new Set(beforeRecords.map((record) => record.element));
1333
+ afterRecords.forEach(({ element, projection }) => {
1334
+ if (beforeElementsSet.has(element) &&
1335
+ projection.resumeFrom &&
1336
+ !projection.resumeFrom.instance &&
1337
+ !projection.isLead()) {
1338
+ projection.resumeFrom = undefined;
1339
+ projection.snapshot = undefined;
1340
+ }
1341
+ });
1342
+ }
1343
+ }
1344
+ function parseAnimateLayoutArgs(scopeOrUpdateDom, updateDomOrOptions, options) {
1345
+ // animateLayout(updateDom)
1346
+ if (typeof scopeOrUpdateDom === "function") {
1347
+ return {
1348
+ scope: document,
1349
+ updateDom: scopeOrUpdateDom,
1350
+ defaultOptions: updateDomOrOptions,
1351
+ };
1352
+ }
1353
+ // animateLayout(scope, updateDom, options?)
1354
+ const elements = resolveElements(scopeOrUpdateDom);
1355
+ const scope = elements[0] || document;
1356
+ return {
1357
+ scope,
1358
+ updateDom: updateDomOrOptions,
1359
+ defaultOptions: options,
1360
+ };
1361
+ }
1362
+ function collectLayoutElements(scope) {
1363
+ const elements = Array.from(scope.querySelectorAll(layoutSelector));
1364
+ if (scope instanceof Element && scope.matches(layoutSelector)) {
1365
+ if (!elements.includes(scope)) {
1366
+ elements.unshift(scope);
1367
+ }
1368
+ }
1369
+ return elements;
1370
+ }
1371
+ function readLayoutAttributes(element) {
1372
+ const layoutId = element.getAttribute("data-layout-id") || undefined;
1373
+ const rawLayout = element.getAttribute("data-layout");
1374
+ let layout;
1375
+ if (rawLayout === "" || rawLayout === "true") {
1376
+ layout = true;
1377
+ }
1378
+ else if (rawLayout) {
1379
+ layout = rawLayout;
1380
+ }
1381
+ return {
1382
+ layout,
1383
+ layoutId,
1384
+ };
1385
+ }
1386
+ function createVisualState() {
1387
+ return {
1388
+ latestValues: {},
1389
+ renderState: {
1390
+ transform: {},
1391
+ transformOrigin: {},
1392
+ style: {},
1393
+ vars: {},
1394
+ },
1395
+ };
1396
+ }
1397
+ function getOrCreateRecord(element, parentProjection, projectionOptions) {
1398
+ const existing = visualElementStore.get(element);
1399
+ const visualElement = existing ??
1400
+ new HTMLVisualElement({
1401
+ props: {},
1402
+ presenceContext: null,
1403
+ visualState: createVisualState(),
1404
+ }, { allowProjection: true });
1405
+ if (!existing || !visualElement.projection) {
1406
+ visualElement.projection = new HTMLProjectionNode(visualElement.latestValues, parentProjection);
1407
+ }
1408
+ visualElement.projection.setOptions({
1409
+ ...projectionOptions,
1410
+ visualElement,
1411
+ });
1412
+ if (!visualElement.current) {
1413
+ visualElement.mount(element);
1414
+ }
1415
+ else if (!visualElement.projection.instance) {
1416
+ // Mount projection if VisualElement is already mounted but projection isn't
1417
+ // This happens when animate() was called before animateLayout()
1418
+ visualElement.projection.mount(element);
1419
+ }
1420
+ if (!existing) {
1421
+ visualElementStore.set(element, visualElement);
1422
+ }
1423
+ return {
1424
+ element,
1425
+ visualElement,
1426
+ projection: visualElement.projection,
1427
+ };
1428
+ }
1429
+ function findParentRecord(element, recordMap, scope) {
1430
+ let parent = element.parentElement;
1431
+ while (parent) {
1432
+ const record = recordMap.get(parent);
1433
+ if (record)
1434
+ return record;
1435
+ if (parent === scope)
1436
+ break;
1437
+ parent = parent.parentElement;
1438
+ }
1439
+ return undefined;
1440
+ }
1441
+ function getProjectionRoot(afterRecords, beforeRecords) {
1442
+ const record = afterRecords[0] || beforeRecords[0];
1443
+ return record?.projection.root;
1444
+ }
1445
+ function collectAnimations(afterRecords) {
1446
+ const animations = new Set();
1447
+ afterRecords.forEach((record) => {
1448
+ const animation = record.projection.currentAnimation;
1449
+ if (animation)
1450
+ animations.add(animation);
1451
+ });
1452
+ return Array.from(animations);
1453
+ }
1454
+
1455
+ /**
1456
+ * @deprecated
1457
+ *
1458
+ * Import as `frame` instead.
1459
+ */
1460
+ const sync = frame;
1461
+ /**
1462
+ * @deprecated
1463
+ *
1464
+ * Use cancelFrame(callback) instead.
1465
+ */
1466
+ const cancelSync = stepsOrder.reduce((acc, key) => {
1467
+ acc[key] = (process) => cancelFrame(process);
1468
+ return acc;
1469
+ }, {});
1470
+
1471
+ /**
1472
+ * Used in conjunction with the `m` component to reduce bundle size.
1473
+ *
1474
+ * `m` is a version of the `motion` component that only loads functionality
1475
+ * critical for the initial render.
1476
+ *
1477
+ * `LazyMotion` can then be used to either synchronously or asynchronously
1478
+ * load animation and gesture support.
1479
+ *
1480
+ * ```jsx
1481
+ * // Synchronous loading
1482
+ * import { LazyMotion, m, domAnimation } from "framer-motion"
1483
+ *
1484
+ * function App() {
1485
+ * return (
1486
+ * <LazyMotion features={domAnimation}>
1487
+ * <m.div animate={{ scale: 2 }} />
1488
+ * </LazyMotion>
1489
+ * )
1490
+ * }
1491
+ *
1492
+ * // Asynchronous loading
1493
+ * import { LazyMotion, m } from "framer-motion"
1494
+ *
1495
+ * function App() {
1496
+ * return (
1497
+ * <LazyMotion features={() => import('./path/to/domAnimation')}>
1498
+ * <m.div animate={{ scale: 2 }} />
1499
+ * </LazyMotion>
1500
+ * )
1501
+ * }
1502
+ * ```
1503
+ *
1504
+ * @public
1505
+ */
1506
+ function LazyMotion({ children, features, strict = false }) {
1507
+ const [, setIsLoaded] = useState(!isLazyBundle(features));
1508
+ const loadedRenderer = useRef(undefined);
1509
+ /**
1510
+ * If this is a synchronous load, load features immediately
1511
+ */
1512
+ if (!isLazyBundle(features)) {
1513
+ const { renderer, ...loadedFeatures } = features;
1514
+ loadedRenderer.current = renderer;
1515
+ loadFeatures(loadedFeatures);
1516
+ }
1517
+ useEffect(() => {
1518
+ if (isLazyBundle(features)) {
1519
+ features().then(({ renderer, ...loadedFeatures }) => {
1520
+ loadFeatures(loadedFeatures);
1521
+ loadedRenderer.current = renderer;
1522
+ setIsLoaded(true);
1523
+ });
1524
+ }
1525
+ }, []);
1526
+ return (jsx(LazyContext.Provider, { value: { renderer: loadedRenderer.current, strict }, children: children }));
1527
+ }
1528
+ function isLazyBundle(features) {
1529
+ return typeof features === "function";
1530
+ }
1531
+
1532
+ /**
1533
+ * `MotionConfig` is used to set configuration options for all children `motion` components.
1534
+ *
1535
+ * ```jsx
1536
+ * import { motion, MotionConfig } from "framer-motion"
1537
+ *
1538
+ * export function App() {
1539
+ * return (
1540
+ * <MotionConfig transition={{ type: "spring" }}>
1541
+ * <motion.div animate={{ x: 100 }} />
1542
+ * </MotionConfig>
1543
+ * )
1544
+ * }
1545
+ * ```
1546
+ *
1547
+ * @public
1548
+ */
1549
+ function MotionConfig({ children, isValidProp, ...config }) {
1550
+ isValidProp && loadExternalIsValidProp(isValidProp);
1551
+ /**
1552
+ * Inherit props from any parent MotionConfig components
1553
+ */
1554
+ const parentConfig = useContext(MotionConfigContext);
1555
+ config = { ...parentConfig, ...config };
1556
+ config.transition = resolveTransition(config.transition, parentConfig.transition);
1557
+ /**
1558
+ * Don't allow isStatic to change between renders as it affects how many hooks
1559
+ * motion components fire.
1560
+ */
1561
+ config.isStatic = useConstant(() => config.isStatic);
1562
+ /**
1563
+ * Creating a new config context object will re-render every `motion` component
1564
+ * every time it renders. So we only want to create a new one sparingly.
1565
+ */
1566
+ const context = useMemo(() => config, [
1567
+ JSON.stringify(config.transition),
1568
+ config.transformPagePoint,
1569
+ config.reducedMotion,
1570
+ config.skipAnimations,
1571
+ ]);
1572
+ return (jsx(MotionConfigContext.Provider, { value: context, children: children }));
1573
+ }
1574
+
1575
+ const m = /*@__PURE__*/ createMotionProxy();
1576
+
1577
+ function useUnmountEffect(callback) {
1578
+ return useEffect(() => () => callback(), []);
1579
+ }
1580
+
1581
+ /**
1582
+ * @public
1583
+ */
1584
+ const domAnimation = {
1585
+ renderer: createDomVisualElement,
1586
+ ...animations,
1587
+ ...gestureAnimations,
1588
+ };
1589
+
1590
+ /**
1591
+ * @public
1592
+ */
1593
+ const domMax = {
1594
+ ...domAnimation,
1595
+ ...drag,
1596
+ ...layout,
1597
+ };
1598
+
1599
+ /**
1600
+ * @public
1601
+ */
1602
+ const domMin = {
1603
+ renderer: createDomVisualElement,
1604
+ ...animations,
1605
+ };
1606
+
1607
+ function useMotionValueEvent(value, event, callback) {
1608
+ /**
1609
+ * useInsertionEffect will create subscriptions before any other
1610
+ * effects will run. Effects run upwards through the tree so it
1611
+ * can be that binding a useLayoutEffect higher up the tree can
1612
+ * miss changes from lower down the tree.
1613
+ */
1614
+ useInsertionEffect(() => value.on(event, callback), [value, event, callback]);
1615
+ }
1616
+
1617
+ function canUseNativeTimeline(target) {
1618
+ if (typeof window === "undefined")
1619
+ return false;
1620
+ return target ? supportsViewTimeline() : supportsScrollTimeline();
1621
+ }
1622
+
1623
+ /**
1624
+ * A time in milliseconds, beyond which we consider the scroll velocity to be 0.
1625
+ */
1626
+ const maxElapsed = 50;
1627
+ const createAxisInfo = () => ({
1628
+ current: 0,
1629
+ offset: [],
1630
+ progress: 0,
1631
+ scrollLength: 0,
1632
+ targetOffset: 0,
1633
+ targetLength: 0,
1634
+ containerLength: 0,
1635
+ velocity: 0,
1636
+ });
1637
+ const createScrollInfo = () => ({
1638
+ time: 0,
1639
+ x: createAxisInfo(),
1640
+ y: createAxisInfo(),
1641
+ });
1642
+ const keys = {
1643
+ x: {
1644
+ length: "Width",
1645
+ position: "Left",
1646
+ },
1647
+ y: {
1648
+ length: "Height",
1649
+ position: "Top",
1650
+ },
1651
+ };
1652
+ function updateAxisInfo(element, axisName, info, time) {
1653
+ const axis = info[axisName];
1654
+ const { length, position } = keys[axisName];
1655
+ const prev = axis.current;
1656
+ const prevTime = info.time;
1657
+ axis.current = Math.abs(element[`scroll${position}`]);
1658
+ axis.scrollLength = element[`scroll${length}`] - element[`client${length}`];
1659
+ axis.offset.length = 0;
1660
+ axis.offset[0] = 0;
1661
+ axis.offset[1] = axis.scrollLength;
1662
+ axis.progress = progress(0, axis.scrollLength, axis.current);
1663
+ const elapsed = time - prevTime;
1664
+ axis.velocity =
1665
+ elapsed > maxElapsed
1666
+ ? 0
1667
+ : velocityPerSecond(axis.current - prev, elapsed);
1668
+ }
1669
+ function updateScrollInfo(element, info, time) {
1670
+ updateAxisInfo(element, "x", info, time);
1671
+ updateAxisInfo(element, "y", info, time);
1672
+ info.time = time;
1673
+ }
1674
+
1675
+ function calcInset(element, container) {
1676
+ const inset = { x: 0, y: 0 };
1677
+ let current = element;
1678
+ while (current && current !== container) {
1679
+ if (isHTMLElement(current)) {
1680
+ inset.x += current.offsetLeft;
1681
+ inset.y += current.offsetTop;
1682
+ current = current.offsetParent;
1683
+ }
1684
+ else if (current.tagName === "svg") {
1685
+ /**
1686
+ * This isn't an ideal approach to measuring the offset of <svg /> tags.
1687
+ * It would be preferable, given they behave like HTMLElements in most ways
1688
+ * to use offsetLeft/Top. But these don't exist on <svg />. Likewise we
1689
+ * can't use .getBBox() like most SVG elements as these provide the offset
1690
+ * relative to the SVG itself, which for <svg /> is usually 0x0.
1691
+ */
1692
+ const svgBoundingBox = current.getBoundingClientRect();
1693
+ current = current.parentElement;
1694
+ const parentBoundingBox = current.getBoundingClientRect();
1695
+ inset.x += svgBoundingBox.left - parentBoundingBox.left;
1696
+ inset.y += svgBoundingBox.top - parentBoundingBox.top;
1697
+ }
1698
+ else if (current instanceof SVGGraphicsElement) {
1699
+ const { x, y } = current.getBBox();
1700
+ inset.x += x;
1701
+ inset.y += y;
1702
+ let svg = null;
1703
+ let parent = current.parentNode;
1704
+ while (!svg) {
1705
+ if (parent.tagName === "svg") {
1706
+ svg = parent;
1707
+ }
1708
+ parent = current.parentNode;
1709
+ }
1710
+ current = svg;
1711
+ }
1712
+ else {
1713
+ break;
1714
+ }
1715
+ }
1716
+ return inset;
1717
+ }
1718
+
1719
+ const namedEdges = {
1720
+ start: 0,
1721
+ center: 0.5,
1722
+ end: 1,
1723
+ };
1724
+ function resolveEdge(edge, length, inset = 0) {
1725
+ let delta = 0;
1726
+ /**
1727
+ * If we have this edge defined as a preset, replace the definition
1728
+ * with the numerical value.
1729
+ */
1730
+ if (edge in namedEdges) {
1731
+ edge = namedEdges[edge];
1732
+ }
1733
+ /**
1734
+ * Handle unit values
1735
+ */
1736
+ if (typeof edge === "string") {
1737
+ const asNumber = parseFloat(edge);
1738
+ if (edge.endsWith("px")) {
1739
+ delta = asNumber;
1740
+ }
1741
+ else if (edge.endsWith("%")) {
1742
+ edge = asNumber / 100;
1743
+ }
1744
+ else if (edge.endsWith("vw")) {
1745
+ delta = (asNumber / 100) * document.documentElement.clientWidth;
1746
+ }
1747
+ else if (edge.endsWith("vh")) {
1748
+ delta = (asNumber / 100) * document.documentElement.clientHeight;
1749
+ }
1750
+ else {
1751
+ edge = asNumber;
1752
+ }
1753
+ }
1754
+ /**
1755
+ * If the edge is defined as a number, handle as a progress value.
1756
+ */
1757
+ if (typeof edge === "number") {
1758
+ delta = length * edge;
1759
+ }
1760
+ return inset + delta;
1761
+ }
1762
+
1763
+ const defaultOffset = [0, 0];
1764
+ function resolveOffset(offset, containerLength, targetLength, targetInset) {
1765
+ let offsetDefinition = Array.isArray(offset) ? offset : defaultOffset;
1766
+ let targetPoint = 0;
1767
+ let containerPoint = 0;
1768
+ if (typeof offset === "number") {
1769
+ /**
1770
+ * If we're provided offset: [0, 0.5, 1] then each number x should become
1771
+ * [x, x], so we default to the behaviour of mapping 0 => 0 of both target
1772
+ * and container etc.
1773
+ */
1774
+ offsetDefinition = [offset, offset];
1775
+ }
1776
+ else if (typeof offset === "string") {
1777
+ offset = offset.trim();
1778
+ if (offset.includes(" ")) {
1779
+ offsetDefinition = offset.split(" ");
1780
+ }
1781
+ else {
1782
+ /**
1783
+ * If we're provided a definition like "100px" then we want to apply
1784
+ * that only to the top of the target point, leaving the container at 0.
1785
+ * Whereas a named offset like "end" should be applied to both.
1786
+ */
1787
+ offsetDefinition = [offset, namedEdges[offset] ? offset : `0`];
1788
+ }
1789
+ }
1790
+ targetPoint = resolveEdge(offsetDefinition[0], targetLength, targetInset);
1791
+ containerPoint = resolveEdge(offsetDefinition[1], containerLength);
1792
+ return targetPoint - containerPoint;
1793
+ }
1794
+
1795
+ const ScrollOffset = {
1796
+ Enter: [
1797
+ [0, 1],
1798
+ [1, 1],
1799
+ ],
1800
+ Exit: [
1801
+ [0, 0],
1802
+ [1, 0],
1803
+ ],
1804
+ Any: [
1805
+ [1, 0],
1806
+ [0, 1],
1807
+ ],
1808
+ All: [
1809
+ [0, 0],
1810
+ [1, 1],
1811
+ ],
1812
+ };
1813
+
1814
+ const point = { x: 0, y: 0 };
1815
+ function getTargetSize(target) {
1816
+ return "getBBox" in target && target.tagName !== "svg"
1817
+ ? target.getBBox()
1818
+ : { width: target.clientWidth, height: target.clientHeight };
1819
+ }
1820
+ function resolveOffsets(container, info, options) {
1821
+ const { offset: offsetDefinition = ScrollOffset.All } = options;
1822
+ const { target = container, axis = "y" } = options;
1823
+ const lengthLabel = axis === "y" ? "height" : "width";
1824
+ const inset = target !== container ? calcInset(target, container) : point;
1825
+ /**
1826
+ * Measure the target and container. If they're the same thing then we
1827
+ * use the container's scrollWidth/Height as the target, from there
1828
+ * all other calculations can remain the same.
1829
+ */
1830
+ const targetSize = target === container
1831
+ ? { width: container.scrollWidth, height: container.scrollHeight }
1832
+ : getTargetSize(target);
1833
+ const containerSize = {
1834
+ width: container.clientWidth,
1835
+ height: container.clientHeight,
1836
+ };
1837
+ /**
1838
+ * Reset the length of the resolved offset array rather than creating a new one.
1839
+ * TODO: More reusable data structures for targetSize/containerSize would also be good.
1840
+ */
1841
+ info[axis].offset.length = 0;
1842
+ /**
1843
+ * Populate the offset array by resolving the user's offset definition into
1844
+ * a list of pixel scroll offets.
1845
+ */
1846
+ let hasChanged = !info[axis].interpolate;
1847
+ const numOffsets = offsetDefinition.length;
1848
+ for (let i = 0; i < numOffsets; i++) {
1849
+ const offset = resolveOffset(offsetDefinition[i], containerSize[lengthLabel], targetSize[lengthLabel], inset[axis]);
1850
+ if (!hasChanged && offset !== info[axis].interpolatorOffsets[i]) {
1851
+ hasChanged = true;
1852
+ }
1853
+ info[axis].offset[i] = offset;
1854
+ }
1855
+ /**
1856
+ * If the pixel scroll offsets have changed, create a new interpolator function
1857
+ * to map scroll value into a progress.
1858
+ */
1859
+ if (hasChanged) {
1860
+ info[axis].interpolate = interpolate(info[axis].offset, defaultOffset$1(offsetDefinition), { clamp: false });
1861
+ info[axis].interpolatorOffsets = [...info[axis].offset];
1862
+ }
1863
+ info[axis].progress = clamp(0, 1, info[axis].interpolate(info[axis].current));
1864
+ }
1865
+
1866
+ function measure(container, target = container, info) {
1867
+ /**
1868
+ * Find inset of target within scrollable container
1869
+ */
1870
+ info.x.targetOffset = 0;
1871
+ info.y.targetOffset = 0;
1872
+ if (target !== container) {
1873
+ let node = target;
1874
+ while (node && node !== container) {
1875
+ info.x.targetOffset += node.offsetLeft;
1876
+ info.y.targetOffset += node.offsetTop;
1877
+ node = node.offsetParent;
1878
+ }
1879
+ }
1880
+ info.x.targetLength =
1881
+ target === container ? target.scrollWidth : target.clientWidth;
1882
+ info.y.targetLength =
1883
+ target === container ? target.scrollHeight : target.clientHeight;
1884
+ info.x.containerLength = container.clientWidth;
1885
+ info.y.containerLength = container.clientHeight;
1886
+ /**
1887
+ * In development mode ensure scroll containers aren't position: static as this makes
1888
+ * it difficult to measure their relative positions.
1889
+ */
1890
+ if (process.env.NODE_ENV !== "production") {
1891
+ if (container && target && target !== container) {
1892
+ warnOnce(getComputedStyle(container).position !== "static", "Please ensure that the container has a non-static position, like 'relative', 'fixed', or 'absolute' to ensure scroll offset is calculated correctly.");
1893
+ }
1894
+ }
1895
+ }
1896
+ function createOnScrollHandler(element, onScroll, info, options = {}) {
1897
+ return {
1898
+ measure: (time) => {
1899
+ measure(element, options.target, info);
1900
+ updateScrollInfo(element, info, time);
1901
+ if (options.offset || options.target) {
1902
+ resolveOffsets(element, info, options);
1903
+ }
1904
+ },
1905
+ notify: () => onScroll(info),
1906
+ };
1907
+ }
1908
+
1909
+ const scrollListeners = new WeakMap();
1910
+ const resizeListeners = new WeakMap();
1911
+ const onScrollHandlers = new WeakMap();
1912
+ const scrollSize = new WeakMap();
1913
+ const dimensionCheckProcesses = new WeakMap();
1914
+ const getEventTarget = (element) => element === document.scrollingElement ? window : element;
1915
+ function scrollInfo(onScroll, { container = document.scrollingElement, trackContentSize = false, ...options } = {}) {
1916
+ if (!container)
1917
+ return noop$1;
1918
+ let containerHandlers = onScrollHandlers.get(container);
1919
+ /**
1920
+ * Get the onScroll handlers for this container.
1921
+ * If one isn't found, create a new one.
1922
+ */
1923
+ if (!containerHandlers) {
1924
+ containerHandlers = new Set();
1925
+ onScrollHandlers.set(container, containerHandlers);
1926
+ }
1927
+ /**
1928
+ * Create a new onScroll handler for the provided callback.
1929
+ */
1930
+ const info = createScrollInfo();
1931
+ const containerHandler = createOnScrollHandler(container, onScroll, info, options);
1932
+ containerHandlers.add(containerHandler);
1933
+ /**
1934
+ * Check if there's a scroll event listener for this container.
1935
+ * If not, create one.
1936
+ */
1937
+ if (!scrollListeners.has(container)) {
1938
+ const measureAll = () => {
1939
+ for (const handler of containerHandlers) {
1940
+ handler.measure(frameData.timestamp);
1941
+ }
1942
+ frame.preUpdate(notifyAll);
1943
+ };
1944
+ const notifyAll = () => {
1945
+ for (const handler of containerHandlers) {
1946
+ handler.notify();
1947
+ }
1948
+ };
1949
+ const listener = () => frame.read(measureAll);
1950
+ scrollListeners.set(container, listener);
1951
+ const target = getEventTarget(container);
1952
+ window.addEventListener("resize", listener);
1953
+ if (container !== document.documentElement) {
1954
+ resizeListeners.set(container, resize(container, listener));
1955
+ }
1956
+ target.addEventListener("scroll", listener);
1957
+ listener();
1958
+ }
1959
+ /**
1960
+ * Enable content size tracking if requested and not already enabled.
1961
+ */
1962
+ if (trackContentSize && !dimensionCheckProcesses.has(container)) {
1963
+ const listener = scrollListeners.get(container);
1964
+ // Store initial scroll dimensions (object is reused to avoid allocation)
1965
+ const size = {
1966
+ width: container.scrollWidth,
1967
+ height: container.scrollHeight,
1968
+ };
1969
+ scrollSize.set(container, size);
1970
+ // Add frame-based scroll dimension checking to detect content changes
1971
+ const checkScrollDimensions = () => {
1972
+ const newWidth = container.scrollWidth;
1973
+ const newHeight = container.scrollHeight;
1974
+ if (size.width !== newWidth || size.height !== newHeight) {
1975
+ listener();
1976
+ size.width = newWidth;
1977
+ size.height = newHeight;
1978
+ }
1979
+ };
1980
+ // Schedule with keepAlive=true to run every frame
1981
+ const dimensionCheckProcess = frame.read(checkScrollDimensions, true);
1982
+ dimensionCheckProcesses.set(container, dimensionCheckProcess);
1983
+ }
1984
+ const listener = scrollListeners.get(container);
1985
+ frame.read(listener, false, true);
1986
+ return () => {
1987
+ cancelFrame(listener);
1988
+ /**
1989
+ * Check if we even have any handlers for this container.
1990
+ */
1991
+ const currentHandlers = onScrollHandlers.get(container);
1992
+ if (!currentHandlers)
1993
+ return;
1994
+ currentHandlers.delete(containerHandler);
1995
+ if (currentHandlers.size)
1996
+ return;
1997
+ /**
1998
+ * If no more handlers, remove the scroll listener too.
1999
+ */
2000
+ const scrollListener = scrollListeners.get(container);
2001
+ scrollListeners.delete(container);
2002
+ if (scrollListener) {
2003
+ getEventTarget(container).removeEventListener("scroll", scrollListener);
2004
+ resizeListeners.get(container)?.();
2005
+ window.removeEventListener("resize", scrollListener);
2006
+ }
2007
+ // Clean up scroll dimension checking
2008
+ const dimensionCheckProcess = dimensionCheckProcesses.get(container);
2009
+ if (dimensionCheckProcess) {
2010
+ cancelFrame(dimensionCheckProcess);
2011
+ dimensionCheckProcesses.delete(container);
2012
+ }
2013
+ scrollSize.delete(container);
2014
+ };
2015
+ }
2016
+
2017
+ /**
2018
+ * Maps from ProgressIntersection pairs used by Motion's preset offsets to
2019
+ * ViewTimeline named ranges. Returns undefined for unrecognised patterns,
2020
+ * which signals the caller to fall back to JS-based scroll tracking.
2021
+ */
2022
+ const presets = [
2023
+ [ScrollOffset.Enter, "entry"],
2024
+ [ScrollOffset.Exit, "exit"],
2025
+ [ScrollOffset.Any, "cover"],
2026
+ [ScrollOffset.All, "contain"],
2027
+ ];
2028
+ const stringToProgress = {
2029
+ start: 0,
2030
+ end: 1,
2031
+ };
2032
+ function parseStringOffset(s) {
2033
+ const parts = s.trim().split(/\s+/);
2034
+ if (parts.length !== 2)
2035
+ return undefined;
2036
+ const a = stringToProgress[parts[0]];
2037
+ const b = stringToProgress[parts[1]];
2038
+ if (a === undefined || b === undefined)
2039
+ return undefined;
2040
+ return [a, b];
2041
+ }
2042
+ function normaliseOffset(offset) {
2043
+ if (offset.length !== 2)
2044
+ return undefined;
2045
+ const result = [];
2046
+ for (const item of offset) {
2047
+ if (Array.isArray(item)) {
2048
+ result.push(item);
2049
+ }
2050
+ else if (typeof item === "string") {
2051
+ const parsed = parseStringOffset(item);
2052
+ if (!parsed)
2053
+ return undefined;
2054
+ result.push(parsed);
2055
+ }
2056
+ else {
2057
+ return undefined;
2058
+ }
2059
+ }
2060
+ return result;
2061
+ }
2062
+ function matchesPreset(offset, preset) {
2063
+ const normalised = normaliseOffset(offset);
2064
+ if (!normalised)
2065
+ return false;
2066
+ for (let i = 0; i < 2; i++) {
2067
+ const o = normalised[i];
2068
+ const p = preset[i];
2069
+ if (o[0] !== p[0] || o[1] !== p[1])
2070
+ return false;
2071
+ }
2072
+ return true;
2073
+ }
2074
+ function offsetToViewTimelineRange(offset) {
2075
+ if (!offset) {
2076
+ return { rangeStart: "contain 0%", rangeEnd: "contain 100%" };
2077
+ }
2078
+ for (const [preset, name] of presets) {
2079
+ if (matchesPreset(offset, preset)) {
2080
+ return { rangeStart: `${name} 0%`, rangeEnd: `${name} 100%` };
2081
+ }
2082
+ }
2083
+ return undefined;
2084
+ }
2085
+
2086
+ const timelineCache = new Map();
2087
+ function scrollTimelineFallback(options) {
2088
+ const currentTime = { value: 0 };
2089
+ const cancel = scrollInfo((info) => {
2090
+ currentTime.value = info[options.axis].progress * 100;
2091
+ }, options);
2092
+ return { currentTime, cancel };
2093
+ }
2094
+ function getTimeline({ source, container, ...options }) {
2095
+ const { axis } = options;
2096
+ if (source)
2097
+ container = source;
2098
+ let containerCache = timelineCache.get(container);
2099
+ if (!containerCache) {
2100
+ containerCache = new Map();
2101
+ timelineCache.set(container, containerCache);
2102
+ }
2103
+ const targetKey = options.target ?? "self";
2104
+ let targetCache = containerCache.get(targetKey);
2105
+ if (!targetCache) {
2106
+ targetCache = {};
2107
+ containerCache.set(targetKey, targetCache);
2108
+ }
2109
+ const axisKey = axis + (options.offset ?? []).join(",");
2110
+ if (!targetCache[axisKey]) {
2111
+ if (options.target && canUseNativeTimeline(options.target)) {
2112
+ const range = offsetToViewTimelineRange(options.offset);
2113
+ if (range) {
2114
+ targetCache[axisKey] = new ViewTimeline({
2115
+ subject: options.target,
2116
+ axis,
2117
+ });
2118
+ }
2119
+ else {
2120
+ targetCache[axisKey] = scrollTimelineFallback({
2121
+ container,
2122
+ ...options,
2123
+ });
2124
+ }
2125
+ }
2126
+ else if (canUseNativeTimeline()) {
2127
+ targetCache[axisKey] = new ScrollTimeline({
2128
+ source: container,
2129
+ axis,
2130
+ });
2131
+ }
2132
+ else {
2133
+ targetCache[axisKey] = scrollTimelineFallback({
2134
+ container,
2135
+ ...options,
2136
+ });
2137
+ }
2138
+ }
2139
+ return targetCache[axisKey];
2140
+ }
2141
+
2142
+ function attachToAnimation(animation, options) {
2143
+ const timeline = getTimeline(options);
2144
+ const range = options.target
2145
+ ? offsetToViewTimelineRange(options.offset)
2146
+ : undefined;
2147
+ /**
2148
+ * Use native timeline when:
2149
+ * - No target: ScrollTimeline (existing behaviour)
2150
+ * - Target with mappable offset: ViewTimeline with named range
2151
+ * - Target with unmappable offset: fall back to JS observe
2152
+ */
2153
+ const useNative = options.target
2154
+ ? canUseNativeTimeline(options.target) && !!range
2155
+ : canUseNativeTimeline();
2156
+ return animation.attachTimeline({
2157
+ timeline: useNative ? timeline : undefined,
2158
+ ...(range &&
2159
+ useNative && {
2160
+ rangeStart: range.rangeStart,
2161
+ rangeEnd: range.rangeEnd,
2162
+ }),
2163
+ observe: (valueAnimation) => {
2164
+ valueAnimation.pause();
2165
+ return observeTimeline((progress) => {
2166
+ valueAnimation.time =
2167
+ valueAnimation.iterationDuration * progress;
2168
+ }, timeline);
2169
+ },
2170
+ });
2171
+ }
2172
+
2173
+ /**
2174
+ * If the onScroll function has two arguments, it's expecting
2175
+ * more specific information about the scroll from scrollInfo.
2176
+ */
2177
+ function isOnScrollWithInfo(onScroll) {
2178
+ return onScroll.length === 2;
2179
+ }
2180
+ function attachToFunction(onScroll, options) {
2181
+ if (isOnScrollWithInfo(onScroll)) {
2182
+ return scrollInfo((info) => {
2183
+ onScroll(info[options.axis].progress, info);
2184
+ }, options);
2185
+ }
2186
+ else {
2187
+ return observeTimeline(onScroll, getTimeline(options));
2188
+ }
2189
+ }
2190
+
2191
+ function scroll(onScroll, { axis = "y", container = document.scrollingElement, ...options } = {}) {
2192
+ if (!container)
2193
+ return noop$1;
2194
+ const optionsWithDefaults = { axis, container, ...options };
2195
+ return typeof onScroll === "function"
2196
+ ? attachToFunction(onScroll, optionsWithDefaults)
2197
+ : attachToAnimation(onScroll, optionsWithDefaults);
2198
+ }
2199
+
2200
+ const createScrollMotionValues = () => ({
2201
+ scrollX: motionValue(0),
2202
+ scrollY: motionValue(0),
2203
+ scrollXProgress: motionValue(0),
2204
+ scrollYProgress: motionValue(0),
2205
+ });
2206
+ const isRefPending = (ref) => {
2207
+ if (!ref)
2208
+ return false;
2209
+ return !ref.current;
2210
+ };
2211
+ function makeAccelerateConfig(axis, options, container, target) {
2212
+ return {
2213
+ factory: (animation) => scroll(animation, {
2214
+ ...options,
2215
+ axis,
2216
+ container: container?.current || undefined,
2217
+ target: target?.current || undefined,
2218
+ }),
2219
+ times: [0, 1],
2220
+ keyframes: [0, 1],
2221
+ ease: (v) => v,
2222
+ duration: 1,
2223
+ };
2224
+ }
2225
+ function canAccelerateScroll(target, offset) {
2226
+ if (typeof window === "undefined")
2227
+ return false;
2228
+ return target
2229
+ ? supportsViewTimeline() && !!offsetToViewTimelineRange(offset)
2230
+ : supportsScrollTimeline();
2231
+ }
2232
+ function useScroll({ container, target, ...options } = {}) {
2233
+ const values = useConstant(createScrollMotionValues);
2234
+ if (canAccelerateScroll(target, options.offset)) {
2235
+ values.scrollXProgress.accelerate = makeAccelerateConfig("x", options, container, target);
2236
+ values.scrollYProgress.accelerate = makeAccelerateConfig("y", options, container, target);
2237
+ }
2238
+ const scrollAnimation = useRef(null);
2239
+ const needsStart = useRef(false);
2240
+ const start = useCallback(() => {
2241
+ scrollAnimation.current = scroll((_progress, { x, y, }) => {
2242
+ values.scrollX.set(x.current);
2243
+ values.scrollXProgress.set(x.progress);
2244
+ values.scrollY.set(y.current);
2245
+ values.scrollYProgress.set(y.progress);
2246
+ }, {
2247
+ ...options,
2248
+ container: container?.current || undefined,
2249
+ target: target?.current || undefined,
2250
+ });
2251
+ return () => {
2252
+ scrollAnimation.current?.();
2253
+ };
2254
+ }, [container, target, JSON.stringify(options.offset)]);
2255
+ useIsomorphicLayoutEffect(() => {
2256
+ needsStart.current = false;
2257
+ if (isRefPending(container) || isRefPending(target)) {
2258
+ needsStart.current = true;
2259
+ return;
2260
+ }
2261
+ else {
2262
+ return start();
2263
+ }
2264
+ }, [start]);
2265
+ useEffect(() => {
2266
+ if (needsStart.current) {
2267
+ invariant(!isRefPending(container), "Container ref is defined but not hydrated", "use-scroll-ref");
2268
+ invariant(!isRefPending(target), "Target ref is defined but not hydrated", "use-scroll-ref");
2269
+ return start();
2270
+ }
2271
+ else {
2272
+ return;
2273
+ }
2274
+ }, [start]);
2275
+ return values;
2276
+ }
2277
+
2278
+ /**
2279
+ * @deprecated useElementScroll is deprecated. Convert to useScroll({ container: ref })
2280
+ */
2281
+ function useElementScroll(ref) {
2282
+ if (process.env.NODE_ENV === "development") {
2283
+ warnOnce(false, "useElementScroll is deprecated. Convert to useScroll({ container: ref }).");
2284
+ }
2285
+ return useScroll({ container: ref });
2286
+ }
2287
+
2288
+ /**
2289
+ * @deprecated useViewportScroll is deprecated. Convert to useScroll()
2290
+ */
2291
+ function useViewportScroll() {
2292
+ if (process.env.NODE_ENV !== "production") {
2293
+ warnOnce(false, "useViewportScroll is deprecated. Convert to useScroll().");
2294
+ }
2295
+ return useScroll();
2296
+ }
2297
+
2298
+ /**
2299
+ * Creates a `MotionValue` to track the state and velocity of a value.
2300
+ *
2301
+ * Usually, these are created automatically. For advanced use-cases, like use with `useTransform`, you can create `MotionValue`s externally and pass them into the animated component via the `style` prop.
2302
+ *
2303
+ * ```jsx
2304
+ * export const MyComponent = () => {
2305
+ * const scale = useMotionValue(1)
2306
+ *
2307
+ * return <motion.div style={{ scale }} />
2308
+ * }
2309
+ * ```
2310
+ *
2311
+ * @param initial - The initial state.
2312
+ *
2313
+ * @public
2314
+ */
2315
+ function useMotionValue(initial) {
2316
+ const value = useConstant(() => motionValue(initial));
2317
+ /**
2318
+ * If this motion value is being used in static mode, like on
2319
+ * the Framer canvas, force components to rerender when the motion
2320
+ * value is updated.
2321
+ */
2322
+ const { isStatic } = useContext(MotionConfigContext);
2323
+ if (isStatic) {
2324
+ const [, setLatest] = useState(initial);
2325
+ useEffect(() => value.on("change", setLatest), []);
2326
+ }
2327
+ return value;
2328
+ }
2329
+
2330
+ function useCombineMotionValues(values, combineValues) {
2331
+ /**
2332
+ * Initialise the returned motion value. This remains the same between renders.
2333
+ */
2334
+ const value = useMotionValue(combineValues());
2335
+ /**
2336
+ * Create a function that will update the template motion value with the latest values.
2337
+ * This is pre-bound so whenever a motion value updates it can schedule its
2338
+ * execution in Framesync. If it's already been scheduled it won't be fired twice
2339
+ * in a single frame.
2340
+ */
2341
+ const updateValue = () => value.set(combineValues());
2342
+ /**
2343
+ * Synchronously update the motion value with the latest values during the render.
2344
+ * This ensures that within a React render, the styles applied to the DOM are up-to-date.
2345
+ */
2346
+ updateValue();
2347
+ /**
2348
+ * Subscribe to all motion values found within the template. Whenever any of them change,
2349
+ * schedule an update.
2350
+ */
2351
+ useIsomorphicLayoutEffect(() => {
2352
+ const scheduleUpdate = () => frame.preRender(updateValue, false, true);
2353
+ const subscriptions = values.map((v) => v.on("change", scheduleUpdate));
2354
+ return () => {
2355
+ subscriptions.forEach((unsubscribe) => unsubscribe());
2356
+ cancelFrame(updateValue);
2357
+ };
2358
+ });
2359
+ return value;
2360
+ }
2361
+
2362
+ /**
2363
+ * Combine multiple motion values into a new one using a string template literal.
2364
+ *
2365
+ * ```jsx
2366
+ * import {
2367
+ * motion,
2368
+ * useSpring,
2369
+ * useMotionValue,
2370
+ * useMotionTemplate
2371
+ * } from "framer-motion"
2372
+ *
2373
+ * function Component() {
2374
+ * const shadowX = useSpring(0)
2375
+ * const shadowY = useMotionValue(0)
2376
+ * const shadow = useMotionTemplate`drop-shadow(${shadowX}px ${shadowY}px 20px rgba(0,0,0,0.3))`
2377
+ *
2378
+ * return <motion.div style={{ filter: shadow }} />
2379
+ * }
2380
+ * ```
2381
+ *
2382
+ * @public
2383
+ */
2384
+ function useMotionTemplate(fragments, ...values) {
2385
+ /**
2386
+ * Create a function that will build a string from the latest motion values.
2387
+ */
2388
+ const numFragments = fragments.length;
2389
+ function buildValue() {
2390
+ let output = ``;
2391
+ for (let i = 0; i < numFragments; i++) {
2392
+ output += fragments[i];
2393
+ const value = values[i];
2394
+ if (value) {
2395
+ output += isMotionValue(value) ? value.get() : value;
2396
+ }
2397
+ }
2398
+ return output;
2399
+ }
2400
+ return useCombineMotionValues(values.filter(isMotionValue), buildValue);
2401
+ }
2402
+
2403
+ function useComputed(compute) {
2404
+ /**
2405
+ * Open session of collectMotionValues. Any MotionValue that calls get()
2406
+ * will be saved into this array.
2407
+ */
2408
+ collectMotionValues.current = [];
2409
+ compute();
2410
+ const value = useCombineMotionValues(collectMotionValues.current, compute);
2411
+ /**
2412
+ * Synchronously close session of collectMotionValues.
2413
+ */
2414
+ collectMotionValues.current = undefined;
2415
+ return value;
2416
+ }
2417
+
2418
+ function useTransform(input, inputRangeOrTransformer, outputRangeOrMap, options) {
2419
+ if (typeof input === "function") {
2420
+ return useComputed(input);
2421
+ }
2422
+ /**
2423
+ * Detect if outputRangeOrMap is an output map (object with keys)
2424
+ * rather than an output range (array).
2425
+ */
2426
+ const isOutputMap = outputRangeOrMap !== undefined &&
2427
+ !Array.isArray(outputRangeOrMap) &&
2428
+ typeof inputRangeOrTransformer !== "function";
2429
+ if (isOutputMap) {
2430
+ return useMapTransform(input, inputRangeOrTransformer, outputRangeOrMap, options);
2431
+ }
2432
+ const outputRange = outputRangeOrMap;
2433
+ const transformer = typeof inputRangeOrTransformer === "function"
2434
+ ? inputRangeOrTransformer
2435
+ : transform(inputRangeOrTransformer, outputRange, options);
2436
+ const result = Array.isArray(input)
2437
+ ? useListTransform(input, transformer)
2438
+ : useListTransform([input], ([latest]) => transformer(latest));
2439
+ const inputAccelerate = !Array.isArray(input)
2440
+ ? input.accelerate
2441
+ : undefined;
2442
+ if (inputAccelerate &&
2443
+ !inputAccelerate.isTransformed &&
2444
+ typeof inputRangeOrTransformer !== "function" &&
2445
+ Array.isArray(outputRangeOrMap) &&
2446
+ options?.clamp !== false) {
2447
+ result.accelerate = {
2448
+ ...inputAccelerate,
2449
+ times: inputRangeOrTransformer,
2450
+ keyframes: outputRangeOrMap,
2451
+ isTransformed: true,
2452
+ ...(options?.ease ? { ease: options.ease } : {}),
2453
+ };
2454
+ }
2455
+ return result;
2456
+ }
2457
+ function useListTransform(values, transformer) {
2458
+ const latest = useConstant(() => []);
2459
+ return useCombineMotionValues(values, () => {
2460
+ latest.length = 0;
2461
+ const numValues = values.length;
2462
+ for (let i = 0; i < numValues; i++) {
2463
+ latest[i] = values[i].get();
2464
+ }
2465
+ return transformer(latest);
2466
+ });
2467
+ }
2468
+ function useMapTransform(inputValue, inputRange, outputMap, options) {
2469
+ /**
2470
+ * Capture keys once to ensure hooks are called in consistent order.
2471
+ */
2472
+ const keys = useConstant(() => Object.keys(outputMap));
2473
+ const output = useConstant(() => ({}));
2474
+ for (const key of keys) {
2475
+ output[key] = useTransform(inputValue, inputRange, outputMap[key], options);
2476
+ }
2477
+ return output;
2478
+ }
2479
+
2480
+ function useFollowValue(source, options = {}) {
2481
+ const { isStatic } = useContext(MotionConfigContext);
2482
+ const getFromSource = () => (isMotionValue(source) ? source.get() : source);
2483
+ // isStatic will never change, allowing early hooks return
2484
+ if (isStatic) {
2485
+ return useTransform(getFromSource);
2486
+ }
2487
+ const value = useMotionValue(getFromSource());
2488
+ useInsertionEffect(() => {
2489
+ return attachFollow(value, source, options);
2490
+ }, [value, JSON.stringify(options)]);
2491
+ return value;
2492
+ }
2493
+
2494
+ function useSpring(source, options = {}) {
2495
+ return useFollowValue(source, { type: "spring", ...options });
2496
+ }
2497
+
2498
+ function useAnimationFrame(callback) {
2499
+ const initialTimestamp = useRef(0);
2500
+ const { isStatic } = useContext(MotionConfigContext);
2501
+ useEffect(() => {
2502
+ if (isStatic)
2503
+ return;
2504
+ const provideTimeSinceStart = ({ timestamp, delta }) => {
2505
+ if (!initialTimestamp.current)
2506
+ initialTimestamp.current = timestamp;
2507
+ callback(timestamp - initialTimestamp.current, delta);
2508
+ };
2509
+ frame.update(provideTimeSinceStart, true);
2510
+ return () => cancelFrame(provideTimeSinceStart);
2511
+ }, [callback]);
2512
+ }
2513
+
2514
+ function useTime() {
2515
+ const time = useMotionValue(0);
2516
+ useAnimationFrame((t) => time.set(t));
2517
+ return time;
2518
+ }
2519
+
2520
+ /**
2521
+ * Creates a `MotionValue` that updates when the velocity of the provided `MotionValue` changes.
2522
+ *
2523
+ * ```javascript
2524
+ * const x = useMotionValue(0)
2525
+ * const xVelocity = useVelocity(x)
2526
+ * const xAcceleration = useVelocity(xVelocity)
2527
+ * ```
2528
+ *
2529
+ * @public
2530
+ */
2531
+ function useVelocity(value) {
2532
+ const velocity = useMotionValue(value.getVelocity());
2533
+ const updateVelocity = () => {
2534
+ const latest = value.getVelocity();
2535
+ velocity.set(latest);
2536
+ /**
2537
+ * If we still have velocity, schedule an update for the next frame
2538
+ * to keep checking until it is zero.
2539
+ */
2540
+ if (latest)
2541
+ frame.update(updateVelocity);
2542
+ };
2543
+ useMotionValueEvent(value, "change", () => {
2544
+ // Schedule an update to this value at the end of the current frame.
2545
+ frame.update(updateVelocity, false, true);
2546
+ });
2547
+ return velocity;
2548
+ }
2549
+
2550
+ class WillChangeMotionValue extends MotionValue {
2551
+ constructor() {
2552
+ super(...arguments);
2553
+ this.isEnabled = false;
2554
+ }
2555
+ add(name) {
2556
+ if (transformProps.has(name) || acceleratedValues.has(name)) {
2557
+ this.isEnabled = true;
2558
+ this.update();
2559
+ }
2560
+ }
2561
+ update() {
2562
+ this.set(this.isEnabled ? "transform" : "auto");
2563
+ }
2564
+ }
2565
+
2566
+ function useWillChange() {
2567
+ return useConstant(() => new WillChangeMotionValue("auto"));
2568
+ }
2569
+
2570
+ /**
2571
+ * A hook that returns `true` if we should be using reduced motion based on the current device's Reduced Motion setting.
2572
+ *
2573
+ * This can be used to implement changes to your UI based on Reduced Motion. For instance, replacing motion-sickness inducing
2574
+ * `x`/`y` animations with `opacity`, disabling the autoplay of background videos, or turning off parallax motion.
2575
+ *
2576
+ * It will actively respond to changes and re-render your components with the latest setting.
2577
+ *
2578
+ * ```jsx
2579
+ * export function Sidebar({ isOpen }) {
2580
+ * const shouldReduceMotion = useReducedMotion()
2581
+ * const closedX = shouldReduceMotion ? 0 : "-100%"
2582
+ *
2583
+ * return (
2584
+ * <motion.div animate={{
2585
+ * opacity: isOpen ? 1 : 0,
2586
+ * x: isOpen ? 0 : closedX
2587
+ * }} />
2588
+ * )
2589
+ * }
2590
+ * ```
2591
+ *
2592
+ * @return boolean
2593
+ *
2594
+ * @public
2595
+ */
2596
+ function useReducedMotion() {
2597
+ /**
2598
+ * Lazy initialisation of prefersReducedMotion
2599
+ */
2600
+ !hasReducedMotionListener.current && initPrefersReducedMotion();
2601
+ const [shouldReduceMotion] = useState(prefersReducedMotion.current);
2602
+ if (process.env.NODE_ENV !== "production") {
2603
+ warnOnce(shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.", "reduced-motion-disabled");
2604
+ }
2605
+ /**
2606
+ * TODO See if people miss automatically updating shouldReduceMotion setting
2607
+ */
2608
+ return shouldReduceMotion;
2609
+ }
2610
+
2611
+ function useReducedMotionConfig() {
2612
+ const reducedMotionPreference = useReducedMotion();
2613
+ const { reducedMotion } = useContext(MotionConfigContext);
2614
+ if (reducedMotion === "never") {
2615
+ return false;
2616
+ }
2617
+ else if (reducedMotion === "always") {
2618
+ return true;
2619
+ }
2620
+ else {
2621
+ return reducedMotionPreference;
2622
+ }
2623
+ }
2624
+
2625
+ function stopAnimation(visualElement) {
2626
+ visualElement.values.forEach((value) => value.stop());
2627
+ }
2628
+ function setVariants(visualElement, variantLabels) {
2629
+ const reversedLabels = [...variantLabels].reverse();
2630
+ reversedLabels.forEach((key) => {
2631
+ const variant = visualElement.getVariant(key);
2632
+ variant && setTarget(visualElement, variant);
2633
+ if (visualElement.variantChildren) {
2634
+ visualElement.variantChildren.forEach((child) => {
2635
+ setVariants(child, variantLabels);
2636
+ });
2637
+ }
2638
+ });
2639
+ }
2640
+ function setValues(visualElement, definition) {
2641
+ if (Array.isArray(definition)) {
2642
+ return setVariants(visualElement, definition);
2643
+ }
2644
+ else if (typeof definition === "string") {
2645
+ return setVariants(visualElement, [definition]);
2646
+ }
2647
+ else {
2648
+ setTarget(visualElement, definition);
2649
+ }
2650
+ }
2651
+ /**
2652
+ * @public
2653
+ */
2654
+ function animationControls() {
2655
+ /**
2656
+ * Track whether the host component has mounted.
2657
+ */
2658
+ let hasMounted = false;
2659
+ /**
2660
+ * A collection of linked component animation controls.
2661
+ */
2662
+ const subscribers = new Set();
2663
+ const controls = {
2664
+ subscribe(visualElement) {
2665
+ subscribers.add(visualElement);
2666
+ return () => void subscribers.delete(visualElement);
2667
+ },
2668
+ start(definition, transitionOverride) {
2669
+ invariant(hasMounted, "controls.start() should only be called after a component has mounted. Consider calling within a useEffect hook.");
2670
+ const animations = [];
2671
+ subscribers.forEach((visualElement) => {
2672
+ animations.push(animateVisualElement(visualElement, definition, {
2673
+ transitionOverride,
2674
+ }));
2675
+ });
2676
+ return Promise.all(animations);
2677
+ },
2678
+ set(definition) {
2679
+ invariant(hasMounted, "controls.set() should only be called after a component has mounted. Consider calling within a useEffect hook.");
2680
+ return subscribers.forEach((visualElement) => {
2681
+ setValues(visualElement, definition);
2682
+ });
2683
+ },
2684
+ stop() {
2685
+ subscribers.forEach((visualElement) => {
2686
+ stopAnimation(visualElement);
2687
+ });
2688
+ },
2689
+ mount() {
2690
+ hasMounted = true;
2691
+ return () => {
2692
+ hasMounted = false;
2693
+ controls.stop();
2694
+ };
2695
+ },
2696
+ };
2697
+ return controls;
2698
+ }
2699
+
2700
+ function isDOMKeyframes(keyframes) {
2701
+ return typeof keyframes === "object" && !Array.isArray(keyframes);
2702
+ }
2703
+
2704
+ function resolveSubjects(subject, keyframes, scope, selectorCache) {
2705
+ if (subject == null) {
2706
+ return [];
2707
+ }
2708
+ if (typeof subject === "string" && isDOMKeyframes(keyframes)) {
2709
+ return resolveElements(subject, scope, selectorCache);
2710
+ }
2711
+ else if (subject instanceof NodeList) {
2712
+ return Array.from(subject);
2713
+ }
2714
+ else if (Array.isArray(subject)) {
2715
+ return subject.filter((s) => s != null);
2716
+ }
2717
+ else {
2718
+ return [subject];
2719
+ }
2720
+ }
2721
+
2722
+ function calculateRepeatDuration(duration, repeat, _repeatDelay) {
2723
+ return duration * (repeat + 1);
2724
+ }
2725
+
2726
+ /**
2727
+ * Given a absolute or relative time definition and current/prev time state of the sequence,
2728
+ * calculate an absolute time for the next keyframes.
2729
+ */
2730
+ function calcNextTime(current, next, prev, labels) {
2731
+ if (typeof next === "number") {
2732
+ return next;
2733
+ }
2734
+ else if (next.startsWith("-") || next.startsWith("+")) {
2735
+ return Math.max(0, current + parseFloat(next));
2736
+ }
2737
+ else if (next === "<") {
2738
+ return prev;
2739
+ }
2740
+ else if (next.startsWith("<")) {
2741
+ return Math.max(0, prev + parseFloat(next.slice(1)));
2742
+ }
2743
+ else {
2744
+ return labels.get(next) ?? current;
2745
+ }
2746
+ }
2747
+
2748
+ function eraseKeyframes(sequence, startTime, endTime) {
2749
+ for (let i = 0; i < sequence.length; i++) {
2750
+ const keyframe = sequence[i];
2751
+ if (keyframe.at > startTime && keyframe.at < endTime) {
2752
+ removeItem(sequence, keyframe);
2753
+ // If we remove this item we have to push the pointer back one
2754
+ i--;
2755
+ }
2756
+ }
2757
+ }
2758
+ function addKeyframes(sequence, keyframes, easing, offset, startTime, endTime) {
2759
+ /**
2760
+ * Erase every existing value between currentTime and targetTime,
2761
+ * this will essentially splice this timeline into any currently
2762
+ * defined ones.
2763
+ */
2764
+ eraseKeyframes(sequence, startTime, endTime);
2765
+ for (let i = 0; i < keyframes.length; i++) {
2766
+ sequence.push({
2767
+ value: keyframes[i],
2768
+ at: mixNumber(startTime, endTime, offset[i]),
2769
+ easing: getEasingForSegment(easing, i),
2770
+ });
2771
+ }
2772
+ }
2773
+
2774
+ /**
2775
+ * Take an array of times that represent repeated keyframes. For instance
2776
+ * if we have original times of [0, 0.5, 1] then our repeated times will
2777
+ * be [0, 0.5, 1, 1, 1.5, 2]. Loop over the times and scale them back
2778
+ * down to a 0-1 scale.
2779
+ */
2780
+ function normalizeTimes(times, repeat) {
2781
+ for (let i = 0; i < times.length; i++) {
2782
+ times[i] = times[i] / (repeat + 1);
2783
+ }
2784
+ }
2785
+
2786
+ function compareByTime(a, b) {
2787
+ if (a.at === b.at) {
2788
+ if (a.value === null)
2789
+ return 1;
2790
+ if (b.value === null)
2791
+ return -1;
2792
+ return 0;
2793
+ }
2794
+ else {
2795
+ return a.at - b.at;
2796
+ }
2797
+ }
2798
+
2799
+ const defaultSegmentEasing = "easeInOut";
2800
+ const MAX_REPEAT = 20;
2801
+ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...sequenceTransition } = {}, scope, generators) {
2802
+ const defaultDuration = defaultTransition.duration || 0.3;
2803
+ const animationDefinitions = new Map();
2804
+ const sequences = new Map();
2805
+ const elementCache = {};
2806
+ const timeLabels = new Map();
2807
+ let prevTime = 0;
2808
+ let currentTime = 0;
2809
+ let totalDuration = 0;
2810
+ /**
2811
+ * Build the timeline by mapping over the sequence array and converting
2812
+ * the definitions into keyframes and offsets with absolute time values.
2813
+ * These will later get converted into relative offsets in a second pass.
2814
+ */
2815
+ for (let i = 0; i < sequence.length; i++) {
2816
+ const segment = sequence[i];
2817
+ /**
2818
+ * If this is a timeline label, mark it and skip the rest of this iteration.
2819
+ */
2820
+ if (typeof segment === "string") {
2821
+ timeLabels.set(segment, currentTime);
2822
+ continue;
2823
+ }
2824
+ else if (!Array.isArray(segment)) {
2825
+ timeLabels.set(segment.name, calcNextTime(currentTime, segment.at, prevTime, timeLabels));
2826
+ continue;
2827
+ }
2828
+ let [subject, keyframes, transition = {}] = segment;
2829
+ /**
2830
+ * If a relative or absolute time value has been specified we need to resolve
2831
+ * it in relation to the currentTime.
2832
+ */
2833
+ if (transition.at !== undefined) {
2834
+ currentTime = calcNextTime(currentTime, transition.at, prevTime, timeLabels);
2835
+ }
2836
+ /**
2837
+ * Keep track of the maximum duration in this definition. This will be
2838
+ * applied to currentTime once the definition has been parsed.
2839
+ */
2840
+ let maxDuration = 0;
2841
+ const resolveValueSequence = (valueKeyframes, valueTransition, valueSequence, elementIndex = 0, numSubjects = 0) => {
2842
+ const valueKeyframesAsList = keyframesAsList(valueKeyframes);
2843
+ const { delay = 0, times = defaultOffset$1(valueKeyframesAsList), type = defaultTransition.type || "keyframes", repeat, repeatType, repeatDelay = 0, ...remainingTransition } = valueTransition;
2844
+ let { ease = defaultTransition.ease || "easeOut", duration } = valueTransition;
2845
+ /**
2846
+ * Resolve stagger() if defined.
2847
+ */
2848
+ const calculatedDelay = typeof delay === "function"
2849
+ ? delay(elementIndex, numSubjects)
2850
+ : delay;
2851
+ /**
2852
+ * If this animation should and can use a spring, generate a spring easing function.
2853
+ */
2854
+ const numKeyframes = valueKeyframesAsList.length;
2855
+ const createGenerator = isGenerator(type)
2856
+ ? type
2857
+ : generators?.[type || "keyframes"];
2858
+ if (numKeyframes <= 2 && createGenerator) {
2859
+ /**
2860
+ * As we're creating an easing function from a spring,
2861
+ * ideally we want to generate it using the real distance
2862
+ * between the two keyframes. However this isn't always
2863
+ * possible - in these situations we use 0-100.
2864
+ */
2865
+ let absoluteDelta = 100;
2866
+ if (numKeyframes === 2 &&
2867
+ isNumberKeyframesArray(valueKeyframesAsList)) {
2868
+ const delta = valueKeyframesAsList[1] - valueKeyframesAsList[0];
2869
+ absoluteDelta = Math.abs(delta);
2870
+ }
2871
+ const springTransition = {
2872
+ ...defaultTransition,
2873
+ ...remainingTransition,
2874
+ };
2875
+ if (duration !== undefined) {
2876
+ springTransition.duration = secondsToMilliseconds(duration);
2877
+ }
2878
+ const springEasing = createGeneratorEasing(springTransition, absoluteDelta, createGenerator);
2879
+ ease = springEasing.ease;
2880
+ duration = springEasing.duration;
2881
+ }
2882
+ duration ?? (duration = defaultDuration);
2883
+ const startTime = currentTime + calculatedDelay;
2884
+ /**
2885
+ * If there's only one time offset of 0, fill in a second with length 1
2886
+ */
2887
+ if (times.length === 1 && times[0] === 0) {
2888
+ times[1] = 1;
2889
+ }
2890
+ /**
2891
+ * Fill out if offset if fewer offsets than keyframes
2892
+ */
2893
+ const remainder = times.length - valueKeyframesAsList.length;
2894
+ remainder > 0 && fillOffset(times, remainder);
2895
+ /**
2896
+ * If only one value has been set, ie [1], push a null to the start of
2897
+ * the keyframe array. This will let us mark a keyframe at this point
2898
+ * that will later be hydrated with the previous value.
2899
+ */
2900
+ valueKeyframesAsList.length === 1 &&
2901
+ valueKeyframesAsList.unshift(null);
2902
+ /**
2903
+ * Handle repeat options
2904
+ */
2905
+ if (repeat) {
2906
+ invariant(repeat < MAX_REPEAT, "Repeat count too high, must be less than 20", "repeat-count-high");
2907
+ duration = calculateRepeatDuration(duration, repeat);
2908
+ const originalKeyframes = [...valueKeyframesAsList];
2909
+ const originalTimes = [...times];
2910
+ ease = Array.isArray(ease) ? [...ease] : [ease];
2911
+ const originalEase = [...ease];
2912
+ for (let repeatIndex = 0; repeatIndex < repeat; repeatIndex++) {
2913
+ valueKeyframesAsList.push(...originalKeyframes);
2914
+ for (let keyframeIndex = 0; keyframeIndex < originalKeyframes.length; keyframeIndex++) {
2915
+ times.push(originalTimes[keyframeIndex] + (repeatIndex + 1));
2916
+ ease.push(keyframeIndex === 0
2917
+ ? "linear"
2918
+ : getEasingForSegment(originalEase, keyframeIndex - 1));
2919
+ }
2920
+ }
2921
+ normalizeTimes(times, repeat);
2922
+ }
2923
+ const targetTime = startTime + duration;
2924
+ /**
2925
+ * Add keyframes, mapping offsets to absolute time.
2926
+ */
2927
+ addKeyframes(valueSequence, valueKeyframesAsList, ease, times, startTime, targetTime);
2928
+ maxDuration = Math.max(calculatedDelay + duration, maxDuration);
2929
+ totalDuration = Math.max(targetTime, totalDuration);
2930
+ };
2931
+ if (isMotionValue(subject)) {
2932
+ const subjectSequence = getSubjectSequence(subject, sequences);
2933
+ resolveValueSequence(keyframes, transition, getValueSequence("default", subjectSequence));
2934
+ }
2935
+ else {
2936
+ const subjects = resolveSubjects(subject, keyframes, scope, elementCache);
2937
+ const numSubjects = subjects.length;
2938
+ /**
2939
+ * For every element in this segment, process the defined values.
2940
+ */
2941
+ for (let subjectIndex = 0; subjectIndex < numSubjects; subjectIndex++) {
2942
+ /**
2943
+ * Cast necessary, but we know these are of this type
2944
+ */
2945
+ keyframes = keyframes;
2946
+ transition = transition;
2947
+ const thisSubject = subjects[subjectIndex];
2948
+ const subjectSequence = getSubjectSequence(thisSubject, sequences);
2949
+ for (const key in keyframes) {
2950
+ resolveValueSequence(keyframes[key], getValueTransition(transition, key), getValueSequence(key, subjectSequence), subjectIndex, numSubjects);
2951
+ }
2952
+ }
2953
+ }
2954
+ prevTime = currentTime;
2955
+ currentTime += maxDuration;
2956
+ }
2957
+ /**
2958
+ * For every element and value combination create a new animation.
2959
+ */
2960
+ sequences.forEach((valueSequences, element) => {
2961
+ for (const key in valueSequences) {
2962
+ const valueSequence = valueSequences[key];
2963
+ /**
2964
+ * Arrange all the keyframes in ascending time order.
2965
+ */
2966
+ valueSequence.sort(compareByTime);
2967
+ const keyframes = [];
2968
+ const valueOffset = [];
2969
+ const valueEasing = [];
2970
+ /**
2971
+ * For each keyframe, translate absolute times into
2972
+ * relative offsets based on the total duration of the timeline.
2973
+ */
2974
+ for (let i = 0; i < valueSequence.length; i++) {
2975
+ const { at, value, easing } = valueSequence[i];
2976
+ keyframes.push(value);
2977
+ valueOffset.push(progress(0, totalDuration, at));
2978
+ valueEasing.push(easing || "easeOut");
2979
+ }
2980
+ /**
2981
+ * If the first keyframe doesn't land on offset: 0
2982
+ * provide one by duplicating the initial keyframe. This ensures
2983
+ * it snaps to the first keyframe when the animation starts.
2984
+ */
2985
+ if (valueOffset[0] !== 0) {
2986
+ valueOffset.unshift(0);
2987
+ keyframes.unshift(keyframes[0]);
2988
+ valueEasing.unshift(defaultSegmentEasing);
2989
+ }
2990
+ /**
2991
+ * If the last keyframe doesn't land on offset: 1
2992
+ * provide one with a null wildcard value. This will ensure it
2993
+ * stays static until the end of the animation.
2994
+ */
2995
+ if (valueOffset[valueOffset.length - 1] !== 1) {
2996
+ valueOffset.push(1);
2997
+ keyframes.push(null);
2998
+ }
2999
+ if (!animationDefinitions.has(element)) {
3000
+ animationDefinitions.set(element, {
3001
+ keyframes: {},
3002
+ transition: {},
3003
+ });
3004
+ }
3005
+ const definition = animationDefinitions.get(element);
3006
+ definition.keyframes[key] = keyframes;
3007
+ /**
3008
+ * Exclude `type` from defaultTransition since springs have been
3009
+ * converted to duration-based easing functions in resolveValueSequence.
3010
+ * Including `type: "spring"` would cause JSAnimation to error when
3011
+ * the merged keyframes array has more than 2 keyframes.
3012
+ */
3013
+ const { type: _type, ...remainingDefaultTransition } = defaultTransition;
3014
+ definition.transition[key] = {
3015
+ ...remainingDefaultTransition,
3016
+ duration: totalDuration,
3017
+ ease: valueEasing,
3018
+ times: valueOffset,
3019
+ ...sequenceTransition,
3020
+ };
3021
+ }
3022
+ });
3023
+ return animationDefinitions;
3024
+ }
3025
+ function getSubjectSequence(subject, sequences) {
3026
+ !sequences.has(subject) && sequences.set(subject, {});
3027
+ return sequences.get(subject);
3028
+ }
3029
+ function getValueSequence(name, sequences) {
3030
+ if (!sequences[name])
3031
+ sequences[name] = [];
3032
+ return sequences[name];
3033
+ }
3034
+ function keyframesAsList(keyframes) {
3035
+ return Array.isArray(keyframes) ? keyframes : [keyframes];
3036
+ }
3037
+ function getValueTransition(transition, key) {
3038
+ return transition && transition[key]
3039
+ ? {
3040
+ ...transition,
3041
+ ...transition[key],
3042
+ }
3043
+ : { ...transition };
3044
+ }
3045
+ const isNumber = (keyframe) => typeof keyframe === "number";
3046
+ const isNumberKeyframesArray = (keyframes) => keyframes.every(isNumber);
3047
+
3048
+ function createDOMVisualElement(element) {
3049
+ const options = {
3050
+ presenceContext: null,
3051
+ props: {},
3052
+ visualState: {
3053
+ renderState: {
3054
+ transform: {},
3055
+ transformOrigin: {},
3056
+ style: {},
3057
+ vars: {},
3058
+ attrs: {},
3059
+ },
3060
+ latestValues: {},
3061
+ },
3062
+ };
3063
+ const node = isSVGElement(element) && !isSVGSVGElement(element)
3064
+ ? new SVGVisualElement(options)
3065
+ : new HTMLVisualElement(options);
3066
+ node.mount(element);
3067
+ visualElementStore.set(element, node);
3068
+ }
3069
+ function createObjectVisualElement(subject) {
3070
+ const options = {
3071
+ presenceContext: null,
3072
+ props: {},
3073
+ visualState: {
3074
+ renderState: {
3075
+ output: {},
3076
+ },
3077
+ latestValues: {},
3078
+ },
3079
+ };
3080
+ const node = new ObjectVisualElement(options);
3081
+ node.mount(subject);
3082
+ visualElementStore.set(subject, node);
3083
+ }
3084
+
3085
+ function isSingleValue(subject, keyframes) {
3086
+ return (isMotionValue(subject) ||
3087
+ typeof subject === "number" ||
3088
+ (typeof subject === "string" && !isDOMKeyframes(keyframes)));
3089
+ }
3090
+ /**
3091
+ * Implementation
3092
+ */
3093
+ function animateSubject(subject, keyframes, options, scope) {
3094
+ const animations = [];
3095
+ if (isSingleValue(subject, keyframes)) {
3096
+ animations.push(animateSingleValue(subject, isDOMKeyframes(keyframes)
3097
+ ? keyframes.default || keyframes
3098
+ : keyframes, options ? options.default || options : options));
3099
+ }
3100
+ else {
3101
+ // Gracefully handle null/undefined subjects (e.g., from querySelector returning null)
3102
+ if (subject == null) {
3103
+ return animations;
3104
+ }
3105
+ const subjects = resolveSubjects(subject, keyframes, scope);
3106
+ const numSubjects = subjects.length;
3107
+ invariant(Boolean(numSubjects), "No valid elements provided.", "no-valid-elements");
3108
+ for (let i = 0; i < numSubjects; i++) {
3109
+ const thisSubject = subjects[i];
3110
+ const createVisualElement = thisSubject instanceof Element
3111
+ ? createDOMVisualElement
3112
+ : createObjectVisualElement;
3113
+ if (!visualElementStore.has(thisSubject)) {
3114
+ createVisualElement(thisSubject);
3115
+ }
3116
+ const visualElement = visualElementStore.get(thisSubject);
3117
+ const transition = { ...options };
3118
+ /**
3119
+ * Resolve stagger function if provided.
3120
+ */
3121
+ if ("delay" in transition &&
3122
+ typeof transition.delay === "function") {
3123
+ transition.delay = transition.delay(i, numSubjects);
3124
+ }
3125
+ animations.push(...animateTarget(visualElement, { ...keyframes, transition }, {}));
3126
+ }
3127
+ }
3128
+ return animations;
3129
+ }
3130
+
3131
+ function animateSequence(sequence, options, scope) {
3132
+ const animations = [];
3133
+ /**
3134
+ * Pre-process: replace function segments with MotionValue segments,
3135
+ * subscribe callbacks immediately
3136
+ */
3137
+ const processedSequence = sequence.map((segment) => {
3138
+ if (Array.isArray(segment) && typeof segment[0] === "function") {
3139
+ const callback = segment[0];
3140
+ const mv = motionValue(0);
3141
+ mv.on("change", callback);
3142
+ if (segment.length === 1) {
3143
+ return [mv, [0, 1]];
3144
+ }
3145
+ else if (segment.length === 2) {
3146
+ return [mv, [0, 1], segment[1]];
3147
+ }
3148
+ else {
3149
+ return [mv, segment[1], segment[2]];
3150
+ }
3151
+ }
3152
+ return segment;
3153
+ });
3154
+ const animationDefinitions = createAnimationsFromSequence(processedSequence, options, scope, { spring });
3155
+ animationDefinitions.forEach(({ keyframes, transition }, subject) => {
3156
+ animations.push(...animateSubject(subject, keyframes, transition));
3157
+ });
3158
+ return animations;
3159
+ }
3160
+
3161
+ function isSequence(value) {
3162
+ return Array.isArray(value) && value.some(Array.isArray);
3163
+ }
3164
+ /**
3165
+ * Creates an animation function that is optionally scoped
3166
+ * to a specific element.
3167
+ */
3168
+ function createScopedAnimate(options = {}) {
3169
+ const { scope, reduceMotion } = options;
3170
+ /**
3171
+ * Implementation
3172
+ */
3173
+ function scopedAnimate(subjectOrSequence, optionsOrKeyframes, options) {
3174
+ let animations = [];
3175
+ let animationOnComplete;
3176
+ if (isSequence(subjectOrSequence)) {
3177
+ const { onComplete, ...sequenceOptions } = optionsOrKeyframes || {};
3178
+ if (typeof onComplete === "function") {
3179
+ animationOnComplete = onComplete;
3180
+ }
3181
+ animations = animateSequence(subjectOrSequence, reduceMotion !== undefined
3182
+ ? { reduceMotion, ...sequenceOptions }
3183
+ : sequenceOptions, scope);
3184
+ }
3185
+ else {
3186
+ // Extract top-level onComplete so it doesn't get applied per-value
3187
+ const { onComplete, ...rest } = options || {};
3188
+ if (typeof onComplete === "function") {
3189
+ animationOnComplete = onComplete;
3190
+ }
3191
+ animations = animateSubject(subjectOrSequence, optionsOrKeyframes, (reduceMotion !== undefined
3192
+ ? { reduceMotion, ...rest }
3193
+ : rest), scope);
3194
+ }
3195
+ const animation = new GroupAnimationWithThen(animations);
3196
+ if (animationOnComplete) {
3197
+ animation.finished.then(animationOnComplete);
3198
+ }
3199
+ if (scope) {
3200
+ scope.animations.push(animation);
3201
+ animation.finished.then(() => {
3202
+ removeItem(scope.animations, animation);
3203
+ });
3204
+ }
3205
+ return animation;
3206
+ }
3207
+ return scopedAnimate;
3208
+ }
3209
+ const animate = createScopedAnimate();
3210
+
3211
+ function useAnimate() {
3212
+ const scope = useConstant(() => ({
3213
+ current: null, // Will be hydrated by React
3214
+ animations: [],
3215
+ }));
3216
+ const reduceMotion = useReducedMotionConfig() ?? undefined;
3217
+ const animate = useMemo(() => createScopedAnimate({ scope, reduceMotion }), [scope, reduceMotion]);
3218
+ useUnmountEffect(() => {
3219
+ scope.animations.forEach((animation) => animation.stop());
3220
+ scope.animations.length = 0;
3221
+ });
3222
+ return [scope, animate];
3223
+ }
3224
+
3225
+ function animateElements(elementOrSelector, keyframes, options, scope) {
3226
+ // Gracefully handle null/undefined elements (e.g., from querySelector returning null)
3227
+ if (elementOrSelector == null) {
3228
+ return [];
3229
+ }
3230
+ const elements = resolveElements(elementOrSelector, scope);
3231
+ const numElements = elements.length;
3232
+ invariant(Boolean(numElements), "No valid elements provided.", "no-valid-elements");
3233
+ /**
3234
+ * WAAPI doesn't support interrupting animations.
3235
+ *
3236
+ * Therefore, starting animations requires a three-step process:
3237
+ * 1. Stop existing animations (write styles to DOM)
3238
+ * 2. Resolve keyframes (read styles from DOM)
3239
+ * 3. Create new animations (write styles to DOM)
3240
+ *
3241
+ * The hybrid `animate()` function uses AsyncAnimation to resolve
3242
+ * keyframes before creating new animations, which removes style
3243
+ * thrashing. Here, we have much stricter filesize constraints.
3244
+ * Therefore we do this in a synchronous way that ensures that
3245
+ * at least within `animate()` calls there is no style thrashing.
3246
+ *
3247
+ * In the motion-native-animate-mini-interrupt benchmark this
3248
+ * was 80% faster than a single loop.
3249
+ */
3250
+ const animationDefinitions = [];
3251
+ /**
3252
+ * Step 1: Build options and stop existing animations (write)
3253
+ */
3254
+ for (let i = 0; i < numElements; i++) {
3255
+ const element = elements[i];
3256
+ const elementTransition = { ...options };
3257
+ /**
3258
+ * Resolve stagger function if provided.
3259
+ */
3260
+ if (typeof elementTransition.delay === "function") {
3261
+ elementTransition.delay = elementTransition.delay(i, numElements);
3262
+ }
3263
+ for (const valueName in keyframes) {
3264
+ let valueKeyframes = keyframes[valueName];
3265
+ if (!Array.isArray(valueKeyframes)) {
3266
+ valueKeyframes = [valueKeyframes];
3267
+ }
3268
+ const valueOptions = {
3269
+ ...getValueTransition$1(elementTransition, valueName),
3270
+ };
3271
+ valueOptions.duration && (valueOptions.duration = secondsToMilliseconds(valueOptions.duration));
3272
+ valueOptions.delay && (valueOptions.delay = secondsToMilliseconds(valueOptions.delay));
3273
+ /**
3274
+ * If there's an existing animation playing on this element then stop it
3275
+ * before creating a new one.
3276
+ */
3277
+ const map = getAnimationMap(element);
3278
+ const key = animationMapKey(valueName, valueOptions.pseudoElement || "");
3279
+ const currentAnimation = map.get(key);
3280
+ currentAnimation && currentAnimation.stop();
3281
+ animationDefinitions.push({
3282
+ map,
3283
+ key,
3284
+ unresolvedKeyframes: valueKeyframes,
3285
+ options: {
3286
+ ...valueOptions,
3287
+ element,
3288
+ name: valueName,
3289
+ allowFlatten: !elementTransition.type && !elementTransition.ease,
3290
+ },
3291
+ });
3292
+ }
3293
+ }
3294
+ /**
3295
+ * Step 2: Resolve keyframes (read)
3296
+ */
3297
+ for (let i = 0; i < animationDefinitions.length; i++) {
3298
+ const { unresolvedKeyframes, options: animationOptions } = animationDefinitions[i];
3299
+ const { element, name, pseudoElement } = animationOptions;
3300
+ if (!pseudoElement && unresolvedKeyframes[0] === null) {
3301
+ unresolvedKeyframes[0] = getComputedStyle$1(element, name);
3302
+ }
3303
+ fillWildcards(unresolvedKeyframes);
3304
+ applyPxDefaults(unresolvedKeyframes, name);
3305
+ /**
3306
+ * If we only have one keyframe, explicitly read the initial keyframe
3307
+ * from the computed style. This is to ensure consistency with WAAPI behaviour
3308
+ * for restarting animations, for instance .play() after finish, when it
3309
+ * has one vs two keyframes.
3310
+ */
3311
+ if (!pseudoElement && unresolvedKeyframes.length < 2) {
3312
+ unresolvedKeyframes.unshift(getComputedStyle$1(element, name));
3313
+ }
3314
+ animationOptions.keyframes = unresolvedKeyframes;
3315
+ }
3316
+ /**
3317
+ * Step 3: Create new animations (write)
3318
+ */
3319
+ const animations = [];
3320
+ for (let i = 0; i < animationDefinitions.length; i++) {
3321
+ const { map, key, options: animationOptions } = animationDefinitions[i];
3322
+ const animation = new NativeAnimation(animationOptions);
3323
+ map.set(key, animation);
3324
+ animation.finished.finally(() => map.delete(key));
3325
+ animations.push(animation);
3326
+ }
3327
+ return animations;
3328
+ }
3329
+
3330
+ const createScopedWaapiAnimate = (scope) => {
3331
+ function scopedAnimate(elementOrSelector, keyframes, options) {
3332
+ return new GroupAnimationWithThen(animateElements(elementOrSelector, keyframes, options, scope));
3333
+ }
3334
+ return scopedAnimate;
3335
+ };
3336
+ const animateMini = /*@__PURE__*/ createScopedWaapiAnimate();
3337
+
3338
+ function useAnimateMini() {
3339
+ const scope = useConstant(() => ({
3340
+ current: null, // Will be hydrated by React
3341
+ animations: [],
3342
+ }));
3343
+ const animate = useConstant(() => createScopedWaapiAnimate(scope));
3344
+ useUnmountEffect(() => {
3345
+ scope.animations.forEach((animation) => animation.stop());
3346
+ });
3347
+ return [scope, animate];
3348
+ }
3349
+
3350
+ /**
3351
+ * Creates `LegacyAnimationControls`, which can be used to manually start, stop
3352
+ * and sequence animations on one or more components.
3353
+ *
3354
+ * The returned `LegacyAnimationControls` should be passed to the `animate` property
3355
+ * of the components you want to animate.
3356
+ *
3357
+ * These components can then be animated with the `start` method.
3358
+ *
3359
+ * ```jsx
3360
+ * import * as React from 'react'
3361
+ * import { motion, useAnimation } from 'framer-motion'
3362
+ *
3363
+ * export function MyComponent(props) {
3364
+ * const controls = useAnimation()
3365
+ *
3366
+ * controls.start({
3367
+ * x: 100,
3368
+ * transition: { duration: 0.5 },
3369
+ * })
3370
+ *
3371
+ * return <motion.div animate={controls} />
3372
+ * }
3373
+ * ```
3374
+ *
3375
+ * @returns Animation controller with `start` and `stop` methods
3376
+ *
3377
+ * @public
3378
+ */
3379
+ function useAnimationControls() {
3380
+ const controls = useConstant(animationControls);
3381
+ useIsomorphicLayoutEffect(controls.mount, []);
3382
+ return controls;
3383
+ }
3384
+ const useAnimation = useAnimationControls;
3385
+
3386
+ function usePresenceData() {
3387
+ const context = useContext(PresenceContext);
3388
+ return context ? context.custom : undefined;
3389
+ }
3390
+
3391
+ /**
3392
+ * Attaches an event listener directly to the provided DOM element.
3393
+ *
3394
+ * Bypassing React's event system can be desirable, for instance when attaching non-passive
3395
+ * event handlers.
3396
+ *
3397
+ * ```jsx
3398
+ * const ref = useRef(null)
3399
+ *
3400
+ * useDomEvent(ref, 'wheel', onWheel, { passive: false })
3401
+ *
3402
+ * return <div ref={ref} />
3403
+ * ```
3404
+ *
3405
+ * @param ref - React.RefObject that's been provided to the element you want to bind the listener to.
3406
+ * @param eventName - Name of the event you want listen for.
3407
+ * @param handler - Function to fire when receiving the event.
3408
+ * @param options - Options to pass to `Event.addEventListener`.
3409
+ *
3410
+ * @public
3411
+ */
3412
+ function useDomEvent(ref, eventName, handler, options) {
3413
+ useEffect(() => {
3414
+ const element = ref.current;
3415
+ if (handler && element) {
3416
+ return addDomEvent(element, eventName, handler, options);
3417
+ }
3418
+ }, [ref, eventName, handler, options]);
3419
+ }
3420
+
3421
+ /**
3422
+ * Can manually trigger a drag gesture on one or more `drag`-enabled `motion` components.
3423
+ *
3424
+ * ```jsx
3425
+ * const dragControls = useDragControls()
3426
+ *
3427
+ * function startDrag(event) {
3428
+ * dragControls.start(event, { snapToCursor: true })
3429
+ * }
3430
+ *
3431
+ * return (
3432
+ * <>
3433
+ * <div onPointerDown={startDrag} />
3434
+ * <motion.div drag="x" dragControls={dragControls} />
3435
+ * </>
3436
+ * )
3437
+ * ```
3438
+ *
3439
+ * @public
3440
+ */
3441
+ class DragControls {
3442
+ constructor() {
3443
+ this.componentControls = new Set();
3444
+ }
3445
+ /**
3446
+ * Subscribe a component's internal `VisualElementDragControls` to the user-facing API.
3447
+ *
3448
+ * @internal
3449
+ */
3450
+ subscribe(controls) {
3451
+ this.componentControls.add(controls);
3452
+ return () => this.componentControls.delete(controls);
3453
+ }
3454
+ /**
3455
+ * Start a drag gesture on every `motion` component that has this set of drag controls
3456
+ * passed into it via the `dragControls` prop.
3457
+ *
3458
+ * ```jsx
3459
+ * dragControls.start(e, {
3460
+ * snapToCursor: true
3461
+ * })
3462
+ * ```
3463
+ *
3464
+ * @param event - PointerEvent
3465
+ * @param options - Options
3466
+ *
3467
+ * @public
3468
+ */
3469
+ start(event, options) {
3470
+ this.componentControls.forEach((controls) => {
3471
+ controls.start(event.nativeEvent || event, options);
3472
+ });
3473
+ }
3474
+ /**
3475
+ * Cancels a drag gesture.
3476
+ *
3477
+ * ```jsx
3478
+ * dragControls.cancel()
3479
+ * ```
3480
+ *
3481
+ * @public
3482
+ */
3483
+ cancel() {
3484
+ this.componentControls.forEach((controls) => {
3485
+ controls.cancel();
3486
+ });
3487
+ }
3488
+ /**
3489
+ * Stops a drag gesture.
3490
+ *
3491
+ * ```jsx
3492
+ * dragControls.stop()
3493
+ * ```
3494
+ *
3495
+ * @public
3496
+ */
3497
+ stop() {
3498
+ this.componentControls.forEach((controls) => {
3499
+ controls.stop();
3500
+ });
3501
+ }
3502
+ }
3503
+ const createDragControls = () => new DragControls();
3504
+ /**
3505
+ * Usually, dragging is initiated by pressing down on a `motion` component with a `drag` prop
3506
+ * and moving it. For some use-cases, for instance clicking at an arbitrary point on a video scrubber, we
3507
+ * might want to initiate that dragging from a different component than the draggable one.
3508
+ *
3509
+ * By creating a `dragControls` using the `useDragControls` hook, we can pass this into
3510
+ * the draggable component's `dragControls` prop. It exposes a `start` method
3511
+ * that can start dragging from pointer events on other components.
3512
+ *
3513
+ * ```jsx
3514
+ * const dragControls = useDragControls()
3515
+ *
3516
+ * function startDrag(event) {
3517
+ * dragControls.start(event, { snapToCursor: true })
3518
+ * }
3519
+ *
3520
+ * return (
3521
+ * <>
3522
+ * <div onPointerDown={startDrag} />
3523
+ * <motion.div drag="x" dragControls={dragControls} />
3524
+ * </>
3525
+ * )
3526
+ * ```
3527
+ *
3528
+ * @public
3529
+ */
3530
+ function useDragControls() {
3531
+ return useConstant(createDragControls);
3532
+ }
3533
+
3534
+ /**
3535
+ * Checks if a component is a `motion` component.
3536
+ */
3537
+ function isMotionComponent(component) {
3538
+ return (component !== null &&
3539
+ typeof component === "object" &&
3540
+ motionComponentSymbol in component);
3541
+ }
3542
+
3543
+ /**
3544
+ * Unwraps a `motion` component and returns either a string for `motion.div` or
3545
+ * the React component for `motion(Component)`.
3546
+ *
3547
+ * If the component is not a `motion` component it returns undefined.
3548
+ */
3549
+ function unwrapMotionComponent(component) {
3550
+ if (isMotionComponent(component)) {
3551
+ return component[motionComponentSymbol];
3552
+ }
3553
+ return undefined;
3554
+ }
3555
+
3556
+ function useInstantLayoutTransition() {
3557
+ return startTransition;
3558
+ }
3559
+ function startTransition(callback) {
3560
+ if (!rootProjectionNode.current)
3561
+ return;
3562
+ rootProjectionNode.current.isUpdating = false;
3563
+ rootProjectionNode.current.blockUpdate();
3564
+ callback && callback();
3565
+ }
3566
+
3567
+ function useResetProjection() {
3568
+ const reset = useCallback(() => {
3569
+ const root = rootProjectionNode.current;
3570
+ if (!root)
3571
+ return;
3572
+ root.resetTree();
3573
+ }, []);
3574
+ return reset;
3575
+ }
3576
+
3577
+ /**
3578
+ * Cycles through a series of visual properties. Can be used to toggle between or cycle through animations. It works similar to `useState` in React. It is provided an initial array of possible states, and returns an array of two arguments.
3579
+ *
3580
+ * An index value can be passed to the returned `cycle` function to cycle to a specific index.
3581
+ *
3582
+ * ```jsx
3583
+ * import * as React from "react"
3584
+ * import { motion, useCycle } from "framer-motion"
3585
+ *
3586
+ * export const MyComponent = () => {
3587
+ * const [x, cycleX] = useCycle(0, 50, 100)
3588
+ *
3589
+ * return (
3590
+ * <motion.div
3591
+ * animate={{ x: x }}
3592
+ * onTap={() => cycleX()}
3593
+ * />
3594
+ * )
3595
+ * }
3596
+ * ```
3597
+ *
3598
+ * @param items - items to cycle through
3599
+ * @returns [currentState, cycleState]
3600
+ *
3601
+ * @public
3602
+ */
3603
+ function useCycle(...items) {
3604
+ const index = useRef(0);
3605
+ const [item, setItem] = useState(items[index.current]);
3606
+ const runCycle = useCallback((next) => {
3607
+ index.current =
3608
+ typeof next !== "number"
3609
+ ? wrap(0, items.length, index.current + 1)
3610
+ : next;
3611
+ setItem(items[index.current]);
3612
+ },
3613
+ // The array will change on each call, but by putting items.length at
3614
+ // the front of this array, we guarantee the dependency comparison will match up
3615
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3616
+ [items.length, ...items]);
3617
+ return [item, runCycle];
3618
+ }
3619
+
3620
+ const thresholds = {
3621
+ some: 0,
3622
+ all: 1,
3623
+ };
3624
+ function inView(elementOrSelector, onStart, { root, margin: rootMargin, amount = "some" } = {}) {
3625
+ const elements = resolveElements(elementOrSelector);
3626
+ const activeIntersections = new WeakMap();
3627
+ const onIntersectionChange = (entries) => {
3628
+ entries.forEach((entry) => {
3629
+ const onEnd = activeIntersections.get(entry.target);
3630
+ /**
3631
+ * If there's no change to the intersection, we don't need to
3632
+ * do anything here.
3633
+ */
3634
+ if (entry.isIntersecting === Boolean(onEnd))
3635
+ return;
3636
+ if (entry.isIntersecting) {
3637
+ const newOnEnd = onStart(entry.target, entry);
3638
+ if (typeof newOnEnd === "function") {
3639
+ activeIntersections.set(entry.target, newOnEnd);
3640
+ }
3641
+ else {
3642
+ observer.unobserve(entry.target);
3643
+ }
3644
+ }
3645
+ else if (typeof onEnd === "function") {
3646
+ onEnd(entry);
3647
+ activeIntersections.delete(entry.target);
3648
+ }
3649
+ });
3650
+ };
3651
+ const observer = new IntersectionObserver(onIntersectionChange, {
3652
+ root,
3653
+ rootMargin,
3654
+ threshold: typeof amount === "number" ? amount : thresholds[amount],
3655
+ });
3656
+ elements.forEach((element) => observer.observe(element));
3657
+ return () => observer.disconnect();
3658
+ }
3659
+
3660
+ function useInView(ref, { root, margin, amount, once = false, initial = false, } = {}) {
3661
+ const [isInView, setInView] = useState(initial);
3662
+ useEffect(() => {
3663
+ if (!ref.current || (once && isInView))
3664
+ return;
3665
+ const onEnter = () => {
3666
+ setInView(true);
3667
+ return once ? undefined : () => setInView(false);
3668
+ };
3669
+ const options = {
3670
+ root: (root && root.current) || undefined,
3671
+ margin,
3672
+ amount,
3673
+ };
3674
+ return inView(ref.current, onEnter, options);
3675
+ }, [root, ref, margin, once, amount]);
3676
+ return isInView;
3677
+ }
3678
+
3679
+ function useInstantTransition() {
3680
+ const [forceUpdate, forcedRenderCount] = useForceUpdate();
3681
+ const startInstantLayoutTransition = useInstantLayoutTransition();
3682
+ const unlockOnFrameRef = useRef(-1);
3683
+ useEffect(() => {
3684
+ /**
3685
+ * Unblock after two animation frames, otherwise this will unblock too soon.
3686
+ */
3687
+ frame.postRender(() => frame.postRender(() => {
3688
+ /**
3689
+ * If the callback has been called again after the effect
3690
+ * triggered this 2 frame delay, don't unblock animations. This
3691
+ * prevents the previous effect from unblocking the current
3692
+ * instant transition too soon. This becomes more likely when
3693
+ * used in conjunction with React.startTransition().
3694
+ */
3695
+ if (forcedRenderCount !== unlockOnFrameRef.current)
3696
+ return;
3697
+ MotionGlobalConfig.instantAnimations = false;
3698
+ }));
3699
+ }, [forcedRenderCount]);
3700
+ return (callback) => {
3701
+ startInstantLayoutTransition(() => {
3702
+ MotionGlobalConfig.instantAnimations = true;
3703
+ forceUpdate();
3704
+ callback();
3705
+ unlockOnFrameRef.current = forcedRenderCount + 1;
3706
+ });
3707
+ };
3708
+ }
3709
+ function disableInstantTransitions() {
3710
+ MotionGlobalConfig.instantAnimations = false;
3711
+ }
3712
+
3713
+ function usePageInView() {
3714
+ const [isInView, setIsInView] = useState(true);
3715
+ useEffect(() => {
3716
+ const handleVisibilityChange = () => setIsInView(!document.hidden);
3717
+ if (document.hidden) {
3718
+ handleVisibilityChange();
3719
+ }
3720
+ document.addEventListener("visibilitychange", handleVisibilityChange);
3721
+ return () => {
3722
+ document.removeEventListener("visibilitychange", handleVisibilityChange);
3723
+ };
3724
+ }, []);
3725
+ return isInView;
3726
+ }
3727
+
3728
+ /**
3729
+ * Creates a `transformPagePoint` function that accounts for SVG viewBox scaling.
3730
+ *
3731
+ * When dragging SVG elements inside an SVG with a viewBox that differs from
3732
+ * the rendered dimensions (e.g., `viewBox="0 0 100 100"` but rendered at 500x500 pixels),
3733
+ * pointer coordinates need to be transformed to match the SVG's coordinate system.
3734
+ *
3735
+ * @example
3736
+ * ```jsx
3737
+ * function App() {
3738
+ * const svgRef = useRef<SVGSVGElement>(null)
3739
+ *
3740
+ * return (
3741
+ * <MotionConfig transformPagePoint={transformViewBoxPoint(svgRef)}>
3742
+ * <svg ref={svgRef} viewBox="0 0 100 100" width={500} height={500}>
3743
+ * <motion.rect drag width={10} height={10} />
3744
+ * </svg>
3745
+ * </MotionConfig>
3746
+ * )
3747
+ * }
3748
+ * ```
3749
+ *
3750
+ * @param svgRef - A React ref to the SVG element
3751
+ * @returns A transformPagePoint function for use with MotionConfig
3752
+ *
3753
+ * @public
3754
+ */
3755
+ function transformViewBoxPoint(svgRef) {
3756
+ return (point) => {
3757
+ const svg = svgRef.current;
3758
+ if (!svg) {
3759
+ return point;
3760
+ }
3761
+ // Get the viewBox attribute
3762
+ const viewBox = svg.viewBox?.baseVal;
3763
+ if (!viewBox || (viewBox.width === 0 && viewBox.height === 0)) {
3764
+ // No viewBox or empty viewBox - no transformation needed
3765
+ return point;
3766
+ }
3767
+ // Get the rendered dimensions of the SVG
3768
+ const bbox = svg.getBoundingClientRect();
3769
+ if (bbox.width === 0 || bbox.height === 0) {
3770
+ return point;
3771
+ }
3772
+ // Calculate scale factors
3773
+ const scaleX = viewBox.width / bbox.width;
3774
+ const scaleY = viewBox.height / bbox.height;
3775
+ // Get the SVG's position on the page
3776
+ const svgX = bbox.left + window.scrollX;
3777
+ const svgY = bbox.top + window.scrollY;
3778
+ // Transform the point:
3779
+ // 1. Calculate position relative to SVG
3780
+ // 2. Scale by viewBox/viewport ratio
3781
+ // 3. Add back the SVG position (but in SVG coordinates)
3782
+ return {
3783
+ x: (point.x - svgX) * scaleX + svgX,
3784
+ y: (point.y - svgY) * scaleY + svgY,
3785
+ };
3786
+ };
3787
+ }
3788
+
3789
+ /**
3790
+ * Creates a `transformPagePoint` function that corrects pointer coordinates
3791
+ * for a parent container with CSS transforms (rotation, scale, skew).
3792
+ *
3793
+ * When dragging elements inside a transformed parent, pointer coordinates
3794
+ * need to be transformed through the inverse of the parent's transform
3795
+ * so the drag offset is in local space.
3796
+ *
3797
+ * Works with both static and continuously animating transforms.
3798
+ *
3799
+ * @example
3800
+ * ```jsx
3801
+ * function App() {
3802
+ * const ref = useRef(null)
3803
+ *
3804
+ * return (
3805
+ * <motion.div ref={ref} style={{ rotate: 90 }}>
3806
+ * <MotionConfig transformPagePoint={correctParentTransform(ref)}>
3807
+ * <motion.div drag />
3808
+ * </MotionConfig>
3809
+ * </motion.div>
3810
+ * )
3811
+ * }
3812
+ * ```
3813
+ *
3814
+ * @param parentRef - A React ref to the transformed parent element
3815
+ * @returns A transformPagePoint function for use with MotionConfig
3816
+ *
3817
+ * @public
3818
+ */
3819
+ function correctParentTransform(parentRef) {
3820
+ return (point) => {
3821
+ const parent = parentRef.current;
3822
+ if (!parent)
3823
+ return point;
3824
+ const inv = getInverseMatrix(parent);
3825
+ if (!inv)
3826
+ return point;
3827
+ // Get center of rotation in page space
3828
+ const rect = parent.getBoundingClientRect();
3829
+ const cx = rect.left + window.scrollX + rect.width / 2;
3830
+ const cy = rect.top + window.scrollY + rect.height / 2;
3831
+ // Transform (point - center) through inverse, then add center back
3832
+ const dx = point.x - cx;
3833
+ const dy = point.y - cy;
3834
+ return {
3835
+ x: cx + inv.a * dx + inv.c * dy,
3836
+ y: cy + inv.b * dx + inv.d * dy,
3837
+ };
3838
+ };
3839
+ }
3840
+ function getInverseMatrix(element) {
3841
+ const { transform } = getComputedStyle(element);
3842
+ if (!transform || transform === "none")
3843
+ return null;
3844
+ const match = transform.match(/^matrix3d\((.*)\)$/u) ||
3845
+ transform.match(/^matrix\((.*)\)$/u);
3846
+ if (!match)
3847
+ return null;
3848
+ const v = match[1].split(",").map(Number);
3849
+ const is3d = transform.startsWith("matrix3d");
3850
+ const a = v[0], b = v[1];
3851
+ const c = is3d ? v[4] : v[2];
3852
+ const d = is3d ? v[5] : v[3];
3853
+ const det = a * d - b * c;
3854
+ if (Math.abs(det) < 1e-10)
3855
+ return null;
3856
+ return { a: d / det, b: -b / det, c: -c / det, d: a / det };
3857
+ }
3858
+
3859
+ const appearAnimationStore = new Map();
3860
+ const appearComplete = new Map();
3861
+
3862
+ const appearStoreId = (elementId, valueName) => {
3863
+ const key = transformProps.has(valueName) ? "transform" : valueName;
3864
+ return `${elementId}: ${key}`;
3865
+ };
3866
+
3867
+ function handoffOptimizedAppearAnimation(elementId, valueName, frame) {
3868
+ const storeId = appearStoreId(elementId, valueName);
3869
+ const optimisedAnimation = appearAnimationStore.get(storeId);
3870
+ if (!optimisedAnimation) {
3871
+ return null;
3872
+ }
3873
+ const { animation, startTime } = optimisedAnimation;
3874
+ function cancelAnimation() {
3875
+ window.MotionCancelOptimisedAnimation?.(elementId, valueName, frame);
3876
+ }
3877
+ /**
3878
+ * We can cancel the animation once it's finished now that we've synced
3879
+ * with Motion.
3880
+ *
3881
+ * Prefer onfinish over finished as onfinish is backwards compatible with
3882
+ * older browsers.
3883
+ */
3884
+ animation.onfinish = cancelAnimation;
3885
+ if (startTime === null || window.MotionHandoffIsComplete?.(elementId)) {
3886
+ /**
3887
+ * If the startTime is null, this animation is the Paint Ready detection animation
3888
+ * and we can cancel it immediately without handoff.
3889
+ *
3890
+ * Or if we've already handed off the animation then we're now interrupting it.
3891
+ * In which case we need to cancel it.
3892
+ */
3893
+ cancelAnimation();
3894
+ return null;
3895
+ }
3896
+ else {
3897
+ return startTime;
3898
+ }
3899
+ }
3900
+
3901
+ /**
3902
+ * A single time to use across all animations to manually set startTime
3903
+ * and ensure they're all in sync.
3904
+ */
3905
+ let startFrameTime;
3906
+ /**
3907
+ * A dummy animation to detect when Chrome is ready to start
3908
+ * painting the page and hold off from triggering the real animation
3909
+ * until then. We only need one animation to detect paint ready.
3910
+ *
3911
+ * https://bugs.chromium.org/p/chromium/issues/detail?id=1406850
3912
+ */
3913
+ let readyAnimation;
3914
+ /**
3915
+ * Keep track of animations that were suspended vs cancelled so we
3916
+ * can easily resume them when we're done measuring layout.
3917
+ */
3918
+ const suspendedAnimations = new Set();
3919
+ function resumeSuspendedAnimations() {
3920
+ suspendedAnimations.forEach((data) => {
3921
+ data.animation.play();
3922
+ data.animation.startTime = data.startTime;
3923
+ });
3924
+ suspendedAnimations.clear();
3925
+ }
3926
+ function startOptimizedAppearAnimation(element, name, keyframes, options, onReady) {
3927
+ // Prevent optimised appear animations if Motion has already started animating.
3928
+ if (window.MotionIsMounted) {
3929
+ return;
3930
+ }
3931
+ const id = element.dataset[optimizedAppearDataId];
3932
+ if (!id)
3933
+ return;
3934
+ window.MotionHandoffAnimation = handoffOptimizedAppearAnimation;
3935
+ const storeId = appearStoreId(id, name);
3936
+ if (!readyAnimation) {
3937
+ readyAnimation = startWaapiAnimation(element, name, [keyframes[0], keyframes[0]],
3938
+ /**
3939
+ * 10 secs is basically just a super-safe duration to give Chrome
3940
+ * long enough to get the animation ready.
3941
+ */
3942
+ { duration: 10000, ease: "linear" });
3943
+ appearAnimationStore.set(storeId, {
3944
+ animation: readyAnimation,
3945
+ startTime: null,
3946
+ });
3947
+ /**
3948
+ * If there's no readyAnimation then there's been no instantiation
3949
+ * of handoff animations.
3950
+ */
3951
+ window.MotionHandoffAnimation = handoffOptimizedAppearAnimation;
3952
+ window.MotionHasOptimisedAnimation = (elementId, valueName) => {
3953
+ if (!elementId)
3954
+ return false;
3955
+ /**
3956
+ * Keep a map of elementIds that have started animating. We check
3957
+ * via ID instead of Element because of hydration errors and
3958
+ * pre-hydration checks. We also actively record IDs as they start
3959
+ * animating rather than simply checking for data-appear-id as
3960
+ * this attrbute might be present but not lead to an animation, for
3961
+ * instance if the element's appear animation is on a different
3962
+ * breakpoint.
3963
+ */
3964
+ if (!valueName) {
3965
+ return appearComplete.has(elementId);
3966
+ }
3967
+ const animationId = appearStoreId(elementId, valueName);
3968
+ return Boolean(appearAnimationStore.get(animationId));
3969
+ };
3970
+ window.MotionHandoffMarkAsComplete = (elementId) => {
3971
+ if (appearComplete.has(elementId)) {
3972
+ appearComplete.set(elementId, true);
3973
+ }
3974
+ };
3975
+ window.MotionHandoffIsComplete = (elementId) => {
3976
+ return appearComplete.get(elementId) === true;
3977
+ };
3978
+ /**
3979
+ * We only need to cancel transform animations as
3980
+ * they're the ones that will interfere with the
3981
+ * layout animation measurements.
3982
+ */
3983
+ window.MotionCancelOptimisedAnimation = (elementId, valueName, frame, canResume) => {
3984
+ const animationId = appearStoreId(elementId, valueName);
3985
+ const data = appearAnimationStore.get(animationId);
3986
+ if (!data)
3987
+ return;
3988
+ if (frame && canResume === undefined) {
3989
+ /**
3990
+ * Wait until the end of the subsequent frame to cancel the animation
3991
+ * to ensure we don't remove the animation before the main thread has
3992
+ * had a chance to resolve keyframes and render.
3993
+ */
3994
+ frame.postRender(() => {
3995
+ frame.postRender(() => {
3996
+ data.animation.cancel();
3997
+ });
3998
+ });
3999
+ }
4000
+ else {
4001
+ data.animation.cancel();
4002
+ }
4003
+ if (frame && canResume) {
4004
+ suspendedAnimations.add(data);
4005
+ frame.render(resumeSuspendedAnimations);
4006
+ }
4007
+ else {
4008
+ appearAnimationStore.delete(animationId);
4009
+ /**
4010
+ * If there are no more animations left, we can remove the cancel function.
4011
+ * This will let us know when we can stop checking for conflicting layout animations.
4012
+ */
4013
+ if (!appearAnimationStore.size) {
4014
+ window.MotionCancelOptimisedAnimation = undefined;
4015
+ }
4016
+ }
4017
+ };
4018
+ window.MotionCheckAppearSync = (visualElement, valueName, value) => {
4019
+ const appearId = getOptimisedAppearId(visualElement);
4020
+ if (!appearId)
4021
+ return;
4022
+ const valueIsOptimised = window.MotionHasOptimisedAnimation?.(appearId, valueName);
4023
+ const externalAnimationValue = visualElement.props.values?.[valueName];
4024
+ if (!valueIsOptimised || !externalAnimationValue)
4025
+ return;
4026
+ const removeSyncCheck = value.on("change", (latestValue) => {
4027
+ if (externalAnimationValue.get() !== latestValue) {
4028
+ window.MotionCancelOptimisedAnimation?.(appearId, valueName);
4029
+ removeSyncCheck();
4030
+ }
4031
+ });
4032
+ return removeSyncCheck;
4033
+ };
4034
+ }
4035
+ const startAnimation = () => {
4036
+ readyAnimation.cancel();
4037
+ const appearAnimation = startWaapiAnimation(element, name, keyframes, options);
4038
+ /**
4039
+ * Record the time of the first started animation. We call performance.now() once
4040
+ * here and once in handoff to ensure we're getting
4041
+ * close to a frame-locked time. This keeps all animations in sync.
4042
+ */
4043
+ if (startFrameTime === undefined) {
4044
+ startFrameTime = performance.now();
4045
+ }
4046
+ appearAnimation.startTime = startFrameTime;
4047
+ appearAnimationStore.set(storeId, {
4048
+ animation: appearAnimation,
4049
+ startTime: startFrameTime,
4050
+ });
4051
+ if (onReady)
4052
+ onReady(appearAnimation);
4053
+ };
4054
+ appearComplete.set(id, false);
4055
+ if (readyAnimation.ready) {
4056
+ readyAnimation.ready.then(startAnimation).catch(noop$1);
4057
+ }
4058
+ else {
4059
+ startAnimation();
4060
+ }
4061
+ }
4062
+
4063
+ const createObject = () => ({});
4064
+ class StateVisualElement extends VisualElement {
4065
+ constructor() {
4066
+ super(...arguments);
4067
+ this.measureInstanceViewportBox = createBox;
4068
+ }
4069
+ build() { }
4070
+ resetTransform() { }
4071
+ restoreTransform() { }
4072
+ removeValueFromRenderState() { }
4073
+ renderInstance() { }
4074
+ scrapeMotionValuesFromProps() {
4075
+ return createObject();
4076
+ }
4077
+ getBaseTargetFromProps() {
4078
+ return undefined;
4079
+ }
4080
+ readValueFromInstance(_state, key, options) {
4081
+ return options.initialState[key] || 0;
4082
+ }
4083
+ sortInstanceNodePosition() {
4084
+ return 0;
4085
+ }
4086
+ }
4087
+ const useVisualState = makeUseVisualState({
4088
+ scrapeMotionValuesFromProps: createObject,
4089
+ createRenderState: createObject,
4090
+ });
4091
+ /**
4092
+ * This is not an officially supported API and may be removed
4093
+ * on any version.
4094
+ */
4095
+ function useAnimatedState(initialState) {
4096
+ const [animationState, setAnimationState] = useState(initialState);
4097
+ const visualState = useVisualState({}, false);
4098
+ const element = useConstant(() => {
4099
+ return new StateVisualElement({
4100
+ props: {
4101
+ onUpdate: (v) => {
4102
+ setAnimationState({ ...v });
4103
+ },
4104
+ },
4105
+ visualState,
4106
+ presenceContext: null,
4107
+ }, { initialState });
4108
+ });
4109
+ useLayoutEffect(() => {
4110
+ element.mount({});
4111
+ return () => element.unmount();
4112
+ }, [element]);
4113
+ const startAnimation = useConstant(() => (animationDefinition) => {
4114
+ return animateVisualElement(element, animationDefinition);
4115
+ });
4116
+ return [animationState, startAnimation];
4117
+ }
4118
+
4119
+ let id = 0;
4120
+ const AnimateSharedLayout = ({ children }) => {
4121
+ React.useEffect(() => {
4122
+ invariant(false, "AnimateSharedLayout is deprecated: https://www.framer.com/docs/guide-upgrade/##shared-layout-animations");
4123
+ }, []);
4124
+ return (jsx(LayoutGroup, { id: useConstant(() => `asl-${id++}`), children: children }));
4125
+ };
4126
+
4127
+ // Keep things reasonable and avoid scale: Infinity. In practise we might need
4128
+ // to add another value, opacity, that could interpolate scaleX/Y [0,0.01] => [0,1]
4129
+ // to simply hide content at unreasonable scales.
4130
+ const maxScale = 100000;
4131
+ const invertScale = (scale) => scale > 0.001 ? 1 / scale : maxScale;
4132
+ let hasWarned = false;
4133
+ /**
4134
+ * Returns a `MotionValue` each for `scaleX` and `scaleY` that update with the inverse
4135
+ * of their respective parent scales.
4136
+ *
4137
+ * This is useful for undoing the distortion of content when scaling a parent component.
4138
+ *
4139
+ * By default, `useInvertedScale` will automatically fetch `scaleX` and `scaleY` from the nearest parent.
4140
+ * By passing other `MotionValue`s in as `useInvertedScale({ scaleX, scaleY })`, it will invert the output
4141
+ * of those instead.
4142
+ *
4143
+ * ```jsx
4144
+ * const MyComponent = () => {
4145
+ * const { scaleX, scaleY } = useInvertedScale()
4146
+ * return <motion.div style={{ scaleX, scaleY }} />
4147
+ * }
4148
+ * ```
4149
+ *
4150
+ * @deprecated
4151
+ */
4152
+ function useInvertedScale(scale) {
4153
+ let parentScaleX = useMotionValue(1);
4154
+ let parentScaleY = useMotionValue(1);
4155
+ const { visualElement } = useContext(MotionContext);
4156
+ invariant(!!(scale || visualElement), "If no scale values are provided, useInvertedScale must be used within a child of another motion component.");
4157
+ warning(hasWarned, "useInvertedScale is deprecated and will be removed in 3.0. Use the layout prop instead.");
4158
+ hasWarned = true;
4159
+ if (scale) {
4160
+ parentScaleX = scale.scaleX || parentScaleX;
4161
+ parentScaleY = scale.scaleY || parentScaleY;
4162
+ }
4163
+ else if (visualElement) {
4164
+ parentScaleX = visualElement.getValue("scaleX", 1);
4165
+ parentScaleY = visualElement.getValue("scaleY", 1);
4166
+ }
4167
+ const scaleX = useTransform(parentScaleX, invertScale);
4168
+ const scaleY = useTransform(parentScaleY, invertScale);
4169
+ return { scaleX, scaleY };
4170
+ }
4171
+
4172
+ const ReorderContext = createContext(null);
4173
+
4174
+ function checkReorder(order, value, offset, velocity) {
4175
+ if (!velocity)
4176
+ return order;
4177
+ const index = order.findIndex((item) => item.value === value);
4178
+ if (index === -1)
4179
+ return order;
4180
+ const nextOffset = velocity > 0 ? 1 : -1;
4181
+ const nextItem = order[index + nextOffset];
4182
+ if (!nextItem)
4183
+ return order;
4184
+ const item = order[index];
4185
+ const nextLayout = nextItem.layout;
4186
+ const nextItemCenter = mixNumber(nextLayout.min, nextLayout.max, 0.5);
4187
+ if ((nextOffset === 1 && item.layout.max + offset > nextItemCenter) ||
4188
+ (nextOffset === -1 && item.layout.min + offset < nextItemCenter)) {
4189
+ return moveItem(order, index, index + nextOffset);
4190
+ }
4191
+ return order;
4192
+ }
4193
+
4194
+ function ReorderGroupComponent({ children, as = "ul", axis = "y", onReorder, values, ...props }, externalRef) {
4195
+ const Component = useConstant(() => motion[as]);
4196
+ const order = [];
4197
+ const isReordering = useRef(false);
4198
+ const groupRef = useRef(null);
4199
+ invariant(Boolean(values), "Reorder.Group must be provided a values prop", "reorder-values");
4200
+ const context = {
4201
+ axis,
4202
+ groupRef,
4203
+ registerItem: (value, layout) => {
4204
+ // If the entry was already added, update it rather than adding it again
4205
+ const idx = order.findIndex((entry) => value === entry.value);
4206
+ if (idx !== -1) {
4207
+ order[idx].layout = layout[axis];
4208
+ }
4209
+ else {
4210
+ order.push({ value: value, layout: layout[axis] });
4211
+ }
4212
+ order.sort(compareMin);
4213
+ },
4214
+ updateOrder: (item, offset, velocity) => {
4215
+ if (isReordering.current)
4216
+ return;
4217
+ const newOrder = checkReorder(order, item, offset, velocity);
4218
+ if (order !== newOrder) {
4219
+ isReordering.current = true;
4220
+ // Find which two values swapped and apply that swap
4221
+ // to the full values array. This preserves unmeasured
4222
+ // items (e.g. in virtualized lists).
4223
+ const newValues = [...values];
4224
+ for (let i = 0; i < newOrder.length; i++) {
4225
+ if (order[i].value !== newOrder[i].value) {
4226
+ const a = values.indexOf(order[i].value);
4227
+ const b = values.indexOf(newOrder[i].value);
4228
+ if (a !== -1 && b !== -1) {
4229
+ [newValues[a], newValues[b]] = [newValues[b], newValues[a]];
4230
+ }
4231
+ break;
4232
+ }
4233
+ }
4234
+ onReorder(newValues);
4235
+ }
4236
+ },
4237
+ };
4238
+ useEffect(() => {
4239
+ isReordering.current = false;
4240
+ });
4241
+ // Combine refs if external ref is provided
4242
+ const setRef = (element) => {
4243
+ groupRef.current = element;
4244
+ if (typeof externalRef === "function") {
4245
+ externalRef(element);
4246
+ }
4247
+ else if (externalRef) {
4248
+ externalRef.current = element;
4249
+ }
4250
+ };
4251
+ /**
4252
+ * Disable browser scroll anchoring on the group container.
4253
+ * When items reorder, scroll anchoring can cause the browser to adjust
4254
+ * the scroll position, which interferes with drag position calculations.
4255
+ */
4256
+ const groupStyle = {
4257
+ overflowAnchor: "none",
4258
+ ...props.style,
4259
+ };
4260
+ return (jsx(Component, { ...props, style: groupStyle, ref: setRef, ignoreStrict: true, children: jsx(ReorderContext.Provider, { value: context, children: children }) }));
4261
+ }
4262
+ const ReorderGroup = /*@__PURE__*/ forwardRef(ReorderGroupComponent);
4263
+ function compareMin(a, b) {
4264
+ return a.layout.min - b.layout.min;
4265
+ }
4266
+
4267
+ const threshold = 50;
4268
+ const maxSpeed = 25;
4269
+ const overflowStyles = new Set(["auto", "scroll"]);
4270
+ // Track initial scroll limits per scrollable element (Bug 1 fix)
4271
+ const initialScrollLimits = new WeakMap();
4272
+ const activeScrollEdge = new WeakMap();
4273
+ // Track which group element is currently dragging to clear state on end
4274
+ let currentGroupElement = null;
4275
+ function resetAutoScrollState() {
4276
+ if (currentGroupElement) {
4277
+ const scrollableAncestor = findScrollableAncestor(currentGroupElement, "y");
4278
+ if (scrollableAncestor) {
4279
+ activeScrollEdge.delete(scrollableAncestor);
4280
+ initialScrollLimits.delete(scrollableAncestor);
4281
+ }
4282
+ // Also try x axis
4283
+ const scrollableAncestorX = findScrollableAncestor(currentGroupElement, "x");
4284
+ if (scrollableAncestorX && scrollableAncestorX !== scrollableAncestor) {
4285
+ activeScrollEdge.delete(scrollableAncestorX);
4286
+ initialScrollLimits.delete(scrollableAncestorX);
4287
+ }
4288
+ currentGroupElement = null;
4289
+ }
4290
+ }
4291
+ function isScrollableElement(element, axis) {
4292
+ const style = getComputedStyle(element);
4293
+ const overflow = axis === "x" ? style.overflowX : style.overflowY;
4294
+ const isDocumentScroll = element === document.body ||
4295
+ element === document.documentElement;
4296
+ return overflowStyles.has(overflow) || isDocumentScroll;
4297
+ }
4298
+ function findScrollableAncestor(element, axis) {
4299
+ let current = element?.parentElement;
4300
+ while (current) {
4301
+ if (isScrollableElement(current, axis)) {
4302
+ return current;
4303
+ }
4304
+ current = current.parentElement;
4305
+ }
4306
+ return null;
4307
+ }
4308
+ function getScrollAmount(pointerPosition, scrollElement, axis) {
4309
+ const rect = scrollElement.getBoundingClientRect();
4310
+ const start = axis === "x" ? Math.max(0, rect.left) : Math.max(0, rect.top);
4311
+ const end = axis === "x" ? Math.min(window.innerWidth, rect.right) : Math.min(window.innerHeight, rect.bottom);
4312
+ const distanceFromStart = pointerPosition - start;
4313
+ const distanceFromEnd = end - pointerPosition;
4314
+ if (distanceFromStart < threshold) {
4315
+ const intensity = 1 - distanceFromStart / threshold;
4316
+ return { amount: -maxSpeed * intensity * intensity, edge: "start" };
4317
+ }
4318
+ else if (distanceFromEnd < threshold) {
4319
+ const intensity = 1 - distanceFromEnd / threshold;
4320
+ return { amount: maxSpeed * intensity * intensity, edge: "end" };
4321
+ }
4322
+ return { amount: 0, edge: null };
4323
+ }
4324
+ function autoScrollIfNeeded(groupElement, pointerPosition, axis, velocity) {
4325
+ if (!groupElement)
4326
+ return;
4327
+ // Track the group element for cleanup
4328
+ currentGroupElement = groupElement;
4329
+ const scrollableAncestor = findScrollableAncestor(groupElement, axis);
4330
+ if (!scrollableAncestor)
4331
+ return;
4332
+ // Convert pointer position from page coordinates to viewport coordinates.
4333
+ // The gesture system uses pageX/pageY but getBoundingClientRect() returns
4334
+ // viewport-relative coordinates, so we need to account for page scroll.
4335
+ const viewportPointerPosition = pointerPosition - (axis === "x" ? window.scrollX : window.scrollY);
4336
+ const { amount: scrollAmount, edge } = getScrollAmount(viewportPointerPosition, scrollableAncestor, axis);
4337
+ // If not in any threshold zone, clear all state
4338
+ if (edge === null) {
4339
+ activeScrollEdge.delete(scrollableAncestor);
4340
+ initialScrollLimits.delete(scrollableAncestor);
4341
+ return;
4342
+ }
4343
+ const currentActiveEdge = activeScrollEdge.get(scrollableAncestor);
4344
+ const isDocumentScroll = scrollableAncestor === document.body ||
4345
+ scrollableAncestor === document.documentElement;
4346
+ // If not currently scrolling this edge, check velocity to see if we should start
4347
+ if (currentActiveEdge !== edge) {
4348
+ // Only start scrolling if velocity is towards the edge
4349
+ const shouldStart = (edge === "start" && velocity < 0) ||
4350
+ (edge === "end" && velocity > 0);
4351
+ if (!shouldStart)
4352
+ return;
4353
+ // Activate this edge
4354
+ activeScrollEdge.set(scrollableAncestor, edge);
4355
+ // Record initial scroll limit (prevents infinite scroll)
4356
+ const maxScroll = axis === "x"
4357
+ ? scrollableAncestor.scrollWidth - (isDocumentScroll ? window.innerWidth : scrollableAncestor.clientWidth)
4358
+ : scrollableAncestor.scrollHeight - (isDocumentScroll ? window.innerHeight : scrollableAncestor.clientHeight);
4359
+ initialScrollLimits.set(scrollableAncestor, maxScroll);
4360
+ }
4361
+ // Cap scrolling at initial limit (prevents infinite scroll)
4362
+ if (scrollAmount > 0) {
4363
+ const initialLimit = initialScrollLimits.get(scrollableAncestor);
4364
+ const currentScroll = axis === "x"
4365
+ ? (isDocumentScroll ? window.scrollX : scrollableAncestor.scrollLeft)
4366
+ : (isDocumentScroll ? window.scrollY : scrollableAncestor.scrollTop);
4367
+ if (currentScroll >= initialLimit)
4368
+ return;
4369
+ }
4370
+ // Apply scroll
4371
+ if (axis === "x") {
4372
+ if (isDocumentScroll) {
4373
+ window.scrollBy({ left: scrollAmount });
4374
+ }
4375
+ else {
4376
+ scrollableAncestor.scrollLeft += scrollAmount;
4377
+ }
4378
+ }
4379
+ else {
4380
+ if (isDocumentScroll) {
4381
+ window.scrollBy({ top: scrollAmount });
4382
+ }
4383
+ else {
4384
+ scrollableAncestor.scrollTop += scrollAmount;
4385
+ }
4386
+ }
4387
+ }
4388
+
4389
+ function useDefaultMotionValue(value, defaultValue = 0) {
4390
+ return isMotionValue(value) ? value : useMotionValue(defaultValue);
4391
+ }
4392
+ function ReorderItemComponent({ children, style = {}, value, as = "li", onDrag, onDragEnd, layout = true, ...props }, externalRef) {
4393
+ const Component = useConstant(() => motion[as]);
4394
+ const context = useContext(ReorderContext);
4395
+ const point = {
4396
+ x: useDefaultMotionValue(style.x),
4397
+ y: useDefaultMotionValue(style.y),
4398
+ };
4399
+ const zIndex = useTransform([point.x, point.y], ([latestX, latestY]) => latestX || latestY ? 1 : "unset");
4400
+ invariant(Boolean(context), "Reorder.Item must be a child of Reorder.Group", "reorder-item-child");
4401
+ const { axis, registerItem, updateOrder, groupRef } = context;
4402
+ return (jsx(Component, { drag: axis, ...props, dragSnapToOrigin: true, style: { ...style, x: point.x, y: point.y, zIndex }, layout: layout, onDrag: (event, gesturePoint) => {
4403
+ const { velocity, point: pointerPoint } = gesturePoint;
4404
+ const offset = point[axis].get();
4405
+ // Always attempt to update order - checkReorder handles the logic
4406
+ updateOrder(value, offset, velocity[axis]);
4407
+ autoScrollIfNeeded(groupRef.current, pointerPoint[axis], axis, velocity[axis]);
4408
+ onDrag && onDrag(event, gesturePoint);
4409
+ }, onDragEnd: (event, gesturePoint) => {
4410
+ resetAutoScrollState();
4411
+ onDragEnd && onDragEnd(event, gesturePoint);
4412
+ }, onLayoutMeasure: (measured) => {
4413
+ registerItem(value, measured);
4414
+ }, ref: externalRef, ignoreStrict: true, children: children }));
4415
+ }
4416
+ const ReorderItem = /*@__PURE__*/ forwardRef(ReorderItemComponent);
4417
+
4418
+ const namespace = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
4419
+ __proto__: null,
4420
+ Group: ReorderGroup,
4421
+ Item: ReorderItem
4422
+ }, Symbol.toStringTag, { value: 'Module' }));
4423
+
4424
+ export { AnimateSharedLayout, DragControls, GroupAnimation, GroupAnimationWithThen, HTMLProjectionNode, HTMLVisualElement, JSAnimation, LayoutAnimationBuilder, LayoutGroup, LazyMotion, MotionConfig, MotionConfigContext, MotionContext, MotionGlobalConfig, MotionValue, NativeAnimation, NativeAnimationWrapper, ObjectVisualElement, PresenceContext, namespace as Reorder, SVGVisualElement, ViewTransitionBuilder, VisualElement, WillChangeMotionValue, acceleratedValues, activeAnimations, addAttrValue, addDomEvent, addStyleValue, animate, animateMini, animateSingleValue, animateTarget, animateView, animateVisualElement, animationControls, animationMapKey, animations, applyGeneratorOptions, applyPxDefaults, attachFollow, attachSpring, attrEffect, camelToDash, cancelFrame, cancelSync, clamp, collectMotionValues, copyBoxInto, correctParentTransform, createBox, createGeneratorEasing, createScopedAnimate, defaultOffset$1 as defaultOffset, disableInstantTransitions, domAnimation, domMax, domMin, easingDefinitionToFunction, fillOffset, fillWildcards, followValue, frame, frameData, getAnimationMap, getComputedStyle$1 as getComputedStyle, getEasingForSegment, getOptimisedAppearId, getOriginIndex, getValueAsType, getValueTransition$1 as getValueTransition, getViewAnimationLayerInfo, getViewAnimations, hasReducedMotionListener, inView, initPrefersReducedMotion, interpolate, invariant, isBezierDefinition, isEasingArray, isGenerator, isHTMLElement, isMotionComponent, isMotionValue, isSVGElement, isSVGSVGElement, isWaapiSupportedEasing, m, makeUseVisualState, mapEasingToNativeEasing, mapValue, memo, microtask, mixNumber, motion, motionValue, moveItem, noop$1 as noop, numberValueTypes, observeTimeline, optimizedAppearDataId, parseAnimateLayoutArgs, prefersReducedMotion, progress, propEffect, recordStats, removeItem, resize, resolveElements, resolveTransition, rootProjectionNode, scroll, scrollInfo, secondsToMilliseconds, setTarget, spring, springValue, stagger, startOptimizedAppearAnimation, startWaapiAnimation, statsBuffer, steps, styleEffect, supportedWaapiEasing, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, supportsViewTimeline, svgEffect, sync, transform, transformPropOrder, transformProps, transformValue, transformViewBoxPoint, unwrapMotionComponent, useAnimate, useAnimateMini, useAnimation, useAnimationControls, useAnimationFrame, useCycle, useAnimatedState as useDeprecatedAnimatedState, useInvertedScale as useDeprecatedInvertedScale, useDomEvent, useDragControls, useElementScroll, useFollowValue, useForceUpdate, useInView, useInstantLayoutTransition, useInstantTransition, useIsomorphicLayoutEffect, useMotionTemplate, useMotionValue, useMotionValueEvent, usePageInView, usePresenceData, useReducedMotion, useReducedMotionConfig, useResetProjection, useScroll, useSpring, useTime, useTransform, useUnmountEffect, useVelocity, useViewportScroll, useWillChange, velocityPerSecond, visualElementStore, warnOnce, warning, wrap };
4425
+ //# sourceMappingURL=motion.js.map