@vritti/quantum-ui 0.3.12 → 0.3.15

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 (508) hide show
  1. package/dist/ActivePoints.js.map +1 -1
  2. package/dist/ActiveShapeUtils.js.map +1 -1
  3. package/dist/Alert.js +1 -1
  4. package/dist/Alert.js.map +1 -1
  5. package/dist/AreaChart.js.map +1 -1
  6. package/dist/Avatar.js +1 -1
  7. package/dist/Avatar.js.map +1 -1
  8. package/dist/Badge2.js +2 -2
  9. package/dist/BarChart.js.map +1 -1
  10. package/dist/BillingCycleSelector.js +37 -0
  11. package/dist/BillingCycleSelector.js.map +1 -0
  12. package/dist/Breadcrumb.js +1 -1
  13. package/dist/Breadcrumb.js.map +1 -1
  14. package/dist/Button.js +1 -1
  15. package/dist/Button.js.map +1 -1
  16. package/dist/Button2.js +2 -2
  17. package/dist/CardSkeleton.js.map +1 -1
  18. package/dist/CartesianChart.js.map +1 -1
  19. package/dist/CategoryFilter.js +6 -4
  20. package/dist/CategoryFilter.js.map +1 -1
  21. package/dist/Chart.js +53 -55
  22. package/dist/Chart.js.map +1 -1
  23. package/dist/Checkbox.js.map +1 -1
  24. package/dist/Checkbox2.js +4 -4
  25. package/dist/CheckboxGroup.js.map +1 -1
  26. package/dist/Collapsible.js.map +1 -1
  27. package/dist/Combination.js +1129 -0
  28. package/dist/Combination.js.map +1 -0
  29. package/dist/CompanySelector.js +20 -0
  30. package/dist/CompanySelector.js.map +1 -0
  31. package/dist/ConfirmHost.js.map +1 -1
  32. package/dist/CopyField.js +71 -0
  33. package/dist/CopyField.js.map +1 -0
  34. package/dist/CountrySelector.js +37 -0
  35. package/dist/CountrySelector.js.map +1 -0
  36. package/dist/CurrencyField.js +1 -0
  37. package/dist/CurrencyField.js.map +1 -1
  38. package/dist/CustomerSelector.js +2 -2
  39. package/dist/CustomerSelector.js.map +1 -1
  40. package/dist/DangerZoneSkeleton.js +21 -3
  41. package/dist/DangerZoneSkeleton.js.map +1 -1
  42. package/dist/DatePicker.js +3 -3
  43. package/dist/DatePicker.js.map +1 -1
  44. package/dist/DateTimePicker.js +2 -2
  45. package/dist/DetailSectionSkeleton.js.map +1 -1
  46. package/dist/Dialog.js.map +1 -1
  47. package/dist/DropdownMenu.js.map +1 -1
  48. package/dist/ErrorBarContext.js.map +1 -1
  49. package/dist/FeaturePermissionSelector.js +37 -0
  50. package/dist/FeaturePermissionSelector.js.map +1 -0
  51. package/dist/Form.js.map +1 -1
  52. package/dist/FormSection.js +4 -4
  53. package/dist/FormSection.js.map +1 -1
  54. package/dist/HierarchyGraph.js +5 -10621
  55. package/dist/HierarchyGraph.js.map +1 -1
  56. package/dist/ISOCountrySelect.js +283 -0
  57. package/dist/ISOCountrySelect.js.map +1 -0
  58. package/dist/IconSelect.js +3 -2
  59. package/dist/IconSelect.js.map +1 -1
  60. package/dist/InventoryItemSelector.js +2 -2
  61. package/dist/InventoryItemSelector.js.map +1 -1
  62. package/dist/Kbd.js +1 -1
  63. package/dist/Kbd.js.map +1 -1
  64. package/dist/Label.js +1 -1
  65. package/dist/LayoutModeContext.js.map +1 -1
  66. package/dist/LegalEntitySelector.js +37 -0
  67. package/dist/LegalEntitySelector.js.map +1 -0
  68. package/dist/LineChart.js.map +1 -1
  69. package/dist/LocationSelector.js +2 -2
  70. package/dist/LocationSelector.js.map +1 -1
  71. package/dist/LotSelector.js +2 -2
  72. package/dist/LotSelector.js.map +1 -1
  73. package/dist/OTPField.js.map +1 -1
  74. package/dist/PageContent.js.map +1 -1
  75. package/dist/PageHeaderSkeleton.js +21 -10
  76. package/dist/PageHeaderSkeleton.js.map +1 -1
  77. package/dist/PasswordField.js.map +1 -1
  78. package/dist/PermissionGate.js +49 -5
  79. package/dist/PermissionGate.js.map +1 -1
  80. package/dist/PersonSelector.js +20 -0
  81. package/dist/PersonSelector.js.map +1 -0
  82. package/dist/PhoneField.js.map +1 -1
  83. package/dist/PieChart.js.map +1 -1
  84. package/dist/PolarChart.js.map +1 -1
  85. package/dist/PurchaseOrderSelector.js +2 -2
  86. package/dist/PurchaseOrderSelector.js.map +1 -1
  87. package/dist/QuantSelector.js +2 -2
  88. package/dist/QuantSelector.js.map +1 -1
  89. package/dist/RadarChart.js.map +1 -1
  90. package/dist/RadialChart.js.map +1 -1
  91. package/dist/RadioGroup.js +6 -6
  92. package/dist/RadioGroup.js.map +1 -1
  93. package/dist/RoleSelector.js +20 -0
  94. package/dist/RoleSelector.js.map +1 -0
  95. package/dist/Select.js +4 -1
  96. package/dist/Select.js.map +1 -1
  97. package/dist/SelectFilter.js.map +1 -1
  98. package/dist/Separator.js.map +1 -1
  99. package/dist/SerialSelector.js +2 -2
  100. package/dist/SerialSelector.js.map +1 -1
  101. package/dist/Sidebar.js +2 -2
  102. package/dist/Sidebar.js.map +1 -1
  103. package/dist/SingleSelect.js +2 -2
  104. package/dist/SingleSelect.js.map +1 -1
  105. package/dist/SiteGroupSelector.js +37 -0
  106. package/dist/SiteGroupSelector.js.map +1 -0
  107. package/dist/SiteSelector.js +37 -0
  108. package/dist/SiteSelector.js.map +1 -0
  109. package/dist/Sonner.js +1 -1
  110. package/dist/Sonner.js.map +1 -1
  111. package/dist/Sortable.js +4 -4417
  112. package/dist/Sortable.js.map +1 -1
  113. package/dist/StepProgressIndicator.js.map +1 -1
  114. package/dist/SupplierItemSelector.js +2 -2
  115. package/dist/SupplierItemSelector.js.map +1 -1
  116. package/dist/SupplierSelector.js +2 -2
  117. package/dist/SupplierSelector.js.map +1 -1
  118. package/dist/Switch.js +3 -3
  119. package/dist/Switch.js.map +1 -1
  120. package/dist/TabsSkeleton.js +101 -49
  121. package/dist/TabsSkeleton.js.map +1 -1
  122. package/dist/TaxClassSelector.js +20 -0
  123. package/dist/TaxClassSelector.js.map +1 -0
  124. package/dist/TextField.js.map +1 -1
  125. package/dist/ThemeContext.js.map +1 -1
  126. package/dist/ThemeToggle.js.map +1 -1
  127. package/dist/Toggle.js +1 -1
  128. package/dist/Toggle.js.map +1 -1
  129. package/dist/Tooltip.js.map +1 -1
  130. package/dist/Typography.js.map +1 -1
  131. package/dist/UomSelector.js +2 -2
  132. package/dist/UomSelector.js.map +1 -1
  133. package/dist/UploadFile.js.map +1 -1
  134. package/dist/assets/quantum-ui.css +44 -13
  135. package/dist/calendar2.js +1 -1
  136. package/dist/collapsible2.js +1 -1
  137. package/dist/components/CompanySelector.js +2 -0
  138. package/dist/components/CompanySelector.js.map +1 -0
  139. package/dist/components/CopyField.js +2 -0
  140. package/dist/components/CopyField.js.map +1 -0
  141. package/dist/components/FormattedDate.js +2 -2
  142. package/dist/components/HierarchyGraph.js +2 -1
  143. package/dist/components/HierarchyGraph.js.map +1 -1
  144. package/dist/components/PermissionGate.js +1 -1
  145. package/dist/components/PersonSelector.js +2 -0
  146. package/dist/components/PersonSelector.js.map +1 -0
  147. package/dist/components/ScanBarcodeButton.js.map +1 -1
  148. package/dist/components/TreeView.js +7 -7
  149. package/dist/components/TreeView.js.map +1 -1
  150. package/dist/copy.js +18 -0
  151. package/dist/copy.js.map +1 -0
  152. package/dist/core.esm.js +4025 -0
  153. package/dist/core.esm.js.map +1 -0
  154. package/dist/dropdown-menu.js +10 -10
  155. package/dist/field.js +1 -1
  156. package/dist/getClassNameFromUnknown.js.map +1 -1
  157. package/dist/getRadiusAndStrokeWidthFromDot.js.map +1 -1
  158. package/dist/getZIndexFromUnknown.js.map +1 -1
  159. package/dist/graphicalItemSelectors.js.map +1 -1
  160. package/dist/image-component.js.map +1 -1
  161. package/dist/index.js +16 -3
  162. package/dist/index.js.map +1 -1
  163. package/dist/index10.js +102 -1499
  164. package/dist/index10.js.map +1 -1
  165. package/dist/index11.js +1499 -37
  166. package/dist/index11.js.map +1 -1
  167. package/dist/index12.js +29 -477
  168. package/dist/index12.js.map +1 -1
  169. package/dist/index13.js +427 -231
  170. package/dist/index13.js.map +1 -1
  171. package/dist/index14.js +215 -1074
  172. package/dist/index14.js.map +1 -1
  173. package/dist/index15.js +1140 -14
  174. package/dist/index15.js.map +1 -1
  175. package/dist/index16.js +13 -19
  176. package/dist/index16.js.map +1 -1
  177. package/dist/index17.js +24 -172
  178. package/dist/index17.js.map +1 -1
  179. package/dist/index18.js +168 -175
  180. package/dist/index18.js.map +1 -1
  181. package/dist/index19.js +173 -201
  182. package/dist/index19.js.map +1 -1
  183. package/dist/index20.js +203 -69
  184. package/dist/index20.js.map +1 -1
  185. package/dist/index21.js +70 -211
  186. package/dist/index21.js.map +1 -1
  187. package/dist/index22.js +207 -117
  188. package/dist/index22.js.map +1 -1
  189. package/dist/index23.js +123 -71
  190. package/dist/index23.js.map +1 -1
  191. package/dist/index24.js +74 -11
  192. package/dist/index24.js.map +1 -1
  193. package/dist/index25.js +13 -1134
  194. package/dist/index25.js.map +1 -1
  195. package/dist/index26.js +1120 -219
  196. package/dist/index26.js.map +1 -1
  197. package/dist/index27.js +202 -2506
  198. package/dist/index27.js.map +1 -1
  199. package/dist/index28.js +2527 -23
  200. package/dist/index28.js.map +1 -1
  201. package/dist/index29.js +32 -4
  202. package/dist/index29.js.map +1 -1
  203. package/dist/index3.js +11543 -267
  204. package/dist/index3.js.map +1 -1
  205. package/dist/index30.js +3 -1124
  206. package/dist/index30.js.map +1 -1
  207. package/dist/index31.js +1 -1
  208. package/dist/index32.js +7 -7
  209. package/dist/index34.js +1 -1
  210. package/dist/index37.js +1 -1
  211. package/dist/index38.js +23 -43
  212. package/dist/index38.js.map +1 -1
  213. package/dist/index4.js +272 -132
  214. package/dist/index4.js.map +1 -1
  215. package/dist/index5.js +138 -388
  216. package/dist/index5.js.map +1 -1
  217. package/dist/index6.js +386 -7
  218. package/dist/index6.js.map +1 -1
  219. package/dist/index7.js +13 -92
  220. package/dist/index7.js.map +1 -1
  221. package/dist/index8.js +92 -43
  222. package/dist/index8.js.map +1 -1
  223. package/dist/index9.js +42 -102
  224. package/dist/index9.js.map +1 -1
  225. package/dist/lib/components/Alert/Alert.d.ts.map +1 -1
  226. package/dist/lib/components/Avatar/Avatar.d.ts.map +1 -1
  227. package/dist/lib/components/Breadcrumb/Breadcrumb.d.ts.map +1 -1
  228. package/dist/lib/components/Button/Button.d.ts.map +1 -1
  229. package/dist/lib/components/Card/CardSkeleton.d.ts.map +1 -1
  230. package/dist/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
  231. package/dist/lib/components/CheckboxGroup/CheckboxGroup.d.ts.map +1 -1
  232. package/dist/lib/components/Collapsible/Collapsible.d.ts.map +1 -1
  233. package/dist/lib/components/CompanySelector/CompanySelector.d.ts +4 -0
  234. package/dist/lib/components/CompanySelector/CompanySelector.d.ts.map +1 -0
  235. package/dist/lib/components/CompanySelector/index.d.ts +2 -0
  236. package/dist/lib/components/CompanySelector/index.d.ts.map +1 -0
  237. package/dist/lib/components/ConfirmHost/ConfirmHost.d.ts.map +1 -1
  238. package/dist/lib/components/CopyField/CopyField.d.ts +10 -0
  239. package/dist/lib/components/CopyField/CopyField.d.ts.map +1 -0
  240. package/dist/lib/components/CopyField/index.d.ts +2 -0
  241. package/dist/lib/components/CopyField/index.d.ts.map +1 -0
  242. package/dist/lib/components/CurrencyField/CurrencyField.d.ts.map +1 -1
  243. package/dist/lib/components/DangerZone/DangerZone.d.ts +3 -1
  244. package/dist/lib/components/DangerZone/DangerZone.d.ts.map +1 -1
  245. package/dist/lib/components/DataTable/CompactTableSkeleton.d.ts.map +1 -1
  246. package/dist/lib/components/DataTable/DataTable.d.ts.map +1 -1
  247. package/dist/lib/components/DataTable/cells/cells.d.ts.map +1 -1
  248. package/dist/lib/components/DataTable/components/DataTableSelectionBar.d.ts.map +1 -1
  249. package/dist/lib/components/DataTable/components/RowActions.d.ts.map +1 -1
  250. package/dist/lib/components/DataTable/hooks/useDataTable.d.ts.map +1 -1
  251. package/dist/lib/components/DataTable/store/store.d.ts.map +1 -1
  252. package/dist/lib/components/DataTable/types.d.ts.map +1 -1
  253. package/dist/lib/components/DatePicker/DatePicker.d.ts +2 -2
  254. package/dist/lib/components/DatePicker/DatePicker.d.ts.map +1 -1
  255. package/dist/lib/components/DetailField/DetailField.d.ts.map +1 -1
  256. package/dist/lib/components/DetailField/DetailHeader.d.ts.map +1 -1
  257. package/dist/lib/components/DetailField/DetailSectionSkeleton.d.ts.map +1 -1
  258. package/dist/lib/components/Dialog/Dialog.d.ts.map +1 -1
  259. package/dist/lib/components/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  260. package/dist/lib/components/DropdownMenu/types.d.ts.map +1 -1
  261. package/dist/lib/components/Editor/editor-ui/color-picker.d.ts.map +1 -1
  262. package/dist/lib/components/Editor/editor-ui/image-component.d.ts.map +1 -1
  263. package/dist/lib/components/Editor/nodes/autocomplete-node.d.ts.map +1 -1
  264. package/dist/lib/components/Editor/plugins/actions/max-length-plugin.d.ts.map +1 -1
  265. package/dist/lib/components/Editor/plugins/embeds/auto-embed-plugin.d.ts.map +1 -1
  266. package/dist/lib/components/Editor/plugins/embeds/youtube-plugin.d.ts.map +1 -1
  267. package/dist/lib/components/Editor/plugins/emojis-plugin.d.ts.map +1 -1
  268. package/dist/lib/components/Editor/plugins/floating-link-editor-plugin.d.ts.map +1 -1
  269. package/dist/lib/components/Editor/plugins/floating-text-format-plugin.d.ts.map +1 -1
  270. package/dist/lib/components/Editor/plugins/images-plugin.d.ts.map +1 -1
  271. package/dist/lib/components/Editor/plugins/keywords-plugin.d.ts.map +1 -1
  272. package/dist/lib/components/Editor/plugins/layout-plugin.d.ts.map +1 -1
  273. package/dist/lib/components/Editor/plugins/list-max-indent-level-plugin.d.ts.map +1 -1
  274. package/dist/lib/components/Editor/plugins/mentions-plugin.d.ts.map +1 -1
  275. package/dist/lib/components/Editor/plugins/picker/component-picker-option.d.ts.map +1 -1
  276. package/dist/lib/components/Editor/plugins/tab-focus-plugin.d.ts.map +1 -1
  277. package/dist/lib/components/Editor/plugins/table-plugin.d.ts.map +1 -1
  278. package/dist/lib/components/Editor/plugins/toolbar/clear-formatting-toolbar-plugin.d.ts.map +1 -1
  279. package/dist/lib/components/Editor/plugins/typing-pref-plugin.d.ts.map +1 -1
  280. package/dist/lib/components/Editor/shared/invariant.d.ts.map +1 -1
  281. package/dist/lib/components/Editor/shared/react-patches.d.ts.map +1 -1
  282. package/dist/lib/components/Editor/shared/react-test-utils.d.ts.map +1 -1
  283. package/dist/lib/components/Editor/shared/simple-diff-with-cursor.d.ts.map +1 -1
  284. package/dist/lib/components/Editor/shared/use-layout-effect.d.ts.map +1 -1
  285. package/dist/lib/components/Editor/transformers/markdown-table-transformer.d.ts.map +1 -1
  286. package/dist/lib/components/Editor/utils/collapsible.d.ts.map +1 -1
  287. package/dist/lib/components/Editor/utils/doc-serialization.d.ts.map +1 -1
  288. package/dist/lib/components/Editor/utils/emoji-list.d.ts.map +1 -1
  289. package/dist/lib/components/Editor/utils/get-dom-range-rect.d.ts.map +1 -1
  290. package/dist/lib/components/Editor/utils/get-selected-node.d.ts.map +1 -1
  291. package/dist/lib/components/Editor/utils/guard.d.ts.map +1 -1
  292. package/dist/lib/components/Editor/utils/set-floating-elem-position-for-link-editor.d.ts.map +1 -1
  293. package/dist/lib/components/Editor/utils/set-floating-elem-position.d.ts.map +1 -1
  294. package/dist/lib/components/Editor/utils/swipe.d.ts.map +1 -1
  295. package/dist/lib/components/Editor/utils/url.d.ts.map +1 -1
  296. package/dist/lib/components/Form/Form.d.ts.map +1 -1
  297. package/dist/lib/components/OTPField/OTPField.d.ts.map +1 -1
  298. package/dist/lib/components/PageContent/PageContent.d.ts.map +1 -1
  299. package/dist/lib/components/PageHeader/PageHeader.d.ts.map +1 -1
  300. package/dist/lib/components/PasswordField/PasswordField.d.ts.map +1 -1
  301. package/dist/lib/components/PermissionGate/PermissionGate.d.ts +15 -4
  302. package/dist/lib/components/PermissionGate/PermissionGate.d.ts.map +1 -1
  303. package/dist/lib/components/PermissionGate/index.d.ts +1 -1
  304. package/dist/lib/components/PermissionGate/index.d.ts.map +1 -1
  305. package/dist/lib/components/PersonSelector/PersonSelector.d.ts +4 -0
  306. package/dist/lib/components/PersonSelector/PersonSelector.d.ts.map +1 -0
  307. package/dist/lib/components/PersonSelector/index.d.ts +2 -0
  308. package/dist/lib/components/PersonSelector/index.d.ts.map +1 -0
  309. package/dist/lib/components/PhoneField/PhoneField.d.ts.map +1 -1
  310. package/dist/lib/components/RadioGroup/RadioGroup.d.ts.map +1 -1
  311. package/dist/lib/components/ScanBarcodeButton/ScanBarcodeButton.d.ts.map +1 -1
  312. package/dist/lib/components/Select/SelectFilter.d.ts.map +1 -1
  313. package/dist/lib/components/Select/components/MultiSelect/MultiSelect.d.ts.map +1 -1
  314. package/dist/lib/components/Select/components/MultiSelect/MultiSelectFilter.d.ts.map +1 -1
  315. package/dist/lib/components/Select/components/SingleSelect/SingleSelect.d.ts.map +1 -1
  316. package/dist/lib/components/Select/components/SingleSelect/SingleSelectFilter.d.ts.map +1 -1
  317. package/dist/lib/components/Select/hooks/useSelect.d.ts.map +1 -1
  318. package/dist/lib/components/Select/hooks/useSingleSelect.d.ts.map +1 -1
  319. package/dist/lib/components/Select/types.d.ts +1 -1
  320. package/dist/lib/components/Select/types.d.ts.map +1 -1
  321. package/dist/lib/components/Separator/Separator.d.ts.map +1 -1
  322. package/dist/lib/components/Sidebar/Sidebar.d.ts.map +1 -1
  323. package/dist/lib/components/Sonner/Sonner.d.ts.map +1 -1
  324. package/dist/lib/components/Sonner/toast.d.ts.map +1 -1
  325. package/dist/lib/components/StepProgressIndicator/StepProgressIndicator.d.ts.map +1 -1
  326. package/dist/lib/components/Switch/Switch.d.ts.map +1 -1
  327. package/dist/lib/components/Tabs/Tabs.d.ts +2 -0
  328. package/dist/lib/components/Tabs/Tabs.d.ts.map +1 -1
  329. package/dist/lib/components/Tabs/TabsSkeleton.d.ts.map +1 -1
  330. package/dist/lib/components/TextField/TextField.d.ts.map +1 -1
  331. package/dist/lib/components/ThemeToggle/ThemeToggle.d.ts.map +1 -1
  332. package/dist/lib/components/Toggle/Toggle.d.ts.map +1 -1
  333. package/dist/lib/components/Tooltip/Tooltip.d.ts.map +1 -1
  334. package/dist/lib/components/TreeView/TreeView.d.ts.map +1 -1
  335. package/dist/lib/components/Typography/Typography.d.ts.map +1 -1
  336. package/dist/lib/components/UploadFile/UploadFile.d.ts.map +1 -1
  337. package/dist/lib/components/index.d.ts +3 -0
  338. package/dist/lib/components/index.d.ts.map +1 -1
  339. package/dist/lib/config/index.d.ts.map +1 -1
  340. package/dist/lib/context/LayoutModeContext.d.ts.map +1 -1
  341. package/dist/lib/context/ThemeContext.d.ts.map +1 -1
  342. package/dist/lib/hooks/useBUCurrency.d.ts.map +1 -1
  343. package/dist/lib/hooks/useBUTimezone.d.ts.map +1 -1
  344. package/dist/lib/hooks/useBarcodeScanner.d.ts.map +1 -1
  345. package/dist/lib/hooks/useFormatters.d.ts.map +1 -1
  346. package/dist/lib/hooks/useSSE.d.ts.map +1 -1
  347. package/dist/lib/hooks/useTheme.d.ts.map +1 -1
  348. package/dist/lib/index.d.ts.map +1 -1
  349. package/dist/lib/selects/billing-cycle/BillingCycleFilter.d.ts +12 -0
  350. package/dist/lib/selects/billing-cycle/BillingCycleFilter.d.ts.map +1 -0
  351. package/dist/lib/selects/billing-cycle/BillingCycleSelector.d.ts +4 -0
  352. package/dist/lib/selects/billing-cycle/BillingCycleSelector.d.ts.map +1 -0
  353. package/dist/lib/selects/billing-cycle/index.d.ts +3 -0
  354. package/dist/lib/selects/billing-cycle/index.d.ts.map +1 -0
  355. package/dist/lib/selects/category/CategoryFilter.d.ts.map +1 -1
  356. package/dist/lib/selects/category/CategorySelector.d.ts.map +1 -1
  357. package/dist/lib/selects/cost-category/CostCategorySelector.d.ts.map +1 -1
  358. package/dist/lib/selects/country/CountryFilter.d.ts +12 -0
  359. package/dist/lib/selects/country/CountryFilter.d.ts.map +1 -0
  360. package/dist/lib/selects/country/CountrySelector.d.ts +4 -0
  361. package/dist/lib/selects/country/CountrySelector.d.ts.map +1 -0
  362. package/dist/lib/selects/country/index.d.ts +3 -0
  363. package/dist/lib/selects/country/index.d.ts.map +1 -0
  364. package/dist/lib/selects/feature-permission/FeaturePermissionFilter.d.ts +12 -0
  365. package/dist/lib/selects/feature-permission/FeaturePermissionFilter.d.ts.map +1 -0
  366. package/dist/lib/selects/feature-permission/FeaturePermissionSelector.d.ts +4 -0
  367. package/dist/lib/selects/feature-permission/FeaturePermissionSelector.d.ts.map +1 -0
  368. package/dist/lib/selects/feature-permission/index.d.ts +3 -0
  369. package/dist/lib/selects/feature-permission/index.d.ts.map +1 -0
  370. package/dist/lib/selects/icon/IconSelect.d.ts.map +1 -1
  371. package/dist/lib/selects/index.d.ts +9 -0
  372. package/dist/lib/selects/index.d.ts.map +1 -1
  373. package/dist/lib/selects/inventory-item/InventoryItemSelector.d.ts +2 -2
  374. package/dist/lib/selects/inventory-item/InventoryItemSelector.d.ts.map +1 -1
  375. package/dist/lib/selects/iso-country/ISOCountrySelect.d.ts +15 -0
  376. package/dist/lib/selects/iso-country/ISOCountrySelect.d.ts.map +1 -0
  377. package/dist/lib/selects/iso-country/index.d.ts +3 -0
  378. package/dist/lib/selects/iso-country/index.d.ts.map +1 -0
  379. package/dist/lib/selects/iso-country/iso-countries.d.ts +7 -0
  380. package/dist/lib/selects/iso-country/iso-countries.d.ts.map +1 -0
  381. package/dist/lib/selects/legal-entity/LegalEntityFilter.d.ts +12 -0
  382. package/dist/lib/selects/legal-entity/LegalEntityFilter.d.ts.map +1 -0
  383. package/dist/lib/selects/legal-entity/LegalEntitySelector.d.ts +4 -0
  384. package/dist/lib/selects/legal-entity/LegalEntitySelector.d.ts.map +1 -0
  385. package/dist/lib/selects/legal-entity/index.d.ts +3 -0
  386. package/dist/lib/selects/legal-entity/index.d.ts.map +1 -0
  387. package/dist/lib/selects/location/LocationSelector.d.ts.map +1 -1
  388. package/dist/lib/selects/purchase-order/PurchaseOrderSelector.d.ts.map +1 -1
  389. package/dist/lib/selects/purchase-order-item/PurchaseOrderItemSelector.d.ts.map +1 -1
  390. package/dist/lib/selects/role/RoleSelector.d.ts +4 -0
  391. package/dist/lib/selects/role/RoleSelector.d.ts.map +1 -0
  392. package/dist/lib/selects/role/index.d.ts +2 -0
  393. package/dist/lib/selects/role/index.d.ts.map +1 -0
  394. package/dist/lib/selects/serial/SerialSelector.d.ts.map +1 -1
  395. package/dist/lib/selects/site/SiteFilter.d.ts +12 -0
  396. package/dist/lib/selects/site/SiteFilter.d.ts.map +1 -0
  397. package/dist/lib/selects/site/SiteSelector.d.ts +4 -0
  398. package/dist/lib/selects/site/SiteSelector.d.ts.map +1 -0
  399. package/dist/lib/selects/site/index.d.ts +3 -0
  400. package/dist/lib/selects/site/index.d.ts.map +1 -0
  401. package/dist/lib/selects/site-group/SiteGroupFilter.d.ts +12 -0
  402. package/dist/lib/selects/site-group/SiteGroupFilter.d.ts.map +1 -0
  403. package/dist/lib/selects/site-group/SiteGroupSelector.d.ts +4 -0
  404. package/dist/lib/selects/site-group/SiteGroupSelector.d.ts.map +1 -0
  405. package/dist/lib/selects/site-group/index.d.ts +3 -0
  406. package/dist/lib/selects/site-group/index.d.ts.map +1 -0
  407. package/dist/lib/selects/supplier/SupplierSelector.d.ts.map +1 -1
  408. package/dist/lib/selects/supplier-item/SupplierItemFilter.d.ts.map +1 -1
  409. package/dist/lib/selects/supplier-item/SupplierItemSelector.d.ts.map +1 -1
  410. package/dist/lib/selects/tax-class/TaxClassSelector.d.ts +4 -0
  411. package/dist/lib/selects/tax-class/TaxClassSelector.d.ts.map +1 -0
  412. package/dist/lib/selects/tax-class/index.d.ts +2 -0
  413. package/dist/lib/selects/tax-class/index.d.ts.map +1 -0
  414. package/dist/lib/theme/index.d.ts.map +1 -1
  415. package/dist/lib/types/catalog-resolver.d.ts +50 -17
  416. package/dist/lib/types/catalog-resolver.d.ts.map +1 -1
  417. package/dist/lib/utils/axios.d.ts.map +1 -1
  418. package/dist/lib/utils/cn.d.ts +3 -0
  419. package/dist/lib/utils/cn.d.ts.map +1 -0
  420. package/dist/lib/utils/dagre.d.ts +2 -0
  421. package/dist/lib/utils/dagre.d.ts.map +1 -0
  422. package/dist/lib/utils/dnd-kit/core.d.ts +2 -0
  423. package/dist/lib/utils/dnd-kit/core.d.ts.map +1 -0
  424. package/dist/lib/utils/dnd-kit/sortable.d.ts +2 -0
  425. package/dist/lib/utils/dnd-kit/sortable.d.ts.map +1 -0
  426. package/dist/lib/utils/dnd-kit/utilities.d.ts +2 -0
  427. package/dist/lib/utils/dnd-kit/utilities.d.ts.map +1 -0
  428. package/dist/lib/utils/formHelpers.d.ts.map +1 -1
  429. package/dist/lib/utils/format.d.ts.map +1 -1
  430. package/dist/lib/utils/permission-deps.d.ts +9 -0
  431. package/dist/lib/utils/permission-deps.d.ts.map +1 -0
  432. package/dist/lib/utils/react-flow.d.ts +2 -0
  433. package/dist/lib/utils/react-flow.d.ts.map +1 -0
  434. package/dist/lib/utils/zod.d.ts +9 -0
  435. package/dist/lib/utils/zod.d.ts.map +1 -1
  436. package/dist/polarScaleSelectors.js.map +1 -1
  437. package/dist/popover.js +1 -1
  438. package/dist/select2.js +1 -1
  439. package/dist/selects/billing-cycle.js +2 -0
  440. package/dist/selects/billing-cycle.js.map +1 -0
  441. package/dist/selects/cost-category.js +2 -2
  442. package/dist/selects/cost-category.js.map +1 -1
  443. package/dist/selects/country.js +2 -0
  444. package/dist/selects/country.js.map +1 -0
  445. package/dist/selects/feature-permission.js +2 -0
  446. package/dist/selects/feature-permission.js.map +1 -0
  447. package/dist/selects/iso-country.js +2 -0
  448. package/dist/selects/iso-country.js.map +1 -0
  449. package/dist/selects/legal-entity.js +2 -0
  450. package/dist/selects/legal-entity.js.map +1 -0
  451. package/dist/selects/purchase-order-item.js +1 -1
  452. package/dist/selects/purchase-order-item.js.map +1 -1
  453. package/dist/selects/role.js +2 -0
  454. package/dist/selects/role.js.map +1 -0
  455. package/dist/selects/site-group.js +2 -0
  456. package/dist/selects/site-group.js.map +1 -0
  457. package/dist/selects/site.js +2 -0
  458. package/dist/selects/site.js.map +1 -0
  459. package/dist/selects/tax-class.js +2 -0
  460. package/dist/selects/tax-class.js.map +1 -0
  461. package/dist/selects/tax-group.js +2 -2
  462. package/dist/selects/tax-group.js.map +1 -1
  463. package/dist/separator2.js +1 -1
  464. package/dist/sortable.esm.js +780 -0
  465. package/dist/sortable.esm.js.map +1 -0
  466. package/dist/theme/index.js.map +1 -1
  467. package/dist/toast.js +2 -26
  468. package/dist/toast.js.map +1 -1
  469. package/dist/tooltip2.js +1 -1
  470. package/dist/tooltipContext.js.map +1 -1
  471. package/dist/types/catalog-resolver.js +5 -2
  472. package/dist/types/catalog-resolver.js.map +1 -1
  473. package/dist/useBUTimezone.js.map +1 -1
  474. package/dist/useDataTable.js +58 -60
  475. package/dist/useDataTable.js.map +1 -1
  476. package/dist/useFormatters.js.map +1 -1
  477. package/dist/useTheme.js.map +1 -1
  478. package/dist/useTimer.js +2 -2
  479. package/dist/useTimer.js.map +1 -1
  480. package/dist/utilities.esm.js +333 -0
  481. package/dist/utilities.esm.js.map +1 -0
  482. package/dist/utils/axios.js +1 -1
  483. package/dist/utils/axios.js.map +1 -1
  484. package/dist/utils/cn.js +6 -0
  485. package/dist/utils/cn.js.map +1 -0
  486. package/dist/utils/currency.js +2 -2
  487. package/dist/utils/dagre.js +4 -0
  488. package/dist/utils/dagre.js.map +1 -0
  489. package/dist/utils/dnd-kit/core.js +2 -0
  490. package/dist/utils/dnd-kit/core.js.map +1 -0
  491. package/dist/utils/dnd-kit/sortable.js +2 -0
  492. package/dist/utils/dnd-kit/sortable.js.map +1 -0
  493. package/dist/utils/dnd-kit/utilities.js +2 -0
  494. package/dist/utils/dnd-kit/utilities.js.map +1 -0
  495. package/dist/utils/format.js +2 -2
  496. package/dist/utils/format.js.map +1 -1
  497. package/dist/utils/hotkeys.js +1 -1
  498. package/dist/utils/money.js +1 -1
  499. package/dist/utils/permission-deps.js +64 -0
  500. package/dist/utils/permission-deps.js.map +1 -0
  501. package/dist/utils/react-flow.js +2 -0
  502. package/dist/utils/react-flow.js.map +1 -0
  503. package/dist/utils/timezone.js +1 -1
  504. package/dist/utils/zod.js +11 -1
  505. package/dist/utils/zod.js.map +1 -1
  506. package/dist/youtube.js +15 -29
  507. package/dist/youtube.js.map +1 -1
  508. package/package.json +77 -1
