@123usmanhaider321/ui 0.1.8 → 1.0.2

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 (545) hide show
  1. package/README.md +416 -31
  2. package/dist/images/icon/1LINK.svg +50 -0
  3. package/dist/images/icon/CreditCard.svg +83 -0
  4. package/dist/images/icon/Easypaisa.png +0 -0
  5. package/dist/images/icon/MobileWallet.png +0 -0
  6. package/dist/images/icon/Raast-Logo.png +0 -0
  7. package/dist/images/icon/VISA.png +0 -0
  8. package/dist/images/icon/add-circle-1.svg +5 -0
  9. package/dist/images/icon/check-circle-broken.svg +3 -0
  10. package/dist/images/icon/close-circle.svg +5 -0
  11. package/dist/images/icon/jazzcash.png +0 -0
  12. package/dist/images/icon/loading_icon.json +3347 -0
  13. package/dist/images/icon/mastercard-logo.webp +0 -0
  14. package/dist/images/icon/paymo.jpeg +0 -0
  15. package/dist/images/icon/preview-svgrepo-com.svg +36 -0
  16. package/dist/images/icon/trash.svg +7 -0
  17. package/dist/images/icon/unionpay-logo.svg +9 -0
  18. package/dist/index-BLoegwT6.js +60476 -0
  19. package/dist/index-BLoegwT6.js.map +1 -0
  20. package/dist/index-CPnu5V8f.js +11119 -0
  21. package/dist/index-CPnu5V8f.js.map +1 -0
  22. package/dist/index.d.ts +1 -10
  23. package/dist/index.es-C5pDhGOr.js +16734 -0
  24. package/dist/index.es-C5pDhGOr.js.map +1 -0
  25. package/dist/index.js +40 -12
  26. package/dist/index.js.map +1 -1
  27. package/dist/loading_icon-n5H5dQBl.js +3375 -0
  28. package/dist/loading_icon-n5H5dQBl.js.map +1 -0
  29. package/dist/src/components/Alert/ErrorAlert.d.ts +6 -0
  30. package/dist/src/components/Alert/SuccessAlert.d.ts +6 -0
  31. package/dist/{components → src/components}/FormBuilder/DiscountInput.d.ts +3 -6
  32. package/dist/{components → src/components}/FormBuilder/FormBuilder.d.ts +2 -11
  33. package/dist/{components → src/components}/FormBuilder/QuestionCard.d.ts +0 -5
  34. package/dist/{components → src/components}/FormBuilder/QuestionEditor.d.ts +0 -5
  35. package/dist/{components → src/components}/FormBuilder/SortableQuestionList.d.ts +0 -5
  36. package/dist/src/components/FormBuilder/questionIcons.d.ts +5 -0
  37. package/dist/{components/EventAddForm → src/components/NewAddEvent}/AddEventLayout.d.ts +2 -1
  38. package/dist/{components/EventAddForm → src/components/NewAddEvent}/AddEventStepper.d.ts +2 -2
  39. package/dist/{components/EventAddForm → src/components/NewAddEvent}/common/ConfirmationModal.d.ts +1 -1
  40. package/dist/src/components/NewAddEvent/components/EventSubmissionConfirmationModal.d.ts +14 -0
  41. package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/StepTwo/TicketTierSection.d.ts +1 -1
  42. package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/TicketTierForm.d.ts +1 -1
  43. package/dist/{components/EventAddForm → src/components/NewAddEvent}/hooks/useStepperForm.d.ts +22 -22
  44. package/dist/{components/EventAddForm → src/components/NewAddEvent}/hooks/useTicketTierForm.d.ts +63 -15
  45. package/dist/src/components/NewAddEvent/schemas/step1.d.ts +211 -0
  46. package/dist/src/components/NewAddEvent/schemas/step2.d.ts +411 -0
  47. package/dist/{components/EventAddForm → src/components/NewAddEvent}/schemas/utils.d.ts +8 -2
  48. package/dist/{components/EventAddForm → src/components/NewAddEvent}/steps/IndividualFormStep.d.ts +1 -1
  49. package/dist/{components/EventAddForm → src/components/NewAddEvent}/steps/SocialProfilesStep.d.ts +1 -1
  50. package/dist/{components/EventAddForm → src/components/NewAddEvent}/steps/TeamFormStep.d.ts +1 -1
  51. package/dist/src/components/Spinner/spinner.d.ts +4 -0
  52. package/dist/src/components/TicketlyUIProvider.d.ts +35 -0
  53. package/dist/src/components/common/Loader/index.d.ts +8 -0
  54. package/dist/src/components/common/Modals/ConfirmationModal.d.ts +7 -0
  55. package/dist/{components/FormInput → src/components/ui}/FormInput.d.ts +1 -1
  56. package/dist/src/components/ui/Loader.d.ts +4 -0
  57. package/dist/{components/Button/Button.d.ts → src/components/ui/button.d.ts} +1 -1
  58. package/dist/src/index.d.ts +10 -0
  59. package/dist/{lib → src/lib}/actions.d.ts +0 -126
  60. package/dist/src/lib/dom-utils.d.ts +2 -0
  61. package/dist/src/lib/storage-utils.d.ts +5 -0
  62. package/dist/src/lib/types.d.ts +258 -0
  63. package/dist/src/redux/baseQuery.d.ts +16 -0
  64. package/dist/{services → src/redux/features}/eventApi.d.ts +1053 -1745
  65. package/dist/src/redux/features/globalSlice.d.ts +17 -0
  66. package/dist/{services → src/redux/features/single-event}/single-event-api.d.ts +856 -1190
  67. package/dist/src/redux/types.d.ts +2 -0
  68. package/dist/src/services/library-services.d.ts +15 -0
  69. package/dist/src/services/remote-config.d.ts +27 -0
  70. package/dist/{services → src/services}/utils.d.ts +1 -1
  71. package/dist/src/theme/colors.d.ts +127 -0
  72. package/dist/src/theme/typography.d.ts +13 -0
  73. package/dist/src/types/api.d.ts +18 -0
  74. package/dist/style.css +2984 -0
  75. package/dist/styles.css +3760 -4014
  76. package/package.json +78 -68
  77. package/dist/_virtual/_commonjsHelpers.js +0 -9
  78. package/dist/_virtual/_commonjsHelpers.js.map +0 -1
  79. package/dist/_virtual/customParseFormat.js +0 -5
  80. package/dist/_virtual/customParseFormat.js.map +0 -1
  81. package/dist/_virtual/dayjs.min.js +0 -5
  82. package/dist/_virtual/dayjs.min.js.map +0 -1
  83. package/dist/_virtual/duration.js +0 -5
  84. package/dist/_virtual/duration.js.map +0 -1
  85. package/dist/_virtual/index.js +0 -5
  86. package/dist/_virtual/index.js.map +0 -1
  87. package/dist/_virtual/isBetween.js +0 -5
  88. package/dist/_virtual/isBetween.js.map +0 -1
  89. package/dist/_virtual/relativeTime.js +0 -5
  90. package/dist/_virtual/relativeTime.js.map +0 -1
  91. package/dist/_virtual/use-sync-external-store-shim.development.js +0 -5
  92. package/dist/_virtual/use-sync-external-store-shim.development.js.map +0 -1
  93. package/dist/_virtual/use-sync-external-store-shim.production.js +0 -5
  94. package/dist/_virtual/use-sync-external-store-shim.production.js.map +0 -1
  95. package/dist/_virtual/with-selector.development.js +0 -5
  96. package/dist/_virtual/with-selector.development.js.map +0 -1
  97. package/dist/_virtual/with-selector.js +0 -5
  98. package/dist/_virtual/with-selector.js.map +0 -1
  99. package/dist/_virtual/with-selector.production.js +0 -5
  100. package/dist/_virtual/with-selector.production.js.map +0 -1
  101. package/dist/components/Alert/Alert.js +0 -51
  102. package/dist/components/Alert/Alert.js.map +0 -1
  103. package/dist/components/Button/Button.js +0 -52
  104. package/dist/components/Button/Button.js.map +0 -1
  105. package/dist/components/Button/Button.test.d.ts +0 -1
  106. package/dist/components/Button/index.d.ts +0 -1
  107. package/dist/components/Checkbox/Checkbox.js +0 -50
  108. package/dist/components/Checkbox/Checkbox.js.map +0 -1
  109. package/dist/components/Checkbox/Checkbox.test.d.ts +0 -1
  110. package/dist/components/Checkbox/index.d.ts +0 -1
  111. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +0 -25
  112. package/dist/components/CheckboxGroup/CheckboxGroup.js +0 -99
  113. package/dist/components/CheckboxGroup/CheckboxGroup.js.map +0 -1
  114. package/dist/components/ConfirmationModal/ConfirmationModal.d.ts +0 -15
  115. package/dist/components/ConfirmationModal/ConfirmationModal.js +0 -136
  116. package/dist/components/ConfirmationModal/ConfirmationModal.js.map +0 -1
  117. package/dist/components/ConfirmationModal/index.d.ts +0 -2
  118. package/dist/components/CustomSelect/CustomSelect.js +0 -259
  119. package/dist/components/CustomSelect/CustomSelect.js.map +0 -1
  120. package/dist/components/EventAddForm/AddEventLayout.js +0 -227
  121. package/dist/components/EventAddForm/AddEventLayout.js.map +0 -1
  122. package/dist/components/EventAddForm/AddEventStepper.js +0 -719
  123. package/dist/components/EventAddForm/AddEventStepper.js.map +0 -1
  124. package/dist/components/EventAddForm/common/ConfirmationModal.js +0 -136
  125. package/dist/components/EventAddForm/common/ConfirmationModal.js.map +0 -1
  126. package/dist/components/EventAddForm/common/DescriptionModal.js +0 -70
  127. package/dist/components/EventAddForm/common/DescriptionModal.js.map +0 -1
  128. package/dist/components/EventAddForm/components/AnimatedBackground.d.ts +0 -8
  129. package/dist/components/EventAddForm/components/ApprovalConfirmationModal.d.ts +0 -7
  130. package/dist/components/EventAddForm/components/CheckboxGroup.js +0 -92
  131. package/dist/components/EventAddForm/components/CheckboxGroup.js.map +0 -1
  132. package/dist/components/EventAddForm/components/CustomMeetingForm.js +0 -237
  133. package/dist/components/EventAddForm/components/CustomMeetingForm.js.map +0 -1
  134. package/dist/components/EventAddForm/components/DateTimeField.js +0 -173
  135. package/dist/components/EventAddForm/components/DateTimeField.js.map +0 -1
  136. package/dist/components/EventAddForm/components/EventSubmissionConfirmationModal.d.ts +0 -33
  137. package/dist/components/EventAddForm/components/EventSubmissionConfirmationModal.js +0 -366
  138. package/dist/components/EventAddForm/components/EventSubmissionConfirmationModal.js.map +0 -1
  139. package/dist/components/EventAddForm/components/FileUpload.js +0 -412
  140. package/dist/components/EventAddForm/components/FileUpload.js.map +0 -1
  141. package/dist/components/EventAddForm/components/FormBuilderProceedModal.js +0 -197
  142. package/dist/components/EventAddForm/components/FormBuilderProceedModal.js.map +0 -1
  143. package/dist/components/EventAddForm/components/GoogleMapsAutocompleteInput.js +0 -1179
  144. package/dist/components/EventAddForm/components/GoogleMapsAutocompleteInput.js.map +0 -1
  145. package/dist/components/EventAddForm/components/InputField.d.ts +0 -15
  146. package/dist/components/EventAddForm/components/RadioGroupButton.d.ts +0 -14
  147. package/dist/components/EventAddForm/components/SelectField.d.ts +0 -19
  148. package/dist/components/EventAddForm/components/SingleDateTimeInput.js +0 -102
  149. package/dist/components/EventAddForm/components/SingleDateTimeInput.js.map +0 -1
  150. package/dist/components/EventAddForm/components/StepTwo/CustomFormSection.js +0 -277
  151. package/dist/components/EventAddForm/components/StepTwo/CustomFormSection.js.map +0 -1
  152. package/dist/components/EventAddForm/components/StepTwo/TicketTierSection.js +0 -148
  153. package/dist/components/EventAddForm/components/StepTwo/TicketTierSection.js.map +0 -1
  154. package/dist/components/EventAddForm/components/TicketTierForm.js +0 -418
  155. package/dist/components/EventAddForm/components/TicketTierForm.js.map +0 -1
  156. package/dist/components/EventAddForm/components/TicketTypeSelection.js +0 -93
  157. package/dist/components/EventAddForm/components/TicketTypeSelection.js.map +0 -1
  158. package/dist/components/EventAddForm/hooks/useStepperForm.js +0 -371
  159. package/dist/components/EventAddForm/hooks/useStepperForm.js.map +0 -1
  160. package/dist/components/EventAddForm/hooks/useTicketTierForm.js +0 -237
  161. package/dist/components/EventAddForm/hooks/useTicketTierForm.js.map +0 -1
  162. package/dist/components/EventAddForm/index.d.ts +0 -3
  163. package/dist/components/EventAddForm/index.js +0 -41
  164. package/dist/components/EventAddForm/index.js.map +0 -1
  165. package/dist/components/EventAddForm/schemas/index.d.ts +0 -2
  166. package/dist/components/EventAddForm/schemas/step1.d.ts +0 -47
  167. package/dist/components/EventAddForm/schemas/step1.js +0 -135
  168. package/dist/components/EventAddForm/schemas/step1.js.map +0 -1
  169. package/dist/components/EventAddForm/schemas/step2.d.ts +0 -138
  170. package/dist/components/EventAddForm/schemas/step2.js +0 -94
  171. package/dist/components/EventAddForm/schemas/step2.js.map +0 -1
  172. package/dist/components/EventAddForm/schemas/utils.js +0 -28
  173. package/dist/components/EventAddForm/schemas/utils.js.map +0 -1
  174. package/dist/components/EventAddForm/steps/IndividualFormStep.js +0 -85
  175. package/dist/components/EventAddForm/steps/IndividualFormStep.js.map +0 -1
  176. package/dist/components/EventAddForm/steps/SocialProfilesStep.js +0 -123
  177. package/dist/components/EventAddForm/steps/SocialProfilesStep.js.map +0 -1
  178. package/dist/components/EventAddForm/steps/StepOne.js +0 -462
  179. package/dist/components/EventAddForm/steps/StepOne.js.map +0 -1
  180. package/dist/components/EventAddForm/steps/StepTwo.js +0 -173
  181. package/dist/components/EventAddForm/steps/StepTwo.js.map +0 -1
  182. package/dist/components/EventAddForm/steps/TeamFormStep.js +0 -13
  183. package/dist/components/EventAddForm/steps/TeamFormStep.js.map +0 -1
  184. package/dist/components/FormBuilder/CategoryList.js +0 -242
  185. package/dist/components/FormBuilder/CategoryList.js.map +0 -1
  186. package/dist/components/FormBuilder/DiscountInput.js +0 -366
  187. package/dist/components/FormBuilder/DiscountInput.js.map +0 -1
  188. package/dist/components/FormBuilder/FormBuilder.js +0 -918
  189. package/dist/components/FormBuilder/FormBuilder.js.map +0 -1
  190. package/dist/components/FormBuilder/OptionList.js +0 -120
  191. package/dist/components/FormBuilder/OptionList.js.map +0 -1
  192. package/dist/components/FormBuilder/PaymentPreview.d.ts +0 -12
  193. package/dist/components/FormBuilder/PaymentPreview.js +0 -70
  194. package/dist/components/FormBuilder/PaymentPreview.js.map +0 -1
  195. package/dist/components/FormBuilder/PreviewInput.d.ts +0 -10
  196. package/dist/components/FormBuilder/PreviewInput.js +0 -143
  197. package/dist/components/FormBuilder/PreviewInput.js.map +0 -1
  198. package/dist/components/FormBuilder/QuestionCard.js +0 -252
  199. package/dist/components/FormBuilder/QuestionCard.js.map +0 -1
  200. package/dist/components/FormBuilder/QuestionEditor.js +0 -166
  201. package/dist/components/FormBuilder/QuestionEditor.js.map +0 -1
  202. package/dist/components/FormBuilder/RequiredToggle.js +0 -43
  203. package/dist/components/FormBuilder/RequiredToggle.js.map +0 -1
  204. package/dist/components/FormBuilder/SortableQuestionList.js +0 -137
  205. package/dist/components/FormBuilder/SortableQuestionList.js.map +0 -1
  206. package/dist/components/FormBuilder/index.d.ts +0 -4
  207. package/dist/components/FormBuilder/utils.js +0 -229
  208. package/dist/components/FormBuilder/utils.js.map +0 -1
  209. package/dist/components/FormInput/FormInput.js +0 -126
  210. package/dist/components/FormInput/FormInput.js.map +0 -1
  211. package/dist/components/FormInput/FormInput.test.d.ts +0 -1
  212. package/dist/components/FormInput/index.d.ts +0 -2
  213. package/dist/components/ImageCropModal/index.js +0 -464
  214. package/dist/components/ImageCropModal/index.js.map +0 -1
  215. package/dist/components/InformationPopover/InformationPopover.d.ts +0 -7
  216. package/dist/components/InformationPopover/InformationPopover.js +0 -19
  217. package/dist/components/InformationPopover/InformationPopover.js.map +0 -1
  218. package/dist/components/InformationPopover.js +0 -19
  219. package/dist/components/InformationPopover.js.map +0 -1
  220. package/dist/components/InputErrorMessage/InputErrorMessage.js +0 -21
  221. package/dist/components/InputErrorMessage/InputErrorMessage.js.map +0 -1
  222. package/dist/components/Modal/Modal.d.ts +0 -15
  223. package/dist/components/Modal/Modal.js +0 -73
  224. package/dist/components/Modal/Modal.js.map +0 -1
  225. package/dist/components/Radio/Radio.js +0 -35
  226. package/dist/components/Radio/Radio.js.map +0 -1
  227. package/dist/components/Spinner/spinner.d.ts +0 -2
  228. package/dist/components/Spinner/spinner.js +0 -22
  229. package/dist/components/Spinner/spinner.js.map +0 -1
  230. package/dist/components/Toggle/Toggle.d.ts +0 -16
  231. package/dist/components/Toggle/index.d.ts +0 -2
  232. package/dist/components/Tooltip/Tooltip.d.ts +0 -12
  233. package/dist/components/Tooltip/Tooltip.js +0 -134
  234. package/dist/components/Tooltip/Tooltip.js.map +0 -1
  235. package/dist/components/common/FallbackImage.js +0 -47
  236. package/dist/components/common/FallbackImage.js.map +0 -1
  237. package/dist/components/ui/Calendar/calendar-utils.js +0 -51
  238. package/dist/components/ui/Calendar/calendar-utils.js.map +0 -1
  239. package/dist/components/ui/Calendar/index.js +0 -142
  240. package/dist/components/ui/Calendar/index.js.map +0 -1
  241. package/dist/components/ui/Checkbox.d.ts +0 -9
  242. package/dist/components/ui/Checkbox.js +0 -50
  243. package/dist/components/ui/Checkbox.js.map +0 -1
  244. package/dist/components/ui/DatePicker/index.js +0 -188
  245. package/dist/components/ui/DatePicker/index.js.map +0 -1
  246. package/dist/components/ui/FormInput.js +0 -129
  247. package/dist/components/ui/FormInput.js.map +0 -1
  248. package/dist/components/ui/InputErrorMessage.d.ts +0 -7
  249. package/dist/components/ui/InputErrorMessage.js +0 -21
  250. package/dist/components/ui/InputErrorMessage.js.map +0 -1
  251. package/dist/components/ui/Modal/index.js +0 -73
  252. package/dist/components/ui/Modal/index.js.map +0 -1
  253. package/dist/components/ui/Radio.d.ts +0 -6
  254. package/dist/components/ui/Radio.js +0 -35
  255. package/dist/components/ui/Radio.js.map +0 -1
  256. package/dist/components/ui/RichTextEditor.js +0 -242
  257. package/dist/components/ui/RichTextEditor.js.map +0 -1
  258. package/dist/components/ui/TimePicker/index.js +0 -215
  259. package/dist/components/ui/TimePicker/index.js.map +0 -1
  260. package/dist/components/ui/TimeSelector/index.js +0 -138
  261. package/dist/components/ui/TimeSelector/index.js.map +0 -1
  262. package/dist/components/ui/Tooltip.d.ts +0 -12
  263. package/dist/components/ui/Tooltip.js +0 -136
  264. package/dist/components/ui/Tooltip.js.map +0 -1
  265. package/dist/hooks/useDropdownPosition.d.ts +0 -11
  266. package/dist/hooks/useFirebaseAuthState.d.ts +0 -6
  267. package/dist/hooks/useFirebaseAuthState.js +0 -23
  268. package/dist/hooks/useFirebaseAuthState.js.map +0 -1
  269. package/dist/hooks/useTicketTierForm.d.ts +0 -61
  270. package/dist/lib/actions.js +0 -32
  271. package/dist/lib/actions.js.map +0 -1
  272. package/dist/lib/cropImage.js +0 -113
  273. package/dist/lib/cropImage.js.map +0 -1
  274. package/dist/lib/imageAnalysis.js +0 -58
  275. package/dist/lib/imageAnalysis.js.map +0 -1
  276. package/dist/lib/utils.js +0 -9
  277. package/dist/lib/utils.js.map +0 -1
  278. package/dist/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.js +0 -60
  279. package/dist/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.js.map +0 -1
  280. package/dist/node_modules/@dnd-kit/core/dist/core.esm.js +0 -3458
  281. package/dist/node_modules/@dnd-kit/core/dist/core.esm.js.map +0 -1
  282. package/dist/node_modules/@dnd-kit/sortable/dist/sortable.esm.js +0 -593
  283. package/dist/node_modules/@dnd-kit/sortable/dist/sortable.esm.js.map +0 -1
  284. package/dist/node_modules/@dnd-kit/utilities/dist/utilities.esm.js +0 -302
  285. package/dist/node_modules/@dnd-kit/utilities/dist/utilities.esm.js.map +0 -1
  286. package/dist/node_modules/@firebase/app/dist/esm/index.esm.js +0 -768
  287. package/dist/node_modules/@firebase/app/dist/esm/index.esm.js.map +0 -1
  288. package/dist/node_modules/@firebase/component/dist/esm/index.esm.js +0 -340
  289. package/dist/node_modules/@firebase/component/dist/esm/index.esm.js.map +0 -1
  290. package/dist/node_modules/@firebase/logger/dist/esm/index.esm.js +0 -123
  291. package/dist/node_modules/@firebase/logger/dist/esm/index.esm.js.map +0 -1
  292. package/dist/node_modules/@firebase/storage/dist/index.esm.js +0 -2623
  293. package/dist/node_modules/@firebase/storage/dist/index.esm.js.map +0 -1
  294. package/dist/node_modules/@firebase/util/dist/index.esm.js +0 -658
  295. package/dist/node_modules/@firebase/util/dist/index.esm.js.map +0 -1
  296. package/dist/node_modules/@firebase/util/dist/postinstall.js +0 -5
  297. package/dist/node_modules/@firebase/util/dist/postinstall.js.map +0 -1
  298. package/dist/node_modules/@fortawesome/fontawesome-svg-core/index.js +0 -3179
  299. package/dist/node_modules/@fortawesome/fontawesome-svg-core/index.js.map +0 -1
  300. package/dist/node_modules/@fortawesome/free-solid-svg-icons/index.js +0 -60
  301. package/dist/node_modules/@fortawesome/free-solid-svg-icons/index.js.map +0 -1
  302. package/dist/node_modules/@fortawesome/react-fontawesome/dist/index.js +0 -400
  303. package/dist/node_modules/@fortawesome/react-fontawesome/dist/index.js.map +0 -1
  304. package/dist/node_modules/@heroicons/react/20/solid/esm/CheckIcon.js +0 -27
  305. package/dist/node_modules/@heroicons/react/20/solid/esm/CheckIcon.js.map +0 -1
  306. package/dist/node_modules/@heroicons/react/20/solid/esm/ChevronDownIcon.js +0 -27
  307. package/dist/node_modules/@heroicons/react/20/solid/esm/ChevronDownIcon.js.map +0 -1
  308. package/dist/node_modules/@heroicons/react/24/outline/esm/ArrowRightIcon.js +0 -29
  309. package/dist/node_modules/@heroicons/react/24/outline/esm/ArrowRightIcon.js.map +0 -1
  310. package/dist/node_modules/@heroicons/react/24/outline/esm/ClockIcon.js +0 -29
  311. package/dist/node_modules/@heroicons/react/24/outline/esm/ClockIcon.js.map +0 -1
  312. package/dist/node_modules/@heroicons/react/24/outline/esm/DocumentDuplicateIcon.js +0 -29
  313. package/dist/node_modules/@heroicons/react/24/outline/esm/DocumentDuplicateIcon.js.map +0 -1
  314. package/dist/node_modules/@heroicons/react/24/outline/esm/InformationCircleIcon.js +0 -29
  315. package/dist/node_modules/@heroicons/react/24/outline/esm/InformationCircleIcon.js.map +0 -1
  316. package/dist/node_modules/@heroicons/react/24/outline/esm/LinkIcon.js +0 -29
  317. package/dist/node_modules/@heroicons/react/24/outline/esm/LinkIcon.js.map +0 -1
  318. package/dist/node_modules/@heroicons/react/24/outline/esm/MagnifyingGlassIcon.js +0 -29
  319. package/dist/node_modules/@heroicons/react/24/outline/esm/MagnifyingGlassIcon.js.map +0 -1
  320. package/dist/node_modules/@heroicons/react/24/outline/esm/MapPinIcon.js +0 -33
  321. package/dist/node_modules/@heroicons/react/24/outline/esm/MapPinIcon.js.map +0 -1
  322. package/dist/node_modules/@heroicons/react/24/outline/esm/VideoCameraIcon.js +0 -29
  323. package/dist/node_modules/@heroicons/react/24/outline/esm/VideoCameraIcon.js.map +0 -1
  324. package/dist/node_modules/@heroicons/react/24/outline/esm/XMarkIcon.js +0 -29
  325. package/dist/node_modules/@heroicons/react/24/outline/esm/XMarkIcon.js.map +0 -1
  326. package/dist/node_modules/@tiptap/core/dist/index.js +0 -5446
  327. package/dist/node_modules/@tiptap/core/dist/index.js.map +0 -1
  328. package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +0 -21
  329. package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js.map +0 -1
  330. package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js +0 -78
  331. package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js.map +0 -1
  332. package/dist/node_modules/@tiptap/extension-bold/dist/index.js +0 -100
  333. package/dist/node_modules/@tiptap/extension-bold/dist/index.js.map +0 -1
  334. package/dist/node_modules/@tiptap/extension-code/dist/index.js +0 -70
  335. package/dist/node_modules/@tiptap/extension-code/dist/index.js.map +0 -1
  336. package/dist/node_modules/@tiptap/extension-code-block/dist/index.js +0 -317
  337. package/dist/node_modules/@tiptap/extension-code-block/dist/index.js.map +0 -1
  338. package/dist/node_modules/@tiptap/extension-document/dist/index.js +0 -16
  339. package/dist/node_modules/@tiptap/extension-document/dist/index.js.map +0 -1
  340. package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js +0 -66
  341. package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js.map +0 -1
  342. package/dist/node_modules/@tiptap/extension-heading/dist/index.js +0 -86
  343. package/dist/node_modules/@tiptap/extension-heading/dist/index.js.map +0 -1
  344. package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js +0 -80
  345. package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js.map +0 -1
  346. package/dist/node_modules/@tiptap/extension-italic/dist/index.js +0 -98
  347. package/dist/node_modules/@tiptap/extension-italic/dist/index.js.map +0 -1
  348. package/dist/node_modules/@tiptap/extension-link/dist/index.js +0 -423
  349. package/dist/node_modules/@tiptap/extension-link/dist/index.js.map +0 -1
  350. package/dist/node_modules/@tiptap/extension-list/dist/index.js +0 -1039
  351. package/dist/node_modules/@tiptap/extension-list/dist/index.js.map +0 -1
  352. package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js +0 -61
  353. package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js.map +0 -1
  354. package/dist/node_modules/@tiptap/extension-placeholder/dist/index.js +0 -7
  355. package/dist/node_modules/@tiptap/extension-placeholder/dist/index.js.map +0 -1
  356. package/dist/node_modules/@tiptap/extension-strike/dist/index.js +0 -79
  357. package/dist/node_modules/@tiptap/extension-strike/dist/index.js.map +0 -1
  358. package/dist/node_modules/@tiptap/extension-text/dist/index.js +0 -16
  359. package/dist/node_modules/@tiptap/extension-text/dist/index.js.map +0 -1
  360. package/dist/node_modules/@tiptap/extension-underline/dist/index.js +0 -76
  361. package/dist/node_modules/@tiptap/extension-underline/dist/index.js.map +0 -1
  362. package/dist/node_modules/@tiptap/extensions/dist/index.js +0 -376
  363. package/dist/node_modules/@tiptap/extensions/dist/index.js.map +0 -1
  364. package/dist/node_modules/@tiptap/react/dist/index.js +0 -650
  365. package/dist/node_modules/@tiptap/react/dist/index.js.map +0 -1
  366. package/dist/node_modules/@tiptap/starter-kit/dist/index.js +0 -97
  367. package/dist/node_modules/@tiptap/starter-kit/dist/index.js.map +0 -1
  368. package/dist/node_modules/dayjs/dayjs.min.js +0 -283
  369. package/dist/node_modules/dayjs/dayjs.min.js.map +0 -1
  370. package/dist/node_modules/dayjs/plugin/customParseFormat.js +0 -130
  371. package/dist/node_modules/dayjs/plugin/customParseFormat.js.map +0 -1
  372. package/dist/node_modules/dayjs/plugin/duration.js +0 -137
  373. package/dist/node_modules/dayjs/plugin/duration.js.map +0 -1
  374. package/dist/node_modules/dayjs/plugin/isBetween.js +0 -20
  375. package/dist/node_modules/dayjs/plugin/isBetween.js.map +0 -1
  376. package/dist/node_modules/dayjs/plugin/relativeTime.js +0 -49
  377. package/dist/node_modules/dayjs/plugin/relativeTime.js.map +0 -1
  378. package/dist/node_modules/fast-equals/dist/es/index.js +0 -442
  379. package/dist/node_modules/fast-equals/dist/es/index.js.map +0 -1
  380. package/dist/node_modules/idb/build/index.js +0 -70
  381. package/dist/node_modules/idb/build/index.js.map +0 -1
  382. package/dist/node_modules/idb/build/wrap-idb-value.js +0 -149
  383. package/dist/node_modules/idb/build/wrap-idb-value.js.map +0 -1
  384. package/dist/node_modules/linkifyjs/dist/linkify.js +0 -1159
  385. package/dist/node_modules/linkifyjs/dist/linkify.js.map +0 -1
  386. package/dist/node_modules/orderedmap/dist/index.js +0 -120
  387. package/dist/node_modules/orderedmap/dist/index.js.map +0 -1
  388. package/dist/node_modules/prosemirror-commands/dist/index.js +0 -527
  389. package/dist/node_modules/prosemirror-commands/dist/index.js.map +0 -1
  390. package/dist/node_modules/prosemirror-dropcursor/dist/index.js +0 -137
  391. package/dist/node_modules/prosemirror-dropcursor/dist/index.js.map +0 -1
  392. package/dist/node_modules/prosemirror-gapcursor/dist/index.js +0 -221
  393. package/dist/node_modules/prosemirror-gapcursor/dist/index.js.map +0 -1
  394. package/dist/node_modules/prosemirror-history/dist/index.js +0 -357
  395. package/dist/node_modules/prosemirror-history/dist/index.js.map +0 -1
  396. package/dist/node_modules/prosemirror-keymap/dist/index.js +0 -84
  397. package/dist/node_modules/prosemirror-keymap/dist/index.js.map +0 -1
  398. package/dist/node_modules/prosemirror-model/dist/index.js +0 -3209
  399. package/dist/node_modules/prosemirror-model/dist/index.js.map +0 -1
  400. package/dist/node_modules/prosemirror-schema-list/dist/index.js +0 -131
  401. package/dist/node_modules/prosemirror-schema-list/dist/index.js.map +0 -1
  402. package/dist/node_modules/prosemirror-state/dist/index.js +0 -936
  403. package/dist/node_modules/prosemirror-state/dist/index.js.map +0 -1
  404. package/dist/node_modules/prosemirror-transform/dist/index.js +0 -1881
  405. package/dist/node_modules/prosemirror-transform/dist/index.js.map +0 -1
  406. package/dist/node_modules/prosemirror-view/dist/index.js +0 -5232
  407. package/dist/node_modules/prosemirror-view/dist/index.js.map +0 -1
  408. package/dist/node_modules/rope-sequence/dist/index.js +0 -184
  409. package/dist/node_modules/rope-sequence/dist/index.js.map +0 -1
  410. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +0 -82
  411. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +0 -1
  412. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +0 -78
  413. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js.map +0 -1
  414. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -78
  415. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +0 -1
  416. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +0 -63
  417. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js.map +0 -1
  418. package/dist/node_modules/use-sync-external-store/shim/index.js +0 -13
  419. package/dist/node_modules/use-sync-external-store/shim/index.js.map +0 -1
  420. package/dist/node_modules/use-sync-external-store/shim/with-selector.js +0 -13
  421. package/dist/node_modules/use-sync-external-store/shim/with-selector.js.map +0 -1
  422. package/dist/node_modules/w3c-keyname/index.js +0 -106
  423. package/dist/node_modules/w3c-keyname/index.js.map +0 -1
  424. package/dist/node_modules/zod/v4/classic/coerce.js +0 -10
  425. package/dist/node_modules/zod/v4/classic/coerce.js.map +0 -1
  426. package/dist/node_modules/zod/v4/classic/compat.js +0 -8
  427. package/dist/node_modules/zod/v4/classic/compat.js.map +0 -1
  428. package/dist/node_modules/zod/v4/classic/errors.js +0 -45
  429. package/dist/node_modules/zod/v4/classic/errors.js.map +0 -1
  430. package/dist/node_modules/zod/v4/classic/iso.js +0 -44
  431. package/dist/node_modules/zod/v4/classic/iso.js.map +0 -1
  432. package/dist/node_modules/zod/v4/classic/parse.js +0 -30
  433. package/dist/node_modules/zod/v4/classic/parse.js.map +0 -1
  434. package/dist/node_modules/zod/v4/classic/schemas.js +0 -711
  435. package/dist/node_modules/zod/v4/classic/schemas.js.map +0 -1
  436. package/dist/node_modules/zod/v4/core/api.js +0 -588
  437. package/dist/node_modules/zod/v4/core/api.js.map +0 -1
  438. package/dist/node_modules/zod/v4/core/checks.js +0 -411
  439. package/dist/node_modules/zod/v4/core/checks.js.map +0 -1
  440. package/dist/node_modules/zod/v4/core/core.js +0 -75
  441. package/dist/node_modules/zod/v4/core/core.js.map +0 -1
  442. package/dist/node_modules/zod/v4/core/doc.js +0 -38
  443. package/dist/node_modules/zod/v4/core/doc.js.map +0 -1
  444. package/dist/node_modules/zod/v4/core/errors.js +0 -73
  445. package/dist/node_modules/zod/v4/core/errors.js.map +0 -1
  446. package/dist/node_modules/zod/v4/core/json-schema-processors.js +0 -359
  447. package/dist/node_modules/zod/v4/core/json-schema-processors.js.map +0 -1
  448. package/dist/node_modules/zod/v4/core/parse.js +0 -96
  449. package/dist/node_modules/zod/v4/core/parse.js.map +0 -1
  450. package/dist/node_modules/zod/v4/core/regexes.js +0 -84
  451. package/dist/node_modules/zod/v4/core/regexes.js.map +0 -1
  452. package/dist/node_modules/zod/v4/core/registries.js +0 -52
  453. package/dist/node_modules/zod/v4/core/registries.js.map +0 -1
  454. package/dist/node_modules/zod/v4/core/schemas.js +0 -1391
  455. package/dist/node_modules/zod/v4/core/schemas.js.map +0 -1
  456. package/dist/node_modules/zod/v4/core/to-json-schema.js +0 -363
  457. package/dist/node_modules/zod/v4/core/to-json-schema.js.map +0 -1
  458. package/dist/node_modules/zod/v4/core/util.js +0 -431
  459. package/dist/node_modules/zod/v4/core/util.js.map +0 -1
  460. package/dist/node_modules/zod/v4/core/versions.js +0 -9
  461. package/dist/node_modules/zod/v4/core/versions.js.map +0 -1
  462. package/dist/redux/baseQuery.d.ts +0 -1
  463. package/dist/redux/baseQuery.js +0 -24
  464. package/dist/redux/baseQuery.js.map +0 -1
  465. package/dist/services/eventApi.js +0 -411
  466. package/dist/services/eventApi.js.map +0 -1
  467. package/dist/services/helpers.js +0 -115
  468. package/dist/services/helpers.js.map +0 -1
  469. package/dist/services/initialize-firebase.d.ts +0 -2
  470. package/dist/services/initialize-firebase.js +0 -20
  471. package/dist/services/initialize-firebase.js.map +0 -1
  472. package/dist/services/process-image-on-server.js +0 -30
  473. package/dist/services/process-image-on-server.js.map +0 -1
  474. package/dist/services/remote-config.d.ts +0 -5
  475. package/dist/services/remote-config.js +0 -9
  476. package/dist/services/remote-config.js.map +0 -1
  477. package/dist/services/single-event-api.js +0 -301
  478. package/dist/services/single-event-api.js.map +0 -1
  479. package/dist/services/utils.js +0 -107
  480. package/dist/services/utils.js.map +0 -1
  481. package/dist/setupTests.d.ts +0 -1
  482. package/dist/stories/Alert.stories.d.ts +0 -10
  483. package/dist/stories/Button.stories.d.ts +0 -13
  484. package/dist/types/redux-types.d.ts +0 -15
  485. package/dist/types/types.d.ts +0 -60
  486. package/dist/types/types.js +0 -10
  487. package/dist/types/types.js.map +0 -1
  488. package/dist/utils/cn.d.ts +0 -6
  489. package/dist/utils/cn.js +0 -9
  490. package/dist/utils/cn.js.map +0 -1
  491. package/dist/utils/date-range.d.ts +0 -4
  492. package/dist/utils/date-range.js +0 -13
  493. package/dist/utils/date-range.js.map +0 -1
  494. package/dist/utils/single-event-helpers.d.ts +0 -50
  495. package/dist/utils/single-event-helpers.js +0 -18
  496. package/dist/utils/single-event-helpers.js.map +0 -1
  497. package/dist/utils/social-validation.js +0 -42
  498. package/dist/utils/social-validation.js.map +0 -1
  499. package/dist/utils/utils.js +0 -20
  500. package/dist/utils/utils.js.map +0 -1
  501. /package/dist/{components/Alert/Alert.d.ts → src/components/Alert/index.d.ts} +0 -0
  502. /package/dist/{components → src/components}/FormBuilder/CategoryList.d.ts +0 -0
  503. /package/dist/{components → src/components}/FormBuilder/OptionList.d.ts +0 -0
  504. /package/dist/{components → src/components}/FormBuilder/RequiredToggle.d.ts +0 -0
  505. /package/dist/{components → src/components}/FormBuilder/types.d.ts +0 -0
  506. /package/dist/{components → src/components}/FormBuilder/utils.d.ts +0 -0
  507. /package/dist/{components → src/components}/ImageCropModal/index.d.ts +0 -0
  508. /package/dist/{components → src/components}/InformationPopover.d.ts +0 -0
  509. /package/dist/{components/EventAddForm → src/components/NewAddEvent}/common/DescriptionModal.d.ts +0 -0
  510. /package/dist/{components/ui/FormInput.d.ts → src/components/NewAddEvent/components/AddEventFormInput.d.ts} +0 -0
  511. /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/CheckboxGroup.d.ts +0 -0
  512. /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/CustomMeetingForm.d.ts +0 -0
  513. /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/DateTimeField.d.ts +0 -0
  514. /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/FileUpload.d.ts +0 -0
  515. /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/FormBuilderProceedModal.d.ts +0 -0
  516. /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/GoogleMapsAutocompleteInput.d.ts +0 -0
  517. /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/SingleDateTimeInput.d.ts +0 -0
  518. /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/StepTwo/CustomFormSection.d.ts +0 -0
  519. /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/TicketTypeSelection.d.ts +0 -0
  520. /package/dist/{components/EventAddForm → src/components/NewAddEvent}/steps/StepOne.d.ts +0 -0
  521. /package/dist/{components/EventAddForm → src/components/NewAddEvent}/steps/StepTwo.d.ts +0 -0
  522. /package/dist/{components/EventAddForm → src/components/NewAddEvent}/types.d.ts +0 -0
  523. /package/dist/{components → src/components}/common/FallbackImage.d.ts +0 -0
  524. /package/dist/{components → src/components}/ui/Calendar/calendar-utils.d.ts +0 -0
  525. /package/dist/{components → src/components}/ui/Calendar/index.d.ts +0 -0
  526. /package/dist/{components/Checkbox → src/components/ui}/Checkbox.d.ts +0 -0
  527. /package/dist/{components/CustomSelect → src/components/ui}/CustomSelect.d.ts +0 -0
  528. /package/dist/{components → src/components}/ui/DatePicker/index.d.ts +0 -0
  529. /package/dist/{components/InputErrorMessage → src/components/ui}/InputErrorMessage.d.ts +0 -0
  530. /package/dist/{components → src/components}/ui/Modal/index.d.ts +0 -0
  531. /package/dist/{components/Radio → src/components/ui}/Radio.d.ts +0 -0
  532. /package/dist/{components → src/components}/ui/RichTextEditor.d.ts +0 -0
  533. /package/dist/{components → src/components}/ui/TimePicker/index.d.ts +0 -0
  534. /package/dist/{components → src/components}/ui/TimeSelector/index.d.ts +0 -0
  535. /package/dist/{components → src/components}/ui/Tooltip/index.d.ts +0 -0
  536. /package/dist/{lib → src/lib}/constants.d.ts +0 -0
  537. /package/dist/{lib → src/lib}/cropImage.d.ts +0 -0
  538. /package/dist/{lib → src/lib}/imageAnalysis.d.ts +0 -0
  539. /package/dist/{utils → src/lib}/social-validation.d.ts +0 -0
  540. /package/dist/{lib/utils.d.ts → src/lib/tailwind-merge.d.ts} +0 -0
  541. /package/dist/{utils → src/lib}/utils.d.ts +0 -0
  542. /package/dist/{services → src/redux/features/single-event}/helpers.d.ts +0 -0
  543. /package/dist/{services → src/services}/process-image-on-server.d.ts +0 -0
  544. /package/dist/{types → src/types}/events.d.ts +0 -0
  545. /package/dist/{types → src/types}/question.d.ts +0 -0
