react-grab 0.1.29 → 0.1.30
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/README.md +2 -5
- package/dist/core/index.cjs +9 -1
- package/dist/core/index.d.cts +11 -3
- package/dist/core/index.d.ts +11 -3
- package/dist/core/index.js +9 -1
- package/dist/core--H_JZk7a.js +16 -0
- package/dist/core-1AoeBJ2R.cjs +4386 -0
- package/dist/core-4VC4A94S.js +4249 -0
- package/dist/core-5Q_6LVh_.cjs +16 -0
- package/dist/core-6sOn3YNs.js +16 -0
- package/dist/core-B3FYVaHv.cjs +16 -0
- package/dist/core-B3I0upO1.js +4250 -0
- package/dist/core-B3ndcALq.cjs +4386 -0
- package/dist/core-B9GWVp1Q.js +16 -0
- package/dist/core-BGIMywNa.js +16 -0
- package/dist/core-BGK4C6ju.js +16 -0
- package/dist/core-BGXprTx7.cjs +16 -0
- package/dist/core-BKt5SHzo.js +16 -0
- package/dist/core-BMObVYUv.cjs +16 -0
- package/dist/core-BNMx90Sn.js +16 -0
- package/dist/core-BWQ6C5g9.js +4268 -0
- package/dist/core-BcwRbSfO.js +16 -0
- package/dist/core-Be-1ubQn.cjs +16 -0
- package/dist/core-BfpPi7c6.cjs +16 -0
- package/dist/core-BiIoWLRk.js +16 -0
- package/dist/core-BjpyJHlW.js +16 -0
- package/dist/core-Bqf3D4Ra.cjs +16 -0
- package/dist/core-Bs0wekHY.cjs +4284 -0
- package/dist/core-Bvqgv6Zr.js +16 -0
- package/dist/core-Bw0-Cecq.cjs +16 -0
- package/dist/core-BzRpJ5QI.cjs +4284 -0
- package/dist/core-C0ZgNdUR.cjs +4386 -0
- package/dist/core-C191WXKe.cjs +16 -0
- package/dist/core-C4yYleJn.js +16 -0
- package/dist/core-C758xgeI.js +16 -0
- package/dist/core-CAZ8ENTv.js +16 -0
- package/dist/core-CBUFmwfx.cjs +4386 -0
- package/dist/core-CDV48I9C.js +4249 -0
- package/dist/core-CGXCsSkm.js +4280 -0
- package/dist/core-CHsFU9FZ.js +16 -0
- package/dist/core-CJOQfSzq.js +4495 -0
- package/dist/core-CLW9tl4L.js +4249 -0
- package/dist/core-CP1yCnSB.js +16 -0
- package/dist/core-CRLyvQCt.cjs +16 -0
- package/dist/core-CZX3EijL.js +16 -0
- package/dist/core-Ccli-yLf.cjs +16 -0
- package/dist/core-Ce4pBUSh.js +16 -0
- package/dist/core-CgCGjXfB.cjs +16 -0
- package/dist/core-CiQl2PfF.cjs +16 -0
- package/dist/core-CnPpGWUc.js +16 -0
- package/dist/core-Co9954wQ.cjs +16 -0
- package/dist/core-Cr4qVf2a.js +16 -0
- package/dist/core-CrQCbm00.js +16 -0
- package/dist/core-CsCg35MW.js +16 -0
- package/dist/core-Cshs0orb.js +16 -0
- package/dist/core-CthjfoZX.cjs +16 -0
- package/dist/core-CtvavOAt.cjs +16 -0
- package/dist/core-CvoFTVjy.cjs +16 -0
- package/dist/core-CzE8I9NL.cjs +16 -0
- package/dist/core-CzGijRTx.js +16 -0
- package/dist/core-CzosrDdO.cjs +16 -0
- package/dist/core-D--fM7Xq.cjs +16 -0
- package/dist/core-D-UGQb_Z.cjs +16 -0
- package/dist/core-D0UqPwu_.cjs +16 -0
- package/dist/core-D2LzIluw.js +4495 -0
- package/dist/core-D4z4W-Qz.cjs +16 -0
- package/dist/core-D7NwJuzy.js +16 -0
- package/dist/core-DCqMIKkK.js +16 -0
- package/dist/core-DFrvwczh.cjs +4284 -0
- package/dist/core-DGxxKKPR.cjs +16 -0
- package/dist/core-DGyQeEXa.js +4495 -0
- package/dist/core-DH8Uvag-.js +4249 -0
- package/dist/core-DHZBYfsC.js +16 -0
- package/dist/core-DKVj078o.js +4249 -0
- package/dist/core-DMRsaGr7.js +16 -0
- package/dist/core-DRUnXCNA.cjs +16 -0
- package/dist/core-DRlG4zYm.cjs +16 -0
- package/dist/core-DSqJwwdV.cjs +4284 -0
- package/dist/core-DXqmRz53.cjs +16 -0
- package/dist/core-DcRxqPad.js +16 -0
- package/dist/core-DdNOX4pt.js +16 -0
- package/dist/core-Df7CMRnd.cjs +4315 -0
- package/dist/core-DiIZA6Hx.js +4495 -0
- package/dist/core-DiVnlonK.cjs +4284 -0
- package/dist/core-Dj1WV911.js +4495 -0
- package/dist/core-DjPDxMID.cjs +16 -0
- package/dist/core-DjcnHWor.cjs +16 -0
- package/dist/core-DkWjrEUZ.cjs +16 -0
- package/dist/core-Dq-CCsij.cjs +4303 -0
- package/dist/core-DsVAkMs2.js +16 -0
- package/dist/core-DueMb4P6.js +4249 -0
- package/dist/core-DvJt5JmX.js +16 -0
- package/dist/core-Dz8Hrc33.js +4249 -0
- package/dist/core-ESHKG2mL.cjs +4285 -0
- package/dist/core-Ij_B_RWV.cjs +16 -0
- package/dist/core-JyczI7kP.cjs +16 -0
- package/dist/core-K0XuILjf.cjs +4284 -0
- package/dist/core-N9HyYpZv.cjs +16 -0
- package/dist/core-PW2DC2Tb.js +4495 -0
- package/dist/core-Q84EBsQ8.cjs +16 -0
- package/dist/core-TSuD8D7m.js +16 -0
- package/dist/core-WN76m9V0.cjs +16 -0
- package/dist/core-YRKn-0AV.js +16 -0
- package/dist/core-fC6GdbUJ.js +16 -0
- package/dist/core-h5q7bqH-.cjs +4284 -0
- package/dist/core-hkgBRD_T.js +16 -0
- package/dist/core-k9l5c9Hk.cjs +16 -0
- package/dist/core-mNhkpUYQ.cjs +16 -0
- package/dist/core-qCvYE9Ox.cjs +4386 -0
- package/dist/core-rvs2FEMH.js +16 -0
- package/dist/core-sXzUCmoJ.js +16 -0
- package/dist/core-t7gaYHyj.cjs +4386 -0
- package/dist/core-thci-YqL.js +16 -0
- package/dist/core-xokESdbC.cjs +16 -0
- package/dist/core-yW0MN96-.cjs +16 -0
- package/dist/core-ydFCYlV4.js +16 -0
- package/dist/core-zQ4jjKHw.cjs +16 -0
- package/dist/extract-element-css-B-R_28uM.cjs +10 -0
- package/dist/extract-element-css-B732tro7.js +10 -0
- package/dist/extract-element-css-B9Xh1wUd.js +10 -0
- package/dist/extract-element-css-BGZPWnck.js +10 -0
- package/dist/extract-element-css-BIniUwQh.js +319 -0
- package/dist/extract-element-css-BOQUDYB3.cjs +10 -0
- package/dist/extract-element-css-BTzDGIs3.cjs +336 -0
- package/dist/extract-element-css-BWUnsvjZ.js +10 -0
- package/dist/extract-element-css-BceTcL6y.cjs +10 -0
- package/dist/extract-element-css-Bi1y8V4z.cjs +336 -0
- package/dist/extract-element-css-Bra6hEzg.js +319 -0
- package/dist/extract-element-css-BuJ3zqGO.js +10 -0
- package/dist/extract-element-css-C8lBuGP7.js +10 -0
- package/dist/extract-element-css-CBHVjrBq.cjs +10 -0
- package/dist/extract-element-css-CGxXdwim.js +10 -0
- package/dist/extract-element-css-CJx4cesM.js +10 -0
- package/dist/extract-element-css-CQBJAbFD.cjs +10 -0
- package/dist/extract-element-css-CQV8FsMB.cjs +10 -0
- package/dist/extract-element-css-CQx4Biqa.cjs +336 -0
- package/dist/extract-element-css-CTy2pRfA.js +10 -0
- package/dist/extract-element-css-CchtITXx.cjs +336 -0
- package/dist/extract-element-css-CjY9vDS6.js +10 -0
- package/dist/extract-element-css-ClnG20sN.cjs +10 -0
- package/dist/extract-element-css-CmMetO-q.cjs +10 -0
- package/dist/extract-element-css-CmOD6UeE.cjs +10 -0
- package/dist/extract-element-css-CnY9b0vB.js +10 -0
- package/dist/extract-element-css-CoQLNjVI.js +10 -0
- package/dist/extract-element-css-CqjmXl0Y.cjs +10 -0
- package/dist/extract-element-css-Cr29xtzW.cjs +10 -0
- package/dist/extract-element-css-CzNVoJEM.js +319 -0
- package/dist/extract-element-css-CzgC7nM9.cjs +10 -0
- package/dist/extract-element-css-D3Dy-3Qz.js +10 -0
- package/dist/extract-element-css-D5qqKVc-.cjs +10 -0
- package/dist/extract-element-css-D5zsPw09.cjs +10 -0
- package/dist/extract-element-css-D6UwJjf4.cjs +336 -0
- package/dist/extract-element-css-DEuA2W6G.js +10 -0
- package/dist/extract-element-css-DKkUiIlS.cjs +10 -0
- package/dist/extract-element-css-DM0EhhXw.cjs +10 -0
- package/dist/extract-element-css-DPA6C_o-.cjs +10 -0
- package/dist/extract-element-css-DU45xRGh.js +10 -0
- package/dist/extract-element-css-DUvYlz4T.js +10 -0
- package/dist/extract-element-css-DVDr5Tn6.cjs +10 -0
- package/dist/extract-element-css-Di9hCigW.js +319 -0
- package/dist/extract-element-css-DivFxCRt.js +319 -0
- package/dist/extract-element-css-DlDbU4YM.cjs +10 -0
- package/dist/extract-element-css-DsssOqcQ.cjs +10 -0
- package/dist/extract-element-css-EnvrIHtf.cjs +336 -0
- package/dist/extract-element-css-FI71J_KB.js +10 -0
- package/dist/extract-element-css-GdDDlzTf.js +10 -0
- package/dist/extract-element-css-U3MgLHty.cjs +10 -0
- package/dist/extract-element-css-U4oxl-UP.js +10 -0
- package/dist/extract-element-css-VyMIgOZy.js +10 -0
- package/dist/extract-element-css-XGv0WWIL.js +319 -0
- package/dist/extract-element-css-Y-x4luJL.cjs +10 -0
- package/dist/extract-element-css-Zz_CgLqY.js +319 -0
- package/dist/extract-element-css-_aFPl5y4.cjs +336 -0
- package/dist/extract-element-css-_uZRVqCT.cjs +10 -0
- package/dist/extract-element-css-i8nzXODQ.js +10 -0
- package/dist/extract-element-css-jh1iLRzJ.js +10 -0
- package/dist/extract-element-css-nkJQc3j1.js +10 -0
- package/dist/freeze-updates--K1ecmFi.cjs +44 -0
- package/dist/freeze-updates-1FTXgIdb.js +44 -0
- package/dist/freeze-updates-3QjTocF-.cjs +2267 -0
- package/dist/freeze-updates-81f5sY45.js +44 -0
- package/dist/freeze-updates-B1mPDmJB.js +44 -0
- package/dist/freeze-updates-B5h8teL6.cjs +44 -0
- package/dist/freeze-updates-BAYe0Nlx.js +44 -0
- package/dist/freeze-updates-BDhlBp3V.js +44 -0
- package/dist/freeze-updates-BGa9CqrW.cjs +2267 -0
- package/dist/freeze-updates-BQH6Y8E1.cjs +44 -0
- package/dist/freeze-updates-BQjWBzy4.cjs +53 -0
- package/dist/freeze-updates-BSOSfpXo.js +44 -0
- package/dist/freeze-updates-BT-s67nK.js +53 -0
- package/dist/freeze-updates-BUJeYIm5.js +44 -0
- package/dist/freeze-updates-BVDrqUzf.js +2498 -0
- package/dist/freeze-updates-BVX0QSXz.cjs +44 -0
- package/dist/freeze-updates-BXMr6a9g.cjs +2912 -0
- package/dist/freeze-updates-BZpmCVDl.cjs +2267 -0
- package/dist/freeze-updates-BbbID39H.js +1866 -0
- package/dist/freeze-updates-BdnJ5RrP.js +1866 -0
- package/dist/freeze-updates-Bj59uWit.cjs +44 -0
- package/dist/freeze-updates-Bla3E0Kv.js +53 -0
- package/dist/freeze-updates-BoYyIB3V.cjs +44 -0
- package/dist/freeze-updates-C2TqDiTp.cjs +44 -0
- package/dist/freeze-updates-C6Tg4EoW.js +44 -0
- package/dist/freeze-updates-C7c9TRvJ.cjs +44 -0
- package/dist/freeze-updates-CPNAwtsl.cjs +2267 -0
- package/dist/freeze-updates-CTP39zuf.js +44 -0
- package/dist/freeze-updates-Cm3EVm_J.cjs +53 -0
- package/dist/freeze-updates-CnSZEKoI.cjs +44 -0
- package/dist/freeze-updates-CrKe4F0s.js +44 -0
- package/dist/freeze-updates-CtYFeM4D.cjs +2267 -0
- package/dist/freeze-updates-CxYFvPj9.cjs +53 -0
- package/dist/freeze-updates-D10Qj9Ec.cjs +44 -0
- package/dist/freeze-updates-D6o46vBw.cjs +44 -0
- package/dist/freeze-updates-D7XFQ3_T.js +53 -0
- package/dist/freeze-updates-D8H25gFt.js +44 -0
- package/dist/freeze-updates-DCpGX7lt.cjs +44 -0
- package/dist/freeze-updates-DG3hLEL2.cjs +44 -0
- package/dist/freeze-updates-DO_M76qf.js +44 -0
- package/dist/freeze-updates-Db4Id665.cjs +2267 -0
- package/dist/freeze-updates-DbL_EXkN.js +1866 -0
- package/dist/freeze-updates-DcvNGCcR.cjs +44 -0
- package/dist/freeze-updates-Dh4GiYXz.cjs +44 -0
- package/dist/freeze-updates-DkKJK_nh.cjs +44 -0
- package/dist/freeze-updates-DmB-ndqy.cjs +44 -0
- package/dist/freeze-updates-DnAA3QYp.cjs +44 -0
- package/dist/freeze-updates-Dpj8jndD.js +44 -0
- package/dist/freeze-updates-DuHXIi3M.js +44 -0
- package/dist/freeze-updates-DwERlFID.js +1866 -0
- package/dist/freeze-updates-HHyWtz8f.cjs +44 -0
- package/dist/freeze-updates-JRZCAR0q.js +1866 -0
- package/dist/freeze-updates-KLyCac_c.js +44 -0
- package/dist/freeze-updates-MaNDvTJS.js +1866 -0
- package/dist/freeze-updates-REe44rww.js +44 -0
- package/dist/freeze-updates-TPRkNnYY.js +44 -0
- package/dist/freeze-updates-WfKs4yF4.js +44 -0
- package/dist/freeze-updates-d9yH0V6A.cjs +44 -0
- package/dist/freeze-updates-nzZkxjqN.js +44 -0
- package/dist/freeze-updates-q_DMlHq7.js +44 -0
- package/dist/index-0hhKx6KA.d.ts +534 -0
- package/dist/index-5oOhE8Ae.d.cts +123 -0
- package/dist/index-BA23Z7zi.d.ts +77 -0
- package/dist/index-BAbHDCJb.d.ts +190 -0
- package/dist/index-BN1ZJhWK.d.cts +471 -0
- package/dist/index-BNt_9BO7.d.ts +77 -0
- package/dist/index-BQIO-ZFv.d.cts +190 -0
- package/dist/index-BTQxeAz1.d.cts +123 -0
- package/dist/index-BxsI0BlT.d.ts +471 -0
- package/dist/index-BzzHoNRc.d.cts +77 -0
- package/dist/index-C0Scq3kL.d.ts +458 -0
- package/dist/index-CAHLDDjY.d.ts +190 -0
- package/dist/index-CIJ7ossb.d.ts +190 -0
- package/dist/index-CJqujqsv.d.cts +190 -0
- package/dist/index-CJrVDk2d.d.ts +470 -0
- package/dist/index-CQBZI4f5.d.cts +458 -0
- package/dist/index-CS3VHZ8R.d.cts +77 -0
- package/dist/index-CWd5aKyK.d.ts +123 -0
- package/dist/index-DM3Ga1zc.d.ts +123 -0
- package/dist/index-DYp_9VQ_.d.cts +470 -0
- package/dist/index-DrK-HiGj.d.ts +203 -0
- package/dist/index-GwiDNOsl.d.ts +457 -0
- package/dist/index-QLMT7NRw.d.cts +203 -0
- package/dist/index-QLi1BtdI.d.cts +190 -0
- package/dist/index-sM3yy652.d.cts +534 -0
- package/dist/index-zvkV7Xwg.d.cts +457 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +21 -12
- package/dist/index.d.ts +21 -12
- package/dist/index.global.js +26 -97
- package/dist/index.iife.js +43 -0
- package/dist/index.js +2 -2
- package/dist/primitives.cjs +2 -2
- package/dist/primitives.d.cts +20 -13
- package/dist/primitives.d.ts +20 -13
- package/dist/primitives.js +2 -2
- package/dist/renderer--AVNuclr.js +9 -0
- package/dist/renderer--bWj0AZJ.js +4101 -0
- package/dist/renderer--cF4pvND.js +9 -0
- package/dist/renderer-0mo5bvxE.js +4126 -0
- package/dist/renderer-4Wa-UMC5.cjs +9 -0
- package/dist/renderer-6D9KbSAS.js +9 -0
- package/dist/renderer-7mjLlkgX.cjs +9 -0
- package/dist/renderer-B0v-2J0H.js +9 -0
- package/dist/renderer-B0yJsSRz.js +9 -0
- package/dist/renderer-B660bBKn.cjs +9 -0
- package/dist/renderer-B6m2pWq1.cjs +4102 -0
- package/dist/renderer-BA_yjKW4.cjs +9 -0
- package/dist/renderer-BDCne7IL.cjs +9 -0
- package/dist/renderer-BDKG-8eW.js +9 -0
- package/dist/renderer-BEisX7lt.js +9 -0
- package/dist/renderer-BEnSHrkN.cjs +9 -0
- package/dist/renderer-BJQHCki_.js +9 -0
- package/dist/renderer-BLEQ0lBg.js +9 -0
- package/dist/renderer-BQMe9vbO.cjs +9 -0
- package/dist/renderer-BZfQAWt2.cjs +9 -0
- package/dist/renderer-BZypunFM.cjs +9 -0
- package/dist/renderer-Be1I1mDW.cjs +9 -0
- package/dist/renderer-Bhrtihjr.cjs +9 -0
- package/dist/renderer-Bp3dRMPA.js +9 -0
- package/dist/renderer-BqYgf0tD.js +9 -0
- package/dist/renderer-BwD9ZaGr.cjs +9 -0
- package/dist/renderer-BxCRcsEK.cjs +4125 -0
- package/dist/renderer-C1Wrh8hn.js +9 -0
- package/dist/renderer-C6pztTyv.js +9 -0
- package/dist/renderer-C9bCr3pC.js +4101 -0
- package/dist/renderer-CEmrAuyA.js +9 -0
- package/dist/renderer-CG1lpM8J.cjs +9 -0
- package/dist/renderer-CIJhv1xD.js +9 -0
- package/dist/renderer-CJ3EovD7.js +9 -0
- package/dist/renderer-CJVIzi67.js +4114 -0
- package/dist/renderer-CKAmRN9i.cjs +9 -0
- package/dist/renderer-CNa9jW2d.js +9 -0
- package/dist/renderer-CS6q5sh-.cjs +4101 -0
- package/dist/renderer-CTip7L4z.cjs +4114 -0
- package/dist/renderer-Cdh6G3WO.cjs +4101 -0
- package/dist/renderer-Cfnc_J-x.js +9 -0
- package/dist/renderer-CidbOiiO.js +9 -0
- package/dist/renderer-CooL8OD4.cjs +9 -0
- package/dist/renderer-Cp8W_Vpj.cjs +4101 -0
- package/dist/renderer-Ctq4IL1w.cjs +9 -0
- package/dist/renderer-D0gZDp8v.js +9 -0
- package/dist/renderer-D2Ius1-3.cjs +9 -0
- package/dist/renderer-D2gUuAUv.cjs +9 -0
- package/dist/renderer-D6qQGrNF.js +9 -0
- package/dist/renderer-D9RBf9He.js +9 -0
- package/dist/renderer-DDpyudCh.js +9 -0
- package/dist/renderer-DEo9eIZj.cjs +9 -0
- package/dist/renderer-DHBz10-G.js +9 -0
- package/dist/renderer-DM6gVYD_.cjs +4126 -0
- package/dist/renderer-DS5wjL1R.cjs +9 -0
- package/dist/renderer-DWZQjHeF.cjs +4101 -0
- package/dist/renderer-DZ-EdxOj.cjs +9 -0
- package/dist/renderer-DblZTrea.js +9 -0
- package/dist/renderer-DcPiCh7r.js +4114 -0
- package/dist/renderer-Dfj6tfg9.cjs +4139 -0
- package/dist/renderer-DhoYb1PY.js +4103 -0
- package/dist/renderer-Dl6awT_I.cjs +9 -0
- package/dist/renderer-DmOXobMF.js +4101 -0
- package/dist/renderer-DmlAyeq6.cjs +4114 -0
- package/dist/renderer-DnwizF3I.cjs +9 -0
- package/dist/renderer-Dpzs-uao.js +4125 -0
- package/dist/renderer-Ds21virZ.cjs +4145 -0
- package/dist/renderer-DslAAsKS.js +4101 -0
- package/dist/renderer-DtBv4wTu.js +4102 -0
- package/dist/renderer-DxuOYfZN.cjs +9 -0
- package/dist/renderer-DyrsoA_r.js +9 -0
- package/dist/renderer-GlgUXTaV.js +9 -0
- package/dist/renderer-KL2bSyIW.cjs +9 -0
- package/dist/renderer-N_yFJNWi.cjs +9 -0
- package/dist/renderer-TkTQ8ZzV.cjs +4101 -0
- package/dist/renderer-WtWG_Uzr.js +4139 -0
- package/dist/renderer-YPWUo91d.cjs +9 -0
- package/dist/renderer-foaHR93_.js +9 -0
- package/dist/renderer-irss7gH9.js +9 -0
- package/dist/renderer-kNWgh9RH.js +9 -0
- package/dist/renderer-l2DsHbX5.js +4145 -0
- package/dist/renderer-lRGat4eI.js +9 -0
- package/dist/renderer-m1ynwV5m.cjs +9 -0
- package/dist/renderer-oDWZTt10.cjs +9 -0
- package/dist/renderer-ruVxrW9_.cjs +9 -0
- package/dist/renderer-tLg9bC5E.cjs +4103 -0
- package/dist/renderer-wKL03A96.cjs +9 -0
- package/dist/renderer-xY7WwwPb.cjs +9 -0
- package/dist/renderer-yNfPLGJa.js +4101 -0
- package/dist/renderer-zFA8Xsqn.js +9 -0
- package/dist/state-0zvRag7o.js +1832 -0
- package/dist/state-1bNOTRwX.js +9 -0
- package/dist/state-4KlM-876.cjs +9 -0
- package/dist/state-5YzsfKSg.js +9 -0
- package/dist/state-B2sO7SGs.cjs +9 -0
- package/dist/state-B30FVO9-.cjs +9 -0
- package/dist/state-BBF5Yd6R.cjs +1488 -0
- package/dist/state-BHM_hL69.cjs +9 -0
- package/dist/state-BKkU5MYC.js +9 -0
- package/dist/state-B_xrj8fC.js +9 -0
- package/dist/state-BaTqKR5-.js +1832 -0
- package/dist/state-Bb1Wechu.js +9 -0
- package/dist/state-BfgVpFaG.cjs +9 -0
- package/dist/state-BoRPcmmD.js +9 -0
- package/dist/state-BqB3gaPk.js +9 -0
- package/dist/state-Bt9zarML.js +1832 -0
- package/dist/state-Bw07Ecsm.js +9 -0
- package/dist/state-Bw9Y8zmt.js +9 -0
- package/dist/state-ByV_XBwX.js +9 -0
- package/dist/state-C4nNE_SS.js +9 -0
- package/dist/state-C4uusDVL.cjs +9 -0
- package/dist/state-CMwBL8Lh.cjs +9 -0
- package/dist/state-C_KJ10Ip.cjs +9 -0
- package/dist/state-ClLJ5ade.cjs +1488 -0
- package/dist/state-CpWrjvjx.js +277 -0
- package/dist/state-CwguFqss.cjs +9 -0
- package/dist/state-Cxj7mpyT.cjs +9 -0
- package/dist/state-CyWfuYBm.js +9 -0
- package/dist/state-Cz4euNVW.js +1832 -0
- package/dist/state-D1eYdbOV.js +9 -0
- package/dist/state-D231Xq-p.js +9 -0
- package/dist/state-D2nMXLig.cjs +9 -0
- package/dist/state-D3NnAU-G.js +9 -0
- package/dist/state-D4g0zX0j.cjs +9 -0
- package/dist/state-D5n1XOr-.cjs +372 -0
- package/dist/state-DPKTXrbJ.cjs +9 -0
- package/dist/state-DREKPmRw.cjs +9 -0
- package/dist/state-DT0Nzp9g.cjs +9 -0
- package/dist/state-Deun4HK-.cjs +9 -0
- package/dist/state-DfcZ51t9.js +9 -0
- package/dist/state-DgvhS6KW.cjs +1488 -0
- package/dist/state-DkjLMcvP.cjs +9 -0
- package/dist/state-DspBT1Sv.js +9 -0
- package/dist/state-DtgVqpBv.js +9 -0
- package/dist/state-DycsTHAk.cjs +9 -0
- package/dist/state-EWoHHdWu.js +9 -0
- package/dist/state-HWOltPgB.js +9 -0
- package/dist/state-JJNPE2tU.js +277 -0
- package/dist/state-KDd3Eouo.js +9 -0
- package/dist/state-Kmc6BtLp.cjs +9 -0
- package/dist/state-Q4M-6UjH.cjs +9 -0
- package/dist/state-U8yVy4Ad.cjs +9 -0
- package/dist/state-Uwm9KEi1.js +1832 -0
- package/dist/state-XYH8BGBU.cjs +372 -0
- package/dist/state-aBiYx-N-.cjs +9 -0
- package/dist/state-arg5pYvx.cjs +1488 -0
- package/dist/state-dFAAWOP9.cjs +1488 -0
- package/dist/state-daFKdtG6.js +9 -0
- package/dist/state-muKg33Sx.cjs +9 -0
- package/dist/state-wvjxc3BL.js +9 -0
- package/dist/styles.css +1 -1
- package/package.json +15 -22
- package/dist/chunk-2VXWII4G.cjs +0 -12
- package/dist/chunk-3HCPVIMZ.cjs +0 -83
- package/dist/chunk-CAZ3NLYA.cjs +0 -10
- package/dist/chunk-IWIPTBFC.js +0 -21
- package/dist/chunk-KH7JPDWT.js +0 -83
- package/dist/chunk-MIM6UREC.cjs +0 -21
- package/dist/chunk-RYNNLFJT.js +0 -10
- package/dist/chunk-VCA74BQS.js +0 -12
- package/dist/index-bB0QMlHm.d.cts +0 -507
- package/dist/index-bB0QMlHm.d.ts +0 -507
- package/dist/renderer-DEPHVNHK.cjs +0 -10
- package/dist/renderer-WYB2HHU6.js +0 -10
- package/scripts/postinstall.cjs +0 -23
|
@@ -0,0 +1,4101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 Aiden Bai
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import { D as style, E as spread, G as on, H as createSignal, I as createComponent, K as onCleanup, L as createEffect, M as For, N as Index, O as template, P as Show, R as createMemo, S as memo, T as setStyleProperty, W as mergeProps, _ as addEventListener, a as isMac, b as delegateEvents, c as getCollapsedPosition, d as getSnapPosition, f as getVisualViewport, g as isElementConnected, h as isKeyboardEventTriggeredByInput, i as isEventFromOverlay, k as use, l as getPositionFromEdgeAndRatio, n as saveToolbarState, o as calculateExpandedPositionFromCollapsed, q as onMount, r as resolveActionEnabled, s as clampToRange, t as loadToolbarState, u as getRatioFromPosition, v as classList, w as setAttribute, x as insert, y as className, z as createRenderEffect } from "./state-Cz4euNVW.js";
|
|
10
|
+
import { $ as OVERLAY_FILL_COLOR_DEFAULT, B as FROZEN_GLOW_COLOR, F as DRAG_LERP_FACTOR, H as LERP_CONVERGENCE_THRESHOLD_PX, L as DROPDOWN_EDGE_TRANSFORM_ORIGIN, N as ARROW_MAX_LABEL_WIDTH_RATIO, O as nativeCancelAnimationFrame, P as DEFAULT_ACTION_ID, Q as OVERLAY_BORDER_COLOR_INSPECT, R as DROPDOWN_OFFSCREEN_POSITION, V as HINT_FLIP_IN_ANIMATION, X as OVERLAY_BORDER_COLOR_DEFAULT, Y as OPACITY_CONVERGENCE_THRESHOLD, Z as OVERLAY_BORDER_COLOR_DRAG, a as freezeGlobalAnimations, at as SELECTION_LERP_FACTOR, ct as TOOLTIP_BASE_CLASS, d as freezePseudoStates, dt as Z_INDEX_OVERLAY, et as OVERLAY_FILL_COLOR_DRAG, ft as Z_INDEX_OVERLAY_CANVAS, it as SELECTION_LABEL_OFFSCREEN_PX, k as nativeRequestAnimationFrame, m as unfreezePseudoStates, o as unfreezeGlobalAnimations, ot as TOOLBAR_DEFAULT_POSITION_RATIO, pt as supportsDisplayP3, rt as SELECTION_HINT_CYCLE_INTERVAL_MS, s as openFile, st as TOOLBAR_SHAKE_TOOLTIP_DURATION_MS, t as freezeUpdates, tt as OVERLAY_FILL_COLOR_INSPECT, z as FEEDBACK_DURATION_MS } from "./freeze-updates-BbbID39H.js";
|
|
11
|
+
|
|
12
|
+
//#region src/utils/lerp.ts
|
|
13
|
+
const lerp = (start, end, factor) => {
|
|
14
|
+
return start + (end - start) * factor;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/components/overlay-canvas.tsx
|
|
19
|
+
var _tmpl$$29 = /* @__PURE__ */ template(`<canvas data-react-grab-overlay-canvas style=position:fixed;top:0;left:0;pointer-events:none>`);
|
|
20
|
+
const DEFAULT_LAYER_STYLE = {
|
|
21
|
+
borderColor: OVERLAY_BORDER_COLOR_DEFAULT,
|
|
22
|
+
fillColor: OVERLAY_FILL_COLOR_DEFAULT,
|
|
23
|
+
lerpFactor: SELECTION_LERP_FACTOR
|
|
24
|
+
};
|
|
25
|
+
const LAYER_STYLES = {
|
|
26
|
+
drag: {
|
|
27
|
+
borderColor: OVERLAY_BORDER_COLOR_DRAG,
|
|
28
|
+
fillColor: OVERLAY_FILL_COLOR_DRAG,
|
|
29
|
+
lerpFactor: DRAG_LERP_FACTOR
|
|
30
|
+
},
|
|
31
|
+
selection: DEFAULT_LAYER_STYLE,
|
|
32
|
+
grabbed: DEFAULT_LAYER_STYLE,
|
|
33
|
+
inspect: {
|
|
34
|
+
borderColor: OVERLAY_BORDER_COLOR_INSPECT,
|
|
35
|
+
fillColor: OVERLAY_FILL_COLOR_INSPECT,
|
|
36
|
+
lerpFactor: SELECTION_LERP_FACTOR
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const OverlayCanvas = (props) => {
|
|
40
|
+
let canvasRef;
|
|
41
|
+
let mainContext = null;
|
|
42
|
+
let canvasWidth = 0;
|
|
43
|
+
let canvasHeight = 0;
|
|
44
|
+
let devicePixelRatio = 1;
|
|
45
|
+
let animationFrameId = null;
|
|
46
|
+
const layers = {
|
|
47
|
+
drag: {
|
|
48
|
+
canvas: null,
|
|
49
|
+
context: null
|
|
50
|
+
},
|
|
51
|
+
selection: {
|
|
52
|
+
canvas: null,
|
|
53
|
+
context: null
|
|
54
|
+
},
|
|
55
|
+
grabbed: {
|
|
56
|
+
canvas: null,
|
|
57
|
+
context: null
|
|
58
|
+
},
|
|
59
|
+
inspect: {
|
|
60
|
+
canvas: null,
|
|
61
|
+
context: null
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
let selectionAnimations = [];
|
|
65
|
+
let dragAnimation = null;
|
|
66
|
+
let grabbedAnimations = [];
|
|
67
|
+
let inspectAnimations = [];
|
|
68
|
+
const canvasColorSpace = supportsDisplayP3() ? "display-p3" : "srgb";
|
|
69
|
+
const createOffscreenLayer = (layerWidth, layerHeight, scaleFactor) => {
|
|
70
|
+
const canvas = new OffscreenCanvas(layerWidth * scaleFactor, layerHeight * scaleFactor);
|
|
71
|
+
const context = canvas.getContext("2d", { colorSpace: canvasColorSpace });
|
|
72
|
+
if (context) context.scale(scaleFactor, scaleFactor);
|
|
73
|
+
return {
|
|
74
|
+
canvas,
|
|
75
|
+
context
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
const initializeCanvas = () => {
|
|
79
|
+
if (!canvasRef) return;
|
|
80
|
+
devicePixelRatio = Math.max(window.devicePixelRatio || 1, 2);
|
|
81
|
+
canvasWidth = window.innerWidth;
|
|
82
|
+
canvasHeight = window.innerHeight;
|
|
83
|
+
canvasRef.width = canvasWidth * devicePixelRatio;
|
|
84
|
+
canvasRef.height = canvasHeight * devicePixelRatio;
|
|
85
|
+
canvasRef.style.width = `${canvasWidth}px`;
|
|
86
|
+
canvasRef.style.height = `${canvasHeight}px`;
|
|
87
|
+
mainContext = canvasRef.getContext("2d", { colorSpace: canvasColorSpace });
|
|
88
|
+
if (mainContext) mainContext.scale(devicePixelRatio, devicePixelRatio);
|
|
89
|
+
for (const layerName of Object.keys(layers)) layers[layerName] = createOffscreenLayer(canvasWidth, canvasHeight, devicePixelRatio);
|
|
90
|
+
};
|
|
91
|
+
const parseBorderRadiusValue = (borderRadius) => {
|
|
92
|
+
if (!borderRadius) return 0;
|
|
93
|
+
const match = borderRadius.match(/^(\d+(?:\.\d+)?)/);
|
|
94
|
+
return match ? parseFloat(match[1]) : 0;
|
|
95
|
+
};
|
|
96
|
+
const createAnimatedBounds = (id, bounds, options) => ({
|
|
97
|
+
id,
|
|
98
|
+
current: {
|
|
99
|
+
x: bounds.x,
|
|
100
|
+
y: bounds.y,
|
|
101
|
+
width: bounds.width,
|
|
102
|
+
height: bounds.height
|
|
103
|
+
},
|
|
104
|
+
target: {
|
|
105
|
+
x: bounds.x,
|
|
106
|
+
y: bounds.y,
|
|
107
|
+
width: bounds.width,
|
|
108
|
+
height: bounds.height
|
|
109
|
+
},
|
|
110
|
+
borderRadius: parseBorderRadiusValue(bounds.borderRadius),
|
|
111
|
+
opacity: options?.opacity ?? 1,
|
|
112
|
+
targetOpacity: options?.targetOpacity ?? options?.opacity ?? 1,
|
|
113
|
+
createdAt: options?.createdAt,
|
|
114
|
+
isInitialized: true
|
|
115
|
+
});
|
|
116
|
+
const updateAnimationTarget = (animation, bounds, targetOpacity) => {
|
|
117
|
+
animation.target = {
|
|
118
|
+
x: bounds.x,
|
|
119
|
+
y: bounds.y,
|
|
120
|
+
width: bounds.width,
|
|
121
|
+
height: bounds.height
|
|
122
|
+
};
|
|
123
|
+
animation.borderRadius = parseBorderRadiusValue(bounds.borderRadius);
|
|
124
|
+
if (targetOpacity !== void 0) animation.targetOpacity = targetOpacity;
|
|
125
|
+
};
|
|
126
|
+
const resolveBoundsArray = (instance) => instance.boundsMultiple ?? [instance.bounds];
|
|
127
|
+
const drawRoundedRectangle = (context, rectX, rectY, rectWidth, rectHeight, cornerRadius, fillColor, strokeColor, opacity = 1) => {
|
|
128
|
+
if (rectWidth <= 0 || rectHeight <= 0) return;
|
|
129
|
+
const maxCornerRadius = Math.min(rectWidth / 2, rectHeight / 2);
|
|
130
|
+
const clampedCornerRadius = Math.min(cornerRadius, maxCornerRadius);
|
|
131
|
+
context.globalAlpha = opacity;
|
|
132
|
+
context.beginPath();
|
|
133
|
+
if (clampedCornerRadius > 0) context.roundRect(rectX, rectY, rectWidth, rectHeight, clampedCornerRadius);
|
|
134
|
+
else context.rect(rectX, rectY, rectWidth, rectHeight);
|
|
135
|
+
context.fillStyle = fillColor;
|
|
136
|
+
context.fill();
|
|
137
|
+
context.strokeStyle = strokeColor;
|
|
138
|
+
context.lineWidth = 1;
|
|
139
|
+
context.stroke();
|
|
140
|
+
context.globalAlpha = 1;
|
|
141
|
+
};
|
|
142
|
+
const renderDragLayer = () => {
|
|
143
|
+
const layer = layers.drag;
|
|
144
|
+
if (!layer.context) return;
|
|
145
|
+
const context = layer.context;
|
|
146
|
+
context.clearRect(0, 0, canvasWidth, canvasHeight);
|
|
147
|
+
if (!props.dragVisible || !dragAnimation) return;
|
|
148
|
+
const style = LAYER_STYLES.drag;
|
|
149
|
+
drawRoundedRectangle(context, dragAnimation.current.x, dragAnimation.current.y, dragAnimation.current.width, dragAnimation.current.height, dragAnimation.borderRadius, style.fillColor, style.borderColor);
|
|
150
|
+
};
|
|
151
|
+
const renderSelectionLayer = () => {
|
|
152
|
+
const layer = layers.selection;
|
|
153
|
+
if (!layer.context) return;
|
|
154
|
+
const context = layer.context;
|
|
155
|
+
context.clearRect(0, 0, canvasWidth, canvasHeight);
|
|
156
|
+
if (!props.selectionVisible) return;
|
|
157
|
+
const style = LAYER_STYLES.selection;
|
|
158
|
+
for (const animation of selectionAnimations) {
|
|
159
|
+
const effectiveOpacity = props.selectionIsFading ? 0 : animation.opacity;
|
|
160
|
+
drawRoundedRectangle(context, animation.current.x, animation.current.y, animation.current.width, animation.current.height, animation.borderRadius, style.fillColor, style.borderColor, effectiveOpacity);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const renderBoundsLayer = (layerName, animations) => {
|
|
164
|
+
const layer = layers[layerName];
|
|
165
|
+
if (!layer.context) return;
|
|
166
|
+
const context = layer.context;
|
|
167
|
+
context.clearRect(0, 0, canvasWidth, canvasHeight);
|
|
168
|
+
const style = LAYER_STYLES[layerName];
|
|
169
|
+
for (const animation of animations) drawRoundedRectangle(context, animation.current.x, animation.current.y, animation.current.width, animation.current.height, animation.borderRadius, style.fillColor, style.borderColor, animation.opacity);
|
|
170
|
+
};
|
|
171
|
+
const compositeAllLayers = () => {
|
|
172
|
+
if (!mainContext || !canvasRef) return;
|
|
173
|
+
mainContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
174
|
+
mainContext.clearRect(0, 0, canvasRef.width, canvasRef.height);
|
|
175
|
+
mainContext.setTransform(devicePixelRatio, 0, 0, devicePixelRatio, 0, 0);
|
|
176
|
+
renderDragLayer();
|
|
177
|
+
renderSelectionLayer();
|
|
178
|
+
renderBoundsLayer("grabbed", grabbedAnimations);
|
|
179
|
+
renderBoundsLayer("inspect", inspectAnimations);
|
|
180
|
+
for (const layerName of [
|
|
181
|
+
"inspect",
|
|
182
|
+
"drag",
|
|
183
|
+
"selection",
|
|
184
|
+
"grabbed"
|
|
185
|
+
]) {
|
|
186
|
+
const layer = layers[layerName];
|
|
187
|
+
if (layer.canvas) mainContext.drawImage(layer.canvas, 0, 0, canvasWidth, canvasHeight);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
const interpolateBounds = (animation, lerpFactor, options) => {
|
|
191
|
+
const lerpedX = lerp(animation.current.x, animation.target.x, lerpFactor);
|
|
192
|
+
const lerpedY = lerp(animation.current.y, animation.target.y, lerpFactor);
|
|
193
|
+
const lerpedWidth = lerp(animation.current.width, animation.target.width, lerpFactor);
|
|
194
|
+
const lerpedHeight = lerp(animation.current.height, animation.target.height, lerpFactor);
|
|
195
|
+
const hasBoundsConverged = Math.abs(lerpedX - animation.target.x) < .5 && Math.abs(lerpedY - animation.target.y) < .5 && Math.abs(lerpedWidth - animation.target.width) < .5 && Math.abs(lerpedHeight - animation.target.height) < .5;
|
|
196
|
+
animation.current.x = hasBoundsConverged ? animation.target.x : lerpedX;
|
|
197
|
+
animation.current.y = hasBoundsConverged ? animation.target.y : lerpedY;
|
|
198
|
+
animation.current.width = hasBoundsConverged ? animation.target.width : lerpedWidth;
|
|
199
|
+
animation.current.height = hasBoundsConverged ? animation.target.height : lerpedHeight;
|
|
200
|
+
let hasOpacityConverged = true;
|
|
201
|
+
if (options?.interpolateOpacity) {
|
|
202
|
+
const lerpedOpacity = lerp(animation.opacity, animation.targetOpacity, lerpFactor);
|
|
203
|
+
hasOpacityConverged = Math.abs(lerpedOpacity - animation.targetOpacity) < OPACITY_CONVERGENCE_THRESHOLD;
|
|
204
|
+
animation.opacity = hasOpacityConverged ? animation.targetOpacity : lerpedOpacity;
|
|
205
|
+
}
|
|
206
|
+
return !hasBoundsConverged || !hasOpacityConverged;
|
|
207
|
+
};
|
|
208
|
+
const runAnimationFrame = () => {
|
|
209
|
+
let shouldContinueAnimating = false;
|
|
210
|
+
if (dragAnimation?.isInitialized) {
|
|
211
|
+
if (interpolateBounds(dragAnimation, LAYER_STYLES.drag.lerpFactor)) shouldContinueAnimating = true;
|
|
212
|
+
}
|
|
213
|
+
for (const animation of selectionAnimations) if (animation.isInitialized) {
|
|
214
|
+
if (interpolateBounds(animation, LAYER_STYLES.selection.lerpFactor)) shouldContinueAnimating = true;
|
|
215
|
+
}
|
|
216
|
+
const currentTimestamp = Date.now();
|
|
217
|
+
grabbedAnimations = grabbedAnimations.filter((animation) => {
|
|
218
|
+
const isLabelAnimation = animation.id.startsWith("label-");
|
|
219
|
+
if (animation.isInitialized) {
|
|
220
|
+
if (interpolateBounds(animation, LAYER_STYLES.grabbed.lerpFactor, { interpolateOpacity: isLabelAnimation })) shouldContinueAnimating = true;
|
|
221
|
+
}
|
|
222
|
+
if (animation.createdAt) {
|
|
223
|
+
const elapsed = currentTimestamp - animation.createdAt;
|
|
224
|
+
if (elapsed >= 1500 + 100) return false;
|
|
225
|
+
if (elapsed > 1500) {
|
|
226
|
+
animation.opacity = 1 - (elapsed - FEEDBACK_DURATION_MS) / 100;
|
|
227
|
+
shouldContinueAnimating = true;
|
|
228
|
+
}
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
if (isLabelAnimation) {
|
|
232
|
+
if (Math.abs(animation.opacity - animation.targetOpacity) < .01 && animation.targetOpacity === 0) return false;
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
return animation.opacity > 0;
|
|
236
|
+
});
|
|
237
|
+
for (const animation of inspectAnimations) if (animation.isInitialized) {
|
|
238
|
+
if (interpolateBounds(animation, LAYER_STYLES.inspect.lerpFactor)) shouldContinueAnimating = true;
|
|
239
|
+
}
|
|
240
|
+
compositeAllLayers();
|
|
241
|
+
if (shouldContinueAnimating) animationFrameId = nativeRequestAnimationFrame(runAnimationFrame);
|
|
242
|
+
else animationFrameId = null;
|
|
243
|
+
};
|
|
244
|
+
const scheduleAnimationFrame = () => {
|
|
245
|
+
if (animationFrameId !== null) return;
|
|
246
|
+
animationFrameId = nativeRequestAnimationFrame(runAnimationFrame);
|
|
247
|
+
};
|
|
248
|
+
const handleWindowResize = () => {
|
|
249
|
+
initializeCanvas();
|
|
250
|
+
scheduleAnimationFrame();
|
|
251
|
+
};
|
|
252
|
+
createEffect(on(() => [
|
|
253
|
+
props.selectionVisible,
|
|
254
|
+
props.selectionBounds,
|
|
255
|
+
props.selectionBoundsMultiple,
|
|
256
|
+
props.selectionIsFading,
|
|
257
|
+
props.selectionShouldSnap
|
|
258
|
+
], ([isVisible, singleBounds, multipleBounds, , shouldSnap]) => {
|
|
259
|
+
if (!isVisible || !singleBounds && (!multipleBounds || multipleBounds.length === 0)) {
|
|
260
|
+
selectionAnimations = [];
|
|
261
|
+
scheduleAnimationFrame();
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
let boundsToRender;
|
|
265
|
+
if (multipleBounds && multipleBounds.length > 0) boundsToRender = multipleBounds;
|
|
266
|
+
else if (singleBounds) boundsToRender = [singleBounds];
|
|
267
|
+
else boundsToRender = [];
|
|
268
|
+
selectionAnimations = boundsToRender.map((bounds, index) => {
|
|
269
|
+
const animationId = `selection-${index}`;
|
|
270
|
+
const existingAnimation = selectionAnimations.find((animation) => animation.id === animationId);
|
|
271
|
+
if (existingAnimation) {
|
|
272
|
+
updateAnimationTarget(existingAnimation, bounds);
|
|
273
|
+
if (shouldSnap) existingAnimation.current = { ...existingAnimation.target };
|
|
274
|
+
return existingAnimation;
|
|
275
|
+
}
|
|
276
|
+
return createAnimatedBounds(animationId, bounds);
|
|
277
|
+
});
|
|
278
|
+
scheduleAnimationFrame();
|
|
279
|
+
}));
|
|
280
|
+
createEffect(on(() => [props.dragVisible, props.dragBounds], ([isVisible, bounds]) => {
|
|
281
|
+
if (!isVisible || !bounds) {
|
|
282
|
+
dragAnimation = null;
|
|
283
|
+
scheduleAnimationFrame();
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (dragAnimation) updateAnimationTarget(dragAnimation, bounds);
|
|
287
|
+
else dragAnimation = createAnimatedBounds("drag", bounds);
|
|
288
|
+
scheduleAnimationFrame();
|
|
289
|
+
}));
|
|
290
|
+
createEffect(on(() => [props.grabbedBoxes, props.labelInstances], ([grabbedBoxes, labelInstances]) => {
|
|
291
|
+
const boxesToProcess = grabbedBoxes ?? [];
|
|
292
|
+
const activeBoxIds = new Set(boxesToProcess.map((box) => box.id));
|
|
293
|
+
const existingAnimationIds = new Set(grabbedAnimations.map((animation) => animation.id));
|
|
294
|
+
for (const box of boxesToProcess) if (!existingAnimationIds.has(box.id)) grabbedAnimations.push(createAnimatedBounds(box.id, box.bounds, { createdAt: box.createdAt }));
|
|
295
|
+
for (const animation of grabbedAnimations) {
|
|
296
|
+
const matchingBox = boxesToProcess.find((box) => box.id === animation.id);
|
|
297
|
+
if (matchingBox) updateAnimationTarget(animation, matchingBox.bounds);
|
|
298
|
+
}
|
|
299
|
+
const instancesToProcess = labelInstances ?? [];
|
|
300
|
+
for (const instance of instancesToProcess) {
|
|
301
|
+
const boundsToRender = resolveBoundsArray(instance);
|
|
302
|
+
const targetOpacity = instance.status === "fading" ? 0 : 1;
|
|
303
|
+
for (let index = 0; index < boundsToRender.length; index++) {
|
|
304
|
+
const bounds = boundsToRender[index];
|
|
305
|
+
const animationId = `label-${instance.id}-${index}`;
|
|
306
|
+
const existingAnimation = grabbedAnimations.find((animation) => animation.id === animationId);
|
|
307
|
+
if (existingAnimation) updateAnimationTarget(existingAnimation, bounds, targetOpacity);
|
|
308
|
+
else grabbedAnimations.push(createAnimatedBounds(animationId, bounds, {
|
|
309
|
+
opacity: 1,
|
|
310
|
+
targetOpacity
|
|
311
|
+
}));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const activeLabelIds = /* @__PURE__ */ new Set();
|
|
315
|
+
for (const instance of instancesToProcess) {
|
|
316
|
+
const boundsToRender = resolveBoundsArray(instance);
|
|
317
|
+
for (let index = 0; index < boundsToRender.length; index++) activeLabelIds.add(`label-${instance.id}-${index}`);
|
|
318
|
+
}
|
|
319
|
+
grabbedAnimations = grabbedAnimations.filter((animation) => {
|
|
320
|
+
if (animation.id.startsWith("label-")) return activeLabelIds.has(animation.id);
|
|
321
|
+
return activeBoxIds.has(animation.id);
|
|
322
|
+
});
|
|
323
|
+
scheduleAnimationFrame();
|
|
324
|
+
}));
|
|
325
|
+
createEffect(on(() => [props.inspectVisible, props.inspectBounds], ([isVisible, bounds]) => {
|
|
326
|
+
if (!isVisible || !bounds || bounds.length === 0) {
|
|
327
|
+
inspectAnimations = [];
|
|
328
|
+
scheduleAnimationFrame();
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
inspectAnimations = bounds.map((ancestorBounds, index) => {
|
|
332
|
+
const animationId = `inspect-${index}`;
|
|
333
|
+
const existingAnimation = inspectAnimations.find((animation) => animation.id === animationId);
|
|
334
|
+
if (existingAnimation) {
|
|
335
|
+
updateAnimationTarget(existingAnimation, ancestorBounds);
|
|
336
|
+
return existingAnimation;
|
|
337
|
+
}
|
|
338
|
+
return createAnimatedBounds(animationId, ancestorBounds);
|
|
339
|
+
});
|
|
340
|
+
scheduleAnimationFrame();
|
|
341
|
+
}));
|
|
342
|
+
onMount(() => {
|
|
343
|
+
initializeCanvas();
|
|
344
|
+
scheduleAnimationFrame();
|
|
345
|
+
window.addEventListener("resize", handleWindowResize);
|
|
346
|
+
let currentDprMediaQuery = null;
|
|
347
|
+
const handleDevicePixelRatioChange = () => {
|
|
348
|
+
if (Math.max(window.devicePixelRatio || 1, 2) !== devicePixelRatio) {
|
|
349
|
+
handleWindowResize();
|
|
350
|
+
setupDprMediaQuery();
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
const setupDprMediaQuery = () => {
|
|
354
|
+
if (currentDprMediaQuery) currentDprMediaQuery.removeEventListener("change", handleDevicePixelRatioChange);
|
|
355
|
+
currentDprMediaQuery = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
|
|
356
|
+
currentDprMediaQuery.addEventListener("change", handleDevicePixelRatioChange);
|
|
357
|
+
};
|
|
358
|
+
setupDprMediaQuery();
|
|
359
|
+
onCleanup(() => {
|
|
360
|
+
window.removeEventListener("resize", handleWindowResize);
|
|
361
|
+
if (currentDprMediaQuery) currentDprMediaQuery.removeEventListener("change", handleDevicePixelRatioChange);
|
|
362
|
+
if (animationFrameId !== null) nativeCancelAnimationFrame(animationFrameId);
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
return (() => {
|
|
366
|
+
var _el$ = _tmpl$$29();
|
|
367
|
+
var _ref$ = canvasRef;
|
|
368
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : canvasRef = _el$;
|
|
369
|
+
createRenderEffect((_$p) => setStyleProperty(_el$, "z-index", String(Z_INDEX_OVERLAY_CANVAS)));
|
|
370
|
+
return _el$;
|
|
371
|
+
})();
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region src/utils/auto-resize-textarea.ts
|
|
376
|
+
const autoResizeTextarea = (textarea, maxHeight) => {
|
|
377
|
+
textarea.style.height = "auto";
|
|
378
|
+
textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/utils/get-arrow-size.ts
|
|
383
|
+
const getArrowSize = (labelWidth) => {
|
|
384
|
+
if (labelWidth <= 0) return 8;
|
|
385
|
+
const scaledSize = labelWidth * ARROW_MAX_LABEL_WIDTH_RATIO;
|
|
386
|
+
return Math.max(4, Math.min(8, scaledSize));
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
//#endregion
|
|
390
|
+
//#region src/utils/cn.ts
|
|
391
|
+
const resolveValue = (input) => {
|
|
392
|
+
if (typeof input === "string" || typeof input === "number") return String(input);
|
|
393
|
+
if (!input || typeof input !== "object") return "";
|
|
394
|
+
if (Array.isArray(input)) {
|
|
395
|
+
let result = "";
|
|
396
|
+
for (const item of input) {
|
|
397
|
+
if (!item) continue;
|
|
398
|
+
const resolved = resolveValue(item);
|
|
399
|
+
if (resolved) result = result ? `${result} ${resolved}` : resolved;
|
|
400
|
+
}
|
|
401
|
+
return result;
|
|
402
|
+
}
|
|
403
|
+
let result = "";
|
|
404
|
+
for (const key in input) if (input[key]) result = result ? `${result} ${key}` : key;
|
|
405
|
+
return result;
|
|
406
|
+
};
|
|
407
|
+
const cn = (...inputs) => {
|
|
408
|
+
let result = "";
|
|
409
|
+
for (const input of inputs) {
|
|
410
|
+
if (!input) continue;
|
|
411
|
+
const resolved = resolveValue(input);
|
|
412
|
+
if (resolved) result = result ? `${result} ${resolved}` : resolved;
|
|
413
|
+
}
|
|
414
|
+
return result;
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
//#endregion
|
|
418
|
+
//#region src/utils/get-tag-display.ts
|
|
419
|
+
const getTagDisplay = (input) => {
|
|
420
|
+
if (input.elementsCount && input.elementsCount > 1) return {
|
|
421
|
+
tagName: `${input.elementsCount} elements`,
|
|
422
|
+
componentName: void 0
|
|
423
|
+
};
|
|
424
|
+
return {
|
|
425
|
+
tagName: input.tagName || input.componentName || "element",
|
|
426
|
+
componentName: input.tagName ? input.componentName : void 0
|
|
427
|
+
};
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/utils/format-shortcut.ts
|
|
432
|
+
const formatShortcut = (shortcut) => {
|
|
433
|
+
if (shortcut === "Enter") return "↵";
|
|
434
|
+
if (isMac()) return `⌘${shortcut}`;
|
|
435
|
+
return `Ctrl+${shortcut.replace("⇧", "Shift+")}`;
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region src/components/icons/icon-submit.tsx
|
|
440
|
+
var _tmpl$$28 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 12 12"fill=none><path d="M6 1L6 11M6 1L2 5M6 1L10 5"stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round>`);
|
|
441
|
+
const IconSubmit = (props) => {
|
|
442
|
+
const size = () => props.size ?? 12;
|
|
443
|
+
return (() => {
|
|
444
|
+
var _el$ = _tmpl$$28();
|
|
445
|
+
createRenderEffect((_p$) => {
|
|
446
|
+
var _v$ = size(), _v$2 = size(), _v$3 = props.class;
|
|
447
|
+
_v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
|
|
448
|
+
_v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
|
|
449
|
+
_v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
|
|
450
|
+
return _p$;
|
|
451
|
+
}, {
|
|
452
|
+
e: void 0,
|
|
453
|
+
t: void 0,
|
|
454
|
+
a: void 0
|
|
455
|
+
});
|
|
456
|
+
return _el$;
|
|
457
|
+
})();
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region src/components/icons/icon-loader.tsx
|
|
462
|
+
var _tmpl$$27 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path class=icon-loader-bar d="M12 2v4"style=animation-delay:0ms></path><path class=icon-loader-bar d="M15 6.8l2-3.5"style=animation-delay:-42ms></path><path class=icon-loader-bar d="M17.2 9l3.5-2"style=animation-delay:-83ms></path><path class=icon-loader-bar d="M18 12h4"style=animation-delay:-125ms></path><path class=icon-loader-bar d="M17.2 15l3.5 2"style=animation-delay:-167ms></path><path class=icon-loader-bar d="M15 17.2l2 3.5"style=animation-delay:-208ms></path><path class=icon-loader-bar d="M12 18v4"style=animation-delay:-250ms></path><path class=icon-loader-bar d="M9 17.2l-2 3.5"style=animation-delay:-292ms></path><path class=icon-loader-bar d="M6.8 15l-3.5 2"style=animation-delay:-333ms></path><path class=icon-loader-bar d="M2 12h4"style=animation-delay:-375ms></path><path class=icon-loader-bar d="M6.8 9l-3.5-2"style=animation-delay:-417ms></path><path class=icon-loader-bar d="M9 6.8l-2-3.5"style=animation-delay:-458ms>`);
|
|
463
|
+
const IconLoader = (props) => {
|
|
464
|
+
const size = () => props.size ?? 16;
|
|
465
|
+
return (() => {
|
|
466
|
+
var _el$ = _tmpl$$27();
|
|
467
|
+
_el$.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling;
|
|
468
|
+
createRenderEffect((_p$) => {
|
|
469
|
+
var _v$ = size(), _v$2 = size(), _v$3 = props.class;
|
|
470
|
+
_v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
|
|
471
|
+
_v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
|
|
472
|
+
_v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
|
|
473
|
+
return _p$;
|
|
474
|
+
}, {
|
|
475
|
+
e: void 0,
|
|
476
|
+
t: void 0,
|
|
477
|
+
a: void 0
|
|
478
|
+
});
|
|
479
|
+
return _el$;
|
|
480
|
+
})();
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region src/components/selection-label/arrow.tsx
|
|
485
|
+
var _tmpl$$26 = /* @__PURE__ */ template(`<div data-react-grab-arrow class="absolute w-0 h-0 z-10">`);
|
|
486
|
+
const Arrow = (props) => {
|
|
487
|
+
const arrowColor = () => props.color ?? "white";
|
|
488
|
+
const isBottom = () => props.position === "bottom";
|
|
489
|
+
const arrowSize = () => getArrowSize(props.labelWidth ?? 0);
|
|
490
|
+
return (() => {
|
|
491
|
+
var _el$ = _tmpl$$26();
|
|
492
|
+
createRenderEffect((_p$) => {
|
|
493
|
+
var _v$ = `calc(${props.leftPercent}% + ${props.leftOffsetPx}px)`, _v$2 = isBottom() ? "0" : void 0, _v$3 = isBottom() ? void 0 : "0", _v$4 = isBottom() ? "translateX(-50%) translateY(-100%)" : "translateX(-50%) translateY(100%)", _v$5 = `${arrowSize()}px solid transparent`, _v$6 = `${arrowSize()}px solid transparent`, _v$7 = isBottom() ? `${arrowSize()}px solid ${arrowColor()}` : void 0, _v$8 = isBottom() ? void 0 : `${arrowSize()}px solid ${arrowColor()}`;
|
|
494
|
+
_v$ !== _p$.e && setStyleProperty(_el$, "left", _p$.e = _v$);
|
|
495
|
+
_v$2 !== _p$.t && setStyleProperty(_el$, "top", _p$.t = _v$2);
|
|
496
|
+
_v$3 !== _p$.a && setStyleProperty(_el$, "bottom", _p$.a = _v$3);
|
|
497
|
+
_v$4 !== _p$.o && setStyleProperty(_el$, "transform", _p$.o = _v$4);
|
|
498
|
+
_v$5 !== _p$.i && setStyleProperty(_el$, "border-left", _p$.i = _v$5);
|
|
499
|
+
_v$6 !== _p$.n && setStyleProperty(_el$, "border-right", _p$.n = _v$6);
|
|
500
|
+
_v$7 !== _p$.s && setStyleProperty(_el$, "border-bottom", _p$.s = _v$7);
|
|
501
|
+
_v$8 !== _p$.h && setStyleProperty(_el$, "border-top", _p$.h = _v$8);
|
|
502
|
+
return _p$;
|
|
503
|
+
}, {
|
|
504
|
+
e: void 0,
|
|
505
|
+
t: void 0,
|
|
506
|
+
a: void 0,
|
|
507
|
+
o: void 0,
|
|
508
|
+
i: void 0,
|
|
509
|
+
n: void 0,
|
|
510
|
+
s: void 0,
|
|
511
|
+
h: void 0
|
|
512
|
+
});
|
|
513
|
+
return _el$;
|
|
514
|
+
})();
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
//#endregion
|
|
518
|
+
//#region src/components/icons/icon-open.tsx
|
|
519
|
+
var _tmpl$$25 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-linecap=round stroke-linejoin=round stroke-width=2><path d="M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6"></path><path d="M11 13l9-9"></path><path d="M15 4h5v5">`);
|
|
520
|
+
const IconOpen = (props) => {
|
|
521
|
+
const size = () => props.size ?? 12;
|
|
522
|
+
return (() => {
|
|
523
|
+
var _el$ = _tmpl$$25();
|
|
524
|
+
createRenderEffect((_p$) => {
|
|
525
|
+
var _v$ = size(), _v$2 = size(), _v$3 = props.class;
|
|
526
|
+
_v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
|
|
527
|
+
_v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
|
|
528
|
+
_v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
|
|
529
|
+
return _p$;
|
|
530
|
+
}, {
|
|
531
|
+
e: void 0,
|
|
532
|
+
t: void 0,
|
|
533
|
+
a: void 0
|
|
534
|
+
});
|
|
535
|
+
return _el$;
|
|
536
|
+
})();
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
//#endregion
|
|
540
|
+
//#region src/components/selection-label/tag-badge.tsx
|
|
541
|
+
var _tmpl$$24 = /* @__PURE__ */ template(`<span class=text-black>`), _tmpl$2$10 = /* @__PURE__ */ template(`<span class=text-black/50>.`), _tmpl$3$7 = /* @__PURE__ */ template(`<div><span class="text-[13px] leading-4 h-fit font-medium overflow-hidden text-ellipsis whitespace-nowrap min-w-0">`);
|
|
542
|
+
const TagBadge = (props) => {
|
|
543
|
+
const [isHovered, setIsHovered] = createSignal(false);
|
|
544
|
+
const handleMouseEnter = () => {
|
|
545
|
+
setIsHovered(true);
|
|
546
|
+
props.onHoverChange?.(true);
|
|
547
|
+
};
|
|
548
|
+
const handleMouseLeave = () => {
|
|
549
|
+
setIsHovered(false);
|
|
550
|
+
props.onHoverChange?.(false);
|
|
551
|
+
};
|
|
552
|
+
return (() => {
|
|
553
|
+
var _el$ = _tmpl$3$7(), _el$2 = _el$.firstChild;
|
|
554
|
+
addEventListener(_el$, "click", props.onClick, true);
|
|
555
|
+
_el$.addEventListener("mouseleave", handleMouseLeave);
|
|
556
|
+
_el$.addEventListener("mouseenter", handleMouseEnter);
|
|
557
|
+
insert(_el$2, createComponent(Show, {
|
|
558
|
+
get when() {
|
|
559
|
+
return props.componentName;
|
|
560
|
+
},
|
|
561
|
+
get children() {
|
|
562
|
+
return [(() => {
|
|
563
|
+
var _el$3 = _tmpl$$24();
|
|
564
|
+
insert(_el$3, () => props.componentName);
|
|
565
|
+
return _el$3;
|
|
566
|
+
})(), (() => {
|
|
567
|
+
var _el$4 = _tmpl$2$10();
|
|
568
|
+
_el$4.firstChild;
|
|
569
|
+
insert(_el$4, () => props.tagName, null);
|
|
570
|
+
return _el$4;
|
|
571
|
+
})()];
|
|
572
|
+
}
|
|
573
|
+
}), null);
|
|
574
|
+
insert(_el$2, createComponent(Show, {
|
|
575
|
+
get when() {
|
|
576
|
+
return !props.componentName;
|
|
577
|
+
},
|
|
578
|
+
get children() {
|
|
579
|
+
var _el$6 = _tmpl$$24();
|
|
580
|
+
insert(_el$6, () => props.tagName);
|
|
581
|
+
return _el$6;
|
|
582
|
+
}
|
|
583
|
+
}), null);
|
|
584
|
+
insert(_el$, createComponent(Show, {
|
|
585
|
+
get when() {
|
|
586
|
+
return props.isClickable || props.forceShowIcon;
|
|
587
|
+
},
|
|
588
|
+
get children() {
|
|
589
|
+
return createComponent(IconOpen, {
|
|
590
|
+
size: 10,
|
|
591
|
+
get ["class"]() {
|
|
592
|
+
return cn("text-black transition-all duration-100 shrink-0", isHovered() || props.forceShowIcon ? "opacity-100 scale-100" : "opacity-0 scale-75 -ml-[2px] w-0");
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
}), null);
|
|
597
|
+
createRenderEffect(() => className(_el$, cn("contain-layout flex items-center gap-1 max-w-[280px] overflow-hidden", props.shrink && "shrink-0", props.isClickable && "cursor-pointer")));
|
|
598
|
+
return _el$;
|
|
599
|
+
})();
|
|
600
|
+
};
|
|
601
|
+
delegateEvents(["click"]);
|
|
602
|
+
|
|
603
|
+
//#endregion
|
|
604
|
+
//#region src/components/selection-label/bottom-section.tsx
|
|
605
|
+
var _tmpl$$23 = /* @__PURE__ */ template(`<div class="[font-synthesis:none] contain-layout shrink-0 flex flex-col items-start px-2 py-1.5 w-auto h-fit self-stretch [border-top-width:0.5px] border-t-solid border-t-[#D9D9D9] antialiased rounded-t-none rounded-b-[6px]">`);
|
|
606
|
+
const BottomSection = (props) => (() => {
|
|
607
|
+
var _el$ = _tmpl$$23();
|
|
608
|
+
insert(_el$, () => props.children);
|
|
609
|
+
return _el$;
|
|
610
|
+
})();
|
|
611
|
+
|
|
612
|
+
//#endregion
|
|
613
|
+
//#region src/utils/confirmation-focus-manager.ts
|
|
614
|
+
let activeConfirmationId = null;
|
|
615
|
+
const confirmationFocusManager = {
|
|
616
|
+
claim: (id) => {
|
|
617
|
+
activeConfirmationId = id;
|
|
618
|
+
},
|
|
619
|
+
release: (id) => {
|
|
620
|
+
if (activeConfirmationId === id) activeConfirmationId = null;
|
|
621
|
+
},
|
|
622
|
+
isActive: (id) => activeConfirmationId === id
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
//#endregion
|
|
626
|
+
//#region src/components/icons/icon-return.tsx
|
|
627
|
+
var _tmpl$$22 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 22 19"fill=none><path d="M6.76263 18.6626C7.48251 18.6626 7.95474 18.1682 7.95474 17.4895C7.95474 17.1207 7.80474 16.8576 7.58683 16.6361L5.3018 14.4137L2.84621 12.3589L2.44374 13.0037L5.92137 13.1622H17.9232C20.4842 13.1622 21.593 12.021 21.593 9.47237V3.66983C21.593 1.10875 20.4842 0 17.9232 0H12.5414C11.8179 0 11.3018 0.545895 11.3018 1.21695C11.3018 1.888 11.8179 2.43389 12.5414 2.43389H17.8424C18.7937 2.43389 19.1897 2.83653 19.1897 3.78784V9.35747C19.1897 10.3257 18.7937 10.7314 17.8424 10.7314H5.92137L2.44374 10.8832L2.84621 11.5281L5.3018 9.47993L7.58683 7.2606C7.80474 7.03914 7.95474 6.7693 7.95474 6.40049C7.95474 5.72854 7.48251 5.22747 6.76263 5.22747C6.46129 5.22747 6.12975 5.36905 5.89231 5.6096L0.376815 11.0425C0.134921 11.2777 0 11.6141 0 11.9452C0 12.2728 0.134921 12.6158 0.376815 12.848L5.89231 18.2871C6.12975 18.5276 6.46129 18.6626 6.76263 18.6626Z"fill=currentColor>`);
|
|
628
|
+
const IconReturn = (props) => {
|
|
629
|
+
const size = () => props.size ?? 12;
|
|
630
|
+
return (() => {
|
|
631
|
+
var _el$ = _tmpl$$22();
|
|
632
|
+
createRenderEffect((_p$) => {
|
|
633
|
+
var _v$ = size(), _v$2 = size() * 19 / 22, _v$3 = props.class;
|
|
634
|
+
_v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
|
|
635
|
+
_v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
|
|
636
|
+
_v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
|
|
637
|
+
return _p$;
|
|
638
|
+
}, {
|
|
639
|
+
e: void 0,
|
|
640
|
+
t: void 0,
|
|
641
|
+
a: void 0
|
|
642
|
+
});
|
|
643
|
+
return _el$;
|
|
644
|
+
})();
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
//#endregion
|
|
648
|
+
//#region src/components/selection-label/discard-prompt.tsx
|
|
649
|
+
var _tmpl$$21 = /* @__PURE__ */ template(`<div class="contain-layout shrink-0 flex items-center justify-end gap-[5px] w-full h-fit"><button data-react-grab-discard-no class="contain-layout shrink-0 flex items-center justify-center px-[3px] py-px rounded-sm bg-white [border-width:0.5px] border-solid border-[#B3B3B3] cursor-pointer transition-all hover:bg-[#F5F5F5] press-scale h-[17px]"><span class="text-black text-[13px] leading-3.5 font-sans font-medium">No</span></button><button data-react-grab-discard-yes class="contain-layout shrink-0 flex items-center justify-center gap-0.5 px-[3px] py-px rounded-sm bg-[#FEF2F2] cursor-pointer transition-all hover:bg-[#FEE2E2] press-scale h-[17px]"><span class="text-[#B91C1C] text-[13px] leading-3.5 font-sans font-medium">Yes`), _tmpl$2$9 = /* @__PURE__ */ template(`<div data-react-grab-discard-prompt class="contain-layout shrink-0 flex flex-col justify-center items-end w-fit h-fit"><div class="contain-layout shrink-0 flex items-center gap-1 pt-1.5 pb-1 px-2 w-full h-fit"><span class="text-black text-[13px] leading-4 shrink-0 font-sans font-medium w-fit h-fit">`);
|
|
650
|
+
const DiscardPrompt = (props) => {
|
|
651
|
+
const instanceId = Symbol();
|
|
652
|
+
const handleKeyDown = (event) => {
|
|
653
|
+
if (!confirmationFocusManager.isActive(instanceId)) return;
|
|
654
|
+
if (isKeyboardEventTriggeredByInput(event)) return;
|
|
655
|
+
const isEnter = event.code === "Enter";
|
|
656
|
+
const isEscape = event.code === "Escape";
|
|
657
|
+
if (isEnter || isEscape) {
|
|
658
|
+
event.preventDefault();
|
|
659
|
+
event.stopPropagation();
|
|
660
|
+
if (isEscape && props.cancelOnEscape) props.onCancel?.();
|
|
661
|
+
else props.onConfirm?.();
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
const handleFocus = () => {
|
|
665
|
+
confirmationFocusManager.claim(instanceId);
|
|
666
|
+
};
|
|
667
|
+
onMount(() => {
|
|
668
|
+
confirmationFocusManager.claim(instanceId);
|
|
669
|
+
window.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
670
|
+
});
|
|
671
|
+
onCleanup(() => {
|
|
672
|
+
confirmationFocusManager.release(instanceId);
|
|
673
|
+
window.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
674
|
+
});
|
|
675
|
+
return (() => {
|
|
676
|
+
var _el$ = _tmpl$2$9(), _el$3 = _el$.firstChild.firstChild;
|
|
677
|
+
_el$.$$click = handleFocus;
|
|
678
|
+
_el$.$$pointerdown = handleFocus;
|
|
679
|
+
insert(_el$3, () => props.label ?? "Discard?");
|
|
680
|
+
insert(_el$, createComponent(BottomSection, { get children() {
|
|
681
|
+
var _el$4 = _tmpl$$21(), _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling;
|
|
682
|
+
_el$6.firstChild;
|
|
683
|
+
addEventListener(_el$5, "click", props.onCancel, true);
|
|
684
|
+
addEventListener(_el$6, "click", props.onConfirm, true);
|
|
685
|
+
insert(_el$6, createComponent(IconReturn, {
|
|
686
|
+
size: 10,
|
|
687
|
+
"class": "text-[#B91C1C]/50"
|
|
688
|
+
}), null);
|
|
689
|
+
return _el$4;
|
|
690
|
+
} }), null);
|
|
691
|
+
return _el$;
|
|
692
|
+
})();
|
|
693
|
+
};
|
|
694
|
+
delegateEvents(["pointerdown", "click"]);
|
|
695
|
+
|
|
696
|
+
//#endregion
|
|
697
|
+
//#region src/components/icons/icon-retry.tsx
|
|
698
|
+
var _tmpl$$20 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none><path d="M17.65 6.35C16.2 4.9 14.21 4 12 4C7.58 4 4.01 7.58 4.01 12C4.01 16.42 7.58 20 12 20C15.73 20 18.84 17.45 19.73 14H17.65C16.83 16.33 14.61 18 12 18C8.69 18 6 15.31 6 12C6 8.69 8.69 6 12 6C13.66 6 15.14 6.69 16.22 7.78L13 11H20V4L17.65 6.35Z"fill=currentColor>`);
|
|
699
|
+
const IconRetry = (props) => {
|
|
700
|
+
const size = () => props.size ?? 12;
|
|
701
|
+
return (() => {
|
|
702
|
+
var _el$ = _tmpl$$20();
|
|
703
|
+
createRenderEffect((_p$) => {
|
|
704
|
+
var _v$ = size(), _v$2 = size(), _v$3 = props.class;
|
|
705
|
+
_v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
|
|
706
|
+
_v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
|
|
707
|
+
_v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
|
|
708
|
+
return _p$;
|
|
709
|
+
}, {
|
|
710
|
+
e: void 0,
|
|
711
|
+
t: void 0,
|
|
712
|
+
a: void 0
|
|
713
|
+
});
|
|
714
|
+
return _el$;
|
|
715
|
+
})();
|
|
716
|
+
};
|
|
717
|
+
|
|
718
|
+
//#endregion
|
|
719
|
+
//#region src/components/selection-label/error-view.tsx
|
|
720
|
+
var _tmpl$$19 = /* @__PURE__ */ template(`<div class="contain-layout shrink-0 flex items-center justify-end gap-[5px] w-full h-fit"><button data-react-grab-retry class="contain-layout shrink-0 flex items-center justify-center gap-1 px-[3px] py-px rounded-sm bg-white [border-width:0.5px] border-solid border-[#B3B3B3] cursor-pointer transition-all hover:bg-[#F5F5F5] press-scale h-[17px]"><span class="text-black text-[13px] leading-3.5 font-sans font-medium">Retry</span></button><button data-react-grab-error-ok class="contain-layout shrink-0 flex items-center justify-center gap-1 px-[3px] py-px rounded-sm bg-white [border-width:0.5px] border-solid border-[#B3B3B3] cursor-pointer transition-all hover:bg-[#F5F5F5] press-scale h-[17px]"><span class="text-black text-[13px] leading-3.5 font-sans font-medium">Ok`), _tmpl$2$8 = /* @__PURE__ */ template(`<div data-react-grab-error class="contain-layout shrink-0 flex flex-col justify-center items-end w-fit h-fit max-w-[280px]"><div class="contain-layout shrink-0 flex items-start gap-1 px-2 w-full h-fit"><span class="text-[#B91C1C] text-[13px] leading-4 font-sans font-medium overflow-hidden line-clamp-5">`);
|
|
721
|
+
const ErrorView = (props) => {
|
|
722
|
+
const instanceId = Symbol();
|
|
723
|
+
const handleKeyDown = (event) => {
|
|
724
|
+
if (!confirmationFocusManager.isActive(instanceId)) return;
|
|
725
|
+
if (isKeyboardEventTriggeredByInput(event)) return;
|
|
726
|
+
const isEnter = event.code === "Enter";
|
|
727
|
+
const isEscape = event.code === "Escape";
|
|
728
|
+
if (isEnter) {
|
|
729
|
+
event.preventDefault();
|
|
730
|
+
event.stopPropagation();
|
|
731
|
+
props.onRetry?.();
|
|
732
|
+
} else if (isEscape) {
|
|
733
|
+
event.preventDefault();
|
|
734
|
+
event.stopPropagation();
|
|
735
|
+
props.onAcknowledge?.();
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
const handleFocus = () => {
|
|
739
|
+
confirmationFocusManager.claim(instanceId);
|
|
740
|
+
};
|
|
741
|
+
onMount(() => {
|
|
742
|
+
confirmationFocusManager.claim(instanceId);
|
|
743
|
+
window.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
744
|
+
});
|
|
745
|
+
onCleanup(() => {
|
|
746
|
+
confirmationFocusManager.release(instanceId);
|
|
747
|
+
window.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
748
|
+
});
|
|
749
|
+
const hasActions = () => Boolean(props.onRetry || props.onAcknowledge);
|
|
750
|
+
return (() => {
|
|
751
|
+
var _el$ = _tmpl$2$8(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
752
|
+
_el$.$$click = handleFocus;
|
|
753
|
+
_el$.$$pointerdown = handleFocus;
|
|
754
|
+
insert(_el$3, () => props.error);
|
|
755
|
+
insert(_el$, createComponent(Show, {
|
|
756
|
+
get when() {
|
|
757
|
+
return hasActions();
|
|
758
|
+
},
|
|
759
|
+
get children() {
|
|
760
|
+
return createComponent(BottomSection, { get children() {
|
|
761
|
+
var _el$4 = _tmpl$$19(), _el$5 = _el$4.firstChild;
|
|
762
|
+
_el$5.firstChild;
|
|
763
|
+
var _el$7 = _el$5.nextSibling;
|
|
764
|
+
addEventListener(_el$5, "click", props.onRetry, true);
|
|
765
|
+
insert(_el$5, createComponent(IconRetry, {
|
|
766
|
+
size: 10,
|
|
767
|
+
"class": "text-black/50"
|
|
768
|
+
}), null);
|
|
769
|
+
addEventListener(_el$7, "click", props.onAcknowledge, true);
|
|
770
|
+
return _el$4;
|
|
771
|
+
} });
|
|
772
|
+
}
|
|
773
|
+
}), null);
|
|
774
|
+
createRenderEffect((_p$) => {
|
|
775
|
+
var _v$ = {
|
|
776
|
+
"pt-1.5 pb-1": hasActions(),
|
|
777
|
+
"py-1.5": !hasActions()
|
|
778
|
+
}, _v$2 = props.error;
|
|
779
|
+
_p$.e = classList(_el$2, _v$, _p$.e);
|
|
780
|
+
_v$2 !== _p$.t && setAttribute(_el$3, "title", _p$.t = _v$2);
|
|
781
|
+
return _p$;
|
|
782
|
+
}, {
|
|
783
|
+
e: void 0,
|
|
784
|
+
t: void 0
|
|
785
|
+
});
|
|
786
|
+
return _el$;
|
|
787
|
+
})();
|
|
788
|
+
};
|
|
789
|
+
delegateEvents(["pointerdown", "click"]);
|
|
790
|
+
|
|
791
|
+
//#endregion
|
|
792
|
+
//#region src/components/icons/icon-ellipsis.tsx
|
|
793
|
+
var _tmpl$$18 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=currentColor><circle cx=5 cy=12 r=2></circle><circle cx=12 cy=12 r=2></circle><circle cx=19 cy=12 r=2>`);
|
|
794
|
+
const IconEllipsis = (props) => {
|
|
795
|
+
const size = () => props.size ?? 12;
|
|
796
|
+
return (() => {
|
|
797
|
+
var _el$ = _tmpl$$18();
|
|
798
|
+
createRenderEffect((_p$) => {
|
|
799
|
+
var _v$ = size(), _v$2 = size(), _v$3 = props.class;
|
|
800
|
+
_v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
|
|
801
|
+
_v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
|
|
802
|
+
_v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
|
|
803
|
+
return _p$;
|
|
804
|
+
}, {
|
|
805
|
+
e: void 0,
|
|
806
|
+
t: void 0,
|
|
807
|
+
a: void 0
|
|
808
|
+
});
|
|
809
|
+
return _el$;
|
|
810
|
+
})();
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
//#endregion
|
|
814
|
+
//#region src/components/icons/icon-check.tsx
|
|
815
|
+
var _tmpl$$17 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 21 21"fill=none><g clip-path=url(#clip0_icon_check)><path d="M20.1767 10.0875C20.1767 15.6478 15.6576 20.175 10.0875 20.175C4.52715 20.175 0 15.6478 0 10.0875C0 4.51914 4.52715 0 10.0875 0C15.6576 0 20.1767 4.51914 20.1767 10.0875ZM13.0051 6.23867L8.96699 12.7041L7.08476 10.3143C6.83358 9.99199 6.59941 9.88828 6.28984 9.88828C5.79414 9.88828 5.39961 10.2918 5.39961 10.7893C5.39961 11.0367 5.48925 11.2621 5.66386 11.4855L8.05703 14.3967C8.33027 14.7508 8.63183 14.9103 8.99902 14.9103C9.36445 14.9103 9.68105 14.7312 9.90546 14.3896L14.4742 7.27206C14.6107 7.04765 14.7289 6.80898 14.7289 6.58359C14.7289 6.07187 14.281 5.72968 13.7934 5.72968C13.4937 5.72968 13.217 5.90527 13.0051 6.23867Z"fill=currentColor></path></g><defs><clipPath id=clip0_icon_check><rect width=20.5381 height=20.1848 fill=white>`);
|
|
816
|
+
const IconCheck = (props) => {
|
|
817
|
+
const size = () => props.size ?? 21;
|
|
818
|
+
return (() => {
|
|
819
|
+
var _el$ = _tmpl$$17();
|
|
820
|
+
createRenderEffect((_p$) => {
|
|
821
|
+
var _v$ = size(), _v$2 = size() * 20.1848 / 20.5381, _v$3 = props.class;
|
|
822
|
+
_v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
|
|
823
|
+
_v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
|
|
824
|
+
_v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
|
|
825
|
+
return _p$;
|
|
826
|
+
}, {
|
|
827
|
+
e: void 0,
|
|
828
|
+
t: void 0,
|
|
829
|
+
a: void 0
|
|
830
|
+
});
|
|
831
|
+
return _el$;
|
|
832
|
+
})();
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
//#endregion
|
|
836
|
+
//#region src/components/selection-label/completion-view.tsx
|
|
837
|
+
var _tmpl$$16 = /* @__PURE__ */ template(`<button data-react-grab-ignore-events data-react-grab-more-options class="flex items-center justify-center size-[18px] rounded-sm cursor-pointer bg-transparent hover:bg-black/10 text-black/30 hover:text-black border-none outline-none p-0 shrink-0 press-scale">`), _tmpl$2$7 = /* @__PURE__ */ template(`<button data-react-grab-dismiss class="contain-layout shrink-0 flex items-center justify-center gap-1 px-[3px] py-px rounded-sm bg-white [border-width:0.5px] border-solid border-[#B3B3B3] cursor-pointer transition-all hover:bg-[#F5F5F5] press-scale h-[17px]"><span class="text-black text-[13px] leading-3.5 font-sans font-medium">Keep`), _tmpl$3$6 = /* @__PURE__ */ template(`<div class="contain-layout shrink-0 flex items-center justify-between gap-2 pt-1.5 pb-1 px-2 w-full h-fit"><span class="text-black text-[13px] leading-4 font-sans font-medium h-fit tabular-nums overflow-hidden text-ellipsis whitespace-nowrap min-w-0"></span><div class="contain-layout shrink-0 flex items-center gap-2 h-fit">`), _tmpl$4$4 = /* @__PURE__ */ template(`<div class="contain-layout shrink-0 flex items-center gap-0.5 py-1.5 px-2 w-full h-fit"><span class="text-black text-[13px] leading-4 font-sans font-medium h-fit tabular-nums overflow-hidden text-ellipsis whitespace-nowrap min-w-0">`), _tmpl$5$3 = /* @__PURE__ */ template(`<div data-react-grab-completion>`);
|
|
838
|
+
const MoreOptionsButton = (props) => {
|
|
839
|
+
return (() => {
|
|
840
|
+
var _el$ = _tmpl$$16();
|
|
841
|
+
addEventListener(_el$, "click", (event) => {
|
|
842
|
+
event.stopImmediatePropagation();
|
|
843
|
+
props.onClick();
|
|
844
|
+
});
|
|
845
|
+
addEventListener(_el$, "pointerdown", (event) => {
|
|
846
|
+
event.stopImmediatePropagation();
|
|
847
|
+
});
|
|
848
|
+
insert(_el$, createComponent(IconEllipsis, { size: 14 }));
|
|
849
|
+
return _el$;
|
|
850
|
+
})();
|
|
851
|
+
};
|
|
852
|
+
const CompletionView = (props) => {
|
|
853
|
+
const instanceId = Symbol();
|
|
854
|
+
let fadeTimeoutId;
|
|
855
|
+
let dismissTimeoutId;
|
|
856
|
+
const [didCopy, setDidCopy] = createSignal(false);
|
|
857
|
+
const [isFading, setIsFading] = createSignal(false);
|
|
858
|
+
const displayStatusText = () => didCopy() ? "Copied" : props.statusText;
|
|
859
|
+
const handleShowContextMenu = () => {
|
|
860
|
+
if (fadeTimeoutId !== void 0) window.clearTimeout(fadeTimeoutId);
|
|
861
|
+
if (dismissTimeoutId !== void 0) window.clearTimeout(dismissTimeoutId);
|
|
862
|
+
setIsFading(true);
|
|
863
|
+
props.onFadingChange?.(true);
|
|
864
|
+
props.onShowContextMenu?.();
|
|
865
|
+
};
|
|
866
|
+
const handleAccept = () => {
|
|
867
|
+
if (didCopy()) return;
|
|
868
|
+
setDidCopy(true);
|
|
869
|
+
fadeTimeoutId = window.setTimeout(() => {
|
|
870
|
+
setIsFading(true);
|
|
871
|
+
props.onFadingChange?.(true);
|
|
872
|
+
dismissTimeoutId = window.setTimeout(() => {
|
|
873
|
+
props.onDismiss?.();
|
|
874
|
+
}, 100);
|
|
875
|
+
}, FEEDBACK_DURATION_MS - 100);
|
|
876
|
+
};
|
|
877
|
+
const handleKeyDown = (event) => {
|
|
878
|
+
if (!confirmationFocusManager.isActive(instanceId)) return;
|
|
879
|
+
const isEnter = event.code === "Enter";
|
|
880
|
+
const isEscape = event.code === "Escape";
|
|
881
|
+
if (isKeyboardEventTriggeredByInput(event)) return;
|
|
882
|
+
if (isEnter) {
|
|
883
|
+
event.preventDefault();
|
|
884
|
+
event.stopPropagation();
|
|
885
|
+
handleAccept();
|
|
886
|
+
} else if (isEscape) {
|
|
887
|
+
event.preventDefault();
|
|
888
|
+
event.stopPropagation();
|
|
889
|
+
props.onDismiss?.();
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
const handleFocus = () => {
|
|
893
|
+
confirmationFocusManager.claim(instanceId);
|
|
894
|
+
};
|
|
895
|
+
onMount(() => {
|
|
896
|
+
confirmationFocusManager.claim(instanceId);
|
|
897
|
+
window.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
898
|
+
});
|
|
899
|
+
onCleanup(() => {
|
|
900
|
+
confirmationFocusManager.release(instanceId);
|
|
901
|
+
window.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
902
|
+
if (fadeTimeoutId !== void 0) window.clearTimeout(fadeTimeoutId);
|
|
903
|
+
if (dismissTimeoutId !== void 0) window.clearTimeout(dismissTimeoutId);
|
|
904
|
+
});
|
|
905
|
+
return (() => {
|
|
906
|
+
var _el$2 = _tmpl$5$3();
|
|
907
|
+
_el$2.$$click = handleFocus;
|
|
908
|
+
_el$2.$$pointerdown = handleFocus;
|
|
909
|
+
insert(_el$2, createComponent(Show, {
|
|
910
|
+
get when() {
|
|
911
|
+
return memo(() => !!!didCopy())() && props.onDismiss;
|
|
912
|
+
},
|
|
913
|
+
get children() {
|
|
914
|
+
var _el$3 = _tmpl$3$6(), _el$4 = _el$3.firstChild, _el$5 = _el$4.nextSibling;
|
|
915
|
+
insert(_el$4, displayStatusText);
|
|
916
|
+
insert(_el$5, createComponent(Show, {
|
|
917
|
+
get when() {
|
|
918
|
+
return props.onShowContextMenu;
|
|
919
|
+
},
|
|
920
|
+
get children() {
|
|
921
|
+
return createComponent(MoreOptionsButton, { onClick: handleShowContextMenu });
|
|
922
|
+
}
|
|
923
|
+
}), null);
|
|
924
|
+
insert(_el$5, createComponent(Show, {
|
|
925
|
+
get when() {
|
|
926
|
+
return props.onDismiss;
|
|
927
|
+
},
|
|
928
|
+
get children() {
|
|
929
|
+
var _el$6 = _tmpl$2$7();
|
|
930
|
+
_el$6.firstChild;
|
|
931
|
+
_el$6.$$click = handleAccept;
|
|
932
|
+
insert(_el$6, createComponent(Show, {
|
|
933
|
+
get when() {
|
|
934
|
+
return !didCopy();
|
|
935
|
+
},
|
|
936
|
+
get children() {
|
|
937
|
+
return createComponent(IconReturn, {
|
|
938
|
+
size: 10,
|
|
939
|
+
"class": "text-black/50"
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
}), null);
|
|
943
|
+
createRenderEffect(() => _el$6.disabled = didCopy());
|
|
944
|
+
return _el$6;
|
|
945
|
+
}
|
|
946
|
+
}), null);
|
|
947
|
+
return _el$3;
|
|
948
|
+
}
|
|
949
|
+
}), null);
|
|
950
|
+
insert(_el$2, createComponent(Show, {
|
|
951
|
+
get when() {
|
|
952
|
+
return didCopy() || !props.onDismiss;
|
|
953
|
+
},
|
|
954
|
+
get children() {
|
|
955
|
+
var _el$8 = _tmpl$4$4(), _el$9 = _el$8.firstChild;
|
|
956
|
+
insert(_el$8, createComponent(IconCheck, {
|
|
957
|
+
size: 14,
|
|
958
|
+
"class": "text-black/85 shrink-0 animate-success-pop"
|
|
959
|
+
}), _el$9);
|
|
960
|
+
insert(_el$9, displayStatusText);
|
|
961
|
+
insert(_el$8, createComponent(Show, {
|
|
962
|
+
get when() {
|
|
963
|
+
return props.onShowContextMenu;
|
|
964
|
+
},
|
|
965
|
+
get children() {
|
|
966
|
+
return createComponent(MoreOptionsButton, { onClick: handleShowContextMenu });
|
|
967
|
+
}
|
|
968
|
+
}), null);
|
|
969
|
+
return _el$8;
|
|
970
|
+
}
|
|
971
|
+
}), null);
|
|
972
|
+
createRenderEffect((_p$) => {
|
|
973
|
+
var _v$ = cn("contain-layout shrink-0 flex flex-col justify-center items-end rounded-[10px] antialiased w-fit h-fit max-w-[280px] transition-opacity duration-100 ease-out [font-synthesis:none] [corner-shape:superellipse(1.25)]", "bg-white"), _v$2 = isFading() ? 0 : 1;
|
|
974
|
+
_v$ !== _p$.e && className(_el$2, _p$.e = _v$);
|
|
975
|
+
_v$2 !== _p$.t && setStyleProperty(_el$2, "opacity", _p$.t = _v$2);
|
|
976
|
+
return _p$;
|
|
977
|
+
}, {
|
|
978
|
+
e: void 0,
|
|
979
|
+
t: void 0
|
|
980
|
+
});
|
|
981
|
+
return _el$2;
|
|
982
|
+
})();
|
|
983
|
+
};
|
|
984
|
+
delegateEvents(["pointerdown", "click"]);
|
|
985
|
+
|
|
986
|
+
//#endregion
|
|
987
|
+
//#region src/utils/create-menu-highlight.ts
|
|
988
|
+
const DEFAULT_HIDDEN_OPACITY = "0";
|
|
989
|
+
const DEFAULT_VISIBLE_OPACITY = "1";
|
|
990
|
+
const createAnimatedBoundsFollower = ({ hiddenOpacity = DEFAULT_HIDDEN_OPACITY, visibleOpacity = DEFAULT_VISIBLE_OPACITY } = {}) => {
|
|
991
|
+
let containerElement;
|
|
992
|
+
let followerElement;
|
|
993
|
+
const hideFollower = () => {
|
|
994
|
+
if (!followerElement) return;
|
|
995
|
+
followerElement.style.opacity = hiddenOpacity;
|
|
996
|
+
};
|
|
997
|
+
const followElement = (targetElement) => {
|
|
998
|
+
if (!followerElement || !containerElement) return;
|
|
999
|
+
if (!targetElement) {
|
|
1000
|
+
hideFollower();
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
const containerRect = containerElement.getBoundingClientRect();
|
|
1004
|
+
const targetRect = targetElement.getBoundingClientRect();
|
|
1005
|
+
const targetTopWithinContainer = targetRect.top - containerRect.top + containerElement.scrollTop;
|
|
1006
|
+
const targetLeftWithinContainer = targetRect.left - containerRect.left + containerElement.scrollLeft;
|
|
1007
|
+
followerElement.style.opacity = visibleOpacity;
|
|
1008
|
+
followerElement.style.top = `${targetTopWithinContainer}px`;
|
|
1009
|
+
followerElement.style.left = `${targetLeftWithinContainer}px`;
|
|
1010
|
+
followerElement.style.width = `${targetRect.width}px`;
|
|
1011
|
+
followerElement.style.height = `${targetRect.height}px`;
|
|
1012
|
+
};
|
|
1013
|
+
const setContainerRef = (containerNode) => {
|
|
1014
|
+
containerElement = containerNode;
|
|
1015
|
+
};
|
|
1016
|
+
const setFollowerRef = (followerNode) => {
|
|
1017
|
+
followerElement = followerNode;
|
|
1018
|
+
};
|
|
1019
|
+
return {
|
|
1020
|
+
containerRef: setContainerRef,
|
|
1021
|
+
followerRef: setFollowerRef,
|
|
1022
|
+
followElement,
|
|
1023
|
+
hideFollower
|
|
1024
|
+
};
|
|
1025
|
+
};
|
|
1026
|
+
const createMenuHighlight = () => {
|
|
1027
|
+
const { containerRef, followerRef: highlightRef, followElement: updateHighlight, hideFollower: clearHighlight } = createAnimatedBoundsFollower();
|
|
1028
|
+
return {
|
|
1029
|
+
containerRef,
|
|
1030
|
+
highlightRef,
|
|
1031
|
+
updateHighlight,
|
|
1032
|
+
clearHighlight
|
|
1033
|
+
};
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
//#endregion
|
|
1037
|
+
//#region src/components/selection-label/arrow-navigation-menu.tsx
|
|
1038
|
+
var _tmpl$$15 = /* @__PURE__ */ template(`<div class="relative flex flex-col w-[calc(100%+16px)] -mx-2 -my-1.5"><div class="pointer-events-none absolute bg-black/5 opacity-0 transition-[top,left,width,height,opacity] duration-75 ease-out">`), _tmpl$2$6 = /* @__PURE__ */ template(`<span class=text-black/40>.`), _tmpl$3$5 = /* @__PURE__ */ template(`<button data-react-grab-ignore-events class="relative z-1 contain-layout flex items-center w-full px-2 py-1 cursor-pointer text-left border-none bg-transparent"><span class="text-[13px] leading-4 h-fit font-medium overflow-hidden text-ellipsis whitespace-nowrap min-w-0 transition-colors">`);
|
|
1039
|
+
const ArrowNavigationMenu = (props) => {
|
|
1040
|
+
const { containerRef: highlightContainerRef, highlightRef, updateHighlight, clearHighlight } = createMenuHighlight();
|
|
1041
|
+
let menuItemsRef;
|
|
1042
|
+
let didPointerMove = false;
|
|
1043
|
+
const getMenuItemByIndex = (itemIndex) => {
|
|
1044
|
+
if (!menuItemsRef) return void 0;
|
|
1045
|
+
return menuItemsRef.querySelector(`[data-react-grab-arrow-nav-index="${itemIndex}"]`) ?? void 0;
|
|
1046
|
+
};
|
|
1047
|
+
createEffect(() => {
|
|
1048
|
+
props.items;
|
|
1049
|
+
didPointerMove = false;
|
|
1050
|
+
});
|
|
1051
|
+
createEffect(() => {
|
|
1052
|
+
const activeMenuItem = getMenuItemByIndex(props.activeIndex);
|
|
1053
|
+
if (activeMenuItem) updateHighlight(activeMenuItem);
|
|
1054
|
+
});
|
|
1055
|
+
return createComponent(BottomSection, { get children() {
|
|
1056
|
+
var _el$ = _tmpl$$15(), _el$2 = _el$.firstChild;
|
|
1057
|
+
_el$.$$pointermove = () => {
|
|
1058
|
+
didPointerMove = true;
|
|
1059
|
+
};
|
|
1060
|
+
use((element) => {
|
|
1061
|
+
menuItemsRef = element;
|
|
1062
|
+
highlightContainerRef(element);
|
|
1063
|
+
}, _el$);
|
|
1064
|
+
use(highlightRef, _el$2);
|
|
1065
|
+
insert(_el$, createComponent(For, {
|
|
1066
|
+
get each() {
|
|
1067
|
+
return props.items;
|
|
1068
|
+
},
|
|
1069
|
+
children: (item, itemIndex) => (() => {
|
|
1070
|
+
var _el$3 = _tmpl$3$5(), _el$4 = _el$3.firstChild;
|
|
1071
|
+
_el$3.$$click = (event) => {
|
|
1072
|
+
event.stopPropagation();
|
|
1073
|
+
props.onSelect(itemIndex());
|
|
1074
|
+
};
|
|
1075
|
+
_el$3.addEventListener("pointerleave", () => {
|
|
1076
|
+
const activeMenuItem = getMenuItemByIndex(props.activeIndex);
|
|
1077
|
+
if (activeMenuItem) updateHighlight(activeMenuItem);
|
|
1078
|
+
else clearHighlight();
|
|
1079
|
+
});
|
|
1080
|
+
_el$3.addEventListener("pointerenter", (event) => {
|
|
1081
|
+
updateHighlight(event.currentTarget);
|
|
1082
|
+
if (didPointerMove) props.onSelect(itemIndex());
|
|
1083
|
+
});
|
|
1084
|
+
_el$3.$$pointerdown = (event) => event.stopPropagation();
|
|
1085
|
+
insert(_el$4, createComponent(Show, {
|
|
1086
|
+
get when() {
|
|
1087
|
+
return item.componentName;
|
|
1088
|
+
},
|
|
1089
|
+
get children() {
|
|
1090
|
+
return [memo(() => item.componentName), _tmpl$2$6()];
|
|
1091
|
+
}
|
|
1092
|
+
}), null);
|
|
1093
|
+
insert(_el$4, () => item.tagName, null);
|
|
1094
|
+
createRenderEffect((_p$) => {
|
|
1095
|
+
var _v$ = item.tagName, _v$2 = itemIndex(), _v$3 = !!(itemIndex() === props.activeIndex), _v$4 = !!(itemIndex() !== props.activeIndex);
|
|
1096
|
+
_v$ !== _p$.e && setAttribute(_el$3, "data-react-grab-arrow-nav-item", _p$.e = _v$);
|
|
1097
|
+
_v$2 !== _p$.t && setAttribute(_el$3, "data-react-grab-arrow-nav-index", _p$.t = _v$2);
|
|
1098
|
+
_v$3 !== _p$.a && _el$4.classList.toggle("text-black", _p$.a = _v$3);
|
|
1099
|
+
_v$4 !== _p$.o && _el$4.classList.toggle("text-black/30", _p$.o = _v$4);
|
|
1100
|
+
return _p$;
|
|
1101
|
+
}, {
|
|
1102
|
+
e: void 0,
|
|
1103
|
+
t: void 0,
|
|
1104
|
+
a: void 0,
|
|
1105
|
+
o: void 0
|
|
1106
|
+
});
|
|
1107
|
+
return _el$3;
|
|
1108
|
+
})()
|
|
1109
|
+
}), null);
|
|
1110
|
+
return _el$;
|
|
1111
|
+
} });
|
|
1112
|
+
};
|
|
1113
|
+
delegateEvents([
|
|
1114
|
+
"pointermove",
|
|
1115
|
+
"pointerdown",
|
|
1116
|
+
"click"
|
|
1117
|
+
]);
|
|
1118
|
+
|
|
1119
|
+
//#endregion
|
|
1120
|
+
//#region src/components/selection-label/index.tsx
|
|
1121
|
+
var _tmpl$$14 = /* @__PURE__ */ template(`<div class="contain-layout shrink-0 flex flex-col justify-center items-start w-fit h-fit max-w-[280px]"><div class="contain-layout shrink-0 flex items-center gap-1 py-1.5 px-2 w-full h-fit"><span class="shimmer-text text-[13px] leading-4 font-sans font-medium h-fit tabular-nums overflow-hidden text-ellipsis whitespace-nowrap">`), _tmpl$2$5 = /* @__PURE__ */ template(`<div class="flex flex-col w-[calc(100%+16px)] -mx-2 -my-1.5">`), _tmpl$3$4 = /* @__PURE__ */ template(`<div class="contain-layout shrink-0 flex flex-col items-start w-fit h-fit"><div class="contain-layout shrink-0 flex items-center gap-1 w-fit h-fit px-2">`), _tmpl$4$3 = /* @__PURE__ */ template(`<button data-react-grab-submit class="contain-layout shrink-0 flex items-center justify-center size-4 rounded-full bg-black cursor-pointer ml-1 interactive-scale">`), _tmpl$5$2 = /* @__PURE__ */ template(`<div class="shrink-0 flex justify-between items-end w-full min-h-4"><textarea data-react-grab-ignore-events data-react-grab-input class="text-black text-[13px] leading-4 font-medium bg-transparent border-none outline-none resize-none flex-1 p-0 m-0 wrap-break-word overflow-y-auto"placeholder="Add context"rows=1 style=field-sizing:content;min-height:16px;scrollbar-width:none>`), _tmpl$6$1 = /* @__PURE__ */ template(`<div class="contain-layout shrink-0 flex flex-col justify-center items-start w-fit h-fit min-w-[150px] max-w-[280px]"><div class="contain-layout shrink-0 flex items-center gap-1 pt-1.5 pb-1 w-fit h-fit px-2 max-w-full">`), _tmpl$7$1 = /* @__PURE__ */ template(`<div data-react-grab-ignore-events data-react-grab-selection-label><div>`), _tmpl$8$1 = /* @__PURE__ */ template(`<span class="text-[11px] font-sans text-black/50 ml-4">`), _tmpl$9$1 = /* @__PURE__ */ template(`<div class="contain-layout flex items-center justify-between w-full px-2 py-1 transition-colors"><span class="text-[13px] leading-4 font-sans font-medium text-black">`);
|
|
1122
|
+
const DEFAULT_OFFSCREEN_POSITION = {
|
|
1123
|
+
left: SELECTION_LABEL_OFFSCREEN_PX,
|
|
1124
|
+
top: SELECTION_LABEL_OFFSCREEN_PX,
|
|
1125
|
+
arrowLeftPercent: 50,
|
|
1126
|
+
arrowLeftOffset: 0,
|
|
1127
|
+
edgeOffsetX: 0
|
|
1128
|
+
};
|
|
1129
|
+
const SelectionLabel = (props) => {
|
|
1130
|
+
let containerRef;
|
|
1131
|
+
let panelRef;
|
|
1132
|
+
let inputRef;
|
|
1133
|
+
let isTagCurrentlyHovered = false;
|
|
1134
|
+
const [measuredWidth, setMeasuredWidth] = createSignal(0);
|
|
1135
|
+
const [measuredHeight, setMeasuredHeight] = createSignal(0);
|
|
1136
|
+
const [panelWidth, setPanelWidth] = createSignal(0);
|
|
1137
|
+
const [viewportVersion, setViewportVersion] = createSignal(0);
|
|
1138
|
+
const [isInternalFading, setIsInternalFading] = createSignal(false);
|
|
1139
|
+
const [isShaking, setIsShaking] = createSignal(false);
|
|
1140
|
+
const canInteract = () => props.status !== "copying" && props.status !== "copied" && props.status !== "fading" && props.status !== "error";
|
|
1141
|
+
const isCompletedStatus = () => props.status === "copied" || props.status === "fading";
|
|
1142
|
+
const shouldEnablePointerEvents = () => {
|
|
1143
|
+
if (props.isPromptMode) return true;
|
|
1144
|
+
if (isCompletedStatus() && (props.onDismiss || props.onShowContextMenu)) return true;
|
|
1145
|
+
if (props.status === "error" && (props.onAcknowledgeError || props.onRetry)) return true;
|
|
1146
|
+
if (props.arrowNavigationState?.isVisible) return true;
|
|
1147
|
+
if (props.inspectNavigationState?.isVisible) return true;
|
|
1148
|
+
return false;
|
|
1149
|
+
};
|
|
1150
|
+
let resizeObserver;
|
|
1151
|
+
const handleTagHoverChange = (hovered) => {
|
|
1152
|
+
isTagCurrentlyHovered = hovered;
|
|
1153
|
+
};
|
|
1154
|
+
const handleViewportChange = () => {
|
|
1155
|
+
setViewportVersion((version) => version + 1);
|
|
1156
|
+
};
|
|
1157
|
+
const handleGlobalKeyDown = (event) => {
|
|
1158
|
+
if (isKeyboardEventTriggeredByInput(event)) return;
|
|
1159
|
+
if (event.code === "Enter" && !props.isPromptMode && canInteract()) {
|
|
1160
|
+
event.preventDefault();
|
|
1161
|
+
event.stopImmediatePropagation();
|
|
1162
|
+
props.onToggleExpand?.();
|
|
1163
|
+
}
|
|
1164
|
+
};
|
|
1165
|
+
onMount(() => {
|
|
1166
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
1167
|
+
for (const entry of entries) {
|
|
1168
|
+
const rect = entry.target.getBoundingClientRect();
|
|
1169
|
+
if (entry.target === containerRef && !isTagCurrentlyHovered) {
|
|
1170
|
+
setMeasuredWidth(rect.width);
|
|
1171
|
+
setMeasuredHeight(rect.height);
|
|
1172
|
+
} else if (entry.target === panelRef) setPanelWidth(rect.width);
|
|
1173
|
+
}
|
|
1174
|
+
});
|
|
1175
|
+
if (containerRef) {
|
|
1176
|
+
const rect = containerRef.getBoundingClientRect();
|
|
1177
|
+
setMeasuredWidth(rect.width);
|
|
1178
|
+
setMeasuredHeight(rect.height);
|
|
1179
|
+
resizeObserver.observe(containerRef);
|
|
1180
|
+
}
|
|
1181
|
+
if (panelRef) {
|
|
1182
|
+
setPanelWidth(panelRef.getBoundingClientRect().width);
|
|
1183
|
+
resizeObserver.observe(panelRef);
|
|
1184
|
+
}
|
|
1185
|
+
window.addEventListener("scroll", handleViewportChange, true);
|
|
1186
|
+
window.addEventListener("resize", handleViewportChange);
|
|
1187
|
+
window.visualViewport?.addEventListener("resize", handleViewportChange);
|
|
1188
|
+
window.visualViewport?.addEventListener("scroll", handleViewportChange);
|
|
1189
|
+
window.addEventListener("keydown", handleGlobalKeyDown, { capture: true });
|
|
1190
|
+
});
|
|
1191
|
+
onCleanup(() => {
|
|
1192
|
+
resizeObserver?.disconnect();
|
|
1193
|
+
window.removeEventListener("scroll", handleViewportChange, true);
|
|
1194
|
+
window.removeEventListener("resize", handleViewportChange);
|
|
1195
|
+
window.visualViewport?.removeEventListener("resize", handleViewportChange);
|
|
1196
|
+
window.visualViewport?.removeEventListener("scroll", handleViewportChange);
|
|
1197
|
+
window.removeEventListener("keydown", handleGlobalKeyDown, { capture: true });
|
|
1198
|
+
});
|
|
1199
|
+
const elementIdentity = () => `${props.tagName ?? ""}:${props.componentName ?? ""}`;
|
|
1200
|
+
const positionComputation = createMemo((previousResult) => {
|
|
1201
|
+
viewportVersion();
|
|
1202
|
+
const currentElementIdentity = elementIdentity();
|
|
1203
|
+
const cached = currentElementIdentity !== previousResult.elementIdentity ? {
|
|
1204
|
+
position: DEFAULT_OFFSCREEN_POSITION,
|
|
1205
|
+
computedArrowPosition: null,
|
|
1206
|
+
hadValidBounds: false,
|
|
1207
|
+
elementIdentity: currentElementIdentity
|
|
1208
|
+
} : previousResult;
|
|
1209
|
+
const bounds = props.selectionBounds;
|
|
1210
|
+
const labelWidth = measuredWidth();
|
|
1211
|
+
const labelHeight = measuredHeight();
|
|
1212
|
+
const hasMeasurements = labelWidth > 0 && labelHeight > 0;
|
|
1213
|
+
const hasValidBounds = bounds && bounds.width > 0 && bounds.height > 0;
|
|
1214
|
+
if (!hasMeasurements || !hasValidBounds) return {
|
|
1215
|
+
position: cached.hadValidBounds ? cached.position : DEFAULT_OFFSCREEN_POSITION,
|
|
1216
|
+
computedArrowPosition: cached.computedArrowPosition,
|
|
1217
|
+
hadValidBounds: cached.hadValidBounds,
|
|
1218
|
+
elementIdentity: currentElementIdentity
|
|
1219
|
+
};
|
|
1220
|
+
const visualViewport = window.visualViewport;
|
|
1221
|
+
const viewportLeft = visualViewport?.offsetLeft ?? 0;
|
|
1222
|
+
const viewportTop = visualViewport?.offsetTop ?? 0;
|
|
1223
|
+
const viewportRight = viewportLeft + (visualViewport?.width ?? window.innerWidth);
|
|
1224
|
+
const viewportBottom = viewportTop + (visualViewport?.height ?? window.innerHeight);
|
|
1225
|
+
if (!(bounds.x + bounds.width > viewportLeft && bounds.x < viewportRight && bounds.y + bounds.height > viewportTop && bounds.y < viewportBottom)) return {
|
|
1226
|
+
position: DEFAULT_OFFSCREEN_POSITION,
|
|
1227
|
+
computedArrowPosition: cached.computedArrowPosition,
|
|
1228
|
+
hadValidBounds: cached.hadValidBounds,
|
|
1229
|
+
elementIdentity: currentElementIdentity
|
|
1230
|
+
};
|
|
1231
|
+
const selectionCenterX = bounds.x + bounds.width / 2;
|
|
1232
|
+
const cursorX = props.mouseX ?? selectionCenterX;
|
|
1233
|
+
const selectionBottom = bounds.y + bounds.height;
|
|
1234
|
+
const selectionTop = bounds.y;
|
|
1235
|
+
const actualArrowHeight = props.hideArrow ? 0 : getArrowSize(panelWidth());
|
|
1236
|
+
const anchorX = cursorX;
|
|
1237
|
+
let edgeOffsetX = 0;
|
|
1238
|
+
let positionTop = selectionBottom + actualArrowHeight + 4;
|
|
1239
|
+
if (labelWidth > 0) {
|
|
1240
|
+
const labelLeft = anchorX - labelWidth / 2;
|
|
1241
|
+
const labelRight = anchorX + labelWidth / 2;
|
|
1242
|
+
if (labelRight > viewportRight - 8) edgeOffsetX = viewportRight - 8 - labelRight;
|
|
1243
|
+
if (labelLeft + edgeOffsetX < viewportLeft + 8) edgeOffsetX = viewportLeft + 8 - labelLeft;
|
|
1244
|
+
}
|
|
1245
|
+
const totalHeightNeeded = labelHeight + actualArrowHeight + 4;
|
|
1246
|
+
const fitsBelow = positionTop + labelHeight <= viewportBottom - 8;
|
|
1247
|
+
if (!fitsBelow) positionTop = selectionTop - totalHeightNeeded;
|
|
1248
|
+
if (positionTop < viewportTop + 8) positionTop = viewportTop + 8;
|
|
1249
|
+
const labelHalfWidth = labelWidth / 2;
|
|
1250
|
+
const arrowCenterPx = labelHalfWidth - edgeOffsetX;
|
|
1251
|
+
const arrowMinPx = Math.min(16, labelHalfWidth);
|
|
1252
|
+
const arrowMaxPx = Math.max(labelWidth - 16, labelHalfWidth);
|
|
1253
|
+
const arrowLeftOffset = Math.max(arrowMinPx, Math.min(arrowMaxPx, arrowCenterPx)) - labelHalfWidth;
|
|
1254
|
+
return {
|
|
1255
|
+
position: {
|
|
1256
|
+
left: anchorX,
|
|
1257
|
+
top: positionTop,
|
|
1258
|
+
arrowLeftPercent: 50,
|
|
1259
|
+
arrowLeftOffset,
|
|
1260
|
+
edgeOffsetX
|
|
1261
|
+
},
|
|
1262
|
+
computedArrowPosition: fitsBelow ? "bottom" : "top",
|
|
1263
|
+
hadValidBounds: true,
|
|
1264
|
+
elementIdentity: currentElementIdentity
|
|
1265
|
+
};
|
|
1266
|
+
}, {
|
|
1267
|
+
position: DEFAULT_OFFSCREEN_POSITION,
|
|
1268
|
+
computedArrowPosition: null,
|
|
1269
|
+
hadValidBounds: false,
|
|
1270
|
+
elementIdentity: ""
|
|
1271
|
+
});
|
|
1272
|
+
const arrowPosition = () => positionComputation().computedArrowPosition ?? "bottom";
|
|
1273
|
+
const hadValidBounds = () => positionComputation().hadValidBounds;
|
|
1274
|
+
createEffect(on(() => props.selectionLabelShakeCount, () => setIsShaking(true), { defer: true }));
|
|
1275
|
+
const handleKeyDown = (event) => {
|
|
1276
|
+
if (event.isComposing || event.keyCode === 229) return;
|
|
1277
|
+
event.stopImmediatePropagation();
|
|
1278
|
+
const isEnterWithoutShift = event.code === "Enter" && !event.shiftKey;
|
|
1279
|
+
const isEscape = event.code === "Escape";
|
|
1280
|
+
if (isEnterWithoutShift) {
|
|
1281
|
+
event.preventDefault();
|
|
1282
|
+
props.onSubmit?.();
|
|
1283
|
+
} else if (isEscape) {
|
|
1284
|
+
event.preventDefault();
|
|
1285
|
+
props.onConfirmDismiss?.();
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
const handleInput = (event) => {
|
|
1289
|
+
const inputTarget = event.target;
|
|
1290
|
+
if (!(inputTarget instanceof HTMLTextAreaElement)) return;
|
|
1291
|
+
autoResizeTextarea(inputTarget, 95);
|
|
1292
|
+
props.onInputChange?.(inputTarget.value);
|
|
1293
|
+
};
|
|
1294
|
+
const tagDisplayResult = () => getTagDisplay({
|
|
1295
|
+
tagName: props.tagName,
|
|
1296
|
+
componentName: props.componentName,
|
|
1297
|
+
elementsCount: props.elementsCount
|
|
1298
|
+
});
|
|
1299
|
+
const isArrowNavigationVisible = () => Boolean(props.arrowNavigationState?.isVisible);
|
|
1300
|
+
const isInspectNavigationVisible = () => Boolean(props.inspectNavigationState?.isVisible);
|
|
1301
|
+
const handleTagClick = (event) => {
|
|
1302
|
+
event.stopImmediatePropagation();
|
|
1303
|
+
if (props.filePath && props.onOpen) props.onOpen();
|
|
1304
|
+
};
|
|
1305
|
+
const handleContainerPointerDown = (event) => {
|
|
1306
|
+
event.stopImmediatePropagation();
|
|
1307
|
+
if (canInteract() && props.isPromptMode && !props.isPendingDismiss && props.onSubmit && inputRef) inputRef.focus({ preventScroll: true });
|
|
1308
|
+
};
|
|
1309
|
+
const shouldPersistDuringFade = () => hadValidBounds() && (isCompletedStatus() || props.status === "error");
|
|
1310
|
+
return createComponent(Show, {
|
|
1311
|
+
get when() {
|
|
1312
|
+
return memo(() => props.visible !== false)() && (props.selectionBounds || shouldPersistDuringFade());
|
|
1313
|
+
},
|
|
1314
|
+
get children() {
|
|
1315
|
+
var _el$ = _tmpl$7$1(), _el$2 = _el$.firstChild;
|
|
1316
|
+
_el$.addEventListener("mouseleave", () => props.onHoverChange?.(false));
|
|
1317
|
+
_el$.addEventListener("mouseenter", () => props.onHoverChange?.(true));
|
|
1318
|
+
_el$.$$click = (event) => {
|
|
1319
|
+
event.stopImmediatePropagation();
|
|
1320
|
+
};
|
|
1321
|
+
_el$.$$pointerdown = handleContainerPointerDown;
|
|
1322
|
+
var _ref$ = containerRef;
|
|
1323
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : containerRef = _el$;
|
|
1324
|
+
setStyleProperty(_el$, "z-index", `${Z_INDEX_OVERLAY}`);
|
|
1325
|
+
insert(_el$, createComponent(Show, {
|
|
1326
|
+
get when() {
|
|
1327
|
+
return !props.hideArrow;
|
|
1328
|
+
},
|
|
1329
|
+
get children() {
|
|
1330
|
+
return createComponent(Arrow, {
|
|
1331
|
+
get position() {
|
|
1332
|
+
return arrowPosition();
|
|
1333
|
+
},
|
|
1334
|
+
get leftPercent() {
|
|
1335
|
+
return positionComputation().position.arrowLeftPercent;
|
|
1336
|
+
},
|
|
1337
|
+
get leftOffsetPx() {
|
|
1338
|
+
return positionComputation().position.arrowLeftOffset;
|
|
1339
|
+
},
|
|
1340
|
+
get labelWidth() {
|
|
1341
|
+
return panelWidth();
|
|
1342
|
+
}
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
}), _el$2);
|
|
1346
|
+
insert(_el$, createComponent(Show, {
|
|
1347
|
+
get when() {
|
|
1348
|
+
return memo(() => !!isCompletedStatus())() && !props.error;
|
|
1349
|
+
},
|
|
1350
|
+
get children() {
|
|
1351
|
+
return createComponent(CompletionView, {
|
|
1352
|
+
get statusText() {
|
|
1353
|
+
return props.statusText ?? "Copied";
|
|
1354
|
+
},
|
|
1355
|
+
get onDismiss() {
|
|
1356
|
+
return props.onDismiss;
|
|
1357
|
+
},
|
|
1358
|
+
onFadingChange: setIsInternalFading,
|
|
1359
|
+
get onShowContextMenu() {
|
|
1360
|
+
return props.onShowContextMenu;
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
}), _el$2);
|
|
1365
|
+
_el$2.addEventListener("animationend", () => setIsShaking(false));
|
|
1366
|
+
var _ref$2 = panelRef;
|
|
1367
|
+
typeof _ref$2 === "function" ? use(_ref$2, _el$2) : panelRef = _el$2;
|
|
1368
|
+
insert(_el$2, createComponent(Show, {
|
|
1369
|
+
get when() {
|
|
1370
|
+
return props.status === "copying";
|
|
1371
|
+
},
|
|
1372
|
+
get children() {
|
|
1373
|
+
var _el$3 = _tmpl$$14(), _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild;
|
|
1374
|
+
insert(_el$4, createComponent(IconLoader, {
|
|
1375
|
+
size: 13,
|
|
1376
|
+
"class": "text-[#71717a] shrink-0"
|
|
1377
|
+
}), _el$5);
|
|
1378
|
+
insert(_el$5, () => props.statusText ?? "Grabbing…");
|
|
1379
|
+
return _el$3;
|
|
1380
|
+
}
|
|
1381
|
+
}), null);
|
|
1382
|
+
insert(_el$2, createComponent(Show, {
|
|
1383
|
+
get when() {
|
|
1384
|
+
return memo(() => !!canInteract())() && !props.isPromptMode;
|
|
1385
|
+
},
|
|
1386
|
+
get children() {
|
|
1387
|
+
var _el$6 = _tmpl$3$4(), _el$7 = _el$6.firstChild;
|
|
1388
|
+
insert(_el$7, createComponent(TagBadge, {
|
|
1389
|
+
get tagName() {
|
|
1390
|
+
return tagDisplayResult().tagName;
|
|
1391
|
+
},
|
|
1392
|
+
get componentName() {
|
|
1393
|
+
return tagDisplayResult().componentName;
|
|
1394
|
+
},
|
|
1395
|
+
get isClickable() {
|
|
1396
|
+
return Boolean(props.filePath && props.onOpen);
|
|
1397
|
+
},
|
|
1398
|
+
onClick: handleTagClick,
|
|
1399
|
+
onHoverChange: handleTagHoverChange,
|
|
1400
|
+
shrink: true,
|
|
1401
|
+
get forceShowIcon() {
|
|
1402
|
+
return memo(() => !!(isArrowNavigationVisible() || isInspectNavigationVisible()))() ? Boolean(props.filePath && props.onOpen) : Boolean(props.isContextMenuOpen);
|
|
1403
|
+
}
|
|
1404
|
+
}));
|
|
1405
|
+
insert(_el$6, createComponent(Show, {
|
|
1406
|
+
get when() {
|
|
1407
|
+
return props.arrowNavigationState?.isVisible;
|
|
1408
|
+
},
|
|
1409
|
+
get children() {
|
|
1410
|
+
return createComponent(ArrowNavigationMenu, {
|
|
1411
|
+
get items() {
|
|
1412
|
+
return props.arrowNavigationState.items;
|
|
1413
|
+
},
|
|
1414
|
+
get activeIndex() {
|
|
1415
|
+
return props.arrowNavigationState.activeIndex;
|
|
1416
|
+
},
|
|
1417
|
+
onSelect: (index) => props.onArrowNavigationSelect?.(index)
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
}), null);
|
|
1421
|
+
insert(_el$6, createComponent(Show, {
|
|
1422
|
+
get when() {
|
|
1423
|
+
return memo(() => !!(!isArrowNavigationVisible() && isInspectNavigationVisible()))() && props.inspectNavigationState;
|
|
1424
|
+
},
|
|
1425
|
+
children: (state) => createComponent(ArrowNavigationMenu, {
|
|
1426
|
+
get items() {
|
|
1427
|
+
return state().items;
|
|
1428
|
+
},
|
|
1429
|
+
get activeIndex() {
|
|
1430
|
+
return state().activeIndex;
|
|
1431
|
+
},
|
|
1432
|
+
onSelect: (index) => props.onInspectSelect?.(index)
|
|
1433
|
+
})
|
|
1434
|
+
}), null);
|
|
1435
|
+
insert(_el$6, createComponent(Show, {
|
|
1436
|
+
get when() {
|
|
1437
|
+
return memo(() => !!(!isArrowNavigationVisible() && !isInspectNavigationVisible()))() && Boolean(props.actionCycleState?.isVisible);
|
|
1438
|
+
},
|
|
1439
|
+
get children() {
|
|
1440
|
+
return createComponent(BottomSection, { get children() {
|
|
1441
|
+
var _el$8 = _tmpl$2$5();
|
|
1442
|
+
insert(_el$8, createComponent(For, {
|
|
1443
|
+
get each() {
|
|
1444
|
+
return props.actionCycleState?.items ?? [];
|
|
1445
|
+
},
|
|
1446
|
+
children: (item, itemIndex) => (() => {
|
|
1447
|
+
var _el$12 = _tmpl$9$1(), _el$13 = _el$12.firstChild;
|
|
1448
|
+
insert(_el$13, () => item.label);
|
|
1449
|
+
insert(_el$12, createComponent(Show, {
|
|
1450
|
+
get when() {
|
|
1451
|
+
return item.shortcut;
|
|
1452
|
+
},
|
|
1453
|
+
get children() {
|
|
1454
|
+
var _el$14 = _tmpl$8$1();
|
|
1455
|
+
insert(_el$14, () => formatShortcut(item.shortcut));
|
|
1456
|
+
return _el$14;
|
|
1457
|
+
}
|
|
1458
|
+
}), null);
|
|
1459
|
+
createRenderEffect((_p$) => {
|
|
1460
|
+
var _v$1 = item.label.toLowerCase(), _v$10 = !!(itemIndex() === (props.actionCycleState?.activeIndex ?? 0)), _v$11 = !!(itemIndex() === (props.actionCycleState?.items ?? []).length - 1);
|
|
1461
|
+
_v$1 !== _p$.e && setAttribute(_el$12, "data-react-grab-action-cycle-item", _p$.e = _v$1);
|
|
1462
|
+
_v$10 !== _p$.t && _el$12.classList.toggle("bg-black/5", _p$.t = _v$10);
|
|
1463
|
+
_v$11 !== _p$.a && _el$12.classList.toggle("rounded-b-[6px]", _p$.a = _v$11);
|
|
1464
|
+
return _p$;
|
|
1465
|
+
}, {
|
|
1466
|
+
e: void 0,
|
|
1467
|
+
t: void 0,
|
|
1468
|
+
a: void 0
|
|
1469
|
+
});
|
|
1470
|
+
return _el$12;
|
|
1471
|
+
})()
|
|
1472
|
+
}));
|
|
1473
|
+
return _el$8;
|
|
1474
|
+
} });
|
|
1475
|
+
}
|
|
1476
|
+
}), null);
|
|
1477
|
+
createRenderEffect((_p$) => {
|
|
1478
|
+
var _v$ = !!(isArrowNavigationVisible() || isInspectNavigationVisible()), _v$2 = {
|
|
1479
|
+
"py-1.5": !isArrowNavigationVisible() && !isInspectNavigationVisible(),
|
|
1480
|
+
"pt-1.5 pb-1": isArrowNavigationVisible() || isInspectNavigationVisible()
|
|
1481
|
+
};
|
|
1482
|
+
_v$ !== _p$.e && _el$6.classList.toggle("min-w-[100px]", _p$.e = _v$);
|
|
1483
|
+
_p$.t = classList(_el$7, _v$2, _p$.t);
|
|
1484
|
+
return _p$;
|
|
1485
|
+
}, {
|
|
1486
|
+
e: void 0,
|
|
1487
|
+
t: void 0
|
|
1488
|
+
});
|
|
1489
|
+
return _el$6;
|
|
1490
|
+
}
|
|
1491
|
+
}), null);
|
|
1492
|
+
insert(_el$2, createComponent(Show, {
|
|
1493
|
+
get when() {
|
|
1494
|
+
return memo(() => !!(canInteract() && props.isPromptMode))() && !props.isPendingDismiss;
|
|
1495
|
+
},
|
|
1496
|
+
get children() {
|
|
1497
|
+
var _el$9 = _tmpl$6$1(), _el$0 = _el$9.firstChild;
|
|
1498
|
+
insert(_el$0, createComponent(TagBadge, {
|
|
1499
|
+
get tagName() {
|
|
1500
|
+
return tagDisplayResult().tagName;
|
|
1501
|
+
},
|
|
1502
|
+
get componentName() {
|
|
1503
|
+
return tagDisplayResult().componentName;
|
|
1504
|
+
},
|
|
1505
|
+
get isClickable() {
|
|
1506
|
+
return Boolean(props.filePath && props.onOpen);
|
|
1507
|
+
},
|
|
1508
|
+
onClick: handleTagClick,
|
|
1509
|
+
onHoverChange: handleTagHoverChange,
|
|
1510
|
+
forceShowIcon: true
|
|
1511
|
+
}));
|
|
1512
|
+
insert(_el$9, createComponent(BottomSection, { get children() {
|
|
1513
|
+
var _el$1 = _tmpl$5$2(), _el$10 = _el$1.firstChild;
|
|
1514
|
+
_el$10.$$keydown = handleKeyDown;
|
|
1515
|
+
_el$10.$$input = handleInput;
|
|
1516
|
+
use((element) => {
|
|
1517
|
+
inputRef = element;
|
|
1518
|
+
if (props.onSubmit) queueMicrotask(() => {
|
|
1519
|
+
element.focus({ preventScroll: true });
|
|
1520
|
+
autoResizeTextarea(element, 95);
|
|
1521
|
+
});
|
|
1522
|
+
}, _el$10);
|
|
1523
|
+
setStyleProperty(_el$10, "max-height", `${95}px`);
|
|
1524
|
+
insert(_el$1, createComponent(Show, {
|
|
1525
|
+
get when() {
|
|
1526
|
+
return props.onSubmit;
|
|
1527
|
+
},
|
|
1528
|
+
get children() {
|
|
1529
|
+
var _el$11 = _tmpl$4$3();
|
|
1530
|
+
_el$11.$$click = () => props.onSubmit?.();
|
|
1531
|
+
insert(_el$11, createComponent(IconSubmit, {
|
|
1532
|
+
size: 10,
|
|
1533
|
+
"class": "text-white"
|
|
1534
|
+
}));
|
|
1535
|
+
return _el$11;
|
|
1536
|
+
}
|
|
1537
|
+
}), null);
|
|
1538
|
+
createRenderEffect(() => _el$10.readOnly = !props.onSubmit);
|
|
1539
|
+
createRenderEffect(() => _el$10.value = props.inputValue ?? "");
|
|
1540
|
+
return _el$1;
|
|
1541
|
+
} }), null);
|
|
1542
|
+
return _el$9;
|
|
1543
|
+
}
|
|
1544
|
+
}), null);
|
|
1545
|
+
insert(_el$2, createComponent(Show, {
|
|
1546
|
+
get when() {
|
|
1547
|
+
return props.isPendingDismiss;
|
|
1548
|
+
},
|
|
1549
|
+
get children() {
|
|
1550
|
+
return createComponent(DiscardPrompt, {
|
|
1551
|
+
get onConfirm() {
|
|
1552
|
+
return props.onConfirmDismiss;
|
|
1553
|
+
},
|
|
1554
|
+
onCancel: () => {
|
|
1555
|
+
props.onCancelDismiss?.();
|
|
1556
|
+
inputRef?.focus({ preventScroll: true });
|
|
1557
|
+
}
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
}), null);
|
|
1561
|
+
insert(_el$2, createComponent(Show, {
|
|
1562
|
+
get when() {
|
|
1563
|
+
return props.error;
|
|
1564
|
+
},
|
|
1565
|
+
get children() {
|
|
1566
|
+
return createComponent(ErrorView, {
|
|
1567
|
+
get error() {
|
|
1568
|
+
return props.error;
|
|
1569
|
+
},
|
|
1570
|
+
get onAcknowledge() {
|
|
1571
|
+
return props.onAcknowledgeError;
|
|
1572
|
+
},
|
|
1573
|
+
get onRetry() {
|
|
1574
|
+
return props.onRetry;
|
|
1575
|
+
}
|
|
1576
|
+
});
|
|
1577
|
+
}
|
|
1578
|
+
}), null);
|
|
1579
|
+
createRenderEffect((_p$) => {
|
|
1580
|
+
var _v$3 = cn("fixed font-sans text-[13px] antialiased filter-[drop-shadow(0px_1px_2px_#51515140)] select-none transition-opacity duration-100 ease-out"), _v$4 = `${positionComputation().position.top}px`, _v$5 = `${positionComputation().position.left}px`, _v$6 = `translateX(calc(-50% + ${positionComputation().position.edgeOffsetX}px))`, _v$7 = shouldEnablePointerEvents() ? "auto" : "none", _v$8 = props.status === "fading" || isInternalFading() ? 0 : 1, _v$9 = cn("contain-layout flex items-center gap-[5px] rounded-[10px] antialiased w-fit h-fit p-0 [font-synthesis:none] [corner-shape:superellipse(1.25)]", "bg-white", isShaking() && "animate-shake"), _v$0 = isCompletedStatus() && !props.error ? "none" : void 0;
|
|
1581
|
+
_v$3 !== _p$.e && className(_el$, _p$.e = _v$3);
|
|
1582
|
+
_v$4 !== _p$.t && setStyleProperty(_el$, "top", _p$.t = _v$4);
|
|
1583
|
+
_v$5 !== _p$.a && setStyleProperty(_el$, "left", _p$.a = _v$5);
|
|
1584
|
+
_v$6 !== _p$.o && setStyleProperty(_el$, "transform", _p$.o = _v$6);
|
|
1585
|
+
_v$7 !== _p$.i && setStyleProperty(_el$, "pointer-events", _p$.i = _v$7);
|
|
1586
|
+
_v$8 !== _p$.n && setStyleProperty(_el$, "opacity", _p$.n = _v$8);
|
|
1587
|
+
_v$9 !== _p$.s && className(_el$2, _p$.s = _v$9);
|
|
1588
|
+
_v$0 !== _p$.h && setStyleProperty(_el$2, "display", _p$.h = _v$0);
|
|
1589
|
+
return _p$;
|
|
1590
|
+
}, {
|
|
1591
|
+
e: void 0,
|
|
1592
|
+
t: void 0,
|
|
1593
|
+
a: void 0,
|
|
1594
|
+
o: void 0,
|
|
1595
|
+
i: void 0,
|
|
1596
|
+
n: void 0,
|
|
1597
|
+
s: void 0,
|
|
1598
|
+
h: void 0
|
|
1599
|
+
});
|
|
1600
|
+
return _el$;
|
|
1601
|
+
}
|
|
1602
|
+
});
|
|
1603
|
+
};
|
|
1604
|
+
delegateEvents([
|
|
1605
|
+
"pointerdown",
|
|
1606
|
+
"click",
|
|
1607
|
+
"input",
|
|
1608
|
+
"keydown"
|
|
1609
|
+
]);
|
|
1610
|
+
|
|
1611
|
+
//#endregion
|
|
1612
|
+
//#region src/components/icons/icon-select.tsx
|
|
1613
|
+
var _tmpl$$13 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 18 18"fill=currentColor><path opacity=0.4 d="M7.65631 10.9565C7.31061 10.0014 7.54012 8.96635 8.25592 8.25195C8.74522 7.76615 9.38771 7.49951 10.0694 7.49951C10.3682 7.49951 10.6641 7.55171 10.9483 7.65381L16.0001 9.49902V4.75C16.0001 3.2334 14.7667 2 13.2501 2H4.75012C3.23352 2 2.00012 3.2334 2.00012 4.75V13.25C2.00012 14.7666 3.23352 16 4.75012 16H9.49962L7.65631 10.9565Z"></path><path d="M17.296 11.5694L10.4415 9.06545C10.0431 8.92235 9.61441 9.01658 9.31551 9.31338C9.01671 9.61168 8.92101 10.0429 9.06551 10.4413L11.5704 17.2948C11.7247 17.7191 12.128 18.0004 12.5772 18.0004C12.585 18.0004 12.5918 17.9999 12.5987 17.9999C13.0577 17.9906 13.4591 17.6913 13.5987 17.2543L14.4854 14.4857L17.2559 13.5985C17.6914 13.4589 17.9903 13.057 18 12.599C18.0097 12.141 17.7267 11.7276 17.296 11.5694Z">`);
|
|
1614
|
+
const IconSelect = (props) => {
|
|
1615
|
+
const size = () => props.size ?? 14;
|
|
1616
|
+
return (() => {
|
|
1617
|
+
var _el$ = _tmpl$$13();
|
|
1618
|
+
createRenderEffect((_p$) => {
|
|
1619
|
+
var _v$ = size(), _v$2 = size(), _v$3 = props.class;
|
|
1620
|
+
_v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
|
|
1621
|
+
_v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
|
|
1622
|
+
_v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
|
|
1623
|
+
return _p$;
|
|
1624
|
+
}, {
|
|
1625
|
+
e: void 0,
|
|
1626
|
+
t: void 0,
|
|
1627
|
+
a: void 0
|
|
1628
|
+
});
|
|
1629
|
+
return _el$;
|
|
1630
|
+
})();
|
|
1631
|
+
};
|
|
1632
|
+
|
|
1633
|
+
//#endregion
|
|
1634
|
+
//#region src/components/icons/icon-comment.tsx
|
|
1635
|
+
var _tmpl$$12 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=currentColor><path d="M9.85 1.75H14.15C18.2041 1.75 20.2311 1.75 21.4906 3.01407C22.75 4.27813 22.75 6.31261 22.75 10.3816V10.9211C22.75 14.99 22.75 17.0245 21.4906 18.2886C20.2311 19.5526 18.2041 19.5526 14.15 19.5526C13.5475 19.5661 13.0676 19.6121 12.5962 19.7199C11.5124 19.9703 10.4961 20.4783 9.49881 20.9768L9.4985 20.977C9.31046 21.071 9.12311 21.1646 8.93611 21.2562C7.25633 22.0782 6.41645 22.4893 5.88937 22.1045C5.38644 21.7285 5.36431 21.0194 5.5044 20.2351C5.56226 19.9112 5.5912 19.7492 5.52074 19.6474C5.45029 19.5457 5.28808 19.5158 4.96365 19.4558C3.90736 19.2607 3.09038 18.8716 2.50944 18.2886C1.25 17.0245 1.25 14.99 1.25 10.9211V10.3816C1.25 6.31261 1.25 4.27813 2.50944 3.01407C3.76888 1.75 5.79592 1.75 9.85 1.75Z">`);
|
|
1636
|
+
const IconComment = (props) => {
|
|
1637
|
+
const size = () => props.size ?? 14;
|
|
1638
|
+
return (() => {
|
|
1639
|
+
var _el$ = _tmpl$$12();
|
|
1640
|
+
createRenderEffect((_p$) => {
|
|
1641
|
+
var _v$ = size(), _v$2 = size(), _v$3 = props.class;
|
|
1642
|
+
_v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
|
|
1643
|
+
_v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
|
|
1644
|
+
_v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
|
|
1645
|
+
return _p$;
|
|
1646
|
+
}, {
|
|
1647
|
+
e: void 0,
|
|
1648
|
+
t: void 0,
|
|
1649
|
+
a: void 0
|
|
1650
|
+
});
|
|
1651
|
+
return _el$;
|
|
1652
|
+
})();
|
|
1653
|
+
};
|
|
1654
|
+
|
|
1655
|
+
//#endregion
|
|
1656
|
+
//#region src/components/icons/icon-copy.tsx
|
|
1657
|
+
var _tmpl$$11 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=currentColor><path d="M16.0549 8.25C17.4225 8.24998 18.5248 8.24996 19.3918 8.36652C20.2919 8.48754 21.0497 8.74643 21.6517 9.34835C22.2536 9.95027 22.5125 10.7081 22.6335 11.6083C22.75 12.4752 22.75 13.5775 22.75 14.9451V14.9451V16.0549V16.0549C22.75 17.4225 22.75 18.5248 22.6335 19.3918C22.5125 20.2919 22.2536 21.0497 21.6517 21.6517C21.0497 22.2536 20.2919 22.5125 19.3918 22.6335C18.5248 22.75 17.4225 22.75 16.0549 22.75H16.0549H14.9451H14.9451C13.5775 22.75 12.4752 22.75 11.6082 22.6335C10.7081 22.5125 9.95027 22.2536 9.34835 21.6516C8.74643 21.0497 8.48754 20.2919 8.36652 19.3918C8.24996 18.5248 8.24998 17.4225 8.25 16.0549V16.0549V14.9451V14.9451C8.24998 13.5775 8.24996 12.4752 8.36652 11.6082C8.48754 10.7081 8.74643 9.95027 9.34835 9.34835C9.95027 8.74643 10.7081 8.48754 11.6083 8.36652C12.4752 8.24996 13.5775 8.24998 14.9451 8.25H14.9451H16.0549H16.0549Z"></path><path d="M6.75 14.8569C6.74991 13.5627 6.74983 12.3758 6.8799 11.4084C7.0232 10.3425 7.36034 9.21504 8.28769 8.28769C9.21504 7.36034 10.3425 7.0232 11.4084 6.8799C12.3758 6.74983 13.5627 6.74991 14.8569 6.75L17.0931 6.75C17.3891 6.75 17.5371 6.75 17.6261 6.65419C17.7151 6.55838 17.7045 6.4142 17.6833 6.12584C17.6648 5.87546 17.6412 5.63892 17.6111 5.41544C17.4818 4.45589 17.2232 3.6585 16.6718 2.98663C16.4744 2.74612 16.2539 2.52558 16.0134 2.3282C15.3044 1.74638 14.4557 1.49055 13.4248 1.36868C12.4205 1.24998 11.1512 1.24999 9.54893 1.25H9.45109C7.84883 1.24999 6.57947 1.24998 5.57525 1.36868C4.54428 1.49054 3.69558 1.74638 2.98663 2.3282C2.74612 2.52558 2.52558 2.74612 2.3282 2.98663C1.74638 3.69558 1.49055 4.54428 1.36868 5.57525C1.24998 6.57947 1.24999 7.84882 1.25 9.45108V9.54891C1.24999 11.1512 1.24998 12.4205 1.36868 13.4247C1.49054 14.4557 1.74638 15.3044 2.3282 16.0134C2.52558 16.2539 2.74612 16.4744 2.98663 16.6718C3.6585 17.2232 4.45589 17.4818 5.41544 17.6111C5.63892 17.6412 5.87546 17.6648 6.12584 17.6833C6.4142 17.7045 6.55838 17.7151 6.65419 17.6261C6.75 17.5371 6.75 17.3891 6.75 17.0931V14.8569Z">`);
|
|
1658
|
+
const IconCopy = (props) => {
|
|
1659
|
+
const size = () => props.size ?? 14;
|
|
1660
|
+
return (() => {
|
|
1661
|
+
var _el$ = _tmpl$$11();
|
|
1662
|
+
createRenderEffect((_p$) => {
|
|
1663
|
+
var _v$ = size(), _v$2 = size(), _v$3 = props.class;
|
|
1664
|
+
_v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
|
|
1665
|
+
_v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
|
|
1666
|
+
_v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
|
|
1667
|
+
return _p$;
|
|
1668
|
+
}, {
|
|
1669
|
+
e: void 0,
|
|
1670
|
+
t: void 0,
|
|
1671
|
+
a: void 0
|
|
1672
|
+
});
|
|
1673
|
+
return _el$;
|
|
1674
|
+
})();
|
|
1675
|
+
};
|
|
1676
|
+
|
|
1677
|
+
//#endregion
|
|
1678
|
+
//#region src/utils/safe-polygon.ts
|
|
1679
|
+
const computeTriangleSign = (point1, point2, point3) => (point1.x - point3.x) * (point2.y - point3.y) - (point2.x - point3.x) * (point1.y - point3.y);
|
|
1680
|
+
const isPositionInTriangle = (point, vertex1, vertex2, vertex3) => {
|
|
1681
|
+
const sign1 = computeTriangleSign(point, vertex1, vertex2);
|
|
1682
|
+
const sign2 = computeTriangleSign(point, vertex2, vertex3);
|
|
1683
|
+
const sign3 = computeTriangleSign(point, vertex3, vertex1);
|
|
1684
|
+
return !(sign1 < 0 || sign2 < 0 || sign3 < 0) || !(sign1 > 0 || sign2 > 0 || sign3 > 0);
|
|
1685
|
+
};
|
|
1686
|
+
const isPositionInRect = (point, rect) => point.x >= rect.x && point.x <= rect.x + rect.width && point.y >= rect.y && point.y <= rect.y + rect.height;
|
|
1687
|
+
const computeFarEdgeCorners = (cursor, targetRect) => {
|
|
1688
|
+
const targetBottom = targetRect.y + targetRect.height;
|
|
1689
|
+
const targetRight = targetRect.x + targetRect.width;
|
|
1690
|
+
if (cursor.y <= targetRect.y) return [{
|
|
1691
|
+
x: targetRect.x,
|
|
1692
|
+
y: targetBottom
|
|
1693
|
+
}, {
|
|
1694
|
+
x: targetRight,
|
|
1695
|
+
y: targetBottom
|
|
1696
|
+
}];
|
|
1697
|
+
if (cursor.y >= targetBottom) return [{
|
|
1698
|
+
x: targetRect.x,
|
|
1699
|
+
y: targetRect.y
|
|
1700
|
+
}, {
|
|
1701
|
+
x: targetRight,
|
|
1702
|
+
y: targetRect.y
|
|
1703
|
+
}];
|
|
1704
|
+
if (cursor.x <= targetRect.x) return [{
|
|
1705
|
+
x: targetRight,
|
|
1706
|
+
y: targetRect.y
|
|
1707
|
+
}, {
|
|
1708
|
+
x: targetRight,
|
|
1709
|
+
y: targetBottom
|
|
1710
|
+
}];
|
|
1711
|
+
return [{
|
|
1712
|
+
x: targetRect.x,
|
|
1713
|
+
y: targetRect.y
|
|
1714
|
+
}, {
|
|
1715
|
+
x: targetRect.x,
|
|
1716
|
+
y: targetBottom
|
|
1717
|
+
}];
|
|
1718
|
+
};
|
|
1719
|
+
const createSafePolygonTracker = () => {
|
|
1720
|
+
let removeListener = null;
|
|
1721
|
+
const stop = () => {
|
|
1722
|
+
removeListener?.();
|
|
1723
|
+
removeListener = null;
|
|
1724
|
+
};
|
|
1725
|
+
const start = (cursorPosition, targetRects, onLeavePolygon) => {
|
|
1726
|
+
stop();
|
|
1727
|
+
const primaryTarget = targetRects[0];
|
|
1728
|
+
if (!primaryTarget) return;
|
|
1729
|
+
if (isPositionInRect(cursorPosition, primaryTarget)) return;
|
|
1730
|
+
const [corner1, corner2] = computeFarEdgeCorners(cursorPosition, primaryTarget);
|
|
1731
|
+
const isInAnySafeRect = (point) => targetRects.some((rect) => isPositionInRect(point, rect));
|
|
1732
|
+
const handleMouseMove = (event) => {
|
|
1733
|
+
const cursor = {
|
|
1734
|
+
x: event.clientX,
|
|
1735
|
+
y: event.clientY
|
|
1736
|
+
};
|
|
1737
|
+
if (isInAnySafeRect(cursor)) {
|
|
1738
|
+
if (isPositionInRect(cursor, primaryTarget)) stop();
|
|
1739
|
+
return;
|
|
1740
|
+
}
|
|
1741
|
+
if (isPositionInTriangle(cursor, cursorPosition, corner1, corner2)) return;
|
|
1742
|
+
stop();
|
|
1743
|
+
onLeavePolygon();
|
|
1744
|
+
};
|
|
1745
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
1746
|
+
removeListener = () => {
|
|
1747
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
1748
|
+
};
|
|
1749
|
+
};
|
|
1750
|
+
return {
|
|
1751
|
+
start,
|
|
1752
|
+
stop
|
|
1753
|
+
};
|
|
1754
|
+
};
|
|
1755
|
+
|
|
1756
|
+
//#endregion
|
|
1757
|
+
//#region src/components/tooltip.tsx
|
|
1758
|
+
var _tmpl$$10 = /* @__PURE__ */ template(`<div>`);
|
|
1759
|
+
let lastCloseTimestamp = 0;
|
|
1760
|
+
const wasTooltipRecentlyVisible = () => {
|
|
1761
|
+
return Date.now() - lastCloseTimestamp < 100;
|
|
1762
|
+
};
|
|
1763
|
+
const Tooltip = (props) => {
|
|
1764
|
+
const [delayedVisible, setDelayedVisible] = createSignal(false);
|
|
1765
|
+
const [shouldAnimate, setShouldAnimate] = createSignal(true);
|
|
1766
|
+
let delayTimeoutId;
|
|
1767
|
+
createEffect(on(() => props.visible, (isVisible) => {
|
|
1768
|
+
if (delayTimeoutId !== void 0) {
|
|
1769
|
+
clearTimeout(delayTimeoutId);
|
|
1770
|
+
delayTimeoutId = void 0;
|
|
1771
|
+
}
|
|
1772
|
+
if (isVisible) if (wasTooltipRecentlyVisible()) {
|
|
1773
|
+
setShouldAnimate(false);
|
|
1774
|
+
setDelayedVisible(true);
|
|
1775
|
+
} else {
|
|
1776
|
+
setShouldAnimate(true);
|
|
1777
|
+
delayTimeoutId = setTimeout(() => {
|
|
1778
|
+
setDelayedVisible(true);
|
|
1779
|
+
}, 400);
|
|
1780
|
+
}
|
|
1781
|
+
else {
|
|
1782
|
+
if (delayedVisible()) lastCloseTimestamp = Date.now();
|
|
1783
|
+
setDelayedVisible(false);
|
|
1784
|
+
}
|
|
1785
|
+
}));
|
|
1786
|
+
onCleanup(() => {
|
|
1787
|
+
if (delayTimeoutId !== void 0) clearTimeout(delayTimeoutId);
|
|
1788
|
+
if (delayedVisible()) lastCloseTimestamp = Date.now();
|
|
1789
|
+
});
|
|
1790
|
+
return createComponent(Show, {
|
|
1791
|
+
get when() {
|
|
1792
|
+
return delayedVisible();
|
|
1793
|
+
},
|
|
1794
|
+
get children() {
|
|
1795
|
+
var _el$ = _tmpl$$10();
|
|
1796
|
+
setStyleProperty(_el$, "z-index", `${Z_INDEX_OVERLAY}`);
|
|
1797
|
+
insert(_el$, () => props.children);
|
|
1798
|
+
createRenderEffect(() => className(_el$, cn(TOOLTIP_BASE_CLASS, "bg-white", props.position === "left" || props.position === "right" ? "top-1/2 -translate-y-1/2" : "left-1/2 -translate-x-1/2", props.position === "top" && "bottom-full mb-2.5", props.position === "bottom" && "top-full mt-2.5", props.position === "left" && "right-full mr-2.5", props.position === "right" && "left-full ml-2.5", shouldAnimate() && "animate-tooltip-fade-in")));
|
|
1799
|
+
return _el$;
|
|
1800
|
+
}
|
|
1801
|
+
});
|
|
1802
|
+
};
|
|
1803
|
+
|
|
1804
|
+
//#endregion
|
|
1805
|
+
//#region src/components/kbd.tsx
|
|
1806
|
+
var _tmpl$$9 = /* @__PURE__ */ template(`<kbd class="inline-flex items-center justify-center px-[3px] h-3.5 rounded-sm [border-width:0.5px] border-solid border-[#B3B3B3] text-black/70 text-[10px] font-medium leading-none">`);
|
|
1807
|
+
const Kbd = (props) => (() => {
|
|
1808
|
+
var _el$ = _tmpl$$9();
|
|
1809
|
+
insert(_el$, () => props.children);
|
|
1810
|
+
return _el$;
|
|
1811
|
+
})();
|
|
1812
|
+
|
|
1813
|
+
//#endregion
|
|
1814
|
+
//#region src/utils/toolbar-layout.ts
|
|
1815
|
+
const getExpandGridClass = (isVertical, isExpanded, collapsedExtra) => {
|
|
1816
|
+
if (isExpanded) return isVertical ? "grid-rows-[1fr] opacity-100" : "grid-cols-[1fr] opacity-100";
|
|
1817
|
+
const base = isVertical ? "grid-rows-[0fr] opacity-0" : "grid-cols-[0fr] opacity-0";
|
|
1818
|
+
return collapsedExtra ? `${base} ${collapsedExtra}` : base;
|
|
1819
|
+
};
|
|
1820
|
+
const getButtonSpacingClass = (isVertical) => isVertical ? "mb-1.5" : "mr-1.5";
|
|
1821
|
+
const getMinDimensionClass = (isVertical) => isVertical ? "min-h-0" : "min-w-0";
|
|
1822
|
+
const getHitboxConstraintClass = (isVertical) => isVertical ? "before:!min-h-full" : "before:!min-w-full";
|
|
1823
|
+
|
|
1824
|
+
//#endregion
|
|
1825
|
+
//#region src/components/icons/icon-chevron.tsx
|
|
1826
|
+
var _tmpl$$8 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2.5 stroke-linecap=round stroke-linejoin=round><path d="m18 15-6-6-6 6">`);
|
|
1827
|
+
const IconChevron = (props) => {
|
|
1828
|
+
const size = () => props.size ?? 12;
|
|
1829
|
+
return (() => {
|
|
1830
|
+
var _el$ = _tmpl$$8();
|
|
1831
|
+
createRenderEffect((_p$) => {
|
|
1832
|
+
var _v$ = size(), _v$2 = size(), _v$3 = props.class;
|
|
1833
|
+
_v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
|
|
1834
|
+
_v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
|
|
1835
|
+
_v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
|
|
1836
|
+
return _p$;
|
|
1837
|
+
}, {
|
|
1838
|
+
e: void 0,
|
|
1839
|
+
t: void 0,
|
|
1840
|
+
a: void 0
|
|
1841
|
+
});
|
|
1842
|
+
return _el$;
|
|
1843
|
+
})();
|
|
1844
|
+
};
|
|
1845
|
+
|
|
1846
|
+
//#endregion
|
|
1847
|
+
//#region src/components/toolbar/toolbar-content.tsx
|
|
1848
|
+
var _tmpl$$7 = /* @__PURE__ */ template(`<button data-react-grab-ignore-events data-react-grab-toolbar-collapse class="contain-layout shrink-0 flex items-center justify-center cursor-pointer interactive-scale">`), _tmpl$2$4 = /* @__PURE__ */ template(`<div><div><div><div><div><div></div></div><div><div></div></div><div><div></div></div></div><div class="relative shrink-0 overflow-visible">`);
|
|
1849
|
+
const ToolbarContent = (props) => {
|
|
1850
|
+
const edge = () => props.snapEdge ?? "bottom";
|
|
1851
|
+
const isVertical = () => edge() === "left" || edge() === "right";
|
|
1852
|
+
const expandGridClass = (isExpanded, collapsedExtra) => getExpandGridClass(isVertical(), isExpanded, collapsedExtra);
|
|
1853
|
+
const gridTransitionClass = () => {
|
|
1854
|
+
if (props.disableGridTransitions) return "";
|
|
1855
|
+
if (isVertical()) return "transition-[grid-template-rows,opacity] duration-150 ease-out";
|
|
1856
|
+
return "transition-[grid-template-columns,opacity] duration-150 ease-out";
|
|
1857
|
+
};
|
|
1858
|
+
const gridSizeTransitionClass = () => {
|
|
1859
|
+
if (props.disableGridTransitions) return "";
|
|
1860
|
+
if (isVertical()) return "transition-[grid-template-rows] duration-150 ease-out";
|
|
1861
|
+
return "transition-[grid-template-columns] duration-150 ease-out";
|
|
1862
|
+
};
|
|
1863
|
+
const minDimensionClass = () => getMinDimensionClass(isVertical());
|
|
1864
|
+
const collapsedEdgeClasses = () => {
|
|
1865
|
+
if (!props.isCollapsed) return "";
|
|
1866
|
+
return `${{
|
|
1867
|
+
top: "rounded-t-none rounded-b-[10px]",
|
|
1868
|
+
bottom: "rounded-b-none rounded-t-[10px]",
|
|
1869
|
+
left: "rounded-l-none rounded-r-[10px]",
|
|
1870
|
+
right: "rounded-r-none rounded-l-[10px]"
|
|
1871
|
+
}[edge()]} ${isVertical() ? "px-0.25 py-2" : "px-2 py-0.25"}`;
|
|
1872
|
+
};
|
|
1873
|
+
const chevronRotation = () => {
|
|
1874
|
+
const collapsed = props.isCollapsed;
|
|
1875
|
+
switch (edge()) {
|
|
1876
|
+
case "top": return collapsed ? "rotate-180" : "rotate-0";
|
|
1877
|
+
case "bottom": return collapsed ? "rotate-0" : "rotate-180";
|
|
1878
|
+
case "left": return collapsed ? "rotate-90" : "-rotate-90";
|
|
1879
|
+
case "right": return collapsed ? "-rotate-90" : "rotate-90";
|
|
1880
|
+
default: return "rotate-0";
|
|
1881
|
+
}
|
|
1882
|
+
};
|
|
1883
|
+
const defaultCollapseButton = () => (() => {
|
|
1884
|
+
var _el$ = _tmpl$$7();
|
|
1885
|
+
addEventListener(_el$, "click", props.onCollapseClick, true);
|
|
1886
|
+
insert(_el$, createComponent(IconChevron, {
|
|
1887
|
+
size: 14,
|
|
1888
|
+
get ["class"]() {
|
|
1889
|
+
return cn("text-[#B3B3B3] transition-transform duration-150", chevronRotation());
|
|
1890
|
+
}
|
|
1891
|
+
}));
|
|
1892
|
+
createRenderEffect(() => setAttribute(_el$, "aria-label", props.isCollapsed ? "Expand toolbar" : "Collapse toolbar"));
|
|
1893
|
+
return _el$;
|
|
1894
|
+
})();
|
|
1895
|
+
return (() => {
|
|
1896
|
+
var _el$2 = _tmpl$2$4(), _el$3 = _el$2.firstChild, _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild, _el$6 = _el$5.firstChild, _el$7 = _el$6.firstChild, _el$8 = _el$6.nextSibling, _el$9 = _el$8.firstChild, _el$0 = _el$8.nextSibling, _el$1 = _el$0.firstChild, _el$10 = _el$5.nextSibling;
|
|
1897
|
+
addEventListener(_el$2, "click", props.onPanelClick, true);
|
|
1898
|
+
addEventListener(_el$2, "animationend", props.onAnimationEnd);
|
|
1899
|
+
use((element) => props.onExpandableButtonsRef?.(element), _el$5);
|
|
1900
|
+
insert(_el$7, () => props.selectButton);
|
|
1901
|
+
insert(_el$9, () => props.commentsButton);
|
|
1902
|
+
insert(_el$1, () => props.copyAllButton);
|
|
1903
|
+
insert(_el$10, () => props.toggleButton);
|
|
1904
|
+
insert(_el$2, () => props.collapseButton ?? defaultCollapseButton(), null);
|
|
1905
|
+
createRenderEffect((_p$) => {
|
|
1906
|
+
var _v$ = cn("flex items-center justify-center rounded-[10px] antialiased relative overflow-visible [font-synthesis:none] filter-[drop-shadow(0px_1px_2px_#51515140)] [corner-shape:superellipse(1.25)]", isVertical() && "flex-col", "bg-white", !props.isCollapsed && (isVertical() ? "px-1.5 gap-1.5 py-2" : "py-1.5 gap-1.5 px-2"), collapsedEdgeClasses(), props.isShaking && "animate-shake"), _v$2 = props.transformOrigin, _v$3 = cn("grid relative overflow-visible", gridSizeTransitionClass(), props.isCollapsed ? isVertical() ? "grid-rows-[0fr] pointer-events-none" : "grid-cols-[0fr] pointer-events-none" : isVertical() ? "grid-rows-[1fr]" : "grid-cols-[1fr]"), _v$4 = cn("flex", isVertical() ? "flex-col items-center min-h-0" : "items-center min-w-0", props.isCollapsed ? "opacity-0" : "opacity-100", !props.disableGridTransitions && "transition-opacity duration-150 ease-out"), _v$5 = cn("flex items-center", isVertical() && "flex-col"), _v$6 = cn("grid", gridTransitionClass(), expandGridClass(Boolean(props.enabled))), _v$7 = cn("relative overflow-visible", minDimensionClass()), _v$8 = cn("grid", gridTransitionClass(), expandGridClass(Boolean(props.enabled) && Boolean(props.isCommentsExpanded), "pointer-events-none")), _v$9 = cn("relative overflow-visible", minDimensionClass()), _v$0 = cn("grid", gridTransitionClass(), expandGridClass(Boolean(props.isCopyAllExpanded), "pointer-events-none")), _v$1 = cn("relative overflow-visible", minDimensionClass());
|
|
1907
|
+
_v$ !== _p$.e && className(_el$2, _p$.e = _v$);
|
|
1908
|
+
_v$2 !== _p$.t && setStyleProperty(_el$2, "transform-origin", _p$.t = _v$2);
|
|
1909
|
+
_v$3 !== _p$.a && className(_el$3, _p$.a = _v$3);
|
|
1910
|
+
_v$4 !== _p$.o && className(_el$4, _p$.o = _v$4);
|
|
1911
|
+
_v$5 !== _p$.i && className(_el$5, _p$.i = _v$5);
|
|
1912
|
+
_v$6 !== _p$.n && className(_el$6, _p$.n = _v$6);
|
|
1913
|
+
_v$7 !== _p$.s && className(_el$7, _p$.s = _v$7);
|
|
1914
|
+
_v$8 !== _p$.h && className(_el$8, _p$.h = _v$8);
|
|
1915
|
+
_v$9 !== _p$.r && className(_el$9, _p$.r = _v$9);
|
|
1916
|
+
_v$0 !== _p$.d && className(_el$0, _p$.d = _v$0);
|
|
1917
|
+
_v$1 !== _p$.l && className(_el$1, _p$.l = _v$1);
|
|
1918
|
+
return _p$;
|
|
1919
|
+
}, {
|
|
1920
|
+
e: void 0,
|
|
1921
|
+
t: void 0,
|
|
1922
|
+
a: void 0,
|
|
1923
|
+
o: void 0,
|
|
1924
|
+
i: void 0,
|
|
1925
|
+
n: void 0,
|
|
1926
|
+
s: void 0,
|
|
1927
|
+
h: void 0,
|
|
1928
|
+
r: void 0,
|
|
1929
|
+
d: void 0,
|
|
1930
|
+
l: void 0
|
|
1931
|
+
});
|
|
1932
|
+
return _el$2;
|
|
1933
|
+
})();
|
|
1934
|
+
};
|
|
1935
|
+
delegateEvents(["click"]);
|
|
1936
|
+
|
|
1937
|
+
//#endregion
|
|
1938
|
+
//#region src/utils/create-toolbar-drag.ts
|
|
1939
|
+
const createToolbarDrag = (config) => {
|
|
1940
|
+
const [isDragging, setIsDragging] = createSignal(false);
|
|
1941
|
+
const [isSnapping, setIsSnapping] = createSignal(false);
|
|
1942
|
+
const [hasDragMoved, setHasDragMoved] = createSignal(false);
|
|
1943
|
+
const [velocity, setVelocity] = createSignal({
|
|
1944
|
+
x: 0,
|
|
1945
|
+
y: 0
|
|
1946
|
+
});
|
|
1947
|
+
let dragOffset = {
|
|
1948
|
+
x: 0,
|
|
1949
|
+
y: 0
|
|
1950
|
+
};
|
|
1951
|
+
let lastPointerPosition = {
|
|
1952
|
+
x: 0,
|
|
1953
|
+
y: 0,
|
|
1954
|
+
time: 0
|
|
1955
|
+
};
|
|
1956
|
+
let pointerStartPosition = {
|
|
1957
|
+
x: 0,
|
|
1958
|
+
y: 0
|
|
1959
|
+
};
|
|
1960
|
+
let didDragOccur = false;
|
|
1961
|
+
let snapAnimationTimeout;
|
|
1962
|
+
const handleWindowPointerMove = (event) => {
|
|
1963
|
+
if (!isDragging()) return;
|
|
1964
|
+
if (!hasDragMoved()) {
|
|
1965
|
+
if (Math.hypot(event.clientX - pointerStartPosition.x, event.clientY - pointerStartPosition.y) <= 5) return;
|
|
1966
|
+
setHasDragMoved(true);
|
|
1967
|
+
config.onDragStart();
|
|
1968
|
+
}
|
|
1969
|
+
const now = performance.now();
|
|
1970
|
+
const deltaTime = now - lastPointerPosition.time;
|
|
1971
|
+
if (deltaTime > 0) setVelocity({
|
|
1972
|
+
x: (event.clientX - lastPointerPosition.x) / deltaTime,
|
|
1973
|
+
y: (event.clientY - lastPointerPosition.y) / deltaTime
|
|
1974
|
+
});
|
|
1975
|
+
lastPointerPosition = {
|
|
1976
|
+
x: event.clientX,
|
|
1977
|
+
y: event.clientY,
|
|
1978
|
+
time: now
|
|
1979
|
+
};
|
|
1980
|
+
const newX = event.clientX - dragOffset.x;
|
|
1981
|
+
const newY = event.clientY - dragOffset.y;
|
|
1982
|
+
config.onPositionUpdate({
|
|
1983
|
+
x: newX,
|
|
1984
|
+
y: newY
|
|
1985
|
+
});
|
|
1986
|
+
};
|
|
1987
|
+
const handleWindowPointerUp = () => {
|
|
1988
|
+
if (!isDragging()) return;
|
|
1989
|
+
window.removeEventListener("pointermove", handleWindowPointerMove);
|
|
1990
|
+
window.removeEventListener("pointerup", handleWindowPointerUp);
|
|
1991
|
+
const didMove = hasDragMoved();
|
|
1992
|
+
setIsDragging(false);
|
|
1993
|
+
if (!didMove) return;
|
|
1994
|
+
didDragOccur = true;
|
|
1995
|
+
const containerRef = config.getContainerRef();
|
|
1996
|
+
const rect = containerRef?.getBoundingClientRect();
|
|
1997
|
+
if (!rect) return;
|
|
1998
|
+
const currentVelocity = velocity();
|
|
1999
|
+
const snap = getSnapPosition(rect.left, rect.top, rect.width, rect.height, currentVelocity.x, currentVelocity.y);
|
|
2000
|
+
const ratio = getRatioFromPosition(snap.edge, snap.x, snap.y, rect.width, rect.height);
|
|
2001
|
+
config.onSnapEdgeChange(snap.edge, ratio);
|
|
2002
|
+
setIsSnapping(true);
|
|
2003
|
+
nativeRequestAnimationFrame(() => {
|
|
2004
|
+
const postRenderRect = containerRef?.getBoundingClientRect();
|
|
2005
|
+
const updatedDimensions = postRenderRect ? {
|
|
2006
|
+
width: postRenderRect.width,
|
|
2007
|
+
height: postRenderRect.height
|
|
2008
|
+
} : config.getExpandedDimensions();
|
|
2009
|
+
nativeRequestAnimationFrame(() => {
|
|
2010
|
+
const snappedPosition = getPositionFromEdgeAndRatio(snap.edge, ratio, updatedDimensions.width, updatedDimensions.height);
|
|
2011
|
+
config.onSnapComplete({
|
|
2012
|
+
edge: snap.edge,
|
|
2013
|
+
ratio,
|
|
2014
|
+
position: snappedPosition,
|
|
2015
|
+
expandedDimensions: updatedDimensions
|
|
2016
|
+
});
|
|
2017
|
+
snapAnimationTimeout = setTimeout(() => {
|
|
2018
|
+
setIsSnapping(false);
|
|
2019
|
+
config.onSnapAnimationEnd();
|
|
2020
|
+
}, 300);
|
|
2021
|
+
});
|
|
2022
|
+
});
|
|
2023
|
+
};
|
|
2024
|
+
const handlePointerDown = (event) => {
|
|
2025
|
+
if (config.isCollapsed()) return;
|
|
2026
|
+
const rect = config.getContainerRef()?.getBoundingClientRect();
|
|
2027
|
+
if (!rect) return;
|
|
2028
|
+
pointerStartPosition = {
|
|
2029
|
+
x: event.clientX,
|
|
2030
|
+
y: event.clientY
|
|
2031
|
+
};
|
|
2032
|
+
dragOffset = {
|
|
2033
|
+
x: event.clientX - rect.left,
|
|
2034
|
+
y: event.clientY - rect.top
|
|
2035
|
+
};
|
|
2036
|
+
setIsDragging(true);
|
|
2037
|
+
setHasDragMoved(false);
|
|
2038
|
+
setVelocity({
|
|
2039
|
+
x: 0,
|
|
2040
|
+
y: 0
|
|
2041
|
+
});
|
|
2042
|
+
lastPointerPosition = {
|
|
2043
|
+
x: event.clientX,
|
|
2044
|
+
y: event.clientY,
|
|
2045
|
+
time: performance.now()
|
|
2046
|
+
};
|
|
2047
|
+
window.addEventListener("pointermove", handleWindowPointerMove);
|
|
2048
|
+
window.addEventListener("pointerup", handleWindowPointerUp);
|
|
2049
|
+
};
|
|
2050
|
+
const createDragAwareHandler = (callback) => (event) => {
|
|
2051
|
+
event.stopImmediatePropagation();
|
|
2052
|
+
if (didDragOccur) {
|
|
2053
|
+
didDragOccur = false;
|
|
2054
|
+
return;
|
|
2055
|
+
}
|
|
2056
|
+
callback();
|
|
2057
|
+
};
|
|
2058
|
+
onCleanup(() => {
|
|
2059
|
+
window.removeEventListener("pointermove", handleWindowPointerMove);
|
|
2060
|
+
window.removeEventListener("pointerup", handleWindowPointerUp);
|
|
2061
|
+
clearTimeout(snapAnimationTimeout);
|
|
2062
|
+
});
|
|
2063
|
+
return {
|
|
2064
|
+
isDragging,
|
|
2065
|
+
isSnapping,
|
|
2066
|
+
handlePointerDown,
|
|
2067
|
+
createDragAwareHandler
|
|
2068
|
+
};
|
|
2069
|
+
};
|
|
2070
|
+
|
|
2071
|
+
//#endregion
|
|
2072
|
+
//#region src/components/toolbar/index.tsx
|
|
2073
|
+
var _tmpl$$6 = /* @__PURE__ */ template(`<span>Click or<!>to capture`), _tmpl$2$3 = /* @__PURE__ */ template(`<span>to fine-tune target`), _tmpl$3$3 = /* @__PURE__ */ template(`<span>to cancel`), _tmpl$4$2 = /* @__PURE__ */ template(`<div>`), _tmpl$5$1 = /* @__PURE__ */ template(`<div>Enable to continue`), _tmpl$6 = /* @__PURE__ */ template(`<div data-react-grab-ignore-events data-react-grab-toolbar>`), _tmpl$7 = /* @__PURE__ */ template(`<button data-react-grab-ignore-events data-react-grab-toolbar-toggle>`), _tmpl$8 = /* @__PURE__ */ template(`<span data-react-grab-unread-indicator class="absolute -top-1 -right-1 min-w-2.5 h-2.5 px-0.5 flex items-center justify-center rounded-full bg-black text-white text-[8px] font-semibold leading-none">`), _tmpl$9 = /* @__PURE__ */ template(`<button data-react-grab-ignore-events data-react-grab-toolbar-comments aria-haspopup=menu><span class="inline-flex relative">`), _tmpl$0 = /* @__PURE__ */ template(`<button data-react-grab-ignore-events data-react-grab-toolbar-copy-all aria-label="Copy all comments">`), _tmpl$1 = /* @__PURE__ */ template(`<button data-react-grab-ignore-events data-react-grab-toolbar-enabled><div><div>`);
|
|
2074
|
+
const Toolbar = (props) => {
|
|
2075
|
+
let containerRef;
|
|
2076
|
+
let expandableButtonsRef;
|
|
2077
|
+
let unfreezeUpdatesCallback = null;
|
|
2078
|
+
let lastKnownExpandableWidth = 0;
|
|
2079
|
+
let lastKnownExpandableHeight = 0;
|
|
2080
|
+
const safePolygonTracker = createSafePolygonTracker();
|
|
2081
|
+
const getElementRect = (selector) => {
|
|
2082
|
+
if (!containerRef) return null;
|
|
2083
|
+
const element = containerRef.getRootNode().querySelector(selector);
|
|
2084
|
+
if (!element) return null;
|
|
2085
|
+
const rect = element.getBoundingClientRect();
|
|
2086
|
+
return {
|
|
2087
|
+
x: rect.x - 8,
|
|
2088
|
+
y: rect.y - 8,
|
|
2089
|
+
width: rect.width + 8 * 2,
|
|
2090
|
+
height: rect.height + 8 * 2
|
|
2091
|
+
};
|
|
2092
|
+
};
|
|
2093
|
+
const getSafePolygonTargets = (...selectors) => {
|
|
2094
|
+
const rects = [];
|
|
2095
|
+
for (const selector of selectors) {
|
|
2096
|
+
const rect = getElementRect(selector);
|
|
2097
|
+
if (rect) rects.push(rect);
|
|
2098
|
+
}
|
|
2099
|
+
return rects.length > 0 ? rects : null;
|
|
2100
|
+
};
|
|
2101
|
+
const savedState = loadToolbarState();
|
|
2102
|
+
const [isVisible, setIsVisible] = createSignal(false);
|
|
2103
|
+
const [isCollapsed, setIsCollapsed] = createSignal(false);
|
|
2104
|
+
const [isResizing, setIsResizing] = createSignal(false);
|
|
2105
|
+
const [snapEdge, setSnapEdge] = createSignal(savedState?.edge ?? "bottom");
|
|
2106
|
+
const [positionRatio, setPositionRatio] = createSignal(savedState?.ratio ?? .5);
|
|
2107
|
+
const [position, setPosition] = createSignal({
|
|
2108
|
+
x: 0,
|
|
2109
|
+
y: 0
|
|
2110
|
+
});
|
|
2111
|
+
const [isShaking, setIsShaking] = createSignal(false);
|
|
2112
|
+
const [isCollapseAnimating, setIsCollapseAnimating] = createSignal(false);
|
|
2113
|
+
const [isSelectTooltipVisible, setIsSelectTooltipVisible] = createSignal(false);
|
|
2114
|
+
const [isToggleTooltipVisible, setIsToggleTooltipVisible] = createSignal(false);
|
|
2115
|
+
const [isShakeTooltipVisible, setIsShakeTooltipVisible] = createSignal(false);
|
|
2116
|
+
const [isToggleAnimating, setIsToggleAnimating] = createSignal(false);
|
|
2117
|
+
const [isRapidRetoggle, setIsRapidRetoggle] = createSignal(false);
|
|
2118
|
+
const [isCommentsTooltipVisible, setIsCommentsTooltipVisible] = createSignal(false);
|
|
2119
|
+
const [isCopyAllTooltipVisible, setIsCopyAllTooltipVisible] = createSignal(false);
|
|
2120
|
+
let clockFlashRef;
|
|
2121
|
+
const [selectionHintIndex, setSelectionHintIndex] = createSignal(0);
|
|
2122
|
+
const [hasHintCycled, setHasHintCycled] = createSignal(false);
|
|
2123
|
+
const drag = createToolbarDrag({
|
|
2124
|
+
getContainerRef: () => containerRef,
|
|
2125
|
+
isCollapsed,
|
|
2126
|
+
getExpandedDimensions: () => expandedDimensions,
|
|
2127
|
+
onDragStart: () => {
|
|
2128
|
+
if (unfreezeUpdatesCallback) {
|
|
2129
|
+
unfreezeUpdatesCallback();
|
|
2130
|
+
unfreezeUpdatesCallback = null;
|
|
2131
|
+
unfreezeGlobalAnimations();
|
|
2132
|
+
unfreezePseudoStates();
|
|
2133
|
+
}
|
|
2134
|
+
},
|
|
2135
|
+
onPositionUpdate: (newPosition) => setPosition(newPosition),
|
|
2136
|
+
onSnapEdgeChange: (edge, ratio) => {
|
|
2137
|
+
setSnapEdge(edge);
|
|
2138
|
+
setPositionRatio(ratio);
|
|
2139
|
+
},
|
|
2140
|
+
onSnapComplete: (result) => {
|
|
2141
|
+
expandedDimensions = result.expandedDimensions;
|
|
2142
|
+
setPosition(result.position);
|
|
2143
|
+
saveAndNotify({
|
|
2144
|
+
edge: result.edge,
|
|
2145
|
+
ratio: result.ratio,
|
|
2146
|
+
collapsed: isCollapsed(),
|
|
2147
|
+
enabled: props.enabled ?? true
|
|
2148
|
+
});
|
|
2149
|
+
},
|
|
2150
|
+
onSnapAnimationEnd: () => {
|
|
2151
|
+
if (props.enabled) measureExpandableDimension();
|
|
2152
|
+
}
|
|
2153
|
+
});
|
|
2154
|
+
const hasLearnedSelectionHints = () => (props.clockFlashTrigger ?? 0) > 0;
|
|
2155
|
+
createEffect(on(() => [props.isActive, hasLearnedSelectionHints()], ([isActive, hasLearned]) => {
|
|
2156
|
+
setSelectionHintIndex(0);
|
|
2157
|
+
setHasHintCycled(false);
|
|
2158
|
+
if (!isActive || hasLearned) return;
|
|
2159
|
+
const intervalId = setInterval(() => {
|
|
2160
|
+
if (!hasHintCycled()) setHasHintCycled(true);
|
|
2161
|
+
setSelectionHintIndex((previousIndex) => (previousIndex + 1) % 3);
|
|
2162
|
+
}, SELECTION_HINT_CYCLE_INTERVAL_MS);
|
|
2163
|
+
onCleanup(() => clearInterval(intervalId));
|
|
2164
|
+
}, { defer: true }));
|
|
2165
|
+
const commentsTooltipLabel = () => {
|
|
2166
|
+
const count = props.commentItemCount ?? 0;
|
|
2167
|
+
return count > 0 ? `Comments (${count})` : "Comments";
|
|
2168
|
+
};
|
|
2169
|
+
const commentsIconClass = () => cn("transition-colors", props.isCommentsPinned ? "text-black/50" : "text-[#B3B3B3]");
|
|
2170
|
+
const isVertical = () => snapEdge() === "left" || snapEdge() === "right";
|
|
2171
|
+
const measureExpandableDimension = () => {
|
|
2172
|
+
if (!expandableButtonsRef) return;
|
|
2173
|
+
const rect = expandableButtonsRef.getBoundingClientRect();
|
|
2174
|
+
if (isVertical()) lastKnownExpandableHeight = rect.height;
|
|
2175
|
+
else lastKnownExpandableWidth = rect.width;
|
|
2176
|
+
};
|
|
2177
|
+
const isTooltipAllowed = () => !isCollapsed() && !props.isCommentsDropdownOpen && !props.isToolbarMenuOpen && !props.isClearPromptOpen;
|
|
2178
|
+
const tooltipPosition = () => {
|
|
2179
|
+
switch (snapEdge()) {
|
|
2180
|
+
case "top": return "bottom";
|
|
2181
|
+
case "bottom": return "top";
|
|
2182
|
+
case "left": return "right";
|
|
2183
|
+
case "right": return "left";
|
|
2184
|
+
}
|
|
2185
|
+
};
|
|
2186
|
+
const buttonSpacingClass = () => getButtonSpacingClass(isVertical());
|
|
2187
|
+
const hitboxConstraintClass = () => getHitboxConstraintClass(isVertical());
|
|
2188
|
+
const shakeTooltipPositionClass = () => {
|
|
2189
|
+
const tooltipSide = tooltipPosition();
|
|
2190
|
+
if (isVertical()) return `top-1/2 -translate-y-1/2 ${tooltipSide === "left" ? "right-full mr-0.5" : "left-full ml-0.5"}`;
|
|
2191
|
+
return `left-1/2 -translate-x-1/2 ${tooltipSide === "top" ? "bottom-full mb-0.5" : "top-full mt-0.5"}`;
|
|
2192
|
+
};
|
|
2193
|
+
const stopEventPropagation = (event) => {
|
|
2194
|
+
event.stopImmediatePropagation();
|
|
2195
|
+
};
|
|
2196
|
+
const createFreezeHandlers = (setTooltipVisible, options) => ({
|
|
2197
|
+
onMouseEnter: () => {
|
|
2198
|
+
if (drag.isDragging()) return;
|
|
2199
|
+
safePolygonTracker.stop();
|
|
2200
|
+
setTooltipVisible(true);
|
|
2201
|
+
if (options?.shouldFreezeInteractions !== false && !unfreezeUpdatesCallback) {
|
|
2202
|
+
unfreezeUpdatesCallback = freezeUpdates();
|
|
2203
|
+
freezeGlobalAnimations();
|
|
2204
|
+
freezePseudoStates();
|
|
2205
|
+
}
|
|
2206
|
+
options?.onHoverChange?.(true);
|
|
2207
|
+
},
|
|
2208
|
+
onMouseLeave: (event) => {
|
|
2209
|
+
setTooltipVisible(false);
|
|
2210
|
+
if (options?.shouldFreezeInteractions !== false && !props.isActive && !props.isContextMenuOpen) {
|
|
2211
|
+
unfreezeUpdatesCallback?.();
|
|
2212
|
+
unfreezeUpdatesCallback = null;
|
|
2213
|
+
unfreezeGlobalAnimations();
|
|
2214
|
+
unfreezePseudoStates();
|
|
2215
|
+
}
|
|
2216
|
+
const targetRects = options?.safePolygonTargets?.();
|
|
2217
|
+
if (targetRects) {
|
|
2218
|
+
safePolygonTracker.start({
|
|
2219
|
+
x: event.clientX,
|
|
2220
|
+
y: event.clientY
|
|
2221
|
+
}, targetRects, () => options?.onHoverChange?.(false));
|
|
2222
|
+
return;
|
|
2223
|
+
}
|
|
2224
|
+
options?.onHoverChange?.(false);
|
|
2225
|
+
}
|
|
2226
|
+
});
|
|
2227
|
+
let shakeTooltipTimeout;
|
|
2228
|
+
const clearShakeTooltipTimeout = () => {
|
|
2229
|
+
if (shakeTooltipTimeout !== void 0) {
|
|
2230
|
+
clearTimeout(shakeTooltipTimeout);
|
|
2231
|
+
shakeTooltipTimeout = void 0;
|
|
2232
|
+
}
|
|
2233
|
+
};
|
|
2234
|
+
createEffect(on(() => props.shakeCount, (count) => {
|
|
2235
|
+
if (count && !props.enabled) {
|
|
2236
|
+
setIsShaking(true);
|
|
2237
|
+
setIsShakeTooltipVisible(true);
|
|
2238
|
+
clearShakeTooltipTimeout();
|
|
2239
|
+
shakeTooltipTimeout = setTimeout(() => {
|
|
2240
|
+
setIsShakeTooltipVisible(false);
|
|
2241
|
+
}, TOOLBAR_SHAKE_TOOLTIP_DURATION_MS);
|
|
2242
|
+
onCleanup(() => {
|
|
2243
|
+
clearShakeTooltipTimeout();
|
|
2244
|
+
});
|
|
2245
|
+
}
|
|
2246
|
+
}));
|
|
2247
|
+
createEffect(on(() => props.enabled, (enabled) => {
|
|
2248
|
+
if (enabled && isShakeTooltipVisible()) {
|
|
2249
|
+
setIsShakeTooltipVisible(false);
|
|
2250
|
+
clearShakeTooltipTimeout();
|
|
2251
|
+
}
|
|
2252
|
+
}));
|
|
2253
|
+
createEffect(on(() => [props.isActive, props.isContextMenuOpen], ([isActive, isContextMenuOpen]) => {
|
|
2254
|
+
if (!isActive && !isContextMenuOpen && unfreezeUpdatesCallback) {
|
|
2255
|
+
unfreezeUpdatesCallback();
|
|
2256
|
+
unfreezeUpdatesCallback = null;
|
|
2257
|
+
}
|
|
2258
|
+
}));
|
|
2259
|
+
const reclampToolbarToViewport = () => {
|
|
2260
|
+
if (!containerRef) return;
|
|
2261
|
+
const rect = containerRef.getBoundingClientRect();
|
|
2262
|
+
expandedDimensions = {
|
|
2263
|
+
width: rect.width,
|
|
2264
|
+
height: rect.height
|
|
2265
|
+
};
|
|
2266
|
+
const currentPos = position();
|
|
2267
|
+
const viewport = getVisualViewport();
|
|
2268
|
+
const edge = snapEdge();
|
|
2269
|
+
let clampedX = currentPos.x;
|
|
2270
|
+
let clampedY = currentPos.y;
|
|
2271
|
+
if (edge === "top" || edge === "bottom") {
|
|
2272
|
+
const minX = viewport.offsetLeft + 16;
|
|
2273
|
+
const maxX = Math.max(minX, viewport.offsetLeft + viewport.width - rect.width - 16);
|
|
2274
|
+
clampedX = clampToRange(currentPos.x, minX, maxX);
|
|
2275
|
+
clampedY = edge === "top" ? viewport.offsetTop + 16 : viewport.offsetTop + viewport.height - rect.height - 16;
|
|
2276
|
+
} else {
|
|
2277
|
+
const minY = viewport.offsetTop + 16;
|
|
2278
|
+
const maxY = Math.max(minY, viewport.offsetTop + viewport.height - rect.height - 16);
|
|
2279
|
+
clampedY = clampToRange(currentPos.y, minY, maxY);
|
|
2280
|
+
clampedX = edge === "left" ? viewport.offsetLeft + 16 : viewport.offsetLeft + viewport.width - rect.width - 16;
|
|
2281
|
+
}
|
|
2282
|
+
setPositionRatio(getRatioFromPosition(edge, clampedX, clampedY, rect.width, rect.height));
|
|
2283
|
+
if (clampedX !== currentPos.x || clampedY !== currentPos.y) {
|
|
2284
|
+
setIsCollapseAnimating(true);
|
|
2285
|
+
nativeRequestAnimationFrame(() => {
|
|
2286
|
+
nativeRequestAnimationFrame(() => {
|
|
2287
|
+
setPosition({
|
|
2288
|
+
x: clampedX,
|
|
2289
|
+
y: clampedY
|
|
2290
|
+
});
|
|
2291
|
+
if (collapseAnimationTimeout) clearTimeout(collapseAnimationTimeout);
|
|
2292
|
+
collapseAnimationTimeout = setTimeout(() => {
|
|
2293
|
+
setIsCollapseAnimating(false);
|
|
2294
|
+
}, 150);
|
|
2295
|
+
});
|
|
2296
|
+
});
|
|
2297
|
+
}
|
|
2298
|
+
};
|
|
2299
|
+
createEffect(on(() => props.clockFlashTrigger ?? 0, () => {
|
|
2300
|
+
if (props.isCommentsDropdownOpen) return;
|
|
2301
|
+
if (clockFlashRef) {
|
|
2302
|
+
clockFlashRef.classList.remove("animate-clock-flash");
|
|
2303
|
+
clockFlashRef.offsetHeight;
|
|
2304
|
+
clockFlashRef.classList.add("animate-clock-flash");
|
|
2305
|
+
}
|
|
2306
|
+
setIsCommentsTooltipVisible(true);
|
|
2307
|
+
const timerId = setTimeout(() => {
|
|
2308
|
+
clockFlashRef?.classList.remove("animate-clock-flash");
|
|
2309
|
+
setIsCommentsTooltipVisible(false);
|
|
2310
|
+
}, FEEDBACK_DURATION_MS);
|
|
2311
|
+
onCleanup(() => {
|
|
2312
|
+
clearTimeout(timerId);
|
|
2313
|
+
setIsCommentsTooltipVisible(false);
|
|
2314
|
+
});
|
|
2315
|
+
}, { defer: true }));
|
|
2316
|
+
createEffect(on(() => props.commentItemCount ?? 0, () => {
|
|
2317
|
+
if (isCollapsed()) return;
|
|
2318
|
+
if (commentItemCountTimeout) clearTimeout(commentItemCountTimeout);
|
|
2319
|
+
commentItemCountTimeout = setTimeout(() => {
|
|
2320
|
+
measureExpandableDimension();
|
|
2321
|
+
reclampToolbarToViewport();
|
|
2322
|
+
}, 150);
|
|
2323
|
+
onCleanup(() => {
|
|
2324
|
+
if (commentItemCountTimeout) clearTimeout(commentItemCountTimeout);
|
|
2325
|
+
});
|
|
2326
|
+
}, { defer: true }));
|
|
2327
|
+
let expandedDimensions = {
|
|
2328
|
+
width: 78,
|
|
2329
|
+
height: 28
|
|
2330
|
+
};
|
|
2331
|
+
const [collapsedDimensions, setCollapsedDimensions] = createSignal({
|
|
2332
|
+
width: 14,
|
|
2333
|
+
height: 14
|
|
2334
|
+
});
|
|
2335
|
+
const getExpandedFromCollapsed = (collapsedPosition, edge) => {
|
|
2336
|
+
const actualRect = containerRef?.getBoundingClientRect();
|
|
2337
|
+
const actualCollapsedWidth = actualRect?.width ?? 14;
|
|
2338
|
+
const actualCollapsedHeight = actualRect?.height ?? 14;
|
|
2339
|
+
return calculateExpandedPositionFromCollapsed(collapsedPosition, edge, expandedDimensions, actualCollapsedWidth, actualCollapsedHeight);
|
|
2340
|
+
};
|
|
2341
|
+
const recalculatePosition = () => {
|
|
2342
|
+
setPosition(getPositionFromEdgeAndRatio(snapEdge(), positionRatio(), expandedDimensions.width, expandedDimensions.height));
|
|
2343
|
+
};
|
|
2344
|
+
const handleToggle = drag.createDragAwareHandler(() => props.onToggle?.());
|
|
2345
|
+
const handleComments = drag.createDragAwareHandler(() => props.onToggleComments?.());
|
|
2346
|
+
const handleCopyAll = drag.createDragAwareHandler(() => props.onCopyAll?.());
|
|
2347
|
+
const handleToggleCollapse = drag.createDragAwareHandler(() => {
|
|
2348
|
+
const rect = containerRef?.getBoundingClientRect();
|
|
2349
|
+
const wasCollapsed = isCollapsed();
|
|
2350
|
+
let newRatio = positionRatio();
|
|
2351
|
+
if (wasCollapsed) {
|
|
2352
|
+
const { position: newPos, ratio } = getExpandedFromCollapsed(currentPosition(), snapEdge());
|
|
2353
|
+
newRatio = ratio;
|
|
2354
|
+
setPosition(newPos);
|
|
2355
|
+
setPositionRatio(newRatio);
|
|
2356
|
+
} else if (rect) expandedDimensions = {
|
|
2357
|
+
width: rect.width,
|
|
2358
|
+
height: rect.height
|
|
2359
|
+
};
|
|
2360
|
+
setIsCollapseAnimating(true);
|
|
2361
|
+
setIsCollapsed((prev) => !prev);
|
|
2362
|
+
saveAndNotify({
|
|
2363
|
+
edge: snapEdge(),
|
|
2364
|
+
ratio: newRatio,
|
|
2365
|
+
collapsed: !wasCollapsed,
|
|
2366
|
+
enabled: props.enabled ?? true
|
|
2367
|
+
});
|
|
2368
|
+
if (collapseAnimationTimeout) clearTimeout(collapseAnimationTimeout);
|
|
2369
|
+
collapseAnimationTimeout = setTimeout(() => {
|
|
2370
|
+
setIsCollapseAnimating(false);
|
|
2371
|
+
if (isCollapsed()) {
|
|
2372
|
+
const collapsedRect = containerRef?.getBoundingClientRect();
|
|
2373
|
+
if (collapsedRect) setCollapsedDimensions({
|
|
2374
|
+
width: collapsedRect.width,
|
|
2375
|
+
height: collapsedRect.height
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
}, 150);
|
|
2379
|
+
});
|
|
2380
|
+
const handleToggleEnabled = drag.createDragAwareHandler(() => {
|
|
2381
|
+
const isCurrentlyEnabled = Boolean(props.enabled);
|
|
2382
|
+
const edge = snapEdge();
|
|
2383
|
+
const preTogglePosition = position();
|
|
2384
|
+
const isVerticalEdge = edge === "left" || edge === "right";
|
|
2385
|
+
const readExpandableDimension = () => isVerticalEdge ? lastKnownExpandableHeight : lastKnownExpandableWidth;
|
|
2386
|
+
if (isCurrentlyEnabled && expandableButtonsRef && !isToggleAnimating()) measureExpandableDimension();
|
|
2387
|
+
let expandableDimension = readExpandableDimension();
|
|
2388
|
+
let shouldCompensatePosition = expandableDimension > 0;
|
|
2389
|
+
let currentRenderedDimension = 0;
|
|
2390
|
+
if (expandableButtonsRef) {
|
|
2391
|
+
const expandableRect = expandableButtonsRef.getBoundingClientRect();
|
|
2392
|
+
currentRenderedDimension = isVerticalEdge ? expandableRect.height : expandableRect.width;
|
|
2393
|
+
}
|
|
2394
|
+
if (!isCurrentlyEnabled && expandableDimension === 0 && expandableButtonsRef) {
|
|
2395
|
+
const hasCommentItems = (props.commentItemCount ?? 0) > 0;
|
|
2396
|
+
const expandedWrappers = Array.from(expandableButtonsRef.children).filter((child) => {
|
|
2397
|
+
if (!(child instanceof HTMLElement)) return false;
|
|
2398
|
+
if (child.querySelector("[data-react-grab-toolbar-comments]")) return hasCommentItems;
|
|
2399
|
+
if (child.querySelector("[data-react-grab-toolbar-copy-all]")) return Boolean(props.isCommentsDropdownOpen);
|
|
2400
|
+
return true;
|
|
2401
|
+
});
|
|
2402
|
+
const gridProperty = isVerticalEdge ? "gridTemplateRows" : "gridTemplateColumns";
|
|
2403
|
+
for (const wrapper of expandedWrappers) {
|
|
2404
|
+
wrapper.style.transition = "none";
|
|
2405
|
+
wrapper.style[gridProperty] = "1fr";
|
|
2406
|
+
}
|
|
2407
|
+
expandableButtonsRef.offsetWidth;
|
|
2408
|
+
measureExpandableDimension();
|
|
2409
|
+
expandableDimension = readExpandableDimension();
|
|
2410
|
+
for (const wrapper of expandedWrappers) wrapper.style[gridProperty] = "";
|
|
2411
|
+
expandableButtonsRef.offsetWidth;
|
|
2412
|
+
for (const wrapper of expandedWrappers) wrapper.style.transition = "";
|
|
2413
|
+
shouldCompensatePosition = expandableDimension > 0;
|
|
2414
|
+
}
|
|
2415
|
+
if (shouldCompensatePosition) {
|
|
2416
|
+
setIsRapidRetoggle(isToggleAnimating());
|
|
2417
|
+
setIsToggleAnimating(true);
|
|
2418
|
+
}
|
|
2419
|
+
props.onToggleEnabled?.();
|
|
2420
|
+
if (shouldCompensatePosition) {
|
|
2421
|
+
const dimensionChange = isCurrentlyEnabled ? -expandableDimension : expandableDimension;
|
|
2422
|
+
if (isVerticalEdge) expandedDimensions = {
|
|
2423
|
+
width: expandedDimensions.width,
|
|
2424
|
+
height: expandedDimensions.height + dimensionChange
|
|
2425
|
+
};
|
|
2426
|
+
else expandedDimensions = {
|
|
2427
|
+
width: expandedDimensions.width + dimensionChange,
|
|
2428
|
+
height: expandedDimensions.height
|
|
2429
|
+
};
|
|
2430
|
+
const collapsedAxisPosition = isVerticalEdge ? preTogglePosition.y + currentRenderedDimension : preTogglePosition.x + currentRenderedDimension;
|
|
2431
|
+
const computeClampedPosition = (expandDimension) => {
|
|
2432
|
+
const viewport = getVisualViewport();
|
|
2433
|
+
const targetAxisPosition = collapsedAxisPosition - expandDimension;
|
|
2434
|
+
if (isVerticalEdge) {
|
|
2435
|
+
const clampMin = viewport.offsetTop + 16;
|
|
2436
|
+
const clampMax = viewport.offsetTop + viewport.height - expandedDimensions.height - 16;
|
|
2437
|
+
return {
|
|
2438
|
+
x: preTogglePosition.x,
|
|
2439
|
+
y: clampToRange(targetAxisPosition, clampMin, clampMax)
|
|
2440
|
+
};
|
|
2441
|
+
}
|
|
2442
|
+
return {
|
|
2443
|
+
x: clampToRange(targetAxisPosition, viewport.offsetLeft + 16, viewport.offsetLeft + viewport.width - expandedDimensions.width - 16),
|
|
2444
|
+
y: preTogglePosition.y
|
|
2445
|
+
};
|
|
2446
|
+
};
|
|
2447
|
+
if (toggleAnimationRafId !== void 0) nativeCancelAnimationFrame(toggleAnimationRafId);
|
|
2448
|
+
if (isRapidRetoggle()) {
|
|
2449
|
+
setPosition(computeClampedPosition(isCurrentlyEnabled ? 0 : expandableDimension));
|
|
2450
|
+
toggleAnimationRafId = void 0;
|
|
2451
|
+
} else {
|
|
2452
|
+
const animationStartTime = performance.now();
|
|
2453
|
+
const syncPositionWithGrid = () => {
|
|
2454
|
+
if (performance.now() - animationStartTime > 150 + 50) {
|
|
2455
|
+
toggleAnimationRafId = void 0;
|
|
2456
|
+
return;
|
|
2457
|
+
}
|
|
2458
|
+
if (expandableButtonsRef) setPosition(computeClampedPosition(isVerticalEdge ? expandableButtonsRef.getBoundingClientRect().height : expandableButtonsRef.getBoundingClientRect().width));
|
|
2459
|
+
toggleAnimationRafId = nativeRequestAnimationFrame(syncPositionWithGrid);
|
|
2460
|
+
};
|
|
2461
|
+
toggleAnimationRafId = nativeRequestAnimationFrame(syncPositionWithGrid);
|
|
2462
|
+
}
|
|
2463
|
+
clearTimeout(toggleAnimationTimeout);
|
|
2464
|
+
toggleAnimationTimeout = setTimeout(() => {
|
|
2465
|
+
if (toggleAnimationRafId !== void 0) {
|
|
2466
|
+
nativeCancelAnimationFrame(toggleAnimationRafId);
|
|
2467
|
+
toggleAnimationRafId = void 0;
|
|
2468
|
+
}
|
|
2469
|
+
setPosition(computeClampedPosition(isCurrentlyEnabled ? 0 : expandableDimension));
|
|
2470
|
+
setIsToggleAnimating(false);
|
|
2471
|
+
setIsRapidRetoggle(false);
|
|
2472
|
+
const newRatio = getRatioFromPosition(edge, position().x, position().y, expandedDimensions.width, expandedDimensions.height);
|
|
2473
|
+
setPositionRatio(newRatio);
|
|
2474
|
+
saveAndNotify({
|
|
2475
|
+
edge,
|
|
2476
|
+
ratio: newRatio,
|
|
2477
|
+
collapsed: isCollapsed(),
|
|
2478
|
+
enabled: !isCurrentlyEnabled
|
|
2479
|
+
});
|
|
2480
|
+
}, 150);
|
|
2481
|
+
} else saveAndNotify({
|
|
2482
|
+
edge,
|
|
2483
|
+
ratio: positionRatio(),
|
|
2484
|
+
collapsed: isCollapsed(),
|
|
2485
|
+
enabled: !isCurrentlyEnabled
|
|
2486
|
+
});
|
|
2487
|
+
});
|
|
2488
|
+
const computeCollapsedPosition = () => getCollapsedPosition(snapEdge(), position(), expandedDimensions, collapsedDimensions());
|
|
2489
|
+
let resizeTimeout;
|
|
2490
|
+
let collapseAnimationTimeout;
|
|
2491
|
+
let toggleAnimationTimeout;
|
|
2492
|
+
let toggleAnimationRafId;
|
|
2493
|
+
let commentItemCountTimeout;
|
|
2494
|
+
const handleResize = () => {
|
|
2495
|
+
if (drag.isDragging()) return;
|
|
2496
|
+
setIsResizing(true);
|
|
2497
|
+
recalculatePosition();
|
|
2498
|
+
if (resizeTimeout) clearTimeout(resizeTimeout);
|
|
2499
|
+
resizeTimeout = setTimeout(() => {
|
|
2500
|
+
setIsResizing(false);
|
|
2501
|
+
const newRatio = getRatioFromPosition(snapEdge(), position().x, position().y, expandedDimensions.width, expandedDimensions.height);
|
|
2502
|
+
setPositionRatio(newRatio);
|
|
2503
|
+
saveAndNotify({
|
|
2504
|
+
edge: snapEdge(),
|
|
2505
|
+
ratio: newRatio,
|
|
2506
|
+
collapsed: isCollapsed(),
|
|
2507
|
+
enabled: props.enabled ?? true
|
|
2508
|
+
});
|
|
2509
|
+
}, 500);
|
|
2510
|
+
};
|
|
2511
|
+
const saveAndNotify = (state) => {
|
|
2512
|
+
saveToolbarState(state);
|
|
2513
|
+
props.onStateChange?.(state);
|
|
2514
|
+
};
|
|
2515
|
+
onMount(() => {
|
|
2516
|
+
if (containerRef) props.onContainerRef?.(containerRef);
|
|
2517
|
+
const rect = containerRef?.getBoundingClientRect();
|
|
2518
|
+
const viewport = getVisualViewport();
|
|
2519
|
+
if (savedState) {
|
|
2520
|
+
if (rect) expandedDimensions = {
|
|
2521
|
+
width: rect.width,
|
|
2522
|
+
height: rect.height
|
|
2523
|
+
};
|
|
2524
|
+
if (savedState.collapsed) {
|
|
2525
|
+
const isHorizontalEdge = savedState.edge === "top" || savedState.edge === "bottom";
|
|
2526
|
+
setCollapsedDimensions({
|
|
2527
|
+
width: isHorizontalEdge ? 28 : 14,
|
|
2528
|
+
height: isHorizontalEdge ? 14 : 28
|
|
2529
|
+
});
|
|
2530
|
+
}
|
|
2531
|
+
setIsCollapsed(savedState.collapsed);
|
|
2532
|
+
setPosition(getPositionFromEdgeAndRatio(savedState.edge, savedState.ratio, expandedDimensions.width, expandedDimensions.height));
|
|
2533
|
+
} else if (rect) {
|
|
2534
|
+
expandedDimensions = {
|
|
2535
|
+
width: rect.width,
|
|
2536
|
+
height: rect.height
|
|
2537
|
+
};
|
|
2538
|
+
setPosition({
|
|
2539
|
+
x: viewport.offsetLeft + (viewport.width - rect.width) / 2,
|
|
2540
|
+
y: viewport.offsetTop + viewport.height - rect.height - 16
|
|
2541
|
+
});
|
|
2542
|
+
setPositionRatio(TOOLBAR_DEFAULT_POSITION_RATIO);
|
|
2543
|
+
} else setPosition(getPositionFromEdgeAndRatio("bottom", TOOLBAR_DEFAULT_POSITION_RATIO, expandedDimensions.width, expandedDimensions.height));
|
|
2544
|
+
if (props.enabled) measureExpandableDimension();
|
|
2545
|
+
if (props.onSubscribeToStateChanges) onCleanup(props.onSubscribeToStateChanges((state) => {
|
|
2546
|
+
if (isCollapseAnimating() || isToggleAnimating()) return;
|
|
2547
|
+
if (!containerRef?.getBoundingClientRect()) return;
|
|
2548
|
+
const didCollapsedChange = isCollapsed() !== state.collapsed;
|
|
2549
|
+
setSnapEdge(state.edge);
|
|
2550
|
+
if (didCollapsedChange && !state.collapsed) {
|
|
2551
|
+
const collapsedPos = currentPosition();
|
|
2552
|
+
setIsCollapseAnimating(true);
|
|
2553
|
+
setIsCollapsed(state.collapsed);
|
|
2554
|
+
const { position: newPos, ratio: newRatio } = getExpandedFromCollapsed(collapsedPos, state.edge);
|
|
2555
|
+
setPosition(newPos);
|
|
2556
|
+
setPositionRatio(newRatio);
|
|
2557
|
+
clearTimeout(collapseAnimationTimeout);
|
|
2558
|
+
collapseAnimationTimeout = setTimeout(() => {
|
|
2559
|
+
setIsCollapseAnimating(false);
|
|
2560
|
+
}, 150);
|
|
2561
|
+
} else {
|
|
2562
|
+
if (didCollapsedChange) {
|
|
2563
|
+
setIsCollapseAnimating(true);
|
|
2564
|
+
clearTimeout(collapseAnimationTimeout);
|
|
2565
|
+
collapseAnimationTimeout = setTimeout(() => {
|
|
2566
|
+
setIsCollapseAnimating(false);
|
|
2567
|
+
}, 150);
|
|
2568
|
+
}
|
|
2569
|
+
setIsCollapsed(state.collapsed);
|
|
2570
|
+
setPosition(getPositionFromEdgeAndRatio(state.edge, state.ratio, expandedDimensions.width, expandedDimensions.height));
|
|
2571
|
+
setPositionRatio(state.ratio);
|
|
2572
|
+
}
|
|
2573
|
+
}));
|
|
2574
|
+
window.addEventListener("resize", handleResize);
|
|
2575
|
+
window.visualViewport?.addEventListener("resize", handleResize);
|
|
2576
|
+
window.visualViewport?.addEventListener("scroll", handleResize);
|
|
2577
|
+
const fadeInTimeout = setTimeout(() => {
|
|
2578
|
+
setIsVisible(true);
|
|
2579
|
+
}, 500);
|
|
2580
|
+
onCleanup(() => {
|
|
2581
|
+
clearTimeout(fadeInTimeout);
|
|
2582
|
+
});
|
|
2583
|
+
});
|
|
2584
|
+
onCleanup(() => {
|
|
2585
|
+
window.removeEventListener("resize", handleResize);
|
|
2586
|
+
window.visualViewport?.removeEventListener("resize", handleResize);
|
|
2587
|
+
window.visualViewport?.removeEventListener("scroll", handleResize);
|
|
2588
|
+
clearTimeout(resizeTimeout);
|
|
2589
|
+
clearTimeout(collapseAnimationTimeout);
|
|
2590
|
+
clearShakeTooltipTimeout();
|
|
2591
|
+
clearTimeout(toggleAnimationTimeout);
|
|
2592
|
+
clearTimeout(commentItemCountTimeout);
|
|
2593
|
+
if (toggleAnimationRafId !== void 0) nativeCancelAnimationFrame(toggleAnimationRafId);
|
|
2594
|
+
unfreezeUpdatesCallback?.();
|
|
2595
|
+
safePolygonTracker.stop();
|
|
2596
|
+
});
|
|
2597
|
+
const currentPosition = () => {
|
|
2598
|
+
return isCollapsed() ? computeCollapsedPosition() : position();
|
|
2599
|
+
};
|
|
2600
|
+
const getCursorClass = () => {
|
|
2601
|
+
if (isCollapsed()) return "cursor-pointer";
|
|
2602
|
+
if (drag.isDragging()) return "cursor-grabbing";
|
|
2603
|
+
return "cursor-grab";
|
|
2604
|
+
};
|
|
2605
|
+
const getTransitionClass = () => {
|
|
2606
|
+
if (isResizing()) return "";
|
|
2607
|
+
if (drag.isSnapping()) return "transition-[transform,opacity] duration-300 ease-out";
|
|
2608
|
+
if (isCollapseAnimating()) return "transition-[transform,opacity] duration-150 ease-out";
|
|
2609
|
+
if (isToggleAnimating()) return "transition-opacity duration-150 ease-out";
|
|
2610
|
+
return "transition-opacity duration-300 ease-out";
|
|
2611
|
+
};
|
|
2612
|
+
const getTransformOrigin = () => {
|
|
2613
|
+
switch (snapEdge()) {
|
|
2614
|
+
case "top": return "center top";
|
|
2615
|
+
case "bottom": return "center bottom";
|
|
2616
|
+
case "left": return "left center";
|
|
2617
|
+
case "right": return "right center";
|
|
2618
|
+
default: return "center center";
|
|
2619
|
+
}
|
|
2620
|
+
};
|
|
2621
|
+
return (() => {
|
|
2622
|
+
var _el$ = _tmpl$6();
|
|
2623
|
+
_el$.addEventListener("mouseleave", () => props.onSelectHoverChange?.(false));
|
|
2624
|
+
_el$.addEventListener("mouseenter", () => !isCollapsed() && props.onSelectHoverChange?.(true));
|
|
2625
|
+
addEventListener(_el$, "mousedown", stopEventPropagation);
|
|
2626
|
+
addEventListener(_el$, "pointerdown", (event) => {
|
|
2627
|
+
stopEventPropagation(event);
|
|
2628
|
+
drag.handlePointerDown(event);
|
|
2629
|
+
});
|
|
2630
|
+
var _ref$ = containerRef;
|
|
2631
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : containerRef = _el$;
|
|
2632
|
+
insert(_el$, createComponent(ToolbarContent, {
|
|
2633
|
+
get isActive() {
|
|
2634
|
+
return props.isActive;
|
|
2635
|
+
},
|
|
2636
|
+
get enabled() {
|
|
2637
|
+
return props.enabled;
|
|
2638
|
+
},
|
|
2639
|
+
get isCollapsed() {
|
|
2640
|
+
return isCollapsed();
|
|
2641
|
+
},
|
|
2642
|
+
get snapEdge() {
|
|
2643
|
+
return snapEdge();
|
|
2644
|
+
},
|
|
2645
|
+
get isShaking() {
|
|
2646
|
+
return isShaking();
|
|
2647
|
+
},
|
|
2648
|
+
get isCommentsExpanded() {
|
|
2649
|
+
return (props.commentItemCount ?? 0) > 0;
|
|
2650
|
+
},
|
|
2651
|
+
get isCopyAllExpanded() {
|
|
2652
|
+
return Boolean(props.isCommentsDropdownOpen);
|
|
2653
|
+
},
|
|
2654
|
+
get isCommentsPinned() {
|
|
2655
|
+
return props.isCommentsPinned;
|
|
2656
|
+
},
|
|
2657
|
+
get disableGridTransitions() {
|
|
2658
|
+
return isRapidRetoggle();
|
|
2659
|
+
},
|
|
2660
|
+
get transformOrigin() {
|
|
2661
|
+
return getTransformOrigin();
|
|
2662
|
+
},
|
|
2663
|
+
onAnimationEnd: () => setIsShaking(false),
|
|
2664
|
+
onCollapseClick: handleToggleCollapse,
|
|
2665
|
+
onExpandableButtonsRef: (element) => {
|
|
2666
|
+
expandableButtonsRef = element;
|
|
2667
|
+
},
|
|
2668
|
+
onPanelClick: (event) => {
|
|
2669
|
+
if (isCollapsed()) {
|
|
2670
|
+
event.stopPropagation();
|
|
2671
|
+
const { position: newPos, ratio: newRatio } = getExpandedFromCollapsed(currentPosition(), snapEdge());
|
|
2672
|
+
setPosition(newPos);
|
|
2673
|
+
setPositionRatio(newRatio);
|
|
2674
|
+
setIsCollapseAnimating(true);
|
|
2675
|
+
setIsCollapsed(false);
|
|
2676
|
+
saveAndNotify({
|
|
2677
|
+
edge: snapEdge(),
|
|
2678
|
+
ratio: newRatio,
|
|
2679
|
+
collapsed: false,
|
|
2680
|
+
enabled: props.enabled ?? true
|
|
2681
|
+
});
|
|
2682
|
+
if (collapseAnimationTimeout) clearTimeout(collapseAnimationTimeout);
|
|
2683
|
+
collapseAnimationTimeout = setTimeout(() => {
|
|
2684
|
+
setIsCollapseAnimating(false);
|
|
2685
|
+
}, 150);
|
|
2686
|
+
}
|
|
2687
|
+
},
|
|
2688
|
+
get selectButton() {
|
|
2689
|
+
return [(() => {
|
|
2690
|
+
var _el$10 = _tmpl$7();
|
|
2691
|
+
addEventListener(_el$10, "contextmenu", (event) => {
|
|
2692
|
+
event.preventDefault();
|
|
2693
|
+
event.stopPropagation();
|
|
2694
|
+
setIsSelectTooltipVisible(false);
|
|
2695
|
+
props.onToggleToolbarMenu?.();
|
|
2696
|
+
});
|
|
2697
|
+
_el$10.$$click = (event) => {
|
|
2698
|
+
setIsSelectTooltipVisible(false);
|
|
2699
|
+
handleToggle(event);
|
|
2700
|
+
};
|
|
2701
|
+
spread(_el$10, mergeProps({
|
|
2702
|
+
get ["aria-label"]() {
|
|
2703
|
+
return props.isActive ? "Stop selecting element" : "Select element";
|
|
2704
|
+
},
|
|
2705
|
+
get ["aria-pressed"]() {
|
|
2706
|
+
return Boolean(props.isActive);
|
|
2707
|
+
},
|
|
2708
|
+
get ["class"]() {
|
|
2709
|
+
return cn("contain-layout flex items-center justify-center cursor-pointer interactive-scale touch-hitbox", buttonSpacingClass(), hitboxConstraintClass());
|
|
2710
|
+
}
|
|
2711
|
+
}, () => createFreezeHandlers(setIsSelectTooltipVisible)), false, true);
|
|
2712
|
+
insert(_el$10, createComponent(IconSelect, {
|
|
2713
|
+
size: 14,
|
|
2714
|
+
get ["class"]() {
|
|
2715
|
+
return cn("transition-colors", props.isActive ? "text-black" : "text-black/70");
|
|
2716
|
+
}
|
|
2717
|
+
}));
|
|
2718
|
+
return _el$10;
|
|
2719
|
+
})(), createComponent(Tooltip, {
|
|
2720
|
+
get visible() {
|
|
2721
|
+
return memo(() => !!isSelectTooltipVisible())() && isTooltipAllowed();
|
|
2722
|
+
},
|
|
2723
|
+
get position() {
|
|
2724
|
+
return tooltipPosition();
|
|
2725
|
+
},
|
|
2726
|
+
get children() {
|
|
2727
|
+
return ["Select element ", createComponent(Kbd, { get children() {
|
|
2728
|
+
return formatShortcut("C");
|
|
2729
|
+
} })];
|
|
2730
|
+
}
|
|
2731
|
+
})];
|
|
2732
|
+
},
|
|
2733
|
+
get commentsButton() {
|
|
2734
|
+
return [(() => {
|
|
2735
|
+
var _el$11 = _tmpl$9(), _el$12 = _el$11.firstChild;
|
|
2736
|
+
_el$11.$$click = (event) => {
|
|
2737
|
+
setIsCommentsTooltipVisible(false);
|
|
2738
|
+
handleComments(event);
|
|
2739
|
+
};
|
|
2740
|
+
spread(_el$11, mergeProps({
|
|
2741
|
+
get ["aria-label"]() {
|
|
2742
|
+
return `Open comments${(props.commentItemCount ?? 0) > 0 ? ` (${props.commentItemCount ?? 0} items)` : ""}`;
|
|
2743
|
+
},
|
|
2744
|
+
get ["aria-expanded"]() {
|
|
2745
|
+
return Boolean(props.isCommentsDropdownOpen);
|
|
2746
|
+
},
|
|
2747
|
+
get ["class"]() {
|
|
2748
|
+
return cn("contain-layout flex items-center justify-center cursor-pointer interactive-scale touch-hitbox", buttonSpacingClass(), hitboxConstraintClass());
|
|
2749
|
+
}
|
|
2750
|
+
}, () => createFreezeHandlers((visible) => {
|
|
2751
|
+
if (visible && props.isCommentsDropdownOpen) return;
|
|
2752
|
+
setIsCommentsTooltipVisible(visible);
|
|
2753
|
+
}, {
|
|
2754
|
+
onHoverChange: (isHovered) => props.onCommentsButtonHover?.(isHovered),
|
|
2755
|
+
shouldFreezeInteractions: false,
|
|
2756
|
+
safePolygonTargets: () => props.isCommentsDropdownOpen ? getSafePolygonTargets("[data-react-grab-comments-dropdown]", "[data-react-grab-toolbar-copy-all]") : null
|
|
2757
|
+
})), false, true);
|
|
2758
|
+
var _ref$2 = clockFlashRef;
|
|
2759
|
+
typeof _ref$2 === "function" ? use(_ref$2, _el$12) : clockFlashRef = _el$12;
|
|
2760
|
+
insert(_el$12, createComponent(IconComment, {
|
|
2761
|
+
size: 14,
|
|
2762
|
+
get ["class"]() {
|
|
2763
|
+
return commentsIconClass();
|
|
2764
|
+
}
|
|
2765
|
+
}), null);
|
|
2766
|
+
insert(_el$12, createComponent(Show, {
|
|
2767
|
+
get when() {
|
|
2768
|
+
return (props.commentItemCount ?? 0) > 0;
|
|
2769
|
+
},
|
|
2770
|
+
get children() {
|
|
2771
|
+
var _el$13 = _tmpl$8();
|
|
2772
|
+
insert(_el$13, () => props.commentItemCount);
|
|
2773
|
+
return _el$13;
|
|
2774
|
+
}
|
|
2775
|
+
}), null);
|
|
2776
|
+
return _el$11;
|
|
2777
|
+
})(), createComponent(Tooltip, {
|
|
2778
|
+
get visible() {
|
|
2779
|
+
return memo(() => !!isCommentsTooltipVisible())() && isTooltipAllowed();
|
|
2780
|
+
},
|
|
2781
|
+
get position() {
|
|
2782
|
+
return tooltipPosition();
|
|
2783
|
+
},
|
|
2784
|
+
get children() {
|
|
2785
|
+
return commentsTooltipLabel();
|
|
2786
|
+
}
|
|
2787
|
+
})];
|
|
2788
|
+
},
|
|
2789
|
+
get copyAllButton() {
|
|
2790
|
+
return [(() => {
|
|
2791
|
+
var _el$14 = _tmpl$0();
|
|
2792
|
+
_el$14.$$click = (event) => {
|
|
2793
|
+
setIsCopyAllTooltipVisible(false);
|
|
2794
|
+
handleCopyAll(event);
|
|
2795
|
+
};
|
|
2796
|
+
spread(_el$14, mergeProps({ get ["class"]() {
|
|
2797
|
+
return cn("contain-layout flex items-center justify-center cursor-pointer interactive-scale touch-hitbox", buttonSpacingClass(), hitboxConstraintClass());
|
|
2798
|
+
} }, () => createFreezeHandlers(setIsCopyAllTooltipVisible, {
|
|
2799
|
+
onHoverChange: (isHovered) => props.onCopyAllHover?.(isHovered),
|
|
2800
|
+
shouldFreezeInteractions: false,
|
|
2801
|
+
safePolygonTargets: () => props.isCommentsDropdownOpen ? getSafePolygonTargets("[data-react-grab-comments-dropdown]", "[data-react-grab-toolbar-comments]") : null
|
|
2802
|
+
})), false, true);
|
|
2803
|
+
insert(_el$14, createComponent(IconCopy, {
|
|
2804
|
+
size: 14,
|
|
2805
|
+
"class": "text-[#B3B3B3] transition-colors"
|
|
2806
|
+
}));
|
|
2807
|
+
return _el$14;
|
|
2808
|
+
})(), createComponent(Tooltip, {
|
|
2809
|
+
get visible() {
|
|
2810
|
+
return memo(() => !!isCopyAllTooltipVisible())() && isTooltipAllowed();
|
|
2811
|
+
},
|
|
2812
|
+
get position() {
|
|
2813
|
+
return tooltipPosition();
|
|
2814
|
+
},
|
|
2815
|
+
children: "Copy all"
|
|
2816
|
+
})];
|
|
2817
|
+
},
|
|
2818
|
+
get toggleButton() {
|
|
2819
|
+
return [(() => {
|
|
2820
|
+
var _el$15 = _tmpl$1(), _el$16 = _el$15.firstChild, _el$17 = _el$16.firstChild;
|
|
2821
|
+
_el$15.addEventListener("mouseleave", () => setIsToggleTooltipVisible(false));
|
|
2822
|
+
_el$15.addEventListener("mouseenter", () => setIsToggleTooltipVisible(true));
|
|
2823
|
+
_el$15.$$click = (event) => {
|
|
2824
|
+
setIsToggleTooltipVisible(false);
|
|
2825
|
+
handleToggleEnabled(event);
|
|
2826
|
+
};
|
|
2827
|
+
createRenderEffect((_p$) => {
|
|
2828
|
+
var _v$1 = props.enabled ? "Disable React Grab" : "Enable React Grab", _v$10 = Boolean(props.enabled), _v$11 = cn("contain-layout flex items-center justify-center cursor-pointer interactive-scale outline-none", isVertical() ? "my-0.5" : "mx-0.5"), _v$12 = cn("relative rounded-full transition-colors", isVertical() ? "w-3.5 h-2.5" : "w-5 h-3", props.enabled ? "bg-black" : "bg-black/25"), _v$13 = cn("absolute top-0.5 rounded-full bg-white transition-transform", isVertical() ? "w-1.5 h-1.5" : "w-2 h-2", !props.enabled && "left-0.5", props.enabled && (isVertical() ? "left-1.5" : "left-2.5"));
|
|
2829
|
+
_v$1 !== _p$.e && setAttribute(_el$15, "aria-label", _p$.e = _v$1);
|
|
2830
|
+
_v$10 !== _p$.t && setAttribute(_el$15, "aria-pressed", _p$.t = _v$10);
|
|
2831
|
+
_v$11 !== _p$.a && className(_el$15, _p$.a = _v$11);
|
|
2832
|
+
_v$12 !== _p$.o && className(_el$16, _p$.o = _v$12);
|
|
2833
|
+
_v$13 !== _p$.i && className(_el$17, _p$.i = _v$13);
|
|
2834
|
+
return _p$;
|
|
2835
|
+
}, {
|
|
2836
|
+
e: void 0,
|
|
2837
|
+
t: void 0,
|
|
2838
|
+
a: void 0,
|
|
2839
|
+
o: void 0,
|
|
2840
|
+
i: void 0
|
|
2841
|
+
});
|
|
2842
|
+
return _el$15;
|
|
2843
|
+
})(), createComponent(Tooltip, {
|
|
2844
|
+
get visible() {
|
|
2845
|
+
return memo(() => !!isToggleTooltipVisible())() && isTooltipAllowed();
|
|
2846
|
+
},
|
|
2847
|
+
get position() {
|
|
2848
|
+
return tooltipPosition();
|
|
2849
|
+
},
|
|
2850
|
+
get children() {
|
|
2851
|
+
return props.enabled ? "Disable" : "Enable";
|
|
2852
|
+
}
|
|
2853
|
+
})];
|
|
2854
|
+
}
|
|
2855
|
+
}), null);
|
|
2856
|
+
insert(_el$, createComponent(Show, {
|
|
2857
|
+
get when() {
|
|
2858
|
+
return memo(() => !!props.isActive)() && !hasLearnedSelectionHints();
|
|
2859
|
+
},
|
|
2860
|
+
get children() {
|
|
2861
|
+
var _el$2 = _tmpl$4$2();
|
|
2862
|
+
insert(_el$2, createComponent(Show, {
|
|
2863
|
+
get when() {
|
|
2864
|
+
return selectionHintIndex() === 0;
|
|
2865
|
+
},
|
|
2866
|
+
get children() {
|
|
2867
|
+
var _el$3 = _tmpl$$6(), _el$6 = _el$3.firstChild.nextSibling;
|
|
2868
|
+
_el$6.nextSibling;
|
|
2869
|
+
insert(_el$3, createComponent(Kbd, { children: "↵" }), _el$6);
|
|
2870
|
+
createRenderEffect(() => className(_el$3, cn("flex items-center gap-1", hasHintCycled() && "animate-[hint-flip-in_var(--transition-normal)_ease-out]")));
|
|
2871
|
+
return _el$3;
|
|
2872
|
+
}
|
|
2873
|
+
}), null);
|
|
2874
|
+
insert(_el$2, createComponent(Show, {
|
|
2875
|
+
get when() {
|
|
2876
|
+
return selectionHintIndex() === 1;
|
|
2877
|
+
},
|
|
2878
|
+
get children() {
|
|
2879
|
+
var _el$7 = _tmpl$2$3(), _el$8 = _el$7.firstChild;
|
|
2880
|
+
insert(_el$7, createComponent(Kbd, { children: "↑" }), _el$8);
|
|
2881
|
+
insert(_el$7, createComponent(Kbd, { children: "↓" }), _el$8);
|
|
2882
|
+
createRenderEffect(() => className(_el$7, cn("flex items-center gap-1", HINT_FLIP_IN_ANIMATION)));
|
|
2883
|
+
return _el$7;
|
|
2884
|
+
}
|
|
2885
|
+
}), null);
|
|
2886
|
+
insert(_el$2, createComponent(Show, {
|
|
2887
|
+
get when() {
|
|
2888
|
+
return selectionHintIndex() === 2;
|
|
2889
|
+
},
|
|
2890
|
+
get children() {
|
|
2891
|
+
var _el$9 = _tmpl$3$3(), _el$0 = _el$9.firstChild;
|
|
2892
|
+
insert(_el$9, createComponent(Kbd, { children: "esc" }), _el$0);
|
|
2893
|
+
createRenderEffect(() => className(_el$9, cn("flex items-center gap-1", HINT_FLIP_IN_ANIMATION)));
|
|
2894
|
+
return _el$9;
|
|
2895
|
+
}
|
|
2896
|
+
}), null);
|
|
2897
|
+
createRenderEffect((_p$) => {
|
|
2898
|
+
var _v$ = cn(TOOLTIP_BASE_CLASS, "flex items-center gap-1 animate-tooltip-fade-in [animation-fill-mode:backwards]", "bg-white", shakeTooltipPositionClass()), _v$2 = { [isVertical() ? "top" : "left"]: "50%" }, _v$3 = String(Z_INDEX_OVERLAY);
|
|
2899
|
+
_v$ !== _p$.e && className(_el$2, _p$.e = _v$);
|
|
2900
|
+
_p$.t = style(_el$2, _v$2, _p$.t);
|
|
2901
|
+
_v$3 !== _p$.a && setStyleProperty(_el$2, "z-index", _p$.a = _v$3);
|
|
2902
|
+
return _p$;
|
|
2903
|
+
}, {
|
|
2904
|
+
e: void 0,
|
|
2905
|
+
t: void 0,
|
|
2906
|
+
a: void 0
|
|
2907
|
+
});
|
|
2908
|
+
return _el$2;
|
|
2909
|
+
}
|
|
2910
|
+
}), null);
|
|
2911
|
+
insert(_el$, createComponent(Show, {
|
|
2912
|
+
get when() {
|
|
2913
|
+
return isShakeTooltipVisible();
|
|
2914
|
+
},
|
|
2915
|
+
get children() {
|
|
2916
|
+
var _el$1 = _tmpl$5$1();
|
|
2917
|
+
createRenderEffect((_p$) => {
|
|
2918
|
+
var _v$4 = cn(TOOLTIP_BASE_CLASS, "animate-tooltip-fade-in", "bg-white", shakeTooltipPositionClass()), _v$5 = { [isVertical() ? "top" : "left"]: "50%" }, _v$6 = String(Z_INDEX_OVERLAY);
|
|
2919
|
+
_v$4 !== _p$.e && className(_el$1, _p$.e = _v$4);
|
|
2920
|
+
_p$.t = style(_el$1, _v$5, _p$.t);
|
|
2921
|
+
_v$6 !== _p$.a && setStyleProperty(_el$1, "z-index", _p$.a = _v$6);
|
|
2922
|
+
return _p$;
|
|
2923
|
+
}, {
|
|
2924
|
+
e: void 0,
|
|
2925
|
+
t: void 0,
|
|
2926
|
+
a: void 0
|
|
2927
|
+
});
|
|
2928
|
+
return _el$1;
|
|
2929
|
+
}
|
|
2930
|
+
}), null);
|
|
2931
|
+
createRenderEffect((_p$) => {
|
|
2932
|
+
var _v$7 = cn("fixed left-0 top-0 font-sans text-[13px] antialiased select-none", getCursorClass(), getTransitionClass(), isVisible() ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none"), _v$8 = String(Z_INDEX_OVERLAY), _v$9 = `translate(${currentPosition().x}px, ${currentPosition().y}px)`, _v$0 = getTransformOrigin();
|
|
2933
|
+
_v$7 !== _p$.e && className(_el$, _p$.e = _v$7);
|
|
2934
|
+
_v$8 !== _p$.t && setStyleProperty(_el$, "z-index", _p$.t = _v$8);
|
|
2935
|
+
_v$9 !== _p$.a && setStyleProperty(_el$, "transform", _p$.a = _v$9);
|
|
2936
|
+
_v$0 !== _p$.o && setStyleProperty(_el$, "transform-origin", _p$.o = _v$0);
|
|
2937
|
+
return _p$;
|
|
2938
|
+
}, {
|
|
2939
|
+
e: void 0,
|
|
2940
|
+
t: void 0,
|
|
2941
|
+
a: void 0,
|
|
2942
|
+
o: void 0
|
|
2943
|
+
});
|
|
2944
|
+
return _el$;
|
|
2945
|
+
})();
|
|
2946
|
+
};
|
|
2947
|
+
delegateEvents(["click"]);
|
|
2948
|
+
|
|
2949
|
+
//#endregion
|
|
2950
|
+
//#region src/utils/suppress-menu-event.ts
|
|
2951
|
+
const suppressMenuEvent = (event) => {
|
|
2952
|
+
if (event.type === "contextmenu") event.preventDefault();
|
|
2953
|
+
event.stopImmediatePropagation();
|
|
2954
|
+
};
|
|
2955
|
+
|
|
2956
|
+
//#endregion
|
|
2957
|
+
//#region src/utils/register-overlay-dismiss.ts
|
|
2958
|
+
const registerOverlayDismiss = (options) => {
|
|
2959
|
+
const handleKeyDown = (event) => {
|
|
2960
|
+
if (!options.isOpen()) return;
|
|
2961
|
+
if (options.shouldIgnoreInputEvents && isKeyboardEventTriggeredByInput(event)) return;
|
|
2962
|
+
if (event.code === "Escape") {
|
|
2963
|
+
event.preventDefault();
|
|
2964
|
+
event.stopImmediatePropagation();
|
|
2965
|
+
options.onDismiss();
|
|
2966
|
+
return;
|
|
2967
|
+
}
|
|
2968
|
+
if (event.code === "Enter" && options.onConfirm) {
|
|
2969
|
+
event.preventDefault();
|
|
2970
|
+
event.stopImmediatePropagation();
|
|
2971
|
+
options.onConfirm();
|
|
2972
|
+
}
|
|
2973
|
+
};
|
|
2974
|
+
const handleClickOutside = (event) => {
|
|
2975
|
+
if (!options.isOpen()) return;
|
|
2976
|
+
if (isEventFromOverlay(event, "data-react-grab-ignore-events")) return;
|
|
2977
|
+
if (options.shouldIgnoreRightClick && event instanceof MouseEvent && event.button === 2) return;
|
|
2978
|
+
options.onDismiss();
|
|
2979
|
+
};
|
|
2980
|
+
const frameId = nativeRequestAnimationFrame(() => {
|
|
2981
|
+
window.addEventListener("mousedown", handleClickOutside, { capture: true });
|
|
2982
|
+
window.addEventListener("touchstart", handleClickOutside, { capture: true });
|
|
2983
|
+
});
|
|
2984
|
+
window.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
2985
|
+
return () => {
|
|
2986
|
+
nativeCancelAnimationFrame(frameId);
|
|
2987
|
+
window.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
2988
|
+
window.removeEventListener("mousedown", handleClickOutside, { capture: true });
|
|
2989
|
+
window.removeEventListener("touchstart", handleClickOutside, { capture: true });
|
|
2990
|
+
};
|
|
2991
|
+
};
|
|
2992
|
+
|
|
2993
|
+
//#endregion
|
|
2994
|
+
//#region src/components/context-menu.tsx
|
|
2995
|
+
var _tmpl$$5 = /* @__PURE__ */ template(`<div class="relative flex flex-col w-[calc(100%+16px)] -mx-2 -my-1.5"><div class="pointer-events-none absolute bg-black/5 opacity-0 transition-[top,left,width,height,opacity] duration-75 ease-out">`), _tmpl$2$2 = /* @__PURE__ */ template(`<div data-react-grab-ignore-events data-react-grab-context-menu class="fixed font-sans text-[13px] antialiased filter-[drop-shadow(0px_1px_2px_#51515140)] select-none"style=pointer-events:auto><div><div class="contain-layout shrink-0 flex items-center gap-1 pt-1.5 pb-1 w-fit h-fit px-2">`), _tmpl$3$2 = /* @__PURE__ */ template(`<button data-react-grab-ignore-events class="relative z-1 contain-layout flex items-center justify-between w-full px-2 py-1 cursor-pointer text-left border-none bg-transparent disabled:opacity-40 disabled:cursor-default"><span class="text-[13px] leading-4 font-sans font-medium text-black">`), _tmpl$4$1 = /* @__PURE__ */ template(`<span class="text-[11px] font-sans text-black/50 ml-4">`);
|
|
2996
|
+
const ContextMenu = (props) => {
|
|
2997
|
+
let containerRef;
|
|
2998
|
+
const { containerRef: highlightContainerRef, highlightRef, updateHighlight, clearHighlight } = createMenuHighlight();
|
|
2999
|
+
const [measuredWidth, setMeasuredWidth] = createSignal(0);
|
|
3000
|
+
const [measuredHeight, setMeasuredHeight] = createSignal(0);
|
|
3001
|
+
const isVisible = () => props.position !== null;
|
|
3002
|
+
const tagDisplayResult = createMemo(() => getTagDisplay({
|
|
3003
|
+
tagName: props.tagName,
|
|
3004
|
+
componentName: props.componentName
|
|
3005
|
+
}));
|
|
3006
|
+
const measureContainer = () => {
|
|
3007
|
+
if (containerRef) {
|
|
3008
|
+
const rect = containerRef.getBoundingClientRect();
|
|
3009
|
+
setMeasuredWidth(rect.width);
|
|
3010
|
+
setMeasuredHeight(rect.height);
|
|
3011
|
+
}
|
|
3012
|
+
};
|
|
3013
|
+
createEffect(() => {
|
|
3014
|
+
if (isVisible()) nativeRequestAnimationFrame(measureContainer);
|
|
3015
|
+
});
|
|
3016
|
+
const computedPosition = createMemo(() => {
|
|
3017
|
+
const bounds = props.selectionBounds;
|
|
3018
|
+
const clickPosition = props.position;
|
|
3019
|
+
const labelWidth = measuredWidth();
|
|
3020
|
+
const labelHeight = measuredHeight();
|
|
3021
|
+
if (labelWidth === 0 || labelHeight === 0 || !bounds || !clickPosition) return {
|
|
3022
|
+
left: DROPDOWN_OFFSCREEN_POSITION.left,
|
|
3023
|
+
top: DROPDOWN_OFFSCREEN_POSITION.top,
|
|
3024
|
+
arrowLeft: 0,
|
|
3025
|
+
arrowPosition: "bottom"
|
|
3026
|
+
};
|
|
3027
|
+
const cursorX = clickPosition.x ?? bounds.x + bounds.width / 2;
|
|
3028
|
+
const positionLeft = Math.max(4, Math.min(cursorX - labelWidth / 2, window.innerWidth - labelWidth - 4));
|
|
3029
|
+
const arrowLeft = Math.max(8, Math.min(cursorX - positionLeft, labelWidth - 8));
|
|
3030
|
+
const positionBelow = bounds.y + bounds.height + 8 + 4;
|
|
3031
|
+
const positionAbove = bounds.y - labelHeight - 8 - 4;
|
|
3032
|
+
const wouldOverflowBottom = positionBelow + labelHeight > window.innerHeight;
|
|
3033
|
+
const hasSpaceAbove = positionAbove >= 0;
|
|
3034
|
+
const shouldFlipAbove = wouldOverflowBottom && hasSpaceAbove;
|
|
3035
|
+
let positionTop = shouldFlipAbove ? positionAbove : positionBelow;
|
|
3036
|
+
let arrowPosition = shouldFlipAbove ? "top" : "bottom";
|
|
3037
|
+
if (wouldOverflowBottom && !hasSpaceAbove) {
|
|
3038
|
+
const cursorY = clickPosition.y ?? bounds.y + bounds.height / 2;
|
|
3039
|
+
positionTop = Math.max(4, Math.min(cursorY + 4, window.innerHeight - labelHeight - 4));
|
|
3040
|
+
arrowPosition = "top";
|
|
3041
|
+
}
|
|
3042
|
+
return {
|
|
3043
|
+
left: positionLeft,
|
|
3044
|
+
top: positionTop,
|
|
3045
|
+
arrowLeft,
|
|
3046
|
+
arrowPosition
|
|
3047
|
+
};
|
|
3048
|
+
});
|
|
3049
|
+
const menuItems = createMemo(() => {
|
|
3050
|
+
const pluginActions = props.actions ?? [];
|
|
3051
|
+
const context = props.actionContext;
|
|
3052
|
+
return pluginActions.map((action) => ({
|
|
3053
|
+
label: action.label,
|
|
3054
|
+
action: () => {
|
|
3055
|
+
if (context) action.onAction(context);
|
|
3056
|
+
},
|
|
3057
|
+
enabled: resolveActionEnabled(action, context),
|
|
3058
|
+
shortcut: action.shortcut
|
|
3059
|
+
}));
|
|
3060
|
+
});
|
|
3061
|
+
const handleAction = (item, event) => {
|
|
3062
|
+
event.stopPropagation();
|
|
3063
|
+
if (item.enabled) {
|
|
3064
|
+
item.action();
|
|
3065
|
+
props.onHide();
|
|
3066
|
+
}
|
|
3067
|
+
};
|
|
3068
|
+
onMount(() => {
|
|
3069
|
+
measureContainer();
|
|
3070
|
+
const handleKeyDown = (event) => {
|
|
3071
|
+
if (!isVisible()) return;
|
|
3072
|
+
const isEnter = event.key === "Enter";
|
|
3073
|
+
const hasModifierKey = event.metaKey || event.ctrlKey;
|
|
3074
|
+
const keyLower = event.key.toLowerCase();
|
|
3075
|
+
const pluginActions = props.actions ?? [];
|
|
3076
|
+
const context = props.actionContext;
|
|
3077
|
+
const runActionIfAllowed = (action) => {
|
|
3078
|
+
if (!context) return false;
|
|
3079
|
+
if (!resolveActionEnabled(action, context)) return false;
|
|
3080
|
+
event.preventDefault();
|
|
3081
|
+
event.stopPropagation();
|
|
3082
|
+
action.onAction(context);
|
|
3083
|
+
props.onHide();
|
|
3084
|
+
return true;
|
|
3085
|
+
};
|
|
3086
|
+
if (isEnter) {
|
|
3087
|
+
const enterAction = pluginActions.find((action) => action.shortcut === "Enter");
|
|
3088
|
+
if (enterAction) runActionIfAllowed(enterAction);
|
|
3089
|
+
return;
|
|
3090
|
+
}
|
|
3091
|
+
if (!hasModifierKey) return;
|
|
3092
|
+
if (event.repeat) return;
|
|
3093
|
+
const modifierAction = pluginActions.find((action) => action.shortcut && action.shortcut !== "Enter" && keyLower === action.shortcut.toLowerCase());
|
|
3094
|
+
if (modifierAction) runActionIfAllowed(modifierAction);
|
|
3095
|
+
};
|
|
3096
|
+
const unregisterOverlayDismiss = registerOverlayDismiss({
|
|
3097
|
+
isOpen: isVisible,
|
|
3098
|
+
onDismiss: props.onDismiss,
|
|
3099
|
+
shouldIgnoreRightClick: true
|
|
3100
|
+
});
|
|
3101
|
+
window.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
3102
|
+
onCleanup(() => {
|
|
3103
|
+
unregisterOverlayDismiss();
|
|
3104
|
+
window.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
3105
|
+
});
|
|
3106
|
+
});
|
|
3107
|
+
return createComponent(Show, {
|
|
3108
|
+
get when() {
|
|
3109
|
+
return isVisible();
|
|
3110
|
+
},
|
|
3111
|
+
get children() {
|
|
3112
|
+
var _el$ = _tmpl$2$2(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
3113
|
+
addEventListener(_el$, "contextmenu", suppressMenuEvent, true);
|
|
3114
|
+
addEventListener(_el$, "click", suppressMenuEvent, true);
|
|
3115
|
+
addEventListener(_el$, "mousedown", suppressMenuEvent, true);
|
|
3116
|
+
addEventListener(_el$, "pointerdown", suppressMenuEvent, true);
|
|
3117
|
+
var _ref$ = containerRef;
|
|
3118
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : containerRef = _el$;
|
|
3119
|
+
setStyleProperty(_el$, "z-index", `${Z_INDEX_OVERLAY}`);
|
|
3120
|
+
insert(_el$, createComponent(Arrow, {
|
|
3121
|
+
get position() {
|
|
3122
|
+
return computedPosition().arrowPosition;
|
|
3123
|
+
},
|
|
3124
|
+
leftPercent: 0,
|
|
3125
|
+
get leftOffsetPx() {
|
|
3126
|
+
return computedPosition().arrowLeft;
|
|
3127
|
+
}
|
|
3128
|
+
}), _el$2);
|
|
3129
|
+
insert(_el$3, createComponent(TagBadge, {
|
|
3130
|
+
get tagName() {
|
|
3131
|
+
return tagDisplayResult().tagName;
|
|
3132
|
+
},
|
|
3133
|
+
get componentName() {
|
|
3134
|
+
return tagDisplayResult().componentName;
|
|
3135
|
+
},
|
|
3136
|
+
get isClickable() {
|
|
3137
|
+
return props.hasFilePath;
|
|
3138
|
+
},
|
|
3139
|
+
onClick: (event) => {
|
|
3140
|
+
event.stopPropagation();
|
|
3141
|
+
if (props.hasFilePath && props.actionContext) (props.actions?.find((action) => action.id === "open"))?.onAction(props.actionContext);
|
|
3142
|
+
},
|
|
3143
|
+
shrink: true,
|
|
3144
|
+
get forceShowIcon() {
|
|
3145
|
+
return props.hasFilePath;
|
|
3146
|
+
}
|
|
3147
|
+
}));
|
|
3148
|
+
insert(_el$2, createComponent(BottomSection, { get children() {
|
|
3149
|
+
var _el$4 = _tmpl$$5(), _el$5 = _el$4.firstChild;
|
|
3150
|
+
use(highlightContainerRef, _el$4);
|
|
3151
|
+
use(highlightRef, _el$5);
|
|
3152
|
+
insert(_el$4, createComponent(For, {
|
|
3153
|
+
get each() {
|
|
3154
|
+
return menuItems();
|
|
3155
|
+
},
|
|
3156
|
+
children: (item) => (() => {
|
|
3157
|
+
var _el$6 = _tmpl$3$2(), _el$7 = _el$6.firstChild;
|
|
3158
|
+
_el$6.$$click = (event) => handleAction(item, event);
|
|
3159
|
+
addEventListener(_el$6, "pointerleave", clearHighlight);
|
|
3160
|
+
_el$6.addEventListener("pointerenter", (event) => {
|
|
3161
|
+
if (item.enabled) updateHighlight(event.currentTarget);
|
|
3162
|
+
});
|
|
3163
|
+
_el$6.$$pointerdown = (event) => event.stopPropagation();
|
|
3164
|
+
insert(_el$7, () => item.label);
|
|
3165
|
+
insert(_el$6, createComponent(Show, {
|
|
3166
|
+
get when() {
|
|
3167
|
+
return item.shortcut;
|
|
3168
|
+
},
|
|
3169
|
+
children: (shortcut) => (() => {
|
|
3170
|
+
var _el$8 = _tmpl$4$1();
|
|
3171
|
+
insert(_el$8, () => formatShortcut(shortcut()));
|
|
3172
|
+
return _el$8;
|
|
3173
|
+
})()
|
|
3174
|
+
}), null);
|
|
3175
|
+
createRenderEffect((_p$) => {
|
|
3176
|
+
var _v$4 = item.label.toLowerCase(), _v$5 = !item.enabled;
|
|
3177
|
+
_v$4 !== _p$.e && setAttribute(_el$6, "data-react-grab-menu-item", _p$.e = _v$4);
|
|
3178
|
+
_v$5 !== _p$.t && (_el$6.disabled = _p$.t = _v$5);
|
|
3179
|
+
return _p$;
|
|
3180
|
+
}, {
|
|
3181
|
+
e: void 0,
|
|
3182
|
+
t: void 0
|
|
3183
|
+
});
|
|
3184
|
+
return _el$6;
|
|
3185
|
+
})()
|
|
3186
|
+
}), null);
|
|
3187
|
+
return _el$4;
|
|
3188
|
+
} }), null);
|
|
3189
|
+
createRenderEffect((_p$) => {
|
|
3190
|
+
var _v$ = `${computedPosition().top}px`, _v$2 = `${computedPosition().left}px`, _v$3 = cn("contain-layout flex flex-col justify-center items-start rounded-[10px] antialiased w-fit h-fit min-w-[100px] [font-synthesis:none] [corner-shape:superellipse(1.25)]", "bg-white");
|
|
3191
|
+
_v$ !== _p$.e && setStyleProperty(_el$, "top", _p$.e = _v$);
|
|
3192
|
+
_v$2 !== _p$.t && setStyleProperty(_el$, "left", _p$.t = _v$2);
|
|
3193
|
+
_v$3 !== _p$.a && className(_el$2, _p$.a = _v$3);
|
|
3194
|
+
return _p$;
|
|
3195
|
+
}, {
|
|
3196
|
+
e: void 0,
|
|
3197
|
+
t: void 0,
|
|
3198
|
+
a: void 0
|
|
3199
|
+
});
|
|
3200
|
+
return _el$;
|
|
3201
|
+
}
|
|
3202
|
+
});
|
|
3203
|
+
};
|
|
3204
|
+
delegateEvents([
|
|
3205
|
+
"pointerdown",
|
|
3206
|
+
"mousedown",
|
|
3207
|
+
"click",
|
|
3208
|
+
"contextmenu"
|
|
3209
|
+
]);
|
|
3210
|
+
|
|
3211
|
+
//#endregion
|
|
3212
|
+
//#region src/utils/clamp-to-viewport.ts
|
|
3213
|
+
const clampToViewport = (value, elementSize, viewportSize, padding) => Math.max(padding, Math.min(value, viewportSize - elementSize - padding));
|
|
3214
|
+
|
|
3215
|
+
//#endregion
|
|
3216
|
+
//#region src/utils/get-anchored-dropdown-position.ts
|
|
3217
|
+
const getAnchoredDropdownPosition = ({ anchor, measuredWidth, measuredHeight, viewportWidth, viewportHeight, anchorGapPx, viewportPaddingPx, offscreenPosition }) => {
|
|
3218
|
+
if (!anchor || measuredWidth === 0 || measuredHeight === 0) return offscreenPosition;
|
|
3219
|
+
let rawLeft;
|
|
3220
|
+
let rawTop;
|
|
3221
|
+
if (anchor.edge === "left" || anchor.edge === "right") {
|
|
3222
|
+
rawLeft = anchor.edge === "left" ? anchor.x + anchorGapPx : anchor.x - measuredWidth - anchorGapPx;
|
|
3223
|
+
rawTop = anchor.y - measuredHeight / 2;
|
|
3224
|
+
} else {
|
|
3225
|
+
rawLeft = anchor.x - measuredWidth / 2;
|
|
3226
|
+
rawTop = anchor.edge === "top" ? anchor.y + anchorGapPx : anchor.y - measuredHeight - anchorGapPx;
|
|
3227
|
+
}
|
|
3228
|
+
return {
|
|
3229
|
+
left: clampToViewport(rawLeft, measuredWidth, viewportWidth, viewportPaddingPx),
|
|
3230
|
+
top: clampToViewport(rawTop, measuredHeight, viewportHeight, viewportPaddingPx)
|
|
3231
|
+
};
|
|
3232
|
+
};
|
|
3233
|
+
|
|
3234
|
+
//#endregion
|
|
3235
|
+
//#region src/utils/create-anchored-dropdown.ts
|
|
3236
|
+
const createAnchoredDropdown = (containerRef, anchorAccessor) => {
|
|
3237
|
+
const [measuredWidth, setMeasuredWidth] = createSignal(0);
|
|
3238
|
+
const [measuredHeight, setMeasuredHeight] = createSignal(0);
|
|
3239
|
+
const [shouldMount, setShouldMount] = createSignal(false);
|
|
3240
|
+
const [isAnimatedIn, setIsAnimatedIn] = createSignal(false);
|
|
3241
|
+
const [viewportVersion, setViewportVersion] = createSignal(0);
|
|
3242
|
+
const [lastAnchorEdge, setLastAnchorEdge] = createSignal("bottom");
|
|
3243
|
+
let exitAnimationTimeout;
|
|
3244
|
+
let enterAnimationFrameId;
|
|
3245
|
+
const clearAnimationHandles = () => {
|
|
3246
|
+
clearTimeout(exitAnimationTimeout);
|
|
3247
|
+
if (enterAnimationFrameId !== void 0) {
|
|
3248
|
+
nativeCancelAnimationFrame(enterAnimationFrameId);
|
|
3249
|
+
enterAnimationFrameId = void 0;
|
|
3250
|
+
}
|
|
3251
|
+
};
|
|
3252
|
+
const measure = () => {
|
|
3253
|
+
const container = containerRef();
|
|
3254
|
+
if (container) {
|
|
3255
|
+
setMeasuredWidth(container.offsetWidth);
|
|
3256
|
+
setMeasuredHeight(container.offsetHeight);
|
|
3257
|
+
}
|
|
3258
|
+
};
|
|
3259
|
+
const handleViewportChange = () => {
|
|
3260
|
+
setViewportVersion((previousViewportVersion) => previousViewportVersion + 1);
|
|
3261
|
+
measure();
|
|
3262
|
+
};
|
|
3263
|
+
createEffect(() => {
|
|
3264
|
+
const anchor = anchorAccessor();
|
|
3265
|
+
if (anchor) {
|
|
3266
|
+
setLastAnchorEdge(anchor.edge);
|
|
3267
|
+
clearTimeout(exitAnimationTimeout);
|
|
3268
|
+
setShouldMount(true);
|
|
3269
|
+
if (enterAnimationFrameId !== void 0) nativeCancelAnimationFrame(enterAnimationFrameId);
|
|
3270
|
+
enterAnimationFrameId = nativeRequestAnimationFrame(() => {
|
|
3271
|
+
measure();
|
|
3272
|
+
containerRef()?.offsetHeight;
|
|
3273
|
+
setIsAnimatedIn(true);
|
|
3274
|
+
});
|
|
3275
|
+
} else {
|
|
3276
|
+
if (enterAnimationFrameId !== void 0) nativeCancelAnimationFrame(enterAnimationFrameId);
|
|
3277
|
+
setIsAnimatedIn(false);
|
|
3278
|
+
exitAnimationTimeout = setTimeout(() => {
|
|
3279
|
+
setShouldMount(false);
|
|
3280
|
+
}, 100);
|
|
3281
|
+
}
|
|
3282
|
+
onCleanup(clearAnimationHandles);
|
|
3283
|
+
});
|
|
3284
|
+
createEffect(() => {
|
|
3285
|
+
if (!anchorAccessor()) return;
|
|
3286
|
+
window.addEventListener("resize", handleViewportChange);
|
|
3287
|
+
window.visualViewport?.addEventListener("resize", handleViewportChange);
|
|
3288
|
+
window.visualViewport?.addEventListener("scroll", handleViewportChange);
|
|
3289
|
+
onCleanup(() => {
|
|
3290
|
+
window.removeEventListener("resize", handleViewportChange);
|
|
3291
|
+
window.visualViewport?.removeEventListener("resize", handleViewportChange);
|
|
3292
|
+
window.visualViewport?.removeEventListener("scroll", handleViewportChange);
|
|
3293
|
+
});
|
|
3294
|
+
});
|
|
3295
|
+
return {
|
|
3296
|
+
shouldMount,
|
|
3297
|
+
isAnimatedIn,
|
|
3298
|
+
lastAnchorEdge,
|
|
3299
|
+
displayPosition: createMemo((previousPosition) => {
|
|
3300
|
+
viewportVersion();
|
|
3301
|
+
const position = getAnchoredDropdownPosition({
|
|
3302
|
+
anchor: anchorAccessor(),
|
|
3303
|
+
measuredWidth: measuredWidth(),
|
|
3304
|
+
measuredHeight: measuredHeight(),
|
|
3305
|
+
viewportWidth: window.innerWidth,
|
|
3306
|
+
viewportHeight: window.innerHeight,
|
|
3307
|
+
anchorGapPx: 8,
|
|
3308
|
+
viewportPaddingPx: 8,
|
|
3309
|
+
offscreenPosition: DROPDOWN_OFFSCREEN_POSITION
|
|
3310
|
+
});
|
|
3311
|
+
if (position.left !== DROPDOWN_OFFSCREEN_POSITION.left) return position;
|
|
3312
|
+
return previousPosition;
|
|
3313
|
+
}, DROPDOWN_OFFSCREEN_POSITION),
|
|
3314
|
+
measure,
|
|
3315
|
+
clearAnimationHandles
|
|
3316
|
+
};
|
|
3317
|
+
};
|
|
3318
|
+
|
|
3319
|
+
//#endregion
|
|
3320
|
+
//#region src/components/toolbar/toolbar-menu.tsx
|
|
3321
|
+
var _tmpl$$4 = /* @__PURE__ */ template(`<div data-react-grab-ignore-events data-react-grab-toolbar-menu class="fixed font-sans text-[13px] antialiased filter-[drop-shadow(0px_1px_2px_#51515140)] select-none transition-[opacity,transform] duration-100 ease-out will-change-[opacity,transform]"><div><div class="relative flex flex-col py-1"><div class="pointer-events-none absolute bg-black/5 opacity-0 transition-[top,left,width,height,opacity] duration-75 ease-out">`), _tmpl$2$1 = /* @__PURE__ */ template(`<button data-react-grab-ignore-events class="relative z-1 contain-layout flex items-center justify-between w-full px-2 py-1 cursor-pointer text-left border-none bg-transparent"><span>`), _tmpl$3$1 = /* @__PURE__ */ template(`<span class="text-[11px] font-sans text-black/50 ml-4">`);
|
|
3322
|
+
const ToolbarMenu = (props) => {
|
|
3323
|
+
let containerRef;
|
|
3324
|
+
const { containerRef: highlightContainerRef, highlightRef, updateHighlight, clearHighlight } = createMenuHighlight();
|
|
3325
|
+
const dropdown = createAnchoredDropdown(() => containerRef, () => props.position);
|
|
3326
|
+
const handleActionClick = (action, event) => {
|
|
3327
|
+
event.stopPropagation();
|
|
3328
|
+
props.onSetDefaultAction(action.id);
|
|
3329
|
+
props.onDismiss();
|
|
3330
|
+
};
|
|
3331
|
+
onMount(() => {
|
|
3332
|
+
dropdown.measure();
|
|
3333
|
+
const unregisterOverlayDismiss = registerOverlayDismiss({
|
|
3334
|
+
isOpen: () => Boolean(props.position),
|
|
3335
|
+
onDismiss: props.onDismiss
|
|
3336
|
+
});
|
|
3337
|
+
onCleanup(() => {
|
|
3338
|
+
dropdown.clearAnimationHandles();
|
|
3339
|
+
unregisterOverlayDismiss();
|
|
3340
|
+
});
|
|
3341
|
+
});
|
|
3342
|
+
return createComponent(Show, {
|
|
3343
|
+
get when() {
|
|
3344
|
+
return dropdown.shouldMount();
|
|
3345
|
+
},
|
|
3346
|
+
get children() {
|
|
3347
|
+
var _el$ = _tmpl$$4(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.firstChild;
|
|
3348
|
+
addEventListener(_el$, "contextmenu", suppressMenuEvent, true);
|
|
3349
|
+
addEventListener(_el$, "click", suppressMenuEvent, true);
|
|
3350
|
+
addEventListener(_el$, "mousedown", suppressMenuEvent, true);
|
|
3351
|
+
addEventListener(_el$, "pointerdown", suppressMenuEvent, true);
|
|
3352
|
+
var _ref$ = containerRef;
|
|
3353
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : containerRef = _el$;
|
|
3354
|
+
setStyleProperty(_el$, "z-index", `${Z_INDEX_OVERLAY}`);
|
|
3355
|
+
setStyleProperty(_el$2, "min-width", `${100}px`);
|
|
3356
|
+
use(highlightContainerRef, _el$3);
|
|
3357
|
+
use(highlightRef, _el$4);
|
|
3358
|
+
insert(_el$3, createComponent(For, {
|
|
3359
|
+
get each() {
|
|
3360
|
+
return props.actions;
|
|
3361
|
+
},
|
|
3362
|
+
children: (action) => {
|
|
3363
|
+
const isDefault = () => action.id === props.defaultActionId;
|
|
3364
|
+
return (() => {
|
|
3365
|
+
var _el$5 = _tmpl$2$1(), _el$6 = _el$5.firstChild;
|
|
3366
|
+
_el$5.$$click = (event) => handleActionClick(action, event);
|
|
3367
|
+
addEventListener(_el$5, "pointerleave", clearHighlight);
|
|
3368
|
+
_el$5.addEventListener("pointerenter", (event) => updateHighlight(event.currentTarget));
|
|
3369
|
+
_el$5.$$pointerdown = (event) => event.stopPropagation();
|
|
3370
|
+
insert(_el$6, () => action.label);
|
|
3371
|
+
insert(_el$5, createComponent(Show, {
|
|
3372
|
+
get when() {
|
|
3373
|
+
return action.shortcut;
|
|
3374
|
+
},
|
|
3375
|
+
children: (shortcutKey) => (() => {
|
|
3376
|
+
var _el$7 = _tmpl$3$1();
|
|
3377
|
+
insert(_el$7, () => formatShortcut(shortcutKey()));
|
|
3378
|
+
return _el$7;
|
|
3379
|
+
})()
|
|
3380
|
+
}), null);
|
|
3381
|
+
createRenderEffect((_p$) => {
|
|
3382
|
+
var _v$8 = action.id, _v$9 = cn("text-[13px] leading-4 font-sans font-medium", isDefault() ? "text-black" : "text-black/60");
|
|
3383
|
+
_v$8 !== _p$.e && setAttribute(_el$5, "data-react-grab-menu-item", _p$.e = _v$8);
|
|
3384
|
+
_v$9 !== _p$.t && className(_el$6, _p$.t = _v$9);
|
|
3385
|
+
return _p$;
|
|
3386
|
+
}, {
|
|
3387
|
+
e: void 0,
|
|
3388
|
+
t: void 0
|
|
3389
|
+
});
|
|
3390
|
+
return _el$5;
|
|
3391
|
+
})();
|
|
3392
|
+
}
|
|
3393
|
+
}), null);
|
|
3394
|
+
createRenderEffect((_p$) => {
|
|
3395
|
+
var _v$ = `${dropdown.displayPosition().top}px`, _v$2 = `${dropdown.displayPosition().left}px`, _v$3 = dropdown.isAnimatedIn() ? "auto" : "none", _v$4 = DROPDOWN_EDGE_TRANSFORM_ORIGIN[dropdown.lastAnchorEdge()], _v$5 = dropdown.isAnimatedIn() ? "1" : "0", _v$6 = dropdown.isAnimatedIn() ? "scale(1)" : "scale(0.95)", _v$7 = cn("contain-layout flex flex-col rounded-[10px] antialiased w-fit h-fit overflow-hidden [font-synthesis:none] [corner-shape:superellipse(1.25)]", "bg-white");
|
|
3396
|
+
_v$ !== _p$.e && setStyleProperty(_el$, "top", _p$.e = _v$);
|
|
3397
|
+
_v$2 !== _p$.t && setStyleProperty(_el$, "left", _p$.t = _v$2);
|
|
3398
|
+
_v$3 !== _p$.a && setStyleProperty(_el$, "pointer-events", _p$.a = _v$3);
|
|
3399
|
+
_v$4 !== _p$.o && setStyleProperty(_el$, "transform-origin", _p$.o = _v$4);
|
|
3400
|
+
_v$5 !== _p$.i && setStyleProperty(_el$, "opacity", _p$.i = _v$5);
|
|
3401
|
+
_v$6 !== _p$.n && setStyleProperty(_el$, "transform", _p$.n = _v$6);
|
|
3402
|
+
_v$7 !== _p$.s && className(_el$2, _p$.s = _v$7);
|
|
3403
|
+
return _p$;
|
|
3404
|
+
}, {
|
|
3405
|
+
e: void 0,
|
|
3406
|
+
t: void 0,
|
|
3407
|
+
a: void 0,
|
|
3408
|
+
o: void 0,
|
|
3409
|
+
i: void 0,
|
|
3410
|
+
n: void 0,
|
|
3411
|
+
s: void 0
|
|
3412
|
+
});
|
|
3413
|
+
return _el$;
|
|
3414
|
+
}
|
|
3415
|
+
});
|
|
3416
|
+
};
|
|
3417
|
+
delegateEvents([
|
|
3418
|
+
"pointerdown",
|
|
3419
|
+
"mousedown",
|
|
3420
|
+
"click",
|
|
3421
|
+
"contextmenu"
|
|
3422
|
+
]);
|
|
3423
|
+
|
|
3424
|
+
//#endregion
|
|
3425
|
+
//#region src/components/icons/icon-trash.tsx
|
|
3426
|
+
var _tmpl$$3 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=currentColor><path fill-rule=evenodd clip-rule=evenodd d="M4.63751 20.1665L3.82444 6.75092L3.73431 5.06621C3.72513 4.89447 3.8619 4.75018 4.03388 4.75018H19.9945C20.1685 4.75018 20.306 4.89769 20.2938 5.07124L20.1756 6.75092L19.3625 20.1665C19.2745 21.618 18.0717 22.7502 16.6176 22.7502H7.38247C5.9283 22.7502 4.72548 21.618 4.63751 20.1665ZM8.74963 16.5002C8.74963 16.9144 9.08542 17.2502 9.49963 17.2502C9.91385 17.2502 10.2496 16.9144 10.2496 16.5002V10.5002C10.2496 10.086 9.91385 9.75018 9.49963 9.75018C9.08542 9.75018 8.74963 10.086 8.74963 10.5002V16.5002ZM14.4996 9.75018C14.9138 9.75018 15.2496 10.086 15.2496 10.5002V16.5002C15.2496 16.9144 14.9138 17.2502 14.4996 17.2502C14.0854 17.2502 13.7496 16.9144 13.7496 16.5002V10.5002C13.7496 10.086 14.0854 9.75018 14.4996 9.75018Z"></path><path fill-rule=evenodd clip-rule=evenodd d="M8.31879 2.46286C8.63394 1.7275 9.35702 1.2507 10.1571 1.2507H13.8383C14.6383 1.2507 15.3614 1.7275 15.6766 2.46286L16.6569 4.75034H19.2239C19.2903 4.75034 19.3523 4.75034 19.4102 4.7507H19.4637C19.4857 4.74973 19.5079 4.74972 19.5303 4.7507H20.9977C21.55 4.7507 21.9977 5.19842 21.9977 5.7507C21.9977 6.30299 21.55 6.7507 20.9977 6.7507H2.99768C2.4454 6.7507 1.99768 6.30299 1.99768 5.7507C1.99768 5.19842 2.4454 4.7507 2.99768 4.7507H4.46507C4.48746 4.74972 4.50968 4.74973 4.53167 4.7507H4.58469C4.6426 4.75034 4.70457 4.75034 4.77093 4.75034H7.33844L8.31879 2.46286ZM13.8903 3.37192L14.481 4.75034H9.5144L10.1052 3.37192C10.1367 3.29838 10.209 3.2507 10.289 3.2507L13.7064 3.2507C13.7864 3.2507 13.8587 3.29838 13.8903 3.37192Z">`);
|
|
3427
|
+
const IconTrash = (props) => {
|
|
3428
|
+
const size = () => props.size ?? 14;
|
|
3429
|
+
return (() => {
|
|
3430
|
+
var _el$ = _tmpl$$3();
|
|
3431
|
+
createRenderEffect((_p$) => {
|
|
3432
|
+
var _v$ = size(), _v$2 = size(), _v$3 = props.class;
|
|
3433
|
+
_v$ !== _p$.e && setAttribute(_el$, "width", _p$.e = _v$);
|
|
3434
|
+
_v$2 !== _p$.t && setAttribute(_el$, "height", _p$.t = _v$2);
|
|
3435
|
+
_v$3 !== _p$.a && setAttribute(_el$, "class", _p$.a = _v$3);
|
|
3436
|
+
return _p$;
|
|
3437
|
+
}, {
|
|
3438
|
+
e: void 0,
|
|
3439
|
+
t: void 0,
|
|
3440
|
+
a: void 0
|
|
3441
|
+
});
|
|
3442
|
+
return _el$;
|
|
3443
|
+
})();
|
|
3444
|
+
};
|
|
3445
|
+
|
|
3446
|
+
//#endregion
|
|
3447
|
+
//#region src/utils/format-relative-time.ts
|
|
3448
|
+
const SECONDS_PER_MINUTE = 60;
|
|
3449
|
+
const MINUTES_PER_HOUR = 60;
|
|
3450
|
+
const HOURS_PER_DAY = 24;
|
|
3451
|
+
const formatRelativeTime = (timestamp) => {
|
|
3452
|
+
const elapsedSeconds = Math.floor((Date.now() - timestamp) / 1e3);
|
|
3453
|
+
if (elapsedSeconds < SECONDS_PER_MINUTE) return "now";
|
|
3454
|
+
const elapsedMinutes = Math.floor(elapsedSeconds / SECONDS_PER_MINUTE);
|
|
3455
|
+
if (elapsedMinutes < MINUTES_PER_HOUR) return `${elapsedMinutes}m`;
|
|
3456
|
+
const elapsedHours = Math.floor(elapsedMinutes / MINUTES_PER_HOUR);
|
|
3457
|
+
if (elapsedHours < HOURS_PER_DAY) return `${elapsedHours}h`;
|
|
3458
|
+
return `${Math.floor(elapsedHours / HOURS_PER_DAY)}d`;
|
|
3459
|
+
};
|
|
3460
|
+
|
|
3461
|
+
//#endregion
|
|
3462
|
+
//#region src/components/comments-dropdown.tsx
|
|
3463
|
+
var _tmpl$$2 = /* @__PURE__ */ template(`<div class="flex items-center gap-[5px]"><div class=relative><button data-react-grab-ignore-events data-react-grab-comments-clear class="contain-layout shrink-0 flex items-center justify-center px-[3px] py-px rounded-sm bg-[#FEF2F2] cursor-pointer transition-all hover:bg-[#FEE2E2] press-scale h-[17px] text-[#B91C1C]"></button></div><div class=relative><button data-react-grab-ignore-events data-react-grab-comments-copy-all class="contain-layout shrink-0 flex items-center justify-center px-[3px] py-px rounded-sm bg-white [border-width:0.5px] border-solid border-[#B3B3B3] cursor-pointer transition-all hover:bg-[#F5F5F5] press-scale h-[17px]">`), _tmpl$2 = /* @__PURE__ */ template(`<div data-react-grab-ignore-events data-react-grab-comments-dropdown class="fixed font-sans text-[13px] antialiased filter-[drop-shadow(0px_1px_2px_#51515140)] select-none transition-[opacity,transform] duration-100 ease-out will-change-[opacity,transform]"><div><div class="contain-layout shrink-0 flex items-center justify-between px-2 pt-1.5 pb-1"><span class="text-[11px] font-medium text-black/40">Comments</span></div><div class="min-h-0 [border-top-width:0.5px] border-t-solid border-t-[#D9D9D9] px-2 py-1.5"><div class="relative flex flex-col max-h-[240px] overflow-y-auto -mx-2 -my-1.5 [scrollbar-width:thin] [scrollbar-color:transparent_transparent] hover:[scrollbar-color:rgba(0,0,0,0.15)_transparent]"><div class="pointer-events-none absolute bg-black/5 opacity-0 transition-[top,left,width,height,opacity] duration-75 ease-out">`), _tmpl$3 = /* @__PURE__ */ template(`<span class="text-black text-[13px] leading-3.5 font-sans font-medium">Copy`), _tmpl$4 = /* @__PURE__ */ template(`<span class="text-[11px] leading-3 font-sans text-black/40 truncate mt-0.5">`), _tmpl$5 = /* @__PURE__ */ template(`<div data-react-grab-ignore-events data-react-grab-comment-item class="group relative z-1 contain-layout flex items-start justify-between w-full px-2 py-1 cursor-pointer text-left gap-2"tabindex=0><span class="flex flex-col min-w-0 flex-1"><span class="text-[12px] leading-4 font-sans font-medium text-black truncate"></span></span><span class="shrink-0 text-[10px] font-sans text-black/25 flex items-center justify-end">`);
|
|
3464
|
+
const getCommentItemDisplayName = (item) => {
|
|
3465
|
+
if (item.elementsCount && item.elementsCount > 1) return `${item.elementsCount} elements`;
|
|
3466
|
+
return item.componentName ?? item.tagName;
|
|
3467
|
+
};
|
|
3468
|
+
const CommentsDropdown = (props) => {
|
|
3469
|
+
let containerRef;
|
|
3470
|
+
const { containerRef: highlightContainerRef, highlightRef, updateHighlight, clearHighlight } = createMenuHighlight();
|
|
3471
|
+
const safePolygonTracker = createSafePolygonTracker();
|
|
3472
|
+
const getToolbarTargetRects = () => {
|
|
3473
|
+
if (!containerRef) return null;
|
|
3474
|
+
const toolbar = containerRef.getRootNode().querySelector("[data-react-grab-toolbar]");
|
|
3475
|
+
if (!toolbar) return null;
|
|
3476
|
+
const rect = toolbar.getBoundingClientRect();
|
|
3477
|
+
return [{
|
|
3478
|
+
x: rect.x - 8,
|
|
3479
|
+
y: rect.y - 8,
|
|
3480
|
+
width: rect.width + 8 * 2,
|
|
3481
|
+
height: rect.height + 8 * 2
|
|
3482
|
+
}];
|
|
3483
|
+
};
|
|
3484
|
+
const dropdown = createAnchoredDropdown(() => containerRef, () => props.position);
|
|
3485
|
+
const [activeHeaderTooltip, setActiveHeaderTooltip] = createSignal(null);
|
|
3486
|
+
const [isCopyAllConfirmed, setIsCopyAllConfirmed] = createSignal(false);
|
|
3487
|
+
let copyAllFeedbackTimeout;
|
|
3488
|
+
createEffect(on(() => dropdown.isAnimatedIn(), (animatedIn) => {
|
|
3489
|
+
if (animatedIn && containerRef?.matches(":hover")) props.onDropdownHover?.(true);
|
|
3490
|
+
}, { defer: true }));
|
|
3491
|
+
const clampedMaxWidth = () => Math.min(280, window.innerWidth - dropdown.displayPosition().left - 8);
|
|
3492
|
+
const clampedMaxHeight = () => window.innerHeight - dropdown.displayPosition().top - 8;
|
|
3493
|
+
const panelMinWidth = () => Math.max(180, props.position?.toolbarWidth ?? 0);
|
|
3494
|
+
onMount(() => {
|
|
3495
|
+
dropdown.measure();
|
|
3496
|
+
const handleKeyDown = (event) => {
|
|
3497
|
+
if (!props.position) return;
|
|
3498
|
+
if (event.code === "Escape") {
|
|
3499
|
+
event.preventDefault();
|
|
3500
|
+
event.stopPropagation();
|
|
3501
|
+
props.onDismiss?.();
|
|
3502
|
+
}
|
|
3503
|
+
};
|
|
3504
|
+
window.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
3505
|
+
onCleanup(() => {
|
|
3506
|
+
clearTimeout(copyAllFeedbackTimeout);
|
|
3507
|
+
dropdown.clearAnimationHandles();
|
|
3508
|
+
window.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
3509
|
+
safePolygonTracker.stop();
|
|
3510
|
+
});
|
|
3511
|
+
});
|
|
3512
|
+
return createComponent(Show, {
|
|
3513
|
+
get when() {
|
|
3514
|
+
return dropdown.shouldMount();
|
|
3515
|
+
},
|
|
3516
|
+
get children() {
|
|
3517
|
+
var _el$ = _tmpl$2(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
3518
|
+
_el$3.firstChild;
|
|
3519
|
+
var _el$1 = _el$3.nextSibling.firstChild, _el$10 = _el$1.firstChild;
|
|
3520
|
+
_el$.addEventListener("mouseleave", (event) => {
|
|
3521
|
+
const targetRects = getToolbarTargetRects();
|
|
3522
|
+
if (targetRects) {
|
|
3523
|
+
safePolygonTracker.start({
|
|
3524
|
+
x: event.clientX,
|
|
3525
|
+
y: event.clientY
|
|
3526
|
+
}, targetRects, () => props.onDropdownHover?.(false));
|
|
3527
|
+
return;
|
|
3528
|
+
}
|
|
3529
|
+
props.onDropdownHover?.(false);
|
|
3530
|
+
});
|
|
3531
|
+
_el$.addEventListener("mouseenter", () => {
|
|
3532
|
+
safePolygonTracker.stop();
|
|
3533
|
+
props.onDropdownHover?.(true);
|
|
3534
|
+
});
|
|
3535
|
+
addEventListener(_el$, "contextmenu", suppressMenuEvent, true);
|
|
3536
|
+
addEventListener(_el$, "click", suppressMenuEvent, true);
|
|
3537
|
+
addEventListener(_el$, "mousedown", suppressMenuEvent, true);
|
|
3538
|
+
addEventListener(_el$, "pointerdown", suppressMenuEvent, true);
|
|
3539
|
+
var _ref$ = containerRef;
|
|
3540
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : containerRef = _el$;
|
|
3541
|
+
setStyleProperty(_el$, "z-index", `${Z_INDEX_OVERLAY}`);
|
|
3542
|
+
insert(_el$3, createComponent(Show, {
|
|
3543
|
+
get when() {
|
|
3544
|
+
return props.items.length > 0;
|
|
3545
|
+
},
|
|
3546
|
+
get children() {
|
|
3547
|
+
var _el$5 = _tmpl$$2(), _el$6 = _el$5.firstChild, _el$7 = _el$6.firstChild, _el$8 = _el$6.nextSibling, _el$9 = _el$8.firstChild;
|
|
3548
|
+
_el$7.addEventListener("mouseleave", () => setActiveHeaderTooltip(null));
|
|
3549
|
+
_el$7.addEventListener("mouseenter", () => setActiveHeaderTooltip("clear"));
|
|
3550
|
+
_el$7.$$click = (event) => {
|
|
3551
|
+
event.stopPropagation();
|
|
3552
|
+
setActiveHeaderTooltip(null);
|
|
3553
|
+
props.onClearAll?.();
|
|
3554
|
+
};
|
|
3555
|
+
insert(_el$7, createComponent(IconTrash, { size: 11 }));
|
|
3556
|
+
insert(_el$6, createComponent(Tooltip, {
|
|
3557
|
+
get visible() {
|
|
3558
|
+
return activeHeaderTooltip() === "clear";
|
|
3559
|
+
},
|
|
3560
|
+
position: "top",
|
|
3561
|
+
children: "Clear all"
|
|
3562
|
+
}), null);
|
|
3563
|
+
_el$9.addEventListener("mouseleave", () => {
|
|
3564
|
+
setActiveHeaderTooltip(null);
|
|
3565
|
+
props.onCopyAllHover?.(false);
|
|
3566
|
+
});
|
|
3567
|
+
_el$9.addEventListener("mouseenter", () => {
|
|
3568
|
+
setActiveHeaderTooltip("copy");
|
|
3569
|
+
if (!isCopyAllConfirmed()) props.onCopyAllHover?.(true);
|
|
3570
|
+
});
|
|
3571
|
+
_el$9.$$click = (event) => {
|
|
3572
|
+
event.stopPropagation();
|
|
3573
|
+
setActiveHeaderTooltip(null);
|
|
3574
|
+
props.onCopyAll?.();
|
|
3575
|
+
setIsCopyAllConfirmed(true);
|
|
3576
|
+
clearTimeout(copyAllFeedbackTimeout);
|
|
3577
|
+
copyAllFeedbackTimeout = setTimeout(() => {
|
|
3578
|
+
setIsCopyAllConfirmed(false);
|
|
3579
|
+
}, FEEDBACK_DURATION_MS);
|
|
3580
|
+
};
|
|
3581
|
+
insert(_el$9, createComponent(Show, {
|
|
3582
|
+
get when() {
|
|
3583
|
+
return isCopyAllConfirmed();
|
|
3584
|
+
},
|
|
3585
|
+
get fallback() {
|
|
3586
|
+
return _tmpl$3();
|
|
3587
|
+
},
|
|
3588
|
+
get children() {
|
|
3589
|
+
return createComponent(IconCheck, {
|
|
3590
|
+
size: 11,
|
|
3591
|
+
"class": "text-black"
|
|
3592
|
+
});
|
|
3593
|
+
}
|
|
3594
|
+
}));
|
|
3595
|
+
insert(_el$8, createComponent(Tooltip, {
|
|
3596
|
+
get visible() {
|
|
3597
|
+
return activeHeaderTooltip() === "copy";
|
|
3598
|
+
},
|
|
3599
|
+
position: "top",
|
|
3600
|
+
children: "Copy all"
|
|
3601
|
+
}), null);
|
|
3602
|
+
return _el$5;
|
|
3603
|
+
}
|
|
3604
|
+
}), null);
|
|
3605
|
+
use(highlightContainerRef, _el$1);
|
|
3606
|
+
use(highlightRef, _el$10);
|
|
3607
|
+
insert(_el$1, createComponent(For, {
|
|
3608
|
+
get each() {
|
|
3609
|
+
return props.items;
|
|
3610
|
+
},
|
|
3611
|
+
children: (item) => (() => {
|
|
3612
|
+
var _el$12 = _tmpl$5(), _el$13 = _el$12.firstChild, _el$14 = _el$13.firstChild, _el$16 = _el$13.nextSibling;
|
|
3613
|
+
addEventListener(_el$12, "blur", clearHighlight);
|
|
3614
|
+
_el$12.addEventListener("focus", (event) => updateHighlight(event.currentTarget));
|
|
3615
|
+
_el$12.addEventListener("mouseleave", () => {
|
|
3616
|
+
props.onItemHover?.(null);
|
|
3617
|
+
clearHighlight();
|
|
3618
|
+
});
|
|
3619
|
+
_el$12.addEventListener("mouseenter", (event) => {
|
|
3620
|
+
if (!props.disconnectedItemIds?.has(item.id)) props.onItemHover?.(item.id);
|
|
3621
|
+
updateHighlight(event.currentTarget);
|
|
3622
|
+
});
|
|
3623
|
+
_el$12.$$keydown = (event) => {
|
|
3624
|
+
if (event.code === "Space" && event.currentTarget === event.target) {
|
|
3625
|
+
event.preventDefault();
|
|
3626
|
+
event.stopPropagation();
|
|
3627
|
+
props.onSelectItem?.(item);
|
|
3628
|
+
}
|
|
3629
|
+
};
|
|
3630
|
+
_el$12.$$click = (event) => {
|
|
3631
|
+
event.stopPropagation();
|
|
3632
|
+
props.onSelectItem?.(item);
|
|
3633
|
+
};
|
|
3634
|
+
_el$12.$$pointerdown = (event) => event.stopPropagation();
|
|
3635
|
+
insert(_el$14, () => getCommentItemDisplayName(item));
|
|
3636
|
+
insert(_el$13, createComponent(Show, {
|
|
3637
|
+
get when() {
|
|
3638
|
+
return item.commentText;
|
|
3639
|
+
},
|
|
3640
|
+
get children() {
|
|
3641
|
+
var _el$15 = _tmpl$4();
|
|
3642
|
+
insert(_el$15, () => item.commentText);
|
|
3643
|
+
return _el$15;
|
|
3644
|
+
}
|
|
3645
|
+
}), null);
|
|
3646
|
+
insert(_el$16, () => formatRelativeTime(item.timestamp));
|
|
3647
|
+
createRenderEffect((_$p) => classList(_el$12, { "opacity-40 hover:opacity-100": Boolean(props.disconnectedItemIds?.has(item.id)) }, _$p));
|
|
3648
|
+
return _el$12;
|
|
3649
|
+
})()
|
|
3650
|
+
}), null);
|
|
3651
|
+
createRenderEffect((_p$) => {
|
|
3652
|
+
var _v$ = `${dropdown.displayPosition().top}px`, _v$2 = `${dropdown.displayPosition().left}px`, _v$3 = dropdown.isAnimatedIn() ? "auto" : "none", _v$4 = DROPDOWN_EDGE_TRANSFORM_ORIGIN[dropdown.lastAnchorEdge()], _v$5 = dropdown.isAnimatedIn() ? "1" : "0", _v$6 = dropdown.isAnimatedIn() ? "scale(1)" : "scale(0.95)", _v$7 = cn("contain-layout flex flex-col rounded-[10px] antialiased w-fit h-fit overflow-hidden [font-synthesis:none] [corner-shape:superellipse(1.25)]", "bg-white"), _v$8 = `${panelMinWidth()}px`, _v$9 = `${clampedMaxWidth()}px`, _v$0 = `${clampedMaxHeight()}px`;
|
|
3653
|
+
_v$ !== _p$.e && setStyleProperty(_el$, "top", _p$.e = _v$);
|
|
3654
|
+
_v$2 !== _p$.t && setStyleProperty(_el$, "left", _p$.t = _v$2);
|
|
3655
|
+
_v$3 !== _p$.a && setStyleProperty(_el$, "pointer-events", _p$.a = _v$3);
|
|
3656
|
+
_v$4 !== _p$.o && setStyleProperty(_el$, "transform-origin", _p$.o = _v$4);
|
|
3657
|
+
_v$5 !== _p$.i && setStyleProperty(_el$, "opacity", _p$.i = _v$5);
|
|
3658
|
+
_v$6 !== _p$.n && setStyleProperty(_el$, "transform", _p$.n = _v$6);
|
|
3659
|
+
_v$7 !== _p$.s && className(_el$2, _p$.s = _v$7);
|
|
3660
|
+
_v$8 !== _p$.h && setStyleProperty(_el$2, "min-width", _p$.h = _v$8);
|
|
3661
|
+
_v$9 !== _p$.r && setStyleProperty(_el$2, "max-width", _p$.r = _v$9);
|
|
3662
|
+
_v$0 !== _p$.d && setStyleProperty(_el$2, "max-height", _p$.d = _v$0);
|
|
3663
|
+
return _p$;
|
|
3664
|
+
}, {
|
|
3665
|
+
e: void 0,
|
|
3666
|
+
t: void 0,
|
|
3667
|
+
a: void 0,
|
|
3668
|
+
o: void 0,
|
|
3669
|
+
i: void 0,
|
|
3670
|
+
n: void 0,
|
|
3671
|
+
s: void 0,
|
|
3672
|
+
h: void 0,
|
|
3673
|
+
r: void 0,
|
|
3674
|
+
d: void 0
|
|
3675
|
+
});
|
|
3676
|
+
return _el$;
|
|
3677
|
+
}
|
|
3678
|
+
});
|
|
3679
|
+
};
|
|
3680
|
+
delegateEvents([
|
|
3681
|
+
"pointerdown",
|
|
3682
|
+
"mousedown",
|
|
3683
|
+
"click",
|
|
3684
|
+
"contextmenu",
|
|
3685
|
+
"keydown"
|
|
3686
|
+
]);
|
|
3687
|
+
|
|
3688
|
+
//#endregion
|
|
3689
|
+
//#region src/components/clear-comments-prompt.tsx
|
|
3690
|
+
var _tmpl$$1 = /* @__PURE__ */ template(`<div data-react-grab-ignore-events data-react-grab-clear-comments-prompt class="fixed font-sans text-[13px] antialiased filter-[drop-shadow(0px_1px_2px_#51515140)] select-none transition-[opacity,transform] duration-100 ease-out will-change-[opacity,transform]"><div>`);
|
|
3691
|
+
const ClearCommentsPrompt = (props) => {
|
|
3692
|
+
let containerRef;
|
|
3693
|
+
const dropdown = createAnchoredDropdown(() => containerRef, () => props.position);
|
|
3694
|
+
onMount(() => {
|
|
3695
|
+
dropdown.measure();
|
|
3696
|
+
const unregisterOverlayDismiss = registerOverlayDismiss({
|
|
3697
|
+
isOpen: () => Boolean(props.position),
|
|
3698
|
+
onDismiss: props.onCancel,
|
|
3699
|
+
onConfirm: props.onConfirm,
|
|
3700
|
+
shouldIgnoreInputEvents: true
|
|
3701
|
+
});
|
|
3702
|
+
onCleanup(() => {
|
|
3703
|
+
dropdown.clearAnimationHandles();
|
|
3704
|
+
unregisterOverlayDismiss();
|
|
3705
|
+
});
|
|
3706
|
+
});
|
|
3707
|
+
return createComponent(Show, {
|
|
3708
|
+
get when() {
|
|
3709
|
+
return dropdown.shouldMount();
|
|
3710
|
+
},
|
|
3711
|
+
get children() {
|
|
3712
|
+
var _el$ = _tmpl$$1(), _el$2 = _el$.firstChild;
|
|
3713
|
+
addEventListener(_el$, "contextmenu", suppressMenuEvent, true);
|
|
3714
|
+
addEventListener(_el$, "click", suppressMenuEvent, true);
|
|
3715
|
+
addEventListener(_el$, "mousedown", suppressMenuEvent, true);
|
|
3716
|
+
addEventListener(_el$, "pointerdown", suppressMenuEvent, true);
|
|
3717
|
+
var _ref$ = containerRef;
|
|
3718
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : containerRef = _el$;
|
|
3719
|
+
setStyleProperty(_el$, "z-index", `${Z_INDEX_OVERLAY}`);
|
|
3720
|
+
insert(_el$2, createComponent(DiscardPrompt, {
|
|
3721
|
+
label: "Clear comments?",
|
|
3722
|
+
cancelOnEscape: true,
|
|
3723
|
+
get onConfirm() {
|
|
3724
|
+
return props.onConfirm;
|
|
3725
|
+
},
|
|
3726
|
+
get onCancel() {
|
|
3727
|
+
return props.onCancel;
|
|
3728
|
+
}
|
|
3729
|
+
}));
|
|
3730
|
+
createRenderEffect((_p$) => {
|
|
3731
|
+
var _v$ = `${dropdown.displayPosition().top}px`, _v$2 = `${dropdown.displayPosition().left}px`, _v$3 = dropdown.isAnimatedIn() ? "auto" : "none", _v$4 = DROPDOWN_EDGE_TRANSFORM_ORIGIN[dropdown.lastAnchorEdge()], _v$5 = dropdown.isAnimatedIn() ? "1" : "0", _v$6 = dropdown.isAnimatedIn() ? "scale(1)" : "scale(0.95)", _v$7 = cn("contain-layout flex flex-col rounded-[10px] antialiased w-fit h-fit [font-synthesis:none] [corner-shape:superellipse(1.25)]", "bg-white");
|
|
3732
|
+
_v$ !== _p$.e && setStyleProperty(_el$, "top", _p$.e = _v$);
|
|
3733
|
+
_v$2 !== _p$.t && setStyleProperty(_el$, "left", _p$.t = _v$2);
|
|
3734
|
+
_v$3 !== _p$.a && setStyleProperty(_el$, "pointer-events", _p$.a = _v$3);
|
|
3735
|
+
_v$4 !== _p$.o && setStyleProperty(_el$, "transform-origin", _p$.o = _v$4);
|
|
3736
|
+
_v$5 !== _p$.i && setStyleProperty(_el$, "opacity", _p$.i = _v$5);
|
|
3737
|
+
_v$6 !== _p$.n && setStyleProperty(_el$, "transform", _p$.n = _v$6);
|
|
3738
|
+
_v$7 !== _p$.s && className(_el$2, _p$.s = _v$7);
|
|
3739
|
+
return _p$;
|
|
3740
|
+
}, {
|
|
3741
|
+
e: void 0,
|
|
3742
|
+
t: void 0,
|
|
3743
|
+
a: void 0,
|
|
3744
|
+
o: void 0,
|
|
3745
|
+
i: void 0,
|
|
3746
|
+
n: void 0,
|
|
3747
|
+
s: void 0
|
|
3748
|
+
});
|
|
3749
|
+
return _el$;
|
|
3750
|
+
}
|
|
3751
|
+
});
|
|
3752
|
+
};
|
|
3753
|
+
delegateEvents([
|
|
3754
|
+
"pointerdown",
|
|
3755
|
+
"mousedown",
|
|
3756
|
+
"click",
|
|
3757
|
+
"contextmenu"
|
|
3758
|
+
]);
|
|
3759
|
+
|
|
3760
|
+
//#endregion
|
|
3761
|
+
//#region src/components/renderer.tsx
|
|
3762
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div style=position:fixed;top:0;right:0;bottom:0;left:0;pointer-events:none;will-change:opacity;contain:strict;transform:translateZ(0)>`);
|
|
3763
|
+
const ReactGrabRenderer = (props) => {
|
|
3764
|
+
return [
|
|
3765
|
+
createComponent(OverlayCanvas, {
|
|
3766
|
+
get selectionVisible() {
|
|
3767
|
+
return props.selectionVisible;
|
|
3768
|
+
},
|
|
3769
|
+
get selectionBounds() {
|
|
3770
|
+
return props.selectionBounds;
|
|
3771
|
+
},
|
|
3772
|
+
get selectionBoundsMultiple() {
|
|
3773
|
+
return props.selectionBoundsMultiple;
|
|
3774
|
+
},
|
|
3775
|
+
get selectionShouldSnap() {
|
|
3776
|
+
return props.selectionShouldSnap;
|
|
3777
|
+
},
|
|
3778
|
+
get selectionIsFading() {
|
|
3779
|
+
return props.selectionLabelStatus === "fading";
|
|
3780
|
+
},
|
|
3781
|
+
get inspectVisible() {
|
|
3782
|
+
return props.inspectVisible;
|
|
3783
|
+
},
|
|
3784
|
+
get inspectBounds() {
|
|
3785
|
+
return props.inspectBounds;
|
|
3786
|
+
},
|
|
3787
|
+
get dragVisible() {
|
|
3788
|
+
return props.dragVisible;
|
|
3789
|
+
},
|
|
3790
|
+
get dragBounds() {
|
|
3791
|
+
return props.dragBounds;
|
|
3792
|
+
},
|
|
3793
|
+
get grabbedBoxes() {
|
|
3794
|
+
return props.grabbedBoxes;
|
|
3795
|
+
},
|
|
3796
|
+
get labelInstances() {
|
|
3797
|
+
return props.labelInstances;
|
|
3798
|
+
}
|
|
3799
|
+
}),
|
|
3800
|
+
(() => {
|
|
3801
|
+
var _el$ = _tmpl$();
|
|
3802
|
+
setStyleProperty(_el$, "z-index", Z_INDEX_OVERLAY_CANVAS);
|
|
3803
|
+
setStyleProperty(_el$, "transition", `opacity ${100}ms ease-out`);
|
|
3804
|
+
setStyleProperty(_el$, "box-shadow", `inset 0 0 ${50}px ${FROZEN_GLOW_COLOR}`);
|
|
3805
|
+
createRenderEffect((_$p) => setStyleProperty(_el$, "opacity", props.isFrozen ? 1 : 0));
|
|
3806
|
+
return _el$;
|
|
3807
|
+
})(),
|
|
3808
|
+
createComponent(Show, {
|
|
3809
|
+
get when() {
|
|
3810
|
+
return memo(() => !!props.selectionLabelVisible)() && props.selectionBounds;
|
|
3811
|
+
},
|
|
3812
|
+
get children() {
|
|
3813
|
+
return createComponent(SelectionLabel, {
|
|
3814
|
+
get tagName() {
|
|
3815
|
+
return props.selectionTagName;
|
|
3816
|
+
},
|
|
3817
|
+
get componentName() {
|
|
3818
|
+
return props.selectionComponentName;
|
|
3819
|
+
},
|
|
3820
|
+
get elementsCount() {
|
|
3821
|
+
return props.selectionElementsCount;
|
|
3822
|
+
},
|
|
3823
|
+
get selectionBounds() {
|
|
3824
|
+
return props.selectionBounds;
|
|
3825
|
+
},
|
|
3826
|
+
get mouseX() {
|
|
3827
|
+
return props.mouseX;
|
|
3828
|
+
},
|
|
3829
|
+
get visible() {
|
|
3830
|
+
return props.selectionLabelVisible;
|
|
3831
|
+
},
|
|
3832
|
+
get isPromptMode() {
|
|
3833
|
+
return props.isPromptMode;
|
|
3834
|
+
},
|
|
3835
|
+
get inputValue() {
|
|
3836
|
+
return props.inputValue;
|
|
3837
|
+
},
|
|
3838
|
+
get status() {
|
|
3839
|
+
return props.selectionLabelStatus;
|
|
3840
|
+
},
|
|
3841
|
+
get actionCycleState() {
|
|
3842
|
+
return props.selectionActionCycleState;
|
|
3843
|
+
},
|
|
3844
|
+
get arrowNavigationState() {
|
|
3845
|
+
return props.selectionArrowNavigationState;
|
|
3846
|
+
},
|
|
3847
|
+
get onArrowNavigationSelect() {
|
|
3848
|
+
return props.onArrowNavigationSelect;
|
|
3849
|
+
},
|
|
3850
|
+
get inspectNavigationState() {
|
|
3851
|
+
return props.inspectNavigationState;
|
|
3852
|
+
},
|
|
3853
|
+
get onInspectSelect() {
|
|
3854
|
+
return props.onInspectSelect;
|
|
3855
|
+
},
|
|
3856
|
+
get filePath() {
|
|
3857
|
+
return props.selectionFilePath;
|
|
3858
|
+
},
|
|
3859
|
+
get onInputChange() {
|
|
3860
|
+
return props.onInputChange;
|
|
3861
|
+
},
|
|
3862
|
+
get onSubmit() {
|
|
3863
|
+
return props.onInputSubmit;
|
|
3864
|
+
},
|
|
3865
|
+
get onToggleExpand() {
|
|
3866
|
+
return props.onToggleExpand;
|
|
3867
|
+
},
|
|
3868
|
+
get isPendingDismiss() {
|
|
3869
|
+
return props.isPendingDismiss;
|
|
3870
|
+
},
|
|
3871
|
+
get selectionLabelShakeCount() {
|
|
3872
|
+
return props.selectionLabelShakeCount;
|
|
3873
|
+
},
|
|
3874
|
+
get onConfirmDismiss() {
|
|
3875
|
+
return props.onConfirmDismiss;
|
|
3876
|
+
},
|
|
3877
|
+
get onCancelDismiss() {
|
|
3878
|
+
return props.onCancelDismiss;
|
|
3879
|
+
},
|
|
3880
|
+
onOpen: () => {
|
|
3881
|
+
if (props.selectionFilePath) openFile(props.selectionFilePath, props.selectionLineNumber);
|
|
3882
|
+
},
|
|
3883
|
+
get isContextMenuOpen() {
|
|
3884
|
+
return props.contextMenuPosition !== null;
|
|
3885
|
+
}
|
|
3886
|
+
});
|
|
3887
|
+
}
|
|
3888
|
+
}),
|
|
3889
|
+
createComponent(Index, {
|
|
3890
|
+
get each() {
|
|
3891
|
+
return props.labelInstances ?? [];
|
|
3892
|
+
},
|
|
3893
|
+
children: (instance) => createComponent(SelectionLabel, {
|
|
3894
|
+
get tagName() {
|
|
3895
|
+
return instance().tagName;
|
|
3896
|
+
},
|
|
3897
|
+
get componentName() {
|
|
3898
|
+
return instance().componentName;
|
|
3899
|
+
},
|
|
3900
|
+
get elementsCount() {
|
|
3901
|
+
return instance().elementsCount;
|
|
3902
|
+
},
|
|
3903
|
+
get selectionBounds() {
|
|
3904
|
+
return instance().bounds;
|
|
3905
|
+
},
|
|
3906
|
+
get mouseX() {
|
|
3907
|
+
return instance().mouseX;
|
|
3908
|
+
},
|
|
3909
|
+
visible: true,
|
|
3910
|
+
get status() {
|
|
3911
|
+
return instance().status;
|
|
3912
|
+
},
|
|
3913
|
+
get statusText() {
|
|
3914
|
+
return instance().statusText;
|
|
3915
|
+
},
|
|
3916
|
+
get isPromptMode() {
|
|
3917
|
+
return instance().isPromptMode;
|
|
3918
|
+
},
|
|
3919
|
+
get inputValue() {
|
|
3920
|
+
return instance().inputValue;
|
|
3921
|
+
},
|
|
3922
|
+
get error() {
|
|
3923
|
+
return instance().errorMessage;
|
|
3924
|
+
},
|
|
3925
|
+
get hideArrow() {
|
|
3926
|
+
return instance().hideArrow;
|
|
3927
|
+
},
|
|
3928
|
+
get onShowContextMenu() {
|
|
3929
|
+
const currentInstance = instance();
|
|
3930
|
+
if (!(currentInstance.status === "copied" || currentInstance.status === "fading") || !isElementConnected(currentInstance.element)) return;
|
|
3931
|
+
return () => props.onShowContextMenuInstance?.(currentInstance.id);
|
|
3932
|
+
},
|
|
3933
|
+
onHoverChange: (isHovered) => props.onLabelInstanceHoverChange?.(instance().id, isHovered)
|
|
3934
|
+
})
|
|
3935
|
+
}),
|
|
3936
|
+
createComponent(Show, {
|
|
3937
|
+
get when() {
|
|
3938
|
+
return props.toolbarVisible !== false;
|
|
3939
|
+
},
|
|
3940
|
+
get children() {
|
|
3941
|
+
return createComponent(Toolbar, {
|
|
3942
|
+
get isActive() {
|
|
3943
|
+
return props.isActive;
|
|
3944
|
+
},
|
|
3945
|
+
get isContextMenuOpen() {
|
|
3946
|
+
return props.contextMenuPosition !== null;
|
|
3947
|
+
},
|
|
3948
|
+
get onToggle() {
|
|
3949
|
+
return props.onToggleActive;
|
|
3950
|
+
},
|
|
3951
|
+
get enabled() {
|
|
3952
|
+
return props.enabled;
|
|
3953
|
+
},
|
|
3954
|
+
get onToggleEnabled() {
|
|
3955
|
+
return props.onToggleEnabled;
|
|
3956
|
+
},
|
|
3957
|
+
get shakeCount() {
|
|
3958
|
+
return props.shakeCount;
|
|
3959
|
+
},
|
|
3960
|
+
get onStateChange() {
|
|
3961
|
+
return props.onToolbarStateChange;
|
|
3962
|
+
},
|
|
3963
|
+
get onSubscribeToStateChanges() {
|
|
3964
|
+
return props.onSubscribeToToolbarStateChanges;
|
|
3965
|
+
},
|
|
3966
|
+
get onSelectHoverChange() {
|
|
3967
|
+
return props.onToolbarSelectHoverChange;
|
|
3968
|
+
},
|
|
3969
|
+
get onContainerRef() {
|
|
3970
|
+
return props.onToolbarRef;
|
|
3971
|
+
},
|
|
3972
|
+
get commentItemCount() {
|
|
3973
|
+
return props.commentItemCount;
|
|
3974
|
+
},
|
|
3975
|
+
get clockFlashTrigger() {
|
|
3976
|
+
return props.clockFlashTrigger;
|
|
3977
|
+
},
|
|
3978
|
+
get onToggleComments() {
|
|
3979
|
+
return props.onToggleComments;
|
|
3980
|
+
},
|
|
3981
|
+
get onCopyAll() {
|
|
3982
|
+
return props.onCopyAll;
|
|
3983
|
+
},
|
|
3984
|
+
get onCopyAllHover() {
|
|
3985
|
+
return props.onCopyAllHover;
|
|
3986
|
+
},
|
|
3987
|
+
get onCommentsButtonHover() {
|
|
3988
|
+
return props.onCommentsButtonHover;
|
|
3989
|
+
},
|
|
3990
|
+
get isCommentsDropdownOpen() {
|
|
3991
|
+
return Boolean(props.commentsDropdownPosition);
|
|
3992
|
+
},
|
|
3993
|
+
get isCommentsPinned() {
|
|
3994
|
+
return props.isCommentsPinned;
|
|
3995
|
+
},
|
|
3996
|
+
get onToggleToolbarMenu() {
|
|
3997
|
+
return props.onToggleToolbarMenu;
|
|
3998
|
+
},
|
|
3999
|
+
get isToolbarMenuOpen() {
|
|
4000
|
+
return Boolean(props.toolbarMenuPosition);
|
|
4001
|
+
},
|
|
4002
|
+
get isClearPromptOpen() {
|
|
4003
|
+
return Boolean(props.clearPromptPosition);
|
|
4004
|
+
}
|
|
4005
|
+
});
|
|
4006
|
+
}
|
|
4007
|
+
}),
|
|
4008
|
+
createComponent(ContextMenu, {
|
|
4009
|
+
get position() {
|
|
4010
|
+
return props.contextMenuPosition ?? null;
|
|
4011
|
+
},
|
|
4012
|
+
get selectionBounds() {
|
|
4013
|
+
return props.contextMenuBounds ?? null;
|
|
4014
|
+
},
|
|
4015
|
+
get tagName() {
|
|
4016
|
+
return props.contextMenuTagName;
|
|
4017
|
+
},
|
|
4018
|
+
get componentName() {
|
|
4019
|
+
return props.contextMenuComponentName;
|
|
4020
|
+
},
|
|
4021
|
+
get hasFilePath() {
|
|
4022
|
+
return props.contextMenuHasFilePath ?? false;
|
|
4023
|
+
},
|
|
4024
|
+
get actions() {
|
|
4025
|
+
return props.actions;
|
|
4026
|
+
},
|
|
4027
|
+
get actionContext() {
|
|
4028
|
+
return props.actionContext;
|
|
4029
|
+
},
|
|
4030
|
+
get onDismiss() {
|
|
4031
|
+
return props.onContextMenuDismiss ?? (() => {});
|
|
4032
|
+
},
|
|
4033
|
+
get onHide() {
|
|
4034
|
+
return props.onContextMenuHide ?? (() => {});
|
|
4035
|
+
}
|
|
4036
|
+
}),
|
|
4037
|
+
createComponent(ToolbarMenu, {
|
|
4038
|
+
get position() {
|
|
4039
|
+
return props.toolbarMenuPosition ?? null;
|
|
4040
|
+
},
|
|
4041
|
+
get actions() {
|
|
4042
|
+
return props.toolbarMenuActions ?? [];
|
|
4043
|
+
},
|
|
4044
|
+
get defaultActionId() {
|
|
4045
|
+
return props.defaultActionId ?? "comment";
|
|
4046
|
+
},
|
|
4047
|
+
get onSetDefaultAction() {
|
|
4048
|
+
return props.onSetDefaultAction ?? (() => {});
|
|
4049
|
+
},
|
|
4050
|
+
get onDismiss() {
|
|
4051
|
+
return props.onToolbarMenuDismiss ?? (() => {});
|
|
4052
|
+
}
|
|
4053
|
+
}),
|
|
4054
|
+
createComponent(ClearCommentsPrompt, {
|
|
4055
|
+
get position() {
|
|
4056
|
+
return props.clearPromptPosition ?? null;
|
|
4057
|
+
},
|
|
4058
|
+
get onConfirm() {
|
|
4059
|
+
return props.onClearCommentsConfirm ?? (() => {});
|
|
4060
|
+
},
|
|
4061
|
+
get onCancel() {
|
|
4062
|
+
return props.onClearCommentsCancel ?? (() => {});
|
|
4063
|
+
}
|
|
4064
|
+
}),
|
|
4065
|
+
createComponent(CommentsDropdown, {
|
|
4066
|
+
get position() {
|
|
4067
|
+
return props.commentsDropdownPosition ?? null;
|
|
4068
|
+
},
|
|
4069
|
+
get items() {
|
|
4070
|
+
return props.commentItems ?? [];
|
|
4071
|
+
},
|
|
4072
|
+
get disconnectedItemIds() {
|
|
4073
|
+
return props.commentsDisconnectedItemIds;
|
|
4074
|
+
},
|
|
4075
|
+
get onSelectItem() {
|
|
4076
|
+
return props.onCommentItemSelect;
|
|
4077
|
+
},
|
|
4078
|
+
get onItemHover() {
|
|
4079
|
+
return props.onCommentItemHover;
|
|
4080
|
+
},
|
|
4081
|
+
get onCopyAll() {
|
|
4082
|
+
return props.onCommentsCopyAll;
|
|
4083
|
+
},
|
|
4084
|
+
get onCopyAllHover() {
|
|
4085
|
+
return props.onCommentsCopyAllHover;
|
|
4086
|
+
},
|
|
4087
|
+
get onClearAll() {
|
|
4088
|
+
return props.onCommentsClear;
|
|
4089
|
+
},
|
|
4090
|
+
get onDismiss() {
|
|
4091
|
+
return props.onCommentsDismiss;
|
|
4092
|
+
},
|
|
4093
|
+
get onDropdownHover() {
|
|
4094
|
+
return props.onCommentsDropdownHover;
|
|
4095
|
+
}
|
|
4096
|
+
})
|
|
4097
|
+
];
|
|
4098
|
+
};
|
|
4099
|
+
|
|
4100
|
+
//#endregion
|
|
4101
|
+
export { ReactGrabRenderer };
|