@@ -0,0 +1,4025 @@
1
+ import React__default, { useState, useCallback, createContext, memo, useReducer, useRef, useMemo, useEffect, useContext, cloneElement, forwardRef } from 'react';
2
+ import { unstable_batchedUpdates, createPortal } from 'react-dom';
3
+ import { r as useLatestValue, x as useUniqueId, g as getEventCoordinates, d as getWindow, a as add, q as useIsomorphicLayoutEffect, b as getOwnerDocument, j as isKeyboardEvent, s as subtract, C as CSS, v as useNodeRef, t as useLazyMemo, e as isHTMLElement, c as canUseDOM, p as useInterval, w as usePrevious, f as findFirstFocusableNode, o as useEvent, i as isDocument, l as isSVGElement, n as isWindow, k as isNode } from './utilities.esm.js';
4
+
5
+ const hiddenStyles = {
6
+ display: 'none'
7
+ };
8
+ function HiddenText(_ref) {
9
+ let {
10
+ id,
11
+ value
12
+ } = _ref;
13
+ return React__default.createElement("div", {
14
+ id: id,
15
+ style: hiddenStyles
16
+ }, value);
17
+ }
18
+
19
+ function LiveRegion(_ref) {
20
+ let {
21
+ id,
22
+ announcement,
23
+ ariaLiveType = "assertive"
24
+ } = _ref;
25
+ // Hide element visually but keep it readable by screen readers
26
+ const visuallyHidden = {
27
+ position: 'fixed',
28
+ top: 0,
29
+ left: 0,
30
+ width: 1,
31
+ height: 1,
32
+ margin: -1,
33
+ border: 0,
34
+ padding: 0,
35
+ overflow: 'hidden',
36
+ clip: 'rect(0 0 0 0)',
37
+ clipPath: 'inset(100%)',
38
+ whiteSpace: 'nowrap'
39
+ };
40
+ return React__default.createElement("div", {
41
+ id: id,
42
+ style: visuallyHidden,
43
+ role: "status",
44
+ "aria-live": ariaLiveType,
45
+ "aria-atomic": true
46
+ }, announcement);
47
+ }
48
+
49
+ function useAnnouncement() {
50
+ const [announcement, setAnnouncement] = useState('');
51
+ const announce = useCallback(value => {
52
+ if (value != null) {
53
+ setAnnouncement(value);
54
+ }
55
+ }, []);
56
+ return {
57
+ announce,
58
+ announcement
59
+ };
60
+ }
61
+
62
+ const DndMonitorContext = /*#__PURE__*/createContext(null);
63
+
64
+ function useDndMonitor(listener) {
65
+ const registerListener = useContext(DndMonitorContext);
66
+ useEffect(() => {
67
+ if (!registerListener) {
68
+ throw new Error('useDndMonitor must be used within a children of <DndContext>');
69
+ }
70
+
71
+ const unsubscribe = registerListener(listener);
72
+ return unsubscribe;
73
+ }, [listener, registerListener]);
74
+ }
75
+
76
+ function useDndMonitorProvider() {
77
+ const [listeners] = useState(() => new Set());
78
+ const registerListener = useCallback(listener => {
79
+ listeners.add(listener);
80
+ return () => listeners.delete(listener);
81
+ }, [listeners]);
82
+ const dispatch = useCallback(_ref => {
83
+ let {
84
+ type,
85
+ event
86
+ } = _ref;
87
+ listeners.forEach(listener => {
88
+ var _listener$type;
89
+
90
+ return (_listener$type = listener[type]) == null ? void 0 : _listener$type.call(listener, event);
91
+ });
92
+ }, [listeners]);
93
+ return [dispatch, registerListener];
94
+ }
95
+
96
+ const defaultScreenReaderInstructions = {
97
+ draggable: "\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "
98
+ };
99
+ const defaultAnnouncements = {
100
+ onDragStart(_ref) {
101
+ let {
102
+ active
103
+ } = _ref;
104
+ return "Picked up draggable item " + active.id + ".";
105
+ },
106
+
107
+ onDragOver(_ref2) {
108
+ let {
109
+ active,
110
+ over
111
+ } = _ref2;
112
+
113
+ if (over) {
114
+ return "Draggable item " + active.id + " was moved over droppable area " + over.id + ".";
115
+ }
116
+
117
+ return "Draggable item " + active.id + " is no longer over a droppable area.";
118
+ },
119
+
120
+ onDragEnd(_ref3) {
121
+ let {
122
+ active,
123
+ over
124
+ } = _ref3;
125
+
126
+ if (over) {
127
+ return "Draggable item " + active.id + " was dropped over droppable area " + over.id;
128
+ }
129
+
130
+ return "Draggable item " + active.id + " was dropped.";
131
+ },
132
+
133
+ onDragCancel(_ref4) {
134
+ let {
135
+ active
136
+ } = _ref4;
137
+ return "Dragging was cancelled. Draggable item " + active.id + " was dropped.";
138
+ }
139
+
140
+ };
141
+
142
+ function Accessibility(_ref) {
143
+ let {
144
+ announcements = defaultAnnouncements,
145
+ container,
146
+ hiddenTextDescribedById,
147
+ screenReaderInstructions = defaultScreenReaderInstructions
148
+ } = _ref;
149
+ const {
150
+ announce,
151
+ announcement
152
+ } = useAnnouncement();
153
+ const liveRegionId = useUniqueId("DndLiveRegion");
154
+ const [mounted, setMounted] = useState(false);
155
+ useEffect(() => {
156
+ setMounted(true);
157
+ }, []);
158
+ useDndMonitor(useMemo(() => ({
159
+ onDragStart(_ref2) {
160
+ let {
161
+ active
162
+ } = _ref2;
163
+ announce(announcements.onDragStart({
164
+ active
165
+ }));
166
+ },
167
+
168
+ onDragMove(_ref3) {
169
+ let {
170
+ active,
171
+ over
172
+ } = _ref3;
173
+
174
+ if (announcements.onDragMove) {
175
+ announce(announcements.onDragMove({
176
+ active,
177
+ over
178
+ }));
179
+ }
180
+ },
181
+
182
+ onDragOver(_ref4) {
183
+ let {
184
+ active,
185
+ over
186
+ } = _ref4;
187
+ announce(announcements.onDragOver({
188
+ active,
189
+ over
190
+ }));
191
+ },
192
+
193
+ onDragEnd(_ref5) {
194
+ let {
195
+ active,
196
+ over
197
+ } = _ref5;
198
+ announce(announcements.onDragEnd({
199
+ active,
200
+ over
201
+ }));
202
+ },
203
+
204
+ onDragCancel(_ref6) {
205
+ let {
206
+ active,
207
+ over
208
+ } = _ref6;
209
+ announce(announcements.onDragCancel({
210
+ active,
211
+ over
212
+ }));
213
+ }
214
+
215
+ }), [announce, announcements]));
216
+
217
+ if (!mounted) {
218
+ return null;
219
+ }
220
+
221
+ const markup = React__default.createElement(React__default.Fragment, null, React__default.createElement(HiddenText, {
222
+ id: hiddenTextDescribedById,
223
+ value: screenReaderInstructions.draggable
224
+ }), React__default.createElement(LiveRegion, {
225
+ id: liveRegionId,
226
+ announcement: announcement
227
+ }));
228
+ return container ? createPortal(markup, container) : markup;
229
+ }
230
+
231
+ var Action;
232
+
233
+ (function (Action) {
234
+ Action["DragStart"] = "dragStart";
235
+ Action["DragMove"] = "dragMove";
236
+ Action["DragEnd"] = "dragEnd";
237
+ Action["DragCancel"] = "dragCancel";
238
+ Action["DragOver"] = "dragOver";
239
+ Action["RegisterDroppable"] = "registerDroppable";
240
+ Action["SetDroppableDisabled"] = "setDroppableDisabled";
241
+ Action["UnregisterDroppable"] = "unregisterDroppable";
242
+ })(Action || (Action = {}));
243
+
244
+ function noop() {}
245
+
246
+ function useSensor(sensor, options) {
247
+ return useMemo(() => ({
248
+ sensor,
249
+ options: options != null ? options : {}
250
+ }), // eslint-disable-next-line react-hooks/exhaustive-deps
251
+ [sensor, options]);
252
+ }
253
+
254
+ function useSensors() {
255
+ for (var _len = arguments.length, sensors = new Array(_len), _key = 0; _key < _len; _key++) {
256
+ sensors[_key] = arguments[_key];
257
+ }
258
+
259
+ return useMemo(() => [...sensors].filter(sensor => sensor != null), // eslint-disable-next-line react-hooks/exhaustive-deps
260
+ [...sensors]);
261
+ }
262
+
263
+ const defaultCoordinates = /*#__PURE__*/Object.freeze({
264
+ x: 0,
265
+ y: 0
266
+ });
267
+
268
+ /**
269
+ * Returns the distance between two points
270
+ */
271
+ function distanceBetween(p1, p2) {
272
+ return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
273
+ }
274
+
275
+ function getRelativeTransformOrigin(event, rect) {
276
+ const eventCoordinates = getEventCoordinates(event);
277
+
278
+ if (!eventCoordinates) {
279
+ return '0 0';
280
+ }
281
+
282
+ const transformOrigin = {
283
+ x: (eventCoordinates.x - rect.left) / rect.width * 100,
284
+ y: (eventCoordinates.y - rect.top) / rect.height * 100
285
+ };
286
+ return transformOrigin.x + "% " + transformOrigin.y + "%";
287
+ }
288
+
289
+ /**
290
+ * Sort collisions from smallest to greatest value
291
+ */
292
+ function sortCollisionsAsc(_ref, _ref2) {
293
+ let {
294
+ data: {
295
+ value: a
296
+ }
297
+ } = _ref;
298
+ let {
299
+ data: {
300
+ value: b
301
+ }
302
+ } = _ref2;
303
+ return a - b;
304
+ }
305
+ /**
306
+ * Sort collisions from greatest to smallest value
307
+ */
308
+
309
+ function sortCollisionsDesc(_ref3, _ref4) {
310
+ let {
311
+ data: {
312
+ value: a
313
+ }
314
+ } = _ref3;
315
+ let {
316
+ data: {
317
+ value: b
318
+ }
319
+ } = _ref4;
320
+ return b - a;
321
+ }
322
+ /**
323
+ * Returns the coordinates of the corners of a given rectangle:
324
+ * [TopLeft {x, y}, TopRight {x, y}, BottomLeft {x, y}, BottomRight {x, y}]
325
+ */
326
+
327
+ function cornersOfRectangle(_ref5) {
328
+ let {
329
+ left,
330
+ top,
331
+ height,
332
+ width
333
+ } = _ref5;
334
+ return [{
335
+ x: left,
336
+ y: top
337
+ }, {
338
+ x: left + width,
339
+ y: top
340
+ }, {
341
+ x: left,
342
+ y: top + height
343
+ }, {
344
+ x: left + width,
345
+ y: top + height
346
+ }];
347
+ }
348
+ function getFirstCollision(collisions, property) {
349
+ if (!collisions || collisions.length === 0) {
350
+ return null;
351
+ }
352
+
353
+ const [firstCollision] = collisions;
354
+ return property ? firstCollision[property] : firstCollision;
355
+ }
356
+
357
+ /**
358
+ * Returns the coordinates of the center of a given ClientRect
359
+ */
360
+
361
+ function centerOfRectangle(rect, left, top) {
362
+ if (left === void 0) {
363
+ left = rect.left;
364
+ }
365
+
366
+ if (top === void 0) {
367
+ top = rect.top;
368
+ }
369
+
370
+ return {
371
+ x: left + rect.width * 0.5,
372
+ y: top + rect.height * 0.5
373
+ };
374
+ }
375
+ /**
376
+ * Returns the closest rectangles from an array of rectangles to the center of a given
377
+ * rectangle.
378
+ */
379
+
380
+
381
+ const closestCenter = _ref => {
382
+ let {
383
+ collisionRect,
384
+ droppableRects,
385
+ droppableContainers
386
+ } = _ref;
387
+ const centerRect = centerOfRectangle(collisionRect, collisionRect.left, collisionRect.top);
388
+ const collisions = [];
389
+
390
+ for (const droppableContainer of droppableContainers) {
391
+ const {
392
+ id
393
+ } = droppableContainer;
394
+ const rect = droppableRects.get(id);
395
+
396
+ if (rect) {
397
+ const distBetween = distanceBetween(centerOfRectangle(rect), centerRect);
398
+ collisions.push({
399
+ id,
400
+ data: {
401
+ droppableContainer,
402
+ value: distBetween
403
+ }
404
+ });
405
+ }
406
+ }
407
+
408
+ return collisions.sort(sortCollisionsAsc);
409
+ };
410
+
411
+ /**
412
+ * Returns the closest rectangles from an array of rectangles to the corners of
413
+ * another rectangle.
414
+ */
415
+
416
+ const closestCorners = _ref => {
417
+ let {
418
+ collisionRect,
419
+ droppableRects,
420
+ droppableContainers
421
+ } = _ref;
422
+ const corners = cornersOfRectangle(collisionRect);
423
+ const collisions = [];
424
+
425
+ for (const droppableContainer of droppableContainers) {
426
+ const {
427
+ id
428
+ } = droppableContainer;
429
+ const rect = droppableRects.get(id);
430
+
431
+ if (rect) {
432
+ const rectCorners = cornersOfRectangle(rect);
433
+ const distances = corners.reduce((accumulator, corner, index) => {
434
+ return accumulator + distanceBetween(rectCorners[index], corner);
435
+ }, 0);
436
+ const effectiveDistance = Number((distances / 4).toFixed(4));
437
+ collisions.push({
438
+ id,
439
+ data: {
440
+ droppableContainer,
441
+ value: effectiveDistance
442
+ }
443
+ });
444
+ }
445
+ }
446
+
447
+ return collisions.sort(sortCollisionsAsc);
448
+ };
449
+
450
+ /**
451
+ * Returns the intersecting rectangle area between two rectangles
452
+ */
453
+
454
+ function getIntersectionRatio(entry, target) {
455
+ const top = Math.max(target.top, entry.top);
456
+ const left = Math.max(target.left, entry.left);
457
+ const right = Math.min(target.left + target.width, entry.left + entry.width);
458
+ const bottom = Math.min(target.top + target.height, entry.top + entry.height);
459
+ const width = right - left;
460
+ const height = bottom - top;
461
+
462
+ if (left < right && top < bottom) {
463
+ const targetArea = target.width * target.height;
464
+ const entryArea = entry.width * entry.height;
465
+ const intersectionArea = width * height;
466
+ const intersectionRatio = intersectionArea / (targetArea + entryArea - intersectionArea);
467
+ return Number(intersectionRatio.toFixed(4));
468
+ } // Rectangles do not overlap, or overlap has an area of zero (edge/corner overlap)
469
+
470
+
471
+ return 0;
472
+ }
473
+ /**
474
+ * Returns the rectangles that has the greatest intersection area with a given
475
+ * rectangle in an array of rectangles.
476
+ */
477
+
478
+ const rectIntersection = _ref => {
479
+ let {
480
+ collisionRect,
481
+ droppableRects,
482
+ droppableContainers
483
+ } = _ref;
484
+ const collisions = [];
485
+
486
+ for (const droppableContainer of droppableContainers) {
487
+ const {
488
+ id
489
+ } = droppableContainer;
490
+ const rect = droppableRects.get(id);
491
+
492
+ if (rect) {
493
+ const intersectionRatio = getIntersectionRatio(rect, collisionRect);
494
+
495
+ if (intersectionRatio > 0) {
496
+ collisions.push({
497
+ id,
498
+ data: {
499
+ droppableContainer,
500
+ value: intersectionRatio
501
+ }
502
+ });
503
+ }
504
+ }
505
+ }
506
+
507
+ return collisions.sort(sortCollisionsDesc);
508
+ };
509
+
510
+ /**
511
+ * Check if a given point is contained within a bounding rectangle
512
+ */
513
+
514
+ function isPointWithinRect(point, rect) {
515
+ const {
516
+ top,
517
+ left,
518
+ bottom,
519
+ right
520
+ } = rect;
521
+ return top <= point.y && point.y <= bottom && left <= point.x && point.x <= right;
522
+ }
523
+ /**
524
+ * Returns the rectangles that the pointer is hovering over
525
+ */
526
+
527
+
528
+ const pointerWithin = _ref => {
529
+ let {
530
+ droppableContainers,
531
+ droppableRects,
532
+ pointerCoordinates
533
+ } = _ref;
534
+
535
+ if (!pointerCoordinates) {
536
+ return [];
537
+ }
538
+
539
+ const collisions = [];
540
+
541
+ for (const droppableContainer of droppableContainers) {
542
+ const {
543
+ id
544
+ } = droppableContainer;
545
+ const rect = droppableRects.get(id);
546
+
547
+ if (rect && isPointWithinRect(pointerCoordinates, rect)) {
548
+ /* There may be more than a single rectangle intersecting
549
+ * with the pointer coordinates. In order to sort the
550
+ * colliding rectangles, we measure the distance between
551
+ * the pointer and the corners of the intersecting rectangle
552
+ */
553
+ const corners = cornersOfRectangle(rect);
554
+ const distances = corners.reduce((accumulator, corner) => {
555
+ return accumulator + distanceBetween(pointerCoordinates, corner);
556
+ }, 0);
557
+ const effectiveDistance = Number((distances / 4).toFixed(4));
558
+ collisions.push({
559
+ id,
560
+ data: {
561
+ droppableContainer,
562
+ value: effectiveDistance
563
+ }
564
+ });
565
+ }
566
+ }
567
+
568
+ return collisions.sort(sortCollisionsAsc);
569
+ };
570
+
571
+ function adjustScale(transform, rect1, rect2) {
572
+ return { ...transform,
573
+ scaleX: rect1 && rect2 ? rect1.width / rect2.width : 1,
574
+ scaleY: rect1 && rect2 ? rect1.height / rect2.height : 1
575
+ };
576
+ }
577
+
578
+ function getRectDelta(rect1, rect2) {
579
+ return rect1 && rect2 ? {
580
+ x: rect1.left - rect2.left,
581
+ y: rect1.top - rect2.top
582
+ } : defaultCoordinates;
583
+ }
584
+
585
+ function createRectAdjustmentFn(modifier) {
586
+ return function adjustClientRect(rect) {
587
+ for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
588
+ adjustments[_key - 1] = arguments[_key];
589
+ }
590
+
591
+ return adjustments.reduce((acc, adjustment) => ({ ...acc,
592
+ top: acc.top + modifier * adjustment.y,
593
+ bottom: acc.bottom + modifier * adjustment.y,
594
+ left: acc.left + modifier * adjustment.x,
595
+ right: acc.right + modifier * adjustment.x
596
+ }), { ...rect
597
+ });
598
+ };
599
+ }
600
+ const getAdjustedRect = /*#__PURE__*/createRectAdjustmentFn(1);
601
+
602
+ function parseTransform(transform) {
603
+ if (transform.startsWith('matrix3d(')) {
604
+ const transformArray = transform.slice(9, -1).split(/, /);
605
+ return {
606
+ x: +transformArray[12],
607
+ y: +transformArray[13],
608
+ scaleX: +transformArray[0],
609
+ scaleY: +transformArray[5]
610
+ };
611
+ } else if (transform.startsWith('matrix(')) {
612
+ const transformArray = transform.slice(7, -1).split(/, /);
613
+ return {
614
+ x: +transformArray[4],
615
+ y: +transformArray[5],
616
+ scaleX: +transformArray[0],
617
+ scaleY: +transformArray[3]
618
+ };
619
+ }
620
+
621
+ return null;
622
+ }
623
+
624
+ function inverseTransform(rect, transform, transformOrigin) {
625
+ const parsedTransform = parseTransform(transform);
626
+
627
+ if (!parsedTransform) {
628
+ return rect;
629
+ }
630
+
631
+ const {
632
+ scaleX,
633
+ scaleY,
634
+ x: translateX,
635
+ y: translateY
636
+ } = parsedTransform;
637
+ const x = rect.left - translateX - (1 - scaleX) * parseFloat(transformOrigin);
638
+ const y = rect.top - translateY - (1 - scaleY) * parseFloat(transformOrigin.slice(transformOrigin.indexOf(' ') + 1));
639
+ const w = scaleX ? rect.width / scaleX : rect.width;
640
+ const h = scaleY ? rect.height / scaleY : rect.height;
641
+ return {
642
+ width: w,
643
+ height: h,
644
+ top: y,
645
+ right: x + w,
646
+ bottom: y + h,
647
+ left: x
648
+ };
649
+ }
650
+
651
+ const defaultOptions = {
652
+ ignoreTransform: false
653
+ };
654
+ /**
655
+ * Returns the bounding client rect of an element relative to the viewport.
656
+ */
657
+
658
+ function getClientRect(element, options) {
659
+ if (options === void 0) {
660
+ options = defaultOptions;
661
+ }
662
+
663
+ let rect = element.getBoundingClientRect();
664
+
665
+ if (options.ignoreTransform) {
666
+ const {
667
+ transform,
668
+ transformOrigin
669
+ } = getWindow(element).getComputedStyle(element);
670
+
671
+ if (transform) {
672
+ rect = inverseTransform(rect, transform, transformOrigin);
673
+ }
674
+ }
675
+
676
+ const {
677
+ top,
678
+ left,
679
+ width,
680
+ height,
681
+ bottom,
682
+ right
683
+ } = rect;
684
+ return {
685
+ top,
686
+ left,
687
+ width,
688
+ height,
689
+ bottom,
690
+ right
691
+ };
692
+ }
693
+ /**
694
+ * Returns the bounding client rect of an element relative to the viewport.
695
+ *
696
+ * @remarks
697
+ * The ClientRect returned by this method does not take into account transforms
698
+ * applied to the element it measures.
699
+ *
700
+ */
701
+
702
+ function getTransformAgnosticClientRect(element) {
703
+ return getClientRect(element, {
704
+ ignoreTransform: true
705
+ });
706
+ }
707
+
708
+ function getWindowClientRect(element) {
709
+ const width = element.innerWidth;
710
+ const height = element.innerHeight;
711
+ return {
712
+ top: 0,
713
+ left: 0,
714
+ right: width,
715
+ bottom: height,
716
+ width,
717
+ height
718
+ };
719
+ }
720
+
721
+ function isFixed(node, computedStyle) {
722
+ if (computedStyle === void 0) {
723
+ computedStyle = getWindow(node).getComputedStyle(node);
724
+ }
725
+
726
+ return computedStyle.position === 'fixed';
727
+ }
728
+
729
+ function isScrollable(element, computedStyle) {
730
+ if (computedStyle === void 0) {
731
+ computedStyle = getWindow(element).getComputedStyle(element);
732
+ }
733
+
734
+ const overflowRegex = /(auto|scroll|overlay)/;
735
+ const properties = ['overflow', 'overflowX', 'overflowY'];
736
+ return properties.some(property => {
737
+ const value = computedStyle[property];
738
+ return typeof value === 'string' ? overflowRegex.test(value) : false;
739
+ });
740
+ }
741
+
742
+ function getScrollableAncestors(element, limit) {
743
+ const scrollParents = [];
744
+
745
+ function findScrollableAncestors(node) {
746
+ if (limit != null && scrollParents.length >= limit) {
747
+ return scrollParents;
748
+ }
749
+
750
+ if (!node) {
751
+ return scrollParents;
752
+ }
753
+
754
+ if (isDocument(node) && node.scrollingElement != null && !scrollParents.includes(node.scrollingElement)) {
755
+ scrollParents.push(node.scrollingElement);
756
+ return scrollParents;
757
+ }
758
+
759
+ if (!isHTMLElement(node) || isSVGElement(node)) {
760
+ return scrollParents;
761
+ }
762
+
763
+ if (scrollParents.includes(node)) {
764
+ return scrollParents;
765
+ }
766
+
767
+ const computedStyle = getWindow(element).getComputedStyle(node);
768
+
769
+ if (node !== element) {
770
+ if (isScrollable(node, computedStyle)) {
771
+ scrollParents.push(node);
772
+ }
773
+ }
774
+
775
+ if (isFixed(node, computedStyle)) {
776
+ return scrollParents;
777
+ }
778
+
779
+ return findScrollableAncestors(node.parentNode);
780
+ }
781
+
782
+ if (!element) {
783
+ return scrollParents;
784
+ }
785
+
786
+ return findScrollableAncestors(element);
787
+ }
788
+ function getFirstScrollableAncestor(node) {
789
+ const [firstScrollableAncestor] = getScrollableAncestors(node, 1);
790
+ return firstScrollableAncestor != null ? firstScrollableAncestor : null;
791
+ }
792
+
793
+ function getScrollableElement(element) {
794
+ if (!canUseDOM || !element) {
795
+ return null;
796
+ }
797
+
798
+ if (isWindow(element)) {
799
+ return element;
800
+ }
801
+
802
+ if (!isNode(element)) {
803
+ return null;
804
+ }
805
+
806
+ if (isDocument(element) || element === getOwnerDocument(element).scrollingElement) {
807
+ return window;
808
+ }
809
+
810
+ if (isHTMLElement(element)) {
811
+ return element;
812
+ }
813
+
814
+ return null;
815
+ }
816
+
817
+ function getScrollXCoordinate(element) {
818
+ if (isWindow(element)) {
819
+ return element.scrollX;
820
+ }
821
+
822
+ return element.scrollLeft;
823
+ }
824
+ function getScrollYCoordinate(element) {
825
+ if (isWindow(element)) {
826
+ return element.scrollY;
827
+ }
828
+
829
+ return element.scrollTop;
830
+ }
831
+ function getScrollCoordinates(element) {
832
+ return {
833
+ x: getScrollXCoordinate(element),
834
+ y: getScrollYCoordinate(element)
835
+ };
836
+ }
837
+
838
+ var Direction;
839
+
840
+ (function (Direction) {
841
+ Direction[Direction["Forward"] = 1] = "Forward";
842
+ Direction[Direction["Backward"] = -1] = "Backward";
843
+ })(Direction || (Direction = {}));
844
+
845
+ function isDocumentScrollingElement(element) {
846
+ if (!canUseDOM || !element) {
847
+ return false;
848
+ }
849
+
850
+ return element === document.scrollingElement;
851
+ }
852
+
853
+ function getScrollPosition(scrollingContainer) {
854
+ const minScroll = {
855
+ x: 0,
856
+ y: 0
857
+ };
858
+ const dimensions = isDocumentScrollingElement(scrollingContainer) ? {
859
+ height: window.innerHeight,
860
+ width: window.innerWidth
861
+ } : {
862
+ height: scrollingContainer.clientHeight,
863
+ width: scrollingContainer.clientWidth
864
+ };
865
+ const maxScroll = {
866
+ x: scrollingContainer.scrollWidth - dimensions.width,
867
+ y: scrollingContainer.scrollHeight - dimensions.height
868
+ };
869
+ const isTop = scrollingContainer.scrollTop <= minScroll.y;
870
+ const isLeft = scrollingContainer.scrollLeft <= minScroll.x;
871
+ const isBottom = scrollingContainer.scrollTop >= maxScroll.y;
872
+ const isRight = scrollingContainer.scrollLeft >= maxScroll.x;
873
+ return {
874
+ isTop,
875
+ isLeft,
876
+ isBottom,
877
+ isRight,
878
+ maxScroll,
879
+ minScroll
880
+ };
881
+ }
882
+
883
+ const defaultThreshold = {
884
+ x: 0.2,
885
+ y: 0.2
886
+ };
887
+ function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, _ref, acceleration, thresholdPercentage) {
888
+ let {
889
+ top,
890
+ left,
891
+ right,
892
+ bottom
893
+ } = _ref;
894
+
895
+ if (acceleration === void 0) {
896
+ acceleration = 10;
897
+ }
898
+
899
+ if (thresholdPercentage === void 0) {
900
+ thresholdPercentage = defaultThreshold;
901
+ }
902
+
903
+ const {
904
+ isTop,
905
+ isBottom,
906
+ isLeft,
907
+ isRight
908
+ } = getScrollPosition(scrollContainer);
909
+ const direction = {
910
+ x: 0,
911
+ y: 0
912
+ };
913
+ const speed = {
914
+ x: 0,
915
+ y: 0
916
+ };
917
+ const threshold = {
918
+ height: scrollContainerRect.height * thresholdPercentage.y,
919
+ width: scrollContainerRect.width * thresholdPercentage.x
920
+ };
921
+
922
+ if (!isTop && top <= scrollContainerRect.top + threshold.height) {
923
+ // Scroll Up
924
+ direction.y = Direction.Backward;
925
+ speed.y = acceleration * Math.abs((scrollContainerRect.top + threshold.height - top) / threshold.height);
926
+ } else if (!isBottom && bottom >= scrollContainerRect.bottom - threshold.height) {
927
+ // Scroll Down
928
+ direction.y = Direction.Forward;
929
+ speed.y = acceleration * Math.abs((scrollContainerRect.bottom - threshold.height - bottom) / threshold.height);
930
+ }
931
+
932
+ if (!isRight && right >= scrollContainerRect.right - threshold.width) {
933
+ // Scroll Right
934
+ direction.x = Direction.Forward;
935
+ speed.x = acceleration * Math.abs((scrollContainerRect.right - threshold.width - right) / threshold.width);
936
+ } else if (!isLeft && left <= scrollContainerRect.left + threshold.width) {
937
+ // Scroll Left
938
+ direction.x = Direction.Backward;
939
+ speed.x = acceleration * Math.abs((scrollContainerRect.left + threshold.width - left) / threshold.width);
940
+ }
941
+
942
+ return {
943
+ direction,
944
+ speed
945
+ };
946
+ }
947
+
948
+ function getScrollElementRect(element) {
949
+ if (element === document.scrollingElement) {
950
+ const {
951
+ innerWidth,
952
+ innerHeight
953
+ } = window;
954
+ return {
955
+ top: 0,
956
+ left: 0,
957
+ right: innerWidth,
958
+ bottom: innerHeight,
959
+ width: innerWidth,
960
+ height: innerHeight
961
+ };
962
+ }
963
+
964
+ const {
965
+ top,
966
+ left,
967
+ right,
968
+ bottom
969
+ } = element.getBoundingClientRect();
970
+ return {
971
+ top,
972
+ left,
973
+ right,
974
+ bottom,
975
+ width: element.clientWidth,
976
+ height: element.clientHeight
977
+ };
978
+ }
979
+
980
+ function getScrollOffsets(scrollableAncestors) {
981
+ return scrollableAncestors.reduce((acc, node) => {
982
+ return add(acc, getScrollCoordinates(node));
983
+ }, defaultCoordinates);
984
+ }
985
+ function getScrollXOffset(scrollableAncestors) {
986
+ return scrollableAncestors.reduce((acc, node) => {
987
+ return acc + getScrollXCoordinate(node);
988
+ }, 0);
989
+ }
990
+ function getScrollYOffset(scrollableAncestors) {
991
+ return scrollableAncestors.reduce((acc, node) => {
992
+ return acc + getScrollYCoordinate(node);
993
+ }, 0);
994
+ }
995
+
996
+ function scrollIntoViewIfNeeded(element, measure) {
997
+ if (measure === void 0) {
998
+ measure = getClientRect;
999
+ }
1000
+
1001
+ if (!element) {
1002
+ return;
1003
+ }
1004
+
1005
+ const {
1006
+ top,
1007
+ left,
1008
+ bottom,
1009
+ right
1010
+ } = measure(element);
1011
+ const firstScrollableAncestor = getFirstScrollableAncestor(element);
1012
+
1013
+ if (!firstScrollableAncestor) {
1014
+ return;
1015
+ }
1016
+
1017
+ if (bottom <= 0 || right <= 0 || top >= window.innerHeight || left >= window.innerWidth) {
1018
+ element.scrollIntoView({
1019
+ block: 'center',
1020
+ inline: 'center'
1021
+ });
1022
+ }
1023
+ }
1024
+
1025
+ const properties = [['x', ['left', 'right'], getScrollXOffset], ['y', ['top', 'bottom'], getScrollYOffset]];
1026
+ class Rect {
1027
+ constructor(rect, element) {
1028
+ this.rect = void 0;
1029
+ this.width = void 0;
1030
+ this.height = void 0;
1031
+ this.top = void 0;
1032
+ this.bottom = void 0;
1033
+ this.right = void 0;
1034
+ this.left = void 0;
1035
+ const scrollableAncestors = getScrollableAncestors(element);
1036
+ const scrollOffsets = getScrollOffsets(scrollableAncestors);
1037
+ this.rect = { ...rect
1038
+ };
1039
+ this.width = rect.width;
1040
+ this.height = rect.height;
1041
+
1042
+ for (const [axis, keys, getScrollOffset] of properties) {
1043
+ for (const key of keys) {
1044
+ Object.defineProperty(this, key, {
1045
+ get: () => {
1046
+ const currentOffsets = getScrollOffset(scrollableAncestors);
1047
+ const scrollOffsetsDeltla = scrollOffsets[axis] - currentOffsets;
1048
+ return this.rect[key] + scrollOffsetsDeltla;
1049
+ },
1050
+ enumerable: true
1051
+ });
1052
+ }
1053
+ }
1054
+
1055
+ Object.defineProperty(this, 'rect', {
1056
+ enumerable: false
1057
+ });
1058
+ }
1059
+
1060
+ }
1061
+
1062
+ class Listeners {
1063
+ constructor(target) {
1064
+ this.target = void 0;
1065
+ this.listeners = [];
1066
+
1067
+ this.removeAll = () => {
1068
+ this.listeners.forEach(listener => {
1069
+ var _this$target;
1070
+
1071
+ return (_this$target = this.target) == null ? void 0 : _this$target.removeEventListener(...listener);
1072
+ });
1073
+ };
1074
+
1075
+ this.target = target;
1076
+ }
1077
+
1078
+ add(eventName, handler, options) {
1079
+ var _this$target2;
1080
+
1081
+ (_this$target2 = this.target) == null ? void 0 : _this$target2.addEventListener(eventName, handler, options);
1082
+ this.listeners.push([eventName, handler, options]);
1083
+ }
1084
+
1085
+ }
1086
+
1087
+ function getEventListenerTarget(target) {
1088
+ // If the `event.target` element is removed from the document events will still be targeted
1089
+ // at it, and hence won't always bubble up to the window or document anymore.
1090
+ // If there is any risk of an element being removed while it is being dragged,
1091
+ // the best practice is to attach the event listeners directly to the target.
1092
+ // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
1093
+ const {
1094
+ EventTarget
1095
+ } = getWindow(target);
1096
+ return target instanceof EventTarget ? target : getOwnerDocument(target);
1097
+ }
1098
+
1099
+ function hasExceededDistance(delta, measurement) {
1100
+ const dx = Math.abs(delta.x);
1101
+ const dy = Math.abs(delta.y);
1102
+
1103
+ if (typeof measurement === 'number') {
1104
+ return Math.sqrt(dx ** 2 + dy ** 2) > measurement;
1105
+ }
1106
+
1107
+ if ('x' in measurement && 'y' in measurement) {
1108
+ return dx > measurement.x && dy > measurement.y;
1109
+ }
1110
+
1111
+ if ('x' in measurement) {
1112
+ return dx > measurement.x;
1113
+ }
1114
+
1115
+ if ('y' in measurement) {
1116
+ return dy > measurement.y;
1117
+ }
1118
+
1119
+ return false;
1120
+ }
1121
+
1122
+ var EventName;
1123
+
1124
+ (function (EventName) {
1125
+ EventName["Click"] = "click";
1126
+ EventName["DragStart"] = "dragstart";
1127
+ EventName["Keydown"] = "keydown";
1128
+ EventName["ContextMenu"] = "contextmenu";
1129
+ EventName["Resize"] = "resize";
1130
+ EventName["SelectionChange"] = "selectionchange";
1131
+ EventName["VisibilityChange"] = "visibilitychange";
1132
+ })(EventName || (EventName = {}));
1133
+
1134
+ function preventDefault(event) {
1135
+ event.preventDefault();
1136
+ }
1137
+ function stopPropagation(event) {
1138
+ event.stopPropagation();
1139
+ }
1140
+
1141
+ var KeyboardCode;
1142
+
1143
+ (function (KeyboardCode) {
1144
+ KeyboardCode["Space"] = "Space";
1145
+ KeyboardCode["Down"] = "ArrowDown";
1146
+ KeyboardCode["Right"] = "ArrowRight";
1147
+ KeyboardCode["Left"] = "ArrowLeft";
1148
+ KeyboardCode["Up"] = "ArrowUp";
1149
+ KeyboardCode["Esc"] = "Escape";
1150
+ KeyboardCode["Enter"] = "Enter";
1151
+ KeyboardCode["Tab"] = "Tab";
1152
+ })(KeyboardCode || (KeyboardCode = {}));
1153
+
1154
+ const defaultKeyboardCodes = {
1155
+ start: [KeyboardCode.Space, KeyboardCode.Enter],
1156
+ cancel: [KeyboardCode.Esc],
1157
+ end: [KeyboardCode.Space, KeyboardCode.Enter, KeyboardCode.Tab]
1158
+ };
1159
+ const defaultKeyboardCoordinateGetter = (event, _ref) => {
1160
+ let {
1161
+ currentCoordinates
1162
+ } = _ref;
1163
+
1164
+ switch (event.code) {
1165
+ case KeyboardCode.Right:
1166
+ return { ...currentCoordinates,
1167
+ x: currentCoordinates.x + 25
1168
+ };
1169
+
1170
+ case KeyboardCode.Left:
1171
+ return { ...currentCoordinates,
1172
+ x: currentCoordinates.x - 25
1173
+ };
1174
+
1175
+ case KeyboardCode.Down:
1176
+ return { ...currentCoordinates,
1177
+ y: currentCoordinates.y + 25
1178
+ };
1179
+
1180
+ case KeyboardCode.Up:
1181
+ return { ...currentCoordinates,
1182
+ y: currentCoordinates.y - 25
1183
+ };
1184
+ }
1185
+
1186
+ return undefined;
1187
+ };
1188
+
1189
+ class KeyboardSensor {
1190
+ constructor(props) {
1191
+ this.props = void 0;
1192
+ this.autoScrollEnabled = false;
1193
+ this.referenceCoordinates = void 0;
1194
+ this.listeners = void 0;
1195
+ this.windowListeners = void 0;
1196
+ this.props = props;
1197
+ const {
1198
+ event: {
1199
+ target
1200
+ }
1201
+ } = props;
1202
+ this.props = props;
1203
+ this.listeners = new Listeners(getOwnerDocument(target));
1204
+ this.windowListeners = new Listeners(getWindow(target));
1205
+ this.handleKeyDown = this.handleKeyDown.bind(this);
1206
+ this.handleCancel = this.handleCancel.bind(this);
1207
+ this.attach();
1208
+ }
1209
+
1210
+ attach() {
1211
+ this.handleStart();
1212
+ this.windowListeners.add(EventName.Resize, this.handleCancel);
1213
+ this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
1214
+ setTimeout(() => this.listeners.add(EventName.Keydown, this.handleKeyDown));
1215
+ }
1216
+
1217
+ handleStart() {
1218
+ const {
1219
+ activeNode,
1220
+ onStart
1221
+ } = this.props;
1222
+ const node = activeNode.node.current;
1223
+
1224
+ if (node) {
1225
+ scrollIntoViewIfNeeded(node);
1226
+ }
1227
+
1228
+ onStart(defaultCoordinates);
1229
+ }
1230
+
1231
+ handleKeyDown(event) {
1232
+ if (isKeyboardEvent(event)) {
1233
+ const {
1234
+ active,
1235
+ context,
1236
+ options
1237
+ } = this.props;
1238
+ const {
1239
+ keyboardCodes = defaultKeyboardCodes,
1240
+ coordinateGetter = defaultKeyboardCoordinateGetter,
1241
+ scrollBehavior = 'smooth'
1242
+ } = options;
1243
+ const {
1244
+ code
1245
+ } = event;
1246
+
1247
+ if (keyboardCodes.end.includes(code)) {
1248
+ this.handleEnd(event);
1249
+ return;
1250
+ }
1251
+
1252
+ if (keyboardCodes.cancel.includes(code)) {
1253
+ this.handleCancel(event);
1254
+ return;
1255
+ }
1256
+
1257
+ const {
1258
+ collisionRect
1259
+ } = context.current;
1260
+ const currentCoordinates = collisionRect ? {
1261
+ x: collisionRect.left,
1262
+ y: collisionRect.top
1263
+ } : defaultCoordinates;
1264
+
1265
+ if (!this.referenceCoordinates) {
1266
+ this.referenceCoordinates = currentCoordinates;
1267
+ }
1268
+
1269
+ const newCoordinates = coordinateGetter(event, {
1270
+ active,
1271
+ context: context.current,
1272
+ currentCoordinates
1273
+ });
1274
+
1275
+ if (newCoordinates) {
1276
+ const coordinatesDelta = subtract(newCoordinates, currentCoordinates);
1277
+ const scrollDelta = {
1278
+ x: 0,
1279
+ y: 0
1280
+ };
1281
+ const {
1282
+ scrollableAncestors
1283
+ } = context.current;
1284
+
1285
+ for (const scrollContainer of scrollableAncestors) {
1286
+ const direction = event.code;
1287
+ const {
1288
+ isTop,
1289
+ isRight,
1290
+ isLeft,
1291
+ isBottom,
1292
+ maxScroll,
1293
+ minScroll
1294
+ } = getScrollPosition(scrollContainer);
1295
+ const scrollElementRect = getScrollElementRect(scrollContainer);
1296
+ const clampedCoordinates = {
1297
+ x: Math.min(direction === KeyboardCode.Right ? scrollElementRect.right - scrollElementRect.width / 2 : scrollElementRect.right, Math.max(direction === KeyboardCode.Right ? scrollElementRect.left : scrollElementRect.left + scrollElementRect.width / 2, newCoordinates.x)),
1298
+ y: Math.min(direction === KeyboardCode.Down ? scrollElementRect.bottom - scrollElementRect.height / 2 : scrollElementRect.bottom, Math.max(direction === KeyboardCode.Down ? scrollElementRect.top : scrollElementRect.top + scrollElementRect.height / 2, newCoordinates.y))
1299
+ };
1300
+ const canScrollX = direction === KeyboardCode.Right && !isRight || direction === KeyboardCode.Left && !isLeft;
1301
+ const canScrollY = direction === KeyboardCode.Down && !isBottom || direction === KeyboardCode.Up && !isTop;
1302
+
1303
+ if (canScrollX && clampedCoordinates.x !== newCoordinates.x) {
1304
+ const newScrollCoordinates = scrollContainer.scrollLeft + coordinatesDelta.x;
1305
+ const canScrollToNewCoordinates = direction === KeyboardCode.Right && newScrollCoordinates <= maxScroll.x || direction === KeyboardCode.Left && newScrollCoordinates >= minScroll.x;
1306
+
1307
+ if (canScrollToNewCoordinates && !coordinatesDelta.y) {
1308
+ // We don't need to update coordinates, the scroll adjustment alone will trigger
1309
+ // logic to auto-detect the new container we are over
1310
+ scrollContainer.scrollTo({
1311
+ left: newScrollCoordinates,
1312
+ behavior: scrollBehavior
1313
+ });
1314
+ return;
1315
+ }
1316
+
1317
+ if (canScrollToNewCoordinates) {
1318
+ scrollDelta.x = scrollContainer.scrollLeft - newScrollCoordinates;
1319
+ } else {
1320
+ scrollDelta.x = direction === KeyboardCode.Right ? scrollContainer.scrollLeft - maxScroll.x : scrollContainer.scrollLeft - minScroll.x;
1321
+ }
1322
+
1323
+ if (scrollDelta.x) {
1324
+ scrollContainer.scrollBy({
1325
+ left: -scrollDelta.x,
1326
+ behavior: scrollBehavior
1327
+ });
1328
+ }
1329
+
1330
+ break;
1331
+ } else if (canScrollY && clampedCoordinates.y !== newCoordinates.y) {
1332
+ const newScrollCoordinates = scrollContainer.scrollTop + coordinatesDelta.y;
1333
+ const canScrollToNewCoordinates = direction === KeyboardCode.Down && newScrollCoordinates <= maxScroll.y || direction === KeyboardCode.Up && newScrollCoordinates >= minScroll.y;
1334
+
1335
+ if (canScrollToNewCoordinates && !coordinatesDelta.x) {
1336
+ // We don't need to update coordinates, the scroll adjustment alone will trigger
1337
+ // logic to auto-detect the new container we are over
1338
+ scrollContainer.scrollTo({
1339
+ top: newScrollCoordinates,
1340
+ behavior: scrollBehavior
1341
+ });
1342
+ return;
1343
+ }
1344
+
1345
+ if (canScrollToNewCoordinates) {
1346
+ scrollDelta.y = scrollContainer.scrollTop - newScrollCoordinates;
1347
+ } else {
1348
+ scrollDelta.y = direction === KeyboardCode.Down ? scrollContainer.scrollTop - maxScroll.y : scrollContainer.scrollTop - minScroll.y;
1349
+ }
1350
+
1351
+ if (scrollDelta.y) {
1352
+ scrollContainer.scrollBy({
1353
+ top: -scrollDelta.y,
1354
+ behavior: scrollBehavior
1355
+ });
1356
+ }
1357
+
1358
+ break;
1359
+ }
1360
+ }
1361
+
1362
+ this.handleMove(event, add(subtract(newCoordinates, this.referenceCoordinates), scrollDelta));
1363
+ }
1364
+ }
1365
+ }
1366
+
1367
+ handleMove(event, coordinates) {
1368
+ const {
1369
+ onMove
1370
+ } = this.props;
1371
+ event.preventDefault();
1372
+ onMove(coordinates);
1373
+ }
1374
+
1375
+ handleEnd(event) {
1376
+ const {
1377
+ onEnd
1378
+ } = this.props;
1379
+ event.preventDefault();
1380
+ this.detach();
1381
+ onEnd();
1382
+ }
1383
+
1384
+ handleCancel(event) {
1385
+ const {
1386
+ onCancel
1387
+ } = this.props;
1388
+ event.preventDefault();
1389
+ this.detach();
1390
+ onCancel();
1391
+ }
1392
+
1393
+ detach() {
1394
+ this.listeners.removeAll();
1395
+ this.windowListeners.removeAll();
1396
+ }
1397
+
1398
+ }
1399
+ KeyboardSensor.activators = [{
1400
+ eventName: 'onKeyDown',
1401
+ handler: (event, _ref, _ref2) => {
1402
+ let {
1403
+ keyboardCodes = defaultKeyboardCodes,
1404
+ onActivation
1405
+ } = _ref;
1406
+ let {
1407
+ active
1408
+ } = _ref2;
1409
+ const {
1410
+ code
1411
+ } = event.nativeEvent;
1412
+
1413
+ if (keyboardCodes.start.includes(code)) {
1414
+ const activator = active.activatorNode.current;
1415
+
1416
+ if (activator && event.target !== activator) {
1417
+ return false;
1418
+ }
1419
+
1420
+ event.preventDefault();
1421
+ onActivation == null ? void 0 : onActivation({
1422
+ event: event.nativeEvent
1423
+ });
1424
+ return true;
1425
+ }
1426
+
1427
+ return false;
1428
+ }
1429
+ }];
1430
+
1431
+ function isDistanceConstraint(constraint) {
1432
+ return Boolean(constraint && 'distance' in constraint);
1433
+ }
1434
+
1435
+ function isDelayConstraint(constraint) {
1436
+ return Boolean(constraint && 'delay' in constraint);
1437
+ }
1438
+
1439
+ class AbstractPointerSensor {
1440
+ constructor(props, events, listenerTarget) {
1441
+ var _getEventCoordinates;
1442
+
1443
+ if (listenerTarget === void 0) {
1444
+ listenerTarget = getEventListenerTarget(props.event.target);
1445
+ }
1446
+
1447
+ this.props = void 0;
1448
+ this.events = void 0;
1449
+ this.autoScrollEnabled = true;
1450
+ this.document = void 0;
1451
+ this.activated = false;
1452
+ this.initialCoordinates = void 0;
1453
+ this.timeoutId = null;
1454
+ this.listeners = void 0;
1455
+ this.documentListeners = void 0;
1456
+ this.windowListeners = void 0;
1457
+ this.props = props;
1458
+ this.events = events;
1459
+ const {
1460
+ event
1461
+ } = props;
1462
+ const {
1463
+ target
1464
+ } = event;
1465
+ this.props = props;
1466
+ this.events = events;
1467
+ this.document = getOwnerDocument(target);
1468
+ this.documentListeners = new Listeners(this.document);
1469
+ this.listeners = new Listeners(listenerTarget);
1470
+ this.windowListeners = new Listeners(getWindow(target));
1471
+ this.initialCoordinates = (_getEventCoordinates = getEventCoordinates(event)) != null ? _getEventCoordinates : defaultCoordinates;
1472
+ this.handleStart = this.handleStart.bind(this);
1473
+ this.handleMove = this.handleMove.bind(this);
1474
+ this.handleEnd = this.handleEnd.bind(this);
1475
+ this.handleCancel = this.handleCancel.bind(this);
1476
+ this.handleKeydown = this.handleKeydown.bind(this);
1477
+ this.removeTextSelection = this.removeTextSelection.bind(this);
1478
+ this.attach();
1479
+ }
1480
+
1481
+ attach() {
1482
+ const {
1483
+ events,
1484
+ props: {
1485
+ options: {
1486
+ activationConstraint,
1487
+ bypassActivationConstraint
1488
+ }
1489
+ }
1490
+ } = this;
1491
+ this.listeners.add(events.move.name, this.handleMove, {
1492
+ passive: false
1493
+ });
1494
+ this.listeners.add(events.end.name, this.handleEnd);
1495
+
1496
+ if (events.cancel) {
1497
+ this.listeners.add(events.cancel.name, this.handleCancel);
1498
+ }
1499
+
1500
+ this.windowListeners.add(EventName.Resize, this.handleCancel);
1501
+ this.windowListeners.add(EventName.DragStart, preventDefault);
1502
+ this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
1503
+ this.windowListeners.add(EventName.ContextMenu, preventDefault);
1504
+ this.documentListeners.add(EventName.Keydown, this.handleKeydown);
1505
+
1506
+ if (activationConstraint) {
1507
+ if (bypassActivationConstraint != null && bypassActivationConstraint({
1508
+ event: this.props.event,
1509
+ activeNode: this.props.activeNode,
1510
+ options: this.props.options
1511
+ })) {
1512
+ return this.handleStart();
1513
+ }
1514
+
1515
+ if (isDelayConstraint(activationConstraint)) {
1516
+ this.timeoutId = setTimeout(this.handleStart, activationConstraint.delay);
1517
+ this.handlePending(activationConstraint);
1518
+ return;
1519
+ }
1520
+
1521
+ if (isDistanceConstraint(activationConstraint)) {
1522
+ this.handlePending(activationConstraint);
1523
+ return;
1524
+ }
1525
+ }
1526
+
1527
+ this.handleStart();
1528
+ }
1529
+
1530
+ detach() {
1531
+ this.listeners.removeAll();
1532
+ this.windowListeners.removeAll(); // Wait until the next event loop before removing document listeners
1533
+ // This is necessary because we listen for `click` and `selection` events on the document
1534
+
1535
+ setTimeout(this.documentListeners.removeAll, 50);
1536
+
1537
+ if (this.timeoutId !== null) {
1538
+ clearTimeout(this.timeoutId);
1539
+ this.timeoutId = null;
1540
+ }
1541
+ }
1542
+
1543
+ handlePending(constraint, offset) {
1544
+ const {
1545
+ active,
1546
+ onPending
1547
+ } = this.props;
1548
+ onPending(active, constraint, this.initialCoordinates, offset);
1549
+ }
1550
+
1551
+ handleStart() {
1552
+ const {
1553
+ initialCoordinates
1554
+ } = this;
1555
+ const {
1556
+ onStart
1557
+ } = this.props;
1558
+
1559
+ if (initialCoordinates) {
1560
+ this.activated = true; // Stop propagation of click events once activation constraints are met
1561
+
1562
+ this.documentListeners.add(EventName.Click, stopPropagation, {
1563
+ capture: true
1564
+ }); // Remove any text selection from the document
1565
+
1566
+ this.removeTextSelection(); // Prevent further text selection while dragging
1567
+
1568
+ this.documentListeners.add(EventName.SelectionChange, this.removeTextSelection);
1569
+ onStart(initialCoordinates);
1570
+ }
1571
+ }
1572
+
1573
+ handleMove(event) {
1574
+ var _getEventCoordinates2;
1575
+
1576
+ const {
1577
+ activated,
1578
+ initialCoordinates,
1579
+ props
1580
+ } = this;
1581
+ const {
1582
+ onMove,
1583
+ options: {
1584
+ activationConstraint
1585
+ }
1586
+ } = props;
1587
+
1588
+ if (!initialCoordinates) {
1589
+ return;
1590
+ }
1591
+
1592
+ const coordinates = (_getEventCoordinates2 = getEventCoordinates(event)) != null ? _getEventCoordinates2 : defaultCoordinates;
1593
+ const delta = subtract(initialCoordinates, coordinates); // Constraint validation
1594
+
1595
+ if (!activated && activationConstraint) {
1596
+ if (isDistanceConstraint(activationConstraint)) {
1597
+ if (activationConstraint.tolerance != null && hasExceededDistance(delta, activationConstraint.tolerance)) {
1598
+ return this.handleCancel();
1599
+ }
1600
+
1601
+ if (hasExceededDistance(delta, activationConstraint.distance)) {
1602
+ return this.handleStart();
1603
+ }
1604
+ }
1605
+
1606
+ if (isDelayConstraint(activationConstraint)) {
1607
+ if (hasExceededDistance(delta, activationConstraint.tolerance)) {
1608
+ return this.handleCancel();
1609
+ }
1610
+ }
1611
+
1612
+ this.handlePending(activationConstraint, delta);
1613
+ return;
1614
+ }
1615
+
1616
+ if (event.cancelable) {
1617
+ event.preventDefault();
1618
+ }
1619
+
1620
+ onMove(coordinates);
1621
+ }
1622
+
1623
+ handleEnd() {
1624
+ const {
1625
+ onAbort,
1626
+ onEnd
1627
+ } = this.props;
1628
+ this.detach();
1629
+
1630
+ if (!this.activated) {
1631
+ onAbort(this.props.active);
1632
+ }
1633
+
1634
+ onEnd();
1635
+ }
1636
+
1637
+ handleCancel() {
1638
+ const {
1639
+ onAbort,
1640
+ onCancel
1641
+ } = this.props;
1642
+ this.detach();
1643
+
1644
+ if (!this.activated) {
1645
+ onAbort(this.props.active);
1646
+ }
1647
+
1648
+ onCancel();
1649
+ }
1650
+
1651
+ handleKeydown(event) {
1652
+ if (event.code === KeyboardCode.Esc) {
1653
+ this.handleCancel();
1654
+ }
1655
+ }
1656
+
1657
+ removeTextSelection() {
1658
+ var _this$document$getSel;
1659
+
1660
+ (_this$document$getSel = this.document.getSelection()) == null ? void 0 : _this$document$getSel.removeAllRanges();
1661
+ }
1662
+
1663
+ }
1664
+
1665
+ const events = {
1666
+ cancel: {
1667
+ name: 'pointercancel'
1668
+ },
1669
+ move: {
1670
+ name: 'pointermove'
1671
+ },
1672
+ end: {
1673
+ name: 'pointerup'
1674
+ }
1675
+ };
1676
+ class PointerSensor extends AbstractPointerSensor {
1677
+ constructor(props) {
1678
+ const {
1679
+ event
1680
+ } = props; // Pointer events stop firing if the target is unmounted while dragging
1681
+ // Therefore we attach listeners to the owner document instead
1682
+
1683
+ const listenerTarget = getOwnerDocument(event.target);
1684
+ super(props, events, listenerTarget);
1685
+ }
1686
+
1687
+ }
1688
+ PointerSensor.activators = [{
1689
+ eventName: 'onPointerDown',
1690
+ handler: (_ref, _ref2) => {
1691
+ let {
1692
+ nativeEvent: event
1693
+ } = _ref;
1694
+ let {
1695
+ onActivation
1696
+ } = _ref2;
1697
+
1698
+ if (!event.isPrimary || event.button !== 0) {
1699
+ return false;
1700
+ }
1701
+
1702
+ onActivation == null ? void 0 : onActivation({
1703
+ event
1704
+ });
1705
+ return true;
1706
+ }
1707
+ }];
1708
+
1709
+ const events$1 = {
1710
+ move: {
1711
+ name: 'mousemove'
1712
+ },
1713
+ end: {
1714
+ name: 'mouseup'
1715
+ }
1716
+ };
1717
+ var MouseButton;
1718
+
1719
+ (function (MouseButton) {
1720
+ MouseButton[MouseButton["RightClick"] = 2] = "RightClick";
1721
+ })(MouseButton || (MouseButton = {}));
1722
+
1723
+ class MouseSensor extends AbstractPointerSensor {
1724
+ constructor(props) {
1725
+ super(props, events$1, getOwnerDocument(props.event.target));
1726
+ }
1727
+
1728
+ }
1729
+ MouseSensor.activators = [{
1730
+ eventName: 'onMouseDown',
1731
+ handler: (_ref, _ref2) => {
1732
+ let {
1733
+ nativeEvent: event
1734
+ } = _ref;
1735
+ let {
1736
+ onActivation
1737
+ } = _ref2;
1738
+
1739
+ if (event.button === MouseButton.RightClick) {
1740
+ return false;
1741
+ }
1742
+
1743
+ onActivation == null ? void 0 : onActivation({
1744
+ event
1745
+ });
1746
+ return true;
1747
+ }
1748
+ }];
1749
+
1750
+ const events$2 = {
1751
+ cancel: {
1752
+ name: 'touchcancel'
1753
+ },
1754
+ move: {
1755
+ name: 'touchmove'
1756
+ },
1757
+ end: {
1758
+ name: 'touchend'
1759
+ }
1760
+ };
1761
+ class TouchSensor extends AbstractPointerSensor {
1762
+ constructor(props) {
1763
+ super(props, events$2);
1764
+ }
1765
+
1766
+ static setup() {
1767
+ // Adding a non-capture and non-passive `touchmove` listener in order
1768
+ // to force `event.preventDefault()` calls to work in dynamically added
1769
+ // touchmove event handlers. This is required for iOS Safari.
1770
+ window.addEventListener(events$2.move.name, noop, {
1771
+ capture: false,
1772
+ passive: false
1773
+ });
1774
+ return function teardown() {
1775
+ window.removeEventListener(events$2.move.name, noop);
1776
+ }; // We create a new handler because the teardown function of another sensor
1777
+ // could remove our event listener if we use a referentially equal listener.
1778
+
1779
+ function noop() {}
1780
+ }
1781
+
1782
+ }
1783
+ TouchSensor.activators = [{
1784
+ eventName: 'onTouchStart',
1785
+ handler: (_ref, _ref2) => {
1786
+ let {
1787
+ nativeEvent: event
1788
+ } = _ref;
1789
+ let {
1790
+ onActivation
1791
+ } = _ref2;
1792
+ const {
1793
+ touches
1794
+ } = event;
1795
+
1796
+ if (touches.length > 1) {
1797
+ return false;
1798
+ }
1799
+
1800
+ onActivation == null ? void 0 : onActivation({
1801
+ event
1802
+ });
1803
+ return true;
1804
+ }
1805
+ }];
1806
+
1807
+ var AutoScrollActivator;
1808
+
1809
+ (function (AutoScrollActivator) {
1810
+ AutoScrollActivator[AutoScrollActivator["Pointer"] = 0] = "Pointer";
1811
+ AutoScrollActivator[AutoScrollActivator["DraggableRect"] = 1] = "DraggableRect";
1812
+ })(AutoScrollActivator || (AutoScrollActivator = {}));
1813
+
1814
+ var TraversalOrder;
1815
+
1816
+ (function (TraversalOrder) {
1817
+ TraversalOrder[TraversalOrder["TreeOrder"] = 0] = "TreeOrder";
1818
+ TraversalOrder[TraversalOrder["ReversedTreeOrder"] = 1] = "ReversedTreeOrder";
1819
+ })(TraversalOrder || (TraversalOrder = {}));
1820
+
1821
+ function useAutoScroller(_ref) {
1822
+ let {
1823
+ acceleration,
1824
+ activator = AutoScrollActivator.Pointer,
1825
+ canScroll,
1826
+ draggingRect,
1827
+ enabled,
1828
+ interval = 5,
1829
+ order = TraversalOrder.TreeOrder,
1830
+ pointerCoordinates,
1831
+ scrollableAncestors,
1832
+ scrollableAncestorRects,
1833
+ delta,
1834
+ threshold
1835
+ } = _ref;
1836
+ const scrollIntent = useScrollIntent({
1837
+ delta,
1838
+ disabled: !enabled
1839
+ });
1840
+ const [setAutoScrollInterval, clearAutoScrollInterval] = useInterval();
1841
+ const scrollSpeed = useRef({
1842
+ x: 0,
1843
+ y: 0
1844
+ });
1845
+ const scrollDirection = useRef({
1846
+ x: 0,
1847
+ y: 0
1848
+ });
1849
+ const rect = useMemo(() => {
1850
+ switch (activator) {
1851
+ case AutoScrollActivator.Pointer:
1852
+ return pointerCoordinates ? {
1853
+ top: pointerCoordinates.y,
1854
+ bottom: pointerCoordinates.y,
1855
+ left: pointerCoordinates.x,
1856
+ right: pointerCoordinates.x
1857
+ } : null;
1858
+
1859
+ case AutoScrollActivator.DraggableRect:
1860
+ return draggingRect;
1861
+ }
1862
+ }, [activator, draggingRect, pointerCoordinates]);
1863
+ const scrollContainerRef = useRef(null);
1864
+ const autoScroll = useCallback(() => {
1865
+ const scrollContainer = scrollContainerRef.current;
1866
+
1867
+ if (!scrollContainer) {
1868
+ return;
1869
+ }
1870
+
1871
+ const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;
1872
+ const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;
1873
+ scrollContainer.scrollBy(scrollLeft, scrollTop);
1874
+ }, []);
1875
+ const sortedScrollableAncestors = useMemo(() => order === TraversalOrder.TreeOrder ? [...scrollableAncestors].reverse() : scrollableAncestors, [order, scrollableAncestors]);
1876
+ useEffect(() => {
1877
+ if (!enabled || !scrollableAncestors.length || !rect) {
1878
+ clearAutoScrollInterval();
1879
+ return;
1880
+ }
1881
+
1882
+ for (const scrollContainer of sortedScrollableAncestors) {
1883
+ if ((canScroll == null ? void 0 : canScroll(scrollContainer)) === false) {
1884
+ continue;
1885
+ }
1886
+
1887
+ const index = scrollableAncestors.indexOf(scrollContainer);
1888
+ const scrollContainerRect = scrollableAncestorRects[index];
1889
+
1890
+ if (!scrollContainerRect) {
1891
+ continue;
1892
+ }
1893
+
1894
+ const {
1895
+ direction,
1896
+ speed
1897
+ } = getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, rect, acceleration, threshold);
1898
+
1899
+ for (const axis of ['x', 'y']) {
1900
+ if (!scrollIntent[axis][direction[axis]]) {
1901
+ speed[axis] = 0;
1902
+ direction[axis] = 0;
1903
+ }
1904
+ }
1905
+
1906
+ if (speed.x > 0 || speed.y > 0) {
1907
+ clearAutoScrollInterval();
1908
+ scrollContainerRef.current = scrollContainer;
1909
+ setAutoScrollInterval(autoScroll, interval);
1910
+ scrollSpeed.current = speed;
1911
+ scrollDirection.current = direction;
1912
+ return;
1913
+ }
1914
+ }
1915
+
1916
+ scrollSpeed.current = {
1917
+ x: 0,
1918
+ y: 0
1919
+ };
1920
+ scrollDirection.current = {
1921
+ x: 0,
1922
+ y: 0
1923
+ };
1924
+ clearAutoScrollInterval();
1925
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
1926
+ [acceleration, autoScroll, canScroll, clearAutoScrollInterval, enabled, interval, // eslint-disable-next-line react-hooks/exhaustive-deps
1927
+ JSON.stringify(rect), // eslint-disable-next-line react-hooks/exhaustive-deps
1928
+ JSON.stringify(scrollIntent), setAutoScrollInterval, scrollableAncestors, sortedScrollableAncestors, scrollableAncestorRects, // eslint-disable-next-line react-hooks/exhaustive-deps
1929
+ JSON.stringify(threshold)]);
1930
+ }
1931
+ const defaultScrollIntent = {
1932
+ x: {
1933
+ [Direction.Backward]: false,
1934
+ [Direction.Forward]: false
1935
+ },
1936
+ y: {
1937
+ [Direction.Backward]: false,
1938
+ [Direction.Forward]: false
1939
+ }
1940
+ };
1941
+
1942
+ function useScrollIntent(_ref2) {
1943
+ let {
1944
+ delta,
1945
+ disabled
1946
+ } = _ref2;
1947
+ const previousDelta = usePrevious(delta);
1948
+ return useLazyMemo(previousIntent => {
1949
+ if (disabled || !previousDelta || !previousIntent) {
1950
+ // Reset scroll intent tracking when auto-scrolling is disabled
1951
+ return defaultScrollIntent;
1952
+ }
1953
+
1954
+ const direction = {
1955
+ x: Math.sign(delta.x - previousDelta.x),
1956
+ y: Math.sign(delta.y - previousDelta.y)
1957
+ }; // Keep track of the user intent to scroll in each direction for both axis
1958
+
1959
+ return {
1960
+ x: {
1961
+ [Direction.Backward]: previousIntent.x[Direction.Backward] || direction.x === -1,
1962
+ [Direction.Forward]: previousIntent.x[Direction.Forward] || direction.x === 1
1963
+ },
1964
+ y: {
1965
+ [Direction.Backward]: previousIntent.y[Direction.Backward] || direction.y === -1,
1966
+ [Direction.Forward]: previousIntent.y[Direction.Forward] || direction.y === 1
1967
+ }
1968
+ };
1969
+ }, [disabled, delta, previousDelta]);
1970
+ }
1971
+
1972
+ function useCachedNode(draggableNodes, id) {
1973
+ const draggableNode = id != null ? draggableNodes.get(id) : undefined;
1974
+ const node = draggableNode ? draggableNode.node.current : null;
1975
+ return useLazyMemo(cachedNode => {
1976
+ var _ref;
1977
+
1978
+ if (id == null) {
1979
+ return null;
1980
+ } // In some cases, the draggable node can unmount while dragging
1981
+ // This is the case for virtualized lists. In those situations,
1982
+ // we fall back to the last known value for that node.
1983
+
1984
+
1985
+ return (_ref = node != null ? node : cachedNode) != null ? _ref : null;
1986
+ }, [node, id]);
1987
+ }
1988
+
1989
+ function useCombineActivators(sensors, getSyntheticHandler) {
1990
+ return useMemo(() => sensors.reduce((accumulator, sensor) => {
1991
+ const {
1992
+ sensor: Sensor
1993
+ } = sensor;
1994
+ const sensorActivators = Sensor.activators.map(activator => ({
1995
+ eventName: activator.eventName,
1996
+ handler: getSyntheticHandler(activator.handler, sensor)
1997
+ }));
1998
+ return [...accumulator, ...sensorActivators];
1999
+ }, []), [sensors, getSyntheticHandler]);
2000
+ }
2001
+
2002
+ var MeasuringStrategy;
2003
+
2004
+ (function (MeasuringStrategy) {
2005
+ MeasuringStrategy[MeasuringStrategy["Always"] = 0] = "Always";
2006
+ MeasuringStrategy[MeasuringStrategy["BeforeDragging"] = 1] = "BeforeDragging";
2007
+ MeasuringStrategy[MeasuringStrategy["WhileDragging"] = 2] = "WhileDragging";
2008
+ })(MeasuringStrategy || (MeasuringStrategy = {}));
2009
+
2010
+ var MeasuringFrequency;
2011
+
2012
+ (function (MeasuringFrequency) {
2013
+ MeasuringFrequency["Optimized"] = "optimized";
2014
+ })(MeasuringFrequency || (MeasuringFrequency = {}));
2015
+
2016
+ const defaultValue = /*#__PURE__*/new Map();
2017
+ function useDroppableMeasuring(containers, _ref) {
2018
+ let {
2019
+ dragging,
2020
+ dependencies,
2021
+ config
2022
+ } = _ref;
2023
+ const [queue, setQueue] = useState(null);
2024
+ const {
2025
+ frequency,
2026
+ measure,
2027
+ strategy
2028
+ } = config;
2029
+ const containersRef = useRef(containers);
2030
+ const disabled = isDisabled();
2031
+ const disabledRef = useLatestValue(disabled);
2032
+ const measureDroppableContainers = useCallback(function (ids) {
2033
+ if (ids === void 0) {
2034
+ ids = [];
2035
+ }
2036
+
2037
+ if (disabledRef.current) {
2038
+ return;
2039
+ }
2040
+
2041
+ setQueue(value => {
2042
+ if (value === null) {
2043
+ return ids;
2044
+ }
2045
+
2046
+ return value.concat(ids.filter(id => !value.includes(id)));
2047
+ });
2048
+ }, [disabledRef]);
2049
+ const timeoutId = useRef(null);
2050
+ const droppableRects = useLazyMemo(previousValue => {
2051
+ if (disabled && !dragging) {
2052
+ return defaultValue;
2053
+ }
2054
+
2055
+ if (!previousValue || previousValue === defaultValue || containersRef.current !== containers || queue != null) {
2056
+ const map = new Map();
2057
+
2058
+ for (let container of containers) {
2059
+ if (!container) {
2060
+ continue;
2061
+ }
2062
+
2063
+ if (queue && queue.length > 0 && !queue.includes(container.id) && container.rect.current) {
2064
+ // This container does not need to be re-measured
2065
+ map.set(container.id, container.rect.current);
2066
+ continue;
2067
+ }
2068
+
2069
+ const node = container.node.current;
2070
+ const rect = node ? new Rect(measure(node), node) : null;
2071
+ container.rect.current = rect;
2072
+
2073
+ if (rect) {
2074
+ map.set(container.id, rect);
2075
+ }
2076
+ }
2077
+
2078
+ return map;
2079
+ }
2080
+
2081
+ return previousValue;
2082
+ }, [containers, queue, dragging, disabled, measure]);
2083
+ useEffect(() => {
2084
+ containersRef.current = containers;
2085
+ }, [containers]);
2086
+ useEffect(() => {
2087
+ if (disabled) {
2088
+ return;
2089
+ }
2090
+
2091
+ measureDroppableContainers();
2092
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
2093
+ [dragging, disabled]);
2094
+ useEffect(() => {
2095
+ if (queue && queue.length > 0) {
2096
+ setQueue(null);
2097
+ }
2098
+ }, //eslint-disable-next-line react-hooks/exhaustive-deps
2099
+ [JSON.stringify(queue)]);
2100
+ useEffect(() => {
2101
+ if (disabled || typeof frequency !== 'number' || timeoutId.current !== null) {
2102
+ return;
2103
+ }
2104
+
2105
+ timeoutId.current = setTimeout(() => {
2106
+ measureDroppableContainers();
2107
+ timeoutId.current = null;
2108
+ }, frequency);
2109
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
2110
+ [frequency, disabled, measureDroppableContainers, ...dependencies]);
2111
+ return {
2112
+ droppableRects,
2113
+ measureDroppableContainers,
2114
+ measuringScheduled: queue != null
2115
+ };
2116
+
2117
+ function isDisabled() {
2118
+ switch (strategy) {
2119
+ case MeasuringStrategy.Always:
2120
+ return false;
2121
+
2122
+ case MeasuringStrategy.BeforeDragging:
2123
+ return dragging;
2124
+
2125
+ default:
2126
+ return !dragging;
2127
+ }
2128
+ }
2129
+ }
2130
+
2131
+ function useInitialValue(value, computeFn) {
2132
+ return useLazyMemo(previousValue => {
2133
+ if (!value) {
2134
+ return null;
2135
+ }
2136
+
2137
+ if (previousValue) {
2138
+ return previousValue;
2139
+ }
2140
+
2141
+ return typeof computeFn === 'function' ? computeFn(value) : value;
2142
+ }, [computeFn, value]);
2143
+ }
2144
+
2145
+ function useInitialRect(node, measure) {
2146
+ return useInitialValue(node, measure);
2147
+ }
2148
+
2149
+ /**
2150
+ * Returns a new MutationObserver instance.
2151
+ * If `MutationObserver` is undefined in the execution environment, returns `undefined`.
2152
+ */
2153
+
2154
+ function useMutationObserver(_ref) {
2155
+ let {
2156
+ callback,
2157
+ disabled
2158
+ } = _ref;
2159
+ const handleMutations = useEvent(callback);
2160
+ const mutationObserver = useMemo(() => {
2161
+ if (disabled || typeof window === 'undefined' || typeof window.MutationObserver === 'undefined') {
2162
+ return undefined;
2163
+ }
2164
+
2165
+ const {
2166
+ MutationObserver
2167
+ } = window;
2168
+ return new MutationObserver(handleMutations);
2169
+ }, [handleMutations, disabled]);
2170
+ useEffect(() => {
2171
+ return () => mutationObserver == null ? void 0 : mutationObserver.disconnect();
2172
+ }, [mutationObserver]);
2173
+ return mutationObserver;
2174
+ }
2175
+
2176
+ /**
2177
+ * Returns a new ResizeObserver instance bound to the `onResize` callback.
2178
+ * If `ResizeObserver` is undefined in the execution environment, returns `undefined`.
2179
+ */
2180
+
2181
+ function useResizeObserver(_ref) {
2182
+ let {
2183
+ callback,
2184
+ disabled
2185
+ } = _ref;
2186
+ const handleResize = useEvent(callback);
2187
+ const resizeObserver = useMemo(() => {
2188
+ if (disabled || typeof window === 'undefined' || typeof window.ResizeObserver === 'undefined') {
2189
+ return undefined;
2190
+ }
2191
+
2192
+ const {
2193
+ ResizeObserver
2194
+ } = window;
2195
+ return new ResizeObserver(handleResize);
2196
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
2197
+ [disabled]);
2198
+ useEffect(() => {
2199
+ return () => resizeObserver == null ? void 0 : resizeObserver.disconnect();
2200
+ }, [resizeObserver]);
2201
+ return resizeObserver;
2202
+ }
2203
+
2204
+ function defaultMeasure(element) {
2205
+ return new Rect(getClientRect(element), element);
2206
+ }
2207
+
2208
+ function useRect(element, measure, fallbackRect) {
2209
+ if (measure === void 0) {
2210
+ measure = defaultMeasure;
2211
+ }
2212
+
2213
+ const [rect, setRect] = useState(null);
2214
+
2215
+ function measureRect() {
2216
+ setRect(currentRect => {
2217
+ if (!element) {
2218
+ return null;
2219
+ }
2220
+
2221
+ if (element.isConnected === false) {
2222
+ var _ref;
2223
+
2224
+ // Fall back to last rect we measured if the element is
2225
+ // no longer connected to the DOM.
2226
+ return (_ref = currentRect != null ? currentRect : fallbackRect) != null ? _ref : null;
2227
+ }
2228
+
2229
+ const newRect = measure(element);
2230
+
2231
+ if (JSON.stringify(currentRect) === JSON.stringify(newRect)) {
2232
+ return currentRect;
2233
+ }
2234
+
2235
+ return newRect;
2236
+ });
2237
+ }
2238
+
2239
+ const mutationObserver = useMutationObserver({
2240
+ callback(records) {
2241
+ if (!element) {
2242
+ return;
2243
+ }
2244
+
2245
+ for (const record of records) {
2246
+ const {
2247
+ type,
2248
+ target
2249
+ } = record;
2250
+
2251
+ if (type === 'childList' && target instanceof HTMLElement && target.contains(element)) {
2252
+ measureRect();
2253
+ break;
2254
+ }
2255
+ }
2256
+ }
2257
+
2258
+ });
2259
+ const resizeObserver = useResizeObserver({
2260
+ callback: measureRect
2261
+ });
2262
+ useIsomorphicLayoutEffect(() => {
2263
+ measureRect();
2264
+
2265
+ if (element) {
2266
+ resizeObserver == null ? void 0 : resizeObserver.observe(element);
2267
+ mutationObserver == null ? void 0 : mutationObserver.observe(document.body, {
2268
+ childList: true,
2269
+ subtree: true
2270
+ });
2271
+ } else {
2272
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
2273
+ mutationObserver == null ? void 0 : mutationObserver.disconnect();
2274
+ }
2275
+ }, [element]);
2276
+ return rect;
2277
+ }
2278
+
2279
+ function useRectDelta(rect) {
2280
+ const initialRect = useInitialValue(rect);
2281
+ return getRectDelta(rect, initialRect);
2282
+ }
2283
+
2284
+ const defaultValue$1 = [];
2285
+ function useScrollableAncestors(node) {
2286
+ const previousNode = useRef(node);
2287
+ const ancestors = useLazyMemo(previousValue => {
2288
+ if (!node) {
2289
+ return defaultValue$1;
2290
+ }
2291
+
2292
+ if (previousValue && previousValue !== defaultValue$1 && node && previousNode.current && node.parentNode === previousNode.current.parentNode) {
2293
+ return previousValue;
2294
+ }
2295
+
2296
+ return getScrollableAncestors(node);
2297
+ }, [node]);
2298
+ useEffect(() => {
2299
+ previousNode.current = node;
2300
+ }, [node]);
2301
+ return ancestors;
2302
+ }
2303
+
2304
+ function useScrollOffsets(elements) {
2305
+ const [scrollCoordinates, setScrollCoordinates] = useState(null);
2306
+ const prevElements = useRef(elements); // To-do: Throttle the handleScroll callback
2307
+
2308
+ const handleScroll = useCallback(event => {
2309
+ const scrollingElement = getScrollableElement(event.target);
2310
+
2311
+ if (!scrollingElement) {
2312
+ return;
2313
+ }
2314
+
2315
+ setScrollCoordinates(scrollCoordinates => {
2316
+ if (!scrollCoordinates) {
2317
+ return null;
2318
+ }
2319
+
2320
+ scrollCoordinates.set(scrollingElement, getScrollCoordinates(scrollingElement));
2321
+ return new Map(scrollCoordinates);
2322
+ });
2323
+ }, []);
2324
+ useEffect(() => {
2325
+ const previousElements = prevElements.current;
2326
+
2327
+ if (elements !== previousElements) {
2328
+ cleanup(previousElements);
2329
+ const entries = elements.map(element => {
2330
+ const scrollableElement = getScrollableElement(element);
2331
+
2332
+ if (scrollableElement) {
2333
+ scrollableElement.addEventListener('scroll', handleScroll, {
2334
+ passive: true
2335
+ });
2336
+ return [scrollableElement, getScrollCoordinates(scrollableElement)];
2337
+ }
2338
+
2339
+ return null;
2340
+ }).filter(entry => entry != null);
2341
+ setScrollCoordinates(entries.length ? new Map(entries) : null);
2342
+ prevElements.current = elements;
2343
+ }
2344
+
2345
+ return () => {
2346
+ cleanup(elements);
2347
+ cleanup(previousElements);
2348
+ };
2349
+
2350
+ function cleanup(elements) {
2351
+ elements.forEach(element => {
2352
+ const scrollableElement = getScrollableElement(element);
2353
+ scrollableElement == null ? void 0 : scrollableElement.removeEventListener('scroll', handleScroll);
2354
+ });
2355
+ }
2356
+ }, [handleScroll, elements]);
2357
+ return useMemo(() => {
2358
+ if (elements.length) {
2359
+ return scrollCoordinates ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => add(acc, coordinates), defaultCoordinates) : getScrollOffsets(elements);
2360
+ }
2361
+
2362
+ return defaultCoordinates;
2363
+ }, [elements, scrollCoordinates]);
2364
+ }
2365
+
2366
+ function useScrollOffsetsDelta(scrollOffsets, dependencies) {
2367
+ if (dependencies === void 0) {
2368
+ dependencies = [];
2369
+ }
2370
+
2371
+ const initialScrollOffsets = useRef(null);
2372
+ useEffect(() => {
2373
+ initialScrollOffsets.current = null;
2374
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
2375
+ dependencies);
2376
+ useEffect(() => {
2377
+ const hasScrollOffsets = scrollOffsets !== defaultCoordinates;
2378
+
2379
+ if (hasScrollOffsets && !initialScrollOffsets.current) {
2380
+ initialScrollOffsets.current = scrollOffsets;
2381
+ }
2382
+
2383
+ if (!hasScrollOffsets && initialScrollOffsets.current) {
2384
+ initialScrollOffsets.current = null;
2385
+ }
2386
+ }, [scrollOffsets]);
2387
+ return initialScrollOffsets.current ? subtract(scrollOffsets, initialScrollOffsets.current) : defaultCoordinates;
2388
+ }
2389
+
2390
+ function useSensorSetup(sensors) {
2391
+ useEffect(() => {
2392
+ if (!canUseDOM) {
2393
+ return;
2394
+ }
2395
+
2396
+ const teardownFns = sensors.map(_ref => {
2397
+ let {
2398
+ sensor
2399
+ } = _ref;
2400
+ return sensor.setup == null ? void 0 : sensor.setup();
2401
+ });
2402
+ return () => {
2403
+ for (const teardown of teardownFns) {
2404
+ teardown == null ? void 0 : teardown();
2405
+ }
2406
+ };
2407
+ }, // TO-DO: Sensors length could theoretically change which would not be a valid dependency
2408
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2409
+ sensors.map(_ref2 => {
2410
+ let {
2411
+ sensor
2412
+ } = _ref2;
2413
+ return sensor;
2414
+ }));
2415
+ }
2416
+
2417
+ function useSyntheticListeners(listeners, id) {
2418
+ return useMemo(() => {
2419
+ return listeners.reduce((acc, _ref) => {
2420
+ let {
2421
+ eventName,
2422
+ handler
2423
+ } = _ref;
2424
+
2425
+ acc[eventName] = event => {
2426
+ handler(event, id);
2427
+ };
2428
+
2429
+ return acc;
2430
+ }, {});
2431
+ }, [listeners, id]);
2432
+ }
2433
+
2434
+ function useWindowRect(element) {
2435
+ return useMemo(() => element ? getWindowClientRect(element) : null, [element]);
2436
+ }
2437
+
2438
+ const defaultValue$2 = [];
2439
+ function useRects(elements, measure) {
2440
+ if (measure === void 0) {
2441
+ measure = getClientRect;
2442
+ }
2443
+
2444
+ const [firstElement] = elements;
2445
+ const windowRect = useWindowRect(firstElement ? getWindow(firstElement) : null);
2446
+ const [rects, setRects] = useState(defaultValue$2);
2447
+
2448
+ function measureRects() {
2449
+ setRects(() => {
2450
+ if (!elements.length) {
2451
+ return defaultValue$2;
2452
+ }
2453
+
2454
+ return elements.map(element => isDocumentScrollingElement(element) ? windowRect : new Rect(measure(element), element));
2455
+ });
2456
+ }
2457
+
2458
+ const resizeObserver = useResizeObserver({
2459
+ callback: measureRects
2460
+ });
2461
+ useIsomorphicLayoutEffect(() => {
2462
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
2463
+ measureRects();
2464
+ elements.forEach(element => resizeObserver == null ? void 0 : resizeObserver.observe(element));
2465
+ }, [elements]);
2466
+ return rects;
2467
+ }
2468
+
2469
+ function getMeasurableNode(node) {
2470
+ if (!node) {
2471
+ return null;
2472
+ }
2473
+
2474
+ if (node.children.length > 1) {
2475
+ return node;
2476
+ }
2477
+
2478
+ const firstChild = node.children[0];
2479
+ return isHTMLElement(firstChild) ? firstChild : node;
2480
+ }
2481
+
2482
+ function useDragOverlayMeasuring(_ref) {
2483
+ let {
2484
+ measure
2485
+ } = _ref;
2486
+ const [rect, setRect] = useState(null);
2487
+ const handleResize = useCallback(entries => {
2488
+ for (const {
2489
+ target
2490
+ } of entries) {
2491
+ if (isHTMLElement(target)) {
2492
+ setRect(rect => {
2493
+ const newRect = measure(target);
2494
+ return rect ? { ...rect,
2495
+ width: newRect.width,
2496
+ height: newRect.height
2497
+ } : newRect;
2498
+ });
2499
+ break;
2500
+ }
2501
+ }
2502
+ }, [measure]);
2503
+ const resizeObserver = useResizeObserver({
2504
+ callback: handleResize
2505
+ });
2506
+ const handleNodeChange = useCallback(element => {
2507
+ const node = getMeasurableNode(element);
2508
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
2509
+
2510
+ if (node) {
2511
+ resizeObserver == null ? void 0 : resizeObserver.observe(node);
2512
+ }
2513
+
2514
+ setRect(node ? measure(node) : null);
2515
+ }, [measure, resizeObserver]);
2516
+ const [nodeRef, setRef] = useNodeRef(handleNodeChange);
2517
+ return useMemo(() => ({
2518
+ nodeRef,
2519
+ rect,
2520
+ setRef
2521
+ }), [rect, nodeRef, setRef]);
2522
+ }
2523
+
2524
+ const defaultSensors = [{
2525
+ sensor: PointerSensor,
2526
+ options: {}
2527
+ }, {
2528
+ sensor: KeyboardSensor,
2529
+ options: {}
2530
+ }];
2531
+ const defaultData = {
2532
+ current: {}
2533
+ };
2534
+ const defaultMeasuringConfiguration = {
2535
+ draggable: {
2536
+ measure: getTransformAgnosticClientRect
2537
+ },
2538
+ droppable: {
2539
+ measure: getTransformAgnosticClientRect,
2540
+ strategy: MeasuringStrategy.WhileDragging,
2541
+ frequency: MeasuringFrequency.Optimized
2542
+ },
2543
+ dragOverlay: {
2544
+ measure: getClientRect
2545
+ }
2546
+ };
2547
+
2548
+ class DroppableContainersMap extends Map {
2549
+ get(id) {
2550
+ var _super$get;
2551
+
2552
+ return id != null ? (_super$get = super.get(id)) != null ? _super$get : undefined : undefined;
2553
+ }
2554
+
2555
+ toArray() {
2556
+ return Array.from(this.values());
2557
+ }
2558
+
2559
+ getEnabled() {
2560
+ return this.toArray().filter(_ref => {
2561
+ let {
2562
+ disabled
2563
+ } = _ref;
2564
+ return !disabled;
2565
+ });
2566
+ }
2567
+
2568
+ getNodeFor(id) {
2569
+ var _this$get$node$curren, _this$get;
2570
+
2571
+ return (_this$get$node$curren = (_this$get = this.get(id)) == null ? void 0 : _this$get.node.current) != null ? _this$get$node$curren : undefined;
2572
+ }
2573
+
2574
+ }
2575
+
2576
+ const defaultPublicContext = {
2577
+ activatorEvent: null,
2578
+ active: null,
2579
+ activeNode: null,
2580
+ activeNodeRect: null,
2581
+ collisions: null,
2582
+ containerNodeRect: null,
2583
+ draggableNodes: /*#__PURE__*/new Map(),
2584
+ droppableRects: /*#__PURE__*/new Map(),
2585
+ droppableContainers: /*#__PURE__*/new DroppableContainersMap(),
2586
+ over: null,
2587
+ dragOverlay: {
2588
+ nodeRef: {
2589
+ current: null
2590
+ },
2591
+ rect: null,
2592
+ setRef: noop
2593
+ },
2594
+ scrollableAncestors: [],
2595
+ scrollableAncestorRects: [],
2596
+ measuringConfiguration: defaultMeasuringConfiguration,
2597
+ measureDroppableContainers: noop,
2598
+ windowRect: null,
2599
+ measuringScheduled: false
2600
+ };
2601
+ const defaultInternalContext = {
2602
+ activatorEvent: null,
2603
+ activators: [],
2604
+ active: null,
2605
+ activeNodeRect: null,
2606
+ ariaDescribedById: {
2607
+ draggable: ''
2608
+ },
2609
+ dispatch: noop,
2610
+ draggableNodes: /*#__PURE__*/new Map(),
2611
+ over: null,
2612
+ measureDroppableContainers: noop
2613
+ };
2614
+ const InternalContext = /*#__PURE__*/createContext(defaultInternalContext);
2615
+ const PublicContext = /*#__PURE__*/createContext(defaultPublicContext);
2616
+
2617
+ function getInitialState() {
2618
+ return {
2619
+ draggable: {
2620
+ active: null,
2621
+ initialCoordinates: {
2622
+ x: 0,
2623
+ y: 0
2624
+ },
2625
+ nodes: new Map(),
2626
+ translate: {
2627
+ x: 0,
2628
+ y: 0
2629
+ }
2630
+ },
2631
+ droppable: {
2632
+ containers: new DroppableContainersMap()
2633
+ }
2634
+ };
2635
+ }
2636
+ function reducer(state, action) {
2637
+ switch (action.type) {
2638
+ case Action.DragStart:
2639
+ return { ...state,
2640
+ draggable: { ...state.draggable,
2641
+ initialCoordinates: action.initialCoordinates,
2642
+ active: action.active
2643
+ }
2644
+ };
2645
+
2646
+ case Action.DragMove:
2647
+ if (state.draggable.active == null) {
2648
+ return state;
2649
+ }
2650
+
2651
+ return { ...state,
2652
+ draggable: { ...state.draggable,
2653
+ translate: {
2654
+ x: action.coordinates.x - state.draggable.initialCoordinates.x,
2655
+ y: action.coordinates.y - state.draggable.initialCoordinates.y
2656
+ }
2657
+ }
2658
+ };
2659
+
2660
+ case Action.DragEnd:
2661
+ case Action.DragCancel:
2662
+ return { ...state,
2663
+ draggable: { ...state.draggable,
2664
+ active: null,
2665
+ initialCoordinates: {
2666
+ x: 0,
2667
+ y: 0
2668
+ },
2669
+ translate: {
2670
+ x: 0,
2671
+ y: 0
2672
+ }
2673
+ }
2674
+ };
2675
+
2676
+ case Action.RegisterDroppable:
2677
+ {
2678
+ const {
2679
+ element
2680
+ } = action;
2681
+ const {
2682
+ id
2683
+ } = element;
2684
+ const containers = new DroppableContainersMap(state.droppable.containers);
2685
+ containers.set(id, element);
2686
+ return { ...state,
2687
+ droppable: { ...state.droppable,
2688
+ containers
2689
+ }
2690
+ };
2691
+ }
2692
+
2693
+ case Action.SetDroppableDisabled:
2694
+ {
2695
+ const {
2696
+ id,
2697
+ key,
2698
+ disabled
2699
+ } = action;
2700
+ const element = state.droppable.containers.get(id);
2701
+
2702
+ if (!element || key !== element.key) {
2703
+ return state;
2704
+ }
2705
+
2706
+ const containers = new DroppableContainersMap(state.droppable.containers);
2707
+ containers.set(id, { ...element,
2708
+ disabled
2709
+ });
2710
+ return { ...state,
2711
+ droppable: { ...state.droppable,
2712
+ containers
2713
+ }
2714
+ };
2715
+ }
2716
+
2717
+ case Action.UnregisterDroppable:
2718
+ {
2719
+ const {
2720
+ id,
2721
+ key
2722
+ } = action;
2723
+ const element = state.droppable.containers.get(id);
2724
+
2725
+ if (!element || key !== element.key) {
2726
+ return state;
2727
+ }
2728
+
2729
+ const containers = new DroppableContainersMap(state.droppable.containers);
2730
+ containers.delete(id);
2731
+ return { ...state,
2732
+ droppable: { ...state.droppable,
2733
+ containers
2734
+ }
2735
+ };
2736
+ }
2737
+
2738
+ default:
2739
+ {
2740
+ return state;
2741
+ }
2742
+ }
2743
+ }
2744
+
2745
+ function RestoreFocus(_ref) {
2746
+ let {
2747
+ disabled
2748
+ } = _ref;
2749
+ const {
2750
+ active,
2751
+ activatorEvent,
2752
+ draggableNodes
2753
+ } = useContext(InternalContext);
2754
+ const previousActivatorEvent = usePrevious(activatorEvent);
2755
+ const previousActiveId = usePrevious(active == null ? void 0 : active.id); // Restore keyboard focus on the activator node
2756
+
2757
+ useEffect(() => {
2758
+ if (disabled) {
2759
+ return;
2760
+ }
2761
+
2762
+ if (!activatorEvent && previousActivatorEvent && previousActiveId != null) {
2763
+ if (!isKeyboardEvent(previousActivatorEvent)) {
2764
+ return;
2765
+ }
2766
+
2767
+ if (document.activeElement === previousActivatorEvent.target) {
2768
+ // No need to restore focus
2769
+ return;
2770
+ }
2771
+
2772
+ const draggableNode = draggableNodes.get(previousActiveId);
2773
+
2774
+ if (!draggableNode) {
2775
+ return;
2776
+ }
2777
+
2778
+ const {
2779
+ activatorNode,
2780
+ node
2781
+ } = draggableNode;
2782
+
2783
+ if (!activatorNode.current && !node.current) {
2784
+ return;
2785
+ }
2786
+
2787
+ requestAnimationFrame(() => {
2788
+ for (const element of [activatorNode.current, node.current]) {
2789
+ if (!element) {
2790
+ continue;
2791
+ }
2792
+
2793
+ const focusableNode = findFirstFocusableNode(element);
2794
+
2795
+ if (focusableNode) {
2796
+ focusableNode.focus();
2797
+ break;
2798
+ }
2799
+ }
2800
+ });
2801
+ }
2802
+ }, [activatorEvent, disabled, draggableNodes, previousActiveId, previousActivatorEvent]);
2803
+ return null;
2804
+ }
2805
+
2806
+ function applyModifiers(modifiers, _ref) {
2807
+ let {
2808
+ transform,
2809
+ ...args
2810
+ } = _ref;
2811
+ return modifiers != null && modifiers.length ? modifiers.reduce((accumulator, modifier) => {
2812
+ return modifier({
2813
+ transform: accumulator,
2814
+ ...args
2815
+ });
2816
+ }, transform) : transform;
2817
+ }
2818
+
2819
+ function useMeasuringConfiguration(config) {
2820
+ return useMemo(() => ({
2821
+ draggable: { ...defaultMeasuringConfiguration.draggable,
2822
+ ...(config == null ? void 0 : config.draggable)
2823
+ },
2824
+ droppable: { ...defaultMeasuringConfiguration.droppable,
2825
+ ...(config == null ? void 0 : config.droppable)
2826
+ },
2827
+ dragOverlay: { ...defaultMeasuringConfiguration.dragOverlay,
2828
+ ...(config == null ? void 0 : config.dragOverlay)
2829
+ }
2830
+ }), // eslint-disable-next-line react-hooks/exhaustive-deps
2831
+ [config == null ? void 0 : config.draggable, config == null ? void 0 : config.droppable, config == null ? void 0 : config.dragOverlay]);
2832
+ }
2833
+
2834
+ function useLayoutShiftScrollCompensation(_ref) {
2835
+ let {
2836
+ activeNode,
2837
+ measure,
2838
+ initialRect,
2839
+ config = true
2840
+ } = _ref;
2841
+ const initialized = useRef(false);
2842
+ const {
2843
+ x,
2844
+ y
2845
+ } = typeof config === 'boolean' ? {
2846
+ x: config,
2847
+ y: config
2848
+ } : config;
2849
+ useIsomorphicLayoutEffect(() => {
2850
+ const disabled = !x && !y;
2851
+
2852
+ if (disabled || !activeNode) {
2853
+ initialized.current = false;
2854
+ return;
2855
+ }
2856
+
2857
+ if (initialized.current || !initialRect) {
2858
+ // Return early if layout shift scroll compensation was already attempted
2859
+ // or if there is no initialRect to compare to.
2860
+ return;
2861
+ } // Get the most up to date node ref for the active draggable
2862
+
2863
+
2864
+ const node = activeNode == null ? void 0 : activeNode.node.current;
2865
+
2866
+ if (!node || node.isConnected === false) {
2867
+ // Return early if there is no attached node ref or if the node is
2868
+ // disconnected from the document.
2869
+ return;
2870
+ }
2871
+
2872
+ const rect = measure(node);
2873
+ const rectDelta = getRectDelta(rect, initialRect);
2874
+
2875
+ if (!x) {
2876
+ rectDelta.x = 0;
2877
+ }
2878
+
2879
+ if (!y) {
2880
+ rectDelta.y = 0;
2881
+ } // Only perform layout shift scroll compensation once
2882
+
2883
+
2884
+ initialized.current = true;
2885
+
2886
+ if (Math.abs(rectDelta.x) > 0 || Math.abs(rectDelta.y) > 0) {
2887
+ const firstScrollableAncestor = getFirstScrollableAncestor(node);
2888
+
2889
+ if (firstScrollableAncestor) {
2890
+ firstScrollableAncestor.scrollBy({
2891
+ top: rectDelta.y,
2892
+ left: rectDelta.x
2893
+ });
2894
+ }
2895
+ }
2896
+ }, [activeNode, x, y, initialRect, measure]);
2897
+ }
2898
+
2899
+ const ActiveDraggableContext = /*#__PURE__*/createContext({ ...defaultCoordinates,
2900
+ scaleX: 1,
2901
+ scaleY: 1
2902
+ });
2903
+ var Status;
2904
+
2905
+ (function (Status) {
2906
+ Status[Status["Uninitialized"] = 0] = "Uninitialized";
2907
+ Status[Status["Initializing"] = 1] = "Initializing";
2908
+ Status[Status["Initialized"] = 2] = "Initialized";
2909
+ })(Status || (Status = {}));
2910
+
2911
+ const DndContext = /*#__PURE__*/memo(function DndContext(_ref) {
2912
+ var _sensorContext$curren, _dragOverlay$nodeRef$, _dragOverlay$rect, _over$rect;
2913
+
2914
+ let {
2915
+ id,
2916
+ accessibility,
2917
+ autoScroll = true,
2918
+ children,
2919
+ sensors = defaultSensors,
2920
+ collisionDetection = rectIntersection,
2921
+ measuring,
2922
+ modifiers,
2923
+ ...props
2924
+ } = _ref;
2925
+ const store = useReducer(reducer, undefined, getInitialState);
2926
+ const [state, dispatch] = store;
2927
+ const [dispatchMonitorEvent, registerMonitorListener] = useDndMonitorProvider();
2928
+ const [status, setStatus] = useState(Status.Uninitialized);
2929
+ const isInitialized = status === Status.Initialized;
2930
+ const {
2931
+ draggable: {
2932
+ active: activeId,
2933
+ nodes: draggableNodes,
2934
+ translate
2935
+ },
2936
+ droppable: {
2937
+ containers: droppableContainers
2938
+ }
2939
+ } = state;
2940
+ const node = activeId != null ? draggableNodes.get(activeId) : null;
2941
+ const activeRects = useRef({
2942
+ initial: null,
2943
+ translated: null
2944
+ });
2945
+ const active = useMemo(() => {
2946
+ var _node$data;
2947
+
2948
+ return activeId != null ? {
2949
+ id: activeId,
2950
+ // It's possible for the active node to unmount while dragging
2951
+ data: (_node$data = node == null ? void 0 : node.data) != null ? _node$data : defaultData,
2952
+ rect: activeRects
2953
+ } : null;
2954
+ }, [activeId, node]);
2955
+ const activeRef = useRef(null);
2956
+ const [activeSensor, setActiveSensor] = useState(null);
2957
+ const [activatorEvent, setActivatorEvent] = useState(null);
2958
+ const latestProps = useLatestValue(props, Object.values(props));
2959
+ const draggableDescribedById = useUniqueId("DndDescribedBy", id);
2960
+ const enabledDroppableContainers = useMemo(() => droppableContainers.getEnabled(), [droppableContainers]);
2961
+ const measuringConfiguration = useMeasuringConfiguration(measuring);
2962
+ const {
2963
+ droppableRects,
2964
+ measureDroppableContainers,
2965
+ measuringScheduled
2966
+ } = useDroppableMeasuring(enabledDroppableContainers, {
2967
+ dragging: isInitialized,
2968
+ dependencies: [translate.x, translate.y],
2969
+ config: measuringConfiguration.droppable
2970
+ });
2971
+ const activeNode = useCachedNode(draggableNodes, activeId);
2972
+ const activationCoordinates = useMemo(() => activatorEvent ? getEventCoordinates(activatorEvent) : null, [activatorEvent]);
2973
+ const autoScrollOptions = getAutoScrollerOptions();
2974
+ const initialActiveNodeRect = useInitialRect(activeNode, measuringConfiguration.draggable.measure);
2975
+ useLayoutShiftScrollCompensation({
2976
+ activeNode: activeId != null ? draggableNodes.get(activeId) : null,
2977
+ config: autoScrollOptions.layoutShiftCompensation,
2978
+ initialRect: initialActiveNodeRect,
2979
+ measure: measuringConfiguration.draggable.measure
2980
+ });
2981
+ const activeNodeRect = useRect(activeNode, measuringConfiguration.draggable.measure, initialActiveNodeRect);
2982
+ const containerNodeRect = useRect(activeNode ? activeNode.parentElement : null);
2983
+ const sensorContext = useRef({
2984
+ activatorEvent: null,
2985
+ active: null,
2986
+ activeNode,
2987
+ collisionRect: null,
2988
+ collisions: null,
2989
+ droppableRects,
2990
+ draggableNodes,
2991
+ draggingNode: null,
2992
+ draggingNodeRect: null,
2993
+ droppableContainers,
2994
+ over: null,
2995
+ scrollableAncestors: [],
2996
+ scrollAdjustedTranslate: null
2997
+ });
2998
+ const overNode = droppableContainers.getNodeFor((_sensorContext$curren = sensorContext.current.over) == null ? void 0 : _sensorContext$curren.id);
2999
+ const dragOverlay = useDragOverlayMeasuring({
3000
+ measure: measuringConfiguration.dragOverlay.measure
3001
+ }); // Use the rect of the drag overlay if it is mounted
3002
+
3003
+ const draggingNode = (_dragOverlay$nodeRef$ = dragOverlay.nodeRef.current) != null ? _dragOverlay$nodeRef$ : activeNode;
3004
+ const draggingNodeRect = isInitialized ? (_dragOverlay$rect = dragOverlay.rect) != null ? _dragOverlay$rect : activeNodeRect : null;
3005
+ const usesDragOverlay = Boolean(dragOverlay.nodeRef.current && dragOverlay.rect); // The delta between the previous and new position of the draggable node
3006
+ // is only relevant when there is no drag overlay
3007
+
3008
+ const nodeRectDelta = useRectDelta(usesDragOverlay ? null : activeNodeRect); // Get the window rect of the dragging node
3009
+
3010
+ const windowRect = useWindowRect(draggingNode ? getWindow(draggingNode) : null); // Get scrollable ancestors of the dragging node
3011
+
3012
+ const scrollableAncestors = useScrollableAncestors(isInitialized ? overNode != null ? overNode : activeNode : null);
3013
+ const scrollableAncestorRects = useRects(scrollableAncestors); // Apply modifiers
3014
+
3015
+ const modifiedTranslate = applyModifiers(modifiers, {
3016
+ transform: {
3017
+ x: translate.x - nodeRectDelta.x,
3018
+ y: translate.y - nodeRectDelta.y,
3019
+ scaleX: 1,
3020
+ scaleY: 1
3021
+ },
3022
+ activatorEvent,
3023
+ active,
3024
+ activeNodeRect,
3025
+ containerNodeRect,
3026
+ draggingNodeRect,
3027
+ over: sensorContext.current.over,
3028
+ overlayNodeRect: dragOverlay.rect,
3029
+ scrollableAncestors,
3030
+ scrollableAncestorRects,
3031
+ windowRect
3032
+ });
3033
+ const pointerCoordinates = activationCoordinates ? add(activationCoordinates, translate) : null;
3034
+ const scrollOffsets = useScrollOffsets(scrollableAncestors); // Represents the scroll delta since dragging was initiated
3035
+
3036
+ const scrollAdjustment = useScrollOffsetsDelta(scrollOffsets); // Represents the scroll delta since the last time the active node rect was measured
3037
+
3038
+ const activeNodeScrollDelta = useScrollOffsetsDelta(scrollOffsets, [activeNodeRect]);
3039
+ const scrollAdjustedTranslate = add(modifiedTranslate, scrollAdjustment);
3040
+ const collisionRect = draggingNodeRect ? getAdjustedRect(draggingNodeRect, modifiedTranslate) : null;
3041
+ const collisions = active && collisionRect ? collisionDetection({
3042
+ active,
3043
+ collisionRect,
3044
+ droppableRects,
3045
+ droppableContainers: enabledDroppableContainers,
3046
+ pointerCoordinates
3047
+ }) : null;
3048
+ const overId = getFirstCollision(collisions, 'id');
3049
+ const [over, setOver] = useState(null); // When there is no drag overlay used, we need to account for the
3050
+ // window scroll delta
3051
+
3052
+ const appliedTranslate = usesDragOverlay ? modifiedTranslate : add(modifiedTranslate, activeNodeScrollDelta);
3053
+ const transform = adjustScale(appliedTranslate, (_over$rect = over == null ? void 0 : over.rect) != null ? _over$rect : null, activeNodeRect);
3054
+ const activeSensorRef = useRef(null);
3055
+ const instantiateSensor = useCallback((event, _ref2) => {
3056
+ let {
3057
+ sensor: Sensor,
3058
+ options
3059
+ } = _ref2;
3060
+
3061
+ if (activeRef.current == null) {
3062
+ return;
3063
+ }
3064
+
3065
+ const activeNode = draggableNodes.get(activeRef.current);
3066
+
3067
+ if (!activeNode) {
3068
+ return;
3069
+ }
3070
+
3071
+ const activatorEvent = event.nativeEvent;
3072
+ const sensorInstance = new Sensor({
3073
+ active: activeRef.current,
3074
+ activeNode,
3075
+ event: activatorEvent,
3076
+ options,
3077
+ // Sensors need to be instantiated with refs for arguments that change over time
3078
+ // otherwise they are frozen in time with the stale arguments
3079
+ context: sensorContext,
3080
+
3081
+ onAbort(id) {
3082
+ const draggableNode = draggableNodes.get(id);
3083
+
3084
+ if (!draggableNode) {
3085
+ return;
3086
+ }
3087
+
3088
+ const {
3089
+ onDragAbort
3090
+ } = latestProps.current;
3091
+ const event = {
3092
+ id
3093
+ };
3094
+ onDragAbort == null ? void 0 : onDragAbort(event);
3095
+ dispatchMonitorEvent({
3096
+ type: 'onDragAbort',
3097
+ event
3098
+ });
3099
+ },
3100
+
3101
+ onPending(id, constraint, initialCoordinates, offset) {
3102
+ const draggableNode = draggableNodes.get(id);
3103
+
3104
+ if (!draggableNode) {
3105
+ return;
3106
+ }
3107
+
3108
+ const {
3109
+ onDragPending
3110
+ } = latestProps.current;
3111
+ const event = {
3112
+ id,
3113
+ constraint,
3114
+ initialCoordinates,
3115
+ offset
3116
+ };
3117
+ onDragPending == null ? void 0 : onDragPending(event);
3118
+ dispatchMonitorEvent({
3119
+ type: 'onDragPending',
3120
+ event
3121
+ });
3122
+ },
3123
+
3124
+ onStart(initialCoordinates) {
3125
+ const id = activeRef.current;
3126
+
3127
+ if (id == null) {
3128
+ return;
3129
+ }
3130
+
3131
+ const draggableNode = draggableNodes.get(id);
3132
+
3133
+ if (!draggableNode) {
3134
+ return;
3135
+ }
3136
+
3137
+ const {
3138
+ onDragStart
3139
+ } = latestProps.current;
3140
+ const event = {
3141
+ activatorEvent,
3142
+ active: {
3143
+ id,
3144
+ data: draggableNode.data,
3145
+ rect: activeRects
3146
+ }
3147
+ };
3148
+ unstable_batchedUpdates(() => {
3149
+ onDragStart == null ? void 0 : onDragStart(event);
3150
+ setStatus(Status.Initializing);
3151
+ dispatch({
3152
+ type: Action.DragStart,
3153
+ initialCoordinates,
3154
+ active: id
3155
+ });
3156
+ dispatchMonitorEvent({
3157
+ type: 'onDragStart',
3158
+ event
3159
+ });
3160
+ setActiveSensor(activeSensorRef.current);
3161
+ setActivatorEvent(activatorEvent);
3162
+ });
3163
+ },
3164
+
3165
+ onMove(coordinates) {
3166
+ dispatch({
3167
+ type: Action.DragMove,
3168
+ coordinates
3169
+ });
3170
+ },
3171
+
3172
+ onEnd: createHandler(Action.DragEnd),
3173
+ onCancel: createHandler(Action.DragCancel)
3174
+ });
3175
+ activeSensorRef.current = sensorInstance;
3176
+
3177
+ function createHandler(type) {
3178
+ return async function handler() {
3179
+ const {
3180
+ active,
3181
+ collisions,
3182
+ over,
3183
+ scrollAdjustedTranslate
3184
+ } = sensorContext.current;
3185
+ let event = null;
3186
+
3187
+ if (active && scrollAdjustedTranslate) {
3188
+ const {
3189
+ cancelDrop
3190
+ } = latestProps.current;
3191
+ event = {
3192
+ activatorEvent,
3193
+ active: active,
3194
+ collisions,
3195
+ delta: scrollAdjustedTranslate,
3196
+ over
3197
+ };
3198
+
3199
+ if (type === Action.DragEnd && typeof cancelDrop === 'function') {
3200
+ const shouldCancel = await Promise.resolve(cancelDrop(event));
3201
+
3202
+ if (shouldCancel) {
3203
+ type = Action.DragCancel;
3204
+ }
3205
+ }
3206
+ }
3207
+
3208
+ activeRef.current = null;
3209
+ unstable_batchedUpdates(() => {
3210
+ dispatch({
3211
+ type
3212
+ });
3213
+ setStatus(Status.Uninitialized);
3214
+ setOver(null);
3215
+ setActiveSensor(null);
3216
+ setActivatorEvent(null);
3217
+ activeSensorRef.current = null;
3218
+ const eventName = type === Action.DragEnd ? 'onDragEnd' : 'onDragCancel';
3219
+
3220
+ if (event) {
3221
+ const handler = latestProps.current[eventName];
3222
+ handler == null ? void 0 : handler(event);
3223
+ dispatchMonitorEvent({
3224
+ type: eventName,
3225
+ event
3226
+ });
3227
+ }
3228
+ });
3229
+ };
3230
+ }
3231
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3232
+ [draggableNodes]);
3233
+ const bindActivatorToSensorInstantiator = useCallback((handler, sensor) => {
3234
+ return (event, active) => {
3235
+ const nativeEvent = event.nativeEvent;
3236
+ const activeDraggableNode = draggableNodes.get(active);
3237
+
3238
+ if ( // Another sensor is already instantiating
3239
+ activeRef.current !== null || // No active draggable
3240
+ !activeDraggableNode || // Event has already been captured
3241
+ nativeEvent.dndKit || nativeEvent.defaultPrevented) {
3242
+ return;
3243
+ }
3244
+
3245
+ const activationContext = {
3246
+ active: activeDraggableNode
3247
+ };
3248
+ const shouldActivate = handler(event, sensor.options, activationContext);
3249
+
3250
+ if (shouldActivate === true) {
3251
+ nativeEvent.dndKit = {
3252
+ capturedBy: sensor.sensor
3253
+ };
3254
+ activeRef.current = active;
3255
+ instantiateSensor(event, sensor);
3256
+ }
3257
+ };
3258
+ }, [draggableNodes, instantiateSensor]);
3259
+ const activators = useCombineActivators(sensors, bindActivatorToSensorInstantiator);
3260
+ useSensorSetup(sensors);
3261
+ useIsomorphicLayoutEffect(() => {
3262
+ if (activeNodeRect && status === Status.Initializing) {
3263
+ setStatus(Status.Initialized);
3264
+ }
3265
+ }, [activeNodeRect, status]);
3266
+ useEffect(() => {
3267
+ const {
3268
+ onDragMove
3269
+ } = latestProps.current;
3270
+ const {
3271
+ active,
3272
+ activatorEvent,
3273
+ collisions,
3274
+ over
3275
+ } = sensorContext.current;
3276
+
3277
+ if (!active || !activatorEvent) {
3278
+ return;
3279
+ }
3280
+
3281
+ const event = {
3282
+ active,
3283
+ activatorEvent,
3284
+ collisions,
3285
+ delta: {
3286
+ x: scrollAdjustedTranslate.x,
3287
+ y: scrollAdjustedTranslate.y
3288
+ },
3289
+ over
3290
+ };
3291
+ unstable_batchedUpdates(() => {
3292
+ onDragMove == null ? void 0 : onDragMove(event);
3293
+ dispatchMonitorEvent({
3294
+ type: 'onDragMove',
3295
+ event
3296
+ });
3297
+ });
3298
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3299
+ [scrollAdjustedTranslate.x, scrollAdjustedTranslate.y]);
3300
+ useEffect(() => {
3301
+ const {
3302
+ active,
3303
+ activatorEvent,
3304
+ collisions,
3305
+ droppableContainers,
3306
+ scrollAdjustedTranslate
3307
+ } = sensorContext.current;
3308
+
3309
+ if (!active || activeRef.current == null || !activatorEvent || !scrollAdjustedTranslate) {
3310
+ return;
3311
+ }
3312
+
3313
+ const {
3314
+ onDragOver
3315
+ } = latestProps.current;
3316
+ const overContainer = droppableContainers.get(overId);
3317
+ const over = overContainer && overContainer.rect.current ? {
3318
+ id: overContainer.id,
3319
+ rect: overContainer.rect.current,
3320
+ data: overContainer.data,
3321
+ disabled: overContainer.disabled
3322
+ } : null;
3323
+ const event = {
3324
+ active,
3325
+ activatorEvent,
3326
+ collisions,
3327
+ delta: {
3328
+ x: scrollAdjustedTranslate.x,
3329
+ y: scrollAdjustedTranslate.y
3330
+ },
3331
+ over
3332
+ };
3333
+ unstable_batchedUpdates(() => {
3334
+ setOver(over);
3335
+ onDragOver == null ? void 0 : onDragOver(event);
3336
+ dispatchMonitorEvent({
3337
+ type: 'onDragOver',
3338
+ event
3339
+ });
3340
+ });
3341
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3342
+ [overId]);
3343
+ useIsomorphicLayoutEffect(() => {
3344
+ sensorContext.current = {
3345
+ activatorEvent,
3346
+ active,
3347
+ activeNode,
3348
+ collisionRect,
3349
+ collisions,
3350
+ droppableRects,
3351
+ draggableNodes,
3352
+ draggingNode,
3353
+ draggingNodeRect,
3354
+ droppableContainers,
3355
+ over,
3356
+ scrollableAncestors,
3357
+ scrollAdjustedTranslate
3358
+ };
3359
+ activeRects.current = {
3360
+ initial: draggingNodeRect,
3361
+ translated: collisionRect
3362
+ };
3363
+ }, [active, activeNode, collisions, collisionRect, draggableNodes, draggingNode, draggingNodeRect, droppableRects, droppableContainers, over, scrollableAncestors, scrollAdjustedTranslate]);
3364
+ useAutoScroller({ ...autoScrollOptions,
3365
+ delta: translate,
3366
+ draggingRect: collisionRect,
3367
+ pointerCoordinates,
3368
+ scrollableAncestors,
3369
+ scrollableAncestorRects
3370
+ });
3371
+ const publicContext = useMemo(() => {
3372
+ const context = {
3373
+ active,
3374
+ activeNode,
3375
+ activeNodeRect,
3376
+ activatorEvent,
3377
+ collisions,
3378
+ containerNodeRect,
3379
+ dragOverlay,
3380
+ draggableNodes,
3381
+ droppableContainers,
3382
+ droppableRects,
3383
+ over,
3384
+ measureDroppableContainers,
3385
+ scrollableAncestors,
3386
+ scrollableAncestorRects,
3387
+ measuringConfiguration,
3388
+ measuringScheduled,
3389
+ windowRect
3390
+ };
3391
+ return context;
3392
+ }, [active, activeNode, activeNodeRect, activatorEvent, collisions, containerNodeRect, dragOverlay, draggableNodes, droppableContainers, droppableRects, over, measureDroppableContainers, scrollableAncestors, scrollableAncestorRects, measuringConfiguration, measuringScheduled, windowRect]);
3393
+ const internalContext = useMemo(() => {
3394
+ const context = {
3395
+ activatorEvent,
3396
+ activators,
3397
+ active,
3398
+ activeNodeRect,
3399
+ ariaDescribedById: {
3400
+ draggable: draggableDescribedById
3401
+ },
3402
+ dispatch,
3403
+ draggableNodes,
3404
+ over,
3405
+ measureDroppableContainers
3406
+ };
3407
+ return context;
3408
+ }, [activatorEvent, activators, active, activeNodeRect, dispatch, draggableDescribedById, draggableNodes, over, measureDroppableContainers]);
3409
+ return React__default.createElement(DndMonitorContext.Provider, {
3410
+ value: registerMonitorListener
3411
+ }, React__default.createElement(InternalContext.Provider, {
3412
+ value: internalContext
3413
+ }, React__default.createElement(PublicContext.Provider, {
3414
+ value: publicContext
3415
+ }, React__default.createElement(ActiveDraggableContext.Provider, {
3416
+ value: transform
3417
+ }, children)), React__default.createElement(RestoreFocus, {
3418
+ disabled: (accessibility == null ? void 0 : accessibility.restoreFocus) === false
3419
+ })), React__default.createElement(Accessibility, { ...accessibility,
3420
+ hiddenTextDescribedById: draggableDescribedById
3421
+ }));
3422
+
3423
+ function getAutoScrollerOptions() {
3424
+ const activeSensorDisablesAutoscroll = (activeSensor == null ? void 0 : activeSensor.autoScrollEnabled) === false;
3425
+ const autoScrollGloballyDisabled = typeof autoScroll === 'object' ? autoScroll.enabled === false : autoScroll === false;
3426
+ const enabled = isInitialized && !activeSensorDisablesAutoscroll && !autoScrollGloballyDisabled;
3427
+
3428
+ if (typeof autoScroll === 'object') {
3429
+ return { ...autoScroll,
3430
+ enabled
3431
+ };
3432
+ }
3433
+
3434
+ return {
3435
+ enabled
3436
+ };
3437
+ }
3438
+ });
3439
+
3440
+ const NullContext = /*#__PURE__*/createContext(null);
3441
+ const defaultRole = 'button';
3442
+ const ID_PREFIX = 'Draggable';
3443
+ function useDraggable(_ref) {
3444
+ let {
3445
+ id,
3446
+ data,
3447
+ disabled = false,
3448
+ attributes
3449
+ } = _ref;
3450
+ const key = useUniqueId(ID_PREFIX);
3451
+ const {
3452
+ activators,
3453
+ activatorEvent,
3454
+ active,
3455
+ activeNodeRect,
3456
+ ariaDescribedById,
3457
+ draggableNodes,
3458
+ over
3459
+ } = useContext(InternalContext);
3460
+ const {
3461
+ role = defaultRole,
3462
+ roleDescription = 'draggable',
3463
+ tabIndex = 0
3464
+ } = attributes != null ? attributes : {};
3465
+ const isDragging = (active == null ? void 0 : active.id) === id;
3466
+ const transform = useContext(isDragging ? ActiveDraggableContext : NullContext);
3467
+ const [node, setNodeRef] = useNodeRef();
3468
+ const [activatorNode, setActivatorNodeRef] = useNodeRef();
3469
+ const listeners = useSyntheticListeners(activators, id);
3470
+ const dataRef = useLatestValue(data);
3471
+ useIsomorphicLayoutEffect(() => {
3472
+ draggableNodes.set(id, {
3473
+ id,
3474
+ key,
3475
+ node,
3476
+ activatorNode,
3477
+ data: dataRef
3478
+ });
3479
+ return () => {
3480
+ const node = draggableNodes.get(id);
3481
+
3482
+ if (node && node.key === key) {
3483
+ draggableNodes.delete(id);
3484
+ }
3485
+ };
3486
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3487
+ [draggableNodes, id]);
3488
+ const memoizedAttributes = useMemo(() => ({
3489
+ role,
3490
+ tabIndex,
3491
+ 'aria-disabled': disabled,
3492
+ 'aria-pressed': isDragging && role === defaultRole ? true : undefined,
3493
+ 'aria-roledescription': roleDescription,
3494
+ 'aria-describedby': ariaDescribedById.draggable
3495
+ }), [disabled, role, tabIndex, isDragging, roleDescription, ariaDescribedById.draggable]);
3496
+ return {
3497
+ active,
3498
+ activatorEvent,
3499
+ activeNodeRect,
3500
+ attributes: memoizedAttributes,
3501
+ isDragging,
3502
+ listeners: disabled ? undefined : listeners,
3503
+ node,
3504
+ over,
3505
+ setNodeRef,
3506
+ setActivatorNodeRef,
3507
+ transform
3508
+ };
3509
+ }
3510
+
3511
+ function useDndContext() {
3512
+ return useContext(PublicContext);
3513
+ }
3514
+
3515
+ const ID_PREFIX$1 = 'Droppable';
3516
+ const defaultResizeObserverConfig = {
3517
+ timeout: 25
3518
+ };
3519
+ function useDroppable(_ref) {
3520
+ let {
3521
+ data,
3522
+ disabled = false,
3523
+ id,
3524
+ resizeObserverConfig
3525
+ } = _ref;
3526
+ const key = useUniqueId(ID_PREFIX$1);
3527
+ const {
3528
+ active,
3529
+ dispatch,
3530
+ over,
3531
+ measureDroppableContainers
3532
+ } = useContext(InternalContext);
3533
+ const previous = useRef({
3534
+ disabled
3535
+ });
3536
+ const resizeObserverConnected = useRef(false);
3537
+ const rect = useRef(null);
3538
+ const callbackId = useRef(null);
3539
+ const {
3540
+ disabled: resizeObserverDisabled,
3541
+ updateMeasurementsFor,
3542
+ timeout: resizeObserverTimeout
3543
+ } = { ...defaultResizeObserverConfig,
3544
+ ...resizeObserverConfig
3545
+ };
3546
+ const ids = useLatestValue(updateMeasurementsFor != null ? updateMeasurementsFor : id);
3547
+ const handleResize = useCallback(() => {
3548
+ if (!resizeObserverConnected.current) {
3549
+ // ResizeObserver invokes the `handleResize` callback as soon as `observe` is called,
3550
+ // assuming the element is rendered and displayed.
3551
+ resizeObserverConnected.current = true;
3552
+ return;
3553
+ }
3554
+
3555
+ if (callbackId.current != null) {
3556
+ clearTimeout(callbackId.current);
3557
+ }
3558
+
3559
+ callbackId.current = setTimeout(() => {
3560
+ measureDroppableContainers(Array.isArray(ids.current) ? ids.current : [ids.current]);
3561
+ callbackId.current = null;
3562
+ }, resizeObserverTimeout);
3563
+ }, //eslint-disable-next-line react-hooks/exhaustive-deps
3564
+ [resizeObserverTimeout]);
3565
+ const resizeObserver = useResizeObserver({
3566
+ callback: handleResize,
3567
+ disabled: resizeObserverDisabled || !active
3568
+ });
3569
+ const handleNodeChange = useCallback((newElement, previousElement) => {
3570
+ if (!resizeObserver) {
3571
+ return;
3572
+ }
3573
+
3574
+ if (previousElement) {
3575
+ resizeObserver.unobserve(previousElement);
3576
+ resizeObserverConnected.current = false;
3577
+ }
3578
+
3579
+ if (newElement) {
3580
+ resizeObserver.observe(newElement);
3581
+ }
3582
+ }, [resizeObserver]);
3583
+ const [nodeRef, setNodeRef] = useNodeRef(handleNodeChange);
3584
+ const dataRef = useLatestValue(data);
3585
+ useEffect(() => {
3586
+ if (!resizeObserver || !nodeRef.current) {
3587
+ return;
3588
+ }
3589
+
3590
+ resizeObserver.disconnect();
3591
+ resizeObserverConnected.current = false;
3592
+ resizeObserver.observe(nodeRef.current);
3593
+ }, [nodeRef, resizeObserver]);
3594
+ useEffect(() => {
3595
+ dispatch({
3596
+ type: Action.RegisterDroppable,
3597
+ element: {
3598
+ id,
3599
+ key,
3600
+ disabled,
3601
+ node: nodeRef,
3602
+ rect,
3603
+ data: dataRef
3604
+ }
3605
+ });
3606
+ return () => dispatch({
3607
+ type: Action.UnregisterDroppable,
3608
+ key,
3609
+ id
3610
+ });
3611
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3612
+ [id]);
3613
+ useEffect(() => {
3614
+ if (disabled !== previous.current.disabled) {
3615
+ dispatch({
3616
+ type: Action.SetDroppableDisabled,
3617
+ id,
3618
+ key,
3619
+ disabled
3620
+ });
3621
+ previous.current.disabled = disabled;
3622
+ }
3623
+ }, [id, key, disabled, dispatch]);
3624
+ return {
3625
+ active,
3626
+ rect,
3627
+ isOver: (over == null ? void 0 : over.id) === id,
3628
+ node: nodeRef,
3629
+ over,
3630
+ setNodeRef
3631
+ };
3632
+ }
3633
+
3634
+ function AnimationManager(_ref) {
3635
+ let {
3636
+ animation,
3637
+ children
3638
+ } = _ref;
3639
+ const [clonedChildren, setClonedChildren] = useState(null);
3640
+ const [element, setElement] = useState(null);
3641
+ const previousChildren = usePrevious(children);
3642
+
3643
+ if (!children && !clonedChildren && previousChildren) {
3644
+ setClonedChildren(previousChildren);
3645
+ }
3646
+
3647
+ useIsomorphicLayoutEffect(() => {
3648
+ if (!element) {
3649
+ return;
3650
+ }
3651
+
3652
+ const key = clonedChildren == null ? void 0 : clonedChildren.key;
3653
+ const id = clonedChildren == null ? void 0 : clonedChildren.props.id;
3654
+
3655
+ if (key == null || id == null) {
3656
+ setClonedChildren(null);
3657
+ return;
3658
+ }
3659
+
3660
+ Promise.resolve(animation(id, element)).then(() => {
3661
+ setClonedChildren(null);
3662
+ });
3663
+ }, [animation, clonedChildren, element]);
3664
+ return React__default.createElement(React__default.Fragment, null, children, clonedChildren ? cloneElement(clonedChildren, {
3665
+ ref: setElement
3666
+ }) : null);
3667
+ }
3668
+
3669
+ const defaultTransform = {
3670
+ x: 0,
3671
+ y: 0,
3672
+ scaleX: 1,
3673
+ scaleY: 1
3674
+ };
3675
+ function NullifiedContextProvider(_ref) {
3676
+ let {
3677
+ children
3678
+ } = _ref;
3679
+ return React__default.createElement(InternalContext.Provider, {
3680
+ value: defaultInternalContext
3681
+ }, React__default.createElement(ActiveDraggableContext.Provider, {
3682
+ value: defaultTransform
3683
+ }, children));
3684
+ }
3685
+
3686
+ const baseStyles = {
3687
+ position: 'fixed',
3688
+ touchAction: 'none'
3689
+ };
3690
+
3691
+ const defaultTransition = activatorEvent => {
3692
+ const isKeyboardActivator = isKeyboardEvent(activatorEvent);
3693
+ return isKeyboardActivator ? 'transform 250ms ease' : undefined;
3694
+ };
3695
+
3696
+ const PositionedOverlay = /*#__PURE__*/forwardRef((_ref, ref) => {
3697
+ let {
3698
+ as,
3699
+ activatorEvent,
3700
+ adjustScale,
3701
+ children,
3702
+ className,
3703
+ rect,
3704
+ style,
3705
+ transform,
3706
+ transition = defaultTransition
3707
+ } = _ref;
3708
+
3709
+ if (!rect) {
3710
+ return null;
3711
+ }
3712
+
3713
+ const scaleAdjustedTransform = adjustScale ? transform : { ...transform,
3714
+ scaleX: 1,
3715
+ scaleY: 1
3716
+ };
3717
+ const styles = { ...baseStyles,
3718
+ width: rect.width,
3719
+ height: rect.height,
3720
+ top: rect.top,
3721
+ left: rect.left,
3722
+ transform: CSS.Transform.toString(scaleAdjustedTransform),
3723
+ transformOrigin: adjustScale && activatorEvent ? getRelativeTransformOrigin(activatorEvent, rect) : undefined,
3724
+ transition: typeof transition === 'function' ? transition(activatorEvent) : transition,
3725
+ ...style
3726
+ };
3727
+ return React__default.createElement(as, {
3728
+ className,
3729
+ style: styles,
3730
+ ref
3731
+ }, children);
3732
+ });
3733
+
3734
+ const defaultDropAnimationSideEffects = options => _ref => {
3735
+ let {
3736
+ active,
3737
+ dragOverlay
3738
+ } = _ref;
3739
+ const originalStyles = {};
3740
+ const {
3741
+ styles,
3742
+ className
3743
+ } = options;
3744
+
3745
+ if (styles != null && styles.active) {
3746
+ for (const [key, value] of Object.entries(styles.active)) {
3747
+ if (value === undefined) {
3748
+ continue;
3749
+ }
3750
+
3751
+ originalStyles[key] = active.node.style.getPropertyValue(key);
3752
+ active.node.style.setProperty(key, value);
3753
+ }
3754
+ }
3755
+
3756
+ if (styles != null && styles.dragOverlay) {
3757
+ for (const [key, value] of Object.entries(styles.dragOverlay)) {
3758
+ if (value === undefined) {
3759
+ continue;
3760
+ }
3761
+
3762
+ dragOverlay.node.style.setProperty(key, value);
3763
+ }
3764
+ }
3765
+
3766
+ if (className != null && className.active) {
3767
+ active.node.classList.add(className.active);
3768
+ }
3769
+
3770
+ if (className != null && className.dragOverlay) {
3771
+ dragOverlay.node.classList.add(className.dragOverlay);
3772
+ }
3773
+
3774
+ return function cleanup() {
3775
+ for (const [key, value] of Object.entries(originalStyles)) {
3776
+ active.node.style.setProperty(key, value);
3777
+ }
3778
+
3779
+ if (className != null && className.active) {
3780
+ active.node.classList.remove(className.active);
3781
+ }
3782
+ };
3783
+ };
3784
+
3785
+ const defaultKeyframeResolver = _ref2 => {
3786
+ let {
3787
+ transform: {
3788
+ initial,
3789
+ final
3790
+ }
3791
+ } = _ref2;
3792
+ return [{
3793
+ transform: CSS.Transform.toString(initial)
3794
+ }, {
3795
+ transform: CSS.Transform.toString(final)
3796
+ }];
3797
+ };
3798
+
3799
+ const defaultDropAnimationConfiguration = {
3800
+ duration: 250,
3801
+ easing: 'ease',
3802
+ keyframes: defaultKeyframeResolver,
3803
+ sideEffects: /*#__PURE__*/defaultDropAnimationSideEffects({
3804
+ styles: {
3805
+ active: {
3806
+ opacity: '0'
3807
+ }
3808
+ }
3809
+ })
3810
+ };
3811
+ function useDropAnimation(_ref3) {
3812
+ let {
3813
+ config,
3814
+ draggableNodes,
3815
+ droppableContainers,
3816
+ measuringConfiguration
3817
+ } = _ref3;
3818
+ return useEvent((id, node) => {
3819
+ if (config === null) {
3820
+ return;
3821
+ }
3822
+
3823
+ const activeDraggable = draggableNodes.get(id);
3824
+
3825
+ if (!activeDraggable) {
3826
+ return;
3827
+ }
3828
+
3829
+ const activeNode = activeDraggable.node.current;
3830
+
3831
+ if (!activeNode) {
3832
+ return;
3833
+ }
3834
+
3835
+ const measurableNode = getMeasurableNode(node);
3836
+
3837
+ if (!measurableNode) {
3838
+ return;
3839
+ }
3840
+
3841
+ const {
3842
+ transform
3843
+ } = getWindow(node).getComputedStyle(node);
3844
+ const parsedTransform = parseTransform(transform);
3845
+
3846
+ if (!parsedTransform) {
3847
+ return;
3848
+ }
3849
+
3850
+ const animation = typeof config === 'function' ? config : createDefaultDropAnimation(config);
3851
+ scrollIntoViewIfNeeded(activeNode, measuringConfiguration.draggable.measure);
3852
+ return animation({
3853
+ active: {
3854
+ id,
3855
+ data: activeDraggable.data,
3856
+ node: activeNode,
3857
+ rect: measuringConfiguration.draggable.measure(activeNode)
3858
+ },
3859
+ draggableNodes,
3860
+ dragOverlay: {
3861
+ node,
3862
+ rect: measuringConfiguration.dragOverlay.measure(measurableNode)
3863
+ },
3864
+ droppableContainers,
3865
+ measuringConfiguration,
3866
+ transform: parsedTransform
3867
+ });
3868
+ });
3869
+ }
3870
+
3871
+ function createDefaultDropAnimation(options) {
3872
+ const {
3873
+ duration,
3874
+ easing,
3875
+ sideEffects,
3876
+ keyframes
3877
+ } = { ...defaultDropAnimationConfiguration,
3878
+ ...options
3879
+ };
3880
+ return _ref4 => {
3881
+ let {
3882
+ active,
3883
+ dragOverlay,
3884
+ transform,
3885
+ ...rest
3886
+ } = _ref4;
3887
+
3888
+ if (!duration) {
3889
+ // Do not animate if animation duration is zero.
3890
+ return;
3891
+ }
3892
+
3893
+ const delta = {
3894
+ x: dragOverlay.rect.left - active.rect.left,
3895
+ y: dragOverlay.rect.top - active.rect.top
3896
+ };
3897
+ const scale = {
3898
+ scaleX: transform.scaleX !== 1 ? active.rect.width * transform.scaleX / dragOverlay.rect.width : 1,
3899
+ scaleY: transform.scaleY !== 1 ? active.rect.height * transform.scaleY / dragOverlay.rect.height : 1
3900
+ };
3901
+ const finalTransform = {
3902
+ x: transform.x - delta.x,
3903
+ y: transform.y - delta.y,
3904
+ ...scale
3905
+ };
3906
+ const animationKeyframes = keyframes({ ...rest,
3907
+ active,
3908
+ dragOverlay,
3909
+ transform: {
3910
+ initial: transform,
3911
+ final: finalTransform
3912
+ }
3913
+ });
3914
+ const [firstKeyframe] = animationKeyframes;
3915
+ const lastKeyframe = animationKeyframes[animationKeyframes.length - 1];
3916
+
3917
+ if (JSON.stringify(firstKeyframe) === JSON.stringify(lastKeyframe)) {
3918
+ // The start and end keyframes are the same, infer that there is no animation needed.
3919
+ return;
3920
+ }
3921
+
3922
+ const cleanup = sideEffects == null ? void 0 : sideEffects({
3923
+ active,
3924
+ dragOverlay,
3925
+ ...rest
3926
+ });
3927
+ const animation = dragOverlay.node.animate(animationKeyframes, {
3928
+ duration,
3929
+ easing,
3930
+ fill: 'forwards'
3931
+ });
3932
+ return new Promise(resolve => {
3933
+ animation.onfinish = () => {
3934
+ cleanup == null ? void 0 : cleanup();
3935
+ resolve();
3936
+ };
3937
+ });
3938
+ };
3939
+ }
3940
+
3941
+ let key = 0;
3942
+ function useKey(id) {
3943
+ return useMemo(() => {
3944
+ if (id == null) {
3945
+ return;
3946
+ }
3947
+
3948
+ key++;
3949
+ return key;
3950
+ }, [id]);
3951
+ }
3952
+
3953
+ const DragOverlay = /*#__PURE__*/React__default.memo(_ref => {
3954
+ let {
3955
+ adjustScale = false,
3956
+ children,
3957
+ dropAnimation: dropAnimationConfig,
3958
+ style,
3959
+ transition,
3960
+ modifiers,
3961
+ wrapperElement = 'div',
3962
+ className,
3963
+ zIndex = 999
3964
+ } = _ref;
3965
+ const {
3966
+ activatorEvent,
3967
+ active,
3968
+ activeNodeRect,
3969
+ containerNodeRect,
3970
+ draggableNodes,
3971
+ droppableContainers,
3972
+ dragOverlay,
3973
+ over,
3974
+ measuringConfiguration,
3975
+ scrollableAncestors,
3976
+ scrollableAncestorRects,
3977
+ windowRect
3978
+ } = useDndContext();
3979
+ const transform = useContext(ActiveDraggableContext);
3980
+ const key = useKey(active == null ? void 0 : active.id);
3981
+ const modifiedTransform = applyModifiers(modifiers, {
3982
+ activatorEvent,
3983
+ active,
3984
+ activeNodeRect,
3985
+ containerNodeRect,
3986
+ draggingNodeRect: dragOverlay.rect,
3987
+ over,
3988
+ overlayNodeRect: dragOverlay.rect,
3989
+ scrollableAncestors,
3990
+ scrollableAncestorRects,
3991
+ transform,
3992
+ windowRect
3993
+ });
3994
+ const initialRect = useInitialValue(activeNodeRect);
3995
+ const dropAnimation = useDropAnimation({
3996
+ config: dropAnimationConfig,
3997
+ draggableNodes,
3998
+ droppableContainers,
3999
+ measuringConfiguration
4000
+ }); // We need to wait for the active node to be measured before connecting the drag overlay ref
4001
+ // otherwise collisions can be computed against a mispositioned drag overlay
4002
+
4003
+ const ref = initialRect ? dragOverlay.setRef : undefined;
4004
+ return React__default.createElement(NullifiedContextProvider, null, React__default.createElement(AnimationManager, {
4005
+ animation: dropAnimation
4006
+ }, active && key ? React__default.createElement(PositionedOverlay, {
4007
+ key: key,
4008
+ id: active.id,
4009
+ ref: ref,
4010
+ as: wrapperElement,
4011
+ activatorEvent: activatorEvent,
4012
+ adjustScale: adjustScale,
4013
+ className: className,
4014
+ transition: transition,
4015
+ rect: initialRect,
4016
+ style: {
4017
+ zIndex,
4018
+ ...style
4019
+ },
4020
+ transform: modifiedTransform
4021
+ }, children) : null));
4022
+ });
4023
+
4024
+ export { AutoScrollActivator as A, DndContext as D, KeyboardCode as K, MeasuringFrequency as M, PointerSensor as P, TouchSensor as T, DragOverlay as a, KeyboardSensor as b, MeasuringStrategy as c, MouseSensor as d, TraversalOrder as e, applyModifiers as f, closestCenter as g, closestCorners as h, defaultAnnouncements as i, defaultCoordinates as j, defaultDropAnimationConfiguration as k, defaultDropAnimationSideEffects as l, defaultKeyboardCoordinateGetter as m, defaultScreenReaderInstructions as n, getClientRect as o, getFirstCollision as p, getScrollableAncestors as q, pointerWithin as r, rectIntersection as s, useDndMonitor as t, useDndContext as u, useDraggable as v, useDroppable as w, useSensor as x, useSensors as y };
4025
+ //# sourceMappingURL=core.esm.js.map