@oj-module/cli 0.2.64 → 0.2.67

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