@mercurjs/admin 2.0.0-canary.24
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/dist/add-campaign-promotions-JDC36EOE.js +265 -0
- package/dist/adjust-inventory-2YLC4O4I.js +262 -0
- package/dist/api-key-management-create-KERROZ6Z.js +282 -0
- package/dist/api-key-management-detail-PXY2ZH4V.js +481 -0
- package/dist/api-key-management-edit-7IPPTW37.js +106 -0
- package/dist/api-key-management-list-QQHOCVV4.js +350 -0
- package/dist/api-key-management-sales-channels-AO6SRCAW.js +201 -0
- package/dist/campaign-budget-edit-C5PCVES3.js +147 -0
- package/dist/campaign-configuration-ONC2CL7Q.js +154 -0
- package/dist/campaign-create-J2PN77A6.js +29 -0
- package/dist/campaign-detail-2XJ7PXOQ.js +666 -0
- package/dist/campaign-edit-MU4TVOEC.js +206 -0
- package/dist/campaign-list-BWYHTJL2.js +187 -0
- package/dist/categories-metadata-UC3N6YSC.js +83 -0
- package/dist/category-create-DRJZI3EM.js +427 -0
- package/dist/category-detail-DEGYVUXB.js +544 -0
- package/dist/category-edit-PTYOK7VV.js +220 -0
- package/dist/category-list-T4GPTLOA.js +286 -0
- package/dist/category-organize-MLBY54BT.js +110 -0
- package/dist/category-products-W7U2VZTZ.js +281 -0
- package/dist/chunk-25LYVP3C.js +37 -0
- package/dist/chunk-26OOAKQ6.js +18 -0
- package/dist/chunk-2I3BDP2Z.js +61 -0
- package/dist/chunk-2KCF3ZIB.js +32 -0
- package/dist/chunk-2MKZ4HD4.js +175 -0
- package/dist/chunk-2PZGY332.js +88 -0
- package/dist/chunk-2QKPRGNK.js +107 -0
- package/dist/chunk-2Y3WMGN6.js +39 -0
- package/dist/chunk-2ZFELO2L.js +13 -0
- package/dist/chunk-33XUAKRP.js +6 -0
- package/dist/chunk-362QMJZM.js +77 -0
- package/dist/chunk-3CKTAFTR.js +143 -0
- package/dist/chunk-3EF54XFY.js +64 -0
- package/dist/chunk-3KOTDGC2.js +18 -0
- package/dist/chunk-3LDJURK5.js +296 -0
- package/dist/chunk-3QSRE5LS.js +161 -0
- package/dist/chunk-3XPXUIK3.js +34 -0
- package/dist/chunk-4F5GP7J7.js +45 -0
- package/dist/chunk-4GPAS5GW.js +36 -0
- package/dist/chunk-54EPH67T.js +34 -0
- package/dist/chunk-54RTJBYO.js +153 -0
- package/dist/chunk-54TMLQH3.js +9 -0
- package/dist/chunk-5LZ2G4ZX.js +422 -0
- package/dist/chunk-5S6J5PG5.js +182 -0
- package/dist/chunk-6IJMSVC6.js +16 -0
- package/dist/chunk-6KI3GDYH.js +46 -0
- package/dist/chunk-7AV5EJJ5.js +29 -0
- package/dist/chunk-7RPRNVBS.js +45 -0
- package/dist/chunk-7SVLKK6Q.js +31 -0
- package/dist/chunk-AW77UWCZ.js +363 -0
- package/dist/chunk-AWZFIP25.js +117 -0
- package/dist/chunk-AYVH6Q5O.js +31 -0
- package/dist/chunk-BDGZ4EQO.js +86 -0
- package/dist/chunk-BMNW3AEU.js +373 -0
- package/dist/chunk-BRUOBAPY.js +234 -0
- package/dist/chunk-BYZIWSBB.js +185 -0
- package/dist/chunk-C6SUTRP2.js +13 -0
- package/dist/chunk-CBRSGM3X.js +342 -0
- package/dist/chunk-CI5Z6FGV.js +87 -0
- package/dist/chunk-CMHI2RPL.js +20 -0
- package/dist/chunk-CP5IL4P6.js +98 -0
- package/dist/chunk-D3KDXELJ.js +110 -0
- package/dist/chunk-D6IERBVW.js +43 -0
- package/dist/chunk-DB6ANJBO.js +35 -0
- package/dist/chunk-DLKKSPFE.js +50 -0
- package/dist/chunk-DV73MHTN.js +457 -0
- package/dist/chunk-DXZOR4AG.js +69 -0
- package/dist/chunk-DY3XQPHC.js +31 -0
- package/dist/chunk-EOZUAYQL.js +6 -0
- package/dist/chunk-ERTSYQAI.js +121 -0
- package/dist/chunk-EZIB4NST.js +94 -0
- package/dist/chunk-FGZCSG7T.js +232 -0
- package/dist/chunk-FI474ADU.js +0 -0
- package/dist/chunk-FLCYR7E5.js +467 -0
- package/dist/chunk-FMFVTERD.js +0 -0
- package/dist/chunk-FODCCP6C.js +76 -0
- package/dist/chunk-FQERBIVS.js +0 -0
- package/dist/chunk-FWPGOIFA.js +22 -0
- package/dist/chunk-G5OVX555.js +26 -0
- package/dist/chunk-GUIDZSDY.js +41 -0
- package/dist/chunk-H22XDSXD.js +47 -0
- package/dist/chunk-HC25LNX7.js +45 -0
- package/dist/chunk-HINXQTCW.js +97 -0
- package/dist/chunk-HYUGYB23.js +161 -0
- package/dist/chunk-I43SCBL3.js +106 -0
- package/dist/chunk-IGTRIAUC.js +84 -0
- package/dist/chunk-INNFZYX2.js +183 -0
- package/dist/chunk-IQPN4PZJ.js +749 -0
- package/dist/chunk-IZ5RG5XI.js +72 -0
- package/dist/chunk-JDGE23BZ.js +332 -0
- package/dist/chunk-JHIMVLB2.js +42 -0
- package/dist/chunk-JISYRXUS.js +389 -0
- package/dist/chunk-JJVGCTKT.js +243 -0
- package/dist/chunk-JQV7CXEC.js +37 -0
- package/dist/chunk-JRTZWK77.js +1764 -0
- package/dist/chunk-KAZ5BYTQ.js +132 -0
- package/dist/chunk-KBYZLKI4.js +1093 -0
- package/dist/chunk-KTKL7M34.js +90 -0
- package/dist/chunk-KUWNYCGL.js +4113 -0
- package/dist/chunk-KW56S7WF.js +67 -0
- package/dist/chunk-LAVHRER2.js +17 -0
- package/dist/chunk-LCZXAT4Q.js +58 -0
- package/dist/chunk-LFKTHNWI.js +83 -0
- package/dist/chunk-LGJWR5LX.js +164 -0
- package/dist/chunk-LLWK3OR6.js +169 -0
- package/dist/chunk-LQSLDDPT.js +67 -0
- package/dist/chunk-LR4ACD6E.js +86676 -0
- package/dist/chunk-LTBX54CI.js +11 -0
- package/dist/chunk-LXP7K6HL.js +817 -0
- package/dist/chunk-LXSBG6LK.js +18 -0
- package/dist/chunk-LZALOVO3.js +372 -0
- package/dist/chunk-M6SOYQJ6.js +39 -0
- package/dist/chunk-MAEP2UCK.js +110 -0
- package/dist/chunk-MG4GKUJW.js +31 -0
- package/dist/chunk-MWOKFNRO.js +446 -0
- package/dist/chunk-N2TQXB44.js +1280 -0
- package/dist/chunk-N5IUYCUZ.js +31 -0
- package/dist/chunk-NBMM2TZK.js +33 -0
- package/dist/chunk-NCMUZ6BQ.js +0 -0
- package/dist/chunk-NCYTM57J.js +160 -0
- package/dist/chunk-NIRWGTM3.js +1104 -0
- package/dist/chunk-NS5CHWOH.js +80 -0
- package/dist/chunk-NWQRHWE5.js +9461 -0
- package/dist/chunk-NXDFDEKP.js +0 -0
- package/dist/chunk-NZJGUN67.js +266 -0
- package/dist/chunk-NZN7PFPB.js +169 -0
- package/dist/chunk-O5HZRJPB.js +55 -0
- package/dist/chunk-O5VKW5FL.js +41 -0
- package/dist/chunk-O67KME6D.js +110 -0
- package/dist/chunk-ODBDAABQ.js +88 -0
- package/dist/chunk-OGYWOPHZ.js +96 -0
- package/dist/chunk-ORW4HNX5.js +357 -0
- package/dist/chunk-P3IZB24Y.js +109 -0
- package/dist/chunk-PHOCVOZ5.js +9 -0
- package/dist/chunk-PVZBDWLK.js +41 -0
- package/dist/chunk-PX675AEP.js +129 -0
- package/dist/chunk-PXYDR7WQ.js +48 -0
- package/dist/chunk-QDPLZDMX.js +17 -0
- package/dist/chunk-QG6PLWNH.js +106 -0
- package/dist/chunk-QSGR43JM.js +30 -0
- package/dist/chunk-RK5N3XIX.js +56 -0
- package/dist/chunk-RLMLYJDI.js +38 -0
- package/dist/chunk-RMXYSYK4.js +50 -0
- package/dist/chunk-RPIJY6TT.js +637 -0
- package/dist/chunk-RSBZREKG.js +144 -0
- package/dist/chunk-RXM4B6HR.js +8 -0
- package/dist/chunk-S2WEYEQR.js +14 -0
- package/dist/chunk-S4SVK5DE.js +39 -0
- package/dist/chunk-S6LPCNXQ.js +29 -0
- package/dist/chunk-SMQT3ZNO.js +8 -0
- package/dist/chunk-T435NFHC.js +490 -0
- package/dist/chunk-THHRRYRS.js +16 -0
- package/dist/chunk-TKGWSUEI.js +0 -0
- package/dist/chunk-TLE6YHGH.js +26 -0
- package/dist/chunk-TN4TIT7O.js +116 -0
- package/dist/chunk-TUJIAA5O.js +101 -0
- package/dist/chunk-U2EI2ZLM.js +32 -0
- package/dist/chunk-U2L77ZDR.js +17 -0
- package/dist/chunk-U2UCL2VG.js +369 -0
- package/dist/chunk-U2ZFCAPX.js +34 -0
- package/dist/chunk-U5MJIHLY.js +87 -0
- package/dist/chunk-U62GYN4A.js +227 -0
- package/dist/chunk-UM7ZR3VU.js +14 -0
- package/dist/chunk-UQITHKTH.js +342 -0
- package/dist/chunk-UZJ2NQSN.js +257 -0
- package/dist/chunk-UZWFZMOX.js +40 -0
- package/dist/chunk-V74Y5NIV.js +49 -0
- package/dist/chunk-VBMMWVB5.js +49 -0
- package/dist/chunk-VKOE5J66.js +31 -0
- package/dist/chunk-VOHEQ7B5.js +31 -0
- package/dist/chunk-VVTSF42Z.js +52 -0
- package/dist/chunk-VW56KWO2.js +9 -0
- package/dist/chunk-VWGKHDZ6.js +528 -0
- package/dist/chunk-W6Y3PPU5.js +73 -0
- package/dist/chunk-WCEMRNW4.js +6 -0
- package/dist/chunk-WDZFLCSQ.js +77 -0
- package/dist/chunk-WIYFXWRI.js +30 -0
- package/dist/chunk-WMA3WTCM.js +117 -0
- package/dist/chunk-WWANSDFM.js +175 -0
- package/dist/chunk-XBMLI2YI.js +85 -0
- package/dist/chunk-XBVIP2BA.js +609 -0
- package/dist/chunk-XCMR2HTV.js +102 -0
- package/dist/chunk-XFR5JLNF.js +44 -0
- package/dist/chunk-XL52SYWY.js +23 -0
- package/dist/chunk-XQNVC4Q7.js +212 -0
- package/dist/chunk-XSX255FK.js +12 -0
- package/dist/chunk-Y2M536WR.js +67 -0
- package/dist/chunk-Y456KVIN.js +116 -0
- package/dist/chunk-Y7QKP6QU.js +35 -0
- package/dist/chunk-YBZWO4ZV.js +57 -0
- package/dist/chunk-YGQUBTKR.js +81 -0
- package/dist/chunk-YGSM5PVN.js +170 -0
- package/dist/chunk-YVCBMOJG.js +50 -0
- package/dist/chunk-YWWUOGJA.js +62 -0
- package/dist/chunk-YXFG3M2D.js +792 -0
- package/dist/chunk-ZAUMHCIL.js +42 -0
- package/dist/chunk-ZDJWCSZ4.js +85 -0
- package/dist/chunk-ZQZHFMD7.js +19 -0
- package/dist/chunk-ZYNBKBY3.js +14 -0
- package/dist/collection-add-products-IUDEIUM5.js +284 -0
- package/dist/collection-create-AQ3GUG3G.js +133 -0
- package/dist/collection-detail-SDFALX6M.js +444 -0
- package/dist/collection-edit-AAHL2WFH.js +121 -0
- package/dist/collection-list-JGKC5EVM.js +228 -0
- package/dist/collection-metadata-YQWA2JTU.js +80 -0
- package/dist/customer-create-5VT2TB6S.js +183 -0
- package/dist/customer-create-address-ICEFEFD2.js +299 -0
- package/dist/customer-detail-CDELSJ77.js +695 -0
- package/dist/customer-edit-DZAD53JC.js +192 -0
- package/dist/customer-list-EIQP23FQ.js +152 -0
- package/dist/customer-metadata-ATAORBRN.js +81 -0
- package/dist/customers-add-customer-group-542PUCCT.js +308 -0
- package/dist/edit-inventory-item-P2HVULPA.js +152 -0
- package/dist/edit-inventory-item-attributes-V2HK3WTQ.js +323 -0
- package/dist/edit-reservation-LX2Z6KVD.js +246 -0
- package/dist/edit-rules-Q5UNWAUD.js +316 -0
- package/dist/home-I3OILW5Z.js +16 -0
- package/dist/index.css +6 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +4824 -0
- package/dist/inventory-create-FT7GL4RK.js +616 -0
- package/dist/inventory-detail-LNZ5QC67.js +771 -0
- package/dist/inventory-list-UXY7PU3N.js +432 -0
- package/dist/inventory-metadata-OYETRH5X.js +83 -0
- package/dist/inventory-stock-3MBERL3K.js +288 -0
- package/dist/invite-HJ7BRO6H.js +372 -0
- package/dist/location-create-ZVVQT2KP.js +238 -0
- package/dist/location-detail-A5SHPUQN.js +823 -0
- package/dist/location-edit-QSRHHDQ2.js +253 -0
- package/dist/location-fulfillment-providers-4HMT5L7L.js +289 -0
- package/dist/location-list-TC5FEN5R.js +346 -0
- package/dist/location-sales-channels-STDHWQSC.js +215 -0
- package/dist/location-service-zone-create-63LUYCJI.js +173 -0
- package/dist/location-service-zone-edit-UNXI5BQV.js +134 -0
- package/dist/location-service-zone-manage-areas-UMD6CZDZ.js +154 -0
- package/dist/location-service-zone-shipping-option-create-5L73SAGE.js +807 -0
- package/dist/location-service-zone-shipping-option-edit-2FEWQD6Y.js +362 -0
- package/dist/location-service-zone-shipping-option-pricing-QSB56QZD.js +362 -0
- package/dist/login-V4HZQTCQ.js +254 -0
- package/dist/manage-locations-NVHONEZE.js +249 -0
- package/dist/no-match-JLVLPCRH.js +33 -0
- package/dist/order-allocate-items-F7CXZQGX.js +558 -0
- package/dist/order-create-claim-GDVWGZJA.js +2203 -0
- package/dist/order-create-edit-6YYKYT66.js +936 -0
- package/dist/order-create-exchange-NLDIMGBG.js +2190 -0
- package/dist/order-create-fulfillment-EIYGSKXP.js +621 -0
- package/dist/order-create-refund-BBXEZNWA.js +403 -0
- package/dist/order-create-return-6TA5J3AW.js +1292 -0
- package/dist/order-create-shipment-T4C6UE2K.js +208 -0
- package/dist/order-detail-Y4EG3P5F.js +3846 -0
- package/dist/order-edit-billing-address-NNIFUC5C.js +400 -0
- package/dist/order-edit-email-VXOX62P6.js +171 -0
- package/dist/order-edit-shipping-address-WDKCQRRG.js +397 -0
- package/dist/order-list-XDOAXZXN.js +231 -0
- package/dist/order-metadata-S6N3GDOA.js +82 -0
- package/dist/order-receive-return-5VWUPWZJ.js +549 -0
- package/dist/order-request-transfer-VFSY5IFF.js +571 -0
- package/dist/price-list-configuration-GH67LL2N.js +356 -0
- package/dist/price-list-create-INX5HG7G.js +973 -0
- package/dist/price-list-detail-5LGPE67O.js +540 -0
- package/dist/price-list-edit-HRWPEIZI.js +227 -0
- package/dist/price-list-list-IXZVTXU5.js +228 -0
- package/dist/price-list-prices-add-QHE3TUTV.js +614 -0
- package/dist/price-list-prices-edit-TMVJ7S7J.js +326 -0
- package/dist/product-attributes-P7WFH4I2.js +358 -0
- package/dist/product-create-YC6MCJ2M.js +2305 -0
- package/dist/product-create-option-BNF2KKJM.js +144 -0
- package/dist/product-create-variant-SIJX7AE3.js +837 -0
- package/dist/product-detail-2GJ3PGHW.js +1638 -0
- package/dist/product-edit-YOGTWZ4I.js +397 -0
- package/dist/product-edit-option-4MUSMFS7.js +152 -0
- package/dist/product-export-5L4HNM3W.js +127 -0
- package/dist/product-import-Y54VG4AC.js +261 -0
- package/dist/product-list-EV2TS3Y4.js +313 -0
- package/dist/product-media-ZSMGHCNP.js +879 -0
- package/dist/product-metadata-572YVJH3.js +80 -0
- package/dist/product-organization-LVKRBJOQ.js +312 -0
- package/dist/product-prices-K5YM2TL6.js +266 -0
- package/dist/product-sales-channels-J3OH4NWX.js +157 -0
- package/dist/product-shipping-profile-NOOFEUBZ.js +146 -0
- package/dist/product-stock-J4LTIX64.js +540 -0
- package/dist/product-tag-create-5JJPPELP.js +122 -0
- package/dist/product-tag-detail-CGLCH3BJ.js +281 -0
- package/dist/product-tag-edit-OR7KSC7I.js +134 -0
- package/dist/product-tag-list-DY7GJUJQ.js +259 -0
- package/dist/product-tag-metadata-BFGPRMME.js +80 -0
- package/dist/product-type-create-FPVSGIKL.js +101 -0
- package/dist/product-type-detail-JYW2DAM4.js +242 -0
- package/dist/product-type-edit-FBT4Z4ZJ.js +113 -0
- package/dist/product-type-list-FK237DSQ.js +175 -0
- package/dist/product-type-metadata-SFJR5OQN.js +80 -0
- package/dist/product-variant-detail-6KPB3HL7.js +485 -0
- package/dist/product-variant-edit-QFHGNDW7.js +538 -0
- package/dist/product-variant-manage-inventory-items-ZEX2IW53.js +340 -0
- package/dist/product-variant-metadata-F45CSWU6.js +86 -0
- package/dist/profile-detail-LLXUNQOT.js +89 -0
- package/dist/profile-edit-UDYMDQLT.js +176 -0
- package/dist/promotion-add-campaign-U6X2FNWZ.js +43 -0
- package/dist/promotion-create-QB7E277L.js +1258 -0
- package/dist/promotion-detail-7D6D6PQ7.js +486 -0
- package/dist/promotion-edit-details-HYQJAZDF.js +512 -0
- package/dist/promotion-list-HTJ5GIWG.js +206 -0
- package/dist/refund-reason-create-LZCL6QJI.js +192 -0
- package/dist/refund-reason-edit-QNGFKZMN.js +192 -0
- package/dist/refund-reason-list-ZEKWYQ45.js +233 -0
- package/dist/region-add-countries-CWJ62VPK.js +226 -0
- package/dist/region-create-Z3JQFIKN.js +507 -0
- package/dist/region-detail-46R3HACJ.js +508 -0
- package/dist/region-edit-W5IVVP7Z.js +380 -0
- package/dist/region-list-DCU6NQFA.js +205 -0
- package/dist/region-metadata-VG5DLCOK.js +83 -0
- package/dist/reservation-create-VG5FSV3F.js +309 -0
- package/dist/reservation-detail-36BA3V2F.js +221 -0
- package/dist/reservation-list-R5UBPNI4.js +298 -0
- package/dist/reservation-metadata-KR4HOHTH.js +83 -0
- package/dist/reset-password-VZPICVMM.js +458 -0
- package/dist/return-reason-create-KTKI6NJE.js +165 -0
- package/dist/return-reason-edit-5KU7WKJF.js +168 -0
- package/dist/return-reason-list-HBSKNIMW.js +240 -0
- package/dist/sales-channel-add-products-6TUDLE4D.js +274 -0
- package/dist/sales-channel-create-2BTWSYIK.js +154 -0
- package/dist/sales-channel-detail-IQIQDN3L.js +437 -0
- package/dist/sales-channel-edit-YBNPALFT.js +163 -0
- package/dist/sales-channel-list-5KNN734B.js +193 -0
- package/dist/sales-channel-metadata-SVW6FYSV.js +88 -0
- package/dist/seller-details-HBVN4GGD.js +77 -0
- package/dist/seller-edit-OXDARXYJ.js +387 -0
- package/dist/seller-list-HG2VXA6V.js +192 -0
- package/dist/settings-D43GVDOO.js +19 -0
- package/dist/shipping-option-type-create-7KYU5NNF.js +195 -0
- package/dist/shipping-option-type-detail-4CNTT3MO.js +169 -0
- package/dist/shipping-option-type-edit-AN6IPVI6.js +191 -0
- package/dist/shipping-option-type-list-36ZS2QZO.js +266 -0
- package/dist/shipping-profile-create-3OWHNAOB.js +123 -0
- package/dist/shipping-profile-detail-WW7IVUVV.js +157 -0
- package/dist/shipping-profile-metadata-AD3DSZLR.js +84 -0
- package/dist/shipping-profiles-list-WOGGP7IT.js +241 -0
- package/dist/store-add-currencies-PIGEOZ4G.js +304 -0
- package/dist/store-detail-MFHPXBIN.js +525 -0
- package/dist/store-edit-WBF6EL5N.js +246 -0
- package/dist/store-metadata-LSK7UVSC.js +85 -0
- package/dist/tax-region-create-XTX4YWRA.js +300 -0
- package/dist/tax-region-detail-XUYJHBHI.js +320 -0
- package/dist/tax-region-edit-AC64YA64.js +162 -0
- package/dist/tax-region-list-XRAYDYK3.js +91 -0
- package/dist/tax-region-metadata-YDQX3Y4X.js +83 -0
- package/dist/tax-region-province-create-GDL65SQF.js +315 -0
- package/dist/tax-region-province-detail-QMPIKT7K.js +215 -0
- package/dist/tax-region-tax-override-create-X2QWOHSU.js +679 -0
- package/dist/tax-region-tax-override-edit-VZJ6EPSU.js +788 -0
- package/dist/tax-region-tax-rate-create-VC2WDVJJ.js +193 -0
- package/dist/tax-region-tax-rate-edit-SDW36H6I.js +192 -0
- package/dist/user-detail-IEIX24PZ.js +163 -0
- package/dist/user-edit-CJ7TNY3H.js +115 -0
- package/dist/user-invite-OTBYWV4L.js +389 -0
- package/dist/user-list-BJXFPTJ7.js +341 -0
- package/dist/user-metadata-ZLC6T6XH.js +83 -0
- package/package.json +87 -0
|
@@ -0,0 +1,792 @@
|
|
|
1
|
+
// src/components/common/sortable-tree/sortable-tree.tsx
|
|
2
|
+
import {
|
|
3
|
+
DndContext,
|
|
4
|
+
DragOverlay,
|
|
5
|
+
KeyboardSensor,
|
|
6
|
+
MeasuringStrategy,
|
|
7
|
+
PointerSensor,
|
|
8
|
+
closestCenter,
|
|
9
|
+
defaultDropAnimation,
|
|
10
|
+
useSensor,
|
|
11
|
+
useSensors
|
|
12
|
+
} from "@dnd-kit/core";
|
|
13
|
+
import {
|
|
14
|
+
SortableContext,
|
|
15
|
+
arrayMove as arrayMove2,
|
|
16
|
+
verticalListSortingStrategy
|
|
17
|
+
} from "@dnd-kit/sortable";
|
|
18
|
+
import { CSS as CSS2 } from "@dnd-kit/utilities";
|
|
19
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
20
|
+
import { createPortal } from "react-dom";
|
|
21
|
+
|
|
22
|
+
// src/components/common/sortable-tree/keyboard-coordinates.ts
|
|
23
|
+
import {
|
|
24
|
+
KeyboardCode,
|
|
25
|
+
closestCorners,
|
|
26
|
+
getFirstCollision
|
|
27
|
+
} from "@dnd-kit/core";
|
|
28
|
+
|
|
29
|
+
// src/components/common/sortable-tree/utils.ts
|
|
30
|
+
import { arrayMove } from "@dnd-kit/sortable";
|
|
31
|
+
var iOS = /iPad|iPhone|iPod/.test(navigator.platform);
|
|
32
|
+
function getDragDepth(offset, indentationWidth) {
|
|
33
|
+
return Math.round(offset / indentationWidth);
|
|
34
|
+
}
|
|
35
|
+
function getProjection(items, activeId, overId, dragOffset, indentationWidth) {
|
|
36
|
+
const overItemIndex = items.findIndex(({ id }) => id === overId);
|
|
37
|
+
const activeItemIndex = items.findIndex(({ id }) => id === activeId);
|
|
38
|
+
const activeItem = items[activeItemIndex];
|
|
39
|
+
const newItems = arrayMove(items, activeItemIndex, overItemIndex);
|
|
40
|
+
const previousItem = newItems[overItemIndex - 1];
|
|
41
|
+
const nextItem = newItems[overItemIndex + 1];
|
|
42
|
+
const dragDepth = getDragDepth(dragOffset, indentationWidth);
|
|
43
|
+
const projectedDepth = activeItem.depth + dragDepth;
|
|
44
|
+
const maxDepth = getMaxDepth({
|
|
45
|
+
previousItem
|
|
46
|
+
});
|
|
47
|
+
const minDepth = getMinDepth({ nextItem });
|
|
48
|
+
let depth = projectedDepth;
|
|
49
|
+
if (projectedDepth >= maxDepth) {
|
|
50
|
+
depth = maxDepth;
|
|
51
|
+
} else if (projectedDepth < minDepth) {
|
|
52
|
+
depth = minDepth;
|
|
53
|
+
}
|
|
54
|
+
return { depth, maxDepth, minDepth, parentId: getParentId() };
|
|
55
|
+
function getParentId() {
|
|
56
|
+
if (depth === 0 || !previousItem) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
if (depth === previousItem.depth) {
|
|
60
|
+
return previousItem.parentId;
|
|
61
|
+
}
|
|
62
|
+
if (depth > previousItem.depth) {
|
|
63
|
+
return previousItem.id;
|
|
64
|
+
}
|
|
65
|
+
const newParent = newItems.slice(0, overItemIndex).reverse().find((item) => item.depth === depth)?.parentId;
|
|
66
|
+
return newParent ?? null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function getMaxDepth({ previousItem }) {
|
|
70
|
+
if (previousItem) {
|
|
71
|
+
return previousItem.depth + 1;
|
|
72
|
+
}
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
function getMinDepth({ nextItem }) {
|
|
76
|
+
if (nextItem) {
|
|
77
|
+
return nextItem.depth;
|
|
78
|
+
}
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
function flatten(items, parentId = null, depth = 0, childrenProp) {
|
|
82
|
+
return items.reduce((acc, item, index) => {
|
|
83
|
+
const children = item[childrenProp] || [];
|
|
84
|
+
return [
|
|
85
|
+
...acc,
|
|
86
|
+
{ ...item, parentId, depth, index },
|
|
87
|
+
...flatten(children, item.id, depth + 1, childrenProp)
|
|
88
|
+
];
|
|
89
|
+
}, []);
|
|
90
|
+
}
|
|
91
|
+
function flattenTree(items, childrenProp) {
|
|
92
|
+
return flatten(items, void 0, void 0, childrenProp);
|
|
93
|
+
}
|
|
94
|
+
function buildTree(flattenedItems, newIndex, childrenProp) {
|
|
95
|
+
const root = { id: "root", [childrenProp]: [] };
|
|
96
|
+
const nodes = { [root.id]: root };
|
|
97
|
+
const items = flattenedItems.map((item) => ({ ...item, [childrenProp]: [] }));
|
|
98
|
+
let update = {
|
|
99
|
+
id: null,
|
|
100
|
+
parentId: null,
|
|
101
|
+
index: 0
|
|
102
|
+
};
|
|
103
|
+
items.forEach((item, index) => {
|
|
104
|
+
const {
|
|
105
|
+
id,
|
|
106
|
+
index: _index,
|
|
107
|
+
depth: _depth,
|
|
108
|
+
parentId: _parentId,
|
|
109
|
+
...rest
|
|
110
|
+
} = item;
|
|
111
|
+
const children = item[childrenProp] || [];
|
|
112
|
+
const parentId = _parentId ?? root.id;
|
|
113
|
+
const parent = nodes[parentId] ?? findItem(items, parentId);
|
|
114
|
+
nodes[id] = { id, [childrenProp]: children };
|
|
115
|
+
parent[childrenProp].push({
|
|
116
|
+
id,
|
|
117
|
+
...rest,
|
|
118
|
+
[childrenProp]: children
|
|
119
|
+
});
|
|
120
|
+
if (index === newIndex) {
|
|
121
|
+
const parentChildren = parent[childrenProp];
|
|
122
|
+
update = {
|
|
123
|
+
id: item.id,
|
|
124
|
+
parentId: parent.id === "root" ? null : parent.id,
|
|
125
|
+
index: parentChildren.length - 1
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
if (!update.id) {
|
|
130
|
+
throw new Error("Could not find item");
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
items: root[childrenProp],
|
|
134
|
+
update
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function findItem(items, itemId) {
|
|
138
|
+
return items.find(({ id }) => id === itemId);
|
|
139
|
+
}
|
|
140
|
+
function findItemDeep(items, itemId, childrenProp) {
|
|
141
|
+
for (const item of items) {
|
|
142
|
+
const { id } = item;
|
|
143
|
+
const children = item[childrenProp] || [];
|
|
144
|
+
if (id === itemId) {
|
|
145
|
+
return item;
|
|
146
|
+
}
|
|
147
|
+
if (children.length) {
|
|
148
|
+
const child = findItemDeep(children, itemId, childrenProp);
|
|
149
|
+
if (child) {
|
|
150
|
+
return child;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return void 0;
|
|
155
|
+
}
|
|
156
|
+
function countChildren(items, count = 0, childrenProp) {
|
|
157
|
+
return items.reduce((acc, item) => {
|
|
158
|
+
const children = item[childrenProp] || [];
|
|
159
|
+
if (children.length) {
|
|
160
|
+
return countChildren(children, acc + 1, childrenProp);
|
|
161
|
+
}
|
|
162
|
+
return acc + 1;
|
|
163
|
+
}, count);
|
|
164
|
+
}
|
|
165
|
+
function getChildCount(items, id, childrenProp) {
|
|
166
|
+
const item = findItemDeep(items, id, childrenProp);
|
|
167
|
+
const children = item?.[childrenProp] || [];
|
|
168
|
+
return item ? countChildren(children, 0, childrenProp) : 0;
|
|
169
|
+
}
|
|
170
|
+
function removeChildrenOf(items, ids, childrenProp) {
|
|
171
|
+
const excludeParentIds = [...ids];
|
|
172
|
+
return items.filter((item) => {
|
|
173
|
+
if (item.parentId && excludeParentIds.includes(item.parentId)) {
|
|
174
|
+
const children = item[childrenProp] || [];
|
|
175
|
+
if (children.length) {
|
|
176
|
+
excludeParentIds.push(item.id);
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
return true;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// src/components/common/sortable-tree/keyboard-coordinates.ts
|
|
185
|
+
var directions = [
|
|
186
|
+
KeyboardCode.Down,
|
|
187
|
+
KeyboardCode.Right,
|
|
188
|
+
KeyboardCode.Up,
|
|
189
|
+
KeyboardCode.Left
|
|
190
|
+
];
|
|
191
|
+
var horizontal = [KeyboardCode.Left, KeyboardCode.Right];
|
|
192
|
+
var sortableTreeKeyboardCoordinates = (context, indentationWidth) => (event, {
|
|
193
|
+
currentCoordinates,
|
|
194
|
+
context: {
|
|
195
|
+
active,
|
|
196
|
+
over,
|
|
197
|
+
collisionRect,
|
|
198
|
+
droppableRects,
|
|
199
|
+
droppableContainers
|
|
200
|
+
}
|
|
201
|
+
}) => {
|
|
202
|
+
if (directions.includes(event.code)) {
|
|
203
|
+
if (!active || !collisionRect) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
event.preventDefault();
|
|
207
|
+
const {
|
|
208
|
+
current: { items, offset }
|
|
209
|
+
} = context;
|
|
210
|
+
if (horizontal.includes(event.code) && over?.id) {
|
|
211
|
+
const { depth, maxDepth, minDepth } = getProjection(
|
|
212
|
+
items,
|
|
213
|
+
active.id,
|
|
214
|
+
over.id,
|
|
215
|
+
offset,
|
|
216
|
+
indentationWidth
|
|
217
|
+
);
|
|
218
|
+
switch (event.code) {
|
|
219
|
+
case KeyboardCode.Left:
|
|
220
|
+
if (depth > minDepth) {
|
|
221
|
+
return {
|
|
222
|
+
...currentCoordinates,
|
|
223
|
+
x: currentCoordinates.x - indentationWidth
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
break;
|
|
227
|
+
case KeyboardCode.Right:
|
|
228
|
+
if (depth < maxDepth) {
|
|
229
|
+
return {
|
|
230
|
+
...currentCoordinates,
|
|
231
|
+
x: currentCoordinates.x + indentationWidth
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
return void 0;
|
|
237
|
+
}
|
|
238
|
+
const containers = [];
|
|
239
|
+
droppableContainers.forEach((container) => {
|
|
240
|
+
if (container?.disabled || container.id === over?.id) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const rect = droppableRects.get(container.id);
|
|
244
|
+
if (!rect) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
switch (event.code) {
|
|
248
|
+
case KeyboardCode.Down:
|
|
249
|
+
if (collisionRect.top < rect.top) {
|
|
250
|
+
containers.push(container);
|
|
251
|
+
}
|
|
252
|
+
break;
|
|
253
|
+
case KeyboardCode.Up:
|
|
254
|
+
if (collisionRect.top > rect.top) {
|
|
255
|
+
containers.push(container);
|
|
256
|
+
}
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
const collisions = closestCorners({
|
|
261
|
+
active,
|
|
262
|
+
collisionRect,
|
|
263
|
+
pointerCoordinates: null,
|
|
264
|
+
droppableRects,
|
|
265
|
+
droppableContainers: containers
|
|
266
|
+
});
|
|
267
|
+
let closestId = getFirstCollision(collisions, "id");
|
|
268
|
+
if (closestId === over?.id && collisions.length > 1) {
|
|
269
|
+
closestId = collisions[1].id;
|
|
270
|
+
}
|
|
271
|
+
if (closestId && over?.id) {
|
|
272
|
+
const activeRect = droppableRects.get(active.id);
|
|
273
|
+
const newRect = droppableRects.get(closestId);
|
|
274
|
+
const newDroppable = droppableContainers.get(closestId);
|
|
275
|
+
if (activeRect && newRect && newDroppable) {
|
|
276
|
+
const newIndex = items.findIndex(({ id }) => id === closestId);
|
|
277
|
+
const newItem = items[newIndex];
|
|
278
|
+
const activeIndex = items.findIndex(({ id }) => id === active.id);
|
|
279
|
+
const activeItem = items[activeIndex];
|
|
280
|
+
if (newItem && activeItem) {
|
|
281
|
+
const { depth } = getProjection(
|
|
282
|
+
items,
|
|
283
|
+
active.id,
|
|
284
|
+
closestId,
|
|
285
|
+
(newItem.depth - activeItem.depth) * indentationWidth,
|
|
286
|
+
indentationWidth
|
|
287
|
+
);
|
|
288
|
+
const isBelow = newIndex > activeIndex;
|
|
289
|
+
const modifier = isBelow ? 1 : -1;
|
|
290
|
+
const offset2 = 0;
|
|
291
|
+
const newCoordinates = {
|
|
292
|
+
x: newRect.left + depth * indentationWidth,
|
|
293
|
+
y: newRect.top + modifier * offset2
|
|
294
|
+
};
|
|
295
|
+
return newCoordinates;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return void 0;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
// src/components/common/sortable-tree/sortable-tree-item.tsx
|
|
304
|
+
import { useSortable } from "@dnd-kit/sortable";
|
|
305
|
+
import { CSS } from "@dnd-kit/utilities";
|
|
306
|
+
|
|
307
|
+
// src/components/common/sortable-tree/tree-item.tsx
|
|
308
|
+
import { forwardRef } from "react";
|
|
309
|
+
import {
|
|
310
|
+
DotsSix,
|
|
311
|
+
FolderIllustration,
|
|
312
|
+
FolderOpenIllustration,
|
|
313
|
+
TagIllustration,
|
|
314
|
+
TriangleRightMini
|
|
315
|
+
} from "@medusajs/icons";
|
|
316
|
+
import { Badge, clx, IconButton } from "@medusajs/ui";
|
|
317
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
318
|
+
var TreeItem = forwardRef(
|
|
319
|
+
({
|
|
320
|
+
childCount,
|
|
321
|
+
clone,
|
|
322
|
+
depth,
|
|
323
|
+
disableSelection,
|
|
324
|
+
disableInteraction,
|
|
325
|
+
ghost,
|
|
326
|
+
handleProps,
|
|
327
|
+
indentationWidth,
|
|
328
|
+
collapsed,
|
|
329
|
+
onCollapse,
|
|
330
|
+
style,
|
|
331
|
+
value,
|
|
332
|
+
disabled,
|
|
333
|
+
wrapperRef,
|
|
334
|
+
...props
|
|
335
|
+
}, ref) => {
|
|
336
|
+
return /* @__PURE__ */ jsx(
|
|
337
|
+
"li",
|
|
338
|
+
{
|
|
339
|
+
ref: wrapperRef,
|
|
340
|
+
style: {
|
|
341
|
+
paddingLeft: `${indentationWidth * depth}px`
|
|
342
|
+
},
|
|
343
|
+
className: clx("-mb-px list-none", {
|
|
344
|
+
"pointer-events-none": disableInteraction,
|
|
345
|
+
"select-none": disableSelection,
|
|
346
|
+
"[&:first-of-type>div]:border-t-0": !clone
|
|
347
|
+
}),
|
|
348
|
+
...props,
|
|
349
|
+
children: /* @__PURE__ */ jsxs(
|
|
350
|
+
"div",
|
|
351
|
+
{
|
|
352
|
+
ref,
|
|
353
|
+
style,
|
|
354
|
+
className: clx(
|
|
355
|
+
"bg-ui-bg-base transition-fg relative flex items-center gap-x-3 border-y px-6 py-2.5",
|
|
356
|
+
{
|
|
357
|
+
"border-l": depth > 0,
|
|
358
|
+
"shadow-elevation-flyout bg-ui-bg-base w-fit rounded-lg border-none pr-6 opacity-80": clone,
|
|
359
|
+
"bg-ui-bg-base-hover z-[1] opacity-50": ghost,
|
|
360
|
+
"bg-ui-bg-disabled": disabled
|
|
361
|
+
}
|
|
362
|
+
),
|
|
363
|
+
children: [
|
|
364
|
+
/* @__PURE__ */ jsx(Handle, { ...handleProps, disabled }),
|
|
365
|
+
/* @__PURE__ */ jsx(
|
|
366
|
+
Collapse,
|
|
367
|
+
{
|
|
368
|
+
collapsed,
|
|
369
|
+
onCollapse,
|
|
370
|
+
clone
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
/* @__PURE__ */ jsx(
|
|
374
|
+
Icon,
|
|
375
|
+
{
|
|
376
|
+
childrenCount: childCount,
|
|
377
|
+
collapsed,
|
|
378
|
+
clone
|
|
379
|
+
}
|
|
380
|
+
),
|
|
381
|
+
/* @__PURE__ */ jsx(Value, { value }),
|
|
382
|
+
/* @__PURE__ */ jsx(ChildrenCount, { clone, childrenCount: childCount })
|
|
383
|
+
]
|
|
384
|
+
}
|
|
385
|
+
)
|
|
386
|
+
}
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
);
|
|
390
|
+
TreeItem.displayName = "TreeItem";
|
|
391
|
+
var Handle = ({
|
|
392
|
+
listeners,
|
|
393
|
+
attributes,
|
|
394
|
+
disabled
|
|
395
|
+
}) => {
|
|
396
|
+
return /* @__PURE__ */ jsx(
|
|
397
|
+
IconButton,
|
|
398
|
+
{
|
|
399
|
+
size: "small",
|
|
400
|
+
variant: "transparent",
|
|
401
|
+
type: "button",
|
|
402
|
+
className: clx("cursor-grab", { "cursor-not-allowed": disabled }),
|
|
403
|
+
disabled,
|
|
404
|
+
...attributes,
|
|
405
|
+
...listeners,
|
|
406
|
+
children: /* @__PURE__ */ jsx(DotsSix, {})
|
|
407
|
+
}
|
|
408
|
+
);
|
|
409
|
+
};
|
|
410
|
+
var Icon = ({ childrenCount, collapsed, clone }) => {
|
|
411
|
+
const isBranch = clone ? childrenCount && childrenCount > 1 : childrenCount;
|
|
412
|
+
const isOpen = clone ? false : !collapsed;
|
|
413
|
+
return /* @__PURE__ */ jsx("div", { className: "flex size-7 items-center justify-center", children: isBranch ? isOpen ? /* @__PURE__ */ jsx(FolderOpenIllustration, {}) : /* @__PURE__ */ jsx(FolderIllustration, {}) : /* @__PURE__ */ jsx(TagIllustration, {}) });
|
|
414
|
+
};
|
|
415
|
+
var Collapse = ({ collapsed, onCollapse, clone }) => {
|
|
416
|
+
if (clone) {
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
if (!onCollapse) {
|
|
420
|
+
return /* @__PURE__ */ jsx("div", { className: "size-7", role: "presentation" });
|
|
421
|
+
}
|
|
422
|
+
return /* @__PURE__ */ jsx(
|
|
423
|
+
IconButton,
|
|
424
|
+
{
|
|
425
|
+
size: "small",
|
|
426
|
+
variant: "transparent",
|
|
427
|
+
onClick: onCollapse,
|
|
428
|
+
type: "button",
|
|
429
|
+
children: /* @__PURE__ */ jsx(
|
|
430
|
+
TriangleRightMini,
|
|
431
|
+
{
|
|
432
|
+
className: clx("text-ui-fg-subtle transition-transform", {
|
|
433
|
+
"rotate-90": !collapsed
|
|
434
|
+
})
|
|
435
|
+
}
|
|
436
|
+
)
|
|
437
|
+
}
|
|
438
|
+
);
|
|
439
|
+
};
|
|
440
|
+
var Value = ({ value }) => {
|
|
441
|
+
return /* @__PURE__ */ jsx("div", { className: "txt-compact-small text-ui-fg-subtle flex-grow truncate", children: value });
|
|
442
|
+
};
|
|
443
|
+
var ChildrenCount = ({ clone, childrenCount }) => {
|
|
444
|
+
if (!clone || !childrenCount) {
|
|
445
|
+
return null;
|
|
446
|
+
}
|
|
447
|
+
if (clone && childrenCount <= 1) {
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
return /* @__PURE__ */ jsx(Badge, { size: "2xsmall", color: "blue", className: "absolute -right-2 -top-2", children: childrenCount });
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
// src/components/common/sortable-tree/sortable-tree-item.tsx
|
|
454
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
455
|
+
var animateLayoutChanges = ({
|
|
456
|
+
isSorting,
|
|
457
|
+
wasDragging
|
|
458
|
+
}) => {
|
|
459
|
+
return isSorting || wasDragging ? false : true;
|
|
460
|
+
};
|
|
461
|
+
function SortableTreeItem({
|
|
462
|
+
id,
|
|
463
|
+
depth,
|
|
464
|
+
disabled,
|
|
465
|
+
...props
|
|
466
|
+
}) {
|
|
467
|
+
const {
|
|
468
|
+
attributes,
|
|
469
|
+
isDragging,
|
|
470
|
+
isSorting,
|
|
471
|
+
listeners,
|
|
472
|
+
setDraggableNodeRef,
|
|
473
|
+
setDroppableNodeRef,
|
|
474
|
+
transform,
|
|
475
|
+
transition
|
|
476
|
+
} = useSortable({
|
|
477
|
+
id,
|
|
478
|
+
animateLayoutChanges,
|
|
479
|
+
disabled
|
|
480
|
+
});
|
|
481
|
+
const style = {
|
|
482
|
+
transform: CSS.Translate.toString(transform),
|
|
483
|
+
transition
|
|
484
|
+
};
|
|
485
|
+
return /* @__PURE__ */ jsx2(
|
|
486
|
+
TreeItem,
|
|
487
|
+
{
|
|
488
|
+
ref: setDraggableNodeRef,
|
|
489
|
+
wrapperRef: setDroppableNodeRef,
|
|
490
|
+
style,
|
|
491
|
+
depth,
|
|
492
|
+
ghost: isDragging,
|
|
493
|
+
disableSelection: iOS,
|
|
494
|
+
disableInteraction: isSorting,
|
|
495
|
+
disabled,
|
|
496
|
+
handleProps: {
|
|
497
|
+
listeners,
|
|
498
|
+
attributes
|
|
499
|
+
},
|
|
500
|
+
...props
|
|
501
|
+
}
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// src/components/common/sortable-tree/sortable-tree.tsx
|
|
506
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
507
|
+
var measuring = {
|
|
508
|
+
droppable: {
|
|
509
|
+
strategy: MeasuringStrategy.Always
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
var dropAnimationConfig = {
|
|
513
|
+
keyframes({ transform }) {
|
|
514
|
+
return [
|
|
515
|
+
{ opacity: 1, transform: CSS2.Transform.toString(transform.initial) },
|
|
516
|
+
{
|
|
517
|
+
opacity: 0,
|
|
518
|
+
transform: CSS2.Transform.toString({
|
|
519
|
+
...transform.final,
|
|
520
|
+
x: transform.final.x + 5,
|
|
521
|
+
y: transform.final.y + 5
|
|
522
|
+
})
|
|
523
|
+
}
|
|
524
|
+
];
|
|
525
|
+
},
|
|
526
|
+
easing: "ease-out",
|
|
527
|
+
sideEffects({ active }) {
|
|
528
|
+
active.node.animate([{ opacity: 0 }, { opacity: 1 }], {
|
|
529
|
+
duration: defaultDropAnimation.duration,
|
|
530
|
+
easing: defaultDropAnimation.easing
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
function SortableTree({
|
|
535
|
+
collapsible = true,
|
|
536
|
+
childrenProp = "children",
|
|
537
|
+
// "children" is the default children prop name
|
|
538
|
+
enableDrag = true,
|
|
539
|
+
items = [],
|
|
540
|
+
indentationWidth = 40,
|
|
541
|
+
onChange,
|
|
542
|
+
renderValue
|
|
543
|
+
}) {
|
|
544
|
+
const [collapsedState, setCollapsedState] = useState({});
|
|
545
|
+
const [activeId, setActiveId] = useState(null);
|
|
546
|
+
const [overId, setOverId] = useState(null);
|
|
547
|
+
const [offsetLeft, setOffsetLeft] = useState(0);
|
|
548
|
+
const [currentPosition, setCurrentPosition] = useState(null);
|
|
549
|
+
const flattenedItems = useMemo(() => {
|
|
550
|
+
const flattenedTree = flattenTree(items, childrenProp);
|
|
551
|
+
const collapsedItems = flattenedTree.reduce(
|
|
552
|
+
(acc, item) => {
|
|
553
|
+
const { id } = item;
|
|
554
|
+
const children = item[childrenProp] || [];
|
|
555
|
+
const collapsed = collapsedState[id];
|
|
556
|
+
return collapsed && children.length ? [...acc, id] : acc;
|
|
557
|
+
},
|
|
558
|
+
[]
|
|
559
|
+
);
|
|
560
|
+
return removeChildrenOf(
|
|
561
|
+
flattenedTree,
|
|
562
|
+
activeId ? [activeId, ...collapsedItems] : collapsedItems,
|
|
563
|
+
childrenProp
|
|
564
|
+
);
|
|
565
|
+
}, [activeId, items, childrenProp, collapsedState]);
|
|
566
|
+
const projected = activeId && overId ? getProjection(
|
|
567
|
+
flattenedItems,
|
|
568
|
+
activeId,
|
|
569
|
+
overId,
|
|
570
|
+
offsetLeft,
|
|
571
|
+
indentationWidth
|
|
572
|
+
) : null;
|
|
573
|
+
const sensorContext = useRef({
|
|
574
|
+
items: flattenedItems,
|
|
575
|
+
offset: offsetLeft
|
|
576
|
+
});
|
|
577
|
+
const [coordinateGetter] = useState(
|
|
578
|
+
() => sortableTreeKeyboardCoordinates(sensorContext, indentationWidth)
|
|
579
|
+
);
|
|
580
|
+
const sensors = useSensors(
|
|
581
|
+
useSensor(PointerSensor),
|
|
582
|
+
useSensor(KeyboardSensor, {
|
|
583
|
+
coordinateGetter
|
|
584
|
+
})
|
|
585
|
+
);
|
|
586
|
+
const sortedIds = useMemo(
|
|
587
|
+
() => flattenedItems.map(({ id }) => id),
|
|
588
|
+
[flattenedItems]
|
|
589
|
+
);
|
|
590
|
+
const activeItem = activeId ? flattenedItems.find(({ id }) => id === activeId) : null;
|
|
591
|
+
useEffect(() => {
|
|
592
|
+
sensorContext.current = {
|
|
593
|
+
items: flattenedItems,
|
|
594
|
+
offset: offsetLeft
|
|
595
|
+
};
|
|
596
|
+
}, [flattenedItems, offsetLeft]);
|
|
597
|
+
function handleDragStart({ active: { id: activeId2 } }) {
|
|
598
|
+
setActiveId(activeId2);
|
|
599
|
+
setOverId(activeId2);
|
|
600
|
+
const activeItem2 = flattenedItems.find(({ id }) => id === activeId2);
|
|
601
|
+
if (activeItem2) {
|
|
602
|
+
setCurrentPosition({
|
|
603
|
+
parentId: activeItem2.parentId,
|
|
604
|
+
overId: activeId2
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
document.body.style.setProperty("cursor", "grabbing");
|
|
608
|
+
}
|
|
609
|
+
function handleDragMove({ delta }) {
|
|
610
|
+
setOffsetLeft(delta.x);
|
|
611
|
+
}
|
|
612
|
+
function handleDragOver({ over }) {
|
|
613
|
+
setOverId(over?.id ?? null);
|
|
614
|
+
}
|
|
615
|
+
function handleDragEnd({ active, over }) {
|
|
616
|
+
resetState();
|
|
617
|
+
if (projected && over) {
|
|
618
|
+
const { depth, parentId } = projected;
|
|
619
|
+
const clonedItems = JSON.parse(
|
|
620
|
+
JSON.stringify(flattenTree(items, childrenProp))
|
|
621
|
+
);
|
|
622
|
+
const overIndex = clonedItems.findIndex(({ id }) => id === over.id);
|
|
623
|
+
const activeIndex = clonedItems.findIndex(({ id }) => id === active.id);
|
|
624
|
+
const activeTreeItem = clonedItems[activeIndex];
|
|
625
|
+
clonedItems[activeIndex] = { ...activeTreeItem, depth, parentId };
|
|
626
|
+
const sortedItems = arrayMove2(clonedItems, activeIndex, overIndex);
|
|
627
|
+
const { items: newItems, update } = buildTree(
|
|
628
|
+
sortedItems,
|
|
629
|
+
overIndex,
|
|
630
|
+
childrenProp
|
|
631
|
+
);
|
|
632
|
+
onChange(update, newItems);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
function handleDragCancel() {
|
|
636
|
+
resetState();
|
|
637
|
+
}
|
|
638
|
+
function resetState() {
|
|
639
|
+
setOverId(null);
|
|
640
|
+
setActiveId(null);
|
|
641
|
+
setOffsetLeft(0);
|
|
642
|
+
setCurrentPosition(null);
|
|
643
|
+
document.body.style.setProperty("cursor", "");
|
|
644
|
+
}
|
|
645
|
+
function handleCollapse(id) {
|
|
646
|
+
setCollapsedState((state) => ({
|
|
647
|
+
...state,
|
|
648
|
+
[id]: state[id] ? false : true
|
|
649
|
+
}));
|
|
650
|
+
}
|
|
651
|
+
function getMovementAnnouncement(eventName, activeId2, overId2) {
|
|
652
|
+
if (overId2 && projected) {
|
|
653
|
+
if (eventName !== "onDragEnd") {
|
|
654
|
+
if (currentPosition && projected.parentId === currentPosition.parentId && overId2 === currentPosition.overId) {
|
|
655
|
+
return;
|
|
656
|
+
} else {
|
|
657
|
+
setCurrentPosition({
|
|
658
|
+
parentId: projected.parentId,
|
|
659
|
+
overId: overId2
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
const clonedItems = JSON.parse(
|
|
664
|
+
JSON.stringify(flattenTree(items, childrenProp))
|
|
665
|
+
);
|
|
666
|
+
const overIndex = clonedItems.findIndex(({ id }) => id === overId2);
|
|
667
|
+
const activeIndex = clonedItems.findIndex(({ id }) => id === activeId2);
|
|
668
|
+
const sortedItems = arrayMove2(clonedItems, activeIndex, overIndex);
|
|
669
|
+
const previousItem = sortedItems[overIndex - 1];
|
|
670
|
+
let announcement;
|
|
671
|
+
const movedVerb = eventName === "onDragEnd" ? "dropped" : "moved";
|
|
672
|
+
const nestedVerb = eventName === "onDragEnd" ? "dropped" : "nested";
|
|
673
|
+
if (!previousItem) {
|
|
674
|
+
const nextItem = sortedItems[overIndex + 1];
|
|
675
|
+
announcement = `${activeId2} was ${movedVerb} before ${nextItem.id}.`;
|
|
676
|
+
} else {
|
|
677
|
+
if (projected.depth > previousItem.depth) {
|
|
678
|
+
announcement = `${activeId2} was ${nestedVerb} under ${previousItem.id}.`;
|
|
679
|
+
} else {
|
|
680
|
+
let previousSibling = previousItem;
|
|
681
|
+
while (previousSibling && projected.depth < previousSibling.depth) {
|
|
682
|
+
const parentId = previousSibling.parentId;
|
|
683
|
+
previousSibling = sortedItems.find(({ id }) => id === parentId);
|
|
684
|
+
}
|
|
685
|
+
if (previousSibling) {
|
|
686
|
+
announcement = `${activeId2} was ${movedVerb} after ${previousSibling.id}.`;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
return announcement;
|
|
691
|
+
}
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
const announcements = {
|
|
695
|
+
onDragStart({ active }) {
|
|
696
|
+
return `Picked up ${active.id}.`;
|
|
697
|
+
},
|
|
698
|
+
onDragMove({ active, over }) {
|
|
699
|
+
return getMovementAnnouncement("onDragMove", active.id, over?.id);
|
|
700
|
+
},
|
|
701
|
+
onDragOver({ active, over }) {
|
|
702
|
+
return getMovementAnnouncement("onDragOver", active.id, over?.id);
|
|
703
|
+
},
|
|
704
|
+
onDragEnd({ active, over }) {
|
|
705
|
+
return getMovementAnnouncement("onDragEnd", active.id, over?.id);
|
|
706
|
+
},
|
|
707
|
+
onDragCancel({ active }) {
|
|
708
|
+
return `Moving was cancelled. ${active.id} was dropped in its original position.`;
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
return /* @__PURE__ */ jsx3(
|
|
712
|
+
DndContext,
|
|
713
|
+
{
|
|
714
|
+
accessibility: { announcements },
|
|
715
|
+
sensors,
|
|
716
|
+
collisionDetection: closestCenter,
|
|
717
|
+
measuring,
|
|
718
|
+
onDragStart: handleDragStart,
|
|
719
|
+
onDragMove: handleDragMove,
|
|
720
|
+
onDragOver: handleDragOver,
|
|
721
|
+
onDragEnd: handleDragEnd,
|
|
722
|
+
onDragCancel: handleDragCancel,
|
|
723
|
+
children: /* @__PURE__ */ jsxs2(SortableContext, { items: sortedIds, strategy: verticalListSortingStrategy, children: [
|
|
724
|
+
flattenedItems.map((item) => {
|
|
725
|
+
const { id, depth } = item;
|
|
726
|
+
const children = item[childrenProp] || [];
|
|
727
|
+
const disabled = typeof enableDrag === "function" ? !enableDrag(item) : !enableDrag;
|
|
728
|
+
return /* @__PURE__ */ jsx3(
|
|
729
|
+
SortableTreeItem,
|
|
730
|
+
{
|
|
731
|
+
id,
|
|
732
|
+
value: renderValue(item),
|
|
733
|
+
disabled,
|
|
734
|
+
depth: id === activeId && projected ? projected.depth : depth,
|
|
735
|
+
indentationWidth,
|
|
736
|
+
collapsed: Boolean(collapsedState[id] && children.length),
|
|
737
|
+
childCount: children.length,
|
|
738
|
+
onCollapse: collapsible && children.length ? () => handleCollapse(id) : void 0
|
|
739
|
+
},
|
|
740
|
+
id
|
|
741
|
+
);
|
|
742
|
+
}),
|
|
743
|
+
createPortal(
|
|
744
|
+
/* @__PURE__ */ jsx3(DragOverlay, { dropAnimation: dropAnimationConfig, children: activeId && activeItem ? /* @__PURE__ */ jsx3(
|
|
745
|
+
SortableTreeItem,
|
|
746
|
+
{
|
|
747
|
+
id: activeId,
|
|
748
|
+
depth: activeItem.depth,
|
|
749
|
+
clone: true,
|
|
750
|
+
childCount: getChildCount(items, activeId, childrenProp) + 1,
|
|
751
|
+
value: renderValue(activeItem),
|
|
752
|
+
indentationWidth: 0
|
|
753
|
+
}
|
|
754
|
+
) : null }),
|
|
755
|
+
document.body
|
|
756
|
+
)
|
|
757
|
+
] })
|
|
758
|
+
}
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// src/pages/categories/common/components/category-tree/category-tree.tsx
|
|
763
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
764
|
+
var CategoryTree = ({
|
|
765
|
+
value,
|
|
766
|
+
onChange,
|
|
767
|
+
renderValue,
|
|
768
|
+
enableDrag = true,
|
|
769
|
+
isLoading = false
|
|
770
|
+
}) => {
|
|
771
|
+
if (isLoading) {
|
|
772
|
+
return /* @__PURE__ */ jsx4("div", { className: "txt-compact-small relative flex-1 overflow-y-auto", children: Array.from({ length: 10 }).map((_, i) => /* @__PURE__ */ jsx4(CategoryLeafPlaceholder, {}, i)) });
|
|
773
|
+
}
|
|
774
|
+
return /* @__PURE__ */ jsx4(
|
|
775
|
+
SortableTree,
|
|
776
|
+
{
|
|
777
|
+
items: value,
|
|
778
|
+
childrenProp: "category_children",
|
|
779
|
+
collapsible: true,
|
|
780
|
+
enableDrag,
|
|
781
|
+
onChange,
|
|
782
|
+
renderValue
|
|
783
|
+
}
|
|
784
|
+
);
|
|
785
|
+
};
|
|
786
|
+
var CategoryLeafPlaceholder = () => {
|
|
787
|
+
return /* @__PURE__ */ jsx4("div", { className: "bg-ui-bg-base -mb-px flex h-12 animate-pulse items-center border-y px-6 py-2.5" });
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
export {
|
|
791
|
+
CategoryTree
|
|
792
|
+
};
|