eidos-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +175 -0
- package/dist/Breadcrumb.types-DaykU-C8.d.cts +20 -0
- package/dist/Breadcrumb.types-DaykU-C8.d.ts +20 -0
- package/dist/Button.types-BH0CPyPx.d.ts +33 -0
- package/dist/Button.types-DZRCVqyN.d.cts +33 -0
- package/dist/CommandPalette.types-DRMMS_ev.d.cts +73 -0
- package/dist/CommandPalette.types-DRMMS_ev.d.ts +73 -0
- package/dist/Footer.types-Dv2TPN2J.d.cts +24 -0
- package/dist/Footer.types-Dv2TPN2J.d.ts +24 -0
- package/dist/Header.types-BZi80bWz.d.cts +17 -0
- package/dist/Header.types-DJt-q01P.d.ts +17 -0
- package/dist/Input.types-DFZNyJGF.d.cts +45 -0
- package/dist/Input.types-XrJTI0JC.d.ts +45 -0
- package/dist/Menu.types-DNIpjSAK.d.ts +49 -0
- package/dist/Menu.types-DwcuCZM7.d.cts +49 -0
- package/dist/Navigation.types-Ctu5mlTa.d.cts +94 -0
- package/dist/Navigation.types-DVcLJnrB.d.ts +94 -0
- package/dist/Table.types-Bv9l7qxd.d.ts +103 -0
- package/dist/Table.types-DQ0ReOLj.d.cts +103 -0
- package/dist/Toolbar.types-BGD57Uhm.d.ts +22 -0
- package/dist/Toolbar.types-tQkLmPIu.d.cts +22 -0
- package/dist/accordion/index.cjs +10 -0
- package/dist/accordion/index.cjs.map +1 -0
- package/dist/accordion/index.d.cts +39 -0
- package/dist/accordion/index.d.ts +39 -0
- package/dist/accordion/index.js +10 -0
- package/dist/accordion/index.js.map +1 -0
- package/dist/alert/index.cjs +12 -0
- package/dist/alert/index.cjs.map +1 -0
- package/dist/alert/index.d.cts +29 -0
- package/dist/alert/index.d.ts +29 -0
- package/dist/alert/index.js +12 -0
- package/dist/alert/index.js.map +1 -0
- package/dist/avatar/index.cjs +10 -0
- package/dist/avatar/index.cjs.map +1 -0
- package/dist/avatar/index.d.cts +26 -0
- package/dist/avatar/index.d.ts +26 -0
- package/dist/avatar/index.js +10 -0
- package/dist/avatar/index.js.map +1 -0
- package/dist/badge/index.cjs +8 -0
- package/dist/badge/index.cjs.map +1 -0
- package/dist/badge/index.d.cts +27 -0
- package/dist/badge/index.d.ts +27 -0
- package/dist/badge/index.js +8 -0
- package/dist/badge/index.js.map +1 -0
- package/dist/breadcrumb/index.cjs +8 -0
- package/dist/breadcrumb/index.cjs.map +1 -0
- package/dist/breadcrumb/index.d.cts +7 -0
- package/dist/breadcrumb/index.d.ts +7 -0
- package/dist/breadcrumb/index.js +8 -0
- package/dist/breadcrumb/index.js.map +1 -0
- package/dist/button/index.cjs +14 -0
- package/dist/button/index.cjs.map +1 -0
- package/dist/button/index.d.cts +21 -0
- package/dist/button/index.d.ts +21 -0
- package/dist/button/index.js +14 -0
- package/dist/button/index.js.map +1 -0
- package/dist/button-group/index.cjs +8 -0
- package/dist/button-group/index.cjs.map +1 -0
- package/dist/button-group/index.d.cts +46 -0
- package/dist/button-group/index.d.ts +46 -0
- package/dist/button-group/index.js +8 -0
- package/dist/button-group/index.js.map +1 -0
- package/dist/card/index.cjs +8 -0
- package/dist/card/index.cjs.map +1 -0
- package/dist/card/index.d.cts +18 -0
- package/dist/card/index.d.ts +18 -0
- package/dist/card/index.js +8 -0
- package/dist/card/index.js.map +1 -0
- package/dist/checkbox/index.cjs +9 -0
- package/dist/checkbox/index.cjs.map +1 -0
- package/dist/checkbox/index.d.cts +16 -0
- package/dist/checkbox/index.d.ts +16 -0
- package/dist/checkbox/index.js +9 -0
- package/dist/checkbox/index.js.map +1 -0
- package/dist/chip/index.cjs +11 -0
- package/dist/chip/index.cjs.map +1 -0
- package/dist/chip/index.d.cts +27 -0
- package/dist/chip/index.d.ts +27 -0
- package/dist/chip/index.js +11 -0
- package/dist/chip/index.js.map +1 -0
- package/dist/chunk-2HTBZGBP.cjs +113 -0
- package/dist/chunk-2HTBZGBP.cjs.map +1 -0
- package/dist/chunk-2JWY36LD.cjs +112 -0
- package/dist/chunk-2JWY36LD.cjs.map +1 -0
- package/dist/chunk-2YQE26EK.js +54 -0
- package/dist/chunk-2YQE26EK.js.map +1 -0
- package/dist/chunk-2ZWBN3LK.cjs +92 -0
- package/dist/chunk-2ZWBN3LK.cjs.map +1 -0
- package/dist/chunk-3ETWFS2N.cjs +40 -0
- package/dist/chunk-3ETWFS2N.cjs.map +1 -0
- package/dist/chunk-3KAR5KCS.cjs +47 -0
- package/dist/chunk-3KAR5KCS.cjs.map +1 -0
- package/dist/chunk-3RUIKBH4.cjs +1 -0
- package/dist/chunk-3RUIKBH4.cjs.map +1 -0
- package/dist/chunk-3SKI6FXB.js +40 -0
- package/dist/chunk-3SKI6FXB.js.map +1 -0
- package/dist/chunk-3YPTYI7R.js +194 -0
- package/dist/chunk-3YPTYI7R.js.map +1 -0
- package/dist/chunk-4NUZP66U.js +299 -0
- package/dist/chunk-4NUZP66U.js.map +1 -0
- package/dist/chunk-5D3LIJYW.cjs +299 -0
- package/dist/chunk-5D3LIJYW.cjs.map +1 -0
- package/dist/chunk-5QG2I3FK.cjs +169 -0
- package/dist/chunk-5QG2I3FK.cjs.map +1 -0
- package/dist/chunk-5TGBNYZK.cjs +11 -0
- package/dist/chunk-5TGBNYZK.cjs.map +1 -0
- package/dist/chunk-5WRI5ZAA.js +31 -0
- package/dist/chunk-5WRI5ZAA.js.map +1 -0
- package/dist/chunk-63N2KZZX.cjs +54 -0
- package/dist/chunk-63N2KZZX.cjs.map +1 -0
- package/dist/chunk-66R54X6R.js +1 -0
- package/dist/chunk-66R54X6R.js.map +1 -0
- package/dist/chunk-6NZXWKUE.js +1 -0
- package/dist/chunk-6NZXWKUE.js.map +1 -0
- package/dist/chunk-6P4WYB3B.js +169 -0
- package/dist/chunk-6P4WYB3B.js.map +1 -0
- package/dist/chunk-6QFT3BUD.cjs +28 -0
- package/dist/chunk-6QFT3BUD.cjs.map +1 -0
- package/dist/chunk-6USUVU6J.js +26 -0
- package/dist/chunk-6USUVU6J.js.map +1 -0
- package/dist/chunk-73EKJU4G.js +11 -0
- package/dist/chunk-73EKJU4G.js.map +1 -0
- package/dist/chunk-7IOOFKG3.js +26 -0
- package/dist/chunk-7IOOFKG3.js.map +1 -0
- package/dist/chunk-7KGV6YCG.cjs +54 -0
- package/dist/chunk-7KGV6YCG.cjs.map +1 -0
- package/dist/chunk-7NZTRSMT.js +1484 -0
- package/dist/chunk-7NZTRSMT.js.map +1 -0
- package/dist/chunk-7R7IFWGB.cjs +86 -0
- package/dist/chunk-7R7IFWGB.cjs.map +1 -0
- package/dist/chunk-A35Y5MRJ.js +235 -0
- package/dist/chunk-A35Y5MRJ.js.map +1 -0
- package/dist/chunk-AOV32YBE.js +113 -0
- package/dist/chunk-AOV32YBE.js.map +1 -0
- package/dist/chunk-AUFCW7QU.cjs +526 -0
- package/dist/chunk-AUFCW7QU.cjs.map +1 -0
- package/dist/chunk-BFYSYUA6.cjs +125 -0
- package/dist/chunk-BFYSYUA6.cjs.map +1 -0
- package/dist/chunk-BTPCSBGP.js +1622 -0
- package/dist/chunk-BTPCSBGP.js.map +1 -0
- package/dist/chunk-C7F2VFAI.cjs +259 -0
- package/dist/chunk-C7F2VFAI.cjs.map +1 -0
- package/dist/chunk-CDV2OAS3.cjs +235 -0
- package/dist/chunk-CDV2OAS3.cjs.map +1 -0
- package/dist/chunk-CJUZDUXW.cjs +79 -0
- package/dist/chunk-CJUZDUXW.cjs.map +1 -0
- package/dist/chunk-CKH36D7H.js +28 -0
- package/dist/chunk-CKH36D7H.js.map +1 -0
- package/dist/chunk-D7PGZ3M3.cjs +117 -0
- package/dist/chunk-D7PGZ3M3.cjs.map +1 -0
- package/dist/chunk-DFADZZ3K.js +126 -0
- package/dist/chunk-DFADZZ3K.js.map +1 -0
- package/dist/chunk-DI2VKKLW.js +1 -0
- package/dist/chunk-DI2VKKLW.js.map +1 -0
- package/dist/chunk-DK4S3EHG.js +29 -0
- package/dist/chunk-DK4S3EHG.js.map +1 -0
- package/dist/chunk-DZUJEN5N.cjs +31 -0
- package/dist/chunk-DZUJEN5N.cjs.map +1 -0
- package/dist/chunk-E2B33QB7.js +97 -0
- package/dist/chunk-E2B33QB7.js.map +1 -0
- package/dist/chunk-E3XATJ63.js +4418 -0
- package/dist/chunk-E3XATJ63.js.map +1 -0
- package/dist/chunk-EACNRR3C.cjs +1 -0
- package/dist/chunk-EACNRR3C.cjs.map +1 -0
- package/dist/chunk-EQ6BNPTL.cjs +39 -0
- package/dist/chunk-EQ6BNPTL.cjs.map +1 -0
- package/dist/chunk-F54MVGKO.js +342 -0
- package/dist/chunk-F54MVGKO.js.map +1 -0
- package/dist/chunk-FNUOTM44.cjs +238 -0
- package/dist/chunk-FNUOTM44.cjs.map +1 -0
- package/dist/chunk-FO5FNTJX.js +69 -0
- package/dist/chunk-FO5FNTJX.js.map +1 -0
- package/dist/chunk-FQZ6F7FQ.cjs +1 -0
- package/dist/chunk-FQZ6F7FQ.cjs.map +1 -0
- package/dist/chunk-G2FANEA2.cjs +101 -0
- package/dist/chunk-G2FANEA2.cjs.map +1 -0
- package/dist/chunk-G36S5CWN.cjs +26 -0
- package/dist/chunk-G36S5CWN.cjs.map +1 -0
- package/dist/chunk-GI7WPGP2.cjs +454 -0
- package/dist/chunk-GI7WPGP2.cjs.map +1 -0
- package/dist/chunk-GL4DHGQE.js +1316 -0
- package/dist/chunk-GL4DHGQE.js.map +1 -0
- package/dist/chunk-GOVOQZYN.js +18 -0
- package/dist/chunk-GOVOQZYN.js.map +1 -0
- package/dist/chunk-GRH57M3E.js +88 -0
- package/dist/chunk-GRH57M3E.js.map +1 -0
- package/dist/chunk-H523JFY2.js +303 -0
- package/dist/chunk-H523JFY2.js.map +1 -0
- package/dist/chunk-H56YUMFB.cjs +1622 -0
- package/dist/chunk-H56YUMFB.cjs.map +1 -0
- package/dist/chunk-HO7P6IJO.js +238 -0
- package/dist/chunk-HO7P6IJO.js.map +1 -0
- package/dist/chunk-HPIBYEGE.cjs +1484 -0
- package/dist/chunk-HPIBYEGE.cjs.map +1 -0
- package/dist/chunk-HQ4KZRFH.js +67 -0
- package/dist/chunk-HQ4KZRFH.js.map +1 -0
- package/dist/chunk-HUNMRKGE.js +21 -0
- package/dist/chunk-HUNMRKGE.js.map +1 -0
- package/dist/chunk-I44YNYI6.cjs +1 -0
- package/dist/chunk-I44YNYI6.cjs.map +1 -0
- package/dist/chunk-I6UOIS4J.cjs +1 -0
- package/dist/chunk-I6UOIS4J.cjs.map +1 -0
- package/dist/chunk-ICJ3SV5I.cjs +183 -0
- package/dist/chunk-ICJ3SV5I.cjs.map +1 -0
- package/dist/chunk-IYQX7PBO.cjs +320 -0
- package/dist/chunk-IYQX7PBO.cjs.map +1 -0
- package/dist/chunk-JFA5ABVE.js +54 -0
- package/dist/chunk-JFA5ABVE.js.map +1 -0
- package/dist/chunk-JORQYNJD.js +79 -0
- package/dist/chunk-JORQYNJD.js.map +1 -0
- package/dist/chunk-K5TKNT6I.cjs +34 -0
- package/dist/chunk-K5TKNT6I.cjs.map +1 -0
- package/dist/chunk-KF64C4QI.js +138 -0
- package/dist/chunk-KF64C4QI.js.map +1 -0
- package/dist/chunk-KGXGTWUL.js +1 -0
- package/dist/chunk-KGXGTWUL.js.map +1 -0
- package/dist/chunk-KKOZX64Z.js +34 -0
- package/dist/chunk-KKOZX64Z.js.map +1 -0
- package/dist/chunk-KO2MKZDW.cjs +69 -0
- package/dist/chunk-KO2MKZDW.cjs.map +1 -0
- package/dist/chunk-KQKJVFYF.js +259 -0
- package/dist/chunk-KQKJVFYF.js.map +1 -0
- package/dist/chunk-KV2FG7AN.cjs +401 -0
- package/dist/chunk-KV2FG7AN.cjs.map +1 -0
- package/dist/chunk-L3UPSLJ5.cjs +4418 -0
- package/dist/chunk-L3UPSLJ5.cjs.map +1 -0
- package/dist/chunk-LEZ4HSBD.cjs +744 -0
- package/dist/chunk-LEZ4HSBD.cjs.map +1 -0
- package/dist/chunk-LQ3C3OR2.js +21 -0
- package/dist/chunk-LQ3C3OR2.js.map +1 -0
- package/dist/chunk-LTOHGCU4.cjs +69 -0
- package/dist/chunk-LTOHGCU4.cjs.map +1 -0
- package/dist/chunk-M56IGNH7.cjs +125 -0
- package/dist/chunk-M56IGNH7.cjs.map +1 -0
- package/dist/chunk-MOX6LYGC.js +125 -0
- package/dist/chunk-MOX6LYGC.js.map +1 -0
- package/dist/chunk-MSQXPGOD.cjs +125 -0
- package/dist/chunk-MSQXPGOD.cjs.map +1 -0
- package/dist/chunk-N5JDL4VE.js +1 -0
- package/dist/chunk-N5JDL4VE.js.map +1 -0
- package/dist/chunk-N7HX5635.cjs +138 -0
- package/dist/chunk-N7HX5635.cjs.map +1 -0
- package/dist/chunk-NDLMU6HJ.js +744 -0
- package/dist/chunk-NDLMU6HJ.js.map +1 -0
- package/dist/chunk-O5ZPSZNY.cjs +88 -0
- package/dist/chunk-O5ZPSZNY.cjs.map +1 -0
- package/dist/chunk-O6B4KB4D.js +125 -0
- package/dist/chunk-O6B4KB4D.js.map +1 -0
- package/dist/chunk-OHUVWPFJ.js +86 -0
- package/dist/chunk-OHUVWPFJ.js.map +1 -0
- package/dist/chunk-OT3VZLN4.js +117 -0
- package/dist/chunk-OT3VZLN4.js.map +1 -0
- package/dist/chunk-OVYIBDGE.js +183 -0
- package/dist/chunk-OVYIBDGE.js.map +1 -0
- package/dist/chunk-P2BTQ33C.cjs +126 -0
- package/dist/chunk-P2BTQ33C.cjs.map +1 -0
- package/dist/chunk-P6ZBENAG.js +211 -0
- package/dist/chunk-P6ZBENAG.js.map +1 -0
- package/dist/chunk-P74HNSNJ.cjs +106 -0
- package/dist/chunk-P74HNSNJ.cjs.map +1 -0
- package/dist/chunk-PEPYVWGY.cjs +327 -0
- package/dist/chunk-PEPYVWGY.cjs.map +1 -0
- package/dist/chunk-POX6JZLO.cjs +67 -0
- package/dist/chunk-POX6JZLO.cjs.map +1 -0
- package/dist/chunk-PWIA4XQD.js +320 -0
- package/dist/chunk-PWIA4XQD.js.map +1 -0
- package/dist/chunk-QGZF5MOS.cjs +342 -0
- package/dist/chunk-QGZF5MOS.cjs.map +1 -0
- package/dist/chunk-QP2A5ZMK.cjs +18 -0
- package/dist/chunk-QP2A5ZMK.cjs.map +1 -0
- package/dist/chunk-QYHTMEI5.js +92 -0
- package/dist/chunk-QYHTMEI5.js.map +1 -0
- package/dist/chunk-QYK4ECSZ.js +69 -0
- package/dist/chunk-QYK4ECSZ.js.map +1 -0
- package/dist/chunk-R36SGSJX.cjs +26 -0
- package/dist/chunk-R36SGSJX.cjs.map +1 -0
- package/dist/chunk-R5QPUQSI.cjs +303 -0
- package/dist/chunk-R5QPUQSI.cjs.map +1 -0
- package/dist/chunk-R5UNLPQZ.cjs +103 -0
- package/dist/chunk-R5UNLPQZ.cjs.map +1 -0
- package/dist/chunk-RSBQNIJZ.js +199 -0
- package/dist/chunk-RSBQNIJZ.js.map +1 -0
- package/dist/chunk-S25WB7KJ.js +50 -0
- package/dist/chunk-S25WB7KJ.js.map +1 -0
- package/dist/chunk-SAFSEXMU.cjs +211 -0
- package/dist/chunk-SAFSEXMU.cjs.map +1 -0
- package/dist/chunk-SJDTFR3I.cjs +1 -0
- package/dist/chunk-SJDTFR3I.cjs.map +1 -0
- package/dist/chunk-SOGUWOSQ.cjs +21 -0
- package/dist/chunk-SOGUWOSQ.cjs.map +1 -0
- package/dist/chunk-SWPZ3HFY.cjs +1 -0
- package/dist/chunk-SWPZ3HFY.cjs.map +1 -0
- package/dist/chunk-SXF3TCYA.js +401 -0
- package/dist/chunk-SXF3TCYA.js.map +1 -0
- package/dist/chunk-T56K5IKQ.js +526 -0
- package/dist/chunk-T56K5IKQ.js.map +1 -0
- package/dist/chunk-TBMVUI7S.cjs +21 -0
- package/dist/chunk-TBMVUI7S.cjs.map +1 -0
- package/dist/chunk-TCX3QKF3.js +103 -0
- package/dist/chunk-TCX3QKF3.js.map +1 -0
- package/dist/chunk-TH3ITGUM.js +1 -0
- package/dist/chunk-TH3ITGUM.js.map +1 -0
- package/dist/chunk-TPNCV7KA.js +1 -0
- package/dist/chunk-TPNCV7KA.js.map +1 -0
- package/dist/chunk-TQCNQKWF.cjs +194 -0
- package/dist/chunk-TQCNQKWF.cjs.map +1 -0
- package/dist/chunk-TZWNX7FF.js +1 -0
- package/dist/chunk-TZWNX7FF.js.map +1 -0
- package/dist/chunk-UEJSRMU2.js +39 -0
- package/dist/chunk-UEJSRMU2.js.map +1 -0
- package/dist/chunk-UTENJWSE.cjs +21 -0
- package/dist/chunk-UTENJWSE.cjs.map +1 -0
- package/dist/chunk-V5JNYS77.cjs +29 -0
- package/dist/chunk-V5JNYS77.cjs.map +1 -0
- package/dist/chunk-VFYG7GAH.js +327 -0
- package/dist/chunk-VFYG7GAH.js.map +1 -0
- package/dist/chunk-VGYJ4VKX.cjs +62 -0
- package/dist/chunk-VGYJ4VKX.cjs.map +1 -0
- package/dist/chunk-VLC2OZV3.cjs +50 -0
- package/dist/chunk-VLC2OZV3.cjs.map +1 -0
- package/dist/chunk-VTAABT55.js +47 -0
- package/dist/chunk-VTAABT55.js.map +1 -0
- package/dist/chunk-VW32UTUE.cjs +1 -0
- package/dist/chunk-VW32UTUE.cjs.map +1 -0
- package/dist/chunk-VYV45YOK.cjs +1316 -0
- package/dist/chunk-VYV45YOK.cjs.map +1 -0
- package/dist/chunk-VZ43OLU6.cjs +97 -0
- package/dist/chunk-VZ43OLU6.cjs.map +1 -0
- package/dist/chunk-XJAXKENE.cjs +1 -0
- package/dist/chunk-XJAXKENE.cjs.map +1 -0
- package/dist/chunk-XJBMEDQ5.js +101 -0
- package/dist/chunk-XJBMEDQ5.js.map +1 -0
- package/dist/chunk-XMRMCWSQ.js +454 -0
- package/dist/chunk-XMRMCWSQ.js.map +1 -0
- package/dist/chunk-XSGUFMT4.js +21 -0
- package/dist/chunk-XSGUFMT4.js.map +1 -0
- package/dist/chunk-XUZOU2EB.js +1 -0
- package/dist/chunk-XUZOU2EB.js.map +1 -0
- package/dist/chunk-YCUT6NQ4.js +106 -0
- package/dist/chunk-YCUT6NQ4.js.map +1 -0
- package/dist/chunk-YLKESEHQ.cjs +199 -0
- package/dist/chunk-YLKESEHQ.cjs.map +1 -0
- package/dist/chunk-YPK7RV3Y.js +62 -0
- package/dist/chunk-YPK7RV3Y.js.map +1 -0
- package/dist/chunk-Z7S4UQKY.js +125 -0
- package/dist/chunk-Z7S4UQKY.js.map +1 -0
- package/dist/chunk-ZBGTVTQJ.js +112 -0
- package/dist/chunk-ZBGTVTQJ.js.map +1 -0
- package/dist/color-picker/index.cjs +9 -0
- package/dist/color-picker/index.cjs.map +1 -0
- package/dist/color-picker/index.d.cts +40 -0
- package/dist/color-picker/index.d.ts +40 -0
- package/dist/color-picker/index.js +9 -0
- package/dist/color-picker/index.js.map +1 -0
- package/dist/combobox/index.cjs +12 -0
- package/dist/combobox/index.cjs.map +1 -0
- package/dist/combobox/index.d.cts +37 -0
- package/dist/combobox/index.d.ts +37 -0
- package/dist/combobox/index.js +12 -0
- package/dist/combobox/index.js.map +1 -0
- package/dist/command-palette/index.cjs +10 -0
- package/dist/command-palette/index.cjs.map +1 -0
- package/dist/command-palette/index.d.cts +7 -0
- package/dist/command-palette/index.d.ts +7 -0
- package/dist/command-palette/index.js +10 -0
- package/dist/command-palette/index.js.map +1 -0
- package/dist/context-menu/index.cjs +13 -0
- package/dist/context-menu/index.cjs.map +1 -0
- package/dist/context-menu/index.d.cts +38 -0
- package/dist/context-menu/index.d.ts +38 -0
- package/dist/context-menu/index.js +13 -0
- package/dist/context-menu/index.js.map +1 -0
- package/dist/data-grid/index.cjs +28 -0
- package/dist/data-grid/index.cjs.map +1 -0
- package/dist/data-grid/index.d.cts +217 -0
- package/dist/data-grid/index.d.ts +217 -0
- package/dist/data-grid/index.js +28 -0
- package/dist/data-grid/index.js.map +1 -0
- package/dist/date-picker/index.cjs +19 -0
- package/dist/date-picker/index.cjs.map +1 -0
- package/dist/date-picker/index.d.cts +106 -0
- package/dist/date-picker/index.d.ts +106 -0
- package/dist/date-picker/index.js +19 -0
- package/dist/date-picker/index.js.map +1 -0
- package/dist/divider/index.cjs +8 -0
- package/dist/divider/index.cjs.map +1 -0
- package/dist/divider/index.d.cts +9 -0
- package/dist/divider/index.d.ts +9 -0
- package/dist/divider/index.js +8 -0
- package/dist/divider/index.js.map +1 -0
- package/dist/drawer/index.cjs +13 -0
- package/dist/drawer/index.cjs.map +1 -0
- package/dist/drawer/index.d.cts +39 -0
- package/dist/drawer/index.d.ts +39 -0
- package/dist/drawer/index.js +13 -0
- package/dist/drawer/index.js.map +1 -0
- package/dist/dropdown/index.cjs +13 -0
- package/dist/dropdown/index.cjs.map +1 -0
- package/dist/dropdown/index.d.cts +66 -0
- package/dist/dropdown/index.d.ts +66 -0
- package/dist/dropdown/index.js +13 -0
- package/dist/dropdown/index.js.map +1 -0
- package/dist/empty-state/index.cjs +8 -0
- package/dist/empty-state/index.cjs.map +1 -0
- package/dist/empty-state/index.d.cts +20 -0
- package/dist/empty-state/index.d.ts +20 -0
- package/dist/empty-state/index.js +8 -0
- package/dist/empty-state/index.js.map +1 -0
- package/dist/file-upload/index.cjs +8 -0
- package/dist/file-upload/index.cjs.map +1 -0
- package/dist/file-upload/index.d.cts +27 -0
- package/dist/file-upload/index.d.ts +27 -0
- package/dist/file-upload/index.js +8 -0
- package/dist/file-upload/index.js.map +1 -0
- package/dist/footer/index.cjs +8 -0
- package/dist/footer/index.cjs.map +1 -0
- package/dist/footer/index.d.cts +7 -0
- package/dist/footer/index.d.ts +7 -0
- package/dist/footer/index.js +8 -0
- package/dist/footer/index.js.map +1 -0
- package/dist/header/index.cjs +13 -0
- package/dist/header/index.cjs.map +1 -0
- package/dist/header/index.d.cts +10 -0
- package/dist/header/index.d.ts +10 -0
- package/dist/header/index.js +13 -0
- package/dist/header/index.js.map +1 -0
- package/dist/index.cjs +269 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +8895 -0
- package/dist/index.css.d.ts +2 -0
- package/dist/index.d.cts +69 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.js +269 -0
- package/dist/index.js.map +1 -0
- package/dist/inline-edit/index.cjs +11 -0
- package/dist/inline-edit/index.cjs.map +1 -0
- package/dist/inline-edit/index.d.cts +56 -0
- package/dist/inline-edit/index.d.ts +56 -0
- package/dist/inline-edit/index.js +11 -0
- package/dist/inline-edit/index.js.map +1 -0
- package/dist/input/index.cjs +11 -0
- package/dist/input/index.cjs.map +1 -0
- package/dist/input/index.d.cts +9 -0
- package/dist/input/index.d.ts +9 -0
- package/dist/input/index.js +11 -0
- package/dist/input/index.js.map +1 -0
- package/dist/kbd/index.cjs +9 -0
- package/dist/kbd/index.cjs.map +1 -0
- package/dist/kbd/index.d.cts +34 -0
- package/dist/kbd/index.d.ts +34 -0
- package/dist/kbd/index.js +9 -0
- package/dist/kbd/index.js.map +1 -0
- package/dist/menu/index.cjs +14 -0
- package/dist/menu/index.cjs.map +1 -0
- package/dist/menu/index.d.cts +14 -0
- package/dist/menu/index.d.ts +14 -0
- package/dist/menu/index.js +14 -0
- package/dist/menu/index.js.map +1 -0
- package/dist/modal/index.cjs +12 -0
- package/dist/modal/index.cjs.map +1 -0
- package/dist/modal/index.d.cts +34 -0
- package/dist/modal/index.d.ts +34 -0
- package/dist/modal/index.js +12 -0
- package/dist/modal/index.js.map +1 -0
- package/dist/navigation/index.cjs +14 -0
- package/dist/navigation/index.cjs.map +1 -0
- package/dist/navigation/index.d.cts +8 -0
- package/dist/navigation/index.d.ts +8 -0
- package/dist/navigation/index.js +14 -0
- package/dist/navigation/index.js.map +1 -0
- package/dist/number-input/index.cjs +8 -0
- package/dist/number-input/index.cjs.map +1 -0
- package/dist/number-input/index.d.cts +31 -0
- package/dist/number-input/index.d.ts +31 -0
- package/dist/number-input/index.js +8 -0
- package/dist/number-input/index.js.map +1 -0
- package/dist/o-t-p-input/index.cjs +8 -0
- package/dist/o-t-p-input/index.cjs.map +1 -0
- package/dist/o-t-p-input/index.d.cts +33 -0
- package/dist/o-t-p-input/index.d.ts +33 -0
- package/dist/o-t-p-input/index.js +8 -0
- package/dist/o-t-p-input/index.js.map +1 -0
- package/dist/page-layout/index.cjs +24 -0
- package/dist/page-layout/index.cjs.map +1 -0
- package/dist/page-layout/index.d.cts +28 -0
- package/dist/page-layout/index.d.ts +28 -0
- package/dist/page-layout/index.js +24 -0
- package/dist/page-layout/index.js.map +1 -0
- package/dist/pagination/index.cjs +17 -0
- package/dist/pagination/index.cjs.map +1 -0
- package/dist/pagination/index.d.cts +34 -0
- package/dist/pagination/index.d.ts +34 -0
- package/dist/pagination/index.js +17 -0
- package/dist/pagination/index.js.map +1 -0
- package/dist/pill/index.cjs +8 -0
- package/dist/pill/index.cjs.map +1 -0
- package/dist/pill/index.d.cts +20 -0
- package/dist/pill/index.d.ts +20 -0
- package/dist/pill/index.js +8 -0
- package/dist/pill/index.js.map +1 -0
- package/dist/popover/index.cjs +8 -0
- package/dist/popover/index.cjs.map +1 -0
- package/dist/popover/index.d.cts +35 -0
- package/dist/popover/index.d.ts +35 -0
- package/dist/popover/index.js +8 -0
- package/dist/popover/index.js.map +1 -0
- package/dist/progress/index.cjs +8 -0
- package/dist/progress/index.cjs.map +1 -0
- package/dist/progress/index.d.cts +18 -0
- package/dist/progress/index.d.ts +18 -0
- package/dist/progress/index.js +8 -0
- package/dist/progress/index.js.map +1 -0
- package/dist/radio/index.cjs +10 -0
- package/dist/radio/index.cjs.map +1 -0
- package/dist/radio/index.d.cts +33 -0
- package/dist/radio/index.d.ts +33 -0
- package/dist/radio/index.js +10 -0
- package/dist/radio/index.js.map +1 -0
- package/dist/renderIcon-C2lEMMzb.d.cts +30 -0
- package/dist/renderIcon-C2lEMMzb.d.ts +30 -0
- package/dist/segmented-control/index.cjs +11 -0
- package/dist/segmented-control/index.cjs.map +1 -0
- package/dist/segmented-control/index.d.cts +70 -0
- package/dist/segmented-control/index.d.ts +70 -0
- package/dist/segmented-control/index.js +11 -0
- package/dist/segmented-control/index.js.map +1 -0
- package/dist/select/index.cjs +13 -0
- package/dist/select/index.cjs.map +1 -0
- package/dist/select/index.d.cts +46 -0
- package/dist/select/index.d.ts +46 -0
- package/dist/select/index.js +13 -0
- package/dist/select/index.js.map +1 -0
- package/dist/sizes-DM6Rrrgq.d.cts +11 -0
- package/dist/sizes-DM6Rrrgq.d.ts +11 -0
- package/dist/skeleton/index.cjs +8 -0
- package/dist/skeleton/index.cjs.map +1 -0
- package/dist/skeleton/index.d.cts +14 -0
- package/dist/skeleton/index.d.ts +14 -0
- package/dist/skeleton/index.js +8 -0
- package/dist/skeleton/index.js.map +1 -0
- package/dist/slider/index.cjs +8 -0
- package/dist/slider/index.cjs.map +1 -0
- package/dist/slider/index.d.cts +37 -0
- package/dist/slider/index.d.ts +37 -0
- package/dist/slider/index.js +8 -0
- package/dist/slider/index.js.map +1 -0
- package/dist/snackbar/index.cjs +18 -0
- package/dist/snackbar/index.cjs.map +1 -0
- package/dist/snackbar/index.d.cts +68 -0
- package/dist/snackbar/index.d.ts +68 -0
- package/dist/snackbar/index.js +18 -0
- package/dist/snackbar/index.js.map +1 -0
- package/dist/spinner/index.cjs +9 -0
- package/dist/spinner/index.cjs.map +1 -0
- package/dist/spinner/index.d.cts +12 -0
- package/dist/spinner/index.d.ts +12 -0
- package/dist/spinner/index.js +9 -0
- package/dist/spinner/index.js.map +1 -0
- package/dist/split-button/index.cjs +13 -0
- package/dist/split-button/index.cjs.map +1 -0
- package/dist/split-button/index.d.cts +53 -0
- package/dist/split-button/index.d.ts +53 -0
- package/dist/split-button/index.js +13 -0
- package/dist/split-button/index.js.map +1 -0
- package/dist/stepper/index.cjs +8 -0
- package/dist/stepper/index.cjs.map +1 -0
- package/dist/stepper/index.d.cts +42 -0
- package/dist/stepper/index.d.ts +42 -0
- package/dist/stepper/index.js +8 -0
- package/dist/stepper/index.js.map +1 -0
- package/dist/switch/index.cjs +8 -0
- package/dist/switch/index.cjs.map +1 -0
- package/dist/switch/index.d.cts +15 -0
- package/dist/switch/index.d.ts +15 -0
- package/dist/switch/index.js +8 -0
- package/dist/switch/index.js.map +1 -0
- package/dist/table/index.cjs +33 -0
- package/dist/table/index.cjs.map +1 -0
- package/dist/table/index.d.cts +20 -0
- package/dist/table/index.d.ts +20 -0
- package/dist/table/index.js +33 -0
- package/dist/table/index.js.map +1 -0
- package/dist/tabs/index.cjs +13 -0
- package/dist/tabs/index.cjs.map +1 -0
- package/dist/tabs/index.d.cts +34 -0
- package/dist/tabs/index.d.ts +34 -0
- package/dist/tabs/index.js +13 -0
- package/dist/tabs/index.js.map +1 -0
- package/dist/tag-input/index.cjs +12 -0
- package/dist/tag-input/index.cjs.map +1 -0
- package/dist/tag-input/index.d.cts +36 -0
- package/dist/tag-input/index.d.ts +36 -0
- package/dist/tag-input/index.js +12 -0
- package/dist/tag-input/index.js.map +1 -0
- package/dist/textarea/index.cjs +10 -0
- package/dist/textarea/index.cjs.map +1 -0
- package/dist/textarea/index.d.cts +28 -0
- package/dist/textarea/index.d.ts +28 -0
- package/dist/textarea/index.js +10 -0
- package/dist/textarea/index.js.map +1 -0
- package/dist/timeline/index.cjs +8 -0
- package/dist/timeline/index.cjs.map +1 -0
- package/dist/timeline/index.d.cts +24 -0
- package/dist/timeline/index.d.ts +24 -0
- package/dist/timeline/index.js +8 -0
- package/dist/timeline/index.js.map +1 -0
- package/dist/toolbar/index.cjs +20 -0
- package/dist/toolbar/index.cjs.map +1 -0
- package/dist/toolbar/index.d.cts +13 -0
- package/dist/toolbar/index.d.ts +13 -0
- package/dist/toolbar/index.js +20 -0
- package/dist/toolbar/index.js.map +1 -0
- package/dist/tooltip/index.cjs +9 -0
- package/dist/tooltip/index.cjs.map +1 -0
- package/dist/tooltip/index.d.cts +25 -0
- package/dist/tooltip/index.d.ts +25 -0
- package/dist/tooltip/index.js +9 -0
- package/dist/tooltip/index.js.map +1 -0
- package/dist/tree-view/index.cjs +8 -0
- package/dist/tree-view/index.cjs.map +1 -0
- package/dist/tree-view/index.d.cts +36 -0
- package/dist/tree-view/index.d.ts +36 -0
- package/dist/tree-view/index.js +8 -0
- package/dist/tree-view/index.js.map +1 -0
- package/dist/virtual-list/index.cjs +9 -0
- package/dist/virtual-list/index.cjs.map +1 -0
- package/dist/virtual-list/index.d.cts +58 -0
- package/dist/virtual-list/index.d.ts +58 -0
- package/dist/virtual-list/index.js +9 -0
- package/dist/virtual-list/index.js.map +1 -0
- package/package.json +108 -0
|
@@ -0,0 +1,4418 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DatePicker
|
|
3
|
+
} from "./chunk-GL4DHGQE.js";
|
|
4
|
+
import {
|
|
5
|
+
Select
|
|
6
|
+
} from "./chunk-F54MVGKO.js";
|
|
7
|
+
import {
|
|
8
|
+
Input
|
|
9
|
+
} from "./chunk-A35Y5MRJ.js";
|
|
10
|
+
import {
|
|
11
|
+
Dropdown
|
|
12
|
+
} from "./chunk-SXF3TCYA.js";
|
|
13
|
+
import {
|
|
14
|
+
Button
|
|
15
|
+
} from "./chunk-FO5FNTJX.js";
|
|
16
|
+
|
|
17
|
+
// src/components/Table/TableFiltersDropdown.component.tsx
|
|
18
|
+
import { useMemo, useState, useEffect, useRef } from "react";
|
|
19
|
+
import { Plus, X, Check, RotateCcw, Funnel } from "lucide-react";
|
|
20
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
var TableFiltersDropdown = ({
|
|
22
|
+
columns,
|
|
23
|
+
filters,
|
|
24
|
+
onFiltersChange,
|
|
25
|
+
defaultFilters = {},
|
|
26
|
+
className = ""
|
|
27
|
+
}) => {
|
|
28
|
+
const [dropdownKey, setDropdownKey] = useState(0);
|
|
29
|
+
const [pendingFilters, setPendingFilters] = useState(() => {
|
|
30
|
+
const initialFilters = Object.keys(filters).length > 0 ? filters : defaultFilters;
|
|
31
|
+
if (Object.keys(initialFilters).length === 0) {
|
|
32
|
+
return { [`__temp_${Date.now()}`]: "" };
|
|
33
|
+
}
|
|
34
|
+
return initialFilters;
|
|
35
|
+
});
|
|
36
|
+
const isFirstRender = useRef(true);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (isFirstRender.current) {
|
|
39
|
+
isFirstRender.current = false;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (Object.keys(filters).length === 0) {
|
|
43
|
+
setPendingFilters({ [`__temp_${Date.now()}`]: "" });
|
|
44
|
+
} else {
|
|
45
|
+
setPendingFilters(filters);
|
|
46
|
+
}
|
|
47
|
+
}, [filters]);
|
|
48
|
+
const filterableColumns = useMemo(() => columns.filter((col) => col.filterable), [columns]);
|
|
49
|
+
const filterRows = useMemo(() => {
|
|
50
|
+
return Object.entries(pendingFilters).map(([columnKey, value], index) => ({
|
|
51
|
+
id: `filter-${index}`,
|
|
52
|
+
columnKey,
|
|
53
|
+
value
|
|
54
|
+
}));
|
|
55
|
+
}, [pendingFilters]);
|
|
56
|
+
const hasChanges = useMemo(() => {
|
|
57
|
+
const cleanedPendingFilters = {};
|
|
58
|
+
Object.entries(pendingFilters).forEach(([key, value]) => {
|
|
59
|
+
if (key.startsWith("__temp_")) return;
|
|
60
|
+
const hasValue = (() => {
|
|
61
|
+
if (value === "" || value === void 0 || value === null) return false;
|
|
62
|
+
if (Array.isArray(value) && value.length === 0) return false;
|
|
63
|
+
if (typeof value === "object" && value !== null && "start" in value && "end" in value) {
|
|
64
|
+
return !!(value.start || value.end);
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
})();
|
|
68
|
+
if (hasValue) {
|
|
69
|
+
cleanedPendingFilters[key] = value;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return JSON.stringify(filters) !== JSON.stringify(cleanedPendingFilters);
|
|
73
|
+
}, [filters, pendingFilters]);
|
|
74
|
+
const hasActiveFilters = useMemo(() => {
|
|
75
|
+
return Object.keys(filters).length > 0;
|
|
76
|
+
}, [filters]);
|
|
77
|
+
const getAllColumnsWithDisabledState = (currentRowId) => {
|
|
78
|
+
const currentRow = filterRows.find((row) => row.id === currentRowId);
|
|
79
|
+
const usedColumns = filterRows.filter((row) => row.id !== currentRowId && !row.columnKey.startsWith("__temp_")).map((row) => row.columnKey);
|
|
80
|
+
return filterableColumns.map((col) => {
|
|
81
|
+
const columnKey = String(col.key);
|
|
82
|
+
const isUsed = usedColumns.includes(columnKey);
|
|
83
|
+
const isCurrent = currentRow?.columnKey === columnKey;
|
|
84
|
+
return {
|
|
85
|
+
id: columnKey,
|
|
86
|
+
value: columnKey,
|
|
87
|
+
label: col.label,
|
|
88
|
+
disabled: isUsed && !isCurrent
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
const getColumnByKey = (columnKey) => {
|
|
93
|
+
return filterableColumns.find((col) => String(col.key) === columnKey);
|
|
94
|
+
};
|
|
95
|
+
const updateFilter = (rowId, columnKey, value) => {
|
|
96
|
+
const newFilters = { ...pendingFilters };
|
|
97
|
+
const oldRow = filterRows.find((row) => row.id === rowId);
|
|
98
|
+
if (oldRow && oldRow.columnKey !== columnKey) {
|
|
99
|
+
delete newFilters[oldRow.columnKey];
|
|
100
|
+
}
|
|
101
|
+
newFilters[columnKey] = value;
|
|
102
|
+
setPendingFilters(newFilters);
|
|
103
|
+
};
|
|
104
|
+
const addFilter = () => {
|
|
105
|
+
const availableColumns = getAllColumnsWithDisabledState();
|
|
106
|
+
if (availableColumns.length === 0) return;
|
|
107
|
+
const tempKey = `__temp_${Date.now()}`;
|
|
108
|
+
const newFilters = { ...pendingFilters };
|
|
109
|
+
newFilters[tempKey] = "";
|
|
110
|
+
setPendingFilters(newFilters);
|
|
111
|
+
};
|
|
112
|
+
const removeFilter = (rowId) => {
|
|
113
|
+
const row = filterRows.find((r) => r.id === rowId);
|
|
114
|
+
if (!row) return;
|
|
115
|
+
const newFilters = { ...pendingFilters };
|
|
116
|
+
delete newFilters[row.columnKey];
|
|
117
|
+
if (Object.keys(newFilters).length === 0) {
|
|
118
|
+
newFilters[`__temp_${Date.now()}`] = "";
|
|
119
|
+
}
|
|
120
|
+
setPendingFilters(newFilters);
|
|
121
|
+
};
|
|
122
|
+
const applyFilters = () => {
|
|
123
|
+
const cleanedFilters = {};
|
|
124
|
+
Object.entries(pendingFilters).forEach(([key, value]) => {
|
|
125
|
+
if (key.startsWith("__temp_")) return;
|
|
126
|
+
const hasValue = (() => {
|
|
127
|
+
if (value === "" || value === void 0 || value === null) return false;
|
|
128
|
+
if (Array.isArray(value) && value.length === 0) return false;
|
|
129
|
+
if (typeof value === "object" && value !== null && "start" in value && "end" in value) {
|
|
130
|
+
return !!(value.start || value.end);
|
|
131
|
+
}
|
|
132
|
+
return true;
|
|
133
|
+
})();
|
|
134
|
+
if (hasValue) {
|
|
135
|
+
cleanedFilters[key] = value;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
onFiltersChange(cleanedFilters);
|
|
139
|
+
setDropdownKey((prev) => prev + 1);
|
|
140
|
+
};
|
|
141
|
+
const resetFilters = () => {
|
|
142
|
+
if (Object.keys(filters).length === 0) {
|
|
143
|
+
setPendingFilters({ [`__temp_${Date.now()}`]: "" });
|
|
144
|
+
} else {
|
|
145
|
+
setPendingFilters(filters);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const clearAllFilters = () => {
|
|
149
|
+
const emptyFilter = { [`__temp_${Date.now()}`]: "" };
|
|
150
|
+
setPendingFilters(emptyFilter);
|
|
151
|
+
onFiltersChange({});
|
|
152
|
+
setDropdownKey((prev) => prev + 1);
|
|
153
|
+
};
|
|
154
|
+
const renderFilterInput = (row, column) => {
|
|
155
|
+
const filterType = column.filterType || "text";
|
|
156
|
+
switch (filterType) {
|
|
157
|
+
case "select":
|
|
158
|
+
return /* @__PURE__ */ jsx(
|
|
159
|
+
Select,
|
|
160
|
+
{
|
|
161
|
+
value: row.value || "",
|
|
162
|
+
onChange: (value) => updateFilter(row.id, row.columnKey, value),
|
|
163
|
+
options: column.filterOptions || [],
|
|
164
|
+
placeholder: "Select value",
|
|
165
|
+
clearable: true,
|
|
166
|
+
inputProps: { size: "sm" }
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
case "boolean":
|
|
170
|
+
return /* @__PURE__ */ jsx(
|
|
171
|
+
Select,
|
|
172
|
+
{
|
|
173
|
+
value: row.value === void 0 ? "" : String(row.value),
|
|
174
|
+
onChange: (value) => updateFilter(row.id, row.columnKey, value === "" ? void 0 : value === "true"),
|
|
175
|
+
options: [
|
|
176
|
+
{ id: "", value: "", label: "All" },
|
|
177
|
+
{ id: "true", value: "true", label: "Yes" },
|
|
178
|
+
{ id: "false", value: "false", label: "No" }
|
|
179
|
+
],
|
|
180
|
+
placeholder: "Select value",
|
|
181
|
+
clearable: false,
|
|
182
|
+
inputProps: { size: "sm" }
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
case "date": {
|
|
186
|
+
const dateMode = column.dateFilterMode || "single";
|
|
187
|
+
const prepareValue = () => {
|
|
188
|
+
if (!row.value) return void 0;
|
|
189
|
+
switch (dateMode) {
|
|
190
|
+
case "single": {
|
|
191
|
+
return row.value ? { date: row.value } : void 0;
|
|
192
|
+
}
|
|
193
|
+
case "multiple": {
|
|
194
|
+
const dates = Array.isArray(row.value) ? row.value : [];
|
|
195
|
+
return dates.length > 0 ? { date: dates } : void 0;
|
|
196
|
+
}
|
|
197
|
+
case "range": {
|
|
198
|
+
const rangeValue = row.value;
|
|
199
|
+
return {
|
|
200
|
+
date: {
|
|
201
|
+
start: rangeValue?.start || null,
|
|
202
|
+
end: rangeValue?.end || null
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
default: {
|
|
207
|
+
return row.value ? { date: row.value } : void 0;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const handleDateChange = (value) => {
|
|
212
|
+
if (!value?.date) {
|
|
213
|
+
updateFilter(row.id, row.columnKey, "");
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
updateFilter(row.id, row.columnKey, value.date);
|
|
217
|
+
};
|
|
218
|
+
const getPlaceholder = () => {
|
|
219
|
+
switch (dateMode) {
|
|
220
|
+
case "single":
|
|
221
|
+
return "Select date";
|
|
222
|
+
case "multiple":
|
|
223
|
+
return "Select dates";
|
|
224
|
+
case "range":
|
|
225
|
+
return "Select date range";
|
|
226
|
+
default:
|
|
227
|
+
return "Select date";
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
return /* @__PURE__ */ jsx(
|
|
231
|
+
DatePicker,
|
|
232
|
+
{
|
|
233
|
+
mode: dateMode,
|
|
234
|
+
value: prepareValue(),
|
|
235
|
+
onChange: handleDateChange,
|
|
236
|
+
placeholder: getPlaceholder(),
|
|
237
|
+
inputProps: { size: "sm" },
|
|
238
|
+
format: {
|
|
239
|
+
displayFormat: "MMM DD, YYYY",
|
|
240
|
+
inputFormat: "YYYY-MM-DD"
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
case "text":
|
|
246
|
+
default:
|
|
247
|
+
return /* @__PURE__ */ jsx(
|
|
248
|
+
Input,
|
|
249
|
+
{
|
|
250
|
+
value: row.value || "",
|
|
251
|
+
onChange: (e) => updateFilter(row.id, row.columnKey, e.target.value),
|
|
252
|
+
placeholder: "Enter value",
|
|
253
|
+
size: "sm"
|
|
254
|
+
}
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
const canAddMore = filterRows.length < filterableColumns.length;
|
|
259
|
+
const triggerButton = /* @__PURE__ */ jsx(
|
|
260
|
+
Button,
|
|
261
|
+
{
|
|
262
|
+
variant: "text",
|
|
263
|
+
size: "sm",
|
|
264
|
+
icon: Funnel,
|
|
265
|
+
className: hasActiveFilters ? "eidos-table-active-filter-button" : ""
|
|
266
|
+
}
|
|
267
|
+
);
|
|
268
|
+
const dropdownContent = /* @__PURE__ */ jsxs("div", { className: `eidos-table-filters-dropdown ${className}`, children: [
|
|
269
|
+
/* @__PURE__ */ jsx("div", { className: "eidos-table-filters-header", children: /* @__PURE__ */ jsx("h4", { className: "eidos-table-filters-title", children: "Filters" }) }),
|
|
270
|
+
filterRows.length > 0 && /* @__PURE__ */ jsx("div", { className: "eidos-table-filter-rows", children: filterRows.map((row) => {
|
|
271
|
+
const column = getColumnByKey(row.columnKey);
|
|
272
|
+
const allColumns = getAllColumnsWithDisabledState(row.id);
|
|
273
|
+
const isTemporaryFilter = row.columnKey.startsWith("__temp_");
|
|
274
|
+
return /* @__PURE__ */ jsxs("div", { className: "eidos-table-filter-row", children: [
|
|
275
|
+
/* @__PURE__ */ jsx("div", { className: "eidos-table-column-select", children: /* @__PURE__ */ jsx(
|
|
276
|
+
Select,
|
|
277
|
+
{
|
|
278
|
+
value: isTemporaryFilter ? "" : row.columnKey,
|
|
279
|
+
onChange: (value) => {
|
|
280
|
+
const newColumn = getColumnByKey(value);
|
|
281
|
+
if (newColumn) {
|
|
282
|
+
updateFilter(row.id, value, "");
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
options: allColumns,
|
|
286
|
+
placeholder: "Select column",
|
|
287
|
+
clearable: false,
|
|
288
|
+
inputProps: { size: "sm" },
|
|
289
|
+
fullWidth: true
|
|
290
|
+
}
|
|
291
|
+
) }),
|
|
292
|
+
/* @__PURE__ */ jsx("div", { className: "eidos-table-value-input", children: column && !isTemporaryFilter ? renderFilterInput(row, column) : /* @__PURE__ */ jsx(Input, { value: "", disabled: true, placeholder: "Select column first", size: "sm" }) }),
|
|
293
|
+
/* @__PURE__ */ jsx(
|
|
294
|
+
Button,
|
|
295
|
+
{
|
|
296
|
+
variant: "text",
|
|
297
|
+
size: "sm",
|
|
298
|
+
icon: X,
|
|
299
|
+
color: "secondary",
|
|
300
|
+
onClick: () => removeFilter(row.id)
|
|
301
|
+
}
|
|
302
|
+
)
|
|
303
|
+
] }, row.id);
|
|
304
|
+
}) }),
|
|
305
|
+
/* @__PURE__ */ jsx("div", { className: "eidos-table-filters-footer", children: /* @__PURE__ */ jsxs("div", { className: "eidos-table-filters-actions", children: [
|
|
306
|
+
/* @__PURE__ */ jsx(
|
|
307
|
+
Button,
|
|
308
|
+
{
|
|
309
|
+
variant: "text",
|
|
310
|
+
size: "sm",
|
|
311
|
+
preIcon: Plus,
|
|
312
|
+
disabled: !canAddMore,
|
|
313
|
+
onClick: addFilter,
|
|
314
|
+
children: "Add Filter"
|
|
315
|
+
}
|
|
316
|
+
),
|
|
317
|
+
hasActiveFilters && /* @__PURE__ */ jsx(Button, { variant: "text", size: "sm", color: "secondary", onClick: clearAllFilters, children: "Clear All" }),
|
|
318
|
+
hasChanges && /* @__PURE__ */ jsxs("div", { className: "eidos-table-filters-apply-actions", children: [
|
|
319
|
+
/* @__PURE__ */ jsx(
|
|
320
|
+
Button,
|
|
321
|
+
{
|
|
322
|
+
variant: "outlined",
|
|
323
|
+
size: "sm",
|
|
324
|
+
color: "secondary",
|
|
325
|
+
preIcon: RotateCcw,
|
|
326
|
+
onClick: resetFilters,
|
|
327
|
+
children: "Discard Changes"
|
|
328
|
+
}
|
|
329
|
+
),
|
|
330
|
+
/* @__PURE__ */ jsx(
|
|
331
|
+
Button,
|
|
332
|
+
{
|
|
333
|
+
variant: "filled",
|
|
334
|
+
size: "sm",
|
|
335
|
+
color: "primary",
|
|
336
|
+
preIcon: Check,
|
|
337
|
+
onClick: applyFilters,
|
|
338
|
+
children: "Apply Filters"
|
|
339
|
+
}
|
|
340
|
+
)
|
|
341
|
+
] })
|
|
342
|
+
] }) })
|
|
343
|
+
] });
|
|
344
|
+
return /* @__PURE__ */ jsx(
|
|
345
|
+
Dropdown,
|
|
346
|
+
{
|
|
347
|
+
trigger: triggerButton,
|
|
348
|
+
content: dropdownContent,
|
|
349
|
+
placement: "bottom",
|
|
350
|
+
align: "end",
|
|
351
|
+
autoWidth: false,
|
|
352
|
+
maxWidth: "auto",
|
|
353
|
+
maxHeight: "auto",
|
|
354
|
+
closeOnClickOutside: true
|
|
355
|
+
},
|
|
356
|
+
dropdownKey
|
|
357
|
+
);
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
// node_modules/@dnd-kit/utilities/dist/utilities.esm.js
|
|
361
|
+
import { useMemo as useMemo2, useLayoutEffect, useEffect as useEffect2, useRef as useRef2, useCallback } from "react";
|
|
362
|
+
function useCombinedRefs() {
|
|
363
|
+
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
364
|
+
refs[_key] = arguments[_key];
|
|
365
|
+
}
|
|
366
|
+
return useMemo2(
|
|
367
|
+
() => (node) => {
|
|
368
|
+
refs.forEach((ref) => ref(node));
|
|
369
|
+
},
|
|
370
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
371
|
+
refs
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
var canUseDOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
375
|
+
function isWindow(element) {
|
|
376
|
+
const elementString = Object.prototype.toString.call(element);
|
|
377
|
+
return elementString === "[object Window]" || // In Electron context the Window object serializes to [object global]
|
|
378
|
+
elementString === "[object global]";
|
|
379
|
+
}
|
|
380
|
+
function isNode(node) {
|
|
381
|
+
return "nodeType" in node;
|
|
382
|
+
}
|
|
383
|
+
function getWindow(target) {
|
|
384
|
+
var _target$ownerDocument, _target$ownerDocument2;
|
|
385
|
+
if (!target) {
|
|
386
|
+
return window;
|
|
387
|
+
}
|
|
388
|
+
if (isWindow(target)) {
|
|
389
|
+
return target;
|
|
390
|
+
}
|
|
391
|
+
if (!isNode(target)) {
|
|
392
|
+
return window;
|
|
393
|
+
}
|
|
394
|
+
return (_target$ownerDocument = (_target$ownerDocument2 = target.ownerDocument) == null ? void 0 : _target$ownerDocument2.defaultView) != null ? _target$ownerDocument : window;
|
|
395
|
+
}
|
|
396
|
+
function isDocument(node) {
|
|
397
|
+
const {
|
|
398
|
+
Document
|
|
399
|
+
} = getWindow(node);
|
|
400
|
+
return node instanceof Document;
|
|
401
|
+
}
|
|
402
|
+
function isHTMLElement(node) {
|
|
403
|
+
if (isWindow(node)) {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
return node instanceof getWindow(node).HTMLElement;
|
|
407
|
+
}
|
|
408
|
+
function isSVGElement(node) {
|
|
409
|
+
return node instanceof getWindow(node).SVGElement;
|
|
410
|
+
}
|
|
411
|
+
function getOwnerDocument(target) {
|
|
412
|
+
if (!target) {
|
|
413
|
+
return document;
|
|
414
|
+
}
|
|
415
|
+
if (isWindow(target)) {
|
|
416
|
+
return target.document;
|
|
417
|
+
}
|
|
418
|
+
if (!isNode(target)) {
|
|
419
|
+
return document;
|
|
420
|
+
}
|
|
421
|
+
if (isDocument(target)) {
|
|
422
|
+
return target;
|
|
423
|
+
}
|
|
424
|
+
if (isHTMLElement(target) || isSVGElement(target)) {
|
|
425
|
+
return target.ownerDocument;
|
|
426
|
+
}
|
|
427
|
+
return document;
|
|
428
|
+
}
|
|
429
|
+
var useIsomorphicLayoutEffect = canUseDOM ? useLayoutEffect : useEffect2;
|
|
430
|
+
function useEvent(handler) {
|
|
431
|
+
const handlerRef = useRef2(handler);
|
|
432
|
+
useIsomorphicLayoutEffect(() => {
|
|
433
|
+
handlerRef.current = handler;
|
|
434
|
+
});
|
|
435
|
+
return useCallback(function() {
|
|
436
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
437
|
+
args[_key] = arguments[_key];
|
|
438
|
+
}
|
|
439
|
+
return handlerRef.current == null ? void 0 : handlerRef.current(...args);
|
|
440
|
+
}, []);
|
|
441
|
+
}
|
|
442
|
+
function useInterval() {
|
|
443
|
+
const intervalRef = useRef2(null);
|
|
444
|
+
const set = useCallback((listener, duration) => {
|
|
445
|
+
intervalRef.current = setInterval(listener, duration);
|
|
446
|
+
}, []);
|
|
447
|
+
const clear = useCallback(() => {
|
|
448
|
+
if (intervalRef.current !== null) {
|
|
449
|
+
clearInterval(intervalRef.current);
|
|
450
|
+
intervalRef.current = null;
|
|
451
|
+
}
|
|
452
|
+
}, []);
|
|
453
|
+
return [set, clear];
|
|
454
|
+
}
|
|
455
|
+
function useLatestValue(value, dependencies) {
|
|
456
|
+
if (dependencies === void 0) {
|
|
457
|
+
dependencies = [value];
|
|
458
|
+
}
|
|
459
|
+
const valueRef = useRef2(value);
|
|
460
|
+
useIsomorphicLayoutEffect(() => {
|
|
461
|
+
if (valueRef.current !== value) {
|
|
462
|
+
valueRef.current = value;
|
|
463
|
+
}
|
|
464
|
+
}, dependencies);
|
|
465
|
+
return valueRef;
|
|
466
|
+
}
|
|
467
|
+
function useLazyMemo(callback, dependencies) {
|
|
468
|
+
const valueRef = useRef2();
|
|
469
|
+
return useMemo2(
|
|
470
|
+
() => {
|
|
471
|
+
const newValue = callback(valueRef.current);
|
|
472
|
+
valueRef.current = newValue;
|
|
473
|
+
return newValue;
|
|
474
|
+
},
|
|
475
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
476
|
+
[...dependencies]
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
function useNodeRef(onChange) {
|
|
480
|
+
const onChangeHandler = useEvent(onChange);
|
|
481
|
+
const node = useRef2(null);
|
|
482
|
+
const setNodeRef = useCallback(
|
|
483
|
+
(element) => {
|
|
484
|
+
if (element !== node.current) {
|
|
485
|
+
onChangeHandler == null ? void 0 : onChangeHandler(element, node.current);
|
|
486
|
+
}
|
|
487
|
+
node.current = element;
|
|
488
|
+
},
|
|
489
|
+
//eslint-disable-next-line
|
|
490
|
+
[]
|
|
491
|
+
);
|
|
492
|
+
return [node, setNodeRef];
|
|
493
|
+
}
|
|
494
|
+
function usePrevious(value) {
|
|
495
|
+
const ref = useRef2();
|
|
496
|
+
useEffect2(() => {
|
|
497
|
+
ref.current = value;
|
|
498
|
+
}, [value]);
|
|
499
|
+
return ref.current;
|
|
500
|
+
}
|
|
501
|
+
var ids = {};
|
|
502
|
+
function useUniqueId(prefix, value) {
|
|
503
|
+
return useMemo2(() => {
|
|
504
|
+
if (value) {
|
|
505
|
+
return value;
|
|
506
|
+
}
|
|
507
|
+
const id = ids[prefix] == null ? 0 : ids[prefix] + 1;
|
|
508
|
+
ids[prefix] = id;
|
|
509
|
+
return prefix + "-" + id;
|
|
510
|
+
}, [prefix, value]);
|
|
511
|
+
}
|
|
512
|
+
function createAdjustmentFn(modifier) {
|
|
513
|
+
return function(object) {
|
|
514
|
+
for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
515
|
+
adjustments[_key - 1] = arguments[_key];
|
|
516
|
+
}
|
|
517
|
+
return adjustments.reduce((accumulator, adjustment) => {
|
|
518
|
+
const entries = Object.entries(adjustment);
|
|
519
|
+
for (const [key, valueAdjustment] of entries) {
|
|
520
|
+
const value = accumulator[key];
|
|
521
|
+
if (value != null) {
|
|
522
|
+
accumulator[key] = value + modifier * valueAdjustment;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return accumulator;
|
|
526
|
+
}, {
|
|
527
|
+
...object
|
|
528
|
+
});
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
var add = /* @__PURE__ */ createAdjustmentFn(1);
|
|
532
|
+
var subtract = /* @__PURE__ */ createAdjustmentFn(-1);
|
|
533
|
+
function hasViewportRelativeCoordinates(event) {
|
|
534
|
+
return "clientX" in event && "clientY" in event;
|
|
535
|
+
}
|
|
536
|
+
function isKeyboardEvent(event) {
|
|
537
|
+
if (!event) {
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
const {
|
|
541
|
+
KeyboardEvent
|
|
542
|
+
} = getWindow(event.target);
|
|
543
|
+
return KeyboardEvent && event instanceof KeyboardEvent;
|
|
544
|
+
}
|
|
545
|
+
function isTouchEvent(event) {
|
|
546
|
+
if (!event) {
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
const {
|
|
550
|
+
TouchEvent
|
|
551
|
+
} = getWindow(event.target);
|
|
552
|
+
return TouchEvent && event instanceof TouchEvent;
|
|
553
|
+
}
|
|
554
|
+
function getEventCoordinates(event) {
|
|
555
|
+
if (isTouchEvent(event)) {
|
|
556
|
+
if (event.touches && event.touches.length) {
|
|
557
|
+
const {
|
|
558
|
+
clientX: x,
|
|
559
|
+
clientY: y
|
|
560
|
+
} = event.touches[0];
|
|
561
|
+
return {
|
|
562
|
+
x,
|
|
563
|
+
y
|
|
564
|
+
};
|
|
565
|
+
} else if (event.changedTouches && event.changedTouches.length) {
|
|
566
|
+
const {
|
|
567
|
+
clientX: x,
|
|
568
|
+
clientY: y
|
|
569
|
+
} = event.changedTouches[0];
|
|
570
|
+
return {
|
|
571
|
+
x,
|
|
572
|
+
y
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
if (hasViewportRelativeCoordinates(event)) {
|
|
577
|
+
return {
|
|
578
|
+
x: event.clientX,
|
|
579
|
+
y: event.clientY
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
return null;
|
|
583
|
+
}
|
|
584
|
+
var CSS = /* @__PURE__ */ Object.freeze({
|
|
585
|
+
Translate: {
|
|
586
|
+
toString(transform) {
|
|
587
|
+
if (!transform) {
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
const {
|
|
591
|
+
x,
|
|
592
|
+
y
|
|
593
|
+
} = transform;
|
|
594
|
+
return "translate3d(" + (x ? Math.round(x) : 0) + "px, " + (y ? Math.round(y) : 0) + "px, 0)";
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
Scale: {
|
|
598
|
+
toString(transform) {
|
|
599
|
+
if (!transform) {
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
const {
|
|
603
|
+
scaleX,
|
|
604
|
+
scaleY
|
|
605
|
+
} = transform;
|
|
606
|
+
return "scaleX(" + scaleX + ") scaleY(" + scaleY + ")";
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
Transform: {
|
|
610
|
+
toString(transform) {
|
|
611
|
+
if (!transform) {
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
return [CSS.Translate.toString(transform), CSS.Scale.toString(transform)].join(" ");
|
|
615
|
+
}
|
|
616
|
+
},
|
|
617
|
+
Transition: {
|
|
618
|
+
toString(_ref) {
|
|
619
|
+
let {
|
|
620
|
+
property,
|
|
621
|
+
duration,
|
|
622
|
+
easing
|
|
623
|
+
} = _ref;
|
|
624
|
+
return property + " " + duration + "ms " + easing;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
var SELECTOR = "a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";
|
|
629
|
+
function findFirstFocusableNode(element) {
|
|
630
|
+
if (element.matches(SELECTOR)) {
|
|
631
|
+
return element;
|
|
632
|
+
}
|
|
633
|
+
return element.querySelector(SELECTOR);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// node_modules/@dnd-kit/core/dist/core.esm.js
|
|
637
|
+
import React2, { createContext, useContext, useEffect as useEffect3, useState as useState3, useCallback as useCallback3, useMemo as useMemo3, useRef as useRef3, memo, useReducer, cloneElement, forwardRef } from "react";
|
|
638
|
+
import { createPortal, unstable_batchedUpdates } from "react-dom";
|
|
639
|
+
|
|
640
|
+
// node_modules/@dnd-kit/accessibility/dist/accessibility.esm.js
|
|
641
|
+
import React, { useState as useState2, useCallback as useCallback2 } from "react";
|
|
642
|
+
var hiddenStyles = {
|
|
643
|
+
display: "none"
|
|
644
|
+
};
|
|
645
|
+
function HiddenText(_ref) {
|
|
646
|
+
let {
|
|
647
|
+
id,
|
|
648
|
+
value
|
|
649
|
+
} = _ref;
|
|
650
|
+
return React.createElement("div", {
|
|
651
|
+
id,
|
|
652
|
+
style: hiddenStyles
|
|
653
|
+
}, value);
|
|
654
|
+
}
|
|
655
|
+
function LiveRegion(_ref) {
|
|
656
|
+
let {
|
|
657
|
+
id,
|
|
658
|
+
announcement,
|
|
659
|
+
ariaLiveType = "assertive"
|
|
660
|
+
} = _ref;
|
|
661
|
+
const visuallyHidden = {
|
|
662
|
+
position: "fixed",
|
|
663
|
+
top: 0,
|
|
664
|
+
left: 0,
|
|
665
|
+
width: 1,
|
|
666
|
+
height: 1,
|
|
667
|
+
margin: -1,
|
|
668
|
+
border: 0,
|
|
669
|
+
padding: 0,
|
|
670
|
+
overflow: "hidden",
|
|
671
|
+
clip: "rect(0 0 0 0)",
|
|
672
|
+
clipPath: "inset(100%)",
|
|
673
|
+
whiteSpace: "nowrap"
|
|
674
|
+
};
|
|
675
|
+
return React.createElement("div", {
|
|
676
|
+
id,
|
|
677
|
+
style: visuallyHidden,
|
|
678
|
+
role: "status",
|
|
679
|
+
"aria-live": ariaLiveType,
|
|
680
|
+
"aria-atomic": true
|
|
681
|
+
}, announcement);
|
|
682
|
+
}
|
|
683
|
+
function useAnnouncement() {
|
|
684
|
+
const [announcement, setAnnouncement] = useState2("");
|
|
685
|
+
const announce = useCallback2((value) => {
|
|
686
|
+
if (value != null) {
|
|
687
|
+
setAnnouncement(value);
|
|
688
|
+
}
|
|
689
|
+
}, []);
|
|
690
|
+
return {
|
|
691
|
+
announce,
|
|
692
|
+
announcement
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// node_modules/@dnd-kit/core/dist/core.esm.js
|
|
697
|
+
var DndMonitorContext = /* @__PURE__ */ createContext(null);
|
|
698
|
+
function useDndMonitor(listener) {
|
|
699
|
+
const registerListener = useContext(DndMonitorContext);
|
|
700
|
+
useEffect3(() => {
|
|
701
|
+
if (!registerListener) {
|
|
702
|
+
throw new Error("useDndMonitor must be used within a children of <DndContext>");
|
|
703
|
+
}
|
|
704
|
+
const unsubscribe = registerListener(listener);
|
|
705
|
+
return unsubscribe;
|
|
706
|
+
}, [listener, registerListener]);
|
|
707
|
+
}
|
|
708
|
+
function useDndMonitorProvider() {
|
|
709
|
+
const [listeners] = useState3(() => /* @__PURE__ */ new Set());
|
|
710
|
+
const registerListener = useCallback3((listener) => {
|
|
711
|
+
listeners.add(listener);
|
|
712
|
+
return () => listeners.delete(listener);
|
|
713
|
+
}, [listeners]);
|
|
714
|
+
const dispatch = useCallback3((_ref) => {
|
|
715
|
+
let {
|
|
716
|
+
type,
|
|
717
|
+
event
|
|
718
|
+
} = _ref;
|
|
719
|
+
listeners.forEach((listener) => {
|
|
720
|
+
var _listener$type;
|
|
721
|
+
return (_listener$type = listener[type]) == null ? void 0 : _listener$type.call(listener, event);
|
|
722
|
+
});
|
|
723
|
+
}, [listeners]);
|
|
724
|
+
return [dispatch, registerListener];
|
|
725
|
+
}
|
|
726
|
+
var defaultScreenReaderInstructions = {
|
|
727
|
+
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 "
|
|
728
|
+
};
|
|
729
|
+
var defaultAnnouncements = {
|
|
730
|
+
onDragStart(_ref) {
|
|
731
|
+
let {
|
|
732
|
+
active
|
|
733
|
+
} = _ref;
|
|
734
|
+
return "Picked up draggable item " + active.id + ".";
|
|
735
|
+
},
|
|
736
|
+
onDragOver(_ref2) {
|
|
737
|
+
let {
|
|
738
|
+
active,
|
|
739
|
+
over
|
|
740
|
+
} = _ref2;
|
|
741
|
+
if (over) {
|
|
742
|
+
return "Draggable item " + active.id + " was moved over droppable area " + over.id + ".";
|
|
743
|
+
}
|
|
744
|
+
return "Draggable item " + active.id + " is no longer over a droppable area.";
|
|
745
|
+
},
|
|
746
|
+
onDragEnd(_ref3) {
|
|
747
|
+
let {
|
|
748
|
+
active,
|
|
749
|
+
over
|
|
750
|
+
} = _ref3;
|
|
751
|
+
if (over) {
|
|
752
|
+
return "Draggable item " + active.id + " was dropped over droppable area " + over.id;
|
|
753
|
+
}
|
|
754
|
+
return "Draggable item " + active.id + " was dropped.";
|
|
755
|
+
},
|
|
756
|
+
onDragCancel(_ref4) {
|
|
757
|
+
let {
|
|
758
|
+
active
|
|
759
|
+
} = _ref4;
|
|
760
|
+
return "Dragging was cancelled. Draggable item " + active.id + " was dropped.";
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
function Accessibility(_ref) {
|
|
764
|
+
let {
|
|
765
|
+
announcements = defaultAnnouncements,
|
|
766
|
+
container,
|
|
767
|
+
hiddenTextDescribedById,
|
|
768
|
+
screenReaderInstructions = defaultScreenReaderInstructions
|
|
769
|
+
} = _ref;
|
|
770
|
+
const {
|
|
771
|
+
announce,
|
|
772
|
+
announcement
|
|
773
|
+
} = useAnnouncement();
|
|
774
|
+
const liveRegionId = useUniqueId("DndLiveRegion");
|
|
775
|
+
const [mounted, setMounted] = useState3(false);
|
|
776
|
+
useEffect3(() => {
|
|
777
|
+
setMounted(true);
|
|
778
|
+
}, []);
|
|
779
|
+
useDndMonitor(useMemo3(() => ({
|
|
780
|
+
onDragStart(_ref2) {
|
|
781
|
+
let {
|
|
782
|
+
active
|
|
783
|
+
} = _ref2;
|
|
784
|
+
announce(announcements.onDragStart({
|
|
785
|
+
active
|
|
786
|
+
}));
|
|
787
|
+
},
|
|
788
|
+
onDragMove(_ref3) {
|
|
789
|
+
let {
|
|
790
|
+
active,
|
|
791
|
+
over
|
|
792
|
+
} = _ref3;
|
|
793
|
+
if (announcements.onDragMove) {
|
|
794
|
+
announce(announcements.onDragMove({
|
|
795
|
+
active,
|
|
796
|
+
over
|
|
797
|
+
}));
|
|
798
|
+
}
|
|
799
|
+
},
|
|
800
|
+
onDragOver(_ref4) {
|
|
801
|
+
let {
|
|
802
|
+
active,
|
|
803
|
+
over
|
|
804
|
+
} = _ref4;
|
|
805
|
+
announce(announcements.onDragOver({
|
|
806
|
+
active,
|
|
807
|
+
over
|
|
808
|
+
}));
|
|
809
|
+
},
|
|
810
|
+
onDragEnd(_ref5) {
|
|
811
|
+
let {
|
|
812
|
+
active,
|
|
813
|
+
over
|
|
814
|
+
} = _ref5;
|
|
815
|
+
announce(announcements.onDragEnd({
|
|
816
|
+
active,
|
|
817
|
+
over
|
|
818
|
+
}));
|
|
819
|
+
},
|
|
820
|
+
onDragCancel(_ref6) {
|
|
821
|
+
let {
|
|
822
|
+
active,
|
|
823
|
+
over
|
|
824
|
+
} = _ref6;
|
|
825
|
+
announce(announcements.onDragCancel({
|
|
826
|
+
active,
|
|
827
|
+
over
|
|
828
|
+
}));
|
|
829
|
+
}
|
|
830
|
+
}), [announce, announcements]));
|
|
831
|
+
if (!mounted) {
|
|
832
|
+
return null;
|
|
833
|
+
}
|
|
834
|
+
const markup = React2.createElement(React2.Fragment, null, React2.createElement(HiddenText, {
|
|
835
|
+
id: hiddenTextDescribedById,
|
|
836
|
+
value: screenReaderInstructions.draggable
|
|
837
|
+
}), React2.createElement(LiveRegion, {
|
|
838
|
+
id: liveRegionId,
|
|
839
|
+
announcement
|
|
840
|
+
}));
|
|
841
|
+
return container ? createPortal(markup, container) : markup;
|
|
842
|
+
}
|
|
843
|
+
var Action;
|
|
844
|
+
(function(Action2) {
|
|
845
|
+
Action2["DragStart"] = "dragStart";
|
|
846
|
+
Action2["DragMove"] = "dragMove";
|
|
847
|
+
Action2["DragEnd"] = "dragEnd";
|
|
848
|
+
Action2["DragCancel"] = "dragCancel";
|
|
849
|
+
Action2["DragOver"] = "dragOver";
|
|
850
|
+
Action2["RegisterDroppable"] = "registerDroppable";
|
|
851
|
+
Action2["SetDroppableDisabled"] = "setDroppableDisabled";
|
|
852
|
+
Action2["UnregisterDroppable"] = "unregisterDroppable";
|
|
853
|
+
})(Action || (Action = {}));
|
|
854
|
+
function noop() {
|
|
855
|
+
}
|
|
856
|
+
function useSensor(sensor, options) {
|
|
857
|
+
return useMemo3(
|
|
858
|
+
() => ({
|
|
859
|
+
sensor,
|
|
860
|
+
options: options != null ? options : {}
|
|
861
|
+
}),
|
|
862
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
863
|
+
[sensor, options]
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
function useSensors() {
|
|
867
|
+
for (var _len = arguments.length, sensors = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
868
|
+
sensors[_key] = arguments[_key];
|
|
869
|
+
}
|
|
870
|
+
return useMemo3(
|
|
871
|
+
() => [...sensors].filter((sensor) => sensor != null),
|
|
872
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
873
|
+
[...sensors]
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
var defaultCoordinates = /* @__PURE__ */ Object.freeze({
|
|
877
|
+
x: 0,
|
|
878
|
+
y: 0
|
|
879
|
+
});
|
|
880
|
+
function distanceBetween(p1, p2) {
|
|
881
|
+
return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
|
|
882
|
+
}
|
|
883
|
+
function sortCollisionsAsc(_ref, _ref2) {
|
|
884
|
+
let {
|
|
885
|
+
data: {
|
|
886
|
+
value: a
|
|
887
|
+
}
|
|
888
|
+
} = _ref;
|
|
889
|
+
let {
|
|
890
|
+
data: {
|
|
891
|
+
value: b
|
|
892
|
+
}
|
|
893
|
+
} = _ref2;
|
|
894
|
+
return a - b;
|
|
895
|
+
}
|
|
896
|
+
function sortCollisionsDesc(_ref3, _ref4) {
|
|
897
|
+
let {
|
|
898
|
+
data: {
|
|
899
|
+
value: a
|
|
900
|
+
}
|
|
901
|
+
} = _ref3;
|
|
902
|
+
let {
|
|
903
|
+
data: {
|
|
904
|
+
value: b
|
|
905
|
+
}
|
|
906
|
+
} = _ref4;
|
|
907
|
+
return b - a;
|
|
908
|
+
}
|
|
909
|
+
function cornersOfRectangle(_ref5) {
|
|
910
|
+
let {
|
|
911
|
+
left,
|
|
912
|
+
top,
|
|
913
|
+
height,
|
|
914
|
+
width
|
|
915
|
+
} = _ref5;
|
|
916
|
+
return [{
|
|
917
|
+
x: left,
|
|
918
|
+
y: top
|
|
919
|
+
}, {
|
|
920
|
+
x: left + width,
|
|
921
|
+
y: top
|
|
922
|
+
}, {
|
|
923
|
+
x: left,
|
|
924
|
+
y: top + height
|
|
925
|
+
}, {
|
|
926
|
+
x: left + width,
|
|
927
|
+
y: top + height
|
|
928
|
+
}];
|
|
929
|
+
}
|
|
930
|
+
function getFirstCollision(collisions, property) {
|
|
931
|
+
if (!collisions || collisions.length === 0) {
|
|
932
|
+
return null;
|
|
933
|
+
}
|
|
934
|
+
const [firstCollision] = collisions;
|
|
935
|
+
return property ? firstCollision[property] : firstCollision;
|
|
936
|
+
}
|
|
937
|
+
function centerOfRectangle(rect, left, top) {
|
|
938
|
+
if (left === void 0) {
|
|
939
|
+
left = rect.left;
|
|
940
|
+
}
|
|
941
|
+
if (top === void 0) {
|
|
942
|
+
top = rect.top;
|
|
943
|
+
}
|
|
944
|
+
return {
|
|
945
|
+
x: left + rect.width * 0.5,
|
|
946
|
+
y: top + rect.height * 0.5
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
var closestCenter = (_ref) => {
|
|
950
|
+
let {
|
|
951
|
+
collisionRect,
|
|
952
|
+
droppableRects,
|
|
953
|
+
droppableContainers
|
|
954
|
+
} = _ref;
|
|
955
|
+
const centerRect = centerOfRectangle(collisionRect, collisionRect.left, collisionRect.top);
|
|
956
|
+
const collisions = [];
|
|
957
|
+
for (const droppableContainer of droppableContainers) {
|
|
958
|
+
const {
|
|
959
|
+
id
|
|
960
|
+
} = droppableContainer;
|
|
961
|
+
const rect = droppableRects.get(id);
|
|
962
|
+
if (rect) {
|
|
963
|
+
const distBetween = distanceBetween(centerOfRectangle(rect), centerRect);
|
|
964
|
+
collisions.push({
|
|
965
|
+
id,
|
|
966
|
+
data: {
|
|
967
|
+
droppableContainer,
|
|
968
|
+
value: distBetween
|
|
969
|
+
}
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
return collisions.sort(sortCollisionsAsc);
|
|
974
|
+
};
|
|
975
|
+
var closestCorners = (_ref) => {
|
|
976
|
+
let {
|
|
977
|
+
collisionRect,
|
|
978
|
+
droppableRects,
|
|
979
|
+
droppableContainers
|
|
980
|
+
} = _ref;
|
|
981
|
+
const corners = cornersOfRectangle(collisionRect);
|
|
982
|
+
const collisions = [];
|
|
983
|
+
for (const droppableContainer of droppableContainers) {
|
|
984
|
+
const {
|
|
985
|
+
id
|
|
986
|
+
} = droppableContainer;
|
|
987
|
+
const rect = droppableRects.get(id);
|
|
988
|
+
if (rect) {
|
|
989
|
+
const rectCorners = cornersOfRectangle(rect);
|
|
990
|
+
const distances = corners.reduce((accumulator, corner, index) => {
|
|
991
|
+
return accumulator + distanceBetween(rectCorners[index], corner);
|
|
992
|
+
}, 0);
|
|
993
|
+
const effectiveDistance = Number((distances / 4).toFixed(4));
|
|
994
|
+
collisions.push({
|
|
995
|
+
id,
|
|
996
|
+
data: {
|
|
997
|
+
droppableContainer,
|
|
998
|
+
value: effectiveDistance
|
|
999
|
+
}
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
return collisions.sort(sortCollisionsAsc);
|
|
1004
|
+
};
|
|
1005
|
+
function getIntersectionRatio(entry, target) {
|
|
1006
|
+
const top = Math.max(target.top, entry.top);
|
|
1007
|
+
const left = Math.max(target.left, entry.left);
|
|
1008
|
+
const right = Math.min(target.left + target.width, entry.left + entry.width);
|
|
1009
|
+
const bottom = Math.min(target.top + target.height, entry.top + entry.height);
|
|
1010
|
+
const width = right - left;
|
|
1011
|
+
const height = bottom - top;
|
|
1012
|
+
if (left < right && top < bottom) {
|
|
1013
|
+
const targetArea = target.width * target.height;
|
|
1014
|
+
const entryArea = entry.width * entry.height;
|
|
1015
|
+
const intersectionArea = width * height;
|
|
1016
|
+
const intersectionRatio = intersectionArea / (targetArea + entryArea - intersectionArea);
|
|
1017
|
+
return Number(intersectionRatio.toFixed(4));
|
|
1018
|
+
}
|
|
1019
|
+
return 0;
|
|
1020
|
+
}
|
|
1021
|
+
var rectIntersection = (_ref) => {
|
|
1022
|
+
let {
|
|
1023
|
+
collisionRect,
|
|
1024
|
+
droppableRects,
|
|
1025
|
+
droppableContainers
|
|
1026
|
+
} = _ref;
|
|
1027
|
+
const collisions = [];
|
|
1028
|
+
for (const droppableContainer of droppableContainers) {
|
|
1029
|
+
const {
|
|
1030
|
+
id
|
|
1031
|
+
} = droppableContainer;
|
|
1032
|
+
const rect = droppableRects.get(id);
|
|
1033
|
+
if (rect) {
|
|
1034
|
+
const intersectionRatio = getIntersectionRatio(rect, collisionRect);
|
|
1035
|
+
if (intersectionRatio > 0) {
|
|
1036
|
+
collisions.push({
|
|
1037
|
+
id,
|
|
1038
|
+
data: {
|
|
1039
|
+
droppableContainer,
|
|
1040
|
+
value: intersectionRatio
|
|
1041
|
+
}
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
return collisions.sort(sortCollisionsDesc);
|
|
1047
|
+
};
|
|
1048
|
+
function adjustScale(transform, rect1, rect2) {
|
|
1049
|
+
return {
|
|
1050
|
+
...transform,
|
|
1051
|
+
scaleX: rect1 && rect2 ? rect1.width / rect2.width : 1,
|
|
1052
|
+
scaleY: rect1 && rect2 ? rect1.height / rect2.height : 1
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
function getRectDelta(rect1, rect2) {
|
|
1056
|
+
return rect1 && rect2 ? {
|
|
1057
|
+
x: rect1.left - rect2.left,
|
|
1058
|
+
y: rect1.top - rect2.top
|
|
1059
|
+
} : defaultCoordinates;
|
|
1060
|
+
}
|
|
1061
|
+
function createRectAdjustmentFn(modifier) {
|
|
1062
|
+
return function adjustClientRect(rect) {
|
|
1063
|
+
for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1064
|
+
adjustments[_key - 1] = arguments[_key];
|
|
1065
|
+
}
|
|
1066
|
+
return adjustments.reduce((acc, adjustment) => ({
|
|
1067
|
+
...acc,
|
|
1068
|
+
top: acc.top + modifier * adjustment.y,
|
|
1069
|
+
bottom: acc.bottom + modifier * adjustment.y,
|
|
1070
|
+
left: acc.left + modifier * adjustment.x,
|
|
1071
|
+
right: acc.right + modifier * adjustment.x
|
|
1072
|
+
}), {
|
|
1073
|
+
...rect
|
|
1074
|
+
});
|
|
1075
|
+
};
|
|
1076
|
+
}
|
|
1077
|
+
var getAdjustedRect = /* @__PURE__ */ createRectAdjustmentFn(1);
|
|
1078
|
+
function parseTransform(transform) {
|
|
1079
|
+
if (transform.startsWith("matrix3d(")) {
|
|
1080
|
+
const transformArray = transform.slice(9, -1).split(/, /);
|
|
1081
|
+
return {
|
|
1082
|
+
x: +transformArray[12],
|
|
1083
|
+
y: +transformArray[13],
|
|
1084
|
+
scaleX: +transformArray[0],
|
|
1085
|
+
scaleY: +transformArray[5]
|
|
1086
|
+
};
|
|
1087
|
+
} else if (transform.startsWith("matrix(")) {
|
|
1088
|
+
const transformArray = transform.slice(7, -1).split(/, /);
|
|
1089
|
+
return {
|
|
1090
|
+
x: +transformArray[4],
|
|
1091
|
+
y: +transformArray[5],
|
|
1092
|
+
scaleX: +transformArray[0],
|
|
1093
|
+
scaleY: +transformArray[3]
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
return null;
|
|
1097
|
+
}
|
|
1098
|
+
function inverseTransform(rect, transform, transformOrigin) {
|
|
1099
|
+
const parsedTransform = parseTransform(transform);
|
|
1100
|
+
if (!parsedTransform) {
|
|
1101
|
+
return rect;
|
|
1102
|
+
}
|
|
1103
|
+
const {
|
|
1104
|
+
scaleX,
|
|
1105
|
+
scaleY,
|
|
1106
|
+
x: translateX,
|
|
1107
|
+
y: translateY
|
|
1108
|
+
} = parsedTransform;
|
|
1109
|
+
const x = rect.left - translateX - (1 - scaleX) * parseFloat(transformOrigin);
|
|
1110
|
+
const y = rect.top - translateY - (1 - scaleY) * parseFloat(transformOrigin.slice(transformOrigin.indexOf(" ") + 1));
|
|
1111
|
+
const w = scaleX ? rect.width / scaleX : rect.width;
|
|
1112
|
+
const h = scaleY ? rect.height / scaleY : rect.height;
|
|
1113
|
+
return {
|
|
1114
|
+
width: w,
|
|
1115
|
+
height: h,
|
|
1116
|
+
top: y,
|
|
1117
|
+
right: x + w,
|
|
1118
|
+
bottom: y + h,
|
|
1119
|
+
left: x
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
var defaultOptions = {
|
|
1123
|
+
ignoreTransform: false
|
|
1124
|
+
};
|
|
1125
|
+
function getClientRect(element, options) {
|
|
1126
|
+
if (options === void 0) {
|
|
1127
|
+
options = defaultOptions;
|
|
1128
|
+
}
|
|
1129
|
+
let rect = element.getBoundingClientRect();
|
|
1130
|
+
if (options.ignoreTransform) {
|
|
1131
|
+
const {
|
|
1132
|
+
transform,
|
|
1133
|
+
transformOrigin
|
|
1134
|
+
} = getWindow(element).getComputedStyle(element);
|
|
1135
|
+
if (transform) {
|
|
1136
|
+
rect = inverseTransform(rect, transform, transformOrigin);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
const {
|
|
1140
|
+
top,
|
|
1141
|
+
left,
|
|
1142
|
+
width,
|
|
1143
|
+
height,
|
|
1144
|
+
bottom,
|
|
1145
|
+
right
|
|
1146
|
+
} = rect;
|
|
1147
|
+
return {
|
|
1148
|
+
top,
|
|
1149
|
+
left,
|
|
1150
|
+
width,
|
|
1151
|
+
height,
|
|
1152
|
+
bottom,
|
|
1153
|
+
right
|
|
1154
|
+
};
|
|
1155
|
+
}
|
|
1156
|
+
function getTransformAgnosticClientRect(element) {
|
|
1157
|
+
return getClientRect(element, {
|
|
1158
|
+
ignoreTransform: true
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
function getWindowClientRect(element) {
|
|
1162
|
+
const width = element.innerWidth;
|
|
1163
|
+
const height = element.innerHeight;
|
|
1164
|
+
return {
|
|
1165
|
+
top: 0,
|
|
1166
|
+
left: 0,
|
|
1167
|
+
right: width,
|
|
1168
|
+
bottom: height,
|
|
1169
|
+
width,
|
|
1170
|
+
height
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
function isFixed(node, computedStyle) {
|
|
1174
|
+
if (computedStyle === void 0) {
|
|
1175
|
+
computedStyle = getWindow(node).getComputedStyle(node);
|
|
1176
|
+
}
|
|
1177
|
+
return computedStyle.position === "fixed";
|
|
1178
|
+
}
|
|
1179
|
+
function isScrollable(element, computedStyle) {
|
|
1180
|
+
if (computedStyle === void 0) {
|
|
1181
|
+
computedStyle = getWindow(element).getComputedStyle(element);
|
|
1182
|
+
}
|
|
1183
|
+
const overflowRegex = /(auto|scroll|overlay)/;
|
|
1184
|
+
const properties2 = ["overflow", "overflowX", "overflowY"];
|
|
1185
|
+
return properties2.some((property) => {
|
|
1186
|
+
const value = computedStyle[property];
|
|
1187
|
+
return typeof value === "string" ? overflowRegex.test(value) : false;
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
function getScrollableAncestors(element, limit) {
|
|
1191
|
+
const scrollParents = [];
|
|
1192
|
+
function findScrollableAncestors(node) {
|
|
1193
|
+
if (limit != null && scrollParents.length >= limit) {
|
|
1194
|
+
return scrollParents;
|
|
1195
|
+
}
|
|
1196
|
+
if (!node) {
|
|
1197
|
+
return scrollParents;
|
|
1198
|
+
}
|
|
1199
|
+
if (isDocument(node) && node.scrollingElement != null && !scrollParents.includes(node.scrollingElement)) {
|
|
1200
|
+
scrollParents.push(node.scrollingElement);
|
|
1201
|
+
return scrollParents;
|
|
1202
|
+
}
|
|
1203
|
+
if (!isHTMLElement(node) || isSVGElement(node)) {
|
|
1204
|
+
return scrollParents;
|
|
1205
|
+
}
|
|
1206
|
+
if (scrollParents.includes(node)) {
|
|
1207
|
+
return scrollParents;
|
|
1208
|
+
}
|
|
1209
|
+
const computedStyle = getWindow(element).getComputedStyle(node);
|
|
1210
|
+
if (node !== element) {
|
|
1211
|
+
if (isScrollable(node, computedStyle)) {
|
|
1212
|
+
scrollParents.push(node);
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
if (isFixed(node, computedStyle)) {
|
|
1216
|
+
return scrollParents;
|
|
1217
|
+
}
|
|
1218
|
+
return findScrollableAncestors(node.parentNode);
|
|
1219
|
+
}
|
|
1220
|
+
if (!element) {
|
|
1221
|
+
return scrollParents;
|
|
1222
|
+
}
|
|
1223
|
+
return findScrollableAncestors(element);
|
|
1224
|
+
}
|
|
1225
|
+
function getFirstScrollableAncestor(node) {
|
|
1226
|
+
const [firstScrollableAncestor] = getScrollableAncestors(node, 1);
|
|
1227
|
+
return firstScrollableAncestor != null ? firstScrollableAncestor : null;
|
|
1228
|
+
}
|
|
1229
|
+
function getScrollableElement(element) {
|
|
1230
|
+
if (!canUseDOM || !element) {
|
|
1231
|
+
return null;
|
|
1232
|
+
}
|
|
1233
|
+
if (isWindow(element)) {
|
|
1234
|
+
return element;
|
|
1235
|
+
}
|
|
1236
|
+
if (!isNode(element)) {
|
|
1237
|
+
return null;
|
|
1238
|
+
}
|
|
1239
|
+
if (isDocument(element) || element === getOwnerDocument(element).scrollingElement) {
|
|
1240
|
+
return window;
|
|
1241
|
+
}
|
|
1242
|
+
if (isHTMLElement(element)) {
|
|
1243
|
+
return element;
|
|
1244
|
+
}
|
|
1245
|
+
return null;
|
|
1246
|
+
}
|
|
1247
|
+
function getScrollXCoordinate(element) {
|
|
1248
|
+
if (isWindow(element)) {
|
|
1249
|
+
return element.scrollX;
|
|
1250
|
+
}
|
|
1251
|
+
return element.scrollLeft;
|
|
1252
|
+
}
|
|
1253
|
+
function getScrollYCoordinate(element) {
|
|
1254
|
+
if (isWindow(element)) {
|
|
1255
|
+
return element.scrollY;
|
|
1256
|
+
}
|
|
1257
|
+
return element.scrollTop;
|
|
1258
|
+
}
|
|
1259
|
+
function getScrollCoordinates(element) {
|
|
1260
|
+
return {
|
|
1261
|
+
x: getScrollXCoordinate(element),
|
|
1262
|
+
y: getScrollYCoordinate(element)
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
var Direction;
|
|
1266
|
+
(function(Direction2) {
|
|
1267
|
+
Direction2[Direction2["Forward"] = 1] = "Forward";
|
|
1268
|
+
Direction2[Direction2["Backward"] = -1] = "Backward";
|
|
1269
|
+
})(Direction || (Direction = {}));
|
|
1270
|
+
function isDocumentScrollingElement(element) {
|
|
1271
|
+
if (!canUseDOM || !element) {
|
|
1272
|
+
return false;
|
|
1273
|
+
}
|
|
1274
|
+
return element === document.scrollingElement;
|
|
1275
|
+
}
|
|
1276
|
+
function getScrollPosition(scrollingContainer) {
|
|
1277
|
+
const minScroll = {
|
|
1278
|
+
x: 0,
|
|
1279
|
+
y: 0
|
|
1280
|
+
};
|
|
1281
|
+
const dimensions = isDocumentScrollingElement(scrollingContainer) ? {
|
|
1282
|
+
height: window.innerHeight,
|
|
1283
|
+
width: window.innerWidth
|
|
1284
|
+
} : {
|
|
1285
|
+
height: scrollingContainer.clientHeight,
|
|
1286
|
+
width: scrollingContainer.clientWidth
|
|
1287
|
+
};
|
|
1288
|
+
const maxScroll = {
|
|
1289
|
+
x: scrollingContainer.scrollWidth - dimensions.width,
|
|
1290
|
+
y: scrollingContainer.scrollHeight - dimensions.height
|
|
1291
|
+
};
|
|
1292
|
+
const isTop = scrollingContainer.scrollTop <= minScroll.y;
|
|
1293
|
+
const isLeft = scrollingContainer.scrollLeft <= minScroll.x;
|
|
1294
|
+
const isBottom = scrollingContainer.scrollTop >= maxScroll.y;
|
|
1295
|
+
const isRight = scrollingContainer.scrollLeft >= maxScroll.x;
|
|
1296
|
+
return {
|
|
1297
|
+
isTop,
|
|
1298
|
+
isLeft,
|
|
1299
|
+
isBottom,
|
|
1300
|
+
isRight,
|
|
1301
|
+
maxScroll,
|
|
1302
|
+
minScroll
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
var defaultThreshold = {
|
|
1306
|
+
x: 0.2,
|
|
1307
|
+
y: 0.2
|
|
1308
|
+
};
|
|
1309
|
+
function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, _ref, acceleration, thresholdPercentage) {
|
|
1310
|
+
let {
|
|
1311
|
+
top,
|
|
1312
|
+
left,
|
|
1313
|
+
right,
|
|
1314
|
+
bottom
|
|
1315
|
+
} = _ref;
|
|
1316
|
+
if (acceleration === void 0) {
|
|
1317
|
+
acceleration = 10;
|
|
1318
|
+
}
|
|
1319
|
+
if (thresholdPercentage === void 0) {
|
|
1320
|
+
thresholdPercentage = defaultThreshold;
|
|
1321
|
+
}
|
|
1322
|
+
const {
|
|
1323
|
+
isTop,
|
|
1324
|
+
isBottom,
|
|
1325
|
+
isLeft,
|
|
1326
|
+
isRight
|
|
1327
|
+
} = getScrollPosition(scrollContainer);
|
|
1328
|
+
const direction = {
|
|
1329
|
+
x: 0,
|
|
1330
|
+
y: 0
|
|
1331
|
+
};
|
|
1332
|
+
const speed = {
|
|
1333
|
+
x: 0,
|
|
1334
|
+
y: 0
|
|
1335
|
+
};
|
|
1336
|
+
const threshold = {
|
|
1337
|
+
height: scrollContainerRect.height * thresholdPercentage.y,
|
|
1338
|
+
width: scrollContainerRect.width * thresholdPercentage.x
|
|
1339
|
+
};
|
|
1340
|
+
if (!isTop && top <= scrollContainerRect.top + threshold.height) {
|
|
1341
|
+
direction.y = Direction.Backward;
|
|
1342
|
+
speed.y = acceleration * Math.abs((scrollContainerRect.top + threshold.height - top) / threshold.height);
|
|
1343
|
+
} else if (!isBottom && bottom >= scrollContainerRect.bottom - threshold.height) {
|
|
1344
|
+
direction.y = Direction.Forward;
|
|
1345
|
+
speed.y = acceleration * Math.abs((scrollContainerRect.bottom - threshold.height - bottom) / threshold.height);
|
|
1346
|
+
}
|
|
1347
|
+
if (!isRight && right >= scrollContainerRect.right - threshold.width) {
|
|
1348
|
+
direction.x = Direction.Forward;
|
|
1349
|
+
speed.x = acceleration * Math.abs((scrollContainerRect.right - threshold.width - right) / threshold.width);
|
|
1350
|
+
} else if (!isLeft && left <= scrollContainerRect.left + threshold.width) {
|
|
1351
|
+
direction.x = Direction.Backward;
|
|
1352
|
+
speed.x = acceleration * Math.abs((scrollContainerRect.left + threshold.width - left) / threshold.width);
|
|
1353
|
+
}
|
|
1354
|
+
return {
|
|
1355
|
+
direction,
|
|
1356
|
+
speed
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1359
|
+
function getScrollElementRect(element) {
|
|
1360
|
+
if (element === document.scrollingElement) {
|
|
1361
|
+
const {
|
|
1362
|
+
innerWidth,
|
|
1363
|
+
innerHeight
|
|
1364
|
+
} = window;
|
|
1365
|
+
return {
|
|
1366
|
+
top: 0,
|
|
1367
|
+
left: 0,
|
|
1368
|
+
right: innerWidth,
|
|
1369
|
+
bottom: innerHeight,
|
|
1370
|
+
width: innerWidth,
|
|
1371
|
+
height: innerHeight
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
const {
|
|
1375
|
+
top,
|
|
1376
|
+
left,
|
|
1377
|
+
right,
|
|
1378
|
+
bottom
|
|
1379
|
+
} = element.getBoundingClientRect();
|
|
1380
|
+
return {
|
|
1381
|
+
top,
|
|
1382
|
+
left,
|
|
1383
|
+
right,
|
|
1384
|
+
bottom,
|
|
1385
|
+
width: element.clientWidth,
|
|
1386
|
+
height: element.clientHeight
|
|
1387
|
+
};
|
|
1388
|
+
}
|
|
1389
|
+
function getScrollOffsets(scrollableAncestors) {
|
|
1390
|
+
return scrollableAncestors.reduce((acc, node) => {
|
|
1391
|
+
return add(acc, getScrollCoordinates(node));
|
|
1392
|
+
}, defaultCoordinates);
|
|
1393
|
+
}
|
|
1394
|
+
function getScrollXOffset(scrollableAncestors) {
|
|
1395
|
+
return scrollableAncestors.reduce((acc, node) => {
|
|
1396
|
+
return acc + getScrollXCoordinate(node);
|
|
1397
|
+
}, 0);
|
|
1398
|
+
}
|
|
1399
|
+
function getScrollYOffset(scrollableAncestors) {
|
|
1400
|
+
return scrollableAncestors.reduce((acc, node) => {
|
|
1401
|
+
return acc + getScrollYCoordinate(node);
|
|
1402
|
+
}, 0);
|
|
1403
|
+
}
|
|
1404
|
+
function scrollIntoViewIfNeeded(element, measure) {
|
|
1405
|
+
if (measure === void 0) {
|
|
1406
|
+
measure = getClientRect;
|
|
1407
|
+
}
|
|
1408
|
+
if (!element) {
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
const {
|
|
1412
|
+
top,
|
|
1413
|
+
left,
|
|
1414
|
+
bottom,
|
|
1415
|
+
right
|
|
1416
|
+
} = measure(element);
|
|
1417
|
+
const firstScrollableAncestor = getFirstScrollableAncestor(element);
|
|
1418
|
+
if (!firstScrollableAncestor) {
|
|
1419
|
+
return;
|
|
1420
|
+
}
|
|
1421
|
+
if (bottom <= 0 || right <= 0 || top >= window.innerHeight || left >= window.innerWidth) {
|
|
1422
|
+
element.scrollIntoView({
|
|
1423
|
+
block: "center",
|
|
1424
|
+
inline: "center"
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
var properties = [["x", ["left", "right"], getScrollXOffset], ["y", ["top", "bottom"], getScrollYOffset]];
|
|
1429
|
+
var Rect = class {
|
|
1430
|
+
constructor(rect, element) {
|
|
1431
|
+
this.rect = void 0;
|
|
1432
|
+
this.width = void 0;
|
|
1433
|
+
this.height = void 0;
|
|
1434
|
+
this.top = void 0;
|
|
1435
|
+
this.bottom = void 0;
|
|
1436
|
+
this.right = void 0;
|
|
1437
|
+
this.left = void 0;
|
|
1438
|
+
const scrollableAncestors = getScrollableAncestors(element);
|
|
1439
|
+
const scrollOffsets = getScrollOffsets(scrollableAncestors);
|
|
1440
|
+
this.rect = {
|
|
1441
|
+
...rect
|
|
1442
|
+
};
|
|
1443
|
+
this.width = rect.width;
|
|
1444
|
+
this.height = rect.height;
|
|
1445
|
+
for (const [axis, keys, getScrollOffset] of properties) {
|
|
1446
|
+
for (const key of keys) {
|
|
1447
|
+
Object.defineProperty(this, key, {
|
|
1448
|
+
get: () => {
|
|
1449
|
+
const currentOffsets = getScrollOffset(scrollableAncestors);
|
|
1450
|
+
const scrollOffsetsDeltla = scrollOffsets[axis] - currentOffsets;
|
|
1451
|
+
return this.rect[key] + scrollOffsetsDeltla;
|
|
1452
|
+
},
|
|
1453
|
+
enumerable: true
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
Object.defineProperty(this, "rect", {
|
|
1458
|
+
enumerable: false
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
var Listeners = class {
|
|
1463
|
+
constructor(target) {
|
|
1464
|
+
this.target = void 0;
|
|
1465
|
+
this.listeners = [];
|
|
1466
|
+
this.removeAll = () => {
|
|
1467
|
+
this.listeners.forEach((listener) => {
|
|
1468
|
+
var _this$target;
|
|
1469
|
+
return (_this$target = this.target) == null ? void 0 : _this$target.removeEventListener(...listener);
|
|
1470
|
+
});
|
|
1471
|
+
};
|
|
1472
|
+
this.target = target;
|
|
1473
|
+
}
|
|
1474
|
+
add(eventName, handler, options) {
|
|
1475
|
+
var _this$target2;
|
|
1476
|
+
(_this$target2 = this.target) == null ? void 0 : _this$target2.addEventListener(eventName, handler, options);
|
|
1477
|
+
this.listeners.push([eventName, handler, options]);
|
|
1478
|
+
}
|
|
1479
|
+
};
|
|
1480
|
+
function getEventListenerTarget(target) {
|
|
1481
|
+
const {
|
|
1482
|
+
EventTarget
|
|
1483
|
+
} = getWindow(target);
|
|
1484
|
+
return target instanceof EventTarget ? target : getOwnerDocument(target);
|
|
1485
|
+
}
|
|
1486
|
+
function hasExceededDistance(delta, measurement) {
|
|
1487
|
+
const dx = Math.abs(delta.x);
|
|
1488
|
+
const dy = Math.abs(delta.y);
|
|
1489
|
+
if (typeof measurement === "number") {
|
|
1490
|
+
return Math.sqrt(dx ** 2 + dy ** 2) > measurement;
|
|
1491
|
+
}
|
|
1492
|
+
if ("x" in measurement && "y" in measurement) {
|
|
1493
|
+
return dx > measurement.x && dy > measurement.y;
|
|
1494
|
+
}
|
|
1495
|
+
if ("x" in measurement) {
|
|
1496
|
+
return dx > measurement.x;
|
|
1497
|
+
}
|
|
1498
|
+
if ("y" in measurement) {
|
|
1499
|
+
return dy > measurement.y;
|
|
1500
|
+
}
|
|
1501
|
+
return false;
|
|
1502
|
+
}
|
|
1503
|
+
var EventName;
|
|
1504
|
+
(function(EventName2) {
|
|
1505
|
+
EventName2["Click"] = "click";
|
|
1506
|
+
EventName2["DragStart"] = "dragstart";
|
|
1507
|
+
EventName2["Keydown"] = "keydown";
|
|
1508
|
+
EventName2["ContextMenu"] = "contextmenu";
|
|
1509
|
+
EventName2["Resize"] = "resize";
|
|
1510
|
+
EventName2["SelectionChange"] = "selectionchange";
|
|
1511
|
+
EventName2["VisibilityChange"] = "visibilitychange";
|
|
1512
|
+
})(EventName || (EventName = {}));
|
|
1513
|
+
function preventDefault(event) {
|
|
1514
|
+
event.preventDefault();
|
|
1515
|
+
}
|
|
1516
|
+
function stopPropagation(event) {
|
|
1517
|
+
event.stopPropagation();
|
|
1518
|
+
}
|
|
1519
|
+
var KeyboardCode;
|
|
1520
|
+
(function(KeyboardCode2) {
|
|
1521
|
+
KeyboardCode2["Space"] = "Space";
|
|
1522
|
+
KeyboardCode2["Down"] = "ArrowDown";
|
|
1523
|
+
KeyboardCode2["Right"] = "ArrowRight";
|
|
1524
|
+
KeyboardCode2["Left"] = "ArrowLeft";
|
|
1525
|
+
KeyboardCode2["Up"] = "ArrowUp";
|
|
1526
|
+
KeyboardCode2["Esc"] = "Escape";
|
|
1527
|
+
KeyboardCode2["Enter"] = "Enter";
|
|
1528
|
+
KeyboardCode2["Tab"] = "Tab";
|
|
1529
|
+
})(KeyboardCode || (KeyboardCode = {}));
|
|
1530
|
+
var defaultKeyboardCodes = {
|
|
1531
|
+
start: [KeyboardCode.Space, KeyboardCode.Enter],
|
|
1532
|
+
cancel: [KeyboardCode.Esc],
|
|
1533
|
+
end: [KeyboardCode.Space, KeyboardCode.Enter, KeyboardCode.Tab]
|
|
1534
|
+
};
|
|
1535
|
+
var defaultKeyboardCoordinateGetter = (event, _ref) => {
|
|
1536
|
+
let {
|
|
1537
|
+
currentCoordinates
|
|
1538
|
+
} = _ref;
|
|
1539
|
+
switch (event.code) {
|
|
1540
|
+
case KeyboardCode.Right:
|
|
1541
|
+
return {
|
|
1542
|
+
...currentCoordinates,
|
|
1543
|
+
x: currentCoordinates.x + 25
|
|
1544
|
+
};
|
|
1545
|
+
case KeyboardCode.Left:
|
|
1546
|
+
return {
|
|
1547
|
+
...currentCoordinates,
|
|
1548
|
+
x: currentCoordinates.x - 25
|
|
1549
|
+
};
|
|
1550
|
+
case KeyboardCode.Down:
|
|
1551
|
+
return {
|
|
1552
|
+
...currentCoordinates,
|
|
1553
|
+
y: currentCoordinates.y + 25
|
|
1554
|
+
};
|
|
1555
|
+
case KeyboardCode.Up:
|
|
1556
|
+
return {
|
|
1557
|
+
...currentCoordinates,
|
|
1558
|
+
y: currentCoordinates.y - 25
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1561
|
+
return void 0;
|
|
1562
|
+
};
|
|
1563
|
+
var KeyboardSensor = class {
|
|
1564
|
+
constructor(props) {
|
|
1565
|
+
this.props = void 0;
|
|
1566
|
+
this.autoScrollEnabled = false;
|
|
1567
|
+
this.referenceCoordinates = void 0;
|
|
1568
|
+
this.listeners = void 0;
|
|
1569
|
+
this.windowListeners = void 0;
|
|
1570
|
+
this.props = props;
|
|
1571
|
+
const {
|
|
1572
|
+
event: {
|
|
1573
|
+
target
|
|
1574
|
+
}
|
|
1575
|
+
} = props;
|
|
1576
|
+
this.props = props;
|
|
1577
|
+
this.listeners = new Listeners(getOwnerDocument(target));
|
|
1578
|
+
this.windowListeners = new Listeners(getWindow(target));
|
|
1579
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
1580
|
+
this.handleCancel = this.handleCancel.bind(this);
|
|
1581
|
+
this.attach();
|
|
1582
|
+
}
|
|
1583
|
+
attach() {
|
|
1584
|
+
this.handleStart();
|
|
1585
|
+
this.windowListeners.add(EventName.Resize, this.handleCancel);
|
|
1586
|
+
this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
|
|
1587
|
+
setTimeout(() => this.listeners.add(EventName.Keydown, this.handleKeyDown));
|
|
1588
|
+
}
|
|
1589
|
+
handleStart() {
|
|
1590
|
+
const {
|
|
1591
|
+
activeNode,
|
|
1592
|
+
onStart
|
|
1593
|
+
} = this.props;
|
|
1594
|
+
const node = activeNode.node.current;
|
|
1595
|
+
if (node) {
|
|
1596
|
+
scrollIntoViewIfNeeded(node);
|
|
1597
|
+
}
|
|
1598
|
+
onStart(defaultCoordinates);
|
|
1599
|
+
}
|
|
1600
|
+
handleKeyDown(event) {
|
|
1601
|
+
if (isKeyboardEvent(event)) {
|
|
1602
|
+
const {
|
|
1603
|
+
active,
|
|
1604
|
+
context,
|
|
1605
|
+
options
|
|
1606
|
+
} = this.props;
|
|
1607
|
+
const {
|
|
1608
|
+
keyboardCodes = defaultKeyboardCodes,
|
|
1609
|
+
coordinateGetter = defaultKeyboardCoordinateGetter,
|
|
1610
|
+
scrollBehavior = "smooth"
|
|
1611
|
+
} = options;
|
|
1612
|
+
const {
|
|
1613
|
+
code
|
|
1614
|
+
} = event;
|
|
1615
|
+
if (keyboardCodes.end.includes(code)) {
|
|
1616
|
+
this.handleEnd(event);
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1619
|
+
if (keyboardCodes.cancel.includes(code)) {
|
|
1620
|
+
this.handleCancel(event);
|
|
1621
|
+
return;
|
|
1622
|
+
}
|
|
1623
|
+
const {
|
|
1624
|
+
collisionRect
|
|
1625
|
+
} = context.current;
|
|
1626
|
+
const currentCoordinates = collisionRect ? {
|
|
1627
|
+
x: collisionRect.left,
|
|
1628
|
+
y: collisionRect.top
|
|
1629
|
+
} : defaultCoordinates;
|
|
1630
|
+
if (!this.referenceCoordinates) {
|
|
1631
|
+
this.referenceCoordinates = currentCoordinates;
|
|
1632
|
+
}
|
|
1633
|
+
const newCoordinates = coordinateGetter(event, {
|
|
1634
|
+
active,
|
|
1635
|
+
context: context.current,
|
|
1636
|
+
currentCoordinates
|
|
1637
|
+
});
|
|
1638
|
+
if (newCoordinates) {
|
|
1639
|
+
const coordinatesDelta = subtract(newCoordinates, currentCoordinates);
|
|
1640
|
+
const scrollDelta = {
|
|
1641
|
+
x: 0,
|
|
1642
|
+
y: 0
|
|
1643
|
+
};
|
|
1644
|
+
const {
|
|
1645
|
+
scrollableAncestors
|
|
1646
|
+
} = context.current;
|
|
1647
|
+
for (const scrollContainer of scrollableAncestors) {
|
|
1648
|
+
const direction = event.code;
|
|
1649
|
+
const {
|
|
1650
|
+
isTop,
|
|
1651
|
+
isRight,
|
|
1652
|
+
isLeft,
|
|
1653
|
+
isBottom,
|
|
1654
|
+
maxScroll,
|
|
1655
|
+
minScroll
|
|
1656
|
+
} = getScrollPosition(scrollContainer);
|
|
1657
|
+
const scrollElementRect = getScrollElementRect(scrollContainer);
|
|
1658
|
+
const clampedCoordinates = {
|
|
1659
|
+
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)),
|
|
1660
|
+
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))
|
|
1661
|
+
};
|
|
1662
|
+
const canScrollX = direction === KeyboardCode.Right && !isRight || direction === KeyboardCode.Left && !isLeft;
|
|
1663
|
+
const canScrollY = direction === KeyboardCode.Down && !isBottom || direction === KeyboardCode.Up && !isTop;
|
|
1664
|
+
if (canScrollX && clampedCoordinates.x !== newCoordinates.x) {
|
|
1665
|
+
const newScrollCoordinates = scrollContainer.scrollLeft + coordinatesDelta.x;
|
|
1666
|
+
const canScrollToNewCoordinates = direction === KeyboardCode.Right && newScrollCoordinates <= maxScroll.x || direction === KeyboardCode.Left && newScrollCoordinates >= minScroll.x;
|
|
1667
|
+
if (canScrollToNewCoordinates && !coordinatesDelta.y) {
|
|
1668
|
+
scrollContainer.scrollTo({
|
|
1669
|
+
left: newScrollCoordinates,
|
|
1670
|
+
behavior: scrollBehavior
|
|
1671
|
+
});
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
if (canScrollToNewCoordinates) {
|
|
1675
|
+
scrollDelta.x = scrollContainer.scrollLeft - newScrollCoordinates;
|
|
1676
|
+
} else {
|
|
1677
|
+
scrollDelta.x = direction === KeyboardCode.Right ? scrollContainer.scrollLeft - maxScroll.x : scrollContainer.scrollLeft - minScroll.x;
|
|
1678
|
+
}
|
|
1679
|
+
if (scrollDelta.x) {
|
|
1680
|
+
scrollContainer.scrollBy({
|
|
1681
|
+
left: -scrollDelta.x,
|
|
1682
|
+
behavior: scrollBehavior
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1685
|
+
break;
|
|
1686
|
+
} else if (canScrollY && clampedCoordinates.y !== newCoordinates.y) {
|
|
1687
|
+
const newScrollCoordinates = scrollContainer.scrollTop + coordinatesDelta.y;
|
|
1688
|
+
const canScrollToNewCoordinates = direction === KeyboardCode.Down && newScrollCoordinates <= maxScroll.y || direction === KeyboardCode.Up && newScrollCoordinates >= minScroll.y;
|
|
1689
|
+
if (canScrollToNewCoordinates && !coordinatesDelta.x) {
|
|
1690
|
+
scrollContainer.scrollTo({
|
|
1691
|
+
top: newScrollCoordinates,
|
|
1692
|
+
behavior: scrollBehavior
|
|
1693
|
+
});
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
if (canScrollToNewCoordinates) {
|
|
1697
|
+
scrollDelta.y = scrollContainer.scrollTop - newScrollCoordinates;
|
|
1698
|
+
} else {
|
|
1699
|
+
scrollDelta.y = direction === KeyboardCode.Down ? scrollContainer.scrollTop - maxScroll.y : scrollContainer.scrollTop - minScroll.y;
|
|
1700
|
+
}
|
|
1701
|
+
if (scrollDelta.y) {
|
|
1702
|
+
scrollContainer.scrollBy({
|
|
1703
|
+
top: -scrollDelta.y,
|
|
1704
|
+
behavior: scrollBehavior
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
break;
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
this.handleMove(event, add(subtract(newCoordinates, this.referenceCoordinates), scrollDelta));
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
handleMove(event, coordinates) {
|
|
1715
|
+
const {
|
|
1716
|
+
onMove
|
|
1717
|
+
} = this.props;
|
|
1718
|
+
event.preventDefault();
|
|
1719
|
+
onMove(coordinates);
|
|
1720
|
+
}
|
|
1721
|
+
handleEnd(event) {
|
|
1722
|
+
const {
|
|
1723
|
+
onEnd
|
|
1724
|
+
} = this.props;
|
|
1725
|
+
event.preventDefault();
|
|
1726
|
+
this.detach();
|
|
1727
|
+
onEnd();
|
|
1728
|
+
}
|
|
1729
|
+
handleCancel(event) {
|
|
1730
|
+
const {
|
|
1731
|
+
onCancel
|
|
1732
|
+
} = this.props;
|
|
1733
|
+
event.preventDefault();
|
|
1734
|
+
this.detach();
|
|
1735
|
+
onCancel();
|
|
1736
|
+
}
|
|
1737
|
+
detach() {
|
|
1738
|
+
this.listeners.removeAll();
|
|
1739
|
+
this.windowListeners.removeAll();
|
|
1740
|
+
}
|
|
1741
|
+
};
|
|
1742
|
+
KeyboardSensor.activators = [{
|
|
1743
|
+
eventName: "onKeyDown",
|
|
1744
|
+
handler: (event, _ref, _ref2) => {
|
|
1745
|
+
let {
|
|
1746
|
+
keyboardCodes = defaultKeyboardCodes,
|
|
1747
|
+
onActivation
|
|
1748
|
+
} = _ref;
|
|
1749
|
+
let {
|
|
1750
|
+
active
|
|
1751
|
+
} = _ref2;
|
|
1752
|
+
const {
|
|
1753
|
+
code
|
|
1754
|
+
} = event.nativeEvent;
|
|
1755
|
+
if (keyboardCodes.start.includes(code)) {
|
|
1756
|
+
const activator = active.activatorNode.current;
|
|
1757
|
+
if (activator && event.target !== activator) {
|
|
1758
|
+
return false;
|
|
1759
|
+
}
|
|
1760
|
+
event.preventDefault();
|
|
1761
|
+
onActivation == null ? void 0 : onActivation({
|
|
1762
|
+
event: event.nativeEvent
|
|
1763
|
+
});
|
|
1764
|
+
return true;
|
|
1765
|
+
}
|
|
1766
|
+
return false;
|
|
1767
|
+
}
|
|
1768
|
+
}];
|
|
1769
|
+
function isDistanceConstraint(constraint) {
|
|
1770
|
+
return Boolean(constraint && "distance" in constraint);
|
|
1771
|
+
}
|
|
1772
|
+
function isDelayConstraint(constraint) {
|
|
1773
|
+
return Boolean(constraint && "delay" in constraint);
|
|
1774
|
+
}
|
|
1775
|
+
var AbstractPointerSensor = class {
|
|
1776
|
+
constructor(props, events2, listenerTarget) {
|
|
1777
|
+
var _getEventCoordinates;
|
|
1778
|
+
if (listenerTarget === void 0) {
|
|
1779
|
+
listenerTarget = getEventListenerTarget(props.event.target);
|
|
1780
|
+
}
|
|
1781
|
+
this.props = void 0;
|
|
1782
|
+
this.events = void 0;
|
|
1783
|
+
this.autoScrollEnabled = true;
|
|
1784
|
+
this.document = void 0;
|
|
1785
|
+
this.activated = false;
|
|
1786
|
+
this.initialCoordinates = void 0;
|
|
1787
|
+
this.timeoutId = null;
|
|
1788
|
+
this.listeners = void 0;
|
|
1789
|
+
this.documentListeners = void 0;
|
|
1790
|
+
this.windowListeners = void 0;
|
|
1791
|
+
this.props = props;
|
|
1792
|
+
this.events = events2;
|
|
1793
|
+
const {
|
|
1794
|
+
event
|
|
1795
|
+
} = props;
|
|
1796
|
+
const {
|
|
1797
|
+
target
|
|
1798
|
+
} = event;
|
|
1799
|
+
this.props = props;
|
|
1800
|
+
this.events = events2;
|
|
1801
|
+
this.document = getOwnerDocument(target);
|
|
1802
|
+
this.documentListeners = new Listeners(this.document);
|
|
1803
|
+
this.listeners = new Listeners(listenerTarget);
|
|
1804
|
+
this.windowListeners = new Listeners(getWindow(target));
|
|
1805
|
+
this.initialCoordinates = (_getEventCoordinates = getEventCoordinates(event)) != null ? _getEventCoordinates : defaultCoordinates;
|
|
1806
|
+
this.handleStart = this.handleStart.bind(this);
|
|
1807
|
+
this.handleMove = this.handleMove.bind(this);
|
|
1808
|
+
this.handleEnd = this.handleEnd.bind(this);
|
|
1809
|
+
this.handleCancel = this.handleCancel.bind(this);
|
|
1810
|
+
this.handleKeydown = this.handleKeydown.bind(this);
|
|
1811
|
+
this.removeTextSelection = this.removeTextSelection.bind(this);
|
|
1812
|
+
this.attach();
|
|
1813
|
+
}
|
|
1814
|
+
attach() {
|
|
1815
|
+
const {
|
|
1816
|
+
events: events2,
|
|
1817
|
+
props: {
|
|
1818
|
+
options: {
|
|
1819
|
+
activationConstraint,
|
|
1820
|
+
bypassActivationConstraint
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
} = this;
|
|
1824
|
+
this.listeners.add(events2.move.name, this.handleMove, {
|
|
1825
|
+
passive: false
|
|
1826
|
+
});
|
|
1827
|
+
this.listeners.add(events2.end.name, this.handleEnd);
|
|
1828
|
+
if (events2.cancel) {
|
|
1829
|
+
this.listeners.add(events2.cancel.name, this.handleCancel);
|
|
1830
|
+
}
|
|
1831
|
+
this.windowListeners.add(EventName.Resize, this.handleCancel);
|
|
1832
|
+
this.windowListeners.add(EventName.DragStart, preventDefault);
|
|
1833
|
+
this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
|
|
1834
|
+
this.windowListeners.add(EventName.ContextMenu, preventDefault);
|
|
1835
|
+
this.documentListeners.add(EventName.Keydown, this.handleKeydown);
|
|
1836
|
+
if (activationConstraint) {
|
|
1837
|
+
if (bypassActivationConstraint != null && bypassActivationConstraint({
|
|
1838
|
+
event: this.props.event,
|
|
1839
|
+
activeNode: this.props.activeNode,
|
|
1840
|
+
options: this.props.options
|
|
1841
|
+
})) {
|
|
1842
|
+
return this.handleStart();
|
|
1843
|
+
}
|
|
1844
|
+
if (isDelayConstraint(activationConstraint)) {
|
|
1845
|
+
this.timeoutId = setTimeout(this.handleStart, activationConstraint.delay);
|
|
1846
|
+
this.handlePending(activationConstraint);
|
|
1847
|
+
return;
|
|
1848
|
+
}
|
|
1849
|
+
if (isDistanceConstraint(activationConstraint)) {
|
|
1850
|
+
this.handlePending(activationConstraint);
|
|
1851
|
+
return;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
this.handleStart();
|
|
1855
|
+
}
|
|
1856
|
+
detach() {
|
|
1857
|
+
this.listeners.removeAll();
|
|
1858
|
+
this.windowListeners.removeAll();
|
|
1859
|
+
setTimeout(this.documentListeners.removeAll, 50);
|
|
1860
|
+
if (this.timeoutId !== null) {
|
|
1861
|
+
clearTimeout(this.timeoutId);
|
|
1862
|
+
this.timeoutId = null;
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
handlePending(constraint, offset) {
|
|
1866
|
+
const {
|
|
1867
|
+
active,
|
|
1868
|
+
onPending
|
|
1869
|
+
} = this.props;
|
|
1870
|
+
onPending(active, constraint, this.initialCoordinates, offset);
|
|
1871
|
+
}
|
|
1872
|
+
handleStart() {
|
|
1873
|
+
const {
|
|
1874
|
+
initialCoordinates
|
|
1875
|
+
} = this;
|
|
1876
|
+
const {
|
|
1877
|
+
onStart
|
|
1878
|
+
} = this.props;
|
|
1879
|
+
if (initialCoordinates) {
|
|
1880
|
+
this.activated = true;
|
|
1881
|
+
this.documentListeners.add(EventName.Click, stopPropagation, {
|
|
1882
|
+
capture: true
|
|
1883
|
+
});
|
|
1884
|
+
this.removeTextSelection();
|
|
1885
|
+
this.documentListeners.add(EventName.SelectionChange, this.removeTextSelection);
|
|
1886
|
+
onStart(initialCoordinates);
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
handleMove(event) {
|
|
1890
|
+
var _getEventCoordinates2;
|
|
1891
|
+
const {
|
|
1892
|
+
activated,
|
|
1893
|
+
initialCoordinates,
|
|
1894
|
+
props
|
|
1895
|
+
} = this;
|
|
1896
|
+
const {
|
|
1897
|
+
onMove,
|
|
1898
|
+
options: {
|
|
1899
|
+
activationConstraint
|
|
1900
|
+
}
|
|
1901
|
+
} = props;
|
|
1902
|
+
if (!initialCoordinates) {
|
|
1903
|
+
return;
|
|
1904
|
+
}
|
|
1905
|
+
const coordinates = (_getEventCoordinates2 = getEventCoordinates(event)) != null ? _getEventCoordinates2 : defaultCoordinates;
|
|
1906
|
+
const delta = subtract(initialCoordinates, coordinates);
|
|
1907
|
+
if (!activated && activationConstraint) {
|
|
1908
|
+
if (isDistanceConstraint(activationConstraint)) {
|
|
1909
|
+
if (activationConstraint.tolerance != null && hasExceededDistance(delta, activationConstraint.tolerance)) {
|
|
1910
|
+
return this.handleCancel();
|
|
1911
|
+
}
|
|
1912
|
+
if (hasExceededDistance(delta, activationConstraint.distance)) {
|
|
1913
|
+
return this.handleStart();
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
if (isDelayConstraint(activationConstraint)) {
|
|
1917
|
+
if (hasExceededDistance(delta, activationConstraint.tolerance)) {
|
|
1918
|
+
return this.handleCancel();
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
this.handlePending(activationConstraint, delta);
|
|
1922
|
+
return;
|
|
1923
|
+
}
|
|
1924
|
+
if (event.cancelable) {
|
|
1925
|
+
event.preventDefault();
|
|
1926
|
+
}
|
|
1927
|
+
onMove(coordinates);
|
|
1928
|
+
}
|
|
1929
|
+
handleEnd() {
|
|
1930
|
+
const {
|
|
1931
|
+
onAbort,
|
|
1932
|
+
onEnd
|
|
1933
|
+
} = this.props;
|
|
1934
|
+
this.detach();
|
|
1935
|
+
if (!this.activated) {
|
|
1936
|
+
onAbort(this.props.active);
|
|
1937
|
+
}
|
|
1938
|
+
onEnd();
|
|
1939
|
+
}
|
|
1940
|
+
handleCancel() {
|
|
1941
|
+
const {
|
|
1942
|
+
onAbort,
|
|
1943
|
+
onCancel
|
|
1944
|
+
} = this.props;
|
|
1945
|
+
this.detach();
|
|
1946
|
+
if (!this.activated) {
|
|
1947
|
+
onAbort(this.props.active);
|
|
1948
|
+
}
|
|
1949
|
+
onCancel();
|
|
1950
|
+
}
|
|
1951
|
+
handleKeydown(event) {
|
|
1952
|
+
if (event.code === KeyboardCode.Esc) {
|
|
1953
|
+
this.handleCancel();
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
removeTextSelection() {
|
|
1957
|
+
var _this$document$getSel;
|
|
1958
|
+
(_this$document$getSel = this.document.getSelection()) == null ? void 0 : _this$document$getSel.removeAllRanges();
|
|
1959
|
+
}
|
|
1960
|
+
};
|
|
1961
|
+
var events = {
|
|
1962
|
+
cancel: {
|
|
1963
|
+
name: "pointercancel"
|
|
1964
|
+
},
|
|
1965
|
+
move: {
|
|
1966
|
+
name: "pointermove"
|
|
1967
|
+
},
|
|
1968
|
+
end: {
|
|
1969
|
+
name: "pointerup"
|
|
1970
|
+
}
|
|
1971
|
+
};
|
|
1972
|
+
var PointerSensor = class extends AbstractPointerSensor {
|
|
1973
|
+
constructor(props) {
|
|
1974
|
+
const {
|
|
1975
|
+
event
|
|
1976
|
+
} = props;
|
|
1977
|
+
const listenerTarget = getOwnerDocument(event.target);
|
|
1978
|
+
super(props, events, listenerTarget);
|
|
1979
|
+
}
|
|
1980
|
+
};
|
|
1981
|
+
PointerSensor.activators = [{
|
|
1982
|
+
eventName: "onPointerDown",
|
|
1983
|
+
handler: (_ref, _ref2) => {
|
|
1984
|
+
let {
|
|
1985
|
+
nativeEvent: event
|
|
1986
|
+
} = _ref;
|
|
1987
|
+
let {
|
|
1988
|
+
onActivation
|
|
1989
|
+
} = _ref2;
|
|
1990
|
+
if (!event.isPrimary || event.button !== 0) {
|
|
1991
|
+
return false;
|
|
1992
|
+
}
|
|
1993
|
+
onActivation == null ? void 0 : onActivation({
|
|
1994
|
+
event
|
|
1995
|
+
});
|
|
1996
|
+
return true;
|
|
1997
|
+
}
|
|
1998
|
+
}];
|
|
1999
|
+
var events$1 = {
|
|
2000
|
+
move: {
|
|
2001
|
+
name: "mousemove"
|
|
2002
|
+
},
|
|
2003
|
+
end: {
|
|
2004
|
+
name: "mouseup"
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
var MouseButton;
|
|
2008
|
+
(function(MouseButton2) {
|
|
2009
|
+
MouseButton2[MouseButton2["RightClick"] = 2] = "RightClick";
|
|
2010
|
+
})(MouseButton || (MouseButton = {}));
|
|
2011
|
+
var MouseSensor = class extends AbstractPointerSensor {
|
|
2012
|
+
constructor(props) {
|
|
2013
|
+
super(props, events$1, getOwnerDocument(props.event.target));
|
|
2014
|
+
}
|
|
2015
|
+
};
|
|
2016
|
+
MouseSensor.activators = [{
|
|
2017
|
+
eventName: "onMouseDown",
|
|
2018
|
+
handler: (_ref, _ref2) => {
|
|
2019
|
+
let {
|
|
2020
|
+
nativeEvent: event
|
|
2021
|
+
} = _ref;
|
|
2022
|
+
let {
|
|
2023
|
+
onActivation
|
|
2024
|
+
} = _ref2;
|
|
2025
|
+
if (event.button === MouseButton.RightClick) {
|
|
2026
|
+
return false;
|
|
2027
|
+
}
|
|
2028
|
+
onActivation == null ? void 0 : onActivation({
|
|
2029
|
+
event
|
|
2030
|
+
});
|
|
2031
|
+
return true;
|
|
2032
|
+
}
|
|
2033
|
+
}];
|
|
2034
|
+
var events$2 = {
|
|
2035
|
+
cancel: {
|
|
2036
|
+
name: "touchcancel"
|
|
2037
|
+
},
|
|
2038
|
+
move: {
|
|
2039
|
+
name: "touchmove"
|
|
2040
|
+
},
|
|
2041
|
+
end: {
|
|
2042
|
+
name: "touchend"
|
|
2043
|
+
}
|
|
2044
|
+
};
|
|
2045
|
+
var TouchSensor = class extends AbstractPointerSensor {
|
|
2046
|
+
constructor(props) {
|
|
2047
|
+
super(props, events$2);
|
|
2048
|
+
}
|
|
2049
|
+
static setup() {
|
|
2050
|
+
window.addEventListener(events$2.move.name, noop2, {
|
|
2051
|
+
capture: false,
|
|
2052
|
+
passive: false
|
|
2053
|
+
});
|
|
2054
|
+
return function teardown() {
|
|
2055
|
+
window.removeEventListener(events$2.move.name, noop2);
|
|
2056
|
+
};
|
|
2057
|
+
function noop2() {
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
};
|
|
2061
|
+
TouchSensor.activators = [{
|
|
2062
|
+
eventName: "onTouchStart",
|
|
2063
|
+
handler: (_ref, _ref2) => {
|
|
2064
|
+
let {
|
|
2065
|
+
nativeEvent: event
|
|
2066
|
+
} = _ref;
|
|
2067
|
+
let {
|
|
2068
|
+
onActivation
|
|
2069
|
+
} = _ref2;
|
|
2070
|
+
const {
|
|
2071
|
+
touches
|
|
2072
|
+
} = event;
|
|
2073
|
+
if (touches.length > 1) {
|
|
2074
|
+
return false;
|
|
2075
|
+
}
|
|
2076
|
+
onActivation == null ? void 0 : onActivation({
|
|
2077
|
+
event
|
|
2078
|
+
});
|
|
2079
|
+
return true;
|
|
2080
|
+
}
|
|
2081
|
+
}];
|
|
2082
|
+
var AutoScrollActivator;
|
|
2083
|
+
(function(AutoScrollActivator2) {
|
|
2084
|
+
AutoScrollActivator2[AutoScrollActivator2["Pointer"] = 0] = "Pointer";
|
|
2085
|
+
AutoScrollActivator2[AutoScrollActivator2["DraggableRect"] = 1] = "DraggableRect";
|
|
2086
|
+
})(AutoScrollActivator || (AutoScrollActivator = {}));
|
|
2087
|
+
var TraversalOrder;
|
|
2088
|
+
(function(TraversalOrder2) {
|
|
2089
|
+
TraversalOrder2[TraversalOrder2["TreeOrder"] = 0] = "TreeOrder";
|
|
2090
|
+
TraversalOrder2[TraversalOrder2["ReversedTreeOrder"] = 1] = "ReversedTreeOrder";
|
|
2091
|
+
})(TraversalOrder || (TraversalOrder = {}));
|
|
2092
|
+
function useAutoScroller(_ref) {
|
|
2093
|
+
let {
|
|
2094
|
+
acceleration,
|
|
2095
|
+
activator = AutoScrollActivator.Pointer,
|
|
2096
|
+
canScroll,
|
|
2097
|
+
draggingRect,
|
|
2098
|
+
enabled,
|
|
2099
|
+
interval = 5,
|
|
2100
|
+
order = TraversalOrder.TreeOrder,
|
|
2101
|
+
pointerCoordinates,
|
|
2102
|
+
scrollableAncestors,
|
|
2103
|
+
scrollableAncestorRects,
|
|
2104
|
+
delta,
|
|
2105
|
+
threshold
|
|
2106
|
+
} = _ref;
|
|
2107
|
+
const scrollIntent = useScrollIntent({
|
|
2108
|
+
delta,
|
|
2109
|
+
disabled: !enabled
|
|
2110
|
+
});
|
|
2111
|
+
const [setAutoScrollInterval, clearAutoScrollInterval] = useInterval();
|
|
2112
|
+
const scrollSpeed = useRef3({
|
|
2113
|
+
x: 0,
|
|
2114
|
+
y: 0
|
|
2115
|
+
});
|
|
2116
|
+
const scrollDirection = useRef3({
|
|
2117
|
+
x: 0,
|
|
2118
|
+
y: 0
|
|
2119
|
+
});
|
|
2120
|
+
const rect = useMemo3(() => {
|
|
2121
|
+
switch (activator) {
|
|
2122
|
+
case AutoScrollActivator.Pointer:
|
|
2123
|
+
return pointerCoordinates ? {
|
|
2124
|
+
top: pointerCoordinates.y,
|
|
2125
|
+
bottom: pointerCoordinates.y,
|
|
2126
|
+
left: pointerCoordinates.x,
|
|
2127
|
+
right: pointerCoordinates.x
|
|
2128
|
+
} : null;
|
|
2129
|
+
case AutoScrollActivator.DraggableRect:
|
|
2130
|
+
return draggingRect;
|
|
2131
|
+
}
|
|
2132
|
+
}, [activator, draggingRect, pointerCoordinates]);
|
|
2133
|
+
const scrollContainerRef = useRef3(null);
|
|
2134
|
+
const autoScroll = useCallback3(() => {
|
|
2135
|
+
const scrollContainer = scrollContainerRef.current;
|
|
2136
|
+
if (!scrollContainer) {
|
|
2137
|
+
return;
|
|
2138
|
+
}
|
|
2139
|
+
const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;
|
|
2140
|
+
const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;
|
|
2141
|
+
scrollContainer.scrollBy(scrollLeft, scrollTop);
|
|
2142
|
+
}, []);
|
|
2143
|
+
const sortedScrollableAncestors = useMemo3(() => order === TraversalOrder.TreeOrder ? [...scrollableAncestors].reverse() : scrollableAncestors, [order, scrollableAncestors]);
|
|
2144
|
+
useEffect3(
|
|
2145
|
+
() => {
|
|
2146
|
+
if (!enabled || !scrollableAncestors.length || !rect) {
|
|
2147
|
+
clearAutoScrollInterval();
|
|
2148
|
+
return;
|
|
2149
|
+
}
|
|
2150
|
+
for (const scrollContainer of sortedScrollableAncestors) {
|
|
2151
|
+
if ((canScroll == null ? void 0 : canScroll(scrollContainer)) === false) {
|
|
2152
|
+
continue;
|
|
2153
|
+
}
|
|
2154
|
+
const index = scrollableAncestors.indexOf(scrollContainer);
|
|
2155
|
+
const scrollContainerRect = scrollableAncestorRects[index];
|
|
2156
|
+
if (!scrollContainerRect) {
|
|
2157
|
+
continue;
|
|
2158
|
+
}
|
|
2159
|
+
const {
|
|
2160
|
+
direction,
|
|
2161
|
+
speed
|
|
2162
|
+
} = getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, rect, acceleration, threshold);
|
|
2163
|
+
for (const axis of ["x", "y"]) {
|
|
2164
|
+
if (!scrollIntent[axis][direction[axis]]) {
|
|
2165
|
+
speed[axis] = 0;
|
|
2166
|
+
direction[axis] = 0;
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
if (speed.x > 0 || speed.y > 0) {
|
|
2170
|
+
clearAutoScrollInterval();
|
|
2171
|
+
scrollContainerRef.current = scrollContainer;
|
|
2172
|
+
setAutoScrollInterval(autoScroll, interval);
|
|
2173
|
+
scrollSpeed.current = speed;
|
|
2174
|
+
scrollDirection.current = direction;
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
scrollSpeed.current = {
|
|
2179
|
+
x: 0,
|
|
2180
|
+
y: 0
|
|
2181
|
+
};
|
|
2182
|
+
scrollDirection.current = {
|
|
2183
|
+
x: 0,
|
|
2184
|
+
y: 0
|
|
2185
|
+
};
|
|
2186
|
+
clearAutoScrollInterval();
|
|
2187
|
+
},
|
|
2188
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2189
|
+
[
|
|
2190
|
+
acceleration,
|
|
2191
|
+
autoScroll,
|
|
2192
|
+
canScroll,
|
|
2193
|
+
clearAutoScrollInterval,
|
|
2194
|
+
enabled,
|
|
2195
|
+
interval,
|
|
2196
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2197
|
+
JSON.stringify(rect),
|
|
2198
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2199
|
+
JSON.stringify(scrollIntent),
|
|
2200
|
+
setAutoScrollInterval,
|
|
2201
|
+
scrollableAncestors,
|
|
2202
|
+
sortedScrollableAncestors,
|
|
2203
|
+
scrollableAncestorRects,
|
|
2204
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2205
|
+
JSON.stringify(threshold)
|
|
2206
|
+
]
|
|
2207
|
+
);
|
|
2208
|
+
}
|
|
2209
|
+
var defaultScrollIntent = {
|
|
2210
|
+
x: {
|
|
2211
|
+
[Direction.Backward]: false,
|
|
2212
|
+
[Direction.Forward]: false
|
|
2213
|
+
},
|
|
2214
|
+
y: {
|
|
2215
|
+
[Direction.Backward]: false,
|
|
2216
|
+
[Direction.Forward]: false
|
|
2217
|
+
}
|
|
2218
|
+
};
|
|
2219
|
+
function useScrollIntent(_ref2) {
|
|
2220
|
+
let {
|
|
2221
|
+
delta,
|
|
2222
|
+
disabled
|
|
2223
|
+
} = _ref2;
|
|
2224
|
+
const previousDelta = usePrevious(delta);
|
|
2225
|
+
return useLazyMemo((previousIntent) => {
|
|
2226
|
+
if (disabled || !previousDelta || !previousIntent) {
|
|
2227
|
+
return defaultScrollIntent;
|
|
2228
|
+
}
|
|
2229
|
+
const direction = {
|
|
2230
|
+
x: Math.sign(delta.x - previousDelta.x),
|
|
2231
|
+
y: Math.sign(delta.y - previousDelta.y)
|
|
2232
|
+
};
|
|
2233
|
+
return {
|
|
2234
|
+
x: {
|
|
2235
|
+
[Direction.Backward]: previousIntent.x[Direction.Backward] || direction.x === -1,
|
|
2236
|
+
[Direction.Forward]: previousIntent.x[Direction.Forward] || direction.x === 1
|
|
2237
|
+
},
|
|
2238
|
+
y: {
|
|
2239
|
+
[Direction.Backward]: previousIntent.y[Direction.Backward] || direction.y === -1,
|
|
2240
|
+
[Direction.Forward]: previousIntent.y[Direction.Forward] || direction.y === 1
|
|
2241
|
+
}
|
|
2242
|
+
};
|
|
2243
|
+
}, [disabled, delta, previousDelta]);
|
|
2244
|
+
}
|
|
2245
|
+
function useCachedNode(draggableNodes, id) {
|
|
2246
|
+
const draggableNode = id != null ? draggableNodes.get(id) : void 0;
|
|
2247
|
+
const node = draggableNode ? draggableNode.node.current : null;
|
|
2248
|
+
return useLazyMemo((cachedNode) => {
|
|
2249
|
+
var _ref;
|
|
2250
|
+
if (id == null) {
|
|
2251
|
+
return null;
|
|
2252
|
+
}
|
|
2253
|
+
return (_ref = node != null ? node : cachedNode) != null ? _ref : null;
|
|
2254
|
+
}, [node, id]);
|
|
2255
|
+
}
|
|
2256
|
+
function useCombineActivators(sensors, getSyntheticHandler) {
|
|
2257
|
+
return useMemo3(() => sensors.reduce((accumulator, sensor) => {
|
|
2258
|
+
const {
|
|
2259
|
+
sensor: Sensor
|
|
2260
|
+
} = sensor;
|
|
2261
|
+
const sensorActivators = Sensor.activators.map((activator) => ({
|
|
2262
|
+
eventName: activator.eventName,
|
|
2263
|
+
handler: getSyntheticHandler(activator.handler, sensor)
|
|
2264
|
+
}));
|
|
2265
|
+
return [...accumulator, ...sensorActivators];
|
|
2266
|
+
}, []), [sensors, getSyntheticHandler]);
|
|
2267
|
+
}
|
|
2268
|
+
var MeasuringStrategy;
|
|
2269
|
+
(function(MeasuringStrategy2) {
|
|
2270
|
+
MeasuringStrategy2[MeasuringStrategy2["Always"] = 0] = "Always";
|
|
2271
|
+
MeasuringStrategy2[MeasuringStrategy2["BeforeDragging"] = 1] = "BeforeDragging";
|
|
2272
|
+
MeasuringStrategy2[MeasuringStrategy2["WhileDragging"] = 2] = "WhileDragging";
|
|
2273
|
+
})(MeasuringStrategy || (MeasuringStrategy = {}));
|
|
2274
|
+
var MeasuringFrequency;
|
|
2275
|
+
(function(MeasuringFrequency2) {
|
|
2276
|
+
MeasuringFrequency2["Optimized"] = "optimized";
|
|
2277
|
+
})(MeasuringFrequency || (MeasuringFrequency = {}));
|
|
2278
|
+
var defaultValue = /* @__PURE__ */ new Map();
|
|
2279
|
+
function useDroppableMeasuring(containers, _ref) {
|
|
2280
|
+
let {
|
|
2281
|
+
dragging,
|
|
2282
|
+
dependencies,
|
|
2283
|
+
config
|
|
2284
|
+
} = _ref;
|
|
2285
|
+
const [queue, setQueue] = useState3(null);
|
|
2286
|
+
const {
|
|
2287
|
+
frequency,
|
|
2288
|
+
measure,
|
|
2289
|
+
strategy
|
|
2290
|
+
} = config;
|
|
2291
|
+
const containersRef = useRef3(containers);
|
|
2292
|
+
const disabled = isDisabled();
|
|
2293
|
+
const disabledRef = useLatestValue(disabled);
|
|
2294
|
+
const measureDroppableContainers = useCallback3(function(ids2) {
|
|
2295
|
+
if (ids2 === void 0) {
|
|
2296
|
+
ids2 = [];
|
|
2297
|
+
}
|
|
2298
|
+
if (disabledRef.current) {
|
|
2299
|
+
return;
|
|
2300
|
+
}
|
|
2301
|
+
setQueue((value) => {
|
|
2302
|
+
if (value === null) {
|
|
2303
|
+
return ids2;
|
|
2304
|
+
}
|
|
2305
|
+
return value.concat(ids2.filter((id) => !value.includes(id)));
|
|
2306
|
+
});
|
|
2307
|
+
}, [disabledRef]);
|
|
2308
|
+
const timeoutId = useRef3(null);
|
|
2309
|
+
const droppableRects = useLazyMemo((previousValue) => {
|
|
2310
|
+
if (disabled && !dragging) {
|
|
2311
|
+
return defaultValue;
|
|
2312
|
+
}
|
|
2313
|
+
if (!previousValue || previousValue === defaultValue || containersRef.current !== containers || queue != null) {
|
|
2314
|
+
const map = /* @__PURE__ */ new Map();
|
|
2315
|
+
for (let container of containers) {
|
|
2316
|
+
if (!container) {
|
|
2317
|
+
continue;
|
|
2318
|
+
}
|
|
2319
|
+
if (queue && queue.length > 0 && !queue.includes(container.id) && container.rect.current) {
|
|
2320
|
+
map.set(container.id, container.rect.current);
|
|
2321
|
+
continue;
|
|
2322
|
+
}
|
|
2323
|
+
const node = container.node.current;
|
|
2324
|
+
const rect = node ? new Rect(measure(node), node) : null;
|
|
2325
|
+
container.rect.current = rect;
|
|
2326
|
+
if (rect) {
|
|
2327
|
+
map.set(container.id, rect);
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
return map;
|
|
2331
|
+
}
|
|
2332
|
+
return previousValue;
|
|
2333
|
+
}, [containers, queue, dragging, disabled, measure]);
|
|
2334
|
+
useEffect3(() => {
|
|
2335
|
+
containersRef.current = containers;
|
|
2336
|
+
}, [containers]);
|
|
2337
|
+
useEffect3(
|
|
2338
|
+
() => {
|
|
2339
|
+
if (disabled) {
|
|
2340
|
+
return;
|
|
2341
|
+
}
|
|
2342
|
+
measureDroppableContainers();
|
|
2343
|
+
},
|
|
2344
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2345
|
+
[dragging, disabled]
|
|
2346
|
+
);
|
|
2347
|
+
useEffect3(
|
|
2348
|
+
() => {
|
|
2349
|
+
if (queue && queue.length > 0) {
|
|
2350
|
+
setQueue(null);
|
|
2351
|
+
}
|
|
2352
|
+
},
|
|
2353
|
+
//eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2354
|
+
[JSON.stringify(queue)]
|
|
2355
|
+
);
|
|
2356
|
+
useEffect3(
|
|
2357
|
+
() => {
|
|
2358
|
+
if (disabled || typeof frequency !== "number" || timeoutId.current !== null) {
|
|
2359
|
+
return;
|
|
2360
|
+
}
|
|
2361
|
+
timeoutId.current = setTimeout(() => {
|
|
2362
|
+
measureDroppableContainers();
|
|
2363
|
+
timeoutId.current = null;
|
|
2364
|
+
}, frequency);
|
|
2365
|
+
},
|
|
2366
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2367
|
+
[frequency, disabled, measureDroppableContainers, ...dependencies]
|
|
2368
|
+
);
|
|
2369
|
+
return {
|
|
2370
|
+
droppableRects,
|
|
2371
|
+
measureDroppableContainers,
|
|
2372
|
+
measuringScheduled: queue != null
|
|
2373
|
+
};
|
|
2374
|
+
function isDisabled() {
|
|
2375
|
+
switch (strategy) {
|
|
2376
|
+
case MeasuringStrategy.Always:
|
|
2377
|
+
return false;
|
|
2378
|
+
case MeasuringStrategy.BeforeDragging:
|
|
2379
|
+
return dragging;
|
|
2380
|
+
default:
|
|
2381
|
+
return !dragging;
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
function useInitialValue(value, computeFn) {
|
|
2386
|
+
return useLazyMemo((previousValue) => {
|
|
2387
|
+
if (!value) {
|
|
2388
|
+
return null;
|
|
2389
|
+
}
|
|
2390
|
+
if (previousValue) {
|
|
2391
|
+
return previousValue;
|
|
2392
|
+
}
|
|
2393
|
+
return typeof computeFn === "function" ? computeFn(value) : value;
|
|
2394
|
+
}, [computeFn, value]);
|
|
2395
|
+
}
|
|
2396
|
+
function useInitialRect(node, measure) {
|
|
2397
|
+
return useInitialValue(node, measure);
|
|
2398
|
+
}
|
|
2399
|
+
function useMutationObserver(_ref) {
|
|
2400
|
+
let {
|
|
2401
|
+
callback,
|
|
2402
|
+
disabled
|
|
2403
|
+
} = _ref;
|
|
2404
|
+
const handleMutations = useEvent(callback);
|
|
2405
|
+
const mutationObserver = useMemo3(() => {
|
|
2406
|
+
if (disabled || typeof window === "undefined" || typeof window.MutationObserver === "undefined") {
|
|
2407
|
+
return void 0;
|
|
2408
|
+
}
|
|
2409
|
+
const {
|
|
2410
|
+
MutationObserver
|
|
2411
|
+
} = window;
|
|
2412
|
+
return new MutationObserver(handleMutations);
|
|
2413
|
+
}, [handleMutations, disabled]);
|
|
2414
|
+
useEffect3(() => {
|
|
2415
|
+
return () => mutationObserver == null ? void 0 : mutationObserver.disconnect();
|
|
2416
|
+
}, [mutationObserver]);
|
|
2417
|
+
return mutationObserver;
|
|
2418
|
+
}
|
|
2419
|
+
function useResizeObserver(_ref) {
|
|
2420
|
+
let {
|
|
2421
|
+
callback,
|
|
2422
|
+
disabled
|
|
2423
|
+
} = _ref;
|
|
2424
|
+
const handleResize = useEvent(callback);
|
|
2425
|
+
const resizeObserver = useMemo3(
|
|
2426
|
+
() => {
|
|
2427
|
+
if (disabled || typeof window === "undefined" || typeof window.ResizeObserver === "undefined") {
|
|
2428
|
+
return void 0;
|
|
2429
|
+
}
|
|
2430
|
+
const {
|
|
2431
|
+
ResizeObserver
|
|
2432
|
+
} = window;
|
|
2433
|
+
return new ResizeObserver(handleResize);
|
|
2434
|
+
},
|
|
2435
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2436
|
+
[disabled]
|
|
2437
|
+
);
|
|
2438
|
+
useEffect3(() => {
|
|
2439
|
+
return () => resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
2440
|
+
}, [resizeObserver]);
|
|
2441
|
+
return resizeObserver;
|
|
2442
|
+
}
|
|
2443
|
+
function defaultMeasure(element) {
|
|
2444
|
+
return new Rect(getClientRect(element), element);
|
|
2445
|
+
}
|
|
2446
|
+
function useRect(element, measure, fallbackRect) {
|
|
2447
|
+
if (measure === void 0) {
|
|
2448
|
+
measure = defaultMeasure;
|
|
2449
|
+
}
|
|
2450
|
+
const [rect, setRect] = useState3(null);
|
|
2451
|
+
function measureRect() {
|
|
2452
|
+
setRect((currentRect) => {
|
|
2453
|
+
if (!element) {
|
|
2454
|
+
return null;
|
|
2455
|
+
}
|
|
2456
|
+
if (element.isConnected === false) {
|
|
2457
|
+
var _ref;
|
|
2458
|
+
return (_ref = currentRect != null ? currentRect : fallbackRect) != null ? _ref : null;
|
|
2459
|
+
}
|
|
2460
|
+
const newRect = measure(element);
|
|
2461
|
+
if (JSON.stringify(currentRect) === JSON.stringify(newRect)) {
|
|
2462
|
+
return currentRect;
|
|
2463
|
+
}
|
|
2464
|
+
return newRect;
|
|
2465
|
+
});
|
|
2466
|
+
}
|
|
2467
|
+
const mutationObserver = useMutationObserver({
|
|
2468
|
+
callback(records) {
|
|
2469
|
+
if (!element) {
|
|
2470
|
+
return;
|
|
2471
|
+
}
|
|
2472
|
+
for (const record of records) {
|
|
2473
|
+
const {
|
|
2474
|
+
type,
|
|
2475
|
+
target
|
|
2476
|
+
} = record;
|
|
2477
|
+
if (type === "childList" && target instanceof HTMLElement && target.contains(element)) {
|
|
2478
|
+
measureRect();
|
|
2479
|
+
break;
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
}
|
|
2483
|
+
});
|
|
2484
|
+
const resizeObserver = useResizeObserver({
|
|
2485
|
+
callback: measureRect
|
|
2486
|
+
});
|
|
2487
|
+
useIsomorphicLayoutEffect(() => {
|
|
2488
|
+
measureRect();
|
|
2489
|
+
if (element) {
|
|
2490
|
+
resizeObserver == null ? void 0 : resizeObserver.observe(element);
|
|
2491
|
+
mutationObserver == null ? void 0 : mutationObserver.observe(document.body, {
|
|
2492
|
+
childList: true,
|
|
2493
|
+
subtree: true
|
|
2494
|
+
});
|
|
2495
|
+
} else {
|
|
2496
|
+
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
2497
|
+
mutationObserver == null ? void 0 : mutationObserver.disconnect();
|
|
2498
|
+
}
|
|
2499
|
+
}, [element]);
|
|
2500
|
+
return rect;
|
|
2501
|
+
}
|
|
2502
|
+
function useRectDelta(rect) {
|
|
2503
|
+
const initialRect = useInitialValue(rect);
|
|
2504
|
+
return getRectDelta(rect, initialRect);
|
|
2505
|
+
}
|
|
2506
|
+
var defaultValue$1 = [];
|
|
2507
|
+
function useScrollableAncestors(node) {
|
|
2508
|
+
const previousNode = useRef3(node);
|
|
2509
|
+
const ancestors = useLazyMemo((previousValue) => {
|
|
2510
|
+
if (!node) {
|
|
2511
|
+
return defaultValue$1;
|
|
2512
|
+
}
|
|
2513
|
+
if (previousValue && previousValue !== defaultValue$1 && node && previousNode.current && node.parentNode === previousNode.current.parentNode) {
|
|
2514
|
+
return previousValue;
|
|
2515
|
+
}
|
|
2516
|
+
return getScrollableAncestors(node);
|
|
2517
|
+
}, [node]);
|
|
2518
|
+
useEffect3(() => {
|
|
2519
|
+
previousNode.current = node;
|
|
2520
|
+
}, [node]);
|
|
2521
|
+
return ancestors;
|
|
2522
|
+
}
|
|
2523
|
+
function useScrollOffsets(elements) {
|
|
2524
|
+
const [scrollCoordinates, setScrollCoordinates] = useState3(null);
|
|
2525
|
+
const prevElements = useRef3(elements);
|
|
2526
|
+
const handleScroll = useCallback3((event) => {
|
|
2527
|
+
const scrollingElement = getScrollableElement(event.target);
|
|
2528
|
+
if (!scrollingElement) {
|
|
2529
|
+
return;
|
|
2530
|
+
}
|
|
2531
|
+
setScrollCoordinates((scrollCoordinates2) => {
|
|
2532
|
+
if (!scrollCoordinates2) {
|
|
2533
|
+
return null;
|
|
2534
|
+
}
|
|
2535
|
+
scrollCoordinates2.set(scrollingElement, getScrollCoordinates(scrollingElement));
|
|
2536
|
+
return new Map(scrollCoordinates2);
|
|
2537
|
+
});
|
|
2538
|
+
}, []);
|
|
2539
|
+
useEffect3(() => {
|
|
2540
|
+
const previousElements = prevElements.current;
|
|
2541
|
+
if (elements !== previousElements) {
|
|
2542
|
+
cleanup(previousElements);
|
|
2543
|
+
const entries = elements.map((element) => {
|
|
2544
|
+
const scrollableElement = getScrollableElement(element);
|
|
2545
|
+
if (scrollableElement) {
|
|
2546
|
+
scrollableElement.addEventListener("scroll", handleScroll, {
|
|
2547
|
+
passive: true
|
|
2548
|
+
});
|
|
2549
|
+
return [scrollableElement, getScrollCoordinates(scrollableElement)];
|
|
2550
|
+
}
|
|
2551
|
+
return null;
|
|
2552
|
+
}).filter((entry) => entry != null);
|
|
2553
|
+
setScrollCoordinates(entries.length ? new Map(entries) : null);
|
|
2554
|
+
prevElements.current = elements;
|
|
2555
|
+
}
|
|
2556
|
+
return () => {
|
|
2557
|
+
cleanup(elements);
|
|
2558
|
+
cleanup(previousElements);
|
|
2559
|
+
};
|
|
2560
|
+
function cleanup(elements2) {
|
|
2561
|
+
elements2.forEach((element) => {
|
|
2562
|
+
const scrollableElement = getScrollableElement(element);
|
|
2563
|
+
scrollableElement == null ? void 0 : scrollableElement.removeEventListener("scroll", handleScroll);
|
|
2564
|
+
});
|
|
2565
|
+
}
|
|
2566
|
+
}, [handleScroll, elements]);
|
|
2567
|
+
return useMemo3(() => {
|
|
2568
|
+
if (elements.length) {
|
|
2569
|
+
return scrollCoordinates ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => add(acc, coordinates), defaultCoordinates) : getScrollOffsets(elements);
|
|
2570
|
+
}
|
|
2571
|
+
return defaultCoordinates;
|
|
2572
|
+
}, [elements, scrollCoordinates]);
|
|
2573
|
+
}
|
|
2574
|
+
function useScrollOffsetsDelta(scrollOffsets, dependencies) {
|
|
2575
|
+
if (dependencies === void 0) {
|
|
2576
|
+
dependencies = [];
|
|
2577
|
+
}
|
|
2578
|
+
const initialScrollOffsets = useRef3(null);
|
|
2579
|
+
useEffect3(
|
|
2580
|
+
() => {
|
|
2581
|
+
initialScrollOffsets.current = null;
|
|
2582
|
+
},
|
|
2583
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2584
|
+
dependencies
|
|
2585
|
+
);
|
|
2586
|
+
useEffect3(() => {
|
|
2587
|
+
const hasScrollOffsets = scrollOffsets !== defaultCoordinates;
|
|
2588
|
+
if (hasScrollOffsets && !initialScrollOffsets.current) {
|
|
2589
|
+
initialScrollOffsets.current = scrollOffsets;
|
|
2590
|
+
}
|
|
2591
|
+
if (!hasScrollOffsets && initialScrollOffsets.current) {
|
|
2592
|
+
initialScrollOffsets.current = null;
|
|
2593
|
+
}
|
|
2594
|
+
}, [scrollOffsets]);
|
|
2595
|
+
return initialScrollOffsets.current ? subtract(scrollOffsets, initialScrollOffsets.current) : defaultCoordinates;
|
|
2596
|
+
}
|
|
2597
|
+
function useSensorSetup(sensors) {
|
|
2598
|
+
useEffect3(
|
|
2599
|
+
() => {
|
|
2600
|
+
if (!canUseDOM) {
|
|
2601
|
+
return;
|
|
2602
|
+
}
|
|
2603
|
+
const teardownFns = sensors.map((_ref) => {
|
|
2604
|
+
let {
|
|
2605
|
+
sensor
|
|
2606
|
+
} = _ref;
|
|
2607
|
+
return sensor.setup == null ? void 0 : sensor.setup();
|
|
2608
|
+
});
|
|
2609
|
+
return () => {
|
|
2610
|
+
for (const teardown of teardownFns) {
|
|
2611
|
+
teardown == null ? void 0 : teardown();
|
|
2612
|
+
}
|
|
2613
|
+
};
|
|
2614
|
+
},
|
|
2615
|
+
// TO-DO: Sensors length could theoretically change which would not be a valid dependency
|
|
2616
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2617
|
+
sensors.map((_ref2) => {
|
|
2618
|
+
let {
|
|
2619
|
+
sensor
|
|
2620
|
+
} = _ref2;
|
|
2621
|
+
return sensor;
|
|
2622
|
+
})
|
|
2623
|
+
);
|
|
2624
|
+
}
|
|
2625
|
+
function useSyntheticListeners(listeners, id) {
|
|
2626
|
+
return useMemo3(() => {
|
|
2627
|
+
return listeners.reduce((acc, _ref) => {
|
|
2628
|
+
let {
|
|
2629
|
+
eventName,
|
|
2630
|
+
handler
|
|
2631
|
+
} = _ref;
|
|
2632
|
+
acc[eventName] = (event) => {
|
|
2633
|
+
handler(event, id);
|
|
2634
|
+
};
|
|
2635
|
+
return acc;
|
|
2636
|
+
}, {});
|
|
2637
|
+
}, [listeners, id]);
|
|
2638
|
+
}
|
|
2639
|
+
function useWindowRect(element) {
|
|
2640
|
+
return useMemo3(() => element ? getWindowClientRect(element) : null, [element]);
|
|
2641
|
+
}
|
|
2642
|
+
var defaultValue$2 = [];
|
|
2643
|
+
function useRects(elements, measure) {
|
|
2644
|
+
if (measure === void 0) {
|
|
2645
|
+
measure = getClientRect;
|
|
2646
|
+
}
|
|
2647
|
+
const [firstElement] = elements;
|
|
2648
|
+
const windowRect = useWindowRect(firstElement ? getWindow(firstElement) : null);
|
|
2649
|
+
const [rects, setRects] = useState3(defaultValue$2);
|
|
2650
|
+
function measureRects() {
|
|
2651
|
+
setRects(() => {
|
|
2652
|
+
if (!elements.length) {
|
|
2653
|
+
return defaultValue$2;
|
|
2654
|
+
}
|
|
2655
|
+
return elements.map((element) => isDocumentScrollingElement(element) ? windowRect : new Rect(measure(element), element));
|
|
2656
|
+
});
|
|
2657
|
+
}
|
|
2658
|
+
const resizeObserver = useResizeObserver({
|
|
2659
|
+
callback: measureRects
|
|
2660
|
+
});
|
|
2661
|
+
useIsomorphicLayoutEffect(() => {
|
|
2662
|
+
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
2663
|
+
measureRects();
|
|
2664
|
+
elements.forEach((element) => resizeObserver == null ? void 0 : resizeObserver.observe(element));
|
|
2665
|
+
}, [elements]);
|
|
2666
|
+
return rects;
|
|
2667
|
+
}
|
|
2668
|
+
function getMeasurableNode(node) {
|
|
2669
|
+
if (!node) {
|
|
2670
|
+
return null;
|
|
2671
|
+
}
|
|
2672
|
+
if (node.children.length > 1) {
|
|
2673
|
+
return node;
|
|
2674
|
+
}
|
|
2675
|
+
const firstChild = node.children[0];
|
|
2676
|
+
return isHTMLElement(firstChild) ? firstChild : node;
|
|
2677
|
+
}
|
|
2678
|
+
function useDragOverlayMeasuring(_ref) {
|
|
2679
|
+
let {
|
|
2680
|
+
measure
|
|
2681
|
+
} = _ref;
|
|
2682
|
+
const [rect, setRect] = useState3(null);
|
|
2683
|
+
const handleResize = useCallback3((entries) => {
|
|
2684
|
+
for (const {
|
|
2685
|
+
target
|
|
2686
|
+
} of entries) {
|
|
2687
|
+
if (isHTMLElement(target)) {
|
|
2688
|
+
setRect((rect2) => {
|
|
2689
|
+
const newRect = measure(target);
|
|
2690
|
+
return rect2 ? {
|
|
2691
|
+
...rect2,
|
|
2692
|
+
width: newRect.width,
|
|
2693
|
+
height: newRect.height
|
|
2694
|
+
} : newRect;
|
|
2695
|
+
});
|
|
2696
|
+
break;
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
}, [measure]);
|
|
2700
|
+
const resizeObserver = useResizeObserver({
|
|
2701
|
+
callback: handleResize
|
|
2702
|
+
});
|
|
2703
|
+
const handleNodeChange = useCallback3((element) => {
|
|
2704
|
+
const node = getMeasurableNode(element);
|
|
2705
|
+
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
2706
|
+
if (node) {
|
|
2707
|
+
resizeObserver == null ? void 0 : resizeObserver.observe(node);
|
|
2708
|
+
}
|
|
2709
|
+
setRect(node ? measure(node) : null);
|
|
2710
|
+
}, [measure, resizeObserver]);
|
|
2711
|
+
const [nodeRef, setRef] = useNodeRef(handleNodeChange);
|
|
2712
|
+
return useMemo3(() => ({
|
|
2713
|
+
nodeRef,
|
|
2714
|
+
rect,
|
|
2715
|
+
setRef
|
|
2716
|
+
}), [rect, nodeRef, setRef]);
|
|
2717
|
+
}
|
|
2718
|
+
var defaultSensors = [{
|
|
2719
|
+
sensor: PointerSensor,
|
|
2720
|
+
options: {}
|
|
2721
|
+
}, {
|
|
2722
|
+
sensor: KeyboardSensor,
|
|
2723
|
+
options: {}
|
|
2724
|
+
}];
|
|
2725
|
+
var defaultData = {
|
|
2726
|
+
current: {}
|
|
2727
|
+
};
|
|
2728
|
+
var defaultMeasuringConfiguration = {
|
|
2729
|
+
draggable: {
|
|
2730
|
+
measure: getTransformAgnosticClientRect
|
|
2731
|
+
},
|
|
2732
|
+
droppable: {
|
|
2733
|
+
measure: getTransformAgnosticClientRect,
|
|
2734
|
+
strategy: MeasuringStrategy.WhileDragging,
|
|
2735
|
+
frequency: MeasuringFrequency.Optimized
|
|
2736
|
+
},
|
|
2737
|
+
dragOverlay: {
|
|
2738
|
+
measure: getClientRect
|
|
2739
|
+
}
|
|
2740
|
+
};
|
|
2741
|
+
var DroppableContainersMap = class extends Map {
|
|
2742
|
+
get(id) {
|
|
2743
|
+
var _super$get;
|
|
2744
|
+
return id != null ? (_super$get = super.get(id)) != null ? _super$get : void 0 : void 0;
|
|
2745
|
+
}
|
|
2746
|
+
toArray() {
|
|
2747
|
+
return Array.from(this.values());
|
|
2748
|
+
}
|
|
2749
|
+
getEnabled() {
|
|
2750
|
+
return this.toArray().filter((_ref) => {
|
|
2751
|
+
let {
|
|
2752
|
+
disabled
|
|
2753
|
+
} = _ref;
|
|
2754
|
+
return !disabled;
|
|
2755
|
+
});
|
|
2756
|
+
}
|
|
2757
|
+
getNodeFor(id) {
|
|
2758
|
+
var _this$get$node$curren, _this$get;
|
|
2759
|
+
return (_this$get$node$curren = (_this$get = this.get(id)) == null ? void 0 : _this$get.node.current) != null ? _this$get$node$curren : void 0;
|
|
2760
|
+
}
|
|
2761
|
+
};
|
|
2762
|
+
var defaultPublicContext = {
|
|
2763
|
+
activatorEvent: null,
|
|
2764
|
+
active: null,
|
|
2765
|
+
activeNode: null,
|
|
2766
|
+
activeNodeRect: null,
|
|
2767
|
+
collisions: null,
|
|
2768
|
+
containerNodeRect: null,
|
|
2769
|
+
draggableNodes: /* @__PURE__ */ new Map(),
|
|
2770
|
+
droppableRects: /* @__PURE__ */ new Map(),
|
|
2771
|
+
droppableContainers: /* @__PURE__ */ new DroppableContainersMap(),
|
|
2772
|
+
over: null,
|
|
2773
|
+
dragOverlay: {
|
|
2774
|
+
nodeRef: {
|
|
2775
|
+
current: null
|
|
2776
|
+
},
|
|
2777
|
+
rect: null,
|
|
2778
|
+
setRef: noop
|
|
2779
|
+
},
|
|
2780
|
+
scrollableAncestors: [],
|
|
2781
|
+
scrollableAncestorRects: [],
|
|
2782
|
+
measuringConfiguration: defaultMeasuringConfiguration,
|
|
2783
|
+
measureDroppableContainers: noop,
|
|
2784
|
+
windowRect: null,
|
|
2785
|
+
measuringScheduled: false
|
|
2786
|
+
};
|
|
2787
|
+
var defaultInternalContext = {
|
|
2788
|
+
activatorEvent: null,
|
|
2789
|
+
activators: [],
|
|
2790
|
+
active: null,
|
|
2791
|
+
activeNodeRect: null,
|
|
2792
|
+
ariaDescribedById: {
|
|
2793
|
+
draggable: ""
|
|
2794
|
+
},
|
|
2795
|
+
dispatch: noop,
|
|
2796
|
+
draggableNodes: /* @__PURE__ */ new Map(),
|
|
2797
|
+
over: null,
|
|
2798
|
+
measureDroppableContainers: noop
|
|
2799
|
+
};
|
|
2800
|
+
var InternalContext = /* @__PURE__ */ createContext(defaultInternalContext);
|
|
2801
|
+
var PublicContext = /* @__PURE__ */ createContext(defaultPublicContext);
|
|
2802
|
+
function getInitialState() {
|
|
2803
|
+
return {
|
|
2804
|
+
draggable: {
|
|
2805
|
+
active: null,
|
|
2806
|
+
initialCoordinates: {
|
|
2807
|
+
x: 0,
|
|
2808
|
+
y: 0
|
|
2809
|
+
},
|
|
2810
|
+
nodes: /* @__PURE__ */ new Map(),
|
|
2811
|
+
translate: {
|
|
2812
|
+
x: 0,
|
|
2813
|
+
y: 0
|
|
2814
|
+
}
|
|
2815
|
+
},
|
|
2816
|
+
droppable: {
|
|
2817
|
+
containers: new DroppableContainersMap()
|
|
2818
|
+
}
|
|
2819
|
+
};
|
|
2820
|
+
}
|
|
2821
|
+
function reducer(state, action) {
|
|
2822
|
+
switch (action.type) {
|
|
2823
|
+
case Action.DragStart:
|
|
2824
|
+
return {
|
|
2825
|
+
...state,
|
|
2826
|
+
draggable: {
|
|
2827
|
+
...state.draggable,
|
|
2828
|
+
initialCoordinates: action.initialCoordinates,
|
|
2829
|
+
active: action.active
|
|
2830
|
+
}
|
|
2831
|
+
};
|
|
2832
|
+
case Action.DragMove:
|
|
2833
|
+
if (state.draggable.active == null) {
|
|
2834
|
+
return state;
|
|
2835
|
+
}
|
|
2836
|
+
return {
|
|
2837
|
+
...state,
|
|
2838
|
+
draggable: {
|
|
2839
|
+
...state.draggable,
|
|
2840
|
+
translate: {
|
|
2841
|
+
x: action.coordinates.x - state.draggable.initialCoordinates.x,
|
|
2842
|
+
y: action.coordinates.y - state.draggable.initialCoordinates.y
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
};
|
|
2846
|
+
case Action.DragEnd:
|
|
2847
|
+
case Action.DragCancel:
|
|
2848
|
+
return {
|
|
2849
|
+
...state,
|
|
2850
|
+
draggable: {
|
|
2851
|
+
...state.draggable,
|
|
2852
|
+
active: null,
|
|
2853
|
+
initialCoordinates: {
|
|
2854
|
+
x: 0,
|
|
2855
|
+
y: 0
|
|
2856
|
+
},
|
|
2857
|
+
translate: {
|
|
2858
|
+
x: 0,
|
|
2859
|
+
y: 0
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
};
|
|
2863
|
+
case Action.RegisterDroppable: {
|
|
2864
|
+
const {
|
|
2865
|
+
element
|
|
2866
|
+
} = action;
|
|
2867
|
+
const {
|
|
2868
|
+
id
|
|
2869
|
+
} = element;
|
|
2870
|
+
const containers = new DroppableContainersMap(state.droppable.containers);
|
|
2871
|
+
containers.set(id, element);
|
|
2872
|
+
return {
|
|
2873
|
+
...state,
|
|
2874
|
+
droppable: {
|
|
2875
|
+
...state.droppable,
|
|
2876
|
+
containers
|
|
2877
|
+
}
|
|
2878
|
+
};
|
|
2879
|
+
}
|
|
2880
|
+
case Action.SetDroppableDisabled: {
|
|
2881
|
+
const {
|
|
2882
|
+
id,
|
|
2883
|
+
key,
|
|
2884
|
+
disabled
|
|
2885
|
+
} = action;
|
|
2886
|
+
const element = state.droppable.containers.get(id);
|
|
2887
|
+
if (!element || key !== element.key) {
|
|
2888
|
+
return state;
|
|
2889
|
+
}
|
|
2890
|
+
const containers = new DroppableContainersMap(state.droppable.containers);
|
|
2891
|
+
containers.set(id, {
|
|
2892
|
+
...element,
|
|
2893
|
+
disabled
|
|
2894
|
+
});
|
|
2895
|
+
return {
|
|
2896
|
+
...state,
|
|
2897
|
+
droppable: {
|
|
2898
|
+
...state.droppable,
|
|
2899
|
+
containers
|
|
2900
|
+
}
|
|
2901
|
+
};
|
|
2902
|
+
}
|
|
2903
|
+
case Action.UnregisterDroppable: {
|
|
2904
|
+
const {
|
|
2905
|
+
id,
|
|
2906
|
+
key
|
|
2907
|
+
} = action;
|
|
2908
|
+
const element = state.droppable.containers.get(id);
|
|
2909
|
+
if (!element || key !== element.key) {
|
|
2910
|
+
return state;
|
|
2911
|
+
}
|
|
2912
|
+
const containers = new DroppableContainersMap(state.droppable.containers);
|
|
2913
|
+
containers.delete(id);
|
|
2914
|
+
return {
|
|
2915
|
+
...state,
|
|
2916
|
+
droppable: {
|
|
2917
|
+
...state.droppable,
|
|
2918
|
+
containers
|
|
2919
|
+
}
|
|
2920
|
+
};
|
|
2921
|
+
}
|
|
2922
|
+
default: {
|
|
2923
|
+
return state;
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2927
|
+
function RestoreFocus(_ref) {
|
|
2928
|
+
let {
|
|
2929
|
+
disabled
|
|
2930
|
+
} = _ref;
|
|
2931
|
+
const {
|
|
2932
|
+
active,
|
|
2933
|
+
activatorEvent,
|
|
2934
|
+
draggableNodes
|
|
2935
|
+
} = useContext(InternalContext);
|
|
2936
|
+
const previousActivatorEvent = usePrevious(activatorEvent);
|
|
2937
|
+
const previousActiveId = usePrevious(active == null ? void 0 : active.id);
|
|
2938
|
+
useEffect3(() => {
|
|
2939
|
+
if (disabled) {
|
|
2940
|
+
return;
|
|
2941
|
+
}
|
|
2942
|
+
if (!activatorEvent && previousActivatorEvent && previousActiveId != null) {
|
|
2943
|
+
if (!isKeyboardEvent(previousActivatorEvent)) {
|
|
2944
|
+
return;
|
|
2945
|
+
}
|
|
2946
|
+
if (document.activeElement === previousActivatorEvent.target) {
|
|
2947
|
+
return;
|
|
2948
|
+
}
|
|
2949
|
+
const draggableNode = draggableNodes.get(previousActiveId);
|
|
2950
|
+
if (!draggableNode) {
|
|
2951
|
+
return;
|
|
2952
|
+
}
|
|
2953
|
+
const {
|
|
2954
|
+
activatorNode,
|
|
2955
|
+
node
|
|
2956
|
+
} = draggableNode;
|
|
2957
|
+
if (!activatorNode.current && !node.current) {
|
|
2958
|
+
return;
|
|
2959
|
+
}
|
|
2960
|
+
requestAnimationFrame(() => {
|
|
2961
|
+
for (const element of [activatorNode.current, node.current]) {
|
|
2962
|
+
if (!element) {
|
|
2963
|
+
continue;
|
|
2964
|
+
}
|
|
2965
|
+
const focusableNode = findFirstFocusableNode(element);
|
|
2966
|
+
if (focusableNode) {
|
|
2967
|
+
focusableNode.focus();
|
|
2968
|
+
break;
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
});
|
|
2972
|
+
}
|
|
2973
|
+
}, [activatorEvent, disabled, draggableNodes, previousActiveId, previousActivatorEvent]);
|
|
2974
|
+
return null;
|
|
2975
|
+
}
|
|
2976
|
+
function applyModifiers(modifiers, _ref) {
|
|
2977
|
+
let {
|
|
2978
|
+
transform,
|
|
2979
|
+
...args
|
|
2980
|
+
} = _ref;
|
|
2981
|
+
return modifiers != null && modifiers.length ? modifiers.reduce((accumulator, modifier) => {
|
|
2982
|
+
return modifier({
|
|
2983
|
+
transform: accumulator,
|
|
2984
|
+
...args
|
|
2985
|
+
});
|
|
2986
|
+
}, transform) : transform;
|
|
2987
|
+
}
|
|
2988
|
+
function useMeasuringConfiguration(config) {
|
|
2989
|
+
return useMemo3(
|
|
2990
|
+
() => ({
|
|
2991
|
+
draggable: {
|
|
2992
|
+
...defaultMeasuringConfiguration.draggable,
|
|
2993
|
+
...config == null ? void 0 : config.draggable
|
|
2994
|
+
},
|
|
2995
|
+
droppable: {
|
|
2996
|
+
...defaultMeasuringConfiguration.droppable,
|
|
2997
|
+
...config == null ? void 0 : config.droppable
|
|
2998
|
+
},
|
|
2999
|
+
dragOverlay: {
|
|
3000
|
+
...defaultMeasuringConfiguration.dragOverlay,
|
|
3001
|
+
...config == null ? void 0 : config.dragOverlay
|
|
3002
|
+
}
|
|
3003
|
+
}),
|
|
3004
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3005
|
+
[config == null ? void 0 : config.draggable, config == null ? void 0 : config.droppable, config == null ? void 0 : config.dragOverlay]
|
|
3006
|
+
);
|
|
3007
|
+
}
|
|
3008
|
+
function useLayoutShiftScrollCompensation(_ref) {
|
|
3009
|
+
let {
|
|
3010
|
+
activeNode,
|
|
3011
|
+
measure,
|
|
3012
|
+
initialRect,
|
|
3013
|
+
config = true
|
|
3014
|
+
} = _ref;
|
|
3015
|
+
const initialized = useRef3(false);
|
|
3016
|
+
const {
|
|
3017
|
+
x,
|
|
3018
|
+
y
|
|
3019
|
+
} = typeof config === "boolean" ? {
|
|
3020
|
+
x: config,
|
|
3021
|
+
y: config
|
|
3022
|
+
} : config;
|
|
3023
|
+
useIsomorphicLayoutEffect(() => {
|
|
3024
|
+
const disabled = !x && !y;
|
|
3025
|
+
if (disabled || !activeNode) {
|
|
3026
|
+
initialized.current = false;
|
|
3027
|
+
return;
|
|
3028
|
+
}
|
|
3029
|
+
if (initialized.current || !initialRect) {
|
|
3030
|
+
return;
|
|
3031
|
+
}
|
|
3032
|
+
const node = activeNode == null ? void 0 : activeNode.node.current;
|
|
3033
|
+
if (!node || node.isConnected === false) {
|
|
3034
|
+
return;
|
|
3035
|
+
}
|
|
3036
|
+
const rect = measure(node);
|
|
3037
|
+
const rectDelta = getRectDelta(rect, initialRect);
|
|
3038
|
+
if (!x) {
|
|
3039
|
+
rectDelta.x = 0;
|
|
3040
|
+
}
|
|
3041
|
+
if (!y) {
|
|
3042
|
+
rectDelta.y = 0;
|
|
3043
|
+
}
|
|
3044
|
+
initialized.current = true;
|
|
3045
|
+
if (Math.abs(rectDelta.x) > 0 || Math.abs(rectDelta.y) > 0) {
|
|
3046
|
+
const firstScrollableAncestor = getFirstScrollableAncestor(node);
|
|
3047
|
+
if (firstScrollableAncestor) {
|
|
3048
|
+
firstScrollableAncestor.scrollBy({
|
|
3049
|
+
top: rectDelta.y,
|
|
3050
|
+
left: rectDelta.x
|
|
3051
|
+
});
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
}, [activeNode, x, y, initialRect, measure]);
|
|
3055
|
+
}
|
|
3056
|
+
var ActiveDraggableContext = /* @__PURE__ */ createContext({
|
|
3057
|
+
...defaultCoordinates,
|
|
3058
|
+
scaleX: 1,
|
|
3059
|
+
scaleY: 1
|
|
3060
|
+
});
|
|
3061
|
+
var Status;
|
|
3062
|
+
(function(Status2) {
|
|
3063
|
+
Status2[Status2["Uninitialized"] = 0] = "Uninitialized";
|
|
3064
|
+
Status2[Status2["Initializing"] = 1] = "Initializing";
|
|
3065
|
+
Status2[Status2["Initialized"] = 2] = "Initialized";
|
|
3066
|
+
})(Status || (Status = {}));
|
|
3067
|
+
var DndContext = /* @__PURE__ */ memo(function DndContext2(_ref) {
|
|
3068
|
+
var _sensorContext$curren, _dragOverlay$nodeRef$, _dragOverlay$rect, _over$rect;
|
|
3069
|
+
let {
|
|
3070
|
+
id,
|
|
3071
|
+
accessibility,
|
|
3072
|
+
autoScroll = true,
|
|
3073
|
+
children,
|
|
3074
|
+
sensors = defaultSensors,
|
|
3075
|
+
collisionDetection = rectIntersection,
|
|
3076
|
+
measuring,
|
|
3077
|
+
modifiers,
|
|
3078
|
+
...props
|
|
3079
|
+
} = _ref;
|
|
3080
|
+
const store = useReducer(reducer, void 0, getInitialState);
|
|
3081
|
+
const [state, dispatch] = store;
|
|
3082
|
+
const [dispatchMonitorEvent, registerMonitorListener] = useDndMonitorProvider();
|
|
3083
|
+
const [status, setStatus] = useState3(Status.Uninitialized);
|
|
3084
|
+
const isInitialized = status === Status.Initialized;
|
|
3085
|
+
const {
|
|
3086
|
+
draggable: {
|
|
3087
|
+
active: activeId,
|
|
3088
|
+
nodes: draggableNodes,
|
|
3089
|
+
translate
|
|
3090
|
+
},
|
|
3091
|
+
droppable: {
|
|
3092
|
+
containers: droppableContainers
|
|
3093
|
+
}
|
|
3094
|
+
} = state;
|
|
3095
|
+
const node = activeId != null ? draggableNodes.get(activeId) : null;
|
|
3096
|
+
const activeRects = useRef3({
|
|
3097
|
+
initial: null,
|
|
3098
|
+
translated: null
|
|
3099
|
+
});
|
|
3100
|
+
const active = useMemo3(() => {
|
|
3101
|
+
var _node$data;
|
|
3102
|
+
return activeId != null ? {
|
|
3103
|
+
id: activeId,
|
|
3104
|
+
// It's possible for the active node to unmount while dragging
|
|
3105
|
+
data: (_node$data = node == null ? void 0 : node.data) != null ? _node$data : defaultData,
|
|
3106
|
+
rect: activeRects
|
|
3107
|
+
} : null;
|
|
3108
|
+
}, [activeId, node]);
|
|
3109
|
+
const activeRef = useRef3(null);
|
|
3110
|
+
const [activeSensor, setActiveSensor] = useState3(null);
|
|
3111
|
+
const [activatorEvent, setActivatorEvent] = useState3(null);
|
|
3112
|
+
const latestProps = useLatestValue(props, Object.values(props));
|
|
3113
|
+
const draggableDescribedById = useUniqueId("DndDescribedBy", id);
|
|
3114
|
+
const enabledDroppableContainers = useMemo3(() => droppableContainers.getEnabled(), [droppableContainers]);
|
|
3115
|
+
const measuringConfiguration = useMeasuringConfiguration(measuring);
|
|
3116
|
+
const {
|
|
3117
|
+
droppableRects,
|
|
3118
|
+
measureDroppableContainers,
|
|
3119
|
+
measuringScheduled
|
|
3120
|
+
} = useDroppableMeasuring(enabledDroppableContainers, {
|
|
3121
|
+
dragging: isInitialized,
|
|
3122
|
+
dependencies: [translate.x, translate.y],
|
|
3123
|
+
config: measuringConfiguration.droppable
|
|
3124
|
+
});
|
|
3125
|
+
const activeNode = useCachedNode(draggableNodes, activeId);
|
|
3126
|
+
const activationCoordinates = useMemo3(() => activatorEvent ? getEventCoordinates(activatorEvent) : null, [activatorEvent]);
|
|
3127
|
+
const autoScrollOptions = getAutoScrollerOptions();
|
|
3128
|
+
const initialActiveNodeRect = useInitialRect(activeNode, measuringConfiguration.draggable.measure);
|
|
3129
|
+
useLayoutShiftScrollCompensation({
|
|
3130
|
+
activeNode: activeId != null ? draggableNodes.get(activeId) : null,
|
|
3131
|
+
config: autoScrollOptions.layoutShiftCompensation,
|
|
3132
|
+
initialRect: initialActiveNodeRect,
|
|
3133
|
+
measure: measuringConfiguration.draggable.measure
|
|
3134
|
+
});
|
|
3135
|
+
const activeNodeRect = useRect(activeNode, measuringConfiguration.draggable.measure, initialActiveNodeRect);
|
|
3136
|
+
const containerNodeRect = useRect(activeNode ? activeNode.parentElement : null);
|
|
3137
|
+
const sensorContext = useRef3({
|
|
3138
|
+
activatorEvent: null,
|
|
3139
|
+
active: null,
|
|
3140
|
+
activeNode,
|
|
3141
|
+
collisionRect: null,
|
|
3142
|
+
collisions: null,
|
|
3143
|
+
droppableRects,
|
|
3144
|
+
draggableNodes,
|
|
3145
|
+
draggingNode: null,
|
|
3146
|
+
draggingNodeRect: null,
|
|
3147
|
+
droppableContainers,
|
|
3148
|
+
over: null,
|
|
3149
|
+
scrollableAncestors: [],
|
|
3150
|
+
scrollAdjustedTranslate: null
|
|
3151
|
+
});
|
|
3152
|
+
const overNode = droppableContainers.getNodeFor((_sensorContext$curren = sensorContext.current.over) == null ? void 0 : _sensorContext$curren.id);
|
|
3153
|
+
const dragOverlay = useDragOverlayMeasuring({
|
|
3154
|
+
measure: measuringConfiguration.dragOverlay.measure
|
|
3155
|
+
});
|
|
3156
|
+
const draggingNode = (_dragOverlay$nodeRef$ = dragOverlay.nodeRef.current) != null ? _dragOverlay$nodeRef$ : activeNode;
|
|
3157
|
+
const draggingNodeRect = isInitialized ? (_dragOverlay$rect = dragOverlay.rect) != null ? _dragOverlay$rect : activeNodeRect : null;
|
|
3158
|
+
const usesDragOverlay = Boolean(dragOverlay.nodeRef.current && dragOverlay.rect);
|
|
3159
|
+
const nodeRectDelta = useRectDelta(usesDragOverlay ? null : activeNodeRect);
|
|
3160
|
+
const windowRect = useWindowRect(draggingNode ? getWindow(draggingNode) : null);
|
|
3161
|
+
const scrollableAncestors = useScrollableAncestors(isInitialized ? overNode != null ? overNode : activeNode : null);
|
|
3162
|
+
const scrollableAncestorRects = useRects(scrollableAncestors);
|
|
3163
|
+
const modifiedTranslate = applyModifiers(modifiers, {
|
|
3164
|
+
transform: {
|
|
3165
|
+
x: translate.x - nodeRectDelta.x,
|
|
3166
|
+
y: translate.y - nodeRectDelta.y,
|
|
3167
|
+
scaleX: 1,
|
|
3168
|
+
scaleY: 1
|
|
3169
|
+
},
|
|
3170
|
+
activatorEvent,
|
|
3171
|
+
active,
|
|
3172
|
+
activeNodeRect,
|
|
3173
|
+
containerNodeRect,
|
|
3174
|
+
draggingNodeRect,
|
|
3175
|
+
over: sensorContext.current.over,
|
|
3176
|
+
overlayNodeRect: dragOverlay.rect,
|
|
3177
|
+
scrollableAncestors,
|
|
3178
|
+
scrollableAncestorRects,
|
|
3179
|
+
windowRect
|
|
3180
|
+
});
|
|
3181
|
+
const pointerCoordinates = activationCoordinates ? add(activationCoordinates, translate) : null;
|
|
3182
|
+
const scrollOffsets = useScrollOffsets(scrollableAncestors);
|
|
3183
|
+
const scrollAdjustment = useScrollOffsetsDelta(scrollOffsets);
|
|
3184
|
+
const activeNodeScrollDelta = useScrollOffsetsDelta(scrollOffsets, [activeNodeRect]);
|
|
3185
|
+
const scrollAdjustedTranslate = add(modifiedTranslate, scrollAdjustment);
|
|
3186
|
+
const collisionRect = draggingNodeRect ? getAdjustedRect(draggingNodeRect, modifiedTranslate) : null;
|
|
3187
|
+
const collisions = active && collisionRect ? collisionDetection({
|
|
3188
|
+
active,
|
|
3189
|
+
collisionRect,
|
|
3190
|
+
droppableRects,
|
|
3191
|
+
droppableContainers: enabledDroppableContainers,
|
|
3192
|
+
pointerCoordinates
|
|
3193
|
+
}) : null;
|
|
3194
|
+
const overId = getFirstCollision(collisions, "id");
|
|
3195
|
+
const [over, setOver] = useState3(null);
|
|
3196
|
+
const appliedTranslate = usesDragOverlay ? modifiedTranslate : add(modifiedTranslate, activeNodeScrollDelta);
|
|
3197
|
+
const transform = adjustScale(appliedTranslate, (_over$rect = over == null ? void 0 : over.rect) != null ? _over$rect : null, activeNodeRect);
|
|
3198
|
+
const activeSensorRef = useRef3(null);
|
|
3199
|
+
const instantiateSensor = useCallback3(
|
|
3200
|
+
(event, _ref2) => {
|
|
3201
|
+
let {
|
|
3202
|
+
sensor: Sensor,
|
|
3203
|
+
options
|
|
3204
|
+
} = _ref2;
|
|
3205
|
+
if (activeRef.current == null) {
|
|
3206
|
+
return;
|
|
3207
|
+
}
|
|
3208
|
+
const activeNode2 = draggableNodes.get(activeRef.current);
|
|
3209
|
+
if (!activeNode2) {
|
|
3210
|
+
return;
|
|
3211
|
+
}
|
|
3212
|
+
const activatorEvent2 = event.nativeEvent;
|
|
3213
|
+
const sensorInstance = new Sensor({
|
|
3214
|
+
active: activeRef.current,
|
|
3215
|
+
activeNode: activeNode2,
|
|
3216
|
+
event: activatorEvent2,
|
|
3217
|
+
options,
|
|
3218
|
+
// Sensors need to be instantiated with refs for arguments that change over time
|
|
3219
|
+
// otherwise they are frozen in time with the stale arguments
|
|
3220
|
+
context: sensorContext,
|
|
3221
|
+
onAbort(id2) {
|
|
3222
|
+
const draggableNode = draggableNodes.get(id2);
|
|
3223
|
+
if (!draggableNode) {
|
|
3224
|
+
return;
|
|
3225
|
+
}
|
|
3226
|
+
const {
|
|
3227
|
+
onDragAbort
|
|
3228
|
+
} = latestProps.current;
|
|
3229
|
+
const event2 = {
|
|
3230
|
+
id: id2
|
|
3231
|
+
};
|
|
3232
|
+
onDragAbort == null ? void 0 : onDragAbort(event2);
|
|
3233
|
+
dispatchMonitorEvent({
|
|
3234
|
+
type: "onDragAbort",
|
|
3235
|
+
event: event2
|
|
3236
|
+
});
|
|
3237
|
+
},
|
|
3238
|
+
onPending(id2, constraint, initialCoordinates, offset) {
|
|
3239
|
+
const draggableNode = draggableNodes.get(id2);
|
|
3240
|
+
if (!draggableNode) {
|
|
3241
|
+
return;
|
|
3242
|
+
}
|
|
3243
|
+
const {
|
|
3244
|
+
onDragPending
|
|
3245
|
+
} = latestProps.current;
|
|
3246
|
+
const event2 = {
|
|
3247
|
+
id: id2,
|
|
3248
|
+
constraint,
|
|
3249
|
+
initialCoordinates,
|
|
3250
|
+
offset
|
|
3251
|
+
};
|
|
3252
|
+
onDragPending == null ? void 0 : onDragPending(event2);
|
|
3253
|
+
dispatchMonitorEvent({
|
|
3254
|
+
type: "onDragPending",
|
|
3255
|
+
event: event2
|
|
3256
|
+
});
|
|
3257
|
+
},
|
|
3258
|
+
onStart(initialCoordinates) {
|
|
3259
|
+
const id2 = activeRef.current;
|
|
3260
|
+
if (id2 == null) {
|
|
3261
|
+
return;
|
|
3262
|
+
}
|
|
3263
|
+
const draggableNode = draggableNodes.get(id2);
|
|
3264
|
+
if (!draggableNode) {
|
|
3265
|
+
return;
|
|
3266
|
+
}
|
|
3267
|
+
const {
|
|
3268
|
+
onDragStart
|
|
3269
|
+
} = latestProps.current;
|
|
3270
|
+
const event2 = {
|
|
3271
|
+
activatorEvent: activatorEvent2,
|
|
3272
|
+
active: {
|
|
3273
|
+
id: id2,
|
|
3274
|
+
data: draggableNode.data,
|
|
3275
|
+
rect: activeRects
|
|
3276
|
+
}
|
|
3277
|
+
};
|
|
3278
|
+
unstable_batchedUpdates(() => {
|
|
3279
|
+
onDragStart == null ? void 0 : onDragStart(event2);
|
|
3280
|
+
setStatus(Status.Initializing);
|
|
3281
|
+
dispatch({
|
|
3282
|
+
type: Action.DragStart,
|
|
3283
|
+
initialCoordinates,
|
|
3284
|
+
active: id2
|
|
3285
|
+
});
|
|
3286
|
+
dispatchMonitorEvent({
|
|
3287
|
+
type: "onDragStart",
|
|
3288
|
+
event: event2
|
|
3289
|
+
});
|
|
3290
|
+
setActiveSensor(activeSensorRef.current);
|
|
3291
|
+
setActivatorEvent(activatorEvent2);
|
|
3292
|
+
});
|
|
3293
|
+
},
|
|
3294
|
+
onMove(coordinates) {
|
|
3295
|
+
dispatch({
|
|
3296
|
+
type: Action.DragMove,
|
|
3297
|
+
coordinates
|
|
3298
|
+
});
|
|
3299
|
+
},
|
|
3300
|
+
onEnd: createHandler(Action.DragEnd),
|
|
3301
|
+
onCancel: createHandler(Action.DragCancel)
|
|
3302
|
+
});
|
|
3303
|
+
activeSensorRef.current = sensorInstance;
|
|
3304
|
+
function createHandler(type) {
|
|
3305
|
+
return async function handler() {
|
|
3306
|
+
const {
|
|
3307
|
+
active: active2,
|
|
3308
|
+
collisions: collisions2,
|
|
3309
|
+
over: over2,
|
|
3310
|
+
scrollAdjustedTranslate: scrollAdjustedTranslate2
|
|
3311
|
+
} = sensorContext.current;
|
|
3312
|
+
let event2 = null;
|
|
3313
|
+
if (active2 && scrollAdjustedTranslate2) {
|
|
3314
|
+
const {
|
|
3315
|
+
cancelDrop
|
|
3316
|
+
} = latestProps.current;
|
|
3317
|
+
event2 = {
|
|
3318
|
+
activatorEvent: activatorEvent2,
|
|
3319
|
+
active: active2,
|
|
3320
|
+
collisions: collisions2,
|
|
3321
|
+
delta: scrollAdjustedTranslate2,
|
|
3322
|
+
over: over2
|
|
3323
|
+
};
|
|
3324
|
+
if (type === Action.DragEnd && typeof cancelDrop === "function") {
|
|
3325
|
+
const shouldCancel = await Promise.resolve(cancelDrop(event2));
|
|
3326
|
+
if (shouldCancel) {
|
|
3327
|
+
type = Action.DragCancel;
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3331
|
+
activeRef.current = null;
|
|
3332
|
+
unstable_batchedUpdates(() => {
|
|
3333
|
+
dispatch({
|
|
3334
|
+
type
|
|
3335
|
+
});
|
|
3336
|
+
setStatus(Status.Uninitialized);
|
|
3337
|
+
setOver(null);
|
|
3338
|
+
setActiveSensor(null);
|
|
3339
|
+
setActivatorEvent(null);
|
|
3340
|
+
activeSensorRef.current = null;
|
|
3341
|
+
const eventName = type === Action.DragEnd ? "onDragEnd" : "onDragCancel";
|
|
3342
|
+
if (event2) {
|
|
3343
|
+
const handler2 = latestProps.current[eventName];
|
|
3344
|
+
handler2 == null ? void 0 : handler2(event2);
|
|
3345
|
+
dispatchMonitorEvent({
|
|
3346
|
+
type: eventName,
|
|
3347
|
+
event: event2
|
|
3348
|
+
});
|
|
3349
|
+
}
|
|
3350
|
+
});
|
|
3351
|
+
};
|
|
3352
|
+
}
|
|
3353
|
+
},
|
|
3354
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3355
|
+
[draggableNodes]
|
|
3356
|
+
);
|
|
3357
|
+
const bindActivatorToSensorInstantiator = useCallback3((handler, sensor) => {
|
|
3358
|
+
return (event, active2) => {
|
|
3359
|
+
const nativeEvent = event.nativeEvent;
|
|
3360
|
+
const activeDraggableNode = draggableNodes.get(active2);
|
|
3361
|
+
if (
|
|
3362
|
+
// Another sensor is already instantiating
|
|
3363
|
+
activeRef.current !== null || // No active draggable
|
|
3364
|
+
!activeDraggableNode || // Event has already been captured
|
|
3365
|
+
nativeEvent.dndKit || nativeEvent.defaultPrevented
|
|
3366
|
+
) {
|
|
3367
|
+
return;
|
|
3368
|
+
}
|
|
3369
|
+
const activationContext = {
|
|
3370
|
+
active: activeDraggableNode
|
|
3371
|
+
};
|
|
3372
|
+
const shouldActivate = handler(event, sensor.options, activationContext);
|
|
3373
|
+
if (shouldActivate === true) {
|
|
3374
|
+
nativeEvent.dndKit = {
|
|
3375
|
+
capturedBy: sensor.sensor
|
|
3376
|
+
};
|
|
3377
|
+
activeRef.current = active2;
|
|
3378
|
+
instantiateSensor(event, sensor);
|
|
3379
|
+
}
|
|
3380
|
+
};
|
|
3381
|
+
}, [draggableNodes, instantiateSensor]);
|
|
3382
|
+
const activators = useCombineActivators(sensors, bindActivatorToSensorInstantiator);
|
|
3383
|
+
useSensorSetup(sensors);
|
|
3384
|
+
useIsomorphicLayoutEffect(() => {
|
|
3385
|
+
if (activeNodeRect && status === Status.Initializing) {
|
|
3386
|
+
setStatus(Status.Initialized);
|
|
3387
|
+
}
|
|
3388
|
+
}, [activeNodeRect, status]);
|
|
3389
|
+
useEffect3(
|
|
3390
|
+
() => {
|
|
3391
|
+
const {
|
|
3392
|
+
onDragMove
|
|
3393
|
+
} = latestProps.current;
|
|
3394
|
+
const {
|
|
3395
|
+
active: active2,
|
|
3396
|
+
activatorEvent: activatorEvent2,
|
|
3397
|
+
collisions: collisions2,
|
|
3398
|
+
over: over2
|
|
3399
|
+
} = sensorContext.current;
|
|
3400
|
+
if (!active2 || !activatorEvent2) {
|
|
3401
|
+
return;
|
|
3402
|
+
}
|
|
3403
|
+
const event = {
|
|
3404
|
+
active: active2,
|
|
3405
|
+
activatorEvent: activatorEvent2,
|
|
3406
|
+
collisions: collisions2,
|
|
3407
|
+
delta: {
|
|
3408
|
+
x: scrollAdjustedTranslate.x,
|
|
3409
|
+
y: scrollAdjustedTranslate.y
|
|
3410
|
+
},
|
|
3411
|
+
over: over2
|
|
3412
|
+
};
|
|
3413
|
+
unstable_batchedUpdates(() => {
|
|
3414
|
+
onDragMove == null ? void 0 : onDragMove(event);
|
|
3415
|
+
dispatchMonitorEvent({
|
|
3416
|
+
type: "onDragMove",
|
|
3417
|
+
event
|
|
3418
|
+
});
|
|
3419
|
+
});
|
|
3420
|
+
},
|
|
3421
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3422
|
+
[scrollAdjustedTranslate.x, scrollAdjustedTranslate.y]
|
|
3423
|
+
);
|
|
3424
|
+
useEffect3(
|
|
3425
|
+
() => {
|
|
3426
|
+
const {
|
|
3427
|
+
active: active2,
|
|
3428
|
+
activatorEvent: activatorEvent2,
|
|
3429
|
+
collisions: collisions2,
|
|
3430
|
+
droppableContainers: droppableContainers2,
|
|
3431
|
+
scrollAdjustedTranslate: scrollAdjustedTranslate2
|
|
3432
|
+
} = sensorContext.current;
|
|
3433
|
+
if (!active2 || activeRef.current == null || !activatorEvent2 || !scrollAdjustedTranslate2) {
|
|
3434
|
+
return;
|
|
3435
|
+
}
|
|
3436
|
+
const {
|
|
3437
|
+
onDragOver
|
|
3438
|
+
} = latestProps.current;
|
|
3439
|
+
const overContainer = droppableContainers2.get(overId);
|
|
3440
|
+
const over2 = overContainer && overContainer.rect.current ? {
|
|
3441
|
+
id: overContainer.id,
|
|
3442
|
+
rect: overContainer.rect.current,
|
|
3443
|
+
data: overContainer.data,
|
|
3444
|
+
disabled: overContainer.disabled
|
|
3445
|
+
} : null;
|
|
3446
|
+
const event = {
|
|
3447
|
+
active: active2,
|
|
3448
|
+
activatorEvent: activatorEvent2,
|
|
3449
|
+
collisions: collisions2,
|
|
3450
|
+
delta: {
|
|
3451
|
+
x: scrollAdjustedTranslate2.x,
|
|
3452
|
+
y: scrollAdjustedTranslate2.y
|
|
3453
|
+
},
|
|
3454
|
+
over: over2
|
|
3455
|
+
};
|
|
3456
|
+
unstable_batchedUpdates(() => {
|
|
3457
|
+
setOver(over2);
|
|
3458
|
+
onDragOver == null ? void 0 : onDragOver(event);
|
|
3459
|
+
dispatchMonitorEvent({
|
|
3460
|
+
type: "onDragOver",
|
|
3461
|
+
event
|
|
3462
|
+
});
|
|
3463
|
+
});
|
|
3464
|
+
},
|
|
3465
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3466
|
+
[overId]
|
|
3467
|
+
);
|
|
3468
|
+
useIsomorphicLayoutEffect(() => {
|
|
3469
|
+
sensorContext.current = {
|
|
3470
|
+
activatorEvent,
|
|
3471
|
+
active,
|
|
3472
|
+
activeNode,
|
|
3473
|
+
collisionRect,
|
|
3474
|
+
collisions,
|
|
3475
|
+
droppableRects,
|
|
3476
|
+
draggableNodes,
|
|
3477
|
+
draggingNode,
|
|
3478
|
+
draggingNodeRect,
|
|
3479
|
+
droppableContainers,
|
|
3480
|
+
over,
|
|
3481
|
+
scrollableAncestors,
|
|
3482
|
+
scrollAdjustedTranslate
|
|
3483
|
+
};
|
|
3484
|
+
activeRects.current = {
|
|
3485
|
+
initial: draggingNodeRect,
|
|
3486
|
+
translated: collisionRect
|
|
3487
|
+
};
|
|
3488
|
+
}, [active, activeNode, collisions, collisionRect, draggableNodes, draggingNode, draggingNodeRect, droppableRects, droppableContainers, over, scrollableAncestors, scrollAdjustedTranslate]);
|
|
3489
|
+
useAutoScroller({
|
|
3490
|
+
...autoScrollOptions,
|
|
3491
|
+
delta: translate,
|
|
3492
|
+
draggingRect: collisionRect,
|
|
3493
|
+
pointerCoordinates,
|
|
3494
|
+
scrollableAncestors,
|
|
3495
|
+
scrollableAncestorRects
|
|
3496
|
+
});
|
|
3497
|
+
const publicContext = useMemo3(() => {
|
|
3498
|
+
const context = {
|
|
3499
|
+
active,
|
|
3500
|
+
activeNode,
|
|
3501
|
+
activeNodeRect,
|
|
3502
|
+
activatorEvent,
|
|
3503
|
+
collisions,
|
|
3504
|
+
containerNodeRect,
|
|
3505
|
+
dragOverlay,
|
|
3506
|
+
draggableNodes,
|
|
3507
|
+
droppableContainers,
|
|
3508
|
+
droppableRects,
|
|
3509
|
+
over,
|
|
3510
|
+
measureDroppableContainers,
|
|
3511
|
+
scrollableAncestors,
|
|
3512
|
+
scrollableAncestorRects,
|
|
3513
|
+
measuringConfiguration,
|
|
3514
|
+
measuringScheduled,
|
|
3515
|
+
windowRect
|
|
3516
|
+
};
|
|
3517
|
+
return context;
|
|
3518
|
+
}, [active, activeNode, activeNodeRect, activatorEvent, collisions, containerNodeRect, dragOverlay, draggableNodes, droppableContainers, droppableRects, over, measureDroppableContainers, scrollableAncestors, scrollableAncestorRects, measuringConfiguration, measuringScheduled, windowRect]);
|
|
3519
|
+
const internalContext = useMemo3(() => {
|
|
3520
|
+
const context = {
|
|
3521
|
+
activatorEvent,
|
|
3522
|
+
activators,
|
|
3523
|
+
active,
|
|
3524
|
+
activeNodeRect,
|
|
3525
|
+
ariaDescribedById: {
|
|
3526
|
+
draggable: draggableDescribedById
|
|
3527
|
+
},
|
|
3528
|
+
dispatch,
|
|
3529
|
+
draggableNodes,
|
|
3530
|
+
over,
|
|
3531
|
+
measureDroppableContainers
|
|
3532
|
+
};
|
|
3533
|
+
return context;
|
|
3534
|
+
}, [activatorEvent, activators, active, activeNodeRect, dispatch, draggableDescribedById, draggableNodes, over, measureDroppableContainers]);
|
|
3535
|
+
return React2.createElement(DndMonitorContext.Provider, {
|
|
3536
|
+
value: registerMonitorListener
|
|
3537
|
+
}, React2.createElement(InternalContext.Provider, {
|
|
3538
|
+
value: internalContext
|
|
3539
|
+
}, React2.createElement(PublicContext.Provider, {
|
|
3540
|
+
value: publicContext
|
|
3541
|
+
}, React2.createElement(ActiveDraggableContext.Provider, {
|
|
3542
|
+
value: transform
|
|
3543
|
+
}, children)), React2.createElement(RestoreFocus, {
|
|
3544
|
+
disabled: (accessibility == null ? void 0 : accessibility.restoreFocus) === false
|
|
3545
|
+
})), React2.createElement(Accessibility, {
|
|
3546
|
+
...accessibility,
|
|
3547
|
+
hiddenTextDescribedById: draggableDescribedById
|
|
3548
|
+
}));
|
|
3549
|
+
function getAutoScrollerOptions() {
|
|
3550
|
+
const activeSensorDisablesAutoscroll = (activeSensor == null ? void 0 : activeSensor.autoScrollEnabled) === false;
|
|
3551
|
+
const autoScrollGloballyDisabled = typeof autoScroll === "object" ? autoScroll.enabled === false : autoScroll === false;
|
|
3552
|
+
const enabled = isInitialized && !activeSensorDisablesAutoscroll && !autoScrollGloballyDisabled;
|
|
3553
|
+
if (typeof autoScroll === "object") {
|
|
3554
|
+
return {
|
|
3555
|
+
...autoScroll,
|
|
3556
|
+
enabled
|
|
3557
|
+
};
|
|
3558
|
+
}
|
|
3559
|
+
return {
|
|
3560
|
+
enabled
|
|
3561
|
+
};
|
|
3562
|
+
}
|
|
3563
|
+
});
|
|
3564
|
+
var NullContext = /* @__PURE__ */ createContext(null);
|
|
3565
|
+
var defaultRole = "button";
|
|
3566
|
+
var ID_PREFIX = "Draggable";
|
|
3567
|
+
function useDraggable(_ref) {
|
|
3568
|
+
let {
|
|
3569
|
+
id,
|
|
3570
|
+
data,
|
|
3571
|
+
disabled = false,
|
|
3572
|
+
attributes
|
|
3573
|
+
} = _ref;
|
|
3574
|
+
const key = useUniqueId(ID_PREFIX);
|
|
3575
|
+
const {
|
|
3576
|
+
activators,
|
|
3577
|
+
activatorEvent,
|
|
3578
|
+
active,
|
|
3579
|
+
activeNodeRect,
|
|
3580
|
+
ariaDescribedById,
|
|
3581
|
+
draggableNodes,
|
|
3582
|
+
over
|
|
3583
|
+
} = useContext(InternalContext);
|
|
3584
|
+
const {
|
|
3585
|
+
role = defaultRole,
|
|
3586
|
+
roleDescription = "draggable",
|
|
3587
|
+
tabIndex = 0
|
|
3588
|
+
} = attributes != null ? attributes : {};
|
|
3589
|
+
const isDragging = (active == null ? void 0 : active.id) === id;
|
|
3590
|
+
const transform = useContext(isDragging ? ActiveDraggableContext : NullContext);
|
|
3591
|
+
const [node, setNodeRef] = useNodeRef();
|
|
3592
|
+
const [activatorNode, setActivatorNodeRef] = useNodeRef();
|
|
3593
|
+
const listeners = useSyntheticListeners(activators, id);
|
|
3594
|
+
const dataRef = useLatestValue(data);
|
|
3595
|
+
useIsomorphicLayoutEffect(
|
|
3596
|
+
() => {
|
|
3597
|
+
draggableNodes.set(id, {
|
|
3598
|
+
id,
|
|
3599
|
+
key,
|
|
3600
|
+
node,
|
|
3601
|
+
activatorNode,
|
|
3602
|
+
data: dataRef
|
|
3603
|
+
});
|
|
3604
|
+
return () => {
|
|
3605
|
+
const node2 = draggableNodes.get(id);
|
|
3606
|
+
if (node2 && node2.key === key) {
|
|
3607
|
+
draggableNodes.delete(id);
|
|
3608
|
+
}
|
|
3609
|
+
};
|
|
3610
|
+
},
|
|
3611
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3612
|
+
[draggableNodes, id]
|
|
3613
|
+
);
|
|
3614
|
+
const memoizedAttributes = useMemo3(() => ({
|
|
3615
|
+
role,
|
|
3616
|
+
tabIndex,
|
|
3617
|
+
"aria-disabled": disabled,
|
|
3618
|
+
"aria-pressed": isDragging && role === defaultRole ? true : void 0,
|
|
3619
|
+
"aria-roledescription": roleDescription,
|
|
3620
|
+
"aria-describedby": ariaDescribedById.draggable
|
|
3621
|
+
}), [disabled, role, tabIndex, isDragging, roleDescription, ariaDescribedById.draggable]);
|
|
3622
|
+
return {
|
|
3623
|
+
active,
|
|
3624
|
+
activatorEvent,
|
|
3625
|
+
activeNodeRect,
|
|
3626
|
+
attributes: memoizedAttributes,
|
|
3627
|
+
isDragging,
|
|
3628
|
+
listeners: disabled ? void 0 : listeners,
|
|
3629
|
+
node,
|
|
3630
|
+
over,
|
|
3631
|
+
setNodeRef,
|
|
3632
|
+
setActivatorNodeRef,
|
|
3633
|
+
transform
|
|
3634
|
+
};
|
|
3635
|
+
}
|
|
3636
|
+
function useDndContext() {
|
|
3637
|
+
return useContext(PublicContext);
|
|
3638
|
+
}
|
|
3639
|
+
var ID_PREFIX$1 = "Droppable";
|
|
3640
|
+
var defaultResizeObserverConfig = {
|
|
3641
|
+
timeout: 25
|
|
3642
|
+
};
|
|
3643
|
+
function useDroppable(_ref) {
|
|
3644
|
+
let {
|
|
3645
|
+
data,
|
|
3646
|
+
disabled = false,
|
|
3647
|
+
id,
|
|
3648
|
+
resizeObserverConfig
|
|
3649
|
+
} = _ref;
|
|
3650
|
+
const key = useUniqueId(ID_PREFIX$1);
|
|
3651
|
+
const {
|
|
3652
|
+
active,
|
|
3653
|
+
dispatch,
|
|
3654
|
+
over,
|
|
3655
|
+
measureDroppableContainers
|
|
3656
|
+
} = useContext(InternalContext);
|
|
3657
|
+
const previous = useRef3({
|
|
3658
|
+
disabled
|
|
3659
|
+
});
|
|
3660
|
+
const resizeObserverConnected = useRef3(false);
|
|
3661
|
+
const rect = useRef3(null);
|
|
3662
|
+
const callbackId = useRef3(null);
|
|
3663
|
+
const {
|
|
3664
|
+
disabled: resizeObserverDisabled,
|
|
3665
|
+
updateMeasurementsFor,
|
|
3666
|
+
timeout: resizeObserverTimeout
|
|
3667
|
+
} = {
|
|
3668
|
+
...defaultResizeObserverConfig,
|
|
3669
|
+
...resizeObserverConfig
|
|
3670
|
+
};
|
|
3671
|
+
const ids2 = useLatestValue(updateMeasurementsFor != null ? updateMeasurementsFor : id);
|
|
3672
|
+
const handleResize = useCallback3(
|
|
3673
|
+
() => {
|
|
3674
|
+
if (!resizeObserverConnected.current) {
|
|
3675
|
+
resizeObserverConnected.current = true;
|
|
3676
|
+
return;
|
|
3677
|
+
}
|
|
3678
|
+
if (callbackId.current != null) {
|
|
3679
|
+
clearTimeout(callbackId.current);
|
|
3680
|
+
}
|
|
3681
|
+
callbackId.current = setTimeout(() => {
|
|
3682
|
+
measureDroppableContainers(Array.isArray(ids2.current) ? ids2.current : [ids2.current]);
|
|
3683
|
+
callbackId.current = null;
|
|
3684
|
+
}, resizeObserverTimeout);
|
|
3685
|
+
},
|
|
3686
|
+
//eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3687
|
+
[resizeObserverTimeout]
|
|
3688
|
+
);
|
|
3689
|
+
const resizeObserver = useResizeObserver({
|
|
3690
|
+
callback: handleResize,
|
|
3691
|
+
disabled: resizeObserverDisabled || !active
|
|
3692
|
+
});
|
|
3693
|
+
const handleNodeChange = useCallback3((newElement, previousElement) => {
|
|
3694
|
+
if (!resizeObserver) {
|
|
3695
|
+
return;
|
|
3696
|
+
}
|
|
3697
|
+
if (previousElement) {
|
|
3698
|
+
resizeObserver.unobserve(previousElement);
|
|
3699
|
+
resizeObserverConnected.current = false;
|
|
3700
|
+
}
|
|
3701
|
+
if (newElement) {
|
|
3702
|
+
resizeObserver.observe(newElement);
|
|
3703
|
+
}
|
|
3704
|
+
}, [resizeObserver]);
|
|
3705
|
+
const [nodeRef, setNodeRef] = useNodeRef(handleNodeChange);
|
|
3706
|
+
const dataRef = useLatestValue(data);
|
|
3707
|
+
useEffect3(() => {
|
|
3708
|
+
if (!resizeObserver || !nodeRef.current) {
|
|
3709
|
+
return;
|
|
3710
|
+
}
|
|
3711
|
+
resizeObserver.disconnect();
|
|
3712
|
+
resizeObserverConnected.current = false;
|
|
3713
|
+
resizeObserver.observe(nodeRef.current);
|
|
3714
|
+
}, [nodeRef, resizeObserver]);
|
|
3715
|
+
useEffect3(
|
|
3716
|
+
() => {
|
|
3717
|
+
dispatch({
|
|
3718
|
+
type: Action.RegisterDroppable,
|
|
3719
|
+
element: {
|
|
3720
|
+
id,
|
|
3721
|
+
key,
|
|
3722
|
+
disabled,
|
|
3723
|
+
node: nodeRef,
|
|
3724
|
+
rect,
|
|
3725
|
+
data: dataRef
|
|
3726
|
+
}
|
|
3727
|
+
});
|
|
3728
|
+
return () => dispatch({
|
|
3729
|
+
type: Action.UnregisterDroppable,
|
|
3730
|
+
key,
|
|
3731
|
+
id
|
|
3732
|
+
});
|
|
3733
|
+
},
|
|
3734
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3735
|
+
[id]
|
|
3736
|
+
);
|
|
3737
|
+
useEffect3(() => {
|
|
3738
|
+
if (disabled !== previous.current.disabled) {
|
|
3739
|
+
dispatch({
|
|
3740
|
+
type: Action.SetDroppableDisabled,
|
|
3741
|
+
id,
|
|
3742
|
+
key,
|
|
3743
|
+
disabled
|
|
3744
|
+
});
|
|
3745
|
+
previous.current.disabled = disabled;
|
|
3746
|
+
}
|
|
3747
|
+
}, [id, key, disabled, dispatch]);
|
|
3748
|
+
return {
|
|
3749
|
+
active,
|
|
3750
|
+
rect,
|
|
3751
|
+
isOver: (over == null ? void 0 : over.id) === id,
|
|
3752
|
+
node: nodeRef,
|
|
3753
|
+
over,
|
|
3754
|
+
setNodeRef
|
|
3755
|
+
};
|
|
3756
|
+
}
|
|
3757
|
+
|
|
3758
|
+
// node_modules/@dnd-kit/sortable/dist/sortable.esm.js
|
|
3759
|
+
import React3, { useMemo as useMemo4, useRef as useRef4, useEffect as useEffect4, useState as useState4, useContext as useContext2 } from "react";
|
|
3760
|
+
function arrayMove(array, from, to) {
|
|
3761
|
+
const newArray = array.slice();
|
|
3762
|
+
newArray.splice(to < 0 ? newArray.length + to : to, 0, newArray.splice(from, 1)[0]);
|
|
3763
|
+
return newArray;
|
|
3764
|
+
}
|
|
3765
|
+
function getSortedRects(items, rects) {
|
|
3766
|
+
return items.reduce((accumulator, id, index) => {
|
|
3767
|
+
const rect = rects.get(id);
|
|
3768
|
+
if (rect) {
|
|
3769
|
+
accumulator[index] = rect;
|
|
3770
|
+
}
|
|
3771
|
+
return accumulator;
|
|
3772
|
+
}, Array(items.length));
|
|
3773
|
+
}
|
|
3774
|
+
function isValidIndex(index) {
|
|
3775
|
+
return index !== null && index >= 0;
|
|
3776
|
+
}
|
|
3777
|
+
function itemsEqual(a, b) {
|
|
3778
|
+
if (a === b) {
|
|
3779
|
+
return true;
|
|
3780
|
+
}
|
|
3781
|
+
if (a.length !== b.length) {
|
|
3782
|
+
return false;
|
|
3783
|
+
}
|
|
3784
|
+
for (let i = 0; i < a.length; i++) {
|
|
3785
|
+
if (a[i] !== b[i]) {
|
|
3786
|
+
return false;
|
|
3787
|
+
}
|
|
3788
|
+
}
|
|
3789
|
+
return true;
|
|
3790
|
+
}
|
|
3791
|
+
function normalizeDisabled(disabled) {
|
|
3792
|
+
if (typeof disabled === "boolean") {
|
|
3793
|
+
return {
|
|
3794
|
+
draggable: disabled,
|
|
3795
|
+
droppable: disabled
|
|
3796
|
+
};
|
|
3797
|
+
}
|
|
3798
|
+
return disabled;
|
|
3799
|
+
}
|
|
3800
|
+
var defaultScale = {
|
|
3801
|
+
scaleX: 1,
|
|
3802
|
+
scaleY: 1
|
|
3803
|
+
};
|
|
3804
|
+
var horizontalListSortingStrategy = (_ref) => {
|
|
3805
|
+
var _rects$activeIndex;
|
|
3806
|
+
let {
|
|
3807
|
+
rects,
|
|
3808
|
+
activeNodeRect: fallbackActiveRect,
|
|
3809
|
+
activeIndex,
|
|
3810
|
+
overIndex,
|
|
3811
|
+
index
|
|
3812
|
+
} = _ref;
|
|
3813
|
+
const activeNodeRect = (_rects$activeIndex = rects[activeIndex]) != null ? _rects$activeIndex : fallbackActiveRect;
|
|
3814
|
+
if (!activeNodeRect) {
|
|
3815
|
+
return null;
|
|
3816
|
+
}
|
|
3817
|
+
const itemGap = getItemGap(rects, index, activeIndex);
|
|
3818
|
+
if (index === activeIndex) {
|
|
3819
|
+
const newIndexRect = rects[overIndex];
|
|
3820
|
+
if (!newIndexRect) {
|
|
3821
|
+
return null;
|
|
3822
|
+
}
|
|
3823
|
+
return {
|
|
3824
|
+
x: activeIndex < overIndex ? newIndexRect.left + newIndexRect.width - (activeNodeRect.left + activeNodeRect.width) : newIndexRect.left - activeNodeRect.left,
|
|
3825
|
+
y: 0,
|
|
3826
|
+
...defaultScale
|
|
3827
|
+
};
|
|
3828
|
+
}
|
|
3829
|
+
if (index > activeIndex && index <= overIndex) {
|
|
3830
|
+
return {
|
|
3831
|
+
x: -activeNodeRect.width - itemGap,
|
|
3832
|
+
y: 0,
|
|
3833
|
+
...defaultScale
|
|
3834
|
+
};
|
|
3835
|
+
}
|
|
3836
|
+
if (index < activeIndex && index >= overIndex) {
|
|
3837
|
+
return {
|
|
3838
|
+
x: activeNodeRect.width + itemGap,
|
|
3839
|
+
y: 0,
|
|
3840
|
+
...defaultScale
|
|
3841
|
+
};
|
|
3842
|
+
}
|
|
3843
|
+
return {
|
|
3844
|
+
x: 0,
|
|
3845
|
+
y: 0,
|
|
3846
|
+
...defaultScale
|
|
3847
|
+
};
|
|
3848
|
+
};
|
|
3849
|
+
function getItemGap(rects, index, activeIndex) {
|
|
3850
|
+
const currentRect = rects[index];
|
|
3851
|
+
const previousRect = rects[index - 1];
|
|
3852
|
+
const nextRect = rects[index + 1];
|
|
3853
|
+
if (!currentRect || !previousRect && !nextRect) {
|
|
3854
|
+
return 0;
|
|
3855
|
+
}
|
|
3856
|
+
if (activeIndex < index) {
|
|
3857
|
+
return previousRect ? currentRect.left - (previousRect.left + previousRect.width) : nextRect.left - (currentRect.left + currentRect.width);
|
|
3858
|
+
}
|
|
3859
|
+
return nextRect ? nextRect.left - (currentRect.left + currentRect.width) : currentRect.left - (previousRect.left + previousRect.width);
|
|
3860
|
+
}
|
|
3861
|
+
var rectSortingStrategy = (_ref) => {
|
|
3862
|
+
let {
|
|
3863
|
+
rects,
|
|
3864
|
+
activeIndex,
|
|
3865
|
+
overIndex,
|
|
3866
|
+
index
|
|
3867
|
+
} = _ref;
|
|
3868
|
+
const newRects = arrayMove(rects, overIndex, activeIndex);
|
|
3869
|
+
const oldRect = rects[index];
|
|
3870
|
+
const newRect = newRects[index];
|
|
3871
|
+
if (!newRect || !oldRect) {
|
|
3872
|
+
return null;
|
|
3873
|
+
}
|
|
3874
|
+
return {
|
|
3875
|
+
x: newRect.left - oldRect.left,
|
|
3876
|
+
y: newRect.top - oldRect.top,
|
|
3877
|
+
scaleX: newRect.width / oldRect.width,
|
|
3878
|
+
scaleY: newRect.height / oldRect.height
|
|
3879
|
+
};
|
|
3880
|
+
};
|
|
3881
|
+
var defaultScale$1 = {
|
|
3882
|
+
scaleX: 1,
|
|
3883
|
+
scaleY: 1
|
|
3884
|
+
};
|
|
3885
|
+
var verticalListSortingStrategy = (_ref) => {
|
|
3886
|
+
var _rects$activeIndex;
|
|
3887
|
+
let {
|
|
3888
|
+
activeIndex,
|
|
3889
|
+
activeNodeRect: fallbackActiveRect,
|
|
3890
|
+
index,
|
|
3891
|
+
rects,
|
|
3892
|
+
overIndex
|
|
3893
|
+
} = _ref;
|
|
3894
|
+
const activeNodeRect = (_rects$activeIndex = rects[activeIndex]) != null ? _rects$activeIndex : fallbackActiveRect;
|
|
3895
|
+
if (!activeNodeRect) {
|
|
3896
|
+
return null;
|
|
3897
|
+
}
|
|
3898
|
+
if (index === activeIndex) {
|
|
3899
|
+
const overIndexRect = rects[overIndex];
|
|
3900
|
+
if (!overIndexRect) {
|
|
3901
|
+
return null;
|
|
3902
|
+
}
|
|
3903
|
+
return {
|
|
3904
|
+
x: 0,
|
|
3905
|
+
y: activeIndex < overIndex ? overIndexRect.top + overIndexRect.height - (activeNodeRect.top + activeNodeRect.height) : overIndexRect.top - activeNodeRect.top,
|
|
3906
|
+
...defaultScale$1
|
|
3907
|
+
};
|
|
3908
|
+
}
|
|
3909
|
+
const itemGap = getItemGap$1(rects, index, activeIndex);
|
|
3910
|
+
if (index > activeIndex && index <= overIndex) {
|
|
3911
|
+
return {
|
|
3912
|
+
x: 0,
|
|
3913
|
+
y: -activeNodeRect.height - itemGap,
|
|
3914
|
+
...defaultScale$1
|
|
3915
|
+
};
|
|
3916
|
+
}
|
|
3917
|
+
if (index < activeIndex && index >= overIndex) {
|
|
3918
|
+
return {
|
|
3919
|
+
x: 0,
|
|
3920
|
+
y: activeNodeRect.height + itemGap,
|
|
3921
|
+
...defaultScale$1
|
|
3922
|
+
};
|
|
3923
|
+
}
|
|
3924
|
+
return {
|
|
3925
|
+
x: 0,
|
|
3926
|
+
y: 0,
|
|
3927
|
+
...defaultScale$1
|
|
3928
|
+
};
|
|
3929
|
+
};
|
|
3930
|
+
function getItemGap$1(clientRects, index, activeIndex) {
|
|
3931
|
+
const currentRect = clientRects[index];
|
|
3932
|
+
const previousRect = clientRects[index - 1];
|
|
3933
|
+
const nextRect = clientRects[index + 1];
|
|
3934
|
+
if (!currentRect) {
|
|
3935
|
+
return 0;
|
|
3936
|
+
}
|
|
3937
|
+
if (activeIndex < index) {
|
|
3938
|
+
return previousRect ? currentRect.top - (previousRect.top + previousRect.height) : nextRect ? nextRect.top - (currentRect.top + currentRect.height) : 0;
|
|
3939
|
+
}
|
|
3940
|
+
return nextRect ? nextRect.top - (currentRect.top + currentRect.height) : previousRect ? currentRect.top - (previousRect.top + previousRect.height) : 0;
|
|
3941
|
+
}
|
|
3942
|
+
var ID_PREFIX2 = "Sortable";
|
|
3943
|
+
var Context = /* @__PURE__ */ React3.createContext({
|
|
3944
|
+
activeIndex: -1,
|
|
3945
|
+
containerId: ID_PREFIX2,
|
|
3946
|
+
disableTransforms: false,
|
|
3947
|
+
items: [],
|
|
3948
|
+
overIndex: -1,
|
|
3949
|
+
useDragOverlay: false,
|
|
3950
|
+
sortedRects: [],
|
|
3951
|
+
strategy: rectSortingStrategy,
|
|
3952
|
+
disabled: {
|
|
3953
|
+
draggable: false,
|
|
3954
|
+
droppable: false
|
|
3955
|
+
}
|
|
3956
|
+
});
|
|
3957
|
+
function SortableContext(_ref) {
|
|
3958
|
+
let {
|
|
3959
|
+
children,
|
|
3960
|
+
id,
|
|
3961
|
+
items: userDefinedItems,
|
|
3962
|
+
strategy = rectSortingStrategy,
|
|
3963
|
+
disabled: disabledProp = false
|
|
3964
|
+
} = _ref;
|
|
3965
|
+
const {
|
|
3966
|
+
active,
|
|
3967
|
+
dragOverlay,
|
|
3968
|
+
droppableRects,
|
|
3969
|
+
over,
|
|
3970
|
+
measureDroppableContainers
|
|
3971
|
+
} = useDndContext();
|
|
3972
|
+
const containerId = useUniqueId(ID_PREFIX2, id);
|
|
3973
|
+
const useDragOverlay = Boolean(dragOverlay.rect !== null);
|
|
3974
|
+
const items = useMemo4(() => userDefinedItems.map((item) => typeof item === "object" && "id" in item ? item.id : item), [userDefinedItems]);
|
|
3975
|
+
const isDragging = active != null;
|
|
3976
|
+
const activeIndex = active ? items.indexOf(active.id) : -1;
|
|
3977
|
+
const overIndex = over ? items.indexOf(over.id) : -1;
|
|
3978
|
+
const previousItemsRef = useRef4(items);
|
|
3979
|
+
const itemsHaveChanged = !itemsEqual(items, previousItemsRef.current);
|
|
3980
|
+
const disableTransforms = overIndex !== -1 && activeIndex === -1 || itemsHaveChanged;
|
|
3981
|
+
const disabled = normalizeDisabled(disabledProp);
|
|
3982
|
+
useIsomorphicLayoutEffect(() => {
|
|
3983
|
+
if (itemsHaveChanged && isDragging) {
|
|
3984
|
+
measureDroppableContainers(items);
|
|
3985
|
+
}
|
|
3986
|
+
}, [itemsHaveChanged, items, isDragging, measureDroppableContainers]);
|
|
3987
|
+
useEffect4(() => {
|
|
3988
|
+
previousItemsRef.current = items;
|
|
3989
|
+
}, [items]);
|
|
3990
|
+
const contextValue = useMemo4(
|
|
3991
|
+
() => ({
|
|
3992
|
+
activeIndex,
|
|
3993
|
+
containerId,
|
|
3994
|
+
disabled,
|
|
3995
|
+
disableTransforms,
|
|
3996
|
+
items,
|
|
3997
|
+
overIndex,
|
|
3998
|
+
useDragOverlay,
|
|
3999
|
+
sortedRects: getSortedRects(items, droppableRects),
|
|
4000
|
+
strategy
|
|
4001
|
+
}),
|
|
4002
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4003
|
+
[activeIndex, containerId, disabled.draggable, disabled.droppable, disableTransforms, items, overIndex, droppableRects, useDragOverlay, strategy]
|
|
4004
|
+
);
|
|
4005
|
+
return React3.createElement(Context.Provider, {
|
|
4006
|
+
value: contextValue
|
|
4007
|
+
}, children);
|
|
4008
|
+
}
|
|
4009
|
+
var defaultNewIndexGetter = (_ref) => {
|
|
4010
|
+
let {
|
|
4011
|
+
id,
|
|
4012
|
+
items,
|
|
4013
|
+
activeIndex,
|
|
4014
|
+
overIndex
|
|
4015
|
+
} = _ref;
|
|
4016
|
+
return arrayMove(items, activeIndex, overIndex).indexOf(id);
|
|
4017
|
+
};
|
|
4018
|
+
var defaultAnimateLayoutChanges = (_ref2) => {
|
|
4019
|
+
let {
|
|
4020
|
+
containerId,
|
|
4021
|
+
isSorting,
|
|
4022
|
+
wasDragging,
|
|
4023
|
+
index,
|
|
4024
|
+
items,
|
|
4025
|
+
newIndex,
|
|
4026
|
+
previousItems,
|
|
4027
|
+
previousContainerId,
|
|
4028
|
+
transition
|
|
4029
|
+
} = _ref2;
|
|
4030
|
+
if (!transition || !wasDragging) {
|
|
4031
|
+
return false;
|
|
4032
|
+
}
|
|
4033
|
+
if (previousItems !== items && index === newIndex) {
|
|
4034
|
+
return false;
|
|
4035
|
+
}
|
|
4036
|
+
if (isSorting) {
|
|
4037
|
+
return true;
|
|
4038
|
+
}
|
|
4039
|
+
return newIndex !== index && containerId === previousContainerId;
|
|
4040
|
+
};
|
|
4041
|
+
var defaultTransition = {
|
|
4042
|
+
duration: 200,
|
|
4043
|
+
easing: "ease"
|
|
4044
|
+
};
|
|
4045
|
+
var transitionProperty = "transform";
|
|
4046
|
+
var disabledTransition = /* @__PURE__ */ CSS.Transition.toString({
|
|
4047
|
+
property: transitionProperty,
|
|
4048
|
+
duration: 0,
|
|
4049
|
+
easing: "linear"
|
|
4050
|
+
});
|
|
4051
|
+
var defaultAttributes = {
|
|
4052
|
+
roleDescription: "sortable"
|
|
4053
|
+
};
|
|
4054
|
+
function useDerivedTransform(_ref) {
|
|
4055
|
+
let {
|
|
4056
|
+
disabled,
|
|
4057
|
+
index,
|
|
4058
|
+
node,
|
|
4059
|
+
rect
|
|
4060
|
+
} = _ref;
|
|
4061
|
+
const [derivedTransform, setDerivedtransform] = useState4(null);
|
|
4062
|
+
const previousIndex = useRef4(index);
|
|
4063
|
+
useIsomorphicLayoutEffect(() => {
|
|
4064
|
+
if (!disabled && index !== previousIndex.current && node.current) {
|
|
4065
|
+
const initial = rect.current;
|
|
4066
|
+
if (initial) {
|
|
4067
|
+
const current = getClientRect(node.current, {
|
|
4068
|
+
ignoreTransform: true
|
|
4069
|
+
});
|
|
4070
|
+
const delta = {
|
|
4071
|
+
x: initial.left - current.left,
|
|
4072
|
+
y: initial.top - current.top,
|
|
4073
|
+
scaleX: initial.width / current.width,
|
|
4074
|
+
scaleY: initial.height / current.height
|
|
4075
|
+
};
|
|
4076
|
+
if (delta.x || delta.y) {
|
|
4077
|
+
setDerivedtransform(delta);
|
|
4078
|
+
}
|
|
4079
|
+
}
|
|
4080
|
+
}
|
|
4081
|
+
if (index !== previousIndex.current) {
|
|
4082
|
+
previousIndex.current = index;
|
|
4083
|
+
}
|
|
4084
|
+
}, [disabled, index, node, rect]);
|
|
4085
|
+
useEffect4(() => {
|
|
4086
|
+
if (derivedTransform) {
|
|
4087
|
+
setDerivedtransform(null);
|
|
4088
|
+
}
|
|
4089
|
+
}, [derivedTransform]);
|
|
4090
|
+
return derivedTransform;
|
|
4091
|
+
}
|
|
4092
|
+
function useSortable(_ref) {
|
|
4093
|
+
let {
|
|
4094
|
+
animateLayoutChanges = defaultAnimateLayoutChanges,
|
|
4095
|
+
attributes: userDefinedAttributes,
|
|
4096
|
+
disabled: localDisabled,
|
|
4097
|
+
data: customData,
|
|
4098
|
+
getNewIndex = defaultNewIndexGetter,
|
|
4099
|
+
id,
|
|
4100
|
+
strategy: localStrategy,
|
|
4101
|
+
resizeObserverConfig,
|
|
4102
|
+
transition = defaultTransition
|
|
4103
|
+
} = _ref;
|
|
4104
|
+
const {
|
|
4105
|
+
items,
|
|
4106
|
+
containerId,
|
|
4107
|
+
activeIndex,
|
|
4108
|
+
disabled: globalDisabled,
|
|
4109
|
+
disableTransforms,
|
|
4110
|
+
sortedRects,
|
|
4111
|
+
overIndex,
|
|
4112
|
+
useDragOverlay,
|
|
4113
|
+
strategy: globalStrategy
|
|
4114
|
+
} = useContext2(Context);
|
|
4115
|
+
const disabled = normalizeLocalDisabled(localDisabled, globalDisabled);
|
|
4116
|
+
const index = items.indexOf(id);
|
|
4117
|
+
const data = useMemo4(() => ({
|
|
4118
|
+
sortable: {
|
|
4119
|
+
containerId,
|
|
4120
|
+
index,
|
|
4121
|
+
items
|
|
4122
|
+
},
|
|
4123
|
+
...customData
|
|
4124
|
+
}), [containerId, customData, index, items]);
|
|
4125
|
+
const itemsAfterCurrentSortable = useMemo4(() => items.slice(items.indexOf(id)), [items, id]);
|
|
4126
|
+
const {
|
|
4127
|
+
rect,
|
|
4128
|
+
node,
|
|
4129
|
+
isOver,
|
|
4130
|
+
setNodeRef: setDroppableNodeRef
|
|
4131
|
+
} = useDroppable({
|
|
4132
|
+
id,
|
|
4133
|
+
data,
|
|
4134
|
+
disabled: disabled.droppable,
|
|
4135
|
+
resizeObserverConfig: {
|
|
4136
|
+
updateMeasurementsFor: itemsAfterCurrentSortable,
|
|
4137
|
+
...resizeObserverConfig
|
|
4138
|
+
}
|
|
4139
|
+
});
|
|
4140
|
+
const {
|
|
4141
|
+
active,
|
|
4142
|
+
activatorEvent,
|
|
4143
|
+
activeNodeRect,
|
|
4144
|
+
attributes,
|
|
4145
|
+
setNodeRef: setDraggableNodeRef,
|
|
4146
|
+
listeners,
|
|
4147
|
+
isDragging,
|
|
4148
|
+
over,
|
|
4149
|
+
setActivatorNodeRef,
|
|
4150
|
+
transform
|
|
4151
|
+
} = useDraggable({
|
|
4152
|
+
id,
|
|
4153
|
+
data,
|
|
4154
|
+
attributes: {
|
|
4155
|
+
...defaultAttributes,
|
|
4156
|
+
...userDefinedAttributes
|
|
4157
|
+
},
|
|
4158
|
+
disabled: disabled.draggable
|
|
4159
|
+
});
|
|
4160
|
+
const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
|
|
4161
|
+
const isSorting = Boolean(active);
|
|
4162
|
+
const displaceItem = isSorting && !disableTransforms && isValidIndex(activeIndex) && isValidIndex(overIndex);
|
|
4163
|
+
const shouldDisplaceDragSource = !useDragOverlay && isDragging;
|
|
4164
|
+
const dragSourceDisplacement = shouldDisplaceDragSource && displaceItem ? transform : null;
|
|
4165
|
+
const strategy = localStrategy != null ? localStrategy : globalStrategy;
|
|
4166
|
+
const finalTransform = displaceItem ? dragSourceDisplacement != null ? dragSourceDisplacement : strategy({
|
|
4167
|
+
rects: sortedRects,
|
|
4168
|
+
activeNodeRect,
|
|
4169
|
+
activeIndex,
|
|
4170
|
+
overIndex,
|
|
4171
|
+
index
|
|
4172
|
+
}) : null;
|
|
4173
|
+
const newIndex = isValidIndex(activeIndex) && isValidIndex(overIndex) ? getNewIndex({
|
|
4174
|
+
id,
|
|
4175
|
+
items,
|
|
4176
|
+
activeIndex,
|
|
4177
|
+
overIndex
|
|
4178
|
+
}) : index;
|
|
4179
|
+
const activeId = active == null ? void 0 : active.id;
|
|
4180
|
+
const previous = useRef4({
|
|
4181
|
+
activeId,
|
|
4182
|
+
items,
|
|
4183
|
+
newIndex,
|
|
4184
|
+
containerId
|
|
4185
|
+
});
|
|
4186
|
+
const itemsHaveChanged = items !== previous.current.items;
|
|
4187
|
+
const shouldAnimateLayoutChanges = animateLayoutChanges({
|
|
4188
|
+
active,
|
|
4189
|
+
containerId,
|
|
4190
|
+
isDragging,
|
|
4191
|
+
isSorting,
|
|
4192
|
+
id,
|
|
4193
|
+
index,
|
|
4194
|
+
items,
|
|
4195
|
+
newIndex: previous.current.newIndex,
|
|
4196
|
+
previousItems: previous.current.items,
|
|
4197
|
+
previousContainerId: previous.current.containerId,
|
|
4198
|
+
transition,
|
|
4199
|
+
wasDragging: previous.current.activeId != null
|
|
4200
|
+
});
|
|
4201
|
+
const derivedTransform = useDerivedTransform({
|
|
4202
|
+
disabled: !shouldAnimateLayoutChanges,
|
|
4203
|
+
index,
|
|
4204
|
+
node,
|
|
4205
|
+
rect
|
|
4206
|
+
});
|
|
4207
|
+
useEffect4(() => {
|
|
4208
|
+
if (isSorting && previous.current.newIndex !== newIndex) {
|
|
4209
|
+
previous.current.newIndex = newIndex;
|
|
4210
|
+
}
|
|
4211
|
+
if (containerId !== previous.current.containerId) {
|
|
4212
|
+
previous.current.containerId = containerId;
|
|
4213
|
+
}
|
|
4214
|
+
if (items !== previous.current.items) {
|
|
4215
|
+
previous.current.items = items;
|
|
4216
|
+
}
|
|
4217
|
+
}, [isSorting, newIndex, containerId, items]);
|
|
4218
|
+
useEffect4(() => {
|
|
4219
|
+
if (activeId === previous.current.activeId) {
|
|
4220
|
+
return;
|
|
4221
|
+
}
|
|
4222
|
+
if (activeId != null && previous.current.activeId == null) {
|
|
4223
|
+
previous.current.activeId = activeId;
|
|
4224
|
+
return;
|
|
4225
|
+
}
|
|
4226
|
+
const timeoutId = setTimeout(() => {
|
|
4227
|
+
previous.current.activeId = activeId;
|
|
4228
|
+
}, 50);
|
|
4229
|
+
return () => clearTimeout(timeoutId);
|
|
4230
|
+
}, [activeId]);
|
|
4231
|
+
return {
|
|
4232
|
+
active,
|
|
4233
|
+
activeIndex,
|
|
4234
|
+
attributes,
|
|
4235
|
+
data,
|
|
4236
|
+
rect,
|
|
4237
|
+
index,
|
|
4238
|
+
newIndex,
|
|
4239
|
+
items,
|
|
4240
|
+
isOver,
|
|
4241
|
+
isSorting,
|
|
4242
|
+
isDragging,
|
|
4243
|
+
listeners,
|
|
4244
|
+
node,
|
|
4245
|
+
overIndex,
|
|
4246
|
+
over,
|
|
4247
|
+
setNodeRef,
|
|
4248
|
+
setActivatorNodeRef,
|
|
4249
|
+
setDroppableNodeRef,
|
|
4250
|
+
setDraggableNodeRef,
|
|
4251
|
+
transform: derivedTransform != null ? derivedTransform : finalTransform,
|
|
4252
|
+
transition: getTransition()
|
|
4253
|
+
};
|
|
4254
|
+
function getTransition() {
|
|
4255
|
+
if (
|
|
4256
|
+
// Temporarily disable transitions for a single frame to set up derived transforms
|
|
4257
|
+
derivedTransform || // Or to prevent items jumping to back to their "new" position when items change
|
|
4258
|
+
itemsHaveChanged && previous.current.newIndex === index
|
|
4259
|
+
) {
|
|
4260
|
+
return disabledTransition;
|
|
4261
|
+
}
|
|
4262
|
+
if (shouldDisplaceDragSource && !isKeyboardEvent(activatorEvent) || !transition) {
|
|
4263
|
+
return void 0;
|
|
4264
|
+
}
|
|
4265
|
+
if (isSorting || shouldAnimateLayoutChanges) {
|
|
4266
|
+
return CSS.Transition.toString({
|
|
4267
|
+
...transition,
|
|
4268
|
+
property: transitionProperty
|
|
4269
|
+
});
|
|
4270
|
+
}
|
|
4271
|
+
return void 0;
|
|
4272
|
+
}
|
|
4273
|
+
}
|
|
4274
|
+
function normalizeLocalDisabled(localDisabled, globalDisabled) {
|
|
4275
|
+
var _localDisabled$dragga, _localDisabled$droppa;
|
|
4276
|
+
if (typeof localDisabled === "boolean") {
|
|
4277
|
+
return {
|
|
4278
|
+
draggable: localDisabled,
|
|
4279
|
+
// Backwards compatibility
|
|
4280
|
+
droppable: false
|
|
4281
|
+
};
|
|
4282
|
+
}
|
|
4283
|
+
return {
|
|
4284
|
+
draggable: (_localDisabled$dragga = localDisabled == null ? void 0 : localDisabled.draggable) != null ? _localDisabled$dragga : globalDisabled.draggable,
|
|
4285
|
+
droppable: (_localDisabled$droppa = localDisabled == null ? void 0 : localDisabled.droppable) != null ? _localDisabled$droppa : globalDisabled.droppable
|
|
4286
|
+
};
|
|
4287
|
+
}
|
|
4288
|
+
function hasSortableData(entry) {
|
|
4289
|
+
if (!entry) {
|
|
4290
|
+
return false;
|
|
4291
|
+
}
|
|
4292
|
+
const data = entry.data.current;
|
|
4293
|
+
if (data && "sortable" in data && typeof data.sortable === "object" && "containerId" in data.sortable && "items" in data.sortable && "index" in data.sortable) {
|
|
4294
|
+
return true;
|
|
4295
|
+
}
|
|
4296
|
+
return false;
|
|
4297
|
+
}
|
|
4298
|
+
var directions = [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];
|
|
4299
|
+
var sortableKeyboardCoordinates = (event, _ref) => {
|
|
4300
|
+
let {
|
|
4301
|
+
context: {
|
|
4302
|
+
active,
|
|
4303
|
+
collisionRect,
|
|
4304
|
+
droppableRects,
|
|
4305
|
+
droppableContainers,
|
|
4306
|
+
over,
|
|
4307
|
+
scrollableAncestors
|
|
4308
|
+
}
|
|
4309
|
+
} = _ref;
|
|
4310
|
+
if (directions.includes(event.code)) {
|
|
4311
|
+
event.preventDefault();
|
|
4312
|
+
if (!active || !collisionRect) {
|
|
4313
|
+
return;
|
|
4314
|
+
}
|
|
4315
|
+
const filteredContainers = [];
|
|
4316
|
+
droppableContainers.getEnabled().forEach((entry) => {
|
|
4317
|
+
if (!entry || entry != null && entry.disabled) {
|
|
4318
|
+
return;
|
|
4319
|
+
}
|
|
4320
|
+
const rect = droppableRects.get(entry.id);
|
|
4321
|
+
if (!rect) {
|
|
4322
|
+
return;
|
|
4323
|
+
}
|
|
4324
|
+
switch (event.code) {
|
|
4325
|
+
case KeyboardCode.Down:
|
|
4326
|
+
if (collisionRect.top < rect.top) {
|
|
4327
|
+
filteredContainers.push(entry);
|
|
4328
|
+
}
|
|
4329
|
+
break;
|
|
4330
|
+
case KeyboardCode.Up:
|
|
4331
|
+
if (collisionRect.top > rect.top) {
|
|
4332
|
+
filteredContainers.push(entry);
|
|
4333
|
+
}
|
|
4334
|
+
break;
|
|
4335
|
+
case KeyboardCode.Left:
|
|
4336
|
+
if (collisionRect.left > rect.left) {
|
|
4337
|
+
filteredContainers.push(entry);
|
|
4338
|
+
}
|
|
4339
|
+
break;
|
|
4340
|
+
case KeyboardCode.Right:
|
|
4341
|
+
if (collisionRect.left < rect.left) {
|
|
4342
|
+
filteredContainers.push(entry);
|
|
4343
|
+
}
|
|
4344
|
+
break;
|
|
4345
|
+
}
|
|
4346
|
+
});
|
|
4347
|
+
const collisions = closestCorners({
|
|
4348
|
+
active,
|
|
4349
|
+
collisionRect,
|
|
4350
|
+
droppableRects,
|
|
4351
|
+
droppableContainers: filteredContainers,
|
|
4352
|
+
pointerCoordinates: null
|
|
4353
|
+
});
|
|
4354
|
+
let closestId = getFirstCollision(collisions, "id");
|
|
4355
|
+
if (closestId === (over == null ? void 0 : over.id) && collisions.length > 1) {
|
|
4356
|
+
closestId = collisions[1].id;
|
|
4357
|
+
}
|
|
4358
|
+
if (closestId != null) {
|
|
4359
|
+
const activeDroppable = droppableContainers.get(active.id);
|
|
4360
|
+
const newDroppable = droppableContainers.get(closestId);
|
|
4361
|
+
const newRect = newDroppable ? droppableRects.get(newDroppable.id) : null;
|
|
4362
|
+
const newNode = newDroppable == null ? void 0 : newDroppable.node.current;
|
|
4363
|
+
if (newNode && newRect && activeDroppable && newDroppable) {
|
|
4364
|
+
const newScrollAncestors = getScrollableAncestors(newNode);
|
|
4365
|
+
const hasDifferentScrollAncestors = newScrollAncestors.some((element, index) => scrollableAncestors[index] !== element);
|
|
4366
|
+
const hasSameContainer = isSameContainer(activeDroppable, newDroppable);
|
|
4367
|
+
const isAfterActive = isAfter(activeDroppable, newDroppable);
|
|
4368
|
+
const offset = hasDifferentScrollAncestors || !hasSameContainer ? {
|
|
4369
|
+
x: 0,
|
|
4370
|
+
y: 0
|
|
4371
|
+
} : {
|
|
4372
|
+
x: isAfterActive ? collisionRect.width - newRect.width : 0,
|
|
4373
|
+
y: isAfterActive ? collisionRect.height - newRect.height : 0
|
|
4374
|
+
};
|
|
4375
|
+
const rectCoordinates = {
|
|
4376
|
+
x: newRect.left,
|
|
4377
|
+
y: newRect.top
|
|
4378
|
+
};
|
|
4379
|
+
const newCoordinates = offset.x && offset.y ? rectCoordinates : subtract(rectCoordinates, offset);
|
|
4380
|
+
return newCoordinates;
|
|
4381
|
+
}
|
|
4382
|
+
}
|
|
4383
|
+
}
|
|
4384
|
+
return void 0;
|
|
4385
|
+
};
|
|
4386
|
+
function isSameContainer(a, b) {
|
|
4387
|
+
if (!hasSortableData(a) || !hasSortableData(b)) {
|
|
4388
|
+
return false;
|
|
4389
|
+
}
|
|
4390
|
+
return a.data.current.sortable.containerId === b.data.current.sortable.containerId;
|
|
4391
|
+
}
|
|
4392
|
+
function isAfter(a, b) {
|
|
4393
|
+
if (!hasSortableData(a) || !hasSortableData(b)) {
|
|
4394
|
+
return false;
|
|
4395
|
+
}
|
|
4396
|
+
if (!isSameContainer(a, b)) {
|
|
4397
|
+
return false;
|
|
4398
|
+
}
|
|
4399
|
+
return a.data.current.sortable.index < b.data.current.sortable.index;
|
|
4400
|
+
}
|
|
4401
|
+
|
|
4402
|
+
export {
|
|
4403
|
+
CSS,
|
|
4404
|
+
useSensor,
|
|
4405
|
+
useSensors,
|
|
4406
|
+
closestCenter,
|
|
4407
|
+
KeyboardSensor,
|
|
4408
|
+
PointerSensor,
|
|
4409
|
+
DndContext,
|
|
4410
|
+
arrayMove,
|
|
4411
|
+
horizontalListSortingStrategy,
|
|
4412
|
+
verticalListSortingStrategy,
|
|
4413
|
+
SortableContext,
|
|
4414
|
+
useSortable,
|
|
4415
|
+
sortableKeyboardCoordinates,
|
|
4416
|
+
TableFiltersDropdown
|
|
4417
|
+
};
|
|
4418
|
+
//# sourceMappingURL=chunk-E3XATJ63.js.map
|