@@ -1,3458 +0,0 @@
1
- import React__default, { useMemo, memo, useReducer, useState, useRef, useCallback, useEffect, useContext, createContext, cloneElement, forwardRef } from "react";
2
- import { unstable_batchedUpdates, createPortal } from "react-dom";
3
- import { useLatestValue, useUniqueId, getEventCoordinates, getWindow, add, useIsomorphicLayoutEffect, getOwnerDocument, isKeyboardEvent, subtract, useLazyMemo, isHTMLElement, useNodeRef, canUseDOM, useInterval, usePrevious, findFirstFocusableNode, useEvent, CSS, isWindow, isNode, isDocument, isSVGElement } from "../../utilities/dist/utilities.esm.js";
4
- import { useAnnouncement, HiddenText, LiveRegion } from "../../accessibility/dist/accessibility.esm.js";
5
- const DndMonitorContext = /* @__PURE__ */ createContext(null);
6
- function useDndMonitor(listener) {
7
- const registerListener = useContext(DndMonitorContext);
8
- useEffect(() => {
9
- if (!registerListener) {
10
- throw new Error("useDndMonitor must be used within a children of <DndContext>");
11
- }
12
- const unsubscribe = registerListener(listener);
13
- return unsubscribe;
14
- }, [listener, registerListener]);
15
- }
16
- function useDndMonitorProvider() {
17
- const [listeners] = useState(() => /* @__PURE__ */ new Set());
18
- const registerListener = useCallback((listener) => {
19
- listeners.add(listener);
20
- return () => listeners.delete(listener);
21
- }, [listeners]);
22
- const dispatch = useCallback((_ref) => {
23
- let {
24
- type,
25
- event
26
- } = _ref;
27
- listeners.forEach((listener) => {
28
- var _listener$type;
29
- return (_listener$type = listener[type]) == null ? void 0 : _listener$type.call(listener, event);
30
- });
31
- }, [listeners]);
32
- return [dispatch, registerListener];
33
- }
34
- const defaultScreenReaderInstructions = {
35
- 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 "
36
- };
37
- const defaultAnnouncements = {
38
- onDragStart(_ref) {
39
- let {
40
- active
41
- } = _ref;
42
- return "Picked up draggable item " + active.id + ".";
43
- },
44
- onDragOver(_ref2) {
45
- let {
46
- active,
47
- over
48
- } = _ref2;
49
- if (over) {
50
- return "Draggable item " + active.id + " was moved over droppable area " + over.id + ".";
51
- }
52
- return "Draggable item " + active.id + " is no longer over a droppable area.";
53
- },
54
- onDragEnd(_ref3) {
55
- let {
56
- active,
57
- over
58
- } = _ref3;
59
- if (over) {
60
- return "Draggable item " + active.id + " was dropped over droppable area " + over.id;
61
- }
62
- return "Draggable item " + active.id + " was dropped.";
63
- },
64
- onDragCancel(_ref4) {
65
- let {
66
- active
67
- } = _ref4;
68
- return "Dragging was cancelled. Draggable item " + active.id + " was dropped.";
69
- }
70
- };
71
- function Accessibility(_ref) {
72
- let {
73
- announcements = defaultAnnouncements,
74
- container,
75
- hiddenTextDescribedById,
76
- screenReaderInstructions = defaultScreenReaderInstructions
77
- } = _ref;
78
- const {
79
- announce,
80
- announcement
81
- } = useAnnouncement();
82
- const liveRegionId = useUniqueId("DndLiveRegion");
83
- const [mounted, setMounted] = useState(false);
84
- useEffect(() => {
85
- setMounted(true);
86
- }, []);
87
- useDndMonitor(useMemo(() => ({
88
- onDragStart(_ref2) {
89
- let {
90
- active
91
- } = _ref2;
92
- announce(announcements.onDragStart({
93
- active
94
- }));
95
- },
96
- onDragMove(_ref3) {
97
- let {
98
- active,
99
- over
100
- } = _ref3;
101
- if (announcements.onDragMove) {
102
- announce(announcements.onDragMove({
103
- active,
104
- over
105
- }));
106
- }
107
- },
108
- onDragOver(_ref4) {
109
- let {
110
- active,
111
- over
112
- } = _ref4;
113
- announce(announcements.onDragOver({
114
- active,
115
- over
116
- }));
117
- },
118
- onDragEnd(_ref5) {
119
- let {
120
- active,
121
- over
122
- } = _ref5;
123
- announce(announcements.onDragEnd({
124
- active,
125
- over
126
- }));
127
- },
128
- onDragCancel(_ref6) {
129
- let {
130
- active,
131
- over
132
- } = _ref6;
133
- announce(announcements.onDragCancel({
134
- active,
135
- over
136
- }));
137
- }
138
- }), [announce, announcements]));
139
- if (!mounted) {
140
- return null;
141
- }
142
- const markup = React__default.createElement(React__default.Fragment, null, React__default.createElement(HiddenText, {
143
- id: hiddenTextDescribedById,
144
- value: screenReaderInstructions.draggable
145
- }), React__default.createElement(LiveRegion, {
146
- id: liveRegionId,
147
- announcement
148
- }));
149
- return container ? createPortal(markup, container) : markup;
150
- }
151
- var Action;
152
- (function(Action2) {
153
- Action2["DragStart"] = "dragStart";
154
- Action2["DragMove"] = "dragMove";
155
- Action2["DragEnd"] = "dragEnd";
156
- Action2["DragCancel"] = "dragCancel";
157
- Action2["DragOver"] = "dragOver";
158
- Action2["RegisterDroppable"] = "registerDroppable";
159
- Action2["SetDroppableDisabled"] = "setDroppableDisabled";
160
- Action2["UnregisterDroppable"] = "unregisterDroppable";
161
- })(Action || (Action = {}));
162
- function noop() {
163
- }
164
- function useSensor(sensor, options) {
165
- return useMemo(
166
- () => ({
167
- sensor,
168
- options: options != null ? options : {}
169
- }),
170
- // eslint-disable-next-line react-hooks/exhaustive-deps
171
- [sensor, options]
172
- );
173
- }
174
- function useSensors() {
175
- for (var _len = arguments.length, sensors = new Array(_len), _key = 0; _key < _len; _key++) {
176
- sensors[_key] = arguments[_key];
177
- }
178
- return useMemo(
179
- () => [...sensors].filter((sensor) => sensor != null),
180
- // eslint-disable-next-line react-hooks/exhaustive-deps
181
- [...sensors]
182
- );
183
- }
184
- const defaultCoordinates = /* @__PURE__ */ Object.freeze({
185
- x: 0,
186
- y: 0
187
- });
188
- function distanceBetween(p1, p2) {
189
- return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
190
- }
191
- function getRelativeTransformOrigin(event, rect) {
192
- const eventCoordinates = getEventCoordinates(event);
193
- if (!eventCoordinates) {
194
- return "0 0";
195
- }
196
- const transformOrigin = {
197
- x: (eventCoordinates.x - rect.left) / rect.width * 100,
198
- y: (eventCoordinates.y - rect.top) / rect.height * 100
199
- };
200
- return transformOrigin.x + "% " + transformOrigin.y + "%";
201
- }
202
- function sortCollisionsAsc(_ref, _ref2) {
203
- let {
204
- data: {
205
- value: a
206
- }
207
- } = _ref;
208
- let {
209
- data: {
210
- value: b
211
- }
212
- } = _ref2;
213
- return a - b;
214
- }
215
- function sortCollisionsDesc(_ref3, _ref4) {
216
- let {
217
- data: {
218
- value: a
219
- }
220
- } = _ref3;
221
- let {
222
- data: {
223
- value: b
224
- }
225
- } = _ref4;
226
- return b - a;
227
- }
228
- function cornersOfRectangle(_ref5) {
229
- let {
230
- left,
231
- top,
232
- height,
233
- width
234
- } = _ref5;
235
- return [{
236
- x: left,
237
- y: top
238
- }, {
239
- x: left + width,
240
- y: top
241
- }, {
242
- x: left,
243
- y: top + height
244
- }, {
245
- x: left + width,
246
- y: top + height
247
- }];
248
- }
249
- function getFirstCollision(collisions, property) {
250
- if (!collisions || collisions.length === 0) {
251
- return null;
252
- }
253
- const [firstCollision] = collisions;
254
- return firstCollision[property];
255
- }
256
- function centerOfRectangle(rect, left, top) {
257
- if (left === void 0) {
258
- left = rect.left;
259
- }
260
- if (top === void 0) {
261
- top = rect.top;
262
- }
263
- return {
264
- x: left + rect.width * 0.5,
265
- y: top + rect.height * 0.5
266
- };
267
- }
268
- const closestCenter = (_ref) => {
269
- let {
270
- collisionRect,
271
- droppableRects,
272
- droppableContainers
273
- } = _ref;
274
- const centerRect = centerOfRectangle(collisionRect, collisionRect.left, collisionRect.top);
275
- const collisions = [];
276
- for (const droppableContainer of droppableContainers) {
277
- const {
278
- id
279
- } = droppableContainer;
280
- const rect = droppableRects.get(id);
281
- if (rect) {
282
- const distBetween = distanceBetween(centerOfRectangle(rect), centerRect);
283
- collisions.push({
284
- id,
285
- data: {
286
- droppableContainer,
287
- value: distBetween
288
- }
289
- });
290
- }
291
- }
292
- return collisions.sort(sortCollisionsAsc);
293
- };
294
- const closestCorners = (_ref) => {
295
- let {
296
- collisionRect,
297
- droppableRects,
298
- droppableContainers
299
- } = _ref;
300
- const corners = cornersOfRectangle(collisionRect);
301
- const collisions = [];
302
- for (const droppableContainer of droppableContainers) {
303
- const {
304
- id
305
- } = droppableContainer;
306
- const rect = droppableRects.get(id);
307
- if (rect) {
308
- const rectCorners = cornersOfRectangle(rect);
309
- const distances = corners.reduce((accumulator, corner, index) => {
310
- return accumulator + distanceBetween(rectCorners[index], corner);
311
- }, 0);
312
- const effectiveDistance = Number((distances / 4).toFixed(4));
313
- collisions.push({
314
- id,
315
- data: {
316
- droppableContainer,
317
- value: effectiveDistance
318
- }
319
- });
320
- }
321
- }
322
- return collisions.sort(sortCollisionsAsc);
323
- };
324
- function getIntersectionRatio(entry, target) {
325
- const top = Math.max(target.top, entry.top);
326
- const left = Math.max(target.left, entry.left);
327
- const right = Math.min(target.left + target.width, entry.left + entry.width);
328
- const bottom = Math.min(target.top + target.height, entry.top + entry.height);
329
- const width = right - left;
330
- const height = bottom - top;
331
- if (left < right && top < bottom) {
332
- const targetArea = target.width * target.height;
333
- const entryArea = entry.width * entry.height;
334
- const intersectionArea = width * height;
335
- const intersectionRatio = intersectionArea / (targetArea + entryArea - intersectionArea);
336
- return Number(intersectionRatio.toFixed(4));
337
- }
338
- return 0;
339
- }
340
- const rectIntersection = (_ref) => {
341
- let {
342
- collisionRect,
343
- droppableRects,
344
- droppableContainers
345
- } = _ref;
346
- const collisions = [];
347
- for (const droppableContainer of droppableContainers) {
348
- const {
349
- id
350
- } = droppableContainer;
351
- const rect = droppableRects.get(id);
352
- if (rect) {
353
- const intersectionRatio = getIntersectionRatio(rect, collisionRect);
354
- if (intersectionRatio > 0) {
355
- collisions.push({
356
- id,
357
- data: {
358
- droppableContainer,
359
- value: intersectionRatio
360
- }
361
- });
362
- }
363
- }
364
- }
365
- return collisions.sort(sortCollisionsDesc);
366
- };
367
- function adjustScale(transform, rect1, rect2) {
368
- return {
369
- ...transform,
370
- scaleX: rect1 && rect2 ? rect1.width / rect2.width : 1,
371
- scaleY: rect1 && rect2 ? rect1.height / rect2.height : 1
372
- };
373
- }
374
- function getRectDelta(rect1, rect2) {
375
- return rect1 && rect2 ? {
376
- x: rect1.left - rect2.left,
377
- y: rect1.top - rect2.top
378
- } : defaultCoordinates;
379
- }
380
- function createRectAdjustmentFn(modifier) {
381
- return function adjustClientRect(rect) {
382
- for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
383
- adjustments[_key - 1] = arguments[_key];
384
- }
385
- return adjustments.reduce((acc, adjustment) => ({
386
- ...acc,
387
- top: acc.top + modifier * adjustment.y,
388
- bottom: acc.bottom + modifier * adjustment.y,
389
- left: acc.left + modifier * adjustment.x,
390
- right: acc.right + modifier * adjustment.x
391
- }), {
392
- ...rect
393
- });
394
- };
395
- }
396
- const getAdjustedRect = /* @__PURE__ */ createRectAdjustmentFn(1);
397
- function parseTransform(transform) {
398
- if (transform.startsWith("matrix3d(")) {
399
- const transformArray = transform.slice(9, -1).split(/, /);
400
- return {
401
- x: +transformArray[12],
402
- y: +transformArray[13],
403
- scaleX: +transformArray[0],
404
- scaleY: +transformArray[5]
405
- };
406
- } else if (transform.startsWith("matrix(")) {
407
- const transformArray = transform.slice(7, -1).split(/, /);
408
- return {
409
- x: +transformArray[4],
410
- y: +transformArray[5],
411
- scaleX: +transformArray[0],
412
- scaleY: +transformArray[3]
413
- };
414
- }
415
- return null;
416
- }
417
- function inverseTransform(rect, transform, transformOrigin) {
418
- const parsedTransform = parseTransform(transform);
419
- if (!parsedTransform) {
420
- return rect;
421
- }
422
- const {
423
- scaleX,
424
- scaleY,
425
- x: translateX,
426
- y: translateY
427
- } = parsedTransform;
428
- const x = rect.left - translateX - (1 - scaleX) * parseFloat(transformOrigin);
429
- const y = rect.top - translateY - (1 - scaleY) * parseFloat(transformOrigin.slice(transformOrigin.indexOf(" ") + 1));
430
- const w = scaleX ? rect.width / scaleX : rect.width;
431
- const h = scaleY ? rect.height / scaleY : rect.height;
432
- return {
433
- width: w,
434
- height: h,
435
- top: y,
436
- right: x + w,
437
- bottom: y + h,
438
- left: x
439
- };
440
- }
441
- const defaultOptions = {
442
- ignoreTransform: false
443
- };
444
- function getClientRect(element, options) {
445
- if (options === void 0) {
446
- options = defaultOptions;
447
- }
448
- let rect = element.getBoundingClientRect();
449
- if (options.ignoreTransform) {
450
- const {
451
- transform,
452
- transformOrigin
453
- } = getWindow(element).getComputedStyle(element);
454
- if (transform) {
455
- rect = inverseTransform(rect, transform, transformOrigin);
456
- }
457
- }
458
- const {
459
- top,
460
- left,
461
- width,
462
- height,
463
- bottom,
464
- right
465
- } = rect;
466
- return {
467
- top,
468
- left,
469
- width,
470
- height,
471
- bottom,
472
- right
473
- };
474
- }
475
- function getTransformAgnosticClientRect(element) {
476
- return getClientRect(element, {
477
- ignoreTransform: true
478
- });
479
- }
480
- function getWindowClientRect(element) {
481
- const width = element.innerWidth;
482
- const height = element.innerHeight;
483
- return {
484
- top: 0,
485
- left: 0,
486
- right: width,
487
- bottom: height,
488
- width,
489
- height
490
- };
491
- }
492
- function isFixed(node, computedStyle) {
493
- if (computedStyle === void 0) {
494
- computedStyle = getWindow(node).getComputedStyle(node);
495
- }
496
- return computedStyle.position === "fixed";
497
- }
498
- function isScrollable(element, computedStyle) {
499
- if (computedStyle === void 0) {
500
- computedStyle = getWindow(element).getComputedStyle(element);
501
- }
502
- const overflowRegex = /(auto|scroll|overlay)/;
503
- const properties2 = ["overflow", "overflowX", "overflowY"];
504
- return properties2.some((property) => {
505
- const value = computedStyle[property];
506
- return typeof value === "string" ? overflowRegex.test(value) : false;
507
- });
508
- }
509
- function getScrollableAncestors(element, limit) {
510
- const scrollParents = [];
511
- function findScrollableAncestors(node) {
512
- if (limit != null && scrollParents.length >= limit) {
513
- return scrollParents;
514
- }
515
- if (!node) {
516
- return scrollParents;
517
- }
518
- if (isDocument(node) && node.scrollingElement != null && !scrollParents.includes(node.scrollingElement)) {
519
- scrollParents.push(node.scrollingElement);
520
- return scrollParents;
521
- }
522
- if (!isHTMLElement(node) || isSVGElement(node)) {
523
- return scrollParents;
524
- }
525
- if (scrollParents.includes(node)) {
526
- return scrollParents;
527
- }
528
- const computedStyle = getWindow(element).getComputedStyle(node);
529
- if (node !== element) {
530
- if (isScrollable(node, computedStyle)) {
531
- scrollParents.push(node);
532
- }
533
- }
534
- if (isFixed(node, computedStyle)) {
535
- return scrollParents;
536
- }
537
- return findScrollableAncestors(node.parentNode);
538
- }
539
- if (!element) {
540
- return scrollParents;
541
- }
542
- return findScrollableAncestors(element);
543
- }
544
- function getFirstScrollableAncestor(node) {
545
- const [firstScrollableAncestor] = getScrollableAncestors(node, 1);
546
- return firstScrollableAncestor != null ? firstScrollableAncestor : null;
547
- }
548
- function getScrollableElement(element) {
549
- if (!canUseDOM || !element) {
550
- return null;
551
- }
552
- if (isWindow(element)) {
553
- return element;
554
- }
555
- if (!isNode(element)) {
556
- return null;
557
- }
558
- if (isDocument(element) || element === getOwnerDocument(element).scrollingElement) {
559
- return window;
560
- }
561
- if (isHTMLElement(element)) {
562
- return element;
563
- }
564
- return null;
565
- }
566
- function getScrollXCoordinate(element) {
567
- if (isWindow(element)) {
568
- return element.scrollX;
569
- }
570
- return element.scrollLeft;
571
- }
572
- function getScrollYCoordinate(element) {
573
- if (isWindow(element)) {
574
- return element.scrollY;
575
- }
576
- return element.scrollTop;
577
- }
578
- function getScrollCoordinates(element) {
579
- return {
580
- x: getScrollXCoordinate(element),
581
- y: getScrollYCoordinate(element)
582
- };
583
- }
584
- var Direction;
585
- (function(Direction2) {
586
- Direction2[Direction2["Forward"] = 1] = "Forward";
587
- Direction2[Direction2["Backward"] = -1] = "Backward";
588
- })(Direction || (Direction = {}));
589
- function isDocumentScrollingElement(element) {
590
- if (!canUseDOM || !element) {
591
- return false;
592
- }
593
- return element === document.scrollingElement;
594
- }
595
- function getScrollPosition(scrollingContainer) {
596
- const minScroll = {
597
- x: 0,
598
- y: 0
599
- };
600
- const dimensions = isDocumentScrollingElement(scrollingContainer) ? {
601
- height: window.innerHeight,
602
- width: window.innerWidth
603
- } : {
604
- height: scrollingContainer.clientHeight,
605
- width: scrollingContainer.clientWidth
606
- };
607
- const maxScroll = {
608
- x: scrollingContainer.scrollWidth - dimensions.width,
609
- y: scrollingContainer.scrollHeight - dimensions.height
610
- };
611
- const isTop = scrollingContainer.scrollTop <= minScroll.y;
612
- const isLeft = scrollingContainer.scrollLeft <= minScroll.x;
613
- const isBottom = scrollingContainer.scrollTop >= maxScroll.y;
614
- const isRight = scrollingContainer.scrollLeft >= maxScroll.x;
615
- return {
616
- isTop,
617
- isLeft,
618
- isBottom,
619
- isRight,
620
- maxScroll,
621
- minScroll
622
- };
623
- }
624
- const defaultThreshold = {
625
- x: 0.2,
626
- y: 0.2
627
- };
628
- function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, _ref, acceleration, thresholdPercentage) {
629
- let {
630
- top,
631
- left,
632
- right,
633
- bottom
634
- } = _ref;
635
- if (acceleration === void 0) {
636
- acceleration = 10;
637
- }
638
- if (thresholdPercentage === void 0) {
639
- thresholdPercentage = defaultThreshold;
640
- }
641
- const {
642
- isTop,
643
- isBottom,
644
- isLeft,
645
- isRight
646
- } = getScrollPosition(scrollContainer);
647
- const direction = {
648
- x: 0,
649
- y: 0
650
- };
651
- const speed = {
652
- x: 0,
653
- y: 0
654
- };
655
- const threshold = {
656
- height: scrollContainerRect.height * thresholdPercentage.y,
657
- width: scrollContainerRect.width * thresholdPercentage.x
658
- };
659
- if (!isTop && top <= scrollContainerRect.top + threshold.height) {
660
- direction.y = Direction.Backward;
661
- speed.y = acceleration * Math.abs((scrollContainerRect.top + threshold.height - top) / threshold.height);
662
- } else if (!isBottom && bottom >= scrollContainerRect.bottom - threshold.height) {
663
- direction.y = Direction.Forward;
664
- speed.y = acceleration * Math.abs((scrollContainerRect.bottom - threshold.height - bottom) / threshold.height);
665
- }
666
- if (!isRight && right >= scrollContainerRect.right - threshold.width) {
667
- direction.x = Direction.Forward;
668
- speed.x = acceleration * Math.abs((scrollContainerRect.right - threshold.width - right) / threshold.width);
669
- } else if (!isLeft && left <= scrollContainerRect.left + threshold.width) {
670
- direction.x = Direction.Backward;
671
- speed.x = acceleration * Math.abs((scrollContainerRect.left + threshold.width - left) / threshold.width);
672
- }
673
- return {
674
- direction,
675
- speed
676
- };
677
- }
678
- function getScrollElementRect(element) {
679
- if (element === document.scrollingElement) {
680
- const {
681
- innerWidth,
682
- innerHeight
683
- } = window;
684
- return {
685
- top: 0,
686
- left: 0,
687
- right: innerWidth,
688
- bottom: innerHeight,
689
- width: innerWidth,
690
- height: innerHeight
691
- };
692
- }
693
- const {
694
- top,
695
- left,
696
- right,
697
- bottom
698
- } = element.getBoundingClientRect();
699
- return {
700
- top,
701
- left,
702
- right,
703
- bottom,
704
- width: element.clientWidth,
705
- height: element.clientHeight
706
- };
707
- }
708
- function getScrollOffsets(scrollableAncestors) {
709
- return scrollableAncestors.reduce((acc, node) => {
710
- return add(acc, getScrollCoordinates(node));
711
- }, defaultCoordinates);
712
- }
713
- function getScrollXOffset(scrollableAncestors) {
714
- return scrollableAncestors.reduce((acc, node) => {
715
- return acc + getScrollXCoordinate(node);
716
- }, 0);
717
- }
718
- function getScrollYOffset(scrollableAncestors) {
719
- return scrollableAncestors.reduce((acc, node) => {
720
- return acc + getScrollYCoordinate(node);
721
- }, 0);
722
- }
723
- function scrollIntoViewIfNeeded(element, measure) {
724
- if (measure === void 0) {
725
- measure = getClientRect;
726
- }
727
- if (!element) {
728
- return;
729
- }
730
- const {
731
- top,
732
- left,
733
- bottom,
734
- right
735
- } = measure(element);
736
- const firstScrollableAncestor = getFirstScrollableAncestor(element);
737
- if (!firstScrollableAncestor) {
738
- return;
739
- }
740
- if (bottom <= 0 || right <= 0 || top >= window.innerHeight || left >= window.innerWidth) {
741
- element.scrollIntoView({
742
- block: "center",
743
- inline: "center"
744
- });
745
- }
746
- }
747
- const properties = [["x", ["left", "right"], getScrollXOffset], ["y", ["top", "bottom"], getScrollYOffset]];
748
- class Rect {
749
- constructor(rect, element) {
750
- this.rect = void 0;
751
- this.width = void 0;
752
- this.height = void 0;
753
- this.top = void 0;
754
- this.bottom = void 0;
755
- this.right = void 0;
756
- this.left = void 0;
757
- const scrollableAncestors = getScrollableAncestors(element);
758
- const scrollOffsets = getScrollOffsets(scrollableAncestors);
759
- this.rect = {
760
- ...rect
761
- };
762
- this.width = rect.width;
763
- this.height = rect.height;
764
- for (const [axis, keys, getScrollOffset] of properties) {
765
- for (const key2 of keys) {
766
- Object.defineProperty(this, key2, {
767
- get: () => {
768
- const currentOffsets = getScrollOffset(scrollableAncestors);
769
- const scrollOffsetsDeltla = scrollOffsets[axis] - currentOffsets;
770
- return this.rect[key2] + scrollOffsetsDeltla;
771
- },
772
- enumerable: true
773
- });
774
- }
775
- }
776
- Object.defineProperty(this, "rect", {
777
- enumerable: false
778
- });
779
- }
780
- }
781
- class Listeners {
782
- constructor(target) {
783
- this.target = void 0;
784
- this.listeners = [];
785
- this.removeAll = () => {
786
- this.listeners.forEach((listener) => {
787
- var _this$target;
788
- return (_this$target = this.target) == null ? void 0 : _this$target.removeEventListener(...listener);
789
- });
790
- };
791
- this.target = target;
792
- }
793
- add(eventName, handler, options) {
794
- var _this$target2;
795
- (_this$target2 = this.target) == null ? void 0 : _this$target2.addEventListener(eventName, handler, options);
796
- this.listeners.push([eventName, handler, options]);
797
- }
798
- }
799
- function getEventListenerTarget(target) {
800
- const {
801
- EventTarget
802
- } = getWindow(target);
803
- return target instanceof EventTarget ? target : getOwnerDocument(target);
804
- }
805
- function hasExceededDistance(delta, measurement) {
806
- const dx = Math.abs(delta.x);
807
- const dy = Math.abs(delta.y);
808
- if (typeof measurement === "number") {
809
- return Math.sqrt(dx ** 2 + dy ** 2) > measurement;
810
- }
811
- if ("x" in measurement && "y" in measurement) {
812
- return dx > measurement.x && dy > measurement.y;
813
- }
814
- if ("x" in measurement) {
815
- return dx > measurement.x;
816
- }
817
- if ("y" in measurement) {
818
- return dy > measurement.y;
819
- }
820
- return false;
821
- }
822
- var EventName;
823
- (function(EventName2) {
824
- EventName2["Click"] = "click";
825
- EventName2["DragStart"] = "dragstart";
826
- EventName2["Keydown"] = "keydown";
827
- EventName2["ContextMenu"] = "contextmenu";
828
- EventName2["Resize"] = "resize";
829
- EventName2["SelectionChange"] = "selectionchange";
830
- EventName2["VisibilityChange"] = "visibilitychange";
831
- })(EventName || (EventName = {}));
832
- function preventDefault(event) {
833
- event.preventDefault();
834
- }
835
- function stopPropagation(event) {
836
- event.stopPropagation();
837
- }
838
- var KeyboardCode;
839
- (function(KeyboardCode2) {
840
- KeyboardCode2["Space"] = "Space";
841
- KeyboardCode2["Down"] = "ArrowDown";
842
- KeyboardCode2["Right"] = "ArrowRight";
843
- KeyboardCode2["Left"] = "ArrowLeft";
844
- KeyboardCode2["Up"] = "ArrowUp";
845
- KeyboardCode2["Esc"] = "Escape";
846
- KeyboardCode2["Enter"] = "Enter";
847
- KeyboardCode2["Tab"] = "Tab";
848
- })(KeyboardCode || (KeyboardCode = {}));
849
- const defaultKeyboardCodes = {
850
- start: [KeyboardCode.Space, KeyboardCode.Enter],
851
- cancel: [KeyboardCode.Esc],
852
- end: [KeyboardCode.Space, KeyboardCode.Enter, KeyboardCode.Tab]
853
- };
854
- const defaultKeyboardCoordinateGetter = (event, _ref) => {
855
- let {
856
- currentCoordinates
857
- } = _ref;
858
- switch (event.code) {
859
- case KeyboardCode.Right:
860
- return {
861
- ...currentCoordinates,
862
- x: currentCoordinates.x + 25
863
- };
864
- case KeyboardCode.Left:
865
- return {
866
- ...currentCoordinates,
867
- x: currentCoordinates.x - 25
868
- };
869
- case KeyboardCode.Down:
870
- return {
871
- ...currentCoordinates,
872
- y: currentCoordinates.y + 25
873
- };
874
- case KeyboardCode.Up:
875
- return {
876
- ...currentCoordinates,
877
- y: currentCoordinates.y - 25
878
- };
879
- }
880
- return void 0;
881
- };
882
- class KeyboardSensor {
883
- constructor(props) {
884
- this.props = void 0;
885
- this.autoScrollEnabled = false;
886
- this.referenceCoordinates = void 0;
887
- this.listeners = void 0;
888
- this.windowListeners = void 0;
889
- this.props = props;
890
- const {
891
- event: {
892
- target
893
- }
894
- } = props;
895
- this.props = props;
896
- this.listeners = new Listeners(getOwnerDocument(target));
897
- this.windowListeners = new Listeners(getWindow(target));
898
- this.handleKeyDown = this.handleKeyDown.bind(this);
899
- this.handleCancel = this.handleCancel.bind(this);
900
- this.attach();
901
- }
902
- attach() {
903
- this.handleStart();
904
- this.windowListeners.add(EventName.Resize, this.handleCancel);
905
- this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
906
- setTimeout(() => this.listeners.add(EventName.Keydown, this.handleKeyDown));
907
- }
908
- handleStart() {
909
- const {
910
- activeNode,
911
- onStart
912
- } = this.props;
913
- const node = activeNode.node.current;
914
- if (node) {
915
- scrollIntoViewIfNeeded(node);
916
- }
917
- onStart(defaultCoordinates);
918
- }
919
- handleKeyDown(event) {
920
- if (isKeyboardEvent(event)) {
921
- const {
922
- active,
923
- context,
924
- options
925
- } = this.props;
926
- const {
927
- keyboardCodes = defaultKeyboardCodes,
928
- coordinateGetter = defaultKeyboardCoordinateGetter,
929
- scrollBehavior = "smooth"
930
- } = options;
931
- const {
932
- code
933
- } = event;
934
- if (keyboardCodes.end.includes(code)) {
935
- this.handleEnd(event);
936
- return;
937
- }
938
- if (keyboardCodes.cancel.includes(code)) {
939
- this.handleCancel(event);
940
- return;
941
- }
942
- const {
943
- collisionRect
944
- } = context.current;
945
- const currentCoordinates = collisionRect ? {
946
- x: collisionRect.left,
947
- y: collisionRect.top
948
- } : defaultCoordinates;
949
- if (!this.referenceCoordinates) {
950
- this.referenceCoordinates = currentCoordinates;
951
- }
952
- const newCoordinates = coordinateGetter(event, {
953
- active,
954
- context: context.current,
955
- currentCoordinates
956
- });
957
- if (newCoordinates) {
958
- const coordinatesDelta = subtract(newCoordinates, currentCoordinates);
959
- const scrollDelta = {
960
- x: 0,
961
- y: 0
962
- };
963
- const {
964
- scrollableAncestors
965
- } = context.current;
966
- for (const scrollContainer of scrollableAncestors) {
967
- const direction = event.code;
968
- const {
969
- isTop,
970
- isRight,
971
- isLeft,
972
- isBottom,
973
- maxScroll,
974
- minScroll
975
- } = getScrollPosition(scrollContainer);
976
- const scrollElementRect = getScrollElementRect(scrollContainer);
977
- const clampedCoordinates = {
978
- 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)),
979
- 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))
980
- };
981
- const canScrollX = direction === KeyboardCode.Right && !isRight || direction === KeyboardCode.Left && !isLeft;
982
- const canScrollY = direction === KeyboardCode.Down && !isBottom || direction === KeyboardCode.Up && !isTop;
983
- if (canScrollX && clampedCoordinates.x !== newCoordinates.x) {
984
- const newScrollCoordinates = scrollContainer.scrollLeft + coordinatesDelta.x;
985
- const canScrollToNewCoordinates = direction === KeyboardCode.Right && newScrollCoordinates <= maxScroll.x || direction === KeyboardCode.Left && newScrollCoordinates >= minScroll.x;
986
- if (canScrollToNewCoordinates && !coordinatesDelta.y) {
987
- scrollContainer.scrollTo({
988
- left: newScrollCoordinates,
989
- behavior: scrollBehavior
990
- });
991
- return;
992
- }
993
- if (canScrollToNewCoordinates) {
994
- scrollDelta.x = scrollContainer.scrollLeft - newScrollCoordinates;
995
- } else {
996
- scrollDelta.x = direction === KeyboardCode.Right ? scrollContainer.scrollLeft - maxScroll.x : scrollContainer.scrollLeft - minScroll.x;
997
- }
998
- if (scrollDelta.x) {
999
- scrollContainer.scrollBy({
1000
- left: -scrollDelta.x,
1001
- behavior: scrollBehavior
1002
- });
1003
- }
1004
- break;
1005
- } else if (canScrollY && clampedCoordinates.y !== newCoordinates.y) {
1006
- const newScrollCoordinates = scrollContainer.scrollTop + coordinatesDelta.y;
1007
- const canScrollToNewCoordinates = direction === KeyboardCode.Down && newScrollCoordinates <= maxScroll.y || direction === KeyboardCode.Up && newScrollCoordinates >= minScroll.y;
1008
- if (canScrollToNewCoordinates && !coordinatesDelta.x) {
1009
- scrollContainer.scrollTo({
1010
- top: newScrollCoordinates,
1011
- behavior: scrollBehavior
1012
- });
1013
- return;
1014
- }
1015
- if (canScrollToNewCoordinates) {
1016
- scrollDelta.y = scrollContainer.scrollTop - newScrollCoordinates;
1017
- } else {
1018
- scrollDelta.y = direction === KeyboardCode.Down ? scrollContainer.scrollTop - maxScroll.y : scrollContainer.scrollTop - minScroll.y;
1019
- }
1020
- if (scrollDelta.y) {
1021
- scrollContainer.scrollBy({
1022
- top: -scrollDelta.y,
1023
- behavior: scrollBehavior
1024
- });
1025
- }
1026
- break;
1027
- }
1028
- }
1029
- this.handleMove(event, add(subtract(newCoordinates, this.referenceCoordinates), scrollDelta));
1030
- }
1031
- }
1032
- }
1033
- handleMove(event, coordinates) {
1034
- const {
1035
- onMove
1036
- } = this.props;
1037
- event.preventDefault();
1038
- onMove(coordinates);
1039
- }
1040
- handleEnd(event) {
1041
- const {
1042
- onEnd
1043
- } = this.props;
1044
- event.preventDefault();
1045
- this.detach();
1046
- onEnd();
1047
- }
1048
- handleCancel(event) {
1049
- const {
1050
- onCancel
1051
- } = this.props;
1052
- event.preventDefault();
1053
- this.detach();
1054
- onCancel();
1055
- }
1056
- detach() {
1057
- this.listeners.removeAll();
1058
- this.windowListeners.removeAll();
1059
- }
1060
- }
1061
- KeyboardSensor.activators = [{
1062
- eventName: "onKeyDown",
1063
- handler: (event, _ref, _ref2) => {
1064
- let {
1065
- keyboardCodes = defaultKeyboardCodes,
1066
- onActivation
1067
- } = _ref;
1068
- let {
1069
- active
1070
- } = _ref2;
1071
- const {
1072
- code
1073
- } = event.nativeEvent;
1074
- if (keyboardCodes.start.includes(code)) {
1075
- const activator = active.activatorNode.current;
1076
- if (activator && event.target !== activator) {
1077
- return false;
1078
- }
1079
- event.preventDefault();
1080
- onActivation == null ? void 0 : onActivation({
1081
- event: event.nativeEvent
1082
- });
1083
- return true;
1084
- }
1085
- return false;
1086
- }
1087
- }];
1088
- function isDistanceConstraint(constraint) {
1089
- return Boolean(constraint && "distance" in constraint);
1090
- }
1091
- function isDelayConstraint(constraint) {
1092
- return Boolean(constraint && "delay" in constraint);
1093
- }
1094
- class AbstractPointerSensor {
1095
- constructor(props, events2, listenerTarget) {
1096
- var _getEventCoordinates;
1097
- if (listenerTarget === void 0) {
1098
- listenerTarget = getEventListenerTarget(props.event.target);
1099
- }
1100
- this.props = void 0;
1101
- this.events = void 0;
1102
- this.autoScrollEnabled = true;
1103
- this.document = void 0;
1104
- this.activated = false;
1105
- this.initialCoordinates = void 0;
1106
- this.timeoutId = null;
1107
- this.listeners = void 0;
1108
- this.documentListeners = void 0;
1109
- this.windowListeners = void 0;
1110
- this.props = props;
1111
- this.events = events2;
1112
- const {
1113
- event
1114
- } = props;
1115
- const {
1116
- target
1117
- } = event;
1118
- this.props = props;
1119
- this.events = events2;
1120
- this.document = getOwnerDocument(target);
1121
- this.documentListeners = new Listeners(this.document);
1122
- this.listeners = new Listeners(listenerTarget);
1123
- this.windowListeners = new Listeners(getWindow(target));
1124
- this.initialCoordinates = (_getEventCoordinates = getEventCoordinates(event)) != null ? _getEventCoordinates : defaultCoordinates;
1125
- this.handleStart = this.handleStart.bind(this);
1126
- this.handleMove = this.handleMove.bind(this);
1127
- this.handleEnd = this.handleEnd.bind(this);
1128
- this.handleCancel = this.handleCancel.bind(this);
1129
- this.handleKeydown = this.handleKeydown.bind(this);
1130
- this.removeTextSelection = this.removeTextSelection.bind(this);
1131
- this.attach();
1132
- }
1133
- attach() {
1134
- const {
1135
- events: events2,
1136
- props: {
1137
- options: {
1138
- activationConstraint,
1139
- bypassActivationConstraint
1140
- }
1141
- }
1142
- } = this;
1143
- this.listeners.add(events2.move.name, this.handleMove, {
1144
- passive: false
1145
- });
1146
- this.listeners.add(events2.end.name, this.handleEnd);
1147
- if (events2.cancel) {
1148
- this.listeners.add(events2.cancel.name, this.handleCancel);
1149
- }
1150
- this.windowListeners.add(EventName.Resize, this.handleCancel);
1151
- this.windowListeners.add(EventName.DragStart, preventDefault);
1152
- this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
1153
- this.windowListeners.add(EventName.ContextMenu, preventDefault);
1154
- this.documentListeners.add(EventName.Keydown, this.handleKeydown);
1155
- if (activationConstraint) {
1156
- if (bypassActivationConstraint != null && bypassActivationConstraint({
1157
- event: this.props.event,
1158
- activeNode: this.props.activeNode,
1159
- options: this.props.options
1160
- })) {
1161
- return this.handleStart();
1162
- }
1163
- if (isDelayConstraint(activationConstraint)) {
1164
- this.timeoutId = setTimeout(this.handleStart, activationConstraint.delay);
1165
- this.handlePending(activationConstraint);
1166
- return;
1167
- }
1168
- if (isDistanceConstraint(activationConstraint)) {
1169
- this.handlePending(activationConstraint);
1170
- return;
1171
- }
1172
- }
1173
- this.handleStart();
1174
- }
1175
- detach() {
1176
- this.listeners.removeAll();
1177
- this.windowListeners.removeAll();
1178
- setTimeout(this.documentListeners.removeAll, 50);
1179
- if (this.timeoutId !== null) {
1180
- clearTimeout(this.timeoutId);
1181
- this.timeoutId = null;
1182
- }
1183
- }
1184
- handlePending(constraint, offset) {
1185
- const {
1186
- active,
1187
- onPending
1188
- } = this.props;
1189
- onPending(active, constraint, this.initialCoordinates, offset);
1190
- }
1191
- handleStart() {
1192
- const {
1193
- initialCoordinates
1194
- } = this;
1195
- const {
1196
- onStart
1197
- } = this.props;
1198
- if (initialCoordinates) {
1199
- this.activated = true;
1200
- this.documentListeners.add(EventName.Click, stopPropagation, {
1201
- capture: true
1202
- });
1203
- this.removeTextSelection();
1204
- this.documentListeners.add(EventName.SelectionChange, this.removeTextSelection);
1205
- onStart(initialCoordinates);
1206
- }
1207
- }
1208
- handleMove(event) {
1209
- var _getEventCoordinates2;
1210
- const {
1211
- activated,
1212
- initialCoordinates,
1213
- props
1214
- } = this;
1215
- const {
1216
- onMove,
1217
- options: {
1218
- activationConstraint
1219
- }
1220
- } = props;
1221
- if (!initialCoordinates) {
1222
- return;
1223
- }
1224
- const coordinates = (_getEventCoordinates2 = getEventCoordinates(event)) != null ? _getEventCoordinates2 : defaultCoordinates;
1225
- const delta = subtract(initialCoordinates, coordinates);
1226
- if (!activated && activationConstraint) {
1227
- if (isDistanceConstraint(activationConstraint)) {
1228
- if (activationConstraint.tolerance != null && hasExceededDistance(delta, activationConstraint.tolerance)) {
1229
- return this.handleCancel();
1230
- }
1231
- if (hasExceededDistance(delta, activationConstraint.distance)) {
1232
- return this.handleStart();
1233
- }
1234
- }
1235
- if (isDelayConstraint(activationConstraint)) {
1236
- if (hasExceededDistance(delta, activationConstraint.tolerance)) {
1237
- return this.handleCancel();
1238
- }
1239
- }
1240
- this.handlePending(activationConstraint, delta);
1241
- return;
1242
- }
1243
- if (event.cancelable) {
1244
- event.preventDefault();
1245
- }
1246
- onMove(coordinates);
1247
- }
1248
- handleEnd() {
1249
- const {
1250
- onAbort,
1251
- onEnd
1252
- } = this.props;
1253
- this.detach();
1254
- if (!this.activated) {
1255
- onAbort(this.props.active);
1256
- }
1257
- onEnd();
1258
- }
1259
- handleCancel() {
1260
- const {
1261
- onAbort,
1262
- onCancel
1263
- } = this.props;
1264
- this.detach();
1265
- if (!this.activated) {
1266
- onAbort(this.props.active);
1267
- }
1268
- onCancel();
1269
- }
1270
- handleKeydown(event) {
1271
- if (event.code === KeyboardCode.Esc) {
1272
- this.handleCancel();
1273
- }
1274
- }
1275
- removeTextSelection() {
1276
- var _this$document$getSel;
1277
- (_this$document$getSel = this.document.getSelection()) == null ? void 0 : _this$document$getSel.removeAllRanges();
1278
- }
1279
- }
1280
- const events = {
1281
- cancel: {
1282
- name: "pointercancel"
1283
- },
1284
- move: {
1285
- name: "pointermove"
1286
- },
1287
- end: {
1288
- name: "pointerup"
1289
- }
1290
- };
1291
- class PointerSensor extends AbstractPointerSensor {
1292
- constructor(props) {
1293
- const {
1294
- event
1295
- } = props;
1296
- const listenerTarget = getOwnerDocument(event.target);
1297
- super(props, events, listenerTarget);
1298
- }
1299
- }
1300
- PointerSensor.activators = [{
1301
- eventName: "onPointerDown",
1302
- handler: (_ref, _ref2) => {
1303
- let {
1304
- nativeEvent: event
1305
- } = _ref;
1306
- let {
1307
- onActivation
1308
- } = _ref2;
1309
- if (!event.isPrimary || event.button !== 0) {
1310
- return false;
1311
- }
1312
- onActivation == null ? void 0 : onActivation({
1313
- event
1314
- });
1315
- return true;
1316
- }
1317
- }];
1318
- const events$1 = {
1319
- move: {
1320
- name: "mousemove"
1321
- },
1322
- end: {
1323
- name: "mouseup"
1324
- }
1325
- };
1326
- var MouseButton;
1327
- (function(MouseButton2) {
1328
- MouseButton2[MouseButton2["RightClick"] = 2] = "RightClick";
1329
- })(MouseButton || (MouseButton = {}));
1330
- class MouseSensor extends AbstractPointerSensor {
1331
- constructor(props) {
1332
- super(props, events$1, getOwnerDocument(props.event.target));
1333
- }
1334
- }
1335
- MouseSensor.activators = [{
1336
- eventName: "onMouseDown",
1337
- handler: (_ref, _ref2) => {
1338
- let {
1339
- nativeEvent: event
1340
- } = _ref;
1341
- let {
1342
- onActivation
1343
- } = _ref2;
1344
- if (event.button === MouseButton.RightClick) {
1345
- return false;
1346
- }
1347
- onActivation == null ? void 0 : onActivation({
1348
- event
1349
- });
1350
- return true;
1351
- }
1352
- }];
1353
- const events$2 = {
1354
- cancel: {
1355
- name: "touchcancel"
1356
- },
1357
- move: {
1358
- name: "touchmove"
1359
- },
1360
- end: {
1361
- name: "touchend"
1362
- }
1363
- };
1364
- class TouchSensor extends AbstractPointerSensor {
1365
- constructor(props) {
1366
- super(props, events$2);
1367
- }
1368
- static setup() {
1369
- window.addEventListener(events$2.move.name, noop2, {
1370
- capture: false,
1371
- passive: false
1372
- });
1373
- return function teardown() {
1374
- window.removeEventListener(events$2.move.name, noop2);
1375
- };
1376
- function noop2() {
1377
- }
1378
- }
1379
- }
1380
- TouchSensor.activators = [{
1381
- eventName: "onTouchStart",
1382
- handler: (_ref, _ref2) => {
1383
- let {
1384
- nativeEvent: event
1385
- } = _ref;
1386
- let {
1387
- onActivation
1388
- } = _ref2;
1389
- const {
1390
- touches
1391
- } = event;
1392
- if (touches.length > 1) {
1393
- return false;
1394
- }
1395
- onActivation == null ? void 0 : onActivation({
1396
- event
1397
- });
1398
- return true;
1399
- }
1400
- }];
1401
- var AutoScrollActivator;
1402
- (function(AutoScrollActivator2) {
1403
- AutoScrollActivator2[AutoScrollActivator2["Pointer"] = 0] = "Pointer";
1404
- AutoScrollActivator2[AutoScrollActivator2["DraggableRect"] = 1] = "DraggableRect";
1405
- })(AutoScrollActivator || (AutoScrollActivator = {}));
1406
- var TraversalOrder;
1407
- (function(TraversalOrder2) {
1408
- TraversalOrder2[TraversalOrder2["TreeOrder"] = 0] = "TreeOrder";
1409
- TraversalOrder2[TraversalOrder2["ReversedTreeOrder"] = 1] = "ReversedTreeOrder";
1410
- })(TraversalOrder || (TraversalOrder = {}));
1411
- function useAutoScroller(_ref) {
1412
- let {
1413
- acceleration,
1414
- activator = AutoScrollActivator.Pointer,
1415
- canScroll,
1416
- draggingRect,
1417
- enabled,
1418
- interval = 5,
1419
- order = TraversalOrder.TreeOrder,
1420
- pointerCoordinates,
1421
- scrollableAncestors,
1422
- scrollableAncestorRects,
1423
- delta,
1424
- threshold
1425
- } = _ref;
1426
- const scrollIntent = useScrollIntent({
1427
- delta,
1428
- disabled: !enabled
1429
- });
1430
- const [setAutoScrollInterval, clearAutoScrollInterval] = useInterval();
1431
- const scrollSpeed = useRef({
1432
- x: 0,
1433
- y: 0
1434
- });
1435
- const scrollDirection = useRef({
1436
- x: 0,
1437
- y: 0
1438
- });
1439
- const rect = useMemo(() => {
1440
- switch (activator) {
1441
- case AutoScrollActivator.Pointer:
1442
- return pointerCoordinates ? {
1443
- top: pointerCoordinates.y,
1444
- bottom: pointerCoordinates.y,
1445
- left: pointerCoordinates.x,
1446
- right: pointerCoordinates.x
1447
- } : null;
1448
- case AutoScrollActivator.DraggableRect:
1449
- return draggingRect;
1450
- }
1451
- }, [activator, draggingRect, pointerCoordinates]);
1452
- const scrollContainerRef = useRef(null);
1453
- const autoScroll = useCallback(() => {
1454
- const scrollContainer = scrollContainerRef.current;
1455
- if (!scrollContainer) {
1456
- return;
1457
- }
1458
- const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;
1459
- const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;
1460
- scrollContainer.scrollBy(scrollLeft, scrollTop);
1461
- }, []);
1462
- const sortedScrollableAncestors = useMemo(() => order === TraversalOrder.TreeOrder ? [...scrollableAncestors].reverse() : scrollableAncestors, [order, scrollableAncestors]);
1463
- useEffect(
1464
- () => {
1465
- if (!enabled || !scrollableAncestors.length || !rect) {
1466
- clearAutoScrollInterval();
1467
- return;
1468
- }
1469
- for (const scrollContainer of sortedScrollableAncestors) {
1470
- if ((canScroll == null ? void 0 : canScroll(scrollContainer)) === false) {
1471
- continue;
1472
- }
1473
- const index = scrollableAncestors.indexOf(scrollContainer);
1474
- const scrollContainerRect = scrollableAncestorRects[index];
1475
- if (!scrollContainerRect) {
1476
- continue;
1477
- }
1478
- const {
1479
- direction,
1480
- speed
1481
- } = getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, rect, acceleration, threshold);
1482
- for (const axis of ["x", "y"]) {
1483
- if (!scrollIntent[axis][direction[axis]]) {
1484
- speed[axis] = 0;
1485
- direction[axis] = 0;
1486
- }
1487
- }
1488
- if (speed.x > 0 || speed.y > 0) {
1489
- clearAutoScrollInterval();
1490
- scrollContainerRef.current = scrollContainer;
1491
- setAutoScrollInterval(autoScroll, interval);
1492
- scrollSpeed.current = speed;
1493
- scrollDirection.current = direction;
1494
- return;
1495
- }
1496
- }
1497
- scrollSpeed.current = {
1498
- x: 0,
1499
- y: 0
1500
- };
1501
- scrollDirection.current = {
1502
- x: 0,
1503
- y: 0
1504
- };
1505
- clearAutoScrollInterval();
1506
- },
1507
- // eslint-disable-next-line react-hooks/exhaustive-deps
1508
- [
1509
- acceleration,
1510
- autoScroll,
1511
- canScroll,
1512
- clearAutoScrollInterval,
1513
- enabled,
1514
- interval,
1515
- // eslint-disable-next-line react-hooks/exhaustive-deps
1516
- JSON.stringify(rect),
1517
- // eslint-disable-next-line react-hooks/exhaustive-deps
1518
- JSON.stringify(scrollIntent),
1519
- setAutoScrollInterval,
1520
- scrollableAncestors,
1521
- sortedScrollableAncestors,
1522
- scrollableAncestorRects,
1523
- // eslint-disable-next-line react-hooks/exhaustive-deps
1524
- JSON.stringify(threshold)
1525
- ]
1526
- );
1527
- }
1528
- const defaultScrollIntent = {
1529
- x: {
1530
- [Direction.Backward]: false,
1531
- [Direction.Forward]: false
1532
- },
1533
- y: {
1534
- [Direction.Backward]: false,
1535
- [Direction.Forward]: false
1536
- }
1537
- };
1538
- function useScrollIntent(_ref2) {
1539
- let {
1540
- delta,
1541
- disabled
1542
- } = _ref2;
1543
- const previousDelta = usePrevious(delta);
1544
- return useLazyMemo((previousIntent) => {
1545
- if (disabled || !previousDelta || !previousIntent) {
1546
- return defaultScrollIntent;
1547
- }
1548
- const direction = {
1549
- x: Math.sign(delta.x - previousDelta.x),
1550
- y: Math.sign(delta.y - previousDelta.y)
1551
- };
1552
- return {
1553
- x: {
1554
- [Direction.Backward]: previousIntent.x[Direction.Backward] || direction.x === -1,
1555
- [Direction.Forward]: previousIntent.x[Direction.Forward] || direction.x === 1
1556
- },
1557
- y: {
1558
- [Direction.Backward]: previousIntent.y[Direction.Backward] || direction.y === -1,
1559
- [Direction.Forward]: previousIntent.y[Direction.Forward] || direction.y === 1
1560
- }
1561
- };
1562
- }, [disabled, delta, previousDelta]);
1563
- }
1564
- function useCachedNode(draggableNodes, id) {
1565
- const draggableNode = id != null ? draggableNodes.get(id) : void 0;
1566
- const node = draggableNode ? draggableNode.node.current : null;
1567
- return useLazyMemo((cachedNode) => {
1568
- var _ref;
1569
- if (id == null) {
1570
- return null;
1571
- }
1572
- return (_ref = node != null ? node : cachedNode) != null ? _ref : null;
1573
- }, [node, id]);
1574
- }
1575
- function useCombineActivators(sensors, getSyntheticHandler) {
1576
- return useMemo(() => sensors.reduce((accumulator, sensor) => {
1577
- const {
1578
- sensor: Sensor
1579
- } = sensor;
1580
- const sensorActivators = Sensor.activators.map((activator) => ({
1581
- eventName: activator.eventName,
1582
- handler: getSyntheticHandler(activator.handler, sensor)
1583
- }));
1584
- return [...accumulator, ...sensorActivators];
1585
- }, []), [sensors, getSyntheticHandler]);
1586
- }
1587
- var MeasuringStrategy;
1588
- (function(MeasuringStrategy2) {
1589
- MeasuringStrategy2[MeasuringStrategy2["Always"] = 0] = "Always";
1590
- MeasuringStrategy2[MeasuringStrategy2["BeforeDragging"] = 1] = "BeforeDragging";
1591
- MeasuringStrategy2[MeasuringStrategy2["WhileDragging"] = 2] = "WhileDragging";
1592
- })(MeasuringStrategy || (MeasuringStrategy = {}));
1593
- var MeasuringFrequency;
1594
- (function(MeasuringFrequency2) {
1595
- MeasuringFrequency2["Optimized"] = "optimized";
1596
- })(MeasuringFrequency || (MeasuringFrequency = {}));
1597
- const defaultValue = /* @__PURE__ */ new Map();
1598
- function useDroppableMeasuring(containers, _ref) {
1599
- let {
1600
- dragging,
1601
- dependencies,
1602
- config
1603
- } = _ref;
1604
- const [queue, setQueue] = useState(null);
1605
- const {
1606
- frequency,
1607
- measure,
1608
- strategy
1609
- } = config;
1610
- const containersRef = useRef(containers);
1611
- const disabled = isDisabled();
1612
- const disabledRef = useLatestValue(disabled);
1613
- const measureDroppableContainers = useCallback(function(ids) {
1614
- if (ids === void 0) {
1615
- ids = [];
1616
- }
1617
- if (disabledRef.current) {
1618
- return;
1619
- }
1620
- setQueue((value) => {
1621
- if (value === null) {
1622
- return ids;
1623
- }
1624
- return value.concat(ids.filter((id) => !value.includes(id)));
1625
- });
1626
- }, [disabledRef]);
1627
- const timeoutId = useRef(null);
1628
- const droppableRects = useLazyMemo((previousValue) => {
1629
- if (disabled && !dragging) {
1630
- return defaultValue;
1631
- }
1632
- if (!previousValue || previousValue === defaultValue || containersRef.current !== containers || queue != null) {
1633
- const map = /* @__PURE__ */ new Map();
1634
- for (let container of containers) {
1635
- if (!container) {
1636
- continue;
1637
- }
1638
- if (queue && queue.length > 0 && !queue.includes(container.id) && container.rect.current) {
1639
- map.set(container.id, container.rect.current);
1640
- continue;
1641
- }
1642
- const node = container.node.current;
1643
- const rect = node ? new Rect(measure(node), node) : null;
1644
- container.rect.current = rect;
1645
- if (rect) {
1646
- map.set(container.id, rect);
1647
- }
1648
- }
1649
- return map;
1650
- }
1651
- return previousValue;
1652
- }, [containers, queue, dragging, disabled, measure]);
1653
- useEffect(() => {
1654
- containersRef.current = containers;
1655
- }, [containers]);
1656
- useEffect(
1657
- () => {
1658
- if (disabled) {
1659
- return;
1660
- }
1661
- measureDroppableContainers();
1662
- },
1663
- // eslint-disable-next-line react-hooks/exhaustive-deps
1664
- [dragging, disabled]
1665
- );
1666
- useEffect(
1667
- () => {
1668
- if (queue && queue.length > 0) {
1669
- setQueue(null);
1670
- }
1671
- },
1672
- //eslint-disable-next-line react-hooks/exhaustive-deps
1673
- [JSON.stringify(queue)]
1674
- );
1675
- useEffect(
1676
- () => {
1677
- if (disabled || typeof frequency !== "number" || timeoutId.current !== null) {
1678
- return;
1679
- }
1680
- timeoutId.current = setTimeout(() => {
1681
- measureDroppableContainers();
1682
- timeoutId.current = null;
1683
- }, frequency);
1684
- },
1685
- // eslint-disable-next-line react-hooks/exhaustive-deps
1686
- [frequency, disabled, measureDroppableContainers, ...dependencies]
1687
- );
1688
- return {
1689
- droppableRects,
1690
- measureDroppableContainers,
1691
- measuringScheduled: queue != null
1692
- };
1693
- function isDisabled() {
1694
- switch (strategy) {
1695
- case MeasuringStrategy.Always:
1696
- return false;
1697
- case MeasuringStrategy.BeforeDragging:
1698
- return dragging;
1699
- default:
1700
- return !dragging;
1701
- }
1702
- }
1703
- }
1704
- function useInitialValue(value, computeFn) {
1705
- return useLazyMemo((previousValue) => {
1706
- if (!value) {
1707
- return null;
1708
- }
1709
- if (previousValue) {
1710
- return previousValue;
1711
- }
1712
- return typeof computeFn === "function" ? computeFn(value) : value;
1713
- }, [computeFn, value]);
1714
- }
1715
- function useInitialRect(node, measure) {
1716
- return useInitialValue(node, measure);
1717
- }
1718
- function useMutationObserver(_ref) {
1719
- let {
1720
- callback,
1721
- disabled
1722
- } = _ref;
1723
- const handleMutations = useEvent(callback);
1724
- const mutationObserver = useMemo(() => {
1725
- if (disabled || typeof window === "undefined" || typeof window.MutationObserver === "undefined") {
1726
- return void 0;
1727
- }
1728
- const {
1729
- MutationObserver
1730
- } = window;
1731
- return new MutationObserver(handleMutations);
1732
- }, [handleMutations, disabled]);
1733
- useEffect(() => {
1734
- return () => mutationObserver == null ? void 0 : mutationObserver.disconnect();
1735
- }, [mutationObserver]);
1736
- return mutationObserver;
1737
- }
1738
- function useResizeObserver(_ref) {
1739
- let {
1740
- callback,
1741
- disabled
1742
- } = _ref;
1743
- const handleResize = useEvent(callback);
1744
- const resizeObserver = useMemo(
1745
- () => {
1746
- if (disabled || typeof window === "undefined" || typeof window.ResizeObserver === "undefined") {
1747
- return void 0;
1748
- }
1749
- const {
1750
- ResizeObserver
1751
- } = window;
1752
- return new ResizeObserver(handleResize);
1753
- },
1754
- // eslint-disable-next-line react-hooks/exhaustive-deps
1755
- [disabled]
1756
- );
1757
- useEffect(() => {
1758
- return () => resizeObserver == null ? void 0 : resizeObserver.disconnect();
1759
- }, [resizeObserver]);
1760
- return resizeObserver;
1761
- }
1762
- function defaultMeasure(element) {
1763
- return new Rect(getClientRect(element), element);
1764
- }
1765
- function useRect(element, measure, fallbackRect) {
1766
- if (measure === void 0) {
1767
- measure = defaultMeasure;
1768
- }
1769
- const [rect, setRect] = useState(null);
1770
- function measureRect() {
1771
- setRect((currentRect) => {
1772
- if (!element) {
1773
- return null;
1774
- }
1775
- if (element.isConnected === false) {
1776
- var _ref;
1777
- return (_ref = currentRect != null ? currentRect : fallbackRect) != null ? _ref : null;
1778
- }
1779
- const newRect = measure(element);
1780
- if (JSON.stringify(currentRect) === JSON.stringify(newRect)) {
1781
- return currentRect;
1782
- }
1783
- return newRect;
1784
- });
1785
- }
1786
- const mutationObserver = useMutationObserver({
1787
- callback(records) {
1788
- if (!element) {
1789
- return;
1790
- }
1791
- for (const record of records) {
1792
- const {
1793
- type,
1794
- target
1795
- } = record;
1796
- if (type === "childList" && target instanceof HTMLElement && target.contains(element)) {
1797
- measureRect();
1798
- break;
1799
- }
1800
- }
1801
- }
1802
- });
1803
- const resizeObserver = useResizeObserver({
1804
- callback: measureRect
1805
- });
1806
- useIsomorphicLayoutEffect(() => {
1807
- measureRect();
1808
- if (element) {
1809
- resizeObserver == null ? void 0 : resizeObserver.observe(element);
1810
- mutationObserver == null ? void 0 : mutationObserver.observe(document.body, {
1811
- childList: true,
1812
- subtree: true
1813
- });
1814
- } else {
1815
- resizeObserver == null ? void 0 : resizeObserver.disconnect();
1816
- mutationObserver == null ? void 0 : mutationObserver.disconnect();
1817
- }
1818
- }, [element]);
1819
- return rect;
1820
- }
1821
- function useRectDelta(rect) {
1822
- const initialRect = useInitialValue(rect);
1823
- return getRectDelta(rect, initialRect);
1824
- }
1825
- const defaultValue$1 = [];
1826
- function useScrollableAncestors(node) {
1827
- const previousNode = useRef(node);
1828
- const ancestors = useLazyMemo((previousValue) => {
1829
- if (!node) {
1830
- return defaultValue$1;
1831
- }
1832
- if (previousValue && previousValue !== defaultValue$1 && node && previousNode.current && node.parentNode === previousNode.current.parentNode) {
1833
- return previousValue;
1834
- }
1835
- return getScrollableAncestors(node);
1836
- }, [node]);
1837
- useEffect(() => {
1838
- previousNode.current = node;
1839
- }, [node]);
1840
- return ancestors;
1841
- }
1842
- function useScrollOffsets(elements) {
1843
- const [scrollCoordinates, setScrollCoordinates] = useState(null);
1844
- const prevElements = useRef(elements);
1845
- const handleScroll = useCallback((event) => {
1846
- const scrollingElement = getScrollableElement(event.target);
1847
- if (!scrollingElement) {
1848
- return;
1849
- }
1850
- setScrollCoordinates((scrollCoordinates2) => {
1851
- if (!scrollCoordinates2) {
1852
- return null;
1853
- }
1854
- scrollCoordinates2.set(scrollingElement, getScrollCoordinates(scrollingElement));
1855
- return new Map(scrollCoordinates2);
1856
- });
1857
- }, []);
1858
- useEffect(() => {
1859
- const previousElements = prevElements.current;
1860
- if (elements !== previousElements) {
1861
- cleanup(previousElements);
1862
- const entries = elements.map((element) => {
1863
- const scrollableElement = getScrollableElement(element);
1864
- if (scrollableElement) {
1865
- scrollableElement.addEventListener("scroll", handleScroll, {
1866
- passive: true
1867
- });
1868
- return [scrollableElement, getScrollCoordinates(scrollableElement)];
1869
- }
1870
- return null;
1871
- }).filter((entry) => entry != null);
1872
- setScrollCoordinates(entries.length ? new Map(entries) : null);
1873
- prevElements.current = elements;
1874
- }
1875
- return () => {
1876
- cleanup(elements);
1877
- cleanup(previousElements);
1878
- };
1879
- function cleanup(elements2) {
1880
- elements2.forEach((element) => {
1881
- const scrollableElement = getScrollableElement(element);
1882
- scrollableElement == null ? void 0 : scrollableElement.removeEventListener("scroll", handleScroll);
1883
- });
1884
- }
1885
- }, [handleScroll, elements]);
1886
- return useMemo(() => {
1887
- if (elements.length) {
1888
- return scrollCoordinates ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => add(acc, coordinates), defaultCoordinates) : getScrollOffsets(elements);
1889
- }
1890
- return defaultCoordinates;
1891
- }, [elements, scrollCoordinates]);
1892
- }
1893
- function useScrollOffsetsDelta(scrollOffsets, dependencies) {
1894
- if (dependencies === void 0) {
1895
- dependencies = [];
1896
- }
1897
- const initialScrollOffsets = useRef(null);
1898
- useEffect(
1899
- () => {
1900
- initialScrollOffsets.current = null;
1901
- },
1902
- // eslint-disable-next-line react-hooks/exhaustive-deps
1903
- dependencies
1904
- );
1905
- useEffect(() => {
1906
- const hasScrollOffsets = scrollOffsets !== defaultCoordinates;
1907
- if (hasScrollOffsets && !initialScrollOffsets.current) {
1908
- initialScrollOffsets.current = scrollOffsets;
1909
- }
1910
- if (!hasScrollOffsets && initialScrollOffsets.current) {
1911
- initialScrollOffsets.current = null;
1912
- }
1913
- }, [scrollOffsets]);
1914
- return initialScrollOffsets.current ? subtract(scrollOffsets, initialScrollOffsets.current) : defaultCoordinates;
1915
- }
1916
- function useSensorSetup(sensors) {
1917
- useEffect(
1918
- () => {
1919
- if (!canUseDOM) {
1920
- return;
1921
- }
1922
- const teardownFns = sensors.map((_ref) => {
1923
- let {
1924
- sensor
1925
- } = _ref;
1926
- return sensor.setup == null ? void 0 : sensor.setup();
1927
- });
1928
- return () => {
1929
- for (const teardown of teardownFns) {
1930
- teardown == null ? void 0 : teardown();
1931
- }
1932
- };
1933
- },
1934
- // TO-DO: Sensors length could theoretically change which would not be a valid dependency
1935
- // eslint-disable-next-line react-hooks/exhaustive-deps
1936
- sensors.map((_ref2) => {
1937
- let {
1938
- sensor
1939
- } = _ref2;
1940
- return sensor;
1941
- })
1942
- );
1943
- }
1944
- function useSyntheticListeners(listeners, id) {
1945
- return useMemo(() => {
1946
- return listeners.reduce((acc, _ref) => {
1947
- let {
1948
- eventName,
1949
- handler
1950
- } = _ref;
1951
- acc[eventName] = (event) => {
1952
- handler(event, id);
1953
- };
1954
- return acc;
1955
- }, {});
1956
- }, [listeners, id]);
1957
- }
1958
- function useWindowRect(element) {
1959
- return useMemo(() => element ? getWindowClientRect(element) : null, [element]);
1960
- }
1961
- const defaultValue$2 = [];
1962
- function useRects(elements, measure) {
1963
- if (measure === void 0) {
1964
- measure = getClientRect;
1965
- }
1966
- const [firstElement] = elements;
1967
- const windowRect = useWindowRect(firstElement ? getWindow(firstElement) : null);
1968
- const [rects, setRects] = useState(defaultValue$2);
1969
- function measureRects() {
1970
- setRects(() => {
1971
- if (!elements.length) {
1972
- return defaultValue$2;
1973
- }
1974
- return elements.map((element) => isDocumentScrollingElement(element) ? windowRect : new Rect(measure(element), element));
1975
- });
1976
- }
1977
- const resizeObserver = useResizeObserver({
1978
- callback: measureRects
1979
- });
1980
- useIsomorphicLayoutEffect(() => {
1981
- resizeObserver == null ? void 0 : resizeObserver.disconnect();
1982
- measureRects();
1983
- elements.forEach((element) => resizeObserver == null ? void 0 : resizeObserver.observe(element));
1984
- }, [elements]);
1985
- return rects;
1986
- }
1987
- function getMeasurableNode(node) {
1988
- if (!node) {
1989
- return null;
1990
- }
1991
- if (node.children.length > 1) {
1992
- return node;
1993
- }
1994
- const firstChild = node.children[0];
1995
- return isHTMLElement(firstChild) ? firstChild : node;
1996
- }
1997
- function useDragOverlayMeasuring(_ref) {
1998
- let {
1999
- measure
2000
- } = _ref;
2001
- const [rect, setRect] = useState(null);
2002
- const handleResize = useCallback((entries) => {
2003
- for (const {
2004
- target
2005
- } of entries) {
2006
- if (isHTMLElement(target)) {
2007
- setRect((rect2) => {
2008
- const newRect = measure(target);
2009
- return rect2 ? {
2010
- ...rect2,
2011
- width: newRect.width,
2012
- height: newRect.height
2013
- } : newRect;
2014
- });
2015
- break;
2016
- }
2017
- }
2018
- }, [measure]);
2019
- const resizeObserver = useResizeObserver({
2020
- callback: handleResize
2021
- });
2022
- const handleNodeChange = useCallback((element) => {
2023
- const node = getMeasurableNode(element);
2024
- resizeObserver == null ? void 0 : resizeObserver.disconnect();
2025
- if (node) {
2026
- resizeObserver == null ? void 0 : resizeObserver.observe(node);
2027
- }
2028
- setRect(node ? measure(node) : null);
2029
- }, [measure, resizeObserver]);
2030
- const [nodeRef, setRef] = useNodeRef(handleNodeChange);
2031
- return useMemo(() => ({
2032
- nodeRef,
2033
- rect,
2034
- setRef
2035
- }), [rect, nodeRef, setRef]);
2036
- }
2037
- const defaultSensors = [{
2038
- sensor: PointerSensor,
2039
- options: {}
2040
- }, {
2041
- sensor: KeyboardSensor,
2042
- options: {}
2043
- }];
2044
- const defaultData = {
2045
- current: {}
2046
- };
2047
- const defaultMeasuringConfiguration = {
2048
- draggable: {
2049
- measure: getTransformAgnosticClientRect
2050
- },
2051
- droppable: {
2052
- measure: getTransformAgnosticClientRect,
2053
- strategy: MeasuringStrategy.WhileDragging,
2054
- frequency: MeasuringFrequency.Optimized
2055
- },
2056
- dragOverlay: {
2057
- measure: getClientRect
2058
- }
2059
- };
2060
- class DroppableContainersMap extends Map {
2061
- get(id) {
2062
- var _super$get;
2063
- return id != null ? (_super$get = super.get(id)) != null ? _super$get : void 0 : void 0;
2064
- }
2065
- toArray() {
2066
- return Array.from(this.values());
2067
- }
2068
- getEnabled() {
2069
- return this.toArray().filter((_ref) => {
2070
- let {
2071
- disabled
2072
- } = _ref;
2073
- return !disabled;
2074
- });
2075
- }
2076
- getNodeFor(id) {
2077
- var _this$get$node$curren, _this$get;
2078
- return (_this$get$node$curren = (_this$get = this.get(id)) == null ? void 0 : _this$get.node.current) != null ? _this$get$node$curren : void 0;
2079
- }
2080
- }
2081
- const defaultPublicContext = {
2082
- activatorEvent: null,
2083
- active: null,
2084
- activeNode: null,
2085
- activeNodeRect: null,
2086
- collisions: null,
2087
- containerNodeRect: null,
2088
- draggableNodes: /* @__PURE__ */ new Map(),
2089
- droppableRects: /* @__PURE__ */ new Map(),
2090
- droppableContainers: /* @__PURE__ */ new DroppableContainersMap(),
2091
- over: null,
2092
- dragOverlay: {
2093
- nodeRef: {
2094
- current: null
2095
- },
2096
- rect: null,
2097
- setRef: noop
2098
- },
2099
- scrollableAncestors: [],
2100
- scrollableAncestorRects: [],
2101
- measuringConfiguration: defaultMeasuringConfiguration,
2102
- measureDroppableContainers: noop,
2103
- windowRect: null,
2104
- measuringScheduled: false
2105
- };
2106
- const defaultInternalContext = {
2107
- activatorEvent: null,
2108
- activators: [],
2109
- active: null,
2110
- activeNodeRect: null,
2111
- ariaDescribedById: {
2112
- draggable: ""
2113
- },
2114
- dispatch: noop,
2115
- draggableNodes: /* @__PURE__ */ new Map(),
2116
- over: null,
2117
- measureDroppableContainers: noop
2118
- };
2119
- const InternalContext = /* @__PURE__ */ createContext(defaultInternalContext);
2120
- const PublicContext = /* @__PURE__ */ createContext(defaultPublicContext);
2121
- function getInitialState() {
2122
- return {
2123
- draggable: {
2124
- active: null,
2125
- initialCoordinates: {
2126
- x: 0,
2127
- y: 0
2128
- },
2129
- nodes: /* @__PURE__ */ new Map(),
2130
- translate: {
2131
- x: 0,
2132
- y: 0
2133
- }
2134
- },
2135
- droppable: {
2136
- containers: new DroppableContainersMap()
2137
- }
2138
- };
2139
- }
2140
- function reducer(state, action) {
2141
- switch (action.type) {
2142
- case Action.DragStart:
2143
- return {
2144
- ...state,
2145
- draggable: {
2146
- ...state.draggable,
2147
- initialCoordinates: action.initialCoordinates,
2148
- active: action.active
2149
- }
2150
- };
2151
- case Action.DragMove:
2152
- if (state.draggable.active == null) {
2153
- return state;
2154
- }
2155
- return {
2156
- ...state,
2157
- draggable: {
2158
- ...state.draggable,
2159
- translate: {
2160
- x: action.coordinates.x - state.draggable.initialCoordinates.x,
2161
- y: action.coordinates.y - state.draggable.initialCoordinates.y
2162
- }
2163
- }
2164
- };
2165
- case Action.DragEnd:
2166
- case Action.DragCancel:
2167
- return {
2168
- ...state,
2169
- draggable: {
2170
- ...state.draggable,
2171
- active: null,
2172
- initialCoordinates: {
2173
- x: 0,
2174
- y: 0
2175
- },
2176
- translate: {
2177
- x: 0,
2178
- y: 0
2179
- }
2180
- }
2181
- };
2182
- case Action.RegisterDroppable: {
2183
- const {
2184
- element
2185
- } = action;
2186
- const {
2187
- id
2188
- } = element;
2189
- const containers = new DroppableContainersMap(state.droppable.containers);
2190
- containers.set(id, element);
2191
- return {
2192
- ...state,
2193
- droppable: {
2194
- ...state.droppable,
2195
- containers
2196
- }
2197
- };
2198
- }
2199
- case Action.SetDroppableDisabled: {
2200
- const {
2201
- id,
2202
- key: key2,
2203
- disabled
2204
- } = action;
2205
- const element = state.droppable.containers.get(id);
2206
- if (!element || key2 !== element.key) {
2207
- return state;
2208
- }
2209
- const containers = new DroppableContainersMap(state.droppable.containers);
2210
- containers.set(id, {
2211
- ...element,
2212
- disabled
2213
- });
2214
- return {
2215
- ...state,
2216
- droppable: {
2217
- ...state.droppable,
2218
- containers
2219
- }
2220
- };
2221
- }
2222
- case Action.UnregisterDroppable: {
2223
- const {
2224
- id,
2225
- key: key2
2226
- } = action;
2227
- const element = state.droppable.containers.get(id);
2228
- if (!element || key2 !== element.key) {
2229
- return state;
2230
- }
2231
- const containers = new DroppableContainersMap(state.droppable.containers);
2232
- containers.delete(id);
2233
- return {
2234
- ...state,
2235
- droppable: {
2236
- ...state.droppable,
2237
- containers
2238
- }
2239
- };
2240
- }
2241
- default: {
2242
- return state;
2243
- }
2244
- }
2245
- }
2246
- function RestoreFocus(_ref) {
2247
- let {
2248
- disabled
2249
- } = _ref;
2250
- const {
2251
- active,
2252
- activatorEvent,
2253
- draggableNodes
2254
- } = useContext(InternalContext);
2255
- const previousActivatorEvent = usePrevious(activatorEvent);
2256
- const previousActiveId = usePrevious(active == null ? void 0 : active.id);
2257
- useEffect(() => {
2258
- if (disabled) {
2259
- return;
2260
- }
2261
- if (!activatorEvent && previousActivatorEvent && previousActiveId != null) {
2262
- if (!isKeyboardEvent(previousActivatorEvent)) {
2263
- return;
2264
- }
2265
- if (document.activeElement === previousActivatorEvent.target) {
2266
- return;
2267
- }
2268
- const draggableNode = draggableNodes.get(previousActiveId);
2269
- if (!draggableNode) {
2270
- return;
2271
- }
2272
- const {
2273
- activatorNode,
2274
- node
2275
- } = draggableNode;
2276
- if (!activatorNode.current && !node.current) {
2277
- return;
2278
- }
2279
- requestAnimationFrame(() => {
2280
- for (const element of [activatorNode.current, node.current]) {
2281
- if (!element) {
2282
- continue;
2283
- }
2284
- const focusableNode = findFirstFocusableNode(element);
2285
- if (focusableNode) {
2286
- focusableNode.focus();
2287
- break;
2288
- }
2289
- }
2290
- });
2291
- }
2292
- }, [activatorEvent, disabled, draggableNodes, previousActiveId, previousActivatorEvent]);
2293
- return null;
2294
- }
2295
- function applyModifiers(modifiers, _ref) {
2296
- let {
2297
- transform,
2298
- ...args
2299
- } = _ref;
2300
- return modifiers != null && modifiers.length ? modifiers.reduce((accumulator, modifier) => {
2301
- return modifier({
2302
- transform: accumulator,
2303
- ...args
2304
- });
2305
- }, transform) : transform;
2306
- }
2307
- function useMeasuringConfiguration(config) {
2308
- return useMemo(
2309
- () => ({
2310
- draggable: {
2311
- ...defaultMeasuringConfiguration.draggable,
2312
- ...config == null ? void 0 : config.draggable
2313
- },
2314
- droppable: {
2315
- ...defaultMeasuringConfiguration.droppable,
2316
- ...config == null ? void 0 : config.droppable
2317
- },
2318
- dragOverlay: {
2319
- ...defaultMeasuringConfiguration.dragOverlay,
2320
- ...config == null ? void 0 : config.dragOverlay
2321
- }
2322
- }),
2323
- // eslint-disable-next-line react-hooks/exhaustive-deps
2324
- [config == null ? void 0 : config.draggable, config == null ? void 0 : config.droppable, config == null ? void 0 : config.dragOverlay]
2325
- );
2326
- }
2327
- function useLayoutShiftScrollCompensation(_ref) {
2328
- let {
2329
- activeNode,
2330
- measure,
2331
- initialRect,
2332
- config = true
2333
- } = _ref;
2334
- const initialized = useRef(false);
2335
- const {
2336
- x,
2337
- y
2338
- } = typeof config === "boolean" ? {
2339
- x: config,
2340
- y: config
2341
- } : config;
2342
- useIsomorphicLayoutEffect(() => {
2343
- const disabled = !x && !y;
2344
- if (disabled || !activeNode) {
2345
- initialized.current = false;
2346
- return;
2347
- }
2348
- if (initialized.current || !initialRect) {
2349
- return;
2350
- }
2351
- const node = activeNode == null ? void 0 : activeNode.node.current;
2352
- if (!node || node.isConnected === false) {
2353
- return;
2354
- }
2355
- const rect = measure(node);
2356
- const rectDelta = getRectDelta(rect, initialRect);
2357
- if (!x) {
2358
- rectDelta.x = 0;
2359
- }
2360
- if (!y) {
2361
- rectDelta.y = 0;
2362
- }
2363
- initialized.current = true;
2364
- if (Math.abs(rectDelta.x) > 0 || Math.abs(rectDelta.y) > 0) {
2365
- const firstScrollableAncestor = getFirstScrollableAncestor(node);
2366
- if (firstScrollableAncestor) {
2367
- firstScrollableAncestor.scrollBy({
2368
- top: rectDelta.y,
2369
- left: rectDelta.x
2370
- });
2371
- }
2372
- }
2373
- }, [activeNode, x, y, initialRect, measure]);
2374
- }
2375
- const ActiveDraggableContext = /* @__PURE__ */ createContext({
2376
- ...defaultCoordinates,
2377
- scaleX: 1,
2378
- scaleY: 1
2379
- });
2380
- var Status;
2381
- (function(Status2) {
2382
- Status2[Status2["Uninitialized"] = 0] = "Uninitialized";
2383
- Status2[Status2["Initializing"] = 1] = "Initializing";
2384
- Status2[Status2["Initialized"] = 2] = "Initialized";
2385
- })(Status || (Status = {}));
2386
- const DndContext = /* @__PURE__ */ memo(function DndContext2(_ref) {
2387
- var _sensorContext$curren, _dragOverlay$nodeRef$, _dragOverlay$rect, _over$rect;
2388
- let {
2389
- id,
2390
- accessibility,
2391
- autoScroll = true,
2392
- children,
2393
- sensors = defaultSensors,
2394
- collisionDetection = rectIntersection,
2395
- measuring,
2396
- modifiers,
2397
- ...props
2398
- } = _ref;
2399
- const store = useReducer(reducer, void 0, getInitialState);
2400
- const [state, dispatch] = store;
2401
- const [dispatchMonitorEvent, registerMonitorListener] = useDndMonitorProvider();
2402
- const [status, setStatus] = useState(Status.Uninitialized);
2403
- const isInitialized = status === Status.Initialized;
2404
- const {
2405
- draggable: {
2406
- active: activeId,
2407
- nodes: draggableNodes,
2408
- translate
2409
- },
2410
- droppable: {
2411
- containers: droppableContainers
2412
- }
2413
- } = state;
2414
- const node = activeId != null ? draggableNodes.get(activeId) : null;
2415
- const activeRects = useRef({
2416
- initial: null,
2417
- translated: null
2418
- });
2419
- const active = useMemo(() => {
2420
- var _node$data;
2421
- return activeId != null ? {
2422
- id: activeId,
2423
- // It's possible for the active node to unmount while dragging
2424
- data: (_node$data = node == null ? void 0 : node.data) != null ? _node$data : defaultData,
2425
- rect: activeRects
2426
- } : null;
2427
- }, [activeId, node]);
2428
- const activeRef = useRef(null);
2429
- const [activeSensor, setActiveSensor] = useState(null);
2430
- const [activatorEvent, setActivatorEvent] = useState(null);
2431
- const latestProps = useLatestValue(props, Object.values(props));
2432
- const draggableDescribedById = useUniqueId("DndDescribedBy", id);
2433
- const enabledDroppableContainers = useMemo(() => droppableContainers.getEnabled(), [droppableContainers]);
2434
- const measuringConfiguration = useMeasuringConfiguration(measuring);
2435
- const {
2436
- droppableRects,
2437
- measureDroppableContainers,
2438
- measuringScheduled
2439
- } = useDroppableMeasuring(enabledDroppableContainers, {
2440
- dragging: isInitialized,
2441
- dependencies: [translate.x, translate.y],
2442
- config: measuringConfiguration.droppable
2443
- });
2444
- const activeNode = useCachedNode(draggableNodes, activeId);
2445
- const activationCoordinates = useMemo(() => activatorEvent ? getEventCoordinates(activatorEvent) : null, [activatorEvent]);
2446
- const autoScrollOptions = getAutoScrollerOptions();
2447
- const initialActiveNodeRect = useInitialRect(activeNode, measuringConfiguration.draggable.measure);
2448
- useLayoutShiftScrollCompensation({
2449
- activeNode: activeId != null ? draggableNodes.get(activeId) : null,
2450
- config: autoScrollOptions.layoutShiftCompensation,
2451
- initialRect: initialActiveNodeRect,
2452
- measure: measuringConfiguration.draggable.measure
2453
- });
2454
- const activeNodeRect = useRect(activeNode, measuringConfiguration.draggable.measure, initialActiveNodeRect);
2455
- const containerNodeRect = useRect(activeNode ? activeNode.parentElement : null);
2456
- const sensorContext = useRef({
2457
- activatorEvent: null,
2458
- active: null,
2459
- activeNode,
2460
- collisionRect: null,
2461
- collisions: null,
2462
- droppableRects,
2463
- draggableNodes,
2464
- draggingNode: null,
2465
- draggingNodeRect: null,
2466
- droppableContainers,
2467
- over: null,
2468
- scrollableAncestors: [],
2469
- scrollAdjustedTranslate: null
2470
- });
2471
- const overNode = droppableContainers.getNodeFor((_sensorContext$curren = sensorContext.current.over) == null ? void 0 : _sensorContext$curren.id);
2472
- const dragOverlay = useDragOverlayMeasuring({
2473
- measure: measuringConfiguration.dragOverlay.measure
2474
- });
2475
- const draggingNode = (_dragOverlay$nodeRef$ = dragOverlay.nodeRef.current) != null ? _dragOverlay$nodeRef$ : activeNode;
2476
- const draggingNodeRect = isInitialized ? (_dragOverlay$rect = dragOverlay.rect) != null ? _dragOverlay$rect : activeNodeRect : null;
2477
- const usesDragOverlay = Boolean(dragOverlay.nodeRef.current && dragOverlay.rect);
2478
- const nodeRectDelta = useRectDelta(usesDragOverlay ? null : activeNodeRect);
2479
- const windowRect = useWindowRect(draggingNode ? getWindow(draggingNode) : null);
2480
- const scrollableAncestors = useScrollableAncestors(isInitialized ? overNode != null ? overNode : activeNode : null);
2481
- const scrollableAncestorRects = useRects(scrollableAncestors);
2482
- const modifiedTranslate = applyModifiers(modifiers, {
2483
- transform: {
2484
- x: translate.x - nodeRectDelta.x,
2485
- y: translate.y - nodeRectDelta.y,
2486
- scaleX: 1,
2487
- scaleY: 1
2488
- },
2489
- activatorEvent,
2490
- active,
2491
- activeNodeRect,
2492
- containerNodeRect,
2493
- draggingNodeRect,
2494
- over: sensorContext.current.over,
2495
- overlayNodeRect: dragOverlay.rect,
2496
- scrollableAncestors,
2497
- scrollableAncestorRects,
2498
- windowRect
2499
- });
2500
- const pointerCoordinates = activationCoordinates ? add(activationCoordinates, translate) : null;
2501
- const scrollOffsets = useScrollOffsets(scrollableAncestors);
2502
- const scrollAdjustment = useScrollOffsetsDelta(scrollOffsets);
2503
- const activeNodeScrollDelta = useScrollOffsetsDelta(scrollOffsets, [activeNodeRect]);
2504
- const scrollAdjustedTranslate = add(modifiedTranslate, scrollAdjustment);
2505
- const collisionRect = draggingNodeRect ? getAdjustedRect(draggingNodeRect, modifiedTranslate) : null;
2506
- const collisions = active && collisionRect ? collisionDetection({
2507
- active,
2508
- collisionRect,
2509
- droppableRects,
2510
- droppableContainers: enabledDroppableContainers,
2511
- pointerCoordinates
2512
- }) : null;
2513
- const overId = getFirstCollision(collisions, "id");
2514
- const [over, setOver] = useState(null);
2515
- const appliedTranslate = usesDragOverlay ? modifiedTranslate : add(modifiedTranslate, activeNodeScrollDelta);
2516
- const transform = adjustScale(appliedTranslate, (_over$rect = over == null ? void 0 : over.rect) != null ? _over$rect : null, activeNodeRect);
2517
- const activeSensorRef = useRef(null);
2518
- const instantiateSensor = useCallback(
2519
- (event, _ref2) => {
2520
- let {
2521
- sensor: Sensor,
2522
- options
2523
- } = _ref2;
2524
- if (activeRef.current == null) {
2525
- return;
2526
- }
2527
- const activeNode2 = draggableNodes.get(activeRef.current);
2528
- if (!activeNode2) {
2529
- return;
2530
- }
2531
- const activatorEvent2 = event.nativeEvent;
2532
- const sensorInstance = new Sensor({
2533
- active: activeRef.current,
2534
- activeNode: activeNode2,
2535
- event: activatorEvent2,
2536
- options,
2537
- // Sensors need to be instantiated with refs for arguments that change over time
2538
- // otherwise they are frozen in time with the stale arguments
2539
- context: sensorContext,
2540
- onAbort(id2) {
2541
- const draggableNode = draggableNodes.get(id2);
2542
- if (!draggableNode) {
2543
- return;
2544
- }
2545
- const {
2546
- onDragAbort
2547
- } = latestProps.current;
2548
- const event2 = {
2549
- id: id2
2550
- };
2551
- onDragAbort == null ? void 0 : onDragAbort(event2);
2552
- dispatchMonitorEvent({
2553
- type: "onDragAbort",
2554
- event: event2
2555
- });
2556
- },
2557
- onPending(id2, constraint, initialCoordinates, offset) {
2558
- const draggableNode = draggableNodes.get(id2);
2559
- if (!draggableNode) {
2560
- return;
2561
- }
2562
- const {
2563
- onDragPending
2564
- } = latestProps.current;
2565
- const event2 = {
2566
- id: id2,
2567
- constraint,
2568
- initialCoordinates,
2569
- offset
2570
- };
2571
- onDragPending == null ? void 0 : onDragPending(event2);
2572
- dispatchMonitorEvent({
2573
- type: "onDragPending",
2574
- event: event2
2575
- });
2576
- },
2577
- onStart(initialCoordinates) {
2578
- const id2 = activeRef.current;
2579
- if (id2 == null) {
2580
- return;
2581
- }
2582
- const draggableNode = draggableNodes.get(id2);
2583
- if (!draggableNode) {
2584
- return;
2585
- }
2586
- const {
2587
- onDragStart
2588
- } = latestProps.current;
2589
- const event2 = {
2590
- activatorEvent: activatorEvent2,
2591
- active: {
2592
- id: id2,
2593
- data: draggableNode.data,
2594
- rect: activeRects
2595
- }
2596
- };
2597
- unstable_batchedUpdates(() => {
2598
- onDragStart == null ? void 0 : onDragStart(event2);
2599
- setStatus(Status.Initializing);
2600
- dispatch({
2601
- type: Action.DragStart,
2602
- initialCoordinates,
2603
- active: id2
2604
- });
2605
- dispatchMonitorEvent({
2606
- type: "onDragStart",
2607
- event: event2
2608
- });
2609
- setActiveSensor(activeSensorRef.current);
2610
- setActivatorEvent(activatorEvent2);
2611
- });
2612
- },
2613
- onMove(coordinates) {
2614
- dispatch({
2615
- type: Action.DragMove,
2616
- coordinates
2617
- });
2618
- },
2619
- onEnd: createHandler(Action.DragEnd),
2620
- onCancel: createHandler(Action.DragCancel)
2621
- });
2622
- activeSensorRef.current = sensorInstance;
2623
- function createHandler(type) {
2624
- return async function handler() {
2625
- const {
2626
- active: active2,
2627
- collisions: collisions2,
2628
- over: over2,
2629
- scrollAdjustedTranslate: scrollAdjustedTranslate2
2630
- } = sensorContext.current;
2631
- let event2 = null;
2632
- if (active2 && scrollAdjustedTranslate2) {
2633
- const {
2634
- cancelDrop
2635
- } = latestProps.current;
2636
- event2 = {
2637
- activatorEvent: activatorEvent2,
2638
- active: active2,
2639
- collisions: collisions2,
2640
- delta: scrollAdjustedTranslate2,
2641
- over: over2
2642
- };
2643
- if (type === Action.DragEnd && typeof cancelDrop === "function") {
2644
- const shouldCancel = await Promise.resolve(cancelDrop(event2));
2645
- if (shouldCancel) {
2646
- type = Action.DragCancel;
2647
- }
2648
- }
2649
- }
2650
- activeRef.current = null;
2651
- unstable_batchedUpdates(() => {
2652
- dispatch({
2653
- type
2654
- });
2655
- setStatus(Status.Uninitialized);
2656
- setOver(null);
2657
- setActiveSensor(null);
2658
- setActivatorEvent(null);
2659
- activeSensorRef.current = null;
2660
- const eventName = type === Action.DragEnd ? "onDragEnd" : "onDragCancel";
2661
- if (event2) {
2662
- const handler2 = latestProps.current[eventName];
2663
- handler2 == null ? void 0 : handler2(event2);
2664
- dispatchMonitorEvent({
2665
- type: eventName,
2666
- event: event2
2667
- });
2668
- }
2669
- });
2670
- };
2671
- }
2672
- },
2673
- // eslint-disable-next-line react-hooks/exhaustive-deps
2674
- [draggableNodes]
2675
- );
2676
- const bindActivatorToSensorInstantiator = useCallback((handler, sensor) => {
2677
- return (event, active2) => {
2678
- const nativeEvent = event.nativeEvent;
2679
- const activeDraggableNode = draggableNodes.get(active2);
2680
- if (
2681
- // Another sensor is already instantiating
2682
- activeRef.current !== null || // No active draggable
2683
- !activeDraggableNode || // Event has already been captured
2684
- nativeEvent.dndKit || nativeEvent.defaultPrevented
2685
- ) {
2686
- return;
2687
- }
2688
- const activationContext = {
2689
- active: activeDraggableNode
2690
- };
2691
- const shouldActivate = handler(event, sensor.options, activationContext);
2692
- if (shouldActivate === true) {
2693
- nativeEvent.dndKit = {
2694
- capturedBy: sensor.sensor
2695
- };
2696
- activeRef.current = active2;
2697
- instantiateSensor(event, sensor);
2698
- }
2699
- };
2700
- }, [draggableNodes, instantiateSensor]);
2701
- const activators = useCombineActivators(sensors, bindActivatorToSensorInstantiator);
2702
- useSensorSetup(sensors);
2703
- useIsomorphicLayoutEffect(() => {
2704
- if (activeNodeRect && status === Status.Initializing) {
2705
- setStatus(Status.Initialized);
2706
- }
2707
- }, [activeNodeRect, status]);
2708
- useEffect(
2709
- () => {
2710
- const {
2711
- onDragMove
2712
- } = latestProps.current;
2713
- const {
2714
- active: active2,
2715
- activatorEvent: activatorEvent2,
2716
- collisions: collisions2,
2717
- over: over2
2718
- } = sensorContext.current;
2719
- if (!active2 || !activatorEvent2) {
2720
- return;
2721
- }
2722
- const event = {
2723
- active: active2,
2724
- activatorEvent: activatorEvent2,
2725
- collisions: collisions2,
2726
- delta: {
2727
- x: scrollAdjustedTranslate.x,
2728
- y: scrollAdjustedTranslate.y
2729
- },
2730
- over: over2
2731
- };
2732
- unstable_batchedUpdates(() => {
2733
- onDragMove == null ? void 0 : onDragMove(event);
2734
- dispatchMonitorEvent({
2735
- type: "onDragMove",
2736
- event
2737
- });
2738
- });
2739
- },
2740
- // eslint-disable-next-line react-hooks/exhaustive-deps
2741
- [scrollAdjustedTranslate.x, scrollAdjustedTranslate.y]
2742
- );
2743
- useEffect(
2744
- () => {
2745
- const {
2746
- active: active2,
2747
- activatorEvent: activatorEvent2,
2748
- collisions: collisions2,
2749
- droppableContainers: droppableContainers2,
2750
- scrollAdjustedTranslate: scrollAdjustedTranslate2
2751
- } = sensorContext.current;
2752
- if (!active2 || activeRef.current == null || !activatorEvent2 || !scrollAdjustedTranslate2) {
2753
- return;
2754
- }
2755
- const {
2756
- onDragOver
2757
- } = latestProps.current;
2758
- const overContainer = droppableContainers2.get(overId);
2759
- const over2 = overContainer && overContainer.rect.current ? {
2760
- id: overContainer.id,
2761
- rect: overContainer.rect.current,
2762
- data: overContainer.data,
2763
- disabled: overContainer.disabled
2764
- } : null;
2765
- const event = {
2766
- active: active2,
2767
- activatorEvent: activatorEvent2,
2768
- collisions: collisions2,
2769
- delta: {
2770
- x: scrollAdjustedTranslate2.x,
2771
- y: scrollAdjustedTranslate2.y
2772
- },
2773
- over: over2
2774
- };
2775
- unstable_batchedUpdates(() => {
2776
- setOver(over2);
2777
- onDragOver == null ? void 0 : onDragOver(event);
2778
- dispatchMonitorEvent({
2779
- type: "onDragOver",
2780
- event
2781
- });
2782
- });
2783
- },
2784
- // eslint-disable-next-line react-hooks/exhaustive-deps
2785
- [overId]
2786
- );
2787
- useIsomorphicLayoutEffect(() => {
2788
- sensorContext.current = {
2789
- activatorEvent,
2790
- active,
2791
- activeNode,
2792
- collisionRect,
2793
- collisions,
2794
- droppableRects,
2795
- draggableNodes,
2796
- draggingNode,
2797
- draggingNodeRect,
2798
- droppableContainers,
2799
- over,
2800
- scrollableAncestors,
2801
- scrollAdjustedTranslate
2802
- };
2803
- activeRects.current = {
2804
- initial: draggingNodeRect,
2805
- translated: collisionRect
2806
- };
2807
- }, [active, activeNode, collisions, collisionRect, draggableNodes, draggingNode, draggingNodeRect, droppableRects, droppableContainers, over, scrollableAncestors, scrollAdjustedTranslate]);
2808
- useAutoScroller({
2809
- ...autoScrollOptions,
2810
- delta: translate,
2811
- draggingRect: collisionRect,
2812
- pointerCoordinates,
2813
- scrollableAncestors,
2814
- scrollableAncestorRects
2815
- });
2816
- const publicContext = useMemo(() => {
2817
- const context = {
2818
- active,
2819
- activeNode,
2820
- activeNodeRect,
2821
- activatorEvent,
2822
- collisions,
2823
- containerNodeRect,
2824
- dragOverlay,
2825
- draggableNodes,
2826
- droppableContainers,
2827
- droppableRects,
2828
- over,
2829
- measureDroppableContainers,
2830
- scrollableAncestors,
2831
- scrollableAncestorRects,
2832
- measuringConfiguration,
2833
- measuringScheduled,
2834
- windowRect
2835
- };
2836
- return context;
2837
- }, [active, activeNode, activeNodeRect, activatorEvent, collisions, containerNodeRect, dragOverlay, draggableNodes, droppableContainers, droppableRects, over, measureDroppableContainers, scrollableAncestors, scrollableAncestorRects, measuringConfiguration, measuringScheduled, windowRect]);
2838
- const internalContext = useMemo(() => {
2839
- const context = {
2840
- activatorEvent,
2841
- activators,
2842
- active,
2843
- activeNodeRect,
2844
- ariaDescribedById: {
2845
- draggable: draggableDescribedById
2846
- },
2847
- dispatch,
2848
- draggableNodes,
2849
- over,
2850
- measureDroppableContainers
2851
- };
2852
- return context;
2853
- }, [activatorEvent, activators, active, activeNodeRect, dispatch, draggableDescribedById, draggableNodes, over, measureDroppableContainers]);
2854
- return React__default.createElement(DndMonitorContext.Provider, {
2855
- value: registerMonitorListener
2856
- }, React__default.createElement(InternalContext.Provider, {
2857
- value: internalContext
2858
- }, React__default.createElement(PublicContext.Provider, {
2859
- value: publicContext
2860
- }, React__default.createElement(ActiveDraggableContext.Provider, {
2861
- value: transform
2862
- }, children)), React__default.createElement(RestoreFocus, {
2863
- disabled: (accessibility == null ? void 0 : accessibility.restoreFocus) === false
2864
- })), React__default.createElement(Accessibility, {
2865
- ...accessibility,
2866
- hiddenTextDescribedById: draggableDescribedById
2867
- }));
2868
- function getAutoScrollerOptions() {
2869
- const activeSensorDisablesAutoscroll = (activeSensor == null ? void 0 : activeSensor.autoScrollEnabled) === false;
2870
- const autoScrollGloballyDisabled = typeof autoScroll === "object" ? autoScroll.enabled === false : autoScroll === false;
2871
- const enabled = isInitialized && !activeSensorDisablesAutoscroll && !autoScrollGloballyDisabled;
2872
- if (typeof autoScroll === "object") {
2873
- return {
2874
- ...autoScroll,
2875
- enabled
2876
- };
2877
- }
2878
- return {
2879
- enabled
2880
- };
2881
- }
2882
- });
2883
- const NullContext = /* @__PURE__ */ createContext(null);
2884
- const defaultRole = "button";
2885
- const ID_PREFIX = "Draggable";
2886
- function useDraggable(_ref) {
2887
- let {
2888
- id,
2889
- data,
2890
- disabled = false,
2891
- attributes
2892
- } = _ref;
2893
- const key2 = useUniqueId(ID_PREFIX);
2894
- const {
2895
- activators,
2896
- activatorEvent,
2897
- active,
2898
- activeNodeRect,
2899
- ariaDescribedById,
2900
- draggableNodes,
2901
- over
2902
- } = useContext(InternalContext);
2903
- const {
2904
- role = defaultRole,
2905
- roleDescription = "draggable",
2906
- tabIndex = 0
2907
- } = attributes != null ? attributes : {};
2908
- const isDragging = (active == null ? void 0 : active.id) === id;
2909
- const transform = useContext(isDragging ? ActiveDraggableContext : NullContext);
2910
- const [node, setNodeRef] = useNodeRef();
2911
- const [activatorNode, setActivatorNodeRef] = useNodeRef();
2912
- const listeners = useSyntheticListeners(activators, id);
2913
- const dataRef = useLatestValue(data);
2914
- useIsomorphicLayoutEffect(
2915
- () => {
2916
- draggableNodes.set(id, {
2917
- id,
2918
- key: key2,
2919
- node,
2920
- activatorNode,
2921
- data: dataRef
2922
- });
2923
- return () => {
2924
- const node2 = draggableNodes.get(id);
2925
- if (node2 && node2.key === key2) {
2926
- draggableNodes.delete(id);
2927
- }
2928
- };
2929
- },
2930
- // eslint-disable-next-line react-hooks/exhaustive-deps
2931
- [draggableNodes, id]
2932
- );
2933
- const memoizedAttributes = useMemo(() => ({
2934
- role,
2935
- tabIndex,
2936
- "aria-disabled": disabled,
2937
- "aria-pressed": isDragging && role === defaultRole ? true : void 0,
2938
- "aria-roledescription": roleDescription,
2939
- "aria-describedby": ariaDescribedById.draggable
2940
- }), [disabled, role, tabIndex, isDragging, roleDescription, ariaDescribedById.draggable]);
2941
- return {
2942
- active,
2943
- activatorEvent,
2944
- activeNodeRect,
2945
- attributes: memoizedAttributes,
2946
- isDragging,
2947
- listeners: disabled ? void 0 : listeners,
2948
- node,
2949
- over,
2950
- setNodeRef,
2951
- setActivatorNodeRef,
2952
- transform
2953
- };
2954
- }
2955
- function useDndContext() {
2956
- return useContext(PublicContext);
2957
- }
2958
- const ID_PREFIX$1 = "Droppable";
2959
- const defaultResizeObserverConfig = {
2960
- timeout: 25
2961
- };
2962
- function useDroppable(_ref) {
2963
- let {
2964
- data,
2965
- disabled = false,
2966
- id,
2967
- resizeObserverConfig
2968
- } = _ref;
2969
- const key2 = useUniqueId(ID_PREFIX$1);
2970
- const {
2971
- active,
2972
- dispatch,
2973
- over,
2974
- measureDroppableContainers
2975
- } = useContext(InternalContext);
2976
- const previous = useRef({
2977
- disabled
2978
- });
2979
- const resizeObserverConnected = useRef(false);
2980
- const rect = useRef(null);
2981
- const callbackId = useRef(null);
2982
- const {
2983
- disabled: resizeObserverDisabled,
2984
- updateMeasurementsFor,
2985
- timeout: resizeObserverTimeout
2986
- } = {
2987
- ...defaultResizeObserverConfig,
2988
- ...resizeObserverConfig
2989
- };
2990
- const ids = useLatestValue(updateMeasurementsFor != null ? updateMeasurementsFor : id);
2991
- const handleResize = useCallback(
2992
- () => {
2993
- if (!resizeObserverConnected.current) {
2994
- resizeObserverConnected.current = true;
2995
- return;
2996
- }
2997
- if (callbackId.current != null) {
2998
- clearTimeout(callbackId.current);
2999
- }
3000
- callbackId.current = setTimeout(() => {
3001
- measureDroppableContainers(Array.isArray(ids.current) ? ids.current : [ids.current]);
3002
- callbackId.current = null;
3003
- }, resizeObserverTimeout);
3004
- },
3005
- //eslint-disable-next-line react-hooks/exhaustive-deps
3006
- [resizeObserverTimeout]
3007
- );
3008
- const resizeObserver = useResizeObserver({
3009
- callback: handleResize,
3010
- disabled: resizeObserverDisabled || !active
3011
- });
3012
- const handleNodeChange = useCallback((newElement, previousElement) => {
3013
- if (!resizeObserver) {
3014
- return;
3015
- }
3016
- if (previousElement) {
3017
- resizeObserver.unobserve(previousElement);
3018
- resizeObserverConnected.current = false;
3019
- }
3020
- if (newElement) {
3021
- resizeObserver.observe(newElement);
3022
- }
3023
- }, [resizeObserver]);
3024
- const [nodeRef, setNodeRef] = useNodeRef(handleNodeChange);
3025
- const dataRef = useLatestValue(data);
3026
- useEffect(() => {
3027
- if (!resizeObserver || !nodeRef.current) {
3028
- return;
3029
- }
3030
- resizeObserver.disconnect();
3031
- resizeObserverConnected.current = false;
3032
- resizeObserver.observe(nodeRef.current);
3033
- }, [nodeRef, resizeObserver]);
3034
- useEffect(
3035
- () => {
3036
- dispatch({
3037
- type: Action.RegisterDroppable,
3038
- element: {
3039
- id,
3040
- key: key2,
3041
- disabled,
3042
- node: nodeRef,
3043
- rect,
3044
- data: dataRef
3045
- }
3046
- });
3047
- return () => dispatch({
3048
- type: Action.UnregisterDroppable,
3049
- key: key2,
3050
- id
3051
- });
3052
- },
3053
- // eslint-disable-next-line react-hooks/exhaustive-deps
3054
- [id]
3055
- );
3056
- useEffect(() => {
3057
- if (disabled !== previous.current.disabled) {
3058
- dispatch({
3059
- type: Action.SetDroppableDisabled,
3060
- id,
3061
- key: key2,
3062
- disabled
3063
- });
3064
- previous.current.disabled = disabled;
3065
- }
3066
- }, [id, key2, disabled, dispatch]);
3067
- return {
3068
- active,
3069
- rect,
3070
- isOver: (over == null ? void 0 : over.id) === id,
3071
- node: nodeRef,
3072
- over,
3073
- setNodeRef
3074
- };
3075
- }
3076
- function AnimationManager(_ref) {
3077
- let {
3078
- animation,
3079
- children
3080
- } = _ref;
3081
- const [clonedChildren, setClonedChildren] = useState(null);
3082
- const [element, setElement] = useState(null);
3083
- const previousChildren = usePrevious(children);
3084
- if (!children && !clonedChildren && previousChildren) {
3085
- setClonedChildren(previousChildren);
3086
- }
3087
- useIsomorphicLayoutEffect(() => {
3088
- if (!element) {
3089
- return;
3090
- }
3091
- const key2 = clonedChildren == null ? void 0 : clonedChildren.key;
3092
- const id = clonedChildren == null ? void 0 : clonedChildren.props.id;
3093
- if (key2 == null || id == null) {
3094
- setClonedChildren(null);
3095
- return;
3096
- }
3097
- Promise.resolve(animation(id, element)).then(() => {
3098
- setClonedChildren(null);
3099
- });
3100
- }, [animation, clonedChildren, element]);
3101
- return React__default.createElement(React__default.Fragment, null, children, clonedChildren ? cloneElement(clonedChildren, {
3102
- ref: setElement
3103
- }) : null);
3104
- }
3105
- const defaultTransform = {
3106
- x: 0,
3107
- y: 0,
3108
- scaleX: 1,
3109
- scaleY: 1
3110
- };
3111
- function NullifiedContextProvider(_ref) {
3112
- let {
3113
- children
3114
- } = _ref;
3115
- return React__default.createElement(InternalContext.Provider, {
3116
- value: defaultInternalContext
3117
- }, React__default.createElement(ActiveDraggableContext.Provider, {
3118
- value: defaultTransform
3119
- }, children));
3120
- }
3121
- const baseStyles = {
3122
- position: "fixed",
3123
- touchAction: "none"
3124
- };
3125
- const defaultTransition = (activatorEvent) => {
3126
- const isKeyboardActivator = isKeyboardEvent(activatorEvent);
3127
- return isKeyboardActivator ? "transform 250ms ease" : void 0;
3128
- };
3129
- const PositionedOverlay = /* @__PURE__ */ forwardRef((_ref, ref) => {
3130
- let {
3131
- as,
3132
- activatorEvent,
3133
- adjustScale: adjustScale2,
3134
- children,
3135
- className,
3136
- rect,
3137
- style,
3138
- transform,
3139
- transition = defaultTransition
3140
- } = _ref;
3141
- if (!rect) {
3142
- return null;
3143
- }
3144
- const scaleAdjustedTransform = adjustScale2 ? transform : {
3145
- ...transform,
3146
- scaleX: 1,
3147
- scaleY: 1
3148
- };
3149
- const styles = {
3150
- ...baseStyles,
3151
- width: rect.width,
3152
- height: rect.height,
3153
- top: rect.top,
3154
- left: rect.left,
3155
- transform: CSS.Transform.toString(scaleAdjustedTransform),
3156
- transformOrigin: adjustScale2 && activatorEvent ? getRelativeTransformOrigin(activatorEvent, rect) : void 0,
3157
- transition: typeof transition === "function" ? transition(activatorEvent) : transition,
3158
- ...style
3159
- };
3160
- return React__default.createElement(as, {
3161
- className,
3162
- style: styles,
3163
- ref
3164
- }, children);
3165
- });
3166
- const defaultDropAnimationSideEffects = (options) => (_ref) => {
3167
- let {
3168
- active,
3169
- dragOverlay
3170
- } = _ref;
3171
- const originalStyles = {};
3172
- const {
3173
- styles,
3174
- className
3175
- } = options;
3176
- if (styles != null && styles.active) {
3177
- for (const [key2, value] of Object.entries(styles.active)) {
3178
- if (value === void 0) {
3179
- continue;
3180
- }
3181
- originalStyles[key2] = active.node.style.getPropertyValue(key2);
3182
- active.node.style.setProperty(key2, value);
3183
- }
3184
- }
3185
- if (styles != null && styles.dragOverlay) {
3186
- for (const [key2, value] of Object.entries(styles.dragOverlay)) {
3187
- if (value === void 0) {
3188
- continue;
3189
- }
3190
- dragOverlay.node.style.setProperty(key2, value);
3191
- }
3192
- }
3193
- if (className != null && className.active) {
3194
- active.node.classList.add(className.active);
3195
- }
3196
- if (className != null && className.dragOverlay) {
3197
- dragOverlay.node.classList.add(className.dragOverlay);
3198
- }
3199
- return function cleanup() {
3200
- for (const [key2, value] of Object.entries(originalStyles)) {
3201
- active.node.style.setProperty(key2, value);
3202
- }
3203
- if (className != null && className.active) {
3204
- active.node.classList.remove(className.active);
3205
- }
3206
- };
3207
- };
3208
- const defaultKeyframeResolver = (_ref2) => {
3209
- let {
3210
- transform: {
3211
- initial,
3212
- final
3213
- }
3214
- } = _ref2;
3215
- return [{
3216
- transform: CSS.Transform.toString(initial)
3217
- }, {
3218
- transform: CSS.Transform.toString(final)
3219
- }];
3220
- };
3221
- const defaultDropAnimationConfiguration = {
3222
- duration: 250,
3223
- easing: "ease",
3224
- keyframes: defaultKeyframeResolver,
3225
- sideEffects: /* @__PURE__ */ defaultDropAnimationSideEffects({
3226
- styles: {
3227
- active: {
3228
- opacity: "0"
3229
- }
3230
- }
3231
- })
3232
- };
3233
- function useDropAnimation(_ref3) {
3234
- let {
3235
- config,
3236
- draggableNodes,
3237
- droppableContainers,
3238
- measuringConfiguration
3239
- } = _ref3;
3240
- return useEvent((id, node) => {
3241
- if (config === null) {
3242
- return;
3243
- }
3244
- const activeDraggable = draggableNodes.get(id);
3245
- if (!activeDraggable) {
3246
- return;
3247
- }
3248
- const activeNode = activeDraggable.node.current;
3249
- if (!activeNode) {
3250
- return;
3251
- }
3252
- const measurableNode = getMeasurableNode(node);
3253
- if (!measurableNode) {
3254
- return;
3255
- }
3256
- const {
3257
- transform
3258
- } = getWindow(node).getComputedStyle(node);
3259
- const parsedTransform = parseTransform(transform);
3260
- if (!parsedTransform) {
3261
- return;
3262
- }
3263
- const animation = typeof config === "function" ? config : createDefaultDropAnimation(config);
3264
- scrollIntoViewIfNeeded(activeNode, measuringConfiguration.draggable.measure);
3265
- return animation({
3266
- active: {
3267
- id,
3268
- data: activeDraggable.data,
3269
- node: activeNode,
3270
- rect: measuringConfiguration.draggable.measure(activeNode)
3271
- },
3272
- draggableNodes,
3273
- dragOverlay: {
3274
- node,
3275
- rect: measuringConfiguration.dragOverlay.measure(measurableNode)
3276
- },
3277
- droppableContainers,
3278
- measuringConfiguration,
3279
- transform: parsedTransform
3280
- });
3281
- });
3282
- }
3283
- function createDefaultDropAnimation(options) {
3284
- const {
3285
- duration,
3286
- easing,
3287
- sideEffects,
3288
- keyframes
3289
- } = {
3290
- ...defaultDropAnimationConfiguration,
3291
- ...options
3292
- };
3293
- return (_ref4) => {
3294
- let {
3295
- active,
3296
- dragOverlay,
3297
- transform,
3298
- ...rest
3299
- } = _ref4;
3300
- if (!duration) {
3301
- return;
3302
- }
3303
- const delta = {
3304
- x: dragOverlay.rect.left - active.rect.left,
3305
- y: dragOverlay.rect.top - active.rect.top
3306
- };
3307
- const scale = {
3308
- scaleX: transform.scaleX !== 1 ? active.rect.width * transform.scaleX / dragOverlay.rect.width : 1,
3309
- scaleY: transform.scaleY !== 1 ? active.rect.height * transform.scaleY / dragOverlay.rect.height : 1
3310
- };
3311
- const finalTransform = {
3312
- x: transform.x - delta.x,
3313
- y: transform.y - delta.y,
3314
- ...scale
3315
- };
3316
- const animationKeyframes = keyframes({
3317
- ...rest,
3318
- active,
3319
- dragOverlay,
3320
- transform: {
3321
- initial: transform,
3322
- final: finalTransform
3323
- }
3324
- });
3325
- const [firstKeyframe] = animationKeyframes;
3326
- const lastKeyframe = animationKeyframes[animationKeyframes.length - 1];
3327
- if (JSON.stringify(firstKeyframe) === JSON.stringify(lastKeyframe)) {
3328
- return;
3329
- }
3330
- const cleanup = sideEffects == null ? void 0 : sideEffects({
3331
- active,
3332
- dragOverlay,
3333
- ...rest
3334
- });
3335
- const animation = dragOverlay.node.animate(animationKeyframes, {
3336
- duration,
3337
- easing,
3338
- fill: "forwards"
3339
- });
3340
- return new Promise((resolve) => {
3341
- animation.onfinish = () => {
3342
- cleanup == null ? void 0 : cleanup();
3343
- resolve();
3344
- };
3345
- });
3346
- };
3347
- }
3348
- let key = 0;
3349
- function useKey(id) {
3350
- return useMemo(() => {
3351
- if (id == null) {
3352
- return;
3353
- }
3354
- key++;
3355
- return key;
3356
- }, [id]);
3357
- }
3358
- const DragOverlay = /* @__PURE__ */ React__default.memo((_ref) => {
3359
- let {
3360
- adjustScale: adjustScale2 = false,
3361
- children,
3362
- dropAnimation: dropAnimationConfig,
3363
- style,
3364
- transition,
3365
- modifiers,
3366
- wrapperElement = "div",
3367
- className,
3368
- zIndex = 999
3369
- } = _ref;
3370
- const {
3371
- activatorEvent,
3372
- active,
3373
- activeNodeRect,
3374
- containerNodeRect,
3375
- draggableNodes,
3376
- droppableContainers,
3377
- dragOverlay,
3378
- over,
3379
- measuringConfiguration,
3380
- scrollableAncestors,
3381
- scrollableAncestorRects,
3382
- windowRect
3383
- } = useDndContext();
3384
- const transform = useContext(ActiveDraggableContext);
3385
- const key2 = useKey(active == null ? void 0 : active.id);
3386
- const modifiedTransform = applyModifiers(modifiers, {
3387
- activatorEvent,
3388
- active,
3389
- activeNodeRect,
3390
- containerNodeRect,
3391
- draggingNodeRect: dragOverlay.rect,
3392
- over,
3393
- overlayNodeRect: dragOverlay.rect,
3394
- scrollableAncestors,
3395
- scrollableAncestorRects,
3396
- transform,
3397
- windowRect
3398
- });
3399
- const initialRect = useInitialValue(activeNodeRect);
3400
- const dropAnimation = useDropAnimation({
3401
- config: dropAnimationConfig,
3402
- draggableNodes,
3403
- droppableContainers,
3404
- measuringConfiguration
3405
- });
3406
- const ref = initialRect ? dragOverlay.setRef : void 0;
3407
- return React__default.createElement(NullifiedContextProvider, null, React__default.createElement(AnimationManager, {
3408
- animation: dropAnimation
3409
- }, active && key2 ? React__default.createElement(PositionedOverlay, {
3410
- key: key2,
3411
- id: active.id,
3412
- ref,
3413
- as: wrapperElement,
3414
- activatorEvent,
3415
- adjustScale: adjustScale2,
3416
- className,
3417
- transition,
3418
- rect: initialRect,
3419
- style: {
3420
- zIndex,
3421
- ...style
3422
- },
3423
- transform: modifiedTransform
3424
- }, children) : null));
3425
- });
3426
- export {
3427
- AutoScrollActivator,
3428
- DndContext,
3429
- DragOverlay,
3430
- KeyboardCode,
3431
- KeyboardSensor,
3432
- MeasuringFrequency,
3433
- MeasuringStrategy,
3434
- MouseSensor,
3435
- PointerSensor,
3436
- TouchSensor,
3437
- TraversalOrder,
3438
- applyModifiers,
3439
- closestCenter,
3440
- closestCorners,
3441
- defaultAnnouncements,
3442
- defaultCoordinates,
3443
- defaultDropAnimationConfiguration as defaultDropAnimation,
3444
- defaultDropAnimationSideEffects,
3445
- defaultKeyboardCoordinateGetter,
3446
- defaultScreenReaderInstructions,
3447
- getClientRect,
3448
- getFirstCollision,
3449
- getScrollableAncestors,
3450
- rectIntersection,
3451
- useDndContext,
3452
- useDndMonitor,
3453
- useDraggable,
3454
- useDroppable,
3455
- useSensor,
3456
- useSensors
3457
- };
3458
- //# sourceMappingURL=core.esm.js.map